static void lcm_suspend(void) { #ifdef TEMP_VER_CHECK #if defined(BUILD_LK) #else if ( first_check == 0 ) { g_PCBver = get_pcb_version(); LCM_PRINT("[LCD-KERNEL]board_version =%d\n",g_PCBver); first_check = 1; } #endif #endif /* TEMP_VER_CHECK */ init_lcm_registers_sleep(); SET_RESET_PIN(0); MDELAY(20); //dsv low ldo_p5m5_dsv_5v5_off(); MDELAY(10); //VCI/IOVCC off ldo_1v8io_off(); //ldo_ext_3v0_off(); LCM_PRINT("[LCD] lcm_suspend \n"); }
static unsigned int lcm_compare_id(void) { #if 0 unsigned int id=0; unsigned char buffer[2]; unsigned int array[16]; SET_RESET_PIN(1); SET_RESET_PIN(0); MDELAY(1); SET_RESET_PIN(1); MDELAY(10);//Must over 6 ms array[0]=0x00043902; array[1]=0x8983FFB9;// page enable dsi_set_cmdq(array, 2, 1); MDELAY(10); array[0] = 0x00023700;// return byte number dsi_set_cmdq(array, 1, 1); MDELAY(10); read_reg_v2(0xF4, buffer, 2); id = buffer[0]; LCM_PRINT("%s, id = 0x%08x\n", __func__, id); return (LCM_ID == id)?1:0; #else LCM_PRINT("[SEOSCTEST] lcm_compare_id \n"); return 1; #endif }
static void lcm_resume_power(void) { if(wakeup_by_swipe == false){ //if(!is_update)mutex_lock(pMutexTouch); ldo_p5m5_dsv_5v5_off(); ldo_1v8io_off(); ldo_3v0_off(); reset_lcd_module(1); //removed reset delay 50ms //chargepump_dsv_reset();//no need it for ESD MDELAY(10); //0318 100ms -> 10ms ldo_3v0_on(); ldo_1v8io_on(); //MDELAY(10); //ldo_p5m5_dsv_5v5_on(); // 0318 move to LP11 MDELAY(50); //SET_RESET_PIN(1); //reset_lcd_module(0); //0318 move to LP11 //MDELAY(150); LCM_PRINT("[LCD] lcm_resume_power \n"); }else{ LCM_PRINT("[LCD] lcm_resume_power wakeup_by_swipe\n"); } }
static void lcm_resume(void) { unsigned int data_array[1]; MDELAY(5); if(wakeup_by_swipe == false){ //reset_lcd_module(0); //MDELAY(10); //seosc ldo_p5m5_dsv_5v5_on(); MDELAY(5); reset_lcd_module(0); MDELAY(1); reset_lcd_module(1); MDELAY(1); reset_lcd_module(0); MDELAY(50); }else{ LCM_PRINT("[LCD] lcm_resume wakeup_by_swipe\n"); } DSI_clk_HS_mode(1); MDELAY(120); dsi_set_cmdq_V3(lcm_initialization_pre_sleep_out_V3, sizeof(lcm_initialization_pre_sleep_out_V3) / sizeof(LCM_setting_table_V3), 1); MDELAY(120); dsi_set_cmdq_V3(lcm_initialization_post_sleep_out_V3, sizeof(lcm_initialization_post_sleep_out_V3) / sizeof(LCM_setting_table_V3), 1); need_set_lcm_addr = 1; LCM_PRINT("[LCD] lcm_resume\n"); }
static void init_lcm_registers(void) { #if (!defined(BUILD_UBOOT) && !defined(BUILD_LK)) && defined(INIT_CODE_TUNNING_BY_SD_CARD) /* */ //sd_initial int line_cnt = 0; LCM_PRINT("[LCD] : [KERNEL] init_lcm_registers \n "); if (Filesize(LCD_INITIAL_TXT) > 0) { line_cnt= lcd_init_read_from_sd(); if (line_cnt > 0) { LCM_PRINT("[LCD] : SD card tunning & initial setting!!! \n "); push_table(lcm_initialization_setting_sd, sizeof(lcm_initialization_setting_sd) / sizeof(struct LCM_setting_table), 1); } else { LCM_PRINT("[LCD] : Default initial setting \n "); push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1); } } else { LCM_PRINT("[LCD] : Default initial setting \n "); push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1); } #else push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1); LCM_PRINT("[LCD] init_lcm_registers \n"); #endif /* */ }
static int get_pcb_version(void) { int data[4] = {0, 0, 0, 0}; int rawvalue = 0; int ret = 0; int PCBvoltage = 0; ret = IMM_GetOneChannelValue(1, data, &rawvalue); if (ret == 0) { LCM_PRINT("[%s] success to get adc value channel(1)=(0x%x) (%d) (ret=%d)\n", __func__, rawvalue, rawvalue, ret); LCM_PRINT("[%s] data[0]=0x%x, data[1]=0x%x\n\n",__func__, data[0], data[1]); } else { LCM_PRINT("[%s] fail to get adc value (ret=%d)\n", __func__, ret); } PCBvoltage = (int)(rawvalue * 150 / 4096); if ( PCBvoltage>HW_REV_B_RANGE ) g_PCBver = HW_REV_B; // rev.b else if ( (PCBvoltage>HW_REV_A_RANGE) && (PCBvoltage<HW_REV_B_RANGE) ) g_PCBver = HW_REV_A_2; // rev.a-2 else g_PCBver = HW_REV_A; // rev.a LCM_PRINT("PCBvoltage(%d), g_PCBver(%d)\n", PCBvoltage, g_PCBver); return g_PCBver; }
static void lcm_set_pwm_for_mix(int enable) { LCM_PARAMS params; lcm_get_params(¶ms); if (params.dsi.pwm_fps == 0) { LCM_PRINT("Please set PWM fps \n"); return; } if (enable) { #if defined(TARGET_MT6582_Y50) /* */ //lcm_set_fps(params.dsi.pwm_fps); #else lcm_set_fps(params.dsi.pwm_fps); #endif /* */ set_enable_te_framesync(); } else { mt_pwm_disable(pwm_setting.pwm_no, pwm_setting.pmic_pad); } LCM_PRINT("[LCD] lcm_set_pwm (%d)\n", enable); return; }
static void set_enable_te_framesync(void) { LCM_PRINT("=============mt_pmic_pwm2_test===============\n"); mt_set_gpio_mode(GPIO_INCELL_DISP_TE_PWM,GPIO_INCELL_DISP_TE_M_PWM); LCM_PRINT("PWM: clk_div = %x, clk_src = %x, pwm_no = %x\n", pwm_setting.clk_div, pwm_setting.clk_src, pwm_setting.pwm_no); pwm_set_spec_config(&pwm_setting); }
bool lcm_register_check(unsigned char addr) { unsigned char data[15] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; unsigned char param_cnt; unsigned char i; bool result; switch(addr) { case 0x35 : // Fall through case 0x36 : // Fall through case 0x3A : // Fall through case 0xB4 : // Fall through case 0xB6 : // Fall through case 0xB7 : // Fall through case 0xC1 : // Fall through case 0xC2 : // Fall through case 0xC5 : // Fall through case 0xEE : // Fall through param_cnt = 1; break; case 0x0A : // Fall through case 0x44 : // Fall through case 0xB1 : // Fall through case 0xC0 : // Fall through case 0xCF : // Fall through param_cnt = 2; break; case 0xF6 : param_cnt = 3; break; case 0x09 : param_cnt = 5; break; case 0xE0 : // Fall through case 0xE1 : // Fall through param_cnt = 15; break; default : LCM_PRINT("[LCD] lcm_register_check, wrong address : 0x%x\n", addr); return TRUE; break; } result = register_data_read(addr, param_cnt, &data); if(result == TRUE) { return register_compare(addr, data, param_cnt); } else { LCM_PRINT("[LCD] register data read fail, return TRUE\n"); return TRUE; } }
static void lcm_init(void) { DSI_clk_HS_mode(1); MDELAY(120); init_lcm_registers(); /* SET EXTC ~ sleep out register */ MDELAY(120); /* init_lcm_registers_added(); //Display On */ need_set_lcm_addr = 1; LCM_PRINT("[SEOSCTEST] lcm_init \n"); LCM_PRINT("[LCD] lcm_init \n"); }
static void lcm_esd_recover(void) { lcm_suspend(); lcm_resume(); LCM_PRINT("[LCD] lcm_esd_recover \n"); }
int dump_lcm_register(char *buf) { int i, j; unsigned char param_cnt; unsigned char addr; unsigned char data[15]; int table_size = sizeof(INN_register_table)/sizeof(LCM_register_table); int ret = FALSE; // register data not changed LCM_register_table *ptr = table_ptr; for(i = 0; i < table_size; i++) { memset(data, 0xFF, sizeof(data)); addr = ptr[i].address; param_cnt = ptr[i].count; register_data_read(addr, param_cnt, &data); LCM_PRINT("[LCD] DUMP LCM REGISTER ADDRESS : 0x%x, data : 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", addr, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14]); if(register_compare(addr, data, param_cnt) == FALSE) { sprintf(buf, "%s 0x%x", buf, addr); ret = TRUE; // register data changed } } sprintf(buf, "%s\0", buf); return ret; }
static void lcm_init_INN(void) { // no power on/off control for TOVIS LCD sleep current consumption issue //hwPowerOn(MT6323_POWER_LDO_VCAM_AF, VOL_2800, "2V8_LCD_VCC_MTK_S"); //MDELAY(1); //hwPowerOn(MT6323_POWER_LDO_VGP1, VOL_1800, "1V8_LCD_VIO_MTK_S"); //MDELAY(1); SET_RESET_PIN(1); MDELAY(10); SET_RESET_PIN(0); MDELAY(10); SET_RESET_PIN(1); MDELAY(120); #if 1 /* LGE_BSP_COMMON LGE_CHANGE_S 140325 jongwoo82.lee : LCD dualization temp code */ if(is_INN_LCD == true) { init_lcm_registers_INN(); } else { init_lcm_registers_TCL(); } #else init_lcm_registers_INN(); #endif /* LGE_BSP_COMMON LGE_CHANGE_E 140325 jongwoo82.lee : LCD dualization temp code */ LCM_PRINT("[LCD] lcm_init \n"); }
void lcm_force_lut_update(void) { dsi_set_cmdq_V3(lcm_lut_update_in_V3, sizeof(lcm_lut_update_in_V3) / sizeof(LCM_setting_table_V3), 1); MDELAY(120); LCM_PRINT("[LCD] lut update for upgrading Touch FW \n"); }
static unsigned int lcm_compare_id(void) { unsigned int id = 0; SET_RESET_PIN(1); SET_RESET_PIN(0); MDELAY(25); SET_RESET_PIN(1); MDELAY(50); send_ctrl_cmd(0xB9); // SET password send_data_cmd(0xFF); send_data_cmd(0x83); send_data_cmd(0x69); send_ctrl_cmd(0xC3); send_data_cmd(0x00); send_data_cmd(0x80); send_data_cmd(0x00); send_ctrl_cmd(0xF4); id = read_data_cmd(); // dummy read id = read_data_cmd(); LCM_PRINT("[HX] ID:0x%x, 0x%x\n", id, LCM_ID); return (LCM_ID == id)?1:0; }
static unsigned int lcm_compare_id(void) { unsigned int id1, id2, id3 = 0; SET_RESET_PIN(1); SET_RESET_PIN(0); MDELAY(5); SET_RESET_PIN(1); MDELAY(20); //*************Enable CMD2 Page1 *******************// set_lcm_register(0xF000, 0x55); set_lcm_register(0xF001, 0xAA); set_lcm_register(0xF002, 0x52); set_lcm_register(0xF003, 0x08); set_lcm_register(0xF004, 0x01); MDELAY(10); send_ctrl_cmd(0xC500); id1 = read_data_cmd(); send_ctrl_cmd(0xC501); id2 = read_data_cmd(); send_ctrl_cmd(0xC502); id3 = read_data_cmd(); LCM_PRINT("[NT] ID:0x%x, 0x%x, 0x%x, 0x%x\n", id1, id2, id3, LCM_ID); return (LCM_ID == (id1 << 8 | id2))?1:0; }
static void reset_lcd_module(unsigned char reset) { mt_set_gpio_mode(GPIO_LCM_RST, GPIO_LCM_RST_M_GPIO); //mt_set_gpio_pull_enable(GPIO_LCM_RST, GPIO_PULL_ENABLE); mt_set_gpio_dir(GPIO_LCM_RST, GPIO_DIR_OUT); if(reset){ mt_set_gpio_out(GPIO_LCM_RST, GPIO_OUT_ONE); LCM_PRINT("[LCD] Reset High \n"); } else { mt_set_gpio_out(GPIO_LCM_RST, GPIO_OUT_ZERO); LCM_PRINT("[LCD] Reset Low \n"); } }
static void init_lcm_registers(void) { #if 1 //DSI_clk_HS_mode(DISP_MODULE_DSI0, NULL, 1); //push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1); //if ( lge_get_board_revno() > EVB_PCB_REVISION ) //dsi_set_cmdq_V3(lcm_initialization_setting_rotation_V3, sizeof(lcm_initialization_setting_rotation_V3) / sizeof(LCM_setting_table_V3), 1); dsi_set_cmdq_V3(lcm_initialization_setting_V3, sizeof(lcm_initialization_setting_V3) / sizeof(LCM_setting_table_V3), 1); MDELAY(120); //dsi_set_cmdq_V3(lcm_initialization_setting_V3_Disp_On, sizeof(lcm_initialization_setting_V3_Disp_On) / sizeof(LCM_setting_table_V3), 1); #else unsigned int data_array[32]; dsi_set_cmdq_V3(lcm_initialization_setting_V3, sizeof(lcm_initialization_setting_V3) / sizeof(LCM_setting_table_V3), 1); data_array[0] = 0x00290500; //Display On dsi_set_cmdq(data_array, 1, 1); data_array[0] = 0x00110500; //Sleep Out dsi_set_cmdq(data_array, 1, 1); MDELAY(120); #endif LCM_PRINT("[LCD] init_lcm_registers \n"); }
static unsigned int lcm_esd_recover(void) { LCM_PRINT("\n[LCD] lcm_esd_recover, LCD re-initialize \n"); lcm_suspend_INN(); MDELAY(200); lcm_init_INN(); return TRUE; }
static bool register_compare(unsigned char addr, unsigned char data[], unsigned char count) { unsigned char index = 0; unsigned char i; LCM_register_table *ptr = table_ptr; switch(addr) { case 0x09 : index = 0; break; case 0x0A : index = 1; break; case 0x35 : index = 2; break; case 0x36 : index = 3; break; case 0x3A : index = 4; break; case 0x44 : index = 5; break; case 0xB1 : index = 6; break; case 0xB4 : index = 7; break; case 0xB6 : index = 8; break; case 0xB7 : index = 9; break; case 0xC0 : index = 10; break; case 0xC1 : index = 11; break; case 0xC2 : index = 12; break; case 0xC5 : index = 13; break; case 0xCF : index = 14; break; case 0xE0 : index = 15; break; case 0xE1 : index = 16; break; case 0xEE : index = 17; break; case 0xF6 : index = 18; break; default : LCM_PRINT("[LCD] register_compare, wrong address : 0x%x\n", addr); return TRUE; break; } for(i = 0; i < count; i++) { if(ptr[index].param_list[i] != data[i]) { LCM_PRINT("[LCD] register data changed, addr : 0x%x, data : 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", addr, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14]); return FALSE; } } return TRUE; }
void lcm_set_fps(int fps) { unsigned int width = 32 * 1024 / (4 * fps) - 1; LCM_PRINT("DSI_set_fps_for_PWM fps (%d), widht (%d)\n", fps, width); pwm_setting.PWM_MODE_OLD_REGS.DATA_WIDTH = width; pwm_setting.PWM_MODE_OLD_REGS.THRESH = width/2; }
void init_lcm_registers_sleep_2nd(void) { unsigned int data_array[1]; //dsi_set_cmdq_V3(lcm_initialization_for_sleep_in_pre, sizeof(lcm_initialization_for_sleep_in_pre) / sizeof(LCM_setting_table_V3), 1); //MDELAY(150); dsi_set_cmdq_V3(lcm_initialization_for_sleep_in_post, sizeof(lcm_initialization_for_sleep_in_post) / sizeof(LCM_setting_table_V3), 1); LCM_PRINT("[LCD] init_lcm_registers_sleep 2nd \n"); }
void lcm_read_fb(unsigned char *buffer) { int i =0; short x0, y0, x1, y1; short h_X_start,l_X_start,h_X_end,l_X_end,h_Y_start,l_Y_start,h_Y_end,l_Y_end; unsigned int readData; x0 = 0; y0 = 0; x1 = FRAME_WIDTH-1; y1 = FRAME_HEIGHT-1; h_X_start=((x0&0x0300)>>8); l_X_start=(x0&0x00FF); h_X_end=((x1&0x0300)>>8); l_X_end=(x1&0x00FF); h_Y_start=((y0&0x0300)>>8); l_Y_start=(y0&0x00FF); h_Y_end=((y1&0x0300)>>8); l_Y_end=(y1&0x00FF); send_ctrl_cmd( 0x2A00 ); send_data_cmd( h_X_start); send_ctrl_cmd( 0x2A01 ); send_data_cmd( l_X_start); send_ctrl_cmd( 0x2A02); send_data_cmd( h_X_end ); send_ctrl_cmd( 0x2A03); send_data_cmd( l_X_end ); send_ctrl_cmd( 0x2B00 ); send_data_cmd( h_Y_start); send_ctrl_cmd( 0x2B01 ); send_data_cmd( l_Y_start); send_ctrl_cmd( 0x2B02); send_data_cmd( h_Y_end ); send_ctrl_cmd( 0x2B03); send_data_cmd( l_Y_end ); send_ctrl_cmd( 0x2E00 ); MDELAY(20); //Dummy Read readData = read_data_cmd(); for(i=0; i<60; i+=3) { readData = read_data_cmd(); LCM_PRINT("Read data: 0x%08x \n", readData); MDELAY(20); buffer[i] =(readData&0x00FF0000)>>16; //R buffer[i+1]=(readData&0x0000FF00)>>8; //G buffer[i+2]=(readData&0x000000FF); //B } }
static void lcm_suspend_power(void) { //MDELAY(120); ldo_p5m5_dsv_off(); // DSV +-5V power off //MDELAY(20); //VCI/IOVCC off //ldo_1v8io_off(); //ldo_ext_3v0_off(); LCM_PRINT("[LCD] lcm_suspend_power \n"); }
static unsigned int lcm_compare_id(void) { LCM_PRINT_FUNC(); unsigned int id = 0; // while(1){ send_ctrl_cmd(0x1180); id = read_data_cmd(); LCM_PRINT("%s, id1 = 0x%08x\n", __func__, id); send_ctrl_cmd(0x1080); id |= (read_data_cmd() << 8); LCM_PRINT("%s, id2 = 0x%08x\n", __func__, id); // } return (LCM_ID == id)?1:0; }
static void lcm_resume(void) { //send_ctrl_cmd(0x11); lcm_init(); MDELAY(120); LCM_PRINT("[LCD] lcm_resume \n"); }
static void lcm_setbacklight(unsigned int level) { LCM_PRINT("lcm_setbacklight = %d\n", level); if (level > 255) level = 255; send_ctrl_cmd(0x51); send_data_cmd(level); }
static void lcm_init(void) { #if defined(BUILD_LK) #ifdef TEMP_VER_CHECK g_PCBver = get_pcb_version(); LCM_PRINT("[LCD] pcb_version =%d\n",g_PCBver); #endif /* TEMP_VER_CHECK */ ldo_p5m5_dsv_5v5_off(); SET_RESET_PIN(0); MDELAY(50); #endif //SET_RESET_PIN(0); //TP_VCI 3.0v on ldo_3v0_on(); MDELAY(200); ldo_1v8io_on(); MDELAY(200); ldo_p5m5_dsv_5v5_on(); MDELAY(20); SET_RESET_PIN(1); MDELAY(20); SET_RESET_PIN(0); MDELAY(2); SET_RESET_PIN(1); MDELAY(20); init_lcm_registers(); //SET EXTC ~ sleep out register MDELAY(80); // init_lcm_registers_added(); //Display On need_set_lcm_addr = 1; LCM_PRINT("[SEOSCTEST] lcm_init \n"); LCM_PRINT("[LCD] lcm_init \n"); }
void lcm_set_pwm_for_mix(int enable) { LCM_PARAMS params; lcm_get_params(¶ms); if (params.dsi.pwm_fps == 0) { LCM_PRINT("Please set PWM fps\n"); return; } if (enable) { lcm_set_fps(params.dsi.pwm_fps); set_enable_te_framesync(); } else { mt_pwm_disable(pwm_setting.pwm_no, pwm_setting.pmic_pad); } LCM_PRINT("[LCD] lcm_set_pwm (%d)\n", enable); return; }
void lcm_shutdown_power(void) { ldo_p5m5_dsv_5v5_off(); MDELAY(5); ldo_1v8io_off(); ldo_3v0_off(); MDELAY(5); reset_lcd_module(1); //removed reset delay 50m LCM_PRINT("[LCD] lcm_shutdown_power \n"); }