求 otm8009a dsi代码一份,谢谢!
时间:10-02
整理:3721RD
点击:
RT:哪位兄弟调通过的麻烦共享下,谢谢!
-
- #include <linux/string.h>
- #include "lcm_drv.h"
- #if defined(BUILD_UBOOT)
- #else
- #include <linux/kernel.h>
- #endif
- // ---------------------------------------------------------------------------
- // Local Constants
- // ---------------------------------------------------------------------------
- #define FRAME_WIDTH (480)
- #define FRAME_HEIGHT (800)
- #define REGFLAG_DELAY 0XFE
- #define REGFLAG_END_OF_TABLE 0xFFF // END OF REGISTERS MARKER
- #define LCM_ID 0x8009
- // ---------------------------------------------------------------------------
- // Local Variables
- // ---------------------------------------------------------------------------
- static LCM_UTIL_FUNCS lcm_util = {0};
- #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
- #define UDELAY(n) (lcm_util.udelay(n))
- #define MDELAY(n) (lcm_util.mdelay(n))
- // ---------------------------------------------------------------------------
- // Local Functions
- // ---------------------------------------------------------------------------
- #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
- #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
- #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
- #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
- #define read_reg lcm_util.dsi_read_reg()
- #define read_reg_v2(cmd,buffer,buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd,buffer,buffer_size)
-
- struct LCM_setting_table {
- unsigned cmd;
- unsigned char count;
- unsigned char para_list[64];
- };
- static struct LCM_setting_table lcm_initialization_setting[] = {
-
- /*
- Note :
- Data ID will depends on the following rule.
-
- count of parameters > 1 => Data ID = 0x39
- count of parameters = 1 => Data ID = 0x15
- count of parameters = 0 => Data ID = 0x05
- Structure Format :
- {DCS command, count of parameters, {parameter list}}
- {REGFLAG_DELAY, milliseconds of time, {}},
- ...
- Setting ending by predefined flag
-
- {REGFLAG_END_OF_TABLE, 0x00, {}}
- */
- #if 0
- {0xF0, 5, {0x55,0xAA,0x52,0x08,0x01}},
- {REGFLAG_DELAY, 10, {}},
- {0xB0, 3, {0x0D, 0x0D, 0x0D}},
- {REGFLAG_DELAY, 10, {}},
- {0xB6, 3, {0x44, 0x44, 0x44}},
- {REGFLAG_DELAY, 10, {}},
- {0xB1, 3, {0x0D, 0x0D, 0x0D}},
- {REGFLAG_DELAY, 10, {}},
- {0xB7, 3, {0x34, 0x34, 0x34}},
- {REGFLAG_DELAY, 10, {}},
- {0xB2, 3, {0x00, 0x00, 0x00}},
- {REGFLAG_DELAY, 10, {}},
- {0xB8, 3, {0x34, 0x34, 0x34}},
- {REGFLAG_DELAY, 10, {}},
- {0xBF, 1, {0x01}},
- {REGFLAG_DELAY, 10, {}},
- {0xB3, 3, {0x0F, 0x0F, 0x0F}},
- {REGFLAG_DELAY, 10, {}},
- {0xB9, 3, {0x34, 0x34, 0x34}},
- {REGFLAG_DELAY, 10, {}},
- {0xB5, 3, {0x08, 0x08, 0x08}},
- {REGFLAG_DELAY, 10, {}},
- {0xC2, 1, {0x03}},
- {REGFLAG_DELAY, 10, {}},
- {0xBA, 3, {0x34, 0x34, 0x34}},
- {REGFLAG_DELAY, 10, {}},
- {0xBC, 3, {0x00, 0x78, 0x00}},
- {REGFLAG_DELAY, 10, {}},
- {0xBD, 3, {0x00, 0x78, 0x00}},
- {REGFLAG_DELAY, 10, {}},
- {0xBE, 2, {0x00, 0x5F}},
- {REGFLAG_DELAY, 10, {}},
- {0xD1, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
- 0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
- 0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
- 0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
- 0x03, 0x33, 0x03, 0x6D }},
- {REGFLAG_DELAY, 10, {}},
- {0xD2, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
- 0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
- 0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
- 0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
- 0x03, 0x33, 0x03, 0x6D }},
- {REGFLAG_DELAY, 10, {}},
-
- {0xD3, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
- 0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
- 0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
- 0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
- 0x03, 0x33, 0x03, 0x6D }},
- {REGFLAG_DELAY, 10, {}},
- {0xD4, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
- 0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
- 0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
- 0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
- 0x03, 0x33, 0x03, 0x6D }},
- {REGFLAG_DELAY, 10, {}},
- {0xD5, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
- 0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
- 0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
- 0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
- 0x03, 0x33, 0x03, 0x6D }},
- {REGFLAG_DELAY, 10, {}},
- {0xD6, 52, {0x00, 0x33, 0x00, 0x34, 0x00, 0x3A, 0x00, 0x4A, 0x00, 0x5C, 0x00, 0x81,
- 0x00, 0xA6, 0x00, 0xE5, 0x01, 0x13, 0x01, 0x54, 0x01, 0x82, 0x01, 0xCA,
- 0x02, 0x00, 0x02, 0x01, 0x02, 0x34, 0x02, 0x67, 0x02, 0x84, 0x02, 0xA4,
- 0x02, 0xB7, 0x02, 0xCF, 0x02, 0xDE, 0x02, 0xF2, 0x02, 0xFE, 0x03, 0x10,
- 0x03, 0x33, 0x03, 0x6D }},
- {REGFLAG_DELAY, 10, {}},
-
- {0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x00}},
- {REGFLAG_DELAY, 10, {}},
- {0xB1, 2, {0xCC, 0x00}},
- {REGFLAG_DELAY, 10, {}},
- {0xB5, 1, {0x50}},
- {REGFLAG_DELAY, 10, {}},
- {0xB6, 1, {0x05}},
- {REGFLAG_DELAY, 10, {}},
- {0xB7, 2, {0x77, 0x77}},
- {REGFLAG_DELAY, 10, {}},
- {0xB8, 4, {0x01, 0x03, 0x03, 0x03}},
- {REGFLAG_DELAY, 10, {}},
- {0xBC, 3, {0x02, 0x00, 0x00}},
- {REGFLAG_DELAY, 10, {}},
- {0xBD, 5, {0x01, 0x84,0x1C,0x1C, 0x00}},
- {REGFLAG_DELAY, 10, {}},
- {0x3a, 1, {0x77}},
- {REGFLAG_DELAY, 10, {}},
- {0xc9, 5, {0xd0, 0x02, 0x50, 0x50, 0x50}},
- {REGFLAG_DELAY, 10, {}},
- {0x35, 1, {0x00}},
- {REGFLAG_DELAY, 10, {}},
-
- // {0x36, 1, {0xfc}},
- // {REGFLAG_DELAY, 10, {}},
- {0x36, 1, {0x00}},
- {REGFLAG_DELAY, 10, {}},
- #endif
- {0x00,1,{0x00}},{0xff,3,{0x80,0x09,0x01}},
- {0x00,1,{0x80}},{0xff,2,{0x80,0x09}},
- {0x00,1,{0x03}},{0xff,1,{0x01}},
- {0x00,1,{0xb4}},{0xc0,1,{0x10}},
- {0x00,1,{0x89}},{0xc4,1,{0x08}},
- {0x00,1,{0xa3}},{0xc0,1,{0x00}},
- {0x00,1,{0x82}},{0xc5,1,{0xa3}},
- {0x00,1,{0x90}},{0xc5,2,{0xd6,0x87}},
- {0x00,1,{0x00}},{0xd8,2,{0x74,0x72}},
- {0x00,1,{0x00}},{0xd9,1,{0x50}},
- {0x00,1,{0x00}},{0xe1,16,{0x09,0x0c,0x12,0x0e,0x08,0x19,0x0c,0x0b,0x01,0x05,0x03,0x07,0x0e,0x26,0x23,0x1b}},
- {0x00,1,{0x00}},{0xe2,16,{0x09,0x0c,0x12,0x0e,0x08,0x19,0x0c,0x0b,0x01,0x05,0x03,0x07,0x0e,0x26,0x23,0x1b}},
- {0x00,1,{0x81}},{0xc1,1,{0x66}},
- {0x00,1,{0xa1}},{0xc1,1,{0x88}},
- {0x00,1,{0x81}},{0xc4,1,{0x83}},
- {0x00,1,{0x92}},{0xc5,1,{0x01}},
- {0x00,1,{0xb1}},{0xc5,1,{0xa9}},
- {0x00,1,{0x80}},{0xce,12,{0x85,0x03,0x00,0x84,0x03,0x00,0x83,0x03,0x00,0x82,0x03,0x00}},
- {0x00,1,{0xa0}},{0xce,14,{0x38,0x02,0x03,0x21,0x00,0x00,0x00,0x38,0x01,0x03,0x22,0x00,0x00,0x00}},
- {0x00,1,{0xb0}},{0xce,14,{0x38,0x00,0x03,0x23,0x00,0x00,0x00,0x30,0x00,0x03,0x24,0x00,0x00,0x00}},
- {0x00,1,{0xc0}},{0xce,14,{0x30,0x01,0x03,0x25,0x00,0x00,0x00,0x30,0x02,0x03,0x26,0x00,0x00,0x00}},
- {0x00,1,{0xd0}},{0xce,14,{0x30,0x03,0x03,0x27,0x00,0x00,0x00,0x30,0x04,0x03,0x28,0x00,0x00,0x00}},
- {0x00,1,{0xc0}},{0xcf,10,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
- {0x00,1,{0xd0}},{0xcf,1,{0x00}},
- {0x00,1,{0xc0}},{0xcb,15,{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00}},
- {0x00,1,{0xd0}},{0xcb,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04}},
- {0x00,1,{0xe0}},{0xcb,10,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
- {0x00,1,{0x80}},{0xcc,10,{0x00,0x00,0x00,0x00,0x0c,0x0a,0x10,0x0e,0x03,0x04}},
- {0x00,1,{0x90}},{0xcc,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b}},
- {0x00,1,{0xa0}},{0xcc,15,{0x09,0x0f,0x0d,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
- {0x00,1,{0xb0}},{0xcc,10,{0x00,0x00,0x00,0x00,0x0d,0x0f,0x09,0x0b,0x02,0x01}},
- {0x00,1,{0xc0}},{0xcc,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e}},
- {0x00,1,{0xd0}},{0xcc,15,{0x10,0x0a,0x0c,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
- {0x00,1,{0x00}},{0xff,3,{0xff,0xff,0xff}},
- {0x3a,1,{0x77}},
- #ifdef DISPLAY_DIRECTION_0_MODE
- DCS_SHORT_1P(0x36,0x00);// Display Direction 0
- DCS_SHORT_1P(0x35,0x00);// TE( Fmark ) Signal On
- DCS_LONG_2P(0x44,0x01,0x22);// TE( Fmark ) Signal Output Position
- #endif
- #ifdef DISPLAY_DIRECTION_180_MODE
- DCS_SHORT_1P(0x36,0xD0);// Display Direction 180
- DCS_SHORT_1P(0x35,0x00);// TE( Fmark ) Signal On
- DCS_LONG_2P(0x44,0x01,0xFF);// TE( Fmark ) Signal Output Position
- #endif
- #ifdef LCD_BACKLIGHT_CONTROL_MODE
- DCS_SHORT_1P(0x51,0xFF);// Backlight Level Control
- DCS_SHORT_1P(0x53,0x2C);// Backlight On
- DCS_SHORT_1P(0x55,0x00);// CABC Function Off
- #endif
- {0x11,0,{}},
- {REGFLAG_DELAY, 50, {}},
- {0x29,0,{}},
- {REGFLAG_DELAY, 200, {}},
- {0x2c,0,{}},
- {REGFLAG_DELAY, 120, {}},
- // Note
- // Strongly recommend not to set Sleep out / Display On here. That will cause messed frame to be shown as later the backlight is on.
- // Setting ending by predefined flag
-
- {REGFLAG_END_OF_TABLE, 0x00, {}}
- };
- static struct LCM_setting_table lcm_set_window[] = {
- {0x2A, 4, {0x00, 0x00, (FRAME_WIDTH>>8), (FRAME_WIDTH&0xFF)}},
- {0x2B, 4, {0x00, 0x00, (FRAME_HEIGHT>>8), (FRAME_HEIGHT&0xFF)}},
- {REGFLAG_END_OF_TABLE, 0x00, {}}
- };
- static struct LCM_setting_table lcm_sleep_out_setting[] = {
- // Sleep Out
- {0x11, 1, {0x00}},
- {REGFLAG_DELAY, 120, {}},
- // Display ON
- {0x29, 1, {0x00}},
- {REGFLAG_DELAY, 20, {}},
- {REGFLAG_END_OF_TABLE, 0x00, {}}
- };
- static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
- // Display off sequence
- {0x28, 1, {0x00}},
- // Sleep Mode On
- {0x10, 1, {0x00}},
- {REGFLAG_DELAY, 120, {}},
- {REGFLAG_END_OF_TABLE, 0x00, {}}
- };
- static struct LCM_setting_table lcm_backlight_level_setting[] = {
- {0x51, 1, {0xFF}},
- {REGFLAG_END_OF_TABLE, 0x00, {}}
- };
- static struct LCM_setting_table lcm_backlight_mode_setting[] = {
- {0x55, 1, {0x1}},
- {REGFLAG_END_OF_TABLE, 0x00, {}}
- };
- static void init_lcm_registers(void)
- {
- unsigned int data_array[16];
- //{0x00,1,{0x00}},{0xff,3,{0x80,0x09,0x01}},
- data_array[0]=0x00001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00043902;
- data_array[1]=0x010980ff;
- dsi_set_cmdq(data_array, 2, 1);
-
- //{0x00,1,{0x80}},{0xff,2,{0x80,0x09}},
- data_array[0]=0x80001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00033902;
- data_array[1]=0x000980ff;
- dsi_set_cmdq(data_array, 2, 1);
-
- //{0x00,1,{0x03}},{0xff,1,{0x01}},
- data_array[0]=0x03001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x01ff1500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0xb4}},{0xc0,1,{0x10}},
- data_array[0]=0xb4001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x20c01500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0x89}},{0xc4,1,{0x08}},
- data_array[0]=0x89001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x08c41500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0xa3}},{0xc0,1,{0x00}},
- data_array[0]=0xa3001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00c01500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0x82}},{0xc5,1,{0xa3}},
- data_array[0]=0x82001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0xa3c51500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0x90}},{0xc5,2,{0xd6,0x87}},
- data_array[0]=0x90001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00033902;
- data_array[1]=0x0087d6c5;
- dsi_set_cmdq(data_array, 2, 1);
-
- //{0x00,1,{0x00}},{0xd8,2,{0x74,0x72}},
- data_array[0]=0x00001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00033902;
- data_array[1]=0x007274d8;
- dsi_set_cmdq(data_array, 2, 1);
-
- //{0x00,1,{0x00}},{0xd9,1,{0x50}},
- data_array[0]=0x00001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x50d91500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0x00}},{0xe1,16,{0x09,0x0c,0x12,0x0e,0x08,0x19,0x0c,0x0b,0x01,0x05,0x03,0x07,0x0e,0x26,0x23,0x1b}},
- data_array[0]=0x00001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00113902;
- data_array[1]=0x120c09e1;
- data_array[2]=0x0c19080e;
- data_array[3]=0x0305010b;
- data_array[4]=0x23260e07;
- data_array[5]=0x0000001b;
- dsi_set_cmdq(data_array, 6, 1);
- //{0x00,1,{0x00}},{0xe2,16,{0x09,0x0c,0x12,0x0e,0x08,0x19,0x0c,0x0b,0x01,0x05,0x03,0x07,0x0e,0x26,0x23,0x1b}},
- data_array[0]=0x00001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00113902;
- data_array[1]=0x120c09e2;
- data_array[2]=0x0c19080e;
- data_array[3]=0x0305010b;
- data_array[4]=0x23260e07;
- data_array[5]=0x0000001b;
- dsi_set_cmdq(data_array, 6, 1);
- //{0x00,1,{0x81}},{0xc1,1,{0x66}},
- data_array[0]=0x81001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x66c11500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0xa1}},{0xc1,1,{0x88}},
- data_array[0]=0xa1001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x88c11500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0x81}},{0xc4,1,{0x83}},
- data_array[0]=0x81001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x83c41500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0x92}},{0xc5,1,{0x01}},
- data_array[0]=0x92001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x01c51500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0xb1}},{0xc5,1,{0xa9}},
- data_array[0]=0xb1001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0xa9c51500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0x80}},{0xce,12,{0x85,0x03,0x00,0x84,0x03,0x00,0x83,0x03,0x00,0x82,0x03,0x00}},
- data_array[0]=0x80001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000d3902;
- data_array[1]=0x000385ce;
- data_array[2]=0x83000384;
- data_array[3]=0x03820003;
- data_array[4]=0x00000000;
- dsi_set_cmdq(data_array, 5, 1);
- //{0x00,1,{0xa0}},{0xce,14,{0x38,0x02,0x03,0x21,0x00,0x00,0x00,0x38,0x01,0x03,0x22,0x00,0x00,0x00}},
- data_array[0]=0xa0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000d3902;
- data_array[1]=0x030238ce;
- data_array[2]=0x00000021;
- data_array[3]=0x22030138;
- data_array[4]=0x00000000;
- dsi_set_cmdq(data_array, 5, 1);
-
-
- //{0x00,1,{0xb0}},{0xce,14,{0x38,0x00,0x03,0x23,0x00,0x00,0x00,0x30,0x00,0x03,0x24,0x00,0x00,0x00}},
- data_array[0]=0xb0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000f3902;
- data_array[1]=0x030038ce;
- data_array[2]=0x00000023;
- data_array[3]=0x24030030;
- data_array[4]=0x23000000;
- dsi_set_cmdq(data_array, 5, 1);
-
- //{0x00,1,{0xc0}},{0xce,14,{0x30,0x01,0x03,0x25,0x00,0x00,0x00,0x30,0x02,0x03,0x26,0x00,0x00,0x00}},
- data_array[0]= 0xc0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000f3902;
- data_array[1]=0x030130ce;
- data_array[2]=0x00000025;
- data_array[3]=0x26030230;
- data_array[4]=0x23000000;
- dsi_set_cmdq(data_array, 5, 1);
-
- //{0x00,1,{0xd0}},{0xce,14,{0x30,0x03,0x03,0x27,0x00,0x00,0x00,0x30,0x04,0x03,0x28,0x00,0x00,0x00}},
- data_array[0]= 0xd0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000f3902;
- data_array[1]=0x030330ce;
- data_array[2]=0x00000027;
- data_array[3]=0x28030430;
- data_array[4]=0x23000000;
- dsi_set_cmdq(data_array, 5, 1);
-
- //{0x00,1,{0xc0}},{0xcf,10,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
- data_array[0]= 0xc0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000b3902;
- data_array[1]=0x000000cf;
- data_array[2]=0x00000000;
- data_array[3]=0x28000000;
- dsi_set_cmdq(data_array, 4, 1);
-
- //{0x00,1,{0xd0}},{0xcf,1,{0x00}},
- data_array[0]=0xd0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00cf1500;
- dsi_set_cmdq(data_array, 1, 1);
-
- //{0x00,1,{0xc0}},{0xcb,15,{0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00}},
- data_array[0]=0xc0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00103902;
- data_array[1]=0x000000cb;
- data_array[2]=0x04040400;
- data_array[3]=0x00040404;
- data_array[4]=0x00000000;
- dsi_set_cmdq(data_array, 5, 1);
- //{0x00,1,{0xd0}},{0xcb,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04}},
- data_array[0]=0xd0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00103902;
- data_array[1]=0x000000cb;
- data_array[2]=0x00000000;
- data_array[3]=0x04040000;
- data_array[4]=0x04040404;
- dsi_set_cmdq(data_array, 5, 1);
- //{0x00,1,{0xe0}},{0xcb,10,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
- data_array[0]=0xe0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000b3902;
- data_array[1]=0x000000cb;
- data_array[2]=0x00000000;
- data_array[3]=0x04000000;
- dsi_set_cmdq(data_array, 4, 1);
-
- //{0x00,1,{0x80}},{0xcc,10,{0x00,0x00,0x00,0x00,0x0c,0x0a,0x10,0x0e,0x03,0x04}},
- data_array[0]=0x80001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000b3902;
- data_array[1]=0x000000cc;
- data_array[2]=0x100a0c00;
- data_array[3]=0x0404030e;
- dsi_set_cmdq(data_array, 4, 1);
-
- //{0x00,1,{0x90}},{0xcc,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b}},
- data_array[0]=0x90001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00103902;
- data_array[1]=0x000000cc;
- data_array[2]=0x00000000;
- data_array[3]=0x00000000;
- data_array[4]=0x0b000000;
- dsi_set_cmdq(data_array, 5, 1);
- //{0x00,1,{0xa0}},{0xcc,15,{0x09,0x0f,0x0d,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
- data_array[0]=0xa0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00103902;
- data_array[1]=0x0d0f09cc;
- data_array[2]= 0x00000201;
- data_array[3]=0x00000000;
- data_array[4]=0x00000000;
- dsi_set_cmdq(data_array, 5, 1);
- //{0x00,1,{0xb0}},{0xcc,10,{0x00,0x00,0x00,0x00,0x0d,0x0f,0x09,0x0b,0x02,0x01}},
- data_array[0]=0xb0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x000b3902;
- data_array[1]=0x000000cc;
- data_array[2]=0x090f0d00;
- data_array[3]=0x0001020b;
- dsi_set_cmdq(data_array, 4, 1);
-
- //{0x00,1,{0xc0}},{0xcc,15,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e}},
- data_array[0]=0xc0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00103902;
- data_array[1]=0x000000cc;
- data_array[2]= 0x00000000;
- data_array[3]=0x00000000;
- data_array[4]=0x00000000;
- dsi_set_cmdq(data_array, 5, 1);
-
- //{0x00,1,{0xd0}},{0xcc,15,{0x10,0x0a,0x0c,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
- data_array[0]=0xd0001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00103902;
- data_array[1]=0x0c0a10cc;
- data_array[2]= 0x00000304;
- data_array[3]=0x00000000;
- data_array[4]=0x00000000;
- dsi_set_cmdq(data_array, 5, 1);
-
- //{0x00,1,{0x00}},{0xff,3,{0xff,0xff,0xff}},
- data_array[0]=0x00001500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00043902;
- data_array[1]=0xffffffff;
- dsi_set_cmdq(data_array, 2, 1);
- //{0x3a,1,{0x77}},
- data_array[0]=0x773a1500;
- dsi_set_cmdq(data_array, 1, 1);
- #ifdef DISPLAY_DIRECTION_0_MODE
- //DCS_SHORT_1P(0x36,0x00);// Display Direction 0
- //DCS_SHORT_1P(0x35,0x00);// TE( Fmark ) Signal On
- //DCS_LONG_2P(0x44,0x01,0x22);// TE( Fmark ) Signal Output Position
- data_array[0]=0x00361500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00351500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00033902;
- data_array[0]=0x00220144;
- dsi_set_cmdq(data_array, 2, 1);
- #endif
- data_array[0]=0x00361500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00351500;
- dsi_set_cmdq(data_array, 1, 1);
- #ifdef DISPLAY_DIRECTION_180_MODE
- //DCS_SHORT_1P(0x36,0xD0);// Display Direction 180
- //DCS_SHORT_1P(0x35,0x00);// TE( Fmark ) Signal On
- //DCS_LONG_2P(0x44,0x01,0xFF);// TE( Fmark ) Signal Output Position
- data_array[0]=0xd0361500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00351500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00033902;
- data_array[0]=0x00ff0144;
- dsi_set_cmdq(data_array, 2, 1);
- #endif
- #ifdef LCD_BACKLIGHT_CONTROL_MODE
- //DCS_SHORT_1P(0x51,0xFF);// Backlight Level Control
- //DCS_SHORT_1P(0x53,0x2C);// Backlight On
- //DCS_SHORT_1P(0x55,0x00);// CABC Function Off
- data_array[0]=0xff511500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x2c531500;
- dsi_set_cmdq(data_array, 1, 1);
- data_array[0]=0x00551500;
- dsi_set_cmdq(data_array, 1, 1);
- #endif
- }
- static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
- {
- unsigned int i;
- for(i = 0; i < count; i++) {
-
- unsigned cmd;
- cmd = table[i].cmd;
-
- switch (cmd) {
-
- case REGFLAG_DELAY :
- MDELAY(table[i].count);
- break;
-
- case REGFLAG_END_OF_TABLE :
- break;
-
- default:
- dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
- }
- }
-
- }
- // ---------------------------------------------------------------------------
- // LCM Driver Implementations
- // ---------------------------------------------------------------------------
- static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
- {
- memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
- }
- static void lcm_get_params(LCM_PARAMS *params)
- {
- memset(params, 0, sizeof(LCM_PARAMS));
-
- params->type = LCM_TYPE_DSI;
- params->width = FRAME_WIDTH;
- params->height = FRAME_HEIGHT;
- // enable tearing-free
- params->dbi.te_mode = LCM_DBI_TE_MODE_VSYNC_ONLY;
- params->dbi.te_edge_polarity = LCM_POLARITY_RISING;
- params->dsi.mode = CMD_MODE;
- // DSI
- /* Command mode setting */
- params->dsi.LANE_NUM = LCM_TWO_LANE;
- //The following defined the fomat for data coming from LCD engine.
- params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
- params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
- params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
- params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
- // Highly depends on LCD driver capability.
- params->dsi.packet_size = 256;
- // Video mode setting
- params->dsi.PS = LCM_PACKED_PS_24BIT_RGB888;
- params->dsi.word_count = 480*3;
- params->dsi.vertical_sync_active = 2;
- params->dsi.vertical_backporch = 2;
- params->dsi.vertical_frontporch = 2;
- params->dsi.vertical_active_line = 800;
-
- params->dsi.line_byte = 2180; // 2256 = 752*3
- params->dsi.horizontal_sync_active_byte = 26;
- params->dsi.horizontal_backporch_byte = 206;
- params->dsi.horizontal_frontporch_byte = 206;
- params->dsi.rgb_byte = (480*3+6);
-
- params->dsi.horizontal_sync_active_word_count = 20;
- params->dsi.horizontal_backporch_word_count = 200;
- params->dsi.horizontal_frontporch_word_count = 200;
- // Bit rate calculation
- params->dsi.pll_div1 = 38; // fref=26MHz, fvco=fref*(div1+1) (div1=0~63, fvco=500MHZ~1GHz)
- params->dsi.pll_div2 = 1; // div2=0~15: fout=fvo/(2*div2)
-
-
- }
- static void lcm_init(void)
- {
- SET_RESET_PIN(1);
- SET_RESET_PIN(0);
- MDELAY(10 );
- SET_RESET_PIN(1);
- MDELAY(10 );
- //push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
- init_lcm_registers();
- }
- static void lcm_suspend(void)
- {
- unsigned int data_array[16];
-
- data_array[0]=0x00280500;
- dsi_set_cmdq(&data_array, 1, 1);
- //MDELAY(50);
-
- data_array[0]=0x00100500;
- dsi_set_cmdq(&data_array, 1, 1);
- MDELAY(150);
- //push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
- }
- static void lcm_resume(void)
- {
- unsigned int data_array[16];
- data_array[0]=0x00110500;
- dsi_set_cmdq(&data_array, 1, 1);
- MDELAY(150);
-
- data_array[0]=0x00290500;
- dsi_set_cmdq(&data_array, 1, 1);
- //push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1);
- }
- static void lcm_update(unsigned int x, unsigned int y,
- unsigned int width, unsigned int height)
- {
- unsigned int x0 = x;
- unsigned int y0 = y;
- unsigned int x1 = x0 + width - 1;
- unsigned int y1 = y0 + height - 1;
- unsigned char x0_MSB = ((x0>>8)&0xFF);
- unsigned char x0_LSB = (x0&0xFF);
- unsigned char x1_MSB = ((x1>>8)&0xFF);
- unsigned char x1_LSB = (x1&0xFF);
- unsigned char y0_MSB = ((y0>>8)&0xFF);
- unsigned char y0_LSB = (y0&0xFF);
- unsigned char y1_MSB = ((y1>>8)&0xFF);
- unsigned char y1_LSB = (y1&0xFF);
- unsigned int data_array[16];
- data_array[0]= 0x00053902;
- data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
- data_array[2]= (x1_LSB);
- data_array[3]= 0x00053902;
- data_array[4]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b;
- data_array[5]= (y1_LSB);
- data_array[6]= 0x002c3909;
- dsi_set_cmdq(&data_array, 7, 0);
- }
- static void lcm_setbacklight(unsigned int level)
- {
- unsigned int default_level = 0;
- unsigned int mapped_level = 0;
- //for LGE backlight IC mapping table
- if(level > 255)
- level = 255;
- if(level >0)
- mapped_level = default_level+(level)*(255-default_level)/(255);
- else
- mapped_level=0;
- // Refresh value of backlight level.
- lcm_backlight_level_setting[0].para_list[0] = mapped_level;
- push_table(lcm_backlight_level_setting, sizeof(lcm_backlight_level_setting) / sizeof(struct LCM_setting_table), 1);
- }
- //static void lcm_setbacklight_mode(unsigned int mode)
- //{
- // lcm_backlight_mode_setting[0].para_list[0] = mode;
- // push_table(lcm_backlight_mode_setting, sizeof(lcm_backlight_mode_setting) / sizeof(struct LCM_setting_table), 1);
- //}
- static void lcm_setpwm(unsigned int divider)
- {
- // TBD
- }
- static unsigned int lcm_getpwm(unsigned int divider)
- {
- // ref freq = 15MHz, B0h setting 0x80, so 80.6% * freq is pwm_clk;
- // pwm_clk / 255 / 2(lcm_setpwm() 6th params) = pwm_duration = 23706
- unsigned int pwm_clk = 23706 / (1<<divider);
- return pwm_clk;
- }
- static unsigned int otm8009a_cmp_id(void)
- {
- unsigned int id=0;
- unsigned char buffer[2];
- unsigned int array[16];
- SET_RESET_PIN(1);
- SET_RESET_PIN(0);
- MDELAY(25);
- SET_RESET_PIN(1);
- MDELAY(50);
- array[0]=0x00043902;
- array[1]=0x010980ff;
- array[2]=0x80001500;
- array[3]=0x00033902;
- array[4]=0x010980ff;
- dsi_set_cmdq(array, 5, 1);
- MDELAY(10);
- array[0] = 0x00023700;// set return byte number
- dsi_set_cmdq(array, 1, 1);
- array[0] = 0x02001500;
- dsi_set_cmdq(array, 1, 1);
- read_reg_v2(0xD2, &buffer, 2);
- id = buffer[0]<<8 |buffer[1];
- #if defined(BUILD_UBOOT)
- //printf("[UBOOT]lcm_compare_id:LCM ID=%x,%x,x%\n",buffer[0],buffer[1],id);
- #else
- //printk("[UBOOT]lcm_compare_id:LCM ID=%x,%x,x%\n",buffer[0],buffer[1],id);
- #endif
- return (LCM_ID == id)?1:0;
- }
- // ---------------------------------------------------------------------------
- // Get LCM Driver Hooks
- // ---------------------------------------------------------------------------
- LCM_DRIVER otm8009a_dsi_lcm_drv =
- {
- .name = "otm8009a_dsi",
- .set_util_funcs = lcm_set_util_funcs,
- .get_params = lcm_get_params,
- .init = lcm_init,
- .suspend = lcm_suspend,
- .resume = lcm_resume,
- .update = lcm_update,
- .set_backlight = lcm_setbacklight,
- // .set_backlight_mode = lcm_setbacklight_mode,
- //.set_pwm = lcm_setpwm,
- //.get_pwm = lcm_getpwm
- .compare_id = otm8009a_cmp_id,
- };
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2008
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- #ifdef BUILD_UBOOT
- #define ENABLE_DSI_INTERRUPT 0
- #include <asm/arch/disp_drv_platform.h>
- #else
- #define ENABLE_DSI_INTERRUPT 1
- #include <linux/delay.h>
- #include <disp_drv_log.h>
- #include <linux/time.h>
- #include <linux/string.h>
- #include <linux/spinlock.h>
- #include <mach/mt6577_typedefs.h>
- #include <mach/mt6577_reg_base.h>
- #include <mach/mt6577_irq.h>
- #include <mach/mt_gpio.h>
- #include "mach/mt6577_clock_manager.h"
- #include <mach/mt6577_boot.h>
- #include "lcd_reg.h"
- #include "lcd_drv.h"
- #include "dpi_reg.h"
- #include "dpi_drv.h"
- #include "dsi_reg.h"
- #include "dsi_drv.h"
- #endif
- #if ENABLE_DSI_INTERRUPT
- #include <linux/sched.h>
- #include <linux/interrupt.h>
- #include <linux/wait.h>
- #include <mach/irqs.h>
- #include "mtkfb.h"
- static wait_queue_head_t _dsi_wait_queue;
- static wait_queue_head_t _dsi_dcs_read_wait_queue;
- #endif
- /*
- #define PLL_BASE (0xF0060000)
- #define DSI_PHY_BASE (0xF0060B00)
- #define DSI_BASE (0xF0140000)
- */
- //#define PWR_OFF (APCONFIG_BASE + 0x0304)
- //#define GRAPH1_PDN (1 << 3)
- #define G1_MEM_PDN (APCONFIG_BASE + 0x0060)
- #define G1_MEM_DSI (1)
- #ifdef BUILD_UBOOT
- #define GRAPH1SYS_CG_SET (GMC1_BASE + 0x320)
- #define GRAPH1SYS_CG_CLR (GMC1_BASE + 0x340)
- #else
- #define GRAPH1SYS_CG_SET (MMSYS1_CONFIG_BASE + 0x320)
- #define GRAPH1SYS_CG_CLR (MMSYS1_CONFIG_BASE + 0x340)
- #endif
- #define GRAPH1SYS_CG_DSI (1 << 28)
- #if !(defined(CONFIG_MT6577_FPGA) || defined(BUILD_UBOOT))
- #define DSI_MIPI_API
- #endif
- static PDSI_REGS const DSI_REG = (PDSI_REGS)(DSI_BASE);
- static PDSI_PHY_REGS const DSI_PHY_REG = (PDSI_PHY_REGS)(MIPI_CONFG_BASE+0x800);
- static PDSI_CMDQ_REGS const DSI_CMDQ_REG = (PDSI_CMDQ_REGS)(DSI_BASE+0x180);
- static PLCD_REGS const LCD_REG = (PLCD_REGS)(LCD_BASE);
- static PDPI_REGS const DPI_REG = (PDPI_REGS)(DPI_BASE);
- static MIPITX_CFG0_REG mipitx_con0;
- static MIPITX_CFG1_REG mipitx_con1;
- static MIPITX_CFG3_REG mipitx_con3;
- static MIPITX_CFG6_REG mipitx_con6;
- static MIPITX_CFG8_REG mipitx_con8;
- static MIPITX_CFG9_REG mipitx_con9;
- typedef struct
- {
- DSI_REGS regBackup;
- unsigned int bit_time_ns;
- unsigned int vfp_period_us;
- unsigned int vsa_vs_period_us;
- unsigned int vsa_hs_period_us;
- unsigned int vsa_ve_period_us;
- unsigned int vbp_period_us;
- void (*pIntCallback)(DISP_INTERRUPT_EVENTS);
- } DSI_CONTEXT;
- static bool s_isDsiPowerOn = FALSE;
- bool is_needReConfig = true;
- static DSI_CONTEXT _dsiContext;
- #ifndef BUILD_UBOOT
- DEFINE_SPINLOCK(g_handle_esd_lock);
- static bool dsi_esd_recovery = false;
- static bool dsi_noncont_clk_enabled = false;
- static unsigned int dsi_noncont_clk_period = 1;
- static bool dsi_int_te_enabled = false;
- static unsigned int dsi_int_te_period = 1;
- static unsigned int dsi_dpi_isr_count = 0;
- unsigned long g_handle_esd_flag;
- #endif
- #ifdef BUILD_UBOOT
- static long int get_current_time_us(void)
- {
- return 0; ///TODO: fix me
- }
- #else
- static long int get_current_time_us(void)
- {
- struct timeval t;
- do_gettimeofday(&t);
- return (t.tv_sec & 0xFFF) * 1000000 + t.tv_usec;
- }
- #endif
- static void lcm_mdelay(UINT32 ms)
- {
- udelay(1000 * ms);
- }
- #if ENABLE_DSI_INTERRUPT
- static irqreturn_t _DSI_InterruptHandler(int irq, void *dev_id)
- {
- DSI_INT_STATUS_REG status = DSI_REG->DSI_INTSTA;
- if (status.RD_RDY)
- {
- ///write clear RD_RDY interrupt
- DSI_REG->DSI_INTSTA.RD_RDY = 1;
- /// write clear RD_RDY interrupt must be before DSI_RACK
- /// because CMD_DONE will raise after DSI_RACK,
- /// so write clear RD_RDY after that will clear CMD_DONE too
-
- do
- {
- ///send read ACK
- DSI_REG->DSI_RACK.DSI_RACK = 1;
- } while(DSI_REG->DSI_STA.BUSY);
- wake_up_interruptible(&_dsi_dcs_read_wait_queue);
- if(_dsiContext.pIntCallback)
- _dsiContext.pIntCallback(DISP_DSI_READ_RDY_INT);
- }
- if (status.CMD_DONE)
- {
- DSI_REG->DSI_INTSTA.CMD_DONE = 1;
- // Go back to LP mode.
- DSI_clk_HS_mode(0);
- wake_up_interruptible(&_dsi_wait_queue);
- if(_dsiContext.pIntCallback)
- _dsiContext.pIntCallback(DISP_DSI_CMD_DONE_INT);
- }
- return IRQ_HANDLED;
- }
- #endif
- static BOOL _IsEngineBusy(void)
- {
- DSI_STATUS_REG status;
- status = DSI_REG->DSI_STA;
-
- if (status.BUSY || status.ERR_MSG)
- return TRUE;
- return FALSE;
- }
- #if 0
- static BOOL _IsCMDQBusy(void)
- {
- DSI_INT_STATUS_REG INT_status;
- INT_status=DSI_REG->DSI_INTSTA;
- if (!INT_status.CMD_DONE)
- {
- DISP_LOG_PRINT(ANDROID_LOG_WARN, "DSI", " DSI CMDQ status BUSY !\n");
-
- return TRUE;
- }
- return FALSE;
- }
- #endif
- static void _WaitForEngineNotBusy(
