diff options
| author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-20 13:17:32 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-20 13:17:32 -0500 |
| commit | a5527c6a586537c1af7ae6db30bb444ee4abdfe8 (patch) | |
| tree | f0682de5c461c270f5f58b7304fd5ea5b5d6fb38 /include | |
| parent | 4afffe5eabc4005674a1ef4f4c96f1ae9f4a979b (diff) | |
| parent | 8f27489d1105c2386e6ed71c35e74e0e69603cbc (diff) | |
Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight
* 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight:
backlight: Remove bogus SYSFS dependency
backlight: simplify corgi_bl locking
backlight: Separate backlight properties from backlight ops pointers
backlight: Clean up pmac_backlight handling
backlight: Improve backlight selection for fbdev drivers
backlight: Rework backlight/fb interaction simplifying, lots
backlight: Remove unneeded backlight update_status calls
backlight: Remove uneeded update_status call from chipsfb.c
backlight/fbcon: Add FB_EVENT_CONBLANK
backlight: Fix Kconfig entries
backlight: Remove uneeded nvidia set_power calls
backlight: Convert semaphore -> mutex
backlight: Fix external uses of backlight internal semaphore
backlight: Minor code cleanups for hp680_bl.c
backlight: Minor code cleanups for corgi_bl.c
backlight: Remove excessive (un)likelys
backlight: Remove unneeded owner field
backlight: Fix error handling
backlight: Add Frontpath ProGear HX1050+ driver
backlight: Add maintainer entry
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/backlight.h | 50 | ||||
| -rw-r--r-- | include/linux/fb.h | 13 | ||||
| -rw-r--r-- | include/linux/lcd.h | 45 |
3 files changed, 81 insertions, 27 deletions
diff --git a/include/linux/backlight.h b/include/linux/backlight.h index a5cf1beacb44..1023ba0d6e55 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h | |||
| @@ -9,17 +9,28 @@ | |||
| 9 | #define _LINUX_BACKLIGHT_H | 9 | #define _LINUX_BACKLIGHT_H |
| 10 | 10 | ||
| 11 | #include <linux/device.h> | 11 | #include <linux/device.h> |
| 12 | #include <linux/mutex.h> | ||
| 12 | #include <linux/notifier.h> | 13 | #include <linux/notifier.h> |
| 13 | 14 | ||
| 15 | /* Notes on locking: | ||
| 16 | * | ||
| 17 | * backlight_device->ops_lock is an internal backlight lock protecting the | ||
| 18 | * ops pointer and no code outside the core should need to touch it. | ||
| 19 | * | ||
| 20 | * Access to update_status() is serialised by the update_lock mutex since | ||
| 21 | * most drivers seem to need this and historically get it wrong. | ||
| 22 | * | ||
| 23 | * Most drivers don't need locking on their get_brightness() method. | ||
| 24 | * If yours does, you need to implement it in the driver. You can use the | ||
| 25 | * update_lock mutex if appropriate. | ||
| 26 | * | ||
| 27 | * Any other use of the locks below is probably wrong. | ||
| 28 | */ | ||
| 29 | |||
| 14 | struct backlight_device; | 30 | struct backlight_device; |
| 15 | struct fb_info; | 31 | struct fb_info; |
| 16 | 32 | ||
| 17 | /* This structure defines all the properties of a backlight | 33 | struct backlight_ops { |
| 18 | (usually attached to a LCD). */ | ||
| 19 | struct backlight_properties { | ||
| 20 | /* Owner module */ | ||
| 21 | struct module *owner; | ||
| 22 | |||
| 23 | /* Notify the backlight driver some property has changed */ | 34 | /* Notify the backlight driver some property has changed */ |
| 24 | int (*update_status)(struct backlight_device *); | 35 | int (*update_status)(struct backlight_device *); |
| 25 | /* Return the current backlight brightness (accounting for power, | 36 | /* Return the current backlight brightness (accounting for power, |
| @@ -28,7 +39,10 @@ struct backlight_properties { | |||
| 28 | /* Check if given framebuffer device is the one bound to this backlight; | 39 | /* Check if given framebuffer device is the one bound to this backlight; |
| 29 | return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ | 40 | return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ |
| 30 | int (*check_fb)(struct fb_info *); | 41 | int (*check_fb)(struct fb_info *); |
| 42 | }; | ||
| 31 | 43 | ||
| 44 | /* This structure defines all the properties of a backlight */ | ||
| 45 | struct backlight_properties { | ||
| 32 | /* Current User requested brightness (0 - max_brightness) */ | 46 | /* Current User requested brightness (0 - max_brightness) */ |
| 33 | int brightness; | 47 | int brightness; |
| 34 | /* Maximal value for brightness (read-only) */ | 48 | /* Maximal value for brightness (read-only) */ |
| @@ -41,20 +55,34 @@ struct backlight_properties { | |||
| 41 | }; | 55 | }; |
| 42 | 56 | ||
| 43 | struct backlight_device { | 57 | struct backlight_device { |
| 44 | /* This protects the 'props' field. If 'props' is NULL, the driver that | 58 | /* Backlight properties */ |
| 59 | struct backlight_properties props; | ||
| 60 | |||
| 61 | /* Serialise access to update_status method */ | ||
| 62 | struct mutex update_lock; | ||
| 63 | |||
| 64 | /* This protects the 'ops' field. If 'ops' is NULL, the driver that | ||
| 45 | registered this device has been unloaded, and if class_get_devdata() | 65 | registered this device has been unloaded, and if class_get_devdata() |
| 46 | points to something in the body of that driver, it is also invalid. */ | 66 | points to something in the body of that driver, it is also invalid. */ |
| 47 | struct semaphore sem; | 67 | struct mutex ops_lock; |
| 48 | /* If this is NULL, the backing module is unloaded */ | 68 | struct backlight_ops *ops; |
| 49 | struct backlight_properties *props; | 69 | |
| 50 | /* The framebuffer notifier block */ | 70 | /* The framebuffer notifier block */ |
| 51 | struct notifier_block fb_notif; | 71 | struct notifier_block fb_notif; |
| 52 | /* The class device structure */ | 72 | /* The class device structure */ |
| 53 | struct class_device class_dev; | 73 | struct class_device class_dev; |
| 54 | }; | 74 | }; |
| 55 | 75 | ||
| 76 | static inline void backlight_update_status(struct backlight_device *bd) | ||
| 77 | { | ||
| 78 | mutex_lock(&bd->update_lock); | ||
| 79 | if (bd->ops && bd->ops->update_status) | ||
| 80 | bd->ops->update_status(bd); | ||
| 81 | mutex_unlock(&bd->update_lock); | ||
| 82 | } | ||
| 83 | |||
| 56 | extern struct backlight_device *backlight_device_register(const char *name, | 84 | extern struct backlight_device *backlight_device_register(const char *name, |
| 57 | struct device *dev,void *devdata,struct backlight_properties *bp); | 85 | struct device *dev, void *devdata, struct backlight_ops *ops); |
| 58 | extern void backlight_device_unregister(struct backlight_device *bd); | 86 | extern void backlight_device_unregister(struct backlight_device *bd); |
| 59 | 87 | ||
| 60 | #define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev) | 88 | #define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev) |
diff --git a/include/linux/fb.h b/include/linux/fb.h index a78e25683f82..be913ec87169 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h | |||
| @@ -516,13 +516,15 @@ struct fb_cursor_user { | |||
| 516 | #define FB_EVENT_GET_CONSOLE_MAP 0x07 | 516 | #define FB_EVENT_GET_CONSOLE_MAP 0x07 |
| 517 | /* CONSOLE-SPECIFIC: set console to framebuffer mapping */ | 517 | /* CONSOLE-SPECIFIC: set console to framebuffer mapping */ |
| 518 | #define FB_EVENT_SET_CONSOLE_MAP 0x08 | 518 | #define FB_EVENT_SET_CONSOLE_MAP 0x08 |
| 519 | /* A display blank is requested */ | 519 | /* A hardware display blank change occured */ |
| 520 | #define FB_EVENT_BLANK 0x09 | 520 | #define FB_EVENT_BLANK 0x09 |
| 521 | /* Private modelist is to be replaced */ | 521 | /* Private modelist is to be replaced */ |
| 522 | #define FB_EVENT_NEW_MODELIST 0x0A | 522 | #define FB_EVENT_NEW_MODELIST 0x0A |
| 523 | /* The resolution of the passed in fb_info about to change and | 523 | /* The resolution of the passed in fb_info about to change and |
| 524 | all vc's should be changed */ | 524 | all vc's should be changed */ |
| 525 | #define FB_EVENT_MODE_CHANGE_ALL 0x0B | 525 | #define FB_EVENT_MODE_CHANGE_ALL 0x0B |
| 526 | /* A software display blank change occured */ | ||
| 527 | #define FB_EVENT_CONBLANK 0x0C | ||
| 526 | 528 | ||
| 527 | struct fb_event { | 529 | struct fb_event { |
| 528 | struct fb_info *info; | 530 | struct fb_info *info; |
| @@ -767,16 +769,13 @@ struct fb_info { | |||
| 767 | struct fb_videomode *mode; /* current mode */ | 769 | struct fb_videomode *mode; /* current mode */ |
| 768 | 770 | ||
| 769 | #ifdef CONFIG_FB_BACKLIGHT | 771 | #ifdef CONFIG_FB_BACKLIGHT |
| 770 | /* Lock ordering: | ||
| 771 | * bl_mutex (protects bl_dev and bl_curve) | ||
| 772 | * bl_dev->sem (backlight class) | ||
| 773 | */ | ||
| 774 | struct mutex bl_mutex; | ||
| 775 | |||
| 776 | /* assigned backlight device */ | 772 | /* assigned backlight device */ |
| 773 | /* set before framebuffer registration, | ||
| 774 | remove after unregister */ | ||
| 777 | struct backlight_device *bl_dev; | 775 | struct backlight_device *bl_dev; |
| 778 | 776 | ||
| 779 | /* Backlight level curve */ | 777 | /* Backlight level curve */ |
| 778 | struct mutex bl_curve_mutex; | ||
| 780 | u8 bl_curve[FB_BACKLIGHT_LEVELS]; | 779 | u8 bl_curve[FB_BACKLIGHT_LEVELS]; |
| 781 | #endif | 780 | #endif |
| 782 | 781 | ||
diff --git a/include/linux/lcd.h b/include/linux/lcd.h index d739b2e7eac2..598793c0745b 100644 --- a/include/linux/lcd.h +++ b/include/linux/lcd.h | |||
| @@ -9,22 +9,38 @@ | |||
| 9 | #define _LINUX_LCD_H | 9 | #define _LINUX_LCD_H |
| 10 | 10 | ||
| 11 | #include <linux/device.h> | 11 | #include <linux/device.h> |
| 12 | #include <linux/mutex.h> | ||
| 12 | #include <linux/notifier.h> | 13 | #include <linux/notifier.h> |
| 13 | 14 | ||
| 15 | /* Notes on locking: | ||
| 16 | * | ||
| 17 | * lcd_device->ops_lock is an internal backlight lock protecting the ops | ||
| 18 | * field and no code outside the core should need to touch it. | ||
| 19 | * | ||
| 20 | * Access to set_power() is serialised by the update_lock mutex since | ||
| 21 | * most drivers seem to need this and historically get it wrong. | ||
| 22 | * | ||
| 23 | * Most drivers don't need locking on their get_power() method. | ||
| 24 | * If yours does, you need to implement it in the driver. You can use the | ||
| 25 | * update_lock mutex if appropriate. | ||
| 26 | * | ||
| 27 | * Any other use of the locks below is probably wrong. | ||
| 28 | */ | ||
| 29 | |||
| 14 | struct lcd_device; | 30 | struct lcd_device; |
| 15 | struct fb_info; | 31 | struct fb_info; |
| 16 | 32 | ||
| 17 | /* This structure defines all the properties of a LCD flat panel. */ | ||
| 18 | struct lcd_properties { | 33 | struct lcd_properties { |
| 19 | /* Owner module */ | 34 | /* The maximum value for contrast (read-only) */ |
| 20 | struct module *owner; | 35 | int max_contrast; |
| 36 | }; | ||
| 37 | |||
| 38 | struct lcd_ops { | ||
| 21 | /* Get the LCD panel power status (0: full on, 1..3: controller | 39 | /* Get the LCD panel power status (0: full on, 1..3: controller |
| 22 | power on, flat panel power off, 4: full off), see FB_BLANK_XXX */ | 40 | power on, flat panel power off, 4: full off), see FB_BLANK_XXX */ |
| 23 | int (*get_power)(struct lcd_device *); | 41 | int (*get_power)(struct lcd_device *); |
| 24 | /* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */ | 42 | /* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */ |
| 25 | int (*set_power)(struct lcd_device *, int power); | 43 | int (*set_power)(struct lcd_device *, int power); |
| 26 | /* The maximum value for contrast (read-only) */ | ||
| 27 | int max_contrast; | ||
| 28 | /* Get the current contrast setting (0-max_contrast) */ | 44 | /* Get the current contrast setting (0-max_contrast) */ |
| 29 | int (*get_contrast)(struct lcd_device *); | 45 | int (*get_contrast)(struct lcd_device *); |
| 30 | /* Set LCD panel contrast */ | 46 | /* Set LCD panel contrast */ |
| @@ -35,20 +51,31 @@ struct lcd_properties { | |||
| 35 | }; | 51 | }; |
| 36 | 52 | ||
| 37 | struct lcd_device { | 53 | struct lcd_device { |
| 38 | /* This protects the 'props' field. If 'props' is NULL, the driver that | 54 | struct lcd_properties props; |
| 55 | /* This protects the 'ops' field. If 'ops' is NULL, the driver that | ||
| 39 | registered this device has been unloaded, and if class_get_devdata() | 56 | registered this device has been unloaded, and if class_get_devdata() |
| 40 | points to something in the body of that driver, it is also invalid. */ | 57 | points to something in the body of that driver, it is also invalid. */ |
| 41 | struct semaphore sem; | 58 | struct mutex ops_lock; |
| 42 | /* If this is NULL, the backing module is unloaded */ | 59 | /* If this is NULL, the backing module is unloaded */ |
| 43 | struct lcd_properties *props; | 60 | struct lcd_ops *ops; |
| 61 | /* Serialise access to set_power method */ | ||
| 62 | struct mutex update_lock; | ||
| 44 | /* The framebuffer notifier block */ | 63 | /* The framebuffer notifier block */ |
| 45 | struct notifier_block fb_notif; | 64 | struct notifier_block fb_notif; |
| 46 | /* The class device structure */ | 65 | /* The class device structure */ |
| 47 | struct class_device class_dev; | 66 | struct class_device class_dev; |
| 48 | }; | 67 | }; |
| 49 | 68 | ||
| 69 | static inline void lcd_set_power(struct lcd_device *ld, int power) | ||
| 70 | { | ||
| 71 | mutex_lock(&ld->update_lock); | ||
| 72 | if (ld->ops && ld->ops->set_power) | ||
| 73 | ld->ops->set_power(ld, power); | ||
| 74 | mutex_unlock(&ld->update_lock); | ||
| 75 | } | ||
| 76 | |||
| 50 | extern struct lcd_device *lcd_device_register(const char *name, | 77 | extern struct lcd_device *lcd_device_register(const char *name, |
| 51 | void *devdata, struct lcd_properties *lp); | 78 | void *devdata, struct lcd_ops *ops); |
| 52 | extern void lcd_device_unregister(struct lcd_device *ld); | 79 | extern void lcd_device_unregister(struct lcd_device *ld); |
| 53 | 80 | ||
| 54 | #define to_lcd_device(obj) container_of(obj, struct lcd_device, class_dev) | 81 | #define to_lcd_device(obj) container_of(obj, struct lcd_device, class_dev) |
