4444
4545#define DSI_CMD_FIFO_DEPTH 16
4646#define DSI_PIX_FIFO_DEPTH 256
47- #define DSI_PIX_FIFO_WIDTH 4
4847
4948#define DSI0_CTRL 0x00
5049
170169#define DSI1_DISP1_CTRL 0x2c
171170/* Format of the data written to TXPKT_PIX_FIFO. */
172171# define DSI_DISP1_PFORMAT_MASK VC4_MASK(2, 1)
173- # define DSI_DISP1_PFORMAT_SHIFT 1
174- # define DSI_DISP1_PFORMAT_16BIT 0
175- # define DSI_DISP1_PFORMAT_24BIT 1
176- # define DSI_DISP1_PFORMAT_32BIT_LE 2
177- # define DSI_DISP1_PFORMAT_32BIT_BE 3
172+ # define DSI1_DISP1_PFORMAT_SHIFT 1
173+ # define DSI0_DISP1_PFORMAT_16BIT 0
174+ # define DSI0_DISP1_PFORMAT_16BIT_ADJ 1
175+ # define DSI0_DISP1_PFORMAT_24BIT 2
176+ # define DSI0_DISP1_PFORMAT_32BIT_LE 3 /* NB Invalid, but required for macros to work */
177+ # define DSI1_DISP1_PFORMAT_16BIT 0
178+ # define DSI1_DISP1_PFORMAT_24BIT 1
179+ # define DSI1_DISP1_PFORMAT_32BIT_LE 2
180+ # define DSI1_DISP1_PFORMAT_32BIT_BE 3
178181
179182/* DISP1 is always command mode. */
180183# define DSI_DISP1_ENABLE BIT(0)
@@ -553,6 +556,7 @@ struct vc4_dsi_variant {
553556 unsigned int port ;
554557
555558 bool broken_axi_workaround ;
559+ unsigned int cmd_fifo_width ;
556560
557561 const char * debugfs_name ;
558562 const struct debugfs_reg32 * regs ;
@@ -1151,10 +1155,16 @@ static void vc4_dsi_bridge_pre_enable(struct drm_bridge *bridge,
11511155 /* Set up DISP1 for transferring long command payloads through
11521156 * the pixfifo.
11531157 */
1154- DSI_PORT_WRITE (DISP1_CTRL ,
1155- VC4_SET_FIELD (DSI_DISP1_PFORMAT_32BIT_LE ,
1156- DSI_DISP1_PFORMAT ) |
1157- DSI_DISP1_ENABLE );
1158+ if (dsi -> variant -> cmd_fifo_width == 4 )
1159+ DSI_PORT_WRITE (DISP1_CTRL ,
1160+ VC4_SET_FIELD (DSI_PORT_BIT (DISP1_PFORMAT_32BIT_LE ),
1161+ DSI_DISP1_PFORMAT ) |
1162+ DSI_DISP1_ENABLE );
1163+ else
1164+ DSI_PORT_WRITE (DISP1_CTRL ,
1165+ VC4_SET_FIELD (DSI_PORT_BIT (DISP1_PFORMAT_24BIT ),
1166+ DSI_DISP1_PFORMAT ) |
1167+ DSI_DISP1_ENABLE );
11581168
11591169 /* Bring AFE out of reset. */
11601170 DSI_PORT_WRITE (PHY_AFEC0 ,
@@ -1235,9 +1245,9 @@ static ssize_t vc4_dsi_transfer(struct vc4_dsi *dsi,
12351245 pix_fifo_len = 0 ;
12361246 } else {
12371247 cmd_fifo_len = (packet .payload_length %
1238- DSI_PIX_FIFO_WIDTH );
1248+ dsi -> variant -> cmd_fifo_width );
12391249 pix_fifo_len = ((packet .payload_length - cmd_fifo_len ) /
1240- DSI_PIX_FIFO_WIDTH );
1250+ dsi -> variant -> cmd_fifo_width );
12411251 }
12421252
12431253 WARN_ON_ONCE (pix_fifo_len >= DSI_PIX_FIFO_DEPTH );
@@ -1255,14 +1265,25 @@ static ssize_t vc4_dsi_transfer(struct vc4_dsi *dsi,
12551265
12561266 for (i = 0 ; i < cmd_fifo_len ; i ++ )
12571267 DSI_PORT_WRITE (TXPKT_CMD_FIFO , packet .payload [i ]);
1258- for (i = 0 ; i < pix_fifo_len ; i ++ ) {
1259- const u8 * pix = packet .payload + cmd_fifo_len + i * 4 ;
1260-
1261- DSI_PORT_WRITE (TXPKT_PIX_FIFO ,
1262- pix [0 ] |
1263- pix [1 ] << 8 |
1264- pix [2 ] << 16 |
1265- pix [3 ] << 24 );
1268+ if (dsi -> variant -> cmd_fifo_width == 4 ) {
1269+ for (i = 0 ; i < pix_fifo_len ; i ++ ) {
1270+ const u8 * pix = packet .payload + cmd_fifo_len + i * 4 ;
1271+
1272+ DSI_PORT_WRITE (TXPKT_PIX_FIFO ,
1273+ pix [0 ] |
1274+ pix [1 ] << 8 |
1275+ pix [2 ] << 16 |
1276+ pix [3 ] << 24 );
1277+ }
1278+ } else {
1279+ for (i = 0 ; i < pix_fifo_len ; i ++ ) {
1280+ const u8 * pix = packet .payload + cmd_fifo_len + i * 3 ;
1281+
1282+ DSI_PORT_WRITE (TXPKT_PIX_FIFO ,
1283+ pix [2 ] |
1284+ pix [1 ] << 8 |
1285+ pix [0 ] << 16 );
1286+ }
12661287 }
12671288
12681289 if (msg -> flags & MIPI_DSI_MSG_USE_LPM )
@@ -1516,20 +1537,23 @@ static const struct drm_encoder_funcs vc4_dsi_encoder_funcs = {
15161537
15171538static const struct vc4_dsi_variant bcm2711_dsi1_variant = {
15181539 .port = 1 ,
1540+ .cmd_fifo_width = 4 ,
15191541 .debugfs_name = "dsi1_regs" ,
15201542 .regs = dsi1_regs ,
15211543 .nregs = ARRAY_SIZE (dsi1_regs ),
15221544};
15231545
15241546static const struct vc4_dsi_variant bcm2835_dsi0_variant = {
15251547 .port = 0 ,
1548+ .cmd_fifo_width = 3 ,
15261549 .debugfs_name = "dsi0_regs" ,
15271550 .regs = dsi0_regs ,
15281551 .nregs = ARRAY_SIZE (dsi0_regs ),
15291552};
15301553
15311554static const struct vc4_dsi_variant bcm2835_dsi1_variant = {
15321555 .port = 1 ,
1556+ .cmd_fifo_width = 4 ,
15331557 .broken_axi_workaround = true,
15341558 .debugfs_name = "dsi1_regs" ,
15351559 .regs = dsi1_regs ,
0 commit comments