Pull backlight updates from Lee Jones: "Core Framework: - Trivial: Code refactoring - New API backlight_is_blank() - New API backlight_get_brightness() - Additional/reworked documentation - Remove 'extern' labels from prototypes - Drop backlight_put() - Staticify of_find_backlight() Driver Removal: - Removal of unused OT200 driver - Removal of unused Generic Backlight driver Fix-ups - Bunch of W=1 warning fixes - Convert to GPIO descriptors; sky81452 - Move platform data handling into driver; sky81452 - Remove superfluous code; lms501kf03 - Many instances of using new APIs" * tag 'backlight-next-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: (34 commits) video: backlight: cr_bllcd: Remove unused variable 'intensity' backlight: backlight: Make of_find_backlight static backlight: backlight: Drop backlight_put() backlight: Use backlight_get_brightness() throughout backlight: jornada720_bl: Introduce backlight_is_blank() backlight: gpio_backlight: Simplify update_status() backlight: cr_bllcd: Introduce gpio-backlight semantics backlight: as3711_bl: Simplify update_status backlight: backlight: Introduce backlight_get_brightness() doc-rst: Wire-up Backlight kernel-doc documentation backlight: backlight: Add overview and update existing doc backlight: backlight: Drop extern from prototypes backlight: generic_bl: Remove this driver as it is unused backlight: backlight: Document enums in backlight.h backlight: backlight: Document inline functions in backlight.h backlight: backlight: Improve backlight_device documentation backlight: backlight: Improve backlight_properties documentation backlight: backlight: Improve backlight_ops documentation backlight: backlight: Add backlight_is_blank() backlight: backlight: Refactor fb_notifier_callback() ...
Unified · Split
| @@ -0,0 +1,12 @@ | ||
| 1 | +================= | |
| 2 | +Backlight support | |
| 3 | +================= | |
| 4 | + | |
| 5 | +.. kernel-doc:: drivers/video/backlight/backlight.c | |
| 6 | + :doc: overview | |
| 7 | + | |
| 8 | +.. kernel-doc:: include/linux/backlight.h | |
| 9 | + :internal: | |
| 10 | + | |
| 11 | +.. kernel-doc:: drivers/video/backlight/backlight.c | |
| 12 | + :export: | |
| @@ -12,6 +12,7 @@ Linux GPU Driver Developer's Guide · 11 unmodified lines | ||
| 12 | 12 | drm-uapi |
| 13 | 13 | drm-client |
| 14 | 14 | drivers |
| 15 | + backlight | |
| 15 | 16 | vga-switcheroo |
| 16 | 17 | vgaarbiter |
| 17 | 18 | todo |
| @@ -47,8 +47,6 @@ static int sky81452_probe(struct i2c_client *client, · 46 unmodified lines | ||
| 47 | 47 | memset(cells, 0, sizeof(cells)); |
| 48 | 48 | cells[0].name = "sky81452-backlight"; |
| 49 | 49 | cells[0].of_compatible = "skyworks,sky81452-backlight"; |
| 50 | − cells[0].platform_data = pdata->bl_pdata; | |
| 51 | − cells[0].pdata_size = sizeof(*pdata->bl_pdata); | |
| 52 | 50 | cells[1].name = "sky81452-regulator"; |
| 53 | 51 | cells[1].platform_data = pdata->regulator_init_data; |
| 54 | 52 | cells[1].pdata_size = sizeof(*pdata->regulator_init_data); |
| @@ -121,18 +121,7 @@ out: · 120 unmodified lines | ||
| 121 | 121 | |
| 122 | 122 | static int pm860x_backlight_update_status(struct backlight_device *bl) |
| 123 | 123 | { |
| 124 | − int brightness = bl->props.brightness; | |
| 125 | − | |
| 126 | − if (bl->props.power != FB_BLANK_UNBLANK) | |
| 127 | − brightness = 0; | |
| 128 | − | |
| 129 | − if (bl->props.fb_blank != FB_BLANK_UNBLANK) | |
| 130 | − brightness = 0; | |
| 131 | − | |
| 132 | − if (bl->props.state & BL_CORE_SUSPENDED) | |
| 133 | − brightness = 0; | |
| 134 | − | |
| 135 | − return pm860x_backlight_set(bl, brightness); | |
| 124 | + return pm860x_backlight_set(bl, backlight_get_brightness(bl)); | |
| 136 | 125 | } |
| 137 | 126 | |
| 138 | 127 | static int pm860x_backlight_get_brightness(struct backlight_device *bl) |
| @@ -173,14 +173,6 @@ config BACKLIGHT_EP93XX · 172 unmodified lines | ||
| 173 | 173 | To compile this driver as a module, choose M here: the module will |
| 174 | 174 | be called ep93xx_bl. |
| 175 | 175 | |
| 176 | −config BACKLIGHT_GENERIC | |
| 177 | − tristate "Generic (aka Sharp Corgi) Backlight Driver" | |
| 178 | − default y | |
| 179 | − help | |
| 180 | − Say y to enable the generic platform backlight driver previously | |
| 181 | − known as the Corgi backlight driver. If you have a Sharp Zaurus | |
| 182 | − SL-C7xx, SL-Cxx00 or SL-6000x say y. | |
| 183 | − | |
| 184 | 176 | config BACKLIGHT_IPAQ_MICRO |
| 185 | 177 | tristate "iPAQ microcontroller backlight driver" |
| 186 | 178 | depends on MFD_IPAQ_MICRO |
| @@ -386,13 +378,6 @@ config BACKLIGHT_LP8788 · 199 unmodified lines | ||
| 386 | 378 | help |
| 387 | 379 | This supports TI LP8788 backlight driver. |
| 388 | 380 | |
| 389 | −config BACKLIGHT_OT200 | |
| 390 | − tristate "Backlight driver for ot200 visualisation device" | |
| 391 | − depends on CS5535_MFGPT && GPIO_CS5535 | |
| 392 | − help | |
| 393 | − To compile this driver as a module, choose M here: the module will be | |
| 394 | − called ot200_bl. | |
| 395 | − | |
| 396 | 381 | config BACKLIGHT_PANDORA |
| 397 | 382 | tristate "Backlight driver for Pandora console" |
| 398 | 383 | depends on TWL4030_CORE |
| @@ -31,7 +31,6 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o · 30 unmodified lines | ||
| 31 | 31 | obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o |
| 32 | 32 | obj-$(CONFIG_BACKLIGHT_DA9052) += da9052_bl.o |
| 33 | 33 | obj-$(CONFIG_BACKLIGHT_EP93XX) += ep93xx_bl.o |
| 34 | −obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o | |
| 35 | 34 | obj-$(CONFIG_BACKLIGHT_GPIO) += gpio_backlight.o |
| 36 | 35 | obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o |
| 37 | 36 | obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o |
| @@ -45,7 +44,6 @@ obj-$(CONFIG_BACKLIGHT_LP8788) += lp8788_bl.o · 7 unmodified lines | ||
| 45 | 44 | obj-$(CONFIG_BACKLIGHT_LV5207LP) += lv5207lp.o |
| 46 | 45 | obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o |
| 47 | 46 | obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o |
| 48 | −obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o | |
| 49 | 47 | obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o |
| 50 | 48 | obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o |
| 51 | 49 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o |
| @@ -65,15 +65,7 @@ static int adp5520_bl_set(struct backlight_device *bl, int brightness) · 64 unmodified lines | ||
| 65 | 65 | |
| 66 | 66 | static int adp5520_bl_update_status(struct backlight_device *bl) |
| 67 | 67 | { |
| 68 | − int brightness = bl->props.brightness; | |
| 69 | − | |
| 70 | − if (bl->props.power != FB_BLANK_UNBLANK) | |
| 71 | − brightness = 0; | |
| 72 | − | |
| 73 | − if (bl->props.fb_blank != FB_BLANK_UNBLANK) | |
| 74 | − brightness = 0; | |
| 75 | − | |
| 76 | − return adp5520_bl_set(bl, brightness); | |
| 68 | + return adp5520_bl_set(bl, backlight_get_brightness(bl)); | |
| 77 | 69 | } |
| 78 | 70 | |
| 79 | 71 | static int adp5520_bl_get_brightness(struct backlight_device *bl) |
| @@ -361,15 +361,7 @@ static int adp8860_bl_set(struct backlight_device *bl, int brightness) · 360 unmodified lines | ||
| 361 | 361 | |
| 362 | 362 | static int adp8860_bl_update_status(struct backlight_device *bl) |
| 363 | 363 | { |
| 364 | − int brightness = bl->props.brightness; | |
| 365 | − | |
| 366 | − if (bl->props.power != FB_BLANK_UNBLANK) | |
| 367 | − brightness = 0; | |
| 368 | − | |
| 369 | − if (bl->props.fb_blank != FB_BLANK_UNBLANK) | |
| 370 | − brightness = 0; | |
| 371 | − | |
| 372 | − return adp8860_bl_set(bl, brightness); | |
| 364 | + return adp8860_bl_set(bl, backlight_get_brightness(bl)); | |
| 373 | 365 | } |
| 374 | 366 | |
| 375 | 367 | static int adp8860_bl_get_brightness(struct backlight_device *bl) |
| @@ -399,15 +399,7 @@ static int adp8870_bl_set(struct backlight_device *bl, int brightness) · 398 unmodified lines | ||
| 399 | 399 | |
| 400 | 400 | static int adp8870_bl_update_status(struct backlight_device *bl) |
| 401 | 401 | { |
| 402 | − int brightness = bl->props.brightness; | |
| 403 | − | |
| 404 | − if (bl->props.power != FB_BLANK_UNBLANK) | |
| 405 | − brightness = 0; | |
| 406 | − | |
| 407 | − if (bl->props.fb_blank != FB_BLANK_UNBLANK) | |
| 408 | − brightness = 0; | |
| 409 | − | |
| 410 | − return adp8870_bl_set(bl, brightness); | |
| 402 | + return adp8870_bl_set(bl, backlight_get_brightness(bl)); | |
| 411 | 403 | } |
| 412 | 404 | |
| 413 | 405 | static int adp8870_bl_get_brightness(struct backlight_device *bl) |
| @@ -104,17 +104,10 @@ static int as3711_bl_update_status(struct backlight_device *bl) · 103 unmodified lines | ||
| 104 | 104 | struct as3711_bl_data *data = bl_get_data(bl); |
| 105 | 105 | struct as3711_bl_supply *supply = to_supply(data); |
| 106 | 106 | struct as3711 *as3711 = supply->as3711; |
| 107 | − int brightness = bl->props.brightness; | |
| 107 | + int brightness; | |
| 108 | 108 | int ret = 0; |
| 109 | 109 | |
| 110 | − dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n", | |
| 111 | − __func__, bl->props.brightness, bl->props.power, | |
| 112 | − bl->props.fb_blank, bl->props.state); | |
| 113 | − | |
| 114 | − if (bl->props.power != FB_BLANK_UNBLANK || | |
| 115 | − bl->props.fb_blank != FB_BLANK_UNBLANK || | |
| 116 | − bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) | |
| 117 | − brightness = 0; | |
| 110 | + brightness = backlight_get_brightness(bl); | |
| 118 | 111 | |
| 119 | 112 | if (data->type == AS3711_BL_SU1) { |
| 120 | 113 | ret = as3711_set_brightness_v(as3711, brightness, |
| @@ -22,6 +22,47 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <asm/backlight.h> |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | +/** | |
| 26 | + * DOC: overview | |
| 27 | + * | |
| 28 | + * The backlight core supports implementing backlight drivers. | |
| 29 | + * | |
| 30 | + * A backlight driver registers a driver using | |
| 31 | + * devm_backlight_device_register(). The properties of the backlight | |
| 32 | + * driver such as type and max_brightness must be specified. | |
| 33 | + * When the core detect changes in for example brightness or power state | |
| 34 | + * the update_status() operation is called. The backlight driver shall | |
| 35 | + * implement this operation and use it to adjust backlight. | |
| 36 | + * | |
| 37 | + * Several sysfs attributes are provided by the backlight core:: | |
| 38 | + * | |
| 39 | + * - brightness R/W, set the requested brightness level | |
| 40 | + * - actual_brightness RO, the brightness level used by the HW | |
| 41 | + * - max_brightness RO, the maximum brightness level supported | |
| 42 | + * | |
| 43 | + * See Documentation/ABI/stable/sysfs-class-backlight for the full list. | |
| 44 | + * | |
| 45 | + * The backlight can be adjusted using the sysfs interface, and | |
| 46 | + * the backlight driver may also support adjusting backlight using | |
| 47 | + * a hot-key or some other platform or firmware specific way. | |
| 48 | + * | |
| 49 | + * The driver must implement the get_brightness() operation if | |
| 50 | + * the HW do not support all the levels that can be specified in | |
| 51 | + * brightness, thus providing user-space access to the actual level | |
| 52 | + * via the actual_brightness attribute. | |
| 53 | + * | |
| 54 | + * When the backlight changes this is reported to user-space using | |
| 55 | + * an uevent connected to the actual_brightness attribute. | |
| 56 | + * When brightness is set by platform specific means, for example | |
| 57 | + * a hot-key to adjust backlight, the driver must notify the backlight | |
| 58 | + * core that brightness has changed using backlight_force_update(). | |
| 59 | + * | |
| 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. | |
| 64 | + */ | |
| 65 | + | |
| 25 | 66 | static struct list_head backlight_dev_list; |
| 26 | 67 | static struct mutex backlight_dev_list_mutex; |
| 27 | 68 | static struct blocking_notifier_head backlight_notifier; |
| @@ -40,9 +81,17 @@ static const char *const backlight_scale_types[] = { · 12 unmodified lines | ||
| 40 | 81 | |
| 41 | 82 | #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ |
| 42 | 83 | defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)) |
| 43 | −/* This callback gets called when something important happens inside a | |
| 44 | − * framebuffer driver. We're looking if that important event is blanking, | |
| 45 | − * and if it is and necessary, we're switching backlight power as well ... | |
| 84 | +/* | |
| 85 | + * fb_notifier_callback | |
| 86 | + * | |
| 87 | + * This callback gets called when something important happens inside a | |
| 88 | + * framebuffer driver. The backlight core only cares about FB_BLANK_UNBLANK | |
| 89 | + * which is reported to the driver using backlight_update_status() | |
| 90 | + * as a state change. | |
| 91 | + * | |
| 92 | + * There may be several fbdev's connected to the backlight device, | |
| 93 | + * in which case they are kept track of. A state change is only reported | |
| 94 | + * if there is a change in backlight for the specified fbdev. | |
| 46 | 95 | */ |
| 47 | 96 | static int fb_notifier_callback(struct notifier_block *self, |
| 48 | 97 | unsigned long event, void *data) |
| @@ -58,28 +107,29 @@ static int fb_notifier_callback(struct notifier_block *self, · 9 unmodified lines | ||
| 58 | 107 | |
| 59 | 108 | bd = container_of(self, struct backlight_device, fb_notif); |
| 60 | 109 | mutex_lock(&bd->ops_lock); |
| 61 | − if (bd->ops) | |
| 62 | − if (!bd->ops->check_fb || | |
| 63 | − bd->ops->check_fb(bd, evdata->info)) { | |
| 64 | − fb_blank = *(int *)evdata->data; | |
| 65 | − if (fb_blank == FB_BLANK_UNBLANK && | |
| 66 | − !bd->fb_bl_on[node]) { | |
| 67 | − bd->fb_bl_on[node] = true; | |
| 68 | − if (!bd->use_count++) { | |
| 69 | − bd->props.state &= ~BL_CORE_FBBLANK; | |
| 70 | − bd->props.fb_blank = FB_BLANK_UNBLANK; | |
| 71 | − backlight_update_status(bd); | |
| 72 | − } | |
| 73 | − } else if (fb_blank != FB_BLANK_UNBLANK && | |
| 74 | − bd->fb_bl_on[node]) { | |
| 75 | − bd->fb_bl_on[node] = false; | |
| 76 | − if (!(--bd->use_count)) { | |
| 77 | − bd->props.state |= BL_CORE_FBBLANK; | |
| 78 | − bd->props.fb_blank = fb_blank; | |
| 79 | − backlight_update_status(bd); | |
| 80 | − } | |
| 81 | − } | |
| 110 | + | |
| 111 | + if (!bd->ops) | |
| 112 | + goto out; | |
| 113 | + if (bd->ops->check_fb && !bd->ops->check_fb(bd, evdata->info)) | |
| 114 | + goto out; | |
| 115 | + | |
| 116 | + fb_blank = *(int *)evdata->data; | |
| 117 | + if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) { | |
| 118 | + bd->fb_bl_on[node] = true; | |
| 119 | + if (!bd->use_count++) { | |
| 120 | + bd->props.state &= ~BL_CORE_FBBLANK; | |
| 121 | + bd->props.fb_blank = FB_BLANK_UNBLANK; | |
| 122 | + backlight_update_status(bd); | |
| 82 | 123 | } |
| 124 | + } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) { | |
| 125 | + bd->fb_bl_on[node] = false; | |
| 126 | + if (!(--bd->use_count)) { | |
| 127 | + bd->props.state |= BL_CORE_FBBLANK; | |
| 128 | + bd->props.fb_blank = fb_blank; | |
| 129 | + backlight_update_status(bd); | |
| 130 | + } | |
| 131 | + } | |
| 132 | +out: | |
| 83 | 133 | mutex_unlock(&bd->ops_lock); |
| 84 | 134 | return 0; |
| 85 | 135 | } |
| @@ -320,9 +370,13 @@ ATTRIBUTE_GROUPS(bl_device); · 234 unmodified lines | ||
| 320 | 370 | * backlight_force_update - tell the backlight subsystem that hardware state |
| 321 | 371 | * has changed |
| 322 | 372 | * @bd: the backlight device to update |
| 373 | + * @reason: reason for update | |
| 323 | 374 | * |
| 324 | 375 | * Updates the internal state of the backlight in response to a hardware event, |
| 325 | − * and generate a uevent to notify userspace | |
| 376 | + * and generates an uevent to notify userspace. A backlight driver shall call | |
| 377 | + * backlight_force_update() when the backlight is changed using, for example, | |
| 378 | + * a hot-key. The updated brightness is read using get_brightness() and the | |
| 379 | + * brightness value is reported using an uevent. | |
| 326 | 380 | */ |
| 327 | 381 | void backlight_force_update(struct backlight_device *bd, |
| 328 | 382 | enum backlight_update_reason reason) |
| @@ -335,19 +389,7 @@ void backlight_force_update(struct backlight_device *bd, · 6 unmodified lines | ||
| 335 | 389 | } |
| 336 | 390 | EXPORT_SYMBOL(backlight_force_update); |
| 337 | 391 | |
| 338 | −/** | |
| 339 | − * backlight_device_register - create and register a new object of | |
| 340 | − * backlight_device class. | |
| 341 | − * @name: the name of the new object(must be the same as the name of the | |
| 342 | − * respective framebuffer device). | |
| 343 | − * @parent: a pointer to the parent device | |
| 344 | − * @devdata: an optional pointer to be stored for private driver use. The | |
| 345 | − * methods may retrieve it by using bl_get_data(bd). | |
| 346 | − * @ops: the backlight operations structure. | |
| 347 | − * | |
| 348 | − * Creates and registers new backlight device. Returns either an | |
| 349 | − * ERR_PTR() or a pointer to the newly allocated device. | |
| 350 | − */ | |
| 392 | +/* deprecated - use devm_backlight_device_register() */ | |
| 351 | 393 | struct backlight_device *backlight_device_register(const char *name, |
| 352 | 394 | struct device *parent, void *devdata, const struct backlight_ops *ops, |
| 353 | 395 | const struct backlight_properties *props) |
| @@ -414,6 +456,15 @@ struct backlight_device *backlight_device_register(const char *name, · 60 unmodified lines | ||
| 414 | 456 | } |
| 415 | 457 | EXPORT_SYMBOL(backlight_device_register); |
| 416 | 458 | |
| 459 | +/** backlight_device_get_by_type - find first backlight device of a type | |
| 460 | + * @type: the type of backlight device | |
| 461 | + * | |
| 462 | + * Look up the first backlight device of the specified type | |
| 463 | + * | |
| 464 | + * RETURNS: | |
| 465 | + * | |
| 466 | + * Pointer to backlight device if any was found. Otherwise NULL. | |
| 467 | + */ | |
| 417 | 468 | struct backlight_device *backlight_device_get_by_type(enum backlight_type type) |
| 418 | 469 | { |
| 419 | 470 | bool found = false; |
| @@ -453,12 +504,7 @@ struct backlight_device *backlight_device_get_by_name(const char *name) · 33 unmodified lines | ||
| 453 | 504 | } |
| 454 | 505 | EXPORT_SYMBOL(backlight_device_get_by_name); |
| 455 | 506 | |
| 456 | −/** | |
| 457 | − * backlight_device_unregister - unregisters a backlight device object. | |
| 458 | − * @bd: the backlight device object to be unregistered and freed. | |
| 459 | − * | |
| 460 | − * Unregisters a previously registered via backlight_device_register object. | |
| 461 | − */ | |
| 507 | +/* deprecated - use devm_backlight_device_unregister() */ | |
| 462 | 508 | void backlight_device_unregister(struct backlight_device *bd) |
| 463 | 509 | { |
| 464 | 510 | if (!bd) |
| @@ -506,10 +552,12 @@ static int devm_backlight_device_match(struct device *dev, void *res, · 41 unmodified lines | ||
| 506 | 552 | * backlight_register_notifier - get notified of backlight (un)registration |
| 507 | 553 | * @nb: notifier block with the notifier to call on backlight (un)registration |
| 508 | 554 | * |
| 509 | − * @return 0 on success, otherwise a negative error code | |
| 510 | − * | |
| 511 | 555 | * Register a notifier to get notified when backlight devices get registered |
| 512 | 556 | * or unregistered. |
| 557 | + * | |
| 558 | + * RETURNS: | |
| 559 | + * | |
| 560 | + * 0 on success, otherwise a negative error code | |
| 513 | 561 | */ |
| 514 | 562 | int backlight_register_notifier(struct notifier_block *nb) |
| 515 | 563 | { |
| @@ -521,10 +569,12 @@ EXPORT_SYMBOL(backlight_register_notifier); · 5 unmodified lines | ||
| 521 | 569 | * backlight_unregister_notifier - unregister a backlight notifier |
| 522 | 570 | * @nb: notifier block to unregister |
| 523 | 571 | * |
| 524 | − * @return 0 on success, otherwise a negative error code | |
| 525 | − * | |
| 526 | 572 | * Register a notifier to get notified when backlight devices get registered |
| 527 | 573 | * or unregistered. |
| 574 | + * | |
| 575 | + * RETURNS: | |
| 576 | + * | |
| 577 | + * 0 on success, otherwise a negative error code | |
| 528 | 578 | */ |
| 529 | 579 | int backlight_unregister_notifier(struct notifier_block *nb) |
| 530 | 580 | { |
| @@ -533,19 +583,21 @@ int backlight_unregister_notifier(struct notifier_block *nb) · 2 unmodified lines | ||
| 533 | 583 | EXPORT_SYMBOL(backlight_unregister_notifier); |
| 534 | 584 | |
| 535 | 585 | /** |
| 536 | − * devm_backlight_device_register - resource managed backlight_device_register() | |
| 586 | + * devm_backlight_device_register - register a new backlight device | |
| 537 | 587 | * @dev: the device to register |
| 538 | 588 | * @name: the name of the device |
| 539 | − * @parent: a pointer to the parent device | |
| 589 | + * @parent: a pointer to the parent device (often the same as @dev) | |
| 540 | 590 | * @devdata: an optional pointer to be stored for private driver use |
| 541 | 591 | * @ops: the backlight operations structure |
| 542 | 592 | * @props: the backlight properties |
| 543 | 593 | * |
| 544 | − * @return a struct backlight on success, or an ERR_PTR on error | |
| 594 | + * Creates and registers new backlight device. When a backlight device | |
| 595 | + * is registered the configuration must be specified in the @props | |
| 596 | + * parameter. See description of &backlight_properties. | |
| 597 | + * | |
| 598 | + * RETURNS: | |
| 545 | 599 | * |
| 546 | − * Managed backlight_device_register(). The backlight_device returned | |
| 547 | − * from this function are automatically freed on driver detach. | |
| 548 | − * See backlight_device_register() for more information. | |
| 600 | + * struct backlight on success, or an ERR_PTR on error | |
| 549 | 601 | */ |
| 550 | 602 | struct backlight_device *devm_backlight_device_register(struct device *dev, |
| 551 | 603 | const char *name, struct device *parent, void *devdata, |
| @@ -573,13 +625,13 @@ struct backlight_device *devm_backlight_device_register(struct device *dev, · 21 unmodified lines | ||
| 573 | 625 | EXPORT_SYMBOL(devm_backlight_device_register); |
| 574 | 626 | |
| 575 | 627 | /** |
| 576 | − * devm_backlight_device_unregister - resource managed backlight_device_unregister() | |
| 628 | + * devm_backlight_device_unregister - unregister backlight device | |
| 577 | 629 | * @dev: the device to unregister |
| 578 | 630 | * @bd: the backlight device to unregister |
| 579 | 631 | * |
| 580 | − * Deallocated a backlight allocated with devm_backlight_device_register(). | |
| 632 | + * Deallocates a backlight allocated with devm_backlight_device_register(). | |
| 581 | 633 | * Normally this function will not need to be called and the resource management |
| 582 | − * code will ensure that the resource is freed. | |
| 634 | + * code will ensure that the resources are freed. | |
| 583 | 635 | */ |
| 584 | 636 | void devm_backlight_device_unregister(struct device *dev, |
| 585 | 637 | struct backlight_device *bd) |
| @@ -621,22 +673,7 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node) · 35 unmodified lines | ||
| 621 | 673 | EXPORT_SYMBOL(of_find_backlight_by_node); |
| 622 | 674 | #endif |
| 623 | 675 | |
| 624 | −/** | |
| 625 | − * of_find_backlight - Get backlight device | |
| 626 | − * @dev: Device | |
| 627 | − * | |
| 628 | − * This function looks for a property named 'backlight' on the DT node | |
| 629 | − * connected to @dev and looks up the backlight device. | |
| 630 | − * | |
| 631 | − * Call backlight_put() to drop the reference on the backlight device. | |
| 632 | − * | |
| 633 | − * Returns: | |
| 634 | − * A pointer to the backlight device if found. | |
| 635 | − * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight | |
| 636 | − * device is found. | |
| 637 | − * NULL if there's no backlight property. | |
| 638 | − */ | |
| 639 | −struct backlight_device *of_find_backlight(struct device *dev) | |
| 676 | +static struct backlight_device *of_find_backlight(struct device *dev) | |
| 640 | 677 | { |
| 641 | 678 | struct backlight_device *bd = NULL; |
| 642 | 679 | struct device_node *np; |
| @@ -662,20 +699,29 @@ struct backlight_device *of_find_backlight(struct device *dev) · 19 unmodified lines | ||
| 662 | 699 | |
| 663 | 700 | return bd; |
| 664 | 701 | } |
| 665 | −EXPORT_SYMBOL(of_find_backlight); | |
| 666 | 702 | |
| 667 | 703 | static void devm_backlight_release(void *data) |
| 668 | 704 | { |
| 669 | − backlight_put(data); | |
| 705 | + struct backlight_device *bd = data; | |
| 706 | + | |
| 707 | + if (bd) | |
| 708 | + put_device(&bd->dev); | |
| 670 | 709 | } |
| 671 | 710 | |
| 672 | 711 | /** |
| 673 | − * devm_of_find_backlight - Resource-managed of_find_backlight() | |
| 674 | − * @dev: Device | |
| 712 | + * devm_of_find_backlight - find backlight for a device | |
| 713 | + * @dev: the device | |
| 675 | 714 | * |
| 676 | − * Device managed version of of_find_backlight(). | |
| 677 | − * The reference on the backlight device is automatically | |
| 715 | + * This function looks for a property named 'backlight' on the DT node | |
| 716 | + * connected to @dev and looks up the backlight device. The lookup is | |
| 717 | + * device managed so the reference to the backlight device is automatically | |
| 678 | 718 | * dropped on driver detach. |
| 719 | + * | |
| 720 | + * RETURNS: | |
| 721 | + * | |
| 722 | + * A pointer to the backlight device if found. | |
| 723 | + * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight | |
| 724 | + * device is found. NULL if there's no backlight property. | |
| 679 | 725 | */ |
| 680 | 726 | struct backlight_device *devm_of_find_backlight(struct device *dev) |
| 681 | 727 | { |
| @@ -687,7 +733,7 @@ struct backlight_device *devm_of_find_backlight(struct device *dev) · 5 unmodified lines | ||
| 687 | 733 | return bd; |
| 688 | 734 | ret = devm_add_action(dev, devm_backlight_release, bd); |
| 689 | 735 | if (ret) { |
| 690 | − backlight_put(bd); | |
| 736 | + put_device(&bd->dev); | |
| 691 | 737 | return ERR_PTR(ret); |
| 692 | 738 | } |
| 693 | 739 | return bd; |
| @@ -82,12 +82,7 @@ static int bd6107_write(struct bd6107 *bd, u8 reg, u8 data) · 81 unmodified lines | ||
| 82 | 82 | static int bd6107_backlight_update_status(struct backlight_device *backlight) |
| 83 | 83 | { |
| 84 | 84 | struct bd6107 *bd = bl_get_data(backlight); |
| 85 | − int brightness = backlight->props.brightness; | |
| 86 | − | |
| 87 | − if (backlight->props.power != FB_BLANK_UNBLANK || | |
| 88 | − backlight->props.fb_blank != FB_BLANK_UNBLANK || | |
| 89 | − backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) | |
| 90 | − brightness = 0; | |
| 85 | + int brightness = backlight_get_brightness(backlight); | |
| 91 | 86 | |
| 92 | 87 | if (brightness) { |
| 93 | 88 | bd6107_write(bd, BD6107_PORTSEL, BD6107_PORTSEL_LEDM(2) | |
| @@ -420,13 +420,7 @@ static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity) · 419 unmodified lines | ||
| 420 | 420 | static int corgi_bl_update_status(struct backlight_device *bd) |
| 421 | 421 | { |
| 422 | 422 | struct corgi_lcd *lcd = bl_get_data(bd); |
| 423 | − int intensity = bd->props.brightness; | |
| 424 | − | |
| 425 | − if (bd->props.power != FB_BLANK_UNBLANK) | |
| 426 | − intensity = 0; | |
| 427 | − | |
| 428 | − if (bd->props.fb_blank != FB_BLANK_UNBLANK) | |
| 429 | − intensity = 0; | |
| 423 | + int intensity = backlight_get_brightness(bd); | |
| 430 | 424 | |
| 431 | 425 | if (corgibl_flags & CORGIBL_SUSPENDED) |
| 432 | 426 | intensity = 0; |
| @@ -59,26 +59,18 @@ struct cr_panel { · 58 unmodified lines | ||
| 59 | 59 | |
| 60 | 60 | static int cr_backlight_set_intensity(struct backlight_device *bd) |
| 61 | 61 | { |
| 62 | − int intensity = bd->props.brightness; | |
| 63 | 62 | u32 addr = gpio_bar + CRVML_PANEL_PORT; |
| 64 | 63 | u32 cur = inl(addr); |
| 65 | 64 | |
| 66 | − if (bd->props.power == FB_BLANK_UNBLANK) | |
| 67 | − intensity = FB_BLANK_UNBLANK; | |
| 68 | − if (bd->props.fb_blank == FB_BLANK_UNBLANK) | |
| 69 | − intensity = FB_BLANK_UNBLANK; | |
| 70 | − if (bd->props.power == FB_BLANK_POWERDOWN) | |
| 71 | − intensity = FB_BLANK_POWERDOWN; | |
| 72 | − if (bd->props.fb_blank == FB_BLANK_POWERDOWN) | |
| 73 | − intensity = FB_BLANK_POWERDOWN; | |
| 74 | − | |
| 75 | − if (intensity == FB_BLANK_UNBLANK) { /* FULL ON */ | |
| 76 | − cur &= ~CRVML_BACKLIGHT_OFF; | |
| 77 | − outl(cur, addr); | |
| 78 | − } else if (intensity == FB_BLANK_POWERDOWN) { /* OFF */ | |
| 65 | + if (backlight_get_brightness(bd) == 0) { | |
| 66 | + /* OFF */ | |
| 79 | 67 | cur |= CRVML_BACKLIGHT_OFF; |
| 80 | 68 | outl(cur, addr); |
| 81 | − } /* anything else, don't bother */ | |
| 69 | + } else { | |
| 70 | + /* FULL ON */ | |
| 71 | + cur &= ~CRVML_BACKLIGHT_OFF; | |
| 72 | + outl(cur, addr); | |
| 73 | + } | |
| 82 | 74 | |
| 83 | 75 | return 0; |
| 84 | 76 | } |
| @@ -90,9 +82,9 @@ static int cr_backlight_get_intensity(struct backlight_device *bd) · 5 unmodified lines | ||
| 90 | 82 | u8 intensity; |
| 91 | 83 | |
| 92 | 84 | if (cur & CRVML_BACKLIGHT_OFF) |
| 93 | − intensity = FB_BLANK_POWERDOWN; | |
| 85 | + intensity = 0; | |
| 94 | 86 | else |
| 95 | − intensity = FB_BLANK_UNBLANK; | |
| 87 | + intensity = 1; | |
| 96 | 88 | |
| 97 | 89 | return intensity; |
| 98 | 90 | } |
| @@ -77,18 +77,7 @@ static int da903x_backlight_set(struct backlight_device *bl, int brightness) · 76 unmodified lines | ||
| 77 | 77 | |
| 78 | 78 | static int da903x_backlight_update_status(struct backlight_device *bl) |
| 79 | 79 | { |
| 80 | − int brightness = bl->props.brightness; | |
| 81 | − | |
| 82 | − if (bl->props.power != FB_BLANK_UNBLANK) | |
| 83 | − brightness = 0; | |
| 84 | − | |
| 85 | − if (bl->props.fb_blank != FB_BLANK_UNBLANK) | |
| 86 | − brightness = 0; | |
| 87 | − | |
| 88 | − if (bl->props.state & BL_CORE_SUSPENDED) | |
| 89 | − brightness = 0; | |
| 90 | − | |
| 91 | − return da903x_backlight_set(bl, brightness); | |
| 80 | + return da903x_backlight_set(bl, backlight_get_brightness(bl)); | |
| 92 | 81 | } |
| 93 | 82 | |
| 94 | 83 | static int da903x_backlight_get_brightness(struct backlight_device *bl) |
| @@ -36,13 +36,7 @@ static int ep93xxbl_set(struct backlight_device *bl, int brightness) · 35 unmodified lines | ||
| 36 | 36 | |
| 37 | 37 | static int ep93xxbl_update_status(struct backlight_device *bl) |
| 38 | 38 | { |
| 39 | − int brightness = bl->props.brightness; | |
| 40 | − | |
| 41 | − if (bl->props.power != FB_BLANK_UNBLANK || | |
| 42 | − bl->props.fb_blank != FB_BLANK_UNBLANK) | |
| 43 | − brightness = 0; | |
| 44 | − | |
| 45 | − return ep93xxbl_set(bl, brightness); | |
| 39 | + return ep93xxbl_set(bl, backlight_get_brightness(bl)); | |
| 46 | 40 | } |
| 47 | 41 | |
| 48 | 42 | static int ep93xxbl_get_brightness(struct backlight_device *bl) |
| @@ -1,110 +0,0 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0-only | |
| 2 | −/* | |
| 3 | − * Generic Backlight Driver | |
| 4 | − * | |
| 5 | − * Copyright (c) 2004-2008 Richard Purdie | |
| 6 | − */ | |
| 7 | − | |
| 8 | −#include <linux/module.h> | |
| 9 | −#include <linux/kernel.h> | |
| 10 | −#include <linux/init.h> | |
| 11 | −#include <linux/platform_device.h> | |
| 12 | −#include <linux/mutex.h> | |
| 13 | −#include <linux/fb.h> | |
| 14 | −#include <linux/backlight.h> | |
| 15 | − | |
| 16 | −static int genericbl_intensity; | |
| 17 | −static struct backlight_device *generic_backlight_device; | |
| 18 | −static struct generic_bl_info *bl_machinfo; | |
| 19 | − | |
| 20 | −static int genericbl_send_intensity(struct backlight_device *bd) | |
| 21 | −{ | |
| 22 | − int intensity = bd->props.brightness; | |
| 23 | − | |
| 24 | − if (bd->props.power != FB_BLANK_UNBLANK) | |
| 25 | − intensity = 0; | |
| 26 | − if (bd->props.state & BL_CORE_FBBLANK) | |
| 27 | − intensity = 0; | |
| 28 | − if (bd->props.state & BL_CORE_SUSPENDED) | |
| 29 | − intensity = 0; | |
| 30 | − | |
| 31 | − bl_machinfo->set_bl_intensity(intensity); | |
| 32 | − | |
| 33 | − genericbl_intensity = intensity; | |
| 34 | − | |
| 35 | − if (bl_machinfo->kick_battery) | |
| 36 | − bl_machinfo->kick_battery(); | |
| 37 | − | |
| 38 | − return 0; | |
| 39 | −} | |
| 40 | − | |
| 41 | −static int genericbl_get_intensity(struct backlight_device *bd) | |
| 42 | −{ | |
| 43 | − return genericbl_intensity; | |
| 44 | −} | |
| 45 | − | |
| 46 | −static const struct backlight_ops genericbl_ops = { | |
| 47 | − .options = BL_CORE_SUSPENDRESUME, | |
| 48 | − .get_brightness = genericbl_get_intensity, | |
| 49 | − .update_status = genericbl_send_intensity, | |
| 50 | −}; | |
| 51 | − | |
| 52 | −static int genericbl_probe(struct platform_device *pdev) | |
| 53 | −{ | |
| 54 | − struct backlight_properties props; | |
| 55 | − struct generic_bl_info *machinfo = dev_get_platdata(&pdev->dev); | |
| 56 | − const char *name = "generic-bl"; | |
| 57 | − struct backlight_device *bd; | |
| 58 | − | |
| 59 | − bl_machinfo = machinfo; | |
| 60 | − if (!machinfo->limit_mask) | |
| 61 | − machinfo->limit_mask = -1; | |
| 62 | − | |
| 63 | − if (machinfo->name) | |
| 64 | − name = machinfo->name; | |
| 65 | − | |
| 66 | − memset(&props, 0, sizeof(struct backlight_properties)); | |
| 67 | − props.type = BACKLIGHT_RAW; | |
| 68 | − props.max_brightness = machinfo->max_intensity; | |
| 69 | − bd = devm_backlight_device_register(&pdev->dev, name, &pdev->dev, | |
| 70 | − NULL, &genericbl_ops, &props); | |
| 71 | − if (IS_ERR(bd)) | |
| 72 | − return PTR_ERR(bd); | |
| 73 | − | |
| 74 | − platform_set_drvdata(pdev, bd); | |
| 75 | − | |
| 76 | − bd->props.power = FB_BLANK_UNBLANK; | |
| 77 | − bd->props.brightness = machinfo->default_intensity; | |
| 78 | − backlight_update_status(bd); | |
| 79 | − | |
| 80 | − generic_backlight_device = bd; | |
| 81 | − | |
| 82 | − dev_info(&pdev->dev, "Generic Backlight Driver Initialized.\n"); | |
| 83 | − return 0; | |
| 84 | −} | |
| 85 | − | |
| 86 | −static int genericbl_remove(struct platform_device *pdev) | |
| 87 | −{ | |
| 88 | − struct backlight_device *bd = platform_get_drvdata(pdev); | |
| 89 | − | |
| 90 | − bd->props.power = 0; | |
| 91 | − bd->props.brightness = 0; | |
| 92 | − backlight_update_status(bd); | |
| 93 | − | |
| 94 | − dev_info(&pdev->dev, "Generic Backlight Driver Unloaded\n"); | |
| 95 | − return 0; | |
| 96 | −} | |
| 97 | − | |
| 98 | −static struct platform_driver genericbl_driver = { | |
| 99 | − .probe = genericbl_probe, | |
| 100 | − .remove = genericbl_remove, | |
| 101 | − .driver = { | |
| 102 | − .name = "generic-bl", | |
| 103 | − }, | |
| 104 | −}; | |
| 105 | − | |
| 106 | −module_platform_driver(genericbl_driver); | |
| 107 | − | |
| 108 | −MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | |
| 109 | −MODULE_DESCRIPTION("Generic Backlight Driver"); | |
| 110 | −MODULE_LICENSE("GPL"); | |
| @@ -21,24 +21,11 @@ struct gpio_backlight { · 20 unmodified lines | ||
| 21 | 21 | struct gpio_desc *gpiod; |
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | −static int gpio_backlight_get_next_brightness(struct backlight_device *bl) | |
| 25 | −{ | |
| 26 | − int brightness = bl->props.brightness; | |
| 27 | − | |
| 28 | − if (bl->props.power != FB_BLANK_UNBLANK || | |
| 29 | − bl->props.fb_blank != FB_BLANK_UNBLANK || | |
| 30 | − bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) | |
| 31 | − brightness = 0; | |
| 32 | − | |
| 33 | − return brightness; | |
| 34 | −} | |
| 35 | − | |
| 36 | 24 | static int gpio_backlight_update_status(struct backlight_device *bl) |
| 37 | 25 | { |
| 38 | 26 | struct gpio_backlight *gbl = bl_get_data(bl); |
| 39 | − int brightness = gpio_backlight_get_next_brightness(bl); | |
| 40 | 27 | |
| 41 | − gpiod_set_value_cansleep(gbl->gpiod, brightness); | |
| 28 | + gpiod_set_value_cansleep(gbl->gpiod, backlight_get_brightness(bl)); | |
| 42 | 29 | |
| 43 | 30 | return 0; |
| 44 | 31 | } |
| @@ -108,7 +95,7 @@ static int gpio_backlight_probe(struct platform_device *pdev) · 63 unmodified lines | ||
| 108 | 95 | |
| 109 | 96 | bl->props.brightness = 1; |
| 110 | 97 | |
| 111 | − init_brightness = gpio_backlight_get_next_brightness(bl); | |
| 98 | + init_brightness = backlight_get_brightness(bl); | |
| 112 | 99 | ret = gpiod_direction_output(gbl->gpiod, init_brightness); |
| 113 | 100 | if (ret) { |
| 114 | 101 | dev_err(dev, "failed to set initial brightness\n"); |
| @@ -33,12 +33,8 @@ static void hp680bl_send_intensity(struct backlight_device *bd) · 32 unmodified lines | ||
| 33 | 33 | { |
| 34 | 34 | unsigned long flags; |
| 35 | 35 | u16 v; |
| 36 | − int intensity = bd->props.brightness; | |
| 36 | + int intensity = backlight_get_brightness(bd); | |
| 37 | 37 | |
| 38 | − if (bd->props.power != FB_BLANK_UNBLANK) | |
| 39 | − intensity = 0; | |
| 40 | − if (bd->props.fb_blank != FB_BLANK_UNBLANK) | |
| 41 | − intensity = 0; | |
| 42 | 38 | if (hp680bl_suspended) |
| 43 | 39 | intensity = 0; |
| 44 | 40 | |
| @@ -107,6 +107,8 @@ · 106 unmodified lines | ||
| 107 | 107 | * lower frequency when the registers are read/written. |
| 108 | 108 | * The macro sets the frequency in the spi_transfer structure if |
| 109 | 109 | * the frequency exceeds the maximum value. |
| 110 | + * @s: pointer to an SPI device | |
| 111 | + * @x: pointer to the read/write buffer pair | |
| 110 | 112 | */ |
| 111 | 113 | #define CHECK_FREQ_REG(s, x) \ |
| 112 | 114 | do { \ |
| @@ -121,7 +123,7 @@ · 8 unmodified lines | ||
| 121 | 123 | |
| 122 | 124 | #define set_tx_byte(b) (tx_invert ? ~(b) : b) |
| 123 | 125 | |
| 124 | −/** | |
| 126 | +/* | |
| 125 | 127 | * ili922x_id - id as set by manufacturer |
| 126 | 128 | */ |
| 127 | 129 | static int ili922x_id = 1; |
| @@ -130,7 +132,7 @@ module_param(ili922x_id, int, 0); · 2 unmodified lines | ||
| 130 | 132 | static int tx_invert; |
| 131 | 133 | module_param(tx_invert, int, 0); |
| 132 | 134 | |
| 133 | −/** | |
| 135 | +/* | |
| 134 | 136 | * driver's private structure |
| 135 | 137 | */ |
| 136 | 138 | struct ili922x { |
| @@ -293,6 +295,8 @@ static int ili922x_write(struct spi_device *spi, u8 reg, u16 value) · 156 unmodified lines | ||
| 293 | 295 | #ifdef DEBUG |
| 294 | 296 | /** |
| 295 | 297 | * ili922x_reg_dump - dump all registers |
| 298 | + * | |
| 299 | + * @spi: pointer to an SPI device | |
| 296 | 300 | */ |
| 297 | 301 | static void ili922x_reg_dump(struct spi_device *spi) |
| 298 | 302 | { |
| @@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd) · 53 unmodified lines | ||
| 54 | 54 | jornada_ssp_start(); |
| 55 | 55 | |
| 56 | 56 | /* If backlight is off then really turn it off */ |
| 57 | − if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) { | |
| 57 | + if (backlight_is_blank(bd)) { | |
| 58 | 58 | ret = jornada_ssp_byte(BRIGHTNESSOFF); |
| 59 | 59 | if (ret != TXDUMMY) { |
| 60 | 60 | dev_info(&bd->dev, "brightness off timeout\n"); |
| @@ -87,12 +87,8 @@ static const struct dmi_system_id kb3886bl_device_table[] __initconst = { · 86 unmodified lines | ||
| 87 | 87 | |
| 88 | 88 | static int kb3886bl_send_intensity(struct backlight_device *bd) |
| 89 | 89 | { |
| 90 | − int intensity = bd->props.brightness; | |
| 90 | + int intensity = backlight_get_brightness(bd); | |
| 91 | 91 | |
| 92 | − if (bd->props.power != FB_BLANK_UNBLANK) | |
| 93 | − intensity = 0; | |
| 94 | − if (bd->props.fb_blank != FB_BLANK_UNBLANK) | |
| 95 | − intensity = 0; | |
| 96 | 92 | if (kb3886bl_flags & KB3886BL_SUSPENDED) |
| 97 | 93 | intensity = 0; |
| 98 | 94 | |
| @@ -179,6 +179,7 @@ ATTRIBUTE_GROUPS(lcd_device); · 178 unmodified lines | ||
| 179 | 179 | * lcd_device_register - register a new object of lcd_device class. |
| 180 | 180 | * @name: the name of the new object(must be the same as the name of the |
| 181 | 181 | * respective framebuffer device). |
| 182 | + * @parent: pointer to the parent's struct device . | |
| 182 | 183 | * @devdata: an optional pointer to be stored in the device. The |
| 183 | 184 | * methods may retrieve it by using lcd_get_data(ld). |
| 184 | 185 | * @ops: the lcd operations structure. |
| @@ -54,12 +54,7 @@ static void led_bl_power_off(struct led_bl_data *priv) · 53 unmodified lines | ||
| 54 | 54 | static int led_bl_update_status(struct backlight_device *bl) |
| 55 | 55 | { |
| 56 | 56 | struct led_bl_data *priv = bl_get_data(bl); |
| 57 | − int brightness = bl->props.brightness; | |
| 58 | − | |
| 59 | − if (bl->props.power != FB_BLANK_UNBLANK || | |
| 60 | − bl->props.fb_blank != FB_BLANK_UNBLANK || | |
| 61 | − bl->props.state & BL_CORE_FBBLANK) | |
| 62 | − brightness = 0; | |
| 57 | + int brightness = backlight_get_brightness(bl); | |
| 63 | 58 | |
| 64 | 59 | if (brightness > 0) |
| 65 | 60 | led_bl_set_brightness(priv, brightness); |
| @@ -39,14 +39,8 @@ static inline int lm3533_bl_get_ctrlbank_id(struct lm3533_bl *bl) · 38 unmodified lines | ||
| 39 | 39 | static int lm3533_bl_update_status(struct backlight_device *bd) |
| 40 | 40 | { |
| 41 | 41 | struct lm3533_bl *bl = bl_get_data(bd); |
| 42 | − int brightness = bd->props.brightness; | |
| 43 | 42 | |
| 44 | − if (bd->props.power != FB_BLANK_UNBLANK) | |
| 45 | − brightness = 0; | |
| 46 | − if (bd->props.fb_blank != FB_BLANK_UNBLANK) | |
| 47 | − brightness = 0; | |
| 48 | − | |
| 49 | − return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness); | |
| 43 | + return lm3533_ctrlbank_set_brightness(&bl->cb, backlight_get_brightness(bd)); | |
| 50 | 44 | } |
| 51 | 45 | |
| 52 | 46 | static int lm3533_bl_get_brightness(struct backlight_device *bd) |
| @@ -235,7 +229,7 @@ static struct attribute *lm3533_bl_attributes[] = { · 182 unmodified lines | ||
| 235 | 229 | static umode_t lm3533_bl_attr_is_visible(struct kobject *kobj, |
| 236 | 230 | struct attribute *attr, int n) |
| 237 | 231 | { |
| 238 | − struct device *dev = container_of(kobj, struct device, kobj); | |
| 232 | + struct device *dev = kobj_to_dev(kobj); | |
| 239 | 233 | struct lm3533_bl *bl = dev_get_drvdata(dev); |
| 240 | 234 | umode_t mode = attr->mode; |
| 241 | 235 | |
| @@ -391,7 +391,7 @@ static int lm3630a_parse_led_sources(struct fwnode_handle *node, · 390 unmodified lines | ||
| 391 | 391 | return ret; |
| 392 | 392 | |
| 393 | 393 | for (i = 0; i < num_sources; i++) { |
| 394 | − if (sources[i] < LM3630A_SINK_0 || sources[i] > LM3630A_SINK_1) | |
| 394 | + if (sources[i] != LM3630A_SINK_0 && sources[i] != LM3630A_SINK_1) | |
| 395 | 395 | return -EINVAL; |
| 396 | 396 | |
| 397 | 397 | ret |= BIT(sources[i]); |
| @@ -412,7 +412,7 @@ static int lm3630a_parse_bank(struct lm3630a_platform_data *pdata, · 14 unmodified lines | ||
| 412 | 412 | if (ret) |
| 413 | 413 | return ret; |
| 414 | 414 | |
| 415 | − if (bank < LM3630A_BANK_0 || bank > LM3630A_BANK_1) | |
| 415 | + if (bank != LM3630A_BANK_0 && bank != LM3630A_BANK_1) | |
| 416 | 416 | return -EINVAL; |
| 417 | 417 | |
| 418 | 418 | led_sources = lm3630a_parse_led_sources(node, BIT(bank)); |
| @@ -9,7 +9,6 @@ · 8 unmodified lines | ||
| 9 | 9 | #include <linux/backlight.h> |
| 10 | 10 | #include <linux/delay.h> |
| 11 | 11 | #include <linux/fb.h> |
| 12 | −#include <linux/gpio.h> | |
| 13 | 12 | #include <linux/lcd.h> |
| 14 | 13 | #include <linux/module.h> |
| 15 | 14 | #include <linux/spi/spi.h> |
| @@ -89,14 +88,6 @@ static const unsigned char seq_rgb_gamma[] = { · 73 unmodified lines | ||
| 89 | 88 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 90 | 89 | }; |
| 91 | 90 | |
| 92 | −static const unsigned char seq_up_dn[] = { | |
| 93 | − 0x36, 0x10, | |
| 94 | −}; | |
| 95 | − | |
| 96 | −static const unsigned char seq_sleep_in[] = { | |
| 97 | − 0x10, | |
| 98 | −}; | |
| 99 | − | |
| 100 | 91 | static const unsigned char seq_sleep_out[] = { |
| 101 | 92 | 0x11, |
| 102 | 93 | }; |
| @@ -111,12 +111,8 @@ static int current_intensity; · 110 unmodified lines | ||
| 111 | 111 | |
| 112 | 112 | static int locomolcd_set_intensity(struct backlight_device *bd) |
| 113 | 113 | { |
| 114 | − int intensity = bd->props.brightness; | |
| 114 | + int intensity = backlight_get_brightness(bd); | |
| 115 | 115 | |
| 116 | − if (bd->props.power != FB_BLANK_UNBLANK) | |
| 117 | − intensity = 0; | |
| 118 | − if (bd->props.fb_blank != FB_BLANK_UNBLANK) | |
| 119 | − intensity = 0; | |
| 120 | 116 | if (locomolcd_flags & LOCOMOLCD_SUSPENDED) |
| 121 | 117 | intensity = 0; |
| 122 | 118 | |
| @@ -46,12 +46,7 @@ static int lv5207lp_write(struct lv5207lp *lv, u8 reg, u8 data) · 45 unmodified lines | ||
| 46 | 46 | static int lv5207lp_backlight_update_status(struct backlight_device *backlight) |
| 47 | 47 | { |
| 48 | 48 | struct lv5207lp *lv = bl_get_data(backlight); |
| 49 | − int brightness = backlight->props.brightness; | |
| 50 | − | |
| 51 | − if (backlight->props.power != FB_BLANK_UNBLANK || | |
| 52 | − backlight->props.fb_blank != FB_BLANK_UNBLANK || | |
| 53 | − backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) | |
| 54 | − brightness = 0; | |
| 49 | + int brightness = backlight_get_brightness(backlight); | |
| 55 | 50 | |
| 56 | 51 | if (brightness) { |
| 57 | 52 | lv5207lp_write(lv, LV5207LP_CTRL1, |
| @@ -64,18 +64,7 @@ out: · 63 unmodified lines | ||
| 64 | 64 | |
| 65 | 65 | static int max8925_backlight_update_status(struct backlight_device *bl) |
| 66 | 66 | { |
| 67 | − int brightness = bl->props.brightness; | |
| 68 | − | |
| 69 | − if (bl->props.power != FB_BLANK_UNBLANK) | |
| 70 | − brightness = 0; | |
| 71 | − | |
| 72 | − if (bl->props.fb_blank != FB_BLANK_UNBLANK) | |
| 73 | − brightness = 0; | |
| 74 | − | |
| 75 | − if (bl->props.state & BL_CORE_SUSPENDED) | |
| 76 | − brightness = 0; | |
| 77 | − | |
| 78 | − return max8925_backlight_set(bl, brightness); | |
| 67 | + return max8925_backlight_set(bl, backlight_get_brightness(bl)); | |
| 79 | 68 | } |
| 80 | 69 | |
| 81 | 70 | static int max8925_backlight_get_brightness(struct backlight_device *bl) |
| @@ -1,162 +0,0 @@ | ||
| 1 | −// SPDX-License-Identifier: GPL-2.0-only | |
| 2 | −/* | |
| 3 | − * Copyright (C) 2012 Bachmann electronic GmbH | |
| 4 | − * Christian Gmeiner <christian.gmeiner@gmail.com> | |
| 5 | − * | |
| 6 | − * Backlight driver for ot200 visualisation device from | |
| 7 | − * Bachmann electronic GmbH. | |
| 8 | − */ | |
| 9 | − | |
| 10 | −#include <linux/module.h> | |
| 11 | −#include <linux/fb.h> | |
| 12 | −#include <linux/backlight.h> | |
| 13 | −#include <linux/gpio.h> | |
| 14 | −#include <linux/platform_device.h> | |
| 15 | −#include <linux/cs5535.h> | |
| 16 | − | |
| 17 | −static struct cs5535_mfgpt_timer *pwm_timer; | |
| 18 | − | |
| 19 | −/* this array defines the mapping of brightness in % to pwm frequency */ | |
| 20 | −static const u8 dim_table[101] = {0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, | |
| 21 | − 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, | |
| 22 | − 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, | |
| 23 | − 10, 10, 11, 11, 12, 12, 13, 14, 15, 15, 16, | |
| 24 | − 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, | |
| 25 | − 30, 31, 33, 35, 37, 39, 41, 43, 45, 47, 50, | |
| 26 | − 53, 55, 58, 61, 65, 68, 72, 75, 79, 84, 88, | |
| 27 | − 93, 97, 103, 108, 114, 120, 126, 133, 140, | |
| 28 | − 147, 155, 163}; | |
| 29 | − | |
| 30 | −struct ot200_backlight_data { | |
| 31 | − int current_brightness; | |
| 32 | −}; | |
| 33 | − | |
| 34 | −#define GPIO_DIMM 27 | |
| 35 | −#define SCALE 1 | |
| 36 | −#define CMP1MODE 0x2 /* compare on GE; output high on compare | |
| 37 | − * greater than or equal */ | |
| 38 | −#define PWM_SETUP (SCALE | CMP1MODE << 6 | MFGPT_SETUP_CNTEN) | |
| 39 | −#define MAX_COMP2 163 | |
| 40 | − | |
| 41 | −static int ot200_backlight_update_status(struct backlight_device *bl) | |
| 42 | −{ | |
| 43 | − struct ot200_backlight_data *data = bl_get_data(bl); | |
| 44 | − int brightness = bl->props.brightness; | |
| 45 | − | |
| 46 | − if (bl->props.state & BL_CORE_FBBLANK) | |
| 47 | − brightness = 0; | |
| 48 | − | |
| 49 | − /* enable or disable PWM timer */ | |
| 50 | − if (brightness == 0) | |
| 51 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, 0); | |
| 52 | − else if (data->current_brightness == 0) { | |
| 53 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_COUNTER, 0); | |
| 54 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, | |
| 55 | − MFGPT_SETUP_CNTEN); | |
| 56 | − } | |
| 57 | − | |
| 58 | − /* apply new brightness value */ | |
| 59 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1, | |
| 60 | − MAX_COMP2 - dim_table[brightness]); | |
| 61 | − data->current_brightness = brightness; | |
| 62 | − | |
| 63 | − return 0; | |
| 64 | −} | |
| 65 | − | |
| 66 | −static int ot200_backlight_get_brightness(struct backlight_device *bl) | |
| 67 | −{ | |
| 68 | − struct ot200_backlight_data *data = bl_get_data(bl); | |
| 69 | − return data->current_brightness; | |
| 70 | −} | |
| 71 | − | |
| 72 | −static const struct backlight_ops ot200_backlight_ops = { | |
| 73 | − .update_status = ot200_backlight_update_status, | |
| 74 | − .get_brightness = ot200_backlight_get_brightness, | |
| 75 | −}; | |
| 76 | − | |
| 77 | −static int ot200_backlight_probe(struct platform_device *pdev) | |
| 78 | −{ | |
| 79 | − struct backlight_device *bl; | |
| 80 | − struct ot200_backlight_data *data; | |
| 81 | − struct backlight_properties props; | |
| 82 | − int retval = 0; | |
| 83 | − | |
| 84 | − /* request gpio */ | |
| 85 | − if (devm_gpio_request(&pdev->dev, GPIO_DIMM, | |
| 86 | − "ot200 backlight dimmer") < 0) { | |
| 87 | − dev_err(&pdev->dev, "failed to request GPIO %d\n", GPIO_DIMM); | |
| 88 | − return -ENODEV; | |
| 89 | − } | |
| 90 | − | |
| 91 | − /* request timer */ | |
| 92 | − pwm_timer = cs5535_mfgpt_alloc_timer(7, MFGPT_DOMAIN_ANY); | |
| 93 | − if (!pwm_timer) { | |
| 94 | − dev_err(&pdev->dev, "MFGPT 7 not available\n"); | |
| 95 | − return -ENODEV; | |
| 96 | − } | |
| 97 | − | |
| 98 | − data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | |
| 99 | − if (!data) { | |
| 100 | − retval = -ENOMEM; | |
| 101 | − goto error_devm_kzalloc; | |
| 102 | − } | |
| 103 | − | |
| 104 | − /* setup gpio */ | |
| 105 | − cs5535_gpio_set(GPIO_DIMM, GPIO_OUTPUT_ENABLE); | |
| 106 | − cs5535_gpio_set(GPIO_DIMM, GPIO_OUTPUT_AUX1); | |
| 107 | − | |
| 108 | − /* setup timer */ | |
| 109 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1, 0); | |
| 110 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP2, MAX_COMP2); | |
| 111 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, PWM_SETUP); | |
| 112 | − | |
| 113 | − data->current_brightness = 100; | |
| 114 | − props.max_brightness = 100; | |
| 115 | − props.brightness = 100; | |
| 116 | − props.type = BACKLIGHT_RAW; | |
| 117 | − | |
| 118 | − bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev), | |
| 119 | − &pdev->dev, data, &ot200_backlight_ops, | |
| 120 | − &props); | |
| 121 | − if (IS_ERR(bl)) { | |
| 122 | − dev_err(&pdev->dev, "failed to register backlight\n"); | |
| 123 | − retval = PTR_ERR(bl); | |
| 124 | − goto error_devm_kzalloc; | |
| 125 | − } | |
| 126 | − | |
| 127 | − platform_set_drvdata(pdev, bl); | |
| 128 | − | |
| 129 | − return 0; | |
| 130 | − | |
| 131 | −error_devm_kzalloc: | |
| 132 | − cs5535_mfgpt_free_timer(pwm_timer); | |
| 133 | − return retval; | |
| 134 | −} | |
| 135 | − | |
| 136 | −static int ot200_backlight_remove(struct platform_device *pdev) | |
| 137 | −{ | |
| 138 | − /* on module unload set brightness to 100% */ | |
| 139 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_COUNTER, 0); | |
| 140 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, MFGPT_SETUP_CNTEN); | |
| 141 | − cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1, | |
| 142 | − MAX_COMP2 - dim_table[100]); | |
| 143 | − | |
| 144 | − cs5535_mfgpt_free_timer(pwm_timer); | |
| 145 | − | |
| 146 | − return 0; | |
| 147 | −} | |
| 148 | − | |
| 149 | −static struct platform_driver ot200_backlight_driver = { | |
| 150 | − .driver = { | |
| 151 | − .name = "ot200-backlight", | |
| 152 | − }, | |
| 153 | − .probe = ot200_backlight_probe, | |
| 154 | − .remove = ot200_backlight_remove, | |
| 155 | −}; | |
| 156 | − | |
| 157 | −module_platform_driver(ot200_backlight_driver); | |
| 158 | − | |
| 159 | −MODULE_DESCRIPTION("backlight driver for ot200 visualisation device"); | |
| 160 | −MODULE_AUTHOR("Christian Gmeiner <christian.gmeiner@gmail.com>"); | |
| 161 | −MODULE_LICENSE("GPL"); | |
| 162 | −MODULE_ALIAS("platform:ot200-backlight"); | |
| @@ -108,14 +108,9 @@ static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness) · 107 unmodified lines | ||
| 108 | 108 | static int pwm_backlight_update_status(struct backlight_device *bl) |
| 109 | 109 | { |
| 110 | 110 | struct pwm_bl_data *pb = bl_get_data(bl); |
| 111 | − int brightness = bl->props.brightness; | |
| 111 | + int brightness = backlight_get_brightness(bl); | |
| 112 | 112 | struct pwm_state state; |
| 113 | 113 | |
| 114 | − if (bl->props.power != FB_BLANK_UNBLANK || | |
| 115 | − bl->props.fb_blank != FB_BLANK_UNBLANK || | |
| 116 | − bl->props.state & BL_CORE_FBBLANK) | |
| 117 | − brightness = 0; | |
| 118 | − | |
| 119 | 114 | if (pb->notify) |
| 120 | 115 | brightness = pb->notify(pb->dev, brightness); |
| 121 | 116 | |
| @@ -433,14 +433,9 @@ static int wled5_ovp_delay(struct wled *wled) · 432 unmodified lines | ||
| 433 | 433 | static int wled_update_status(struct backlight_device *bl) |
| 434 | 434 | { |
| 435 | 435 | struct wled *wled = bl_get_data(bl); |
| 436 | − u16 brightness = bl->props.brightness; | |
| 436 | + u16 brightness = backlight_get_brightness(bl); | |
| 437 | 437 | int rc = 0; |
| 438 | 438 | |
| 439 | − if (bl->props.power != FB_BLANK_UNBLANK || | |
| 440 | − bl->props.fb_blank != FB_BLANK_UNBLANK || | |
| 441 | − bl->props.state & BL_CORE_FBBLANK) | |
| 442 | − brightness = 0; | |
| 443 | − | |
| 444 | 439 | mutex_lock(&wled->lock); |
| 445 | 440 | if (brightness) { |
| 446 | 441 | rc = wled->wled_set_brightness(wled, brightness); |
| @@ -1287,14 +1282,6 @@ static const struct wled_var_cfg wled4_string_i_limit_cfg = { · 840 unmodified lines | ||
| 1287 | 1282 | .size = ARRAY_SIZE(wled4_string_i_limit_values), |
| 1288 | 1283 | }; |
| 1289 | 1284 | |
| 1290 | −static const struct wled_var_cfg wled3_string_cfg = { | |
| 1291 | − .size = 8, | |
| 1292 | −}; | |
| 1293 | − | |
| 1294 | −static const struct wled_var_cfg wled4_string_cfg = { | |
| 1295 | − .size = 16, | |
| 1296 | −}; | |
| 1297 | − | |
| 1298 | 1285 | static const struct wled_var_cfg wled5_mod_sel_cfg = { |
| 1299 | 1286 | .size = 2, |
| 1300 | 1287 | }; |
| @@ -8,15 +8,13 @@ · 7 unmodified lines | ||
| 8 | 8 | |
| 9 | 9 | #include <linux/backlight.h> |
| 10 | 10 | #include <linux/err.h> |
| 11 | −#include <linux/gpio.h> | |
| 11 | +#include <linux/gpio/consumer.h> | |
| 12 | 12 | #include <linux/init.h> |
| 13 | 13 | #include <linux/kernel.h> |
| 14 | 14 | #include <linux/module.h> |
| 15 | 15 | #include <linux/of.h> |
| 16 | −#include <linux/of_gpio.h> | |
| 17 | 16 | #include <linux/platform_device.h> |
| 18 | 17 | #include <linux/regmap.h> |
| 19 | −#include <linux/platform_data/sky81452-backlight.h> | |
| 20 | 18 | #include <linux/slab.h> |
| 21 | 19 | |
| 22 | 20 | /* registers */ |
| @@ -42,6 +40,29 @@ · 19 unmodified lines | ||
| 42 | 40 | #define SKY81452_DEFAULT_NAME "lcd-backlight" |
| 43 | 41 | #define SKY81452_MAX_BRIGHTNESS (SKY81452_CS + 1) |
| 44 | 42 | |
| 43 | +/** | |
| 44 | + * struct sky81452_platform_data | |
| 45 | + * @name: backlight driver name. | |
| 46 | + * If it is not defined, default name is lcd-backlight. | |
| 47 | + * @gpiod_enable:GPIO descriptor which control EN pin | |
| 48 | + * @enable: Enable mask for current sink channel 1, 2, 3, 4, 5 and 6. | |
| 49 | + * @ignore_pwm: true if DPWMI should be ignored. | |
| 50 | + * @dpwm_mode: true is DPWM dimming mode, otherwise Analog dimming mode. | |
| 51 | + * @phase_shift:true is phase shift mode. | |
| 52 | + * @short_detection_threshold: It should be one of 4, 5, 6 and 7V. | |
| 53 | + * @boost_current_limit: It should be one of 2300, 2750mA. | |
| 54 | + */ | |
| 55 | +struct sky81452_bl_platform_data { | |
| 56 | + const char *name; | |
| 57 | + struct gpio_desc *gpiod_enable; | |
| 58 | + unsigned int enable; | |
| 59 | + bool ignore_pwm; | |
| 60 | + bool dpwm_mode; | |
| 61 | + bool phase_shift; | |
| 62 | + unsigned int short_detection_threshold; | |
| 63 | + unsigned int boost_current_limit; | |
| 64 | +}; | |
| 65 | + | |
| 45 | 66 | #define CTZ(b) __builtin_ctz(b) |
| 46 | 67 | |
| 47 | 68 | static int sky81452_bl_update_status(struct backlight_device *bd) |
| @@ -182,7 +203,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt( · 134 unmodified lines | ||
| 182 | 203 | pdata->ignore_pwm = of_property_read_bool(np, "skyworks,ignore-pwm"); |
| 183 | 204 | pdata->dpwm_mode = of_property_read_bool(np, "skyworks,dpwm-mode"); |
| 184 | 205 | pdata->phase_shift = of_property_read_bool(np, "skyworks,phase-shift"); |
| 185 | − pdata->gpio_enable = of_get_gpio(np, 0); | |
| 206 | + pdata->gpiod_enable = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH); | |
| 186 | 207 | |
| 187 | 208 | ret = of_property_count_u32_elems(np, "led-sources"); |
| 188 | 209 | if (ret < 0) { |
| @@ -252,26 +273,15 @@ static int sky81452_bl_probe(struct platform_device *pdev) · 63 unmodified lines | ||
| 252 | 273 | { |
| 253 | 274 | struct device *dev = &pdev->dev; |
| 254 | 275 | struct regmap *regmap = dev_get_drvdata(dev->parent); |
| 255 | − struct sky81452_bl_platform_data *pdata = dev_get_platdata(dev); | |
| 276 | + struct sky81452_bl_platform_data *pdata; | |
| 256 | 277 | struct backlight_device *bd; |
| 257 | 278 | struct backlight_properties props; |
| 258 | 279 | const char *name; |
| 259 | 280 | int ret; |
| 260 | 281 | |
| 261 | − if (!pdata) { | |
| 262 | − pdata = sky81452_bl_parse_dt(dev); | |
| 263 | − if (IS_ERR(pdata)) | |
| 264 | − return PTR_ERR(pdata); | |
| 265 | − } | |
| 266 | − | |
| 267 | − if (gpio_is_valid(pdata->gpio_enable)) { | |
| 268 | − ret = devm_gpio_request_one(dev, pdata->gpio_enable, | |
| 269 | − GPIOF_OUT_INIT_HIGH, "sky81452-en"); | |
| 270 | − if (ret < 0) { | |
| 271 | − dev_err(dev, "failed to request GPIO. err=%d\n", ret); | |
| 272 | − return ret; | |
| 273 | − } | |
| 274 | − } | |
| 282 | + pdata = sky81452_bl_parse_dt(dev); | |
| 283 | + if (IS_ERR(pdata)) | |
| 284 | + return PTR_ERR(pdata); | |
| 275 | 285 | |
| 276 | 286 | ret = sky81452_bl_init_device(regmap, pdata); |
| 277 | 287 | if (ret < 0) { |
| @@ -312,8 +322,8 @@ static int sky81452_bl_remove(struct platform_device *pdev) · 34 unmodified lines | ||
| 312 | 322 | bd->props.brightness = 0; |
| 313 | 323 | backlight_update_status(bd); |
| 314 | 324 | |
| 315 | − if (gpio_is_valid(pdata->gpio_enable)) | |
| 316 | − gpio_set_value_cansleep(pdata->gpio_enable, 0); | |
| 325 | + if (pdata->gpiod_enable) | |
| 326 | + gpiod_set_value_cansleep(pdata->gpiod_enable, 0); | |
| 317 | 327 | |
| 318 | 328 | return 0; |
| 319 | 329 | } |
| @@ -77,15 +77,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl) · 76 unmodified lines | ||
| 77 | 77 | { |
| 78 | 78 | struct tps65217_bl *tps65217_bl = bl_get_data(bl); |
| 79 | 79 | int rc; |
| 80 | − int brightness = bl->props.brightness; | |
| 81 | − | |
| 82 | − if (bl->props.state & BL_CORE_SUSPENDED) | |
| 83 | − brightness = 0; | |
| 84 | − | |
| 85 | − if ((bl->props.power != FB_BLANK_UNBLANK) || | |
| 86 | − (bl->props.fb_blank != FB_BLANK_UNBLANK)) | |
| 87 | − /* framebuffer in low power mode or blanking active */ | |
| 88 | − brightness = 0; | |
| 80 | + int brightness = backlight_get_brightness(bl); | |
| 89 | 81 | |
| 90 | 82 | if (brightness > 0) { |
| 91 | 83 | rc = tps65217_reg_write(tps65217_bl->tps, |
| @@ -91,18 +91,7 @@ err: · 90 unmodified lines | ||
| 91 | 91 | |
| 92 | 92 | static int wm831x_backlight_update_status(struct backlight_device *bl) |
| 93 | 93 | { |
| 94 | − int brightness = bl->props.brightness; | |
| 95 | − | |
| 96 | − if (bl->props.power != FB_BLANK_UNBLANK) | |
| 97 | − brightness = 0; | |
| 98 | − | |
| 99 | − if (bl->props.fb_blank != FB_BLANK_UNBLANK) | |
| 100 | − brightness = 0; | |
| 101 | − | |
| 102 | − if (bl->props.state & BL_CORE_SUSPENDED) | |
| 103 | − brightness = 0; | |
| 104 | − | |
| 105 | − return wm831x_backlight_set(bl, brightness); | |
| 94 | + return wm831x_backlight_set(bl, backlight_get_brightness(bl)); | |
| 106 | 95 | } |
| 107 | 96 | |
| 108 | 97 | static int wm831x_backlight_get_brightness(struct backlight_device *bl) |
| @@ -14,113 +14,336 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <linux/mutex.h> |
| 15 | 15 | #include <linux/notifier.h> |
| 16 | 16 | |
| 17 | −/* Notes on locking: | |
| 18 | − * | |
| 19 | − * backlight_device->ops_lock is an internal backlight lock protecting the | |
| 20 | − * ops pointer and no code outside the core should need to touch it. | |
| 21 | − * | |
| 22 | − * Access to update_status() is serialised by the update_lock mutex since | |
| 23 | − * most drivers seem to need this and historically get it wrong. | |
| 24 | − * | |
| 25 | − * Most drivers don't need locking on their get_brightness() method. | |
| 26 | − * If yours does, you need to implement it in the driver. You can use the | |
| 27 | − * update_lock mutex if appropriate. | |
| 17 | +/** | |
| 18 | + * enum backlight_update_reason - what method was used to update backlight | |
| 28 | 19 | * |
| 29 | − * Any other use of the locks below is probably wrong. | |
| 20 | + * A driver indicates the method (reason) used for updating the backlight | |
| 21 | + * when calling backlight_force_update(). | |
| 30 | 22 | */ |
| 31 | − | |
| 32 | 23 | enum backlight_update_reason { |
| 24 | + /** | |
| 25 | + * @BACKLIGHT_UPDATE_HOTKEY: The backlight was updated using a hot-key. | |
| 26 | + */ | |
| 33 | 27 | BACKLIGHT_UPDATE_HOTKEY, |
| 28 | + | |
| 29 | + /** | |
| 30 | + * @BACKLIGHT_UPDATE_SYSFS: The backlight was updated using sysfs. | |
| 31 | + */ | |
| 34 | 32 | BACKLIGHT_UPDATE_SYSFS, |
| 35 | 33 | }; |
| 36 | 34 | |
| 35 | +/** | |
| 36 | + * enum backlight_type - the type of backlight control | |
| 37 | + * | |
| 38 | + * The type of interface used to control the backlight. | |
| 39 | + */ | |
| 37 | 40 | enum backlight_type { |
| 41 | + /** | |
| 42 | + * @BACKLIGHT_RAW: | |
| 43 | + * | |
| 44 | + * The backlight is controlled using hardware registers. | |
| 45 | + */ | |
| 38 | 46 | BACKLIGHT_RAW = 1, |
| 47 | + | |
| 48 | + /** | |
| 49 | + * @BACKLIGHT_PLATFORM: | |
| 50 | + * | |
| 51 | + * The backlight is controlled using a platform-specific interface. | |
| 52 | + */ | |
| 39 | 53 | BACKLIGHT_PLATFORM, |
| 54 | + | |
| 55 | + /** | |
| 56 | + * @BACKLIGHT_FIRMWARE: | |
| 57 | + * | |
| 58 | + * The backlight is controlled using a standard firmware interface. | |
| 59 | + */ | |
| 40 | 60 | BACKLIGHT_FIRMWARE, |
| 61 | + | |
| 62 | + /** | |
| 63 | + * @BACKLIGHT_TYPE_MAX: Number of entries. | |
| 64 | + */ | |
| 41 | 65 | BACKLIGHT_TYPE_MAX, |
| 42 | 66 | }; |
| 43 | 67 | |
| 68 | +/** | |
| 69 | + * enum backlight_notification - the type of notification | |
| 70 | + * | |
| 71 | + * The notifications that is used for notification sent to the receiver | |
| 72 | + * that registered notifications using backlight_register_notifier(). | |
| 73 | + */ | |
| 44 | 74 | enum backlight_notification { |
| 75 | + /** | |
| 76 | + * @BACKLIGHT_REGISTERED: The backlight device is registered. | |
| 77 | + */ | |
| 45 | 78 | BACKLIGHT_REGISTERED, |
| 79 | + | |
| 80 | + /** | |
| 81 | + * @BACKLIGHT_UNREGISTERED: The backlight revice is unregistered. | |
| 82 | + */ | |
| 46 | 83 | BACKLIGHT_UNREGISTERED, |
| 47 | 84 | }; |
| 48 | 85 | |
| 86 | +/** enum backlight_scale - the type of scale used for brightness values | |
| 87 | + * | |
| 88 | + * The type of scale used for brightness values. | |
| 89 | + */ | |
| 49 | 90 | enum backlight_scale { |
| 91 | + /** | |
| 92 | + * @BACKLIGHT_SCALE_UNKNOWN: The scale is unknown. | |
| 93 | + */ | |
| 50 | 94 | BACKLIGHT_SCALE_UNKNOWN = 0, |
| 95 | + | |
| 96 | + /** | |
| 97 | + * @BACKLIGHT_SCALE_LINEAR: The scale is linear. | |
| 98 | + * | |
| 99 | + * The linear scale will increase brightness the same for each step. | |
| 100 | + */ | |
| 51 | 101 | BACKLIGHT_SCALE_LINEAR, |
| 102 | + | |
| 103 | + /** | |
| 104 | + * @BACKLIGHT_SCALE_NON_LINEAR: The scale is not linear. | |
| 105 | + * | |
| 106 | + * This is often used when the brightness values tries to adjust to | |
| 107 | + * the relative perception of the eye demanding a non-linear scale. | |
| 108 | + */ | |
| 52 | 109 | BACKLIGHT_SCALE_NON_LINEAR, |
| 53 | 110 | }; |
| 54 | 111 | |
| 55 | 112 | struct backlight_device; |
| 56 | 113 | struct fb_info; |
| 57 | 114 | |
| 115 | +/** | |
| 116 | + * struct backlight_ops - backlight operations | |
| 117 | + * | |
| 118 | + * The backlight operations are specified when the backlight device is registered. | |
| 119 | + */ | |
| 58 | 120 | struct backlight_ops { |
| 121 | + /** | |
| 122 | + * @options: Configure how operations are called from the core. | |
| 123 | + * | |
| 124 | + * The options parameter is used to adjust the behaviour of the core. | |
| 125 | + * Set BL_CORE_SUSPENDRESUME to get the update_status() operation called | |
| 126 | + * upon suspend and resume. | |
| 127 | + */ | |
| 59 | 128 | unsigned int options; |
| 60 | 129 | |
| 61 | 130 | #define BL_CORE_SUSPENDRESUME (1 << 0) |
| 62 | 131 | |
| 63 | − /* Notify the backlight driver some property has changed */ | |
| 132 | + /** | |
| 133 | + * @update_status: Operation called when properties have changed. | |
| 134 | + * | |
| 135 | + * Notify the backlight driver some property has changed. | |
| 136 | + * The update_status operation is protected by the update_lock. | |
| 137 | + * | |
| 138 | + * The backlight driver is expected to use backlight_is_blank() | |
| 139 | + * to check if the display is blanked and set brightness accordingly. | |
| 140 | + * update_status() is called when any of the properties has changed. | |
| 141 | + * | |
| 142 | + * RETURNS: | |
| 143 | + * | |
| 144 | + * 0 on success, negative error code if any failure occurred. | |
| 145 | + */ | |
| 64 | 146 | int (*update_status)(struct backlight_device *); |
| 65 | − /* Return the current backlight brightness (accounting for power, | |
| 66 | − fb_blank etc.) */ | |
| 147 | + | |
| 148 | + /** | |
| 149 | + * @get_brightness: Return the current backlight brightness. | |
| 150 | + * | |
| 151 | + * The driver may implement this as a readback from the HW. | |
| 152 | + * This operation is optional and if not present then the current | |
| 153 | + * brightness property value is used. | |
| 154 | + * | |
| 155 | + * RETURNS: | |
| 156 | + * | |
| 157 | + * A brightness value which is 0 or a positive number. | |
| 158 | + * On failure a negative error code is returned. | |
| 159 | + */ | |
| 67 | 160 | int (*get_brightness)(struct backlight_device *); |
| 68 | − /* Check if given framebuffer device is the one bound to this backlight; | |
| 69 | − return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ | |
| 70 | − int (*check_fb)(struct backlight_device *, struct fb_info *); | |
| 161 | + | |
| 162 | + /** | |
| 163 | + * @check_fb: Check the framebuffer device. | |
| 164 | + * | |
| 165 | + * Check if given framebuffer device is the one bound to this backlight. | |
| 166 | + * This operation is optional and if not implemented it is assumed that the | |
| 167 | + * fbdev is always the one bound to the backlight. | |
| 168 | + * | |
| 169 | + * RETURNS: | |
| 170 | + * | |
| 171 | + * If info is NULL or the info matches the fbdev bound to the backlight return true. | |
| 172 | + * If info does not match the fbdev bound to the backlight return false. | |
| 173 | + */ | |
| 174 | + int (*check_fb)(struct backlight_device *bd, struct fb_info *info); | |
| 71 | 175 | }; |
| 72 | 176 | |
| 73 | −/* This structure defines all the properties of a backlight */ | |
| 177 | +/** | |
| 178 | + * struct backlight_properties - backlight properties | |
| 179 | + * | |
| 180 | + * This structure defines all the properties of a backlight. | |
| 181 | + */ | |
| 74 | 182 | struct backlight_properties { |
| 75 | − /* Current User requested brightness (0 - max_brightness) */ | |
| 183 | + /** | |
| 184 | + * @brightness: The current brightness requested by the user. | |
| 185 | + * | |
| 186 | + * The backlight core makes sure the range is (0 to max_brightness) | |
| 187 | + * when the brightness is set via the sysfs attribute: | |
| 188 | + * /sys/class/backlight/<backlight>/brightness. | |
| 189 | + * | |
| 190 | + * This value can be set in the backlight_properties passed | |
| 191 | + * to devm_backlight_device_register() to set a default brightness | |
| 192 | + * value. | |
| 193 | + */ | |
| 76 | 194 | int brightness; |
| 77 | − /* Maximal value for brightness (read-only) */ | |
| 195 | + | |
| 196 | + /** | |
| 197 | + * @max_brightness: The maximum brightness value. | |
| 198 | + * | |
| 199 | + * This value must be set in the backlight_properties passed to | |
| 200 | + * devm_backlight_device_register() and shall not be modified by the | |
| 201 | + * driver after registration. | |
| 202 | + */ | |
| 78 | 203 | int max_brightness; |
| 79 | − /* Current FB Power mode (0: full on, 1..3: power saving | |
| 80 | − modes; 4: full off), see FB_BLANK_XXX */ | |
| 204 | + | |
| 205 | + /** | |
| 206 | + * @power: The current power mode. | |
| 207 | + * | |
| 208 | + * User space can configure the power mode using the sysfs | |
| 209 | + * attribute: /sys/class/backlight/<backlight>/bl_power | |
| 210 | + * When the power property is updated update_status() is called. | |
| 211 | + * | |
| 212 | + * The possible values are: (0: full on, 1 to 3: power saving | |
| 213 | + * modes; 4: full off), see FB_BLANK_XXX. | |
| 214 | + * | |
| 215 | + * When the backlight device is enabled @power is set | |
| 216 | + * to FB_BLANK_UNBLANK. When the backlight device is disabled | |
| 217 | + * @power is set to FB_BLANK_POWERDOWN. | |
| 218 | + */ | |
| 81 | 219 | int power; |
| 82 | − /* FB Blanking active? (values as for power) */ | |
| 83 | − /* Due to be removed, please use (state & BL_CORE_FBBLANK) */ | |
| 220 | + | |
| 221 | + /** | |
| 222 | + * @fb_blank: The power state from the FBIOBLANK ioctl. | |
| 223 | + * | |
| 224 | + * When the FBIOBLANK ioctl is called @fb_blank is set to the | |
| 225 | + * blank parameter and the update_status() operation is called. | |
| 226 | + * | |
| 227 | + * When the backlight device is enabled @fb_blank is set | |
| 228 | + * to FB_BLANK_UNBLANK. When the backlight device is disabled | |
| 229 | + * @fb_blank is set to FB_BLANK_POWERDOWN. | |
| 230 | + * | |
| 231 | + * Backlight drivers should avoid using this property. It has been | |
| 232 | + * replaced by state & BL_CORE_FBLANK (although most drivers should | |
| 233 | + * use backlight_is_blank() as the preferred means to get the blank | |
| 234 | + * state). | |
| 235 | + * | |
| 236 | + * fb_blank is deprecated and will be removed. | |
| 237 | + */ | |
| 84 | 238 | int fb_blank; |
| 85 | − /* Backlight type */ | |
| 239 | + | |
| 240 | + /** | |
| 241 | + * @type: The type of backlight supported. | |
| 242 | + * | |
| 243 | + * The backlight type allows userspace to make appropriate | |
| 244 | + * policy decisions based on the backlight type. | |
| 245 | + * | |
| 246 | + * This value must be set in the backlight_properties | |
| 247 | + * passed to devm_backlight_device_register(). | |
| 248 | + */ | |
| 86 | 249 | enum backlight_type type; |
| 87 | − /* Flags used to signal drivers of state changes */ | |
| 250 | + | |
| 251 | + /** | |
| 252 | + * @state: The state of the backlight core. | |
| 253 | + * | |
| 254 | + * The state is a bitmask. BL_CORE_FBBLANK is set when the display | |
| 255 | + * is expected to be blank. BL_CORE_SUSPENDED is set when the | |
| 256 | + * driver is suspended. | |
| 257 | + * | |
| 258 | + * backlight drivers are expected to use backlight_is_blank() | |
| 259 | + * in their update_status() operation rather than reading the | |
| 260 | + * state property. | |
| 261 | + * | |
| 262 | + * The state is maintained by the core and drivers may not modify it. | |
| 263 | + */ | |
| 88 | 264 | unsigned int state; |
| 89 | − /* Type of the brightness scale (linear, non-linear, ...) */ | |
| 90 | − enum backlight_scale scale; | |
| 91 | 265 | |
| 92 | 266 | #define BL_CORE_SUSPENDED (1 << 0) /* backlight is suspended */ |
| 93 | 267 | #define BL_CORE_FBBLANK (1 << 1) /* backlight is under an fb blank event */ |
| 94 | 268 | |
| 269 | + /** | |
| 270 | + * @scale: The type of the brightness scale. | |
| 271 | + */ | |
| 272 | + enum backlight_scale scale; | |
| 95 | 273 | }; |
| 96 | 274 | |
| 275 | +/** | |
| 276 | + * struct backlight_device - backlight device data | |
| 277 | + * | |
| 278 | + * This structure holds all data required by a backlight device. | |
| 279 | + */ | |
| 97 | 280 | struct backlight_device { |
| 98 | − /* Backlight properties */ | |
| 281 | + /** | |
| 282 | + * @props: Backlight properties | |
| 283 | + */ | |
| 99 | 284 | struct backlight_properties props; |
| 100 | 285 | |
| 101 | − /* Serialise access to update_status method */ | |
| 286 | + /** | |
| 287 | + * @update_lock: The lock used when calling the update_status() operation. | |
| 288 | + * | |
| 289 | + * update_lock is an internal backlight lock that serialise access | |
| 290 | + * to the update_status() operation. The backlight core holds the update_lock | |
| 291 | + * when calling the update_status() operation. The update_lock shall not | |
| 292 | + * be used by backlight drivers. | |
| 293 | + */ | |
| 102 | 294 | struct mutex update_lock; |
| 103 | 295 | |
| 104 | − /* This protects the 'ops' field. If 'ops' is NULL, the driver that | |
| 105 | − registered this device has been unloaded, and if class_get_devdata() | |
| 106 | − points to something in the body of that driver, it is also invalid. */ | |
| 296 | + /** | |
| 297 | + * @ops_lock: The lock used around everything related to backlight_ops. | |
| 298 | + * | |
| 299 | + * ops_lock is an internal backlight lock that protects the ops pointer | |
| 300 | + * and is used around all accesses to ops and when the operations are | |
| 301 | + * invoked. The ops_lock shall not be used by backlight drivers. | |
| 302 | + */ | |
| 107 | 303 | struct mutex ops_lock; |
| 304 | + | |
| 305 | + /** | |
| 306 | + * @ops: Pointer to the backlight operations. | |
| 307 | + * | |
| 308 | + * If ops is NULL, the driver that registered this device has been unloaded, | |
| 309 | + * and if class_get_devdata() points to something in the body of that driver, | |
| 310 | + * it is also invalid. | |
| 311 | + */ | |
| 108 | 312 | const struct backlight_ops *ops; |
| 109 | 313 | |
| 110 | − /* The framebuffer notifier block */ | |
| 314 | + /** | |
| 315 | + * @fb_notif: The framebuffer notifier block | |
| 316 | + */ | |
| 111 | 317 | struct notifier_block fb_notif; |
| 112 | 318 | |
| 113 | − /* list entry of all registered backlight devices */ | |
| 319 | + /** | |
| 320 | + * @entry: List entry of all registered backlight devices | |
| 321 | + */ | |
| 114 | 322 | struct list_head entry; |
| 115 | 323 | |
| 324 | + /** | |
| 325 | + * @dev: Parent device. | |
| 326 | + */ | |
| 116 | 327 | struct device dev; |
| 117 | 328 | |
| 118 | − /* Multiple framebuffers may share one backlight device */ | |
| 329 | + /** | |
| 330 | + * @fb_bl_on: The state of individual fbdev's. | |
| 331 | + * | |
| 332 | + * Multiple fbdev's may share one backlight device. The fb_bl_on | |
| 333 | + * records the state of the individual fbdev. | |
| 334 | + */ | |
| 119 | 335 | bool fb_bl_on[FB_MAX]; |
| 120 | 336 | |
| 337 | + /** | |
| 338 | + * @use_count: The number of uses of fb_bl_on. | |
| 339 | + */ | |
| 121 | 340 | int use_count; |
| 122 | 341 | }; |
| 123 | 342 | |
| 343 | +/** | |
| 344 | + * backlight_update_status - force an update of the backlight device status | |
| 345 | + * @bd: the backlight device | |
| 346 | + */ | |
| 124 | 347 | static inline int backlight_update_status(struct backlight_device *bd) |
| 125 | 348 | { |
| 126 | 349 | int ret = -ENOENT; |
| @@ -166,49 +389,83 @@ static inline int backlight_disable(struct backlight_device *bd) · 39 unmodified lines | ||
| 166 | 389 | } |
| 167 | 390 | |
| 168 | 391 | /** |
| 169 | − * backlight_put - Drop backlight reference | |
| 170 | − * @bd: the backlight device to put | |
| 392 | + * backlight_is_blank - Return true if display is expected to be blank | |
| 393 | + * @bd: the backlight device | |
| 394 | + * | |
| 395 | + * Display is expected to be blank if any of these is true:: | |
| 396 | + * | |
| 397 | + * 1) if power in not UNBLANK | |
| 398 | + * 2) if fb_blank is not UNBLANK | |
| 399 | + * 3) if state indicate BLANK or SUSPENDED | |
| 400 | + * | |
| 401 | + * Returns true if display is expected to be blank, false otherwise. | |
| 171 | 402 | */ |
| 172 | −static inline void backlight_put(struct backlight_device *bd) | |
| 403 | +static inline bool backlight_is_blank(const struct backlight_device *bd) | |
| 173 | 404 | { |
| 174 | − if (bd) | |
| 175 | − put_device(&bd->dev); | |
| 405 | + return bd->props.power != FB_BLANK_UNBLANK || | |
| 406 | + bd->props.fb_blank != FB_BLANK_UNBLANK || | |
| 407 | + bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); | |
| 176 | 408 | } |
| 177 | 409 | |
| 178 | −extern struct backlight_device *backlight_device_register(const char *name, | |
| 179 | − struct device *dev, void *devdata, const struct backlight_ops *ops, | |
| 180 | − const struct backlight_properties *props); | |
| 181 | −extern struct backlight_device *devm_backlight_device_register( | |
| 182 | − struct device *dev, const char *name, struct device *parent, | |
| 183 | − void *devdata, const struct backlight_ops *ops, | |
| 184 | − const struct backlight_properties *props); | |
| 185 | −extern void backlight_device_unregister(struct backlight_device *bd); | |
| 186 | −extern void devm_backlight_device_unregister(struct device *dev, | |
| 187 | − struct backlight_device *bd); | |
| 188 | −extern void backlight_force_update(struct backlight_device *bd, | |
| 189 | − enum backlight_update_reason reason); | |
| 190 | −extern int backlight_register_notifier(struct notifier_block *nb); | |
| 191 | −extern int backlight_unregister_notifier(struct notifier_block *nb); | |
| 192 | −extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type); | |
| 410 | +/** | |
| 411 | + * backlight_get_brightness - Returns the current brightness value | |
| 412 | + * @bd: the backlight device | |
| 413 | + * | |
| 414 | + * Returns the current brightness value, taking in consideration the current | |
| 415 | + * state. If backlight_is_blank() returns true then return 0 as brightness | |
| 416 | + * otherwise return the current brightness property value. | |
| 417 | + * | |
| 418 | + * Backlight drivers are expected to use this function in their update_status() | |
| 419 | + * operation to get the brightness value. | |
| 420 | + */ | |
| 421 | +static inline int backlight_get_brightness(const struct backlight_device *bd) | |
| 422 | +{ | |
| 423 | + if (backlight_is_blank(bd)) | |
| 424 | + return 0; | |
| 425 | + else | |
| 426 | + return bd->props.brightness; | |
| 427 | +} | |
| 428 | + | |
| 429 | +struct backlight_device * | |
| 430 | +backlight_device_register(const char *name, struct device *dev, void *devdata, | |
| 431 | + const struct backlight_ops *ops, | |
| 432 | + const struct backlight_properties *props); | |
| 433 | +struct backlight_device * | |
| 434 | +devm_backlight_device_register(struct device *dev, const char *name, | |
| 435 | + struct device *parent, void *devdata, | |
| 436 | + const struct backlight_ops *ops, | |
| 437 | + const struct backlight_properties *props); | |
| 438 | +void backlight_device_unregister(struct backlight_device *bd); | |
| 439 | +void devm_backlight_device_unregister(struct device *dev, | |
| 440 | + struct backlight_device *bd); | |
| 441 | +void backlight_force_update(struct backlight_device *bd, | |
| 442 | + enum backlight_update_reason reason); | |
| 443 | +int backlight_register_notifier(struct notifier_block *nb); | |
| 444 | +int backlight_unregister_notifier(struct notifier_block *nb); | |
| 193 | 445 | struct backlight_device *backlight_device_get_by_name(const char *name); |
| 194 | −extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness); | |
| 446 | +struct backlight_device *backlight_device_get_by_type(enum backlight_type type); | |
| 447 | +int backlight_device_set_brightness(struct backlight_device *bd, | |
| 448 | + unsigned long brightness); | |
| 195 | 449 | |
| 196 | 450 | #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) |
| 197 | 451 | |
| 452 | +/** | |
| 453 | + * bl_get_data - access devdata | |
| 454 | + * @bl_dev: pointer to backlight device | |
| 455 | + * | |
| 456 | + * When a backlight device is registered the driver has the possibility | |
| 457 | + * to supply a void * devdata. bl_get_data() return a pointer to the | |
| 458 | + * devdata. | |
| 459 | + * | |
| 460 | + * RETURNS: | |
| 461 | + * | |
| 462 | + * pointer to devdata stored while registering the backlight device. | |
| 463 | + */ | |
| 198 | 464 | static inline void * bl_get_data(struct backlight_device *bl_dev) |
| 199 | 465 | { |
| 200 | 466 | return dev_get_drvdata(&bl_dev->dev); |
| 201 | 467 | } |
| 202 | 468 | |
| 203 | −struct generic_bl_info { | |
| 204 | − const char *name; | |
| 205 | − int max_intensity; | |
| 206 | − int default_intensity; | |
| 207 | − int limit_mask; | |
| 208 | − void (*set_bl_intensity)(int intensity); | |
| 209 | − void (*kick_battery)(void); | |
| 210 | −}; | |
| 211 | − | |
| 212 | 469 | #ifdef CONFIG_OF |
| 213 | 470 | struct backlight_device *of_find_backlight_by_node(struct device_node *node); |
| 214 | 471 | #else |
| @@ -220,14 +477,8 @@ of_find_backlight_by_node(struct device_node *node) · 5 unmodified lines | ||
| 220 | 477 | #endif |
| 221 | 478 | |
| 222 | 479 | #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) |
| 223 | −struct backlight_device *of_find_backlight(struct device *dev); | |
| 224 | 480 | struct backlight_device *devm_of_find_backlight(struct device *dev); |
| 225 | 481 | #else |
| 226 | −static inline struct backlight_device *of_find_backlight(struct device *dev) | |
| 227 | −{ | |
| 228 | − return NULL; | |
| 229 | −} | |
| 230 | − | |
| 231 | 482 | static inline struct backlight_device * |
| 232 | 483 | devm_of_find_backlight(struct device *dev) |
| 233 | 484 | { |
| @@ -9,11 +9,9 @@ · 8 unmodified lines | ||
| 9 | 9 | #ifndef _SKY81452_H |
| 10 | 10 | #define _SKY81452_H |
| 11 | 11 | |
| 12 | −#include <linux/platform_data/sky81452-backlight.h> | |
| 13 | 12 | #include <linux/regulator/machine.h> |
| 14 | 13 | |
| 15 | 14 | struct sky81452_platform_data { |
| 16 | − struct sky81452_bl_platform_data *bl_pdata; | |
| 17 | 15 | struct regulator_init_data *regulator_init_data; |
| 18 | 16 | }; |
| 19 | 17 | |
| @@ -1,35 +0,0 @@ | ||
| 1 | −/* SPDX-License-Identifier: GPL-2.0-only */ | |
| 2 | −/* | |
| 3 | − * sky81452.h SKY81452 backlight driver | |
| 4 | − * | |
| 5 | − * Copyright 2014 Skyworks Solutions Inc. | |
| 6 | − * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com> | |
| 7 | − */ | |
| 8 | − | |
| 9 | −#ifndef _SKY81452_BACKLIGHT_H | |
| 10 | −#define _SKY81452_BACKLIGHT_H | |
| 11 | − | |
| 12 | −/** | |
| 13 | − * struct sky81452_platform_data | |
| 14 | − * @name: backlight driver name. | |
| 15 | − If it is not defined, default name is lcd-backlight. | |
| 16 | − * @gpio_enable:GPIO number which control EN pin | |
| 17 | − * @enable: Enable mask for current sink channel 1, 2, 3, 4, 5 and 6. | |
| 18 | − * @ignore_pwm: true if DPWMI should be ignored. | |
| 19 | − * @dpwm_mode: true is DPWM dimming mode, otherwise Analog dimming mode. | |
| 20 | − * @phase_shift:true is phase shift mode. | |
| 21 | − * @short_detecion_threshold: It should be one of 4, 5, 6 and 7V. | |
| 22 | − * @boost_current_limit: It should be one of 2300, 2750mA. | |
| 23 | − */ | |
| 24 | −struct sky81452_bl_platform_data { | |
| 25 | − const char *name; | |
| 26 | − int gpio_enable; | |
| 27 | − unsigned int enable; | |
| 28 | − bool ignore_pwm; | |
| 29 | − bool dpwm_mode; | |
| 30 | − bool phase_shift; | |
| 31 | − unsigned int short_detection_threshold; | |
| 32 | − unsigned int boost_current_limit; | |
| 33 | −}; | |
| 34 | − | |
| 35 | −#endif | |