Skip to content

Commit e98696c

Browse files
Thomas Zimmermannlag-linaro
authored andcommitted
backlight: lcd: Move event handling into helpers
Move the handling of display updates to separate helper functions. There is code for handling fbdev blank events and fbdev mode changes. The code currently runs from fbdev event notifiers, which will be replaced. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: "Daniel Thompson (RISCstar)" <danielt@kernel.org> Acked-by: Simona Vetter <simona.vetter@ffwll.ch> Link: https://lore.kernel.org/r/20250321095517.313713-8-tzimmermann@suse.de Signed-off-by: Lee Jones <lee@kernel.org>
1 parent b01beb2 commit e98696c

File tree

1 file changed

+28
-10
lines changed
  • drivers/video/backlight

1 file changed

+28
-10
lines changed

drivers/video/backlight/lcd.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,32 @@
1818
#include <linux/fb.h>
1919
#include <linux/slab.h>
2020

21+
static void lcd_notify_blank(struct lcd_device *ld, struct device *display_dev,
22+
int power)
23+
{
24+
guard(mutex)(&ld->ops_lock);
25+
26+
if (!ld->ops || !ld->ops->set_power)
27+
return;
28+
if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev))
29+
return;
30+
31+
ld->ops->set_power(ld, power);
32+
}
33+
34+
static void lcd_notify_mode_change(struct lcd_device *ld, struct device *display_dev,
35+
unsigned int width, unsigned int height)
36+
{
37+
guard(mutex)(&ld->ops_lock);
38+
39+
if (!ld->ops || !ld->ops->set_mode)
40+
return;
41+
if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev))
42+
return;
43+
44+
ld->ops->set_mode(ld, width, height);
45+
}
46+
2147
#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
2248
defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
2349
static int to_lcd_power(int fb_blank)
@@ -50,25 +76,17 @@ static int fb_notifier_callback(struct notifier_block *self,
5076
struct fb_info *info = evdata->info;
5177
struct lcd_device *fb_lcd = fb_lcd_device(info);
5278

53-
guard(mutex)(&ld->ops_lock);
54-
55-
if (!ld->ops)
56-
return 0;
57-
if (ld->ops->controls_device && !ld->ops->controls_device(ld, info->device))
58-
return 0;
5979
if (fb_lcd && fb_lcd != ld)
6080
return 0;
6181

6282
if (event == FB_EVENT_BLANK) {
6383
int power = to_lcd_power(*(int *)evdata->data);
6484

65-
if (ld->ops->set_power)
66-
ld->ops->set_power(ld, power);
85+
lcd_notify_blank(ld, info->device, power);
6786
} else {
6887
const struct fb_videomode *videomode = evdata->data;
6988

70-
if (ld->ops->set_mode)
71-
ld->ops->set_mode(ld, videomode->xres, videomode->yres);
89+
lcd_notify_mode_change(ld, info->device, videomode->xres, videomode->yres);
7290
}
7391

7492
return 0;

0 commit comments

Comments
 (0)