feat(gdeq031t10): support an optional frontlight (#633)
This commit is contained in:
@@ -36,3 +36,10 @@ properties:
|
|||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
description: Panel is mounted upside down relative to the reference orientation
|
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.
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ extern "C" {
|
|||||||
|
|
||||||
#include <tactility/drivers/gpio.h>
|
#include <tactility/drivers/gpio.h>
|
||||||
|
|
||||||
|
struct Device;
|
||||||
|
|
||||||
/** Waveform/refresh mode used for automatic full-screen refreshes. */
|
/** Waveform/refresh mode used for automatic full-screen refreshes. */
|
||||||
enum Gdeq031t10RefreshMode {
|
enum Gdeq031t10RefreshMode {
|
||||||
GDEQ031T10_REFRESH_FULL = 0, // ~3s, best quality
|
GDEQ031T10_REFRESH_FULL = 0, // ~3s, best quality
|
||||||
@@ -26,6 +28,8 @@ struct Gdeq031t10Config {
|
|||||||
enum Gdeq031t10RefreshMode refresh_mode;
|
enum Gdeq031t10RefreshMode refresh_mode;
|
||||||
/** Panel is mounted upside down relative to the reference orientation */
|
/** Panel is mounted upside down relative to the reference orientation */
|
||||||
bool mirror_180;
|
bool mirror_180;
|
||||||
|
/** Optional reference to this panel's frontlight/backlight device, NULL if none. */
|
||||||
|
struct Device* backlight;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
constexpr auto* TAG = "GDEQ031T10";
|
constexpr auto* TAG = "GDEQ031T10";
|
||||||
#define GET_CONFIG(device) (static_cast<const Gdeq031t10Config*>((device)->config))
|
#define GET_CONFIG(device) (static_cast<const Gdeq031t10Config*>((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 WIDTH = 240;
|
||||||
static constexpr int HEIGHT = 320;
|
static constexpr int HEIGHT = 320;
|
||||||
static constexpr size_t FRAMEBUFFER_SIZE = (WIDTH * HEIGHT) / 8; // 1 bpp packed
|
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
|
// 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 = {
|
static const DisplayApi gdeq031t10_display_api = {
|
||||||
.capabilities = DISPLAY_CAPABILITY_ON_OFF | DISPLAY_CAPABILITY_SLOW_REFRESH,
|
.capabilities = GDEQ031T10_STATIC_CAPABILITIES,
|
||||||
.reset = gdeq031t10_reset,
|
.reset = gdeq031t10_reset,
|
||||||
.init = gdeq031t10_init,
|
.init = gdeq031t10_init,
|
||||||
.draw_bitmap = gdeq031t10_draw_bitmap,
|
.draw_bitmap = gdeq031t10_draw_bitmap,
|
||||||
@@ -553,8 +575,8 @@ static const DisplayApi gdeq031t10_display_api = {
|
|||||||
.get_resolution_y = gdeq031t10_get_resolution_y,
|
.get_resolution_y = gdeq031t10_get_resolution_y,
|
||||||
.get_frame_buffer = gdeq031t10_get_frame_buffer,
|
.get_frame_buffer = gdeq031t10_get_frame_buffer,
|
||||||
.get_frame_buffer_count = gdeq031t10_get_frame_buffer_count,
|
.get_frame_buffer_count = gdeq031t10_get_frame_buffer_count,
|
||||||
.get_backlight = nullptr,
|
.get_backlight = gdeq031t10_get_backlight,
|
||||||
.has_capability = nullptr,
|
.has_capability = gdeq031t10_has_capability,
|
||||||
};
|
};
|
||||||
|
|
||||||
// region Driver lifecycle
|
// region Driver lifecycle
|
||||||
|
|||||||
Reference in New Issue
Block a user