Skip to content

Commit 6ed3554

Browse files
danieldegrassekartben
authored andcommitted
drivers: display: st7796s: use mipi_dbi_configure_te API
Use the mipi_dbi_configure_te API within the st7796s display driver. If the MIPI DBI controller supports the tearing enable signal, then configure the ST7796S to output the TE line signal. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 83aa4aa commit 6ed3554

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

drivers/display/display_st7796s.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct st7796s_config {
4646
uint8_t pgc[14]; /* Positive gamma control */
4747
uint8_t ngc[14]; /* Negative gamma control */
4848
uint8_t madctl; /* Memory data access control */
49+
uint8_t te_mode; /* Tearing enable mode */
50+
uint32_t te_delay; /* Tearing enable delay */
4951
bool rgb_is_inverted;
5052
};
5153

@@ -155,7 +157,7 @@ static int st7796s_write(const struct device *dev,
155157
{
156158
const struct st7796s_config *config = dev->config;
157159
int ret;
158-
struct display_buffer_descriptor mipi_desc;
160+
struct display_buffer_descriptor mipi_desc = {0};
159161
enum display_pixel_format pixfmt;
160162

161163
ret = st7796s_set_cursor(dev, x, y, desc->width, desc->height);
@@ -164,6 +166,7 @@ static int st7796s_write(const struct device *dev,
164166
}
165167

166168
mipi_desc.buf_size = desc->width * desc->height * ST7796S_PIXEL_SIZE;
169+
mipi_desc.frame_incomplete = desc->frame_incomplete;
167170

168171
ret = mipi_dbi_command_write(config->mipi_dbi,
169172
&config->dbi_config, ST7796S_CMD_RAMWR,
@@ -282,6 +285,18 @@ static int st7796s_lcd_config(const struct device *dev)
282285
return ret;
283286
}
284287

288+
/* Attempt to enable TE signal */
289+
ret = mipi_dbi_configure_te(config->mipi_dbi, config->te_mode,
290+
config->te_delay);
291+
if (ret == 0) {
292+
/* TE was enabled- send TEON, and enable vblank only */
293+
param = 0x0; /* Set TMEM bit to 0 */
294+
ret = st7796s_send_cmd(dev, ST7796S_CMD_TEON, &param, sizeof(param));
295+
if (ret < 0) {
296+
return ret;
297+
}
298+
}
299+
285300
/* Lock display configuration */
286301
param = ST7796S_LOCK_1;
287302
ret = st7796s_send_cmd(dev, ST7796S_CMD_CSCON, &param, sizeof(param));
@@ -385,6 +400,8 @@ static DEVICE_API(display, st7796s_api) = {
385400
.ngc = DT_INST_PROP(n, ngc), \
386401
.madctl = DT_INST_PROP(n, madctl), \
387402
.rgb_is_inverted = DT_INST_PROP(n, rgb_is_inverted), \
403+
.te_mode = MIPI_DBI_TE_MODE_DT_INST(n, te_mode), \
404+
.te_delay = DT_INST_PROP(n, te_delay), \
388405
}; \
389406
\
390407
DEVICE_DT_INST_DEFINE(n, st7796s_init, \

drivers/display/display_st7796s.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define ST7796S_CMD_RAMWR 0x2C /* Memory write */
1717
#define ST7796S_CMD_DISPOFF 0x28 /* Display off */
1818
#define ST7796S_CMD_DISPON 0x29 /* Display on */
19+
#define ST7796S_CMD_TEON 0x35 /* Tearing effect on */
1920
#define ST7796S_CMD_MADCTL 0x36 /* Memory data access control */
2021
#define ST7796S_CMD_COLMOD 0x3A /* Interface pixel format */
2122
#define ST7796S_CMD_FRMCTR1 0xB1 /* Frame rate control 1 (normal mode) */

0 commit comments

Comments
 (0)