Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | f563dc1 | 2016-01-21 19:44:58 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | f563dc1 | 2016-01-21 19:44:58 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Patrick Delaunay | b953ec2 | 2021-04-27 11:02:19 +0200 | [diff] [blame] | 7 | #define LOG_CATEGORY UCLASS_PANEL |
| 8 | |
Simon Glass | f563dc1 | 2016-01-21 19:44:58 -0700 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <panel.h> |
| 11 | |
| 12 | int panel_enable_backlight(struct udevice *dev) |
| 13 | { |
| 14 | struct panel_ops *ops = panel_get_ops(dev); |
| 15 | |
| 16 | if (!ops->enable_backlight) |
| 17 | return -ENOSYS; |
| 18 | |
| 19 | return ops->enable_backlight(dev); |
| 20 | } |
| 21 | |
Simon Glass | a4f737a | 2018-10-01 12:22:41 -0600 | [diff] [blame] | 22 | /** |
| 23 | * panel_set_backlight - Set brightness for the panel backlight |
| 24 | * |
| 25 | * @dev: Panel device containing the backlight to update |
| 26 | * @percent: Brightness value (0=off, 1=min brightness, |
| 27 | * 100=full brightness) |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 28 | * Return: 0 if OK, -ve on error |
Simon Glass | a4f737a | 2018-10-01 12:22:41 -0600 | [diff] [blame] | 29 | */ |
| 30 | int panel_set_backlight(struct udevice *dev, int percent) |
| 31 | { |
| 32 | struct panel_ops *ops = panel_get_ops(dev); |
| 33 | |
| 34 | if (!ops->set_backlight) |
| 35 | return -ENOSYS; |
| 36 | |
| 37 | return ops->set_backlight(dev, percent); |
| 38 | } |
| 39 | |
Yannick Fertré | 28576f8 | 2018-07-13 14:11:09 +0200 | [diff] [blame] | 40 | int panel_get_display_timing(struct udevice *dev, |
| 41 | struct display_timing *timings) |
| 42 | { |
| 43 | struct panel_ops *ops = panel_get_ops(dev); |
| 44 | |
| 45 | if (!ops->get_display_timing) |
| 46 | return -ENOSYS; |
| 47 | |
| 48 | return ops->get_display_timing(dev, timings); |
| 49 | } |
| 50 | |
Simon Glass | f563dc1 | 2016-01-21 19:44:58 -0700 | [diff] [blame] | 51 | UCLASS_DRIVER(panel) = { |
| 52 | .id = UCLASS_PANEL, |
| 53 | .name = "panel", |
| 54 | }; |