Pull backlight updates from Lee Jones: "Core Framework: - Trivial: Code refactoring - New API backlight_is_blank() - New API backlight_get_brightness() - Additional/reworked documentation - Remove 'extern' labels from prototypes - Drop backlight_put() - Staticify of_find_backlight() Driver Removal: - Removal of unused OT200 driver - Removal of unused Generic Backlight driver Fix-ups - Bunch of W=1 warning fixes - Convert to GPIO descriptors; sky81452 - Move platform data handling into driver; sky81452 - Remove superfluous code; lms501kf03 - Many instances of using new APIs" * tag 'backlight-next-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: (34 commits) video: backlight: cr_bllcd: Remove unused variable 'intensity' backlight: backlight: Make of_find_backlight static backlight: backlight: Drop backlight_put() backlight: Use backlight_get_brightness() throughout backlight: jornada720_bl: Introduce backlight_is_blank() backlight: gpio_backlight: Simplify update_status() backlight: cr_bllcd: Introduce gpio-backlight semantics backlight: as3711_bl: Simplify update_status backlight: backlight: Introduce backlight_get_brightness() doc-rst: Wire-up Backlight kernel-doc documentation backlight: backlight: Add overview and update existing doc backlight: backlight: Drop extern from prototypes backlight: generic_bl: Remove this driver as it is unused backlight: backlight: Document enums in backlight.h backlight: backlight: Document inline functions in backlight.h backlight: backlight: Improve backlight_device documentation backlight: backlight: Improve backlight_properties documentation backlight: backlight: Improve backlight_ops documentation backlight: backlight: Add backlight_is_blank() backlight: backlight: Refactor fb_notifier_callback() ...
Showing the changes to include/linux (3 of 39 files). Show all
Unified · Split
| @@ -14,113 +14,336 @@ · 13 unmodified lines | |||
| 14 | #include <linux/mutex.h> | 14 | #include <linux/mutex.h> |
| 15 | #include <linux/notifier.h> | 15 | #include <linux/notifier.h> |
| 16 | 16 | ||
| 17 | /* Notes on locking: | 17 | /** |
| 18 | * | 18 | * enum backlight_update_reason - what method was used to update backlight |
| 19 | * backlight_device->ops_lock is an internal backlight lock protecting the | ||
| 20 | * ops pointer and no code outside the core should need to touch it. | ||
| 21 | * | ||
| 22 | * Access to update_status() is serialised by the update_lock mutex since | ||
| 23 | * most drivers seem to need this and historically get it wrong. | ||
| 24 | * | ||
| 25 | * Most drivers don't need locking on their get_brightness() method. | ||
| 26 | * If yours does, you need to implement it in the driver. You can use the | ||
| 27 | * update_lock mutex if appropriate. | ||
| 28 | * | 19 | * |
| 29 | * Any other use of the locks below is probably wrong. | 20 | * A driver indicates the method (reason) used for updating the backlight |
| 21 | * when calling backlight_force_update(). | ||
| 30 | */ | 22 | */ |
| 31 | |||
| 32 | enum backlight_update_reason { | 23 | enum backlight_update_reason { |
| 24 | /** | ||
| 25 | * @BACKLIGHT_UPDATE_HOTKEY: The backlight was updated using a hot-key. | ||
| 26 | */ | ||
| 33 | BACKLIGHT_UPDATE_HOTKEY, | 27 | BACKLIGHT_UPDATE_HOTKEY, |
| 28 | |||
| 29 | /** | ||
| 30 | * @BACKLIGHT_UPDATE_SYSFS: The backlight was updated using sysfs. | ||
| 31 | */ | ||
| 34 | BACKLIGHT_UPDATE_SYSFS, | 32 | BACKLIGHT_UPDATE_SYSFS, |
| 35 | }; | 33 | }; |
| 36 | 34 | ||
| 35 | /** | ||
| 36 | * enum backlight_type - the type of backlight control | ||
| 37 | * | ||
| 38 | * The type of interface used to control the backlight. | ||
| 39 | */ | ||
| 37 | enum backlight_type { | 40 | enum backlight_type { |
| 41 | /** | ||
| 42 | * @BACKLIGHT_RAW: | ||
| 43 | * | ||
| 44 | * The backlight is controlled using hardware registers. | ||
| 45 | */ | ||
| 38 | BACKLIGHT_RAW = 1, | 46 | BACKLIGHT_RAW = 1, |
| 47 | |||
| 48 | /** | ||
| 49 | * @BACKLIGHT_PLATFORM: | ||
| 50 | * | ||
| 51 | * The backlight is controlled using a platform-specific interface. | ||
| 52 | */ | ||
| 39 | BACKLIGHT_PLATFORM, | 53 | BACKLIGHT_PLATFORM, |
| 54 | |||
| 55 | /** | ||
| 56 | * @BACKLIGHT_FIRMWARE: | ||
| 57 | * | ||
| 58 | * The backlight is controlled using a standard firmware interface. | ||
| 59 | */ | ||
| 40 | BACKLIGHT_FIRMWARE, | 60 | BACKLIGHT_FIRMWARE, |
| 61 | |||
| 62 | /** | ||
| 63 | * @BACKLIGHT_TYPE_MAX: Number of entries. | ||
| 64 | */ | ||
| 41 | BACKLIGHT_TYPE_MAX, | 65 | BACKLIGHT_TYPE_MAX, |
| 42 | }; | 66 | }; |
| 43 | 67 | ||
| 68 | /** | ||
| 69 | * enum backlight_notification - the type of notification | ||
| 70 | * | ||
| 71 | * The notifications that is used for notification sent to the receiver | ||
| 72 | * that registered notifications using backlight_register_notifier(). | ||
| 73 | */ | ||
| 44 | enum backlight_notification { | 74 | enum backlight_notification { |
| 75 | /** | ||
| 76 | * @BACKLIGHT_REGISTERED: The backlight device is registered. | ||
| 77 | */ | ||
| 45 | BACKLIGHT_REGISTERED, | 78 | BACKLIGHT_REGISTERED, |
| 79 | |||
| 80 | /** | ||
| 81 | * @BACKLIGHT_UNREGISTERED: The backlight revice is unregistered. | ||
| 82 | */ | ||
| 46 | BACKLIGHT_UNREGISTERED, | 83 | BACKLIGHT_UNREGISTERED, |
| 47 | }; | 84 | }; |
| 48 | 85 | ||
| 86 | /** enum backlight_scale - the type of scale used for brightness values | ||
| 87 | * | ||
| 88 | * The type of scale used for brightness values. | ||
| 89 | */ | ||
| 49 | enum backlight_scale { | 90 | enum backlight_scale { |
| 91 | /** | ||
| 92 | * @BACKLIGHT_SCALE_UNKNOWN: The scale is unknown. | ||
| 93 | */ | ||
| 50 | BACKLIGHT_SCALE_UNKNOWN = 0, | 94 | BACKLIGHT_SCALE_UNKNOWN = 0, |
| 95 | |||
| 96 | /** | ||
| 97 | * @BACKLIGHT_SCALE_LINEAR: The scale is linear. | ||
| 98 | * | ||
| 99 | * The linear scale will increase brightness the same for each step. | ||
| 100 | */ | ||
| 51 | BACKLIGHT_SCALE_LINEAR, | 101 | BACKLIGHT_SCALE_LINEAR, |
| 102 | |||
| 103 | /** | ||
| 104 | * @BACKLIGHT_SCALE_NON_LINEAR: The scale is not linear. | ||
| 105 | * | ||
| 106 | * This is often used when the brightness values tries to adjust to | ||
| 107 | * the relative perception of the eye demanding a non-linear scale. | ||
| 108 | */ | ||
| 52 | BACKLIGHT_SCALE_NON_LINEAR, | 109 | BACKLIGHT_SCALE_NON_LINEAR, |
| 53 | }; | 110 | }; |
| 54 | 111 | ||
| 55 | struct backlight_device; | 112 | struct backlight_device; |
| 56 | struct fb_info; | 113 | struct fb_info; |
| 57 | 114 | ||
| 115 | /** | ||
| 116 | * struct backlight_ops - backlight operations | ||
| 117 | * | ||
| 118 | * The backlight operations are specified when the backlight device is registered. | ||
| 119 | */ | ||
| 58 | struct backlight_ops { | 120 | struct backlight_ops { |
| 121 | /** | ||
| 122 | * @options: Configure how operations are called from the core. | ||
| 123 | * | ||
| 124 | * The options parameter is used to adjust the behaviour of the core. | ||
| 125 | * Set BL_CORE_SUSPENDRESUME to get the update_status() operation called | ||
| 126 | * upon suspend and resume. | ||
| 127 | */ | ||
| 59 | unsigned int options; | 128 | unsigned int options; |
| 60 | 129 | ||
| 61 | #define BL_CORE_SUSPENDRESUME (1 << 0) | 130 | #define BL_CORE_SUSPENDRESUME (1 << 0) |
| 62 | 131 | ||
| 63 | /* Notify the backlight driver some property has changed */ | 132 | /** |
| 133 | * @update_status: Operation called when properties have changed. | ||
| 134 | * | ||
| 135 | * Notify the backlight driver some property has changed. | ||
| 136 | * The update_status operation is protected by the update_lock. | ||
| 137 | * | ||
| 138 | * The backlight driver is expected to use backlight_is_blank() | ||
| 139 | * to check if the display is blanked and set brightness accordingly. | ||
| 140 | * update_status() is called when any of the properties has changed. | ||
| 141 | * | ||
| 142 | * RETURNS: | ||
| 143 | * | ||
| 144 | * 0 on success, negative error code if any failure occurred. | ||
| 145 | */ | ||
| 64 | int (*update_status)(struct backlight_device *); | 146 | int (*update_status)(struct backlight_device *); |
| 65 | /* Return the current backlight brightness (accounting for power, | 147 | |
| 66 | fb_blank etc.) */ | 148 | /** |
| 149 | * @get_brightness: Return the current backlight brightness. | ||
| 150 | * | ||
| 151 | * The driver may implement this as a readback from the HW. | ||
| 152 | * This operation is optional and if not present then the current | ||
| 153 | * brightness property value is used. | ||
| 154 | * | ||
| 155 | * RETURNS: | ||
| 156 | * | ||
| 157 | * A brightness value which is 0 or a positive number. | ||
| 158 | * On failure a negative error code is returned. | ||
| 159 | */ | ||
| 67 | int (*get_brightness)(struct backlight_device *); | 160 | int (*get_brightness)(struct backlight_device *); |
| 68 | /* Check if given framebuffer device is the one bound to this backlight; | 161 | |
| 69 | return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ | 162 | /** |
| 70 | int (*check_fb)(struct backlight_device *, struct fb_info *); | 163 | * @check_fb: Check the framebuffer device. |
| 164 | * | ||
| 165 | * Check if given framebuffer device is the one bound to this backlight. | ||
| 166 | * This operation is optional and if not implemented it is assumed that the | ||
| 167 | * fbdev is always the one bound to the backlight. | ||
| 168 | * | ||
| 169 | * RETURNS: | ||
| 170 | * | ||
| 171 | * If info is NULL or the info matches the fbdev bound to the backlight return true. | ||
| 172 | * If info does not match the fbdev bound to the backlight return false. | ||
| 173 | */ | ||
| 174 | int (*check_fb)(struct backlight_device *bd, struct fb_info *info); | ||
| 71 | }; | 175 | }; |
| 72 | 176 | ||
| 73 | /* This structure defines all the properties of a backlight */ | 177 | /** |
| 178 | * struct backlight_properties - backlight properties | ||
| 179 | * | ||
| 180 | * This structure defines all the properties of a backlight. | ||
| 181 | */ | ||
| 74 | struct backlight_properties { | 182 | struct backlight_properties { |
| 75 | /* Current User requested brightness (0 - max_brightness) */ | 183 | /** |
| 184 | * @brightness: The current brightness requested by the user. | ||
| 185 | * | ||
| 186 | * The backlight core makes sure the range is (0 to max_brightness) | ||
| 187 | * when the brightness is set via the sysfs attribute: | ||
| 188 | * /sys/class/backlight/<backlight>/brightness. | ||
| 189 | * | ||
| 190 | * This value can be set in the backlight_properties passed | ||
| 191 | * to devm_backlight_device_register() to set a default brightness | ||
| 192 | * value. | ||
| 193 | */ | ||
| 76 | int brightness; | 194 | int brightness; |
| 77 | /* Maximal value for brightness (read-only) */ | 195 | |
| 196 | /** | ||
| 197 | * @max_brightness: The maximum brightness value. | ||
| 198 | * | ||
| 199 | * This value must be set in the backlight_properties passed to | ||
| 200 | * devm_backlight_device_register() and shall not be modified by the | ||
| 201 | * driver after registration. | ||
| 202 | */ | ||
| 78 | int max_brightness; | 203 | int max_brightness; |
| 79 | /* Current FB Power mode (0: full on, 1..3: power saving | 204 | |
| 80 | modes; 4: full off), see FB_BLANK_XXX */ | 205 | /** |
| 206 | * @power: The current power mode. | ||
| 207 | * | ||
| 208 | * User space can configure the power mode using the sysfs | ||
| 209 | * attribute: /sys/class/backlight/<backlight>/bl_power | ||
| 210 | * When the power property is updated update_status() is called. | ||
| 211 | * | ||
| 212 | * The possible values are: (0: full on, 1 to 3: power saving | ||
| 213 | * modes; 4: full off), see FB_BLANK_XXX. | ||
| 214 | * | ||
| 215 | * When the backlight device is enabled @power is set | ||
| 216 | * to FB_BLANK_UNBLANK. When the backlight device is disabled | ||
| 217 | * @power is set to FB_BLANK_POWERDOWN. | ||
| 218 | */ | ||
| 81 | int power; | 219 | int power; |
| 82 | /* FB Blanking active? (values as for power) */ | 220 | |
| 83 | /* Due to be removed, please use (state & BL_CORE_FBBLANK) */ | 221 | /** |
| 222 | * @fb_blank: The power state from the FBIOBLANK ioctl. | ||
| 223 | * | ||
| 224 | * When the FBIOBLANK ioctl is called @fb_blank is set to the | ||
| 225 | * blank parameter and the update_status() operation is called. | ||
| 226 | * | ||
| 227 | * When the backlight device is enabled @fb_blank is set | ||
| 228 | * to FB_BLANK_UNBLANK. When the backlight device is disabled | ||
| 229 | * @fb_blank is set to FB_BLANK_POWERDOWN. | ||
| 230 | * | ||
| 231 | * Backlight drivers should avoid using this property. It has been | ||
| 232 | * replaced by state & BL_CORE_FBLANK (although most drivers should | ||
| 233 | * use backlight_is_blank() as the preferred means to get the blank | ||
| 234 | * state). | ||
| 235 | * | ||
| 236 | * fb_blank is deprecated and will be removed. | ||
| 237 | */ | ||
| 84 | int fb_blank; | 238 | int fb_blank; |
| 85 | /* Backlight type */ | 239 | |
| 240 | /** | ||
| 241 | * @type: The type of backlight supported. | ||
| 242 | * | ||
| 243 | * The backlight type allows userspace to make appropriate | ||
| 244 | * policy decisions based on the backlight type. | ||
| 245 | * | ||
| 246 | * This value must be set in the backlight_properties | ||
| 247 | * passed to devm_backlight_device_register(). | ||
| 248 | */ | ||
| 86 | enum backlight_type type; | 249 | enum backlight_type type; |
| 87 | /* Flags used to signal drivers of state changes */ | 250 | |
| 251 | /** | ||
| 252 | * @state: The state of the backlight core. | ||
| 253 | * | ||
| 254 | * The state is a bitmask. BL_CORE_FBBLANK is set when the display | ||
| 255 | * is expected to be blank. BL_CORE_SUSPENDED is set when the | ||
| 256 | * driver is suspended. | ||
| 257 | * | ||
| 258 | * backlight drivers are expected to use backlight_is_blank() | ||
| 259 | * in their update_status() operation rather than reading the | ||
| 260 | * state property. | ||
| 261 | * | ||
| 262 | * The state is maintained by the core and drivers may not modify it. | ||
| 263 | */ | ||
| 88 | unsigned int state; | 264 | unsigned int state; |
| 89 | /* Type of the brightness scale (linear, non-linear, ...) */ | ||
| 90 | enum backlight_scale scale; | ||
| 91 | 265 | ||
| 92 | #define BL_CORE_SUSPENDED (1 << 0) /* backlight is suspended */ | 266 | #define BL_CORE_SUSPENDED (1 << 0) /* backlight is suspended */ |
| 93 | #define BL_CORE_FBBLANK (1 << 1) /* backlight is under an fb blank event */ | 267 | #define BL_CORE_FBBLANK (1 << 1) /* backlight is under an fb blank event */ |
| 94 | 268 | ||
| 269 | /** | ||
| 270 | * @scale: The type of the brightness scale. | ||
| 271 | */ | ||
| 272 | enum backlight_scale scale; | ||
| 95 | }; | 273 | }; |
| 96 | 274 | ||
| 275 | /** | ||
| 276 | * struct backlight_device - backlight device data | ||
| 277 | * | ||
| 278 | * This structure holds all data required by a backlight device. | ||
| 279 | */ | ||
| 97 | struct backlight_device { | 280 | struct backlight_device { |
| 98 | /* Backlight properties */ | 281 | /** |
| 282 | * @props: Backlight properties | ||
| 283 | */ | ||
| 99 | struct backlight_properties props; | 284 | struct backlight_properties props; |
| 100 | 285 | ||
| 101 | /* Serialise access to update_status method */ | 286 | /** |
| 287 | * @update_lock: The lock used when calling the update_status() operation. | ||
| 288 | * | ||
| 289 | * update_lock is an internal backlight lock that serialise access | ||
| 290 | * to the update_status() operation. The backlight core holds the update_lock | ||
| 291 | * when calling the update_status() operation. The update_lock shall not | ||
| 292 | * be used by backlight drivers. | ||
| 293 | */ | ||
| 102 | struct mutex update_lock; | 294 | struct mutex update_lock; |
| 103 | 295 | ||
| 104 | /* This protects the 'ops' field. If 'ops' is NULL, the driver that | 296 | /** |
| 105 | registered this device has been unloaded, and if class_get_devdata() | 297 | * @ops_lock: The lock used around everything related to backlight_ops. |
| 106 | points to something in the body of that driver, it is also invalid. */ | 298 | * |
| 299 | * ops_lock is an internal backlight lock that protects the ops pointer | ||
| 300 | * and is used around all accesses to ops and when the operations are | ||
| 301 | * invoked. The ops_lock shall not be used by backlight drivers. | ||
| 302 | */ | ||
| 107 | struct mutex ops_lock; | 303 | struct mutex ops_lock; |
| 304 | |||
| 305 | /** | ||
| 306 | * @ops: Pointer to the backlight operations. | ||
| 307 | * | ||
| 308 | * If ops is NULL, the driver that registered this device has been unloaded, | ||
| 309 | * and if class_get_devdata() points to something in the body of that driver, | ||
| 310 | * it is also invalid. | ||
| 311 | */ | ||
| 108 | const struct backlight_ops *ops; | 312 | const struct backlight_ops *ops; |
| 109 | 313 | ||
| 110 | /* The framebuffer notifier block */ | 314 | /** |
| 315 | * @fb_notif: The framebuffer notifier block | ||
| 316 | */ | ||
| 111 | struct notifier_block fb_notif; | 317 | struct notifier_block fb_notif; |
| 112 | 318 | ||
| 113 | /* list entry of all registered backlight devices */ | 319 | /** |
| 320 | * @entry: List entry of all registered backlight devices | ||
| 321 | */ | ||
| 114 | struct list_head entry; | 322 | struct list_head entry; |
| 115 | 323 | ||
| 324 | /** | ||
| 325 | * @dev: Parent device. | ||
| 326 | */ | ||
| 116 | struct device dev; | 327 | struct device dev; |
| 117 | 328 | ||
| 118 | /* Multiple framebuffers may share one backlight device */ | 329 | /** |
| 330 | * @fb_bl_on: The state of individual fbdev's. | ||
| 331 | * | ||
| 332 | * Multiple fbdev's may share one backlight device. The fb_bl_on | ||
| 333 | * records the state of the individual fbdev. | ||
| 334 | */ | ||
| 119 | bool fb_bl_on[FB_MAX]; | 335 | bool fb_bl_on[FB_MAX]; |
| 120 | 336 | ||
| 337 | /** | ||
| 338 | * @use_count: The number of uses of fb_bl_on. | ||
| 339 | */ | ||
| 121 | int use_count; | 340 | int use_count; |
| 122 | }; | 341 | }; |
| 123 | 342 | ||
| 343 | /** | ||
| 344 | * backlight_update_status - force an update of the backlight device status | ||
| 345 | * @bd: the backlight device | ||
| 346 | */ | ||
| 124 | static inline int backlight_update_status(struct backlight_device *bd) | 347 | static inline int backlight_update_status(struct backlight_device *bd) |
| 125 | { | 348 | { |
| 126 | int ret = -ENOENT; | 349 | int ret = -ENOENT; |
| @@ -166,49 +389,83 @@ static inline int backlight_disable(struct backlight_device *bd) · 39 unmodified lines | |||
| 166 | } | 389 | } |
| 167 | 390 | ||
| 168 | /** | 391 | /** |
| 169 | * backlight_put - Drop backlight reference | 392 | * backlight_is_blank - Return true if display is expected to be blank |
| 170 | * @bd: the backlight device to put | 393 | * @bd: the backlight device |
| 394 | * | ||
| 395 | * Display is expected to be blank if any of these is true:: | ||
| 396 | * | ||
| 397 | * 1) if power in not UNBLANK | ||
| 398 | * 2) if fb_blank is not UNBLANK | ||
| 399 | * 3) if state indicate BLANK or SUSPENDED | ||
| 400 | * | ||
| 401 | * Returns true if display is expected to be blank, false otherwise. | ||
| 171 | */ | 402 | */ |
| 172 | static inline void backlight_put(struct backlight_device *bd) | 403 | static inline bool backlight_is_blank(const struct backlight_device *bd) |
| 173 | { | 404 | { |
| 174 | if (bd) | 405 | return bd->props.power != FB_BLANK_UNBLANK || |
| 175 | put_device(&bd->dev); | 406 | bd->props.fb_blank != FB_BLANK_UNBLANK || |
| 407 | bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); | ||
| 176 | } | 408 | } |
| 177 | 409 | ||
| 178 | extern struct backlight_device *backlight_device_register(const char *name, | 410 | /** |
| 179 | struct device *dev, void *devdata, const struct backlight_ops *ops, | 411 | * backlight_get_brightness - Returns the current brightness value |
| 180 | const struct backlight_properties *props); | 412 | * @bd: the backlight device |
| 181 | extern struct backlight_device *devm_backlight_device_register( | 413 | * |
| 182 | struct device *dev, const char *name, struct device *parent, | 414 | * Returns the current brightness value, taking in consideration the current |
| 183 | void *devdata, const struct backlight_ops *ops, | 415 | * state. If backlight_is_blank() returns true then return 0 as brightness |
| 184 | const struct backlight_properties *props); | 416 | * otherwise return the current brightness property value. |
| 185 | extern void backlight_device_unregister(struct backlight_device *bd); | 417 | * |
| 186 | extern void devm_backlight_device_unregister(struct device *dev, | 418 | * Backlight drivers are expected to use this function in their update_status() |
| 187 | struct backlight_device *bd); | 419 | * operation to get the brightness value. |
| 188 | extern void backlight_force_update(struct backlight_device *bd, | 420 | */ |
| 189 | enum backlight_update_reason reason); | 421 | static inline int backlight_get_brightness(const struct backlight_device *bd) |
| 190 | extern int backlight_register_notifier(struct notifier_block *nb); | 422 | { |
| 191 | extern int backlight_unregister_notifier(struct notifier_block *nb); | 423 | if (backlight_is_blank(bd)) |
| 192 | extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type); | 424 | return 0; |
| 425 | else | ||
| 426 | return bd->props.brightness; | ||
| 427 | } | ||
| 428 | |||
| 429 | struct backlight_device * | ||
| 430 | backlight_device_register(const char *name, struct device *dev, void *devdata, | ||
| 431 | const struct backlight_ops *ops, | ||
| 432 | const struct backlight_properties *props); | ||
| 433 | struct backlight_device * | ||
| 434 | devm_backlight_device_register(struct device *dev, const char *name, | ||
| 435 | struct device *parent, void *devdata, | ||
| 436 | const struct backlight_ops *ops, | ||
| 437 | const struct backlight_properties *props); | ||
| 438 | void backlight_device_unregister(struct backlight_device *bd); | ||
| 439 | void devm_backlight_device_unregister(struct device *dev, | ||
| 440 | struct backlight_device *bd); | ||
| 441 | void backlight_force_update(struct backlight_device *bd, | ||
| 442 | enum backlight_update_reason reason); | ||
| 443 | int backlight_register_notifier(struct notifier_block *nb); | ||
| 444 | int backlight_unregister_notifier(struct notifier_block *nb); | ||
| 193 | struct backlight_device *backlight_device_get_by_name(const char *name); | 445 | struct backlight_device *backlight_device_get_by_name(const char *name); |
| 194 | extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness); | 446 | struct backlight_device *backlight_device_get_by_type(enum backlight_type type); |
| 447 | int backlight_device_set_brightness(struct backlight_device *bd, | ||
| 448 | unsigned long brightness); | ||
| 195 | 449 | ||
| 196 | #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) | 450 | #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) |
| 197 | 451 | ||
| 452 | /** | ||
| 453 | * bl_get_data - access devdata | ||
| 454 | * @bl_dev: pointer to backlight device | ||
| 455 | * | ||
| 456 | * When a backlight device is registered the driver has the possibility | ||
| 457 | * to supply a void * devdata. bl_get_data() return a pointer to the | ||
| 458 | * devdata. | ||
| 459 | * | ||
| 460 | * RETURNS: | ||
| 461 | * | ||
| 462 | * pointer to devdata stored while registering the backlight device. | ||
| 463 | */ | ||
| 198 | static inline void * bl_get_data(struct backlight_device *bl_dev) | 464 | static inline void * bl_get_data(struct backlight_device *bl_dev) |
| 199 | { | 465 | { |
| 200 | return dev_get_drvdata(&bl_dev->dev); | 466 | return dev_get_drvdata(&bl_dev->dev); |
| 201 | } | 467 | } |
| 202 | 468 | ||
| 203 | struct generic_bl_info { | ||
| 204 | const char *name; | ||
| 205 | int max_intensity; | ||
| 206 | int default_intensity; | ||
| 207 | int limit_mask; | ||
| 208 | void (*set_bl_intensity)(int intensity); | ||
| 209 | void (*kick_battery)(void); | ||
| 210 | }; | ||
| 211 | |||
| 212 | #ifdef CONFIG_OF | 469 | #ifdef CONFIG_OF |
| 213 | struct backlight_device *of_find_backlight_by_node(struct device_node *node); | 470 | struct backlight_device *of_find_backlight_by_node(struct device_node *node); |
| 214 | #else | 471 | #else |
| @@ -220,14 +477,8 @@ of_find_backlight_by_node(struct device_node *node) · 5 unmodified lines | |||
| 220 | #endif | 477 | #endif |
| 221 | 478 | ||
| 222 | #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) | 479 | #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) |
| 223 | struct backlight_device *of_find_backlight(struct device *dev); | ||
| 224 | struct backlight_device *devm_of_find_backlight(struct device *dev); | 480 | struct backlight_device *devm_of_find_backlight(struct device *dev); |
| 225 | #else | 481 | #else |
| 226 | static inline struct backlight_device *of_find_backlight(struct device *dev) | ||
| 227 | { | ||
| 228 | return NULL; | ||
| 229 | } | ||
| 230 | |||
| 231 | static inline struct backlight_device * | 482 | static inline struct backlight_device * |
| 232 | devm_of_find_backlight(struct device *dev) | 483 | devm_of_find_backlight(struct device *dev) |
| 233 | { | 484 | { |
| @@ -9,11 +9,9 @@ · 8 unmodified lines | |||
| 9 | #ifndef _SKY81452_H | 9 | #ifndef _SKY81452_H |
| 10 | #define _SKY81452_H | 10 | #define _SKY81452_H |
| 11 | 11 | ||
| 12 | #include <linux/platform_data/sky81452-backlight.h> | ||
| 13 | #include <linux/regulator/machine.h> | 12 | #include <linux/regulator/machine.h> |
| 14 | 13 | ||
| 15 | struct sky81452_platform_data { | 14 | struct sky81452_platform_data { |
| 16 | struct sky81452_bl_platform_data *bl_pdata; | ||
| 17 | struct regulator_init_data *regulator_init_data; | 15 | struct regulator_init_data *regulator_init_data; |
| 18 | }; | 16 | }; |
| 19 | 17 | ||
| @@ -1,35 +0,0 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ | ||
| 2 | /* | ||
| 3 | * sky81452.h SKY81452 backlight driver | ||
| 4 | * | ||
| 5 | * Copyright 2014 Skyworks Solutions Inc. | ||
| 6 | * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com> | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef _SKY81452_BACKLIGHT_H | ||
| 10 | #define _SKY81452_BACKLIGHT_H | ||
| 11 | |||
| 12 | /** | ||
| 13 | * struct sky81452_platform_data | ||
| 14 | * @name: backlight driver name. | ||
| 15 | If it is not defined, default name is lcd-backlight. | ||
| 16 | * @gpio_enable:GPIO number which control EN pin | ||
| 17 | * @enable: Enable mask for current sink channel 1, 2, 3, 4, 5 and 6. | ||
| 18 | * @ignore_pwm: true if DPWMI should be ignored. | ||
| 19 | * @dpwm_mode: true is DPWM dimming mode, otherwise Analog dimming mode. | ||
| 20 | * @phase_shift:true is phase shift mode. | ||
| 21 | * @short_detecion_threshold: It should be one of 4, 5, 6 and 7V. | ||
| 22 | * @boost_current_limit: It should be one of 2300, 2750mA. | ||
| 23 | */ | ||
| 24 | struct sky81452_bl_platform_data { | ||
| 25 | const char *name; | ||
| 26 | int gpio_enable; | ||
| 27 | unsigned int enable; | ||
| 28 | bool ignore_pwm; | ||
| 29 | bool dpwm_mode; | ||
| 30 | bool phase_shift; | ||
| 31 | unsigned int short_detection_threshold; | ||
| 32 | unsigned int boost_current_limit; | ||
| 33 | }; | ||
| 34 | |||
| 35 | #endif | ||