diff options
Diffstat (limited to 'drivers/macintosh/via-pmu-backlight.c')
-rw-r--r-- | drivers/macintosh/via-pmu-backlight.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/drivers/macintosh/via-pmu-backlight.c b/drivers/macintosh/via-pmu-backlight.c index 7e27071746e4..741a2e3f4fc6 100644 --- a/drivers/macintosh/via-pmu-backlight.c +++ b/drivers/macintosh/via-pmu-backlight.c | |||
@@ -22,7 +22,7 @@ static u8 bl_curve[FB_BACKLIGHT_LEVELS]; | |||
22 | 22 | ||
23 | static void pmu_backlight_init_curve(u8 off, u8 min, u8 max) | 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 | bl_curve[0] = off; | 27 | bl_curve[0] = off; |
28 | 28 | ||
@@ -68,17 +68,11 @@ static int pmu_backlight_get_level_brightness(int level) | |||
68 | return pmulevel; | 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 | struct adb_request req; | 73 | struct adb_request req; |
74 | unsigned long flags; | ||
75 | int level = bd->props.brightness; | 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 | if (bd->props.power != FB_BLANK_UNBLANK || | 77 | if (bd->props.power != FB_BLANK_UNBLANK || |
84 | bd->props.fb_blank != FB_BLANK_UNBLANK) | 78 | bd->props.fb_blank != FB_BLANK_UNBLANK) |
@@ -99,12 +93,23 @@ static int pmu_backlight_update_status(struct backlight_device *bd) | |||
99 | pmu_wait_complete(&req); | 93 | pmu_wait_complete(&req); |
100 | } | 94 | } |
101 | 95 | ||
102 | out: | ||
103 | spin_unlock_irqrestore(&pmu_backlight_lock, flags); | ||
104 | |||
105 | return 0; | 96 | return 0; |
106 | } | 97 | } |
107 | 98 | ||
99 | static int pmu_backlight_update_status(struct backlight_device *bd) | ||
100 | { | ||
101 | unsigned long flags; | ||
102 | int rc = 0; | ||
103 | |||
104 | spin_lock_irqsave(&pmu_backlight_lock, flags); | ||
105 | /* Don't update brightness when sleeping */ | ||
106 | if (!sleeping) | ||
107 | rc = __pmu_backlight_update_status(bd); | ||
108 | spin_unlock_irqrestore(&pmu_backlight_lock, flags); | ||
109 | return rc; | ||
110 | } | ||
111 | |||
112 | |||
108 | static int pmu_backlight_get_brightness(struct backlight_device *bd) | 113 | static int pmu_backlight_get_brightness(struct backlight_device *bd) |
109 | { | 114 | { |
110 | return bd->props.brightness; | 115 | return bd->props.brightness; |
@@ -123,6 +128,16 @@ void pmu_backlight_set_sleep(int sleep) | |||
123 | 128 | ||
124 | spin_lock_irqsave(&pmu_backlight_lock, flags); | 129 | spin_lock_irqsave(&pmu_backlight_lock, flags); |
125 | sleeping = sleep; | 130 | sleeping = sleep; |
131 | if (pmac_backlight) { | ||
132 | if (sleep) { | ||
133 | struct adb_request req; | ||
134 | |||
135 | pmu_request(&req, NULL, 2, PMU_POWER_CTRL, | ||
136 | PMU_POW_BACKLIGHT | PMU_POW_OFF); | ||
137 | pmu_wait_complete(&req); | ||
138 | } else | ||
139 | __pmu_backlight_update_status(pmac_backlight); | ||
140 | } | ||
126 | spin_unlock_irqrestore(&pmu_backlight_lock, flags); | 141 | spin_unlock_irqrestore(&pmu_backlight_lock, flags); |
127 | } | 142 | } |
128 | #endif /* CONFIG_PM */ | 143 | #endif /* CONFIG_PM */ |
@@ -148,8 +163,8 @@ void __init pmu_backlight_init() | |||
148 | 163 | ||
149 | bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data); | 164 | bd = backlight_device_register(name, NULL, NULL, &pmu_backlight_data); |
150 | if (IS_ERR(bd)) { | 165 | if (IS_ERR(bd)) { |
151 | printk("pmubl: Backlight registration failed\n"); | 166 | printk(KERN_ERR "PMU Backlight registration failed\n"); |
152 | goto error; | 167 | return; |
153 | } | 168 | } |
154 | bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; | 169 | bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1; |
155 | pmu_backlight_init_curve(0x7F, 0x46, 0x0E); | 170 | pmu_backlight_init_curve(0x7F, 0x46, 0x0E); |
@@ -171,10 +186,5 @@ void __init pmu_backlight_init() | |||
171 | bd->props.power = FB_BLANK_UNBLANK; | 186 | bd->props.power = FB_BLANK_UNBLANK; |
172 | backlight_update_status(bd); | 187 | backlight_update_status(bd); |
173 | 188 | ||
174 | printk("pmubl: Backlight initialized (%s)\n", name); | 189 | printk(KERN_INFO "PMU Backlight initialized (%s)\n", name); |
175 | |||
176 | return; | ||
177 | |||
178 | error: | ||
179 | return; | ||
180 | } | 190 | } |