Mtk6573平台调LCM亮度

MTK6573平台修改LCM的最高亮度,有几种方法修改。

1.修改中检测,把上层的亮度值加转换,限制最大值。比如最大的亮度,上层写到sys 里是255,那我在中间层把这个值变为200,那驱动层收到的值就是200. 

这样最大亮度就降低了。同理,可以把最小亮度给提高一些。 

看下面代码 找到lights.c文件 

tatic struct light_state_t g_notification;
static struct light_state_t g_battery;
static int g_backlight = 200;
static int g_trackball = -1;
static int g_buttons = 0;
static int g_attention = 0;

/* TRACKBALL BACKLIGHT */
char const*const TRACKBALL_FILE
        = "/sys/class/leds/jogball-backlight/brightness";

/* RED LED */
char const*const RED_LED_FILE
        = "/sys/class/leds/red/brightness";

char const*const RED_TRIGGER_FILE
        = "/sys/class/leds/red/trigger";

char const*const RED_DELAY_ON_FILE
        = "/sys/class/leds/red/delay_on";

char const*const RED_DELAY_OFF_FILE
        = "/sys/class/leds/red/delay_off";

/* GREEN LED */
char const*const GREEN_LED_FILE
        = "/sys/class/leds/green/brightness";

char const*const GREEN_TRIGGER_FILE
        = "/sys/class/leds/green/trigger";

char const*const GREEN_DELAY_ON_FILE
        = "/sys/class/leds/green/delay_on";

char const*const GREEN_DELAY_OFF_FILE
        = "/sys/class/leds/green/delay_off";

/* BLUE LED */
char const*const BLUE_LED_FILE
        = "/sys/class/leds/blue/brightness";

char const*const BLUE_TRIGGER_FILE
        = "/sys/class/leds/blue/trigger";

char const*const BLUE_DELAY_ON_FILE
        = "/sys/class/leds/blue/delay_on";

char const*const BLUE_DELAY_OFF_FILE
        = "/sys/class/leds/blue/delay_off";

/* LCD BACKLIGHT */
char const*const LCD_FILE
        = "/sys/class/leds/lcd-backlight/brightness";

/* KEYBOARD BACKLIGHT */
char const*const KEYBOARD_FILE
        = "/sys/class/leds/keyboard-backlight/brightness";// 屏的接口文件。

/* BUTTON BACKLIGHT */
char const*const BUTTON_FILE
        = "/sys/class/leds/button-backlight/brightness";



set_light_backlight(struct light_device_t* dev,
        struct light_state_t const* state)
{
    int err = 0;
    int brightness = rgb_to_brightness(state);
    pthread_mutex_lock(&g_lock);
	LOGD("%s: brightness=%d start+++\n", __func__, brightness);
	if(brightness>200)
		brightness=200;//这里就是把上层传下来的给变换了。
    g_backlight = brightness;
    err = write_int(LCD_FILE, brightness);
    if (g_haveTrackballLight) {
        handle_trackball_light_locked(dev);
    }
    pthread_mutex_unlock(&g_lock);
    return err;
}


这是在中间层来实现。


二,当然也可以在我们的pwm,驱动里来做,

 

static int backlight_set_pwm(int pwm_num, u32 level, u32 div)
{
	struct pwm_spec_config pwm_setting;
	pwm_setting.pwm_no = pwm_num;
	pwm_setting.mode = PWM_MODE_FIFO; //new mode fifo and periodical mode
	pwm_setting.clk_div = div;
	pwm_setting.clk_src = PWM_CLK_NEW_MODE_BLOCK;//PWM_CLK_NEW_MODE_BLOCK_DIV_BY_1625;
	
	pwm_setting.PWM_MODE_FIFO_REGS.IDLE_VALUE = 0;
	pwm_setting.PWM_MODE_FIFO_REGS.GUARD_VALUE = 0;
	pwm_setting.PWM_MODE_FIFO_REGS.STOP_BITPOS_VALUE = 63;
	pwm_setting.PWM_MODE_FIFO_REGS.HDURATION = 4;
	pwm_setting.PWM_MODE_FIFO_REGS.LDURATION = 4;
	pwm_setting.PWM_MODE_FIFO_REGS.GDURATION = 0;
	pwm_setting.PWM_MODE_FIFO_REGS.WAVE_NUM = 0;
	
	LEDS_DEBUG("[LED]backlight_set_pwm:duty is %d\n", level);
    if(level <= 32)
	{
		pwm_setting.PWM_MODE_FIFO_REGS.SEND_DATA0 =  (1 << level) - 1 ;
		pwm_setting.PWM_MODE_FIFO_REGS.SEND_DATA1 = 0 ;
	}else if(level>32 && level <=64)
	{
	   //level -= 32;//32
	   if(level>28)level=28; //因为硬件的亮度等级是0--31,32个等级。我们把硬件的最大亮度等级设置为28,也达到了目的。
		pwm_setting.PWM_MODE_FIFO_REGS.SEND_DATA0 =  0xFFFFFFFF ;
		pwm_setting.PWM_MODE_FIFO_REGS.SEND_DATA1 = (1 << level) - 1;
	}else
	{
		LEDS_DEBUG("[LED]Error level in backlight\n");
	}

	pwm_set_spec_config(&pwm_setting);
	//printk("[LED]PWM con register is %x \n", INREG32(PWM_BASE + 0x0150));
	return 0;

}



转载于:https://www.cnblogs.com/yuzaipiaofei/archive/2012/01/14/4124287.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值