blob: ac59eb293b45de51686fa8c033709077bdf0465b [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 Glassfe68a452018-10-01 12:22:41 -060010enum {
11 BACKLIGHT_MAX = 100,
12 BACKLIGHT_MIN = 0,
13 BACKLIGHT_OFF = -1,
14 BACKLIGHT_DEFAULT = -2,
15};
16
Simon Glass8f790482016-01-21 19:44:56 -070017struct 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 Glassfe68a452018-10-01 12:22:41 -060025
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 Glass8f790482016-01-21 19:44:56 -070034};
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 */
44int backlight_enable(struct udevice *dev);
45
Simon Glassfe68a452018-10-01 12:22:41 -060046/**
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 */
53int backlight_set_brightness(struct udevice *dev, int percent);
54
Simon Glass8f790482016-01-21 19:44:56 -070055#endif