xref: /openbmc/u-boot/include/backlight.h (revision cb3f9471)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2016 Google, Inc
4  * Written by Simon Glass <sjg@chromium.org>
5  */
6 
7 #ifndef _BACKLIGHT_H
8 #define _BACKLIGHT_H
9 
10 enum {
11 	BACKLIGHT_MAX		= 100,
12 	BACKLIGHT_MIN		= 0,
13 	BACKLIGHT_OFF		= -1,
14 	BACKLIGHT_DEFAULT	= -2,
15 };
16 
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);
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);
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 
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 
55 #endif
56