Prepare v2023.10
[platform/kernel/u-boot.git] / drivers / video / backlight-uclass.c
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 #define LOG_CATEGORY UCLASS_PANEL_BACKLIGHT
8
9 #include <common.h>
10 #include <dm.h>
11 #include <backlight.h>
12
13 int backlight_enable(struct udevice *dev)
14 {
15         const struct backlight_ops *ops = backlight_get_ops(dev);
16
17         if (!ops->enable)
18                 return -ENOSYS;
19
20         return ops->enable(dev);
21 }
22
23 int backlight_set_brightness(struct udevice *dev, int percent)
24 {
25         const struct backlight_ops *ops = backlight_get_ops(dev);
26
27         if (!ops->set_brightness)
28                 return -ENOSYS;
29
30         return ops->set_brightness(dev, percent);
31 }
32
33 UCLASS_DRIVER(backlight) = {
34         .id             = UCLASS_PANEL_BACKLIGHT,
35         .name           = "backlight",
36 };