6572平台+HX8394D 屏幕无法点亮,求帮忙看看
时间:10-02
整理:3721RD
点击:
72的代码已经破解,目前尝试点亮 HX8394D 8寸屏 分辨率 800*1280 竖屏。目前显示如下:驱动代码如下:
#define FRAME_WIDTH (800)
#define FRAME_HEIGHT (1280)
#define REGFLAG_DELAY 0XFE
#define REGFLAG_END_OF_TABLE 0xFF // END OF REGISTERS MARKER
#define LCM_DSI_CMD_MODE 0
// ---------------------------------------------------------------------------
// Local Variables
// ---------------------------------------------------------------------------
static LCM_UTIL_FUNCS lcm_util;
#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_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#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(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#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[120];
};
static unsigned int lcm_read_id(void);
#if 1
static struct LCM_setting_table old_lcm_initialization_setting[] = {
{0xB9, 3, {0xFF, 0x83, 0x94} },
{0xBA, 2, {0x72,0x83} },
{0xB1, 15,
{0x6c, 0x15, 0x15, 0x24, 0xe4, 0x11, 0xf1, 0x80, 0xe4, 0xD7, 0x23, 0x80, 0xC0, 0xD2,
0x58} },
{0xB2, 11, {0x00, 0x64, 0x10, 0x07, 0X20, 0x1C, 0x08, 0x08, 0x1C, 0x4D, 0x00} },
{0xB4, 12,
{0x00, 0xFF, 0x03, 0x5a, 0x03, 0x5a, 0x03, 0x5a, 0x01, 0x6a, 0x01, 0x6a} },
{0xB6, 2, {0x6F, 0x6F} },
{0xCC, 1, {0x01} },
{0xD3, 30,
{0x00, 0x06, 0x00, 0x40, 0x1a, 0x08, 0x00, 0x32, 0x10, 0x07, 0x00, 0x07, 0x54, 0x15, 0x0f,
0x05, 0x04, 0x02, 0x12, 0x10, 0x05, 0x07, 0x33, 0x33, 0x0b, 0x0b, 0x37, 0x10, 0x07, 0x07} },
{0xD5, 44,
{0x19, 0x19, 0x18, 0x18, 0x1a, 0x1a, 0x1b, 0x1b, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02,
0x03, 0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x22, 0x23, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 44,
{0x18, 0x18, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, 0x03, 0x02, 0x01, 0x00, 0x07, 0x06, 0x05,
0x04, 0x23, 0x22, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x21, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xE0, 42,
{0x00, 0x06, 0x0C, 0x31, 0x34, 0x3F, 0x1D, 0x41, 0x06, 0x0A, 0x0C, 0x17, 0x0F, 0x12, 0x15,
0x13, 0x14, 0x07, 0x12, 0x15, 0x16, 0x00, 0x06, 0x0B, 0X30, 0x34, 0x3F, 0x1D, 0x40, 0x07,
0x0A, 0x0D, 0x18, 0x0E, 0x12, 0x14, 0x12, 0x14, 0x08, 0x13, 0x14, 0x19} },
{0xd2, 1, {0x55} },
{0xC0, 2, {0x30, 0x14} },
{0xbf, 3, {0x41, 0x0e,0x01} },
{0xC7, 4, {0x00, 0xc0,0x40,0xc0} },
{0xdf, 1, {0x8e} },
{0x11, 0, {} },
{REGFLAG_DELAY, 250, {} },
{0x29, 0, {} },
{REGFLAG_DELAY, 50, {} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
#endif
static LCM_setting_table_V3 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, {}}
*/
{0x39, 0xB9, 3 ,{0xFF, 0x83, 0x94}},
{0x39, 0xBA, 2 ,{0x72, 0x83}},
{0x39, 0xB1, 15 ,{0x6c, 0x12, 0x12,
0x26, 0x04, 0x11, 0xf1,
0x81, 0x3a, 0x54, 0x23,
0x80, 0xc0, 0xd2, 0x58}},
{0x39, 0xB2, 11 ,{0x00,0x64,0x0E,0x0D,
0x22,0x1C,0x08,0x08,0x1C,0x4D,0x00}},
{0x39, 0xB4, 12 ,{0x00,0xFF,0x51,0x5A,
0x59,0x5A,0x03,0x5A,0x01,
0x70,0x01,0x70}},
{0x15, 0xBc, 1 ,{0x07}},
{0x39, 0xBF, 3 ,{0x41,0x0E,0x01}},
{0x39, 0xd3, 37 ,{0x00,0x0F,0x00,0x40,
0x07,0x10,0x00,0x08,0x10,
0x08,0x00,0x08,0x54,0x15,
0x0E,0x05,0x0E,0x02,0x15,
0x06,0x05,0x06,0x47,0x44,
0x0A,0x0A,0x4B,0x10,0x07,
0x07,0x08,0x00,0x00,0x00,
0x0A,0x00,0x01}},
{0x39, 0xD5, 44 ,{0x1A,0x1A,0x1B,0x1B,
0x00,0x01,0x02,0x03,0x04,
0x05,0x06,0x07,0x08,0x09,
0x0A,0x0B,0x24,0x25,0x18,
0x18,0x26,0x27,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x20,
0x21,0x18,0x18,0x18,0x18}},
{0x39, 0xD6, 44 ,{0x1A,0x1A,0x1B,0x1B,
0x0B,0x0A,0x09,0x08,0x07,
0x06,0x05,0x04,0x03,0x02,
0x01,0x00,0x21,0x20,0x58,
0x58,0x27,0x26,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x25,
0x24,0x18,0x18,0x18,0x18}},
{0x15, 0xCC, 1 ,{0x09}},
{0x39, 0xC0, 2 ,{0x30, 0x14}},
{0x39, 0xC7, 4 ,{0x00,0xC0,0x40,0xC0}},
{0x39, 0xb6, 2 ,{0x6B,0x6B}},
{0x39, 0xE0, 42 ,{0x00,0x0A,0x0F,0x24,
0x3A,0x3F,0x20,0x3B,0x08,
0x0D,0x0E,0x16,0x0F,0x12,
0x15,0x13,0x15,0x09,0x12,
0x12,0x18,0x00,0x0A,0x0F,
0x24,0x3A,0x3F,0x20,0x3B,
0x08,0x0D,0x0E,0x16,0x0F,
0x12,0x15,0x13,0x15,0x09,
0x12,0x12,0x18}},
{0x15, 0xbd, 1 ,{0x00}},
{0x39, 0xC1, 43 ,{0x01,0x00,0x06,0x0C,
0x14,0x1D,0x27,0x2F,0x38,
0x41,0x49,0x51,0x59,0x61,
0x69,0x71,0x79,0x81,0x89,
0x91,0x99,0xA1,0xA9,0xB2,
0xB9,0xC1,0xCA,0xD1,0xD8,
0xE2,0xEA,0xF0,0xF7,0xFF,
0x38,0xFC,0x3F,0x0B,0xC1,
0x13,0xF1,0x0D,0xC0}},
{0x15, 0xbd, 1 ,{0x01}},
{0x39, 0xC1, 42 ,{0x00,0x06,0x0C,0x14,
0x1D,0x27,0x2F,0x38,0x41,
0x49,0x51,0x59,0x61,0x69,
0x71,0x79,0x81,0x89,0x91,
0x99,0xA1,0xA9,0xB2,0xB9,
0xC1,0xCA,0xD1,0xD8,0xE2,
0xEA,0xF0,0xF7,0xFF,0x38,
0xFC,0x3F,0x0B,0xC1,0x13,
0xF1,0x0D,0xC0}},
{0x15, 0xbd, 1 ,{0x02}},
{0x39, 0xC1, 42 ,{0x00,0x06,0x0C,0x14,
0x1D,0x27,0x2F,0x38,0x41,
0x49,0x51,0x59,0x61,0x69,
0x71,0x79,0x81,0x89,0x91,
0x99,0xA1,0xA9,0xB2,0xB9,
0xC1,0xCA,0xD1,0xD8,0xE2,
0xEA,0xF0,0xF7,0xFF,0x38,
0xFC,0x3F,0x0B,0xC1,0x13,
0xF1,0x0D,0xC0}},
{0x15, 0x36, 1 ,{0x03}},
{0x05, 0x11,0,{}},//
{REGFLAG_ESCAPE_ID,REGFLAG_DELAY_MS_V3,120,{}},
{0x05, 0x29,0,{}},//
{REGFLAG_ESCAPE_ID,REGFLAG_DELAY_MS_V3,20,{}},
/* FIXME */
/*
params->dsi.horizontal_sync_active = 0x16;// 50 2
params->dsi.horizontal_backporch = 0x38;
params->dsi.horizontal_frontporch = 0x18;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.horizontal_blanking_pixel =0; //lenovo:fix flicker issue
//params->dsi.LPX=8;
*/
};
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
// Display off sequence
{0x28, 0, {0x00}},
{REGFLAG_DELAY, 120, {}},
// Sleep Mode On
{0x10, 0, {0x00}},
{REGFLAG_DELAY, 20, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static void init_lcm_registers(void)
{
unsigned int data_array[16];
data_array[0]=0x00043902;
data_array[1]=0x9483FFB9;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00033902;
data_array[1]=0x008372BA;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
//BAh,1st para=73,2nd para=43,7th para=09,8th para=40,9th para=10,10th para=00,11th para=00
data_array[0]=0x00103902;
data_array[1]=0x110B6CB1;
data_array[2]=0xF1110437;//vgl=-5.55*2
data_array[3]=0x2395E380;
data_array[4]=0x18D2C080;
dsi_set_cmdq(data_array, 5, 1);
MDELAY(10);
data_array[0]=0x000C3902;
data_array[1]=0x0E6400B2;
data_array[2]=0x0823320D;
data_array[3]=0x004D1C08;
dsi_set_cmdq(data_array, 4, 1);
MDELAY(1);
data_array[0]=0x000D3902;
data_array[1]=0x03FF00B4;
data_array[2]=0x03500350;
data_array[3]=0x016A0150;
data_array[4]=0x0000006A;
dsi_set_cmdq(data_array, 5, 1);
MDELAY(1);
data_array[0]=0x00043902;
data_array[1]=0x010E41BF;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00263902;
data_array[1]=0x000700D3;
data_array[2]=0x00100000;
data_array[3]=0x00051032;
data_array[4]=0x00103200;
data_array[5]=0x10320000;
data_array[6]=0x36000000;
data_array[7]=0x37090903;
data_array[8]=0x00370000;
data_array[9]=0x0A000000;
data_array[10]=0x00000100;
dsi_set_cmdq(data_array, 11, 1);
MDELAY(1);
data_array[0]=0x002D3902;
data_array[1]=0x000302D5;
data_array[2]=0x04070601;
data_array[3]=0x22212005;
data_array[4]=0x18181823;
data_array[5]=0x18181818;
data_array[6]=0x18181818;
data_array[7]=0x18181818;
data_array[8]=0x18181818;
data_array[9]=0x18181818;
data_array[10]=0x24181818;
data_array[11]=0x19181825;
data_array[12]=0x00000019;
dsi_set_cmdq(data_array, 13, 1);
MDELAY(1);
data_array[0]=0x002D3902;
data_array[1]=0x070405D6;
data_array[2]=0x03000106;
data_array[3]=0x21222302;
data_array[4]=0x18181820;
data_array[5]=0x58181818;
data_array[6]=0x18181858;
data_array[7]=0x18181818;
data_array[8]=0x18181818;
data_array[9]=0x18181818;
data_array[10]=0x25181818;
data_array[11]=0x18191924;
data_array[12]=0x00000018;
dsi_set_cmdq(data_array, 13, 1);
MDELAY(1);
data_array[0]=0x002B3902;
data_array[1]=0x211C07E0;
data_array[2]=0x2D3F3E38;// data_array[2]=0x1A332924;
data_array[3]=0x0C0B064B;// data_array[3]=0x0D0B083C;
data_array[4]=0x15110F17;// data_array[4]=0x15120F17;
data_array[5]=0x12061413;
data_array[6]=0x1C071814;
data_array[7]=0x3F3E3922;
data_array[8]=0x0A064B2D;// data_array[8]=0x0B083C1A;
data_array[9]=0x110F170D;// data_array[9]=0x120F170D;
data_array[10]=0x07141315;// data_array[10]=0x08141315;
data_array[11]=0x00181412;
dsi_set_cmdq(data_array, 12, 1);
MDELAY(1);
data_array[0]=0x00023902;
data_array[1]=0x000009CC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00053902;
data_array[1]=0x40C000C7;
data_array[2]=0x000000C0;
dsi_set_cmdq(data_array, 3, 1);
MDELAY(10);
//data_array[0]=0x00033902;
//data_array[1]=0x007F69b6;//VCOM
//dsi_set_cmdq(data_array, 2, 1);
//MDELAY(1);
data_array[0]=0x00033902;
data_array[1]=0x001430C0;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00023902;
data_array[1]=0x000007BC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00043902;
data_array[1]=0x14001FC9;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00352300;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(10);
data_array[0]=0x00512300;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);
data_array[0]=0x24532300;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);
data_array[0]=0x01552300;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(20);
data_array[0]=0x00033902;
data_array[1]=0x000111E4;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]= 0x00110500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(200);
data_array[0]= 0x00290500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(10);
}
// ---------------------------------------------------------------------------
// 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_DISABLED;
// params->dbi.te_edge_polarity = LCM_POLARITY_RISING;
params->dsi.mode = BURST_VDO_MODE;
// DSI
/* Command mode setting */
params->dsi.LANE_NUM = LCM_THREE_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;
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;
params->dsi.packet_size=256;
// Highly depends on LCD driver capability.
// Not support in MT6573
//params->dsi.packet_size=256;
// Video mode setting
//params->dsi.intermediat_buffer_num = 2;
//params->dsi.intermediat_buffer_num = 0;
params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
#if 0
params->dsi.vertical_sync_active = 0x02;//2
params->dsi.vertical_backporch = 0x10;//50
params->dsi.vertical_frontporch = 0x09;//20
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 0x24;//2
params->dsi.horizontal_backporch = 0x44;//100
params->dsi.horizontal_frontporch = 0x39;//100
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.PLL_CLOCK = 240;
#endif
params->dsi.vertical_sync_active = 4;
params->dsi.vertical_backporch = 12;
params->dsi.vertical_frontporch = 16;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 24;
params->dsi.horizontal_backporch = 100;
params->dsi.horizontal_frontporch = 50;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.PLL_CLOCK = 345;
#ifdef BUILD_LK
printf("[lcm] LCM_PARAMS\n");
#else
printk("[lcm] LCM_PARAMS\n");
#endif
}
static unsigned int lcm_read_id(void)
{
unsigned int id = 0;
unsigned char buffer[3];
unsigned int data_array[16];
SET_RESET_PIN(1); /* NOTE:should reset LCM firstly */
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
MDELAY(20);
data_array[0] = 0x00043902;
data_array[1] = 0x9483FFB9;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(10);
data_array[0] = 0x00033700;
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, buffer, 3);
id = (buffer[0] << 8) | buffer[1]; /* we only need ID */
#ifdef BUILD_LK
printf("+++++++read id, buf:0x%02x ,0x%02x,0x%02x, id=0X%X++++++++", buffer[0], buffer[1], buffer[2],id);
#else
printk("++++++++read id, buf:0x%02x ,0x%02x,0x%02x, id=0X%X+++++++", buffer[0], buffer[1], buffer[2],id);
#endif
return 0;
}
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.cmd;
switch (cmd) {
case REGFLAG_DELAY :
MDELAY(table.count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
dsi_set_cmdq_V2(cmd, table.count, table.para_list, force_update);
}
}
}
extern void DSI_clk_HS_mode(bool enter);
static void lcm_init(void)
{
//DSI_clk_HS_mode(0);
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(50);//Must > 10ms
SET_RESET_PIN(1);
MDELAY(50);//Must > 120ms
// lcm_read_id();
//DSI_clk_HS_mode(1);
//MDELAY(10);
//push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
//init_lcm_registers();
dsi_set_cmdq_V3(lcm_initialization_setting,sizeof(lcm_initialization_setting)/sizeof(lcm_initialization_setting[0]),1);
}
static void lcm_suspend(void)
{
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(50);//Must > 10ms
SET_RESET_PIN(1);
MDELAY(50);//Must > 120ms
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)
{
lcm_read_id();
lcm_init();
}
file:///C:\Users\Administrator\Documents\Tencent Files\1445266146\Image\Group\Image1\I)NJVJU0UWF15YWZ7X63RPM.jpg
#define FRAME_WIDTH (800)
#define FRAME_HEIGHT (1280)
#define REGFLAG_DELAY 0XFE
#define REGFLAG_END_OF_TABLE 0xFF // END OF REGISTERS MARKER
#define LCM_DSI_CMD_MODE 0
// ---------------------------------------------------------------------------
// Local Variables
// ---------------------------------------------------------------------------
static LCM_UTIL_FUNCS lcm_util;
#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_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
#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(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
#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[120];
};
static unsigned int lcm_read_id(void);
#if 1
static struct LCM_setting_table old_lcm_initialization_setting[] = {
{0xB9, 3, {0xFF, 0x83, 0x94} },
{0xBA, 2, {0x72,0x83} },
{0xB1, 15,
{0x6c, 0x15, 0x15, 0x24, 0xe4, 0x11, 0xf1, 0x80, 0xe4, 0xD7, 0x23, 0x80, 0xC0, 0xD2,
0x58} },
{0xB2, 11, {0x00, 0x64, 0x10, 0x07, 0X20, 0x1C, 0x08, 0x08, 0x1C, 0x4D, 0x00} },
{0xB4, 12,
{0x00, 0xFF, 0x03, 0x5a, 0x03, 0x5a, 0x03, 0x5a, 0x01, 0x6a, 0x01, 0x6a} },
{0xB6, 2, {0x6F, 0x6F} },
{0xCC, 1, {0x01} },
{0xD3, 30,
{0x00, 0x06, 0x00, 0x40, 0x1a, 0x08, 0x00, 0x32, 0x10, 0x07, 0x00, 0x07, 0x54, 0x15, 0x0f,
0x05, 0x04, 0x02, 0x12, 0x10, 0x05, 0x07, 0x33, 0x33, 0x0b, 0x0b, 0x37, 0x10, 0x07, 0x07} },
{0xD5, 44,
{0x19, 0x19, 0x18, 0x18, 0x1a, 0x1a, 0x1b, 0x1b, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02,
0x03, 0x20, 0x21, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x22, 0x23, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xD6, 44,
{0x18, 0x18, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, 0x03, 0x02, 0x01, 0x00, 0x07, 0x06, 0x05,
0x04, 0x23, 0x22, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x21, 0x20, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18} },
{0xE0, 42,
{0x00, 0x06, 0x0C, 0x31, 0x34, 0x3F, 0x1D, 0x41, 0x06, 0x0A, 0x0C, 0x17, 0x0F, 0x12, 0x15,
0x13, 0x14, 0x07, 0x12, 0x15, 0x16, 0x00, 0x06, 0x0B, 0X30, 0x34, 0x3F, 0x1D, 0x40, 0x07,
0x0A, 0x0D, 0x18, 0x0E, 0x12, 0x14, 0x12, 0x14, 0x08, 0x13, 0x14, 0x19} },
{0xd2, 1, {0x55} },
{0xC0, 2, {0x30, 0x14} },
{0xbf, 3, {0x41, 0x0e,0x01} },
{0xC7, 4, {0x00, 0xc0,0x40,0xc0} },
{0xdf, 1, {0x8e} },
{0x11, 0, {} },
{REGFLAG_DELAY, 250, {} },
{0x29, 0, {} },
{REGFLAG_DELAY, 50, {} },
{REGFLAG_END_OF_TABLE, 0x00, {} }
};
#endif
static LCM_setting_table_V3 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, {}}
*/
{0x39, 0xB9, 3 ,{0xFF, 0x83, 0x94}},
{0x39, 0xBA, 2 ,{0x72, 0x83}},
{0x39, 0xB1, 15 ,{0x6c, 0x12, 0x12,
0x26, 0x04, 0x11, 0xf1,
0x81, 0x3a, 0x54, 0x23,
0x80, 0xc0, 0xd2, 0x58}},
{0x39, 0xB2, 11 ,{0x00,0x64,0x0E,0x0D,
0x22,0x1C,0x08,0x08,0x1C,0x4D,0x00}},
{0x39, 0xB4, 12 ,{0x00,0xFF,0x51,0x5A,
0x59,0x5A,0x03,0x5A,0x01,
0x70,0x01,0x70}},
{0x15, 0xBc, 1 ,{0x07}},
{0x39, 0xBF, 3 ,{0x41,0x0E,0x01}},
{0x39, 0xd3, 37 ,{0x00,0x0F,0x00,0x40,
0x07,0x10,0x00,0x08,0x10,
0x08,0x00,0x08,0x54,0x15,
0x0E,0x05,0x0E,0x02,0x15,
0x06,0x05,0x06,0x47,0x44,
0x0A,0x0A,0x4B,0x10,0x07,
0x07,0x08,0x00,0x00,0x00,
0x0A,0x00,0x01}},
{0x39, 0xD5, 44 ,{0x1A,0x1A,0x1B,0x1B,
0x00,0x01,0x02,0x03,0x04,
0x05,0x06,0x07,0x08,0x09,
0x0A,0x0B,0x24,0x25,0x18,
0x18,0x26,0x27,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x20,
0x21,0x18,0x18,0x18,0x18}},
{0x39, 0xD6, 44 ,{0x1A,0x1A,0x1B,0x1B,
0x0B,0x0A,0x09,0x08,0x07,
0x06,0x05,0x04,0x03,0x02,
0x01,0x00,0x21,0x20,0x58,
0x58,0x27,0x26,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x25,
0x24,0x18,0x18,0x18,0x18}},
{0x15, 0xCC, 1 ,{0x09}},
{0x39, 0xC0, 2 ,{0x30, 0x14}},
{0x39, 0xC7, 4 ,{0x00,0xC0,0x40,0xC0}},
{0x39, 0xb6, 2 ,{0x6B,0x6B}},
{0x39, 0xE0, 42 ,{0x00,0x0A,0x0F,0x24,
0x3A,0x3F,0x20,0x3B,0x08,
0x0D,0x0E,0x16,0x0F,0x12,
0x15,0x13,0x15,0x09,0x12,
0x12,0x18,0x00,0x0A,0x0F,
0x24,0x3A,0x3F,0x20,0x3B,
0x08,0x0D,0x0E,0x16,0x0F,
0x12,0x15,0x13,0x15,0x09,
0x12,0x12,0x18}},
{0x15, 0xbd, 1 ,{0x00}},
{0x39, 0xC1, 43 ,{0x01,0x00,0x06,0x0C,
0x14,0x1D,0x27,0x2F,0x38,
0x41,0x49,0x51,0x59,0x61,
0x69,0x71,0x79,0x81,0x89,
0x91,0x99,0xA1,0xA9,0xB2,
0xB9,0xC1,0xCA,0xD1,0xD8,
0xE2,0xEA,0xF0,0xF7,0xFF,
0x38,0xFC,0x3F,0x0B,0xC1,
0x13,0xF1,0x0D,0xC0}},
{0x15, 0xbd, 1 ,{0x01}},
{0x39, 0xC1, 42 ,{0x00,0x06,0x0C,0x14,
0x1D,0x27,0x2F,0x38,0x41,
0x49,0x51,0x59,0x61,0x69,
0x71,0x79,0x81,0x89,0x91,
0x99,0xA1,0xA9,0xB2,0xB9,
0xC1,0xCA,0xD1,0xD8,0xE2,
0xEA,0xF0,0xF7,0xFF,0x38,
0xFC,0x3F,0x0B,0xC1,0x13,
0xF1,0x0D,0xC0}},
{0x15, 0xbd, 1 ,{0x02}},
{0x39, 0xC1, 42 ,{0x00,0x06,0x0C,0x14,
0x1D,0x27,0x2F,0x38,0x41,
0x49,0x51,0x59,0x61,0x69,
0x71,0x79,0x81,0x89,0x91,
0x99,0xA1,0xA9,0xB2,0xB9,
0xC1,0xCA,0xD1,0xD8,0xE2,
0xEA,0xF0,0xF7,0xFF,0x38,
0xFC,0x3F,0x0B,0xC1,0x13,
0xF1,0x0D,0xC0}},
{0x15, 0x36, 1 ,{0x03}},
{0x05, 0x11,0,{}},//
{REGFLAG_ESCAPE_ID,REGFLAG_DELAY_MS_V3,120,{}},
{0x05, 0x29,0,{}},//
{REGFLAG_ESCAPE_ID,REGFLAG_DELAY_MS_V3,20,{}},
/* FIXME */
/*
params->dsi.horizontal_sync_active = 0x16;// 50 2
params->dsi.horizontal_backporch = 0x38;
params->dsi.horizontal_frontporch = 0x18;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.horizontal_blanking_pixel =0; //lenovo:fix flicker issue
//params->dsi.LPX=8;
*/
};
static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
// Display off sequence
{0x28, 0, {0x00}},
{REGFLAG_DELAY, 120, {}},
// Sleep Mode On
{0x10, 0, {0x00}},
{REGFLAG_DELAY, 20, {}},
{REGFLAG_END_OF_TABLE, 0x00, {}}
};
static void init_lcm_registers(void)
{
unsigned int data_array[16];
data_array[0]=0x00043902;
data_array[1]=0x9483FFB9;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00033902;
data_array[1]=0x008372BA;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
//BAh,1st para=73,2nd para=43,7th para=09,8th para=40,9th para=10,10th para=00,11th para=00
data_array[0]=0x00103902;
data_array[1]=0x110B6CB1;
data_array[2]=0xF1110437;//vgl=-5.55*2
data_array[3]=0x2395E380;
data_array[4]=0x18D2C080;
dsi_set_cmdq(data_array, 5, 1);
MDELAY(10);
data_array[0]=0x000C3902;
data_array[1]=0x0E6400B2;
data_array[2]=0x0823320D;
data_array[3]=0x004D1C08;
dsi_set_cmdq(data_array, 4, 1);
MDELAY(1);
data_array[0]=0x000D3902;
data_array[1]=0x03FF00B4;
data_array[2]=0x03500350;
data_array[3]=0x016A0150;
data_array[4]=0x0000006A;
dsi_set_cmdq(data_array, 5, 1);
MDELAY(1);
data_array[0]=0x00043902;
data_array[1]=0x010E41BF;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00263902;
data_array[1]=0x000700D3;
data_array[2]=0x00100000;
data_array[3]=0x00051032;
data_array[4]=0x00103200;
data_array[5]=0x10320000;
data_array[6]=0x36000000;
data_array[7]=0x37090903;
data_array[8]=0x00370000;
data_array[9]=0x0A000000;
data_array[10]=0x00000100;
dsi_set_cmdq(data_array, 11, 1);
MDELAY(1);
data_array[0]=0x002D3902;
data_array[1]=0x000302D5;
data_array[2]=0x04070601;
data_array[3]=0x22212005;
data_array[4]=0x18181823;
data_array[5]=0x18181818;
data_array[6]=0x18181818;
data_array[7]=0x18181818;
data_array[8]=0x18181818;
data_array[9]=0x18181818;
data_array[10]=0x24181818;
data_array[11]=0x19181825;
data_array[12]=0x00000019;
dsi_set_cmdq(data_array, 13, 1);
MDELAY(1);
data_array[0]=0x002D3902;
data_array[1]=0x070405D6;
data_array[2]=0x03000106;
data_array[3]=0x21222302;
data_array[4]=0x18181820;
data_array[5]=0x58181818;
data_array[6]=0x18181858;
data_array[7]=0x18181818;
data_array[8]=0x18181818;
data_array[9]=0x18181818;
data_array[10]=0x25181818;
data_array[11]=0x18191924;
data_array[12]=0x00000018;
dsi_set_cmdq(data_array, 13, 1);
MDELAY(1);
data_array[0]=0x002B3902;
data_array[1]=0x211C07E0;
data_array[2]=0x2D3F3E38;// data_array[2]=0x1A332924;
data_array[3]=0x0C0B064B;// data_array[3]=0x0D0B083C;
data_array[4]=0x15110F17;// data_array[4]=0x15120F17;
data_array[5]=0x12061413;
data_array[6]=0x1C071814;
data_array[7]=0x3F3E3922;
data_array[8]=0x0A064B2D;// data_array[8]=0x0B083C1A;
data_array[9]=0x110F170D;// data_array[9]=0x120F170D;
data_array[10]=0x07141315;// data_array[10]=0x08141315;
data_array[11]=0x00181412;
dsi_set_cmdq(data_array, 12, 1);
MDELAY(1);
data_array[0]=0x00023902;
data_array[1]=0x000009CC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00053902;
data_array[1]=0x40C000C7;
data_array[2]=0x000000C0;
dsi_set_cmdq(data_array, 3, 1);
MDELAY(10);
//data_array[0]=0x00033902;
//data_array[1]=0x007F69b6;//VCOM
//dsi_set_cmdq(data_array, 2, 1);
//MDELAY(1);
data_array[0]=0x00033902;
data_array[1]=0x001430C0;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00023902;
data_array[1]=0x000007BC;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00043902;
data_array[1]=0x14001FC9;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]=0x00352300;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(10);
data_array[0]=0x00512300;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);
data_array[0]=0x24532300;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);
data_array[0]=0x01552300;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(20);
data_array[0]=0x00033902;
data_array[1]=0x000111E4;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(1);
data_array[0]= 0x00110500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(200);
data_array[0]= 0x00290500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(10);
}
// ---------------------------------------------------------------------------
// 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_DISABLED;
// params->dbi.te_edge_polarity = LCM_POLARITY_RISING;
params->dsi.mode = BURST_VDO_MODE;
// DSI
/* Command mode setting */
params->dsi.LANE_NUM = LCM_THREE_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;
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;
params->dsi.packet_size=256;
// Highly depends on LCD driver capability.
// Not support in MT6573
//params->dsi.packet_size=256;
// Video mode setting
//params->dsi.intermediat_buffer_num = 2;
//params->dsi.intermediat_buffer_num = 0;
params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
#if 0
params->dsi.vertical_sync_active = 0x02;//2
params->dsi.vertical_backporch = 0x10;//50
params->dsi.vertical_frontporch = 0x09;//20
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 0x24;//2
params->dsi.horizontal_backporch = 0x44;//100
params->dsi.horizontal_frontporch = 0x39;//100
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.PLL_CLOCK = 240;
#endif
params->dsi.vertical_sync_active = 4;
params->dsi.vertical_backporch = 12;
params->dsi.vertical_frontporch = 16;
params->dsi.vertical_active_line = FRAME_HEIGHT;
params->dsi.horizontal_sync_active = 24;
params->dsi.horizontal_backporch = 100;
params->dsi.horizontal_frontporch = 50;
params->dsi.horizontal_active_pixel = FRAME_WIDTH;
params->dsi.PLL_CLOCK = 345;
#ifdef BUILD_LK
printf("[lcm] LCM_PARAMS\n");
#else
printk("[lcm] LCM_PARAMS\n");
#endif
}
static unsigned int lcm_read_id(void)
{
unsigned int id = 0;
unsigned char buffer[3];
unsigned int data_array[16];
SET_RESET_PIN(1); /* NOTE:should reset LCM firstly */
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(10);
SET_RESET_PIN(1);
MDELAY(10);
MDELAY(20);
data_array[0] = 0x00043902;
data_array[1] = 0x9483FFB9;
dsi_set_cmdq(data_array, 2, 1);
MDELAY(10);
data_array[0] = 0x00033700;
dsi_set_cmdq(data_array, 1, 1);
read_reg_v2(0x04, buffer, 3);
id = (buffer[0] << 8) | buffer[1]; /* we only need ID */
#ifdef BUILD_LK
printf("+++++++read id, buf:0x%02x ,0x%02x,0x%02x, id=0X%X++++++++", buffer[0], buffer[1], buffer[2],id);
#else
printk("++++++++read id, buf:0x%02x ,0x%02x,0x%02x, id=0X%X+++++++", buffer[0], buffer[1], buffer[2],id);
#endif
return 0;
}
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.cmd;
switch (cmd) {
case REGFLAG_DELAY :
MDELAY(table.count);
break;
case REGFLAG_END_OF_TABLE :
break;
default:
dsi_set_cmdq_V2(cmd, table.count, table.para_list, force_update);
}
}
}
extern void DSI_clk_HS_mode(bool enter);
static void lcm_init(void)
{
//DSI_clk_HS_mode(0);
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(50);//Must > 10ms
SET_RESET_PIN(1);
MDELAY(50);//Must > 120ms
// lcm_read_id();
//DSI_clk_HS_mode(1);
//MDELAY(10);
//push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
//init_lcm_registers();
dsi_set_cmdq_V3(lcm_initialization_setting,sizeof(lcm_initialization_setting)/sizeof(lcm_initialization_setting[0]),1);
}
static void lcm_suspend(void)
{
SET_RESET_PIN(1);
MDELAY(10);
SET_RESET_PIN(0);
MDELAY(50);//Must > 10ms
SET_RESET_PIN(1);
MDELAY(50);//Must > 120ms
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)
{
lcm_read_id();
lcm_init();
}
file:///C:\Users\Administrator\Documents\Tencent Files\1445266146\Image\Group\Image1\I)NJVJU0UWF15YWZ7X63RPM.jpg
你这分辨率超过了72的最大分辨率了呢