ENGR00264855 backlight: Support backlight shared by multiple fbs
One backlight device may shared by multiple framebuffers. We don't hope blanking one of the framebuffers may turn the backlight off for all the other framebuffers, since they are likely active to show display content. This patch adds logic to record each framebuffer's backlight usage to determine the backlight device use count and whether the backlight should be turned on or off. Signed-off-by: Liu Ying <Ying.Liu@freescale.com> (cherry picked from commit 37cbf741e4dff1f757f3ade6bb861d9a2af70693)
This commit is contained in:
@ -38,6 +38,7 @@ static int fb_notifier_callback(struct notifier_block *self,
|
||||
{
|
||||
struct backlight_device *bd;
|
||||
struct fb_event *evdata = data;
|
||||
int node = evdata->info->node;
|
||||
|
||||
/* If we aren't interested in this event, skip it immediately ... */
|
||||
if (event != FB_EVENT_BLANK && event != FB_EVENT_CONBLANK)
|
||||
@ -49,11 +50,21 @@ static int fb_notifier_callback(struct notifier_block *self,
|
||||
if (!bd->ops->check_fb ||
|
||||
bd->ops->check_fb(bd, evdata->info)) {
|
||||
bd->props.fb_blank = *(int *)evdata->data;
|
||||
if (bd->props.fb_blank == FB_BLANK_UNBLANK)
|
||||
bd->props.state &= ~BL_CORE_FBBLANK;
|
||||
else
|
||||
bd->props.state |= BL_CORE_FBBLANK;
|
||||
backlight_update_status(bd);
|
||||
if (bd->props.fb_blank == FB_BLANK_UNBLANK &&
|
||||
!bd->fb_bl_on[node]) {
|
||||
bd->fb_bl_on[node] = true;
|
||||
if (!bd->use_count++) {
|
||||
bd->props.state &= ~BL_CORE_FBBLANK;
|
||||
backlight_update_status(bd);
|
||||
}
|
||||
} else if (bd->props.fb_blank != FB_BLANK_UNBLANK &&
|
||||
bd->fb_bl_on[node]) {
|
||||
bd->fb_bl_on[node] = false;
|
||||
if (!(--bd->use_count)) {
|
||||
bd->props.state |= BL_CORE_FBBLANK;
|
||||
backlight_update_status(bd);
|
||||
}
|
||||
}
|
||||
}
|
||||
mutex_unlock(&bd->ops_lock);
|
||||
return 0;
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#define _LINUX_BACKLIGHT_H
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/notifier.h>
|
||||
|
||||
@ -101,6 +102,11 @@ struct backlight_device {
|
||||
struct notifier_block fb_notif;
|
||||
|
||||
struct device dev;
|
||||
|
||||
/* Multiple framebuffers may share one backlight device */
|
||||
bool fb_bl_on[FB_MAX];
|
||||
|
||||
int use_count;
|
||||
};
|
||||
|
||||
static inline void backlight_update_status(struct backlight_device *bd)
|
||||
|
||||
Reference in New Issue
Block a user