Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=3777f7748a5d10222a55ce88f753a19b16c17032
Commit:     3777f7748a5d10222a55ce88f753a19b16c17032
Parent:     03f5b2cee6cabd0400b9f89956c373a0b5d3802a
Author:     Russell King <[EMAIL PROTECTED]>
AuthorDate: Thu Nov 8 11:22:48 2007 +0000
Committer:  Russell King <[EMAIL PROTECTED]>
CommitDate: Sat Jan 26 15:07:50 2008 +0000

    [ARM] pxa: mainstone: update backlight to use the backlight infrastructure
    
    Linux has framebuffer backlight support infrastructure which should
    be used to expose backlight attributes.  Mainstone should use it.
    
    Signed-off-by: Russell King <[EMAIL PROTECTED]>
---
 arch/arm/mach-pxa/mainstone.c |   60 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 41d8c6c..a5db00c 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -23,6 +23,7 @@
 #include <linux/ioport.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/backlight.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -263,21 +264,60 @@ static struct platform_device mst_flash_device[2] = {
        },
 };
 
-static void mainstone_backlight_power(int on)
+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
+static int mainstone_backlight_update_status(struct backlight_device *bl)
 {
-       if (on) {
+       int brightness = bl->props.brightness;
+
+       if (bl->props.power != FB_BLANK_UNBLANK ||
+           bl->props.fb_blank != FB_BLANK_UNBLANK)
+               brightness = 0;
+
+       if (brightness != 0) {
                pxa_gpio_mode(GPIO16_PWM0_MD);
                pxa_set_cken(CKEN_PWM0, 1);
-               PWM_CTRL0 = 0;
-               PWM_PWDUTY0 = 0x3ff;
-               PWM_PERVAL0 = 0x3ff;
-       } else {
-               PWM_CTRL0 = 0;
-               PWM_PWDUTY0 = 0x0;
-               PWM_PERVAL0 = 0x3FF;
+       }
+       PWM_CTRL0 = 0;
+       PWM_PWDUTY0 = brightness;
+       PWM_PERVAL0 = bl->props.max_brightness;
+       if (brightness == 0)
                pxa_set_cken(CKEN_PWM0, 0);
+       return 0; /* pointless return value */
+}
+
+static int mainstone_backlight_get_brightness(struct backlight_device *bl)
+{
+       return PWM_PWDUTY0;
+}
+
+static /*const*/ struct backlight_ops mainstone_backlight_ops = {
+       .update_status  = mainstone_backlight_update_status,
+       .get_brightness = mainstone_backlight_get_brightness,
+};
+
+static void __init mainstone_backlight_register(void)
+{
+       struct backlight_device *bl;
+
+       bl = backlight_device_register("mainstone-bl", &pxa_device_fb.dev,
+                                      NULL, &mainstone_backlight_ops);
+       if (IS_ERR(bl)) {
+               printk(KERN_ERR "mainstone: unable to register backlight: 
%ld\n",
+                      PTR_ERR(bl));
+               return;
        }
+
+       /*
+        * broken design - register-then-setup interfaces are
+        * utterly broken by definition.
+        */
+       bl->props.max_brightness = 1023;
+       bl->props.brightness = 1023;
+       backlight_update_status(bl);
 }
+#else
+#define mainstone_backlight_register() do { } while (0)
+#endif
 
 static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
        .pixclock               = 50000,
@@ -311,7 +351,6 @@ static struct pxafb_mach_info mainstone_pxafb_info = {
        .num_modes              = 1,
        .lccr0                  = LCCR0_Act,
        .lccr3                  = LCCR3_PCP,
-       .pxafb_backlight_power  = mainstone_backlight_power,
 };
 
 static int mainstone_mci_init(struct device *dev, irq_handler_t 
mstone_detect_int, void *data)
@@ -473,6 +512,7 @@ static void __init mainstone_init(void)
                mainstone_pxafb_info.modes = &toshiba_ltm035a776c_mode;
 
        set_pxa_fb_info(&mainstone_pxafb_info);
+       mainstone_backlight_register();
 
        pxa_set_mci_info(&mainstone_mci_platform_data);
        pxa_set_ficp_info(&mainstone_ficp_platform_data);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to