@@ -47,6 +47,7 @@ struct ssd1327_config {
47
47
uint8_t function_selection_b ;
48
48
uint8_t precharge_voltage ;
49
49
uint8_t vcomh_voltage ;
50
+ uint8_t * greyscale_table ;
50
51
bool color_inversion ;
51
52
uint8_t * conversion_buf ;
52
53
size_t conversion_buf_size ;
@@ -119,6 +120,13 @@ static inline int ssd1327_set_timing_setting(const struct device *dev)
119
120
if (err < 0 ) {
120
121
return err ;
121
122
}
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
+ }
122
130
err = config -> write_cmd (dev , SSD1327_SET_PRECHARGE_VOLTAGE , & config -> precharge_voltage , 1 );
123
131
if (err < 0 ) {
124
132
return err ;
@@ -452,9 +460,16 @@ static DEVICE_API(display, ssd1327_driver_api) = {
452
460
#define SSD1327_CONV_BUFFER_SIZE (node_id ) \
453
461
DIV_ROUND_UP(DT_PROP(node_id, width) * CONFIG_SSD1327_CONV_BUFFER_LINES, 2)
454
462
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
+
455
467
#define SSD1327_DEFINE_I2C (node_id ) \
456
468
static uint8_t conversion_buf##node_id[SSD1327_CONV_BUFFER_SIZE(node_id)]; \
457
469
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);), ()) \
458
473
static const struct ssd1327_config config##node_id = { \
459
474
.i2c = I2C_DT_SPEC_GET(node_id), \
460
475
.height = DT_PROP(node_id, height), \
@@ -470,6 +485,7 @@ static DEVICE_API(display, ssd1327_driver_api) = {
470
485
.function_selection_b = DT_PROP(node_id, function_selection_b), \
471
486
.precharge_voltage = DT_PROP(node_id, precharge_voltage), \
472
487
.vcomh_voltage = DT_PROP(node_id, vcomh_voltage), \
488
+ SSD1327_GREYSCALE_TABLE(node_id), \
473
489
.write_cmd = ssd1327_write_bus_cmd_i2c, \
474
490
.write_pixels = ssd1327_write_pixels_i2c, \
475
491
.conversion_buf = conversion_buf##node_id, \
@@ -482,6 +498,9 @@ static DEVICE_API(display, ssd1327_driver_api) = {
482
498
#define SSD1327_DEFINE_MIPI (node_id ) \
483
499
static uint8_t conversion_buf##node_id[SSD1327_CONV_BUFFER_SIZE(node_id)]; \
484
500
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);), ()) \
485
504
static const struct ssd1327_config config##node_id = { \
486
505
.mipi_dev = DEVICE_DT_GET(DT_PARENT(node_id)), \
487
506
.dbi_config = MIPI_DBI_CONFIG_DT( \
@@ -499,6 +518,7 @@ static DEVICE_API(display, ssd1327_driver_api) = {
499
518
.function_selection_b = DT_PROP(node_id, function_selection_b), \
500
519
.precharge_voltage = DT_PROP(node_id, precharge_voltage), \
501
520
.vcomh_voltage = DT_PROP(node_id, vcomh_voltage), \
521
+ SSD1327_GREYSCALE_TABLE(node_id), \
502
522
.write_cmd = ssd1327_write_bus_cmd_mipi, \
503
523
.write_pixels = ssd1327_write_pixels_mipi, \
504
524
.conversion_buf = conversion_buf##node_id, \
0 commit comments