C3000背光驱动

修改kernel_imx/drivers/video/backlight/pwm_bl.c就行

void lcd_backlight(int level)
{
    unsigned int iPulse;

//    printk(KERN_INFO "lcd_backlight.........qiang.......... .\n");

    if( level < 9 )
         level = 8;
    //turn the 0-255 range to mc13892's duty range 0 -32;
    level = level / 8;

    if (level > 32)
    {
        iPulse = 1;
    }
    else
    {
        iPulse = 32 - level;
    }

    gpio_set_value(GPIO_LCD_BACKLIGHT, 0);
    udelay(2000);

    while(iPulse--)
    {
        gpio_set_value(GPIO_LCD_BACKLIGHT, 1);
        udelay(5);//Jo++ 200  0--Hi == 11 us
        gpio_set_value(GPIO_LCD_BACKLIGHT, 0);
        udelay(5); //Jo++ 200    0--Low == 3 us
    }
    
    gpio_set_value(GPIO_LCD_BACKLIGHT, 1);
}

static int pwm_backlight_update_status(struct backlight_device *bl)
{
    struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev);
    int brightness = bl->props.brightness;
    int max = bl->props.max_brightness;

    if (bl->props.power != FB_BLANK_UNBLANK)
        brightness = 0;

    if (bl->props.fb_blank != FB_BLANK_UNBLANK)
        brightness = 0;

    if (pb->notify)
        brightness = pb->notify(pb->dev, brightness);

    //add by qiang   ////////////////////////
//    printk(KERN_INFO "pwm_backlight_update_status.........brightness: %d.......... .\n", brightness);

    lcd_backlight(brightness);
    /*
    if (brightness == 0) {
        pwm_config(pb->pwm, 0, pb->period);
        pwm_disable(pb->pwm);
    } else {
        pwm_config(pb->pwm, brightness * pb->period / max, pb->period);
        pwm_enable(pb->pwm);
    }*/
    ////////////////////////////////////
    return 0;
}

你可能感兴趣的:(C3000背光驱动)