在调光代码中添加spinlock 解决
#define MAX_LEVEL 240
#define MIN_LEVEL 15
static void gpio_bl_set(struct mdss_panel_data *pdata,u32 bl_level)
{
static int old_brightness = 0;
int new_brightness = bl_level;
static int brightness_level = 0;
int i;
int old_count = 0; //当前上升沿个数
int new_count = 0; //目标上升沿个数
int total_count = 0; //需要调节的脉冲数
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
unsigned long flags;
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
panel_data);
pr_err("peter : bl_level is %d\n",bl_level);
if (ctrl_pdata == NULL)
{
pr_err("%s: ctrl_pdata\n", __func__);
return;
}
if(new_brightness >= MAX_LEVEL)
new_brightness = MAX_LEVEL;
if(new_brightness <= MIN_LEVEL && new_brightness > 0)
new_brightness = MIN_LEVEL;
if(new_brightness == 0)
{
gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 0);
pr_err("bl_level = 0, close bl...\n");
old_brightness = new_brightness;
return;
}
else if(old_brightness == 0)
{
//first pulse must set high more than 20 us
gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 1);
udelay(20);
brightness_level = new_brightness / 15;
total_count = 16 - brightness_level;
pr_err("new_brightness:%d,total_count %d, when old==0\n",new_brightness,total_count);
spin_lock_irqsave(&aw_lock,flags);
for (i = 0; i < total_count; i++)
{
gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 0);
//udelay(2);
gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 1);
//udelay(2);
}
spin_unlock_irqrestore(&aw_lock,flags);
}
else
{
brightness_level = new_brightness / 15;
new_count = 17 - brightness_level;
brightness_level = old_brightness / 15;
old_count = 17 - brightness_level;
if(old_brightness < new_brightness)
{
pr_err("up up up\n");
pr_err("new_count = %d, old_count = %d\n", new_count, old_count);
total_count = new_count - old_count + 16;
//first pulse must set high more than 20 us
//gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 1);
//udelay(20);
spin_lock_irqsave(&aw_lock,flags);
for (i = 0; i < total_count; i++)
{
gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 0);
//udelay(2);
gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 1);
//udelay(2);
}
spin_unlock_irqrestore(&aw_lock,flags);
}
else if(old_brightness > new_brightness)
{
pr_err("down down down\n");
pr_err("new_count = %d, old_count = %d\n", new_count, old_count);
total_count = new_count - old_count;
//first pulse must set high more than 20 us
//gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 1);
//udelay(20);
spin_lock_irqsave(&aw_lock,flags);
for (i = 0; i < total_count; i++)
{
gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 0);
//udelay(2);
gpio_direction_output(ctrl_pdata->aw9364_en_gpio, 1);
//udelay(2);
}
spin_unlock_irqrestore(&aw_lock,flags);
}
else
{
total_count = new_count;
}
}
pr_err("over: old_brightness = %d, new_brightness = %d, total_count = %d\n", old_brightness, new_brightness, total_count);
old_brightness = new_brightness;
}