diff options
Diffstat (limited to 'drivers/video/aty/atyfb_base.c')
-rw-r--r-- | drivers/video/aty/atyfb_base.c | 100 |
1 files changed, 17 insertions, 83 deletions
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 301612cef354..a7e0062233f2 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c | |||
@@ -2114,15 +2114,13 @@ static int atyfb_pci_resume(struct pci_dev *pdev) | |||
2114 | #ifdef CONFIG_FB_ATY_BACKLIGHT | 2114 | #ifdef CONFIG_FB_ATY_BACKLIGHT |
2115 | #define MAX_LEVEL 0xFF | 2115 | #define MAX_LEVEL 0xFF |
2116 | 2116 | ||
2117 | static struct backlight_properties aty_bl_data; | ||
2118 | |||
2119 | /* Call with fb_info->bl_mutex held */ | ||
2120 | static int aty_bl_get_level_brightness(struct atyfb_par *par, int level) | 2117 | static int aty_bl_get_level_brightness(struct atyfb_par *par, int level) |
2121 | { | 2118 | { |
2122 | struct fb_info *info = pci_get_drvdata(par->pdev); | 2119 | struct fb_info *info = pci_get_drvdata(par->pdev); |
2123 | int atylevel; | 2120 | int atylevel; |
2124 | 2121 | ||
2125 | /* Get and convert the value */ | 2122 | /* Get and convert the value */ |
2123 | /* No locking of bl_curve since we read a single value */ | ||
2126 | atylevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; | 2124 | atylevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; |
2127 | 2125 | ||
2128 | if (atylevel < 0) | 2126 | if (atylevel < 0) |
@@ -2133,18 +2131,17 @@ static int aty_bl_get_level_brightness(struct atyfb_par *par, int level) | |||
2133 | return atylevel; | 2131 | return atylevel; |
2134 | } | 2132 | } |
2135 | 2133 | ||
2136 | /* Call with fb_info->bl_mutex held */ | 2134 | static int aty_bl_update_status(struct backlight_device *bd) |
2137 | static int __aty_bl_update_status(struct backlight_device *bd) | ||
2138 | { | 2135 | { |
2139 | struct atyfb_par *par = class_get_devdata(&bd->class_dev); | 2136 | struct atyfb_par *par = class_get_devdata(&bd->class_dev); |
2140 | unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par); | 2137 | unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par); |
2141 | int level; | 2138 | int level; |
2142 | 2139 | ||
2143 | if (bd->props->power != FB_BLANK_UNBLANK || | 2140 | if (bd->props.power != FB_BLANK_UNBLANK || |
2144 | bd->props->fb_blank != FB_BLANK_UNBLANK) | 2141 | bd->props.fb_blank != FB_BLANK_UNBLANK) |
2145 | level = 0; | 2142 | level = 0; |
2146 | else | 2143 | else |
2147 | level = bd->props->brightness; | 2144 | level = bd->props.brightness; |
2148 | 2145 | ||
2149 | reg |= (BLMOD_EN | BIASMOD_EN); | 2146 | reg |= (BLMOD_EN | BIASMOD_EN); |
2150 | if (level > 0) { | 2147 | if (level > 0) { |
@@ -2159,45 +2156,16 @@ static int __aty_bl_update_status(struct backlight_device *bd) | |||
2159 | return 0; | 2156 | return 0; |
2160 | } | 2157 | } |
2161 | 2158 | ||
2162 | static int aty_bl_update_status(struct backlight_device *bd) | ||
2163 | { | ||
2164 | struct atyfb_par *par = class_get_devdata(&bd->class_dev); | ||
2165 | struct fb_info *info = pci_get_drvdata(par->pdev); | ||
2166 | int ret; | ||
2167 | |||
2168 | mutex_lock(&info->bl_mutex); | ||
2169 | ret = __aty_bl_update_status(bd); | ||
2170 | mutex_unlock(&info->bl_mutex); | ||
2171 | |||
2172 | return ret; | ||
2173 | } | ||
2174 | |||
2175 | static int aty_bl_get_brightness(struct backlight_device *bd) | 2159 | static int aty_bl_get_brightness(struct backlight_device *bd) |
2176 | { | 2160 | { |
2177 | return bd->props->brightness; | 2161 | return bd->props.brightness; |
2178 | } | 2162 | } |
2179 | 2163 | ||
2180 | static struct backlight_properties aty_bl_data = { | 2164 | static struct backlight_ops aty_bl_data = { |
2181 | .owner = THIS_MODULE, | ||
2182 | .get_brightness = aty_bl_get_brightness, | 2165 | .get_brightness = aty_bl_get_brightness, |
2183 | .update_status = aty_bl_update_status, | 2166 | .update_status = aty_bl_update_status, |
2184 | .max_brightness = (FB_BACKLIGHT_LEVELS - 1), | ||
2185 | }; | 2167 | }; |
2186 | 2168 | ||
2187 | static void aty_bl_set_power(struct fb_info *info, int power) | ||
2188 | { | ||
2189 | mutex_lock(&info->bl_mutex); | ||
2190 | |||
2191 | if (info->bl_dev) { | ||
2192 | down(&info->bl_dev->sem); | ||
2193 | info->bl_dev->props->power = power; | ||
2194 | __aty_bl_update_status(info->bl_dev); | ||
2195 | up(&info->bl_dev->sem); | ||
2196 | } | ||
2197 | |||
2198 | mutex_unlock(&info->bl_mutex); | ||
2199 | } | ||
2200 | |||
2201 | static void aty_bl_init(struct atyfb_par *par) | 2169 | static void aty_bl_init(struct atyfb_par *par) |
2202 | { | 2170 | { |
2203 | struct fb_info *info = pci_get_drvdata(par->pdev); | 2171 | struct fb_info *info = pci_get_drvdata(par->pdev); |
@@ -2218,25 +2186,15 @@ static void aty_bl_init(struct atyfb_par *par) | |||
2218 | goto error; | 2186 | goto error; |
2219 | } | 2187 | } |
2220 | 2188 | ||
2221 | mutex_lock(&info->bl_mutex); | ||
2222 | info->bl_dev = bd; | 2189 | info->bl_dev = bd; |
2223 | fb_bl_default_curve(info, 0, | 2190 | fb_bl_default_curve(info, 0, |
2224 | 0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL, | 2191 | 0x3F * FB_BACKLIGHT_MAX / MAX_LEVEL, |
2225 | 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); | 2192 | 0xFF * FB_BACKLIGHT_MAX / MAX_LEVEL); |
2226 | mutex_unlock(&info->bl_mutex); | ||
2227 | |||
2228 | down(&bd->sem); | ||
2229 | bd->props->brightness = aty_bl_data.max_brightness; | ||
2230 | bd->props->power = FB_BLANK_UNBLANK; | ||
2231 | bd->props->update_status(bd); | ||
2232 | up(&bd->sem); | ||
2233 | 2193 | ||
2234 | #ifdef CONFIG_PMAC_BACKLIGHT | 2194 | bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; |
2235 | mutex_lock(&pmac_backlight_mutex); | 2195 | bd->props.brightness = bd->props.max_brightness; |
2236 | if (!pmac_backlight) | 2196 | bd->props.power = FB_BLANK_UNBLANK; |
2237 | pmac_backlight = bd; | 2197 | backlight_update_status(bd); |
2238 | mutex_unlock(&pmac_backlight_mutex); | ||
2239 | #endif | ||
2240 | 2198 | ||
2241 | printk("aty: Backlight initialized (%s)\n", name); | 2199 | printk("aty: Backlight initialized (%s)\n", name); |
2242 | 2200 | ||
@@ -2246,30 +2204,10 @@ error: | |||
2246 | return; | 2204 | return; |
2247 | } | 2205 | } |
2248 | 2206 | ||
2249 | static void aty_bl_exit(struct atyfb_par *par) | 2207 | static void aty_bl_exit(struct backlight_device *bd) |
2250 | { | 2208 | { |
2251 | struct fb_info *info = pci_get_drvdata(par->pdev); | 2209 | backlight_device_unregister(bd); |
2252 | 2210 | printk("aty: Backlight unloaded\n"); | |
2253 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
2254 | mutex_lock(&pmac_backlight_mutex); | ||
2255 | #endif | ||
2256 | |||
2257 | mutex_lock(&info->bl_mutex); | ||
2258 | if (info->bl_dev) { | ||
2259 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
2260 | if (pmac_backlight == info->bl_dev) | ||
2261 | pmac_backlight = NULL; | ||
2262 | #endif | ||
2263 | |||
2264 | backlight_device_unregister(info->bl_dev); | ||
2265 | |||
2266 | printk("aty: Backlight unloaded\n"); | ||
2267 | } | ||
2268 | mutex_unlock(&info->bl_mutex); | ||
2269 | |||
2270 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
2271 | mutex_unlock(&pmac_backlight_mutex); | ||
2272 | #endif | ||
2273 | } | 2211 | } |
2274 | 2212 | ||
2275 | #endif /* CONFIG_FB_ATY_BACKLIGHT */ | 2213 | #endif /* CONFIG_FB_ATY_BACKLIGHT */ |
@@ -2814,8 +2752,6 @@ static int atyfb_blank(int blank, struct fb_info *info) | |||
2814 | return 0; | 2752 | return 0; |
2815 | 2753 | ||
2816 | #ifdef CONFIG_FB_ATY_BACKLIGHT | 2754 | #ifdef CONFIG_FB_ATY_BACKLIGHT |
2817 | if (machine_is(powermac) && blank > FB_BLANK_NORMAL) | ||
2818 | aty_bl_set_power(info, FB_BLANK_POWERDOWN); | ||
2819 | #elif defined(CONFIG_FB_ATY_GENERIC_LCD) | 2755 | #elif defined(CONFIG_FB_ATY_GENERIC_LCD) |
2820 | if (par->lcd_table && blank > FB_BLANK_NORMAL && | 2756 | if (par->lcd_table && blank > FB_BLANK_NORMAL && |
2821 | (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { | 2757 | (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { |
@@ -2846,8 +2782,6 @@ static int atyfb_blank(int blank, struct fb_info *info) | |||
2846 | aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par); | 2782 | aty_st_le32(CRTC_GEN_CNTL, gen_cntl, par); |
2847 | 2783 | ||
2848 | #ifdef CONFIG_FB_ATY_BACKLIGHT | 2784 | #ifdef CONFIG_FB_ATY_BACKLIGHT |
2849 | if (machine_is(powermac) && blank <= FB_BLANK_NORMAL) | ||
2850 | aty_bl_set_power(info, FB_BLANK_UNBLANK); | ||
2851 | #elif defined(CONFIG_FB_ATY_GENERIC_LCD) | 2785 | #elif defined(CONFIG_FB_ATY_GENERIC_LCD) |
2852 | if (par->lcd_table && blank <= FB_BLANK_NORMAL && | 2786 | if (par->lcd_table && blank <= FB_BLANK_NORMAL && |
2853 | (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { | 2787 | (aty_ld_lcd(LCD_GEN_CNTL, par) & LCD_ON)) { |
@@ -3726,13 +3660,13 @@ static void __devexit atyfb_remove(struct fb_info *info) | |||
3726 | aty_set_crtc(par, &saved_crtc); | 3660 | aty_set_crtc(par, &saved_crtc); |
3727 | par->pll_ops->set_pll(info, &saved_pll); | 3661 | par->pll_ops->set_pll(info, &saved_pll); |
3728 | 3662 | ||
3663 | unregister_framebuffer(info); | ||
3664 | |||
3729 | #ifdef CONFIG_FB_ATY_BACKLIGHT | 3665 | #ifdef CONFIG_FB_ATY_BACKLIGHT |
3730 | if (M64_HAS(MOBIL_BUS)) | 3666 | if (M64_HAS(MOBIL_BUS)) |
3731 | aty_bl_exit(par); | 3667 | aty_bl_exit(info->bl_dev); |
3732 | #endif | 3668 | #endif |
3733 | 3669 | ||
3734 | unregister_framebuffer(info); | ||
3735 | |||
3736 | #ifdef CONFIG_MTRR | 3670 | #ifdef CONFIG_MTRR |
3737 | if (par->mtrr_reg >= 0) { | 3671 | if (par->mtrr_reg >= 0) { |
3738 | mtrr_del(par->mtrr_reg, 0, 0); | 3672 | mtrr_del(par->mtrr_reg, 0, 0); |