Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Eric Miao and committed by
Russell King
faa312da 6ae19b04

+19 -3
+15 -3
drivers/video/backlight/lcd.c
··· 27 27 struct fb_event *evdata = data; 28 28 29 29 /* 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: 31 36 return 0; 37 + } 32 38 33 39 ld = container_of(self, struct lcd_device, fb_notif); 40 + if (!ld->ops) 41 + return 0; 42 + 34 43 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) 37 46 ld->ops->set_power(ld, *(int *)evdata->data); 47 + else 48 + ld->ops->set_mode(ld, evdata->data); 49 + } 38 50 mutex_unlock(&ld->ops_lock); 39 51 return 0; 40 52 }
+1
drivers/video/fbmem.c
··· 979 979 980 980 info->flags &= ~FBINFO_MISC_USEREVENT; 981 981 event.info = info; 982 + event.data = &mode; 982 983 fb_notifier_call_chain(evnt, &event); 983 984 } 984 985 }
+3
include/linux/lcd.h
··· 11 11 #include <linux/device.h> 12 12 #include <linux/mutex.h> 13 13 #include <linux/notifier.h> 14 + #include <linux/fb.h> 14 15 15 16 /* Notes on locking: 16 17 * ··· 46 45 int (*get_contrast)(struct lcd_device *); 47 46 /* Set LCD panel contrast */ 48 47 int (*set_contrast)(struct lcd_device *, int contrast); 48 + /* Set LCD panel mode (resolutions ...) */ 49 + int (*set_mode)(struct lcd_device *, struct fb_videomode *); 49 50 /* Check if given framebuffer device is the one LCD is bound to; 50 51 return 0 if not, !=0 if it is. If NULL, lcd always matches the fb. */ 51 52 int (*check_fb)(struct lcd_device *, struct fb_info *);