[PATCH] Rewritten backlight infrastructure for portable Apple computers
This patch contains a total rewrite of the backlight infrastructure for portable Apple computers. Backward compatibility is retained. A sysfs interface allows userland to control the brightness with more steps than before. Userland is allowed to upload a brightness curve for different monitors, similar to Mac OS X. [akpm@osdl.org: add needed exports] Signed-off-by: Michael Hanselmann <linux-kernel@hansmi.ch> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
17660bdd5c
commit
5474c120aa
@@ -2,30 +2,30 @@
|
||||
* Routines for handling backlight control on PowerBooks
|
||||
*
|
||||
* For now, implementation resides in
|
||||
* arch/powerpc/platforms/powermac/pmac_support.c
|
||||
* arch/powerpc/platforms/powermac/backlight.c
|
||||
*
|
||||
*/
|
||||
#ifndef __ASM_POWERPC_BACKLIGHT_H
|
||||
#define __ASM_POWERPC_BACKLIGHT_H
|
||||
#ifdef __KERNEL__
|
||||
|
||||
/* Abstract values */
|
||||
#define BACKLIGHT_OFF 0
|
||||
#define BACKLIGHT_MIN 1
|
||||
#define BACKLIGHT_MAX 0xf
|
||||
#include <linux/fb.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
struct backlight_controller {
|
||||
int (*set_enable)(int enable, int level, void *data);
|
||||
int (*set_level)(int level, void *data);
|
||||
};
|
||||
/* For locking instructions, see the implementation file */
|
||||
extern struct backlight_device *pmac_backlight;
|
||||
extern struct mutex pmac_backlight_mutex;
|
||||
|
||||
extern void register_backlight_controller(struct backlight_controller *ctrler, void *data, char *type);
|
||||
extern void unregister_backlight_controller(struct backlight_controller *ctrler, void *data);
|
||||
extern void pmac_backlight_calc_curve(struct fb_info*);
|
||||
extern int pmac_backlight_curve_lookup(struct fb_info *info, int value);
|
||||
|
||||
extern int set_backlight_enable(int enable);
|
||||
extern int get_backlight_enable(void);
|
||||
extern int set_backlight_level(int level);
|
||||
extern int get_backlight_level(void);
|
||||
extern int pmac_has_backlight_type(const char *type);
|
||||
|
||||
extern void pmac_backlight_key_up(void);
|
||||
extern void pmac_backlight_key_down(void);
|
||||
|
||||
extern int pmac_backlight_set_legacy_brightness(int brightness);
|
||||
extern int pmac_backlight_get_legacy_brightness(void);
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _LINUX_FB_H
|
||||
#define _LINUX_FB_H
|
||||
|
||||
#include <linux/backlight.h>
|
||||
#include <asm/types.h>
|
||||
|
||||
/* Definitions of frame buffers */
|
||||
@@ -366,6 +367,12 @@ struct fb_cursor {
|
||||
struct fb_image image; /* Cursor image */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_FB_BACKLIGHT
|
||||
/* Settings for the generic backlight code */
|
||||
#define FB_BACKLIGHT_LEVELS 128
|
||||
#define FB_BACKLIGHT_MAX 0xFF
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#include <linux/fs.h>
|
||||
@@ -756,6 +763,21 @@ struct fb_info {
|
||||
struct fb_cmap cmap; /* Current cmap */
|
||||
struct list_head modelist; /* mode list */
|
||||
struct fb_videomode *mode; /* current mode */
|
||||
|
||||
#ifdef CONFIG_FB_BACKLIGHT
|
||||
/* Lock ordering:
|
||||
* bl_mutex (protects bl_dev and bl_curve)
|
||||
* bl_dev->sem (backlight class)
|
||||
*/
|
||||
struct mutex bl_mutex;
|
||||
|
||||
/* assigned backlight device */
|
||||
struct backlight_device *bl_dev;
|
||||
|
||||
/* Backlight level curve */
|
||||
u8 bl_curve[FB_BACKLIGHT_LEVELS];
|
||||
#endif
|
||||
|
||||
struct fb_ops *fbops;
|
||||
struct device *device;
|
||||
struct class_device *class_device; /* sysfs per device attrs */
|
||||
@@ -895,6 +917,7 @@ extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
|
||||
extern void framebuffer_release(struct fb_info *info);
|
||||
extern int fb_init_class_device(struct fb_info *fb_info);
|
||||
extern void fb_cleanup_class_device(struct fb_info *head);
|
||||
extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max);
|
||||
|
||||
/* drivers/video/fbmon.c */
|
||||
#define FB_MAXTIMINGS 0
|
||||
|
||||
@@ -230,4 +230,8 @@ extern int pmu_battery_count;
|
||||
extern struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES];
|
||||
extern unsigned int pmu_power_flags;
|
||||
|
||||
/* Backlight */
|
||||
extern int disable_kernel_backlight;
|
||||
extern void pmu_backlight_init(struct device_node*);
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
Reference in New Issue
Block a user