Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

backlight: backlight: Add overview and update existing doc

Add overview chapter to backlight.c.

Update existing kernel-doc to follow a more consistent style and drop
kernel-doc for deprecated functions.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Sam Ravnborg and committed by
Lee Jones
a1230eb2 9c4aa311

+97 -41
+97 -41
drivers/video/backlight/backlight.c
··· 22 22 #include <asm/backlight.h> 23 23 #endif 24 24 25 + /** 26 + * DOC: overview 27 + * 28 + * The backlight core supports implementing backlight drivers. 29 + * 30 + * A backlight driver registers a driver using 31 + * devm_backlight_device_register(). The properties of the backlight 32 + * driver such as type and max_brightness must be specified. 33 + * When the core detect changes in for example brightness or power state 34 + * the update_status() operation is called. The backlight driver shall 35 + * implement this operation and use it to adjust backlight. 36 + * 37 + * Several sysfs attributes are provided by the backlight core:: 38 + * 39 + * - brightness R/W, set the requested brightness level 40 + * - actual_brightness RO, the brightness level used by the HW 41 + * - max_brightness RO, the maximum brightness level supported 42 + * 43 + * See Documentation/ABI/stable/sysfs-class-backlight for the full list. 44 + * 45 + * The backlight can be adjusted using the sysfs interface, and 46 + * the backlight driver may also support adjusting backlight using 47 + * a hot-key or some other platform or firmware specific way. 48 + * 49 + * The driver must implement the get_brightness() operation if 50 + * the HW do not support all the levels that can be specified in 51 + * brightness, thus providing user-space access to the actual level 52 + * via the actual_brightness attribute. 53 + * 54 + * When the backlight changes this is reported to user-space using 55 + * an uevent connected to the actual_brightness attribute. 56 + * When brightness is set by platform specific means, for example 57 + * a hot-key to adjust backlight, the driver must notify the backlight 58 + * core that brightness has changed using backlight_force_update(). 59 + * 60 + * The backlight driver core receives notifications from fbdev and 61 + * if the event is FB_EVENT_BLANK and if the value of blank, from the 62 + * FBIOBLANK ioctrl, results in a change in the backlight state the 63 + * update_status() operation is called. 64 + */ 65 + 25 66 static struct list_head backlight_dev_list; 26 67 static struct mutex backlight_dev_list_mutex; 27 68 static struct blocking_notifier_head backlight_notifier; ··· 81 40 82 41 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ 83 42 defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)) 84 - /* This callback gets called when something important happens inside a 85 - * framebuffer driver. We're looking if that important event is blanking, 86 - * and if it is and necessary, we're switching backlight power as well ... 43 + /* 44 + * fb_notifier_callback 45 + * 46 + * This callback gets called when something important happens inside a 47 + * framebuffer driver. The backlight core only cares about FB_BLANK_UNBLANK 48 + * which is reported to the driver using backlight_update_status() 49 + * as a state change. 50 + * 51 + * There may be several fbdev's connected to the backlight device, 52 + * in which case they are kept track of. A state change is only reported 53 + * if there is a change in backlight for the specified fbdev. 87 54 */ 88 55 static int fb_notifier_callback(struct notifier_block *self, 89 56 unsigned long event, void *data) ··· 373 324 * @reason: reason for update 374 325 * 375 326 * Updates the internal state of the backlight in response to a hardware event, 376 - * and generate a uevent to notify userspace 327 + * and generates an uevent to notify userspace. A backlight driver shall call 328 + * backlight_force_update() when the backlight is changed using, for example, 329 + * a hot-key. The updated brightness is read using get_brightness() and the 330 + * brightness value is reported using an uevent. 377 331 */ 378 332 void backlight_force_update(struct backlight_device *bd, 379 333 enum backlight_update_reason reason) ··· 389 337 } 390 338 EXPORT_SYMBOL(backlight_force_update); 391 339 392 - /** 393 - * backlight_device_register - create and register a new object of 394 - * backlight_device class. 395 - * @name: the name of the new object(must be the same as the name of the 396 - * respective framebuffer device). 397 - * @parent: a pointer to the parent device 398 - * @devdata: an optional pointer to be stored for private driver use. The 399 - * methods may retrieve it by using bl_get_data(bd). 400 - * @ops: the backlight operations structure. 401 - * @props: pointer to backlight's properties structure. 402 - * 403 - * Creates and registers new backlight device. Returns either an 404 - * ERR_PTR() or a pointer to the newly allocated device. 405 - */ 340 + /* deprecated - use devm_backlight_device_register() */ 406 341 struct backlight_device *backlight_device_register(const char *name, 407 342 struct device *parent, void *devdata, const struct backlight_ops *ops, 408 343 const struct backlight_properties *props) ··· 456 417 } 457 418 EXPORT_SYMBOL(backlight_device_register); 458 419 420 + /** backlight_device_get_by_type - find first backlight device of a type 421 + * @type: the type of backlight device 422 + * 423 + * Look up the first backlight device of the specified type 424 + * 425 + * RETURNS: 426 + * 427 + * Pointer to backlight device if any was found. Otherwise NULL. 428 + */ 459 429 struct backlight_device *backlight_device_get_by_type(enum backlight_type type) 460 430 { 461 431 bool found = false; ··· 504 456 } 505 457 EXPORT_SYMBOL(backlight_device_get_by_name); 506 458 507 - /** 508 - * backlight_device_unregister - unregisters a backlight device object. 509 - * @bd: the backlight device object to be unregistered and freed. 510 - * 511 - * Unregisters a previously registered via backlight_device_register object. 512 - */ 459 + /* deprecated - use devm_backlight_device_unregister() */ 513 460 void backlight_device_unregister(struct backlight_device *bd) 514 461 { 515 462 if (!bd) ··· 552 509 * backlight_register_notifier - get notified of backlight (un)registration 553 510 * @nb: notifier block with the notifier to call on backlight (un)registration 554 511 * 555 - * @return 0 on success, otherwise a negative error code 556 - * 557 512 * Register a notifier to get notified when backlight devices get registered 558 513 * or unregistered. 514 + * 515 + * RETURNS: 516 + * 517 + * 0 on success, otherwise a negative error code 559 518 */ 560 519 int backlight_register_notifier(struct notifier_block *nb) 561 520 { ··· 569 524 * backlight_unregister_notifier - unregister a backlight notifier 570 525 * @nb: notifier block to unregister 571 526 * 572 - * @return 0 on success, otherwise a negative error code 573 - * 574 527 * Register a notifier to get notified when backlight devices get registered 575 528 * or unregistered. 529 + * 530 + * RETURNS: 531 + * 532 + * 0 on success, otherwise a negative error code 576 533 */ 577 534 int backlight_unregister_notifier(struct notifier_block *nb) 578 535 { ··· 583 536 EXPORT_SYMBOL(backlight_unregister_notifier); 584 537 585 538 /** 586 - * devm_backlight_device_register - resource managed backlight_device_register() 539 + * devm_backlight_device_register - register a new backlight device 587 540 * @dev: the device to register 588 541 * @name: the name of the device 589 - * @parent: a pointer to the parent device 542 + * @parent: a pointer to the parent device (often the same as @dev) 590 543 * @devdata: an optional pointer to be stored for private driver use 591 544 * @ops: the backlight operations structure 592 545 * @props: the backlight properties 593 546 * 594 - * @return a struct backlight on success, or an ERR_PTR on error 547 + * Creates and registers new backlight device. When a backlight device 548 + * is registered the configuration must be specified in the @props 549 + * parameter. See description of &backlight_properties. 595 550 * 596 - * Managed backlight_device_register(). The backlight_device returned 597 - * from this function are automatically freed on driver detach. 598 - * See backlight_device_register() for more information. 551 + * RETURNS: 552 + * 553 + * struct backlight on success, or an ERR_PTR on error 599 554 */ 600 555 struct backlight_device *devm_backlight_device_register(struct device *dev, 601 556 const char *name, struct device *parent, void *devdata, ··· 625 576 EXPORT_SYMBOL(devm_backlight_device_register); 626 577 627 578 /** 628 - * devm_backlight_device_unregister - resource managed backlight_device_unregister() 579 + * devm_backlight_device_unregister - unregister backlight device 629 580 * @dev: the device to unregister 630 581 * @bd: the backlight device to unregister 631 582 * 632 - * Deallocated a backlight allocated with devm_backlight_device_register(). 583 + * Deallocates a backlight allocated with devm_backlight_device_register(). 633 584 * Normally this function will not need to be called and the resource management 634 - * code will ensure that the resource is freed. 585 + * code will ensure that the resources are freed. 635 586 */ 636 587 void devm_backlight_device_unregister(struct device *dev, 637 588 struct backlight_device *bd) ··· 722 673 } 723 674 724 675 /** 725 - * devm_of_find_backlight - Resource-managed of_find_backlight() 726 - * @dev: Device 676 + * devm_of_find_backlight - find backlight for a device 677 + * @dev: the device 727 678 * 728 - * Device managed version of of_find_backlight(). 729 - * The reference on the backlight device is automatically 679 + * This function looks for a property named 'backlight' on the DT node 680 + * connected to @dev and looks up the backlight device. The lookup is 681 + * device managed so the reference to the backlight device is automatically 730 682 * dropped on driver detach. 683 + * 684 + * RETURNS: 685 + * 686 + * A pointer to the backlight device if found. 687 + * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight 688 + * device is found. NULL if there's no backlight property. 731 689 */ 732 690 struct backlight_device *devm_of_find_backlight(struct device *dev) 733 691 {