Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 363bf77 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | 363bf77 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _BACKLIGHT_H |
| 8 | #define _BACKLIGHT_H |
| 9 | |
Simon Glass | a4f737a | 2018-10-01 12:22:41 -0600 | [diff] [blame] | 10 | enum { |
| 11 | BACKLIGHT_MAX = 100, |
| 12 | BACKLIGHT_MIN = 0, |
| 13 | BACKLIGHT_OFF = -1, |
| 14 | BACKLIGHT_DEFAULT = -2, |
| 15 | }; |
| 16 | |
Simon Glass | 363bf77 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 17 | struct backlight_ops { |
| 18 | /** |
| 19 | * enable() - Enable a backlight |
| 20 | * |
| 21 | * @dev: Backlight device to enable |
| 22 | * @return 0 if OK, -ve on error |
| 23 | */ |
| 24 | int (*enable)(struct udevice *dev); |
Simon Glass | a4f737a | 2018-10-01 12:22:41 -0600 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * set_brightness - Set brightness |
| 28 | * |
| 29 | * @dev: Backlight device to update |
| 30 | * @percent: Brightness value (0 to 100, or BACKLIGHT_... value) |
| 31 | * @return 0 if OK, -ve on error |
| 32 | */ |
| 33 | int (*set_brightness)(struct udevice *dev, int percent); |
Simon Glass | 363bf77 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | #define backlight_get_ops(dev) ((struct backlight_ops *)(dev)->driver->ops) |
| 37 | |
| 38 | /** |
| 39 | * backlight_enable() - Enable a backlight |
| 40 | * |
| 41 | * @dev: Backlight device to enable |
| 42 | * @return 0 if OK, -ve on error |
| 43 | */ |
| 44 | int backlight_enable(struct udevice *dev); |
| 45 | |
Simon Glass | a4f737a | 2018-10-01 12:22:41 -0600 | [diff] [blame] | 46 | /** |
| 47 | * backlight_set_brightness - Set brightness |
| 48 | * |
| 49 | * @dev: Backlight device to update |
| 50 | * @percent: Brightness value (0 to 100, or BACKLIGHT_... value) |
| 51 | * @return 0 if OK, -ve on error |
| 52 | */ |
| 53 | int backlight_set_brightness(struct udevice *dev, int percent); |
| 54 | |
Simon Glass | 363bf77 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 55 | #endif |