From b7577f2328448ef5c6b039c5ad22b1b94e6d8106 Mon Sep 17 00:00:00 2001 From: Crazypedia Date: Fri, 28 Aug 2026 02:59:46 -0400 Subject: [PATCH] feat(gdeq031t10): support an optional frontlight (#633) --- .../bindings/gooddisplay,gdeq031t10.yaml | 7 +++++ .../include/drivers/gdeq031t10.h | 4 +++ .../gdeq031t10-module/source/gdeq031t10.cpp | 28 +++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Drivers/gdeq031t10-module/bindings/gooddisplay,gdeq031t10.yaml b/Drivers/gdeq031t10-module/bindings/gooddisplay,gdeq031t10.yaml index 4d5fd5d7..44fd9cc6 100644 --- a/Drivers/gdeq031t10-module/bindings/gooddisplay,gdeq031t10.yaml +++ b/Drivers/gdeq031t10-module/bindings/gooddisplay,gdeq031t10.yaml @@ -36,3 +36,10 @@ properties: type: boolean default: false description: Panel is mounted upside down relative to the reference orientation + backlight: + type: phandle + default: "NULL" + description: > + Optional reference to this panel's frontlight device. E-paper panels are reflective, so + this lights the panel from the front rather than behind it, but it is driven through the + same BACKLIGHT_TYPE API and appears as the brightness control in Display settings. diff --git a/Drivers/gdeq031t10-module/include/drivers/gdeq031t10.h b/Drivers/gdeq031t10-module/include/drivers/gdeq031t10.h index dbd95b56..0314f77e 100644 --- a/Drivers/gdeq031t10-module/include/drivers/gdeq031t10.h +++ b/Drivers/gdeq031t10-module/include/drivers/gdeq031t10.h @@ -10,6 +10,8 @@ extern "C" { #include +struct Device; + /** Waveform/refresh mode used for automatic full-screen refreshes. */ enum Gdeq031t10RefreshMode { GDEQ031T10_REFRESH_FULL = 0, // ~3s, best quality @@ -26,6 +28,8 @@ struct Gdeq031t10Config { enum Gdeq031t10RefreshMode refresh_mode; /** Panel is mounted upside down relative to the reference orientation */ bool mirror_180; + /** Optional reference to this panel's frontlight/backlight device, NULL if none. */ + struct Device* backlight; }; #ifdef __cplusplus diff --git a/Drivers/gdeq031t10-module/source/gdeq031t10.cpp b/Drivers/gdeq031t10-module/source/gdeq031t10.cpp index e7d90246..51334e1c 100644 --- a/Drivers/gdeq031t10-module/source/gdeq031t10.cpp +++ b/Drivers/gdeq031t10-module/source/gdeq031t10.cpp @@ -25,6 +25,9 @@ constexpr auto* TAG = "GDEQ031T10"; #define GET_CONFIG(device) (static_cast((device)->config)) +/** Capabilities every instance has; see gdeq031t10_has_capability() for the per-board ones. */ +#define GDEQ031T10_STATIC_CAPABILITIES (DISPLAY_CAPABILITY_ON_OFF | DISPLAY_CAPABILITY_SLOW_REFRESH) + static constexpr int WIDTH = 240; static constexpr int HEIGHT = 320; static constexpr size_t FRAMEBUFFER_SIZE = (WIDTH * HEIGHT) / 8; // 1 bpp packed @@ -532,8 +535,27 @@ static uint8_t gdeq031t10_get_frame_buffer_count(Device*) { // endregion +static error_t gdeq031t10_get_backlight(Device* device, Device** backlight) { + auto* configured_backlight = GET_CONFIG(device)->backlight; + if (configured_backlight == nullptr) { + return ERROR_NOT_SUPPORTED; + } + *backlight = configured_backlight; + return ERROR_NONE; +} + +// Whether this panel has a frontlight is per-board (the T-Deck Max has one, the T-Deck Pro +// doesn't), so BACKLIGHT can't live in the driver-wide static capability mask. +static bool gdeq031t10_has_capability(Device* device, uint32_t capability) { + uint32_t capabilities = GDEQ031T10_STATIC_CAPABILITIES; + if (GET_CONFIG(device)->backlight != nullptr) { + capabilities |= DISPLAY_CAPABILITY_BACKLIGHT; + } + return (capabilities & capability) == capability; +} + static const DisplayApi gdeq031t10_display_api = { - .capabilities = DISPLAY_CAPABILITY_ON_OFF | DISPLAY_CAPABILITY_SLOW_REFRESH, + .capabilities = GDEQ031T10_STATIC_CAPABILITIES, .reset = gdeq031t10_reset, .init = gdeq031t10_init, .draw_bitmap = gdeq031t10_draw_bitmap, @@ -553,8 +575,8 @@ static const DisplayApi gdeq031t10_display_api = { .get_resolution_y = gdeq031t10_get_resolution_y, .get_frame_buffer = gdeq031t10_get_frame_buffer, .get_frame_buffer_count = gdeq031t10_get_frame_buffer_count, - .get_backlight = nullptr, - .has_capability = nullptr, + .get_backlight = gdeq031t10_get_backlight, + .has_capability = gdeq031t10_has_capability, }; // region Driver lifecycle