backlight updates
Subsystems (11)
v3 cover backlight updates
v3:
- Dropped video patch that was reviewd and thus applied
- Updated kernel-doc so all fields now have a short intro
- Improved readability in a lot of places, thanks to review feedback from Daniel - thanks!
- Added better intro to backlight
- Added acks
Several other smaller changes documented in the patches.
I left out patches to make functions static as
there are dependencies to drm-misc-next for these. When this is landed I have a pile of follow-up patches waiting, mostly introducing backlight_is_blank() all over.
v2:
- Dropped drm patches that was reviewed and thus applied (Thanks Tomi)
- Updated backligth_is_blank() based on Daniel's feedback
- Dropped EXPORT_SYMBOL that was no longer relevant
- Reordered patches, so patches with no external dependencies comes first
- Updated the description that follows.
This following series touches a lot of backlight things.
Starts with a small refactoring in backligth.c to remove some indents. This increases the readability and no functional changes.
Then a new helper backlight_is_blank() is added.
This helper will simplify the implementation of update_status() in almost all backlight drivers.
Then while surfing the code I missed some documentation. So I got a bit carried away and updated the documentation for the backlight core and added it to kernel-doc. The documentation express my current understanding. Everything from spelling errors to outright wrong content shall be anticipated - so please review!
We are all best helped if the documentation is correct and up-to-date and it is readable.
In this process I identified that the backlight_bl driver was no longer in use - so drop it.
Everything builds, but so far no run-time testing.
Sam
Sam Ravnborg (13):
backlight: refactor fb_notifier_callback()
backlight: add backlight_is_blank()
backlight: improve backlight_ops documentation
backlight: improve backlight_properties documentation
backlight: improve backlight_device documentation
backlight: document inline functions in backlight.h
backlight: document enums in backlight.h
backlight: remove the unused backlight_bl driver
backlight: drop extern from prototypes
backlight: add overview and update existing doc
backlight: wire up kernel-doc documentation
backlight: as3711_bl: introduce backlight_is_blank()
backlight: use backlight_is_blank() in all backlight drivers
Documentation/gpu/backlight.rst | 12 + Documentation/gpu/index.rst | 1 + drivers/video/backlight/88pm860x_bl.c | 8 +- drivers/video/backlight/Kconfig | 8 - drivers/video/backlight/Makefile | 1 - drivers/video/backlight/adp5520_bl.c | 5 +- drivers/video/backlight/adp8860_bl.c | 5 +- drivers/video/backlight/adp8870_bl.c | 5 +- drivers/video/backlight/as3711_bl.c | 8 +- drivers/video/backlight/backlight.c | 174 +++++++++----- drivers/video/backlight/bd6107.c | 4 +- drivers/video/backlight/corgi_lcd.c | 5 +- drivers/video/backlight/cr_bllcd.c | 22 +- drivers/video/backlight/da903x_bl.c | 8 +- drivers/video/backlight/ep93xx_bl.c | 3 +- drivers/video/backlight/generic_bl.c | 110 --------- drivers/video/backlight/gpio_backlight.c | 4 +- drivers/video/backlight/hp680_bl.c | 4 +- drivers/video/backlight/jornada720_bl.c | 2 +- drivers/video/backlight/kb3886_bl.c | 4 +- drivers/video/backlight/led_bl.c | 4 +- drivers/video/backlight/lm3533_bl.c | 4 +- drivers/video/backlight/locomolcd.c | 4 +- drivers/video/backlight/lv5207lp.c | 4 +- drivers/video/backlight/max8925_bl.c | 8 +- drivers/video/backlight/pwm_bl.c | 4 +- drivers/video/backlight/qcom-wled.c | 4 +- drivers/video/backlight/tps65217_bl.c | 4 +- drivers/video/backlight/wm831x_bl.c | 8 +- include/linux/backlight.h | 374 +++++++++++++++++++++++++------ 30 files changed, 465 insertions(+), 346 deletions(-)
PATCH v3 1/13 backlight: refactor fb_notifier_callback()
Increase readability of fb_notifier_callback() by removing a few indent levels.
No functional change.
--- drivers/video/backlight/backlight.c | 43 +++++++++++++++-------------- 1 file changed, 22 insertions(+), 21 deletions(-)
drivers/video/backlight/backlight.c +22 -21
@@ -58,28 +58,29 @@ static int fb_notifier_callback(struct notifier_block *self, bd = container_of(self, struct backlight_device, fb_notif);mutex_lock (&bd->ops_lock); -if (bd->ops) -if (!bd->ops->check_fb || - bd->ops->check_fb (bd, evdata->info)) { - fb_blank = *(int *)evdata->data; -if (fb_blank ==FB_BLANK_UNBLANK && - !bd->fb_bl_on[node]) { - bd->fb_bl_on[node] = true; -if (!bd->use_count++) { - bd->props.state &= ~BL_CORE_FBBLANK ; - bd->props.fb_blank =FB_BLANK_UNBLANK ; -backlight_update_status (bd); - } - }else if (fb_blank !=FB_BLANK_UNBLANK && - bd->fb_bl_on[node]) { - bd->fb_bl_on[node] = false; -if (!(--bd->use_count)) { - bd->props.state |=BL_CORE_FBBLANK ; - bd->props.fb_blank = fb_blank; -backlight_update_status (bd); - } - } + +if (!bd->ops) + goto out; +if (bd->ops->check_fb && !bd->ops->check_fb (bd, evdata->info)) + goto out; + + fb_blank = *(int *)evdata->data; +if (fb_blank ==FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) { + bd->fb_bl_on[node] = true; +if (!bd->use_count++) { + bd->props.state &= ~BL_CORE_FBBLANK ; + bd->props.fb_blank =FB_BLANK_UNBLANK ; +backlight_update_status (bd); + } + }else if (fb_blank !=FB_BLANK_UNBLANK && bd->fb_bl_on[node]) { + bd->fb_bl_on[node] = false; +if (!(--bd->use_count)) { + bd->props.state |=BL_CORE_FBBLANK ; + bd->props.fb_blank = fb_blank; +backlight_update_status (bd); } + } +out:mutex_unlock (&bd->ops_lock);return 0 ; }
Signature · 1 line
2.25.1
PATCH v3 2/13 backlight: add backlight_is_blank()
In reply to Sam RavnborgThe backlight support has two properties that express the state:
- power
- state
It is un-documented and easy to get wrong. Add backlight_is_blank() helper to make it simpler for drivers to get the check of the state correct.
A lot of drivers also includes checks for fb_blank. This check is redundant when the state is checked and thus not needed in this helper function. But added anyway to avoid introducing subtle bugs due to the creative use of fb_blank in some drivers. Introducing this helper will for some drivers results in added support for fb_blank. This will be a change in functionality, which will improve the backlight driver.
Rolling out this helper to all relevant backlight drivers will eliminate almost all accesses to fb_blank.
v3:
- Clarified that the fb_blank support in backlight_is_blank() may result in functionality changes for the users (Emil)
v2:
- Added fb_blank condition (Daniel)
--- include/linux/backlight.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/linux/backlight.h +19 -0
@@ -175,6 +175,25 @@ static inline void backlight_put(struct backlight_device *bd)put_device (&bd->dev); } +/** +* backlight_is_blank - Return true if display is expected to be blank +* @bd: the backlight device +* +* Display is expected to be blank if any of these is true:: +* +* 1) if power in not UNBLANK +* 2) if fb_blank is not UNBLANK +* 3) if state indicate BLANK or SUSPENDED +* +* Returns true if display is expected to be blank, false otherwise. +*/ +static inline bool backlight_is_blank (struct backlight_device *bd) +{ +return bd->props.power !=FB_BLANK_UNBLANK || + bd->props.fb_blank !=FB_BLANK_UNBLANK || + bd->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK ); +} +extern struct backlight_device *backlight_device_register (const char *name,struct device *dev,void *devdata,const struct backlight_ops *ops,const struct backlight_properties *props);
Signature · 1 line
2.25.1
Re: [PATCH v3 02/13] backlight: add backlight_is_blank()
Quoted 17 lines · Sam Ravnborg
The backlight support has two properties that express the state:
- power
- stateIt is un-documented and easy to get wrong. Add
backlight_is_blank()helper to make it simpler for drivers to get the check of the state correct.A lot of drivers also includes checks for
fb_blank. This check is redundant when the state is checked and thus not needed in this helper function. But added anyway to avoid introducing subtle bugs due to the creative use offb_blankin some drivers. Introducing this helper will for some drivers results in added support forfb_blank. This will be a change in functionality, which will improve the backlight driver.
Quoted 2 lines
Rolling out this helper to all relevant backlight drivers will eliminate almost all accesses to
fb_blank.
Quoted 41 lines
v3:
- Clarified that thefb_blanksupport inbacklight_is_blank()may result in functionality changes for the users (Emil)v2:
- Addedfb_blankcondition (Daniel)Signed-off-by Sam Ravnborg <[email protected]>Reviewed-by Daniel Thompson <[email protected]>Cc Emil Velikov <[email protected]>Cc Daniel Vetter <[email protected]>Cc Lee Jones <[email protected]>Cc Daniel Thompson <[email protected]>Cc Jingoo Han <[email protected]>--- include/linux/backlight.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)include/linux/backlight.h +12
-0@@ -175,6 +175,25 @@ static inline void backlight_put(struct backlight_device *bd)put_device (&bd->dev); } +/** +* backlight_is_blank - Return true if display is expected to be blank +* @bd: the backlight device +* +* Display is expected to be blank if any of these is true:: +* +* 1) if power in not UNBLANK +* 2) if fb_blank is not UNBLANK +* 3) if state indicate BLANK or SUSPENDED +* +* Returns true if display is expected to be blank, false otherwise. +*/
include/linux/backlight.h static inline void backlight_put(struct backlight_device *bd) · line 199
Quoted 10 lines
include/linux/backlight.h +7
-0+static inline bool backlight_is_blank (struct backlight_device *bd) +{ +return bd->props.power !=FB_BLANK_UNBLANK || + bd->props.fb_blank !=FB_BLANK_UNBLANK || + bd->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK ); +} +extern struct backlight_device *backlight_device_register (const char *name,struct device *dev,void *devdata,const struct backlight_ops *ops,const struct backlight_properties *props);
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 3/13 backlight: improve backlight_ops documentation
In reply to Sam RavnborgImprove the documentation for backlight_ops and adapt it to kernel-doc style.
v2:
- Add intro for each field (Daniel)
--- include/linux/backlight.h | 59 +++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-)
include/linux/backlight.h +53 -6
@@ -55,19 +55,66 @@ enum backlight_scale {struct backlight_device ;struct fb_info ; +/** +* struct backlight_ops - backlight operations +* +* The backlight operations are specifed when the backlight device is registered. +*/ struct backlight_ops { +/** +* @options: Configure how operations are called from the core. +* +* The options parameter is used to adjust the behaviour of the core. +* Set BL_CORE_SUSPENDRESUME to get the update_status() operation called +* upon suspend and resume. +*/ unsigned int options;#define BL_CORE_SUSPENDRESUME (1 << 0) -/* Notify the backlight driver some property has changed */ +/** +* @update_status: Operation called when properties have changed. +* +* Notify the backlight driver some property has changed. +* The update_status operation is protected by the update_lock. +* +* The backlight driver is expected to use backlight_is_blank() +* to check if the display is blanked and set brightness accordingly. +* update_status() is called when any of the properties has changed. +* +* RETURNS: +* +* 0 on sucees, negative error code if any failure occured. +*/ int (*update_status)(struct backlight_device *); -/* Return the current backlight brightness (accounting for power, -fb_blank etc.) */ + +/** +* @get_brightness: Return the current backlight brightness. +* +* The driver may implement this as a readback from the HW. +* This operation is optional and if not present then the current +* brightness property value is used. +* +* RETURNS: +* +* A brightness value which is 0 or a positive numer. +* On failure a negative error code is returned. +*/ int (*get_brightness)(struct backlight_device *); -/* Check if given framebuffer device is the one bound to this backlight; -return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ -int (*check_fb)(struct backlight_device *,struct fb_info *); + +/** +* @check_fb: Check the framebuffer device. +* +* Check if given framebuffer device is the one bound to this backlight. +* This operation is optional and if not implemented it is assumed that the +* fbdev is always the one bound to the backlight. +* +* RETURNS: +* +* If info is NULL or the info matches the fbdev bound to the backlight return true. +* If info does not match the fbdev bound to the backlight return false. +*/ +int (*check_fb)(struct backlight_device *bd,struct fb_info *info); };/* This structure defines all the properties of a backlight */
Signature · 1 line
2.25.1
PATCH v3 4/13 backlight: improve backlight_properties documentation
In reply to Sam RavnborgImprove the documentation for backlight_properties and adapt it to kernel-doc style.
v2:
- Added into for each field (Daniel)
- Re-written some parts to explain what to do, rather than what not to do.
Partly based on suggestions from the review (Daniel)
--- include/linux/backlight.h | 96 ++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 11 deletions(-)
include/linux/backlight.h +85 -11
@@ -117,28 +117,102 @@ struct backlight_ops {int (*check_fb)(struct backlight_device *bd,struct fb_info *info); }; -/* This structure defines all the properties of a backlight */ +/** +* struct backlight_properties - backlight properties +* +* This structure defines all the properties of a backlight. +*/ struct backlight_properties { -/* Current User requested brightness (0 - max_brightness) */ +/** +* @brightness: The current brightness requested by the user. +* +* The backlight core makes sure the range is (0 to max_brightness) +* when the brightness is set via the sysfs attribute: +* /sys/class/backlight/<backlight>/brightness. +* +* This value can be set in the backlight_properties passed +* to devm_backlight_device_register() to set a default brightness +* value. +*/ int brightness; -/* Maximal value for brightness (read-only) */ + +/** +* @max_brightness: The maximum brightness value. +* +* This value must be set in the backlight_properties passed to +* devm_backlight_device_register() and shall not be modified by the +* driver after registration. +*/ int max_brightness; -/* Current FB Power mode (0: full on, 1..3: power saving -modes; 4: full off), see FB_BLANK_XXX */ + +/** +* @power: The current power mode. +* +* User space can configure the power mode using the sysfs +* attribute: /sys/class/backlight/<backlight>/bl_power +* When the power property is updated update_status() is called. +* +* The possible values are: (0: full on, 1 to 3: power saving +* modes; 4: full off), see FB_BLANK_XXX. +* +* When the backlight device is enabled @power is set +* to FB_BLANK_UNBLANK. When the backlight device is disabled +* @power is set to FB_BLANK_POWERDOWN. +*/ int power; -/* FB Blanking active? (values as for power) */ -/* Due to be removed, please use (state & BL_CORE_FBBLANK) */ + +/** +* @fb_blank: The power state from the FBIOBLANK ioclt. +* +* When the FBIOBLANK ioctl is called fb_blank is set to the +* blank parameter and the update_status() operation is called. +* +* When the backlight device is enabled @fb_blank is set +* to FB_BLANK_UNBLANK. When the backlight device is disabled +* @fb_blank is set to FB_BLANK_POWERDOWN. +* +* Backlight drivers should avoid using this property. It has been +* replaced by state & BL_CORE_FBLANK (although most drivers should +* use backlight_is_blank() as the preferred means to get the blank +* state). +* +* fb_blank is deprecated and will be removed. +*/ int fb_blank; -/* Backlight type */ + +/** +* @type: The type of backlight supported. +* +* The backlight type allows userspace to make appropriate +* policy desicions based on the backlight type. +* +* This value must be set in the backlight_properties +* passed to devm_backlight_device_register(). +*/ enum backlight_type type; -/* Flags used to signal drivers of state changes */ + +/** +* @state: The state of the backlight core. +* +* The state is a bitmask. BL_CORE_FBBLANK is set when the display +* is expected to be blank. BL_CORE_SUSPENDED is set when the +* driver is suspended. +* +* backlight drivers are excpected to use backlight_is_blank() +* in their update_status() operation rather than reading the +* state property. +* +* The state is maintained by the core and drivers may not modify it. +*/ unsigned int state; -/* Type of the brightness scale (linear, non-linear, ...) */ -enum backlight_scale scale;#define BL_CORE_SUSPENDED (1 << 0)/* backlight is suspended */ #define BL_CORE_FBBLANK (1 << 1)/* backlight is under an fb blank event */ +/** +* @scale: The type of the brightness scale. +*/ +enum backlight_scale scale; };struct backlight_device {
Signature · 1 line
2.25.1
Re: [PATCH v3 04/13] backlight: improve backlight_properties documentation
Quoted 10 lines · Sam Ravnborg
Improve the documentation for
backlight_propertiesand adapt it to kernel-doc style.v2:
- Added into for each field (Daniel)
- Re-written some parts to explain what to do, rather than what not to do.
Partly based on suggestions from the review (Daniel)Signed-off-by Sam Ravnborg <[email protected]>
Quoted 128 lines
Cc Lee Jones <[email protected]>Cc Daniel Thompson <[email protected]>Cc Jingoo Han <[email protected]>--- include/linux/backlight.h | 96 ++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 11 deletions(-)include/linux/backlight.h +85
-11@@ -117,28 +117,102 @@ struct backlight_ops {int (*check_fb)(struct backlight_device *bd,struct fb_info *info); }; -/* This structure defines all the properties of a backlight */ +/** +* struct backlight_properties - backlight properties +* +* This structure defines all the properties of a backlight. +*/ struct backlight_properties { -/* Current User requested brightness (0 - max_brightness) */ +/** +* @brightness: The current brightness requested by the user. +* +* The backlight core makes sure the range is (0 to max_brightness) +* when the brightness is set via the sysfs attribute: +* /sys/class/backlight/<backlight>/brightness. +* +* This value can be set in the backlight_properties passed +* to devm_backlight_device_register() to set a default brightness +* value. +*/ int brightness; -/* Maximal value for brightness (read-only) */ + +/** +* @max_brightness: The maximum brightness value. +* +* This value must be set in the backlight_properties passed to +* devm_backlight_device_register() and shall not be modified by the +* driver after registration. +*/ int max_brightness; -/* Current FB Power mode (0: full on, 1..3: power saving -modes; 4: full off), see FB_BLANK_XXX */ + +/** +* @power: The current power mode. +* +* User space can configure the power mode using the sysfs +* attribute: /sys/class/backlight/<backlight>/bl_power +* When the power property is updated update_status() is called. +* +* The possible values are: (0: full on, 1 to 3: power saving +* modes; 4: full off), see FB_BLANK_XXX. +* +* When the backlight device is enabled @power is set +* to FB_BLANK_UNBLANK. When the backlight device is disabled +* @power is set to FB_BLANK_POWERDOWN. +*/ int power; -/* FB Blanking active? (values as for power) */ -/* Due to be removed, please use (state & BL_CORE_FBBLANK) */ + +/** +* @fb_blank: The power state from the FBIOBLANK ioclt. +* +* When the FBIOBLANK ioctl is called fb_blank is set to the +* blank parameter and the update_status() operation is called. +* +* When the backlight device is enabled @fb_blank is set +* to FB_BLANK_UNBLANK. When the backlight device is disabled +* @fb_blank is set to FB_BLANK_POWERDOWN. +* +* Backlight drivers should avoid using this property. It has been +* replaced by state & BL_CORE_FBLANK (although most drivers should +* use backlight_is_blank() as the preferred means to get the blank +* state). +* +* fb_blank is deprecated and will be removed. +*/ int fb_blank; -/* Backlight type */ + +/** +* @type: The type of backlight supported. +* +* The backlight type allows userspace to make appropriate +* policy desicions based on the backlight type. +* +* This value must be set in the backlight_properties +* passed to devm_backlight_device_register(). +*/ enum backlight_type type; -/* Flags used to signal drivers of state changes */ + +/** +* @state: The state of the backlight core. +* +* The state is a bitmask. BL_CORE_FBBLANK is set when the display +* is expected to be blank. BL_CORE_SUSPENDED is set when the +* driver is suspended. +* +* backlight drivers are excpected to use backlight_is_blank() +* in their update_status() operation rather than reading the +* state property. +* +* The state is maintained by the core and drivers may not modify it. +*/ unsigned int state; -/* Type of the brightness scale (linear, non-linear, ...) */ -enum backlight_scale scale;#define BL_CORE_SUSPENDED (1 << 0)/* backlight is suspended */ #define BL_CORE_FBBLANK (1 << 1)/* backlight is under an fb blank event */ +/** +* @scale: The type of the brightness scale. +*/ +enum backlight_scale scale; };struct backlight_device {Signature · 1 line
2.25.1
PATCH v3 5/13 backlight: improve backlight_device documentation
In reply to Sam RavnborgImprove the documentation for backlight_device and adapt it to kernel-doc style.
v2:
- Add short intro to all fields (Daniel)
- Updated description of update_lock (Daniel)
--- include/linux/backlight.h | 72 ++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 23 deletions(-)
include/linux/backlight.h +49 -23
@@ -14,21 +14,6 @@#include <linux/mutex.h> #include <linux/notifier.h> -/* Notes on locking: -* -* backlight_device->ops_lock is an internal backlight lock protecting the -* ops pointer and no code outside the core should need to touch it. -* -* Access to update_status() is serialised by the update_lock mutex since -* most drivers seem to need this and historically get it wrong. -* -* Most drivers don't need locking on their get_brightness() method. -* If yours does, you need to implement it in the driver. You can use the -* update_lock mutex if appropriate. -* -* Any other use of the locks below is probably wrong. -*/ -enum backlight_update_reason {BACKLIGHT_UPDATE_HOTKEY ,BACKLIGHT_UPDATE_SYSFS ,
@@ -215,30 +200,71 @@ struct backlight_properties {enum backlight_scale scale; }; +/** +* struct backlight_device - backlight device data +* +* This structure holds all data required by a backlight device. +*/ struct backlight_device { -/* Backlight properties */ +/** +* @props: Backlight properties +*/ struct backlight_properties props; -/* Serialise access to update_status method */ +/** +* @update_lock: The lock used when calling the update_status() operation. +* +* update_lock is an internal backlight lock that serialise access +* to the update_status() operation. The backlight core holds the update_lock +* when calling the update_status() operation. The update_lock shall not +* be used by backlight drivers. +*/ struct mutex update_lock; -/* This protects the 'ops' field. If 'ops' is NULL, the driver that -registered this device has been unloaded, and if class_get_devdata() -points to something in the body of that driver, it is also invalid. */ +/** +* @ops_lock: The lock used around everything related to backlight_ops. +* +* ops_lock is an internal backlight lock that protects the ops pointer +* and is used around all accesses to ops and when the operations are +* invoked. The ops_lock shall not be used by backlight drivers. +*/ struct mutex ops_lock; + +/** +* @ops: Pointer to the backlight operations. +* +* If ops is NULL, the driver that registered this device has been unloaded, +* and if class_get_devdata() points to something in the body of that driver, +* it is also invalid. +*/ const struct backlight_ops *ops; -/* The framebuffer notifier block */ +/** +* @fb_notif: The framebuffer notifier block +*/ struct notifier_block fb_notif; -/* list entry of all registered backlight devices */ +/** +* @entry: List entry of all registered backlight devices +*/ struct list_head entry; +/** +* @dev: Parent device. +*/ struct device dev; -/* Multiple framebuffers may share one backlight device */ +/** +* @fb_bl_on: The state of individual fbdev's. +* +* Multiple fbdev's may share one backlight device. The fb_bl_on +* records the state of the individual fbdev. +*/ bool fb_bl_on[FB_MAX ]; +/** +* @use_count: The number of uses of fb_bl_on. +*/ int use_count; };
Signature · 1 line
2.25.1
Re: [PATCH v3 05/13] backlight: improve backlight_device documentation
Quoted 6 lines · Sam Ravnborg
Improve the documentation for
backlight_deviceand adapt it to kernel-doc style.v2:
- Add short intro to all fields (Daniel)
- Updated description ofupdate_lock(Daniel)
I like the update... but it doesn't cover what I was commenting on.
Quoted 9 lines
include/linux/backlight.h +0
-1@@ -14,21 +14,6 @@#include <linux/mutex.h> #include <linux/notifier.h> -/* Notes on locking:
include/linux/backlight.h line 27
Quoted 10 lines
include/linux/backlight.h +0
-10-* -* backlight_device->ops_lock is an internal backlight lock protecting the -* ops pointer and no code outside the core should need to touch it. -* -* Access to update_status() is serialised by the update_lock mutex since -* most drivers seem to need this and historically get it wrong. -* -* Most drivers don't need locking on their get_brightness() method. -* If yours does, you need to implement it in the driver. You can use the -* update_lock mutex if appropriate.
This explicitly says that drivers are permitted to use update_lock in their get_brightness() method.
Quoted 22 lines
include/linux/backlight.h +8
-5-* -* Any other use of the locks below is probably wrong. -*/ -enum backlight_update_reason {BACKLIGHT_UPDATE_HOTKEY ,BACKLIGHT_UPDATE_SYSFS ,@@ -215,30 +200,71 @@ struct backlight_properties {enum backlight_scale scale; }; +/** +* struct backlight_device - backlight device data +* +* This structure holds all data required by a backlight device. +*/ struct backlight_device { -/* Backlight properties */ +/** +* @props: Backlight properties +*/ struct backlight_properties props;
include/linux/backlight.h struct backlight_properties { · line 221
Quoted 10 lines
include/linux/backlight.h +8
-1-/* Serialise access to update_status method */ +/** +* @update_lock: The lock used when calling the update_status() operation. +* +* update_lock is an internal backlight lock that serialise access +* to the update_status() operation. The backlight core holds the update_lock +* when calling the update_status() operation. The update_lock shall not +* be used by backlight drivers. +*/
This contradicts the original comment about locking.
I'm fairly neutral about the change (AFAICT no driver actually ever uses update_lock from get_brightness) but if we add new documentation that flatly contradicts old documentary comments then I'd expect to see something in the patch description explaining that the change really is deliberate (and why it is a good change).
Daniel.
PATCH v3 6/13 backlight: document inline functions in backlight.h
In reply to Sam RavnborgAdd documentation for the inline functions in backlight.h
v2:
- Fix spelling (Daniel)
--- include/linux/backlight.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
include/linux/backlight.h +16 -0
@@ -268,6 +268,10 @@ struct backlight_device {int use_count; }; +/** +* backlight_update_status - force an update of the backlight device status +* @bd: the backlight device +*/ static inline int backlight_update_status (struct backlight_device *bd) {int ret = -ENOENT ;
@@ -360,6 +364,18 @@ extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned#define to_backlight_device (obj) container_of(obj, struct backlight_device, dev) +/** +* bl_get_data - access devdata +* @bl_dev: pointer to backlight device +* +* When a backlight device is registered the driver has the possibility +* to supply a void * devdata. bl_get_data() return a pointer to the +* devdata. +* +* RETURNS: +* +* pointer to devdata stored while registering the backlight device. +*/ static inline void *bl_get_data (struct backlight_device *bl_dev) {return dev_get_drvdata (&bl_dev->dev);
Signature · 1 line
2.25.1
PATCH v3 7/13 backlight: document enums in backlight.h
In reply to Sam RavnborgAdd kernel-doc documentation for the backlight enums
v2:
- Add intro to each enum member (Daniel) Except backlight type as line lenght was too long. The generated HTML is the same.
--- include/linux/backlight.h | 74 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-)
include/linux/backlight.h +73 -1
@@ -14,26 +14,98 @@#include <linux/mutex.h> #include <linux/notifier.h> +/** +* enum backlight_update_reason - what method was used to update backlight +* +* A driver indicates the method (reason) used for updating the backlight +* when calling backlight_force_update(). +*/ enum backlight_update_reason { +/** +* @BACKLIGHT_UPDATE_HOTKEY: The backlight was updated using a hot-key. +*/ BACKLIGHT_UPDATE_HOTKEY , + +/** +* @BACKLIGHT_UPDATE_SYSFS: The backlight was updated using sysfs. +*/ BACKLIGHT_UPDATE_SYSFS , }; +/** +* enum backlight_type - the type of backlight control +* +* The type of interface used to control the backlight. +*/ enum backlight_type { +/** +* @BACKLIGHT_RAW: +* +* The backlight is controlled using hardware registers. +*/ BACKLIGHT_RAW =1 , + +/** +* @BACKLIGHT_PLATFORM: +* +* The backlight is controlled using a platform-specific interface. +*/ BACKLIGHT_PLATFORM , + +/** +* @BACKLIGHT_FIRMWARE: +* +* The backlight is controlled using a standard firmware interface. +*/ BACKLIGHT_FIRMWARE , + +/** +* @BACKLIGHT_TYPE_MAX: Number of entries. +*/ BACKLIGHT_TYPE_MAX , }; +/** +* enum backlight_notification - the type of notification +* +* The notifications that is used for notification sent to the receiver +* that registered notifications using backlight_register_notifier(). +*/ enum backlight_notification { +/** +* @BACKLIGHT_REGISTERED: The backlight device is registered. +*/ BACKLIGHT_REGISTERED , + +/** +* @BACKLIGHT_UNREGISTERED: The backlight revice is unregistered. +*/ BACKLIGHT_UNREGISTERED , }; +/** enum backlight_scale - the type of scale used for brightness values +* +* The type of scale used for brightness values. +*/ enum backlight_scale { +/** +* @BACKLIGHT_SCALE_UNKNOWN: The scale is unknown. +*/ BACKLIGHT_SCALE_UNKNOWN =0 , + +/** +* @BACKLIGHT_SCALE_LINEAR: The scale is linear. +* +* The linear scale will increase brightness the same for each step. +*/ BACKLIGHT_SCALE_LINEAR , + +/** +* @BACKLIGHT_SCALE_NON_LINEAR: The scale is not linear. +* +* This is often used when the brightness values tries to adjust to +* the relative perception of the eye demanding a non-linear scale. +*/ BACKLIGHT_SCALE_NON_LINEAR , };
@@ -149,7 +221,7 @@ struct backlight_properties {/** * @fb_blank: The power state from the FBIOBLANK ioclt. * -* When the FBIOBLANK ioctl is called fb_blank is set to the +* When the FBIOBLANK ioctl is called @fb_blank is set to the * blank parameter and the update_status() operation is called. * * When the backlight device is enabled @fb_blank is set
Signature · 1 line
2.25.1
PATCH v3 8/13 backlight: remove the unused backlight_bl driver
In reply to Sam RavnborgThe backlight_bl driver required initialization using struct generic_bl_info. As there are no more references to this struct there is no users left.
So it is safe to delete the driver.
--- drivers/video/backlight/Kconfig | 8 -- drivers/video/backlight/Makefile | 1 - drivers/video/backlight/generic_bl.c | 110 --------------------------- include/linux/backlight.h | 9 --- 4 files changed, 128 deletions(-) delete mode 100644 drivers/video/backlight/generic_bl.c
drivers/video/backlight/Kconfig +0 -8
@@ -173,14 +173,6 @@ config BACKLIGHT_EP93XX To compile this driver as a module, choose M here: the module will be called ep93xx_bl. -config BACKLIGHT_GENERIC - tristate "Generic (aka Sharp Corgi) Backlight Driver" - default y - help - Say y to enable the generic platform backlight driver previously - known as the Corgi backlight driver. If you have a Sharp Zaurus - SL-C7xx, SL-Cxx00 or SL-6000x say y. - config BACKLIGHT_IPAQ_MICRO tristate "iPAQ microcontroller backlight driver" depends on MFD_IPAQ_MICRO
drivers/video/backlight/Makefile +0 -1
@@ -31,7 +31,6 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o obj-$(CONFIG_BACKLIGHT_DA9052) += da9052_bl.o obj-$(CONFIG_BACKLIGHT_EP93XX) += ep93xx_bl.o -obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o obj-$(CONFIG_BACKLIGHT_GPIO) += gpio_backlight.o obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o
drivers/video/backlight/generic_bl.c deleted +0 -110
110 lines not on this page · raw message
include/linux/backlight.h +0 -9
@@ -453,15 +453,6 @@ static inline void * bl_get_data(struct backlight_device *bl_dev)return dev_get_drvdata (&bl_dev->dev); } -struct generic_bl_info { -const char *name; -int max_intensity; -int default_intensity; -int limit_mask; -void (*set_bl_intensity)(int intensity); -void (*kick_battery)(void ); -}; -#ifdef CONFIG_OF struct backlight_device *of_find_backlight_by_node (struct device_node *node);#else
Signature · 1 line
2.25.1
PATCH v3 9/13 backlight: drop extern from prototypes
In reply to Sam RavnborgNo need to put "extern" in front of prototypes. While touching the prototypes adjust indent to follow the kernel style.
--- include/linux/backlight.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
include/linux/backlight.h +19 -16
@@ -417,22 +417,25 @@ static inline bool backlight_is_blank(struct backlight_device *bd) bd->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK ); } -extern struct backlight_device *backlight_device_register (const char *name, -struct device *dev,void *devdata,const struct backlight_ops *ops, -const struct backlight_properties *props); -extern struct backlight_device *devm_backlight_device_register ( -struct device *dev,const char *name,struct device *parent, -void *devdata,const struct backlight_ops *ops, -const struct backlight_properties *props); -extern void backlight_device_unregister (struct backlight_device *bd); -extern void devm_backlight_device_unregister (struct device *dev, -struct backlight_device *bd); -extern void backlight_force_update (struct backlight_device *bd, -enum backlight_update_reason reason); -extern int backlight_register_notifier (struct notifier_block *nb); -extern int backlight_unregister_notifier (struct notifier_block *nb); -extern struct backlight_device *backlight_device_get_by_type (enum backlight_type type); -extern int backlight_device_set_brightness (struct backlight_device *bd,unsigned long brightness); +struct backlight_device * +backlight_device_register (const char *name,struct device *dev,void *devdata, +const struct backlight_ops *ops, +const struct backlight_properties *props); +struct backlight_device * +devm_backlight_device_register (struct device *dev,const char *name, +struct device *parent,void *devdata, +const struct backlight_ops *ops, +const struct backlight_properties *props); +void backlight_device_unregister (struct backlight_device *bd); +void devm_backlight_device_unregister (struct device *dev, +struct backlight_device *bd); +void backlight_force_update (struct backlight_device *bd, +enum backlight_update_reason reason); +int backlight_register_notifier (struct notifier_block *nb); +int backlight_unregister_notifier (struct notifier_block *nb); +struct backlight_device *backlight_device_get_by_type (enum backlight_type type); +int backlight_device_set_brightness (struct backlight_device *bd, +unsigned long brightness);#define to_backlight_device (obj) container_of(obj, struct backlight_device, dev)
Signature · 1 line
2.25.1
PATCH v3 10/13 backlight: add overview and update existing doc
In reply to Sam RavnborgAdd overview chapter to backlight.c.
Update existing kernel-doc to follow a more consistent style and drop kernel-doc for deprecated functions.
v2:
- Sevaral editorial corrections that makes reading much easier (Daniel)
- Spelling fixes (Daniel)
- updated intro chapter with a little more info
--- drivers/video/backlight/backlight.c | 131 +++++++++++++++++++--------- 1 file changed, 90 insertions(+), 41 deletions(-)
drivers/video/backlight/backlight.c +90 -41
@@ -22,6 +22,46 @@#include <asm/backlight.h> #endif +/** +* DOC: overview +* +* The backlight core supports implementing backlight drivers. +* +* A backlight driver registers a driver using +* devm_backlight_device_register(). The properties of the backlight +* driver such as type and max_brightness must be specified. +* When the core detect changes in for example brightness or power state +* the update_status() operation is called. The backlight driver shall +* implement this operation and use it to adjust backlight. +* +* Several sysfs attributes are provided by the backlight core:: +* +* - brightness R/W, set the requested brightness level +* - actual_brighness RO, the brightness level used by the HW +* - max_brightness RO, the maximum brightness level supported +* +* See Documentation/ABI/stable/sysfs-class-backlight for the full list. +* +* The backlight can be adjusted using the sysfs interface, and +* the backlight driver may also support adjusting backlight using +* a hot-key or some other platfrom or firmware specific way. +* +* The driver shall implement the get_brightness() operation if +* the HW do not support all the levels that can be specified in +* brightness, thus providing user-space access to the actual level +* via the actual_brightness attribute. +* When the backlight changes this is reported to user-space using +* an uevent connected to the actual_brightness attribute. +* When brightness is set by platform specific means, for example +* a hot-key to adjust backlight, the driver must notify the backlight +* core that brightness has changed using backlight_force_update(). +* +* The backlight driver core receives notifications from fbdev and +* if the event is FB_EVENT_BLANK and if the value of blank, from the +* FBIOBLANK ioclt, results in a change in the backlight state the +* update_status() operation is called. +*/ +static struct list_head backlight_dev_list;static struct mutex backlight_dev_list_mutex;static struct blocking_notifier_head backlight_notifier;
@@ -40,9 +80,17 @@ static const char *const backlight_scale_types[] = {#if defined(CONFIG_FB ) || (defined(CONFIG_FB_MODULE ) && \ defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE )) -/* This callback gets called when something important happens inside a -* framebuffer driver. We're looking if that important event is blanking, -* and if it is and necessary, we're switching backlight power as well ... +/* +* fb_notifier_callback +* +* This callback gets called when something important happens inside a +* framebuffer driver. The backlight core only cares about FB_BLANK_UNBLANK +* which is reported to the driver using backlight_update_status() +* as a state change. +* +* There may be several fbdev's connected to the backlight device, +* in which case they are kept track of. A state change is only reported +* if there is a change in backlight for the specified fbdev. */ static int fb_notifier_callback (struct notifier_block *self,unsigned long event,void *data)
@@ -318,12 +366,15 @@ static struct attribute *bl_device_attrs[] = {ATTRIBUTE_GROUPS (bl_device);/** -* backlight_force_update - tell the backlight subsystem that hardware state -* has changed +* backlight_force_update - force an update due to a hardware change * @bd: the backlight device to update +* @reason: the method used for the backlight update * * Updates the internal state of the backlight in response to a hardware event, -* and generate a uevent to notify userspace +* and generates an uevent to notify userspace. A backlight driver shall call +* backlight_force_update() when the backlight is changed using, for example, +* a hot-key. The updated brightness is read using get_brightness() and the +* brightness value is reported using an uevent. */ void backlight_force_update (struct backlight_device *bd,enum backlight_update_reason reason)
@@ -336,19 +387,7 @@ void backlight_force_update(struct backlight_device *bd, }EXPORT_SYMBOL (backlight_force_update); -/** -* backlight_device_register - create and register a new object of -* backlight_device class. -* @name: the name of the new object(must be the same as the name of the -* respective framebuffer device). -* @parent: a pointer to the parent device -* @devdata: an optional pointer to be stored for private driver use. The -* methods may retrieve it by using bl_get_data(bd). -* @ops: the backlight operations structure. -* -* Creates and registers new backlight device. Returns either an -* ERR_PTR() or a pointer to the newly allocated device. -*/ +/* deprecated - use devm_backlight_device_register() */ struct backlight_device *backlight_device_register (const char *name,struct device *parent,void *devdata,const struct backlight_ops *ops,const struct backlight_properties *props)
@@ -415,6 +454,15 @@ struct backlight_device *backlight_device_register(const char *name, }EXPORT_SYMBOL (backlight_device_register); +/** backlight_device_get_by_type - find first backlight device of a type +* @type: the type of backlight device +* +* Look up the first backlight device of the specified type +* +* RETURNS: +* +* Pointer to backlight device if any was found. Otherwise NULL. +*/ struct backlight_device *backlight_device_get_by_type (enum backlight_type type) {bool found = false;
@@ -433,12 +481,7 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type) }EXPORT_SYMBOL (backlight_device_get_by_type); -/** -* backlight_device_unregister - unregisters a backlight device object. -* @bd: the backlight device object to be unregistered and freed. -* -* Unregisters a previously registered via backlight_device_register object. -*/ +/* deprecated - use devm_backlight_device_unregister() */ void backlight_device_unregister (struct backlight_device *bd) {if (!bd)
@@ -486,10 +529,12 @@ static int devm_backlight_device_match(struct device *dev, void *res,* backlight_register_notifier - get notified of backlight (un)registration * @nb: notifier block with the notifier to call on backlight (un)registration * -* @return 0 on success, otherwise a negative error code -* * Register a notifier to get notified when backlight devices get registered * or unregistered. +* +* RETURNS: +* +* 0 on success, otherwise a negative error code */ int backlight_register_notifier (struct notifier_block *nb) {
@@ -501,10 +546,12 @@ EXPORT_SYMBOL(backlight_register_notifier);* backlight_unregister_notifier - unregister a backlight notifier * @nb: notifier block to unregister * -* @return 0 on success, otherwise a negative error code -* * Register a notifier to get notified when backlight devices get registered * or unregistered. +* +* RETURNS: +* +* 0 on success, otherwise a negative error code */ int backlight_unregister_notifier (struct notifier_block *nb) {
@@ -513,20 +560,22 @@ int backlight_unregister_notifier(struct notifier_block *nb)EXPORT_SYMBOL (backlight_unregister_notifier);/** -* devm_backlight_device_register - resource managed backlight_device_register() +* devm_backlight_device_register - register a new backlight device * @dev: the device to register * @name: the name of the device -* @parent: a pointer to the parent device +* @parent: a pointer to the parent device (often the same as @dev) * @devdata: an optional pointer to be stored for private driver use * @ops: the backlight operations structure * @props: the backlight properties * -* @return a struct backlight on success, or an ERR_PTR on error +* Creates and registers new backlight device. When a backlight device +* is registered the configuration must be specified in the @props +* parameter. See description of &backlight_properties. * -* Managed backlight_device_register(). The backlight_device returned -* from this function are automatically freed on driver detach. -* See backlight_device_register() for more information. -*/ +* RETURNS: +* +* struct backlight on success, or an ERR_PTR on error +*/ struct backlight_device *devm_backlight_device_register(struct device *dev, const char *name, struct device *parent, void *devdata, const struct backlight_ops *ops,
@@ -553,13 +602,13 @@ struct backlight_device *devm_backlight_device_register(struct device *dev,EXPORT_SYMBOL (devm_backlight_device_register);/** -* devm_backlight_device_unregister - resource managed backlight_device_unregister() +* devm_backlight_device_unregister - unregister backlight device * @dev: the device to unregister * @bd: the backlight device to unregister * -* Deallocated a backlight allocated with devm_backlight_device_register(). +* Deallocates a backlight allocated with devm_backlight_device_register(). * Normally this function will not need to be called and the resource management -* code will ensure that the resource is freed. +* code will ensure that the resources are freed. */ void devm_backlight_device_unregister (struct device *dev,struct backlight_device *bd)
@@ -650,8 +699,8 @@ static void devm_backlight_release(void *data) }/** -* devm_of_find_backlight - Resource-managed of_find_backlight() -* @dev: Device +* devm_of_find_backlight - find backlight for a device +* @dev: the device * * Device managed version of of_find_backlight(). * The reference on the backlight device is automatically
Signature · 1 line
2.25.1
Re: [PATCH v3 10/13] backlight: add overview and update existing doc
Quoted 11 lines · Sam Ravnborg
Add overview chapter to
backlight.c.
Update existing kernel-doc to follow a more consistent style and drop kernel-doc for deprecated functions.v2:
- Sevaral editorial corrections that makes reading much easier (Daniel)
- Spelling fixes (Daniel)
- updated intro chapter with a little more infoSigned-off-by Sam Ravnborg <[email protected]>
Two very small nits... but one will affect formatted output so I had to raise it. Feel free add my Reviewed-by: when recirculating!
Daniel.
Quoted 30 lines
Cc Lee Jones <[email protected]>Cc Daniel Thompson <[email protected]>Cc Jingoo Han <[email protected]>--- drivers/video/backlight/backlight.c | 131 +++++++++++++++++++--------- 1 file changed, 90 insertions(+), 41 deletions(-)drivers/video/backlight/backlight.c +15
-0@@ -22,6 +22,46 @@#include <asm/backlight.h> #endif +/** +* DOC: overview +* +* The backlight core supports implementing backlight drivers. +* +* A backlight driver registers a driver using +* devm_backlight_device_register(). The properties of the backlight +* driver such as type and max_brightness must be specified. +* When the core detect changes in for example brightness or power state +* the update_status() operation is called. The backlight driver shall +* implement this operation and use it to adjust backlight. +* +* Several sysfs attributes are provided by the backlight core:: +* +* - brightness R/W, set the requested brightness level
drivers/video/backlight/backlight.c line 49
Quoted 10 lines
drivers/video/backlight/backlight.c +10
-0+* - actual_brighness RO, the brightness level used by the HW +* - max_brightness RO, the maximum brightness level supported +* +* See Documentation/ABI/stable/sysfs-class-backlight for the full list. +* +* The backlight can be adjusted using the sysfs interface, and +* the backlight driver may also support adjusting backlight using +* a hot-key or some other platfrom or firmware specific way. +* +* The driver shall implement the get_brightness() operation if
I overlooked this before but this reads better with "must" rather than "shall". It's not wrong to use shall but I think it is more idiomatic to use "must".
drivers/video/backlight/backlight.c line 53
Quoted 4 lines
drivers/video/backlight/backlight.c +4
-0+* the HW do not support all the levels that can be specified in +* brightness, thus providing user-space access to the actual level +* via the actual_brightness attribute. +* When the backlight changes this is reported to user-space using
Missing newline between paragraphs...
Quoted 196 lines
drivers/video/backlight/backlight.c +61
-41+* an uevent connected to the actual_brightness attribute. +* When brightness is set by platform specific means, for example +* a hot-key to adjust backlight, the driver must notify the backlight +* core that brightness has changed using backlight_force_update(). +* +* The backlight driver core receives notifications from fbdev and +* if the event is FB_EVENT_BLANK and if the value of blank, from the +* FBIOBLANK ioclt, results in a change in the backlight state the +* update_status() operation is called. +*/ +static struct list_head backlight_dev_list;static struct mutex backlight_dev_list_mutex;static struct blocking_notifier_head backlight_notifier;@@ -40,9 +80,17 @@ static const char *const backlight_scale_types[] = {#if defined(CONFIG_FB ) || (defined(CONFIG_FB_MODULE ) && \ defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE )) -/* This callback gets called when something important happens inside a -* framebuffer driver. We're looking if that important event is blanking, -* and if it is and necessary, we're switching backlight power as well ... +/* +* fb_notifier_callback +* +* This callback gets called when something important happens inside a +* framebuffer driver. The backlight core only cares about FB_BLANK_UNBLANK +* which is reported to the driver using backlight_update_status() +* as a state change. +* +* There may be several fbdev's connected to the backlight device, +* in which case they are kept track of. A state change is only reported +* if there is a change in backlight for the specified fbdev. */ static int fb_notifier_callback (struct notifier_block *self,unsigned long event,void *data)@@ -318,12 +366,15 @@ static struct attribute *bl_device_attrs[] = {ATTRIBUTE_GROUPS (bl_device);/** -* backlight_force_update - tell the backlight subsystem that hardware state -* has changed +* backlight_force_update - force an update due to a hardware change * @bd: the backlight device to update +* @reason: the method used for the backlight update * * Updates the internal state of the backlight in response to a hardware event, -* and generate a uevent to notify userspace +* and generates an uevent to notify userspace. A backlight driver shall call +* backlight_force_update() when the backlight is changed using, for example, +* a hot-key. The updated brightness is read using get_brightness() and the +* brightness value is reported using an uevent. */ void backlight_force_update (struct backlight_device *bd,enum backlight_update_reason reason)@@ -336,19 +387,7 @@ void backlight_force_update(struct backlight_device *bd, }EXPORT_SYMBOL (backlight_force_update); -/** -* backlight_device_register - create and register a new object of -* backlight_device class. -* @name: the name of the new object(must be the same as the name of the -* respective framebuffer device). -* @parent: a pointer to the parent device -* @devdata: an optional pointer to be stored for private driver use. The -* methods may retrieve it by using bl_get_data(bd). -* @ops: the backlight operations structure. -* -* Creates and registers new backlight device. Returns either an -* ERR_PTR() or a pointer to the newly allocated device. -*/ +/* deprecated - use devm_backlight_device_register() */ struct backlight_device *backlight_device_register (const char *name,struct device *parent,void *devdata,const struct backlight_ops *ops,const struct backlight_properties *props)@@ -415,6 +454,15 @@ struct backlight_device *backlight_device_register(const char *name, }EXPORT_SYMBOL (backlight_device_register); +/** backlight_device_get_by_type - find first backlight device of a type +* @type: the type of backlight device +* +* Look up the first backlight device of the specified type +* +* RETURNS: +* +* Pointer to backlight device if any was found. Otherwise NULL. +*/ struct backlight_device *backlight_device_get_by_type (enum backlight_type type) {bool found = false;@@ -433,12 +481,7 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type) }EXPORT_SYMBOL (backlight_device_get_by_type); -/** -* backlight_device_unregister - unregisters a backlight device object. -* @bd: the backlight device object to be unregistered and freed. -* -* Unregisters a previously registered via backlight_device_register object. -*/ +/* deprecated - use devm_backlight_device_unregister() */ void backlight_device_unregister (struct backlight_device *bd) {if (!bd)@@ -486,10 +529,12 @@ static int devm_backlight_device_match(struct device *dev, void *res,* backlight_register_notifier - get notified of backlight (un)registration * @nb: notifier block with the notifier to call on backlight (un)registration * -* @return 0 on success, otherwise a negative error code -* * Register a notifier to get notified when backlight devices get registered * or unregistered. +* +* RETURNS: +* +* 0 on success, otherwise a negative error code */ int backlight_register_notifier (struct notifier_block *nb) {@@ -501,10 +546,12 @@ EXPORT_SYMBOL(backlight_register_notifier);* backlight_unregister_notifier - unregister a backlight notifier * @nb: notifier block to unregister * -* @return 0 on success, otherwise a negative error code -* * Register a notifier to get notified when backlight devices get registered * or unregistered. +* +* RETURNS: +* +* 0 on success, otherwise a negative error code */ int backlight_unregister_notifier (struct notifier_block *nb) {@@ -513,20 +560,22 @@ int backlight_unregister_notifier(struct notifier_block *nb)EXPORT_SYMBOL (backlight_unregister_notifier);/** -* devm_backlight_device_register - resource managed backlight_device_register() +* devm_backlight_device_register - register a new backlight device * @dev: the device to register * @name: the name of the device -* @parent: a pointer to the parent device +* @parent: a pointer to the parent device (often the same as @dev) * @devdata: an optional pointer to be stored for private driver use * @ops: the backlight operations structure * @props: the backlight properties * -* @return a struct backlight on success, or an ERR_PTR on error +* Creates and registers new backlight device. When a backlight device +* is registered the configuration must be specified in the @props +* parameter. See description of &backlight_properties. * -* Managed backlight_device_register(). The backlight_device returned -* from this function are automatically freed on driver detach. -* See backlight_device_register() for more information. -*/ +* RETURNS: +* +* struct backlight on success, or an ERR_PTR on error +*/ struct backlight_device *devm_backlight_device_register(struct device *dev, const char *name, struct device *parent, void *devdata, const struct backlight_ops *ops,@@ -553,13 +602,13 @@ struct backlight_device *devm_backlight_device_register(struct device *dev,EXPORT_SYMBOL (devm_backlight_device_register);/** -* devm_backlight_device_unregister - resource managed backlight_device_unregister() +* devm_backlight_device_unregister - unregister backlight device * @dev: the device to unregister * @bd: the backlight device to unregister * -* Deallocated a backlight allocated with devm_backlight_device_register(). +* Deallocates a backlight allocated with devm_backlight_device_register(). * Normally this function will not need to be called and the resource management -* code will ensure that the resource is freed. +* code will ensure that the resources are freed. */ void devm_backlight_device_unregister (struct device *dev,struct backlight_device *bd)@@ -650,8 +699,8 @@ static void devm_backlight_release(void *data) }/** -* devm_of_find_backlight - Resource-managed of_find_backlight() -* @dev: Device +* devm_of_find_backlight - find backlight for a device +* @dev: the device * * Device managed version of of_find_backlight(). * The reference on the backlight device is automatically Signature · 1 line
2.25.1
PATCH v3 11/13 backlight: wire up kernel-doc documentation
In reply to Sam RavnborgInclude backlight so the documentation is now generated with make htmldocs and friends.
--- Documentation/gpu/backlight.rst | 12 ++++++++++++ Documentation/gpu/index.rst | 1 + 2 files changed, 13 insertions(+) create mode 100644 Documentation/gpu/backlight.rst
Documentation/gpu/backlight.rst new file +12 -0
@@ -0,0 +1,12 @@ +================= +Backlight support +================= + +.. kernel-doc:: drivers/video/backlight/backlight.c + :doc: overview + +.. kernel-doc:: include/linux/backlight.h + :internal: + +.. kernel-doc:: drivers/video/backlight/backlight.c + :export:
Documentation/gpu/index.rst +1 -0
@@ -12,6 +12,7 @@ Linux GPU Driver Developer's Guide drm-uapi drm-client drivers + backlight vga-switcheroo vgaarbiter todo
Signature · 1 line
2.25.1
PATCH v3 12/13 backlight: as3711_bl: introduce backlight_is_blank()
In reply to Sam RavnborgReplaces the open-coded checks of the state, with the backlight_is_blank() helper. This increases readability of the code and aling the functionality across the drivers.
Futhermore drop the debug prints in update_status().
If we need debug printing then we can add it to the backlight core.
--- drivers/video/backlight/as3711_bl.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/video/backlight/as3711_bl.c +1 -7
@@ -107,13 +107,7 @@ static int as3711_bl_update_status(struct backlight_device *bl)int brightness = bl->props.brightness;int ret =0 ; -dev_dbg (&bl->dev,"%s(): brightness %u, pwr %x, blank %x, state %x\n" , - __func__, bl->props.brightness, bl->props.power, - bl->props.fb_blank, bl->props.state); - -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (bl)) brightness =0 ;if (data->type ==AS3711_BL_SU1 ) {
Signature · 1 line
2.25.1
Re: [PATCH v3 12/13] backlight: as3711_bl: introduce backlight_is_blank()
Quoted 8 lines · Sam Ravnborg
Replaces the open-coded checks of the state, with the
backlight_is_blank()helper. This increases readability of the code and aling the functionality across the drivers.Futhermore drop the debug prints in
update_status().
If we need debug printing then we can add it to the backlight core.Signed-off-by Sam Ravnborg <[email protected]>
Quoted 30 lines
Cc Lee Jones <[email protected]>Cc Daniel Thompson <[email protected]>Cc Jingoo Han <[email protected]>Cc Emil Velikov <[email protected]>--- drivers/video/backlight/as3711_bl.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/video/backlight/as3711_bl.c +1
-7@@ -107,13 +107,7 @@ static int as3711_bl_update_status(struct backlight_device *bl)int brightness = bl->props.brightness;int ret =0 ; -dev_dbg (&bl->dev,"%s(): brightness %u, pwr %x, blank %x, state %x\n" , - __func__, bl->props.brightness, bl->props.power, - bl->props.fb_blank, bl->props.state); - -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (bl)) brightness =0 ;if (data->type ==AS3711_BL_SU1 ) {Signature · 1 line
2.25.1
PATCH v3 13/13 backlight: use backlight_is_blank() in all backlight drivers
In reply to Sam RavnborgReplaces the open-coded checks of the state etc., with the backlight_is_blank() helper.
This increases readability of the code and align the functionality across the drivers.
v3:
- Dropped as3711_bl, it will be modified in another patch
v2:
- Fixed so changelog is readable
--- drivers/video/backlight/88pm860x_bl.c | 8 +------- drivers/video/backlight/adp5520_bl.c | 5 +---- drivers/video/backlight/adp8860_bl.c | 5 +---- drivers/video/backlight/adp8870_bl.c | 5 +---- drivers/video/backlight/bd6107.c | 4 +--- drivers/video/backlight/corgi_lcd.c | 5 +---- drivers/video/backlight/cr_bllcd.c | 22 +++++++--------------- drivers/video/backlight/da903x_bl.c | 8 +------- drivers/video/backlight/ep93xx_bl.c | 3 +-- drivers/video/backlight/gpio_backlight.c | 4 +--- drivers/video/backlight/hp680_bl.c | 4 +--- drivers/video/backlight/jornada720_bl.c | 2 +- drivers/video/backlight/kb3886_bl.c | 4 +--- drivers/video/backlight/led_bl.c | 4 +--- drivers/video/backlight/lm3533_bl.c | 4 +--- drivers/video/backlight/locomolcd.c | 4 +--- drivers/video/backlight/lv5207lp.c | 4 +--- drivers/video/backlight/max8925_bl.c | 8 +------- drivers/video/backlight/pwm_bl.c | 4 +--- drivers/video/backlight/qcom-wled.c | 4 +--- drivers/video/backlight/tps65217_bl.c | 4 +--- drivers/video/backlight/wm831x_bl.c | 8 +------- 22 files changed, 28 insertions(+), 95 deletions(-)
drivers/video/backlight/88pm860x_bl.c +1 -7
@@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return pm860x_backlight_set (bl, brightness);
drivers/video/backlight/adp5520_bl.c +1 -4
@@ -67,10 +67,7 @@ static int adp5520_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp5520_bl_set (bl, brightness);
drivers/video/backlight/adp8860_bl.c +1 -4
@@ -363,10 +363,7 @@ static int adp8860_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp8860_bl_set (bl, brightness);
drivers/video/backlight/adp8870_bl.c +1 -4
@@ -401,10 +401,7 @@ static int adp8870_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp8870_bl_set (bl, brightness);
drivers/video/backlight/bd6107.c +1 -3
@@ -84,9 +84,7 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)struct bd6107 *bd =bl_get_data (backlight);int brightness = backlight->props.brightness; -if (backlight->props.power !=FB_BLANK_UNBLANK || - backlight->props.fb_blank !=FB_BLANK_UNBLANK || - backlight->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (backlight)) brightness =0 ;if (brightness) {
drivers/video/backlight/corgi_lcd.c +1 -4
@@ -422,10 +422,7 @@ static int corgi_bl_update_status(struct backlight_device *bd)struct corgi_lcd *lcd =bl_get_data (bd);int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; - -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (corgibl_flags &CORGIBL_SUSPENDED )
drivers/video/backlight/cr_bllcd.c +7 -15
@@ -59,26 +59,18 @@ struct cr_panel {static int cr_backlight_set_intensity (struct backlight_device *bd) { -int intensity = bd->props.brightness;u32 addr = gpio_bar +CRVML_PANEL_PORT ;u32 cur =inl (addr); -if (bd->props.power ==FB_BLANK_UNBLANK ) - intensity =FB_BLANK_UNBLANK ; -if (bd->props.fb_blank ==FB_BLANK_UNBLANK ) - intensity =FB_BLANK_UNBLANK ; -if (bd->props.power ==FB_BLANK_POWERDOWN ) - intensity =FB_BLANK_POWERDOWN ; -if (bd->props.fb_blank ==FB_BLANK_POWERDOWN ) - intensity =FB_BLANK_POWERDOWN ; - -if (intensity ==FB_BLANK_UNBLANK ) {/* FULL ON */ - cur &= ~CRVML_BACKLIGHT_OFF ; -outl (cur, addr); - }else if (intensity ==FB_BLANK_POWERDOWN ) {/* OFF */ +if (backlight_is_blank (bd)) { +/* OFF */ cur |=CRVML_BACKLIGHT_OFF ;outl (cur, addr); - }/* anything else, don't bother */ + }else { +/* FULL ON */ + cur &= ~CRVML_BACKLIGHT_OFF ; +outl (cur, addr); + }return 0 ; }
drivers/video/backlight/da903x_bl.c +1 -7
@@ -79,13 +79,7 @@ static int da903x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return da903x_backlight_set (bl, brightness);
drivers/video/backlight/ep93xx_bl.c +1 -2
@@ -38,8 +38,7 @@ static int ep93xxbl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return ep93xxbl_set (bl, brightness);
drivers/video/backlight/gpio_backlight.c +1 -3
@@ -25,9 +25,7 @@ static int gpio_backlight_get_next_brightness(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (bl)) brightness =0 ;return brightness;
drivers/video/backlight/hp680_bl.c +1 -3
@@ -35,9 +35,7 @@ static void hp680bl_send_intensity(struct backlight_device *bd)u16 v;int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (hp680bl_suspended) intensity =0 ;
drivers/video/backlight/jornada720_bl.c +1 -1
@@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)jornada_ssp_start ();/* If backlight is off then really turn it off */ -if ((bd->props.power !=FB_BLANK_UNBLANK ) || (bd->props.fb_blank !=FB_BLANK_UNBLANK )) { +if (backlight_is_blank (bd)) { ret =jornada_ssp_byte (BRIGHTNESSOFF );if (ret !=TXDUMMY ) {dev_info (&bd->dev,"brightness off timeout\n" );
drivers/video/backlight/kb3886_bl.c +1 -3
@@ -89,9 +89,7 @@ static int kb3886bl_send_intensity(struct backlight_device *bd) {int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (kb3886bl_flags &KB3886BL_SUSPENDED ) intensity =0 ;
drivers/video/backlight/led_bl.c +1 -3
@@ -56,9 +56,7 @@ static int led_bl_update_status(struct backlight_device *bl)struct led_bl_data *priv =bl_get_data (bl);int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;if (brightness >0 )
drivers/video/backlight/lm3533_bl.c +1 -3
@@ -41,9 +41,7 @@ static int lm3533_bl_update_status(struct backlight_device *bd)struct lm3533_bl *bl =bl_get_data (bd);int brightness = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) brightness =0 ;return lm3533_ctrlbank_set_brightness (&bl->cb, (u8 )brightness);
drivers/video/backlight/locomolcd.c +1 -3
@@ -113,9 +113,7 @@ static int locomolcd_set_intensity(struct backlight_device *bd) {int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (locomolcd_flags &LOCOMOLCD_SUSPENDED ) intensity =0 ;
drivers/video/backlight/lv5207lp.c +1 -3
@@ -48,9 +48,7 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)struct lv5207lp *lv =bl_get_data (backlight);int brightness = backlight->props.brightness; -if (backlight->props.power !=FB_BLANK_UNBLANK || - backlight->props.fb_blank !=FB_BLANK_UNBLANK || - backlight->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (backlight)) brightness =0 ;if (brightness) {
drivers/video/backlight/max8925_bl.c +1 -7
@@ -66,13 +66,7 @@ static int max8925_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return max8925_backlight_set (bl, brightness);
drivers/video/backlight/pwm_bl.c +1 -3
@@ -111,9 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)int brightness = bl->props.brightness;struct pwm_state state; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;if (pb->notify)
drivers/video/backlight/qcom-wled.c +1 -3
@@ -261,9 +261,7 @@ static int wled_update_status(struct backlight_device *bl)u16 brightness = bl->props.brightness;int rc =0 ; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;mutex_lock (&wled->lock);
drivers/video/backlight/tps65217_bl.c +1 -3
@@ -82,9 +82,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)if (bl->props.state &BL_CORE_SUSPENDED ) brightness =0 ; -if ((bl->props.power !=FB_BLANK_UNBLANK ) || - (bl->props.fb_blank !=FB_BLANK_UNBLANK )) -/* framebuffer in low power mode or blanking active */ +if (backlight_is_blank (bl)) brightness =0 ;if (brightness >0 ) {
drivers/video/backlight/wm831x_bl.c +1 -7
@@ -93,13 +93,7 @@ static int wm831x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return wm831x_backlight_set (bl, brightness);
Signature · 1 line
2.25.1
Re: [PATCH v3 13/13] backlight: use backlight_is_blank() in all backlight drivers
Quoted 4 lines · Sam Ravnborg
Replaces the open-coded checks of the state etc., with the
backlight_is_blank()helper.
This increases readability of the code and align the functionality across the drivers.
Quoted 406 lines
v3:
- Droppedas3711_bl, it will be modified in another patchv2:
- Fixed so changelog is readableSigned-off-by Sam Ravnborg <[email protected]>Reviewed-by Daniel Thompson <[email protected]>Cc Lee Jones <[email protected]>Cc Daniel Thompson <[email protected]>Cc Jingoo Han <[email protected]>Cc Michael Hennerich <[email protected]>Cc Support Opensource <[email protected]>Cc Thierry Reding <[email protected]>Cc "Uwe Kleine-König" <[email protected]>Cc Andy Gross <[email protected]>Cc Bjorn Andersson <[email protected]>--- drivers/video/backlight/88pm860x_bl.c | 8 +------- drivers/video/backlight/adp5520_bl.c | 5 +---- drivers/video/backlight/adp8860_bl.c | 5 +---- drivers/video/backlight/adp8870_bl.c | 5 +---- drivers/video/backlight/bd6107.c | 4 +--- drivers/video/backlight/corgi_lcd.c | 5 +---- drivers/video/backlight/cr_bllcd.c | 22 +++++++--------------- drivers/video/backlight/da903x_bl.c | 8 +------- drivers/video/backlight/ep93xx_bl.c | 3 +-- drivers/video/backlight/gpio_backlight.c | 4 +--- drivers/video/backlight/hp680_bl.c | 4 +--- drivers/video/backlight/jornada720_bl.c | 2 +- drivers/video/backlight/kb3886_bl.c | 4 +--- drivers/video/backlight/led_bl.c | 4 +--- drivers/video/backlight/lm3533_bl.c | 4 +--- drivers/video/backlight/locomolcd.c | 4 +--- drivers/video/backlight/lv5207lp.c | 4 +--- drivers/video/backlight/max8925_bl.c | 8 +------- drivers/video/backlight/pwm_bl.c | 4 +--- drivers/video/backlight/qcom-wled.c | 4 +--- drivers/video/backlight/tps65217_bl.c | 4 +--- drivers/video/backlight/wm831x_bl.c | 8 +------- 22 files changed, 28 insertions(+), 95 deletions(-)drivers/video/backlight/88pm860x_bl.c +1
-7@@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return pm860x_backlight_set (bl, brightness);drivers/video/backlight/adp5520_bl.c +1
-4@@ -67,10 +67,7 @@ static int adp5520_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp5520_bl_set (bl, brightness);drivers/video/backlight/adp8860_bl.c +1
-4@@ -363,10 +363,7 @@ static int adp8860_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp8860_bl_set (bl, brightness);drivers/video/backlight/adp8870_bl.c +1
-4@@ -401,10 +401,7 @@ static int adp8870_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp8870_bl_set (bl, brightness);drivers/video/backlight/bd6107.c +1
-3@@ -84,9 +84,7 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)struct bd6107 *bd =bl_get_data (backlight);int brightness = backlight->props.brightness; -if (backlight->props.power !=FB_BLANK_UNBLANK || - backlight->props.fb_blank !=FB_BLANK_UNBLANK || - backlight->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (backlight)) brightness =0 ;if (brightness) {drivers/video/backlight/corgi_lcd.c +1
-4@@ -422,10 +422,7 @@ static int corgi_bl_update_status(struct backlight_device *bd)struct corgi_lcd *lcd =bl_get_data (bd);int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; - -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (corgibl_flags &CORGIBL_SUSPENDED )drivers/video/backlight/cr_bllcd.c +7
-15@@ -59,26 +59,18 @@ struct cr_panel {static int cr_backlight_set_intensity (struct backlight_device *bd) { -int intensity = bd->props.brightness;u32 addr = gpio_bar +CRVML_PANEL_PORT ;u32 cur =inl (addr); -if (bd->props.power ==FB_BLANK_UNBLANK ) - intensity =FB_BLANK_UNBLANK ; -if (bd->props.fb_blank ==FB_BLANK_UNBLANK ) - intensity =FB_BLANK_UNBLANK ; -if (bd->props.power ==FB_BLANK_POWERDOWN ) - intensity =FB_BLANK_POWERDOWN ; -if (bd->props.fb_blank ==FB_BLANK_POWERDOWN ) - intensity =FB_BLANK_POWERDOWN ; - -if (intensity ==FB_BLANK_UNBLANK ) {/* FULL ON */ - cur &= ~CRVML_BACKLIGHT_OFF ; -outl (cur, addr); - }else if (intensity ==FB_BLANK_POWERDOWN ) {/* OFF */ +if (backlight_is_blank (bd)) { +/* OFF */ cur |=CRVML_BACKLIGHT_OFF ;outl (cur, addr); - }/* anything else, don't bother */ + }else { +/* FULL ON */ + cur &= ~CRVML_BACKLIGHT_OFF ; +outl (cur, addr); + }return 0 ; }drivers/video/backlight/da903x_bl.c +1
-7@@ -79,13 +79,7 @@ static int da903x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return da903x_backlight_set (bl, brightness);drivers/video/backlight/ep93xx_bl.c +1
-2@@ -38,8 +38,7 @@ static int ep93xxbl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return ep93xxbl_set (bl, brightness);drivers/video/backlight/gpio_backlight.c +1
-3@@ -25,9 +25,7 @@ static int gpio_backlight_get_next_brightness(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (bl)) brightness =0 ;return brightness;drivers/video/backlight/hp680_bl.c +1
-3@@ -35,9 +35,7 @@ static void hp680bl_send_intensity(struct backlight_device *bd)u16 v;int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (hp680bl_suspended) intensity =0 ;drivers/video/backlight/jornada720_bl.c +1
-1@@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)jornada_ssp_start ();/* If backlight is off then really turn it off */ -if ((bd->props.power !=FB_BLANK_UNBLANK ) || (bd->props.fb_blank !=FB_BLANK_UNBLANK )) { +if (backlight_is_blank (bd)) { ret =jornada_ssp_byte (BRIGHTNESSOFF );if (ret !=TXDUMMY ) {dev_info (&bd->dev,"brightness off timeout\n" );drivers/video/backlight/kb3886_bl.c +1
-3@@ -89,9 +89,7 @@ static int kb3886bl_send_intensity(struct backlight_device *bd) {int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (kb3886bl_flags &KB3886BL_SUSPENDED ) intensity =0 ;drivers/video/backlight/led_bl.c +1
-3@@ -56,9 +56,7 @@ static int led_bl_update_status(struct backlight_device *bl)struct led_bl_data *priv =bl_get_data (bl);int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;if (brightness >0 )drivers/video/backlight/lm3533_bl.c +1
-3@@ -41,9 +41,7 @@ static int lm3533_bl_update_status(struct backlight_device *bd)struct lm3533_bl *bl =bl_get_data (bd);int brightness = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) brightness =0 ;return lm3533_ctrlbank_set_brightness (&bl->cb, (u8 )brightness);drivers/video/backlight/locomolcd.c +1
-3@@ -113,9 +113,7 @@ static int locomolcd_set_intensity(struct backlight_device *bd) {int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (locomolcd_flags &LOCOMOLCD_SUSPENDED ) intensity =0 ;drivers/video/backlight/lv5207lp.c +1
-3@@ -48,9 +48,7 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)struct lv5207lp *lv =bl_get_data (backlight);int brightness = backlight->props.brightness; -if (backlight->props.power !=FB_BLANK_UNBLANK || - backlight->props.fb_blank !=FB_BLANK_UNBLANK || - backlight->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (backlight)) brightness =0 ;if (brightness) {drivers/video/backlight/max8925_bl.c +1
-7@@ -66,13 +66,7 @@ static int max8925_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return max8925_backlight_set (bl, brightness);drivers/video/backlight/pwm_bl.c +1
-3@@ -111,9 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)int brightness = bl->props.brightness;struct pwm_state state; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;if (pb->notify)drivers/video/backlight/qcom-wled.c +1
-3@@ -261,9 +261,7 @@ static int wled_update_status(struct backlight_device *bl)u16 brightness = bl->props.brightness;int rc =0 ; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;mutex_lock (&wled->lock);drivers/video/backlight/tps65217_bl.c +1
-3@@ -82,9 +82,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)if (bl->props.state &BL_CORE_SUSPENDED ) brightness =0 ; -if ((bl->props.power !=FB_BLANK_UNBLANK ) || - (bl->props.fb_blank !=FB_BLANK_UNBLANK )) -/* framebuffer in low power mode or blanking active */ +if (backlight_is_blank (bl)) brightness =0 ;if (brightness >0 ) {drivers/video/backlight/wm831x_bl.c +0
-1@@ -93,13 +93,7 @@ static int wm831x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK )
drivers/video/backlight/wm831x_bl.c static int wm831x_backlight_update_status(struct backlight_device *bl) · line 99
Quoted 10 lines
drivers/video/backlight/wm831x_bl.c +1
-6- brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return wm831x_backlight_set (bl, brightness);
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 13/13] backlight: use backlight_is_blank() in all backlight drivers
Quoted 9 lines · Peter Ujfalusi
Quoted 4 lines · Sam Ravnborg
Replaces the open-coded checks of the state etc., with the
backlight_is_blank()helper.
This increases readability of the code and align the functionality across the drivers.Reviewed-by Peter Ujfalusi <[email protected]>
Thanks, I missed your previsous r-b. Sorry.
Sam
Quoted 415 lines
Quoted 415 lines
v3:
- Droppedas3711_bl, it will be modified in another patchv2:
- Fixed so changelog is readableSigned-off-by Sam Ravnborg <[email protected]>Reviewed-by Daniel Thompson <[email protected]>Cc Lee Jones <[email protected]>Cc Daniel Thompson <[email protected]>Cc Jingoo Han <[email protected]>Cc Michael Hennerich <[email protected]>Cc Support Opensource <[email protected]>Cc Thierry Reding <[email protected]>Cc "Uwe Kleine-König" <[email protected]>Cc Andy Gross <[email protected]>Cc Bjorn Andersson <[email protected]>--- drivers/video/backlight/88pm860x_bl.c | 8 +------- drivers/video/backlight/adp5520_bl.c | 5 +---- drivers/video/backlight/adp8860_bl.c | 5 +---- drivers/video/backlight/adp8870_bl.c | 5 +---- drivers/video/backlight/bd6107.c | 4 +--- drivers/video/backlight/corgi_lcd.c | 5 +---- drivers/video/backlight/cr_bllcd.c | 22 +++++++--------------- drivers/video/backlight/da903x_bl.c | 8 +------- drivers/video/backlight/ep93xx_bl.c | 3 +-- drivers/video/backlight/gpio_backlight.c | 4 +--- drivers/video/backlight/hp680_bl.c | 4 +--- drivers/video/backlight/jornada720_bl.c | 2 +- drivers/video/backlight/kb3886_bl.c | 4 +--- drivers/video/backlight/led_bl.c | 4 +--- drivers/video/backlight/lm3533_bl.c | 4 +--- drivers/video/backlight/locomolcd.c | 4 +--- drivers/video/backlight/lv5207lp.c | 4 +--- drivers/video/backlight/max8925_bl.c | 8 +------- drivers/video/backlight/pwm_bl.c | 4 +--- drivers/video/backlight/qcom-wled.c | 4 +--- drivers/video/backlight/tps65217_bl.c | 4 +--- drivers/video/backlight/wm831x_bl.c | 8 +------- 22 files changed, 28 insertions(+), 95 deletions(-)drivers/video/backlight/88pm860x_bl.c +1
-7@@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return pm860x_backlight_set (bl, brightness);drivers/video/backlight/adp5520_bl.c +1
-4@@ -67,10 +67,7 @@ static int adp5520_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp5520_bl_set (bl, brightness);drivers/video/backlight/adp8860_bl.c +1
-4@@ -363,10 +363,7 @@ static int adp8860_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp8860_bl_set (bl, brightness);drivers/video/backlight/adp8870_bl.c +1
-4@@ -401,10 +401,7 @@ static int adp8870_bl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return adp8870_bl_set (bl, brightness);drivers/video/backlight/bd6107.c +1
-3@@ -84,9 +84,7 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)struct bd6107 *bd =bl_get_data (backlight);int brightness = backlight->props.brightness; -if (backlight->props.power !=FB_BLANK_UNBLANK || - backlight->props.fb_blank !=FB_BLANK_UNBLANK || - backlight->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (backlight)) brightness =0 ;if (brightness) {drivers/video/backlight/corgi_lcd.c +1
-4@@ -422,10 +422,7 @@ static int corgi_bl_update_status(struct backlight_device *bd)struct corgi_lcd *lcd =bl_get_data (bd);int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; - -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (corgibl_flags &CORGIBL_SUSPENDED )drivers/video/backlight/cr_bllcd.c +7
-15@@ -59,26 +59,18 @@ struct cr_panel {static int cr_backlight_set_intensity (struct backlight_device *bd) { -int intensity = bd->props.brightness;u32 addr = gpio_bar +CRVML_PANEL_PORT ;u32 cur =inl (addr); -if (bd->props.power ==FB_BLANK_UNBLANK ) - intensity =FB_BLANK_UNBLANK ; -if (bd->props.fb_blank ==FB_BLANK_UNBLANK ) - intensity =FB_BLANK_UNBLANK ; -if (bd->props.power ==FB_BLANK_POWERDOWN ) - intensity =FB_BLANK_POWERDOWN ; -if (bd->props.fb_blank ==FB_BLANK_POWERDOWN ) - intensity =FB_BLANK_POWERDOWN ; - -if (intensity ==FB_BLANK_UNBLANK ) {/* FULL ON */ - cur &= ~CRVML_BACKLIGHT_OFF ; -outl (cur, addr); - }else if (intensity ==FB_BLANK_POWERDOWN ) {/* OFF */ +if (backlight_is_blank (bd)) { +/* OFF */ cur |=CRVML_BACKLIGHT_OFF ;outl (cur, addr); - }/* anything else, don't bother */ + }else { +/* FULL ON */ + cur &= ~CRVML_BACKLIGHT_OFF ; +outl (cur, addr); + }return 0 ; }drivers/video/backlight/da903x_bl.c +1
-7@@ -79,13 +79,7 @@ static int da903x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return da903x_backlight_set (bl, brightness);drivers/video/backlight/ep93xx_bl.c +1
-2@@ -38,8 +38,7 @@ static int ep93xxbl_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;return ep93xxbl_set (bl, brightness);drivers/video/backlight/gpio_backlight.c +1
-3@@ -25,9 +25,7 @@ static int gpio_backlight_get_next_brightness(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (bl)) brightness =0 ;return brightness;drivers/video/backlight/hp680_bl.c +1
-3@@ -35,9 +35,7 @@ static void hp680bl_send_intensity(struct backlight_device *bd)u16 v;int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (hp680bl_suspended) intensity =0 ;drivers/video/backlight/jornada720_bl.c +1
-1@@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)jornada_ssp_start ();/* If backlight is off then really turn it off */ -if ((bd->props.power !=FB_BLANK_UNBLANK ) || (bd->props.fb_blank !=FB_BLANK_UNBLANK )) { +if (backlight_is_blank (bd)) { ret =jornada_ssp_byte (BRIGHTNESSOFF );if (ret !=TXDUMMY ) {dev_info (&bd->dev,"brightness off timeout\n" );drivers/video/backlight/kb3886_bl.c +1
-3@@ -89,9 +89,7 @@ static int kb3886bl_send_intensity(struct backlight_device *bd) {int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (kb3886bl_flags &KB3886BL_SUSPENDED ) intensity =0 ;drivers/video/backlight/led_bl.c +1
-3@@ -56,9 +56,7 @@ static int led_bl_update_status(struct backlight_device *bl)struct led_bl_data *priv =bl_get_data (bl);int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;if (brightness >0 )drivers/video/backlight/lm3533_bl.c +1
-3@@ -41,9 +41,7 @@ static int lm3533_bl_update_status(struct backlight_device *bd)struct lm3533_bl *bl =bl_get_data (bd);int brightness = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) brightness =0 ;return lm3533_ctrlbank_set_brightness (&bl->cb, (u8 )brightness);drivers/video/backlight/locomolcd.c +1
-3@@ -113,9 +113,7 @@ static int locomolcd_set_intensity(struct backlight_device *bd) {int intensity = bd->props.brightness; -if (bd->props.power !=FB_BLANK_UNBLANK ) - intensity =0 ; -if (bd->props.fb_blank !=FB_BLANK_UNBLANK ) +if (backlight_is_blank (bd)) intensity =0 ;if (locomolcd_flags &LOCOMOLCD_SUSPENDED ) intensity =0 ;drivers/video/backlight/lv5207lp.c +1
-3@@ -48,9 +48,7 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)struct lv5207lp *lv =bl_get_data (backlight);int brightness = backlight->props.brightness; -if (backlight->props.power !=FB_BLANK_UNBLANK || - backlight->props.fb_blank !=FB_BLANK_UNBLANK || - backlight->props.state & (BL_CORE_SUSPENDED |BL_CORE_FBBLANK )) +if (backlight_is_blank (backlight)) brightness =0 ;if (brightness) {drivers/video/backlight/max8925_bl.c +1
-7@@ -66,13 +66,7 @@ static int max8925_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;return max8925_backlight_set (bl, brightness);drivers/video/backlight/pwm_bl.c +1
-3@@ -111,9 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)int brightness = bl->props.brightness;struct pwm_state state; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;if (pb->notify)drivers/video/backlight/qcom-wled.c +1
-3@@ -261,9 +261,7 @@ static int wled_update_status(struct backlight_device *bl)u16 brightness = bl->props.brightness;int rc =0 ; -if (bl->props.power !=FB_BLANK_UNBLANK || - bl->props.fb_blank !=FB_BLANK_UNBLANK || - bl->props.state &BL_CORE_FBBLANK ) +if (backlight_is_blank (bl)) brightness =0 ;mutex_lock (&wled->lock);drivers/video/backlight/tps65217_bl.c +1
-3@@ -82,9 +82,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)if (bl->props.state &BL_CORE_SUSPENDED ) brightness =0 ; -if ((bl->props.power !=FB_BLANK_UNBLANK ) || - (bl->props.fb_blank !=FB_BLANK_UNBLANK )) -/* framebuffer in low power mode or blanking active */ +if (backlight_is_blank (bl)) brightness =0 ;if (brightness >0 ) {drivers/video/backlight/wm831x_bl.c +1
-7@@ -93,13 +93,7 @@ static int wm831x_backlight_update_status(struct backlight_device *bl) {int brightness = bl->props.brightness; -if (bl->props.power !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.fb_blank !=FB_BLANK_UNBLANK ) - brightness =0 ; - -if (bl->props.state &BL_CORE_SUSPENDED ) +if (backlight_is_blank (bl)) brightness =0 ;
Quoted 7 lines
drivers/video/backlight/wm831x_bl.c static int wm831x_backlight_update_status(struct backlight_device *bl) · line 99
Quoted 2 lines
drivers/video/backlight/wm831x_bl.c +0
-0return wm831x_backlight_set (bl, brightness);- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Sam,
Quoted 9 lines · Sam Ravnborg
v3:
- Dropped video patch that was reviewd and thus applied
- Updated kernel-doc so all fields now have a short intro
- Improved readability in a lot of places, thanks to review feedback from Daniel - thanks!
- Added better intro to backlight
- Added acks
Quoted 7 lines
Several other smaller changes documented in the patches.
I left out patches to make functions static as
there are dependencies to drm-misc-next for these. When this is landed I have a pile of follow-up patches waiting, mostly introducingbacklight_is_blank()all over.
What happened with my suggestion to use backlight_is_blank() in fbdev core itself?
It effectively makes 13/13 and the above mentioned follow-up series obsolete.
That said, series look spot on. With the documentation fixed (pointer by Daniel) patches 1-12 are:
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Emil.
Long overdue feedback, I did not find time to go back to this patch-set until now.
Quoted 19 lines · Emil Velikov
Hi Sam,
Quoted 9 lines · Sam Ravnborg
v3:
- Dropped video patch that was reviewd and thus applied
- Updated kernel-doc so all fields now have a short intro
- Improved readability in a lot of places, thanks to review feedback from Daniel - thanks!
- Added better intro to backlight
- Added acksQuoted 7 lines
Several other smaller changes documented in the patches.
I left out patches to make functions static as
there are dependencies to drm-misc-next for these. When this is landed I have a pile of follow-up patches waiting, mostly introducingbacklight_is_blank()all over.
Quoted 2 lines
What happened with my suggestion to use
backlight_is_blank()in fbdev core itself?
Following your suggestion I implemented:
+static inline int backlight_get_brightness(struct backlight_device *bd) +{
+ if (backlight_is_blank(bd))
+ return 0;
+ else
+ return bd->props.brightness;
+}
This results in code like this:
static int adp8870_bl_update_status(struct backlight_device *bl)
{
return adp8870_bl_set(bl, backlight_get_brightness(bl));
}Compare that with the original code:
static int adp8870_bl_update_status(struct backlight_device *bl)
{
int brightness = bl->props.brightness;
if (bl->props.power != FB_BLANK_UNBLANK)
brightness = 0;
if (bl->props.fb_blank != FB_BLANK_UNBLANK)
brightness = 0;
return adp8870_bl_set(bl, brightness);
}Much nicer!
The old code reads the brightness property direct.
I prefer the small helper so we do not hardcode too much of the internals in the drivers.
Also the above is simpler than trying to maintain the correct value in props.brightness all the time. And can be introduced gradually.
I will rework the series to use this helper.
I will also fix so I can use a const backlight_device *.
Thanks for the suggestion.
Sam
Quoted 11 lines
It effectively makes 13/13 and the above mentioned follow-up series obsolete.
That said, series look spot on. With the documentation fixed (pointer by Daniel) patches 1-12 are:
Reviewed-by Emil Velikov <[email protected]>-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel