Lines Matching refs:bd
43 struct backlight_device *bd; in fb_notifier_callback() local
52 bd = container_of(self, struct backlight_device, fb_notif); in fb_notifier_callback()
53 mutex_lock(&bd->ops_lock); in fb_notifier_callback()
54 if (bd->ops) in fb_notifier_callback()
55 if (!bd->ops->check_fb || in fb_notifier_callback()
56 bd->ops->check_fb(bd, evdata->info)) { in fb_notifier_callback()
59 !bd->fb_bl_on[node]) { in fb_notifier_callback()
60 bd->fb_bl_on[node] = true; in fb_notifier_callback()
61 if (!bd->use_count++) { in fb_notifier_callback()
62 bd->props.state &= ~BL_CORE_FBBLANK; in fb_notifier_callback()
63 bd->props.fb_blank = FB_BLANK_UNBLANK; in fb_notifier_callback()
64 backlight_update_status(bd); in fb_notifier_callback()
67 bd->fb_bl_on[node]) { in fb_notifier_callback()
68 bd->fb_bl_on[node] = false; in fb_notifier_callback()
69 if (!(--bd->use_count)) { in fb_notifier_callback()
70 bd->props.state |= BL_CORE_FBBLANK; in fb_notifier_callback()
71 bd->props.fb_blank = fb_blank; in fb_notifier_callback()
72 backlight_update_status(bd); in fb_notifier_callback()
76 mutex_unlock(&bd->ops_lock); in fb_notifier_callback()
80 static int backlight_register_fb(struct backlight_device *bd) in backlight_register_fb() argument
82 memset(&bd->fb_notif, 0, sizeof(bd->fb_notif)); in backlight_register_fb()
83 bd->fb_notif.notifier_call = fb_notifier_callback; in backlight_register_fb()
85 return fb_register_client(&bd->fb_notif); in backlight_register_fb()
88 static void backlight_unregister_fb(struct backlight_device *bd) in backlight_unregister_fb() argument
90 fb_unregister_client(&bd->fb_notif); in backlight_unregister_fb()
93 static inline int backlight_register_fb(struct backlight_device *bd) in backlight_register_fb() argument
98 static inline void backlight_unregister_fb(struct backlight_device *bd) in backlight_unregister_fb() argument
103 static void backlight_generate_event(struct backlight_device *bd, in backlight_generate_event() argument
120 kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp); in backlight_generate_event()
121 sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness"); in backlight_generate_event()
127 struct backlight_device *bd = to_backlight_device(dev); in bl_power_show() local
129 return sprintf(buf, "%d\n", bd->props.power); in bl_power_show()
136 struct backlight_device *bd = to_backlight_device(dev); in bl_power_store() local
144 mutex_lock(&bd->ops_lock); in bl_power_store()
145 if (bd->ops) { in bl_power_store()
147 if (bd->props.power != power) { in bl_power_store()
148 old_power = bd->props.power; in bl_power_store()
149 bd->props.power = power; in bl_power_store()
150 rc = backlight_update_status(bd); in bl_power_store()
152 bd->props.power = old_power; in bl_power_store()
159 mutex_unlock(&bd->ops_lock); in bl_power_store()
168 struct backlight_device *bd = to_backlight_device(dev); in brightness_show() local
170 return sprintf(buf, "%d\n", bd->props.brightness); in brightness_show()
173 int backlight_device_set_brightness(struct backlight_device *bd, in backlight_device_set_brightness() argument
178 mutex_lock(&bd->ops_lock); in backlight_device_set_brightness()
179 if (bd->ops) { in backlight_device_set_brightness()
180 if (brightness > bd->props.max_brightness) in backlight_device_set_brightness()
184 bd->props.brightness = brightness; in backlight_device_set_brightness()
185 rc = backlight_update_status(bd); in backlight_device_set_brightness()
188 mutex_unlock(&bd->ops_lock); in backlight_device_set_brightness()
190 backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS); in backlight_device_set_brightness()
200 struct backlight_device *bd = to_backlight_device(dev); in brightness_store() local
207 rc = backlight_device_set_brightness(bd, brightness); in brightness_store()
216 struct backlight_device *bd = to_backlight_device(dev); in type_show() local
218 return sprintf(buf, "%s\n", backlight_types[bd->props.type]); in type_show()
225 struct backlight_device *bd = to_backlight_device(dev); in max_brightness_show() local
227 return sprintf(buf, "%d\n", bd->props.max_brightness); in max_brightness_show()
235 struct backlight_device *bd = to_backlight_device(dev); in actual_brightness_show() local
237 mutex_lock(&bd->ops_lock); in actual_brightness_show()
238 if (bd->ops && bd->ops->get_brightness) in actual_brightness_show()
239 rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd)); in actual_brightness_show()
241 rc = sprintf(buf, "%d\n", bd->props.brightness); in actual_brightness_show()
242 mutex_unlock(&bd->ops_lock); in actual_brightness_show()
253 struct backlight_device *bd = to_backlight_device(dev); in backlight_suspend() local
255 mutex_lock(&bd->ops_lock); in backlight_suspend()
256 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { in backlight_suspend()
257 bd->props.state |= BL_CORE_SUSPENDED; in backlight_suspend()
258 backlight_update_status(bd); in backlight_suspend()
260 mutex_unlock(&bd->ops_lock); in backlight_suspend()
267 struct backlight_device *bd = to_backlight_device(dev); in backlight_resume() local
269 mutex_lock(&bd->ops_lock); in backlight_resume()
270 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { in backlight_resume()
271 bd->props.state &= ~BL_CORE_SUSPENDED; in backlight_resume()
272 backlight_update_status(bd); in backlight_resume()
274 mutex_unlock(&bd->ops_lock); in backlight_resume()
285 struct backlight_device *bd = to_backlight_device(dev); in bl_device_release() local
286 kfree(bd); in bl_device_release()
307 void backlight_force_update(struct backlight_device *bd, in backlight_force_update() argument
310 mutex_lock(&bd->ops_lock); in backlight_force_update()
311 if (bd->ops && bd->ops->get_brightness) in backlight_force_update()
312 bd->props.brightness = bd->ops->get_brightness(bd); in backlight_force_update()
313 mutex_unlock(&bd->ops_lock); in backlight_force_update()
314 backlight_generate_event(bd, reason); in backlight_force_update()
400 struct backlight_device *bd; in backlight_device_get_by_type() local
403 list_for_each_entry(bd, &backlight_dev_list, entry) { in backlight_device_get_by_type()
404 if (bd->props.type == type) { in backlight_device_get_by_type()
411 return found ? bd : NULL; in backlight_device_get_by_type()
421 void backlight_device_unregister(struct backlight_device *bd) in backlight_device_unregister() argument
423 if (!bd) in backlight_device_unregister()
427 list_del(&bd->entry); in backlight_device_unregister()
432 if (pmac_backlight == bd) in backlight_device_unregister()
438 BACKLIGHT_UNREGISTERED, bd); in backlight_device_unregister()
440 mutex_lock(&bd->ops_lock); in backlight_device_unregister()
441 bd->ops = NULL; in backlight_device_unregister()
442 mutex_unlock(&bd->ops_lock); in backlight_device_unregister()
444 backlight_unregister_fb(bd); in backlight_device_unregister()
445 device_unregister(&bd->dev); in backlight_device_unregister()
544 struct backlight_device *bd) in devm_backlight_device_unregister() argument
549 devm_backlight_device_match, bd); in devm_backlight_device_unregister()