Skip to content

Misc SSD1327 and SSD1363 improvements #94316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/releases/migration-guide-4.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Display
This has now been fixed. Boards and applications that were tested or developed based on the
previous sample may be affected by this change (see :github:`79996` for more information).

* SSD1363's properties using 'greyscale' now use 'grayscale'.

PTP Clock
*********

Expand Down
44 changes: 23 additions & 21 deletions drivers/display/display_ssd1363.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ LOG_MODULE_REGISTER(ssd1363, CONFIG_DISPLAY_LOG_LEVEL);
#define SSD1363_WRITE_RAM 0x5C
#define SSD1363_READ_RAM 0x5D
#define SSD1363_SET_REMAP_VALUE 0xA0
#define SSD1363_SET_GREY_ENHANCE 0xB4
#define SSD1363_SET_GRAY_ENHANCE 0xB4

#define SSD1363_RESET_DELAY 100
#define SSD1363_RESET_DELAY 100
#define SSD1363_SET_LUT_COUNT 15

typedef int (*ssd1363_write_bus_cmd_fn)(const struct device *dev, const uint8_t cmd,
const uint8_t *data, size_t len);
Expand Down Expand Up @@ -75,10 +76,9 @@ struct ssd1363_config {
uint8_t precharge_period;
uint8_t precharge_config;
uint16_t column_offset;
uint8_t greyscale_table[15];
bool greyscale_table_present;
const uint8_t *grayscale_table;
bool color_inversion;
bool greyscale_enhancement;
bool grayscale_enhancement;
uint8_t *conversion_buf;
size_t conversion_buf_size;
};
Expand Down Expand Up @@ -156,8 +156,9 @@ static inline int ssd1363_set_hardware_config(const struct device *dev)
if (err < 0) {
return err;
}
if (config->greyscale_table_present) {
err = config->write_cmd(dev, SSD1363_SET_LUT, config->greyscale_table, 15);
if (config->grayscale_table != NULL) {
err = config->write_cmd(dev, SSD1363_SET_LUT, config->grayscale_table,
SSD1363_SET_LUT_COUNT);
if (err < 0) {
return err;
}
Expand All @@ -178,11 +179,11 @@ static inline int ssd1363_set_hardware_config(const struct device *dev)
if (err < 0) {
return err;
}
if (config->greyscale_enhancement) {
if (config->grayscale_enhancement) {
/* Undocumented values from datasheet */
buf[0] = 0x32;
buf[1] = 0x0c;
err = config->write_cmd(dev, SSD1363_SET_GREY_ENHANCE, buf, 2);
err = config->write_cmd(dev, SSD1363_SET_GRAY_ENHANCE, buf, 2);
if (err < 0) {
return err;
}
Expand Down Expand Up @@ -462,17 +463,15 @@ static DEVICE_API(display, ssd1363_driver_api) = {
#define SSD1363_CONV_BUFFER_SIZE(node_id) \
DIV_ROUND_UP(DT_PROP(node_id, width) * CONFIG_SSD1363_CONV_BUFFER_LINES, 1)

#define SSD1363_GREYSCALE_TABLE_YES(node_id) \
.greyscale_table = DT_PROP(node_id, greyscale_table), .greyscale_table_present = true

#define SSD1363_GREYSCALE_TABLE_NO(node_id) .greyscale_table_present = false

#define SSD1363_GREYSCALE_TABLE(node_id) \
COND_CODE_1(DT_NODE_HAS_PROP(node_id, greyscale_table), \
(SSD1363_GREYSCALE_TABLE_YES(node_id)), (SSD1363_GREYSCALE_TABLE_NO(node_id)))
#define SSD1363_GRAYSCALE_TABLE(node_id) \
.grayscale_table = COND_CODE_1(DT_NODE_HAS_PROP(node_id, grayscale_table), \
(ssd1363_grayscale_table_##node_id), (NULL))

#define SSD1363_DEFINE_I2C(node_id) \
static uint8_t conversion_buf##node_id[SSD1363_CONV_BUFFER_SIZE(node_id)]; \
COND_CODE_1(DT_NODE_HAS_PROP(node_id, grayscale_table), ( \
static const uint8_t ssd1363_grayscale_table_##node_id[SSD1363_SET_LUT_COUNT] = \
DT_PROP(node_id, grayscale_table);), ()) \
static const struct ssd1363_config config##node_id = { \
.i2c = I2C_DT_SPEC_GET(node_id), \
.height = DT_PROP(node_id, height), \
Expand All @@ -490,8 +489,8 @@ static DEVICE_API(display, ssd1363_driver_api) = {
.precharge_period = DT_PROP(node_id, precharge_period), \
.precharge_config = DT_PROP(node_id, precharge_config), \
.column_offset = DT_PROP(node_id, column_offset), \
.greyscale_enhancement = DT_PROP(node_id, greyscale_enhancement), \
SSD1363_GREYSCALE_TABLE(node_id), \
.grayscale_enhancement = DT_PROP(node_id, grayscale_enhancement), \
SSD1363_GRAYSCALE_TABLE(node_id), \
.write_cmd = ssd1363_write_bus_cmd_i2c, \
.write_pixels = ssd1363_write_pixels_i2c, \
.conversion_buf = conversion_buf##node_id, \
Expand All @@ -503,6 +502,9 @@ static DEVICE_API(display, ssd1363_driver_api) = {

#define SSD1363_DEFINE_MIPI(node_id) \
static uint8_t conversion_buf##node_id[SSD1363_CONV_BUFFER_SIZE(node_id)]; \
COND_CODE_1(DT_NODE_HAS_PROP(node_id, grayscale_table), ( \
static const uint8_t ssd1363_grayscale_table_##node_id[SSD1363_SET_LUT_COUNT] = \
DT_PROP(node_id, grayscale_table);), ()) \
static const struct ssd1363_config config##node_id = { \
.mipi_dev = DEVICE_DT_GET(DT_PARENT(node_id)), \
.dbi_config = MIPI_DBI_CONFIG_DT( \
Expand All @@ -522,8 +524,8 @@ static DEVICE_API(display, ssd1363_driver_api) = {
.precharge_period = DT_PROP(node_id, precharge_period), \
.precharge_config = DT_PROP(node_id, precharge_config), \
.column_offset = DT_PROP(node_id, column_offset), \
.greyscale_enhancement = DT_PROP(node_id, greyscale_enhancement), \
SSD1363_GREYSCALE_TABLE(node_id), \
.grayscale_enhancement = DT_PROP(node_id, grayscale_enhancement), \
SSD1363_GRAYSCALE_TABLE(node_id), \
.write_cmd = ssd1363_write_bus_cmd_mipi, \
.write_pixels = ssd1363_write_pixels_mipi, \
.conversion_buf = conversion_buf##node_id, \
Expand Down
6 changes: 3 additions & 3 deletions drivers/display/ssd1327.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct ssd1327_config {
uint8_t function_selection_b;
uint8_t precharge_voltage;
uint8_t vcomh_voltage;
uint8_t *grayscale_table;
const uint8_t *grayscale_table;
bool color_inversion;
uint8_t *conversion_buf;
size_t conversion_buf_size;
Expand Down Expand Up @@ -468,7 +468,7 @@ static DEVICE_API(display, ssd1327_driver_api) = {
static uint8_t conversion_buf##node_id[SSD1327_CONV_BUFFER_SIZE(node_id)]; \
static struct ssd1327_data data##node_id; \
COND_CODE_1(DT_NODE_HAS_PROP(node_id, grayscale_table), ( \
static uint8_t ssd1327_grayscale_table_##node_id[SSD1327_SET_LUT_COUNT] = \
static const uint8_t ssd1327_grayscale_table_##node_id[SSD1327_SET_LUT_COUNT] = \
DT_PROP(node_id, grayscale_table);), ()) \
static const struct ssd1327_config config##node_id = { \
.i2c = I2C_DT_SPEC_GET(node_id), \
Expand Down Expand Up @@ -499,7 +499,7 @@ static DEVICE_API(display, ssd1327_driver_api) = {
static uint8_t conversion_buf##node_id[SSD1327_CONV_BUFFER_SIZE(node_id)]; \
static struct ssd1327_data data##node_id; \
COND_CODE_1(DT_NODE_HAS_PROP(node_id, grayscale_table), ( \
static uint8_t ssd1327_grayscale_table_##node_id[SSD1327_SET_LUT_COUNT] = \
static const uint8_t ssd1327_grayscale_table_##node_id[SSD1327_SET_LUT_COUNT] = \
DT_PROP(node_id, grayscale_table);), ()) \
static const struct ssd1327_config config##node_id = { \
.mipi_dev = DEVICE_DT_GET(DT_PARENT(node_id)), \
Expand Down
6 changes: 3 additions & 3 deletions dts/bindings/display/solomon,ssd1363-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ properties:
type: boolean
description: Turn on display color inverting

greyscale-enhancement:
grayscale-enhancement:
type: boolean
description: Enable greyscale enhancement, undocumented.
description: Enable grayscale enhancement, undocumented.

greyscale-table:
grayscale-table:
Comment on lines +93 to +97
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change needs to be mentioned in migration guide as its requiring downstream users to make changes to their code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

type: uint8-array
description: 15 elements array defines gamma settings for each brightness levels.
It seems last element must always be 60/0x3C.