diff options
Diffstat (limited to 'drivers/video/aty/aty128fb.c')
-rw-r--r-- | drivers/video/aty/aty128fb.c | 102 |
1 files changed, 19 insertions, 83 deletions
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index 2e976ffcde0f..8726c3669713 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c | |||
@@ -1695,9 +1695,6 @@ static int __devinit aty128fb_setup(char *options) | |||
1695 | #ifdef CONFIG_FB_ATY128_BACKLIGHT | 1695 | #ifdef CONFIG_FB_ATY128_BACKLIGHT |
1696 | #define MAX_LEVEL 0xFF | 1696 | #define MAX_LEVEL 0xFF |
1697 | 1697 | ||
1698 | static struct backlight_properties aty128_bl_data; | ||
1699 | |||
1700 | /* Call with fb_info->bl_mutex held */ | ||
1701 | static int aty128_bl_get_level_brightness(struct aty128fb_par *par, | 1698 | static int aty128_bl_get_level_brightness(struct aty128fb_par *par, |
1702 | int level) | 1699 | int level) |
1703 | { | 1700 | { |
@@ -1705,6 +1702,7 @@ static int aty128_bl_get_level_brightness(struct aty128fb_par *par, | |||
1705 | int atylevel; | 1702 | int atylevel; |
1706 | 1703 | ||
1707 | /* Get and convert the value */ | 1704 | /* Get and convert the value */ |
1705 | /* No locking of bl_curve since we read a single value */ | ||
1708 | atylevel = MAX_LEVEL - | 1706 | atylevel = MAX_LEVEL - |
1709 | (info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL); | 1707 | (info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL); |
1710 | 1708 | ||
@@ -1724,19 +1722,18 @@ static int aty128_bl_get_level_brightness(struct aty128fb_par *par, | |||
1724 | /* That one prevents proper CRT output with LCD off */ | 1722 | /* That one prevents proper CRT output with LCD off */ |
1725 | #undef BACKLIGHT_DAC_OFF | 1723 | #undef BACKLIGHT_DAC_OFF |
1726 | 1724 | ||
1727 | /* Call with fb_info->bl_mutex held */ | 1725 | static int aty128_bl_update_status(struct backlight_device *bd) |
1728 | static int __aty128_bl_update_status(struct backlight_device *bd) | ||
1729 | { | 1726 | { |
1730 | struct aty128fb_par *par = class_get_devdata(&bd->class_dev); | 1727 | struct aty128fb_par *par = class_get_devdata(&bd->class_dev); |
1731 | unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL); | 1728 | unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL); |
1732 | int level; | 1729 | int level; |
1733 | 1730 | ||
1734 | if (bd->props->power != FB_BLANK_UNBLANK || | 1731 | if (bd->props.power != FB_BLANK_UNBLANK || |
1735 | bd->props->fb_blank != FB_BLANK_UNBLANK || | 1732 | bd->props.fb_blank != FB_BLANK_UNBLANK || |
1736 | !par->lcd_on) | 1733 | !par->lcd_on) |
1737 | level = 0; | 1734 | level = 0; |
1738 | else | 1735 | else |
1739 | level = bd->props->brightness; | 1736 | level = bd->props.brightness; |
1740 | 1737 | ||
1741 | reg |= LVDS_BL_MOD_EN | LVDS_BLON; | 1738 | reg |= LVDS_BL_MOD_EN | LVDS_BLON; |
1742 | if (level > 0) { | 1739 | if (level > 0) { |
@@ -1778,43 +1775,22 @@ static int __aty128_bl_update_status(struct backlight_device *bd) | |||
1778 | return 0; | 1775 | return 0; |
1779 | } | 1776 | } |
1780 | 1777 | ||
1781 | static int aty128_bl_update_status(struct backlight_device *bd) | ||
1782 | { | ||
1783 | struct aty128fb_par *par = class_get_devdata(&bd->class_dev); | ||
1784 | struct fb_info *info = pci_get_drvdata(par->pdev); | ||
1785 | int ret; | ||
1786 | |||
1787 | mutex_lock(&info->bl_mutex); | ||
1788 | ret = __aty128_bl_update_status(bd); | ||
1789 | mutex_unlock(&info->bl_mutex); | ||
1790 | |||
1791 | return ret; | ||
1792 | } | ||
1793 | |||
1794 | static int aty128_bl_get_brightness(struct backlight_device *bd) | 1778 | static int aty128_bl_get_brightness(struct backlight_device *bd) |
1795 | { | 1779 | { |
1796 | return bd->props->brightness; | 1780 | return bd->props.brightness; |
1797 | } | 1781 | } |
1798 | 1782 | ||
1799 | static struct backlight_properties aty128_bl_data = { | 1783 | static struct backlight_ops aty128_bl_data = { |
1800 | .owner = THIS_MODULE, | ||
1801 | .get_brightness = aty128_bl_get_brightness, | 1784 | .get_brightness = aty128_bl_get_brightness, |
1802 | .update_status = aty128_bl_update_status, | 1785 | .update_status = aty128_bl_update_status, |
1803 | .max_brightness = (FB_BACKLIGHT_LEVELS - 1), | ||
1804 | }; | 1786 | }; |
1805 | 1787 | ||
1806 | static void aty128_bl_set_power(struct fb_info *info, int power) | 1788 | static void aty128_bl_set_power(struct fb_info *info, int power) |
1807 | { | 1789 | { |
1808 | mutex_lock(&info->bl_mutex); | ||
1809 | |||
1810 | if (info->bl_dev) { | 1790 | if (info->bl_dev) { |
1811 | down(&info->bl_dev->sem); | 1791 | info->bl_dev->props.power = power; |
1812 | info->bl_dev->props->power = power; | 1792 | backlight_update_status(info->bl_dev); |
1813 | __aty128_bl_update_status(info->bl_dev); | ||
1814 | up(&info->bl_dev->sem); | ||
1815 | } | 1793 | } |
1816 | |||
1817 | mutex_unlock(&info->bl_mutex); | ||
1818 | } | 1794 | } |
1819 | 1795 | ||
1820 | static void aty128_bl_init(struct aty128fb_par *par) | 1796 | static void aty128_bl_init(struct aty128fb_par *par) |
@@ -1841,25 +1817,15 @@ static void aty128_bl_init(struct aty128fb_par *par) | |||
1841 | goto error; | 1817 | goto error; |
1842 | } | 1818 | } |
1843 | 1819 | ||
1844 | mutex_lock(&info->bl_mutex); | ||
1845 | info->bl_dev = bd; | 1820 | info->bl_dev = bd; |
1846 | fb_bl_default_curve(info, 0, | 1821 | fb_bl_default_curve(info, 0, |
1847 | 63 * FB_BACKLIGHT_MAX / MAX_LEVEL, | 1822 | 63 * FB_BACKLIGHT_MAX / MAX_LEVEL, |
1848 | 219 * FB_BACKLIGHT_MAX / MAX_LEVEL); | 1823 | 219 * FB_BACKLIGHT_MAX / MAX_LEVEL); |
1849 | mutex_unlock(&info->bl_mutex); | ||
1850 | 1824 | ||
1851 | down(&bd->sem); | 1825 | bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; |
1852 | bd->props->brightness = aty128_bl_data.max_brightness; | 1826 | bd->props.brightness = bd->props.max_brightness; |
1853 | bd->props->power = FB_BLANK_UNBLANK; | 1827 | bd->props.power = FB_BLANK_UNBLANK; |
1854 | bd->props->update_status(bd); | 1828 | backlight_update_status(bd); |
1855 | up(&bd->sem); | ||
1856 | |||
1857 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
1858 | mutex_lock(&pmac_backlight_mutex); | ||
1859 | if (!pmac_backlight) | ||
1860 | pmac_backlight = bd; | ||
1861 | mutex_unlock(&pmac_backlight_mutex); | ||
1862 | #endif | ||
1863 | 1829 | ||
1864 | printk("aty128: Backlight initialized (%s)\n", name); | 1830 | printk("aty128: Backlight initialized (%s)\n", name); |
1865 | 1831 | ||
@@ -1869,31 +1835,10 @@ error: | |||
1869 | return; | 1835 | return; |
1870 | } | 1836 | } |
1871 | 1837 | ||
1872 | static void aty128_bl_exit(struct aty128fb_par *par) | 1838 | static void aty128_bl_exit(struct backlight_device *bd) |
1873 | { | 1839 | { |
1874 | struct fb_info *info = pci_get_drvdata(par->pdev); | 1840 | backlight_device_unregister(bd); |
1875 | 1841 | printk("aty128: Backlight unloaded\n"); | |
1876 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
1877 | mutex_lock(&pmac_backlight_mutex); | ||
1878 | #endif | ||
1879 | |||
1880 | mutex_lock(&info->bl_mutex); | ||
1881 | if (info->bl_dev) { | ||
1882 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
1883 | if (pmac_backlight == info->bl_dev) | ||
1884 | pmac_backlight = NULL; | ||
1885 | #endif | ||
1886 | |||
1887 | backlight_device_unregister(info->bl_dev); | ||
1888 | info->bl_dev = NULL; | ||
1889 | |||
1890 | printk("aty128: Backlight unloaded\n"); | ||
1891 | } | ||
1892 | mutex_unlock(&info->bl_mutex); | ||
1893 | |||
1894 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
1895 | mutex_unlock(&pmac_backlight_mutex); | ||
1896 | #endif | ||
1897 | } | 1842 | } |
1898 | #endif /* CONFIG_FB_ATY128_BACKLIGHT */ | 1843 | #endif /* CONFIG_FB_ATY128_BACKLIGHT */ |
1899 | 1844 | ||
@@ -2180,11 +2125,12 @@ static void __devexit aty128_remove(struct pci_dev *pdev) | |||
2180 | 2125 | ||
2181 | par = info->par; | 2126 | par = info->par; |
2182 | 2127 | ||
2128 | unregister_framebuffer(info); | ||
2129 | |||
2183 | #ifdef CONFIG_FB_ATY128_BACKLIGHT | 2130 | #ifdef CONFIG_FB_ATY128_BACKLIGHT |
2184 | aty128_bl_exit(par); | 2131 | aty128_bl_exit(info->bl_dev); |
2185 | #endif | 2132 | #endif |
2186 | 2133 | ||
2187 | unregister_framebuffer(info); | ||
2188 | #ifdef CONFIG_MTRR | 2134 | #ifdef CONFIG_MTRR |
2189 | if (par->mtrr.vram_valid) | 2135 | if (par->mtrr.vram_valid) |
2190 | mtrr_del(par->mtrr.vram, info->fix.smem_start, | 2136 | mtrr_del(par->mtrr.vram, info->fix.smem_start, |
@@ -2214,11 +2160,6 @@ static int aty128fb_blank(int blank, struct fb_info *fb) | |||
2214 | if (par->lock_blank || par->asleep) | 2160 | if (par->lock_blank || par->asleep) |
2215 | return 0; | 2161 | return 0; |
2216 | 2162 | ||
2217 | #ifdef CONFIG_FB_ATY128_BACKLIGHT | ||
2218 | if (machine_is(powermac) && blank) | ||
2219 | aty128_bl_set_power(fb, FB_BLANK_POWERDOWN); | ||
2220 | #endif | ||
2221 | |||
2222 | if (blank & FB_BLANK_VSYNC_SUSPEND) | 2163 | if (blank & FB_BLANK_VSYNC_SUSPEND) |
2223 | state |= 2; | 2164 | state |= 2; |
2224 | if (blank & FB_BLANK_HSYNC_SUSPEND) | 2165 | if (blank & FB_BLANK_HSYNC_SUSPEND) |
@@ -2233,11 +2174,6 @@ static int aty128fb_blank(int blank, struct fb_info *fb) | |||
2233 | aty128_set_lcd_enable(par, par->lcd_on && !blank); | 2174 | aty128_set_lcd_enable(par, par->lcd_on && !blank); |
2234 | } | 2175 | } |
2235 | 2176 | ||
2236 | #ifdef CONFIG_FB_ATY128_BACKLIGHT | ||
2237 | if (machine_is(powermac) && !blank) | ||
2238 | aty128_bl_set_power(fb, FB_BLANK_UNBLANK); | ||
2239 | #endif | ||
2240 | |||
2241 | return 0; | 2177 | return 0; |
2242 | } | 2178 | } |
2243 | 2179 | ||