Merge branch 'sii-m15w' into upstream
[pandora-kernel.git] / drivers / video / aty / atyfb_base.c
index 22e7206..053ff63 100644 (file)
@@ -49,7 +49,6 @@
 ******************************************************************************/
 
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
@@ -1568,7 +1567,7 @@ static int aty_enable_irq(struct atyfb_par *par, int reenable)
        u32 int_cntl;
 
        if (!test_and_set_bit(0, &par->irq_flags)) {
-               if (request_irq(par->irq, aty_irq, SA_SHIRQ, "atyfb", par)) {
+               if (request_irq(par->irq, aty_irq, IRQF_SHARED, "atyfb", par)) {
                        clear_bit(0, &par->irq_flags);
                        return -EINVAL;
                }
@@ -2130,15 +2129,14 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
 
 static struct backlight_properties aty_bl_data;
 
+/* Call with fb_info->bl_mutex held */
 static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
 {
        struct fb_info *info = pci_get_drvdata(par->pdev);
        int atylevel;
 
        /* Get and convert the value */
-       mutex_lock(&info->bl_mutex);
        atylevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL;
-       mutex_unlock(&info->bl_mutex);
 
        if (atylevel < 0)
                atylevel = 0;
@@ -2148,7 +2146,8 @@ static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
        return atylevel;
 }
 
-static int aty_bl_update_status(struct backlight_device *bd)
+/* Call with fb_info->bl_mutex held */
+static int __aty_bl_update_status(struct backlight_device *bd)
 {
        struct atyfb_par *par = class_get_devdata(&bd->class_dev);
        unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
@@ -2173,6 +2172,19 @@ static int aty_bl_update_status(struct backlight_device *bd)
        return 0;
 }
 
+static int aty_bl_update_status(struct backlight_device *bd)
+{
+       struct atyfb_par *par = class_get_devdata(&bd->class_dev);
+       struct fb_info *info = pci_get_drvdata(par->pdev);
+       int ret;
+
+       mutex_lock(&info->bl_mutex);
+       ret = __aty_bl_update_status(bd);
+       mutex_unlock(&info->bl_mutex);
+
+       return ret;
+}
+
 static int aty_bl_get_brightness(struct backlight_device *bd)
 {
        return bd->props->brightness;
@@ -2185,6 +2197,16 @@ static struct backlight_properties aty_bl_data = {
        .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
 };
 
+static void aty_bl_set_power(struct fb_info *info, int power)
+{
+       mutex_lock(&info->bl_mutex);
+       up(&info->bl_dev->sem);
+       info->bl_dev->props->power = power;
+       __aty_bl_update_status(info->bl_dev);
+       down(&info->bl_dev->sem);
+       mutex_unlock(&info->bl_mutex);
+}
+
 static void aty_bl_init(struct atyfb_par *par)
 {
        struct fb_info *info = pci_get_drvdata(par->pdev);
@@ -2790,17 +2812,9 @@ static int atyfb_blank(int blank, struct fb_info *info)
        if (par->lock_blank || par->asleep)
                return 0;
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       if (machine_is(powermac) && blank > FB_BLANK_NORMAL) {
-               mutex_lock(&info->bl_mutex);
-               if (info->bl_dev) {
-                       down(&info->bl_dev->sem);
-                       info->bl_dev->props->power = FB_BLANK_POWERDOWN;
-                       info->bl_dev->props->update_status(info->bl_dev);
-                       up(&info->bl_dev->sem);
-               }
-               mutex_unlock(&info->bl_mutex);
-       }
+#ifdef CONFIG_FB_ATY_BACKLIGHT
+       if (machine_is(powermac) && blank > FB_BLANK_NORMAL)
+               aty_bl_set_power(info, FB_BLANK_POWERDOWN);
 #elif defined(CONFIG_FB_ATY_GENERIC_LCD)
        if (par->lcd_table && blank > FB_BLANK_NORMAL &&
            (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {
@@ -2830,17 +2844,9 @@ static int atyfb_blank(int blank, struct fb_info *info)
        }
        aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par);
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       if (machine_is(powermac) && blank <= FB_BLANK_NORMAL) {
-               mutex_lock(&info->bl_mutex);
-               if (info->bl_dev) {
-                       down(&info->bl_dev->sem);
-                       info->bl_dev->props->power = FB_BLANK_UNBLANK;
-                       info->bl_dev->props->update_status(info->bl_dev);
-                       up(&info->bl_dev->sem);
-               }
-               mutex_unlock(&info->bl_mutex);
-       }
+#ifdef CONFIG_FB_ATY_BACKLIGHT
+       if (machine_is(powermac) && blank <= FB_BLANK_NORMAL)
+               aty_bl_set_power(info, FB_BLANK_UNBLANK);
 #elif defined(CONFIG_FB_ATY_GENERIC_LCD)
        if (par->lcd_table && blank <= FB_BLANK_NORMAL &&
            (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) {