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