blob: b44da50bc30648c0059ece596d02da4735e4ad0a [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass8f790482016-01-21 19:44:56 -07002/*
3 * Copyright (c) 2016 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glass8f790482016-01-21 19:44:56 -07005 */
6
7#ifndef _BACKLIGHT_H
8#define _BACKLIGHT_H
9
Simon Glass3ba929a2020-10-30 21:38:53 -060010struct udevice;
11
Simon Glassfe68a452018-10-01 12:22:41 -060012enum {
13 BACKLIGHT_MAX = 100,
14 BACKLIGHT_MIN = 0,
15 BACKLIGHT_OFF = -1,
16 BACKLIGHT_DEFAULT = -2,
17};
18
Simon Glass8f790482016-01-21 19:44:56 -070019struct 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 Glassfe68a452018-10-01 12:22:41 -060027
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 Glass8f790482016-01-21 19:44:56 -070036};
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 */
46int backlight_enable(struct udevice *dev);
47
Simon Glassfe68a452018-10-01 12:22:41 -060048/**
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 */
55int backlight_set_brightness(struct udevice *dev, int percent);
56
Simon Glass8f790482016-01-21 19:44:56 -070057#endif