Skip to content

Commit df3fb27

Browse files
committed
drm/mipi-dbi: Make bits per word configurable for pixel transfers
MIPI DCS write/set commands have 8 bit parameters except for the write_memory commands where it depends on the pixel format. drm_mipi_dbi does currently only support RGB565 which is 16-bit and it has to make sure that the pixels enters the SPI bus in big endian format since the MIPI DBI spec doesn't have support for little endian. drm_mipi_dbi is optimized for DBI interface option 3 which means that the 16-bit bytes are swapped by the upper layer if the SPI bus does not support 16 bits per word, signified by the swap_bytes member. In order to support both 16-bit and 24-bit pixel transfers we need a way to tell the DBI command layer the format of the buffer. Add a write_memory_bpw member that the upper layer can use to tell how many bits per word to use for the SPI transfer. v4: - Expand the commit message (Dmitry) Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Noralf Trønnes <[email protected]>
1 parent f34f014 commit df3fb27

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

drivers/gpu/drm/drm_mipi_dbi.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ static int mipi_dbi_typec1_command_read(struct mipi_dbi *dbi, u8 *cmd,
10791079
static int mipi_dbi_typec1_command(struct mipi_dbi *dbi, u8 *cmd,
10801080
u8 *parameters, size_t num)
10811081
{
1082-
unsigned int bpw = (*cmd == MIPI_DCS_WRITE_MEMORY_START) ? 16 : 8;
1082+
unsigned int bpw = 8;
10831083
int ret;
10841084

10851085
if (mipi_dbi_command_is_read(dbi, *cmd))
@@ -1091,6 +1091,9 @@ static int mipi_dbi_typec1_command(struct mipi_dbi *dbi, u8 *cmd,
10911091
if (ret || !num)
10921092
return ret;
10931093

1094+
if (*cmd == MIPI_DCS_WRITE_MEMORY_START)
1095+
bpw = dbi->write_memory_bpw;
1096+
10941097
return mipi_dbi_spi1_transfer(dbi, 1, parameters, num, bpw);
10951098
}
10961099

@@ -1184,8 +1187,8 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *dbi, u8 *cmd,
11841187
if (ret || !num)
11851188
return ret;
11861189

1187-
if (*cmd == MIPI_DCS_WRITE_MEMORY_START && !dbi->swap_bytes)
1188-
bpw = 16;
1190+
if (*cmd == MIPI_DCS_WRITE_MEMORY_START)
1191+
bpw = dbi->write_memory_bpw;
11891192

11901193
spi_bus_lock(spi->controller);
11911194
gpiod_set_value_cansleep(dbi->dc, 1);
@@ -1256,12 +1259,15 @@ int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi,
12561259

12571260
dbi->spi = spi;
12581261
dbi->read_commands = mipi_dbi_dcs_read_commands;
1262+
dbi->write_memory_bpw = 16;
12591263

12601264
if (dc) {
12611265
dbi->command = mipi_dbi_typec3_command;
12621266
dbi->dc = dc;
1263-
if (!spi_is_bpw_supported(spi, 16))
1267+
if (!spi_is_bpw_supported(spi, 16)) {
1268+
dbi->write_memory_bpw = 8;
12641269
dbi->swap_bytes = true;
1270+
}
12651271
} else {
12661272
dbi->command = mipi_dbi_typec1_command;
12671273
dbi->tx_buf9_len = SZ_16K;

include/drm/drm_mipi_dbi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ struct mipi_dbi {
5656
*/
5757
struct spi_device *spi;
5858

59+
/**
60+
* @write_memory_bpw: Bits per word used on a MIPI_DCS_WRITE_MEMORY_START transfer
61+
*/
62+
unsigned int write_memory_bpw;
63+
5964
/**
6065
* @dc: Optional D/C gpio.
6166
*/

0 commit comments

Comments
 (0)