xref: /openbmc/u-boot/include/backlight.h (revision 3d5ced9e22d32112a20f9dc0f5fb1f22ef088079)
183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2363bf77aSSimon Glass /*
3363bf77aSSimon Glass  * Copyright (c) 2016 Google, Inc
4363bf77aSSimon Glass  * Written by Simon Glass <sjg@chromium.org>
5363bf77aSSimon Glass  */
6363bf77aSSimon Glass 
7363bf77aSSimon Glass #ifndef _BACKLIGHT_H
8363bf77aSSimon Glass #define _BACKLIGHT_H
9363bf77aSSimon Glass 
10*a4f737a9SSimon Glass enum {
11*a4f737a9SSimon Glass 	BACKLIGHT_MAX		= 100,
12*a4f737a9SSimon Glass 	BACKLIGHT_MIN		= 0,
13*a4f737a9SSimon Glass 	BACKLIGHT_OFF		= -1,
14*a4f737a9SSimon Glass 	BACKLIGHT_DEFAULT	= -2,
15*a4f737a9SSimon Glass };
16*a4f737a9SSimon Glass 
17363bf77aSSimon Glass struct backlight_ops {
18363bf77aSSimon Glass 	/**
19363bf77aSSimon Glass 	 * enable() - Enable a backlight
20363bf77aSSimon Glass 	 *
21363bf77aSSimon Glass 	 * @dev:	Backlight device to enable
22363bf77aSSimon Glass 	 * @return 0 if OK, -ve on error
23363bf77aSSimon Glass 	 */
24363bf77aSSimon Glass 	int (*enable)(struct udevice *dev);
25*a4f737a9SSimon Glass 
26*a4f737a9SSimon Glass 	/**
27*a4f737a9SSimon Glass 	 * set_brightness - Set brightness
28*a4f737a9SSimon Glass 	 *
29*a4f737a9SSimon Glass 	 * @dev:	Backlight device to update
30*a4f737a9SSimon Glass 	 * @percent:	Brightness value (0 to 100, or BACKLIGHT_... value)
31*a4f737a9SSimon Glass 	 * @return 0 if OK, -ve on error
32*a4f737a9SSimon Glass 	 */
33*a4f737a9SSimon Glass 	int (*set_brightness)(struct udevice *dev, int percent);
34363bf77aSSimon Glass };
35363bf77aSSimon Glass 
36363bf77aSSimon Glass #define backlight_get_ops(dev)	((struct backlight_ops *)(dev)->driver->ops)
37363bf77aSSimon Glass 
38363bf77aSSimon Glass /**
39363bf77aSSimon Glass  * backlight_enable() - Enable a backlight
40363bf77aSSimon Glass  *
41363bf77aSSimon Glass  * @dev:	Backlight device to enable
42363bf77aSSimon Glass  * @return 0 if OK, -ve on error
43363bf77aSSimon Glass  */
44363bf77aSSimon Glass int backlight_enable(struct udevice *dev);
45363bf77aSSimon Glass 
46*a4f737a9SSimon Glass /**
47*a4f737a9SSimon Glass  * backlight_set_brightness - Set brightness
48*a4f737a9SSimon Glass  *
49*a4f737a9SSimon Glass  * @dev:	Backlight device to update
50*a4f737a9SSimon Glass  * @percent:	Brightness value (0 to 100, or BACKLIGHT_... value)
51*a4f737a9SSimon Glass  * @return 0 if OK, -ve on error
52*a4f737a9SSimon Glass  */
53*a4f737a9SSimon Glass int backlight_set_brightness(struct udevice *dev, int percent);
54*a4f737a9SSimon Glass 
55363bf77aSSimon Glass #endif
56