diff options
author | Michael Hanselmann <linux-kernel@hansmi.ch> | 2006-06-25 08:47:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 13:00:59 -0400 |
commit | 5474c120aafe78ca54bf272f7a01107c42da2b21 (patch) | |
tree | c1b002a27703ce92c816bfb9844752186e33d403 /drivers/video/aty/radeon_base.c | |
parent | 17660bdd5c1f1a165273c1a59cb5b87670a81cc4 (diff) |
[PATCH] Rewritten backlight infrastructure for portable Apple computers
This patch contains a total rewrite of the backlight infrastructure for
portable Apple computers. Backward compatibility is retained. A sysfs
interface allows userland to control the brightness with more steps than
before. Userland is allowed to upload a brightness curve for different
monitors, similar to Mac OS X.
[akpm@osdl.org: add needed exports]
Signed-off-by: Michael Hanselmann <linux-kernel@hansmi.ch>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/aty/radeon_base.c')
-rw-r--r-- | drivers/video/aty/radeon_base.c | 140 |
1 files changed, 3 insertions, 137 deletions
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index 387a18a47ac2..c5ecbb02e01d 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c | |||
@@ -78,10 +78,6 @@ | |||
78 | #include <asm/pci-bridge.h> | 78 | #include <asm/pci-bridge.h> |
79 | #include "../macmodes.h" | 79 | #include "../macmodes.h" |
80 | 80 | ||
81 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
82 | #include <asm/backlight.h> | ||
83 | #endif | ||
84 | |||
85 | #ifdef CONFIG_BOOTX_TEXT | 81 | #ifdef CONFIG_BOOTX_TEXT |
86 | #include <asm/btext.h> | 82 | #include <asm/btext.h> |
87 | #endif | 83 | #endif |
@@ -277,20 +273,6 @@ static int nomtrr = 0; | |||
277 | * prototypes | 273 | * prototypes |
278 | */ | 274 | */ |
279 | 275 | ||
280 | |||
281 | #ifdef CONFIG_PPC_OF | ||
282 | |||
283 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
284 | static int radeon_set_backlight_enable(int on, int level, void *data); | ||
285 | static int radeon_set_backlight_level(int level, void *data); | ||
286 | static struct backlight_controller radeon_backlight_controller = { | ||
287 | radeon_set_backlight_enable, | ||
288 | radeon_set_backlight_level | ||
289 | }; | ||
290 | #endif /* CONFIG_PMAC_BACKLIGHT */ | ||
291 | |||
292 | #endif /* CONFIG_PPC_OF */ | ||
293 | |||
294 | static void radeon_unmap_ROM(struct radeonfb_info *rinfo, struct pci_dev *dev) | 276 | static void radeon_unmap_ROM(struct radeonfb_info *rinfo, struct pci_dev *dev) |
295 | { | 277 | { |
296 | if (!rinfo->bios_seg) | 278 | if (!rinfo->bios_seg) |
@@ -1913,116 +1895,6 @@ static int __devinit radeon_set_fbinfo (struct radeonfb_info *rinfo) | |||
1913 | return 0; | 1895 | return 0; |
1914 | } | 1896 | } |
1915 | 1897 | ||
1916 | |||
1917 | #ifdef CONFIG_PMAC_BACKLIGHT | ||
1918 | |||
1919 | /* TODO: Dbl check these tables, we don't go up to full ON backlight | ||
1920 | * in these, possibly because we noticed MacOS doesn't, but I'd prefer | ||
1921 | * having some more official numbers from ATI | ||
1922 | */ | ||
1923 | static int backlight_conv_m6[] = { | ||
1924 | 0xff, 0xc0, 0xb5, 0xaa, 0x9f, 0x94, 0x89, 0x7e, | ||
1925 | 0x73, 0x68, 0x5d, 0x52, 0x47, 0x3c, 0x31, 0x24 | ||
1926 | }; | ||
1927 | static int backlight_conv_m7[] = { | ||
1928 | 0x00, 0x3f, 0x4a, 0x55, 0x60, 0x6b, 0x76, 0x81, | ||
1929 | 0x8c, 0x97, 0xa2, 0xad, 0xb8, 0xc3, 0xce, 0xd9 | ||
1930 | }; | ||
1931 | |||
1932 | #define BACKLIGHT_LVDS_OFF | ||
1933 | #undef BACKLIGHT_DAC_OFF | ||
1934 | |||
1935 | /* We turn off the LCD completely instead of just dimming the backlight. | ||
1936 | * This provides some greater power saving and the display is useless | ||
1937 | * without backlight anyway. | ||
1938 | */ | ||
1939 | static int radeon_set_backlight_enable(int on, int level, void *data) | ||
1940 | { | ||
1941 | struct radeonfb_info *rinfo = (struct radeonfb_info *)data; | ||
1942 | u32 lvds_gen_cntl, tmpPixclksCntl; | ||
1943 | int* conv_table; | ||
1944 | |||
1945 | if (rinfo->mon1_type != MT_LCD) | ||
1946 | return 0; | ||
1947 | |||
1948 | /* Pardon me for that hack... maybe some day we can figure | ||
1949 | * out in what direction backlight should work on a given | ||
1950 | * panel ? | ||
1951 | */ | ||
1952 | if ((rinfo->family == CHIP_FAMILY_RV200 || | ||
1953 | rinfo->family == CHIP_FAMILY_RV250 || | ||
1954 | rinfo->family == CHIP_FAMILY_RV280 || | ||
1955 | rinfo->family == CHIP_FAMILY_RV350) && | ||
1956 | !machine_is_compatible("PowerBook4,3") && | ||
1957 | !machine_is_compatible("PowerBook6,3") && | ||
1958 | !machine_is_compatible("PowerBook6,5")) | ||
1959 | conv_table = backlight_conv_m7; | ||
1960 | else | ||
1961 | conv_table = backlight_conv_m6; | ||
1962 | |||
1963 | del_timer_sync(&rinfo->lvds_timer); | ||
1964 | radeon_engine_idle(); | ||
1965 | |||
1966 | lvds_gen_cntl = INREG(LVDS_GEN_CNTL); | ||
1967 | if (on && (level > BACKLIGHT_OFF)) { | ||
1968 | lvds_gen_cntl &= ~LVDS_DISPLAY_DIS; | ||
1969 | if (!(lvds_gen_cntl & LVDS_BLON) || !(lvds_gen_cntl & LVDS_ON)) { | ||
1970 | lvds_gen_cntl |= (rinfo->init_state.lvds_gen_cntl & LVDS_DIGON); | ||
1971 | lvds_gen_cntl |= LVDS_BLON | LVDS_EN; | ||
1972 | OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); | ||
1973 | lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK; | ||
1974 | lvds_gen_cntl |= (conv_table[level] << | ||
1975 | LVDS_BL_MOD_LEVEL_SHIFT); | ||
1976 | lvds_gen_cntl |= LVDS_ON; | ||
1977 | lvds_gen_cntl |= (rinfo->init_state.lvds_gen_cntl & LVDS_BL_MOD_EN); | ||
1978 | rinfo->pending_lvds_gen_cntl = lvds_gen_cntl; | ||
1979 | mod_timer(&rinfo->lvds_timer, | ||
1980 | jiffies + msecs_to_jiffies(rinfo->panel_info.pwr_delay)); | ||
1981 | } else { | ||
1982 | lvds_gen_cntl &= ~LVDS_BL_MOD_LEVEL_MASK; | ||
1983 | lvds_gen_cntl |= (conv_table[level] << | ||
1984 | LVDS_BL_MOD_LEVEL_SHIFT); | ||
1985 | OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); | ||
1986 | } | ||
1987 | rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK; | ||
1988 | rinfo->init_state.lvds_gen_cntl |= rinfo->pending_lvds_gen_cntl | ||
1989 | & LVDS_STATE_MASK; | ||
1990 | } else { | ||
1991 | /* Asic bug, when turning off LVDS_ON, we have to make sure | ||
1992 | RADEON_PIXCLK_LVDS_ALWAYS_ON bit is off | ||
1993 | */ | ||
1994 | tmpPixclksCntl = INPLL(PIXCLKS_CNTL); | ||
1995 | if (rinfo->is_mobility || rinfo->is_IGP) | ||
1996 | OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb); | ||
1997 | lvds_gen_cntl &= ~(LVDS_BL_MOD_LEVEL_MASK | LVDS_BL_MOD_EN); | ||
1998 | lvds_gen_cntl |= (conv_table[0] << | ||
1999 | LVDS_BL_MOD_LEVEL_SHIFT); | ||
2000 | lvds_gen_cntl |= LVDS_DISPLAY_DIS; | ||
2001 | OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); | ||
2002 | udelay(100); | ||
2003 | lvds_gen_cntl &= ~(LVDS_ON | LVDS_EN); | ||
2004 | OUTREG(LVDS_GEN_CNTL, lvds_gen_cntl); | ||
2005 | lvds_gen_cntl &= ~(LVDS_DIGON); | ||
2006 | rinfo->pending_lvds_gen_cntl = lvds_gen_cntl; | ||
2007 | mod_timer(&rinfo->lvds_timer, | ||
2008 | jiffies + msecs_to_jiffies(rinfo->panel_info.pwr_delay)); | ||
2009 | if (rinfo->is_mobility || rinfo->is_IGP) | ||
2010 | OUTPLL(PIXCLKS_CNTL, tmpPixclksCntl); | ||
2011 | } | ||
2012 | rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK; | ||
2013 | rinfo->init_state.lvds_gen_cntl |= (lvds_gen_cntl & LVDS_STATE_MASK); | ||
2014 | |||
2015 | return 0; | ||
2016 | } | ||
2017 | |||
2018 | |||
2019 | static int radeon_set_backlight_level(int level, void *data) | ||
2020 | { | ||
2021 | return radeon_set_backlight_enable(1, level, data); | ||
2022 | } | ||
2023 | #endif /* CONFIG_PMAC_BACKLIGHT */ | ||
2024 | |||
2025 | |||
2026 | /* | 1898 | /* |
2027 | * This reconfigure the card's internal memory map. In theory, we'd like | 1899 | * This reconfigure the card's internal memory map. In theory, we'd like |
2028 | * to setup the card's memory at the same address as it's PCI bus address, | 1900 | * to setup the card's memory at the same address as it's PCI bus address, |
@@ -2477,14 +2349,7 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev, | |||
2477 | MTRR_TYPE_WRCOMB, 1); | 2349 | MTRR_TYPE_WRCOMB, 1); |
2478 | #endif | 2350 | #endif |
2479 | 2351 | ||
2480 | #ifdef CONFIG_PMAC_BACKLIGHT | 2352 | radeonfb_bl_init(rinfo); |
2481 | if (rinfo->mon1_type == MT_LCD) { | ||
2482 | register_backlight_controller(&radeon_backlight_controller, | ||
2483 | rinfo, "ati"); | ||
2484 | register_backlight_controller(&radeon_backlight_controller, | ||
2485 | rinfo, "mnca"); | ||
2486 | } | ||
2487 | #endif | ||
2488 | 2353 | ||
2489 | printk ("radeonfb (%s): %s\n", pci_name(rinfo->pdev), rinfo->name); | 2354 | printk ("radeonfb (%s): %s\n", pci_name(rinfo->pdev), rinfo->name); |
2490 | 2355 | ||
@@ -2528,7 +2393,8 @@ static void __devexit radeonfb_pci_unregister (struct pci_dev *pdev) | |||
2528 | 2393 | ||
2529 | if (!rinfo) | 2394 | if (!rinfo) |
2530 | return; | 2395 | return; |
2531 | 2396 | ||
2397 | radeonfb_bl_exit(rinfo); | ||
2532 | radeonfb_pm_exit(rinfo); | 2398 | radeonfb_pm_exit(rinfo); |
2533 | 2399 | ||
2534 | if (rinfo->mon1_EDID) | 2400 | if (rinfo->mon1_EDID) |