Skip to content

Commit faf96bc

Browse files
VynDragonjhedberg
authored andcommitted
drivers: display: Add gamma table setting to ssd1327
This adds the ability to send gamma settings to the controller Signed-off-by: Camille BAUD <[email protected]>
1 parent bfd2ac7 commit faf96bc

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

drivers/display/ssd1327.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct ssd1327_config {
4747
uint8_t function_selection_b;
4848
uint8_t precharge_voltage;
4949
uint8_t vcomh_voltage;
50+
uint8_t *greyscale_table;
5051
bool color_inversion;
5152
uint8_t *conversion_buf;
5253
size_t conversion_buf_size;
@@ -119,6 +120,13 @@ static inline int ssd1327_set_timing_setting(const struct device *dev)
119120
if (err < 0) {
120121
return err;
121122
}
123+
if (config->greyscale_table != NULL) {
124+
err = config->write_cmd(dev, SSD1327_SET_LUT, config->greyscale_table,
125+
SSD1327_SET_LUT_COUNT);
126+
if (err < 0) {
127+
return err;
128+
}
129+
}
122130
err = config->write_cmd(dev, SSD1327_SET_PRECHARGE_VOLTAGE, &config->precharge_voltage, 1);
123131
if (err < 0) {
124132
return err;
@@ -452,9 +460,16 @@ static DEVICE_API(display, ssd1327_driver_api) = {
452460
#define SSD1327_CONV_BUFFER_SIZE(node_id) \
453461
DIV_ROUND_UP(DT_PROP(node_id, width) * CONFIG_SSD1327_CONV_BUFFER_LINES, 2)
454462

463+
#define SSD1327_GREYSCALE_TABLE(node_id) \
464+
.greyscale_table = COND_CODE_1(DT_NODE_HAS_PROP(node_id, greyscale_table), \
465+
(ssd1327_greyscale_table_##node_id), (NULL))
466+
455467
#define SSD1327_DEFINE_I2C(node_id) \
456468
static uint8_t conversion_buf##node_id[SSD1327_CONV_BUFFER_SIZE(node_id)]; \
457469
static struct ssd1327_data data##node_id; \
470+
COND_CODE_1(DT_NODE_HAS_PROP(node_id, greyscale_table), ( \
471+
static uint8_t ssd1327_greyscale_table_##node_id[SSD1327_SET_LUT_COUNT] = \
472+
DT_PROP(node_id, greyscale_table);), ()) \
458473
static const struct ssd1327_config config##node_id = { \
459474
.i2c = I2C_DT_SPEC_GET(node_id), \
460475
.height = DT_PROP(node_id, height), \
@@ -470,6 +485,7 @@ static DEVICE_API(display, ssd1327_driver_api) = {
470485
.function_selection_b = DT_PROP(node_id, function_selection_b), \
471486
.precharge_voltage = DT_PROP(node_id, precharge_voltage), \
472487
.vcomh_voltage = DT_PROP(node_id, vcomh_voltage), \
488+
SSD1327_GREYSCALE_TABLE(node_id), \
473489
.write_cmd = ssd1327_write_bus_cmd_i2c, \
474490
.write_pixels = ssd1327_write_pixels_i2c, \
475491
.conversion_buf = conversion_buf##node_id, \
@@ -482,6 +498,9 @@ static DEVICE_API(display, ssd1327_driver_api) = {
482498
#define SSD1327_DEFINE_MIPI(node_id) \
483499
static uint8_t conversion_buf##node_id[SSD1327_CONV_BUFFER_SIZE(node_id)]; \
484500
static struct ssd1327_data data##node_id; \
501+
COND_CODE_1(DT_NODE_HAS_PROP(node_id, greyscale_table), ( \
502+
static uint8_t ssd1327_greyscale_table_##node_id[SSD1327_SET_LUT_COUNT] = \
503+
DT_PROP(node_id, greyscale_table);), ()) \
485504
static const struct ssd1327_config config##node_id = { \
486505
.mipi_dev = DEVICE_DT_GET(DT_PARENT(node_id)), \
487506
.dbi_config = MIPI_DBI_CONFIG_DT( \
@@ -499,6 +518,7 @@ static DEVICE_API(display, ssd1327_driver_api) = {
499518
.function_selection_b = DT_PROP(node_id, function_selection_b), \
500519
.precharge_voltage = DT_PROP(node_id, precharge_voltage), \
501520
.vcomh_voltage = DT_PROP(node_id, vcomh_voltage), \
521+
SSD1327_GREYSCALE_TABLE(node_id), \
502522
.write_cmd = ssd1327_write_bus_cmd_mipi, \
503523
.write_pixels = ssd1327_write_pixels_mipi, \
504524
.conversion_buf = conversion_buf##node_id, \

drivers/display/ssd1327_regs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#define SSD1327_SET_PRECHARGE_PERIOD 0xb6
3535
#define SSD1327_FUNCTION_SELECTION_B 0xd5
3636

37+
#define SSD1327_SET_LUT 0xb8
38+
#define SSD1327_SET_LUT_COUNT 15
3739
#define SSD1327_LINEAR_LUT 0xb9
3840

3941
#define SSD1327_SET_PRECHARGE_VOLTAGE 0xbc

dts/bindings/display/solomon,ssd1327fb-common.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ properties:
7676
inversion-on:
7777
type: boolean
7878
description: Turn on display color inverting
79+
80+
greyscale-table:
81+
type: uint8-array
82+
description: 15 elements array defines gamma settings for each brightness levels.

0 commit comments

Comments
 (0)