Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[POWERPC] Fix for via-pmu based backlight control

This fixes a few issues with via-pmu based backlight control.

First, it fixes a sign problem with the setup of the backlight
curve since the `range' value there -can- (and will) go negative.

Then, it reworks the interaction between this and the via-pmu sleep
code to properly restore backlight on wakeup from sleep.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Benjamin Herrenschmidt and committed by
Paul Mackerras
0094f2cd 7ac5dde9

+42 -34
+29 -19
drivers/macintosh/via-pmu-backlight.c
··· 22 22 23 23 static void pmu_backlight_init_curve(u8 off, u8 min, u8 max) 24 24 { 25 - unsigned int i, flat, count, range = (max - min); 25 + int i, flat, count, range = (max - min); 26 26 27 27 bl_curve[0] = off; 28 28 ··· 68 68 return pmulevel; 69 69 } 70 70 71 - static int pmu_backlight_update_status(struct backlight_device *bd) 71 + static int __pmu_backlight_update_status(struct backlight_device *bd) 72 72 { 73 73 struct adb_request req; 74 - unsigned long flags; 75 74 int level = bd->props.brightness; 76 75 77 - spin_lock_irqsave(&pmu_backlight_lock, flags); 78 - 79 - /* Don't update brightness when sleeping */ 80 - if (sleeping) 81 - goto out; 82 76 83 77 if (bd->props.power != FB_BLANK_UNBLANK || 84 78 bd->props.fb_blank != FB_BLANK_UNBLANK) ··· 93 99 pmu_wait_complete(&req); 94 100 } 95 101 96 - out: 97 - spin_unlock_irqrestore(&pmu_backlight_lock, flags); 98 - 99 102 return 0; 100 103 } 104 + 105 + static int pmu_backlight_update_status(struct backlight_device *bd) 106 + { 107 + unsigned long flags; 108 + int rc = 0; 109 + 110 + spin_lock_irqsave(&pmu_backlight_lock, flags); 111 + /* Don't update brightness when sleeping */ 112 + if (!sleeping) 113 + rc = __pmu_backlight_update_status(bd); 114 + spin_unlock_irqrestore(&pmu_backlight_lock, flags); 115 + return rc; 116 + } 117 + 101 118 102 119 static int pmu_backlight_get_brightness(struct backlight_device *bd) 103 120 { ··· 128 123 129 124 spin_lock_irqsave(&pmu_backlight_lock, flags); 130 125 sleeping = sleep; 126 + if (pmac_backlight) { 127 + if (sleep) { 128 + struct adb_request req; 129 + 130 + pmu_request(&req, NULL, 2, PMU_POWER_CTRL, 131 + PMU_POW_BACKLIGHT | PMU_POW_OFF); 132 + pmu_wait_complete(&req); 133 + } else 134 + __pmu_backlight_update_status(pmac_backlight); 135 + } 131 136 spin_unlock_irqrestore(&pmu_backlight_lock, flags); 132 137 } 133 138 #endif /* CONFIG_PM */ ··· 163 148 164 149 bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data); 165 150 if (IS_ERR(bd)) { 166 - printk("pmubl: Backlight registration failed\n"); 167 - goto error; 151 + printk(KERN_ERR "PMU Backlight registration failed\n"); 152 + return; 168 153 } 169 154 bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; 170 155 pmu_backlight_init_curve(0x7F, 0x46, 0x0E); ··· 186 171 bd->props.power = FB_BLANK_UNBLANK; 187 172 backlight_update_status(bd); 188 173 189 - printk("pmubl: Backlight initialized (%s)\n", name); 190 - 191 - return; 192 - 193 - error: 194 - return; 174 + printk(KERN_INFO "PMU Backlight initialized (%s)\n", name); 195 175 }
+11 -15
drivers/macintosh/via-pmu.c
··· 1748 1748 out_8(&via[IER], IER_SET | SR_INT | CB1_INT); 1749 1749 } 1750 1750 1751 - extern void pmu_backlight_set_sleep(int sleep); 1752 - 1753 1751 #define GRACKLE_PM (1<<7) 1754 1752 #define GRACKLE_DOZE (1<<5) 1755 1753 #define GRACKLE_NAP (1<<4) ··· 2158 2160 #if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32) 2159 2161 static void pmac_suspend_disable_irqs(void) 2160 2162 { 2161 - #ifdef CONFIG_PMAC_BACKLIGHT 2162 - /* Tell backlight code not to muck around with the chip anymore */ 2163 - pmu_backlight_set_sleep(1); 2164 - #endif 2165 - 2166 2163 /* Call platform functions marked "on sleep" */ 2167 2164 pmac_pfunc_i2c_suspend(); 2168 2165 pmac_pfunc_base_suspend(); ··· 2200 2207 return error; 2201 2208 2202 2209 mdelay(100); 2203 - 2204 - #ifdef CONFIG_PMAC_BACKLIGHT 2205 - /* Tell backlight code it can use the chip again */ 2206 - pmu_backlight_set_sleep(0); 2207 - #endif 2208 2210 2209 2211 return 0; 2210 2212 } ··· 2445 2457 if (state.event != PM_EVENT_SUSPEND || pmu_sys_suspended) 2446 2458 return 0; 2447 2459 2448 - /* Suspend PMU event interrupts */ 2460 + /* Suspend PMU event interrupts */\ 2449 2461 pmu_suspend(); 2450 - 2451 2462 pmu_sys_suspended = 1; 2463 + 2464 + #ifdef CONFIG_PMAC_BACKLIGHT 2465 + /* Tell backlight code not to muck around with the chip anymore */ 2466 + pmu_backlight_set_sleep(1); 2467 + #endif 2468 + 2452 2469 return 0; 2453 2470 } 2454 2471 ··· 2468 2475 pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2); 2469 2476 pmu_wait_complete(&req); 2470 2477 2478 + #ifdef CONFIG_PMAC_BACKLIGHT 2479 + /* Tell backlight code it can use the chip again */ 2480 + pmu_backlight_set_sleep(0); 2481 + #endif 2471 2482 /* Resume PMU event interrupts */ 2472 2483 pmu_resume(); 2473 - 2474 2484 pmu_sys_suspended = 0; 2475 2485 2476 2486 return 0;
+2
include/linux/pmu.h
··· 159 159 extern int pmu_present(void); 160 160 extern int pmu_get_model(void); 161 161 162 + extern void pmu_backlight_set_sleep(int sleep); 163 + 162 164 #define PMU_MAX_BATTERIES 2 163 165 164 166 /* values for pmu_power_flags */