MTK6515 配置lcd背光

  • 1 配置lcm背光的控制脚
  • 2 配置uboot
    • 2.1 mediatek/custom/bbk75_ics/uboot/cust_leds.c
    • 2.2 mediatek/platform/mt6575/uboot/mt65xx_leds.c
  • 3 配置kernel
    • 3.1 mediatek/custom/bbk75_ics/kernel/leds/mt65xx/cust_leds.c
    • 3.2 mediatek/source/kernel/drivers/leds/leds.c
  • 4 注意事项

配置lcm背光的控制脚

lcm背光控制主要有两个引脚:使能脚EN和亮度控制引脚VFB。使能脚用来控制背光的使能与否,比如这里是1为enable,0为disable;亮度控制引脚则是用来接PWM输出,通过PWM的占空比来控制背光亮度,这里是低为亮,高为灭。

所以在这两个引脚的连接和配置上要保证EN连接至gpio上,而VFB则连接至BB的PWM输出口,然后通过dct工具将上述引脚配置成对应的mode。

配置uboot

mediatek/custom/bbk75_ics/uboot/cust_leds.c

在 cust_led_list数组中更改 lcd-backlight的配置为pwm:

static struct cust_mt65xx_led cust_led_list[MT65XX_LED_TYPE_TOTAL] = {
...
	//{"lcd-backlight",     MT65XX_LED_MODE_CUST, (int)DISP_SetBacklight,{0}},
	{"lcd-backlight",     MT65XX_LED_MODE_PWM, PWM1,{0}},
};

mediatek/platform/mt6575/uboot/mt65xx_leds.c

在 mt65xx_led_set_cust中添加对lcm使能脚的控制,以更好地对屏幕的亮灭进行控制:

...
		case MT65XX_LED_MODE_PWM:
			if(strcmp(cust->name,"lcd-backlight") == 0)
			{
				if(level == 0)
				{
					mt_set_gpio_out(BACKLIGHT_EN_PIN,GPIO_OUT_ZERO);	
				
				}else
				{
					if (level < 80) level =80;
					level = level/4;
					brightness_set_pwm(cust->data, level,&(cust->config_data));
					udelay(10000);
					mt_set_gpio_out(BACKLIGHT_EN_PIN,GPIO_OUT_ONE);
				}
            
			//return brightness_set_pwm(cust->data, level,&cust->config_data);
			}
			else
			{
				return led_set_pwm(cust->data, level);
			}
			return 1;
		case MT65XX_LED_MODE_GPIO:
...

以下两个函数同步更改:

void mt65xx_backlight_on(void)
{
	printf("[LEDS]uboot: mt65xx_backlight_on \n\r");
	mt_set_gpio_mode(BACKLIGHT_EN_PIN, GPIO_MODE_00);// GPIO MODE
	mt_set_gpio_dir(BACKLIGHT_EN_PIN, GPIO_DIR_OUT);
	mt_set_gpio_out(BACKLIGHT_EN_PIN, GPIO_OUT_ONE); 
	mt65xx_leds_brightness_set(MT65XX_LED_TYPE_LCD, LED_FULL);
}

void mt65xx_backlight_off(void)
{
	printf("[LEDS]uboot: mt65xx_backlight_off \n\r");
	mt_set_gpio_mode(BACKLIGHT_EN_PIN, GPIO_MODE_00);// GPIO MODE
	mt_set_gpio_dir(BACKLIGHT_EN_PIN, GPIO_DIR_OUT);
	mt_set_gpio_out(BACKLIGHT_EN_PIN, GPIO_OUT_ZERO);    
	mt65xx_leds_brightness_set(MT65XX_LED_TYPE_LCD, LED_OFF);
}


配置kernel

mediatek/custom/bbk75_ics/kernel/leds/mt65xx/cust_leds.c

将背光led的控制方式更改为pwm:

static struct cust_mt65xx_led cust_led_list[MT65XX_LED_TYPE_TOTAL] = {
...
	///{"lcd-backlight",     MT65XX_LED_MODE_CUST, (int)Cust_SetBacklight,{0}},
	{"lcd-backlight",     MT65XX_LED_MODE_PWM, PWM1,{0}},    
};

mediatek/source/kernel/drivers/leds/leds.c

和uboot一样,在 mt65xx_led_set_cust中添加对lcm使能脚的控制,以更好地对屏幕的亮灭进行控制:

	if (level > LED_FULL)
		level = LED_FULL;
	else if (level < 0)
		level = 0;
	mt_set_gpio_mode(BACKLIGHT_EN_PIN, GPIO_MODE_GPIO);
	mt_set_gpio_dir(BACKLIGHT_EN_PIN, GPIO_DIR_OUT);
	mt_set_gpio_mode(BACKLIGHT_VFB_PIN, GPIO_MODE_01);
	mt_set_gpio_dir(BACKLIGHT_VFB_PIN, GPIO_DIR_OUT); //GPIO_PWM_1_PIN_M_PWM

    printk("mt65xx_leds_set_cust: set brightness, name:%s, mode:%d, level:%d\n", 
		cust->name, cust->mode, level);
	switch (cust->mode) {
		case MT65XX_LED_MODE_PWM:
			if(strcmp(cust->name,"lcd-backlight") == 0)
			{
				bl_brightness = level;
				if(level == 0)
				{
					mt_set_gpio_out(BACKLIGHT_EN_PIN,GPIO_OUT_ZERO);
					mt_set_pwm_disable(cust->data);
					mt_power_off (cust->data);
				}else
				{
					level = brightness_mapping(tmp_level);
					if(level > 0 && level < 20 ) level = 20;//45
						if ( level < 195 ) 
						{
							level=(level-20)/7;
						}
						else
						{
							level=level - 20 ;
							level=(level-175)/4; 
							level=level+25;
						}
					if (level > 244 && level < 255) level =244; //level 37
					//if (level > 54) level = 54;
					backlight_set_pwm(cust->data, level, bl_div,&(cust->config_data));
					mt_set_gpio_out(BACKLIGHT_EN_PIN,GPIO_OUT_ONE);
				}
                bl_duty = level;	
				
			}else
			{
				if(level == 0)
				{
					led_tmp_setting.nled_mode = NLED_OFF;
				}else
				{
					led_tmp_setting.nled_mode = NLED_ON;
				}
				led_set_pwm(cust->data,&led_tmp_setting);
			}
			return 1;
            
		case MT65XX_LED_MODE_GPIO:

注意事项

如果uboot中将VFB配置成了gpio并且输出低使背光一直保持全亮,在进入kernel后通过代码再将其设置为pwm模式,这理应是ok的;但现实就是不行,这样会导致背光不能调节(不过由于没有量波形,故不知是有波形输出还是仍一直输出低电平),就在这里耗时较长,所以关注一下这点。


附修改记录:

Modified : /trunk/ALPS.ICS.MP.V1_T_20120405/mediatek/custom/bbk15_td_ics/kernel/leds/mt65xx/cust_leds.c
Modified : /trunk/ALPS.ICS.MP.V1_T_20120405/mediatek/custom/bbk15_td_ics/uboot/cust_leds.c
Modified : /trunk/ALPS.ICS.MP.V1_T_20120405/mediatek/platform/mt6575/uboot/mt65xx_leds.c
Modified : /trunk/ALPS.ICS.MP.V1_T_20120405/mediatek/source/kernel/drivers/leds/leds.c

你可能感兴趣的:(list,struct,div,工具,MTK)