blob: c8418828d17bdc7dd0d411ffc21f8a8930088f90 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass363bf772016-01-21 19:44:56 -07002/*
3 * Copyright (c) 2016 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glass363bf772016-01-21 19:44:56 -07005 */
6
7#ifndef _BACKLIGHT_H
8#define _BACKLIGHT_H
9
Simon Glass401d1c42020-10-30 21:38:53 -060010struct udevice;
11
Simon Glassa4f737a2018-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 Glass363bf772016-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 Glassa4f737a2018-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 Glass363bf772016-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
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010044 * Return: 0 if OK, -ve on error
Simon Glass363bf772016-01-21 19:44:56 -070045 */
46int backlight_enable(struct udevice *dev);
47
Simon Glassa4f737a2018-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)
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010053 * Return: 0 if OK, -ve on error
Simon Glassa4f737a2018-10-01 12:22:41 -060054 */
55int backlight_set_brightness(struct udevice *dev, int percent);
56
Simon Glass363bf772016-01-21 19:44:56 -070057#endif