]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] backlight: corgi_bl: Generalise to support other Sharp SL hardware
authorRichard Purdie <rpurdie@rpsys.net>
Fri, 31 Mar 2006 10:31:51 +0000 (02:31 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 31 Mar 2006 20:19:00 +0000 (12:19 -0800)
Generalise the Corgi backlight driver by moving the default intensity and
limit mask settings into the platform specific data structure.  This enables
the driver to support other Zaurus hardware, specifically the SL-6000x (Tosa)
model.

Also change the spinlock to a mutex (the spinlock is overkill).

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/arm/mach-pxa/corgi.c
arch/arm/mach-pxa/spitz.c
drivers/video/backlight/Kconfig
drivers/video/backlight/corgi_bl.c
include/asm-arm/arch-pxa/sharpsl.h

index 99604a544629dfa75907bb4ddba00ad330d1b3b2..d6d7260363613a2a17afaa64c73aba6d3591694c 100644 (file)
@@ -141,6 +141,8 @@ struct corgissp_machinfo corgi_ssp_machinfo = {
  */
 static struct corgibl_machinfo corgi_bl_machinfo = {
        .max_intensity = 0x2f,
+       .default_intensity = 0x1f,
+       .limit_mask = 0x0b,
        .set_bl_intensity = corgi_bl_set_intensity,
 };
 
index ebe4730533920d9ba3ac570aeb8221067ec8d7ec..19b372df544a094a086c05cc3e438c9fb7a606b6 100644 (file)
@@ -220,6 +220,8 @@ struct corgissp_machinfo spitz_ssp_machinfo = {
  * Spitz Backlight Device
  */
 static struct corgibl_machinfo spitz_bl_machinfo = {
+       .default_intensity = 0x1f,
+       .limit_mask = 0x0b,
        .max_intensity = 0x2f,
 };
 
index 9d996f2c10d5775099629340901c03bbac95774d..b895eaaa73fd86f6366a0330d6e491d413188188 100644 (file)
@@ -43,11 +43,11 @@ config LCD_DEVICE
        default y
 
 config BACKLIGHT_CORGI
-       tristate "Sharp Corgi Backlight Driver (SL-C7xx Series)"
+       tristate "Sharp Corgi Backlight Driver (SL Series)"
        depends on BACKLIGHT_DEVICE && PXA_SHARPSL
        default y
        help
-         If you have a Sharp Zaurus SL-C7xx, say y to enable the
+         If you have a Sharp Zaurus SL-C7xx, SL-Cxx00 or SL-6000x say y to enable the
          backlight driver.
 
 config BACKLIGHT_HP680
index f86213b4a8fb07476bacdd0a10aaff0b23f01770..2ebbfd95145fd34587cbd715b2d59048c283abfb 100644 (file)
@@ -1,7 +1,7 @@
 /*
- *  Backlight Driver for Sharp Corgi
+ *  Backlight Driver for Sharp Zaurus Handhelds (various models)
  *
- *  Copyright (c) 2004-2005 Richard Purdie
+ *  Copyright (c) 2004-2006 Richard Purdie
  *
  *  Based on Sharp's 2.4 Backlight Driver
  *
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/spinlock.h>
+#include <linux/mutex.h>
 #include <linux/fb.h>
 #include <linux/backlight.h>
-
 #include <asm/arch/sharpsl.h>
 #include <asm/hardware/sharpsl_pm.h>
 
-#define CORGI_DEFAULT_INTENSITY                0x1f
-#define CORGI_LIMIT_MASK               0x0b
-
 static int corgibl_intensity;
-static void (*corgibl_mach_set_intensity)(int intensity);
-static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_MUTEX(bl_mutex);
 static struct backlight_properties corgibl_data;
 static struct backlight_device *corgi_backlight_device;
+static struct corgibl_machinfo *bl_machinfo;
 
 static unsigned long corgibl_flags;
 #define CORGIBL_SUSPENDED     0x01
@@ -37,7 +33,6 @@ static unsigned long corgibl_flags;
 
 static int corgibl_send_intensity(struct backlight_device *bd)
 {
-       unsigned long flags;
        void (*corgi_kick_batt)(void);
        int intensity = bd->props->brightness;
 
@@ -48,13 +43,11 @@ static int corgibl_send_intensity(struct backlight_device *bd)
        if (corgibl_flags & CORGIBL_SUSPENDED)
                intensity = 0;
        if (corgibl_flags & CORGIBL_BATTLOW)
-               intensity &= CORGI_LIMIT_MASK;
-
-       spin_lock_irqsave(&bl_lock, flags);
-
-       corgibl_mach_set_intensity(intensity);
+               intensity &= bl_machinfo->limit_mask;
 
-       spin_unlock_irqrestore(&bl_lock, flags);
+       mutex_lock(&bl_mutex);
+       bl_machinfo->set_bl_intensity(intensity);
+       mutex_unlock(&bl_mutex);
 
        corgibl_intensity = intensity;
 
@@ -122,8 +115,10 @@ static int __init corgibl_probe(struct platform_device *pdev)
 {
        struct corgibl_machinfo *machinfo = pdev->dev.platform_data;
 
+       bl_machinfo = machinfo;
        corgibl_data.max_brightness = machinfo->max_intensity;
-       corgibl_mach_set_intensity = machinfo->set_bl_intensity;
+       if (!machinfo->limit_mask)
+               machinfo->limit_mask = -1;
 
        corgi_backlight_device = backlight_device_register ("corgi-bl",
                NULL, &corgibl_data);
@@ -131,7 +126,7 @@ static int __init corgibl_probe(struct platform_device *pdev)
                return PTR_ERR (corgi_backlight_device);
 
        corgibl_data.power = FB_BLANK_UNBLANK;
-       corgibl_data.brightness = CORGI_DEFAULT_INTENSITY;
+       corgibl_data.brightness = machinfo->default_intensity;
        corgibl_send_intensity(corgi_backlight_device);
 
        printk("Corgi Backlight Driver Initialized.\n");
index 0b43495d24b4c38c857754775a355795dc990c50..94cb4982af82e473d7a6985a53c4e8c9dcabd2f2 100644 (file)
@@ -27,6 +27,8 @@ struct corgits_machinfo {
  */
 struct corgibl_machinfo {
        int max_intensity;
+       int default_intensity;
+       int limit_mask;
        void (*set_bl_intensity)(int intensity);
 };
 extern void corgibl_limit_intensity(int limit);