diff options
| author | Markus Schneider-Pargmann (TI.com) <[email protected]> | 2026-01-05 10:36:27 +0100 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-01-16 09:07:28 -0600 |
| commit | 36829e951bfeddb7b2e9eaa93223d646577fcc02 (patch) | |
| tree | b0b5d0b6f1612334b038d1f032ada685e70ee5bc /drivers | |
| parent | 60f5170c1fe2a438e36b71eea0237ca166e6ef23 (diff) | |
panel: Lightweight support of get_modes()
Linux uses get_modes() to fetch all available panel modes from the
driver. This is also used to fetch the modes from Linux's simple panel
implementation where a list of drm_display_mode structs is used to
define the different possible panels.
To make our work easier, create a compatible way of fetching and
defining these modes in u-boot. get_modes() fetches the available modes
from the panel driver. The get_display_timing() call maps the
drm_display_mode properties to the display_timing struct. This call now
uses whatever panel operation is available, get_display_timing() or
get_modes().
Reviewed-by: Fabio Estevam <[email protected]>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <[email protected]>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/video/panel-uclass.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/drivers/video/panel-uclass.c b/drivers/video/panel-uclass.c index 52a3466dc8c..82e8339dde1 100644 --- a/drivers/video/panel-uclass.c +++ b/drivers/video/panel-uclass.c @@ -37,15 +37,47 @@ int panel_set_backlight(struct udevice *dev, int percent) return ops->set_backlight(dev, percent); } +static void drm_mode_to_display_timing(const struct drm_display_mode *mode, + struct display_timing *timing) +{ + timing->pixelclock.typ = mode->clock * 1000; /* kHz to Hz */ + timing->hactive.typ = mode->hdisplay; + timing->hfront_porch.typ = mode->hsync_start - mode->hdisplay; + timing->hsync_len.typ = mode->hsync_end - mode->hsync_start; + timing->hback_porch.typ = mode->htotal - mode->hsync_end; + timing->vactive.typ = mode->vdisplay; + timing->vfront_porch.typ = mode->vsync_start - mode->vdisplay; + timing->vsync_len.typ = mode->vsync_end - mode->vsync_start; + timing->vback_porch.typ = mode->vtotal - mode->vsync_end; + + /* DRM_MODE_FLAG_* defines are already mapped to u-boot DISPLAY_FLAGS */ + timing->flags = mode->flags; +} + int panel_get_display_timing(struct udevice *dev, struct display_timing *timings) { struct panel_ops *ops = panel_get_ops(dev); + const struct drm_display_mode *modes; + int ret = -ENOSYS; - if (!ops->get_display_timing) - return -ENOSYS; + if (ops->get_display_timing) { + ret = ops->get_display_timing(dev, timings); + if (ret != -ENODEV) + return ret; + } + + if (!ops->get_modes) + return ret; + + ret = ops->get_modes(dev, &modes); + if (ret < 0) + return ret; + else if (ret == 0) + return -ENODEV; - return ops->get_display_timing(dev, timings); + drm_mode_to_display_timing(&modes[0], timings); + return 0; } UCLASS_DRIVER(panel) = { |
