aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/aty/aty128fb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/aty/aty128fb.c')
-rw-r--r--drivers/video/aty/aty128fb.c80
1 files changed, 41 insertions, 39 deletions
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index 72c589109471..3e827e04a2aa 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -52,7 +52,6 @@
52#include <linux/errno.h> 52#include <linux/errno.h>
53#include <linux/string.h> 53#include <linux/string.h>
54#include <linux/mm.h> 54#include <linux/mm.h>
55#include <linux/tty.h>
56#include <linux/slab.h> 55#include <linux/slab.h>
57#include <linux/vmalloc.h> 56#include <linux/vmalloc.h>
58#include <linux/delay.h> 57#include <linux/delay.h>
@@ -457,6 +456,10 @@ static void wait_for_fifo(u16 entries, struct aty128fb_par *par);
457static void wait_for_idle(struct aty128fb_par *par); 456static void wait_for_idle(struct aty128fb_par *par);
458static u32 depth_to_dst(u32 depth); 457static u32 depth_to_dst(u32 depth);
459 458
459#ifdef CONFIG_FB_ATY128_BACKLIGHT
460static void aty128_bl_set_power(struct fb_info *info, int power);
461#endif
462
460#define BIOS_IN8(v) (readb(bios + (v))) 463#define BIOS_IN8(v) (readb(bios + (v)))
461#define BIOS_IN16(v) (readb(bios + (v)) | \ 464#define BIOS_IN16(v) (readb(bios + (v)) | \
462 (readb(bios + (v) + 1) << 8)) 465 (readb(bios + (v) + 1) << 8))
@@ -1258,25 +1261,11 @@ static void aty128_set_lcd_enable(struct aty128fb_par *par, int on)
1258 reg &= ~LVDS_DISPLAY_DIS; 1261 reg &= ~LVDS_DISPLAY_DIS;
1259 aty_st_le32(LVDS_GEN_CNTL, reg); 1262 aty_st_le32(LVDS_GEN_CNTL, reg);
1260#ifdef CONFIG_FB_ATY128_BACKLIGHT 1263#ifdef CONFIG_FB_ATY128_BACKLIGHT
1261 mutex_lock(&info->bl_mutex); 1264 aty128_bl_set_power(info, FB_BLANK_UNBLANK);
1262 if (info->bl_dev) {
1263 down(&info->bl_dev->sem);
1264 info->bl_dev->props->update_status(info->bl_dev);
1265 up(&info->bl_dev->sem);
1266 }
1267 mutex_unlock(&info->bl_mutex);
1268#endif 1265#endif
1269 } else { 1266 } else {
1270#ifdef CONFIG_FB_ATY128_BACKLIGHT 1267#ifdef CONFIG_FB_ATY128_BACKLIGHT
1271 mutex_lock(&info->bl_mutex); 1268 aty128_bl_set_power(info, FB_BLANK_POWERDOWN);
1272 if (info->bl_dev) {
1273 down(&info->bl_dev->sem);
1274 info->bl_dev->props->brightness = 0;
1275 info->bl_dev->props->power = FB_BLANK_POWERDOWN;
1276 info->bl_dev->props->update_status(info->bl_dev);
1277 up(&info->bl_dev->sem);
1278 }
1279 mutex_unlock(&info->bl_mutex);
1280#endif 1269#endif
1281 reg = aty_ld_le32(LVDS_GEN_CNTL); 1270 reg = aty_ld_le32(LVDS_GEN_CNTL);
1282 reg |= LVDS_DISPLAY_DIS; 1271 reg |= LVDS_DISPLAY_DIS;
@@ -1703,6 +1692,7 @@ static int __devinit aty128fb_setup(char *options)
1703 1692
1704static struct backlight_properties aty128_bl_data; 1693static struct backlight_properties aty128_bl_data;
1705 1694
1695/* Call with fb_info->bl_mutex held */
1706static int aty128_bl_get_level_brightness(struct aty128fb_par *par, 1696static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
1707 int level) 1697 int level)
1708{ 1698{
@@ -1710,10 +1700,8 @@ static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
1710 int atylevel; 1700 int atylevel;
1711 1701
1712 /* Get and convert the value */ 1702 /* Get and convert the value */
1713 mutex_lock(&info->bl_mutex);
1714 atylevel = MAX_LEVEL - 1703 atylevel = MAX_LEVEL -
1715 (info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL); 1704 (info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL);
1716 mutex_unlock(&info->bl_mutex);
1717 1705
1718 if (atylevel < 0) 1706 if (atylevel < 0)
1719 atylevel = 0; 1707 atylevel = 0;
@@ -1731,7 +1719,8 @@ static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
1731/* That one prevents proper CRT output with LCD off */ 1719/* That one prevents proper CRT output with LCD off */
1732#undef BACKLIGHT_DAC_OFF 1720#undef BACKLIGHT_DAC_OFF
1733 1721
1734static int aty128_bl_update_status(struct backlight_device *bd) 1722/* Call with fb_info->bl_mutex held */
1723static int __aty128_bl_update_status(struct backlight_device *bd)
1735{ 1724{
1736 struct aty128fb_par *par = class_get_devdata(&bd->class_dev); 1725 struct aty128fb_par *par = class_get_devdata(&bd->class_dev);
1737 unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL); 1726 unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL);
@@ -1784,6 +1773,19 @@ static int aty128_bl_update_status(struct backlight_device *bd)
1784 return 0; 1773 return 0;
1785} 1774}
1786 1775
1776static int aty128_bl_update_status(struct backlight_device *bd)
1777{
1778 struct aty128fb_par *par = class_get_devdata(&bd->class_dev);
1779 struct fb_info *info = pci_get_drvdata(par->pdev);
1780 int ret;
1781
1782 mutex_lock(&info->bl_mutex);
1783 ret = __aty128_bl_update_status(bd);
1784 mutex_unlock(&info->bl_mutex);
1785
1786 return ret;
1787}
1788
1787static int aty128_bl_get_brightness(struct backlight_device *bd) 1789static int aty128_bl_get_brightness(struct backlight_device *bd)
1788{ 1790{
1789 return bd->props->brightness; 1791 return bd->props->brightness;
@@ -1796,6 +1798,16 @@ static struct backlight_properties aty128_bl_data = {
1796 .max_brightness = (FB_BACKLIGHT_LEVELS - 1), 1798 .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
1797}; 1799};
1798 1800
1801static void aty128_bl_set_power(struct fb_info *info, int power)
1802{
1803 mutex_lock(&info->bl_mutex);
1804 up(&info->bl_dev->sem);
1805 info->bl_dev->props->power = power;
1806 __aty128_bl_update_status(info->bl_dev);
1807 down(&info->bl_dev->sem);
1808 mutex_unlock(&info->bl_mutex);
1809}
1810
1799static void aty128_bl_init(struct aty128fb_par *par) 1811static void aty128_bl_init(struct aty128fb_par *par)
1800{ 1812{
1801 struct fb_info *info = pci_get_drvdata(par->pdev); 1813 struct fb_info *info = pci_get_drvdata(par->pdev);
@@ -1901,9 +1913,6 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
1901 u8 chip_rev; 1913 u8 chip_rev;
1902 u32 dac; 1914 u32 dac;
1903 1915
1904 if (!par->vram_size) /* may have already been probed */
1905 par->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF;
1906
1907 /* Get the chip revision */ 1916 /* Get the chip revision */
1908 chip_rev = (aty_ld_le32(CONFIG_CNTL) >> 16) & 0x1F; 1917 chip_rev = (aty_ld_le32(CONFIG_CNTL) >> 16) & 0x1F;
1909 1918
@@ -2016,9 +2025,6 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
2016 2025
2017 aty128_init_engine(par); 2026 aty128_init_engine(par);
2018 2027
2019 if (register_framebuffer(info) < 0)
2020 return 0;
2021
2022 par->pm_reg = pci_find_capability(pdev, PCI_CAP_ID_PM); 2028 par->pm_reg = pci_find_capability(pdev, PCI_CAP_ID_PM);
2023 par->pdev = pdev; 2029 par->pdev = pdev;
2024 par->asleep = 0; 2030 par->asleep = 0;
@@ -2028,6 +2034,9 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
2028 aty128_bl_init(par); 2034 aty128_bl_init(par);
2029#endif 2035#endif
2030 2036
2037 if (register_framebuffer(info) < 0)
2038 return 0;
2039
2031 printk(KERN_INFO "fb%d: %s frame buffer device on %s\n", 2040 printk(KERN_INFO "fb%d: %s frame buffer device on %s\n",
2032 info->node, info->fix.id, video_card); 2041 info->node, info->fix.id, video_card);
2033 2042
@@ -2077,7 +2086,6 @@ static int __devinit aty128_probe(struct pci_dev *pdev, const struct pci_device_
2077 par = info->par; 2086 par = info->par;
2078 2087
2079 info->pseudo_palette = par->pseudo_palette; 2088 info->pseudo_palette = par->pseudo_palette;
2080 info->fix = aty128fb_fix;
2081 2089
2082 /* Virtualize mmio region */ 2090 /* Virtualize mmio region */
2083 info->fix.mmio_start = reg_addr; 2091 info->fix.mmio_start = reg_addr;
@@ -2198,12 +2206,8 @@ static int aty128fb_blank(int blank, struct fb_info *fb)
2198 return 0; 2206 return 0;
2199 2207
2200#ifdef CONFIG_FB_ATY128_BACKLIGHT 2208#ifdef CONFIG_FB_ATY128_BACKLIGHT
2201 if (machine_is(powermac) && blank) { 2209 if (machine_is(powermac) && blank)
2202 down(&fb->bl_dev->sem); 2210 aty128_bl_set_power(fb, FB_BLANK_POWERDOWN);
2203 fb->bl_dev->props->power = FB_BLANK_POWERDOWN;
2204 fb->bl_dev->props->update_status(fb->bl_dev);
2205 up(&fb->bl_dev->sem);
2206 }
2207#endif 2211#endif
2208 2212
2209 if (blank & FB_BLANK_VSYNC_SUSPEND) 2213 if (blank & FB_BLANK_VSYNC_SUSPEND)
@@ -2219,14 +2223,12 @@ static int aty128fb_blank(int blank, struct fb_info *fb)
2219 aty128_set_crt_enable(par, par->crt_on && !blank); 2223 aty128_set_crt_enable(par, par->crt_on && !blank);
2220 aty128_set_lcd_enable(par, par->lcd_on && !blank); 2224 aty128_set_lcd_enable(par, par->lcd_on && !blank);
2221 } 2225 }
2226
2222#ifdef CONFIG_FB_ATY128_BACKLIGHT 2227#ifdef CONFIG_FB_ATY128_BACKLIGHT
2223 if (machine_is(powermac) && !blank) { 2228 if (machine_is(powermac) && !blank)
2224 down(&fb->bl_dev->sem); 2229 aty128_bl_set_power(fb, FB_BLANK_UNBLANK);
2225 fb->bl_dev->props->power = FB_BLANK_UNBLANK;
2226 fb->bl_dev->props->update_status(fb->bl_dev);
2227 up(&fb->bl_dev->sem);
2228 }
2229#endif 2230#endif
2231
2230 return 0; 2232 return 0;
2231} 2233}
2232 2234