rk mipi: fixed the bug of send generic short packet in rk32_mipi_dsi.c
authorchenyifu <chenyf@rock-chips.com>
Tue, 18 Nov 2014 01:57:13 +0000 (09:57 +0800)
committerchenyifu <chenyf@rock-chips.com>
Tue, 18 Nov 2014 02:11:03 +0000 (10:11 +0800)
DTYPE_GEN_SWRITE_2P:
  Generic Short WRITE Packet with 2 parameters(one command
and one parameter). But the users may send the packet more
than 2 parameters.

DTYPE_GEN_SWRITE_1P:
Generic Short WRITE Packet with 1 parameters(one command
without parameter).
DTYPE_GEN_SWRITE_0P:
Generic Short WRITE Packet with 0 parameters(nop packet
without command and parameter).

drivers/video/rockchip/transmitter/rk32_mipi_dsi.c

index d0a98b6ecc8d1198d7e28feed03fc9d8ff6f67d9..a7f5bd1cb8e65a75f61ae1584e197e827bc6facb 100755 (executable)
@@ -1124,8 +1124,20 @@ static int rk32_mipi_dsi_send_packet(void *arg, unsigned char cmds[], u32 length
                data = (dsi->vid << 6) | type;
                data |= (liTmp & 0xffff) << 8;
                break;
-       case DTYPE_GEN_SWRITE_2P:
+       case DTYPE_GEN_SWRITE_2P: /* one command and one parameter */
                rk32_dsi_set_bits(dsi, regs[0], gen_sw_2p_tx);
+               if (liTmp <= 2) {
+                       /* It is used for normal Generic Short WRITE Packet with 2 parameters. */
+                       data = type;
+                       data |= regs[2] << 8;   /* dcs command */
+                       data |= regs[3] << 16;  /* parameter of command */
+                       break;  
+               }
+
+               /* The below is used for Generic Short WRITE Packet with 2 parameters
+                * that more than 2 parameters. Though it is illegal dcs command, we can't
+                * make sure the users do not send that command.
+                */
                for (i = 0; i < liTmp; i++) {
                        regs[i] = regs[i+2];
                }
@@ -1145,16 +1157,14 @@ static int rk32_mipi_dsi_send_packet(void *arg, unsigned char cmds[], u32 length
                data = type;
                data |= (liTmp & 0xffff) << 8;
                break;
-       case DTYPE_GEN_SWRITE_1P:
+       case DTYPE_GEN_SWRITE_1P: /* one command without parameter */
                rk32_dsi_set_bits(dsi, regs[0], gen_sw_1p_tx);
                data = type;
                data |= regs[2] << 8;
-               data |= regs[3] << 16;
                break;
-       case DTYPE_GEN_SWRITE_0P:
+       case DTYPE_GEN_SWRITE_0P: /* nop packet without command and parameter */
                rk32_dsi_set_bits(dsi, regs[0], gen_sw_0p_tx);
                data =  type;
-               data |= regs[2] << 8;
                break;
        default:
                printk("0x%x:this type not suppport!\n", type);