Lines Matching full:bd
98 struct backlight_device *bd; in fb_notifier_callback() local
109 bd = container_of(self, struct backlight_device, fb_notif); in fb_notifier_callback()
110 mutex_lock(&bd->ops_lock); in fb_notifier_callback()
112 if (!bd->ops) in fb_notifier_callback()
114 if (bd->ops->controls_device && !bd->ops->controls_device(bd, info->device)) in fb_notifier_callback()
116 if (fb_bd && fb_bd != bd) in fb_notifier_callback()
120 if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) { in fb_notifier_callback()
121 bd->fb_bl_on[node] = true; in fb_notifier_callback()
122 if (!bd->use_count++) { in fb_notifier_callback()
123 bd->props.state &= ~BL_CORE_FBBLANK; in fb_notifier_callback()
124 backlight_update_status(bd); in fb_notifier_callback()
126 } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) { in fb_notifier_callback()
127 bd->fb_bl_on[node] = false; in fb_notifier_callback()
128 if (!(--bd->use_count)) { in fb_notifier_callback()
129 bd->props.state |= BL_CORE_FBBLANK; in fb_notifier_callback()
130 backlight_update_status(bd); in fb_notifier_callback()
134 mutex_unlock(&bd->ops_lock); in fb_notifier_callback()
138 static int backlight_register_fb(struct backlight_device *bd) in backlight_register_fb() argument
140 memset(&bd->fb_notif, 0, sizeof(bd->fb_notif)); in backlight_register_fb()
141 bd->fb_notif.notifier_call = fb_notifier_callback; in backlight_register_fb()
143 return fb_register_client(&bd->fb_notif); in backlight_register_fb()
146 static void backlight_unregister_fb(struct backlight_device *bd) in backlight_unregister_fb() argument
148 fb_unregister_client(&bd->fb_notif); in backlight_unregister_fb()
151 static inline int backlight_register_fb(struct backlight_device *bd) in backlight_register_fb() argument
156 static inline void backlight_unregister_fb(struct backlight_device *bd) in backlight_unregister_fb() argument
161 static void backlight_generate_event(struct backlight_device *bd, in backlight_generate_event() argument
178 kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp); in backlight_generate_event()
179 sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness"); in backlight_generate_event()
185 struct backlight_device *bd = to_backlight_device(dev); in bl_power_show() local
187 return sprintf(buf, "%d\n", bd->props.power); in bl_power_show()
194 struct backlight_device *bd = to_backlight_device(dev); in bl_power_store() local
202 mutex_lock(&bd->ops_lock); in bl_power_store()
203 if (bd->ops) { in bl_power_store()
205 if (bd->props.power != power) { in bl_power_store()
206 old_power = bd->props.power; in bl_power_store()
207 bd->props.power = power; in bl_power_store()
208 rc = backlight_update_status(bd); in bl_power_store()
210 bd->props.power = old_power; in bl_power_store()
217 mutex_unlock(&bd->ops_lock); in bl_power_store()
226 struct backlight_device *bd = to_backlight_device(dev); in brightness_show() local
228 return sprintf(buf, "%d\n", bd->props.brightness); in brightness_show()
231 int backlight_device_set_brightness(struct backlight_device *bd, in backlight_device_set_brightness() argument
236 mutex_lock(&bd->ops_lock); in backlight_device_set_brightness()
237 if (bd->ops) { in backlight_device_set_brightness()
238 if (brightness > bd->props.max_brightness) in backlight_device_set_brightness()
242 bd->props.brightness = brightness; in backlight_device_set_brightness()
243 rc = backlight_update_status(bd); in backlight_device_set_brightness()
246 mutex_unlock(&bd->ops_lock); in backlight_device_set_brightness()
248 backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS); in backlight_device_set_brightness()
258 struct backlight_device *bd = to_backlight_device(dev); in brightness_store() local
265 rc = backlight_device_set_brightness(bd, brightness); in brightness_store()
274 struct backlight_device *bd = to_backlight_device(dev); in type_show() local
276 return sprintf(buf, "%s\n", backlight_types[bd->props.type]); in type_show()
283 struct backlight_device *bd = to_backlight_device(dev); in max_brightness_show() local
285 return sprintf(buf, "%d\n", bd->props.max_brightness); in max_brightness_show()
293 struct backlight_device *bd = to_backlight_device(dev); in actual_brightness_show() local
295 mutex_lock(&bd->ops_lock); in actual_brightness_show()
296 if (bd->ops && bd->ops->get_brightness) { in actual_brightness_show()
297 rc = bd->ops->get_brightness(bd); in actual_brightness_show()
301 rc = sprintf(buf, "%d\n", bd->props.brightness); in actual_brightness_show()
303 mutex_unlock(&bd->ops_lock); in actual_brightness_show()
312 struct backlight_device *bd = to_backlight_device(dev); in scale_show() local
314 if (WARN_ON(bd->props.scale > BACKLIGHT_SCALE_NON_LINEAR)) in scale_show()
317 return sprintf(buf, "%s\n", backlight_scale_types[bd->props.scale]); in scale_show()
324 struct backlight_device *bd = to_backlight_device(dev); in backlight_suspend() local
326 mutex_lock(&bd->ops_lock); in backlight_suspend()
327 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { in backlight_suspend()
328 bd->props.state |= BL_CORE_SUSPENDED; in backlight_suspend()
329 backlight_update_status(bd); in backlight_suspend()
331 mutex_unlock(&bd->ops_lock); in backlight_suspend()
338 struct backlight_device *bd = to_backlight_device(dev); in backlight_resume() local
340 mutex_lock(&bd->ops_lock); in backlight_resume()
341 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) { in backlight_resume()
342 bd->props.state &= ~BL_CORE_SUSPENDED; in backlight_resume()
343 backlight_update_status(bd); in backlight_resume()
345 mutex_unlock(&bd->ops_lock); in backlight_resume()
356 struct backlight_device *bd = to_backlight_device(dev); in bl_device_release() local
357 kfree(bd); in bl_device_release()
380 * @bd: the backlight device to update
389 void backlight_force_update(struct backlight_device *bd, in backlight_force_update() argument
394 mutex_lock(&bd->ops_lock); in backlight_force_update()
395 if (bd->ops && bd->ops->get_brightness) { in backlight_force_update()
396 brightness = bd->ops->get_brightness(bd); in backlight_force_update()
398 bd->props.brightness = brightness; in backlight_force_update()
400 dev_err(&bd->dev, in backlight_force_update()
404 mutex_unlock(&bd->ops_lock); in backlight_force_update()
405 backlight_generate_event(bd, reason); in backlight_force_update()
485 struct backlight_device *bd; in backlight_device_get_by_type() local
488 list_for_each_entry(bd, &backlight_dev_list, entry) { in backlight_device_get_by_type()
489 if (bd->props.type == type) { in backlight_device_get_by_type()
496 return found ? bd : NULL; in backlight_device_get_by_type()
522 void backlight_device_unregister(struct backlight_device *bd) in backlight_device_unregister() argument
524 if (!bd) in backlight_device_unregister()
528 list_del(&bd->entry); in backlight_device_unregister()
533 if (pmac_backlight == bd) in backlight_device_unregister()
538 mutex_lock(&bd->ops_lock); in backlight_device_unregister()
539 bd->ops = NULL; in backlight_device_unregister()
540 mutex_unlock(&bd->ops_lock); in backlight_device_unregister()
542 backlight_unregister_fb(bd); in backlight_device_unregister()
543 device_unregister(&bd->dev); in backlight_device_unregister()
607 * @bd: the backlight device to unregister
614 struct backlight_device *bd) in devm_backlight_device_unregister() argument
619 devm_backlight_device_match, bd); in devm_backlight_device_unregister()
655 struct backlight_device *bd = NULL; in of_find_backlight() local
664 bd = of_find_backlight_by_node(np); in of_find_backlight()
666 if (!bd) in of_find_backlight()
671 return bd; in of_find_backlight()
676 struct backlight_device *bd = data; in devm_backlight_release() local
678 put_device(&bd->dev); in devm_backlight_release()
698 struct backlight_device *bd; in devm_of_find_backlight() local
701 bd = of_find_backlight(dev); in devm_of_find_backlight()
702 if (IS_ERR_OR_NULL(bd)) in devm_of_find_backlight()
703 return bd; in devm_of_find_backlight()
704 ret = devm_add_action_or_reset(dev, devm_backlight_release, bd); in devm_of_find_backlight()
708 return bd; in devm_of_find_backlight()