Skip to content

Commit faa312d

Browse files
Eric MiaoRussell King
authored andcommitted
lcd: allow lcd device to handle mode change events
Some LCD panels are capable of different resolutions, and is allowed to change at run-time, so to make "struct lcd_device" to be able to handle mode change events here. Signed-off-by: Eric Miao <eric.miao@marvell.com> Acked-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 6ae19b0 commit faa312d

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎drivers/video/backlight/lcd.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,26 @@ static int fb_notifier_callback(struct notifier_block *self,
2727
struct fb_event *evdata = data;
2828

2929
/* If we aren't interested in this event, skip it immediately ... */
30-
if (event != FB_EVENT_BLANK)
30+
switch (event) {
31+
case FB_EVENT_BLANK:
32+
case FB_EVENT_MODE_CHANGE:
33+
case FB_EVENT_MODE_CHANGE_ALL:
34+
break;
35+
default:
3136
return 0;
37+
}
3238

3339
ld = container_of(self, struct lcd_device, fb_notif);
40+
if (!ld->ops)
41+
return 0;
42+
3443
mutex_lock(&ld->ops_lock);
35-
if (ld->ops)
36-
if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info))
44+
if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) {
45+
if (event == FB_EVENT_BLANK)
3746
ld->ops->set_power(ld, *(int *)evdata->data);
47+
else
48+
ld->ops->set_mode(ld, evdata->data);
49+
}
3850
mutex_unlock(&ld->ops_lock);
3951
return 0;
4052
}

‎drivers/video/fbmem.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
979979

980980
info->flags &= ~FBINFO_MISC_USEREVENT;
981981
event.info = info;
982+
event.data = &mode;
982983
fb_notifier_call_chain(evnt, &event);
983984
}
984985
}

‎include/linux/lcd.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/device.h>
1212
#include <linux/mutex.h>
1313
#include <linux/notifier.h>
14+
#include <linux/fb.h>
1415

1516
/* Notes on locking:
1617
*
@@ -45,6 +46,8 @@ struct lcd_ops {
4546
int (*get_contrast)(struct lcd_device *);
4647
/* Set LCD panel contrast */
4748
int (*set_contrast)(struct lcd_device *, int contrast);
49+
/* Set LCD panel mode (resolutions ...) */
50+
int (*set_mode)(struct lcd_device *, struct fb_videomode *);
4851
/* Check if given framebuffer device is the one LCD is bound to;
4952
return 0 if not, !=0 if it is. If NULL, lcd always matches the fb. */
5053
int (*check_fb)(struct lcd_device *, struct fb_info *);

0 commit comments

Comments
 (0)