Dingoo A320 ⇒ Dingux

移植ILI9340驅動程式


因為司徒已經替換A320掌機的屏幕為ILI9340,因此對應的驅動程式也須一起更改,而相較於丁果系統的Binary Patch手法,開源的Dingux系統就容易許多,司徒只需修改屏幕的初始化程式就可以,過程說明如下:

$ vim drivers/video/jz4740_slcd.c
--- jz4740_slcd_old.c
+++ jz4740_slcd_new.c
@@ -93,7 +93,7 @@
 };
 
 static struct jzfb_info jzfb = {
-#if defined(CONFIG_JZ_SLCD_A320_ILI9325) || defined (CONFIG_JZ_SLCD_A320_ILI9331) || defined (CONFIG_JZ_SLCD_A320_ILI9338)
+#if defined(CONFIG_JZ_SLCD_A320_ILI9325) || defined (CONFIG_JZ_SLCD_A320_ILI9331) || defined (CONFIG_JZ_SLCD_A320_ILI9338) || defined (CONFIG_JZ_SLCD_A320_ILI9340) || defined (CONFIG_JZ_SLCD_A320_ILI9341)
   SLCD_CFG_CS_ACTIVE_LOW | SLCD_CFG_RS_CMD_LOW | SLCD_CFG_TYPE_PARALLEL,
   320, 240, 16, 16, 16800000  /*16 bpp, 16 bus */
 #endif

$ vim drivers/video/jz4740_slcd.h
--- jz4740_slcd_old.h
+++ jz4740_slcd_new.h
@@ -32,6 +32,295 @@
 #define FBIO_SET_REG    0x4690
 
 
+#ifdef CONFIG_JZ_SLCD_A320_ILI9340
+#define PIN_RS_N  (32*2+19)  /* Port 2 pin 19: RS# (register select, active low) */
+#define PIN_CS_N  (32*1+17)  /* Port 1 pin 17: CS# (chip select, active low) */
+#define PIN_RESET_N  (32*1+18)  /* Port 1 pin 18: RESET# (reset, active low) */
+
+#define  __slcd_special_pin_init()  \
+do {          \
+  __gpio_as_output(PIN_RS_N);  \
+  __gpio_set_pin(PIN_RS_N);  \
+  __gpio_as_output(PIN_CS_N);  \
+  __gpio_set_pin(PIN_CS_N);  \
+  __gpio_as_output(PIN_RESET_N);  \
+  __gpio_clear_pin(PIN_RESET_N);  \
+} while(0)
+
+#define __slcd_special_on()     \
+do {          \
+  /* RESET pulse */    \
+  __gpio_clear_pin(PIN_RESET_N);  \
+  mdelay(10);      \
+  __gpio_set_pin(PIN_RESET_N);  \
+  mdelay(50);      \
+          \
+  /* Enable chip select */  \
+  __gpio_clear_pin(PIN_CS_N);  \
+          \
+  /* Black magic */    \
+  Mcupanel_Command(0x11);    \
+  mdelay(500);      \
+  Mcupanel_Command(0xCB);    \
+  Mcupanel_Data(0X01);    \
+  Mcupanel_Command(0xC0);    \
+  Mcupanel_Data(0X27);    \
+  Mcupanel_Data(0X09);    \
+  Mcupanel_Command(0xC1);    \
+  Mcupanel_Data(0X10);    \
+  Mcupanel_Command(0xC5);    \
+  Mcupanel_Data(0X31);    \
+  Mcupanel_Data(0X3C);    \
+  Mcupanel_Command(0x36);   \
+  Mcupanel_Data(0X0C);    \
+  Mcupanel_Command(0x3A);    \
+  Mcupanel_Data(0X05);    \
+  Mcupanel_Command(0xB1);    \
+  Mcupanel_Data(0X00);    \
+  Mcupanel_Data(0X18);    \
+  Mcupanel_Command(0xB6);    \
+  Mcupanel_Data(0X0A);    \
+  Mcupanel_Data(0X02);    \
+  Mcupanel_Command(0xC7);   \
+  Mcupanel_Data(0XCF);    \
+  Mcupanel_Command(0xE8);    \
+  Mcupanel_Data(0X89);    \
+  Mcupanel_Data(0X11);    \
+  Mcupanel_Data(0X78);    \
+  Mcupanel_Command(0xF2);    \
+  Mcupanel_Data(0X00);    \
+  Mcupanel_Command(0xE0);    \
+  Mcupanel_Data(0X0F);    \
+  Mcupanel_Data(0X3F);    \
+  Mcupanel_Data(0X3F);    \
+  Mcupanel_Data(0X02);    \
+  Mcupanel_Data(0X04);    \
+  Mcupanel_Data(0X05);    \
+  Mcupanel_Data(0X49);    \
+  Mcupanel_Data(0X75);    \
+  Mcupanel_Data(0X20);    \
+  Mcupanel_Data(0X08);    \
+  Mcupanel_Data(0X14);    \
+  Mcupanel_Data(0X0C);    \
+  Mcupanel_Data(0X15);    \
+  Mcupanel_Data(0X0E);    \
+  Mcupanel_Data(0X00);    \
+  Mcupanel_Command(0xE1);    \
+  Mcupanel_Data(0X00);    \
+  Mcupanel_Data(0X00);    \
+  Mcupanel_Data(0X00);    \
+  Mcupanel_Data(0X0C);    \
+  Mcupanel_Data(0X1A);    \
+  Mcupanel_Data(0X0D);    \
+  Mcupanel_Data(0X3A);    \
+  Mcupanel_Data(0X8A);    \
+  Mcupanel_Data(0X40);    \
+  Mcupanel_Data(0X08);    \
+  Mcupanel_Data(0X11);    \
+  Mcupanel_Data(0X0F);    \
+  Mcupanel_Data(0X3F);    \
+  Mcupanel_Data(0X3F);    \
+  Mcupanel_Data(0X0F);    \
+  Mcupanel_Command(0x2a);      \
+  Mcupanel_Data(0x00);      \
+  Mcupanel_Data(0x00);      \
+  Mcupanel_Data(0x01);      \
+  Mcupanel_Data(0x3f);      \
+  Mcupanel_Command(0x2b);      \
+  Mcupanel_Data(0x00);      \
+  Mcupanel_Data(0x00);      \
+  Mcupanel_Data(0x00);      \
+  Mcupanel_Data(0xef);      \
+  Mcupanel_Command(0x36);      \
+  Mcupanel_Data(0xe8);      \
+  Mcupanel_Command(0x3A);      \
+  Mcupanel_Data(0x05);      \
+  Mcupanel_Command(0x29);      \
+  Mcupanel_Command(0x2c);      \
+} while (0)
+
+/* TODO(IGP): make sure LCD power consumption is low in these conditions */
+
+#define __slcd_special_off()    \
+do {          \
+  /* Keep chip select disabled */  \
+  __gpio_set_pin(PIN_CS_N);  \
+  /* Keep RESET active */    \
+  __gpio_clear_pin(PIN_RESET_N);  \
+} while (0)
+
+#define __slcd_special_rs_enable()  \
+do {          \
+  __gpio_clear_pin(PIN_RS_N);  \
+} while (0)
+
+#define __slcd_special_rs_disable()  \
+do {          \
+  __gpio_set_pin(PIN_RS_N);  \
+} while(0)
+
+#endif /* CONFIG_JZ_SLCD_A320_ILI9340 */
+
+
+
+#ifdef CONFIG_JZ_SLCD_A320_ILI9341
+#define PIN_RS_N  (32*2+19)  /* Port 2 pin 19: RS# (register select, active low) */
+#define PIN_CS_N  (32*1+17)  /* Port 1 pin 17: CS# (chip select, active low) */
+#define PIN_RESET_N  (32*1+18)  /* Port 1 pin 18: RESET# (reset, active low) */
+
+#define  __slcd_special_pin_init()  \
+do {          \
+  __gpio_as_output(PIN_RS_N);  \
+  __gpio_set_pin(PIN_RS_N);  \
+  __gpio_as_output(PIN_CS_N);  \
+  __gpio_set_pin(PIN_CS_N);  \
+  __gpio_as_output(PIN_RESET_N);  \
+  __gpio_clear_pin(PIN_RESET_N);  \
+} while(0)
+
+#define __slcd_special_on()     \
+do {          \
+  /* RESET pulse */    \
+  __gpio_clear_pin(PIN_RESET_N);  \
+  mdelay(10);      \
+  __gpio_set_pin(PIN_RESET_N);  \
+  mdelay(50);      \
+          \
+  /* Enable chip select */  \
+  __gpio_clear_pin(PIN_CS_N);  \
+          \
+  /* Black magic */    \
+        Mcupanel_Command(0x3A);    \
+        Mcupanel_Data(0x55);    \
+        Mcupanel_Command(0xB5);    \
+        Mcupanel_Data(0x04);    \
+        Mcupanel_Data(0x04);    \
+        Mcupanel_Data(0x0A);    \
+        Mcupanel_Data(0x14);    \
+        Mcupanel_Command(0x35);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Command(0xCF);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0xEA);    \
+        Mcupanel_Data(0XF0);    \
+        Mcupanel_Command(0xED);    \
+        Mcupanel_Data(0x64);    \
+        Mcupanel_Data(0x03);    \
+        Mcupanel_Data(0X12);    \
+        Mcupanel_Data(0X81);    \
+        Mcupanel_Command(0xE8);    \
+        Mcupanel_Data(0x85);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0x78);    \
+        Mcupanel_Command(0xCB);    \
+        Mcupanel_Data(0x39);    \
+        Mcupanel_Data(0x2C);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0x33);    \
+        Mcupanel_Data(0x06);    \
+        Mcupanel_Command(0xF7);    \
+        Mcupanel_Data(0x20);    \
+        Mcupanel_Command(0xEA);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Command(0xC0);    \
+        Mcupanel_Data(0x2D);    \
+        Mcupanel_Command(0xC1);    \
+        Mcupanel_Data(0x11);    \
+        Mcupanel_Command(0xC5);    \
+        Mcupanel_Data(0x44);    \
+        Mcupanel_Data(0x3A);    \
+        Mcupanel_Command(0xC7);    \
+        Mcupanel_Data(0xba);    \
+        Mcupanel_Command(0x36);    \
+        Mcupanel_Data(0x48);    \
+        Mcupanel_Command(0xB1);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0x13);    \
+        Mcupanel_Command(0xB6);    \
+        Mcupanel_Data(0x0A);    \
+        Mcupanel_Data(0xA2);    \
+        Mcupanel_Command(0xF2);    \
+        Mcupanel_Data(0x02);    \
+        Mcupanel_Command(0xE0);    \
+        Mcupanel_Data(0x0F);    \
+        Mcupanel_Data(0x23);    \
+        Mcupanel_Data(0x1F);    \
+        Mcupanel_Data(0x0B);    \
+        Mcupanel_Data(0x0E);    \
+        Mcupanel_Data(0x08);    \
+        Mcupanel_Data(0x4B);    \
+        Mcupanel_Data(0x64);    \
+        Mcupanel_Data(0x3B);    \
+        Mcupanel_Data(0x0A);    \
+        Mcupanel_Data(0x14);    \
+        Mcupanel_Data(0x06);    \
+        Mcupanel_Data(0x10);    \
+        Mcupanel_Data(0x09);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Command(0XE1);    \
+        Mcupanel_Data(0x02);    \
+        Mcupanel_Data(0x1c);    \
+        Mcupanel_Data(0x20);    \
+        Mcupanel_Data(0x04);    \
+        Mcupanel_Data(0x10);    \
+        Mcupanel_Data(0x08);    \
+        Mcupanel_Data(0x34);    \
+        Mcupanel_Data(0x47);    \
+        Mcupanel_Data(0x44);    \
+        Mcupanel_Data(0x05);    \
+        Mcupanel_Data(0x0B);    \
+        Mcupanel_Data(0x09);    \
+        Mcupanel_Data(0x2F);    \
+        Mcupanel_Data(0x11);    \
+        Mcupanel_Data(0x0F);    \
+        Mcupanel_Command(0x2B);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0x01);    \
+        Mcupanel_Data(0x3f);    \
+        Mcupanel_Command(0x2A);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0x00);    \
+        Mcupanel_Data(0xef);    \
+        Mcupanel_Command(0x11);    \
+        mdelay(120);      \
+        Mcupanel_Command(0x29);    \
+        Mcupanel_Command(0x36);    \
+        Mcupanel_Data(0x6C);    \
+} while (0)
+
+/* TODO(IGP): make sure LCD power consumption is low in these conditions */
+
+#define __slcd_special_off()    \
+do {          \
+  /* Keep chip select disabled */  \
+  __gpio_set_pin(PIN_CS_N);  \
+  /* Keep RESET active */    \
+  __gpio_clear_pin(PIN_RESET_N);  \
+} while (0)
+
+#define __slcd_special_rs_enable()  \
+do {          \
+  __gpio_clear_pin(PIN_RS_N);  \
+} while (0)
+
+#define __slcd_special_rs_disable()  \
+do {          \
+  __gpio_set_pin(PIN_RS_N);  \
+} while(0)
+
+#endif /* CONFIG_JZ_SLCD_A320_ILI9341 */
+
+
 
 /*
  * Dingoo A320 IL9325 specific stuff.

$ vim drivers/video/Kconfig
--- Kconfig_old
+++ Kconfig_new
@@ -236,7 +236,17 @@
 config JZ_SLCD_A320_ILI9338
   bool "Dingoo A320 ILI9338 smart LCD panel"
   ---help---
-  Driver for ILI9331 smart LCD panel as connected in Dingoo A320 (provided by ChinaChip).
+  Driver for ILI9338 smart LCD panel as connected in Dingoo A320 (provided by ChinaChip).
+
+config JZ_SLCD_A320_ILI9340
+  bool "Dingoo A320 ILI9340 smart LCD panel"
+  ---help---
+  Driver for ILI9340 smart IPS panel as connected in Dingoo A320 (provided by ChinaChip).
+
+config JZ_SLCD_A320_ILI9341
+  bool "Dingoo A320 ILI9341 smart LCD panel"
+  ---help---
+  Driver for ILI9341 smart LCD panel as connected in Dingoo A320 (provided by ChinaChip).
 
 config JZ_SLCD_LGDP4551
   bool "LG LGDP4551 Smart LCD panel"

$ make menuconfig

Device Drivers ⇒ Graphics support ⇒ Support for frame buffer devices ⇒ SLCD panel ⇒ Dingoo A320 ILI9340 smart LCD panel

$ make


返回上一頁