Lines Matching refs:bd
99 struct backlight_device *bd; in fb_notifier_callback() local
108 bd = container_of(self, struct backlight_device, fb_notif); in fb_notifier_callback()
109 mutex_lock(&bd->ops_lock); in fb_notifier_callback()
111 if (!bd->ops) in fb_notifier_callback()
113 if (bd->ops->check_fb && !bd->ops->check_fb(bd, evdata->info)) in fb_notifier_callback()
117 if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) { in fb_notifier_callback()
118 bd->fb_bl_on[node] = true; in fb_notifier_callback()
119 if (!bd->use_count++) { in fb_notifier_callback()
120 bd->props.state &= ~BL_CORE_FBBLANK; in fb_notifier_callback()
121 bd->props.fb_blank = FB_BLANK_UNBLANK; in fb_notifier_callback()
122 backlight_update_status(bd); in fb_notifier_callback()
124 } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) { in fb_notifier_callback()
125 bd->fb_bl_on[node] = false; in fb_notifier_callback()
126 if (!(--bd->use_count)) { in fb_notifier_callback()
127 bd->props.state |= BL_CORE_FBBLANK; in fb_notifier_callback()
128 bd->props.fb_blank = fb_blank; in fb_notifier_callback()
129 backlight_update_status(bd); in fb_notifier_callback()
133 mutex_unlock(&bd->ops_lock); in fb_notifier_callback()
137 static int backlight_register_fb(struct backlight_device *bd) in backlight_register_fb() argument
139 memset(&bd->fb_notif, 0, sizeof(bd->fb_notif)); in backlight_register_fb()
140 bd->fb_notif.notifier_call = fb_notifier_callback; in backlight_register_fb()
142 return fb_register_client(&bd->fb_notif); in backlight_register_fb()
145 static void backlight_unregister_fb(struct backlight_device *bd) in backlight_unregister_fb() argument
147 fb_unregister_client(&bd->fb_notif); in backlight_unregister_fb()
150 static inline int backlight_register_fb(struct backlight_device *bd) in backlight_register_fb() argument
155 static inline void backlight_unregister_fb(struct backlight_device *bd) in backlight_unregister_fb() argument
160 static void backlight_generate_event(struct backlight_device *bd, in backlight_generate_event() argument
177 kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp); in backlight_generate_event()
178 sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness"); in backlight_generate_event()
184 struct backlight_device *bd = to_backlight_device(dev); in bl_power_show() local
186 return sprintf(buf, "%d\n", bd->props.power); in bl_power_show()
193 struct backlight_device *bd = to_backlight_device(dev); in bl_power_store() local
201 mutex_lock(&bd->ops_lock); in bl_power_store()
202 if (bd->ops) { in bl_power_store()
204 if (bd->props.power != power) { in bl_power_store()
205 old_power = bd->props.power; in bl_power_store()
206 bd->props.power = power; in bl_power_store()
207 rc = backlight_update_status(bd); in bl_power_store()
209 bd->props.power = old_power; in bl_power_store()
216 mutex_unlock(&bd->ops_lock); in bl_power_store()
225 struct backlight_device *bd = to_backlight_device(dev); in brightness_show() local
227 return sprintf(buf, "%d\n", bd->props.brightness); in brightness_show()
230 int backlight_device_set_brightness(struct backlight_device *bd, in backlight_device_set_brightness() argument
235 mutex_lock(&bd->ops_lock); in backlight_device_set_brightness()
236 if (bd->ops) { in backlight_device_set_brightness()
237 if (brightness > bd->props.max_brightness) in backlight_device_set_brightness()
241 bd->props.brightness = brightness; in backlight_device_set_brightness()
242 rc = backlight_update_status(bd); in backlight_device_set_brightness()
245 mutex_unlock(&bd->ops_lock); in backlight_device_set_brightness()
247 backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS); in backlight_device_set_brightness()
257 struct backlight_device *bd = to_backlight_device(dev); in brightness_store() local
264 rc = backlight_device_set_brightness(bd, brightness); in brightness_store()
273 struct backlight_device *bd = to_backlight_device(dev); in type_show() local
275 return sprintf(buf, "%s\n", backlight_types[bd->props.type]); in type_show()
282 struct backlight_device *bd = to_backlight_device(dev); in max_brightness_show() local
284 return sprintf(buf, "%d\n", bd->props.max_brightness); in max_brightness_show()
292 struct backlight_device *bd = to_backlight_device(dev); in actual_brightness_show() local
294 mutex_lock(&bd->ops_lock); in actual_brightness_show()
295 if (bd->ops && bd->ops->get_brightness) { in actual_brightness_show()
296 rc = bd->ops->get_brightness(bd); in actual_brightness_show()
300 rc = sprintf(buf, "%d\n", bd->props.brightness); in actual_brightness_show()
302 mutex_unlock(&bd->ops_lock); in actual_brightness_show()
311 struct backlight_device *bd = to_backlight_device(dev); in scale_show() local
313 if (WARN_ON(bd->props.scale > BACKLIGHT_SCALE_NON_LINEAR)) in scale_show()
316 return sprintf(buf, "%s\n", backlight_scale_types[bd->props.scale]); in scale_show()
325 struct backlight_device *bd = to_backlight_device(dev); in backlight_suspend() local
327 mutex_lock(&bd->ops_lock); in backlight_suspend()
328 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { in backlight_suspend()
329 bd->props.state |= BL_CORE_SUSPENDED; in backlight_suspend()
330 backlight_update_status(bd); in backlight_suspend()
332 mutex_unlock(&bd->ops_lock); in backlight_suspend()
339 struct backlight_device *bd = to_backlight_device(dev); in backlight_resume() local
341 mutex_lock(&bd->ops_lock); in backlight_resume()
342 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { in backlight_resume()
343 bd->props.state &= ~BL_CORE_SUSPENDED; in backlight_resume()
344 backlight_update_status(bd); in backlight_resume()
346 mutex_unlock(&bd->ops_lock); in backlight_resume()
357 struct backlight_device *bd = to_backlight_device(dev); in bl_device_release() local
358 kfree(bd); in bl_device_release()
384 void backlight_force_update(struct backlight_device *bd, in backlight_force_update() argument
389 mutex_lock(&bd->ops_lock); in backlight_force_update()
390 if (bd->ops && bd->ops->get_brightness) { in backlight_force_update()
391 brightness = bd->ops->get_brightness(bd); in backlight_force_update()
393 bd->props.brightness = brightness; in backlight_force_update()
395 dev_err(&bd->dev, in backlight_force_update()
399 mutex_unlock(&bd->ops_lock); in backlight_force_update()
400 backlight_generate_event(bd, reason); in backlight_force_update()
483 struct backlight_device *bd; in backlight_device_get_by_type() local
486 list_for_each_entry(bd, &backlight_dev_list, entry) { in backlight_device_get_by_type()
487 if (bd->props.type == type) { in backlight_device_get_by_type()
494 return found ? bd : NULL; in backlight_device_get_by_type()
520 void backlight_device_unregister(struct backlight_device *bd) in backlight_device_unregister() argument
522 if (!bd) in backlight_device_unregister()
526 list_del(&bd->entry); in backlight_device_unregister()
531 if (pmac_backlight == bd) in backlight_device_unregister()
537 BACKLIGHT_UNREGISTERED, bd); in backlight_device_unregister()
539 mutex_lock(&bd->ops_lock); in backlight_device_unregister()
540 bd->ops = NULL; in backlight_device_unregister()
541 mutex_unlock(&bd->ops_lock); in backlight_device_unregister()
543 backlight_unregister_fb(bd); in backlight_device_unregister()
544 device_unregister(&bd->dev); in backlight_device_unregister()
649 struct backlight_device *bd) in devm_backlight_device_unregister() argument
654 devm_backlight_device_match, bd); in devm_backlight_device_unregister()
690 struct backlight_device *bd = NULL; in of_find_backlight() local
699 bd = of_find_backlight_by_node(np); in of_find_backlight()
701 if (!bd) in of_find_backlight()
706 return bd; in of_find_backlight()
711 struct backlight_device *bd = data; in devm_backlight_release() local
713 put_device(&bd->dev); in devm_backlight_release()
733 struct backlight_device *bd; in devm_of_find_backlight() local
736 bd = of_find_backlight(dev); in devm_of_find_backlight()
737 if (IS_ERR_OR_NULL(bd)) in devm_of_find_backlight()
738 return bd; in devm_of_find_backlight()
739 ret = devm_add_action_or_reset(dev, devm_backlight_release, bd); in devm_of_find_backlight()
743 return bd; in devm_of_find_backlight()