Lines Matching refs:bd

50 	struct backlight_device *bd;  in fb_notifier_callback()  local
59 bd = container_of(self, struct backlight_device, fb_notif); in fb_notifier_callback()
60 mutex_lock(&bd->ops_lock); in fb_notifier_callback()
61 if (bd->ops) in fb_notifier_callback()
62 if (!bd->ops->check_fb || in fb_notifier_callback()
63 bd->ops->check_fb(bd, evdata->info)) { in fb_notifier_callback()
66 !bd->fb_bl_on[node]) { in fb_notifier_callback()
67 bd->fb_bl_on[node] = true; in fb_notifier_callback()
68 if (!bd->use_count++) { in fb_notifier_callback()
69 bd->props.state &= ~BL_CORE_FBBLANK; in fb_notifier_callback()
70 bd->props.fb_blank = FB_BLANK_UNBLANK; in fb_notifier_callback()
71 backlight_update_status(bd); in fb_notifier_callback()
74 bd->fb_bl_on[node]) { in fb_notifier_callback()
75 bd->fb_bl_on[node] = false; in fb_notifier_callback()
76 if (!(--bd->use_count)) { in fb_notifier_callback()
77 bd->props.state |= BL_CORE_FBBLANK; in fb_notifier_callback()
78 bd->props.fb_blank = fb_blank; in fb_notifier_callback()
79 backlight_update_status(bd); in fb_notifier_callback()
83 mutex_unlock(&bd->ops_lock); in fb_notifier_callback()
87 static int backlight_register_fb(struct backlight_device *bd) in backlight_register_fb() argument
89 memset(&bd->fb_notif, 0, sizeof(bd->fb_notif)); in backlight_register_fb()
90 bd->fb_notif.notifier_call = fb_notifier_callback; in backlight_register_fb()
92 return fb_register_client(&bd->fb_notif); in backlight_register_fb()
95 static void backlight_unregister_fb(struct backlight_device *bd) in backlight_unregister_fb() argument
97 fb_unregister_client(&bd->fb_notif); in backlight_unregister_fb()
100 static inline int backlight_register_fb(struct backlight_device *bd) in backlight_register_fb() argument
105 static inline void backlight_unregister_fb(struct backlight_device *bd) in backlight_unregister_fb() argument
110 static void backlight_generate_event(struct backlight_device *bd, in backlight_generate_event() argument
127 kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp); in backlight_generate_event()
128 sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness"); in backlight_generate_event()
134 struct backlight_device *bd = to_backlight_device(dev); in bl_power_show() local
136 return sprintf(buf, "%d\n", bd->props.power); in bl_power_show()
143 struct backlight_device *bd = to_backlight_device(dev); in bl_power_store() local
151 mutex_lock(&bd->ops_lock); in bl_power_store()
152 if (bd->ops) { in bl_power_store()
154 if (bd->props.power != power) { in bl_power_store()
155 old_power = bd->props.power; in bl_power_store()
156 bd->props.power = power; in bl_power_store()
157 rc = backlight_update_status(bd); in bl_power_store()
159 bd->props.power = old_power; in bl_power_store()
166 mutex_unlock(&bd->ops_lock); in bl_power_store()
175 struct backlight_device *bd = to_backlight_device(dev); in brightness_show() local
177 return sprintf(buf, "%d\n", bd->props.brightness); in brightness_show()
180 int backlight_device_set_brightness(struct backlight_device *bd, in backlight_device_set_brightness() argument
185 mutex_lock(&bd->ops_lock); in backlight_device_set_brightness()
186 if (bd->ops) { in backlight_device_set_brightness()
187 if (brightness > bd->props.max_brightness) in backlight_device_set_brightness()
191 bd->props.brightness = brightness; in backlight_device_set_brightness()
192 rc = backlight_update_status(bd); in backlight_device_set_brightness()
195 mutex_unlock(&bd->ops_lock); in backlight_device_set_brightness()
197 backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS); in backlight_device_set_brightness()
207 struct backlight_device *bd = to_backlight_device(dev); in brightness_store() local
214 rc = backlight_device_set_brightness(bd, brightness); in brightness_store()
223 struct backlight_device *bd = to_backlight_device(dev); in type_show() local
225 return sprintf(buf, "%s\n", backlight_types[bd->props.type]); in type_show()
232 struct backlight_device *bd = to_backlight_device(dev); in max_brightness_show() local
234 return sprintf(buf, "%d\n", bd->props.max_brightness); in max_brightness_show()
242 struct backlight_device *bd = to_backlight_device(dev); in actual_brightness_show() local
244 mutex_lock(&bd->ops_lock); in actual_brightness_show()
245 if (bd->ops && bd->ops->get_brightness) in actual_brightness_show()
246 rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd)); in actual_brightness_show()
248 rc = sprintf(buf, "%d\n", bd->props.brightness); in actual_brightness_show()
249 mutex_unlock(&bd->ops_lock); in actual_brightness_show()
258 struct backlight_device *bd = to_backlight_device(dev); in scale_show() local
260 if (WARN_ON(bd->props.scale > BACKLIGHT_SCALE_NON_LINEAR)) in scale_show()
263 return sprintf(buf, "%s\n", backlight_scale_types[bd->props.scale]); in scale_show()
272 struct backlight_device *bd = to_backlight_device(dev); in backlight_suspend() local
274 mutex_lock(&bd->ops_lock); in backlight_suspend()
275 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { in backlight_suspend()
276 bd->props.state |= BL_CORE_SUSPENDED; in backlight_suspend()
277 backlight_update_status(bd); in backlight_suspend()
279 mutex_unlock(&bd->ops_lock); in backlight_suspend()
286 struct backlight_device *bd = to_backlight_device(dev); in backlight_resume() local
288 mutex_lock(&bd->ops_lock); in backlight_resume()
289 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { in backlight_resume()
290 bd->props.state &= ~BL_CORE_SUSPENDED; in backlight_resume()
291 backlight_update_status(bd); in backlight_resume()
293 mutex_unlock(&bd->ops_lock); in backlight_resume()
304 struct backlight_device *bd = to_backlight_device(dev); in bl_device_release() local
305 kfree(bd); in bl_device_release()
327 void backlight_force_update(struct backlight_device *bd, in backlight_force_update() argument
330 mutex_lock(&bd->ops_lock); in backlight_force_update()
331 if (bd->ops && bd->ops->get_brightness) in backlight_force_update()
332 bd->props.brightness = bd->ops->get_brightness(bd); in backlight_force_update()
333 mutex_unlock(&bd->ops_lock); in backlight_force_update()
334 backlight_generate_event(bd, reason); in backlight_force_update()
420 struct backlight_device *bd; in backlight_device_get_by_type() local
423 list_for_each_entry(bd, &backlight_dev_list, entry) { in backlight_device_get_by_type()
424 if (bd->props.type == type) { in backlight_device_get_by_type()
431 return found ? bd : NULL; in backlight_device_get_by_type()
441 void backlight_device_unregister(struct backlight_device *bd) in backlight_device_unregister() argument
443 if (!bd) in backlight_device_unregister()
447 list_del(&bd->entry); in backlight_device_unregister()
452 if (pmac_backlight == bd) in backlight_device_unregister()
458 BACKLIGHT_UNREGISTERED, bd); in backlight_device_unregister()
460 mutex_lock(&bd->ops_lock); in backlight_device_unregister()
461 bd->ops = NULL; in backlight_device_unregister()
462 mutex_unlock(&bd->ops_lock); in backlight_device_unregister()
464 backlight_unregister_fb(bd); in backlight_device_unregister()
465 device_unregister(&bd->dev); in backlight_device_unregister()
564 struct backlight_device *bd) in devm_backlight_device_unregister() argument
569 devm_backlight_device_match, bd); in devm_backlight_device_unregister()
620 struct backlight_device *bd = NULL; in of_find_backlight() local
629 bd = of_find_backlight_by_node(np); in of_find_backlight()
631 if (!bd) in of_find_backlight()
637 if (!bd->props.brightness) in of_find_backlight()
638 bd->props.brightness = bd->props.max_brightness; in of_find_backlight()
642 return bd; in of_find_backlight()
661 struct backlight_device *bd; in devm_of_find_backlight() local
664 bd = of_find_backlight(dev); in devm_of_find_backlight()
665 if (IS_ERR_OR_NULL(bd)) in devm_of_find_backlight()
666 return bd; in devm_of_find_backlight()
667 ret = devm_add_action(dev, devm_backlight_release, bd); in devm_of_find_backlight()
669 backlight_put(bd); in devm_of_find_backlight()
672 return bd; in devm_of_find_backlight()