X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fvideo%2Faty%2Fatyfb_base.c;h=19a71f045784008c3a278be54f1f42f19cfda6c9;hb=23930fa1cebfea6f79881c588ccd1b0781e49e3f;hp=22e720611bf674b31702260ca858b684c889084f;hpb=489244498ec99c949ecbd7105299066cff283dcd;p=linux-2.6-omap-h63xx.git diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 22e720611bf..19a71f04578 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c @@ -49,7 +49,6 @@ ******************************************************************************/ -#include #include #include #include @@ -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,20 @@ 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); + + if (info->bl_dev) { + down(&info->bl_dev->sem); + info->bl_dev->props->power = power; + __aty_bl_update_status(info->bl_dev); + up(&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); @@ -2201,7 +2227,7 @@ static void aty_bl_init(struct atyfb_par *par) bd = backlight_device_register(name, par, &aty_bl_data); if (IS_ERR(bd)) { info->bl_dev = NULL; - printk("aty: Backlight registration failed\n"); + printk(KERN_WARNING "aty: Backlight registration failed\n"); goto error; } @@ -2212,11 +2238,11 @@ static void aty_bl_init(struct atyfb_par *par) 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); mutex_unlock(&info->bl_mutex); - up(&bd->sem); + down(&bd->sem); bd->props->brightness = aty_bl_data.max_brightness; bd->props->power = FB_BLANK_UNBLANK; bd->props->update_status(bd); - down(&bd->sem); + up(&bd->sem); #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); @@ -2790,17 +2816,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 +2848,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)) {