15
15
#include <linux/notifier.h>
16
16
#include <linux/ctype.h>
17
17
#include <linux/err.h>
18
- #include <linux/fb.h>
19
18
#include <linux/slab.h>
20
19
21
20
#ifdef CONFIG_PMAC_BACKLIGHT
57
56
* a hot-key to adjust backlight, the driver must notify the backlight
58
57
* core that brightness has changed using backlight_force_update().
59
58
*
60
- * The backlight driver core receives notifications from fbdev and
61
- * if the event is FB_EVENT_BLANK and if the value of blank, from the
62
- * FBIOBLANK ioctrl, results in a change in the backlight state the
63
- * update_status() operation is called .
59
+ * Display drives can control the backlight device's status using
60
+ * backlight_notify_blank() and backlight_notify_blank_all(). If this
61
+ * results in a change in the backlight state the functions call the
62
+ * update_status() operation.
64
63
*/
65
64
66
65
static struct list_head backlight_dev_list ;
@@ -78,11 +77,8 @@ static const char *const backlight_scale_types[] = {
78
77
[BACKLIGHT_SCALE_NON_LINEAR ] = "non-linear" ,
79
78
};
80
79
81
- #if defined(CONFIG_FB_CORE ) || (defined(CONFIG_FB_CORE_MODULE ) && \
82
- defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE ))
83
- static void backlight_notify_blank (struct backlight_device * bd ,
84
- struct device * display_dev ,
85
- bool fb_on , bool prev_fb_on )
80
+ void backlight_notify_blank (struct backlight_device * bd , struct device * display_dev ,
81
+ bool fb_on , bool prev_fb_on )
86
82
{
87
83
guard (mutex )(& bd -> ops_lock );
88
84
@@ -103,68 +99,18 @@ static void backlight_notify_blank(struct backlight_device *bd,
103
99
}
104
100
}
105
101
}
102
+ EXPORT_SYMBOL (backlight_notify_blank );
106
103
107
- /*
108
- * fb_notifier_callback
109
- *
110
- * This callback gets called when something important happens inside a
111
- * framebuffer driver. The backlight core only cares about FB_BLANK_UNBLANK
112
- * which is reported to the driver using backlight_update_status()
113
- * as a state change.
114
- *
115
- * There may be several fbdev's connected to the backlight device,
116
- * in which case they are kept track of. A state change is only reported
117
- * if there is a change in backlight for the specified fbdev.
118
- */
119
- static int fb_notifier_callback (struct notifier_block * self ,
120
- unsigned long event , void * data )
104
+ void backlight_notify_blank_all (struct device * display_dev , bool fb_on , bool prev_fb_on )
121
105
{
122
106
struct backlight_device * bd ;
123
- struct fb_event * evdata = data ;
124
- struct fb_info * info = evdata -> info ;
125
- const int * fb_blank = evdata -> data ;
126
- struct backlight_device * fb_bd = fb_bl_device (info );
127
- bool fb_on , prev_fb_on ;
128
-
129
- /* If we aren't interested in this event, skip it immediately ... */
130
- if (event != FB_EVENT_BLANK )
131
- return 0 ;
132
-
133
- bd = container_of (self , struct backlight_device , fb_notif );
134
-
135
- if (fb_bd && fb_bd != bd )
136
- return 0 ;
137
-
138
- fb_on = fb_blank [0 ] == FB_BLANK_UNBLANK ;
139
- prev_fb_on = fb_blank [1 ] == FB_BLANK_UNBLANK ;
140
-
141
- backlight_notify_blank (bd , info -> device , fb_on , prev_fb_on );
142
-
143
- return 0 ;
144
- }
145
-
146
- static int backlight_register_fb (struct backlight_device * bd )
147
- {
148
- memset (& bd -> fb_notif , 0 , sizeof (bd -> fb_notif ));
149
- bd -> fb_notif .notifier_call = fb_notifier_callback ;
150
107
151
- return fb_register_client (& bd -> fb_notif );
152
- }
108
+ guard (mutex )(& backlight_dev_list_mutex );
153
109
154
- static void backlight_unregister_fb (struct backlight_device * bd )
155
- {
156
- fb_unregister_client (& bd -> fb_notif );
157
- }
158
- #else
159
- static inline int backlight_register_fb (struct backlight_device * bd )
160
- {
161
- return 0 ;
110
+ list_for_each_entry (bd , & backlight_dev_list , entry )
111
+ backlight_notify_blank (bd , display_dev , fb_on , prev_fb_on );
162
112
}
163
-
164
- static inline void backlight_unregister_fb (struct backlight_device * bd )
165
- {
166
- }
167
- #endif /* CONFIG_FB_CORE */
113
+ EXPORT_SYMBOL (backlight_notify_blank_all );
168
114
169
115
static void backlight_generate_event (struct backlight_device * bd ,
170
116
enum backlight_update_reason reason )
@@ -455,12 +401,6 @@ struct backlight_device *backlight_device_register(const char *name,
455
401
return ERR_PTR (rc );
456
402
}
457
403
458
- rc = backlight_register_fb (new_bd );
459
- if (rc ) {
460
- device_unregister (& new_bd -> dev );
461
- return ERR_PTR (rc );
462
- }
463
-
464
404
new_bd -> ops = ops ;
465
405
466
406
#ifdef CONFIG_PMAC_BACKLIGHT
@@ -547,7 +487,6 @@ void backlight_device_unregister(struct backlight_device *bd)
547
487
bd -> ops = NULL ;
548
488
mutex_unlock (& bd -> ops_lock );
549
489
550
- backlight_unregister_fb (bd );
551
490
device_unregister (& bd -> dev );
552
491
}
553
492
EXPORT_SYMBOL (backlight_device_unregister );
0 commit comments