diff options
Diffstat (limited to 'sound/ppc')
-rw-r--r-- | sound/ppc/Kconfig | 2 | ||||
-rw-r--r-- | sound/ppc/Makefile | 2 | ||||
-rw-r--r-- | sound/ppc/pmac.c | 8 | ||||
-rw-r--r-- | sound/ppc/pmac.h | 4 | ||||
-rw-r--r-- | sound/ppc/powermac.c | 7 | ||||
-rw-r--r-- | sound/ppc/toonie.c | 379 | ||||
-rw-r--r-- | sound/ppc/tumbler.c | 28 |
7 files changed, 420 insertions, 10 deletions
diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig index b0a9ebf8bf3b..75213bf4d567 100644 --- a/sound/ppc/Kconfig +++ b/sound/ppc/Kconfig | |||
@@ -11,7 +11,7 @@ comment "ALSA PowerMac requires INPUT" | |||
11 | 11 | ||
12 | config SND_POWERMAC | 12 | config SND_POWERMAC |
13 | tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)" | 13 | tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)" |
14 | depends on SND && I2C && INPUT | 14 | depends on SND && I2C && INPUT && PPC_PMAC |
15 | select SND_PCM | 15 | select SND_PCM |
16 | help | 16 | help |
17 | Say Y here to include support for the integrated sound device. | 17 | Say Y here to include support for the integrated sound device. |
diff --git a/sound/ppc/Makefile b/sound/ppc/Makefile index 4d95c652c8ca..d6ba9959097b 100644 --- a/sound/ppc/Makefile +++ b/sound/ppc/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> | 3 | # Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> |
4 | # | 4 | # |
5 | 5 | ||
6 | snd-powermac-objs := powermac.o pmac.o awacs.o burgundy.o daca.o tumbler.o keywest.o beep.o | 6 | snd-powermac-objs := powermac.o pmac.o awacs.o burgundy.o daca.o tumbler.o toonie.o keywest.o beep.o |
7 | 7 | ||
8 | # Toplevel Module Dependency | 8 | # Toplevel Module Dependency |
9 | obj-$(CONFIG_SND_POWERMAC) += snd-powermac.o | 9 | obj-$(CONFIG_SND_POWERMAC) += snd-powermac.o |
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 3bf5f069a03d..32d94754acf8 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c | |||
@@ -986,7 +986,13 @@ static int __init snd_pmac_detect(pmac_t *chip) | |||
986 | chip->num_freqs = ARRAY_SIZE(tumbler_freqs); | 986 | chip->num_freqs = ARRAY_SIZE(tumbler_freqs); |
987 | chip->model = PMAC_SNAPPER; | 987 | chip->model = PMAC_SNAPPER; |
988 | chip->can_byte_swap = 0; /* FIXME: check this */ | 988 | chip->can_byte_swap = 0; /* FIXME: check this */ |
989 | chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */ | 989 | chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */ |
990 | break; | ||
991 | case 0x3a: | ||
992 | chip->num_freqs = ARRAY_SIZE(tumbler_freqs); | ||
993 | chip->model = PMAC_TOONIE; | ||
994 | chip->can_byte_swap = 0; /* FIXME: check this */ | ||
995 | chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */ | ||
990 | break; | 996 | break; |
991 | } | 997 | } |
992 | } | 998 | } |
diff --git a/sound/ppc/pmac.h b/sound/ppc/pmac.h index dc6c99dd14e7..0a84c05f714b 100644 --- a/sound/ppc/pmac.h +++ b/sound/ppc/pmac.h | |||
@@ -94,7 +94,8 @@ struct snd_pmac_stream { | |||
94 | */ | 94 | */ |
95 | 95 | ||
96 | enum snd_pmac_model { | 96 | enum snd_pmac_model { |
97 | PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER, PMAC_SNAPPER | 97 | PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER, |
98 | PMAC_SNAPPER, PMAC_TOONIE | ||
98 | }; | 99 | }; |
99 | 100 | ||
100 | struct snd_pmac { | 101 | struct snd_pmac { |
@@ -191,6 +192,7 @@ int snd_pmac_burgundy_init(pmac_t *chip); | |||
191 | int snd_pmac_daca_init(pmac_t *chip); | 192 | int snd_pmac_daca_init(pmac_t *chip); |
192 | int snd_pmac_tumbler_init(pmac_t *chip); | 193 | int snd_pmac_tumbler_init(pmac_t *chip); |
193 | int snd_pmac_tumbler_post_init(void); | 194 | int snd_pmac_tumbler_post_init(void); |
195 | int snd_pmac_toonie_init(pmac_t *chip); | ||
194 | 196 | ||
195 | /* i2c functions */ | 197 | /* i2c functions */ |
196 | typedef struct snd_pmac_keywest { | 198 | typedef struct snd_pmac_keywest { |
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index 8f1953a8e290..231f6432ea6d 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c | |||
@@ -95,6 +95,13 @@ static int __init snd_pmac_probe(void) | |||
95 | if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0) | 95 | if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0) |
96 | goto __error; | 96 | goto __error; |
97 | break; | 97 | break; |
98 | case PMAC_TOONIE: | ||
99 | strcpy(card->driver, "PMac Toonie"); | ||
100 | strcpy(card->shortname, "PowerMac Toonie"); | ||
101 | strcpy(card->longname, card->shortname); | ||
102 | if ((err = snd_pmac_toonie_init(chip)) < 0) | ||
103 | goto __error; | ||
104 | break; | ||
98 | case PMAC_AWACS: | 105 | case PMAC_AWACS: |
99 | case PMAC_SCREAMER: | 106 | case PMAC_SCREAMER: |
100 | name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS"; | 107 | name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS"; |
diff --git a/sound/ppc/toonie.c b/sound/ppc/toonie.c new file mode 100644 index 000000000000..082bc4babab5 --- /dev/null +++ b/sound/ppc/toonie.c | |||
@@ -0,0 +1,379 @@ | |||
1 | /* | ||
2 | * Mac Mini "toonie" mixer control | ||
3 | * | ||
4 | * Copyright (c) 2005 by Benjamin Herrenschmidt <benh@kernel.crashing.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <sound/driver.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/i2c-dev.h> | ||
26 | #include <linux/kmod.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <sound/core.h> | ||
30 | #include <asm/io.h> | ||
31 | #include <asm/irq.h> | ||
32 | #include <asm/machdep.h> | ||
33 | #include <asm/pmac_feature.h> | ||
34 | #include "pmac.h" | ||
35 | |||
36 | #undef DEBUG | ||
37 | |||
38 | #ifdef DEBUG | ||
39 | #define DBG(fmt...) printk(fmt) | ||
40 | #else | ||
41 | #define DBG(fmt...) | ||
42 | #endif | ||
43 | |||
44 | struct pmac_gpio { | ||
45 | unsigned int addr; | ||
46 | u8 active_val; | ||
47 | u8 inactive_val; | ||
48 | u8 active_state; | ||
49 | }; | ||
50 | |||
51 | struct pmac_toonie | ||
52 | { | ||
53 | struct pmac_gpio hp_detect_gpio; | ||
54 | struct pmac_gpio hp_mute_gpio; | ||
55 | struct pmac_gpio amp_mute_gpio; | ||
56 | int hp_detect_irq; | ||
57 | int auto_mute_notify; | ||
58 | struct work_struct detect_work; | ||
59 | }; | ||
60 | |||
61 | |||
62 | /* | ||
63 | * gpio access | ||
64 | */ | ||
65 | #define do_gpio_write(gp, val) \ | ||
66 | pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, (gp)->addr, val) | ||
67 | #define do_gpio_read(gp) \ | ||
68 | pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, (gp)->addr, 0) | ||
69 | #define tumbler_gpio_free(gp) /* NOP */ | ||
70 | |||
71 | static void write_audio_gpio(struct pmac_gpio *gp, int active) | ||
72 | { | ||
73 | if (! gp->addr) | ||
74 | return; | ||
75 | active = active ? gp->active_val : gp->inactive_val; | ||
76 | do_gpio_write(gp, active); | ||
77 | DBG("(I) gpio %x write %d\n", gp->addr, active); | ||
78 | } | ||
79 | |||
80 | static int check_audio_gpio(struct pmac_gpio *gp) | ||
81 | { | ||
82 | int ret; | ||
83 | |||
84 | if (! gp->addr) | ||
85 | return 0; | ||
86 | |||
87 | ret = do_gpio_read(gp); | ||
88 | |||
89 | return (ret & 0xd) == (gp->active_val & 0xd); | ||
90 | } | ||
91 | |||
92 | static int read_audio_gpio(struct pmac_gpio *gp) | ||
93 | { | ||
94 | int ret; | ||
95 | if (! gp->addr) | ||
96 | return 0; | ||
97 | ret = ((do_gpio_read(gp) & 0x02) !=0); | ||
98 | return ret == gp->active_state; | ||
99 | } | ||
100 | |||
101 | |||
102 | enum { TOONIE_MUTE_HP, TOONIE_MUTE_AMP }; | ||
103 | |||
104 | static int toonie_get_mute_switch(snd_kcontrol_t *kcontrol, | ||
105 | snd_ctl_elem_value_t *ucontrol) | ||
106 | { | ||
107 | pmac_t *chip = snd_kcontrol_chip(kcontrol); | ||
108 | struct pmac_toonie *mix = chip->mixer_data; | ||
109 | struct pmac_gpio *gp; | ||
110 | |||
111 | if (mix == NULL) | ||
112 | return -ENODEV; | ||
113 | switch(kcontrol->private_value) { | ||
114 | case TOONIE_MUTE_HP: | ||
115 | gp = &mix->hp_mute_gpio; | ||
116 | break; | ||
117 | case TOONIE_MUTE_AMP: | ||
118 | gp = &mix->amp_mute_gpio; | ||
119 | break; | ||
120 | default: | ||
121 | return -EINVAL;; | ||
122 | } | ||
123 | ucontrol->value.integer.value[0] = !check_audio_gpio(gp); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static int toonie_put_mute_switch(snd_kcontrol_t *kcontrol, | ||
128 | snd_ctl_elem_value_t *ucontrol) | ||
129 | { | ||
130 | pmac_t *chip = snd_kcontrol_chip(kcontrol); | ||
131 | struct pmac_toonie *mix = chip->mixer_data; | ||
132 | struct pmac_gpio *gp; | ||
133 | int val; | ||
134 | |||
135 | if (chip->update_automute && chip->auto_mute) | ||
136 | return 0; /* don't touch in the auto-mute mode */ | ||
137 | |||
138 | if (mix == NULL) | ||
139 | return -ENODEV; | ||
140 | |||
141 | switch(kcontrol->private_value) { | ||
142 | case TOONIE_MUTE_HP: | ||
143 | gp = &mix->hp_mute_gpio; | ||
144 | break; | ||
145 | case TOONIE_MUTE_AMP: | ||
146 | gp = &mix->amp_mute_gpio; | ||
147 | break; | ||
148 | default: | ||
149 | return -EINVAL;; | ||
150 | } | ||
151 | val = ! check_audio_gpio(gp); | ||
152 | if (val != ucontrol->value.integer.value[0]) { | ||
153 | write_audio_gpio(gp, ! ucontrol->value.integer.value[0]); | ||
154 | return 1; | ||
155 | } | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static snd_kcontrol_new_t toonie_hp_sw __initdata = { | ||
160 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
161 | .name = "Headphone Playback Switch", | ||
162 | .info = snd_pmac_boolean_mono_info, | ||
163 | .get = toonie_get_mute_switch, | ||
164 | .put = toonie_put_mute_switch, | ||
165 | .private_value = TOONIE_MUTE_HP, | ||
166 | }; | ||
167 | static snd_kcontrol_new_t toonie_speaker_sw __initdata = { | ||
168 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
169 | .name = "PC Speaker Playback Switch", | ||
170 | .info = snd_pmac_boolean_mono_info, | ||
171 | .get = toonie_get_mute_switch, | ||
172 | .put = toonie_put_mute_switch, | ||
173 | .private_value = TOONIE_MUTE_AMP, | ||
174 | }; | ||
175 | |||
176 | /* | ||
177 | * auto-mute stuffs | ||
178 | */ | ||
179 | static int toonie_detect_headphone(pmac_t *chip) | ||
180 | { | ||
181 | struct pmac_toonie *mix = chip->mixer_data; | ||
182 | int detect = 0; | ||
183 | |||
184 | if (mix->hp_detect_gpio.addr) | ||
185 | detect |= read_audio_gpio(&mix->hp_detect_gpio); | ||
186 | return detect; | ||
187 | } | ||
188 | |||
189 | static void toonie_check_mute(pmac_t *chip, struct pmac_gpio *gp, int val, | ||
190 | int do_notify, snd_kcontrol_t *sw) | ||
191 | { | ||
192 | if (check_audio_gpio(gp) != val) { | ||
193 | write_audio_gpio(gp, val); | ||
194 | if (do_notify) | ||
195 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
196 | &sw->id); | ||
197 | } | ||
198 | } | ||
199 | |||
200 | static void toonie_detect_handler(void *self) | ||
201 | { | ||
202 | pmac_t *chip = (pmac_t*) self; | ||
203 | struct pmac_toonie *mix; | ||
204 | int headphone; | ||
205 | |||
206 | if (!chip) | ||
207 | return; | ||
208 | |||
209 | mix = chip->mixer_data; | ||
210 | snd_assert(mix, return); | ||
211 | |||
212 | headphone = toonie_detect_headphone(chip); | ||
213 | |||
214 | DBG("headphone: %d, lineout: %d\n", headphone, lineout); | ||
215 | |||
216 | if (headphone) { | ||
217 | /* unmute headphone/lineout & mute speaker */ | ||
218 | toonie_check_mute(chip, &mix->hp_mute_gpio, 0, | ||
219 | mix->auto_mute_notify, chip->master_sw_ctl); | ||
220 | toonie_check_mute(chip, &mix->amp_mute_gpio, 1, | ||
221 | mix->auto_mute_notify, chip->speaker_sw_ctl); | ||
222 | } else { | ||
223 | /* unmute speaker, mute others */ | ||
224 | toonie_check_mute(chip, &mix->amp_mute_gpio, 0, | ||
225 | mix->auto_mute_notify, chip->speaker_sw_ctl); | ||
226 | toonie_check_mute(chip, &mix->hp_mute_gpio, 1, | ||
227 | mix->auto_mute_notify, chip->master_sw_ctl); | ||
228 | } | ||
229 | if (mix->auto_mute_notify) { | ||
230 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
231 | &chip->hp_detect_ctl->id); | ||
232 | } | ||
233 | } | ||
234 | |||
235 | static void toonie_update_automute(pmac_t *chip, int do_notify) | ||
236 | { | ||
237 | if (chip->auto_mute) { | ||
238 | struct pmac_toonie *mix; | ||
239 | mix = chip->mixer_data; | ||
240 | snd_assert(mix, return); | ||
241 | mix->auto_mute_notify = do_notify; | ||
242 | schedule_work(&mix->detect_work); | ||
243 | } | ||
244 | } | ||
245 | |||
246 | /* interrupt - headphone plug changed */ | ||
247 | static irqreturn_t toonie_hp_intr(int irq, void *devid, struct pt_regs *regs) | ||
248 | { | ||
249 | pmac_t *chip = devid; | ||
250 | |||
251 | if (chip->update_automute && chip->initialized) { | ||
252 | chip->update_automute(chip, 1); | ||
253 | return IRQ_HANDLED; | ||
254 | } | ||
255 | return IRQ_NONE; | ||
256 | } | ||
257 | |||
258 | /* look for audio gpio device */ | ||
259 | static int find_audio_gpio(const char *name, const char *platform, | ||
260 | struct pmac_gpio *gp) | ||
261 | { | ||
262 | struct device_node *np; | ||
263 | u32 *base, addr; | ||
264 | |||
265 | if (! (np = find_devices("gpio"))) | ||
266 | return -ENODEV; | ||
267 | |||
268 | for (np = np->child; np; np = np->sibling) { | ||
269 | char *property = get_property(np, "audio-gpio", NULL); | ||
270 | if (property && strcmp(property, name) == 0) | ||
271 | break; | ||
272 | if (device_is_compatible(np, name)) | ||
273 | break; | ||
274 | } | ||
275 | if (np == NULL) | ||
276 | return -ENODEV; | ||
277 | |||
278 | base = (u32 *)get_property(np, "AAPL,address", NULL); | ||
279 | if (! base) { | ||
280 | base = (u32 *)get_property(np, "reg", NULL); | ||
281 | if (!base) { | ||
282 | DBG("(E) cannot find address for device %s !\n", name); | ||
283 | return -ENODEV; | ||
284 | } | ||
285 | addr = *base; | ||
286 | if (addr < 0x50) | ||
287 | addr += 0x50; | ||
288 | } else | ||
289 | addr = *base; | ||
290 | |||
291 | gp->addr = addr & 0x0000ffff; | ||
292 | |||
293 | /* Try to find the active state, default to 0 ! */ | ||
294 | base = (u32 *)get_property(np, "audio-gpio-active-state", NULL); | ||
295 | if (base) { | ||
296 | gp->active_state = *base; | ||
297 | gp->active_val = (*base) ? 0x5 : 0x4; | ||
298 | gp->inactive_val = (*base) ? 0x4 : 0x5; | ||
299 | } else { | ||
300 | u32 *prop = NULL; | ||
301 | gp->active_state = 0; | ||
302 | gp->active_val = 0x4; | ||
303 | gp->inactive_val = 0x5; | ||
304 | /* Here are some crude hacks to extract the GPIO polarity and | ||
305 | * open collector informations out of the do-platform script | ||
306 | * as we don't yet have an interpreter for these things | ||
307 | */ | ||
308 | if (platform) | ||
309 | prop = (u32 *)get_property(np, platform, NULL); | ||
310 | if (prop) { | ||
311 | if (prop[3] == 0x9 && prop[4] == 0x9) { | ||
312 | gp->active_val = 0xd; | ||
313 | gp->inactive_val = 0xc; | ||
314 | } | ||
315 | if (prop[3] == 0x1 && prop[4] == 0x1) { | ||
316 | gp->active_val = 0x5; | ||
317 | gp->inactive_val = 0x4; | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | |||
322 | DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n", | ||
323 | name, gp->addr, gp->active_state); | ||
324 | |||
325 | return (np->n_intrs > 0) ? np->intrs[0].line : 0; | ||
326 | } | ||
327 | |||
328 | static void toonie_cleanup(pmac_t *chip) | ||
329 | { | ||
330 | struct pmac_toonie *mix = chip->mixer_data; | ||
331 | if (! mix) | ||
332 | return; | ||
333 | if (mix->hp_detect_irq >= 0) | ||
334 | free_irq(mix->hp_detect_irq, chip); | ||
335 | kfree(mix); | ||
336 | chip->mixer_data = NULL; | ||
337 | } | ||
338 | |||
339 | int snd_pmac_toonie_init(pmac_t *chip) | ||
340 | { | ||
341 | struct pmac_toonie *mix; | ||
342 | |||
343 | mix = kmalloc(sizeof(*mix), GFP_KERNEL); | ||
344 | if (! mix) | ||
345 | return -ENOMEM; | ||
346 | |||
347 | chip->mixer_data = mix; | ||
348 | chip->mixer_free = toonie_cleanup; | ||
349 | |||
350 | find_audio_gpio("headphone-mute", NULL, &mix->hp_mute_gpio); | ||
351 | find_audio_gpio("amp-mute", NULL, &mix->amp_mute_gpio); | ||
352 | mix->hp_detect_irq = find_audio_gpio("headphone-detect", | ||
353 | NULL, &mix->hp_detect_gpio); | ||
354 | |||
355 | strcpy(chip->card->mixername, "PowerMac Toonie"); | ||
356 | |||
357 | chip->master_sw_ctl = snd_ctl_new1(&toonie_hp_sw, chip); | ||
358 | snd_ctl_add(chip->card, chip->master_sw_ctl); | ||
359 | |||
360 | chip->speaker_sw_ctl = snd_ctl_new1(&toonie_speaker_sw, chip); | ||
361 | snd_ctl_add(chip->card, chip->speaker_sw_ctl); | ||
362 | |||
363 | INIT_WORK(&mix->detect_work, toonie_detect_handler, (void *)chip); | ||
364 | |||
365 | if (mix->hp_detect_irq >= 0) { | ||
366 | snd_pmac_add_automute(chip); | ||
367 | |||
368 | chip->detect_headphone = toonie_detect_headphone; | ||
369 | chip->update_automute = toonie_update_automute; | ||
370 | toonie_update_automute(chip, 0); | ||
371 | |||
372 | if (request_irq(mix->hp_detect_irq, toonie_hp_intr, 0, | ||
373 | "Sound Headphone Detection", chip) < 0) | ||
374 | mix->hp_detect_irq = -1; | ||
375 | } | ||
376 | |||
377 | return 0; | ||
378 | } | ||
379 | |||
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index c71807e069ee..9332237cb6a4 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c | |||
@@ -99,6 +99,7 @@ typedef struct pmac_tumbler_t { | |||
99 | pmac_gpio_t hp_detect; | 99 | pmac_gpio_t hp_detect; |
100 | int headphone_irq; | 100 | int headphone_irq; |
101 | int lineout_irq; | 101 | int lineout_irq; |
102 | unsigned int save_master_vol[2]; | ||
102 | unsigned int master_vol[2]; | 103 | unsigned int master_vol[2]; |
103 | unsigned int save_master_switch[2]; | 104 | unsigned int save_master_switch[2]; |
104 | unsigned int master_switch[2]; | 105 | unsigned int master_switch[2]; |
@@ -177,11 +178,22 @@ static void write_audio_gpio(pmac_gpio_t *gp, int active) | |||
177 | if (! gp->addr) | 178 | if (! gp->addr) |
178 | return; | 179 | return; |
179 | active = active ? gp->active_val : gp->inactive_val; | 180 | active = active ? gp->active_val : gp->inactive_val; |
180 | |||
181 | do_gpio_write(gp, active); | 181 | do_gpio_write(gp, active); |
182 | DBG("(I) gpio %x write %d\n", gp->addr, active); | 182 | DBG("(I) gpio %x write %d\n", gp->addr, active); |
183 | } | 183 | } |
184 | 184 | ||
185 | static int check_audio_gpio(pmac_gpio_t *gp) | ||
186 | { | ||
187 | int ret; | ||
188 | |||
189 | if (! gp->addr) | ||
190 | return 0; | ||
191 | |||
192 | ret = do_gpio_read(gp); | ||
193 | |||
194 | return (ret & 0xd) == (gp->active_val & 0xd); | ||
195 | } | ||
196 | |||
185 | static int read_audio_gpio(pmac_gpio_t *gp) | 197 | static int read_audio_gpio(pmac_gpio_t *gp) |
186 | { | 198 | { |
187 | int ret; | 199 | int ret; |
@@ -683,7 +695,7 @@ static int tumbler_get_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ | |||
683 | } | 695 | } |
684 | if (gp == NULL) | 696 | if (gp == NULL) |
685 | return -EINVAL; | 697 | return -EINVAL; |
686 | ucontrol->value.integer.value[0] = ! read_audio_gpio(gp); | 698 | ucontrol->value.integer.value[0] = !check_audio_gpio(gp); |
687 | return 0; | 699 | return 0; |
688 | } | 700 | } |
689 | 701 | ||
@@ -711,7 +723,7 @@ static int tumbler_put_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ | |||
711 | } | 723 | } |
712 | if (gp == NULL) | 724 | if (gp == NULL) |
713 | return -EINVAL; | 725 | return -EINVAL; |
714 | val = ! read_audio_gpio(gp); | 726 | val = ! check_audio_gpio(gp); |
715 | if (val != ucontrol->value.integer.value[0]) { | 727 | if (val != ucontrol->value.integer.value[0]) { |
716 | write_audio_gpio(gp, ! ucontrol->value.integer.value[0]); | 728 | write_audio_gpio(gp, ! ucontrol->value.integer.value[0]); |
717 | return 1; | 729 | return 1; |
@@ -897,11 +909,11 @@ static int tumbler_detect_lineout(pmac_t *chip) | |||
897 | 909 | ||
898 | static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw) | 910 | static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw) |
899 | { | 911 | { |
900 | //pmac_tumbler_t *mix = chip->mixer_data; | 912 | if (check_audio_gpio(gp) != val) { |
901 | if (val != read_audio_gpio(gp)) { | ||
902 | write_audio_gpio(gp, val); | 913 | write_audio_gpio(gp, val); |
903 | if (do_notify) | 914 | if (do_notify) |
904 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &sw->id); | 915 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, |
916 | &sw->id); | ||
905 | } | 917 | } |
906 | } | 918 | } |
907 | 919 | ||
@@ -1128,6 +1140,8 @@ static void tumbler_suspend(pmac_t *chip) | |||
1128 | disable_irq(mix->lineout_irq); | 1140 | disable_irq(mix->lineout_irq); |
1129 | mix->save_master_switch[0] = mix->master_switch[0]; | 1141 | mix->save_master_switch[0] = mix->master_switch[0]; |
1130 | mix->save_master_switch[1] = mix->master_switch[1]; | 1142 | mix->save_master_switch[1] = mix->master_switch[1]; |
1143 | mix->save_master_vol[0] = mix->master_vol[0]; | ||
1144 | mix->save_master_vol[1] = mix->master_vol[1]; | ||
1131 | mix->master_switch[0] = mix->master_switch[1] = 0; | 1145 | mix->master_switch[0] = mix->master_switch[1] = 0; |
1132 | tumbler_set_master_volume(mix); | 1146 | tumbler_set_master_volume(mix); |
1133 | if (!mix->anded_reset) { | 1147 | if (!mix->anded_reset) { |
@@ -1155,6 +1169,8 @@ static void tumbler_resume(pmac_t *chip) | |||
1155 | mix->acs &= ~1; | 1169 | mix->acs &= ~1; |
1156 | mix->master_switch[0] = mix->save_master_switch[0]; | 1170 | mix->master_switch[0] = mix->save_master_switch[0]; |
1157 | mix->master_switch[1] = mix->save_master_switch[1]; | 1171 | mix->master_switch[1] = mix->save_master_switch[1]; |
1172 | mix->master_vol[0] = mix->save_master_vol[0]; | ||
1173 | mix->master_vol[1] = mix->save_master_vol[1]; | ||
1158 | tumbler_reset_audio(chip); | 1174 | tumbler_reset_audio(chip); |
1159 | if (mix->i2c.client && mix->i2c.init_client) { | 1175 | if (mix->i2c.client && mix->i2c.init_client) { |
1160 | if (mix->i2c.init_client(&mix->i2c) < 0) | 1176 | if (mix->i2c.init_client(&mix->i2c) < 0) |