static void lcm_init(void)
{

	SET_RESET_PIN(1);
	MDELAY(5);
	SET_RESET_PIN(0);
	MDELAY(5);
	SET_RESET_PIN(1);
	MDELAY(120);//Must over 6 ms,SPEC request
	LCM_DBG("[WUHAI] -- hx8389b lcm_init start ");
	//	init_lcm_registers();
	push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
	LCM_DBG("[WUHAI] -- hx8389b lcm_init end ");
}
static unsigned int check_display_normal(void)
{
#if 1
    unsigned int normal=0;
    unsigned char buffer1[1];
    unsigned char buffer2[1];
    unsigned char buffer3[1];
    unsigned char buffer4[1];
    unsigned int array[16];
    //Tinno_Open_Mipi_HS_Read();
    array[0] = 0x00013700;// set return byte number
    dsi_set_cmdq(array, 1, 1);
    read_reg_V2(0x0A, &buffer1, 1);
    //Tinno_Close_Mipi_HS_Read();
//    read_reg_V2(0x0B, &buffer2, 1);
//    read_reg_V2(0x0C, &buffer3, 1);
//    read_reg_V2(0x0D, &buffer4, 1);
//    normal = buffer[0];
//    LCM_DBG("[Magnum] --test ic normal == 0x%x , 0x%x , 0x%x , 0x%x\n",buffer1[0],buffer2[0],buffer3[0],buffer4[0]);
    LCM_DBG("[Magnum] --test ic normal == 0x%x\n",buffer1[0]);
        if(buffer1[0] == 0x9c)// && buffer2[0] == 0x0 && buffer3[0] == 0x7 && buffer4[0] == 0x0)
         return 1;
    else
        return 0;
#endif

#if 0
    return 1;
    int array[4];
    char buffer[5];
    char id_high=0;
    char id_low=0;
    int id=0;
    push_table(lcm_compare_id_setting, sizeof(lcm_compare_id_setting) / sizeof(struct LCM_setting_table), 1);

    array[0] = 0x00053700;// set return byte number
    dsi_set_cmdq(array, 1, 1);

    read_reg_V2(0xA1, &buffer, 2);//D2
    LCM_DBG("buffer0 == 0x%02x, buffer1 == 0x%02x \n",buffer[0],buffer[1]);

    id = buffer[0]<<8 |buffer[1];

    LCM_DBG("OTM8018B 0x%x , 0x%x , 0x%x \n",buffer[0],buffer[1],id);

    return (id == LCM_ID_OTM8018B)?1:0;
#endif
}
static unsigned int lcm_compare_id(void)
{
	unsigned int id=0;
	unsigned int id1=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]; 
        id1 = buffer[0]<<8 |buffer[1]; 

	LCM_DBG("[WUHAI] -- hx8389b 0x%x , 0x%x , 0x%x , 0x%x \n",buffer[0],buffer[1],id,id1);

	#if defined(BUILD_UBOOT) || defined(BUILD_LK)
		return 1;//lcm_adc_read_chip_id();			
	#endif
	return 1	;
}
static unsigned int test_compare_id(void)
{
	unsigned int id=0;
	unsigned int id1=0;
	unsigned char buffer[2];
	unsigned int array[16];  

	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]; 
        id1 = buffer[0]<<8 |buffer[1]; 

	LCM_DBG("[WUHAI] -- hx8389b 0x%x , 0x%x , 0x%x , 0x%x \n",buffer[0],buffer[1],id,id1);
	
	if(LCM_ID_HX8389B == id){
			//#if defined(BUILD_UBOOT) || defined(BUILD_LK)
				if(lcm_adc_read_chip_id())
					return 1;
				else
					return  0;//Default LCM
			//#endif
			return 1;
		}
	return 0	;

}
Пример #5
0
static void config_gpio(void)
{
	LCM_DBG();
	mt_set_gpio_mode(GPIO_LCD_BACKLIGHT_EN_PIN, GPIO_LCD_BACKLIGHT_EN_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_LCD_BACKLIGHT_EN_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_LCD_BACKLIGHT_EN_PIN, GPIO_PULL_DISABLE);
}
Пример #6
0
static unsigned int lcm_compare_id(void)
{
	unsigned int id = 0, id2 = 0;
	unsigned char buffer[4];
	unsigned int array[16];

//	push_table(lcm_compare_id_setting, sizeof(lcm_compare_id_setting) / sizeof(struct LCM_setting_table), 1);
	
//Ivan
// 00 = MTK Config = Type 0 Instruction = Short Packet read/write
// 37 = DSI Data type = Set Maximum return packet size
// 0003 = data length = 3 bytes data to read
//Data = 00/11/22/33	
//	config_gpio();
/*
	SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
	MDELAY(10);
	SET_RESET_PIN(0);
	MDELAY(10);
	SET_RESET_PIN(1);
	MDELAY(120);	

	array[0] = 0x00013700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	MDELAY(10);	
	
	read_reg_v2(0xDB, buffer, 1);
	id = buffer[0]; //we only need ID
*/

	SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
	MDELAY(10);
	SET_RESET_PIN(0);
	MDELAY(10);
	SET_RESET_PIN(1);
	MDELAY(120);	
	buffer[0] = 0;
	buffer[1] = 0;
	buffer[2] = 0;
	buffer[3] = 0;	
	
	array[0]=0x00063902;
	array[1]=0x52AA55F0;
	array[2]=0x00000108;
	dsi_set_cmdq(&array, 3, 1);
	MDELAY(10); 

	array[0] = 0x00023700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	MDELAY(10); 
	
	read_reg_v2(0xC5, buffer, 2);
	id = buffer[0]; //we only need ID
	id2= buffer[1]; //we test buffer 1	

	LCM_DBG("ID1 = %x, ID2 = %x, ID3 = %x, ID4 = %x", buffer[0],buffer[1],buffer[2],buffer[3]);	
//	return (LCM_ID == id)?1:0;
	return 1;
}
Пример #7
0
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);	
	LCM_DBG();
	return pwm_clk;
}
Пример #8
0
static void lcm_resume(void)
{
	LCM_DBG();
#ifdef BUILD_UBOOT
	lcm_reset();
	lcm_init();
#endif
	push_table(lcm_sleep_out_setting);
}
static unsigned int lcm_compare_id(void)
{
	unsigned int id=0, id1 = 0,id2 = 0;
	unsigned int check_esd = 0;
	unsigned int array[16]; 
	unsigned char buffer[4];
       int volt = 0;
	unsigned int data[4];
	
	array[0] = 0x00043700;// read id return 4 bytes,version and id
	dsi_set_cmdq(array, 1, 1);
	MDELAY(10);	
	read_reg_v2(0xA1, buffer, 4);
       id1 = buffer[2];
       id2 = buffer[3];
       id = (id1<<8 | id2);
       LCM_DBG("lcm_compare_id read id=0x%x, id1=0x%x, id2=0x%x",id, id1,id2);
    
	array[0] = 0x00033700;// read esd return 3 bytes
	dsi_set_cmdq(array, 1, 1);	
	MDELAY(10);
	read_reg_v2(0x0A, buffer, 3);    
       check_esd = buffer[0];
       LCM_DBG("lcm_compare_id read check_esd=0x%x",check_esd);
 
       if(LCM_ID_OTM1283 == id)
       {
           IMM_GetOneChannelValue(0, data, &volt);
      	    #ifndef BUILD_LK
      	        printk(" lcm_compare_id tcl_oncell lishengli    volt = %d ", volt);
      	    #else
      	        printf(" lcm_compare_id tcl_onclee lishengli   volt = %d ", volt);
      	    #endif
      
      	    if(volt > 100)
      	 	 return 1;
      	    else
      		return 0;
	}
	else
	    return 0;

	//return (LCM_ID_OTM1283 == id)?1:0;
}                                     
Пример #10
0
static void light_lcd_on(int on)
{
	LCM_DBG("on=%d", on);
	if ( on ){
		mt_set_gpio_out(GPIO_LCD_BACKLIGHT_EN_PIN, GPIO_OUT_ONE);			
	}
	else{
		mt_set_gpio_out(GPIO_LCD_BACKLIGHT_EN_PIN, GPIO_OUT_ZERO);						
	}
}
Пример #11
0
static void lcm_resume(void)
{
	LCM_DBG();
	#ifdef BUILD_LK
		printf("%s, LK \n", __func__);
	#else
		printk("%s, kernel", __func__);
	#endif
	lcm_init();

}
static unsigned int lcm_adc_read_chip_id()
{
    LCM_DBG("read lcm_adc_read_chip_id\n");
    int data[4] = {0, 0, 0, 0};
    int tmp = 0, rc = 0, iVoltage = -1;
    rc = IMM_GetOneChannelValue(AUXADC_LCD_ID_CHANNEL, data, &tmp);
    if(rc < 0) {
        LCM_DBG("read LCD_ID vol erro\n");
        return 0;
    }
    else {
        iVoltage = (data[0]*1000) + (data[1]*10) + (data[2]);
        LCM_DBG("read LCD_ID success, data[0]=%d, data[1]=%d, data[2]=%d, data[3]=%d, iVoltage=%d\n",
            data[0], data[1], data[2], data[3], iVoltage);
        if(LCM_MIN_VOLTAGE < iVoltage &&
            iVoltage < LCM_MAX_VOLTAGE)
            return 1;
        else
            return 0;
    }
}
static void lcm_suspend(void)
{
	LCM_DBG("lcm_suspend");


	push_table(lcm_sleep_in_setting, sizeof(lcm_sleep_in_setting) / sizeof(struct LCM_setting_table), 1);
    SET_RESET_PIN(1);
	SET_RESET_PIN(0);	
	MDELAY(10);	
	SET_RESET_PIN(1);
    MDELAY(120);	
}
Пример #14
0
static void lcm_setbacklight(unsigned int level)
{
	LCM_DBG("level=%d", level);

	
	// Refresh value of backlight level.
	lcm_backlight_level_setting[0].para_list[0] = level;

	push_table(lcm_backlight_level_setting, sizeof(lcm_backlight_level_setting) / sizeof(struct LCM_setting_table), 1);
	
	light_lcd_on( level );
}
Пример #15
0
static void lcm_suspend(void)
{
	unsigned int data_array[2];
	LCM_DBG();

	data_array[0] = 0x00280500; // Display Off
	dsi_set_cmdq(&data_array, 1, 1);
	MDELAY(10); 
	data_array[0] = 0x00100500; // Sleep In
	dsi_set_cmdq(&data_array, 1, 1);
	MDELAY(100);
}
Пример #16
0
static void lcm_get_params(LCM_PARAMS *params)
{
	LCM_DBG();
	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   = 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;
	params->dsi.LPX      = 13;

	// 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; //0x07
	params->dsi.vertical_frontporch=2; //0x31
	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=0x1A;//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)

}
Пример #17
0
static void dsi_send_cmdq_tinno(unsigned cmd, unsigned char count, unsigned char *para_list, unsigned char force_update)
{
	unsigned int item[16];
	unsigned char dsi_cmd = (unsigned char)cmd;
	unsigned char dc;
	int index = 0, length = 0;
	
	memset(item,0,sizeof(item));
	if(count+1 > 60)
	{
		LCM_DBG("Exceed 16 entry\n");
		return;
	}
/*
	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
*/	
	if(count == 0)
	{
		item[0] = 0x0500 | (dsi_cmd<<16);
		length = 1;
	}
	else if(count == 1)
	{
		item[0] = 0x1500 | (dsi_cmd<<16) | (para_list[0]<<24);
		length = 1;
	}
	else
	{
		item[0] = 0x3902 | ((count+1)<<16);//Count include command.
		++length;
		while(1)
		{
			if (index == count+1)
				break;
			if ( 0 == index ){
				dc = cmd;
			}else{
				dc = para_list[index-1];
			}
			item[index/4+1] |= (dc<<(8*(index%4)));
			if ( index%4 == 0 ) ++length;
			++index;
		}
	}
	
	dsi_set_cmdq(&item, length, force_update);

}
static unsigned int lcm_esd_check(void)
{
    if(esdSwitch == 0){
        LCM_DBG("[Magnum] --esdSwitch == false\n");
        return 0;
    }
    unsigned int ret=0;
    ret = check_display_normal();//test_cmp_id();
    if (ret)
        return 0;
    return 1;

}
static unsigned int lcm_adc_read_chip_id()
{
	int data[4] = {0, 0, 0, 0};
	int tmp = 0, rc = 0, iVoltage = 0;
	rc = IMM_GetOneChannelValue(AUXADC_LCD_ID_CHANNEL, data, &tmp);
	if(rc < 0) {
		LCM_DBG("read LCD_ID vol error--Liu\n");
		return 0;
	}
	else {
		iVoltage = (data[0]*1000) + (data[1]*10) + (data[2]);
		LCM_DBG("Magnum read LCD_ID success, data[0]=%d, data[1]=%d, data[2]=%d, data[3]=%d, iVoltage=%d\n", data[0], data[1], data[2], data[3], iVoltage);
		if( (LCM_MIN_VOLTAGE == iVoltage) ||(LCM_MIN_VOLTAGE < iVoltage &&iVoltage < LCM_MAX_VOLTAGE))
		{
			LCM_DBG("LCM compare sucessfuell ..+++++++++++++++++\n");
			return 1;
		}
		else
			return 0;
	}
	return 0;
}
static unsigned int lcm_compare_id(void)
{
    int array[4];
    char buffer[5];
    char id_high=0;
    char id_low=0;
    int id=0;

    SET_RESET_PIN(1);
    SET_RESET_PIN(0);
    MDELAY(50);
    SET_RESET_PIN(1);
    MDELAY(100);

    push_table(lcm_compare_id_setting, sizeof(lcm_compare_id_setting) / sizeof(struct LCM_setting_table), 1);

    array[0] = 0x00023700;// set return byte number
    dsi_set_cmdq(array, 1, 1);

    read_reg_V2(0xD2, &buffer, 2);
    LCM_DBG("buffer0 == 0x%02x, buffer1 == 0x%02x \n",buffer[0],buffer[1]);

    id = buffer[0]<<8 |buffer[1];
    LCM_DBG("OTM8018B 0x%x , 0x%x , 0x%x \n",buffer[0],buffer[1],id);

    lcm_driver_id = id;
    // TBD
    lcm_module_id = 0x0;

    //return (id == LCM_ID_OTM8018B)?1:0;
    if(LCM_ID_OTM8018B == id){
        #if defined(BUILD_UBOOT) || defined(BUILD_LK)
            //return lcm_adc_read_chip_id();
        #endif
        return 1;
       }
    else
        return 0;
}
Пример #21
0
static void lcm_init(void)
{
	LCM_DBG();
//	config_gpio();
//	lcm_compare_id();

	SET_RESET_PIN(1);
	MDELAY(1);
	SET_RESET_PIN(0);
	MDELAY(10);
	SET_RESET_PIN(1);
	MDELAY(150);

//	push_table(lcm_sw_reset_setting, sizeof(lcm_sw_reset_setting) / sizeof(struct LCM_setting_table), 1);

	push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
	
	MDELAY(25);
}
Пример #22
0
static void lcm_init(void)
{

		LCM_DBG();
		#ifdef BUILD_LK
		printf("%s, LK \n", __func__);
	#else
		printk("%s, kernel", __func__);
	#endif
		//lcm_compare_id();
		//SET_RESET_PIN(0);
		lcd_power_en(1);
		MDELAY(80);
		lcd_reset(1);
		MDELAY(5);
		lcd_reset(0);
		MDELAY(5); 
		lcd_reset(1);
		MDELAY(120); 
		dsi_set_cmdq_V3(lcm_initialization_setting,sizeof(lcm_initialization_setting)/sizeof(lcm_initialization_setting[0]),1);		
}
static void lcm_init(void)
{
    int i, j;
    int size;

    LCM_DBG(" Magnum lcm_init...\n");
    SET_RESET_PIN(1);
    SET_RESET_PIN(0);
    MDELAY(10);
    SET_RESET_PIN(1);
    MDELAY(20);

    if (para_init_table != NULL)
    {
        push_table(para_init_table, para_init_size, 1);
    }
    else
    {
    push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
}
}
Пример #24
0
static void lcm_resume(void)
{
	LCM_DBG();
	push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1);
}
Пример #25
0
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
	LCM_DBG();
	memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
Пример #26
0
static void lcm_init(void)
{
	LCM_DBG();
	push_table(lcm_initialization_setting);
}
Пример #27
0
static void lcm_setpwm(unsigned int divider)
{
	LCM_DBG();
	// TBD
}
Пример #28
0
static void lcm_suspend(void)
{
	LCM_DBG();
	push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
}