Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 8f79048 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | 8f79048 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Patrick Delaunay | 8131335 | 2021-04-27 11:02:19 +0200 | [diff] [blame] | 7 | #define LOG_CATEGORY UCLASS_PANEL_BACKLIGHT |
| 8 | |
Simon Glass | 8f79048 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <backlight.h> |
| 11 | |
| 12 | int backlight_enable(struct udevice *dev) |
| 13 | { |
| 14 | const struct backlight_ops *ops = backlight_get_ops(dev); |
| 15 | |
| 16 | if (!ops->enable) |
| 17 | return -ENOSYS; |
| 18 | |
| 19 | return ops->enable(dev); |
| 20 | } |
| 21 | |
Simon Glass | fe68a45 | 2018-10-01 12:22:41 -0600 | [diff] [blame] | 22 | int backlight_set_brightness(struct udevice *dev, int percent) |
| 23 | { |
| 24 | const struct backlight_ops *ops = backlight_get_ops(dev); |
| 25 | |
| 26 | if (!ops->set_brightness) |
| 27 | return -ENOSYS; |
| 28 | |
| 29 | return ops->set_brightness(dev, percent); |
| 30 | } |
| 31 | |
Simon Glass | 8f79048 | 2016-01-21 19:44:56 -0700 | [diff] [blame] | 32 | UCLASS_DRIVER(backlight) = { |
| 33 | .id = UCLASS_PANEL_BACKLIGHT, |
| 34 | .name = "backlight", |
| 35 | }; |