diff options
Diffstat (limited to 'sound')
152 files changed, 13156 insertions, 2672 deletions
diff --git a/sound/Kconfig b/sound/Kconfig index 047d59ea0573..ee794ae06040 100644 --- a/sound/Kconfig +++ b/sound/Kconfig | |||
@@ -42,6 +42,11 @@ menu "Advanced Linux Sound Architecture" | |||
42 | config SND | 42 | config SND |
43 | tristate "Advanced Linux Sound Architecture" | 43 | tristate "Advanced Linux Sound Architecture" |
44 | depends on SOUND | 44 | depends on SOUND |
45 | help | ||
46 | Say 'Y' or 'M' to enable ALSA (Advanced Linux Sound Architecture), | ||
47 | the new base sound system. | ||
48 | |||
49 | For more information, see <http://www.alsa-project.org/> | ||
45 | 50 | ||
46 | source "sound/core/Kconfig" | 51 | source "sound/core/Kconfig" |
47 | 52 | ||
diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig index cdacf4d3a387..34c1740aa6e9 100644 --- a/sound/arm/Kconfig +++ b/sound/arm/Kconfig | |||
@@ -14,5 +14,11 @@ config SND_SA11XX_UDA1341 | |||
14 | To compile this driver as a module, choose M here: the module | 14 | To compile this driver as a module, choose M here: the module |
15 | will be called snd-sa11xx-uda1341. | 15 | will be called snd-sa11xx-uda1341. |
16 | 16 | ||
17 | config SND_ARMAACI | ||
18 | tristate "ARM PrimeCell PL041 AC Link support" | ||
19 | depends on SND && ARM_AMBA | ||
20 | select SND_PCM | ||
21 | select SND_AC97_CODEC | ||
22 | |||
17 | endmenu | 23 | endmenu |
18 | 24 | ||
diff --git a/sound/arm/Makefile b/sound/arm/Makefile index d7e7dc0c3cdf..f74ec28e1068 100644 --- a/sound/arm/Makefile +++ b/sound/arm/Makefile | |||
@@ -6,3 +6,6 @@ snd-sa11xx-uda1341-objs := sa11xx-uda1341.o | |||
6 | 6 | ||
7 | # Toplevel Module Dependency | 7 | # Toplevel Module Dependency |
8 | obj-$(CONFIG_SND_SA11XX_UDA1341) += snd-sa11xx-uda1341.o | 8 | obj-$(CONFIG_SND_SA11XX_UDA1341) += snd-sa11xx-uda1341.o |
9 | |||
10 | obj-$(CONFIG_SND_ARMAACI) += snd-aaci.o | ||
11 | snd-aaci-objs := aaci.o devdma.o | ||
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c new file mode 100644 index 000000000000..08cc3ddca96f --- /dev/null +++ b/sound/arm/aaci.c | |||
@@ -0,0 +1,968 @@ | |||
1 | /* | ||
2 | * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver | ||
3 | * | ||
4 | * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * Documentation: ARM DDI 0173B | ||
11 | */ | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/delay.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/ioport.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/spinlock.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/err.h> | ||
20 | |||
21 | #include <asm/io.h> | ||
22 | #include <asm/irq.h> | ||
23 | #include <asm/hardware/amba.h> | ||
24 | |||
25 | #include <sound/driver.h> | ||
26 | #include <sound/core.h> | ||
27 | #include <sound/initval.h> | ||
28 | #include <sound/ac97_codec.h> | ||
29 | #include <sound/pcm.h> | ||
30 | #include <sound/pcm_params.h> | ||
31 | |||
32 | #include "aaci.h" | ||
33 | #include "devdma.h" | ||
34 | |||
35 | #define DRIVER_NAME "aaci-pl041" | ||
36 | |||
37 | /* | ||
38 | * PM support is not complete. Turn it off. | ||
39 | */ | ||
40 | #undef CONFIG_PM | ||
41 | |||
42 | static void aaci_ac97_select_codec(struct aaci *aaci, ac97_t *ac97) | ||
43 | { | ||
44 | u32 v, maincr = aaci->maincr | MAINCR_SCRA(ac97->num); | ||
45 | |||
46 | /* | ||
47 | * Ensure that the slot 1/2 RX registers are empty. | ||
48 | */ | ||
49 | v = readl(aaci->base + AACI_SLFR); | ||
50 | if (v & SLFR_2RXV) | ||
51 | readl(aaci->base + AACI_SL2RX); | ||
52 | if (v & SLFR_1RXV) | ||
53 | readl(aaci->base + AACI_SL1RX); | ||
54 | |||
55 | writel(maincr, aaci->base + AACI_MAINCR); | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | * P29: | ||
60 | * The recommended use of programming the external codec through slot 1 | ||
61 | * and slot 2 data is to use the channels during setup routines and the | ||
62 | * slot register at any other time. The data written into slot 1, slot 2 | ||
63 | * and slot 12 registers is transmitted only when their corresponding | ||
64 | * SI1TxEn, SI2TxEn and SI12TxEn bits are set in the AACI_MAINCR | ||
65 | * register. | ||
66 | */ | ||
67 | static void aaci_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) | ||
68 | { | ||
69 | struct aaci *aaci = ac97->private_data; | ||
70 | u32 v; | ||
71 | |||
72 | if (ac97->num >= 4) | ||
73 | return; | ||
74 | |||
75 | down(&aaci->ac97_sem); | ||
76 | |||
77 | aaci_ac97_select_codec(aaci, ac97); | ||
78 | |||
79 | /* | ||
80 | * P54: You must ensure that AACI_SL2TX is always written | ||
81 | * to, if required, before data is written to AACI_SL1TX. | ||
82 | */ | ||
83 | writel(val << 4, aaci->base + AACI_SL2TX); | ||
84 | writel(reg << 12, aaci->base + AACI_SL1TX); | ||
85 | |||
86 | /* | ||
87 | * Wait for the transmission of both slots to complete. | ||
88 | */ | ||
89 | do { | ||
90 | v = readl(aaci->base + AACI_SLFR); | ||
91 | } while (v & (SLFR_1TXB|SLFR_2TXB)); | ||
92 | |||
93 | up(&aaci->ac97_sem); | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * Read an AC'97 register. | ||
98 | */ | ||
99 | static unsigned short aaci_ac97_read(ac97_t *ac97, unsigned short reg) | ||
100 | { | ||
101 | struct aaci *aaci = ac97->private_data; | ||
102 | u32 v; | ||
103 | |||
104 | if (ac97->num >= 4) | ||
105 | return ~0; | ||
106 | |||
107 | down(&aaci->ac97_sem); | ||
108 | |||
109 | aaci_ac97_select_codec(aaci, ac97); | ||
110 | |||
111 | /* | ||
112 | * Write the register address to slot 1. | ||
113 | */ | ||
114 | writel((reg << 12) | (1 << 19), aaci->base + AACI_SL1TX); | ||
115 | |||
116 | /* | ||
117 | * Wait for the transmission to complete. | ||
118 | */ | ||
119 | do { | ||
120 | v = readl(aaci->base + AACI_SLFR); | ||
121 | } while (v & SLFR_1TXB); | ||
122 | |||
123 | /* | ||
124 | * Give the AC'97 codec more than enough time | ||
125 | * to respond. (42us = ~2 frames at 48kHz.) | ||
126 | */ | ||
127 | udelay(42); | ||
128 | |||
129 | /* | ||
130 | * Wait for slot 2 to indicate data. | ||
131 | */ | ||
132 | do { | ||
133 | cond_resched(); | ||
134 | v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV); | ||
135 | } while (v != (SLFR_1RXV|SLFR_2RXV)); | ||
136 | |||
137 | v = readl(aaci->base + AACI_SL1RX) >> 12; | ||
138 | if (v == reg) { | ||
139 | v = readl(aaci->base + AACI_SL2RX) >> 4; | ||
140 | } else { | ||
141 | dev_err(&aaci->dev->dev, | ||
142 | "wrong ac97 register read back (%x != %x)\n", | ||
143 | v, reg); | ||
144 | v = ~0; | ||
145 | } | ||
146 | |||
147 | up(&aaci->ac97_sem); | ||
148 | return v; | ||
149 | } | ||
150 | |||
151 | static inline void aaci_chan_wait_ready(struct aaci_runtime *aacirun) | ||
152 | { | ||
153 | u32 val; | ||
154 | int timeout = 5000; | ||
155 | |||
156 | do { | ||
157 | val = readl(aacirun->base + AACI_SR); | ||
158 | } while (val & (SR_TXB|SR_RXB) && timeout--); | ||
159 | } | ||
160 | |||
161 | |||
162 | |||
163 | /* | ||
164 | * Interrupt support. | ||
165 | */ | ||
166 | static void aaci_fifo_irq(struct aaci *aaci, u32 mask) | ||
167 | { | ||
168 | if (mask & ISR_URINTR) { | ||
169 | writel(ICLR_TXUEC1, aaci->base + AACI_INTCLR); | ||
170 | } | ||
171 | |||
172 | if (mask & ISR_TXINTR) { | ||
173 | struct aaci_runtime *aacirun = &aaci->playback; | ||
174 | void *ptr; | ||
175 | |||
176 | if (!aacirun->substream || !aacirun->start) { | ||
177 | dev_warn(&aaci->dev->dev, "TX interrupt???"); | ||
178 | writel(0, aacirun->base + AACI_IE); | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | ptr = aacirun->ptr; | ||
183 | do { | ||
184 | unsigned int len = aacirun->fifosz; | ||
185 | u32 val; | ||
186 | |||
187 | if (aacirun->bytes <= 0) { | ||
188 | aacirun->bytes += aacirun->period; | ||
189 | aacirun->ptr = ptr; | ||
190 | spin_unlock(&aaci->lock); | ||
191 | snd_pcm_period_elapsed(aacirun->substream); | ||
192 | spin_lock(&aaci->lock); | ||
193 | } | ||
194 | if (!(aacirun->cr & TXCR_TXEN)) | ||
195 | break; | ||
196 | |||
197 | val = readl(aacirun->base + AACI_SR); | ||
198 | if (!(val & SR_TXHE)) | ||
199 | break; | ||
200 | if (!(val & SR_TXFE)) | ||
201 | len >>= 1; | ||
202 | |||
203 | aacirun->bytes -= len; | ||
204 | |||
205 | /* writing 16 bytes at a time */ | ||
206 | for ( ; len > 0; len -= 16) { | ||
207 | asm( | ||
208 | "ldmia %0!, {r0, r1, r2, r3}\n\t" | ||
209 | "stmia %1, {r0, r1, r2, r3}" | ||
210 | : "+r" (ptr) | ||
211 | : "r" (aacirun->fifo) | ||
212 | : "r0", "r1", "r2", "r3", "cc"); | ||
213 | |||
214 | if (ptr >= aacirun->end) | ||
215 | ptr = aacirun->start; | ||
216 | } | ||
217 | } while (1); | ||
218 | |||
219 | aacirun->ptr = ptr; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | static irqreturn_t aaci_irq(int irq, void *devid, struct pt_regs *regs) | ||
224 | { | ||
225 | struct aaci *aaci = devid; | ||
226 | u32 mask; | ||
227 | int i; | ||
228 | |||
229 | spin_lock(&aaci->lock); | ||
230 | mask = readl(aaci->base + AACI_ALLINTS); | ||
231 | if (mask) { | ||
232 | u32 m = mask; | ||
233 | for (i = 0; i < 4; i++, m >>= 7) { | ||
234 | if (m & 0x7f) { | ||
235 | aaci_fifo_irq(aaci, m); | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | spin_unlock(&aaci->lock); | ||
240 | |||
241 | return mask ? IRQ_HANDLED : IRQ_NONE; | ||
242 | } | ||
243 | |||
244 | |||
245 | |||
246 | /* | ||
247 | * ALSA support. | ||
248 | */ | ||
249 | |||
250 | struct aaci_stream { | ||
251 | unsigned char codec_idx; | ||
252 | unsigned char rate_idx; | ||
253 | }; | ||
254 | |||
255 | static struct aaci_stream aaci_streams[] = { | ||
256 | [ACSTREAM_FRONT] = { | ||
257 | .codec_idx = 0, | ||
258 | .rate_idx = AC97_RATES_FRONT_DAC, | ||
259 | }, | ||
260 | [ACSTREAM_SURROUND] = { | ||
261 | .codec_idx = 0, | ||
262 | .rate_idx = AC97_RATES_SURR_DAC, | ||
263 | }, | ||
264 | [ACSTREAM_LFE] = { | ||
265 | .codec_idx = 0, | ||
266 | .rate_idx = AC97_RATES_LFE_DAC, | ||
267 | }, | ||
268 | }; | ||
269 | |||
270 | static inline unsigned int aaci_rate_mask(struct aaci *aaci, int streamid) | ||
271 | { | ||
272 | struct aaci_stream *s = aaci_streams + streamid; | ||
273 | return aaci->ac97_bus->codec[s->codec_idx]->rates[s->rate_idx]; | ||
274 | } | ||
275 | |||
276 | static unsigned int rate_list[] = { | ||
277 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, | ||
278 | 48000, 64000, 88200, 96000, 176400, 192000 | ||
279 | }; | ||
280 | |||
281 | /* | ||
282 | * Double-rate rule: we can support double rate iff channels == 2 | ||
283 | * (unimplemented) | ||
284 | */ | ||
285 | static int | ||
286 | aaci_rule_rate_by_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule) | ||
287 | { | ||
288 | struct aaci *aaci = rule->private; | ||
289 | unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512; | ||
290 | snd_interval_t *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
291 | |||
292 | switch (c->max) { | ||
293 | case 6: | ||
294 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_LFE); | ||
295 | case 4: | ||
296 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_SURROUND); | ||
297 | case 2: | ||
298 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_FRONT); | ||
299 | } | ||
300 | |||
301 | return snd_interval_list(hw_param_interval(p, rule->var), | ||
302 | ARRAY_SIZE(rate_list), rate_list, | ||
303 | rate_mask); | ||
304 | } | ||
305 | |||
306 | static snd_pcm_hardware_t aaci_hw_info = { | ||
307 | .info = SNDRV_PCM_INFO_MMAP | | ||
308 | SNDRV_PCM_INFO_MMAP_VALID | | ||
309 | SNDRV_PCM_INFO_INTERLEAVED | | ||
310 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
311 | SNDRV_PCM_INFO_RESUME, | ||
312 | |||
313 | /* | ||
314 | * ALSA doesn't support 18-bit or 20-bit packed into 32-bit | ||
315 | * words. It also doesn't support 12-bit at all. | ||
316 | */ | ||
317 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
318 | |||
319 | /* should this be continuous or knot? */ | ||
320 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | ||
321 | .rate_max = 48000, | ||
322 | .rate_min = 4000, | ||
323 | .channels_min = 2, | ||
324 | .channels_max = 6, | ||
325 | .buffer_bytes_max = 64 * 1024, | ||
326 | .period_bytes_min = 256, | ||
327 | .period_bytes_max = PAGE_SIZE, | ||
328 | .periods_min = 4, | ||
329 | .periods_max = PAGE_SIZE / 16, | ||
330 | }; | ||
331 | |||
332 | static int aaci_pcm_open(struct aaci *aaci, snd_pcm_substream_t *substream, | ||
333 | struct aaci_runtime *aacirun) | ||
334 | { | ||
335 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
336 | int ret; | ||
337 | |||
338 | aacirun->substream = substream; | ||
339 | runtime->private_data = aacirun; | ||
340 | runtime->hw = aaci_hw_info; | ||
341 | |||
342 | /* | ||
343 | * FIXME: ALSA specifies fifo_size in bytes. If we're in normal | ||
344 | * mode, each 32-bit word contains one sample. If we're in | ||
345 | * compact mode, each 32-bit word contains two samples, effectively | ||
346 | * halving the FIFO size. However, we don't know for sure which | ||
347 | * we'll be using at this point. We set this to the lower limit. | ||
348 | */ | ||
349 | runtime->hw.fifo_size = aaci->fifosize * 2; | ||
350 | |||
351 | /* | ||
352 | * Add rule describing hardware rate dependency | ||
353 | * on the number of channels. | ||
354 | */ | ||
355 | ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | ||
356 | aaci_rule_rate_by_channels, aaci, | ||
357 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
358 | SNDRV_PCM_HW_PARAM_RATE, -1); | ||
359 | if (ret) | ||
360 | goto out; | ||
361 | |||
362 | ret = request_irq(aaci->dev->irq[0], aaci_irq, SA_SHIRQ|SA_INTERRUPT, | ||
363 | DRIVER_NAME, aaci); | ||
364 | if (ret) | ||
365 | goto out; | ||
366 | |||
367 | return 0; | ||
368 | |||
369 | out: | ||
370 | return ret; | ||
371 | } | ||
372 | |||
373 | |||
374 | /* | ||
375 | * Common ALSA stuff | ||
376 | */ | ||
377 | static int aaci_pcm_close(snd_pcm_substream_t *substream) | ||
378 | { | ||
379 | struct aaci *aaci = substream->private_data; | ||
380 | struct aaci_runtime *aacirun = substream->runtime->private_data; | ||
381 | |||
382 | WARN_ON(aacirun->cr & TXCR_TXEN); | ||
383 | |||
384 | aacirun->substream = NULL; | ||
385 | free_irq(aaci->dev->irq[0], aaci); | ||
386 | |||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | static int aaci_pcm_hw_free(snd_pcm_substream_t *substream) | ||
391 | { | ||
392 | struct aaci_runtime *aacirun = substream->runtime->private_data; | ||
393 | |||
394 | /* | ||
395 | * This must not be called with the device enabled. | ||
396 | */ | ||
397 | WARN_ON(aacirun->cr & TXCR_TXEN); | ||
398 | |||
399 | if (aacirun->pcm_open) | ||
400 | snd_ac97_pcm_close(aacirun->pcm); | ||
401 | aacirun->pcm_open = 0; | ||
402 | |||
403 | /* | ||
404 | * Clear out the DMA and any allocated buffers. | ||
405 | */ | ||
406 | devdma_hw_free(NULL, substream); | ||
407 | |||
408 | return 0; | ||
409 | } | ||
410 | |||
411 | static int aaci_pcm_hw_params(snd_pcm_substream_t *substream, | ||
412 | struct aaci_runtime *aacirun, | ||
413 | snd_pcm_hw_params_t *params) | ||
414 | { | ||
415 | int err; | ||
416 | |||
417 | aaci_pcm_hw_free(substream); | ||
418 | |||
419 | err = devdma_hw_alloc(NULL, substream, | ||
420 | params_buffer_bytes(params)); | ||
421 | if (err < 0) | ||
422 | goto out; | ||
423 | |||
424 | err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params), | ||
425 | params_channels(params), | ||
426 | aacirun->pcm->r[0].slots); | ||
427 | if (err) | ||
428 | goto out; | ||
429 | |||
430 | aacirun->pcm_open = 1; | ||
431 | |||
432 | out: | ||
433 | return err; | ||
434 | } | ||
435 | |||
436 | static int aaci_pcm_prepare(snd_pcm_substream_t *substream) | ||
437 | { | ||
438 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
439 | struct aaci_runtime *aacirun = runtime->private_data; | ||
440 | |||
441 | aacirun->start = (void *)runtime->dma_area; | ||
442 | aacirun->end = aacirun->start + runtime->dma_bytes; | ||
443 | aacirun->ptr = aacirun->start; | ||
444 | aacirun->period = | ||
445 | aacirun->bytes = frames_to_bytes(runtime, runtime->period_size); | ||
446 | |||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | static snd_pcm_uframes_t aaci_pcm_pointer(snd_pcm_substream_t *substream) | ||
451 | { | ||
452 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
453 | struct aaci_runtime *aacirun = runtime->private_data; | ||
454 | ssize_t bytes = aacirun->ptr - aacirun->start; | ||
455 | |||
456 | return bytes_to_frames(runtime, bytes); | ||
457 | } | ||
458 | |||
459 | static int aaci_pcm_mmap(snd_pcm_substream_t *substream, struct vm_area_struct *vma) | ||
460 | { | ||
461 | return devdma_mmap(NULL, substream, vma); | ||
462 | } | ||
463 | |||
464 | |||
465 | /* | ||
466 | * Playback specific ALSA stuff | ||
467 | */ | ||
468 | static const u32 channels_to_txmask[] = { | ||
469 | [2] = TXCR_TX3 | TXCR_TX4, | ||
470 | [4] = TXCR_TX3 | TXCR_TX4 | TXCR_TX7 | TXCR_TX8, | ||
471 | [6] = TXCR_TX3 | TXCR_TX4 | TXCR_TX7 | TXCR_TX8 | TXCR_TX6 | TXCR_TX9, | ||
472 | }; | ||
473 | |||
474 | /* | ||
475 | * We can support two and four channel audio. Unfortunately | ||
476 | * six channel audio requires a non-standard channel ordering: | ||
477 | * 2 -> FL(3), FR(4) | ||
478 | * 4 -> FL(3), FR(4), SL(7), SR(8) | ||
479 | * 6 -> FL(3), FR(4), SL(7), SR(8), C(6), LFE(9) (required) | ||
480 | * FL(3), FR(4), C(6), SL(7), SR(8), LFE(9) (actual) | ||
481 | * This requires an ALSA configuration file to correct. | ||
482 | */ | ||
483 | static unsigned int channel_list[] = { 2, 4, 6 }; | ||
484 | |||
485 | static int | ||
486 | aaci_rule_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule) | ||
487 | { | ||
488 | struct aaci *aaci = rule->private; | ||
489 | unsigned int chan_mask = 1 << 0, slots; | ||
490 | |||
491 | /* | ||
492 | * pcms[0] is the our 5.1 PCM instance. | ||
493 | */ | ||
494 | slots = aaci->ac97_bus->pcms[0].r[0].slots; | ||
495 | if (slots & (1 << AC97_SLOT_PCM_SLEFT)) { | ||
496 | chan_mask |= 1 << 1; | ||
497 | if (slots & (1 << AC97_SLOT_LFE)) | ||
498 | chan_mask |= 1 << 2; | ||
499 | } | ||
500 | |||
501 | return snd_interval_list(hw_param_interval(p, rule->var), | ||
502 | ARRAY_SIZE(channel_list), channel_list, | ||
503 | chan_mask); | ||
504 | } | ||
505 | |||
506 | static int aaci_pcm_playback_open(snd_pcm_substream_t *substream) | ||
507 | { | ||
508 | struct aaci *aaci = substream->private_data; | ||
509 | int ret; | ||
510 | |||
511 | /* | ||
512 | * Add rule describing channel dependency. | ||
513 | */ | ||
514 | ret = snd_pcm_hw_rule_add(substream->runtime, 0, | ||
515 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
516 | aaci_rule_channels, aaci, | ||
517 | SNDRV_PCM_HW_PARAM_CHANNELS, -1); | ||
518 | if (ret) | ||
519 | return ret; | ||
520 | |||
521 | return aaci_pcm_open(aaci, substream, &aaci->playback); | ||
522 | } | ||
523 | |||
524 | static int aaci_pcm_playback_hw_params(snd_pcm_substream_t *substream, | ||
525 | snd_pcm_hw_params_t *params) | ||
526 | { | ||
527 | struct aaci *aaci = substream->private_data; | ||
528 | struct aaci_runtime *aacirun = substream->runtime->private_data; | ||
529 | unsigned int channels = params_channels(params); | ||
530 | int ret; | ||
531 | |||
532 | WARN_ON(channels >= ARRAY_SIZE(channels_to_txmask) || | ||
533 | !channels_to_txmask[channels]); | ||
534 | |||
535 | ret = aaci_pcm_hw_params(substream, aacirun, params); | ||
536 | |||
537 | /* | ||
538 | * Enable FIFO, compact mode, 16 bits per sample. | ||
539 | * FIXME: double rate slots? | ||
540 | */ | ||
541 | if (ret >= 0) { | ||
542 | aacirun->cr = TXCR_FEN | TXCR_COMPACT | TXCR_TSZ16; | ||
543 | aacirun->cr |= channels_to_txmask[channels]; | ||
544 | |||
545 | aacirun->fifosz = aaci->fifosize * 4; | ||
546 | if (aacirun->cr & TXCR_COMPACT) | ||
547 | aacirun->fifosz >>= 1; | ||
548 | } | ||
549 | return ret; | ||
550 | } | ||
551 | |||
552 | static void aaci_pcm_playback_stop(struct aaci_runtime *aacirun) | ||
553 | { | ||
554 | u32 ie; | ||
555 | |||
556 | ie = readl(aacirun->base + AACI_IE); | ||
557 | ie &= ~(IE_URIE|IE_TXIE); | ||
558 | writel(ie, aacirun->base + AACI_IE); | ||
559 | aacirun->cr &= ~TXCR_TXEN; | ||
560 | aaci_chan_wait_ready(aacirun); | ||
561 | writel(aacirun->cr, aacirun->base + AACI_TXCR); | ||
562 | } | ||
563 | |||
564 | static void aaci_pcm_playback_start(struct aaci_runtime *aacirun) | ||
565 | { | ||
566 | u32 ie; | ||
567 | |||
568 | aaci_chan_wait_ready(aacirun); | ||
569 | aacirun->cr |= TXCR_TXEN; | ||
570 | |||
571 | ie = readl(aacirun->base + AACI_IE); | ||
572 | ie |= IE_URIE | IE_TXIE; | ||
573 | writel(ie, aacirun->base + AACI_IE); | ||
574 | writel(aacirun->cr, aacirun->base + AACI_TXCR); | ||
575 | } | ||
576 | |||
577 | static int aaci_pcm_playback_trigger(snd_pcm_substream_t *substream, int cmd) | ||
578 | { | ||
579 | struct aaci *aaci = substream->private_data; | ||
580 | struct aaci_runtime *aacirun = substream->runtime->private_data; | ||
581 | unsigned long flags; | ||
582 | int ret = 0; | ||
583 | |||
584 | spin_lock_irqsave(&aaci->lock, flags); | ||
585 | switch (cmd) { | ||
586 | case SNDRV_PCM_TRIGGER_START: | ||
587 | aaci_pcm_playback_start(aacirun); | ||
588 | break; | ||
589 | |||
590 | case SNDRV_PCM_TRIGGER_RESUME: | ||
591 | aaci_pcm_playback_start(aacirun); | ||
592 | break; | ||
593 | |||
594 | case SNDRV_PCM_TRIGGER_STOP: | ||
595 | aaci_pcm_playback_stop(aacirun); | ||
596 | break; | ||
597 | |||
598 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
599 | aaci_pcm_playback_stop(aacirun); | ||
600 | break; | ||
601 | |||
602 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
603 | break; | ||
604 | |||
605 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
606 | break; | ||
607 | |||
608 | default: | ||
609 | ret = -EINVAL; | ||
610 | } | ||
611 | spin_unlock_irqrestore(&aaci->lock, flags); | ||
612 | |||
613 | return ret; | ||
614 | } | ||
615 | |||
616 | static snd_pcm_ops_t aaci_playback_ops = { | ||
617 | .open = aaci_pcm_playback_open, | ||
618 | .close = aaci_pcm_close, | ||
619 | .ioctl = snd_pcm_lib_ioctl, | ||
620 | .hw_params = aaci_pcm_playback_hw_params, | ||
621 | .hw_free = aaci_pcm_hw_free, | ||
622 | .prepare = aaci_pcm_prepare, | ||
623 | .trigger = aaci_pcm_playback_trigger, | ||
624 | .pointer = aaci_pcm_pointer, | ||
625 | .mmap = aaci_pcm_mmap, | ||
626 | }; | ||
627 | |||
628 | |||
629 | |||
630 | /* | ||
631 | * Power Management. | ||
632 | */ | ||
633 | #ifdef CONFIG_PM | ||
634 | static int aaci_do_suspend(snd_card_t *card, unsigned int state) | ||
635 | { | ||
636 | struct aaci *aaci = card->private_data; | ||
637 | if (aaci->card->power_state != SNDRV_CTL_POWER_D3cold) { | ||
638 | snd_pcm_suspend_all(aaci->pcm); | ||
639 | snd_power_change_state(aaci->card, SNDRV_CTL_POWER_D3cold); | ||
640 | } | ||
641 | return 0; | ||
642 | } | ||
643 | |||
644 | static int aaci_do_resume(snd_card_t *card, unsigned int state) | ||
645 | { | ||
646 | struct aaci *aaci = card->private_data; | ||
647 | if (aaci->card->power_state != SNDRV_CTL_POWER_D0) { | ||
648 | snd_power_change_state(aaci->card, SNDRV_CTL_POWER_D0); | ||
649 | } | ||
650 | return 0; | ||
651 | } | ||
652 | |||
653 | static int aaci_suspend(struct amba_device *dev, u32 state) | ||
654 | { | ||
655 | snd_card_t *card = amba_get_drvdata(dev); | ||
656 | return card ? aaci_do_suspend(card) : 0; | ||
657 | } | ||
658 | |||
659 | static int aaci_resume(struct amba_device *dev) | ||
660 | { | ||
661 | snd_card_t *card = amba_get_drvdata(dev); | ||
662 | return card ? aaci_do_resume(card) : 0; | ||
663 | } | ||
664 | #else | ||
665 | #define aaci_do_suspend NULL | ||
666 | #define aaci_do_resume NULL | ||
667 | #define aaci_suspend NULL | ||
668 | #define aaci_resume NULL | ||
669 | #endif | ||
670 | |||
671 | |||
672 | static struct ac97_pcm ac97_defs[] __devinitdata = { | ||
673 | [0] = { /* Front PCM */ | ||
674 | .exclusive = 1, | ||
675 | .r = { | ||
676 | [0] = { | ||
677 | .slots = (1 << AC97_SLOT_PCM_LEFT) | | ||
678 | (1 << AC97_SLOT_PCM_RIGHT) | | ||
679 | (1 << AC97_SLOT_PCM_CENTER) | | ||
680 | (1 << AC97_SLOT_PCM_SLEFT) | | ||
681 | (1 << AC97_SLOT_PCM_SRIGHT) | | ||
682 | (1 << AC97_SLOT_LFE), | ||
683 | }, | ||
684 | }, | ||
685 | }, | ||
686 | [1] = { /* PCM in */ | ||
687 | .stream = 1, | ||
688 | .exclusive = 1, | ||
689 | .r = { | ||
690 | [0] = { | ||
691 | .slots = (1 << AC97_SLOT_PCM_LEFT) | | ||
692 | (1 << AC97_SLOT_PCM_RIGHT), | ||
693 | }, | ||
694 | }, | ||
695 | }, | ||
696 | [2] = { /* Mic in */ | ||
697 | .stream = 1, | ||
698 | .exclusive = 1, | ||
699 | .r = { | ||
700 | [0] = { | ||
701 | .slots = (1 << AC97_SLOT_MIC), | ||
702 | }, | ||
703 | }, | ||
704 | } | ||
705 | }; | ||
706 | |||
707 | static ac97_bus_ops_t aaci_bus_ops = { | ||
708 | .write = aaci_ac97_write, | ||
709 | .read = aaci_ac97_read, | ||
710 | }; | ||
711 | |||
712 | static int __devinit aaci_probe_ac97(struct aaci *aaci) | ||
713 | { | ||
714 | ac97_template_t ac97_template; | ||
715 | ac97_bus_t *ac97_bus; | ||
716 | ac97_t *ac97; | ||
717 | int ret; | ||
718 | |||
719 | /* | ||
720 | * Assert AACIRESET for 2us | ||
721 | */ | ||
722 | writel(0, aaci->base + AACI_RESET); | ||
723 | udelay(2); | ||
724 | writel(RESET_NRST, aaci->base + AACI_RESET); | ||
725 | |||
726 | /* | ||
727 | * Give the AC'97 codec more than enough time | ||
728 | * to wake up. (42us = ~2 frames at 48kHz.) | ||
729 | */ | ||
730 | udelay(42); | ||
731 | |||
732 | ret = snd_ac97_bus(aaci->card, 0, &aaci_bus_ops, aaci, &ac97_bus); | ||
733 | if (ret) | ||
734 | goto out; | ||
735 | |||
736 | ac97_bus->clock = 48000; | ||
737 | aaci->ac97_bus = ac97_bus; | ||
738 | |||
739 | memset(&ac97_template, 0, sizeof(ac97_template_t)); | ||
740 | ac97_template.private_data = aaci; | ||
741 | ac97_template.num = 0; | ||
742 | ac97_template.scaps = AC97_SCAP_SKIP_MODEM; | ||
743 | |||
744 | ret = snd_ac97_mixer(ac97_bus, &ac97_template, &ac97); | ||
745 | if (ret) | ||
746 | goto out; | ||
747 | |||
748 | /* | ||
749 | * Disable AC97 PC Beep input on audio codecs. | ||
750 | */ | ||
751 | if (ac97_is_audio(ac97)) | ||
752 | snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x801e); | ||
753 | |||
754 | ret = snd_ac97_pcm_assign(ac97_bus, ARRAY_SIZE(ac97_defs), ac97_defs); | ||
755 | if (ret) | ||
756 | goto out; | ||
757 | |||
758 | aaci->playback.pcm = &ac97_bus->pcms[0]; | ||
759 | |||
760 | out: | ||
761 | return ret; | ||
762 | } | ||
763 | |||
764 | static void aaci_free_card(snd_card_t *card) | ||
765 | { | ||
766 | struct aaci *aaci = card->private_data; | ||
767 | if (aaci->base) | ||
768 | iounmap(aaci->base); | ||
769 | } | ||
770 | |||
771 | static struct aaci * __devinit aaci_init_card(struct amba_device *dev) | ||
772 | { | ||
773 | struct aaci *aaci; | ||
774 | snd_card_t *card; | ||
775 | |||
776 | card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, | ||
777 | THIS_MODULE, sizeof(struct aaci)); | ||
778 | if (card == NULL) | ||
779 | return ERR_PTR(-ENOMEM); | ||
780 | |||
781 | card->private_free = aaci_free_card; | ||
782 | snd_card_set_pm_callback(card, aaci_do_suspend, aaci_do_resume, NULL); | ||
783 | |||
784 | strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver)); | ||
785 | strlcpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname)); | ||
786 | snprintf(card->longname, sizeof(card->longname), | ||
787 | "%s at 0x%08lx, irq %d", | ||
788 | card->shortname, dev->res.start, dev->irq[0]); | ||
789 | |||
790 | aaci = card->private_data; | ||
791 | init_MUTEX(&aaci->ac97_sem); | ||
792 | spin_lock_init(&aaci->lock); | ||
793 | aaci->card = card; | ||
794 | aaci->dev = dev; | ||
795 | |||
796 | /* Set MAINCR to allow slot 1 and 2 data IO */ | ||
797 | aaci->maincr = MAINCR_IE | MAINCR_SL1RXEN | MAINCR_SL1TXEN | | ||
798 | MAINCR_SL2RXEN | MAINCR_SL2TXEN; | ||
799 | |||
800 | return aaci; | ||
801 | } | ||
802 | |||
803 | static int __devinit aaci_init_pcm(struct aaci *aaci) | ||
804 | { | ||
805 | snd_pcm_t *pcm; | ||
806 | int ret; | ||
807 | |||
808 | ret = snd_pcm_new(aaci->card, "AACI AC'97", 0, 1, 0, &pcm); | ||
809 | if (ret == 0) { | ||
810 | aaci->pcm = pcm; | ||
811 | pcm->private_data = aaci; | ||
812 | pcm->info_flags = 0; | ||
813 | |||
814 | strlcpy(pcm->name, DRIVER_NAME, sizeof(pcm->name)); | ||
815 | |||
816 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops); | ||
817 | } | ||
818 | |||
819 | return ret; | ||
820 | } | ||
821 | |||
822 | static unsigned int __devinit aaci_size_fifo(struct aaci *aaci) | ||
823 | { | ||
824 | void *base = aaci->base + AACI_CSCH1; | ||
825 | int i; | ||
826 | |||
827 | writel(TXCR_FEN | TXCR_TSZ16 | TXCR_TXEN, base + AACI_TXCR); | ||
828 | |||
829 | for (i = 0; !(readl(base + AACI_SR) & SR_TXFF) && i < 4096; i++) | ||
830 | writel(0, aaci->base + AACI_DR1); | ||
831 | |||
832 | writel(0, base + AACI_TXCR); | ||
833 | |||
834 | /* | ||
835 | * Re-initialise the AACI after the FIFO depth test, to | ||
836 | * ensure that the FIFOs are empty. Unfortunately, merely | ||
837 | * disabling the channel doesn't clear the FIFO. | ||
838 | */ | ||
839 | writel(aaci->maincr & ~MAINCR_IE, aaci->base + AACI_MAINCR); | ||
840 | writel(aaci->maincr, aaci->base + AACI_MAINCR); | ||
841 | |||
842 | /* | ||
843 | * If we hit 4096, we failed. Go back to the specified | ||
844 | * fifo depth. | ||
845 | */ | ||
846 | if (i == 4096) | ||
847 | i = 8; | ||
848 | |||
849 | return i; | ||
850 | } | ||
851 | |||
852 | static int __devinit aaci_probe(struct amba_device *dev, void *id) | ||
853 | { | ||
854 | struct aaci *aaci; | ||
855 | int ret, i; | ||
856 | |||
857 | ret = amba_request_regions(dev, NULL); | ||
858 | if (ret) | ||
859 | return ret; | ||
860 | |||
861 | aaci = aaci_init_card(dev); | ||
862 | if (IS_ERR(aaci)) { | ||
863 | ret = PTR_ERR(aaci); | ||
864 | goto out; | ||
865 | } | ||
866 | |||
867 | aaci->base = ioremap(dev->res.start, SZ_4K); | ||
868 | if (!aaci->base) { | ||
869 | ret = -ENOMEM; | ||
870 | goto out; | ||
871 | } | ||
872 | |||
873 | /* | ||
874 | * Playback uses AACI channel 0 | ||
875 | */ | ||
876 | aaci->playback.base = aaci->base + AACI_CSCH1; | ||
877 | aaci->playback.fifo = aaci->base + AACI_DR1; | ||
878 | |||
879 | for (i = 0; i < 4; i++) { | ||
880 | void *base = aaci->base + i * 0x14; | ||
881 | |||
882 | writel(0, base + AACI_IE); | ||
883 | writel(0, base + AACI_TXCR); | ||
884 | writel(0, base + AACI_RXCR); | ||
885 | } | ||
886 | |||
887 | writel(0x1fff, aaci->base + AACI_INTCLR); | ||
888 | writel(aaci->maincr, aaci->base + AACI_MAINCR); | ||
889 | |||
890 | /* | ||
891 | * Size the FIFOs. | ||
892 | */ | ||
893 | aaci->fifosize = aaci_size_fifo(aaci); | ||
894 | |||
895 | ret = aaci_probe_ac97(aaci); | ||
896 | if (ret) | ||
897 | goto out; | ||
898 | |||
899 | ret = aaci_init_pcm(aaci); | ||
900 | if (ret) | ||
901 | goto out; | ||
902 | |||
903 | ret = snd_card_register(aaci->card); | ||
904 | if (ret == 0) { | ||
905 | dev_info(&dev->dev, "%s, fifo %d\n", aaci->card->longname, | ||
906 | aaci->fifosize); | ||
907 | amba_set_drvdata(dev, aaci->card); | ||
908 | return ret; | ||
909 | } | ||
910 | |||
911 | out: | ||
912 | if (aaci) | ||
913 | snd_card_free(aaci->card); | ||
914 | amba_release_regions(dev); | ||
915 | return ret; | ||
916 | } | ||
917 | |||
918 | static int __devexit aaci_remove(struct amba_device *dev) | ||
919 | { | ||
920 | snd_card_t *card = amba_get_drvdata(dev); | ||
921 | |||
922 | amba_set_drvdata(dev, NULL); | ||
923 | |||
924 | if (card) { | ||
925 | struct aaci *aaci = card->private_data; | ||
926 | writel(0, aaci->base + AACI_MAINCR); | ||
927 | |||
928 | snd_card_free(card); | ||
929 | amba_release_regions(dev); | ||
930 | } | ||
931 | |||
932 | return 0; | ||
933 | } | ||
934 | |||
935 | static struct amba_id aaci_ids[] = { | ||
936 | { | ||
937 | .id = 0x00041041, | ||
938 | .mask = 0x000fffff, | ||
939 | }, | ||
940 | { 0, 0 }, | ||
941 | }; | ||
942 | |||
943 | static struct amba_driver aaci_driver = { | ||
944 | .drv = { | ||
945 | .name = DRIVER_NAME, | ||
946 | }, | ||
947 | .probe = aaci_probe, | ||
948 | .remove = __devexit_p(aaci_remove), | ||
949 | .suspend = aaci_suspend, | ||
950 | .resume = aaci_resume, | ||
951 | .id_table = aaci_ids, | ||
952 | }; | ||
953 | |||
954 | static int __init aaci_init(void) | ||
955 | { | ||
956 | return amba_driver_register(&aaci_driver); | ||
957 | } | ||
958 | |||
959 | static void __exit aaci_exit(void) | ||
960 | { | ||
961 | amba_driver_unregister(&aaci_driver); | ||
962 | } | ||
963 | |||
964 | module_init(aaci_init); | ||
965 | module_exit(aaci_exit); | ||
966 | |||
967 | MODULE_LICENSE("GPL"); | ||
968 | MODULE_DESCRIPTION("ARM PrimeCell PL041 Advanced Audio CODEC Interface driver"); | ||
diff --git a/sound/arm/aaci.h b/sound/arm/aaci.h new file mode 100644 index 000000000000..d752e6426894 --- /dev/null +++ b/sound/arm/aaci.h | |||
@@ -0,0 +1,246 @@ | |||
1 | /* | ||
2 | * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver | ||
3 | * | ||
4 | * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #ifndef AACI_H | ||
11 | #define AACI_H | ||
12 | |||
13 | /* | ||
14 | * Control and status register offsets | ||
15 | * P39. | ||
16 | */ | ||
17 | #define AACI_CSCH1 0x000 | ||
18 | #define AACI_CSCH2 0x014 | ||
19 | #define AACI_CSCH3 0x028 | ||
20 | #define AACI_CSCH4 0x03c | ||
21 | |||
22 | #define AACI_RXCR 0x000 /* 29 bits Control Rx FIFO */ | ||
23 | #define AACI_TXCR 0x004 /* 17 bits Control Tx FIFO */ | ||
24 | #define AACI_SR 0x008 /* 12 bits Status */ | ||
25 | #define AACI_ISR 0x00c /* 7 bits Int Status */ | ||
26 | #define AACI_IE 0x010 /* 7 bits Int Enable */ | ||
27 | |||
28 | /* | ||
29 | * Other registers | ||
30 | */ | ||
31 | #define AACI_SL1RX 0x050 | ||
32 | #define AACI_SL1TX 0x054 | ||
33 | #define AACI_SL2RX 0x058 | ||
34 | #define AACI_SL2TX 0x05c | ||
35 | #define AACI_SL12RX 0x060 | ||
36 | #define AACI_SL12TX 0x064 | ||
37 | #define AACI_SLFR 0x068 /* slot flags */ | ||
38 | #define AACI_SLISTAT 0x06c /* slot interrupt status */ | ||
39 | #define AACI_SLIEN 0x070 /* slot interrupt enable */ | ||
40 | #define AACI_INTCLR 0x074 /* interrupt clear */ | ||
41 | #define AACI_MAINCR 0x078 /* main control */ | ||
42 | #define AACI_RESET 0x07c /* reset control */ | ||
43 | #define AACI_SYNC 0x080 /* sync control */ | ||
44 | #define AACI_ALLINTS 0x084 /* all fifo interrupt status */ | ||
45 | #define AACI_MAINFR 0x088 /* main flag register */ | ||
46 | #define AACI_DR1 0x090 /* data read/written fifo 1 */ | ||
47 | #define AACI_DR2 0x0b0 /* data read/written fifo 2 */ | ||
48 | #define AACI_DR3 0x0d0 /* data read/written fifo 3 */ | ||
49 | #define AACI_DR4 0x0f0 /* data read/written fifo 4 */ | ||
50 | |||
51 | /* | ||
52 | * transmit fifo control register. P48 | ||
53 | */ | ||
54 | #define TXCR_FEN (1 << 16) /* fifo enable */ | ||
55 | #define TXCR_COMPACT (1 << 15) /* compact mode */ | ||
56 | #define TXCR_TSZ16 (0 << 13) /* 16 bits */ | ||
57 | #define TXCR_TSZ18 (1 << 13) /* 18 bits */ | ||
58 | #define TXCR_TSZ20 (2 << 13) /* 20 bits */ | ||
59 | #define TXCR_TSZ12 (3 << 13) /* 12 bits */ | ||
60 | #define TXCR_TX12 (1 << 12) /* transmits slot 12 */ | ||
61 | #define TXCR_TX11 (1 << 11) /* transmits slot 12 */ | ||
62 | #define TXCR_TX10 (1 << 10) /* transmits slot 12 */ | ||
63 | #define TXCR_TX9 (1 << 9) /* transmits slot 12 */ | ||
64 | #define TXCR_TX8 (1 << 8) /* transmits slot 12 */ | ||
65 | #define TXCR_TX7 (1 << 7) /* transmits slot 12 */ | ||
66 | #define TXCR_TX6 (1 << 6) /* transmits slot 12 */ | ||
67 | #define TXCR_TX5 (1 << 5) /* transmits slot 12 */ | ||
68 | #define TXCR_TX4 (1 << 4) /* transmits slot 12 */ | ||
69 | #define TXCR_TX3 (1 << 3) /* transmits slot 12 */ | ||
70 | #define TXCR_TX2 (1 << 2) /* transmits slot 12 */ | ||
71 | #define TXCR_TX1 (1 << 1) /* transmits slot 12 */ | ||
72 | #define TXCR_TXEN (1 << 0) /* transmit enable */ | ||
73 | |||
74 | /* | ||
75 | * status register bits. P49 | ||
76 | */ | ||
77 | #define SR_RXTOFE (1 << 11) /* rx timeout fifo empty */ | ||
78 | #define SR_TXTO (1 << 10) /* rx timeout fifo nonempty */ | ||
79 | #define SR_TXU (1 << 9) /* tx underrun */ | ||
80 | #define SR_RXO (1 << 8) /* rx overrun */ | ||
81 | #define SR_TXB (1 << 7) /* tx busy */ | ||
82 | #define SR_RXB (1 << 6) /* rx busy */ | ||
83 | #define SR_TXFF (1 << 5) /* tx fifo full */ | ||
84 | #define SR_RXFF (1 << 4) /* rx fifo full */ | ||
85 | #define SR_TXHE (1 << 3) /* tx fifo half empty */ | ||
86 | #define SR_RXHF (1 << 2) /* rx fifo half full */ | ||
87 | #define SR_TXFE (1 << 1) /* tx fifo empty */ | ||
88 | #define SR_RXFE (1 << 0) /* rx fifo empty */ | ||
89 | |||
90 | /* | ||
91 | * interrupt status register bits. | ||
92 | */ | ||
93 | #define ISR_RXTOFEINTR (1 << 6) /* rx fifo empty */ | ||
94 | #define ISR_URINTR (1 << 5) /* tx underflow */ | ||
95 | #define ISR_ORINTR (1 << 4) /* rx overflow */ | ||
96 | #define ISR_RXINTR (1 << 3) /* rx fifo */ | ||
97 | #define ISR_TXINTR (1 << 2) /* tx fifo intr */ | ||
98 | #define ISR_RXTOINTR (1 << 1) /* tx timeout */ | ||
99 | #define ISR_TXCINTR (1 << 0) /* tx complete */ | ||
100 | |||
101 | /* | ||
102 | * interrupt enable register bits. | ||
103 | */ | ||
104 | #define IE_RXTOIE (1 << 6) | ||
105 | #define IE_URIE (1 << 5) | ||
106 | #define IE_ORIE (1 << 4) | ||
107 | #define IE_RXIE (1 << 3) | ||
108 | #define IE_TXIE (1 << 2) | ||
109 | #define IE_RXTIE (1 << 1) | ||
110 | #define IE_TXCIE (1 << 0) | ||
111 | |||
112 | /* | ||
113 | * interrupt status. P51 | ||
114 | */ | ||
115 | #define ISR_RXTOFE (1 << 6) /* rx timeout fifo empty */ | ||
116 | #define ISR_UR (1 << 5) /* tx fifo underrun */ | ||
117 | #define ISR_OR (1 << 4) /* rx fifo overrun */ | ||
118 | #define ISR_RX (1 << 3) /* rx interrupt status */ | ||
119 | #define ISR_TX (1 << 2) /* tx interrupt status */ | ||
120 | #define ISR_RXTO (1 << 1) /* rx timeout */ | ||
121 | #define ISR_TXC (1 << 0) /* tx complete */ | ||
122 | |||
123 | /* | ||
124 | * interrupt enable. P52 | ||
125 | */ | ||
126 | #define IE_RXTOFE (1 << 6) /* rx timeout fifo empty */ | ||
127 | #define IE_UR (1 << 5) /* tx fifo underrun */ | ||
128 | #define IE_OR (1 << 4) /* rx fifo overrun */ | ||
129 | #define IE_RX (1 << 3) /* rx interrupt status */ | ||
130 | #define IE_TX (1 << 2) /* tx interrupt status */ | ||
131 | #define IE_RXTO (1 << 1) /* rx timeout */ | ||
132 | #define IE_TXC (1 << 0) /* tx complete */ | ||
133 | |||
134 | /* | ||
135 | * slot flag register bits. P56 | ||
136 | */ | ||
137 | #define SLFR_RWIS (1 << 13) /* raw wake-up interrupt status */ | ||
138 | #define SLFR_RGPIOINTR (1 << 12) /* raw gpio interrupt */ | ||
139 | #define SLFR_12TXE (1 << 11) /* slot 12 tx empty */ | ||
140 | #define SLFR_12RXV (1 << 10) /* slot 12 rx valid */ | ||
141 | #define SLFR_2TXE (1 << 9) /* slot 2 tx empty */ | ||
142 | #define SLFR_2RXV (1 << 8) /* slot 2 rx valid */ | ||
143 | #define SLFR_1TXE (1 << 7) /* slot 1 tx empty */ | ||
144 | #define SLFR_1RXV (1 << 6) /* slot 1 rx valid */ | ||
145 | #define SLFR_12TXB (1 << 5) /* slot 12 tx busy */ | ||
146 | #define SLFR_12RXB (1 << 4) /* slot 12 rx busy */ | ||
147 | #define SLFR_2TXB (1 << 3) /* slot 2 tx busy */ | ||
148 | #define SLFR_2RXB (1 << 2) /* slot 2 rx busy */ | ||
149 | #define SLFR_1TXB (1 << 1) /* slot 1 tx busy */ | ||
150 | #define SLFR_1RXB (1 << 0) /* slot 1 rx busy */ | ||
151 | |||
152 | /* | ||
153 | * Interrupt clear register. | ||
154 | */ | ||
155 | #define ICLR_RXTOFEC4 (1 << 12) | ||
156 | #define ICLR_RXTOFEC3 (1 << 11) | ||
157 | #define ICLR_RXTOFEC2 (1 << 10) | ||
158 | #define ICLR_RXTOFEC1 (1 << 9) | ||
159 | #define ICLR_TXUEC4 (1 << 8) | ||
160 | #define ICLR_TXUEC3 (1 << 7) | ||
161 | #define ICLR_TXUEC2 (1 << 6) | ||
162 | #define ICLR_TXUEC1 (1 << 5) | ||
163 | #define ICLR_RXOEC4 (1 << 4) | ||
164 | #define ICLR_RXOEC3 (1 << 3) | ||
165 | #define ICLR_RXOEC2 (1 << 2) | ||
166 | #define ICLR_RXOEC1 (1 << 1) | ||
167 | #define ICLR_WISC (1 << 0) | ||
168 | |||
169 | /* | ||
170 | * Main control register bits. P62 | ||
171 | */ | ||
172 | #define MAINCR_SCRA(x) ((x) << 10) /* secondary codec reg access */ | ||
173 | #define MAINCR_DMAEN (1 << 9) /* dma enable */ | ||
174 | #define MAINCR_SL12TXEN (1 << 8) /* slot 12 transmit enable */ | ||
175 | #define MAINCR_SL12RXEN (1 << 7) /* slot 12 receive enable */ | ||
176 | #define MAINCR_SL2TXEN (1 << 6) /* slot 2 transmit enable */ | ||
177 | #define MAINCR_SL2RXEN (1 << 5) /* slot 2 receive enable */ | ||
178 | #define MAINCR_SL1TXEN (1 << 4) /* slot 1 transmit enable */ | ||
179 | #define MAINCR_SL1RXEN (1 << 3) /* slot 1 receive enable */ | ||
180 | #define MAINCR_LPM (1 << 2) /* low power mode */ | ||
181 | #define MAINCR_LOOPBK (1 << 1) /* loopback */ | ||
182 | #define MAINCR_IE (1 << 0) /* aaci interface enable */ | ||
183 | |||
184 | /* | ||
185 | * Reset register bits. P65 | ||
186 | */ | ||
187 | #define RESET_NRST (1 << 0) | ||
188 | |||
189 | /* | ||
190 | * Sync register bits. P65 | ||
191 | */ | ||
192 | #define SYNC_FORCE (1 << 0) | ||
193 | |||
194 | /* | ||
195 | * Main flag register bits. P66 | ||
196 | */ | ||
197 | #define MAINFR_TXB (1 << 1) /* transmit busy */ | ||
198 | #define MAINFR_RXB (1 << 0) /* receive busy */ | ||
199 | |||
200 | |||
201 | |||
202 | struct aaci_runtime { | ||
203 | void *base; | ||
204 | void *fifo; | ||
205 | |||
206 | struct ac97_pcm *pcm; | ||
207 | int pcm_open; | ||
208 | |||
209 | u32 cr; | ||
210 | snd_pcm_substream_t *substream; | ||
211 | |||
212 | /* | ||
213 | * PIO support | ||
214 | */ | ||
215 | void *start; | ||
216 | void *end; | ||
217 | void *ptr; | ||
218 | int bytes; | ||
219 | unsigned int period; | ||
220 | unsigned int fifosz; | ||
221 | }; | ||
222 | |||
223 | struct aaci { | ||
224 | struct amba_device *dev; | ||
225 | snd_card_t *card; | ||
226 | void *base; | ||
227 | unsigned int fifosize; | ||
228 | |||
229 | /* AC'97 */ | ||
230 | struct semaphore ac97_sem; | ||
231 | ac97_bus_t *ac97_bus; | ||
232 | |||
233 | u32 maincr; | ||
234 | spinlock_t lock; | ||
235 | |||
236 | struct aaci_runtime playback; | ||
237 | struct aaci_runtime capture; | ||
238 | |||
239 | snd_pcm_t *pcm; | ||
240 | }; | ||
241 | |||
242 | #define ACSTREAM_FRONT 0 | ||
243 | #define ACSTREAM_SURROUND 1 | ||
244 | #define ACSTREAM_LFE 2 | ||
245 | |||
246 | #endif | ||
diff --git a/sound/arm/devdma.c b/sound/arm/devdma.c new file mode 100644 index 000000000000..60826a5324b4 --- /dev/null +++ b/sound/arm/devdma.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * linux/sound/arm/devdma.c | ||
3 | * | ||
4 | * Copyright (C) 2003-2004 Russell King, All rights reserved. | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * ARM DMA shim for ALSA. | ||
11 | */ | ||
12 | #include <linux/device.h> | ||
13 | #include <linux/dma-mapping.h> | ||
14 | |||
15 | #include <sound/driver.h> | ||
16 | #include <sound/core.h> | ||
17 | #include <sound/pcm.h> | ||
18 | |||
19 | #include "devdma.h" | ||
20 | |||
21 | void devdma_hw_free(struct device *dev, snd_pcm_substream_t *substream) | ||
22 | { | ||
23 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
24 | struct snd_dma_buffer *buf = runtime->dma_buffer_p; | ||
25 | |||
26 | if (runtime->dma_area == NULL) | ||
27 | return; | ||
28 | |||
29 | if (buf != &substream->dma_buffer) { | ||
30 | dma_free_coherent(buf->dev.dev, buf->bytes, buf->area, buf->addr); | ||
31 | kfree(runtime->dma_buffer_p); | ||
32 | } | ||
33 | |||
34 | snd_pcm_set_runtime_buffer(substream, NULL); | ||
35 | } | ||
36 | |||
37 | int devdma_hw_alloc(struct device *dev, snd_pcm_substream_t *substream, size_t size) | ||
38 | { | ||
39 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
40 | struct snd_dma_buffer *buf = runtime->dma_buffer_p; | ||
41 | int ret = 0; | ||
42 | |||
43 | if (buf) { | ||
44 | if (buf->bytes >= size) | ||
45 | goto out; | ||
46 | devdma_hw_free(dev, substream); | ||
47 | } | ||
48 | |||
49 | if (substream->dma_buffer.area != NULL && substream->dma_buffer.bytes >= size) { | ||
50 | buf = &substream->dma_buffer; | ||
51 | } else { | ||
52 | buf = kmalloc(sizeof(struct snd_dma_buffer), GFP_KERNEL); | ||
53 | if (!buf) | ||
54 | goto nomem; | ||
55 | |||
56 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
57 | buf->dev.dev = dev; | ||
58 | buf->area = dma_alloc_coherent(dev, size, &buf->addr, GFP_KERNEL); | ||
59 | buf->bytes = size; | ||
60 | buf->private_data = NULL; | ||
61 | |||
62 | if (!buf->area) | ||
63 | goto free; | ||
64 | } | ||
65 | snd_pcm_set_runtime_buffer(substream, buf); | ||
66 | ret = 1; | ||
67 | out: | ||
68 | runtime->dma_bytes = size; | ||
69 | return ret; | ||
70 | |||
71 | free: | ||
72 | kfree(buf); | ||
73 | nomem: | ||
74 | return -ENOMEM; | ||
75 | } | ||
76 | |||
77 | int devdma_mmap(struct device *dev, snd_pcm_substream_t *substream, struct vm_area_struct *vma) | ||
78 | { | ||
79 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
80 | return dma_mmap_coherent(dev, vma, runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); | ||
81 | } | ||
diff --git a/sound/arm/devdma.h b/sound/arm/devdma.h new file mode 100644 index 000000000000..5a33b6bacc34 --- /dev/null +++ b/sound/arm/devdma.h | |||
@@ -0,0 +1,3 @@ | |||
1 | void devdma_hw_free(struct device *dev, snd_pcm_substream_t *substream); | ||
2 | int devdma_hw_alloc(struct device *dev, snd_pcm_substream_t *substream, size_t size); | ||
3 | int devdma_mmap(struct device *dev, snd_pcm_substream_t *substream, struct vm_area_struct *vma); | ||
diff --git a/sound/core/control.c b/sound/core/control.c index f4ea6bff1dd3..227f3cf02771 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -215,7 +215,7 @@ snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access) | |||
215 | * | 215 | * |
216 | * Returns the pointer of the newly generated instance, or NULL on failure. | 216 | * Returns the pointer of the newly generated instance, or NULL on failure. |
217 | */ | 217 | */ |
218 | snd_kcontrol_t *snd_ctl_new1(snd_kcontrol_new_t * ncontrol, void *private_data) | 218 | snd_kcontrol_t *snd_ctl_new1(const snd_kcontrol_new_t * ncontrol, void *private_data) |
219 | { | 219 | { |
220 | snd_kcontrol_t kctl; | 220 | snd_kcontrol_t kctl; |
221 | unsigned int access; | 221 | unsigned int access; |
@@ -1102,7 +1102,7 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg | |||
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | up_read(&snd_ioctl_rwsem); | 1104 | up_read(&snd_ioctl_rwsem); |
1105 | snd_printd("unknown ioctl = 0x%x\n", cmd); | 1105 | snd_printdd("unknown ioctl = 0x%x\n", cmd); |
1106 | return -ENOTTY; | 1106 | return -ENOTTY; |
1107 | } | 1107 | } |
1108 | 1108 | ||
diff --git a/sound/core/info.c b/sound/core/info.c index 31faffe01cb0..5e122bbe7c92 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/vmalloc.h> | 24 | #include <linux/vmalloc.h> |
25 | #include <linux/time.h> | 25 | #include <linux/time.h> |
26 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> |
27 | #include <linux/string.h> | ||
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
28 | #include <sound/minors.h> | 29 | #include <sound/minors.h> |
29 | #include <sound/info.h> | 30 | #include <sound/info.h> |
@@ -754,7 +755,7 @@ static snd_info_entry_t *snd_info_create_entry(const char *name) | |||
754 | entry = kcalloc(1, sizeof(*entry), GFP_KERNEL); | 755 | entry = kcalloc(1, sizeof(*entry), GFP_KERNEL); |
755 | if (entry == NULL) | 756 | if (entry == NULL) |
756 | return NULL; | 757 | return NULL; |
757 | entry->name = snd_kmalloc_strdup(name, GFP_KERNEL); | 758 | entry->name = kstrdup(name, GFP_KERNEL); |
758 | if (entry->name == NULL) { | 759 | if (entry->name == NULL) { |
759 | kfree(entry); | 760 | kfree(entry); |
760 | return NULL; | 761 | return NULL; |
diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c index f9e4ce443454..12107968d402 100644 --- a/sound/core/info_oss.c +++ b/sound/core/info_oss.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <sound/driver.h> | 22 | #include <sound/driver.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/time.h> | 24 | #include <linux/time.h> |
25 | #include <linux/string.h> | ||
25 | #include <sound/core.h> | 26 | #include <sound/core.h> |
26 | #include <sound/minors.h> | 27 | #include <sound/minors.h> |
27 | #include <sound/info.h> | 28 | #include <sound/info.h> |
@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int num, char *string) | |||
51 | x = NULL; | 52 | x = NULL; |
52 | } | 53 | } |
53 | } else { | 54 | } else { |
54 | x = snd_kmalloc_strdup(string, GFP_KERNEL); | 55 | x = kstrdup(string, GFP_KERNEL); |
55 | if (x == NULL) { | 56 | if (x == NULL) { |
56 | up(&strings); | 57 | up(&strings); |
57 | return -ENOMEM; | 58 | return -ENOMEM; |
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 344a83fd7c2e..dbc23e35fa06 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/pci.h> | 28 | #include <linux/pci.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/mm.h> | 30 | #include <linux/mm.h> |
31 | #include <asm/uaccess.h> | ||
31 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
32 | #include <linux/moduleparam.h> | 33 | #include <linux/moduleparam.h> |
33 | #include <asm/semaphore.h> | 34 | #include <asm/semaphore.h> |
@@ -46,13 +47,6 @@ MODULE_LICENSE("GPL"); | |||
46 | #define SNDRV_CARDS 8 | 47 | #define SNDRV_CARDS 8 |
47 | #endif | 48 | #endif |
48 | 49 | ||
49 | /* FIXME: so far only some PCI devices have the preallocation table */ | ||
50 | #ifdef CONFIG_PCI | ||
51 | static int enable[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1}; | ||
52 | module_param_array(enable, bool, NULL, 0444); | ||
53 | MODULE_PARM_DESC(enable, "Enable cards to allocate buffers."); | ||
54 | #endif | ||
55 | |||
56 | /* | 50 | /* |
57 | */ | 51 | */ |
58 | 52 | ||
@@ -451,9 +445,13 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) | |||
451 | list_for_each(p, &mem_list_head) { | 445 | list_for_each(p, &mem_list_head) { |
452 | mem = list_entry(p, struct snd_mem_list, list); | 446 | mem = list_entry(p, struct snd_mem_list, list); |
453 | if (mem->id == id && | 447 | if (mem->id == id && |
454 | ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev))) { | 448 | (mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL || |
449 | ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) { | ||
450 | struct device *dev = dmab->dev.dev; | ||
455 | list_del(p); | 451 | list_del(p); |
456 | *dmab = mem->buffer; | 452 | *dmab = mem->buffer; |
453 | if (dmab->dev.dev == NULL) | ||
454 | dmab->dev.dev = dev; | ||
457 | kfree(mem); | 455 | kfree(mem); |
458 | up(&list_mutex); | 456 | up(&list_mutex); |
459 | return dmab->bytes; | 457 | return dmab->bytes; |
@@ -508,91 +506,13 @@ static void free_all_reserved_pages(void) | |||
508 | } | 506 | } |
509 | 507 | ||
510 | 508 | ||
511 | |||
512 | /* | ||
513 | * allocation of buffers for pre-defined devices | ||
514 | */ | ||
515 | |||
516 | #ifdef CONFIG_PCI | ||
517 | /* FIXME: for pci only - other bus? */ | ||
518 | struct prealloc_dev { | ||
519 | unsigned short vendor; | ||
520 | unsigned short device; | ||
521 | unsigned long dma_mask; | ||
522 | unsigned int size; | ||
523 | unsigned int buffers; | ||
524 | }; | ||
525 | |||
526 | #define HAMMERFALL_BUFFER_SIZE (16*1024*4*(26+1)+0x10000) | ||
527 | |||
528 | static struct prealloc_dev prealloc_devices[] __initdata = { | ||
529 | { | ||
530 | /* hammerfall */ | ||
531 | .vendor = 0x10ee, | ||
532 | .device = 0x3fc4, | ||
533 | .dma_mask = 0xffffffff, | ||
534 | .size = HAMMERFALL_BUFFER_SIZE, | ||
535 | .buffers = 2 | ||
536 | }, | ||
537 | { | ||
538 | /* HDSP */ | ||
539 | .vendor = 0x10ee, | ||
540 | .device = 0x3fc5, | ||
541 | .dma_mask = 0xffffffff, | ||
542 | .size = HAMMERFALL_BUFFER_SIZE, | ||
543 | .buffers = 2 | ||
544 | }, | ||
545 | { }, /* terminator */ | ||
546 | }; | ||
547 | |||
548 | static void __init preallocate_cards(void) | ||
549 | { | ||
550 | struct pci_dev *pci = NULL; | ||
551 | int card; | ||
552 | |||
553 | card = 0; | ||
554 | |||
555 | while ((pci = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci)) != NULL) { | ||
556 | struct prealloc_dev *dev; | ||
557 | unsigned int i; | ||
558 | if (card >= SNDRV_CARDS) | ||
559 | break; | ||
560 | for (dev = prealloc_devices; dev->vendor; dev++) { | ||
561 | if (dev->vendor == pci->vendor && dev->device == pci->device) | ||
562 | break; | ||
563 | } | ||
564 | if (! dev->vendor) | ||
565 | continue; | ||
566 | if (! enable[card++]) { | ||
567 | printk(KERN_DEBUG "snd-page-alloc: skipping card %d, device %04x:%04x\n", card, pci->vendor, pci->device); | ||
568 | continue; | ||
569 | } | ||
570 | |||
571 | if (pci_set_dma_mask(pci, dev->dma_mask) < 0 || | ||
572 | pci_set_consistent_dma_mask(pci, dev->dma_mask) < 0) { | ||
573 | printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", dev->dma_mask, dev->vendor, dev->device); | ||
574 | continue; | ||
575 | } | ||
576 | for (i = 0; i < dev->buffers; i++) { | ||
577 | struct snd_dma_buffer dmab; | ||
578 | memset(&dmab, 0, sizeof(dmab)); | ||
579 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), | ||
580 | dev->size, &dmab) < 0) | ||
581 | printk(KERN_WARNING "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", dev->size); | ||
582 | else | ||
583 | snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci)); | ||
584 | } | ||
585 | } | ||
586 | } | ||
587 | #else | ||
588 | #define preallocate_cards() /* NOP */ | ||
589 | #endif | ||
590 | |||
591 | |||
592 | #ifdef CONFIG_PROC_FS | 509 | #ifdef CONFIG_PROC_FS |
593 | /* | 510 | /* |
594 | * proc file interface | 511 | * proc file interface |
595 | */ | 512 | */ |
513 | #define SND_MEM_PROC_FILE "driver/snd-page-alloc" | ||
514 | struct proc_dir_entry *snd_mem_proc; | ||
515 | |||
596 | static int snd_mem_proc_read(char *page, char **start, off_t off, | 516 | static int snd_mem_proc_read(char *page, char **start, off_t off, |
597 | int count, int *eof, void *data) | 517 | int count, int *eof, void *data) |
598 | { | 518 | { |
@@ -621,6 +541,97 @@ static int snd_mem_proc_read(char *page, char **start, off_t off, | |||
621 | up(&list_mutex); | 541 | up(&list_mutex); |
622 | return len; | 542 | return len; |
623 | } | 543 | } |
544 | |||
545 | /* FIXME: for pci only - other bus? */ | ||
546 | #ifdef CONFIG_PCI | ||
547 | #define gettoken(bufp) strsep(bufp, " \t\n") | ||
548 | |||
549 | static int snd_mem_proc_write(struct file *file, const char __user *buffer, | ||
550 | unsigned long count, void *data) | ||
551 | { | ||
552 | char buf[128]; | ||
553 | char *token, *p; | ||
554 | |||
555 | if (count > ARRAY_SIZE(buf) - 1) | ||
556 | count = ARRAY_SIZE(buf) - 1; | ||
557 | if (copy_from_user(buf, buffer, count)) | ||
558 | return -EFAULT; | ||
559 | buf[ARRAY_SIZE(buf) - 1] = '\0'; | ||
560 | |||
561 | p = buf; | ||
562 | token = gettoken(&p); | ||
563 | if (! token || *token == '#') | ||
564 | return (int)count; | ||
565 | if (strcmp(token, "add") == 0) { | ||
566 | char *endp; | ||
567 | int vendor, device, size, buffers; | ||
568 | long mask; | ||
569 | int i, alloced; | ||
570 | struct pci_dev *pci; | ||
571 | |||
572 | if ((token = gettoken(&p)) == NULL || | ||
573 | (vendor = simple_strtol(token, NULL, 0)) <= 0 || | ||
574 | (token = gettoken(&p)) == NULL || | ||
575 | (device = simple_strtol(token, NULL, 0)) <= 0 || | ||
576 | (token = gettoken(&p)) == NULL || | ||
577 | (mask = simple_strtol(token, NULL, 0)) < 0 || | ||
578 | (token = gettoken(&p)) == NULL || | ||
579 | (size = memparse(token, &endp)) < 64*1024 || | ||
580 | size > 16*1024*1024 /* too big */ || | ||
581 | (token = gettoken(&p)) == NULL || | ||
582 | (buffers = simple_strtol(token, NULL, 0)) <= 0 || | ||
583 | buffers > 4) { | ||
584 | printk(KERN_ERR "snd-page-alloc: invalid proc write format\n"); | ||
585 | return (int)count; | ||
586 | } | ||
587 | vendor &= 0xffff; | ||
588 | device &= 0xffff; | ||
589 | |||
590 | alloced = 0; | ||
591 | pci = NULL; | ||
592 | while ((pci = pci_find_device(vendor, device, pci)) != NULL) { | ||
593 | if (mask > 0 && mask < 0xffffffff) { | ||
594 | if (pci_set_dma_mask(pci, mask) < 0 || | ||
595 | pci_set_consistent_dma_mask(pci, mask) < 0) { | ||
596 | printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", mask, vendor, device); | ||
597 | return (int)count; | ||
598 | } | ||
599 | } | ||
600 | for (i = 0; i < buffers; i++) { | ||
601 | struct snd_dma_buffer dmab; | ||
602 | memset(&dmab, 0, sizeof(dmab)); | ||
603 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), | ||
604 | size, &dmab) < 0) { | ||
605 | printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size); | ||
606 | return (int)count; | ||
607 | } | ||
608 | snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci)); | ||
609 | } | ||
610 | alloced++; | ||
611 | } | ||
612 | if (! alloced) { | ||
613 | for (i = 0; i < buffers; i++) { | ||
614 | struct snd_dma_buffer dmab; | ||
615 | memset(&dmab, 0, sizeof(dmab)); | ||
616 | /* FIXME: We can allocate only in ZONE_DMA | ||
617 | * without a device pointer! | ||
618 | */ | ||
619 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, NULL, | ||
620 | size, &dmab) < 0) { | ||
621 | printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size); | ||
622 | break; | ||
623 | } | ||
624 | snd_dma_reserve_buf(&dmab, (unsigned int)((vendor << 16) | device)); | ||
625 | } | ||
626 | } | ||
627 | } else if (strcmp(token, "erase") == 0) | ||
628 | /* FIXME: need for releasing each buffer chunk? */ | ||
629 | free_all_reserved_pages(); | ||
630 | else | ||
631 | printk(KERN_ERR "snd-page-alloc: invalid proc cmd\n"); | ||
632 | return (int)count; | ||
633 | } | ||
634 | #endif /* CONFIG_PCI */ | ||
624 | #endif /* CONFIG_PROC_FS */ | 635 | #endif /* CONFIG_PROC_FS */ |
625 | 636 | ||
626 | /* | 637 | /* |
@@ -630,15 +641,21 @@ static int snd_mem_proc_read(char *page, char **start, off_t off, | |||
630 | static int __init snd_mem_init(void) | 641 | static int __init snd_mem_init(void) |
631 | { | 642 | { |
632 | #ifdef CONFIG_PROC_FS | 643 | #ifdef CONFIG_PROC_FS |
633 | create_proc_read_entry("driver/snd-page-alloc", 0, NULL, snd_mem_proc_read, NULL); | 644 | snd_mem_proc = create_proc_entry(SND_MEM_PROC_FILE, 0644, NULL); |
645 | if (snd_mem_proc) { | ||
646 | snd_mem_proc->read_proc = snd_mem_proc_read; | ||
647 | #ifdef CONFIG_PCI | ||
648 | snd_mem_proc->write_proc = snd_mem_proc_write; | ||
649 | #endif | ||
650 | } | ||
634 | #endif | 651 | #endif |
635 | preallocate_cards(); | ||
636 | return 0; | 652 | return 0; |
637 | } | 653 | } |
638 | 654 | ||
639 | static void __exit snd_mem_exit(void) | 655 | static void __exit snd_mem_exit(void) |
640 | { | 656 | { |
641 | remove_proc_entry("driver/snd-page-alloc", NULL); | 657 | if (snd_mem_proc) |
658 | remove_proc_entry(SND_MEM_PROC_FILE, NULL); | ||
642 | free_all_reserved_pages(); | 659 | free_all_reserved_pages(); |
643 | if (snd_allocated_pages > 0) | 660 | if (snd_allocated_pages > 0) |
644 | printk(KERN_ERR "snd-malloc: Memory leak? pages not freed = %li\n", snd_allocated_pages); | 661 | printk(KERN_ERR "snd-malloc: Memory leak? pages not freed = %li\n", snd_allocated_pages); |
diff --git a/sound/core/memory.c b/sound/core/memory.c index 20860fec9364..c1fb28e84330 100644 --- a/sound/core/memory.c +++ b/sound/core/memory.c | |||
@@ -184,6 +184,20 @@ void snd_hidden_vfree(void *obj) | |||
184 | snd_wrapper_vfree(obj); | 184 | snd_wrapper_vfree(obj); |
185 | } | 185 | } |
186 | 186 | ||
187 | char *snd_hidden_kstrdup(const char *s, int flags) | ||
188 | { | ||
189 | int len; | ||
190 | char *buf; | ||
191 | |||
192 | if (!s) return NULL; | ||
193 | |||
194 | len = strlen(s) + 1; | ||
195 | buf = _snd_kmalloc(len, flags); | ||
196 | if (buf) | ||
197 | memcpy(buf, s, len); | ||
198 | return buf; | ||
199 | } | ||
200 | |||
187 | static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) | 201 | static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) |
188 | { | 202 | { |
189 | snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc); | 203 | snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc); |
@@ -214,36 +228,9 @@ int __exit snd_memory_info_done(void) | |||
214 | return 0; | 228 | return 0; |
215 | } | 229 | } |
216 | 230 | ||
217 | #else | ||
218 | |||
219 | #define _snd_kmalloc kmalloc | ||
220 | |||
221 | #endif /* CONFIG_SND_DEBUG_MEMORY */ | 231 | #endif /* CONFIG_SND_DEBUG_MEMORY */ |
222 | 232 | ||
223 | /** | 233 | /** |
224 | * snd_kmalloc_strdup - copy the string | ||
225 | * @string: the original string | ||
226 | * @flags: allocation conditions, GFP_XXX | ||
227 | * | ||
228 | * Allocates a memory chunk via kmalloc() and copies the string to it. | ||
229 | * | ||
230 | * Returns the pointer, or NULL if no enoguh memory. | ||
231 | */ | ||
232 | char *snd_kmalloc_strdup(const char *string, int flags) | ||
233 | { | ||
234 | size_t len; | ||
235 | char *ptr; | ||
236 | |||
237 | if (!string) | ||
238 | return NULL; | ||
239 | len = strlen(string) + 1; | ||
240 | ptr = _snd_kmalloc(len, flags); | ||
241 | if (ptr) | ||
242 | memcpy(ptr, string, len); | ||
243 | return ptr; | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * copy_to_user_fromio - copy data from mmio-space to user-space | 234 | * copy_to_user_fromio - copy data from mmio-space to user-space |
248 | * @dst: the destination pointer on user-space | 235 | * @dst: the destination pointer on user-space |
249 | * @src: the source pointer on mmio | 236 | * @src: the source pointer on mmio |
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 98ed9a9f0da6..98fc0766f885 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/smp_lock.h> | 24 | #include <linux/smp_lock.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/time.h> | 26 | #include <linux/time.h> |
27 | #include <linux/string.h> | ||
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
28 | #include <sound/minors.h> | 29 | #include <sound/minors.h> |
29 | #include <sound/control.h> | 30 | #include <sound/control.h> |
@@ -1137,7 +1138,7 @@ static void snd_mixer_oss_proc_write(snd_info_entry_t *entry, | |||
1137 | goto __unlock; | 1138 | goto __unlock; |
1138 | } | 1139 | } |
1139 | tbl->oss_id = ch; | 1140 | tbl->oss_id = ch; |
1140 | tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL); | 1141 | tbl->name = kstrdup(str, GFP_KERNEL); |
1141 | if (! tbl->name) { | 1142 | if (! tbl->name) { |
1142 | kfree(tbl); | 1143 | kfree(tbl); |
1143 | goto __unlock; | 1144 | goto __unlock; |
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 1a805020f57a..de7444c586f9 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/time.h> | 33 | #include <linux/time.h> |
34 | #include <linux/vmalloc.h> | 34 | #include <linux/vmalloc.h> |
35 | #include <linux/moduleparam.h> | 35 | #include <linux/moduleparam.h> |
36 | #include <linux/string.h> | ||
36 | #include <sound/core.h> | 37 | #include <sound/core.h> |
37 | #include <sound/minors.h> | 38 | #include <sound/minors.h> |
38 | #include <sound/pcm.h> | 39 | #include <sound/pcm.h> |
@@ -125,17 +126,26 @@ int snd_pcm_plugin_append(snd_pcm_plugin_t *plugin) | |||
125 | static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames) | 126 | static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames) |
126 | { | 127 | { |
127 | snd_pcm_runtime_t *runtime = substream->runtime; | 128 | snd_pcm_runtime_t *runtime = substream->runtime; |
128 | snd_pcm_uframes_t buffer_size = snd_pcm_lib_buffer_bytes(substream); | 129 | long buffer_size = snd_pcm_lib_buffer_bytes(substream); |
129 | frames = frames_to_bytes(runtime, frames); | 130 | long bytes = frames_to_bytes(runtime, frames); |
130 | if (buffer_size == runtime->oss.buffer_bytes) | 131 | if (buffer_size == runtime->oss.buffer_bytes) |
131 | return frames; | 132 | return bytes; |
132 | return (runtime->oss.buffer_bytes * frames) / buffer_size; | 133 | #if BITS_PER_LONG >= 64 |
134 | return runtime->oss.buffer_bytes * bytes / buffer_size; | ||
135 | #else | ||
136 | { | ||
137 | u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes; | ||
138 | u32 rem; | ||
139 | div64_32(&bsize, buffer_size, &rem); | ||
140 | return (long)bsize; | ||
141 | } | ||
142 | #endif | ||
133 | } | 143 | } |
134 | 144 | ||
135 | static long snd_pcm_alsa_frames(snd_pcm_substream_t *substream, long bytes) | 145 | static long snd_pcm_alsa_frames(snd_pcm_substream_t *substream, long bytes) |
136 | { | 146 | { |
137 | snd_pcm_runtime_t *runtime = substream->runtime; | 147 | snd_pcm_runtime_t *runtime = substream->runtime; |
138 | snd_pcm_uframes_t buffer_size = snd_pcm_lib_buffer_bytes(substream); | 148 | long buffer_size = snd_pcm_lib_buffer_bytes(substream); |
139 | if (buffer_size == runtime->oss.buffer_bytes) | 149 | if (buffer_size == runtime->oss.buffer_bytes) |
140 | return bytes_to_frames(runtime, bytes); | 150 | return bytes_to_frames(runtime, bytes); |
141 | return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes); | 151 | return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes); |
@@ -464,7 +474,8 @@ static int snd_pcm_oss_change_params(snd_pcm_substream_t *substream) | |||
464 | sw_params->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; | 474 | sw_params->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; |
465 | sw_params->period_step = 1; | 475 | sw_params->period_step = 1; |
466 | sw_params->sleep_min = 0; | 476 | sw_params->sleep_min = 0; |
467 | sw_params->avail_min = 1; | 477 | sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? |
478 | 1 : runtime->period_size; | ||
468 | sw_params->xfer_align = 1; | 479 | sw_params->xfer_align = 1; |
469 | if (atomic_read(&runtime->mmap_count) || | 480 | if (atomic_read(&runtime->mmap_count) || |
470 | (substream->oss.setup && substream->oss.setup->nosilence)) { | 481 | (substream->oss.setup && substream->oss.setup->nosilence)) { |
@@ -1527,12 +1538,15 @@ static int snd_pcm_oss_get_ptr(snd_pcm_oss_file_t *pcm_oss_file, int stream, str | |||
1527 | snd_pcm_oss_simulate_fill(substream, delay); | 1538 | snd_pcm_oss_simulate_fill(substream, delay); |
1528 | info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX; | 1539 | info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX; |
1529 | } else { | 1540 | } else { |
1530 | delay = snd_pcm_oss_bytes(substream, delay) + fixup; | 1541 | delay = snd_pcm_oss_bytes(substream, delay); |
1531 | info.blocks = delay / runtime->oss.period_bytes; | 1542 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
1532 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) | 1543 | info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes; |
1533 | info.bytes = (runtime->oss.bytes - delay) & INT_MAX; | 1544 | info.bytes = (runtime->oss.bytes - delay) & INT_MAX; |
1534 | else | 1545 | } else { |
1546 | delay += fixup; | ||
1547 | info.blocks = delay / runtime->oss.period_bytes; | ||
1535 | info.bytes = (runtime->oss.bytes + delay) & INT_MAX; | 1548 | info.bytes = (runtime->oss.bytes + delay) & INT_MAX; |
1549 | } | ||
1536 | } | 1550 | } |
1537 | if (copy_to_user(_info, &info, sizeof(info))) | 1551 | if (copy_to_user(_info, &info, sizeof(info))) |
1538 | return -EFAULT; | 1552 | return -EFAULT; |
@@ -2347,7 +2361,7 @@ static void snd_pcm_oss_proc_write(snd_info_entry_t *entry, | |||
2347 | for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next); | 2361 | for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next); |
2348 | setup1->next = setup; | 2362 | setup1->next = setup; |
2349 | } | 2363 | } |
2350 | template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL); | 2364 | template.task_name = kstrdup(task_name, GFP_KERNEL); |
2351 | } else { | 2365 | } else { |
2352 | buffer->error = -ENOMEM; | 2366 | buffer->error = -ENOMEM; |
2353 | } | 2367 | } |
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index 6bb31009f0b4..6430410c6c04 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c | |||
@@ -663,10 +663,7 @@ static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug, | |||
663 | bitset_t *dstmask = bs; | 663 | bitset_t *dstmask = bs; |
664 | int err; | 664 | int err; |
665 | bitset_one(dstmask, schannels); | 665 | bitset_one(dstmask, schannels); |
666 | if (plugin == NULL) { | 666 | |
667 | bitset_and(client_vmask, dstmask, schannels); | ||
668 | return 0; | ||
669 | } | ||
670 | while (1) { | 667 | while (1) { |
671 | err = plugin->src_channels_mask(plugin, dstmask, &srcmask); | 668 | err = plugin->src_channels_mask(plugin, dstmask, &srcmask); |
672 | if (err < 0) | 669 | if (err < 0) |
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 8d94325529a8..9f4c9209b271 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -451,6 +451,7 @@ static int snd_pcm_stream_proc_init(snd_pcm_str_t *pstr) | |||
451 | entry->c.text.read = snd_pcm_xrun_debug_read; | 451 | entry->c.text.read = snd_pcm_xrun_debug_read; |
452 | entry->c.text.write_size = 64; | 452 | entry->c.text.write_size = 64; |
453 | entry->c.text.write = snd_pcm_xrun_debug_write; | 453 | entry->c.text.write = snd_pcm_xrun_debug_write; |
454 | entry->mode |= S_IWUSR; | ||
454 | entry->private_data = pstr; | 455 | entry->private_data = pstr; |
455 | if (snd_info_register(entry) < 0) { | 456 | if (snd_info_register(entry) < 0) { |
456 | snd_info_free_entry(entry); | 457 | snd_info_free_entry(entry); |
@@ -1048,7 +1049,6 @@ EXPORT_SYMBOL(snd_pcm_release_substream); | |||
1048 | EXPORT_SYMBOL(snd_pcm_format_name); | 1049 | EXPORT_SYMBOL(snd_pcm_format_name); |
1049 | /* pcm_native.c */ | 1050 | /* pcm_native.c */ |
1050 | EXPORT_SYMBOL(snd_pcm_link_rwlock); | 1051 | EXPORT_SYMBOL(snd_pcm_link_rwlock); |
1051 | EXPORT_SYMBOL(snd_pcm_start); | ||
1052 | #ifdef CONFIG_PM | 1052 | #ifdef CONFIG_PM |
1053 | EXPORT_SYMBOL(snd_pcm_suspend); | 1053 | EXPORT_SYMBOL(snd_pcm_suspend); |
1054 | EXPORT_SYMBOL(snd_pcm_suspend_all); | 1054 | EXPORT_SYMBOL(snd_pcm_suspend_all); |
@@ -1068,6 +1068,7 @@ EXPORT_SYMBOL(snd_pcm_format_little_endian); | |||
1068 | EXPORT_SYMBOL(snd_pcm_format_big_endian); | 1068 | EXPORT_SYMBOL(snd_pcm_format_big_endian); |
1069 | EXPORT_SYMBOL(snd_pcm_format_width); | 1069 | EXPORT_SYMBOL(snd_pcm_format_width); |
1070 | EXPORT_SYMBOL(snd_pcm_format_physical_width); | 1070 | EXPORT_SYMBOL(snd_pcm_format_physical_width); |
1071 | EXPORT_SYMBOL(snd_pcm_format_size); | ||
1071 | EXPORT_SYMBOL(snd_pcm_format_silence_64); | 1072 | EXPORT_SYMBOL(snd_pcm_format_silence_64); |
1072 | EXPORT_SYMBOL(snd_pcm_format_set_silence); | 1073 | EXPORT_SYMBOL(snd_pcm_format_set_silence); |
1073 | EXPORT_SYMBOL(snd_pcm_build_linear_format); | 1074 | EXPORT_SYMBOL(snd_pcm_build_linear_format); |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 151fd99ca2c9..c5bfd0918cff 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -1143,7 +1143,8 @@ int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime, | |||
1143 | #define INT_MIN ((int)((unsigned int)INT_MAX+1)) | 1143 | #define INT_MIN ((int)((unsigned int)INT_MAX+1)) |
1144 | #endif | 1144 | #endif |
1145 | 1145 | ||
1146 | void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var) | 1146 | static void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params, |
1147 | snd_pcm_hw_param_t var) | ||
1147 | { | 1148 | { |
1148 | if (hw_is_mask(var)) { | 1149 | if (hw_is_mask(var)) { |
1149 | snd_mask_any(hw_param_mask(params, var)); | 1150 | snd_mask_any(hw_param_mask(params, var)); |
@@ -1160,6 +1161,7 @@ void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var) | |||
1160 | snd_BUG(); | 1161 | snd_BUG(); |
1161 | } | 1162 | } |
1162 | 1163 | ||
1164 | #if 0 | ||
1163 | /** | 1165 | /** |
1164 | * snd_pcm_hw_param_any | 1166 | * snd_pcm_hw_param_any |
1165 | */ | 1167 | */ |
@@ -1169,6 +1171,7 @@ int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, | |||
1169 | _snd_pcm_hw_param_any(params, var); | 1171 | _snd_pcm_hw_param_any(params, var); |
1170 | return snd_pcm_hw_refine(pcm, params); | 1172 | return snd_pcm_hw_refine(pcm, params); |
1171 | } | 1173 | } |
1174 | #endif /* 0 */ | ||
1172 | 1175 | ||
1173 | void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) | 1176 | void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) |
1174 | { | 1177 | { |
@@ -1181,6 +1184,7 @@ void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) | |||
1181 | params->info = ~0U; | 1184 | params->info = ~0U; |
1182 | } | 1185 | } |
1183 | 1186 | ||
1187 | #if 0 | ||
1184 | /** | 1188 | /** |
1185 | * snd_pcm_hw_params_any | 1189 | * snd_pcm_hw_params_any |
1186 | * | 1190 | * |
@@ -1191,6 +1195,7 @@ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) | |||
1191 | _snd_pcm_hw_params_any(params); | 1195 | _snd_pcm_hw_params_any(params); |
1192 | return snd_pcm_hw_refine(pcm, params); | 1196 | return snd_pcm_hw_refine(pcm, params); |
1193 | } | 1197 | } |
1198 | #endif /* 0 */ | ||
1194 | 1199 | ||
1195 | /** | 1200 | /** |
1196 | * snd_pcm_hw_param_value | 1201 | * snd_pcm_hw_param_value |
@@ -1198,8 +1203,8 @@ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) | |||
1198 | * Return the value for field PAR if it's fixed in configuration space | 1203 | * Return the value for field PAR if it's fixed in configuration space |
1199 | * defined by PARAMS. Return -EINVAL otherwise | 1204 | * defined by PARAMS. Return -EINVAL otherwise |
1200 | */ | 1205 | */ |
1201 | int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, | 1206 | static int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, |
1202 | snd_pcm_hw_param_t var, int *dir) | 1207 | snd_pcm_hw_param_t var, int *dir) |
1203 | { | 1208 | { |
1204 | if (hw_is_mask(var)) { | 1209 | if (hw_is_mask(var)) { |
1205 | const snd_mask_t *mask = hw_param_mask_c(params, var); | 1210 | const snd_mask_t *mask = hw_param_mask_c(params, var); |
@@ -1296,6 +1301,7 @@ int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params, | |||
1296 | return changed; | 1301 | return changed; |
1297 | } | 1302 | } |
1298 | 1303 | ||
1304 | #if 0 | ||
1299 | /** | 1305 | /** |
1300 | * snd_pcm_hw_param_setinteger | 1306 | * snd_pcm_hw_param_setinteger |
1301 | * | 1307 | * |
@@ -1317,9 +1323,10 @@ int snd_pcm_hw_param_setinteger(snd_pcm_t *pcm, | |||
1317 | } | 1323 | } |
1318 | return 0; | 1324 | return 0; |
1319 | } | 1325 | } |
1326 | #endif /* 0 */ | ||
1320 | 1327 | ||
1321 | int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, | 1328 | static int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, |
1322 | snd_pcm_hw_param_t var) | 1329 | snd_pcm_hw_param_t var) |
1323 | { | 1330 | { |
1324 | int changed; | 1331 | int changed; |
1325 | if (hw_is_mask(var)) | 1332 | if (hw_is_mask(var)) |
@@ -1345,9 +1352,9 @@ int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, | |||
1345 | * values > minimum. Reduce configuration space accordingly. | 1352 | * values > minimum. Reduce configuration space accordingly. |
1346 | * Return the minimum. | 1353 | * Return the minimum. |
1347 | */ | 1354 | */ |
1348 | int snd_pcm_hw_param_first(snd_pcm_t *pcm, | 1355 | static int snd_pcm_hw_param_first(snd_pcm_t *pcm, |
1349 | snd_pcm_hw_params_t *params, | 1356 | snd_pcm_hw_params_t *params, |
1350 | snd_pcm_hw_param_t var, int *dir) | 1357 | snd_pcm_hw_param_t var, int *dir) |
1351 | { | 1358 | { |
1352 | int changed = _snd_pcm_hw_param_first(params, var); | 1359 | int changed = _snd_pcm_hw_param_first(params, var); |
1353 | if (changed < 0) | 1360 | if (changed < 0) |
@@ -1359,8 +1366,8 @@ int snd_pcm_hw_param_first(snd_pcm_t *pcm, | |||
1359 | return snd_pcm_hw_param_value(params, var, dir); | 1366 | return snd_pcm_hw_param_value(params, var, dir); |
1360 | } | 1367 | } |
1361 | 1368 | ||
1362 | int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, | 1369 | static int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, |
1363 | snd_pcm_hw_param_t var) | 1370 | snd_pcm_hw_param_t var) |
1364 | { | 1371 | { |
1365 | int changed; | 1372 | int changed; |
1366 | if (hw_is_mask(var)) | 1373 | if (hw_is_mask(var)) |
@@ -1386,9 +1393,9 @@ int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, | |||
1386 | * values < maximum. Reduce configuration space accordingly. | 1393 | * values < maximum. Reduce configuration space accordingly. |
1387 | * Return the maximum. | 1394 | * Return the maximum. |
1388 | */ | 1395 | */ |
1389 | int snd_pcm_hw_param_last(snd_pcm_t *pcm, | 1396 | static int snd_pcm_hw_param_last(snd_pcm_t *pcm, |
1390 | snd_pcm_hw_params_t *params, | 1397 | snd_pcm_hw_params_t *params, |
1391 | snd_pcm_hw_param_t var, int *dir) | 1398 | snd_pcm_hw_param_t var, int *dir) |
1392 | { | 1399 | { |
1393 | int changed = _snd_pcm_hw_param_last(params, var); | 1400 | int changed = _snd_pcm_hw_param_last(params, var); |
1394 | if (changed < 0) | 1401 | if (changed < 0) |
@@ -1437,8 +1444,9 @@ int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, | |||
1437 | * values < VAL. Reduce configuration space accordingly. | 1444 | * values < VAL. Reduce configuration space accordingly. |
1438 | * Return new minimum or -EINVAL if the configuration space is empty | 1445 | * Return new minimum or -EINVAL if the configuration space is empty |
1439 | */ | 1446 | */ |
1440 | int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, | 1447 | static int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, |
1441 | snd_pcm_hw_param_t var, unsigned int val, int *dir) | 1448 | snd_pcm_hw_param_t var, unsigned int val, |
1449 | int *dir) | ||
1442 | { | 1450 | { |
1443 | int changed = _snd_pcm_hw_param_min(params, var, val, dir ? *dir : 0); | 1451 | int changed = _snd_pcm_hw_param_min(params, var, val, dir ? *dir : 0); |
1444 | if (changed < 0) | 1452 | if (changed < 0) |
@@ -1451,8 +1459,9 @@ int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, | |||
1451 | return snd_pcm_hw_param_value_min(params, var, dir); | 1459 | return snd_pcm_hw_param_value_min(params, var, dir); |
1452 | } | 1460 | } |
1453 | 1461 | ||
1454 | int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, | 1462 | static int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, |
1455 | snd_pcm_hw_param_t var, unsigned int val, int dir) | 1463 | snd_pcm_hw_param_t var, unsigned int val, |
1464 | int dir) | ||
1456 | { | 1465 | { |
1457 | int changed; | 1466 | int changed; |
1458 | int open = 0; | 1467 | int open = 0; |
@@ -1490,8 +1499,9 @@ int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, | |||
1490 | * values >= VAL + 1. Reduce configuration space accordingly. | 1499 | * values >= VAL + 1. Reduce configuration space accordingly. |
1491 | * Return new maximum or -EINVAL if the configuration space is empty | 1500 | * Return new maximum or -EINVAL if the configuration space is empty |
1492 | */ | 1501 | */ |
1493 | int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, | 1502 | static int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, |
1494 | snd_pcm_hw_param_t var, unsigned int val, int *dir) | 1503 | snd_pcm_hw_param_t var, unsigned int val, |
1504 | int *dir) | ||
1495 | { | 1505 | { |
1496 | int changed = _snd_pcm_hw_param_max(params, var, val, dir ? *dir : 0); | 1506 | int changed = _snd_pcm_hw_param_max(params, var, val, dir ? *dir : 0); |
1497 | if (changed < 0) | 1507 | if (changed < 0) |
@@ -2564,9 +2574,6 @@ snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, | |||
2564 | EXPORT_SYMBOL(snd_interval_refine); | 2574 | EXPORT_SYMBOL(snd_interval_refine); |
2565 | EXPORT_SYMBOL(snd_interval_list); | 2575 | EXPORT_SYMBOL(snd_interval_list); |
2566 | EXPORT_SYMBOL(snd_interval_ratnum); | 2576 | EXPORT_SYMBOL(snd_interval_ratnum); |
2567 | EXPORT_SYMBOL(snd_interval_muldivk); | ||
2568 | EXPORT_SYMBOL(snd_interval_mulkdiv); | ||
2569 | EXPORT_SYMBOL(snd_interval_div); | ||
2570 | EXPORT_SYMBOL(_snd_pcm_hw_params_any); | 2577 | EXPORT_SYMBOL(_snd_pcm_hw_params_any); |
2571 | EXPORT_SYMBOL(_snd_pcm_hw_param_min); | 2578 | EXPORT_SYMBOL(_snd_pcm_hw_param_min); |
2572 | EXPORT_SYMBOL(_snd_pcm_hw_param_set); | 2579 | EXPORT_SYMBOL(_snd_pcm_hw_param_set); |
@@ -2580,7 +2587,6 @@ EXPORT_SYMBOL(snd_pcm_hw_param_last); | |||
2580 | EXPORT_SYMBOL(snd_pcm_hw_param_near); | 2587 | EXPORT_SYMBOL(snd_pcm_hw_param_near); |
2581 | EXPORT_SYMBOL(snd_pcm_hw_param_set); | 2588 | EXPORT_SYMBOL(snd_pcm_hw_param_set); |
2582 | EXPORT_SYMBOL(snd_pcm_hw_refine); | 2589 | EXPORT_SYMBOL(snd_pcm_hw_refine); |
2583 | EXPORT_SYMBOL(snd_pcm_hw_params); | ||
2584 | EXPORT_SYMBOL(snd_pcm_hw_constraints_init); | 2590 | EXPORT_SYMBOL(snd_pcm_hw_constraints_init); |
2585 | EXPORT_SYMBOL(snd_pcm_hw_constraints_complete); | 2591 | EXPORT_SYMBOL(snd_pcm_hw_constraints_complete); |
2586 | EXPORT_SYMBOL(snd_pcm_hw_constraint_list); | 2592 | EXPORT_SYMBOL(snd_pcm_hw_constraint_list); |
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index f1d5f7a6ee0c..9a174fb96565 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -204,6 +204,7 @@ static int snd_pcm_lib_preallocate_pages1(snd_pcm_substream_t *substream, | |||
204 | entry->c.text.read = snd_pcm_lib_preallocate_proc_read; | 204 | entry->c.text.read = snd_pcm_lib_preallocate_proc_read; |
205 | entry->c.text.write_size = 64; | 205 | entry->c.text.write_size = 64; |
206 | entry->c.text.write = snd_pcm_lib_preallocate_proc_write; | 206 | entry->c.text.write = snd_pcm_lib_preallocate_proc_write; |
207 | entry->mode |= S_IWUSR; | ||
207 | entry->private_data = substream; | 208 | entry->private_data = substream; |
208 | if (snd_info_register(entry) < 0) { | 209 | if (snd_info_register(entry) < 0) { |
209 | snd_info_free_entry(entry); | 210 | snd_info_free_entry(entry); |
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index 422b8db14154..1453743e4da0 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c | |||
@@ -270,22 +270,6 @@ int snd_pcm_format_big_endian(snd_pcm_format_t format) | |||
270 | } | 270 | } |
271 | 271 | ||
272 | /** | 272 | /** |
273 | * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian | ||
274 | * @format: the format to check | ||
275 | * | ||
276 | * Returns 1 if the given PCM format is CPU-endian, 0 if | ||
277 | * opposite, or a negative error code if endian not specified. | ||
278 | */ | ||
279 | int snd_pcm_format_cpu_endian(snd_pcm_format_t format) | ||
280 | { | ||
281 | #ifdef SNDRV_LITTLE_ENDIAN | ||
282 | return snd_pcm_format_little_endian(format); | ||
283 | #else | ||
284 | return snd_pcm_format_big_endian(format); | ||
285 | #endif | ||
286 | } | ||
287 | |||
288 | /** | ||
289 | * snd_pcm_format_width - return the bit-width of the format | 273 | * snd_pcm_format_width - return the bit-width of the format |
290 | * @format: the format to check | 274 | * @format: the format to check |
291 | * | 275 | * |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index cad9bbde9986..10c2c9832649 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -337,8 +337,8 @@ out: | |||
337 | return err; | 337 | return err; |
338 | } | 338 | } |
339 | 339 | ||
340 | int snd_pcm_hw_params(snd_pcm_substream_t *substream, | 340 | static int snd_pcm_hw_params(snd_pcm_substream_t *substream, |
341 | snd_pcm_hw_params_t *params) | 341 | snd_pcm_hw_params_t *params) |
342 | { | 342 | { |
343 | snd_pcm_runtime_t *runtime; | 343 | snd_pcm_runtime_t *runtime; |
344 | int err; | 344 | int err; |
@@ -1368,43 +1368,32 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream) | |||
1368 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) | 1368 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) |
1369 | return -EBADFD; | 1369 | return -EBADFD; |
1370 | 1370 | ||
1371 | down_read(&snd_pcm_link_rwsem); | ||
1372 | snd_power_lock(card); | 1371 | snd_power_lock(card); |
1373 | if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { | 1372 | if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { |
1374 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile); | 1373 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile); |
1375 | if (result < 0) | 1374 | if (result < 0) { |
1376 | goto _unlock; | 1375 | snd_power_unlock(card); |
1376 | return result; | ||
1377 | } | ||
1377 | } | 1378 | } |
1378 | 1379 | ||
1379 | /* allocate temporary record for drain sync */ | 1380 | /* allocate temporary record for drain sync */ |
1381 | down_read(&snd_pcm_link_rwsem); | ||
1380 | if (snd_pcm_stream_linked(substream)) { | 1382 | if (snd_pcm_stream_linked(substream)) { |
1381 | drec = kmalloc(substream->group->count * sizeof(*drec), GFP_KERNEL); | 1383 | drec = kmalloc(substream->group->count * sizeof(*drec), GFP_KERNEL); |
1382 | if (! drec) { | 1384 | if (! drec) { |
1383 | result = -ENOMEM; | 1385 | up_read(&snd_pcm_link_rwsem); |
1384 | goto _unlock; | 1386 | snd_power_unlock(card); |
1387 | return -ENOMEM; | ||
1385 | } | 1388 | } |
1386 | } else | 1389 | } else |
1387 | drec = &drec_tmp; | 1390 | drec = &drec_tmp; |
1388 | 1391 | ||
1389 | snd_pcm_stream_lock_irq(substream); | 1392 | /* count only playback streams */ |
1390 | /* resume pause */ | ||
1391 | if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) | ||
1392 | snd_pcm_pause(substream, 0); | ||
1393 | |||
1394 | /* pre-start/stop - all running streams are changed to DRAINING state */ | ||
1395 | result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); | ||
1396 | if (result < 0) | ||
1397 | goto _end; | ||
1398 | |||
1399 | /* check streams with PLAYBACK & DRAINING */ | ||
1400 | num_drecs = 0; | 1393 | num_drecs = 0; |
1401 | snd_pcm_group_for_each(pos, substream) { | 1394 | snd_pcm_group_for_each(pos, substream) { |
1402 | snd_pcm_substream_t *s = snd_pcm_group_substream_entry(pos); | 1395 | snd_pcm_substream_t *s = snd_pcm_group_substream_entry(pos); |
1403 | runtime = s->runtime; | 1396 | runtime = s->runtime; |
1404 | if (runtime->status->state != SNDRV_PCM_STATE_DRAINING) { | ||
1405 | runtime->status->state = SNDRV_PCM_STATE_SETUP; | ||
1406 | continue; | ||
1407 | } | ||
1408 | if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 1397 | if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
1409 | d = &drec[num_drecs++]; | 1398 | d = &drec[num_drecs++]; |
1410 | d->substream = s; | 1399 | d->substream = s; |
@@ -1418,9 +1407,21 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream) | |||
1418 | runtime->stop_threshold = runtime->buffer_size; | 1407 | runtime->stop_threshold = runtime->buffer_size; |
1419 | } | 1408 | } |
1420 | } | 1409 | } |
1421 | 1410 | up_read(&snd_pcm_link_rwsem); | |
1422 | if (! num_drecs) | 1411 | if (! num_drecs) |
1423 | goto _end; | 1412 | goto _error; |
1413 | |||
1414 | snd_pcm_stream_lock_irq(substream); | ||
1415 | /* resume pause */ | ||
1416 | if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) | ||
1417 | snd_pcm_pause(substream, 0); | ||
1418 | |||
1419 | /* pre-start/stop - all running streams are changed to DRAINING state */ | ||
1420 | result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); | ||
1421 | if (result < 0) { | ||
1422 | snd_pcm_stream_unlock_irq(substream); | ||
1423 | goto _error; | ||
1424 | } | ||
1424 | 1425 | ||
1425 | for (;;) { | 1426 | for (;;) { |
1426 | long tout; | 1427 | long tout; |
@@ -1428,6 +1429,15 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream) | |||
1428 | result = -ERESTARTSYS; | 1429 | result = -ERESTARTSYS; |
1429 | break; | 1430 | break; |
1430 | } | 1431 | } |
1432 | /* all finished? */ | ||
1433 | for (i = 0; i < num_drecs; i++) { | ||
1434 | runtime = drec[i].substream->runtime; | ||
1435 | if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) | ||
1436 | break; | ||
1437 | } | ||
1438 | if (i == num_drecs) | ||
1439 | break; /* yes, all drained */ | ||
1440 | |||
1431 | set_current_state(TASK_INTERRUPTIBLE); | 1441 | set_current_state(TASK_INTERRUPTIBLE); |
1432 | snd_pcm_stream_unlock_irq(substream); | 1442 | snd_pcm_stream_unlock_irq(substream); |
1433 | snd_power_unlock(card); | 1443 | snd_power_unlock(card); |
@@ -1444,15 +1454,11 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream) | |||
1444 | } | 1454 | } |
1445 | break; | 1455 | break; |
1446 | } | 1456 | } |
1447 | /* all finished? */ | ||
1448 | for (i = 0; i < num_drecs; i++) { | ||
1449 | runtime = drec[i].substream->runtime; | ||
1450 | if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) | ||
1451 | break; | ||
1452 | } | ||
1453 | if (i == num_drecs) | ||
1454 | break; | ||
1455 | } | 1457 | } |
1458 | |||
1459 | snd_pcm_stream_unlock_irq(substream); | ||
1460 | |||
1461 | _error: | ||
1456 | for (i = 0; i < num_drecs; i++) { | 1462 | for (i = 0; i < num_drecs; i++) { |
1457 | d = &drec[i]; | 1463 | d = &drec[i]; |
1458 | runtime = d->substream->runtime; | 1464 | runtime = d->substream->runtime; |
@@ -1460,13 +1466,9 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream) | |||
1460 | runtime->stop_threshold = d->stop_threshold; | 1466 | runtime->stop_threshold = d->stop_threshold; |
1461 | } | 1467 | } |
1462 | 1468 | ||
1463 | _end: | ||
1464 | snd_pcm_stream_unlock_irq(substream); | ||
1465 | if (drec != &drec_tmp) | 1469 | if (drec != &drec_tmp) |
1466 | kfree(drec); | 1470 | kfree(drec); |
1467 | _unlock: | ||
1468 | snd_power_unlock(card); | 1471 | snd_power_unlock(card); |
1469 | up_read(&snd_pcm_link_rwsem); | ||
1470 | 1472 | ||
1471 | return result; | 1473 | return result; |
1472 | } | 1474 | } |
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 638cc148706d..1a7736cbf3a4 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c | |||
@@ -325,14 +325,10 @@ snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp) | |||
325 | } | 325 | } |
326 | snd_use_lock_free(&rec->use_lock); | 326 | snd_use_lock_free(&rec->use_lock); |
327 | } | 327 | } |
328 | if (info->sysex) { | 328 | kfree(info->sysex); |
329 | kfree(info->sysex); | 329 | info->sysex = NULL; |
330 | info->sysex = NULL; | 330 | kfree(info->ch); |
331 | } | 331 | info->ch = NULL; |
332 | if (info->ch) { | ||
333 | kfree(info->ch); | ||
334 | info->ch = NULL; | ||
335 | } | ||
336 | } | 332 | } |
337 | dp->synth_opened = 0; | 333 | dp->synth_opened = 0; |
338 | dp->max_synthdev = 0; | 334 | dp->max_synthdev = 0; |
@@ -418,14 +414,10 @@ snd_seq_oss_synth_reset(seq_oss_devinfo_t *dp, int dev) | |||
418 | dp->file_mode) < 0) { | 414 | dp->file_mode) < 0) { |
419 | midi_synth_dev.opened--; | 415 | midi_synth_dev.opened--; |
420 | info->opened = 0; | 416 | info->opened = 0; |
421 | if (info->sysex) { | 417 | kfree(info->sysex); |
422 | kfree(info->sysex); | 418 | info->sysex = NULL; |
423 | info->sysex = NULL; | 419 | kfree(info->ch); |
424 | } | 420 | info->ch = NULL; |
425 | if (info->ch) { | ||
426 | kfree(info->ch); | ||
427 | info->ch = NULL; | ||
428 | } | ||
429 | } | 421 | } |
430 | return; | 422 | return; |
431 | } | 423 | } |
diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c index e88967c5b93d..ea945a5d2a0b 100644 --- a/sound/core/seq/seq_dummy.c +++ b/sound/core/seq/seq_dummy.c | |||
@@ -140,10 +140,7 @@ dummy_input(snd_seq_event_t *ev, int direct, void *private_data, int atomic, int | |||
140 | static void | 140 | static void |
141 | dummy_free(void *private_data) | 141 | dummy_free(void *private_data) |
142 | { | 142 | { |
143 | snd_seq_dummy_port_t *p; | 143 | kfree(private_data); |
144 | |||
145 | p = private_data; | ||
146 | kfree(p); | ||
147 | } | 144 | } |
148 | 145 | ||
149 | /* | 146 | /* |
diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index 18247db45db6..57be9155eb62 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c | |||
@@ -414,6 +414,8 @@ snd_seq_midisynth_register_port(snd_seq_device_t *dev) | |||
414 | if (newclient) | 414 | if (newclient) |
415 | synths[card->number] = client; | 415 | synths[card->number] = client; |
416 | up(®ister_mutex); | 416 | up(®ister_mutex); |
417 | kfree(info); | ||
418 | kfree(port); | ||
417 | return 0; /* success */ | 419 | return 0; /* success */ |
418 | 420 | ||
419 | __nomem: | 421 | __nomem: |
diff --git a/sound/core/seq/seq_midi_event.c b/sound/core/seq/seq_midi_event.c index 21e569062bc3..df1e2bb39745 100644 --- a/sound/core/seq/seq_midi_event.c +++ b/sound/core/seq/seq_midi_event.c | |||
@@ -171,11 +171,13 @@ void snd_midi_event_reset_decode(snd_midi_event_t *dev) | |||
171 | spin_unlock_irqrestore(&dev->lock, flags); | 171 | spin_unlock_irqrestore(&dev->lock, flags); |
172 | } | 172 | } |
173 | 173 | ||
174 | #if 0 | ||
174 | void snd_midi_event_init(snd_midi_event_t *dev) | 175 | void snd_midi_event_init(snd_midi_event_t *dev) |
175 | { | 176 | { |
176 | snd_midi_event_reset_encode(dev); | 177 | snd_midi_event_reset_encode(dev); |
177 | snd_midi_event_reset_decode(dev); | 178 | snd_midi_event_reset_decode(dev); |
178 | } | 179 | } |
180 | #endif /* 0 */ | ||
179 | 181 | ||
180 | void snd_midi_event_no_status(snd_midi_event_t *dev, int on) | 182 | void snd_midi_event_no_status(snd_midi_event_t *dev, int on) |
181 | { | 183 | { |
@@ -185,6 +187,7 @@ void snd_midi_event_no_status(snd_midi_event_t *dev, int on) | |||
185 | /* | 187 | /* |
186 | * resize buffer | 188 | * resize buffer |
187 | */ | 189 | */ |
190 | #if 0 | ||
188 | int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize) | 191 | int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize) |
189 | { | 192 | { |
190 | unsigned char *new_buf, *old_buf; | 193 | unsigned char *new_buf, *old_buf; |
@@ -204,6 +207,7 @@ int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize) | |||
204 | kfree(old_buf); | 207 | kfree(old_buf); |
205 | return 0; | 208 | return 0; |
206 | } | 209 | } |
210 | #endif /* 0 */ | ||
207 | 211 | ||
208 | /* | 212 | /* |
209 | * read bytes and encode to sequencer event if finished | 213 | * read bytes and encode to sequencer event if finished |
@@ -517,8 +521,6 @@ static int extra_decode_xrpn(snd_midi_event_t *dev, unsigned char *buf, int coun | |||
517 | 521 | ||
518 | EXPORT_SYMBOL(snd_midi_event_new); | 522 | EXPORT_SYMBOL(snd_midi_event_new); |
519 | EXPORT_SYMBOL(snd_midi_event_free); | 523 | EXPORT_SYMBOL(snd_midi_event_free); |
520 | EXPORT_SYMBOL(snd_midi_event_resize_buffer); | ||
521 | EXPORT_SYMBOL(snd_midi_event_init); | ||
522 | EXPORT_SYMBOL(snd_midi_event_reset_encode); | 524 | EXPORT_SYMBOL(snd_midi_event_reset_encode); |
523 | EXPORT_SYMBOL(snd_midi_event_reset_decode); | 525 | EXPORT_SYMBOL(snd_midi_event_reset_decode); |
524 | EXPORT_SYMBOL(snd_midi_event_no_status); | 526 | EXPORT_SYMBOL(snd_midi_event_no_status); |
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index 3afc7cc0c9a7..98de2e711fde 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c | |||
@@ -672,7 +672,8 @@ static void queue_broadcast_event(queue_t *q, snd_seq_event_t *ev, int atomic, i | |||
672 | * process a received queue-control event. | 672 | * process a received queue-control event. |
673 | * this function is exported for seq_sync.c. | 673 | * this function is exported for seq_sync.c. |
674 | */ | 674 | */ |
675 | void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, int atomic, int hop) | 675 | static void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, |
676 | int atomic, int hop) | ||
676 | { | 677 | { |
677 | switch (ev->type) { | 678 | switch (ev->type) { |
678 | case SNDRV_SEQ_EVENT_START: | 679 | case SNDRV_SEQ_EVENT_START: |
diff --git a/sound/core/seq/seq_queue.h b/sound/core/seq/seq_queue.h index b1bf5519fb3b..ea3c54216ea8 100644 --- a/sound/core/seq/seq_queue.h +++ b/sound/core/seq/seq_queue.h | |||
@@ -111,7 +111,6 @@ int snd_seq_queue_use(int queueid, int client, int use); | |||
111 | int snd_seq_queue_is_used(int queueid, int client); | 111 | int snd_seq_queue_is_used(int queueid, int client); |
112 | 112 | ||
113 | int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop); | 113 | int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop); |
114 | void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, int atomic, int hop); | ||
115 | 114 | ||
116 | /* | 115 | /* |
117 | * 64bit division - for sync stuff.. | 116 | * 64bit division - for sync stuff.. |
diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c index 753f1c0863cc..a7f76fc95280 100644 --- a/sound/core/seq/seq_timer.c +++ b/sound/core/seq/seq_timer.c | |||
@@ -36,7 +36,8 @@ extern int seq_default_timer_resolution; | |||
36 | 36 | ||
37 | #define SKEW_BASE 0x10000 /* 16bit shift */ | 37 | #define SKEW_BASE 0x10000 /* 16bit shift */ |
38 | 38 | ||
39 | void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick, int tempo, int ppq, int nticks) | 39 | static void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick, |
40 | int tempo, int ppq, int nticks) | ||
40 | { | 41 | { |
41 | if (tempo < 1000000) | 42 | if (tempo < 1000000) |
42 | tick->resolution = (tempo * 1000) / ppq; | 43 | tick->resolution = (tempo * 1000) / ppq; |
diff --git a/sound/core/seq/seq_timer.h b/sound/core/seq/seq_timer.h index 4c0872df8931..287ed68591de 100644 --- a/sound/core/seq/seq_timer.h +++ b/sound/core/seq/seq_timer.h | |||
@@ -64,8 +64,6 @@ extern seq_timer_t *snd_seq_timer_new(void); | |||
64 | /* delete timer (destructor) */ | 64 | /* delete timer (destructor) */ |
65 | extern void snd_seq_timer_delete(seq_timer_t **tmr); | 65 | extern void snd_seq_timer_delete(seq_timer_t **tmr); |
66 | 66 | ||
67 | void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick, int tempo, int ppq, int nticks); | ||
68 | |||
69 | /* */ | 67 | /* */ |
70 | static inline void snd_seq_timer_update_tick(seq_timer_tick_t *tick, unsigned long resolution) | 68 | static inline void snd_seq_timer_update_tick(seq_timer_tick_t *tick, unsigned long resolution) |
71 | { | 69 | { |
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 6b4e630ace54..a66484b5cf0e 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c | |||
@@ -110,7 +110,7 @@ static int snd_virmidi_dev_receive_event(snd_virmidi_dev_t *rdev, snd_seq_event_ | |||
110 | * handler of a remote port which is attached to the virmidi via | 110 | * handler of a remote port which is attached to the virmidi via |
111 | * SNDRV_VIRMIDI_SEQ_ATTACH. | 111 | * SNDRV_VIRMIDI_SEQ_ATTACH. |
112 | */ | 112 | */ |
113 | /* exported */ | 113 | #if 0 |
114 | int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev) | 114 | int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev) |
115 | { | 115 | { |
116 | snd_virmidi_dev_t *rdev; | 116 | snd_virmidi_dev_t *rdev; |
@@ -118,6 +118,7 @@ int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev) | |||
118 | rdev = rmidi->private_data; | 118 | rdev = rmidi->private_data; |
119 | return snd_virmidi_dev_receive_event(rdev, ev); | 119 | return snd_virmidi_dev_receive_event(rdev, ev); |
120 | } | 120 | } |
121 | #endif /* 0 */ | ||
121 | 122 | ||
122 | /* | 123 | /* |
123 | * event handler of virmidi port | 124 | * event handler of virmidi port |
@@ -384,7 +385,7 @@ static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev) | |||
384 | info->client = client; | 385 | info->client = client; |
385 | info->type = KERNEL_CLIENT; | 386 | info->type = KERNEL_CLIENT; |
386 | sprintf(info->name, "%s %d-%d", rdev->rmidi->name, rdev->card->number, rdev->device); | 387 | sprintf(info->name, "%s %d-%d", rdev->rmidi->name, rdev->card->number, rdev->device); |
387 | snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &info); | 388 | snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, info); |
388 | 389 | ||
389 | /* create a port */ | 390 | /* create a port */ |
390 | memset(pinfo, 0, sizeof(*pinfo)); | 391 | memset(pinfo, 0, sizeof(*pinfo)); |
@@ -405,7 +406,7 @@ static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev) | |||
405 | pcallbacks.unuse = snd_virmidi_unuse; | 406 | pcallbacks.unuse = snd_virmidi_unuse; |
406 | pcallbacks.event_input = snd_virmidi_event_input; | 407 | pcallbacks.event_input = snd_virmidi_event_input; |
407 | pinfo->kernel = &pcallbacks; | 408 | pinfo->kernel = &pcallbacks; |
408 | err = snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_CREATE_PORT, &pinfo); | 409 | err = snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_CREATE_PORT, pinfo); |
409 | if (err < 0) { | 410 | if (err < 0) { |
410 | snd_seq_delete_kernel_client(client); | 411 | snd_seq_delete_kernel_client(client); |
411 | rdev->client = -1; | 412 | rdev->client = -1; |
@@ -548,4 +549,3 @@ module_init(alsa_virmidi_init) | |||
548 | module_exit(alsa_virmidi_exit) | 549 | module_exit(alsa_virmidi_exit) |
549 | 550 | ||
550 | EXPORT_SYMBOL(snd_virmidi_new); | 551 | EXPORT_SYMBOL(snd_virmidi_new); |
551 | EXPORT_SYMBOL(snd_virmidi_receive); | ||
diff --git a/sound/core/sound.c b/sound/core/sound.c index 88e052079f85..7612884f530b 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -64,7 +64,7 @@ static struct list_head snd_minors_hash[SNDRV_CARDS]; | |||
64 | 64 | ||
65 | static DECLARE_MUTEX(sound_mutex); | 65 | static DECLARE_MUTEX(sound_mutex); |
66 | 66 | ||
67 | extern struct class_simple *sound_class; | 67 | extern struct class *sound_class; |
68 | 68 | ||
69 | 69 | ||
70 | #ifdef CONFIG_KMOD | 70 | #ifdef CONFIG_KMOD |
@@ -231,7 +231,7 @@ int snd_register_device(int type, snd_card_t * card, int dev, snd_minor_t * reg, | |||
231 | devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name); | 231 | devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name); |
232 | if (card) | 232 | if (card) |
233 | device = card->dev; | 233 | device = card->dev; |
234 | class_simple_device_add(sound_class, MKDEV(major, minor), device, name); | 234 | class_device_create(sound_class, MKDEV(major, minor), device, "%s", name); |
235 | 235 | ||
236 | up(&sound_mutex); | 236 | up(&sound_mutex); |
237 | return 0; | 237 | return 0; |
@@ -263,7 +263,7 @@ int snd_unregister_device(int type, snd_card_t * card, int dev) | |||
263 | 263 | ||
264 | if (strncmp(mptr->name, "controlC", 8) || card->number >= cards_limit) /* created in sound.c */ | 264 | if (strncmp(mptr->name, "controlC", 8) || card->number >= cards_limit) /* created in sound.c */ |
265 | devfs_remove("snd/%s", mptr->name); | 265 | devfs_remove("snd/%s", mptr->name); |
266 | class_simple_device_remove(MKDEV(major, minor)); | 266 | class_device_destroy(sound_class, MKDEV(major, minor)); |
267 | 267 | ||
268 | list_del(&mptr->list); | 268 | list_del(&mptr->list); |
269 | up(&sound_mutex); | 269 | up(&sound_mutex); |
@@ -399,8 +399,8 @@ EXPORT_SYMBOL(snd_hidden_kcalloc); | |||
399 | EXPORT_SYMBOL(snd_hidden_kfree); | 399 | EXPORT_SYMBOL(snd_hidden_kfree); |
400 | EXPORT_SYMBOL(snd_hidden_vmalloc); | 400 | EXPORT_SYMBOL(snd_hidden_vmalloc); |
401 | EXPORT_SYMBOL(snd_hidden_vfree); | 401 | EXPORT_SYMBOL(snd_hidden_vfree); |
402 | EXPORT_SYMBOL(snd_hidden_kstrdup); | ||
402 | #endif | 403 | #endif |
403 | EXPORT_SYMBOL(snd_kmalloc_strdup); | ||
404 | EXPORT_SYMBOL(copy_to_user_fromio); | 404 | EXPORT_SYMBOL(copy_to_user_fromio); |
405 | EXPORT_SYMBOL(copy_from_user_toio); | 405 | EXPORT_SYMBOL(copy_from_user_toio); |
406 | /* init.c */ | 406 | /* init.c */ |
@@ -431,7 +431,6 @@ EXPORT_SYMBOL(snd_card_pci_resume); | |||
431 | EXPORT_SYMBOL(snd_device_new); | 431 | EXPORT_SYMBOL(snd_device_new); |
432 | EXPORT_SYMBOL(snd_device_register); | 432 | EXPORT_SYMBOL(snd_device_register); |
433 | EXPORT_SYMBOL(snd_device_free); | 433 | EXPORT_SYMBOL(snd_device_free); |
434 | EXPORT_SYMBOL(snd_device_free_all); | ||
435 | /* isadma.c */ | 434 | /* isadma.c */ |
436 | #ifdef CONFIG_ISA | 435 | #ifdef CONFIG_ISA |
437 | EXPORT_SYMBOL(snd_dma_program); | 436 | EXPORT_SYMBOL(snd_dma_program); |
diff --git a/sound/core/timer.c b/sound/core/timer.c index fa762ca439be..cfaccd415b3b 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/time.h> | 27 | #include <linux/time.h> |
28 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
29 | #include <linux/string.h> | ||
29 | #include <sound/core.h> | 30 | #include <sound/core.h> |
30 | #include <sound/timer.h> | 31 | #include <sound/timer.h> |
31 | #include <sound/control.h> | 32 | #include <sound/control.h> |
@@ -69,6 +70,7 @@ typedef struct { | |||
69 | struct timespec tstamp; /* trigger tstamp */ | 70 | struct timespec tstamp; /* trigger tstamp */ |
70 | wait_queue_head_t qchange_sleep; | 71 | wait_queue_head_t qchange_sleep; |
71 | struct fasync_struct *fasync; | 72 | struct fasync_struct *fasync; |
73 | struct semaphore tread_sem; | ||
72 | } snd_timer_user_t; | 74 | } snd_timer_user_t; |
73 | 75 | ||
74 | /* list of timers */ | 76 | /* list of timers */ |
@@ -99,7 +101,7 @@ static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *ti | |||
99 | timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL); | 101 | timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL); |
100 | if (timeri == NULL) | 102 | if (timeri == NULL) |
101 | return NULL; | 103 | return NULL; |
102 | timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL); | 104 | timeri->owner = kstrdup(owner, GFP_KERNEL); |
103 | if (! timeri->owner) { | 105 | if (! timeri->owner) { |
104 | kfree(timeri); | 106 | kfree(timeri); |
105 | return NULL; | 107 | return NULL; |
@@ -844,7 +846,7 @@ int snd_timer_dev_register(snd_device_t *dev) | |||
844 | return 0; | 846 | return 0; |
845 | } | 847 | } |
846 | 848 | ||
847 | int snd_timer_unregister(snd_timer_t *timer) | 849 | static int snd_timer_unregister(snd_timer_t *timer) |
848 | { | 850 | { |
849 | struct list_head *p, *n; | 851 | struct list_head *p, *n; |
850 | snd_timer_instance_t *ti; | 852 | snd_timer_instance_t *ti; |
@@ -945,11 +947,6 @@ struct snd_timer_system_private { | |||
945 | unsigned long correction; | 947 | unsigned long correction; |
946 | }; | 948 | }; |
947 | 949 | ||
948 | unsigned int snd_timer_system_resolution(void) | ||
949 | { | ||
950 | return 1000000000L / HZ; | ||
951 | } | ||
952 | |||
953 | static void snd_timer_s_function(unsigned long data) | 950 | static void snd_timer_s_function(unsigned long data) |
954 | { | 951 | { |
955 | snd_timer_t *timer = (snd_timer_t *)data; | 952 | snd_timer_t *timer = (snd_timer_t *)data; |
@@ -1208,6 +1205,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file) | |||
1208 | return -ENOMEM; | 1205 | return -ENOMEM; |
1209 | spin_lock_init(&tu->qlock); | 1206 | spin_lock_init(&tu->qlock); |
1210 | init_waitqueue_head(&tu->qchange_sleep); | 1207 | init_waitqueue_head(&tu->qchange_sleep); |
1208 | init_MUTEX(&tu->tread_sem); | ||
1211 | tu->ticks = 1; | 1209 | tu->ticks = 1; |
1212 | tu->queue_size = 128; | 1210 | tu->queue_size = 128; |
1213 | tu->queue = (snd_timer_read_t *)kmalloc(tu->queue_size * sizeof(snd_timer_read_t), GFP_KERNEL); | 1211 | tu->queue = (snd_timer_read_t *)kmalloc(tu->queue_size * sizeof(snd_timer_read_t), GFP_KERNEL); |
@@ -1454,46 +1452,51 @@ static int snd_timer_user_tselect(struct file *file, snd_timer_select_t __user * | |||
1454 | snd_timer_user_t *tu; | 1452 | snd_timer_user_t *tu; |
1455 | snd_timer_select_t tselect; | 1453 | snd_timer_select_t tselect; |
1456 | char str[32]; | 1454 | char str[32]; |
1457 | int err; | 1455 | int err = 0; |
1458 | 1456 | ||
1459 | tu = file->private_data; | 1457 | tu = file->private_data; |
1460 | if (tu->timeri) | 1458 | down(&tu->tread_sem); |
1459 | if (tu->timeri) { | ||
1461 | snd_timer_close(tu->timeri); | 1460 | snd_timer_close(tu->timeri); |
1462 | if (copy_from_user(&tselect, _tselect, sizeof(tselect))) | 1461 | tu->timeri = NULL; |
1463 | return -EFAULT; | 1462 | } |
1463 | if (copy_from_user(&tselect, _tselect, sizeof(tselect))) { | ||
1464 | err = -EFAULT; | ||
1465 | goto __err; | ||
1466 | } | ||
1464 | sprintf(str, "application %i", current->pid); | 1467 | sprintf(str, "application %i", current->pid); |
1465 | if (tselect.id.dev_class != SNDRV_TIMER_CLASS_SLAVE) | 1468 | if (tselect.id.dev_class != SNDRV_TIMER_CLASS_SLAVE) |
1466 | tselect.id.dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION; | 1469 | tselect.id.dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION; |
1467 | if ((err = snd_timer_open(&tu->timeri, str, &tselect.id, current->pid)) < 0) | 1470 | if ((err = snd_timer_open(&tu->timeri, str, &tselect.id, current->pid)) < 0) |
1468 | return err; | 1471 | goto __err; |
1469 | 1472 | ||
1470 | if (tu->queue) { | 1473 | kfree(tu->queue); |
1471 | kfree(tu->queue); | 1474 | tu->queue = NULL; |
1472 | tu->queue = NULL; | 1475 | kfree(tu->tqueue); |
1473 | } | 1476 | tu->tqueue = NULL; |
1474 | if (tu->tqueue) { | ||
1475 | kfree(tu->tqueue); | ||
1476 | tu->tqueue = NULL; | ||
1477 | } | ||
1478 | if (tu->tread) { | 1477 | if (tu->tread) { |
1479 | tu->tqueue = (snd_timer_tread_t *)kmalloc(tu->queue_size * sizeof(snd_timer_tread_t), GFP_KERNEL); | 1478 | tu->tqueue = (snd_timer_tread_t *)kmalloc(tu->queue_size * sizeof(snd_timer_tread_t), GFP_KERNEL); |
1480 | if (tu->tqueue == NULL) { | 1479 | if (tu->tqueue == NULL) |
1481 | snd_timer_close(tu->timeri); | 1480 | err = -ENOMEM; |
1482 | return -ENOMEM; | ||
1483 | } | ||
1484 | } else { | 1481 | } else { |
1485 | tu->queue = (snd_timer_read_t *)kmalloc(tu->queue_size * sizeof(snd_timer_read_t), GFP_KERNEL); | 1482 | tu->queue = (snd_timer_read_t *)kmalloc(tu->queue_size * sizeof(snd_timer_read_t), GFP_KERNEL); |
1486 | if (tu->queue == NULL) { | 1483 | if (tu->queue == NULL) |
1487 | snd_timer_close(tu->timeri); | 1484 | err = -ENOMEM; |
1488 | return -ENOMEM; | ||
1489 | } | ||
1490 | } | 1485 | } |
1491 | 1486 | ||
1492 | tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST; | 1487 | if (err < 0) { |
1493 | tu->timeri->callback = tu->tread ? snd_timer_user_tinterrupt : snd_timer_user_interrupt; | 1488 | snd_timer_close(tu->timeri); |
1494 | tu->timeri->ccallback = snd_timer_user_ccallback; | 1489 | tu->timeri = NULL; |
1495 | tu->timeri->callback_data = (void *)tu; | 1490 | } else { |
1496 | return 0; | 1491 | tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST; |
1492 | tu->timeri->callback = tu->tread ? snd_timer_user_tinterrupt : snd_timer_user_interrupt; | ||
1493 | tu->timeri->ccallback = snd_timer_user_ccallback; | ||
1494 | tu->timeri->callback_data = (void *)tu; | ||
1495 | } | ||
1496 | |||
1497 | __err: | ||
1498 | up(&tu->tread_sem); | ||
1499 | return err; | ||
1497 | } | 1500 | } |
1498 | 1501 | ||
1499 | static int snd_timer_user_info(struct file *file, snd_timer_info_t __user *_info) | 1502 | static int snd_timer_user_info(struct file *file, snd_timer_info_t __user *_info) |
@@ -1669,6 +1672,23 @@ static int snd_timer_user_continue(struct file *file) | |||
1669 | return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0; | 1672 | return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0; |
1670 | } | 1673 | } |
1671 | 1674 | ||
1675 | static int snd_timer_user_pause(struct file *file) | ||
1676 | { | ||
1677 | int err; | ||
1678 | snd_timer_user_t *tu; | ||
1679 | |||
1680 | tu = file->private_data; | ||
1681 | snd_assert(tu->timeri != NULL, return -ENXIO); | ||
1682 | return (err = snd_timer_pause(tu->timeri)) < 0 ? err : 0; | ||
1683 | } | ||
1684 | |||
1685 | enum { | ||
1686 | SNDRV_TIMER_IOCTL_START_OLD = _IO('T', 0x20), | ||
1687 | SNDRV_TIMER_IOCTL_STOP_OLD = _IO('T', 0x21), | ||
1688 | SNDRV_TIMER_IOCTL_CONTINUE_OLD = _IO('T', 0x22), | ||
1689 | SNDRV_TIMER_IOCTL_PAUSE_OLD = _IO('T', 0x23), | ||
1690 | }; | ||
1691 | |||
1672 | static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 1692 | static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
1673 | { | 1693 | { |
1674 | snd_timer_user_t *tu; | 1694 | snd_timer_user_t *tu; |
@@ -1685,11 +1705,17 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned l | |||
1685 | { | 1705 | { |
1686 | int xarg; | 1706 | int xarg; |
1687 | 1707 | ||
1688 | if (tu->timeri) /* too late */ | 1708 | down(&tu->tread_sem); |
1709 | if (tu->timeri) { /* too late */ | ||
1710 | up(&tu->tread_sem); | ||
1689 | return -EBUSY; | 1711 | return -EBUSY; |
1690 | if (get_user(xarg, p)) | 1712 | } |
1713 | if (get_user(xarg, p)) { | ||
1714 | up(&tu->tread_sem); | ||
1691 | return -EFAULT; | 1715 | return -EFAULT; |
1716 | } | ||
1692 | tu->tread = xarg ? 1 : 0; | 1717 | tu->tread = xarg ? 1 : 0; |
1718 | up(&tu->tread_sem); | ||
1693 | return 0; | 1719 | return 0; |
1694 | } | 1720 | } |
1695 | case SNDRV_TIMER_IOCTL_GINFO: | 1721 | case SNDRV_TIMER_IOCTL_GINFO: |
@@ -1707,11 +1733,17 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned l | |||
1707 | case SNDRV_TIMER_IOCTL_STATUS: | 1733 | case SNDRV_TIMER_IOCTL_STATUS: |
1708 | return snd_timer_user_status(file, argp); | 1734 | return snd_timer_user_status(file, argp); |
1709 | case SNDRV_TIMER_IOCTL_START: | 1735 | case SNDRV_TIMER_IOCTL_START: |
1736 | case SNDRV_TIMER_IOCTL_START_OLD: | ||
1710 | return snd_timer_user_start(file); | 1737 | return snd_timer_user_start(file); |
1711 | case SNDRV_TIMER_IOCTL_STOP: | 1738 | case SNDRV_TIMER_IOCTL_STOP: |
1739 | case SNDRV_TIMER_IOCTL_STOP_OLD: | ||
1712 | return snd_timer_user_stop(file); | 1740 | return snd_timer_user_stop(file); |
1713 | case SNDRV_TIMER_IOCTL_CONTINUE: | 1741 | case SNDRV_TIMER_IOCTL_CONTINUE: |
1742 | case SNDRV_TIMER_IOCTL_CONTINUE_OLD: | ||
1714 | return snd_timer_user_continue(file); | 1743 | return snd_timer_user_continue(file); |
1744 | case SNDRV_TIMER_IOCTL_PAUSE: | ||
1745 | case SNDRV_TIMER_IOCTL_PAUSE_OLD: | ||
1746 | return snd_timer_user_pause(file); | ||
1715 | } | 1747 | } |
1716 | return -ENOTTY; | 1748 | return -ENOTTY; |
1717 | } | 1749 | } |
@@ -1898,4 +1930,3 @@ EXPORT_SYMBOL(snd_timer_global_free); | |||
1898 | EXPORT_SYMBOL(snd_timer_global_register); | 1930 | EXPORT_SYMBOL(snd_timer_global_register); |
1899 | EXPORT_SYMBOL(snd_timer_global_unregister); | 1931 | EXPORT_SYMBOL(snd_timer_global_unregister); |
1900 | EXPORT_SYMBOL(snd_timer_interrupt); | 1932 | EXPORT_SYMBOL(snd_timer_interrupt); |
1901 | EXPORT_SYMBOL(snd_timer_system_resolution); | ||
diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c index 9fbc3957a22d..3de552dfe80f 100644 --- a/sound/core/timer_compat.c +++ b/sound/core/timer_compat.c | |||
@@ -106,8 +106,13 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns | |||
106 | case SNDRV_TIMER_IOCTL_SELECT: | 106 | case SNDRV_TIMER_IOCTL_SELECT: |
107 | case SNDRV_TIMER_IOCTL_PARAMS: | 107 | case SNDRV_TIMER_IOCTL_PARAMS: |
108 | case SNDRV_TIMER_IOCTL_START: | 108 | case SNDRV_TIMER_IOCTL_START: |
109 | case SNDRV_TIMER_IOCTL_START_OLD: | ||
109 | case SNDRV_TIMER_IOCTL_STOP: | 110 | case SNDRV_TIMER_IOCTL_STOP: |
111 | case SNDRV_TIMER_IOCTL_STOP_OLD: | ||
110 | case SNDRV_TIMER_IOCTL_CONTINUE: | 112 | case SNDRV_TIMER_IOCTL_CONTINUE: |
113 | case SNDRV_TIMER_IOCTL_CONTINUE_OLD: | ||
114 | case SNDRV_TIMER_IOCTL_PAUSE: | ||
115 | case SNDRV_TIMER_IOCTL_PAUSE_OLD: | ||
111 | case SNDRV_TIMER_IOCTL_NEXT_DEVICE: | 116 | case SNDRV_TIMER_IOCTL_NEXT_DEVICE: |
112 | return snd_timer_user_ioctl(file, cmd, (unsigned long)argp); | 117 | return snd_timer_user_ioctl(file, cmd, (unsigned long)argp); |
113 | case SNDRV_TIMER_IOCTL_INFO32: | 118 | case SNDRV_TIMER_IOCTL_INFO32: |
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index 98587176b327..af381b15fe5c 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c | |||
@@ -1264,14 +1264,10 @@ static void snd_vx_pcm_free(snd_pcm_t *pcm) | |||
1264 | { | 1264 | { |
1265 | vx_core_t *chip = pcm->private_data; | 1265 | vx_core_t *chip = pcm->private_data; |
1266 | chip->pcm[pcm->device] = NULL; | 1266 | chip->pcm[pcm->device] = NULL; |
1267 | if (chip->playback_pipes) { | 1267 | kfree(chip->playback_pipes); |
1268 | kfree(chip->playback_pipes); | 1268 | chip->playback_pipes = NULL; |
1269 | chip->playback_pipes = NULL; | 1269 | kfree(chip->capture_pipes); |
1270 | } | 1270 | chip->capture_pipes = NULL; |
1271 | if (chip->capture_pipes) { | ||
1272 | kfree(chip->capture_pipes); | ||
1273 | chip->capture_pipes = NULL; | ||
1274 | } | ||
1275 | } | 1271 | } |
1276 | 1272 | ||
1277 | /* | 1273 | /* |
diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index bb503e70b664..2da8d7f157f4 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c | |||
@@ -266,8 +266,7 @@ TEA6330T_TREBLE("Tone Control - Treble", 0) | |||
266 | 266 | ||
267 | static void snd_tea6330_free(snd_i2c_device_t *device) | 267 | static void snd_tea6330_free(snd_i2c_device_t *device) |
268 | { | 268 | { |
269 | tea6330t_t *tea = device->private_data; | 269 | kfree(device->private_data); |
270 | kfree(tea); | ||
271 | } | 270 | } |
272 | 271 | ||
273 | int snd_tea6330t_update_mixer(snd_card_t * card, | 272 | int snd_tea6330t_update_mixer(snd_card_t * card, |
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 3a3228b18726..148a856a43ad 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig | |||
@@ -179,6 +179,7 @@ config SND_INTERWAVE_STB | |||
179 | select SND_RAWMIDI | 179 | select SND_RAWMIDI |
180 | select SND_CS4231_LIB | 180 | select SND_CS4231_LIB |
181 | select SND_GUS_SYNTH | 181 | select SND_GUS_SYNTH |
182 | select ISAPNP | ||
182 | help | 183 | help |
183 | Say Y here to include support for AMD InterWave based | 184 | Say Y here to include support for AMD InterWave based |
184 | soundcards with a TEA6330T bass and treble regulator | 185 | soundcards with a TEA6330T bass and treble regulator |
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index 9fa7a78da6c3..563296d02894 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c | |||
@@ -83,6 +83,8 @@ struct snd_card_ad1816a { | |||
83 | static struct pnp_card_device_id snd_ad1816a_pnpids[] = { | 83 | static struct pnp_card_device_id snd_ad1816a_pnpids[] = { |
84 | /* Analog Devices AD1815 */ | 84 | /* Analog Devices AD1815 */ |
85 | { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } }, | 85 | { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } }, |
86 | /* Analog Device AD1816? */ | ||
87 | { .id = "ADS7180", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, | ||
86 | /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */ | 88 | /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */ |
87 | { .id = "ADS7181", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, | 89 | { .id = "ADS7181", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, |
88 | /* Analog Devices AD1816A - Aztech/Newcom SC-16 3D */ | 90 | /* Analog Devices AD1816A - Aztech/Newcom SC-16 3D */ |
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index e745a54e00a1..39f4eff44f5c 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c | |||
@@ -349,8 +349,7 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, | |||
349 | pnp_init_resource_table(cfg); | 349 | pnp_init_resource_table(cfg); |
350 | if (mpu_port[dev] != SNDRV_AUTO_PORT) | 350 | if (mpu_port[dev] != SNDRV_AUTO_PORT) |
351 | pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); | 351 | pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); |
352 | if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0 && | 352 | if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0) |
353 | pnp_irq_valid(pdev, 0)) | ||
354 | pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); | 353 | pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); |
355 | err = pnp_manual_config_dev(pdev, cfg, 0); | 354 | err = pnp_manual_config_dev(pdev, cfg, 0); |
356 | if (err < 0) | 355 | if (err < 0) |
diff --git a/sound/isa/gus/gus_io.c b/sound/isa/gus/gus_io.c index f0570f2bf75f..337b0e2a8a36 100644 --- a/sound/isa/gus/gus_io.c +++ b/sound/isa/gus/gus_io.c | |||
@@ -244,6 +244,8 @@ unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg) | |||
244 | return res; | 244 | return res; |
245 | } | 245 | } |
246 | 246 | ||
247 | #if 0 | ||
248 | |||
247 | void snd_gf1_i_adlib_write(snd_gus_card_t * gus, | 249 | void snd_gf1_i_adlib_write(snd_gus_card_t * gus, |
248 | unsigned char reg, | 250 | unsigned char reg, |
249 | unsigned char data) | 251 | unsigned char data) |
@@ -265,6 +267,8 @@ void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg, | |||
265 | spin_unlock_irqrestore(&gus->reg_lock, flags); | 267 | spin_unlock_irqrestore(&gus->reg_lock, flags); |
266 | } | 268 | } |
267 | 269 | ||
270 | #endif /* 0 */ | ||
271 | |||
268 | unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, | 272 | unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, |
269 | unsigned char reg, short w_16bit) | 273 | unsigned char reg, short w_16bit) |
270 | { | 274 | { |
@@ -329,6 +333,8 @@ unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr) | |||
329 | return res; | 333 | return res; |
330 | } | 334 | } |
331 | 335 | ||
336 | #if 0 | ||
337 | |||
332 | void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data) | 338 | void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data) |
333 | { | 339 | { |
334 | unsigned long flags; | 340 | unsigned long flags; |
@@ -405,9 +411,7 @@ void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr, | |||
405 | spin_unlock_irqrestore(&gus->reg_lock, flags); | 411 | spin_unlock_irqrestore(&gus->reg_lock, flags); |
406 | } | 412 | } |
407 | 413 | ||
408 | /* | 414 | #endif /* 0 */ |
409 | |||
410 | */ | ||
411 | 415 | ||
412 | void snd_gf1_select_active_voices(snd_gus_card_t * gus) | 416 | void snd_gf1_select_active_voices(snd_gus_card_t * gus) |
413 | { | 417 | { |
@@ -469,6 +473,8 @@ void snd_gf1_print_voice_registers(snd_gus_card_t * gus) | |||
469 | printk(" -%i- GF1 pan = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x0c)); | 473 | printk(" -%i- GF1 pan = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x0c)); |
470 | } | 474 | } |
471 | 475 | ||
476 | #if 0 | ||
477 | |||
472 | void snd_gf1_print_global_registers(snd_gus_card_t * gus) | 478 | void snd_gf1_print_global_registers(snd_gus_card_t * gus) |
473 | { | 479 | { |
474 | unsigned char global_mode = 0x00; | 480 | unsigned char global_mode = 0x00; |
@@ -528,4 +534,6 @@ void snd_gf1_peek_print_block(snd_gus_card_t * gus, unsigned int addr, int count | |||
528 | } | 534 | } |
529 | } | 535 | } |
530 | 536 | ||
537 | #endif /* 0 */ | ||
538 | |||
531 | #endif | 539 | #endif |
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 73f81c14f768..94bbd344be5e 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c | |||
@@ -459,7 +459,6 @@ EXPORT_SYMBOL(snd_gf1_write16); | |||
459 | EXPORT_SYMBOL(snd_gf1_look16); | 459 | EXPORT_SYMBOL(snd_gf1_look16); |
460 | EXPORT_SYMBOL(snd_gf1_i_write8); | 460 | EXPORT_SYMBOL(snd_gf1_i_write8); |
461 | EXPORT_SYMBOL(snd_gf1_i_look8); | 461 | EXPORT_SYMBOL(snd_gf1_i_look8); |
462 | EXPORT_SYMBOL(snd_gf1_i_write16); | ||
463 | EXPORT_SYMBOL(snd_gf1_i_look16); | 462 | EXPORT_SYMBOL(snd_gf1_i_look16); |
464 | EXPORT_SYMBOL(snd_gf1_dram_addr); | 463 | EXPORT_SYMBOL(snd_gf1_dram_addr); |
465 | EXPORT_SYMBOL(snd_gf1_write_addr); | 464 | EXPORT_SYMBOL(snd_gf1_write_addr); |
@@ -470,8 +469,6 @@ EXPORT_SYMBOL(snd_gf1_alloc_voice); | |||
470 | EXPORT_SYMBOL(snd_gf1_free_voice); | 469 | EXPORT_SYMBOL(snd_gf1_free_voice); |
471 | EXPORT_SYMBOL(snd_gf1_ctrl_stop); | 470 | EXPORT_SYMBOL(snd_gf1_ctrl_stop); |
472 | EXPORT_SYMBOL(snd_gf1_stop_voice); | 471 | EXPORT_SYMBOL(snd_gf1_stop_voice); |
473 | EXPORT_SYMBOL(snd_gf1_start); | ||
474 | EXPORT_SYMBOL(snd_gf1_stop); | ||
475 | /* gus_mixer.c */ | 472 | /* gus_mixer.c */ |
476 | EXPORT_SYMBOL(snd_gf1_new_mixer); | 473 | EXPORT_SYMBOL(snd_gf1_new_mixer); |
477 | /* gus_pcm.c */ | 474 | /* gus_pcm.c */ |
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c index bfc2b91001d5..5eb766dd564b 100644 --- a/sound/isa/gus/gus_mem.c +++ b/sound/isa/gus/gus_mem.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <sound/driver.h> | 22 | #include <sound/driver.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/string.h> | ||
24 | #include <sound/core.h> | 25 | #include <sound/core.h> |
25 | #include <sound/gus.h> | 26 | #include <sound/gus.h> |
26 | #include <sound/info.h> | 27 | #include <sound/info.h> |
@@ -39,8 +40,8 @@ void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup) | |||
39 | } | 40 | } |
40 | } | 41 | } |
41 | 42 | ||
42 | snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc, | 43 | static snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc, |
43 | snd_gf1_mem_block_t * block) | 44 | snd_gf1_mem_block_t * block) |
44 | { | 45 | { |
45 | snd_gf1_mem_block_t *pblock, *nblock; | 46 | snd_gf1_mem_block_t *pblock, *nblock; |
46 | 47 | ||
@@ -105,8 +106,8 @@ int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block) | |||
105 | return 0; | 106 | return 0; |
106 | } | 107 | } |
107 | 108 | ||
108 | snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, | 109 | static snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, |
109 | unsigned int address) | 110 | unsigned int address) |
110 | { | 111 | { |
111 | snd_gf1_mem_block_t *block; | 112 | snd_gf1_mem_block_t *block; |
112 | 113 | ||
@@ -118,8 +119,8 @@ snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, | |||
118 | return NULL; | 119 | return NULL; |
119 | } | 120 | } |
120 | 121 | ||
121 | snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc, | 122 | static snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc, |
122 | unsigned int *share_id) | 123 | unsigned int *share_id) |
123 | { | 124 | { |
124 | snd_gf1_mem_block_t *block; | 125 | snd_gf1_mem_block_t *block; |
125 | 126 | ||
@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, | |||
213 | if (share_id != NULL) | 214 | if (share_id != NULL) |
214 | memcpy(&block.share_id, share_id, sizeof(block.share_id)); | 215 | memcpy(&block.share_id, share_id, sizeof(block.share_id)); |
215 | block.owner = owner; | 216 | block.owner = owner; |
216 | block.name = snd_kmalloc_strdup(name, GFP_KERNEL); | 217 | block.name = kstrdup(name, GFP_KERNEL); |
217 | nblock = snd_gf1_mem_xalloc(alloc, &block); | 218 | nblock = snd_gf1_mem_xalloc(alloc, &block); |
218 | snd_gf1_mem_lock(alloc, 1); | 219 | snd_gf1_mem_lock(alloc, 1); |
219 | return nblock; | 220 | return nblock; |
@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gus) | |||
253 | if (gus->gf1.enh_mode) { | 254 | if (gus->gf1.enh_mode) { |
254 | block.ptr = 0; | 255 | block.ptr = 0; |
255 | block.size = 1024; | 256 | block.size = 1024; |
256 | block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL); | 257 | block.name = kstrdup("InterWave LFOs", GFP_KERNEL); |
257 | if (snd_gf1_mem_xalloc(alloc, &block) == NULL) | 258 | if (snd_gf1_mem_xalloc(alloc, &block) == NULL) |
258 | return -ENOMEM; | 259 | return -ENOMEM; |
259 | } | 260 | } |
260 | block.ptr = gus->gf1.default_voice_address; | 261 | block.ptr = gus->gf1.default_voice_address; |
261 | block.size = 4; | 262 | block.size = 4; |
262 | block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL); | 263 | block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL); |
263 | if (snd_gf1_mem_xalloc(alloc, &block) == NULL) | 264 | if (snd_gf1_mem_xalloc(alloc, &block) == NULL) |
264 | return -ENOMEM; | 265 | return -ENOMEM; |
265 | #ifdef CONFIG_SND_DEBUG | 266 | #ifdef CONFIG_SND_DEBUG |
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 8995ad9c516d..b75066ab46fc 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c | |||
@@ -656,8 +656,7 @@ static snd_pcm_hardware_t snd_gf1_pcm_capture = | |||
656 | 656 | ||
657 | static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime) | 657 | static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime) |
658 | { | 658 | { |
659 | gus_pcm_private_t * pcmp = runtime->private_data; | 659 | kfree(runtime->private_data); |
660 | kfree(pcmp); | ||
661 | } | 660 | } |
662 | 661 | ||
663 | static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) | 662 | static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) |
diff --git a/sound/isa/gus/gus_reset.c b/sound/isa/gus/gus_reset.c index b4e66f6a10ae..ef687abc7070 100644 --- a/sound/isa/gus/gus_reset.c +++ b/sound/isa/gus/gus_reset.c | |||
@@ -161,7 +161,8 @@ void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice) | |||
161 | #endif | 161 | #endif |
162 | } | 162 | } |
163 | 163 | ||
164 | void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max) | 164 | static void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, |
165 | unsigned short v_max) | ||
165 | { | 166 | { |
166 | unsigned long flags; | 167 | unsigned long flags; |
167 | unsigned int daddr; | 168 | unsigned int daddr; |
diff --git a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c index 66552e6013a4..f51c386ee192 100644 --- a/sound/isa/gus/gus_synth.c +++ b/sound/isa/gus/gus_synth.c | |||
@@ -99,7 +99,8 @@ static void snd_gus_synth_free_private_instruments(snd_gus_port_t *p, int client | |||
99 | snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0); | 99 | snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0); |
100 | } | 100 | } |
101 | 101 | ||
102 | int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct, void *private_data, int atomic, int hop) | 102 | static int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct, |
103 | void *private_data, int atomic, int hop) | ||
103 | { | 104 | { |
104 | snd_gus_port_t * p = (snd_gus_port_t *) private_data; | 105 | snd_gus_port_t * p = (snd_gus_port_t *) private_data; |
105 | 106 | ||
diff --git a/sound/isa/gus/gus_tables.h b/sound/isa/gus/gus_tables.h index ed8e9d85ad31..4adf098d3269 100644 --- a/sound/isa/gus/gus_tables.h +++ b/sound/isa/gus/gus_tables.h | |||
@@ -23,6 +23,8 @@ | |||
23 | 23 | ||
24 | #ifdef __GUS_TABLES_ALLOC__ | 24 | #ifdef __GUS_TABLES_ALLOC__ |
25 | 25 | ||
26 | #if 0 | ||
27 | |||
26 | unsigned int snd_gf1_scale_table[SNDRV_GF1_SCALE_TABLE_SIZE] = | 28 | unsigned int snd_gf1_scale_table[SNDRV_GF1_SCALE_TABLE_SIZE] = |
27 | { | 29 | { |
28 | 8372, 8870, 9397, 9956, 10548, 11175, | 30 | 8372, 8870, 9397, 9956, 10548, 11175, |
@@ -49,6 +51,8 @@ unsigned int snd_gf1_scale_table[SNDRV_GF1_SCALE_TABLE_SIZE] = | |||
49 | 12123977, 12844906 | 51 | 12123977, 12844906 |
50 | }; | 52 | }; |
51 | 53 | ||
54 | #endif /* 0 */ | ||
55 | |||
52 | unsigned short snd_gf1_atten_table[SNDRV_GF1_ATTEN_TABLE_SIZE] = { | 56 | unsigned short snd_gf1_atten_table[SNDRV_GF1_ATTEN_TABLE_SIZE] = { |
53 | 4095 /* 0 */,1789 /* 1 */,1533 /* 2 */,1383 /* 3 */,1277 /* 4 */, | 57 | 4095 /* 0 */,1789 /* 1 */,1533 /* 2 */,1383 /* 3 */,1277 /* 4 */, |
54 | 1195 /* 5 */,1127 /* 6 */,1070 /* 7 */,1021 /* 8 */,978 /* 9 */, | 58 | 1195 /* 5 */,1127 /* 6 */,1070 /* 7 */,1021 /* 8 */,978 /* 9 */, |
diff --git a/sound/isa/gus/gus_volume.c b/sound/isa/gus/gus_volume.c index b72bcfb28617..3d36f6c8ee6a 100644 --- a/sound/isa/gus/gus_volume.c +++ b/sound/isa/gus/gus_volume.c | |||
@@ -55,6 +55,8 @@ unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol) | |||
55 | return (e << 8) | m; | 55 | return (e << 8) | m; |
56 | } | 56 | } |
57 | 57 | ||
58 | #if 0 | ||
59 | |||
58 | unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol) | 60 | unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol) |
59 | { | 61 | { |
60 | unsigned int rvol; | 62 | unsigned int rvol; |
@@ -108,6 +110,8 @@ unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus, | |||
108 | return (range << 6) | (increment & 0x3f); | 110 | return (range << 6) | (increment & 0x3f); |
109 | } | 111 | } |
110 | 112 | ||
113 | #endif /* 0 */ | ||
114 | |||
111 | unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16) | 115 | unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16) |
112 | { | 116 | { |
113 | freq16 >>= 3; | 117 | freq16 >>= 3; |
@@ -120,6 +124,8 @@ unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16) | |||
120 | return ((freq16 << 9) + (gus->gf1.playback_freq >> 1)) / gus->gf1.playback_freq; | 124 | return ((freq16 << 9) + (gus->gf1.playback_freq >> 1)) / gus->gf1.playback_freq; |
121 | } | 125 | } |
122 | 126 | ||
127 | #if 0 | ||
128 | |||
123 | short snd_gf1_compute_vibrato(short cents, unsigned short fc_register) | 129 | short snd_gf1_compute_vibrato(short cents, unsigned short fc_register) |
124 | { | 130 | { |
125 | static short vibrato_table[] = | 131 | static short vibrato_table[] = |
@@ -208,3 +214,5 @@ unsigned short snd_gf1_compute_freq(unsigned int freq, | |||
208 | } | 214 | } |
209 | return (unsigned short) fc; | 215 | return (unsigned short) fc; |
210 | } | 216 | } |
217 | |||
218 | #endif /* 0 */ | ||
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig index 33e28089f8d7..7bd95ceab7cc 100644 --- a/sound/oss/Kconfig +++ b/sound/oss/Kconfig | |||
@@ -6,7 +6,7 @@ | |||
6 | # Prompt user for primary drivers. | 6 | # Prompt user for primary drivers. |
7 | config SOUND_BT878 | 7 | config SOUND_BT878 |
8 | tristate "BT878 audio dma" | 8 | tristate "BT878 audio dma" |
9 | depends on SOUND_PRIME!=n && SOUND | 9 | depends on SOUND_PRIME |
10 | ---help--- | 10 | ---help--- |
11 | Audio DMA support for bt878 based grabber boards. As you might have | 11 | Audio DMA support for bt878 based grabber boards. As you might have |
12 | already noticed, bt878 is listed with two functions in /proc/pci. | 12 | already noticed, bt878 is listed with two functions in /proc/pci. |
@@ -22,7 +22,7 @@ config SOUND_BT878 | |||
22 | 22 | ||
23 | config SOUND_CMPCI | 23 | config SOUND_CMPCI |
24 | tristate "C-Media PCI (CMI8338/8738)" | 24 | tristate "C-Media PCI (CMI8338/8738)" |
25 | depends on SOUND_PRIME!=n && SOUND && PCI | 25 | depends on SOUND_PRIME && PCI |
26 | help | 26 | help |
27 | Say Y or M if you have a PCI sound card using the CMI8338 | 27 | Say Y or M if you have a PCI sound card using the CMI8338 |
28 | or the CMI8738 chipset. Data on these chips are available at | 28 | or the CMI8738 chipset. Data on these chips are available at |
@@ -61,7 +61,7 @@ config SOUND_CMPCI_JOYSTICK | |||
61 | 61 | ||
62 | config SOUND_EMU10K1 | 62 | config SOUND_EMU10K1 |
63 | tristate "Creative SBLive! (EMU10K1)" | 63 | tristate "Creative SBLive! (EMU10K1)" |
64 | depends on SOUND_PRIME!=n && SOUND && PCI | 64 | depends on SOUND_PRIME && PCI |
65 | ---help--- | 65 | ---help--- |
66 | Say Y or M if you have a PCI sound card using the EMU10K1 chipset, | 66 | Say Y or M if you have a PCI sound card using the EMU10K1 chipset, |
67 | such as the Creative SBLive!, SB PCI512 or Emu-APS. | 67 | such as the Creative SBLive!, SB PCI512 or Emu-APS. |
@@ -87,7 +87,7 @@ config MIDI_EMU10K1 | |||
87 | 87 | ||
88 | config SOUND_FUSION | 88 | config SOUND_FUSION |
89 | tristate "Crystal SoundFusion (CS4280/461x)" | 89 | tristate "Crystal SoundFusion (CS4280/461x)" |
90 | depends on SOUND_PRIME!=n && SOUND | 90 | depends on SOUND_PRIME |
91 | help | 91 | help |
92 | This module drives the Crystal SoundFusion devices (CS4280/46xx | 92 | This module drives the Crystal SoundFusion devices (CS4280/46xx |
93 | series) when wired as native sound drivers with AC97 codecs. If | 93 | series) when wired as native sound drivers with AC97 codecs. If |
@@ -95,14 +95,14 @@ config SOUND_FUSION | |||
95 | 95 | ||
96 | config SOUND_CS4281 | 96 | config SOUND_CS4281 |
97 | tristate "Crystal Sound CS4281" | 97 | tristate "Crystal Sound CS4281" |
98 | depends on SOUND_PRIME!=n && SOUND | 98 | depends on SOUND_PRIME |
99 | help | 99 | help |
100 | Picture and feature list at | 100 | Picture and feature list at |
101 | <http://www.pcbroker.com/crystal4281.html>. | 101 | <http://www.pcbroker.com/crystal4281.html>. |
102 | 102 | ||
103 | config SOUND_BCM_CS4297A | 103 | config SOUND_BCM_CS4297A |
104 | tristate "Crystal Sound CS4297a (for Swarm)" | 104 | tristate "Crystal Sound CS4297a (for Swarm)" |
105 | depends on SOUND_PRIME!=n && SIBYTE_SWARM && SOUND | 105 | depends on SOUND_PRIME && SIBYTE_SWARM |
106 | help | 106 | help |
107 | The BCM91250A has a Crystal CS4297a on synchronous serial | 107 | The BCM91250A has a Crystal CS4297a on synchronous serial |
108 | port B (in addition to the DB-9 serial port). Say Y or M | 108 | port B (in addition to the DB-9 serial port). Say Y or M |
@@ -112,7 +112,7 @@ config SOUND_BCM_CS4297A | |||
112 | 112 | ||
113 | config SOUND_ES1370 | 113 | config SOUND_ES1370 |
114 | tristate "Ensoniq AudioPCI (ES1370)" | 114 | tristate "Ensoniq AudioPCI (ES1370)" |
115 | depends on SOUND_PRIME!=n && SOUND && PCI | 115 | depends on SOUND_PRIME && PCI |
116 | help | 116 | help |
117 | Say Y or M if you have a PCI sound card utilizing the Ensoniq | 117 | Say Y or M if you have a PCI sound card utilizing the Ensoniq |
118 | ES1370 chipset, such as Ensoniq's AudioPCI (non-97). To find | 118 | ES1370 chipset, such as Ensoniq's AudioPCI (non-97). To find |
@@ -125,7 +125,7 @@ config SOUND_ES1370 | |||
125 | 125 | ||
126 | config SOUND_ES1371 | 126 | config SOUND_ES1371 |
127 | tristate "Creative Ensoniq AudioPCI 97 (ES1371)" | 127 | tristate "Creative Ensoniq AudioPCI 97 (ES1371)" |
128 | depends on SOUND_PRIME!=n && SOUND && PCI | 128 | depends on SOUND_PRIME && PCI |
129 | help | 129 | help |
130 | Say Y or M if you have a PCI sound card utilizing the Ensoniq | 130 | Say Y or M if you have a PCI sound card utilizing the Ensoniq |
131 | ES1371 chipset, such as Ensoniq's AudioPCI97. To find out if | 131 | ES1371 chipset, such as Ensoniq's AudioPCI97. To find out if |
@@ -138,7 +138,7 @@ config SOUND_ES1371 | |||
138 | 138 | ||
139 | config SOUND_ESSSOLO1 | 139 | config SOUND_ESSSOLO1 |
140 | tristate "ESS Technology Solo1" | 140 | tristate "ESS Technology Solo1" |
141 | depends on SOUND_PRIME!=n && SOUND && PCI | 141 | depends on SOUND_PRIME && PCI |
142 | help | 142 | help |
143 | Say Y or M if you have a PCI sound card utilizing the ESS Technology | 143 | Say Y or M if you have a PCI sound card utilizing the ESS Technology |
144 | Solo1 chip. To find out if your sound card uses a | 144 | Solo1 chip. To find out if your sound card uses a |
@@ -149,7 +149,7 @@ config SOUND_ESSSOLO1 | |||
149 | 149 | ||
150 | config SOUND_MAESTRO | 150 | config SOUND_MAESTRO |
151 | tristate "ESS Maestro, Maestro2, Maestro2E driver" | 151 | tristate "ESS Maestro, Maestro2, Maestro2E driver" |
152 | depends on SOUND_PRIME!=n && SOUND && PCI | 152 | depends on SOUND_PRIME && PCI |
153 | help | 153 | help |
154 | Say Y or M if you have a sound system driven by ESS's Maestro line | 154 | Say Y or M if you have a sound system driven by ESS's Maestro line |
155 | of PCI sound chips. These include the Maestro 1, Maestro 2, and | 155 | of PCI sound chips. These include the Maestro 1, Maestro 2, and |
@@ -158,28 +158,28 @@ config SOUND_MAESTRO | |||
158 | 158 | ||
159 | config SOUND_MAESTRO3 | 159 | config SOUND_MAESTRO3 |
160 | tristate "ESS Maestro3/Allegro driver (EXPERIMENTAL)" | 160 | tristate "ESS Maestro3/Allegro driver (EXPERIMENTAL)" |
161 | depends on SOUND_PRIME!=n && SOUND && PCI && EXPERIMENTAL | 161 | depends on SOUND_PRIME && PCI && EXPERIMENTAL |
162 | help | 162 | help |
163 | Say Y or M if you have a sound system driven by ESS's Maestro 3 | 163 | Say Y or M if you have a sound system driven by ESS's Maestro 3 |
164 | PCI sound chip. | 164 | PCI sound chip. |
165 | 165 | ||
166 | config SOUND_ICH | 166 | config SOUND_ICH |
167 | tristate "Intel ICH (i8xx) audio support" | 167 | tristate "Intel ICH (i8xx) audio support" |
168 | depends on SOUND_PRIME!=n && PCI | 168 | depends on SOUND_PRIME && PCI |
169 | help | 169 | help |
170 | Support for integral audio in Intel's I/O Controller Hub (ICH) | 170 | Support for integral audio in Intel's I/O Controller Hub (ICH) |
171 | chipset, as used on the 810/820/840 motherboards. | 171 | chipset, as used on the 810/820/840 motherboards. |
172 | 172 | ||
173 | config SOUND_HARMONY | 173 | config SOUND_HARMONY |
174 | tristate "PA Harmony audio driver" | 174 | tristate "PA Harmony audio driver" |
175 | depends on GSC_LASI && SOUND_PRIME!=n | 175 | depends on GSC_LASI && SOUND_PRIME |
176 | help | 176 | help |
177 | Say 'Y' or 'M' to include support for Harmony soundchip | 177 | Say 'Y' or 'M' to include support for Harmony soundchip |
178 | on HP 712, 715/new and many other GSC based machines. | 178 | on HP 712, 715/new and many other GSC based machines. |
179 | 179 | ||
180 | config SOUND_SONICVIBES | 180 | config SOUND_SONICVIBES |
181 | tristate "S3 SonicVibes" | 181 | tristate "S3 SonicVibes" |
182 | depends on SOUND_PRIME!=n && SOUND | 182 | depends on SOUND_PRIME |
183 | help | 183 | help |
184 | Say Y or M if you have a PCI sound card utilizing the S3 | 184 | Say Y or M if you have a PCI sound card utilizing the S3 |
185 | SonicVibes chipset. To find out if your sound card uses a | 185 | SonicVibes chipset. To find out if your sound card uses a |
@@ -190,7 +190,7 @@ config SOUND_SONICVIBES | |||
190 | 190 | ||
191 | config SOUND_VWSND | 191 | config SOUND_VWSND |
192 | tristate "SGI Visual Workstation Sound" | 192 | tristate "SGI Visual Workstation Sound" |
193 | depends on SOUND_PRIME!=n && X86_VISWS && SOUND | 193 | depends on SOUND_PRIME && X86_VISWS |
194 | help | 194 | help |
195 | Say Y or M if you have an SGI Visual Workstation and you want to be | 195 | Say Y or M if you have an SGI Visual Workstation and you want to be |
196 | able to use its on-board audio. Read | 196 | able to use its on-board audio. Read |
@@ -199,18 +199,18 @@ config SOUND_VWSND | |||
199 | 199 | ||
200 | config SOUND_HAL2 | 200 | config SOUND_HAL2 |
201 | tristate "SGI HAL2 sound (EXPERIMENTAL)" | 201 | tristate "SGI HAL2 sound (EXPERIMENTAL)" |
202 | depends on SOUND_PRIME!=n && SOUND && SGI_IP22 && EXPERIMENTAL | 202 | depends on SOUND_PRIME && SGI_IP22 && EXPERIMENTAL |
203 | help | 203 | help |
204 | Say Y or M if you have an SGI Indy system and want to be able to | 204 | Say Y or M if you have an SGI Indy system and want to be able to |
205 | use it's on-board A2 audio system. | 205 | use it's on-board A2 audio system. |
206 | 206 | ||
207 | config SOUND_IT8172 | 207 | config SOUND_IT8172 |
208 | tristate "IT8172G Sound" | 208 | tristate "IT8172G Sound" |
209 | depends on SOUND_PRIME!=n && (MIPS_ITE8172 || MIPS_IVR) && SOUND | 209 | depends on SOUND_PRIME && (MIPS_ITE8172 || MIPS_IVR) |
210 | 210 | ||
211 | config SOUND_VRC5477 | 211 | config SOUND_VRC5477 |
212 | tristate "NEC Vrc5477 AC97 sound" | 212 | tristate "NEC Vrc5477 AC97 sound" |
213 | depends on SOUND_PRIME!=n && DDB5477 && SOUND | 213 | depends on SOUND_PRIME && DDB5477 |
214 | help | 214 | help |
215 | Say Y here to enable sound support for the NEC Vrc5477 chip, an | 215 | Say Y here to enable sound support for the NEC Vrc5477 chip, an |
216 | integrated, multi-function controller chip for MIPS CPUs. Works | 216 | integrated, multi-function controller chip for MIPS CPUs. Works |
@@ -218,15 +218,15 @@ config SOUND_VRC5477 | |||
218 | 218 | ||
219 | config SOUND_AU1000 | 219 | config SOUND_AU1000 |
220 | tristate "Au1000 Sound" | 220 | tristate "Au1000 Sound" |
221 | depends on SOUND_PRIME!=n && (SOC_AU1000 || SOC_AU1100 || SOC_AU1500) && SOUND | 221 | depends on SOUND_PRIME && (SOC_AU1000 || SOC_AU1100 || SOC_AU1500) |
222 | 222 | ||
223 | config SOUND_AU1550_AC97 | 223 | config SOUND_AU1550_AC97 |
224 | tristate "Au1550 AC97 Sound" | 224 | tristate "Au1550 AC97 Sound" |
225 | depends on SOUND_PRIME!=n && SOC_AU1550 && SOUND | 225 | depends on SOUND_PRIME && SOC_AU1550 |
226 | 226 | ||
227 | config SOUND_TRIDENT | 227 | config SOUND_TRIDENT |
228 | tristate "Trident 4DWave DX/NX, SiS 7018 or ALi 5451 PCI Audio Core" | 228 | tristate "Trident 4DWave DX/NX, SiS 7018 or ALi 5451 PCI Audio Core" |
229 | depends on SOUND_PRIME!=n && SOUND | 229 | depends on SOUND_PRIME |
230 | ---help--- | 230 | ---help--- |
231 | Say Y or M if you have a PCI sound card utilizing the Trident | 231 | Say Y or M if you have a PCI sound card utilizing the Trident |
232 | 4DWave-DX/NX chipset or your mother board chipset has SiS 7018 | 232 | 4DWave-DX/NX chipset or your mother board chipset has SiS 7018 |
@@ -267,7 +267,7 @@ config SOUND_TRIDENT | |||
267 | 267 | ||
268 | config SOUND_MSNDCLAS | 268 | config SOUND_MSNDCLAS |
269 | tristate "Support for Turtle Beach MultiSound Classic, Tahiti, Monterey" | 269 | tristate "Support for Turtle Beach MultiSound Classic, Tahiti, Monterey" |
270 | depends on SOUND_PRIME!=n && SOUND && (m || !STANDALONE) | 270 | depends on SOUND_PRIME && (m || !STANDALONE) |
271 | help | 271 | help |
272 | Say M here if you have a Turtle Beach MultiSound Classic, Tahiti or | 272 | Say M here if you have a Turtle Beach MultiSound Classic, Tahiti or |
273 | Monterey (not for the Pinnacle or Fiji). | 273 | Monterey (not for the Pinnacle or Fiji). |
@@ -331,7 +331,7 @@ config MSNDCLAS_IO | |||
331 | 331 | ||
332 | config SOUND_MSNDPIN | 332 | config SOUND_MSNDPIN |
333 | tristate "Support for Turtle Beach MultiSound Pinnacle, Fiji" | 333 | tristate "Support for Turtle Beach MultiSound Pinnacle, Fiji" |
334 | depends on SOUND_PRIME!=n && SOUND && (m || !STANDALONE) | 334 | depends on SOUND_PRIME && (m || !STANDALONE) |
335 | help | 335 | help |
336 | Say M here if you have a Turtle Beach MultiSound Pinnacle or Fiji. | 336 | Say M here if you have a Turtle Beach MultiSound Pinnacle or Fiji. |
337 | See <file:Documentation/sound/oss/MultiSound> for important information | 337 | See <file:Documentation/sound/oss/MultiSound> for important information |
@@ -492,7 +492,7 @@ config MSND_FIFOSIZE | |||
492 | 492 | ||
493 | config SOUND_VIA82CXXX | 493 | config SOUND_VIA82CXXX |
494 | tristate "VIA 82C686 Audio Codec" | 494 | tristate "VIA 82C686 Audio Codec" |
495 | depends on SOUND_PRIME!=n && PCI | 495 | depends on SOUND_PRIME && PCI |
496 | help | 496 | help |
497 | Say Y here to include support for the audio codec found on VIA | 497 | Say Y here to include support for the audio codec found on VIA |
498 | 82Cxxx-based chips. Typically these are built into a motherboard. | 498 | 82Cxxx-based chips. Typically these are built into a motherboard. |
@@ -512,7 +512,7 @@ config MIDI_VIA82CXXX | |||
512 | 512 | ||
513 | config SOUND_OSS | 513 | config SOUND_OSS |
514 | tristate "OSS sound modules" | 514 | tristate "OSS sound modules" |
515 | depends on SOUND_PRIME!=n && SOUND | 515 | depends on SOUND_PRIME |
516 | help | 516 | help |
517 | OSS is the Open Sound System suite of sound card drivers. They make | 517 | OSS is the Open Sound System suite of sound card drivers. They make |
518 | sound programming easier since they provide a common API. Say Y or | 518 | sound programming easier since they provide a common API. Say Y or |
@@ -1077,7 +1077,7 @@ config SOUND_WAVEARTIST | |||
1077 | 1077 | ||
1078 | config SOUND_TVMIXER | 1078 | config SOUND_TVMIXER |
1079 | tristate "TV card (bt848) mixer support" | 1079 | tristate "TV card (bt848) mixer support" |
1080 | depends on SOUND_PRIME!=n && SOUND && I2C | 1080 | depends on SOUND_PRIME && I2C |
1081 | help | 1081 | help |
1082 | Support for audio mixer facilities on the BT848 TV frame-grabber | 1082 | Support for audio mixer facilities on the BT848 TV frame-grabber |
1083 | card. | 1083 | card. |
@@ -1088,11 +1088,11 @@ config SOUND_KAHLUA | |||
1088 | 1088 | ||
1089 | config SOUND_ALI5455 | 1089 | config SOUND_ALI5455 |
1090 | tristate "ALi5455 audio support" | 1090 | tristate "ALi5455 audio support" |
1091 | depends on SOUND_PRIME!=n && PCI | 1091 | depends on SOUND_PRIME && PCI |
1092 | 1092 | ||
1093 | config SOUND_FORTE | 1093 | config SOUND_FORTE |
1094 | tristate "ForteMedia FM801 driver" | 1094 | tristate "ForteMedia FM801 driver" |
1095 | depends on SOUND_PRIME!=n && PCI | 1095 | depends on SOUND_PRIME && PCI |
1096 | help | 1096 | help |
1097 | Say Y or M if you want driver support for the ForteMedia FM801 PCI | 1097 | Say Y or M if you want driver support for the ForteMedia FM801 PCI |
1098 | audio controller (Abit AU10, Genius Sound Maker, HP Workstation | 1098 | audio controller (Abit AU10, Genius Sound Maker, HP Workstation |
@@ -1100,7 +1100,7 @@ config SOUND_FORTE | |||
1100 | 1100 | ||
1101 | config SOUND_RME96XX | 1101 | config SOUND_RME96XX |
1102 | tristate "RME Hammerfall (RME96XX) support" | 1102 | tristate "RME Hammerfall (RME96XX) support" |
1103 | depends on SOUND_PRIME!=n && PCI | 1103 | depends on SOUND_PRIME && PCI |
1104 | help | 1104 | help |
1105 | Say Y or M if you have a Hammerfall or Hammerfall light | 1105 | Say Y or M if you have a Hammerfall or Hammerfall light |
1106 | multichannel card from RME. If you want to access advanced | 1106 | multichannel card from RME. If you want to access advanced |
@@ -1108,11 +1108,11 @@ config SOUND_RME96XX | |||
1108 | 1108 | ||
1109 | config SOUND_AD1980 | 1109 | config SOUND_AD1980 |
1110 | tristate "AD1980 front/back switch plugin" | 1110 | tristate "AD1980 front/back switch plugin" |
1111 | depends on SOUND_PRIME!=n | 1111 | depends on SOUND_PRIME |
1112 | 1112 | ||
1113 | config SOUND_SH_DAC_AUDIO | 1113 | config SOUND_SH_DAC_AUDIO |
1114 | tristate "SuperH DAC audio support" | 1114 | tristate "SuperH DAC audio support" |
1115 | depends on SOUND_PRIME!=n && SOUND && CPU_SH3 | 1115 | depends on SOUND_PRIME && CPU_SH3 |
1116 | 1116 | ||
1117 | config SOUND_SH_DAC_AUDIO_CHANNEL | 1117 | config SOUND_SH_DAC_AUDIO_CHANNEL |
1118 | int " DAC channel" | 1118 | int " DAC channel" |
diff --git a/sound/oss/ad1816.c b/sound/oss/ad1816.c index 22dae5d0fda3..95586de02028 100644 --- a/sound/oss/ad1816.c +++ b/sound/oss/ad1816.c | |||
@@ -592,7 +592,7 @@ typedef struct mixer_def mixer_ent; | |||
592 | {{reg_l, pola_l, pos_l, len_l}, {reg_r, pola_r, pos_r, len_r}} | 592 | {{reg_l, pola_l, pos_l, len_l}, {reg_r, pola_r, pos_r, len_r}} |
593 | 593 | ||
594 | 594 | ||
595 | mixer_ent mix_devices[SOUND_MIXER_NRDEVICES][2] = { | 595 | static mixer_ent mix_devices[SOUND_MIXER_NRDEVICES][2] = { |
596 | MIX_ENT(SOUND_MIXER_VOLUME, 14, 1, 8, 5, 14, 1, 0, 5), | 596 | MIX_ENT(SOUND_MIXER_VOLUME, 14, 1, 8, 5, 14, 1, 0, 5), |
597 | MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0), | 597 | MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0), |
598 | MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0), | 598 | MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0), |
diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c index 4384dac3f794..7c835abd99bc 100644 --- a/sound/oss/ad1848.c +++ b/sound/oss/ad1848.c | |||
@@ -2178,8 +2178,7 @@ void ad1848_unload(int io_base, int irq, int dma_playback, int dma_capture, int | |||
2178 | 2178 | ||
2179 | if (devc != NULL) | 2179 | if (devc != NULL) |
2180 | { | 2180 | { |
2181 | if(audio_devs[dev]->portc!=NULL) | 2181 | kfree(audio_devs[dev]->portc); |
2182 | kfree(audio_devs[dev]->portc); | ||
2183 | release_region(devc->base, 4); | 2182 | release_region(devc->base, 4); |
2184 | 2183 | ||
2185 | if (!share_dma) | 2184 | if (!share_dma) |
diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c index b767c621fd09..2cfd214e4c2a 100644 --- a/sound/oss/ad1889.c +++ b/sound/oss/ad1889.c | |||
@@ -277,8 +277,7 @@ static void ad1889_free_dev(ad1889_dev_t *dev) | |||
277 | 277 | ||
278 | for (j = 0; j < AD_MAX_STATES; j++) { | 278 | for (j = 0; j < AD_MAX_STATES; j++) { |
279 | dmabuf = &dev->state[j].dmabuf; | 279 | dmabuf = &dev->state[j].dmabuf; |
280 | if (dmabuf->rawbuf != NULL) | 280 | kfree(dmabuf->rawbuf); |
281 | kfree(dmabuf->rawbuf); | ||
282 | } | 281 | } |
283 | 282 | ||
284 | kfree(dev); | 283 | kfree(dev); |
diff --git a/sound/oss/cmpci.c b/sound/oss/cmpci.c index 34720e66dae1..74dcca78c6c0 100644 --- a/sound/oss/cmpci.c +++ b/sound/oss/cmpci.c | |||
@@ -123,6 +123,7 @@ | |||
123 | #include <linux/smp_lock.h> | 123 | #include <linux/smp_lock.h> |
124 | #include <linux/bitops.h> | 124 | #include <linux/bitops.h> |
125 | #include <linux/wait.h> | 125 | #include <linux/wait.h> |
126 | #include <linux/dma-mapping.h> | ||
126 | 127 | ||
127 | #include <asm/io.h> | 128 | #include <asm/io.h> |
128 | #include <asm/page.h> | 129 | #include <asm/page.h> |
@@ -3058,7 +3059,7 @@ static int __devinit cm_probe(struct pci_dev *pcidev, const struct pci_device_id | |||
3058 | return -ENODEV; | 3059 | return -ENODEV; |
3059 | if (pcidev->irq == 0) | 3060 | if (pcidev->irq == 0) |
3060 | return -ENODEV; | 3061 | return -ENODEV; |
3061 | i = pci_set_dma_mask(pcidev, 0xffffffff); | 3062 | i = pci_set_dma_mask(pcidev, DMA_32BIT_MASK); |
3062 | if (i) { | 3063 | if (i) { |
3063 | printk(KERN_WARNING "cmpci: architecture does not support 32bit PCI busmaster DMA\n"); | 3064 | printk(KERN_WARNING "cmpci: architecture does not support 32bit PCI busmaster DMA\n"); |
3064 | return i; | 3065 | return i; |
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c index 5281b88987f3..33108661e671 100644 --- a/sound/oss/dmasound/dmasound_awacs.c +++ b/sound/oss/dmasound/dmasound_awacs.c | |||
@@ -671,14 +671,10 @@ static void PMacIrqCleanup(void) | |||
671 | release_OF_resource(awacs_node, 1); | 671 | release_OF_resource(awacs_node, 1); |
672 | release_OF_resource(awacs_node, 2); | 672 | release_OF_resource(awacs_node, 2); |
673 | 673 | ||
674 | if (awacs_tx_cmd_space) | 674 | kfree(awacs_tx_cmd_space); |
675 | kfree(awacs_tx_cmd_space); | 675 | kfree(awacs_rx_cmd_space); |
676 | if (awacs_rx_cmd_space) | 676 | kfree(beep_dbdma_cmd_space); |
677 | kfree(awacs_rx_cmd_space); | 677 | kfree(beep_buf); |
678 | if (beep_dbdma_cmd_space) | ||
679 | kfree(beep_dbdma_cmd_space); | ||
680 | if (beep_buf) | ||
681 | kfree(beep_buf); | ||
682 | #ifdef CONFIG_PMAC_PBOOK | 678 | #ifdef CONFIG_PMAC_PBOOK |
683 | pmu_unregister_sleep_notifier(&awacs_sleep_notifier); | 679 | pmu_unregister_sleep_notifier(&awacs_sleep_notifier); |
684 | #endif | 680 | #endif |
@@ -2301,8 +2297,7 @@ if (count <= 0) | |||
2301 | #endif | 2297 | #endif |
2302 | 2298 | ||
2303 | if ((write_sq.max_count + 1) > number_of_tx_cmd_buffers) { | 2299 | if ((write_sq.max_count + 1) > number_of_tx_cmd_buffers) { |
2304 | if (awacs_tx_cmd_space) | 2300 | kfree(awacs_tx_cmd_space); |
2305 | kfree(awacs_tx_cmd_space); | ||
2306 | number_of_tx_cmd_buffers = 0; | 2301 | number_of_tx_cmd_buffers = 0; |
2307 | 2302 | ||
2308 | /* we need nbufs + 1 (for the loop) and we should request + 1 | 2303 | /* we need nbufs + 1 (for the loop) and we should request + 1 |
@@ -2360,8 +2355,7 @@ if (count <= 0) | |||
2360 | #endif | 2355 | #endif |
2361 | 2356 | ||
2362 | if ((read_sq.max_count+1) > number_of_rx_cmd_buffers ) { | 2357 | if ((read_sq.max_count+1) > number_of_rx_cmd_buffers ) { |
2363 | if (awacs_rx_cmd_space) | 2358 | kfree(awacs_rx_cmd_space); |
2364 | kfree(awacs_rx_cmd_space); | ||
2365 | number_of_rx_cmd_buffers = 0; | 2359 | number_of_rx_cmd_buffers = 0; |
2366 | 2360 | ||
2367 | /* we need nbufs + 1 (for the loop) and we should request + 1 again | 2361 | /* we need nbufs + 1 (for the loop) and we should request + 1 again |
@@ -2805,7 +2799,7 @@ __init setup_beep(void) | |||
2805 | beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL); | 2799 | beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL); |
2806 | if (beep_buf == NULL) { | 2800 | if (beep_buf == NULL) { |
2807 | printk(KERN_ERR "dmasound_pmac: no memory for beep buffer\n"); | 2801 | printk(KERN_ERR "dmasound_pmac: no memory for beep buffer\n"); |
2808 | if( beep_dbdma_cmd_space ) kfree(beep_dbdma_cmd_space) ; | 2802 | kfree(beep_dbdma_cmd_space) ; |
2809 | return -ENOMEM ; | 2803 | return -ENOMEM ; |
2810 | } | 2804 | } |
2811 | return 0 ; | 2805 | return 0 ; |
diff --git a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c index 33dea3d56c1e..b40b5f97aace 100644 --- a/sound/oss/emu10k1/midi.c +++ b/sound/oss/emu10k1/midi.c | |||
@@ -523,10 +523,8 @@ void emu10k1_seq_midi_close(int dev) | |||
523 | card = midi_devs[dev]->devc; | 523 | card = midi_devs[dev]->devc; |
524 | emu10k1_mpuout_close(card); | 524 | emu10k1_mpuout_close(card); |
525 | 525 | ||
526 | if (card->seq_mididev) { | 526 | kfree(card->seq_mididev); |
527 | kfree(card->seq_mididev); | 527 | card->seq_mididev = NULL; |
528 | card->seq_mididev = NULL; | ||
529 | } | ||
530 | } | 528 | } |
531 | 529 | ||
532 | int emu10k1_seq_midi_out(int dev, unsigned char midi_byte) | 530 | int emu10k1_seq_midi_out(int dev, unsigned char midi_byte) |
diff --git a/sound/oss/emu10k1/passthrough.c b/sound/oss/emu10k1/passthrough.c index 4094be55f3be..4e3baca7d41f 100644 --- a/sound/oss/emu10k1/passthrough.c +++ b/sound/oss/emu10k1/passthrough.c | |||
@@ -213,8 +213,7 @@ void emu10k1_pt_stop(struct emu10k1_card *card) | |||
213 | sblive_writeptr(card, SPCS0 + i, 0, pt->old_spcs[i]); | 213 | sblive_writeptr(card, SPCS0 + i, 0, pt->old_spcs[i]); |
214 | } | 214 | } |
215 | pt->state = PT_STATE_INACTIVE; | 215 | pt->state = PT_STATE_INACTIVE; |
216 | if(pt->buf) | 216 | kfree(pt->buf); |
217 | kfree(pt->buf); | ||
218 | } | 217 | } |
219 | } | 218 | } |
220 | 219 | ||
diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c index 563a52fbdd39..8538085086e7 100644 --- a/sound/oss/es1370.c +++ b/sound/oss/es1370.c | |||
@@ -156,6 +156,7 @@ | |||
156 | #include <linux/spinlock.h> | 156 | #include <linux/spinlock.h> |
157 | #include <linux/gameport.h> | 157 | #include <linux/gameport.h> |
158 | #include <linux/wait.h> | 158 | #include <linux/wait.h> |
159 | #include <linux/dma-mapping.h> | ||
159 | 160 | ||
160 | #include <asm/io.h> | 161 | #include <asm/io.h> |
161 | #include <asm/page.h> | 162 | #include <asm/page.h> |
@@ -2621,7 +2622,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic | |||
2621 | return -ENODEV; | 2622 | return -ENODEV; |
2622 | if (pcidev->irq == 0) | 2623 | if (pcidev->irq == 0) |
2623 | return -ENODEV; | 2624 | return -ENODEV; |
2624 | i = pci_set_dma_mask(pcidev, 0xffffffff); | 2625 | i = pci_set_dma_mask(pcidev, DMA_32BIT_MASK); |
2625 | if (i) { | 2626 | if (i) { |
2626 | printk(KERN_WARNING "es1370: architecture does not support 32bit PCI busmaster DMA\n"); | 2627 | printk(KERN_WARNING "es1370: architecture does not support 32bit PCI busmaster DMA\n"); |
2627 | return i; | 2628 | return i; |
diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c index c38ae1eca25f..12a56d5ab498 100644 --- a/sound/oss/es1371.c +++ b/sound/oss/es1371.c | |||
@@ -128,6 +128,7 @@ | |||
128 | #include <linux/ac97_codec.h> | 128 | #include <linux/ac97_codec.h> |
129 | #include <linux/gameport.h> | 129 | #include <linux/gameport.h> |
130 | #include <linux/wait.h> | 130 | #include <linux/wait.h> |
131 | #include <linux/dma-mapping.h> | ||
131 | 132 | ||
132 | #include <asm/io.h> | 133 | #include <asm/io.h> |
133 | #include <asm/page.h> | 134 | #include <asm/page.h> |
@@ -2862,7 +2863,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic | |||
2862 | return -ENODEV; | 2863 | return -ENODEV; |
2863 | if (pcidev->irq == 0) | 2864 | if (pcidev->irq == 0) |
2864 | return -ENODEV; | 2865 | return -ENODEV; |
2865 | i = pci_set_dma_mask(pcidev, 0xffffffff); | 2866 | i = pci_set_dma_mask(pcidev, DMA_32BIT_MASK); |
2866 | if (i) { | 2867 | if (i) { |
2867 | printk(KERN_WARNING "es1371: architecture does not support 32bit PCI busmaster DMA\n"); | 2868 | printk(KERN_WARNING "es1371: architecture does not support 32bit PCI busmaster DMA\n"); |
2868 | return i; | 2869 | return i; |
diff --git a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c index a682ab1242cc..a4ecab2f0522 100644 --- a/sound/oss/esssolo1.c +++ b/sound/oss/esssolo1.c | |||
@@ -104,6 +104,7 @@ | |||
104 | #include <linux/smp_lock.h> | 104 | #include <linux/smp_lock.h> |
105 | #include <linux/gameport.h> | 105 | #include <linux/gameport.h> |
106 | #include <linux/wait.h> | 106 | #include <linux/wait.h> |
107 | #include <linux/dma-mapping.h> | ||
107 | 108 | ||
108 | #include <asm/io.h> | 109 | #include <asm/io.h> |
109 | #include <asm/page.h> | 110 | #include <asm/page.h> |
@@ -2346,7 +2347,7 @@ static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device | |||
2346 | * to 24 bits first, then 32 bits (playback only) if that fails. | 2347 | * to 24 bits first, then 32 bits (playback only) if that fails. |
2347 | */ | 2348 | */ |
2348 | if (pci_set_dma_mask(pcidev, 0x00ffffff) && | 2349 | if (pci_set_dma_mask(pcidev, 0x00ffffff) && |
2349 | pci_set_dma_mask(pcidev, 0xffffffff)) { | 2350 | pci_set_dma_mask(pcidev, DMA_32BIT_MASK)) { |
2350 | printk(KERN_WARNING "solo1: architecture does not support 24bit or 32bit PCI busmaster DMA\n"); | 2351 | printk(KERN_WARNING "solo1: architecture does not support 24bit or 32bit PCI busmaster DMA\n"); |
2351 | return -ENODEV; | 2352 | return -ENODEV; |
2352 | } | 2353 | } |
diff --git a/sound/oss/maestro.c b/sound/oss/maestro.c index 52d2db4bc312..3dce504e6d6d 100644 --- a/sound/oss/maestro.c +++ b/sound/oss/maestro.c | |||
@@ -2356,7 +2356,7 @@ ess_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) | |||
2356 | } | 2356 | } |
2357 | 2357 | ||
2358 | rec_return_free: | 2358 | rec_return_free: |
2359 | if(combbuf) kfree(combbuf); | 2359 | kfree(combbuf); |
2360 | return ret; | 2360 | return ret; |
2361 | } | 2361 | } |
2362 | 2362 | ||
diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c index b66f53fa8db0..0aac54c68f01 100644 --- a/sound/oss/mpu401.c +++ b/sound/oss/mpu401.c | |||
@@ -1240,8 +1240,7 @@ void unload_mpu401(struct address_info *hw_config) | |||
1240 | p=mpu401_synth_operations[n]; | 1240 | p=mpu401_synth_operations[n]; |
1241 | sound_unload_mididev(n); | 1241 | sound_unload_mididev(n); |
1242 | sound_unload_timerdev(hw_config->slots[2]); | 1242 | sound_unload_timerdev(hw_config->slots[2]); |
1243 | if(p) | 1243 | kfree(p); |
1244 | kfree(p); | ||
1245 | } | 1244 | } |
1246 | } | 1245 | } |
1247 | 1246 | ||
diff --git a/sound/oss/nm256.h b/sound/oss/nm256.h index eae7d99d6826..21e07b5081f2 100644 --- a/sound/oss/nm256.h +++ b/sound/oss/nm256.h | |||
@@ -128,9 +128,6 @@ struct nm256_info | |||
128 | struct nm256_info *next_card; | 128 | struct nm256_info *next_card; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | /* Debug flag--bigger numbers mean more output. */ | ||
132 | extern int nm256_debug; | ||
133 | |||
134 | /* The BIOS signature. */ | 131 | /* The BIOS signature. */ |
135 | #define NM_SIGNATURE 0x4e4d0000 | 132 | #define NM_SIGNATURE 0x4e4d0000 |
136 | /* Signature mask. */ | 133 | /* Signature mask. */ |
@@ -284,7 +281,7 @@ nm256_readBuffer8 (struct nm256_info *card, u8 *dst, int port, int offset, | |||
284 | } | 281 | } |
285 | 282 | ||
286 | /* Returns a non-zero value if we should use the coefficient cache. */ | 283 | /* Returns a non-zero value if we should use the coefficient cache. */ |
287 | extern int nm256_cachedCoefficients (struct nm256_info *card); | 284 | static int nm256_cachedCoefficients (struct nm256_info *card); |
288 | 285 | ||
289 | #endif | 286 | #endif |
290 | 287 | ||
diff --git a/sound/oss/nm256_audio.c b/sound/oss/nm256_audio.c index f9166e135192..66970062eb36 100644 --- a/sound/oss/nm256_audio.c +++ b/sound/oss/nm256_audio.c | |||
@@ -28,12 +28,13 @@ | |||
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
30 | #include "sound_config.h" | 30 | #include "sound_config.h" |
31 | #include "nm256.h" | ||
32 | #include "nm256_coeff.h" | ||
33 | 31 | ||
34 | int nm256_debug; | 32 | static int nm256_debug; |
35 | static int force_load; | 33 | static int force_load; |
36 | 34 | ||
35 | #include "nm256.h" | ||
36 | #include "nm256_coeff.h" | ||
37 | |||
37 | /* | 38 | /* |
38 | * The size of the playback reserve. When the playback buffer has less | 39 | * The size of the playback reserve. When the playback buffer has less |
39 | * than NM256_PLAY_WMARK_SIZE bytes to output, we request a new | 40 | * than NM256_PLAY_WMARK_SIZE bytes to output, we request a new |
@@ -138,7 +139,7 @@ static int usecache; | |||
138 | static int buffertop; | 139 | static int buffertop; |
139 | 140 | ||
140 | /* Check to see if we're using the bank of cached coefficients. */ | 141 | /* Check to see if we're using the bank of cached coefficients. */ |
141 | int | 142 | static int |
142 | nm256_cachedCoefficients (struct nm256_info *card) | 143 | nm256_cachedCoefficients (struct nm256_info *card) |
143 | { | 144 | { |
144 | return usecache; | 145 | return usecache; |
diff --git a/sound/oss/nm256_coeff.h b/sound/oss/nm256_coeff.h index 0ceecc20077b..6fc07f3cb33b 100644 --- a/sound/oss/nm256_coeff.h +++ b/sound/oss/nm256_coeff.h | |||
@@ -4650,7 +4650,7 @@ nm256_loadAllCoefficients (struct nm256_info *card) | |||
4650 | card->coeffsCurrent = 1; | 4650 | card->coeffsCurrent = 1; |
4651 | } | 4651 | } |
4652 | 4652 | ||
4653 | void | 4653 | static void |
4654 | nm256_loadCoefficient (struct nm256_info *card, int which, int number) | 4654 | nm256_loadCoefficient (struct nm256_info *card, int which, int number) |
4655 | { | 4655 | { |
4656 | static u16 addrs[3] = { 0x1c, 0x21c, 0x408 }; | 4656 | static u16 addrs[3] = { 0x1c, 0x21c, 0x408 }; |
diff --git a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c index 76774bbc1436..7609c68a89f4 100644 --- a/sound/oss/rme96xx.c +++ b/sound/oss/rme96xx.c | |||
@@ -807,7 +807,7 @@ static void* busmaster_malloc(int size) { | |||
807 | struct page* page, *last_page; | 807 | struct page* page, *last_page; |
808 | 808 | ||
809 | page = virt_to_page(buf); | 809 | page = virt_to_page(buf); |
810 | last_page = virt_to_page(buf + (1 << pg)); | 810 | last_page = page + (1 << pg); |
811 | DBG(printk("setting reserved bit\n")); | 811 | DBG(printk("setting reserved bit\n")); |
812 | while (page < last_page) { | 812 | while (page < last_page) { |
813 | SetPageReserved(page); | 813 | SetPageReserved(page); |
@@ -1750,9 +1750,7 @@ static unsigned int rme96xx_poll(struct file *file, struct poll_table_struct *wa | |||
1750 | 1750 | ||
1751 | 1751 | ||
1752 | static struct file_operations rme96xx_audio_fops = { | 1752 | static struct file_operations rme96xx_audio_fops = { |
1753 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) | ||
1754 | .owner = THIS_MODULE, | 1753 | .owner = THIS_MODULE, |
1755 | #endif | ||
1756 | .read = rme96xx_read, | 1754 | .read = rme96xx_read, |
1757 | .write = rme96xx_write, | 1755 | .write = rme96xx_write, |
1758 | .poll = rme96xx_poll, | 1756 | .poll = rme96xx_poll, |
@@ -1852,9 +1850,7 @@ static int rme96xx_mixer_release(struct inode *inode, struct file *file) | |||
1852 | } | 1850 | } |
1853 | 1851 | ||
1854 | static /*const*/ struct file_operations rme96xx_mixer_fops = { | 1852 | static /*const*/ struct file_operations rme96xx_mixer_fops = { |
1855 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) | ||
1856 | .owner = THIS_MODULE, | 1853 | .owner = THIS_MODULE, |
1857 | #endif | ||
1858 | .ioctl = rme96xx_mixer_ioctl, | 1854 | .ioctl = rme96xx_mixer_ioctl, |
1859 | .open = rme96xx_mixer_open, | 1855 | .open = rme96xx_mixer_open, |
1860 | .release = rme96xx_mixer_release, | 1856 | .release = rme96xx_mixer_release, |
diff --git a/sound/oss/sb_common.c b/sound/oss/sb_common.c index ce359e6c933a..5f955e3d2e26 100644 --- a/sound/oss/sb_common.c +++ b/sound/oss/sb_common.c | |||
@@ -915,8 +915,8 @@ void sb_dsp_unload(struct address_info *hw_config, int sbmpu) | |||
915 | } | 915 | } |
916 | else | 916 | else |
917 | release_region(hw_config->io_base, 16); | 917 | release_region(hw_config->io_base, 16); |
918 | if(detected_devc) | 918 | |
919 | kfree(detected_devc); | 919 | kfree(detected_devc); |
920 | } | 920 | } |
921 | 921 | ||
922 | /* | 922 | /* |
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c index de91c90a0112..a686be936aff 100644 --- a/sound/oss/soundcard.c +++ b/sound/oss/soundcard.c | |||
@@ -73,7 +73,7 @@ static char dma_alloc_map[MAX_DMA_CHANNELS]; | |||
73 | 73 | ||
74 | 74 | ||
75 | unsigned long seq_time = 0; /* Time for /dev/sequencer */ | 75 | unsigned long seq_time = 0; /* Time for /dev/sequencer */ |
76 | extern struct class_simple *sound_class; | 76 | extern struct class *sound_class; |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * Table for configurable mixer volume handling | 79 | * Table for configurable mixer volume handling |
@@ -567,9 +567,9 @@ static int __init oss_init(void) | |||
567 | devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor), | 567 | devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor), |
568 | S_IFCHR | dev_list[i].mode, | 568 | S_IFCHR | dev_list[i].mode, |
569 | "sound/%s", dev_list[i].name); | 569 | "sound/%s", dev_list[i].name); |
570 | class_simple_device_add(sound_class, | 570 | class_device_create(sound_class, |
571 | MKDEV(SOUND_MAJOR, dev_list[i].minor), | 571 | MKDEV(SOUND_MAJOR, dev_list[i].minor), |
572 | NULL, "%s", dev_list[i].name); | 572 | NULL, "%s", dev_list[i].name); |
573 | 573 | ||
574 | if (!dev_list[i].num) | 574 | if (!dev_list[i].num) |
575 | continue; | 575 | continue; |
@@ -579,10 +579,9 @@ static int __init oss_init(void) | |||
579 | dev_list[i].minor + (j*0x10)), | 579 | dev_list[i].minor + (j*0x10)), |
580 | S_IFCHR | dev_list[i].mode, | 580 | S_IFCHR | dev_list[i].mode, |
581 | "sound/%s%d", dev_list[i].name, j); | 581 | "sound/%s%d", dev_list[i].name, j); |
582 | class_simple_device_add(sound_class, | 582 | class_device_create(sound_class, |
583 | MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)), | 583 | MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)), |
584 | NULL, | 584 | NULL, "%s%d", dev_list[i].name, j); |
585 | "%s%d", dev_list[i].name, j); | ||
586 | } | 585 | } |
587 | } | 586 | } |
588 | 587 | ||
@@ -598,12 +597,12 @@ static void __exit oss_cleanup(void) | |||
598 | 597 | ||
599 | for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) { | 598 | for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) { |
600 | devfs_remove("sound/%s", dev_list[i].name); | 599 | devfs_remove("sound/%s", dev_list[i].name); |
601 | class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor)); | 600 | class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor)); |
602 | if (!dev_list[i].num) | 601 | if (!dev_list[i].num) |
603 | continue; | 602 | continue; |
604 | for (j = 1; j < *dev_list[i].num; j++) { | 603 | for (j = 1; j < *dev_list[i].num; j++) { |
605 | devfs_remove("sound/%s%d", dev_list[i].name, j); | 604 | devfs_remove("sound/%s%d", dev_list[i].name, j); |
606 | class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10))); | 605 | class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10))); |
607 | } | 606 | } |
608 | } | 607 | } |
609 | 608 | ||
diff --git a/sound/oss/sscape.c b/sound/oss/sscape.c index 50ca64629450..9ed5211c3168 100644 --- a/sound/oss/sscape.c +++ b/sound/oss/sscape.c | |||
@@ -991,7 +991,6 @@ static void __init sscape_pnp_init_hw(sscape_info* devc) | |||
991 | unsigned i; | 991 | unsigned i; |
992 | static char code_file_name[23] = "/sndscape/sndscape.cox"; | 992 | static char code_file_name[23] = "/sndscape/sndscape.cox"; |
993 | 993 | ||
994 | int sscape_sb_enable = 0; | ||
995 | int sscape_joystic_enable = 0x7f; | 994 | int sscape_joystic_enable = 0x7f; |
996 | int sscape_mic_enable = 0; | 995 | int sscape_mic_enable = 0; |
997 | int sscape_ext_midi = 0; | 996 | int sscape_ext_midi = 0; |
@@ -1015,14 +1014,9 @@ static void __init sscape_pnp_init_hw(sscape_info* devc) | |||
1015 | sscape_write( devc, 2, devc->ic_type == IC_ODIE ? 0x70 : 0x40); | 1014 | sscape_write( devc, 2, devc->ic_type == IC_ODIE ? 0x70 : 0x40); |
1016 | sscape_write( devc, 3, ( devc -> dma << 4) | 0x80); | 1015 | sscape_write( devc, 3, ( devc -> dma << 4) | 0x80); |
1017 | 1016 | ||
1018 | if ( sscape_sb_enable ) | 1017 | sscape_write (devc, 4, 0xF0 | (midi_irq<<2) | midi_irq); |
1019 | sscape_write (devc, 4, 0xF0 | (sb_irq << 2) | midi_irq); | ||
1020 | else | ||
1021 | sscape_write (devc, 4, 0xF0 | (midi_irq<<2) | midi_irq); | ||
1022 | 1018 | ||
1023 | i = 0x10; //sscape_read(devc, 9) & (devc->ic_type == IC_ODIE ? 0xf0 : 0xc0); | 1019 | i = 0x10; //sscape_read(devc, 9) & (devc->ic_type == IC_ODIE ? 0xf0 : 0xc0); |
1024 | if ( sscape_sb_enable ) | ||
1025 | i |= devc->ic_type == IC_ODIE ? 0x05 : 0x07; | ||
1026 | if (sscape_joystic_enable) i |= 8; | 1020 | if (sscape_joystic_enable) i |= 8; |
1027 | 1021 | ||
1028 | sscape_write (devc, 9, i); | 1022 | sscape_write (devc, 9, i); |
diff --git a/sound/oss/v_midi.c b/sound/oss/v_midi.c index 077b76797665..a7ef04fab075 100644 --- a/sound/oss/v_midi.c +++ b/sound/oss/v_midi.c | |||
@@ -39,8 +39,6 @@ static void *midi_mem = NULL; | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | 41 | ||
42 | void (*midi_input_intr) (int dev, unsigned char data); | ||
43 | |||
44 | static int v_midi_open (int dev, int mode, | 42 | static int v_midi_open (int dev, int mode, |
45 | void (*input) (int dev, unsigned char data), | 43 | void (*input) (int dev, unsigned char data), |
46 | void (*output) (int dev) | 44 | void (*output) (int dev) |
diff --git a/sound/oss/wavfront.c b/sound/oss/wavfront.c index cce1278dc487..b92ba8921638 100644 --- a/sound/oss/wavfront.c +++ b/sound/oss/wavfront.c | |||
@@ -151,11 +151,11 @@ static int (*midi_load_patch) (int devno, int format, const char __user *addr, | |||
151 | 151 | ||
152 | /*** Module-accessible parameters ***************************************/ | 152 | /*** Module-accessible parameters ***************************************/ |
153 | 153 | ||
154 | int wf_raw; /* we normally check for "raw state" to firmware | 154 | static int wf_raw; /* we normally check for "raw state" to firmware |
155 | loading. if set, then during driver loading, the | 155 | loading. if set, then during driver loading, the |
156 | state of the board is ignored, and we reset the | 156 | state of the board is ignored, and we reset the |
157 | board and load the firmware anyway. | 157 | board and load the firmware anyway. |
158 | */ | 158 | */ |
159 | 159 | ||
160 | static int fx_raw = 1; /* if this is zero, we'll leave the FX processor in | 160 | static int fx_raw = 1; /* if this is zero, we'll leave the FX processor in |
161 | whatever state it is when the driver is loaded. | 161 | whatever state it is when the driver is loaded. |
@@ -2911,7 +2911,7 @@ int __init detect_wffx (void) | |||
2911 | return 0; | 2911 | return 0; |
2912 | } | 2912 | } |
2913 | 2913 | ||
2914 | void | 2914 | static void |
2915 | wffx_mute (int onoff) | 2915 | wffx_mute (int onoff) |
2916 | 2916 | ||
2917 | { | 2917 | { |
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 428efdbd70a1..6d7a00f34d82 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig | |||
@@ -274,6 +274,19 @@ config SND_HDSP | |||
274 | To compile this driver as a module, choose M here: the module | 274 | To compile this driver as a module, choose M here: the module |
275 | will be called snd-hdsp. | 275 | will be called snd-hdsp. |
276 | 276 | ||
277 | config SND_HDSPM | ||
278 | tristate "RME Hammerfall DSP MADI" | ||
279 | depends on SND | ||
280 | select SND_HWDEP | ||
281 | select SND_RAWMIDI | ||
282 | select SND_PCM | ||
283 | help | ||
284 | Say Y here to include support for RME Hammerfall DSP MADI | ||
285 | soundcards. | ||
286 | |||
287 | To compile this driver as a module, choose M here: the module | ||
288 | will be called snd-hdspm. | ||
289 | |||
277 | config SND_TRIDENT | 290 | config SND_TRIDENT |
278 | tristate "Trident 4D-Wave DX/NX; SiS 7018" | 291 | tristate "Trident 4D-Wave DX/NX; SiS 7018" |
279 | depends on SND | 292 | depends on SND |
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 0b024ec1f709..a4b72cd2eea0 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c | |||
@@ -120,6 +120,7 @@ static const ac97_codec_id_t snd_ac97_codec_ids[] = { | |||
120 | { 0x414c4770, 0xfffffff0, "ALC203", NULL, NULL }, | 120 | { 0x414c4770, 0xfffffff0, "ALC203", NULL, NULL }, |
121 | { 0x434d4941, 0xffffffff, "CMI9738", patch_cm9738, NULL }, | 121 | { 0x434d4941, 0xffffffff, "CMI9738", patch_cm9738, NULL }, |
122 | { 0x434d4961, 0xffffffff, "CMI9739", patch_cm9739, NULL }, | 122 | { 0x434d4961, 0xffffffff, "CMI9739", patch_cm9739, NULL }, |
123 | { 0x434d4969, 0xffffffff, "CMI9780", patch_cm9780, NULL }, | ||
123 | { 0x434d4978, 0xffffffff, "CMI9761", patch_cm9761, NULL }, | 124 | { 0x434d4978, 0xffffffff, "CMI9761", patch_cm9761, NULL }, |
124 | { 0x434d4982, 0xffffffff, "CMI9761", patch_cm9761, NULL }, | 125 | { 0x434d4982, 0xffffffff, "CMI9761", patch_cm9761, NULL }, |
125 | { 0x434d4983, 0xffffffff, "CMI9761", patch_cm9761, NULL }, | 126 | { 0x434d4983, 0xffffffff, "CMI9761", patch_cm9761, NULL }, |
@@ -149,7 +150,7 @@ static const ac97_codec_id_t snd_ac97_codec_ids[] = { | |||
149 | { 0x4e534331, 0xffffffff, "LM4549", NULL, NULL }, | 150 | { 0x4e534331, 0xffffffff, "LM4549", NULL, NULL }, |
150 | { 0x4e534350, 0xffffffff, "LM4550", NULL, NULL }, | 151 | { 0x4e534350, 0xffffffff, "LM4550", NULL, NULL }, |
151 | { 0x50534304, 0xffffffff, "UCB1400", NULL, NULL }, | 152 | { 0x50534304, 0xffffffff, "UCB1400", NULL, NULL }, |
152 | { 0x53494c20, 0xffffffe0, "Si3036,8", NULL, mpatch_si3036 }, | 153 | { 0x53494c20, 0xffffffe0, "Si3036,8", mpatch_si3036, mpatch_si3036, AC97_MODEM_PATCH }, |
153 | { 0x54524102, 0xffffffff, "TR28022", NULL, NULL }, | 154 | { 0x54524102, 0xffffffff, "TR28022", NULL, NULL }, |
154 | { 0x54524106, 0xffffffff, "TR28026", NULL, NULL }, | 155 | { 0x54524106, 0xffffffff, "TR28026", NULL, NULL }, |
155 | { 0x54524108, 0xffffffff, "TR28028", patch_tritech_tr28028, NULL }, // added by xin jin [07/09/99] | 156 | { 0x54524108, 0xffffffff, "TR28028", patch_tritech_tr28028, NULL }, // added by xin jin [07/09/99] |
@@ -462,12 +463,14 @@ int snd_ac97_get_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u | |||
462 | { | 463 | { |
463 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 464 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); |
464 | struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; | 465 | struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; |
465 | unsigned short val; | 466 | unsigned short val, bitmask; |
466 | 467 | ||
468 | for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) | ||
469 | ; | ||
467 | val = snd_ac97_read_cache(ac97, e->reg); | 470 | val = snd_ac97_read_cache(ac97, e->reg); |
468 | ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (e->mask - 1); | 471 | ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1); |
469 | if (e->shift_l != e->shift_r) | 472 | if (e->shift_l != e->shift_r) |
470 | ucontrol->value.enumerated.item[1] = (val >> e->shift_r) & (e->mask - 1); | 473 | ucontrol->value.enumerated.item[1] = (val >> e->shift_r) & (bitmask - 1); |
471 | 474 | ||
472 | return 0; | 475 | return 0; |
473 | } | 476 | } |
@@ -477,17 +480,19 @@ int snd_ac97_put_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u | |||
477 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 480 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); |
478 | struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; | 481 | struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; |
479 | unsigned short val; | 482 | unsigned short val; |
480 | unsigned short mask; | 483 | unsigned short mask, bitmask; |
481 | 484 | ||
485 | for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) | ||
486 | ; | ||
482 | if (ucontrol->value.enumerated.item[0] > e->mask - 1) | 487 | if (ucontrol->value.enumerated.item[0] > e->mask - 1) |
483 | return -EINVAL; | 488 | return -EINVAL; |
484 | val = ucontrol->value.enumerated.item[0] << e->shift_l; | 489 | val = ucontrol->value.enumerated.item[0] << e->shift_l; |
485 | mask = (e->mask - 1) << e->shift_l; | 490 | mask = (bitmask - 1) << e->shift_l; |
486 | if (e->shift_l != e->shift_r) { | 491 | if (e->shift_l != e->shift_r) { |
487 | if (ucontrol->value.enumerated.item[1] > e->mask - 1) | 492 | if (ucontrol->value.enumerated.item[1] > e->mask - 1) |
488 | return -EINVAL; | 493 | return -EINVAL; |
489 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; | 494 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; |
490 | mask |= (e->mask - 1) << e->shift_r; | 495 | mask |= (bitmask - 1) << e->shift_r; |
491 | } | 496 | } |
492 | return snd_ac97_update_bits(ac97, e->reg, mask, val); | 497 | return snd_ac97_update_bits(ac97, e->reg, mask, val); |
493 | } | 498 | } |
@@ -658,14 +663,14 @@ AC97_SINGLE("LFE Playback Switch", AC97_CENTER_LFE_MASTER, 15, 1, 1), | |||
658 | AC97_SINGLE("LFE Playback Volume", AC97_CENTER_LFE_MASTER, 8, 31, 1) | 663 | AC97_SINGLE("LFE Playback Volume", AC97_CENTER_LFE_MASTER, 8, 31, 1) |
659 | }; | 664 | }; |
660 | 665 | ||
661 | static const snd_kcontrol_new_t snd_ac97_controls_surround[2] = { | ||
662 | AC97_DOUBLE("Surround Playback Switch", AC97_SURROUND_MASTER, 15, 7, 1, 1), | ||
663 | AC97_DOUBLE("Surround Playback Volume", AC97_SURROUND_MASTER, 8, 0, 31, 1), | ||
664 | }; | ||
665 | |||
666 | static const snd_kcontrol_new_t snd_ac97_control_eapd = | 666 | static const snd_kcontrol_new_t snd_ac97_control_eapd = |
667 | AC97_SINGLE("External Amplifier", AC97_POWERDOWN, 15, 1, 1); | 667 | AC97_SINGLE("External Amplifier", AC97_POWERDOWN, 15, 1, 1); |
668 | 668 | ||
669 | static const snd_kcontrol_new_t snd_ac97_controls_modem_switches[2] = { | ||
670 | AC97_SINGLE("Off-hook Switch", AC97_GPIO_STATUS, 0, 1, 0), | ||
671 | AC97_SINGLE("Caller ID Switch", AC97_GPIO_STATUS, 2, 1, 0) | ||
672 | }; | ||
673 | |||
669 | /* change the existing EAPD control as inverted */ | 674 | /* change the existing EAPD control as inverted */ |
670 | static void set_inv_eapd(ac97_t *ac97, snd_kcontrol_t *kctl) | 675 | static void set_inv_eapd(ac97_t *ac97, snd_kcontrol_t *kctl) |
671 | { | 676 | { |
@@ -1072,9 +1077,9 @@ static void check_volume_resolution(ac97_t *ac97, int reg, unsigned char *lo_max | |||
1072 | unsigned short val; | 1077 | unsigned short val; |
1073 | snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8)); | 1078 | snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8)); |
1074 | val = snd_ac97_read(ac97, reg); | 1079 | val = snd_ac97_read(ac97, reg); |
1075 | if (! *lo_max && (val & cbit[i])) | 1080 | if (! *lo_max && (val & 0x7f) == cbit[i]) |
1076 | *lo_max = max[i]; | 1081 | *lo_max = max[i]; |
1077 | if (! *hi_max && (val & (cbit[i] << 8))) | 1082 | if (! *hi_max && ((val >> 8) & 0x7f) == cbit[i]) |
1078 | *hi_max = max[i]; | 1083 | *hi_max = max[i]; |
1079 | if (*lo_max && *hi_max) | 1084 | if (*lo_max && *hi_max) |
1080 | break; | 1085 | break; |
@@ -1526,13 +1531,25 @@ static int snd_ac97_mixer_build(ac97_t * ac97) | |||
1526 | 1531 | ||
1527 | static int snd_ac97_modem_build(snd_card_t * card, ac97_t * ac97) | 1532 | static int snd_ac97_modem_build(snd_card_t * card, ac97_t * ac97) |
1528 | { | 1533 | { |
1529 | /* TODO */ | 1534 | int err, idx; |
1535 | |||
1530 | //printk("AC97_GPIO_CFG = %x\n",snd_ac97_read(ac97,AC97_GPIO_CFG)); | 1536 | //printk("AC97_GPIO_CFG = %x\n",snd_ac97_read(ac97,AC97_GPIO_CFG)); |
1531 | snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH)); | 1537 | snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH)); |
1532 | snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH)); | 1538 | snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH)); |
1533 | snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff); | 1539 | snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff); |
1534 | snd_ac97_write(ac97, AC97_GPIO_WAKEUP, 0x0); | 1540 | snd_ac97_write(ac97, AC97_GPIO_WAKEUP, 0x0); |
1535 | snd_ac97_write(ac97, AC97_MISC_AFE, 0x0); | 1541 | snd_ac97_write(ac97, AC97_MISC_AFE, 0x0); |
1542 | |||
1543 | /* build modem switches */ | ||
1544 | for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_modem_switches); idx++) | ||
1545 | if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_modem_switches[idx], ac97))) < 0) | ||
1546 | return err; | ||
1547 | |||
1548 | /* build chip specific controls */ | ||
1549 | if (ac97->build_ops->build_specific) | ||
1550 | if ((err = ac97->build_ops->build_specific(ac97)) < 0) | ||
1551 | return err; | ||
1552 | |||
1536 | return 0; | 1553 | return 0; |
1537 | } | 1554 | } |
1538 | 1555 | ||
@@ -1872,7 +1889,11 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97) | |||
1872 | goto __access_ok; | 1889 | goto __access_ok; |
1873 | } | 1890 | } |
1874 | 1891 | ||
1875 | snd_ac97_write(ac97, AC97_RESET, 0); /* reset to defaults */ | 1892 | /* reset to defaults */ |
1893 | if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO)) | ||
1894 | snd_ac97_write(ac97, AC97_RESET, 0); | ||
1895 | if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) | ||
1896 | snd_ac97_write(ac97, AC97_EXTENDED_MID, 0); | ||
1876 | if (bus->ops->wait) | 1897 | if (bus->ops->wait) |
1877 | bus->ops->wait(ac97); | 1898 | bus->ops->wait(ac97); |
1878 | else { | 1899 | else { |
@@ -1964,21 +1985,21 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97) | |||
1964 | /* note: it's important to set the rate at first */ | 1985 | /* note: it's important to set the rate at first */ |
1965 | tmp = AC97_MEA_GPIO; | 1986 | tmp = AC97_MEA_GPIO; |
1966 | if (ac97->ext_mid & AC97_MEI_LINE1) { | 1987 | if (ac97->ext_mid & AC97_MEI_LINE1) { |
1967 | snd_ac97_write_cache(ac97, AC97_LINE1_RATE, 12000); | 1988 | snd_ac97_write_cache(ac97, AC97_LINE1_RATE, 8000); |
1968 | tmp |= AC97_MEA_ADC1 | AC97_MEA_DAC1; | 1989 | tmp |= AC97_MEA_ADC1 | AC97_MEA_DAC1; |
1969 | } | 1990 | } |
1970 | if (ac97->ext_mid & AC97_MEI_LINE2) { | 1991 | if (ac97->ext_mid & AC97_MEI_LINE2) { |
1971 | snd_ac97_write_cache(ac97, AC97_LINE2_RATE, 12000); | 1992 | snd_ac97_write_cache(ac97, AC97_LINE2_RATE, 8000); |
1972 | tmp |= AC97_MEA_ADC2 | AC97_MEA_DAC2; | 1993 | tmp |= AC97_MEA_ADC2 | AC97_MEA_DAC2; |
1973 | } | 1994 | } |
1974 | if (ac97->ext_mid & AC97_MEI_HANDSET) { | 1995 | if (ac97->ext_mid & AC97_MEI_HANDSET) { |
1975 | snd_ac97_write_cache(ac97, AC97_HANDSET_RATE, 12000); | 1996 | snd_ac97_write_cache(ac97, AC97_HANDSET_RATE, 8000); |
1976 | tmp |= AC97_MEA_HADC | AC97_MEA_HDAC; | 1997 | tmp |= AC97_MEA_HADC | AC97_MEA_HDAC; |
1977 | } | 1998 | } |
1978 | snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xff00 & ~(tmp << 8)); | 1999 | snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0); |
1979 | udelay(100); | 2000 | udelay(100); |
1980 | /* nothing should be in powerdown mode */ | 2001 | /* nothing should be in powerdown mode */ |
1981 | snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xff00 & ~(tmp << 8)); | 2002 | snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0); |
1982 | end_time = jiffies + (HZ / 10); | 2003 | end_time = jiffies + (HZ / 10); |
1983 | do { | 2004 | do { |
1984 | if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp) | 2005 | if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp) |
@@ -2521,11 +2542,11 @@ int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, const char *o | |||
2521 | return result; | 2542 | return result; |
2522 | } | 2543 | } |
2523 | 2544 | ||
2524 | for (; quirk->vendor; quirk++) { | 2545 | for (; quirk->subvendor; quirk++) { |
2525 | if (quirk->vendor != ac97->subsystem_vendor) | 2546 | if (quirk->subvendor != ac97->subsystem_vendor) |
2526 | continue; | 2547 | continue; |
2527 | if ((! quirk->mask && quirk->device == ac97->subsystem_device) || | 2548 | if ((! quirk->mask && quirk->subdevice == ac97->subsystem_device) || |
2528 | quirk->device == (quirk->mask & ac97->subsystem_device)) { | 2549 | quirk->subdevice == (quirk->mask & ac97->subsystem_device)) { |
2529 | if (quirk->codec_id && quirk->codec_id != ac97->id) | 2550 | if (quirk->codec_id && quirk->codec_id != ac97->id) |
2530 | continue; | 2551 | continue; |
2531 | snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device); | 2552 | snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device); |
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 13c34a5d8206..a15eb8522b7c 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c | |||
@@ -64,6 +64,116 @@ static int ac97_update_bits_page(ac97_t *ac97, unsigned short reg, unsigned shor | |||
64 | return ret; | 64 | return ret; |
65 | } | 65 | } |
66 | 66 | ||
67 | /* | ||
68 | * shared line-in/mic controls | ||
69 | */ | ||
70 | static int ac97_enum_text_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo, | ||
71 | const char **texts, unsigned int nums) | ||
72 | { | ||
73 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
74 | uinfo->count = 1; | ||
75 | uinfo->value.enumerated.items = nums; | ||
76 | if (uinfo->value.enumerated.item > nums - 1) | ||
77 | uinfo->value.enumerated.item = nums - 1; | ||
78 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static int ac97_surround_jack_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
83 | { | ||
84 | static const char *texts[] = { "Shared", "Independent" }; | ||
85 | return ac97_enum_text_info(kcontrol, uinfo, texts, 2); | ||
86 | } | ||
87 | |||
88 | static int ac97_surround_jack_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
89 | { | ||
90 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
91 | |||
92 | ucontrol->value.enumerated.item[0] = ac97->indep_surround; | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static int ac97_surround_jack_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
97 | { | ||
98 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
99 | unsigned char indep = !!ucontrol->value.enumerated.item[0]; | ||
100 | |||
101 | if (indep != ac97->indep_surround) { | ||
102 | ac97->indep_surround = indep; | ||
103 | if (ac97->build_ops->update_jacks) | ||
104 | ac97->build_ops->update_jacks(ac97); | ||
105 | return 1; | ||
106 | } | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static int ac97_channel_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
111 | { | ||
112 | static const char *texts[] = { "2ch", "4ch", "6ch" }; | ||
113 | if (kcontrol->private_value) | ||
114 | return ac97_enum_text_info(kcontrol, uinfo, texts, 2); /* 4ch only */ | ||
115 | return ac97_enum_text_info(kcontrol, uinfo, texts, 3); | ||
116 | } | ||
117 | |||
118 | static int ac97_channel_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
119 | { | ||
120 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
121 | |||
122 | ucontrol->value.enumerated.item[0] = ac97->channel_mode; | ||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | static int ac97_channel_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
127 | { | ||
128 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
129 | unsigned char mode = ucontrol->value.enumerated.item[0]; | ||
130 | |||
131 | if (mode != ac97->channel_mode) { | ||
132 | ac97->channel_mode = mode; | ||
133 | if (ac97->build_ops->update_jacks) | ||
134 | ac97->build_ops->update_jacks(ac97); | ||
135 | return 1; | ||
136 | } | ||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | #define AC97_SURROUND_JACK_MODE_CTL \ | ||
141 | { \ | ||
142 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
143 | .name = "Surround Jack Mode", \ | ||
144 | .info = ac97_surround_jack_mode_info, \ | ||
145 | .get = ac97_surround_jack_mode_get, \ | ||
146 | .put = ac97_surround_jack_mode_put, \ | ||
147 | } | ||
148 | #define AC97_CHANNEL_MODE_CTL \ | ||
149 | { \ | ||
150 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
151 | .name = "Channel Mode", \ | ||
152 | .info = ac97_channel_mode_info, \ | ||
153 | .get = ac97_channel_mode_get, \ | ||
154 | .put = ac97_channel_mode_put, \ | ||
155 | } | ||
156 | #define AC97_CHANNEL_MODE_4CH_CTL \ | ||
157 | { \ | ||
158 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
159 | .name = "Channel Mode", \ | ||
160 | .info = ac97_channel_mode_info, \ | ||
161 | .get = ac97_channel_mode_get, \ | ||
162 | .put = ac97_channel_mode_put, \ | ||
163 | .private_value = 1, \ | ||
164 | } | ||
165 | |||
166 | static inline int is_shared_linein(ac97_t *ac97) | ||
167 | { | ||
168 | return ! ac97->indep_surround && ac97->channel_mode >= 1; | ||
169 | } | ||
170 | |||
171 | static inline int is_shared_micin(ac97_t *ac97) | ||
172 | { | ||
173 | return ! ac97->indep_surround && ac97->channel_mode >= 2; | ||
174 | } | ||
175 | |||
176 | |||
67 | /* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ | 177 | /* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ |
68 | 178 | ||
69 | /* It is possible to indicate to the Yamaha YMF753 the type of speakers being used. */ | 179 | /* It is possible to indicate to the Yamaha YMF753 the type of speakers being used. */ |
@@ -1390,6 +1500,16 @@ static int snd_ac97_ad1888_downmix_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va | |||
1390 | AC97_AD198X_DMIX0 | AC97_AD198X_DMIX1, val); | 1500 | AC97_AD198X_DMIX0 | AC97_AD198X_DMIX1, val); |
1391 | } | 1501 | } |
1392 | 1502 | ||
1503 | static void ad1888_update_jacks(ac97_t *ac97) | ||
1504 | { | ||
1505 | /* shared Line-In */ | ||
1506 | snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 12, | ||
1507 | is_shared_linein(ac97) ? 0 : 1 << 12); | ||
1508 | /* shared Mic */ | ||
1509 | snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 11, | ||
1510 | is_shared_micin(ac97) ? 0 : 1 << 11); | ||
1511 | } | ||
1512 | |||
1393 | static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = { | 1513 | static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = { |
1394 | { | 1514 | { |
1395 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1515 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
@@ -1406,8 +1526,8 @@ static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = { | |||
1406 | .get = snd_ac97_ad1888_downmix_get, | 1526 | .get = snd_ac97_ad1888_downmix_get, |
1407 | .put = snd_ac97_ad1888_downmix_put | 1527 | .put = snd_ac97_ad1888_downmix_put |
1408 | }, | 1528 | }, |
1409 | AC97_SINGLE("Surround Jack as Input", AC97_AD_MISC, 12, 1, 0), | 1529 | AC97_SURROUND_JACK_MODE_CTL, |
1410 | AC97_SINGLE("Center/LFE Jack as Input", AC97_AD_MISC, 11, 1, 0), | 1530 | AC97_CHANNEL_MODE_CTL, |
1411 | }; | 1531 | }; |
1412 | 1532 | ||
1413 | static int patch_ad1888_specific(ac97_t *ac97) | 1533 | static int patch_ad1888_specific(ac97_t *ac97) |
@@ -1422,8 +1542,9 @@ static struct snd_ac97_build_ops patch_ad1888_build_ops = { | |||
1422 | .build_post_spdif = patch_ad198x_post_spdif, | 1542 | .build_post_spdif = patch_ad198x_post_spdif, |
1423 | .build_specific = patch_ad1888_specific, | 1543 | .build_specific = patch_ad1888_specific, |
1424 | #ifdef CONFIG_PM | 1544 | #ifdef CONFIG_PM |
1425 | .resume = ad18xx_resume | 1545 | .resume = ad18xx_resume, |
1426 | #endif | 1546 | #endif |
1547 | .update_jacks = ad1888_update_jacks, | ||
1427 | }; | 1548 | }; |
1428 | 1549 | ||
1429 | int patch_ad1888(ac97_t * ac97) | 1550 | int patch_ad1888(ac97_t * ac97) |
@@ -1459,8 +1580,9 @@ static struct snd_ac97_build_ops patch_ad1980_build_ops = { | |||
1459 | .build_post_spdif = patch_ad198x_post_spdif, | 1580 | .build_post_spdif = patch_ad198x_post_spdif, |
1460 | .build_specific = patch_ad1980_specific, | 1581 | .build_specific = patch_ad1980_specific, |
1461 | #ifdef CONFIG_PM | 1582 | #ifdef CONFIG_PM |
1462 | .resume = ad18xx_resume | 1583 | .resume = ad18xx_resume, |
1463 | #endif | 1584 | #endif |
1585 | .update_jacks = ad1888_update_jacks, | ||
1464 | }; | 1586 | }; |
1465 | 1587 | ||
1466 | int patch_ad1980(ac97_t * ac97) | 1588 | int patch_ad1980(ac97_t * ac97) |
@@ -1471,10 +1593,21 @@ int patch_ad1980(ac97_t * ac97) | |||
1471 | } | 1593 | } |
1472 | 1594 | ||
1473 | static const snd_kcontrol_new_t snd_ac97_ad1985_controls[] = { | 1595 | static const snd_kcontrol_new_t snd_ac97_ad1985_controls[] = { |
1474 | AC97_SINGLE("Center/LFE Jack as Mic", AC97_AD_SERIAL_CFG, 9, 1, 0), | ||
1475 | AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0) | 1596 | AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0) |
1476 | }; | 1597 | }; |
1477 | 1598 | ||
1599 | static void ad1985_update_jacks(ac97_t *ac97) | ||
1600 | { | ||
1601 | /* shared Line-In */ | ||
1602 | snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 12, | ||
1603 | is_shared_linein(ac97) ? 0 : 1 << 12); | ||
1604 | /* shared Mic */ | ||
1605 | snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 11, | ||
1606 | is_shared_micin(ac97) ? 0 : 1 << 11); | ||
1607 | snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9, | ||
1608 | is_shared_micin(ac97) ? 0 : 1 << 9); | ||
1609 | } | ||
1610 | |||
1478 | static int patch_ad1985_specific(ac97_t *ac97) | 1611 | static int patch_ad1985_specific(ac97_t *ac97) |
1479 | { | 1612 | { |
1480 | int err; | 1613 | int err; |
@@ -1488,8 +1621,9 @@ static struct snd_ac97_build_ops patch_ad1985_build_ops = { | |||
1488 | .build_post_spdif = patch_ad198x_post_spdif, | 1621 | .build_post_spdif = patch_ad198x_post_spdif, |
1489 | .build_specific = patch_ad1985_specific, | 1622 | .build_specific = patch_ad1985_specific, |
1490 | #ifdef CONFIG_PM | 1623 | #ifdef CONFIG_PM |
1491 | .resume = ad18xx_resume | 1624 | .resume = ad18xx_resume, |
1492 | #endif | 1625 | #endif |
1626 | .update_jacks = ad1985_update_jacks, | ||
1493 | }; | 1627 | }; |
1494 | 1628 | ||
1495 | int patch_ad1985(ac97_t * ac97) | 1629 | int patch_ad1985(ac97_t * ac97) |
@@ -1521,31 +1655,25 @@ int patch_ad1985(ac97_t * ac97) | |||
1521 | /* | 1655 | /* |
1522 | * realtek ALC65x/850 codecs | 1656 | * realtek ALC65x/850 codecs |
1523 | */ | 1657 | */ |
1524 | static int snd_ac97_alc650_mic_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) | 1658 | static void alc650_update_jacks(ac97_t *ac97) |
1525 | { | ||
1526 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
1527 | ucontrol->value.integer.value[0] = (ac97->regs[AC97_ALC650_MULTICH] >> 10) & 1; | ||
1528 | return 0; | ||
1529 | } | ||
1530 | |||
1531 | static int snd_ac97_alc650_mic_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
1532 | { | 1659 | { |
1533 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 1660 | int shared; |
1534 | int change, val; | 1661 | |
1535 | val = !!(snd_ac97_read(ac97, AC97_ALC650_MULTICH) & (1 << 10)); | 1662 | /* shared Line-In */ |
1536 | change = (ucontrol->value.integer.value[0] != val); | 1663 | shared = is_shared_linein(ac97); |
1537 | if (change) { | 1664 | snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9, |
1538 | /* disable/enable vref */ | 1665 | shared ? (1 << 9) : 0); |
1539 | snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12, | 1666 | /* update shared Mic */ |
1540 | ucontrol->value.integer.value[0] ? (1 << 12) : 0); | 1667 | shared = is_shared_micin(ac97); |
1541 | /* turn on/off center-on-mic */ | 1668 | /* disable/enable vref */ |
1542 | snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10, | 1669 | snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12, |
1543 | ucontrol->value.integer.value[0] ? (1 << 10) : 0); | 1670 | shared ? (1 << 12) : 0); |
1544 | /* GPIO0 high for mic */ | 1671 | /* turn on/off center-on-mic */ |
1545 | snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100, | 1672 | snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10, |
1546 | ucontrol->value.integer.value[0] ? 0 : 0x100); | 1673 | shared ? (1 << 10) : 0); |
1547 | } | 1674 | /* GPIO0 high for mic */ |
1548 | return change; | 1675 | snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100, |
1676 | shared ? 0 : 0x100); | ||
1549 | } | 1677 | } |
1550 | 1678 | ||
1551 | static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = { | 1679 | static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = { |
@@ -1558,8 +1686,8 @@ static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = { | |||
1558 | /* 6: Independent Master Volume Right */ | 1686 | /* 6: Independent Master Volume Right */ |
1559 | /* 7: Independent Master Volume Left */ | 1687 | /* 7: Independent Master Volume Left */ |
1560 | /* 8: reserved */ | 1688 | /* 8: reserved */ |
1561 | AC97_SINGLE("Line-In As Surround", AC97_ALC650_MULTICH, 9, 1, 0), | 1689 | /* 9: Line-In/Surround share */ |
1562 | /* 10: mic, see below */ | 1690 | /* 10: Mic/CLFE share */ |
1563 | /* 11-13: in IEC958 controls */ | 1691 | /* 11-13: in IEC958 controls */ |
1564 | AC97_SINGLE("Swap Surround Slot", AC97_ALC650_MULTICH, 14, 1, 0), | 1692 | AC97_SINGLE("Swap Surround Slot", AC97_ALC650_MULTICH, 14, 1, 0), |
1565 | #if 0 /* always set in patch_alc650 */ | 1693 | #if 0 /* always set in patch_alc650 */ |
@@ -1570,14 +1698,8 @@ static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = { | |||
1570 | AC97_SINGLE("Center/LFE DAC Switch", AC97_ALC650_LFE_DAC_VOL, 15, 1, 1), | 1698 | AC97_SINGLE("Center/LFE DAC Switch", AC97_ALC650_LFE_DAC_VOL, 15, 1, 1), |
1571 | AC97_DOUBLE("Center/LFE DAC Volume", AC97_ALC650_LFE_DAC_VOL, 8, 0, 31, 1), | 1699 | AC97_DOUBLE("Center/LFE DAC Volume", AC97_ALC650_LFE_DAC_VOL, 8, 0, 31, 1), |
1572 | #endif | 1700 | #endif |
1573 | { | 1701 | AC97_SURROUND_JACK_MODE_CTL, |
1574 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1702 | AC97_CHANNEL_MODE_CTL, |
1575 | .name = "Mic As Center/LFE", | ||
1576 | .info = snd_ac97_info_volsw, | ||
1577 | .get = snd_ac97_alc650_mic_get, | ||
1578 | .put = snd_ac97_alc650_mic_put, | ||
1579 | .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */ | ||
1580 | }, | ||
1581 | }; | 1703 | }; |
1582 | 1704 | ||
1583 | static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc650[] = { | 1705 | static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc650[] = { |
@@ -1601,7 +1723,8 @@ static int patch_alc650_specific(ac97_t * ac97) | |||
1601 | } | 1723 | } |
1602 | 1724 | ||
1603 | static struct snd_ac97_build_ops patch_alc650_ops = { | 1725 | static struct snd_ac97_build_ops patch_alc650_ops = { |
1604 | .build_specific = patch_alc650_specific | 1726 | .build_specific = patch_alc650_specific, |
1727 | .update_jacks = alc650_update_jacks | ||
1605 | }; | 1728 | }; |
1606 | 1729 | ||
1607 | int patch_alc650(ac97_t * ac97) | 1730 | int patch_alc650(ac97_t * ac97) |
@@ -1659,37 +1782,27 @@ int patch_alc650(ac97_t * ac97) | |||
1659 | return 0; | 1782 | return 0; |
1660 | } | 1783 | } |
1661 | 1784 | ||
1662 | static int snd_ac97_alc655_mic_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) | 1785 | static void alc655_update_jacks(ac97_t *ac97) |
1663 | { | ||
1664 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
1665 | ucontrol->value.integer.value[0] = (ac97->regs[AC97_ALC650_MULTICH] >> 10) & 1; | ||
1666 | return 0; | ||
1667 | } | ||
1668 | |||
1669 | static int snd_ac97_alc655_mic_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
1670 | { | 1786 | { |
1671 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 1787 | int shared; |
1672 | 1788 | ||
1789 | /* shared Line-In */ | ||
1790 | shared = is_shared_linein(ac97); | ||
1791 | ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9, | ||
1792 | shared ? (1 << 9) : 0, 0); | ||
1793 | /* update shared mic */ | ||
1794 | shared = is_shared_micin(ac97); | ||
1673 | /* misc control; vrefout disable */ | 1795 | /* misc control; vrefout disable */ |
1674 | snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12, | 1796 | snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12, |
1675 | ucontrol->value.integer.value[0] ? (1 << 12) : 0); | 1797 | shared ? (1 << 12) : 0); |
1676 | return ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 10, | 1798 | ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 10, |
1677 | ucontrol->value.integer.value[0] ? (1 << 10) : 0, | 1799 | shared ? (1 << 10) : 0, 0); |
1678 | 0); | ||
1679 | } | 1800 | } |
1680 | 1801 | ||
1681 | |||
1682 | static const snd_kcontrol_new_t snd_ac97_controls_alc655[] = { | 1802 | static const snd_kcontrol_new_t snd_ac97_controls_alc655[] = { |
1683 | AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), | 1803 | AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), |
1684 | AC97_PAGE_SINGLE("Line-In As Surround", AC97_ALC650_MULTICH, 9, 1, 0, 0), | 1804 | AC97_SURROUND_JACK_MODE_CTL, |
1685 | { | 1805 | AC97_CHANNEL_MODE_CTL, |
1686 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1687 | .name = "Mic As Center/LFE", | ||
1688 | .info = snd_ac97_info_volsw, | ||
1689 | .get = snd_ac97_alc655_mic_get, | ||
1690 | .put = snd_ac97_alc655_mic_put, | ||
1691 | .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */ | ||
1692 | }, | ||
1693 | }; | 1806 | }; |
1694 | 1807 | ||
1695 | static int alc655_iec958_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | 1808 | static int alc655_iec958_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) |
@@ -1759,7 +1872,8 @@ static int patch_alc655_specific(ac97_t * ac97) | |||
1759 | } | 1872 | } |
1760 | 1873 | ||
1761 | static struct snd_ac97_build_ops patch_alc655_ops = { | 1874 | static struct snd_ac97_build_ops patch_alc655_ops = { |
1762 | .build_specific = patch_alc655_specific | 1875 | .build_specific = patch_alc655_specific, |
1876 | .update_jacks = alc655_update_jacks | ||
1763 | }; | 1877 | }; |
1764 | 1878 | ||
1765 | int patch_alc655(ac97_t * ac97) | 1879 | int patch_alc655(ac97_t * ac97) |
@@ -1798,63 +1912,33 @@ int patch_alc655(ac97_t * ac97) | |||
1798 | #define AC97_ALC850_JACK_SELECT 0x76 | 1912 | #define AC97_ALC850_JACK_SELECT 0x76 |
1799 | #define AC97_ALC850_MISC1 0x7a | 1913 | #define AC97_ALC850_MISC1 0x7a |
1800 | 1914 | ||
1801 | static int ac97_alc850_surround_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) | 1915 | static void alc850_update_jacks(ac97_t *ac97) |
1802 | { | ||
1803 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
1804 | ucontrol->value.integer.value[0] = ((ac97->regs[AC97_ALC850_JACK_SELECT] >> 12) & 7) == 2; | ||
1805 | return 0; | ||
1806 | } | ||
1807 | |||
1808 | static int ac97_alc850_surround_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
1809 | { | 1916 | { |
1810 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 1917 | int shared; |
1811 | 1918 | ||
1919 | /* shared Line-In */ | ||
1920 | shared = is_shared_linein(ac97); | ||
1812 | /* SURR 1kOhm (bit4), Amp (bit5) */ | 1921 | /* SURR 1kOhm (bit4), Amp (bit5) */ |
1813 | snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5), | 1922 | snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5), |
1814 | ucontrol->value.integer.value[0] ? (1<<5) : (1<<4)); | 1923 | shared ? (1<<5) : (1<<4)); |
1815 | /* LINE-IN = 0, SURROUND = 2 */ | 1924 | /* LINE-IN = 0, SURROUND = 2 */ |
1816 | return snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12, | 1925 | snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12, |
1817 | ucontrol->value.integer.value[0] ? (2<<12) : (0<<12)); | 1926 | shared ? (2<<12) : (0<<12)); |
1818 | } | 1927 | /* update shared mic */ |
1819 | 1928 | shared = is_shared_micin(ac97); | |
1820 | static int ac97_alc850_mic_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
1821 | { | ||
1822 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
1823 | ucontrol->value.integer.value[0] = ((ac97->regs[AC97_ALC850_JACK_SELECT] >> 4) & 7) == 2; | ||
1824 | return 0; | ||
1825 | } | ||
1826 | |||
1827 | static int ac97_alc850_mic_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
1828 | { | ||
1829 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
1830 | |||
1831 | /* Vref disable (bit12), 1kOhm (bit13) */ | 1929 | /* Vref disable (bit12), 1kOhm (bit13) */ |
1832 | snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13), | 1930 | snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13), |
1833 | ucontrol->value.integer.value[0] ? (1<<12) : (1<<13)); | 1931 | shared ? (1<<12) : (1<<13)); |
1834 | /* MIC-IN = 1, CENTER-LFE = 2 */ | 1932 | /* MIC-IN = 1, CENTER-LFE = 2 */ |
1835 | return snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4, | 1933 | snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4, |
1836 | ucontrol->value.integer.value[0] ? (2<<4) : (1<<4)); | 1934 | shared ? (2<<4) : (1<<4)); |
1837 | } | 1935 | } |
1838 | 1936 | ||
1839 | static const snd_kcontrol_new_t snd_ac97_controls_alc850[] = { | 1937 | static const snd_kcontrol_new_t snd_ac97_controls_alc850[] = { |
1840 | AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), | 1938 | AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), |
1841 | { | 1939 | AC97_SINGLE("Mic Front Input Switch", AC97_ALC850_JACK_SELECT, 15, 1, 1), |
1842 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1940 | AC97_SURROUND_JACK_MODE_CTL, |
1843 | .name = "Line-In As Surround", | 1941 | AC97_CHANNEL_MODE_CTL, |
1844 | .info = snd_ac97_info_volsw, | ||
1845 | .get = ac97_alc850_surround_get, | ||
1846 | .put = ac97_alc850_surround_put, | ||
1847 | .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */ | ||
1848 | }, | ||
1849 | { | ||
1850 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1851 | .name = "Mic As Center/LFE", | ||
1852 | .info = snd_ac97_info_volsw, | ||
1853 | .get = ac97_alc850_mic_get, | ||
1854 | .put = ac97_alc850_mic_put, | ||
1855 | .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */ | ||
1856 | }, | ||
1857 | |||
1858 | }; | 1942 | }; |
1859 | 1943 | ||
1860 | static int patch_alc850_specific(ac97_t *ac97) | 1944 | static int patch_alc850_specific(ac97_t *ac97) |
@@ -1871,7 +1955,8 @@ static int patch_alc850_specific(ac97_t *ac97) | |||
1871 | } | 1955 | } |
1872 | 1956 | ||
1873 | static struct snd_ac97_build_ops patch_alc850_ops = { | 1957 | static struct snd_ac97_build_ops patch_alc850_ops = { |
1874 | .build_specific = patch_alc850_specific | 1958 | .build_specific = patch_alc850_specific, |
1959 | .update_jacks = alc850_update_jacks | ||
1875 | }; | 1960 | }; |
1876 | 1961 | ||
1877 | int patch_alc850(ac97_t *ac97) | 1962 | int patch_alc850(ac97_t *ac97) |
@@ -1911,9 +1996,17 @@ int patch_alc850(ac97_t *ac97) | |||
1911 | /* | 1996 | /* |
1912 | * C-Media CM97xx codecs | 1997 | * C-Media CM97xx codecs |
1913 | */ | 1998 | */ |
1999 | static void cm9738_update_jacks(ac97_t *ac97) | ||
2000 | { | ||
2001 | /* shared Line-In */ | ||
2002 | snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10, | ||
2003 | is_shared_linein(ac97) ? (1 << 10) : 0); | ||
2004 | } | ||
2005 | |||
1914 | static const snd_kcontrol_new_t snd_ac97_cm9738_controls[] = { | 2006 | static const snd_kcontrol_new_t snd_ac97_cm9738_controls[] = { |
1915 | AC97_SINGLE("Line-In As Surround", AC97_CM9738_VENDOR_CTRL, 10, 1, 0), | ||
1916 | AC97_SINGLE("Duplicate Front", AC97_CM9738_VENDOR_CTRL, 13, 1, 0), | 2007 | AC97_SINGLE("Duplicate Front", AC97_CM9738_VENDOR_CTRL, 13, 1, 0), |
2008 | AC97_SURROUND_JACK_MODE_CTL, | ||
2009 | AC97_CHANNEL_MODE_4CH_CTL, | ||
1917 | }; | 2010 | }; |
1918 | 2011 | ||
1919 | static int patch_cm9738_specific(ac97_t * ac97) | 2012 | static int patch_cm9738_specific(ac97_t * ac97) |
@@ -1922,7 +2015,8 @@ static int patch_cm9738_specific(ac97_t * ac97) | |||
1922 | } | 2015 | } |
1923 | 2016 | ||
1924 | static struct snd_ac97_build_ops patch_cm9738_ops = { | 2017 | static struct snd_ac97_build_ops patch_cm9738_ops = { |
1925 | .build_specific = patch_cm9738_specific | 2018 | .build_specific = patch_cm9738_specific, |
2019 | .update_jacks = cm9738_update_jacks | ||
1926 | }; | 2020 | }; |
1927 | 2021 | ||
1928 | int patch_cm9738(ac97_t * ac97) | 2022 | int patch_cm9738(ac97_t * ac97) |
@@ -1986,34 +2080,19 @@ static const snd_kcontrol_new_t snd_ac97_cm9739_controls_spdif[] = { | |||
1986 | /* BIT 8: SPD32 - 32bit SPDIF - not supported yet */ | 2080 | /* BIT 8: SPD32 - 32bit SPDIF - not supported yet */ |
1987 | }; | 2081 | }; |
1988 | 2082 | ||
1989 | static int snd_ac97_cm9739_center_mic_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 2083 | static void cm9739_update_jacks(ac97_t *ac97) |
1990 | { | ||
1991 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
1992 | if (ac97->regs[AC97_CM9739_MULTI_CHAN] & 0x1000) | ||
1993 | ucontrol->value.integer.value[0] = 1; | ||
1994 | else | ||
1995 | ucontrol->value.integer.value[0] = 0; | ||
1996 | return 0; | ||
1997 | } | ||
1998 | |||
1999 | static int snd_ac97_cm9739_center_mic_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
2000 | { | 2084 | { |
2001 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 2085 | /* shared Line-In */ |
2002 | return snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000, | 2086 | snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10, |
2003 | ucontrol->value.integer.value[0] ? | 2087 | is_shared_linein(ac97) ? (1 << 10) : 0); |
2004 | 0x1000 : 0x2000); | 2088 | /* shared Mic */ |
2089 | snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000, | ||
2090 | is_shared_micin(ac97) ? 0x1000 : 0x2000); | ||
2005 | } | 2091 | } |
2006 | 2092 | ||
2007 | static const snd_kcontrol_new_t snd_ac97_cm9739_controls[] = { | 2093 | static const snd_kcontrol_new_t snd_ac97_cm9739_controls[] = { |
2008 | AC97_SINGLE("Line-In As Surround", AC97_CM9739_MULTI_CHAN, 10, 1, 0), | 2094 | AC97_SURROUND_JACK_MODE_CTL, |
2009 | { | 2095 | AC97_CHANNEL_MODE_CTL, |
2010 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2011 | .name = "Mic As Center/LFE", | ||
2012 | .info = snd_ac97_info_volsw, | ||
2013 | .get = snd_ac97_cm9739_center_mic_get, | ||
2014 | .put = snd_ac97_cm9739_center_mic_put, | ||
2015 | .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */ | ||
2016 | }, | ||
2017 | }; | 2096 | }; |
2018 | 2097 | ||
2019 | static int patch_cm9739_specific(ac97_t * ac97) | 2098 | static int patch_cm9739_specific(ac97_t * ac97) |
@@ -2028,7 +2107,8 @@ static int patch_cm9739_post_spdif(ac97_t * ac97) | |||
2028 | 2107 | ||
2029 | static struct snd_ac97_build_ops patch_cm9739_ops = { | 2108 | static struct snd_ac97_build_ops patch_cm9739_ops = { |
2030 | .build_specific = patch_cm9739_specific, | 2109 | .build_specific = patch_cm9739_specific, |
2031 | .build_post_spdif = patch_cm9739_post_spdif | 2110 | .build_post_spdif = patch_cm9739_post_spdif, |
2111 | .update_jacks = cm9739_update_jacks | ||
2032 | }; | 2112 | }; |
2033 | 2113 | ||
2034 | int patch_cm9739(ac97_t * ac97) | 2114 | int patch_cm9739(ac97_t * ac97) |
@@ -2087,71 +2167,97 @@ int patch_cm9739(ac97_t * ac97) | |||
2087 | } | 2167 | } |
2088 | 2168 | ||
2089 | #define AC97_CM9761_MULTI_CHAN 0x64 | 2169 | #define AC97_CM9761_MULTI_CHAN 0x64 |
2170 | #define AC97_CM9761_FUNC 0x66 | ||
2090 | #define AC97_CM9761_SPDIF_CTRL 0x6c | 2171 | #define AC97_CM9761_SPDIF_CTRL 0x6c |
2091 | 2172 | ||
2092 | static int snd_ac97_cm9761_linein_rear_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 2173 | static void cm9761_update_jacks(ac97_t *ac97) |
2093 | { | ||
2094 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | ||
2095 | if (ac97->regs[AC97_CM9739_MULTI_CHAN] & 0x0400) | ||
2096 | ucontrol->value.integer.value[0] = 1; | ||
2097 | else | ||
2098 | ucontrol->value.integer.value[0] = 0; | ||
2099 | return 0; | ||
2100 | } | ||
2101 | |||
2102 | static int snd_ac97_cm9761_linein_rear_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
2103 | { | 2174 | { |
2104 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 2175 | unsigned short surr_vals[2][2] = { |
2105 | unsigned short vals[2][2] = { | ||
2106 | { 0x0008, 0x0400 }, /* off, on */ | 2176 | { 0x0008, 0x0400 }, /* off, on */ |
2107 | { 0x0000, 0x0408 }, /* off, on (9761-82 rev.B) */ | 2177 | { 0x0000, 0x0408 }, /* off, on (9761-82 rev.B) */ |
2108 | }; | 2178 | }; |
2109 | return snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x0408, | 2179 | unsigned short clfe_vals[2][2] = { |
2110 | vals[ac97->spec.dev_flags][!!ucontrol->value.integer.value[0]]); | 2180 | { 0x2000, 0x1880 }, /* off, on */ |
2181 | { 0x1000, 0x2880 }, /* off, on (9761-82 rev.B) */ | ||
2182 | }; | ||
2183 | |||
2184 | /* shared Line-In */ | ||
2185 | snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x0408, | ||
2186 | surr_vals[ac97->spec.dev_flags][is_shared_linein(ac97)]); | ||
2187 | /* shared Mic */ | ||
2188 | snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3880, | ||
2189 | clfe_vals[ac97->spec.dev_flags][is_shared_micin(ac97)]); | ||
2190 | } | ||
2191 | |||
2192 | static const snd_kcontrol_new_t snd_ac97_cm9761_controls[] = { | ||
2193 | AC97_SURROUND_JACK_MODE_CTL, | ||
2194 | AC97_CHANNEL_MODE_CTL, | ||
2195 | }; | ||
2196 | |||
2197 | static int cm9761_spdif_out_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
2198 | { | ||
2199 | static char *texts[] = { "AC-Link", "ADC", "SPDIF-In" }; | ||
2200 | |||
2201 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2202 | uinfo->count = 1; | ||
2203 | uinfo->value.enumerated.items = 3; | ||
2204 | if (uinfo->value.enumerated.item > 2) | ||
2205 | uinfo->value.enumerated.item = 2; | ||
2206 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
2207 | return 0; | ||
2111 | } | 2208 | } |
2112 | 2209 | ||
2113 | static int snd_ac97_cm9761_center_mic_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 2210 | static int cm9761_spdif_out_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
2114 | { | 2211 | { |
2115 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 2212 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); |
2116 | if (ac97->regs[AC97_CM9739_MULTI_CHAN] & 0x1000) | 2213 | |
2117 | ucontrol->value.integer.value[0] = 1; | 2214 | if (ac97->regs[AC97_CM9761_FUNC] & 0x1) |
2215 | ucontrol->value.enumerated.item[0] = 2; /* SPDIF-loopback */ | ||
2216 | else if (ac97->regs[AC97_CM9761_SPDIF_CTRL] & 0x2) | ||
2217 | ucontrol->value.enumerated.item[0] = 1; /* ADC loopback */ | ||
2118 | else | 2218 | else |
2119 | ucontrol->value.integer.value[0] = 0; | 2219 | ucontrol->value.enumerated.item[0] = 0; /* AC-link */ |
2120 | if (ac97->spec.dev_flags) /* 9761-82 rev.B */ | ||
2121 | ucontrol->value.integer.value[0] = !ucontrol->value.integer.value[0]; | ||
2122 | return 0; | 2220 | return 0; |
2123 | } | 2221 | } |
2124 | 2222 | ||
2125 | static int snd_ac97_cm9761_center_mic_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 2223 | static int cm9761_spdif_out_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
2126 | { | 2224 | { |
2127 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); | 2225 | ac97_t *ac97 = snd_kcontrol_chip(kcontrol); |
2128 | unsigned short vals[2][2] = { | 2226 | |
2129 | { 0x2000, 0x1880 }, /* off, on */ | 2227 | if (ucontrol->value.enumerated.item[0] == 2) |
2130 | { 0x1000, 0x2880 }, /* off, on (9761-82 rev.B) */ | 2228 | return snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0x1); |
2131 | }; | 2229 | snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0); |
2132 | return snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3880, | 2230 | return snd_ac97_update_bits(ac97, AC97_CM9761_SPDIF_CTRL, 0x2, |
2133 | vals[ac97->spec.dev_flags][!!ucontrol->value.integer.value[0]]); | 2231 | ucontrol->value.enumerated.item[0] == 1 ? 0x2 : 0); |
2134 | } | 2232 | } |
2135 | 2233 | ||
2136 | static const snd_kcontrol_new_t snd_ac97_cm9761_controls[] = { | 2234 | static const char *cm9761_dac_clock[] = { "AC-Link", "SPDIF-In", "Both" }; |
2137 | { | 2235 | static const struct ac97_enum cm9761_dac_clock_enum = |
2138 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2236 | AC97_ENUM_SINGLE(AC97_CM9761_SPDIF_CTRL, 9, 3, cm9761_dac_clock); |
2139 | .name = "Line-In As Surround", | 2237 | |
2140 | .info = snd_ac97_info_volsw, | 2238 | static const snd_kcontrol_new_t snd_ac97_cm9761_controls_spdif[] = { |
2141 | .get = snd_ac97_cm9761_linein_rear_get, | 2239 | { /* BIT 1: SPDIFS */ |
2142 | .put = snd_ac97_cm9761_linein_rear_put, | 2240 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2143 | .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */ | 2241 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", |
2144 | }, | 2242 | .info = cm9761_spdif_out_source_info, |
2145 | { | 2243 | .get = cm9761_spdif_out_source_get, |
2146 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2244 | .put = cm9761_spdif_out_source_put, |
2147 | .name = "Mic As Center/LFE", | ||
2148 | .info = snd_ac97_info_volsw, | ||
2149 | .get = snd_ac97_cm9761_center_mic_get, | ||
2150 | .put = snd_ac97_cm9761_center_mic_put, | ||
2151 | .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */ | ||
2152 | }, | 2245 | }, |
2246 | /* BIT 2: IG_SPIV */ | ||
2247 | AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Valid Switch", AC97_CM9761_SPDIF_CTRL, 2, 1, 0), | ||
2248 | /* BIT 3: SPI2F */ | ||
2249 | AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Monitor", AC97_CM9761_SPDIF_CTRL, 3, 1, 0), | ||
2250 | /* BIT 4: SPI2SDI */ | ||
2251 | AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), AC97_CM9761_SPDIF_CTRL, 4, 1, 0), | ||
2252 | /* BIT 9-10: DAC_CTL */ | ||
2253 | AC97_ENUM("DAC Clock Source", cm9761_dac_clock_enum), | ||
2153 | }; | 2254 | }; |
2154 | 2255 | ||
2256 | static int patch_cm9761_post_spdif(ac97_t * ac97) | ||
2257 | { | ||
2258 | return patch_build_controls(ac97, snd_ac97_cm9761_controls_spdif, ARRAY_SIZE(snd_ac97_cm9761_controls_spdif)); | ||
2259 | } | ||
2260 | |||
2155 | static int patch_cm9761_specific(ac97_t * ac97) | 2261 | static int patch_cm9761_specific(ac97_t * ac97) |
2156 | { | 2262 | { |
2157 | return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls)); | 2263 | return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls)); |
@@ -2159,7 +2265,8 @@ static int patch_cm9761_specific(ac97_t * ac97) | |||
2159 | 2265 | ||
2160 | static struct snd_ac97_build_ops patch_cm9761_ops = { | 2266 | static struct snd_ac97_build_ops patch_cm9761_ops = { |
2161 | .build_specific = patch_cm9761_specific, | 2267 | .build_specific = patch_cm9761_specific, |
2162 | .build_post_spdif = patch_cm9739_post_spdif /* hope it's identical... */ | 2268 | .build_post_spdif = patch_cm9761_post_spdif, |
2269 | .update_jacks = cm9761_update_jacks | ||
2163 | }; | 2270 | }; |
2164 | 2271 | ||
2165 | int patch_cm9761(ac97_t *ac97) | 2272 | int patch_cm9761(ac97_t *ac97) |
@@ -2193,24 +2300,25 @@ int patch_cm9761(ac97_t *ac97) | |||
2193 | /* to be sure: we overwrite the ext status bits */ | 2300 | /* to be sure: we overwrite the ext status bits */ |
2194 | snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0); | 2301 | snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0); |
2195 | /* Don't set 0x0200 here. This results in the silent analog output */ | 2302 | /* Don't set 0x0200 here. This results in the silent analog output */ |
2196 | snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0009); | 2303 | snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0001); /* enable spdif-in */ |
2197 | ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */ | 2304 | ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */ |
2198 | 2305 | ||
2199 | /* set-up multi channel */ | 2306 | /* set-up multi channel */ |
2200 | /* bit 15: pc master beep off | 2307 | /* bit 15: pc master beep off |
2201 | * bit 14: ?? | 2308 | * bit 14: pin47 = EAPD/SPDIF |
2202 | * bit 13: vref ctl [= cm9739] | 2309 | * bit 13: vref ctl [= cm9739] |
2203 | * bit 12: center/mic [= cm9739] (reverted on rev B) | 2310 | * bit 12: CLFE control (reverted on rev B) |
2204 | * bit 11: ?? (mic/center/lfe) (reverted on rev B) | 2311 | * bit 11: Mic/center share (reverted on rev B) |
2205 | * bit 10: suddound/line [= cm9739] | 2312 | * bit 10: suddound/line share |
2206 | * bit 9: mix 2 surround | 2313 | * bit 9: Analog-in mix -> surround |
2207 | * bit 8: ? | 2314 | * bit 8: Analog-in mix -> CLFE |
2208 | * bit 7: ?? (mic/center/lfe) | 2315 | * bit 7: Mic/LFE share (mic/center/lfe) |
2209 | * bit 4: ?? (front) | 2316 | * bit 5: vref select (9761A) |
2210 | * bit 3: ?? (line-in/rear share) (revereted with rev B) | 2317 | * bit 4: front control |
2211 | * bit 2: ?? (surround) | 2318 | * bit 3: surround control (revereted with rev B) |
2212 | * bit 1: front mic | 2319 | * bit 2: front mic |
2213 | * bit 0: mic boost | 2320 | * bit 1: stereo mic |
2321 | * bit 0: mic boost level (0=20dB, 1=30dB) | ||
2214 | */ | 2322 | */ |
2215 | 2323 | ||
2216 | #if 0 | 2324 | #if 0 |
@@ -2230,6 +2338,47 @@ int patch_cm9761(ac97_t *ac97) | |||
2230 | return 0; | 2338 | return 0; |
2231 | } | 2339 | } |
2232 | 2340 | ||
2341 | #define AC97_CM9780_SIDE 0x60 | ||
2342 | #define AC97_CM9780_JACK 0x62 | ||
2343 | #define AC97_CM9780_MIXER 0x64 | ||
2344 | #define AC97_CM9780_MULTI_CHAN 0x66 | ||
2345 | #define AC97_CM9780_SPDIF 0x6c | ||
2346 | |||
2347 | static const char *cm9780_ch_select[] = { "Front", "Side", "Center/LFE", "Rear" }; | ||
2348 | static const struct ac97_enum cm9780_ch_select_enum = | ||
2349 | AC97_ENUM_SINGLE(AC97_CM9780_MULTI_CHAN, 6, 4, cm9780_ch_select); | ||
2350 | static const snd_kcontrol_new_t cm9780_controls[] = { | ||
2351 | AC97_DOUBLE("Side Playback Switch", AC97_CM9780_SIDE, 15, 7, 1, 1), | ||
2352 | AC97_DOUBLE("Side Playback Volume", AC97_CM9780_SIDE, 8, 0, 31, 0), | ||
2353 | AC97_ENUM("Side Playback Route", cm9780_ch_select_enum), | ||
2354 | }; | ||
2355 | |||
2356 | static int patch_cm9780_specific(ac97_t *ac97) | ||
2357 | { | ||
2358 | return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls)); | ||
2359 | } | ||
2360 | |||
2361 | static struct snd_ac97_build_ops patch_cm9780_ops = { | ||
2362 | .build_specific = patch_cm9780_specific, | ||
2363 | .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */ | ||
2364 | }; | ||
2365 | |||
2366 | int patch_cm9780(ac97_t *ac97) | ||
2367 | { | ||
2368 | unsigned short val; | ||
2369 | |||
2370 | ac97->build_ops = &patch_cm9780_ops; | ||
2371 | |||
2372 | /* enable spdif */ | ||
2373 | if (ac97->ext_id & AC97_EI_SPDIF) { | ||
2374 | ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */ | ||
2375 | val = snd_ac97_read(ac97, AC97_CM9780_SPDIF); | ||
2376 | val |= 0x1; /* SPDI_EN */ | ||
2377 | snd_ac97_write_cache(ac97, AC97_CM9780_SPDIF, val); | ||
2378 | } | ||
2379 | |||
2380 | return 0; | ||
2381 | } | ||
2233 | 2382 | ||
2234 | /* | 2383 | /* |
2235 | * VIA VT1616 codec | 2384 | * VIA VT1616 codec |
@@ -2263,9 +2412,21 @@ int patch_vt1616(ac97_t * ac97) | |||
2263 | return 0; | 2412 | return 0; |
2264 | } | 2413 | } |
2265 | 2414 | ||
2415 | /* | ||
2416 | */ | ||
2417 | static void it2646_update_jacks(ac97_t *ac97) | ||
2418 | { | ||
2419 | /* shared Line-In */ | ||
2420 | snd_ac97_update_bits(ac97, 0x76, 1 << 9, | ||
2421 | is_shared_linein(ac97) ? (1<<9) : 0); | ||
2422 | /* shared Mic */ | ||
2423 | snd_ac97_update_bits(ac97, 0x76, 1 << 10, | ||
2424 | is_shared_micin(ac97) ? (1<<10) : 0); | ||
2425 | } | ||
2426 | |||
2266 | static const snd_kcontrol_new_t snd_ac97_controls_it2646[] = { | 2427 | static const snd_kcontrol_new_t snd_ac97_controls_it2646[] = { |
2267 | AC97_SINGLE("Line-In As Surround", 0x76, 9, 1, 0), | 2428 | AC97_SURROUND_JACK_MODE_CTL, |
2268 | AC97_SINGLE("Mic As Center/LFE", 0x76, 10, 1, 0), | 2429 | AC97_CHANNEL_MODE_CTL, |
2269 | }; | 2430 | }; |
2270 | 2431 | ||
2271 | static const snd_kcontrol_new_t snd_ac97_spdif_controls_it2646[] = { | 2432 | static const snd_kcontrol_new_t snd_ac97_spdif_controls_it2646[] = { |
@@ -2285,7 +2446,8 @@ static int patch_it2646_specific(ac97_t * ac97) | |||
2285 | } | 2446 | } |
2286 | 2447 | ||
2287 | static struct snd_ac97_build_ops patch_it2646_ops = { | 2448 | static struct snd_ac97_build_ops patch_it2646_ops = { |
2288 | .build_specific = patch_it2646_specific | 2449 | .build_specific = patch_it2646_specific, |
2450 | .update_jacks = it2646_update_jacks | ||
2289 | }; | 2451 | }; |
2290 | 2452 | ||
2291 | int patch_it2646(ac97_t * ac97) | 2453 | int patch_it2646(ac97_t * ac97) |
@@ -2297,12 +2459,29 @@ int patch_it2646(ac97_t * ac97) | |||
2297 | return 0; | 2459 | return 0; |
2298 | } | 2460 | } |
2299 | 2461 | ||
2300 | /* Si3036/8 specific registers */ | 2462 | /* |
2463 | * Si3036 codec | ||
2464 | */ | ||
2465 | |||
2301 | #define AC97_SI3036_CHIP_ID 0x5a | 2466 | #define AC97_SI3036_CHIP_ID 0x5a |
2467 | #define AC97_SI3036_LINE_CFG 0x5c | ||
2468 | |||
2469 | static const snd_kcontrol_new_t snd_ac97_controls_si3036[] = { | ||
2470 | AC97_DOUBLE("Modem Speaker Volume", 0x5c, 14, 12, 3, 1) | ||
2471 | }; | ||
2472 | |||
2473 | static int patch_si3036_specific(ac97_t * ac97) | ||
2474 | { | ||
2475 | return patch_build_controls(ac97, snd_ac97_controls_si3036, ARRAY_SIZE(snd_ac97_controls_si3036)); | ||
2476 | } | ||
2477 | |||
2478 | static struct snd_ac97_build_ops patch_si3036_ops = { | ||
2479 | .build_specific = patch_si3036_specific, | ||
2480 | }; | ||
2302 | 2481 | ||
2303 | int mpatch_si3036(ac97_t * ac97) | 2482 | int mpatch_si3036(ac97_t * ac97) |
2304 | { | 2483 | { |
2305 | //printk("mpatch_si3036: chip id = %x\n", snd_ac97_read(ac97, 0x5a)); | 2484 | ac97->build_ops = &patch_si3036_ops; |
2306 | snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); | 2485 | snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); |
2307 | snd_ac97_write_cache(ac97, 0x68, 0); | 2486 | snd_ac97_write_cache(ac97, 0x68, 0); |
2308 | return 0; | 2487 | return 0; |
diff --git a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h index 6db51c96f5d0..7b7377d0f2ae 100644 --- a/sound/pci/ac97/ac97_patch.h +++ b/sound/pci/ac97/ac97_patch.h | |||
@@ -54,6 +54,7 @@ int patch_alc850(ac97_t * ac97); | |||
54 | int patch_cm9738(ac97_t * ac97); | 54 | int patch_cm9738(ac97_t * ac97); |
55 | int patch_cm9739(ac97_t * ac97); | 55 | int patch_cm9739(ac97_t * ac97); |
56 | int patch_cm9761(ac97_t * ac97); | 56 | int patch_cm9761(ac97_t * ac97); |
57 | int patch_cm9780(ac97_t * ac97); | ||
57 | int patch_vt1616(ac97_t * ac97); | 58 | int patch_vt1616(ac97_t * ac97); |
58 | int patch_it2646(ac97_t * ac97); | 59 | int patch_it2646(ac97_t * ac97); |
59 | int mpatch_si3036(ac97_t * ac97); | 60 | int mpatch_si3036(ac97_t * ac97); |
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 984d5d4ba4e1..eb5c36d31a52 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c | |||
@@ -98,6 +98,8 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); | |||
98 | #define ALI_LEF_CHANNEL 23 | 98 | #define ALI_LEF_CHANNEL 23 |
99 | #define ALI_SURR_LEFT_CHANNEL 26 | 99 | #define ALI_SURR_LEFT_CHANNEL 26 |
100 | #define ALI_SURR_RIGHT_CHANNEL 25 | 100 | #define ALI_SURR_RIGHT_CHANNEL 25 |
101 | #define ALI_MODEM_IN_CHANNEL 21 | ||
102 | #define ALI_MODEM_OUT_CHANNEL 20 | ||
101 | 103 | ||
102 | #define SNDRV_ALI_VOICE_TYPE_PCM 01 | 104 | #define SNDRV_ALI_VOICE_TYPE_PCM 01 |
103 | #define SNDRV_ALI_VOICE_TYPE_OTH 02 | 105 | #define SNDRV_ALI_VOICE_TYPE_OTH 02 |
@@ -122,7 +124,15 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); | |||
122 | 124 | ||
123 | #define ALI_SCTRL 0x48 | 125 | #define ALI_SCTRL 0x48 |
124 | #define ALI_SPDIF_OUT_ENABLE 0x20 | 126 | #define ALI_SPDIF_OUT_ENABLE 0x20 |
127 | #define ALI_SCTRL_LINE_IN2 (1 << 9) | ||
128 | #define ALI_SCTRL_GPIO_IN2 (1 << 13) | ||
129 | #define ALI_SCTRL_LINE_OUT_EN (1 << 20) | ||
130 | #define ALI_SCTRL_GPIO_OUT_EN (1 << 23) | ||
131 | #define ALI_SCTRL_CODEC1_READY (1 << 24) | ||
132 | #define ALI_SCTRL_CODEC2_READY (1 << 25) | ||
125 | #define ALI_AC97_GPIO 0x4c | 133 | #define ALI_AC97_GPIO 0x4c |
134 | #define ALI_AC97_GPIO_ENABLE 0x8000 | ||
135 | #define ALI_AC97_GPIO_DATA_SHIFT 16 | ||
126 | #define ALI_SPDIF_CS 0x70 | 136 | #define ALI_SPDIF_CS 0x70 |
127 | #define ALI_SPDIF_CTRL 0x74 | 137 | #define ALI_SPDIF_CTRL 0x74 |
128 | #define ALI_SPDIF_IN_FUNC_ENABLE 0x02 | 138 | #define ALI_SPDIF_IN_FUNC_ENABLE 0x02 |
@@ -143,6 +153,7 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); | |||
143 | #define TARGET_REACHED 0x00008000 | 153 | #define TARGET_REACHED 0x00008000 |
144 | #define MIXER_OVERFLOW 0x00000800 | 154 | #define MIXER_OVERFLOW 0x00000800 |
145 | #define MIXER_UNDERFLOW 0x00000400 | 155 | #define MIXER_UNDERFLOW 0x00000400 |
156 | #define GPIO_IRQ 0x01000000 | ||
146 | #define ALI_SBBL_SBCL 0xc0 | 157 | #define ALI_SBBL_SBCL 0xc0 |
147 | #define ALI_SBCTRL_SBE2R_SBDD 0xc4 | 158 | #define ALI_SBCTRL_SBE2R_SBDD 0xc4 |
148 | #define ALI_STIMER 0xc8 | 159 | #define ALI_STIMER 0xc8 |
@@ -162,6 +173,9 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); | |||
162 | 173 | ||
163 | #define ALI_REG(codec, x) ((codec)->port + x) | 174 | #define ALI_REG(codec, x) ((codec)->port + x) |
164 | 175 | ||
176 | #define MAX_CODECS 2 | ||
177 | |||
178 | |||
165 | typedef struct snd_stru_ali ali_t; | 179 | typedef struct snd_stru_ali ali_t; |
166 | typedef struct snd_ali_stru_voice snd_ali_voice_t; | 180 | typedef struct snd_ali_stru_voice snd_ali_voice_t; |
167 | 181 | ||
@@ -245,7 +259,7 @@ struct snd_stru_ali { | |||
245 | struct pci_dev *pci_m7101; | 259 | struct pci_dev *pci_m7101; |
246 | 260 | ||
247 | snd_card_t *card; | 261 | snd_card_t *card; |
248 | snd_pcm_t *pcm; | 262 | snd_pcm_t *pcm[MAX_CODECS]; |
249 | alidev_t synth; | 263 | alidev_t synth; |
250 | snd_ali_channel_control_t chregs; | 264 | snd_ali_channel_control_t chregs; |
251 | 265 | ||
@@ -255,8 +269,10 @@ struct snd_stru_ali { | |||
255 | unsigned int spurious_irq_count; | 269 | unsigned int spurious_irq_count; |
256 | unsigned int spurious_irq_max_delta; | 270 | unsigned int spurious_irq_max_delta; |
257 | 271 | ||
272 | unsigned int num_of_codecs; | ||
273 | |||
258 | ac97_bus_t *ac97_bus; | 274 | ac97_bus_t *ac97_bus; |
259 | ac97_t *ac97; | 275 | ac97_t *ac97[MAX_CODECS]; |
260 | unsigned short ac97_ext_id; | 276 | unsigned short ac97_ext_id; |
261 | unsigned short ac97_ext_status; | 277 | unsigned short ac97_ext_status; |
262 | 278 | ||
@@ -489,7 +505,12 @@ static void snd_ali_codec_write(ac97_t *ac97, | |||
489 | ali_t *codec = ac97->private_data; | 505 | ali_t *codec = ac97->private_data; |
490 | 506 | ||
491 | snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val); | 507 | snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val); |
492 | snd_ali_codec_poke(codec, 0, reg, val); | 508 | if(reg == AC97_GPIO_STATUS) { |
509 | outl((val << ALI_AC97_GPIO_DATA_SHIFT)|ALI_AC97_GPIO_ENABLE, | ||
510 | ALI_REG(codec, ALI_AC97_GPIO)); | ||
511 | return; | ||
512 | } | ||
513 | snd_ali_codec_poke(codec, ac97->num, reg, val); | ||
493 | return ; | 514 | return ; |
494 | } | 515 | } |
495 | 516 | ||
@@ -499,7 +520,7 @@ static unsigned short snd_ali_codec_read(ac97_t *ac97, unsigned short reg) | |||
499 | ali_t *codec = ac97->private_data; | 520 | ali_t *codec = ac97->private_data; |
500 | 521 | ||
501 | snd_ali_printk("codec_read reg=%xh.\n", reg); | 522 | snd_ali_printk("codec_read reg=%xh.\n", reg); |
502 | return (snd_ali_codec_peek(codec, 0, reg)); | 523 | return (snd_ali_codec_peek(codec, ac97->num, reg)); |
503 | } | 524 | } |
504 | 525 | ||
505 | /* | 526 | /* |
@@ -1051,7 +1072,7 @@ static irqreturn_t snd_ali_card_interrupt(int irq, | |||
1051 | } | 1072 | } |
1052 | 1073 | ||
1053 | 1074 | ||
1054 | static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec) | 1075 | static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec, int channel) |
1055 | { | 1076 | { |
1056 | snd_ali_voice_t *pvoice = NULL; | 1077 | snd_ali_voice_t *pvoice = NULL; |
1057 | unsigned long flags; | 1078 | unsigned long flags; |
@@ -1061,7 +1082,8 @@ static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec) | |||
1061 | 1082 | ||
1062 | spin_lock_irqsave(&codec->voice_alloc, flags); | 1083 | spin_lock_irqsave(&codec->voice_alloc, flags); |
1063 | if (type == SNDRV_ALI_VOICE_TYPE_PCM) { | 1084 | if (type == SNDRV_ALI_VOICE_TYPE_PCM) { |
1064 | idx = snd_ali_find_free_channel(codec,rec); | 1085 | idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : |
1086 | snd_ali_find_free_channel(codec,rec); | ||
1065 | if(idx < 0) { | 1087 | if(idx < 0) { |
1066 | snd_printk("ali_alloc_voice: err.\n"); | 1088 | snd_printk("ali_alloc_voice: err.\n"); |
1067 | spin_unlock_irqrestore(&codec->voice_alloc, flags); | 1089 | spin_unlock_irqrestore(&codec->voice_alloc, flags); |
@@ -1297,7 +1319,7 @@ static int snd_ali_playback_hw_params(snd_pcm_substream_t * substream, | |||
1297 | 1319 | ||
1298 | if (params_buffer_size(hw_params)/2 != params_period_size(hw_params)) { | 1320 | if (params_buffer_size(hw_params)/2 != params_period_size(hw_params)) { |
1299 | if (evoice == NULL) { | 1321 | if (evoice == NULL) { |
1300 | evoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0); | 1322 | evoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0, -1); |
1301 | if (evoice == NULL) | 1323 | if (evoice == NULL) |
1302 | return -ENOMEM; | 1324 | return -ENOMEM; |
1303 | pvoice->extra = evoice; | 1325 | pvoice->extra = evoice; |
@@ -1328,13 +1350,13 @@ static int snd_ali_playback_hw_free(snd_pcm_substream_t * substream) | |||
1328 | return 0; | 1350 | return 0; |
1329 | } | 1351 | } |
1330 | 1352 | ||
1331 | static int snd_ali_capture_hw_params(snd_pcm_substream_t * substream, | 1353 | static int snd_ali_hw_params(snd_pcm_substream_t * substream, |
1332 | snd_pcm_hw_params_t * hw_params) | 1354 | snd_pcm_hw_params_t * hw_params) |
1333 | { | 1355 | { |
1334 | return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); | 1356 | return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); |
1335 | } | 1357 | } |
1336 | 1358 | ||
1337 | static int snd_ali_capture_hw_free(snd_pcm_substream_t * substream) | 1359 | static int snd_ali_hw_free(snd_pcm_substream_t * substream) |
1338 | { | 1360 | { |
1339 | return snd_pcm_lib_free_pages(substream); | 1361 | return snd_pcm_lib_free_pages(substream); |
1340 | } | 1362 | } |
@@ -1428,7 +1450,7 @@ static int snd_ali_playback_prepare(snd_pcm_substream_t * substream) | |||
1428 | } | 1450 | } |
1429 | 1451 | ||
1430 | 1452 | ||
1431 | static int snd_ali_capture_prepare(snd_pcm_substream_t * substream) | 1453 | static int snd_ali_prepare(snd_pcm_substream_t * substream) |
1432 | { | 1454 | { |
1433 | ali_t *codec = snd_pcm_substream_chip(substream); | 1455 | ali_t *codec = snd_pcm_substream_chip(substream); |
1434 | snd_pcm_runtime_t *runtime = substream->runtime; | 1456 | snd_pcm_runtime_t *runtime = substream->runtime; |
@@ -1446,11 +1468,13 @@ static int snd_ali_capture_prepare(snd_pcm_substream_t * substream) | |||
1446 | 1468 | ||
1447 | spin_lock_irqsave(&codec->reg_lock, flags); | 1469 | spin_lock_irqsave(&codec->reg_lock, flags); |
1448 | 1470 | ||
1449 | snd_ali_printk("capture_prepare...\n"); | 1471 | snd_ali_printk("ali_prepare...\n"); |
1450 | 1472 | ||
1451 | snd_ali_enable_special_channel(codec,pvoice->number); | 1473 | snd_ali_enable_special_channel(codec,pvoice->number); |
1452 | 1474 | ||
1453 | Delta = snd_ali_convert_rate(runtime->rate, 1); | 1475 | Delta = (pvoice->number == ALI_MODEM_IN_CHANNEL || |
1476 | pvoice->number == ALI_MODEM_OUT_CHANNEL) ? | ||
1477 | 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode); | ||
1454 | 1478 | ||
1455 | // Prepare capture intr channel | 1479 | // Prepare capture intr channel |
1456 | if (pvoice->number == ALI_SPDIF_IN_CHANNEL) { | 1480 | if (pvoice->number == ALI_SPDIF_IN_CHANNEL) { |
@@ -1534,7 +1558,7 @@ static snd_pcm_uframes_t snd_ali_playback_pointer(snd_pcm_substream_t *substream | |||
1534 | } | 1558 | } |
1535 | 1559 | ||
1536 | 1560 | ||
1537 | static snd_pcm_uframes_t snd_ali_capture_pointer(snd_pcm_substream_t *substream) | 1561 | static snd_pcm_uframes_t snd_ali_pointer(snd_pcm_substream_t *substream) |
1538 | { | 1562 | { |
1539 | ali_t *codec = snd_pcm_substream_chip(substream); | 1563 | ali_t *codec = snd_pcm_substream_chip(substream); |
1540 | snd_pcm_runtime_t *runtime = substream->runtime; | 1564 | snd_pcm_runtime_t *runtime = substream->runtime; |
@@ -1616,7 +1640,8 @@ static void snd_ali_pcm_free_substream(snd_pcm_runtime_t *runtime) | |||
1616 | } | 1640 | } |
1617 | } | 1641 | } |
1618 | 1642 | ||
1619 | static int snd_ali_playback_open(snd_pcm_substream_t * substream) | 1643 | static int snd_ali_open(snd_pcm_substream_t * substream, int rec, int channel, |
1644 | snd_pcm_hardware_t *phw) | ||
1620 | { | 1645 | { |
1621 | ali_t *codec = snd_pcm_substream_chip(substream); | 1646 | ali_t *codec = snd_pcm_substream_chip(substream); |
1622 | snd_pcm_runtime_t *runtime = substream->runtime; | 1647 | snd_pcm_runtime_t *runtime = substream->runtime; |
@@ -1624,7 +1649,7 @@ static int snd_ali_playback_open(snd_pcm_substream_t * substream) | |||
1624 | unsigned long flags = 0; | 1649 | unsigned long flags = 0; |
1625 | 1650 | ||
1626 | spin_lock_irqsave(&codec->reg_lock, flags); | 1651 | spin_lock_irqsave(&codec->reg_lock, flags); |
1627 | pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0); | 1652 | pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, channel); |
1628 | if (pvoice == NULL) { | 1653 | if (pvoice == NULL) { |
1629 | spin_unlock_irqrestore(&codec->reg_lock, flags); | 1654 | spin_unlock_irqrestore(&codec->reg_lock, flags); |
1630 | return -EAGAIN; | 1655 | return -EAGAIN; |
@@ -1636,49 +1661,31 @@ static int snd_ali_playback_open(snd_pcm_substream_t * substream) | |||
1636 | runtime->private_data = pvoice; | 1661 | runtime->private_data = pvoice; |
1637 | runtime->private_free = snd_ali_pcm_free_substream; | 1662 | runtime->private_free = snd_ali_pcm_free_substream; |
1638 | 1663 | ||
1639 | runtime->hw = snd_ali_playback; | 1664 | runtime->hw = *phw; |
1640 | snd_pcm_set_sync(substream); | 1665 | snd_pcm_set_sync(substream); |
1641 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024); | 1666 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024); |
1642 | return 0; | 1667 | return 0; |
1643 | } | 1668 | } |
1644 | 1669 | ||
1670 | static int snd_ali_playback_open(snd_pcm_substream_t * substream) | ||
1671 | { | ||
1672 | return snd_ali_open(substream, 0, -1, &snd_ali_playback); | ||
1673 | } | ||
1645 | 1674 | ||
1646 | static int snd_ali_capture_open(snd_pcm_substream_t * substream) | 1675 | static int snd_ali_capture_open(snd_pcm_substream_t * substream) |
1647 | { | 1676 | { |
1648 | ali_t *codec = snd_pcm_substream_chip(substream); | 1677 | return snd_ali_open(substream, 1, -1, &snd_ali_capture); |
1649 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
1650 | snd_ali_voice_t *pvoice; | ||
1651 | unsigned long flags; | ||
1652 | |||
1653 | spin_lock_irqsave(&codec->reg_lock, flags); | ||
1654 | pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 1); | ||
1655 | if (pvoice == NULL) { | ||
1656 | spin_unlock_irqrestore(&codec->reg_lock, flags); | ||
1657 | return -EAGAIN; | ||
1658 | } | ||
1659 | pvoice->codec = codec; | ||
1660 | spin_unlock_irqrestore(&codec->reg_lock, flags); | ||
1661 | |||
1662 | pvoice->substream = substream; | ||
1663 | runtime->private_data = pvoice; | ||
1664 | runtime->private_free = snd_ali_pcm_free_substream; | ||
1665 | runtime->hw = snd_ali_capture; | ||
1666 | snd_pcm_set_sync(substream); | ||
1667 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024); | ||
1668 | return 0; | ||
1669 | } | 1678 | } |
1670 | 1679 | ||
1671 | |||
1672 | static int snd_ali_playback_close(snd_pcm_substream_t * substream) | 1680 | static int snd_ali_playback_close(snd_pcm_substream_t * substream) |
1673 | { | 1681 | { |
1674 | return 0; | 1682 | return 0; |
1675 | } | 1683 | } |
1676 | 1684 | ||
1677 | static int snd_ali_capture_close(snd_pcm_substream_t * substream) | 1685 | static int snd_ali_close(snd_pcm_substream_t * substream) |
1678 | { | 1686 | { |
1679 | ali_t *codec = snd_pcm_substream_chip(substream); | 1687 | ali_t *codec = snd_pcm_substream_chip(substream); |
1680 | snd_pcm_runtime_t *runtime = substream->runtime; | 1688 | snd_ali_voice_t *pvoice = (snd_ali_voice_t *) substream->runtime->private_data; |
1681 | snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; | ||
1682 | 1689 | ||
1683 | snd_ali_disable_special_channel(codec,pvoice->number); | 1690 | snd_ali_disable_special_channel(codec,pvoice->number); |
1684 | 1691 | ||
@@ -1698,29 +1705,121 @@ static snd_pcm_ops_t snd_ali_playback_ops = { | |||
1698 | 1705 | ||
1699 | static snd_pcm_ops_t snd_ali_capture_ops = { | 1706 | static snd_pcm_ops_t snd_ali_capture_ops = { |
1700 | .open = snd_ali_capture_open, | 1707 | .open = snd_ali_capture_open, |
1701 | .close = snd_ali_capture_close, | 1708 | .close = snd_ali_close, |
1702 | .ioctl = snd_ali_ioctl, | 1709 | .ioctl = snd_ali_ioctl, |
1703 | .hw_params = snd_ali_capture_hw_params, | 1710 | .hw_params = snd_ali_hw_params, |
1704 | .hw_free = snd_ali_capture_hw_free, | 1711 | .hw_free = snd_ali_hw_free, |
1705 | .prepare = snd_ali_capture_prepare, | 1712 | .prepare = snd_ali_prepare, |
1713 | .trigger = snd_ali_trigger, | ||
1714 | .pointer = snd_ali_pointer, | ||
1715 | }; | ||
1716 | |||
1717 | /* | ||
1718 | * Modem PCM | ||
1719 | */ | ||
1720 | |||
1721 | static int snd_ali_modem_hw_params(snd_pcm_substream_t * substream, | ||
1722 | snd_pcm_hw_params_t * hw_params) | ||
1723 | { | ||
1724 | ali_t *chip = snd_pcm_substream_chip(substream); | ||
1725 | unsigned int modem_num = chip->num_of_codecs - 1; | ||
1726 | snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params)); | ||
1727 | snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); | ||
1728 | return snd_ali_hw_params(substream, hw_params); | ||
1729 | } | ||
1730 | |||
1731 | static snd_pcm_hardware_t snd_ali_modem = | ||
1732 | { | ||
1733 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | ||
1734 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
1735 | SNDRV_PCM_INFO_MMAP_VALID | | ||
1736 | SNDRV_PCM_INFO_RESUME | | ||
1737 | SNDRV_PCM_INFO_SYNC_START), | ||
1738 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
1739 | .rates = SNDRV_PCM_RATE_KNOT|SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000, | ||
1740 | .rate_min = 8000, | ||
1741 | .rate_max = 16000, | ||
1742 | .channels_min = 1, | ||
1743 | .channels_max = 1, | ||
1744 | .buffer_bytes_max = (256*1024), | ||
1745 | .period_bytes_min = 64, | ||
1746 | .period_bytes_max = (256*1024), | ||
1747 | .periods_min = 1, | ||
1748 | .periods_max = 1024, | ||
1749 | .fifo_size = 0, | ||
1750 | }; | ||
1751 | |||
1752 | static int snd_ali_modem_open(snd_pcm_substream_t * substream, int rec, int channel) | ||
1753 | { | ||
1754 | static unsigned int rates [] = {8000,9600,12000,16000}; | ||
1755 | static snd_pcm_hw_constraint_list_t hw_constraint_rates = { | ||
1756 | .count = ARRAY_SIZE(rates), | ||
1757 | .list = rates, | ||
1758 | .mask = 0, | ||
1759 | }; | ||
1760 | int err = snd_ali_open(substream, rec, channel, &snd_ali_modem); | ||
1761 | if (err) | ||
1762 | return err; | ||
1763 | return snd_pcm_hw_constraint_list(substream->runtime, 0, | ||
1764 | SNDRV_PCM_HW_PARAM_RATE, &hw_constraint_rates); | ||
1765 | } | ||
1766 | |||
1767 | static int snd_ali_modem_playback_open(snd_pcm_substream_t * substream) | ||
1768 | { | ||
1769 | return snd_ali_modem_open(substream, 0, ALI_MODEM_OUT_CHANNEL); | ||
1770 | } | ||
1771 | |||
1772 | static int snd_ali_modem_capture_open(snd_pcm_substream_t * substream) | ||
1773 | { | ||
1774 | return snd_ali_modem_open(substream, 1, ALI_MODEM_IN_CHANNEL); | ||
1775 | } | ||
1776 | |||
1777 | static snd_pcm_ops_t snd_ali_modem_playback_ops = { | ||
1778 | .open = snd_ali_modem_playback_open, | ||
1779 | .close = snd_ali_close, | ||
1780 | .ioctl = snd_pcm_lib_ioctl, | ||
1781 | .hw_params = snd_ali_modem_hw_params, | ||
1782 | .hw_free = snd_ali_hw_free, | ||
1783 | .prepare = snd_ali_prepare, | ||
1784 | .trigger = snd_ali_trigger, | ||
1785 | .pointer = snd_ali_pointer, | ||
1786 | }; | ||
1787 | |||
1788 | static snd_pcm_ops_t snd_ali_modem_capture_ops = { | ||
1789 | .open = snd_ali_modem_capture_open, | ||
1790 | .close = snd_ali_close, | ||
1791 | .ioctl = snd_pcm_lib_ioctl, | ||
1792 | .hw_params = snd_ali_modem_hw_params, | ||
1793 | .hw_free = snd_ali_hw_free, | ||
1794 | .prepare = snd_ali_prepare, | ||
1706 | .trigger = snd_ali_trigger, | 1795 | .trigger = snd_ali_trigger, |
1707 | .pointer = snd_ali_capture_pointer, | 1796 | .pointer = snd_ali_pointer, |
1797 | }; | ||
1798 | |||
1799 | |||
1800 | struct ali_pcm_description { | ||
1801 | char *name; | ||
1802 | unsigned int playback_num; | ||
1803 | unsigned int capture_num; | ||
1804 | snd_pcm_ops_t *playback_ops; | ||
1805 | snd_pcm_ops_t *capture_ops; | ||
1708 | }; | 1806 | }; |
1709 | 1807 | ||
1710 | 1808 | ||
1711 | static void snd_ali_pcm_free(snd_pcm_t *pcm) | 1809 | static void snd_ali_pcm_free(snd_pcm_t *pcm) |
1712 | { | 1810 | { |
1713 | ali_t *codec = pcm->private_data; | 1811 | ali_t *codec = pcm->private_data; |
1714 | codec->pcm = NULL; | 1812 | codec->pcm[pcm->device] = NULL; |
1715 | } | 1813 | } |
1716 | 1814 | ||
1717 | static int __devinit snd_ali_pcm(ali_t * codec, int device, snd_pcm_t ** rpcm) | 1815 | |
1816 | static int __devinit snd_ali_pcm(ali_t * codec, int device, struct ali_pcm_description *desc) | ||
1718 | { | 1817 | { |
1719 | snd_pcm_t *pcm; | 1818 | snd_pcm_t *pcm; |
1720 | int err; | 1819 | int err; |
1721 | 1820 | ||
1722 | if (rpcm) *rpcm = NULL; | 1821 | err = snd_pcm_new(codec->card, desc->name, device, |
1723 | err = snd_pcm_new(codec->card, "ALI 5451", device, ALI_CHANNELS, 1, &pcm); | 1822 | desc->playback_num, desc->capture_num, &pcm); |
1724 | if (err < 0) { | 1823 | if (err < 0) { |
1725 | snd_printk("snd_ali_pcm: err called snd_pcm_new.\n"); | 1824 | snd_printk("snd_ali_pcm: err called snd_pcm_new.\n"); |
1726 | return err; | 1825 | return err; |
@@ -1728,20 +1827,36 @@ static int __devinit snd_ali_pcm(ali_t * codec, int device, snd_pcm_t ** rpcm) | |||
1728 | pcm->private_data = codec; | 1827 | pcm->private_data = codec; |
1729 | pcm->private_free = snd_ali_pcm_free; | 1828 | pcm->private_free = snd_ali_pcm_free; |
1730 | pcm->info_flags = 0; | 1829 | pcm->info_flags = 0; |
1731 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ali_playback_ops); | 1830 | if (desc->playback_ops) |
1732 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ali_capture_ops); | 1831 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, desc->playback_ops); |
1832 | if (desc->capture_ops) | ||
1833 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, desc->capture_ops); | ||
1733 | 1834 | ||
1734 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 1835 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
1735 | snd_dma_pci_data(codec->pci), 64*1024, 128*1024); | 1836 | snd_dma_pci_data(codec->pci), 64*1024, 128*1024); |
1736 | 1837 | ||
1737 | pcm->info_flags = 0; | 1838 | pcm->info_flags = 0; |
1738 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; | 1839 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; |
1739 | strcpy(pcm->name, "ALI 5451"); | 1840 | strcpy(pcm->name, desc->name); |
1740 | codec->pcm = pcm; | 1841 | codec->pcm[0] = pcm; |
1741 | if (rpcm) *rpcm = pcm; | ||
1742 | return 0; | 1842 | return 0; |
1743 | } | 1843 | } |
1744 | 1844 | ||
1845 | struct ali_pcm_description ali_pcms[] = { | ||
1846 | { "ALI 5451", ALI_CHANNELS, 1, &snd_ali_playback_ops, &snd_ali_capture_ops }, | ||
1847 | { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops } | ||
1848 | }; | ||
1849 | |||
1850 | static int __devinit snd_ali_build_pcms(ali_t *codec) | ||
1851 | { | ||
1852 | int i, err; | ||
1853 | for(i = 0 ; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms) ; i++) | ||
1854 | if((err = snd_ali_pcm(codec, i, &ali_pcms[i])) < 0) | ||
1855 | return err; | ||
1856 | return 0; | ||
1857 | } | ||
1858 | |||
1859 | |||
1745 | #define ALI5451_SPDIF(xname, xindex, value) \ | 1860 | #define ALI5451_SPDIF(xname, xindex, value) \ |
1746 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ | 1861 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ |
1747 | .info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \ | 1862 | .info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \ |
@@ -1860,14 +1975,14 @@ static void snd_ali_mixer_free_ac97_bus(ac97_bus_t *bus) | |||
1860 | static void snd_ali_mixer_free_ac97(ac97_t *ac97) | 1975 | static void snd_ali_mixer_free_ac97(ac97_t *ac97) |
1861 | { | 1976 | { |
1862 | ali_t *codec = ac97->private_data; | 1977 | ali_t *codec = ac97->private_data; |
1863 | codec->ac97 = NULL; | 1978 | codec->ac97[ac97->num] = NULL; |
1864 | } | 1979 | } |
1865 | 1980 | ||
1866 | static int __devinit snd_ali_mixer(ali_t * codec) | 1981 | static int __devinit snd_ali_mixer(ali_t * codec) |
1867 | { | 1982 | { |
1868 | ac97_template_t ac97; | 1983 | ac97_template_t ac97; |
1869 | unsigned int idx; | 1984 | unsigned int idx; |
1870 | int err; | 1985 | int i, err; |
1871 | static ac97_bus_ops_t ops = { | 1986 | static ac97_bus_ops_t ops = { |
1872 | .write = snd_ali_codec_write, | 1987 | .write = snd_ali_codec_write, |
1873 | .read = snd_ali_codec_read, | 1988 | .read = snd_ali_codec_read, |
@@ -1880,10 +1995,16 @@ static int __devinit snd_ali_mixer(ali_t * codec) | |||
1880 | memset(&ac97, 0, sizeof(ac97)); | 1995 | memset(&ac97, 0, sizeof(ac97)); |
1881 | ac97.private_data = codec; | 1996 | ac97.private_data = codec; |
1882 | ac97.private_free = snd_ali_mixer_free_ac97; | 1997 | ac97.private_free = snd_ali_mixer_free_ac97; |
1883 | if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97)) < 0) { | 1998 | |
1884 | snd_printk("ali mixer creating error.\n"); | 1999 | for ( i = 0 ; i < codec->num_of_codecs ; i++) { |
2000 | ac97.num = i; | ||
2001 | if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) { | ||
2002 | snd_printk("ali mixer %d creating error.\n", i); | ||
2003 | if(i == 0) | ||
1885 | return err; | 2004 | return err; |
1886 | } | 2005 | } |
2006 | } | ||
2007 | |||
1887 | if (codec->spdif_support) { | 2008 | if (codec->spdif_support) { |
1888 | for(idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) { | 2009 | for(idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) { |
1889 | err=snd_ctl_add(codec->card, snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec)); | 2010 | err=snd_ctl_add(codec->card, snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec)); |
@@ -1904,8 +2025,12 @@ static int ali_suspend(snd_card_t *card, pm_message_t state) | |||
1904 | if (! im) | 2025 | if (! im) |
1905 | return 0; | 2026 | return 0; |
1906 | 2027 | ||
1907 | snd_pcm_suspend_all(chip->pcm); | 2028 | for(i = 0 ; i < chip->num_of_codecs ; i++) { |
1908 | snd_ac97_suspend(chip->ac97); | 2029 | if (chip->pcm[i]) |
2030 | snd_pcm_suspend_all(chip->pcm[i]); | ||
2031 | if(chip->ac97[i]) | ||
2032 | snd_ac97_suspend(chip->ac97[i]); | ||
2033 | } | ||
1909 | 2034 | ||
1910 | spin_lock_irq(&chip->reg_lock); | 2035 | spin_lock_irq(&chip->reg_lock); |
1911 | 2036 | ||
@@ -1969,7 +2094,9 @@ static int ali_resume(snd_card_t *card) | |||
1969 | 2094 | ||
1970 | spin_unlock_irq(&chip->reg_lock); | 2095 | spin_unlock_irq(&chip->reg_lock); |
1971 | 2096 | ||
1972 | snd_ac97_resume(chip->ac97); | 2097 | for(i = 0 ; i < chip->num_of_codecs ; i++) |
2098 | if(chip->ac97[i]) | ||
2099 | snd_ac97_resume(chip->ac97[i]); | ||
1973 | 2100 | ||
1974 | return 0; | 2101 | return 0; |
1975 | } | 2102 | } |
@@ -2036,11 +2163,37 @@ static int snd_ali_chip_init(ali_t *codec) | |||
2036 | codec->spdif_mask = 0x00000002; | 2163 | codec->spdif_mask = 0x00000002; |
2037 | } | 2164 | } |
2038 | 2165 | ||
2166 | codec->num_of_codecs = 1; | ||
2167 | |||
2168 | /* secondary codec - modem */ | ||
2169 | if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) { | ||
2170 | codec->num_of_codecs++; | ||
2171 | outl(inl(ALI_REG(codec, ALI_SCTRL)) | | ||
2172 | (ALI_SCTRL_LINE_IN2|ALI_SCTRL_GPIO_IN2|ALI_SCTRL_LINE_OUT_EN), | ||
2173 | ALI_REG(codec, ALI_SCTRL)); | ||
2174 | } | ||
2175 | |||
2039 | snd_ali_printk("chip initialize succeed.\n"); | 2176 | snd_ali_printk("chip initialize succeed.\n"); |
2040 | return 0; | 2177 | return 0; |
2041 | 2178 | ||
2042 | } | 2179 | } |
2043 | 2180 | ||
2181 | /* proc for register dump */ | ||
2182 | static void snd_ali_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buf) | ||
2183 | { | ||
2184 | ali_t *codec = entry->private_data; | ||
2185 | int i; | ||
2186 | for(i = 0 ; i < 256 ; i+= 4) | ||
2187 | snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i))); | ||
2188 | } | ||
2189 | |||
2190 | static void __devinit snd_ali_proc_init(ali_t *codec) | ||
2191 | { | ||
2192 | snd_info_entry_t *entry; | ||
2193 | if(!snd_card_proc_new(codec->card, "ali5451", &entry)) | ||
2194 | snd_info_set_text_ops(entry, codec, 1024, snd_ali_proc_read); | ||
2195 | } | ||
2196 | |||
2044 | static int __devinit snd_ali_resources(ali_t *codec) | 2197 | static int __devinit snd_ali_resources(ali_t *codec) |
2045 | { | 2198 | { |
2046 | int err; | 2199 | int err; |
@@ -2233,11 +2386,13 @@ static int __devinit snd_ali_probe(struct pci_dev *pci, | |||
2233 | } | 2386 | } |
2234 | 2387 | ||
2235 | snd_ali_printk("pcm building ...\n"); | 2388 | snd_ali_printk("pcm building ...\n"); |
2236 | if ((err = snd_ali_pcm(codec, 0, NULL)) < 0) { | 2389 | if ((err = snd_ali_build_pcms(codec)) < 0) { |
2237 | snd_card_free(card); | 2390 | snd_card_free(card); |
2238 | return err; | 2391 | return err; |
2239 | } | 2392 | } |
2240 | 2393 | ||
2394 | snd_ali_proc_init(codec); | ||
2395 | |||
2241 | strcpy(card->driver, "ALI5451"); | 2396 | strcpy(card->driver, "ALI5451"); |
2242 | strcpy(card->shortname, "ALI 5451"); | 2397 | strcpy(card->shortname, "ALI 5451"); |
2243 | 2398 | ||
@@ -2270,7 +2425,7 @@ static struct pci_driver driver = { | |||
2270 | 2425 | ||
2271 | static int __init alsa_card_ali_init(void) | 2426 | static int __init alsa_card_ali_init(void) |
2272 | { | 2427 | { |
2273 | return pci_module_init(&driver); | 2428 | return pci_register_driver(&driver); |
2274 | } | 2429 | } |
2275 | 2430 | ||
2276 | static void __exit alsa_card_ali_exit(void) | 2431 | static void __exit alsa_card_ali_exit(void) |
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index f1a5f5723ee6..ca28b229c704 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c | |||
@@ -367,7 +367,7 @@ static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id, struct pt_regs * | |||
367 | if ((gcr_status & 0x40) && (chip->capture_substream)) /* capturing */ | 367 | if ((gcr_status & 0x40) && (chip->capture_substream)) /* capturing */ |
368 | snd_pcm_period_elapsed(chip->capture_substream); | 368 | snd_pcm_period_elapsed(chip->capture_substream); |
369 | if ((gcr_status & 0x10) && (chip->rmidi)) /* MPU401 interrupt */ | 369 | if ((gcr_status & 0x10) && (chip->rmidi)) /* MPU401 interrupt */ |
370 | snd_mpu401_uart_interrupt(irq, chip->rmidi, regs); | 370 | snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs); |
371 | /* release the gcr */ | 371 | /* release the gcr */ |
372 | outb(gcr_status, chip->alt_port + 0xe); | 372 | outb(gcr_status, chip->alt_port + 0xe); |
373 | 373 | ||
@@ -777,7 +777,7 @@ static struct pci_driver driver = { | |||
777 | 777 | ||
778 | static int __init alsa_card_als4000_init(void) | 778 | static int __init alsa_card_als4000_init(void) |
779 | { | 779 | { |
780 | return pci_module_init(&driver); | 780 | return pci_register_driver(&driver); |
781 | } | 781 | } |
782 | 782 | ||
783 | static void __exit alsa_card_als4000_exit(void) | 783 | static void __exit alsa_card_als4000_exit(void) |
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 6b04c0acc6f7..cafab4af5c57 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c | |||
@@ -1334,8 +1334,8 @@ static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id, struct pt_regs *r | |||
1334 | 1334 | ||
1335 | static struct ac97_quirk ac97_quirks[] __devinitdata = { | 1335 | static struct ac97_quirk ac97_quirks[] __devinitdata = { |
1336 | { | 1336 | { |
1337 | .vendor = 0x103c, | 1337 | .subvendor = 0x103c, |
1338 | .device = 0x006b, | 1338 | .subdevice = 0x006b, |
1339 | .name = "HP Pavilion ZV5030US", | 1339 | .name = "HP Pavilion ZV5030US", |
1340 | .type = AC97_TUNE_MUTE_LED | 1340 | .type = AC97_TUNE_MUTE_LED |
1341 | }, | 1341 | }, |
@@ -1645,7 +1645,7 @@ static struct pci_driver driver = { | |||
1645 | 1645 | ||
1646 | static int __init alsa_card_atiixp_init(void) | 1646 | static int __init alsa_card_atiixp_init(void) |
1647 | { | 1647 | { |
1648 | return pci_module_init(&driver); | 1648 | return pci_register_driver(&driver); |
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | static void __exit alsa_card_atiixp_exit(void) | 1651 | static void __exit alsa_card_atiixp_exit(void) |
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index fb7cecea846d..a6b4b8d589fd 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c | |||
@@ -463,6 +463,11 @@ static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg) | |||
463 | static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) | 463 | static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) |
464 | { | 464 | { |
465 | atiixp_t *chip = ac97->private_data; | 465 | atiixp_t *chip = ac97->private_data; |
466 | if (reg == AC97_GPIO_STATUS) { | ||
467 | atiixp_write(chip, MODEM_OUT_GPIO, | ||
468 | (val << ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT) | ATI_REG_MODEM_OUT_GPIO_EN); | ||
469 | return; | ||
470 | } | ||
466 | snd_atiixp_codec_write(chip, ac97->num, reg, val); | 471 | snd_atiixp_codec_write(chip, ac97->num, reg, val); |
467 | } | 472 | } |
468 | 473 | ||
@@ -663,44 +668,33 @@ static int snd_atiixp_pcm_trigger(snd_pcm_substream_t *substream, int cmd) | |||
663 | { | 668 | { |
664 | atiixp_t *chip = snd_pcm_substream_chip(substream); | 669 | atiixp_t *chip = snd_pcm_substream_chip(substream); |
665 | atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; | 670 | atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; |
666 | unsigned int reg = 0; | 671 | int err = 0; |
667 | int i; | ||
668 | 672 | ||
669 | snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); | 673 | snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); |
670 | 674 | ||
671 | if (cmd != SNDRV_PCM_TRIGGER_START && cmd != SNDRV_PCM_TRIGGER_STOP) | ||
672 | return -EINVAL; | ||
673 | |||
674 | spin_lock(&chip->reg_lock); | 675 | spin_lock(&chip->reg_lock); |
675 | 676 | switch(cmd) { | |
676 | /* hook off/on: via GPIO_OUT */ | 677 | case SNDRV_PCM_TRIGGER_START: |
677 | for (i = 0; i < NUM_ATI_CODECS; i++) { | ||
678 | if (chip->ac97[i]) { | ||
679 | reg = snd_ac97_read(chip->ac97[i], AC97_GPIO_STATUS); | ||
680 | break; | ||
681 | } | ||
682 | } | ||
683 | if(cmd == SNDRV_PCM_TRIGGER_START) | ||
684 | reg |= AC97_GPIO_LINE1_OH; | ||
685 | else | ||
686 | reg &= ~AC97_GPIO_LINE1_OH; | ||
687 | reg = (reg << ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT) | ATI_REG_MODEM_OUT_GPIO_EN ; | ||
688 | atiixp_write(chip, MODEM_OUT_GPIO, reg); | ||
689 | |||
690 | if (cmd == SNDRV_PCM_TRIGGER_START) { | ||
691 | dma->ops->enable_transfer(chip, 1); | 678 | dma->ops->enable_transfer(chip, 1); |
692 | dma->running = 1; | 679 | dma->running = 1; |
693 | } else { | 680 | break; |
681 | case SNDRV_PCM_TRIGGER_STOP: | ||
694 | dma->ops->enable_transfer(chip, 0); | 682 | dma->ops->enable_transfer(chip, 0); |
695 | dma->running = 0; | 683 | dma->running = 0; |
684 | break; | ||
685 | default: | ||
686 | err = -EINVAL; | ||
687 | break; | ||
696 | } | 688 | } |
689 | if (! err) { | ||
697 | snd_atiixp_check_bus_busy(chip); | 690 | snd_atiixp_check_bus_busy(chip); |
698 | if (cmd == SNDRV_PCM_TRIGGER_STOP) { | 691 | if (cmd == SNDRV_PCM_TRIGGER_STOP) { |
699 | dma->ops->flush_dma(chip); | 692 | dma->ops->flush_dma(chip); |
700 | snd_atiixp_check_bus_busy(chip); | 693 | snd_atiixp_check_bus_busy(chip); |
701 | } | 694 | } |
695 | } | ||
702 | spin_unlock(&chip->reg_lock); | 696 | spin_unlock(&chip->reg_lock); |
703 | return 0; | 697 | return err; |
704 | } | 698 | } |
705 | 699 | ||
706 | 700 | ||
@@ -1332,7 +1326,7 @@ static struct pci_driver driver = { | |||
1332 | 1326 | ||
1333 | static int __init alsa_card_atiixp_init(void) | 1327 | static int __init alsa_card_atiixp_init(void) |
1334 | { | 1328 | { |
1335 | return pci_module_init(&driver); | 1329 | return pci_register_driver(&driver); |
1336 | } | 1330 | } |
1337 | 1331 | ||
1338 | static void __exit alsa_card_atiixp_exit(void) | 1332 | static void __exit alsa_card_atiixp_exit(void) |
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index 889b4a1a51a1..f6236c63aaaa 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c | |||
@@ -375,7 +375,7 @@ static struct pci_driver driver = { | |||
375 | // initialization of the module | 375 | // initialization of the module |
376 | static int __init alsa_card_vortex_init(void) | 376 | static int __init alsa_card_vortex_init(void) |
377 | { | 377 | { |
378 | return pci_module_init(&driver); | 378 | return pci_register_driver(&driver); |
379 | } | 379 | } |
380 | 380 | ||
381 | // clean up the module | 381 | // clean up the module |
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index b8ae534125c1..72bba7b2d983 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c | |||
@@ -1520,7 +1520,7 @@ static int __init alsa_card_azf3328_init(void) | |||
1520 | { | 1520 | { |
1521 | int err; | 1521 | int err; |
1522 | snd_azf3328_dbgcallenter(); | 1522 | snd_azf3328_dbgcallenter(); |
1523 | err = pci_module_init(&driver); | 1523 | err = pci_register_driver(&driver); |
1524 | snd_azf3328_dbgcallleave(); | 1524 | snd_azf3328_dbgcallleave(); |
1525 | return err; | 1525 | return err; |
1526 | } | 1526 | } |
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 89a7ffe5e7d7..defdc5a459f0 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c | |||
@@ -918,7 +918,7 @@ static int __init alsa_card_bt87x_init(void) | |||
918 | { | 918 | { |
919 | if (load_all) | 919 | if (load_all) |
920 | driver.id_table = snd_bt87x_default_ids; | 920 | driver.id_table = snd_bt87x_default_ids; |
921 | return pci_module_init(&driver); | 921 | return pci_register_driver(&driver); |
922 | } | 922 | } |
923 | 923 | ||
924 | static void __exit alsa_card_bt87x_exit(void) | 924 | static void __exit alsa_card_bt87x_exit(void) |
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h index deb028851056..da09cab405a9 100644 --- a/sound/pci/ca0106/ca0106.h +++ b/sound/pci/ca0106/ca0106.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> | 2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> |
3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit | 3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit |
4 | * Version: 0.0.20 | 4 | * Version: 0.0.21 |
5 | * | 5 | * |
6 | * FEATURES currently supported: | 6 | * FEATURES currently supported: |
7 | * See ca0106_main.c for features. | 7 | * See ca0106_main.c for features. |
@@ -45,6 +45,8 @@ | |||
45 | * Added I2C and SPI registers. Filled in interrupt enable. | 45 | * Added I2C and SPI registers. Filled in interrupt enable. |
46 | * 0.0.20 | 46 | * 0.0.20 |
47 | * Added GPIO info for SB Live 24bit. | 47 | * Added GPIO info for SB Live 24bit. |
48 | * 0.0.21 | ||
49 | * Implement support for Line-in capture on SB Live 24bit. | ||
48 | * | 50 | * |
49 | * | 51 | * |
50 | * This code was initally based on code from ALSA's emu10k1x.c which is: | 52 | * This code was initally based on code from ALSA's emu10k1x.c which is: |
@@ -152,7 +154,7 @@ | |||
152 | * bit 9 0 = Mute / 1 = Analog out. | 154 | * bit 9 0 = Mute / 1 = Analog out. |
153 | * bit 10 0 = Line-in / 1 = Mic-in. | 155 | * bit 10 0 = Line-in / 1 = Mic-in. |
154 | * bit 11 0 = ? / 1 = ? | 156 | * bit 11 0 = ? / 1 = ? |
155 | * bit 12 0 = ? / 1 = ? | 157 | * bit 12 0 = 48 Khz / 1 = 96 Khz Analog out on SB Live 24bit. |
156 | * bit 13 0 = ? / 1 = ? | 158 | * bit 13 0 = ? / 1 = ? |
157 | * bit 14 0 = Mute / 1 = Analog out | 159 | * bit 14 0 = Mute / 1 = Analog out |
158 | * bit 15 0 = ? / 1 = ? | 160 | * bit 15 0 = ? / 1 = ? |
@@ -475,9 +477,56 @@ | |||
475 | /* Causes interrupts based on timer intervals. */ | 477 | /* Causes interrupts based on timer intervals. */ |
476 | #define SPI 0x7a /* SPI: Serial Interface Register */ | 478 | #define SPI 0x7a /* SPI: Serial Interface Register */ |
477 | #define I2C_A 0x7b /* I2C Address. 32 bit */ | 479 | #define I2C_A 0x7b /* I2C Address. 32 bit */ |
478 | #define I2C_0 0x7c /* I2C Data Port 0. 32 bit */ | 480 | #define I2C_D0 0x7c /* I2C Data Port 0. 32 bit */ |
479 | #define I2C_1 0x7d /* I2C Data Port 1. 32 bit */ | 481 | #define I2C_D1 0x7d /* I2C Data Port 1. 32 bit */ |
482 | //I2C values | ||
483 | #define I2C_A_ADC_ADD_MASK 0x000000fe //The address is a 7 bit address | ||
484 | #define I2C_A_ADC_RW_MASK 0x00000001 //bit mask for R/W | ||
485 | #define I2C_A_ADC_TRANS_MASK 0x00000010 //Bit mask for I2c address DAC value | ||
486 | #define I2C_A_ADC_ABORT_MASK 0x00000020 //Bit mask for I2C transaction abort flag | ||
487 | #define I2C_A_ADC_LAST_MASK 0x00000040 //Bit mask for Last word transaction | ||
488 | #define I2C_A_ADC_BYTE_MASK 0x00000080 //Bit mask for Byte Mode | ||
480 | 489 | ||
490 | #define I2C_A_ADC_ADD 0x00000034 //This is the Device address for ADC | ||
491 | #define I2C_A_ADC_READ 0x00000001 //To perform a read operation | ||
492 | #define I2C_A_ADC_START 0x00000100 //Start I2C transaction | ||
493 | #define I2C_A_ADC_ABORT 0x00000200 //I2C transaction abort | ||
494 | #define I2C_A_ADC_LAST 0x00000400 //I2C last transaction | ||
495 | #define I2C_A_ADC_BYTE 0x00000800 //I2C one byte mode | ||
496 | |||
497 | #define I2C_D_ADC_REG_MASK 0xfe000000 //ADC address register | ||
498 | #define I2C_D_ADC_DAT_MASK 0x01ff0000 //ADC data register | ||
499 | |||
500 | #define ADC_TIMEOUT 0x00000007 //ADC Timeout Clock Disable | ||
501 | #define ADC_IFC_CTRL 0x0000000b //ADC Interface Control | ||
502 | #define ADC_MASTER 0x0000000c //ADC Master Mode Control | ||
503 | #define ADC_POWER 0x0000000d //ADC PowerDown Control | ||
504 | #define ADC_ATTEN_ADCL 0x0000000e //ADC Attenuation ADCL | ||
505 | #define ADC_ATTEN_ADCR 0x0000000f //ADC Attenuation ADCR | ||
506 | #define ADC_ALC_CTRL1 0x00000010 //ADC ALC Control 1 | ||
507 | #define ADC_ALC_CTRL2 0x00000011 //ADC ALC Control 2 | ||
508 | #define ADC_ALC_CTRL3 0x00000012 //ADC ALC Control 3 | ||
509 | #define ADC_NOISE_CTRL 0x00000013 //ADC Noise Gate Control | ||
510 | #define ADC_LIMIT_CTRL 0x00000014 //ADC Limiter Control | ||
511 | #define ADC_MUX 0x00000015 //ADC Mux offset | ||
512 | |||
513 | #if 0 | ||
514 | /* FIXME: Not tested yet. */ | ||
515 | #define ADC_GAIN_MASK 0x000000ff //Mask for ADC Gain | ||
516 | #define ADC_ZERODB 0x000000cf //Value to set ADC to 0dB | ||
517 | #define ADC_MUTE_MASK 0x000000c0 //Mask for ADC mute | ||
518 | #define ADC_MUTE 0x000000c0 //Value to mute ADC | ||
519 | #define ADC_OSR 0x00000008 //Mask for ADC oversample rate select | ||
520 | #define ADC_TIMEOUT_DISABLE 0x00000008 //Value and mask to disable Timeout clock | ||
521 | #define ADC_HPF_DISABLE 0x00000100 //Value and mask to disable High pass filter | ||
522 | #define ADC_TRANWIN_MASK 0x00000070 //Mask for Length of Transient Window | ||
523 | #endif | ||
524 | |||
525 | #define ADC_MUX_MASK 0x0000000f //Mask for ADC Mux | ||
526 | #define ADC_MUX_MIC 0x00000002 //Value to select Mic at ADC Mux | ||
527 | #define ADC_MUX_LINEIN 0x00000004 //Value to select LineIn at ADC Mux | ||
528 | #define ADC_MUX_PHONE 0x00000001 //Value to select TAD at ADC Mux (Not used) | ||
529 | #define ADC_MUX_AUX 0x00000008 //Value to select Aux at ADC Mux | ||
481 | 530 | ||
482 | #define SET_CHANNEL 0 /* Testing channel outputs 0=Front, 1=Center/LFE, 2=Unknown, 3=Rear */ | 531 | #define SET_CHANNEL 0 /* Testing channel outputs 0=Front, 1=Center/LFE, 2=Unknown, 3=Rear */ |
483 | #define PCM_FRONT_CHANNEL 0 | 532 | #define PCM_FRONT_CHANNEL 0 |
@@ -508,9 +557,18 @@ struct snd_ca0106_pcm { | |||
508 | unsigned short running; | 557 | unsigned short running; |
509 | }; | 558 | }; |
510 | 559 | ||
560 | typedef struct { | ||
561 | u32 serial; | ||
562 | char * name; | ||
563 | int ac97; | ||
564 | int gpio_type; | ||
565 | int i2c_adc; | ||
566 | } ca0106_details_t; | ||
567 | |||
511 | // definition of the chip-specific record | 568 | // definition of the chip-specific record |
512 | struct snd_ca0106 { | 569 | struct snd_ca0106 { |
513 | snd_card_t *card; | 570 | snd_card_t *card; |
571 | ca0106_details_t *details; | ||
514 | struct pci_dev *pci; | 572 | struct pci_dev *pci; |
515 | 573 | ||
516 | unsigned long port; | 574 | unsigned long port; |
@@ -531,6 +589,7 @@ struct snd_ca0106 { | |||
531 | u32 spdif_bits[4]; /* s/pdif out setup */ | 589 | u32 spdif_bits[4]; /* s/pdif out setup */ |
532 | int spdif_enable; | 590 | int spdif_enable; |
533 | int capture_source; | 591 | int capture_source; |
592 | int capture_mic_line_in; | ||
534 | 593 | ||
535 | struct snd_dma_buffer buffer; | 594 | struct snd_dma_buffer buffer; |
536 | }; | 595 | }; |
@@ -547,3 +606,6 @@ void snd_ca0106_ptr_write(ca0106_t *emu, | |||
547 | unsigned int chn, | 606 | unsigned int chn, |
548 | unsigned int data); | 607 | unsigned int data); |
549 | 608 | ||
609 | int snd_ca0106_i2c_write(ca0106_t *emu, u32 reg, u32 value); | ||
610 | |||
611 | |||
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 82533b45bc8c..95c289284267 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> | 2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> |
3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit | 3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit |
4 | * Version: 0.0.22 | 4 | * Version: 0.0.23 |
5 | * | 5 | * |
6 | * FEATURES currently supported: | 6 | * FEATURES currently supported: |
7 | * Front, Rear and Center/LFE. | 7 | * Front, Rear and Center/LFE. |
@@ -77,6 +77,8 @@ | |||
77 | * Add SPDIF capture using optional digital I/O module for SB Live 24bit. (Analog capture does not yet work.) | 77 | * Add SPDIF capture using optional digital I/O module for SB Live 24bit. (Analog capture does not yet work.) |
78 | * 0.0.22 | 78 | * 0.0.22 |
79 | * Add support for MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97. From kiksen, bug #901 | 79 | * Add support for MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97. From kiksen, bug #901 |
80 | * 0.0.23 | ||
81 | * Implement support for Line-in capture on SB Live 24bit. | ||
80 | * | 82 | * |
81 | * BUGS: | 83 | * BUGS: |
82 | * Some stability problems when unloading the snd-ca0106 kernel module. | 84 | * Some stability problems when unloading the snd-ca0106 kernel module. |
@@ -136,6 +138,7 @@ | |||
136 | #include <linux/pci.h> | 138 | #include <linux/pci.h> |
137 | #include <linux/slab.h> | 139 | #include <linux/slab.h> |
138 | #include <linux/moduleparam.h> | 140 | #include <linux/moduleparam.h> |
141 | #include <linux/dma-mapping.h> | ||
139 | #include <sound/core.h> | 142 | #include <sound/core.h> |
140 | #include <sound/initval.h> | 143 | #include <sound/initval.h> |
141 | #include <sound/pcm.h> | 144 | #include <sound/pcm.h> |
@@ -161,18 +164,32 @@ MODULE_PARM_DESC(enable, "Enable the CA0106 soundcard."); | |||
161 | 164 | ||
162 | #include "ca0106.h" | 165 | #include "ca0106.h" |
163 | 166 | ||
164 | typedef struct { | 167 | static ca0106_details_t ca0106_chip_details[] = { |
165 | u32 serial; | 168 | /* AudigyLS[SB0310] */ |
166 | char * name; | 169 | { .serial = 0x10021102, |
167 | } ca0106_names_t; | 170 | .name = "AudigyLS [SB0310]", |
168 | 171 | .ac97 = 1 } , | |
169 | static ca0106_names_t ca0106_chip_names[] = { | 172 | /* Unknown AudigyLS that also says SB0310 on it */ |
170 | { 0x10021102, "AudigyLS [SB0310]"} , | 173 | { .serial = 0x10051102, |
171 | { 0x10051102, "AudigyLS [SB0310b]"} , /* Unknown AudigyLS that also says SB0310 on it */ | 174 | .name = "AudigyLS [SB0310b]", |
172 | { 0x10061102, "Live! 7.1 24bit [SB0410]"} , /* New Sound Blaster Live! 7.1 24bit. This does not have an AC97. 53SB041000001 */ | 175 | .ac97 = 1 } , |
173 | { 0x10071102, "Live! 7.1 24bit [SB0413]"} , /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */ | 176 | /* New Sound Blaster Live! 7.1 24bit. This does not have an AC97. 53SB041000001 */ |
174 | { 0x10091462, "MSI K8N Diamond MB [SB0438]"}, /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ | 177 | { .serial = 0x10061102, |
175 | { 0, "AudigyLS [Unknown]" } | 178 | .name = "Live! 7.1 24bit [SB0410]", |
179 | .gpio_type = 1, | ||
180 | .i2c_adc = 1 } , | ||
181 | /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */ | ||
182 | { .serial = 0x10071102, | ||
183 | .name = "Live! 7.1 24bit [SB0413]", | ||
184 | .gpio_type = 1, | ||
185 | .i2c_adc = 1 } , | ||
186 | /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ | ||
187 | { .serial = 0x10091462, | ||
188 | .name = "MSI K8N Diamond MB [SB0438]", | ||
189 | .gpio_type = 1, | ||
190 | .i2c_adc = 1 } , | ||
191 | { .serial = 0, | ||
192 | .name = "AudigyLS [Unknown]" } | ||
176 | }; | 193 | }; |
177 | 194 | ||
178 | /* hardware definition */ | 195 | /* hardware definition */ |
@@ -200,10 +217,10 @@ static snd_pcm_hardware_t snd_ca0106_capture_hw = { | |||
200 | SNDRV_PCM_INFO_INTERLEAVED | | 217 | SNDRV_PCM_INFO_INTERLEAVED | |
201 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 218 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
202 | SNDRV_PCM_INFO_MMAP_VALID), | 219 | SNDRV_PCM_INFO_MMAP_VALID), |
203 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 220 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, |
204 | .rates = SNDRV_PCM_RATE_48000, | 221 | .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, |
205 | .rate_min = 48000, | 222 | .rate_min = 44100, |
206 | .rate_max = 48000, | 223 | .rate_max = 192000, |
207 | .channels_min = 2, | 224 | .channels_min = 2, |
208 | .channels_max = 2, | 225 | .channels_max = 2, |
209 | .buffer_bytes_max = ((65536 - 64) * 8), | 226 | .buffer_bytes_max = ((65536 - 64) * 8), |
@@ -246,6 +263,62 @@ void snd_ca0106_ptr_write(ca0106_t *emu, | |||
246 | spin_unlock_irqrestore(&emu->emu_lock, flags); | 263 | spin_unlock_irqrestore(&emu->emu_lock, flags); |
247 | } | 264 | } |
248 | 265 | ||
266 | int snd_ca0106_i2c_write(ca0106_t *emu, | ||
267 | u32 reg, | ||
268 | u32 value) | ||
269 | { | ||
270 | u32 tmp; | ||
271 | int timeout=0; | ||
272 | int status; | ||
273 | int retry; | ||
274 | if ((reg > 0x7f) || (value > 0x1ff)) | ||
275 | { | ||
276 | snd_printk("i2c_write: invalid values.\n"); | ||
277 | return -EINVAL; | ||
278 | } | ||
279 | |||
280 | tmp = reg << 25 | value << 16; | ||
281 | /* Not sure what this I2C channel controls. */ | ||
282 | /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */ | ||
283 | |||
284 | /* This controls the I2C connected to the WM8775 ADC Codec */ | ||
285 | snd_ca0106_ptr_write(emu, I2C_D1, 0, tmp); | ||
286 | |||
287 | for(retry=0;retry<10;retry++) | ||
288 | { | ||
289 | /* Send the data to i2c */ | ||
290 | tmp = snd_ca0106_ptr_read(emu, I2C_A, 0); | ||
291 | tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); | ||
292 | tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD); | ||
293 | snd_ca0106_ptr_write(emu, I2C_A, 0, tmp); | ||
294 | |||
295 | /* Wait till the transaction ends */ | ||
296 | while(1) | ||
297 | { | ||
298 | status = snd_ca0106_ptr_read(emu, I2C_A, 0); | ||
299 | //snd_printk("I2C:status=0x%x\n", status); | ||
300 | timeout++; | ||
301 | if((status & I2C_A_ADC_START)==0) | ||
302 | break; | ||
303 | |||
304 | if(timeout>1000) | ||
305 | break; | ||
306 | } | ||
307 | //Read back and see if the transaction is successful | ||
308 | if((status & I2C_A_ADC_ABORT)==0) | ||
309 | break; | ||
310 | } | ||
311 | |||
312 | if(retry==10) | ||
313 | { | ||
314 | snd_printk("Writing to ADC failed!\n"); | ||
315 | return -EINVAL; | ||
316 | } | ||
317 | |||
318 | return 0; | ||
319 | } | ||
320 | |||
321 | |||
249 | static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) | 322 | static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) |
250 | { | 323 | { |
251 | unsigned long flags; | 324 | unsigned long flags; |
@@ -259,11 +332,7 @@ static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) | |||
259 | 332 | ||
260 | static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime) | 333 | static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime) |
261 | { | 334 | { |
262 | ca0106_pcm_t *epcm = runtime->private_data; | 335 | kfree(runtime->private_data); |
263 | |||
264 | if (epcm) { | ||
265 | kfree(epcm); | ||
266 | } | ||
267 | } | 336 | } |
268 | 337 | ||
269 | /* open_playback callback */ | 338 | /* open_playback callback */ |
@@ -538,6 +607,61 @@ static int snd_ca0106_pcm_prepare_capture(snd_pcm_substream_t *substream) | |||
538 | snd_pcm_runtime_t *runtime = substream->runtime; | 607 | snd_pcm_runtime_t *runtime = substream->runtime; |
539 | ca0106_pcm_t *epcm = runtime->private_data; | 608 | ca0106_pcm_t *epcm = runtime->private_data; |
540 | int channel = epcm->channel_id; | 609 | int channel = epcm->channel_id; |
610 | u32 hcfg_mask = HCFG_CAPTURE_S32_LE; | ||
611 | u32 hcfg_set = 0x00000000; | ||
612 | u32 hcfg; | ||
613 | u32 over_sampling=0x2; | ||
614 | u32 reg71_mask = 0x0000c000 ; /* Global. Set ADC rate. */ | ||
615 | u32 reg71_set = 0; | ||
616 | u32 reg71; | ||
617 | |||
618 | //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1)); | ||
619 | //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base); | ||
620 | //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); | ||
621 | /* reg71 controls ADC rate. */ | ||
622 | switch (runtime->rate) { | ||
623 | case 44100: | ||
624 | reg71_set = 0x00004000; | ||
625 | break; | ||
626 | case 48000: | ||
627 | reg71_set = 0; | ||
628 | break; | ||
629 | case 96000: | ||
630 | reg71_set = 0x00008000; | ||
631 | over_sampling=0xa; | ||
632 | break; | ||
633 | case 192000: | ||
634 | reg71_set = 0x0000c000; | ||
635 | over_sampling=0xa; | ||
636 | break; | ||
637 | default: | ||
638 | reg71_set = 0; | ||
639 | break; | ||
640 | } | ||
641 | /* Format is a global setting */ | ||
642 | /* FIXME: Only let the first channel accessed set this. */ | ||
643 | switch (runtime->format) { | ||
644 | case SNDRV_PCM_FORMAT_S16_LE: | ||
645 | hcfg_set = 0; | ||
646 | break; | ||
647 | case SNDRV_PCM_FORMAT_S32_LE: | ||
648 | hcfg_set = HCFG_CAPTURE_S32_LE; | ||
649 | break; | ||
650 | default: | ||
651 | hcfg_set = 0; | ||
652 | break; | ||
653 | } | ||
654 | hcfg = inl(emu->port + HCFG) ; | ||
655 | hcfg = (hcfg & ~hcfg_mask) | hcfg_set; | ||
656 | outl(hcfg, emu->port + HCFG); | ||
657 | reg71 = snd_ca0106_ptr_read(emu, 0x71, 0); | ||
658 | reg71 = (reg71 & ~reg71_mask) | reg71_set; | ||
659 | snd_ca0106_ptr_write(emu, 0x71, 0, reg71); | ||
660 | if (emu->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ | ||
661 | snd_ca0106_i2c_write(emu, ADC_MASTER, over_sampling); /* Adjust the over sampler to better suit the capture rate. */ | ||
662 | } | ||
663 | |||
664 | |||
541 | //printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); | 665 | //printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); |
542 | snd_ca0106_ptr_write(emu, 0x13, channel, 0); | 666 | snd_ca0106_ptr_write(emu, 0x13, channel, 0); |
543 | snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); | 667 | snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); |
@@ -810,6 +934,7 @@ static int snd_ca0106_ac97(ca0106_t *chip) | |||
810 | 934 | ||
811 | memset(&ac97, 0, sizeof(ac97)); | 935 | memset(&ac97, 0, sizeof(ac97)); |
812 | ac97.private_data = chip; | 936 | ac97.private_data = chip; |
937 | ac97.scaps = AC97_SCAP_NO_SPDIF; | ||
813 | return snd_ac97_mixer(pbus, &ac97, &chip->ac97); | 938 | return snd_ac97_mixer(pbus, &ac97, &chip->ac97); |
814 | } | 939 | } |
815 | 940 | ||
@@ -993,6 +1118,7 @@ static int __devinit snd_ca0106_create(snd_card_t *card, | |||
993 | ca0106_t **rchip) | 1118 | ca0106_t **rchip) |
994 | { | 1119 | { |
995 | ca0106_t *chip; | 1120 | ca0106_t *chip; |
1121 | ca0106_details_t *c; | ||
996 | int err; | 1122 | int err; |
997 | int ch; | 1123 | int ch; |
998 | static snd_device_ops_t ops = { | 1124 | static snd_device_ops_t ops = { |
@@ -1003,8 +1129,8 @@ static int __devinit snd_ca0106_create(snd_card_t *card, | |||
1003 | 1129 | ||
1004 | if ((err = pci_enable_device(pci)) < 0) | 1130 | if ((err = pci_enable_device(pci)) < 0) |
1005 | return err; | 1131 | return err; |
1006 | if (pci_set_dma_mask(pci, 0xffffffffUL) < 0 || | 1132 | if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 || |
1007 | pci_set_consistent_dma_mask(pci, 0xffffffffUL) < 0) { | 1133 | pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { |
1008 | printk(KERN_ERR "error to set 32bit mask DMA\n"); | 1134 | printk(KERN_ERR "error to set 32bit mask DMA\n"); |
1009 | pci_disable_device(pci); | 1135 | pci_disable_device(pci); |
1010 | return -ENXIO; | 1136 | return -ENXIO; |
@@ -1054,6 +1180,15 @@ static int __devinit snd_ca0106_create(snd_card_t *card, | |||
1054 | printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, | 1180 | printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, |
1055 | chip->revision, chip->serial); | 1181 | chip->revision, chip->serial); |
1056 | #endif | 1182 | #endif |
1183 | strcpy(card->driver, "CA0106"); | ||
1184 | strcpy(card->shortname, "CA0106"); | ||
1185 | |||
1186 | for (c=ca0106_chip_details; c->serial; c++) { | ||
1187 | if (c->serial == chip->serial) break; | ||
1188 | } | ||
1189 | chip->details = c; | ||
1190 | sprintf(card->longname, "%s at 0x%lx irq %i", | ||
1191 | c->name, chip->port, chip->irq); | ||
1057 | 1192 | ||
1058 | outl(0, chip->port + INTE); | 1193 | outl(0, chip->port + INTE); |
1059 | 1194 | ||
@@ -1113,7 +1248,7 @@ static int __devinit snd_ca0106_create(snd_card_t *card, | |||
1113 | //snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); /* OSS drivers set this. */ | 1248 | //snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); /* OSS drivers set this. */ |
1114 | /* Analog or Digital output */ | 1249 | /* Analog or Digital output */ |
1115 | snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); | 1250 | snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); |
1116 | snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000b0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers */ | 1251 | snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers. Use 0x000f0000 for surround71 */ |
1117 | chip->spdif_enable = 0; /* Set digital SPDIF output off */ | 1252 | chip->spdif_enable = 0; /* Set digital SPDIF output off */ |
1118 | chip->capture_source = 3; /* Set CAPTURE_SOURCE */ | 1253 | chip->capture_source = 3; /* Set CAPTURE_SOURCE */ |
1119 | //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */ | 1254 | //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */ |
@@ -1138,13 +1273,11 @@ static int __devinit snd_ca0106_create(snd_card_t *card, | |||
1138 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */ | 1273 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */ |
1139 | chip->capture_source = 3; /* Set CAPTURE_SOURCE */ | 1274 | chip->capture_source = 3; /* Set CAPTURE_SOURCE */ |
1140 | 1275 | ||
1141 | if ((chip->serial == 0x10061102) || | 1276 | if (chip->details->gpio_type == 1) { /* The SB0410 and SB0413 use GPIO differently. */ |
1142 | (chip->serial == 0x10071102) || | ||
1143 | (chip->serial == 0x10091462)) { /* The SB0410 and SB0413 use GPIO differently. */ | ||
1144 | /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ | 1277 | /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ |
1145 | outl(0x0, chip->port+GPIO); | 1278 | outl(0x0, chip->port+GPIO); |
1146 | //outl(0x00f0e000, chip->port+GPIO); /* Analog */ | 1279 | //outl(0x00f0e000, chip->port+GPIO); /* Analog */ |
1147 | outl(0x005f4300, chip->port+GPIO); /* Analog */ | 1280 | outl(0x005f5301, chip->port+GPIO); /* Analog */ |
1148 | } else { | 1281 | } else { |
1149 | outl(0x0, chip->port+GPIO); | 1282 | outl(0x0, chip->port+GPIO); |
1150 | outl(0x005f03a3, chip->port+GPIO); /* Analog */ | 1283 | outl(0x005f03a3, chip->port+GPIO); /* Analog */ |
@@ -1157,6 +1290,10 @@ static int __devinit snd_ca0106_create(snd_card_t *card, | |||
1157 | //outl(0x00000009, chip->port+HCFG); | 1290 | //outl(0x00000009, chip->port+HCFG); |
1158 | outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */ | 1291 | outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */ |
1159 | 1292 | ||
1293 | if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ | ||
1294 | snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ | ||
1295 | } | ||
1296 | |||
1160 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, | 1297 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, |
1161 | chip, &ops)) < 0) { | 1298 | chip, &ops)) < 0) { |
1162 | snd_ca0106_free(chip); | 1299 | snd_ca0106_free(chip); |
@@ -1172,7 +1309,6 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, | |||
1172 | static int dev; | 1309 | static int dev; |
1173 | snd_card_t *card; | 1310 | snd_card_t *card; |
1174 | ca0106_t *chip; | 1311 | ca0106_t *chip; |
1175 | ca0106_names_t *c; | ||
1176 | int err; | 1312 | int err; |
1177 | 1313 | ||
1178 | if (dev >= SNDRV_CARDS) | 1314 | if (dev >= SNDRV_CARDS) |
@@ -1207,9 +1343,7 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, | |||
1207 | snd_card_free(card); | 1343 | snd_card_free(card); |
1208 | return err; | 1344 | return err; |
1209 | } | 1345 | } |
1210 | if ((chip->serial != 0x10061102) && | 1346 | if (chip->details->ac97 == 1) { /* The SB0410 and SB0413 do not have an AC97 chip. */ |
1211 | (chip->serial != 0x10071102) && | ||
1212 | (chip->serial != 0x10091462) ) { /* The SB0410 and SB0413 do not have an ac97 chip. */ | ||
1213 | if ((err = snd_ca0106_ac97(chip)) < 0) { | 1347 | if ((err = snd_ca0106_ac97(chip)) < 0) { |
1214 | snd_card_free(card); | 1348 | snd_card_free(card); |
1215 | return err; | 1349 | return err; |
@@ -1222,15 +1356,6 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, | |||
1222 | 1356 | ||
1223 | snd_ca0106_proc_init(chip); | 1357 | snd_ca0106_proc_init(chip); |
1224 | 1358 | ||
1225 | strcpy(card->driver, "CA0106"); | ||
1226 | strcpy(card->shortname, "CA0106"); | ||
1227 | |||
1228 | for (c=ca0106_chip_names; c->serial; c++) { | ||
1229 | if (c->serial == chip->serial) break; | ||
1230 | } | ||
1231 | sprintf(card->longname, "%s at 0x%lx irq %i", | ||
1232 | c->name, chip->port, chip->irq); | ||
1233 | |||
1234 | if ((err = snd_card_register(card)) < 0) { | 1359 | if ((err = snd_card_register(card)) < 0) { |
1235 | snd_card_free(card); | 1360 | snd_card_free(card); |
1236 | return err; | 1361 | return err; |
@@ -1267,7 +1392,7 @@ static int __init alsa_card_ca0106_init(void) | |||
1267 | { | 1392 | { |
1268 | int err; | 1393 | int err; |
1269 | 1394 | ||
1270 | if ((err = pci_module_init(&driver)) > 0) | 1395 | if ((err = pci_register_driver(&driver)) > 0) |
1271 | return err; | 1396 | return err; |
1272 | 1397 | ||
1273 | return 0; | 1398 | return 0; |
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 97bed1b0899d..0e5e9ce0ff28 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> | 2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> |
3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit | 3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit |
4 | * Version: 0.0.16 | 4 | * Version: 0.0.17 |
5 | * | 5 | * |
6 | * FEATURES currently supported: | 6 | * FEATURES currently supported: |
7 | * See ca0106_main.c for features. | 7 | * See ca0106_main.c for features. |
@@ -37,6 +37,8 @@ | |||
37 | * Separated ca0106.c into separate functional .c files. | 37 | * Separated ca0106.c into separate functional .c files. |
38 | * 0.0.16 | 38 | * 0.0.16 |
39 | * Modified Copyright message. | 39 | * Modified Copyright message. |
40 | * 0.0.17 | ||
41 | * Implement Mic and Line in Capture. | ||
40 | * | 42 | * |
41 | * This code was initally based on code from ALSA's emu10k1x.c which is: | 43 | * This code was initally based on code from ALSA's emu10k1x.c which is: |
42 | * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> | 44 | * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> |
@@ -113,7 +115,7 @@ static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol, | |||
113 | } else { | 115 | } else { |
114 | /* Analog */ | 116 | /* Analog */ |
115 | snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf); | 117 | snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf); |
116 | snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000b0000); | 118 | snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000f0000); |
117 | snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, | 119 | snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, |
118 | snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000); | 120 | snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000); |
119 | mask = inl(emu->port + GPIO) | 0x101; | 121 | mask = inl(emu->port + GPIO) | 0x101; |
@@ -183,6 +185,65 @@ static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata = | |||
183 | .put = snd_ca0106_capture_source_put | 185 | .put = snd_ca0106_capture_source_put |
184 | }; | 186 | }; |
185 | 187 | ||
188 | static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | ||
189 | { | ||
190 | static char *texts[2] = { "Line in", "Mic in" }; | ||
191 | |||
192 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
193 | uinfo->count = 1; | ||
194 | uinfo->value.enumerated.items = 2; | ||
195 | if (uinfo->value.enumerated.item > 1) | ||
196 | uinfo->value.enumerated.item = 1; | ||
197 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | static int snd_ca0106_capture_mic_line_in_get(snd_kcontrol_t * kcontrol, | ||
202 | snd_ctl_elem_value_t * ucontrol) | ||
203 | { | ||
204 | ca0106_t *emu = snd_kcontrol_chip(kcontrol); | ||
205 | |||
206 | ucontrol->value.enumerated.item[0] = emu->capture_mic_line_in; | ||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol, | ||
211 | snd_ctl_elem_value_t * ucontrol) | ||
212 | { | ||
213 | ca0106_t *emu = snd_kcontrol_chip(kcontrol); | ||
214 | unsigned int val; | ||
215 | int change = 0; | ||
216 | u32 tmp; | ||
217 | |||
218 | val = ucontrol->value.enumerated.item[0] ; | ||
219 | change = (emu->capture_mic_line_in != val); | ||
220 | if (change) { | ||
221 | emu->capture_mic_line_in = val; | ||
222 | if (val) { | ||
223 | snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */ | ||
224 | tmp = inl(emu->port+GPIO) & ~0x400; | ||
225 | tmp = tmp | 0x400; | ||
226 | outl(tmp, emu->port+GPIO); | ||
227 | snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC); | ||
228 | } else { | ||
229 | snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */ | ||
230 | tmp = inl(emu->port+GPIO) & ~0x400; | ||
231 | outl(tmp, emu->port+GPIO); | ||
232 | snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN); | ||
233 | } | ||
234 | } | ||
235 | return change; | ||
236 | } | ||
237 | |||
238 | static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata = | ||
239 | { | ||
240 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
241 | .name = "Mic/Line in Capture", | ||
242 | .info = snd_ca0106_capture_mic_line_in_info, | ||
243 | .get = snd_ca0106_capture_mic_line_in_get, | ||
244 | .put = snd_ca0106_capture_mic_line_in_put | ||
245 | }; | ||
246 | |||
186 | static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 247 | static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) |
187 | { | 248 | { |
188 | uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; | 249 | uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; |
@@ -437,7 +498,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe = | |||
437 | static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = | 498 | static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = |
438 | { | 499 | { |
439 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 500 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
440 | .name = "Analog Unknown Volume", | 501 | .name = "Analog Side Volume", |
441 | .info = snd_ca0106_volume_info, | 502 | .info = snd_ca0106_volume_info, |
442 | .get = snd_ca0106_volume_get_analog_unknown, | 503 | .get = snd_ca0106_volume_get_analog_unknown, |
443 | .put = snd_ca0106_volume_put_analog_unknown | 504 | .put = snd_ca0106_volume_put_analog_unknown |
@@ -620,10 +681,11 @@ int __devinit snd_ca0106_mixer(ca0106_t *emu) | |||
620 | return -ENOMEM; | 681 | return -ENOMEM; |
621 | if ((err = snd_ctl_add(card, kctl))) | 682 | if ((err = snd_ctl_add(card, kctl))) |
622 | return err; | 683 | return err; |
623 | if ((kctl = ctl_find(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT))) != NULL) { | 684 | if (emu->details->i2c_adc == 1) { |
624 | /* already defined by ac97, remove it */ | 685 | if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL) |
625 | /* FIXME: or do we need both controls? */ | 686 | return -ENOMEM; |
626 | remove_ctl(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT)); | 687 | if ((err = snd_ctl_add(card, kctl))) |
688 | return err; | ||
627 | } | 689 | } |
628 | if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) | 690 | if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) |
629 | return -ENOMEM; | 691 | return -ENOMEM; |
diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c index afb711421e47..1c9cc821d1b9 100644 --- a/sound/pci/ca0106/ca0106_proc.c +++ b/sound/pci/ca0106/ca0106_proc.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> | 2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> |
3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit | 3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit |
4 | * Version: 0.0.17 | 4 | * Version: 0.0.18 |
5 | * | 5 | * |
6 | * FEATURES currently supported: | 6 | * FEATURES currently supported: |
7 | * See ca0106_main.c for features. | 7 | * See ca0106_main.c for features. |
@@ -39,7 +39,9 @@ | |||
39 | * Modified Copyright message. | 39 | * Modified Copyright message. |
40 | * 0.0.17 | 40 | * 0.0.17 |
41 | * Add iec958 file in proc file system to show status of SPDIF in. | 41 | * Add iec958 file in proc file system to show status of SPDIF in. |
42 | * | 42 | * 0.0.18 |
43 | * Implement support for Line-in capture on SB Live 24bit. | ||
44 | * | ||
43 | * This code was initally based on code from ALSA's emu10k1x.c which is: | 45 | * This code was initally based on code from ALSA's emu10k1x.c which is: |
44 | * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> | 46 | * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> |
45 | * | 47 | * |
@@ -95,7 +97,7 @@ static struct snd_ca0106_category_str snd_ca0106_con_category[] = { | |||
95 | }; | 97 | }; |
96 | 98 | ||
97 | 99 | ||
98 | void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value) | 100 | static void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value) |
99 | { | 101 | { |
100 | int i; | 102 | int i; |
101 | u32 status[4]; | 103 | u32 status[4]; |
@@ -407,6 +409,20 @@ static void snd_ca0106_proc_reg_write(snd_info_entry_t *entry, | |||
407 | } | 409 | } |
408 | } | 410 | } |
409 | 411 | ||
412 | static void snd_ca0106_proc_i2c_write(snd_info_entry_t *entry, | ||
413 | snd_info_buffer_t * buffer) | ||
414 | { | ||
415 | ca0106_t *emu = entry->private_data; | ||
416 | char line[64]; | ||
417 | unsigned int reg, val; | ||
418 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | ||
419 | if (sscanf(line, "%x %x", ®, &val) != 2) | ||
420 | continue; | ||
421 | if ((reg <= 0x7f) || (val <= 0x1ff)) { | ||
422 | snd_ca0106_i2c_write(emu, reg, val); | ||
423 | } | ||
424 | } | ||
425 | } | ||
410 | 426 | ||
411 | int __devinit snd_ca0106_proc_init(ca0106_t * emu) | 427 | int __devinit snd_ca0106_proc_init(ca0106_t * emu) |
412 | { | 428 | { |
@@ -418,6 +434,7 @@ int __devinit snd_ca0106_proc_init(ca0106_t * emu) | |||
418 | snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read32); | 434 | snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read32); |
419 | entry->c.text.write_size = 64; | 435 | entry->c.text.write_size = 64; |
420 | entry->c.text.write = snd_ca0106_proc_reg_write32; | 436 | entry->c.text.write = snd_ca0106_proc_reg_write32; |
437 | entry->mode |= S_IWUSR; | ||
421 | } | 438 | } |
422 | if(! snd_card_proc_new(emu->card, "ca0106_reg16", &entry)) | 439 | if(! snd_card_proc_new(emu->card, "ca0106_reg16", &entry)) |
423 | snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read16); | 440 | snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read16); |
@@ -427,6 +444,14 @@ int __devinit snd_ca0106_proc_init(ca0106_t * emu) | |||
427 | snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read1); | 444 | snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read1); |
428 | entry->c.text.write_size = 64; | 445 | entry->c.text.write_size = 64; |
429 | entry->c.text.write = snd_ca0106_proc_reg_write; | 446 | entry->c.text.write = snd_ca0106_proc_reg_write; |
447 | entry->mode |= S_IWUSR; | ||
448 | // entry->private_data = emu; | ||
449 | } | ||
450 | if(! snd_card_proc_new(emu->card, "ca0106_i2c", &entry)) { | ||
451 | snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_i2c_write); | ||
452 | entry->c.text.write_size = 64; | ||
453 | entry->c.text.write = snd_ca0106_proc_i2c_write; | ||
454 | entry->mode |= S_IWUSR; | ||
430 | // entry->private_data = emu; | 455 | // entry->private_data = emu; |
431 | } | 456 | } |
432 | if(! snd_card_proc_new(emu->card, "ca0106_regs2", &entry)) | 457 | if(! snd_card_proc_new(emu->card, "ca0106_regs2", &entry)) |
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 113208fbde1b..b4503385ea69 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c | |||
@@ -519,40 +519,50 @@ inline static unsigned char snd_cmipci_read_b(cmipci_t *cm, unsigned int cmd) | |||
519 | } | 519 | } |
520 | 520 | ||
521 | /* bit operations for dword register */ | 521 | /* bit operations for dword register */ |
522 | static void snd_cmipci_set_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) | 522 | static int snd_cmipci_set_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) |
523 | { | 523 | { |
524 | unsigned int val; | 524 | unsigned int val, oval; |
525 | val = inl(cm->iobase + cmd); | 525 | val = oval = inl(cm->iobase + cmd); |
526 | val |= flag; | 526 | val |= flag; |
527 | if (val == oval) | ||
528 | return 0; | ||
527 | outl(val, cm->iobase + cmd); | 529 | outl(val, cm->iobase + cmd); |
530 | return 1; | ||
528 | } | 531 | } |
529 | 532 | ||
530 | static void snd_cmipci_clear_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) | 533 | static int snd_cmipci_clear_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) |
531 | { | 534 | { |
532 | unsigned int val; | 535 | unsigned int val, oval; |
533 | val = inl(cm->iobase + cmd); | 536 | val = oval = inl(cm->iobase + cmd); |
534 | val &= ~flag; | 537 | val &= ~flag; |
538 | if (val == oval) | ||
539 | return 0; | ||
535 | outl(val, cm->iobase + cmd); | 540 | outl(val, cm->iobase + cmd); |
541 | return 1; | ||
536 | } | 542 | } |
537 | 543 | ||
538 | #if 0 // not used | ||
539 | /* bit operations for byte register */ | 544 | /* bit operations for byte register */ |
540 | static void snd_cmipci_set_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag) | 545 | static int snd_cmipci_set_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag) |
541 | { | 546 | { |
542 | unsigned char val; | 547 | unsigned char val, oval; |
543 | val = inb(cm->iobase + cmd); | 548 | val = oval = inb(cm->iobase + cmd); |
544 | val |= flag; | 549 | val |= flag; |
550 | if (val == oval) | ||
551 | return 0; | ||
545 | outb(val, cm->iobase + cmd); | 552 | outb(val, cm->iobase + cmd); |
553 | return 1; | ||
546 | } | 554 | } |
547 | 555 | ||
548 | static void snd_cmipci_clear_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag) | 556 | static int snd_cmipci_clear_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag) |
549 | { | 557 | { |
550 | unsigned char val; | 558 | unsigned char val, oval; |
551 | val = inb(cm->iobase + cmd); | 559 | val = oval = inb(cm->iobase + cmd); |
552 | val &= ~flag; | 560 | val &= ~flag; |
561 | if (val == oval) | ||
562 | return 0; | ||
553 | outb(val, cm->iobase + cmd); | 563 | outb(val, cm->iobase + cmd); |
564 | return 1; | ||
554 | } | 565 | } |
555 | #endif | ||
556 | 566 | ||
557 | 567 | ||
558 | /* | 568 | /* |
@@ -2250,8 +2260,8 @@ DEFINE_SWITCH_ARG(exchange_dac, CM_REG_MISC_CTRL, CM_XCHGDAC, 0, 0, 0); /* rever | |||
2250 | DEFINE_SWITCH_ARG(exchange_dac, CM_REG_MISC_CTRL, CM_XCHGDAC, CM_XCHGDAC, 0, 0); | 2260 | DEFINE_SWITCH_ARG(exchange_dac, CM_REG_MISC_CTRL, CM_XCHGDAC, CM_XCHGDAC, 0, 0); |
2251 | #endif | 2261 | #endif |
2252 | DEFINE_BIT_SWITCH_ARG(fourch, CM_REG_MISC_CTRL, CM_N4SPK3D, 0, 0); | 2262 | DEFINE_BIT_SWITCH_ARG(fourch, CM_REG_MISC_CTRL, CM_N4SPK3D, 0, 0); |
2253 | DEFINE_BIT_SWITCH_ARG(line_rear, CM_REG_MIXER1, CM_SPK4, 1, 0); | 2263 | // DEFINE_BIT_SWITCH_ARG(line_rear, CM_REG_MIXER1, CM_SPK4, 1, 0); |
2254 | DEFINE_BIT_SWITCH_ARG(line_bass, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS, 0, 0); | 2264 | // DEFINE_BIT_SWITCH_ARG(line_bass, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS, 0, 0); |
2255 | // DEFINE_BIT_SWITCH_ARG(joystick, CM_REG_FUNCTRL1, CM_JYSTK_EN, 0, 0); /* now module option */ | 2265 | // DEFINE_BIT_SWITCH_ARG(joystick, CM_REG_FUNCTRL1, CM_JYSTK_EN, 0, 0); /* now module option */ |
2256 | DEFINE_SWITCH_ARG(modem, CM_REG_MISC_CTRL, CM_FLINKON|CM_FLINKOFF, CM_FLINKON, 0, 0); | 2266 | DEFINE_SWITCH_ARG(modem, CM_REG_MISC_CTRL, CM_FLINKON|CM_FLINKOFF, CM_FLINKON, 0, 0); |
2257 | 2267 | ||
@@ -2300,10 +2310,114 @@ static int snd_cmipci_spdout_enable_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_v | |||
2300 | } | 2310 | } |
2301 | 2311 | ||
2302 | 2312 | ||
2313 | static int snd_cmipci_line_in_mode_info(snd_kcontrol_t *kcontrol, | ||
2314 | snd_ctl_elem_info_t *uinfo) | ||
2315 | { | ||
2316 | cmipci_t *cm = snd_kcontrol_chip(kcontrol); | ||
2317 | static char *texts[3] = { "Line-In", "Rear Output", "Bass Output" }; | ||
2318 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2319 | uinfo->count = 1; | ||
2320 | uinfo->value.enumerated.items = cm->chip_version >= 39 ? 3 : 2; | ||
2321 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
2322 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
2323 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
2324 | return 0; | ||
2325 | } | ||
2326 | |||
2327 | static inline unsigned int get_line_in_mode(cmipci_t *cm) | ||
2328 | { | ||
2329 | unsigned int val; | ||
2330 | if (cm->chip_version >= 39) { | ||
2331 | val = snd_cmipci_read(cm, CM_REG_LEGACY_CTRL); | ||
2332 | if (val & CM_LINE_AS_BASS) | ||
2333 | return 2; | ||
2334 | } | ||
2335 | val = snd_cmipci_read_b(cm, CM_REG_MIXER1); | ||
2336 | if (val & CM_SPK4) | ||
2337 | return 1; | ||
2338 | return 0; | ||
2339 | } | ||
2340 | |||
2341 | static int snd_cmipci_line_in_mode_get(snd_kcontrol_t *kcontrol, | ||
2342 | snd_ctl_elem_value_t *ucontrol) | ||
2343 | { | ||
2344 | cmipci_t *cm = snd_kcontrol_chip(kcontrol); | ||
2345 | |||
2346 | spin_lock_irq(&cm->reg_lock); | ||
2347 | ucontrol->value.enumerated.item[0] = get_line_in_mode(cm); | ||
2348 | spin_unlock_irq(&cm->reg_lock); | ||
2349 | return 0; | ||
2350 | } | ||
2351 | |||
2352 | static int snd_cmipci_line_in_mode_put(snd_kcontrol_t *kcontrol, | ||
2353 | snd_ctl_elem_value_t *ucontrol) | ||
2354 | { | ||
2355 | cmipci_t *cm = snd_kcontrol_chip(kcontrol); | ||
2356 | int change; | ||
2357 | |||
2358 | spin_lock_irq(&cm->reg_lock); | ||
2359 | if (ucontrol->value.enumerated.item[0] == 2) | ||
2360 | change = snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS); | ||
2361 | else | ||
2362 | change = snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS); | ||
2363 | if (ucontrol->value.enumerated.item[0] == 1) | ||
2364 | change |= snd_cmipci_set_bit_b(cm, CM_REG_MIXER1, CM_SPK4); | ||
2365 | else | ||
2366 | change |= snd_cmipci_clear_bit_b(cm, CM_REG_MIXER1, CM_SPK4); | ||
2367 | spin_unlock_irq(&cm->reg_lock); | ||
2368 | return change; | ||
2369 | } | ||
2370 | |||
2371 | static int snd_cmipci_mic_in_mode_info(snd_kcontrol_t *kcontrol, | ||
2372 | snd_ctl_elem_info_t *uinfo) | ||
2373 | { | ||
2374 | static char *texts[2] = { "Mic-In", "Center/LFE Output" }; | ||
2375 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2376 | uinfo->count = 1; | ||
2377 | uinfo->value.enumerated.items = 2; | ||
2378 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
2379 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
2380 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
2381 | return 0; | ||
2382 | } | ||
2383 | |||
2384 | static int snd_cmipci_mic_in_mode_get(snd_kcontrol_t *kcontrol, | ||
2385 | snd_ctl_elem_value_t *ucontrol) | ||
2386 | { | ||
2387 | cmipci_t *cm = snd_kcontrol_chip(kcontrol); | ||
2388 | /* same bit as spdi_phase */ | ||
2389 | spin_lock_irq(&cm->reg_lock); | ||
2390 | ucontrol->value.enumerated.item[0] = | ||
2391 | (snd_cmipci_read_b(cm, CM_REG_MISC) & CM_SPDIF_INVERSE) ? 1 : 0; | ||
2392 | spin_unlock_irq(&cm->reg_lock); | ||
2393 | return 0; | ||
2394 | } | ||
2395 | |||
2396 | static int snd_cmipci_mic_in_mode_put(snd_kcontrol_t *kcontrol, | ||
2397 | snd_ctl_elem_value_t *ucontrol) | ||
2398 | { | ||
2399 | cmipci_t *cm = snd_kcontrol_chip(kcontrol); | ||
2400 | int change; | ||
2401 | |||
2402 | spin_lock_irq(&cm->reg_lock); | ||
2403 | if (ucontrol->value.enumerated.item[0]) | ||
2404 | change = snd_cmipci_set_bit_b(cm, CM_REG_MISC, CM_SPDIF_INVERSE); | ||
2405 | else | ||
2406 | change = snd_cmipci_clear_bit_b(cm, CM_REG_MISC, CM_SPDIF_INVERSE); | ||
2407 | spin_unlock_irq(&cm->reg_lock); | ||
2408 | return change; | ||
2409 | } | ||
2410 | |||
2303 | /* both for CM8338/8738 */ | 2411 | /* both for CM8338/8738 */ |
2304 | static snd_kcontrol_new_t snd_cmipci_mixer_switches[] __devinitdata = { | 2412 | static snd_kcontrol_new_t snd_cmipci_mixer_switches[] __devinitdata = { |
2305 | DEFINE_MIXER_SWITCH("Four Channel Mode", fourch), | 2413 | DEFINE_MIXER_SWITCH("Four Channel Mode", fourch), |
2306 | DEFINE_MIXER_SWITCH("Line-In As Rear", line_rear), | 2414 | { |
2415 | .name = "Line-In Mode", | ||
2416 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2417 | .info = snd_cmipci_line_in_mode_info, | ||
2418 | .get = snd_cmipci_line_in_mode_get, | ||
2419 | .put = snd_cmipci_line_in_mode_put, | ||
2420 | }, | ||
2307 | }; | 2421 | }; |
2308 | 2422 | ||
2309 | /* for non-multichannel chips */ | 2423 | /* for non-multichannel chips */ |
@@ -2341,10 +2455,15 @@ static snd_kcontrol_new_t snd_cmipci_old_mixer_switches[] __devinitdata = { | |||
2341 | 2455 | ||
2342 | /* only for model 039 or later */ | 2456 | /* only for model 039 or later */ |
2343 | static snd_kcontrol_new_t snd_cmipci_extra_mixer_switches[] __devinitdata = { | 2457 | static snd_kcontrol_new_t snd_cmipci_extra_mixer_switches[] __devinitdata = { |
2344 | DEFINE_MIXER_SWITCH("Line-In As Bass", line_bass), | ||
2345 | DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel2), | 2458 | DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel2), |
2346 | DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase2), | 2459 | DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase2), |
2347 | DEFINE_MIXER_SWITCH("Mic As Center/LFE", spdi_phase), /* same bit as spdi_phase */ | 2460 | { |
2461 | .name = "Mic-In Mode", | ||
2462 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2463 | .info = snd_cmipci_mic_in_mode_info, | ||
2464 | .get = snd_cmipci_mic_in_mode_get, | ||
2465 | .put = snd_cmipci_mic_in_mode_put, | ||
2466 | } | ||
2348 | }; | 2467 | }; |
2349 | 2468 | ||
2350 | /* card control switches */ | 2469 | /* card control switches */ |
@@ -2944,7 +3063,7 @@ static struct pci_driver driver = { | |||
2944 | 3063 | ||
2945 | static int __init alsa_card_cmipci_init(void) | 3064 | static int __init alsa_card_cmipci_init(void) |
2946 | { | 3065 | { |
2947 | return pci_module_init(&driver); | 3066 | return pci_register_driver(&driver); |
2948 | } | 3067 | } |
2949 | 3068 | ||
2950 | static void __exit alsa_card_cmipci_exit(void) | 3069 | static void __exit alsa_card_cmipci_exit(void) |
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 0b53f7c61f86..eb3c52b03af3 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c | |||
@@ -206,7 +206,10 @@ MODULE_PARM_DESC(dual_codec, "Secondary Codec ID (0 = disabled)."); | |||
206 | 206 | ||
207 | #define BA0_PMCS 0x0344 /* Power Management Control/Status */ | 207 | #define BA0_PMCS 0x0344 /* Power Management Control/Status */ |
208 | #define BA0_CWPR 0x03e0 /* Configuration Write Protect */ | 208 | #define BA0_CWPR 0x03e0 /* Configuration Write Protect */ |
209 | |||
209 | #define BA0_EPPMC 0x03e4 /* Extended PCI Power Management Control */ | 210 | #define BA0_EPPMC 0x03e4 /* Extended PCI Power Management Control */ |
211 | #define BA0_EPPMC_FPDN (1<<14) /* Full Power DowN */ | ||
212 | |||
210 | #define BA0_GPIOR 0x03e8 /* GPIO Pin Interface Register */ | 213 | #define BA0_GPIOR 0x03e8 /* GPIO Pin Interface Register */ |
211 | 214 | ||
212 | #define BA0_SPMC 0x03ec /* Serial Port Power Management Control (& ASDIN2 enable) */ | 215 | #define BA0_SPMC 0x03ec /* Serial Port Power Management Control (& ASDIN2 enable) */ |
@@ -1456,6 +1459,11 @@ static int snd_cs4281_chip_init(cs4281_t *chip) | |||
1456 | int timeout; | 1459 | int timeout; |
1457 | int retry_count = 2; | 1460 | int retry_count = 2; |
1458 | 1461 | ||
1462 | /* Having EPPMC.FPDN=1 prevent proper chip initialisation */ | ||
1463 | tmp = snd_cs4281_peekBA0(chip, BA0_EPPMC); | ||
1464 | if (tmp & BA0_EPPMC_FPDN) | ||
1465 | snd_cs4281_pokeBA0(chip, BA0_EPPMC, tmp & ~BA0_EPPMC_FPDN); | ||
1466 | |||
1459 | __retry: | 1467 | __retry: |
1460 | tmp = snd_cs4281_peekBA0(chip, BA0_CFLR); | 1468 | tmp = snd_cs4281_peekBA0(chip, BA0_CFLR); |
1461 | if (tmp != BA0_CFLR_DEFAULT) { | 1469 | if (tmp != BA0_CFLR_DEFAULT) { |
@@ -2119,7 +2127,7 @@ static struct pci_driver driver = { | |||
2119 | 2127 | ||
2120 | static int __init alsa_card_cs4281_init(void) | 2128 | static int __init alsa_card_cs4281_init(void) |
2121 | { | 2129 | { |
2122 | return pci_module_init(&driver); | 2130 | return pci_register_driver(&driver); |
2123 | } | 2131 | } |
2124 | 2132 | ||
2125 | static void __exit alsa_card_cs4281_exit(void) | 2133 | static void __exit alsa_card_cs4281_exit(void) |
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index 25d6466a867c..db212ecd792a 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c | |||
@@ -171,7 +171,7 @@ static struct pci_driver driver = { | |||
171 | 171 | ||
172 | static int __init alsa_card_cs46xx_init(void) | 172 | static int __init alsa_card_cs46xx_init(void) |
173 | { | 173 | { |
174 | return pci_module_init(&driver); | 174 | return pci_register_driver(&driver); |
175 | } | 175 | } |
176 | 176 | ||
177 | static void __exit alsa_card_cs46xx_exit(void) | 177 | static void __exit alsa_card_cs46xx_exit(void) |
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 5f2ffb7efa06..fd4c50c88bc9 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c | |||
@@ -1295,8 +1295,7 @@ static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = { | |||
1295 | 1295 | ||
1296 | static void snd_cs46xx_pcm_free_substream(snd_pcm_runtime_t *runtime) | 1296 | static void snd_cs46xx_pcm_free_substream(snd_pcm_runtime_t *runtime) |
1297 | { | 1297 | { |
1298 | cs46xx_pcm_t * cpcm = runtime->private_data; | 1298 | kfree(runtime->private_data); |
1299 | kfree(cpcm); | ||
1300 | } | 1299 | } |
1301 | 1300 | ||
1302 | static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pcm_channel_id) | 1301 | static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pcm_channel_id) |
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 6446afe19d80..2085a998eaeb 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c | |||
@@ -228,7 +228,7 @@ static struct pci_driver driver = { | |||
228 | 228 | ||
229 | static int __init alsa_card_emu10k1_init(void) | 229 | static int __init alsa_card_emu10k1_init(void) |
230 | { | 230 | { |
231 | return pci_module_init(&driver); | 231 | return pci_register_driver(&driver); |
232 | } | 232 | } |
233 | 233 | ||
234 | static void __exit alsa_card_emu10k1_exit(void) | 234 | static void __exit alsa_card_emu10k1_exit(void) |
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index c3c96f9f2c7f..a341e758acde 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c | |||
@@ -170,7 +170,7 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) | |||
170 | SPCS_GENERATIONSTATUS | 0x00001200 | | 170 | SPCS_GENERATIONSTATUS | 0x00001200 | |
171 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); | 171 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); |
172 | 172 | ||
173 | if (emu->audigy && emu->revision == 4) { /* audigy2 */ | 173 | if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ |
174 | /* Hacks for Alice3 to work independent of haP16V driver */ | 174 | /* Hacks for Alice3 to work independent of haP16V driver */ |
175 | u32 tmp; | 175 | u32 tmp; |
176 | 176 | ||
@@ -189,7 +189,7 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) | |||
189 | /* Enabled Phased (8-channel) P16V playback */ | 189 | /* Enabled Phased (8-channel) P16V playback */ |
190 | outl(0x0201, emu->port + HCFG2); | 190 | outl(0x0201, emu->port + HCFG2); |
191 | /* Set playback routing. */ | 191 | /* Set playback routing. */ |
192 | snd_emu10k1_ptr_write(emu, CAPTURE_P16V_SOURCE, 0, 78e4); | 192 | snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, 0x78e4); |
193 | } | 193 | } |
194 | if (emu->audigy && (emu->serial == 0x10011102) ) { /* audigy2 Value */ | 194 | if (emu->audigy && (emu->serial == 0x10011102) ) { /* audigy2 Value */ |
195 | /* Hacks for Alice3 to work independent of haP16V driver */ | 195 | /* Hacks for Alice3 to work independent of haP16V driver */ |
@@ -600,7 +600,7 @@ static int snd_emu10k1_free(emu10k1_t *emu) | |||
600 | if (emu->port) | 600 | if (emu->port) |
601 | pci_release_regions(emu->pci); | 601 | pci_release_regions(emu->pci); |
602 | pci_disable_device(emu->pci); | 602 | pci_disable_device(emu->pci); |
603 | if (emu->audigy && emu->revision == 4) /* P16V */ | 603 | if (emu->card_capabilities->ca0151_chip) /* P16V */ |
604 | snd_p16v_free(emu); | 604 | snd_p16v_free(emu); |
605 | kfree(emu); | 605 | kfree(emu); |
606 | return 0; | 606 | return 0; |
@@ -612,21 +612,24 @@ static int snd_emu10k1_dev_free(snd_device_t *device) | |||
612 | return snd_emu10k1_free(emu); | 612 | return snd_emu10k1_free(emu); |
613 | } | 613 | } |
614 | 614 | ||
615 | /* vendor, device, subsystem, emu10k1_chip, emu10k2_chip, ca0102_chip, ca0108_chip, ca0151_chip, spk71, spdif_bug, ac97_chip, ecard, driver, name */ | ||
616 | |||
617 | static emu_chip_details_t emu_chip_details[] = { | 615 | static emu_chip_details_t emu_chip_details[] = { |
618 | /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ | 616 | /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ |
619 | {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, | 617 | {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, |
620 | .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", | 618 | .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", |
619 | .id = "Audigy2", | ||
621 | .emu10k2_chip = 1, | 620 | .emu10k2_chip = 1, |
622 | .ca0108_chip = 1, | 621 | .ca0108_chip = 1, |
623 | .spk71 = 1} , | 622 | .spk71 = 1, |
623 | .ac97_chip = 1} , | ||
624 | {.vendor = 0x1102, .device = 0x0008, | 624 | {.vendor = 0x1102, .device = 0x0008, |
625 | .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", | 625 | .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", |
626 | .id = "Audigy2", | ||
626 | .emu10k2_chip = 1, | 627 | .emu10k2_chip = 1, |
627 | .ca0108_chip = 1} , | 628 | .ca0108_chip = 1, |
629 | .ac97_chip = 1} , | ||
628 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, | 630 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, |
629 | .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", | 631 | .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", |
632 | .id = "Audigy2", | ||
630 | .emu10k2_chip = 1, | 633 | .emu10k2_chip = 1, |
631 | .ca0102_chip = 1, | 634 | .ca0102_chip = 1, |
632 | .ca0151_chip = 1, | 635 | .ca0151_chip = 1, |
@@ -635,6 +638,7 @@ static emu_chip_details_t emu_chip_details[] = { | |||
635 | .ac97_chip = 1} , | 638 | .ac97_chip = 1} , |
636 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, | 639 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, |
637 | .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", | 640 | .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", |
641 | .id = "Audigy2", | ||
638 | .emu10k2_chip = 1, | 642 | .emu10k2_chip = 1, |
639 | .ca0102_chip = 1, | 643 | .ca0102_chip = 1, |
640 | .ca0151_chip = 1, | 644 | .ca0151_chip = 1, |
@@ -643,6 +647,7 @@ static emu_chip_details_t emu_chip_details[] = { | |||
643 | .ac97_chip = 1} , | 647 | .ac97_chip = 1} , |
644 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, | 648 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, |
645 | .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", | 649 | .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", |
650 | .id = "Audigy2", | ||
646 | .emu10k2_chip = 1, | 651 | .emu10k2_chip = 1, |
647 | .ca0102_chip = 1, | 652 | .ca0102_chip = 1, |
648 | .ca0151_chip = 1, | 653 | .ca0151_chip = 1, |
@@ -651,6 +656,7 @@ static emu_chip_details_t emu_chip_details[] = { | |||
651 | .ac97_chip = 1} , | 656 | .ac97_chip = 1} , |
652 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, | 657 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, |
653 | .driver = "Audigy2", .name = "Audigy 2 [SB0240]", | 658 | .driver = "Audigy2", .name = "Audigy 2 [SB0240]", |
659 | .id = "Audigy2", | ||
654 | .emu10k2_chip = 1, | 660 | .emu10k2_chip = 1, |
655 | .ca0102_chip = 1, | 661 | .ca0102_chip = 1, |
656 | .ca0151_chip = 1, | 662 | .ca0151_chip = 1, |
@@ -659,35 +665,165 @@ static emu_chip_details_t emu_chip_details[] = { | |||
659 | .ac97_chip = 1} , | 665 | .ac97_chip = 1} , |
660 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, | 666 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, |
661 | .driver = "Audigy2", .name = "Audigy 2 EX [1005]", | 667 | .driver = "Audigy2", .name = "Audigy 2 EX [1005]", |
668 | .id = "Audigy2", | ||
662 | .emu10k2_chip = 1, | 669 | .emu10k2_chip = 1, |
663 | .ca0102_chip = 1, | 670 | .ca0102_chip = 1, |
664 | .ca0151_chip = 1, | 671 | .ca0151_chip = 1, |
665 | .spdif_bug = 1} , | 672 | .spdif_bug = 1} , |
666 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, | 673 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, |
667 | .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", | 674 | .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", |
675 | .id = "Audigy2", | ||
668 | .emu10k2_chip = 1, | 676 | .emu10k2_chip = 1, |
669 | .ca0102_chip = 1, | 677 | .ca0102_chip = 1, |
670 | .ca0151_chip = 1, | 678 | .ca0151_chip = 1, |
671 | .spk71 = 1, | 679 | .spk71 = 1, |
672 | .spdif_bug = 1, | 680 | .spdif_bug = 1, |
673 | .ac97_chip = 1} , | 681 | .ac97_chip = 1} , |
682 | {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, | ||
683 | .driver = "Audigy2", .name = "Audigy 2 [Unknown]", | ||
684 | .id = "Audigy2", | ||
685 | .emu10k2_chip = 1, | ||
686 | .ca0102_chip = 1, | ||
687 | .ca0151_chip = 1, | ||
688 | .spdif_bug = 1, | ||
689 | .ac97_chip = 1} , | ||
690 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10020052, | ||
691 | .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", | ||
692 | .id = "Audigy", | ||
693 | .emu10k2_chip = 1, | ||
694 | .ca0102_chip = 1, | ||
695 | .spdif_bug = 1, | ||
696 | .ac97_chip = 1} , | ||
697 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, | ||
698 | .driver = "Audigy", .name = "Audigy 1 [SB0090]", | ||
699 | .id = "Audigy", | ||
700 | .emu10k2_chip = 1, | ||
701 | .ca0102_chip = 1, | ||
702 | .ac97_chip = 1} , | ||
703 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, | ||
704 | .driver = "Audigy", .name = "Audigy 1 [SB0090]", | ||
705 | .id = "Audigy", | ||
706 | .emu10k2_chip = 1, | ||
707 | .ca0102_chip = 1, | ||
708 | .ac97_chip = 1} , | ||
674 | {.vendor = 0x1102, .device = 0x0004, | 709 | {.vendor = 0x1102, .device = 0x0004, |
675 | .driver = "Audigy", .name = "Audigy 1 or 2 [Unknown]", | 710 | .driver = "Audigy", .name = "Audigy 1 [Unknown]", |
711 | .id = "Audigy", | ||
676 | .emu10k2_chip = 1, | 712 | .emu10k2_chip = 1, |
677 | .ca0102_chip = 1, | 713 | .ca0102_chip = 1, |
678 | .spdif_bug = 1} , | 714 | .ac97_chip = 1} , |
679 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, | 715 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, |
680 | .driver = "EMU10K1", .name = "E-mu APS [4001]", | 716 | .driver = "EMU10K1", .name = "E-mu APS [4001]", |
717 | .id = "APS", | ||
681 | .emu10k1_chip = 1, | 718 | .emu10k1_chip = 1, |
682 | .ecard = 1} , | 719 | .ecard = 1} , |
720 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, | ||
721 | .driver = "EMU10K1", .name = "SBLive! Player 5.1 [SB0060]", | ||
722 | .id = "Live", | ||
723 | .emu10k1_chip = 1, | ||
724 | .ac97_chip = 1, | ||
725 | .sblive51 = 1} , | ||
683 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, | 726 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, |
684 | .driver = "EMU10K1", .name = "SB Live 5.1", | 727 | .driver = "EMU10K1", .name = "SB Live 5.1", |
728 | .id = "Live", | ||
729 | .emu10k1_chip = 1, | ||
730 | .ac97_chip = 1, | ||
731 | .sblive51 = 1} , | ||
732 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, | ||
733 | .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", | ||
734 | .id = "Live", | ||
685 | .emu10k1_chip = 1, | 735 | .emu10k1_chip = 1, |
686 | .ac97_chip = 1} , | 736 | .ac97_chip = 1} , |
737 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, | ||
738 | .driver = "EMU10K1", .name = "SBLive! [CT4620]", | ||
739 | .id = "Live", | ||
740 | .emu10k1_chip = 1, | ||
741 | .ac97_chip = 1, | ||
742 | .sblive51 = 1} , | ||
743 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, | ||
744 | .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", | ||
745 | .id = "Live", | ||
746 | .emu10k1_chip = 1, | ||
747 | .ac97_chip = 1, | ||
748 | .sblive51 = 1} , | ||
749 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, | ||
750 | .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", | ||
751 | .id = "Live", | ||
752 | .emu10k1_chip = 1, | ||
753 | .ac97_chip = 1, | ||
754 | .sblive51 = 1} , | ||
755 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, | ||
756 | .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", | ||
757 | .id = "Live", | ||
758 | .emu10k1_chip = 1, | ||
759 | .ac97_chip = 1, | ||
760 | .sblive51 = 1} , | ||
761 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, | ||
762 | .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", | ||
763 | .id = "Live", | ||
764 | .emu10k1_chip = 1, | ||
765 | .ac97_chip = 1, | ||
766 | .sblive51 = 1} , | ||
767 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, | ||
768 | .driver = "EMU10K1", .name = "SBLive! Value [CT4831]", | ||
769 | .id = "Live", | ||
770 | .emu10k1_chip = 1, | ||
771 | .ac97_chip = 1, | ||
772 | .sblive51 = 1} , | ||
773 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, | ||
774 | .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", | ||
775 | .id = "Live", | ||
776 | .emu10k1_chip = 1, | ||
777 | .ac97_chip = 1, | ||
778 | .sblive51 = 1} , | ||
779 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, | ||
780 | .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", | ||
781 | .id = "Live", | ||
782 | .emu10k1_chip = 1, | ||
783 | .ac97_chip = 1, | ||
784 | .sblive51 = 1} , | ||
785 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, | ||
786 | .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", | ||
787 | .id = "Live", | ||
788 | .emu10k1_chip = 1, | ||
789 | .ac97_chip = 1, | ||
790 | .sblive51 = 1} , | ||
791 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, | ||
792 | .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", | ||
793 | .id = "Live", | ||
794 | .emu10k1_chip = 1, | ||
795 | .ac97_chip = 1, | ||
796 | .sblive51 = 1} , | ||
797 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, | ||
798 | .driver = "EMU10K1", .name = "SBLive! Value [SB0060]", | ||
799 | .id = "Live", | ||
800 | .emu10k1_chip = 1, | ||
801 | .ac97_chip = 1, | ||
802 | .sblive51 = 1} , | ||
803 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, | ||
804 | .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", | ||
805 | .id = "Live", | ||
806 | .emu10k1_chip = 1, | ||
807 | .ac97_chip = 1, | ||
808 | .sblive51 = 1} , | ||
809 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, | ||
810 | .driver = "EMU10K1", .name = "SBLive! Value [SB0103]", | ||
811 | .id = "Live", | ||
812 | .emu10k1_chip = 1, | ||
813 | .ac97_chip = 1, | ||
814 | .sblive51 = 1} , | ||
815 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, | ||
816 | .driver = "EMU10K1", .name = "SBLive! [SB0105]", | ||
817 | .id = "Live", | ||
818 | .emu10k1_chip = 1, | ||
819 | .ac97_chip = 1, | ||
820 | .sblive51 = 1} , | ||
687 | {.vendor = 0x1102, .device = 0x0002, | 821 | {.vendor = 0x1102, .device = 0x0002, |
688 | .driver = "EMU10K1", .name = "SB Live [Unknown]", | 822 | .driver = "EMU10K1", .name = "SB Live [Unknown]", |
823 | .id = "Live", | ||
689 | .emu10k1_chip = 1, | 824 | .emu10k1_chip = 1, |
690 | .ac97_chip = 1} , | 825 | .ac97_chip = 1, |
826 | .sblive51 = 1} , | ||
691 | { } /* terminator */ | 827 | { } /* terminator */ |
692 | }; | 828 | }; |
693 | 829 | ||
@@ -738,13 +874,15 @@ int __devinit snd_emu10k1_create(snd_card_t * card, | |||
738 | emu->revision = revision; | 874 | emu->revision = revision; |
739 | pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); | 875 | pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); |
740 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); | 876 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); |
741 | emu->card_type = EMU10K1_CARD_CREATIVE; | ||
742 | snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model); | 877 | snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model); |
743 | 878 | ||
744 | for (c = emu_chip_details; c->vendor; c++) { | 879 | for (c = emu_chip_details; c->vendor; c++) { |
745 | if (c->vendor == pci->vendor && c->device == pci->device) { | 880 | if (c->vendor == pci->vendor && c->device == pci->device) { |
746 | if (c->subsystem == emu->serial) break; | 881 | if (c->subsystem && c->subsystem != emu->serial) |
747 | if (c->subsystem == 0) break; | 882 | continue; |
883 | if (c->revision && c->revision != emu->revision) | ||
884 | continue; | ||
885 | break; | ||
748 | } | 886 | } |
749 | } | 887 | } |
750 | if (c->vendor == 0) { | 888 | if (c->vendor == 0) { |
@@ -759,6 +897,23 @@ int __devinit snd_emu10k1_create(snd_card_t * card, | |||
759 | else | 897 | else |
760 | snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x\n", c->name, pci->vendor, pci->device, emu->serial); | 898 | snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x\n", c->name, pci->vendor, pci->device, emu->serial); |
761 | 899 | ||
900 | if (!*card->id && c->id) { | ||
901 | int i, n = 0; | ||
902 | strlcpy(card->id, c->id, sizeof(card->id)); | ||
903 | for (;;) { | ||
904 | for (i = 0; i < snd_ecards_limit; i++) { | ||
905 | if (snd_cards[i] && !strcmp(snd_cards[i]->id, card->id)) | ||
906 | break; | ||
907 | } | ||
908 | if (i >= snd_ecards_limit) | ||
909 | break; | ||
910 | n++; | ||
911 | if (n >= SNDRV_CARDS) | ||
912 | break; | ||
913 | snprintf(card->id, sizeof(card->id), "%s_%d", c->id, n); | ||
914 | } | ||
915 | } | ||
916 | |||
762 | is_audigy = emu->audigy = c->emu10k2_chip; | 917 | is_audigy = emu->audigy = c->emu10k2_chip; |
763 | 918 | ||
764 | /* set the DMA transfer mask */ | 919 | /* set the DMA transfer mask */ |
@@ -816,15 +971,6 @@ int __devinit snd_emu10k1_create(snd_card_t * card, | |||
816 | 971 | ||
817 | pci_set_master(pci); | 972 | pci_set_master(pci); |
818 | 973 | ||
819 | if (c->ecard) { | ||
820 | emu->card_type = EMU10K1_CARD_EMUAPS; | ||
821 | emu->APS = 1; | ||
822 | } | ||
823 | if (! c->ac97_chip) | ||
824 | emu->no_ac97 = 1; | ||
825 | |||
826 | emu->spk71 = c->spk71; | ||
827 | |||
828 | emu->fx8010.fxbus_mask = 0x303f; | 974 | emu->fx8010.fxbus_mask = 0x303f; |
829 | if (extin_mask == 0) | 975 | if (extin_mask == 0) |
830 | extin_mask = 0x3fcf; | 976 | extin_mask = 0x3fcf; |
@@ -833,7 +979,7 @@ int __devinit snd_emu10k1_create(snd_card_t * card, | |||
833 | emu->fx8010.extin_mask = extin_mask; | 979 | emu->fx8010.extin_mask = extin_mask; |
834 | emu->fx8010.extout_mask = extout_mask; | 980 | emu->fx8010.extout_mask = extout_mask; |
835 | 981 | ||
836 | if (emu->APS) { | 982 | if (emu->card_capabilities->ecard) { |
837 | if ((err = snd_emu10k1_ecard_init(emu)) < 0) { | 983 | if ((err = snd_emu10k1_ecard_init(emu)) < 0) { |
838 | snd_emu10k1_free(emu); | 984 | snd_emu10k1_free(emu); |
839 | return err; | 985 | return err; |
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 27dfd8ddddf4..e90c5ddd1d17 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c | |||
@@ -361,10 +361,7 @@ static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value) | |||
361 | 361 | ||
362 | static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime) | 362 | static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime) |
363 | { | 363 | { |
364 | emu10k1x_pcm_t *epcm = runtime->private_data; | 364 | kfree(runtime->private_data); |
365 | |||
366 | if (epcm) | ||
367 | kfree(epcm); | ||
368 | } | 365 | } |
369 | 366 | ||
370 | static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) | 367 | static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) |
@@ -1075,6 +1072,7 @@ static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu) | |||
1075 | snd_info_set_text_ops(entry, emu, 1024, snd_emu10k1x_proc_reg_read); | 1072 | snd_info_set_text_ops(entry, emu, 1024, snd_emu10k1x_proc_reg_read); |
1076 | entry->c.text.write_size = 64; | 1073 | entry->c.text.write_size = 64; |
1077 | entry->c.text.write = snd_emu10k1x_proc_reg_write; | 1074 | entry->c.text.write = snd_emu10k1x_proc_reg_write; |
1075 | entry->mode |= S_IWUSR; | ||
1078 | entry->private_data = emu; | 1076 | entry->private_data = emu; |
1079 | } | 1077 | } |
1080 | 1078 | ||
@@ -1627,7 +1625,7 @@ static int __init alsa_card_emu10k1x_init(void) | |||
1627 | { | 1625 | { |
1628 | int err; | 1626 | int err; |
1629 | 1627 | ||
1630 | if ((err = pci_module_init(&driver)) > 0) | 1628 | if ((err = pci_register_driver(&driver)) > 0) |
1631 | return err; | 1629 | return err; |
1632 | 1630 | ||
1633 | return 0; | 1631 | return 0; |
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index b9fa2e887fee..0529fb281125 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c | |||
@@ -1077,7 +1077,7 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) | |||
1077 | gpr += 2; | 1077 | gpr += 2; |
1078 | 1078 | ||
1079 | /* PCM Side Playback (independent from stereo mix) */ | 1079 | /* PCM Side Playback (independent from stereo mix) */ |
1080 | if (emu->spk71) { | 1080 | if (emu->card_capabilities->spk71) { |
1081 | A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_SIDE)); | 1081 | A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_SIDE)); |
1082 | A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_SIDE)); | 1082 | A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_SIDE)); |
1083 | snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Side Playback Volume", gpr, 100); | 1083 | snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Side Playback Volume", gpr, 100); |
@@ -1145,14 +1145,14 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) | |||
1145 | A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_SPDIF_CD_L); | 1145 | A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_SPDIF_CD_L); |
1146 | A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_SPDIF_CD_R); | 1146 | A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_SPDIF_CD_R); |
1147 | snd_emu10k1_init_stereo_control(&controls[nctl++], | 1147 | snd_emu10k1_init_stereo_control(&controls[nctl++], |
1148 | emu->no_ac97 ? "CD Playback Volume" : "Audigy CD Playback Volume", | 1148 | emu->card_capabilities->ac97_chip ? "Audigy CD Playback Volume" : "CD Playback Volume", |
1149 | gpr, 0); | 1149 | gpr, 0); |
1150 | gpr += 2; | 1150 | gpr += 2; |
1151 | /* Audigy CD Capture Volume */ | 1151 | /* Audigy CD Capture Volume */ |
1152 | A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_SPDIF_CD_L); | 1152 | A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_SPDIF_CD_L); |
1153 | A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_SPDIF_CD_R); | 1153 | A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_SPDIF_CD_R); |
1154 | snd_emu10k1_init_stereo_control(&controls[nctl++], | 1154 | snd_emu10k1_init_stereo_control(&controls[nctl++], |
1155 | emu->no_ac97 ? "CD Capture Volume" : "Audigy CD Capture Volume", | 1155 | emu->card_capabilities->ac97_chip ? "Audigy CD Capture Volume" : "CD Capture Volume", |
1156 | gpr, 0); | 1156 | gpr, 0); |
1157 | gpr += 2; | 1157 | gpr += 2; |
1158 | 1158 | ||
@@ -1171,14 +1171,14 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) | |||
1171 | A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_LINE2_L); | 1171 | A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_LINE2_L); |
1172 | A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_LINE2_R); | 1172 | A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_LINE2_R); |
1173 | snd_emu10k1_init_stereo_control(&controls[nctl++], | 1173 | snd_emu10k1_init_stereo_control(&controls[nctl++], |
1174 | emu->no_ac97 ? "Line Playback Volume" : "Line2 Playback Volume", | 1174 | emu->card_capabilities->ac97_chip ? "Line2 Playback Volume" : "Line Playback Volume", |
1175 | gpr, 0); | 1175 | gpr, 0); |
1176 | gpr += 2; | 1176 | gpr += 2; |
1177 | /* Line2 Capture Volume */ | 1177 | /* Line2 Capture Volume */ |
1178 | A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_LINE2_L); | 1178 | A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_LINE2_L); |
1179 | A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_LINE2_R); | 1179 | A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_LINE2_R); |
1180 | snd_emu10k1_init_stereo_control(&controls[nctl++], | 1180 | snd_emu10k1_init_stereo_control(&controls[nctl++], |
1181 | emu->no_ac97 ? "Line Capture Volume" : "Line2 Capture Volume", | 1181 | emu->card_capabilities->ac97_chip ? "Line2 Capture Volume" : "Line Capture Volume", |
1182 | gpr, 0); | 1182 | gpr, 0); |
1183 | gpr += 2; | 1183 | gpr += 2; |
1184 | 1184 | ||
@@ -1197,14 +1197,14 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) | |||
1197 | A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_AUX2_L); | 1197 | A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_AUX2_L); |
1198 | A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_AUX2_R); | 1198 | A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_AUX2_R); |
1199 | snd_emu10k1_init_stereo_control(&controls[nctl++], | 1199 | snd_emu10k1_init_stereo_control(&controls[nctl++], |
1200 | emu->no_ac97 ? "Aux Playback Volume" : "Aux2 Playback Volume", | 1200 | emu->card_capabilities->ac97_chip ? "Aux2 Playback Volume" : "Aux Playback Volume", |
1201 | gpr, 0); | 1201 | gpr, 0); |
1202 | gpr += 2; | 1202 | gpr += 2; |
1203 | /* Aux2 Capture Volume */ | 1203 | /* Aux2 Capture Volume */ |
1204 | A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_AUX2_L); | 1204 | A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_AUX2_L); |
1205 | A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_AUX2_R); | 1205 | A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_AUX2_R); |
1206 | snd_emu10k1_init_stereo_control(&controls[nctl++], | 1206 | snd_emu10k1_init_stereo_control(&controls[nctl++], |
1207 | emu->no_ac97 ? "Aux Capture Volume" : "Aux2 Capture Volume", | 1207 | emu->card_capabilities->ac97_chip ? "Aux2 Capture Volume" : "Aux Capture Volume", |
1208 | gpr, 0); | 1208 | gpr, 0); |
1209 | gpr += 2; | 1209 | gpr += 2; |
1210 | 1210 | ||
@@ -1232,7 +1232,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) | |||
1232 | snd_emu10k1_init_mono_control(&controls[nctl++], "LFE Playback Volume", gpr, 0); | 1232 | snd_emu10k1_init_mono_control(&controls[nctl++], "LFE Playback Volume", gpr, 0); |
1233 | gpr++; | 1233 | gpr++; |
1234 | 1234 | ||
1235 | if (emu->spk71) { | 1235 | if (emu->card_capabilities->spk71) { |
1236 | /* Stereo Mix Side Playback */ | 1236 | /* Stereo Mix Side Playback */ |
1237 | A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_GPR(playback+6), A_GPR(gpr), A_GPR(stereo_mix)); | 1237 | A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_GPR(playback+6), A_GPR(gpr), A_GPR(stereo_mix)); |
1238 | A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_GPR(playback+7), A_GPR(gpr+1), A_GPR(stereo_mix+1)); | 1238 | A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_GPR(playback+7), A_GPR(gpr+1), A_GPR(stereo_mix+1)); |
@@ -1266,7 +1266,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) | |||
1266 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 3), A_GPR(playback + 3), A_C_00000000, A_C_00000000); /* rear right */ | 1266 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 3), A_GPR(playback + 3), A_C_00000000, A_C_00000000); /* rear right */ |
1267 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 4), A_GPR(playback + 4), A_C_00000000, A_C_00000000); /* center */ | 1267 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 4), A_GPR(playback + 4), A_C_00000000, A_C_00000000); /* center */ |
1268 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), A_GPR(playback + 5), A_C_00000000, A_C_00000000); /* LFE */ | 1268 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), A_GPR(playback + 5), A_C_00000000, A_C_00000000); /* LFE */ |
1269 | if (emu->spk71) { | 1269 | if (emu->card_capabilities->spk71) { |
1270 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 6), A_GPR(playback + 6), A_C_00000000, A_C_00000000); /* side left */ | 1270 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 6), A_GPR(playback + 6), A_C_00000000, A_C_00000000); /* side left */ |
1271 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 7), A_GPR(playback + 7), A_C_00000000, A_C_00000000); /* side right */ | 1271 | A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 7), A_GPR(playback + 7), A_C_00000000, A_C_00000000); /* side right */ |
1272 | } | 1272 | } |
@@ -1359,7 +1359,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) | |||
1359 | A_PUT_STEREO_OUTPUT(A_EXTOUT_AREAR_L, A_EXTOUT_AREAR_R, playback+2 + SND_EMU10K1_PLAYBACK_CHANNELS); | 1359 | A_PUT_STEREO_OUTPUT(A_EXTOUT_AREAR_L, A_EXTOUT_AREAR_R, playback+2 + SND_EMU10K1_PLAYBACK_CHANNELS); |
1360 | A_PUT_OUTPUT(A_EXTOUT_ACENTER, playback+4 + SND_EMU10K1_PLAYBACK_CHANNELS); | 1360 | A_PUT_OUTPUT(A_EXTOUT_ACENTER, playback+4 + SND_EMU10K1_PLAYBACK_CHANNELS); |
1361 | A_PUT_OUTPUT(A_EXTOUT_ALFE, playback+5 + SND_EMU10K1_PLAYBACK_CHANNELS); | 1361 | A_PUT_OUTPUT(A_EXTOUT_ALFE, playback+5 + SND_EMU10K1_PLAYBACK_CHANNELS); |
1362 | if (emu->spk71) | 1362 | if (emu->card_capabilities->spk71) |
1363 | A_PUT_STEREO_OUTPUT(A_EXTOUT_ASIDE_L, A_EXTOUT_ASIDE_R, playback+6 + SND_EMU10K1_PLAYBACK_CHANNELS); | 1363 | A_PUT_STEREO_OUTPUT(A_EXTOUT_ASIDE_L, A_EXTOUT_ASIDE_R, playback+6 + SND_EMU10K1_PLAYBACK_CHANNELS); |
1364 | 1364 | ||
1365 | /* headphone */ | 1365 | /* headphone */ |
@@ -1982,22 +1982,27 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) | |||
1982 | OP(icode, &ptr, iACC3, EXTOUT(EXTOUT_MIC_CAP), GPR(capture + 2), C_00000000, C_00000000); | 1982 | OP(icode, &ptr, iACC3, EXTOUT(EXTOUT_MIC_CAP), GPR(capture + 2), C_00000000, C_00000000); |
1983 | 1983 | ||
1984 | /* EFX capture - capture the 16 EXTINS */ | 1984 | /* EFX capture - capture the 16 EXTINS */ |
1985 | OP(icode, &ptr, iACC3, FXBUS2(14), C_00000000, C_00000000, EXTIN(0)); | 1985 | if (emu->card_capabilities->sblive51) { |
1986 | OP(icode, &ptr, iACC3, FXBUS2(15), C_00000000, C_00000000, EXTIN(1)); | 1986 | /* On the Live! 5.1, FXBUS2(1) and FXBUS(2) are shared with EXTOUT_ACENTER |
1987 | OP(icode, &ptr, iACC3, FXBUS2(0), C_00000000, C_00000000, EXTIN(2)); | 1987 | * and EXTOUT_ALFE, so we can't connect inputs to them for multitrack recording. |
1988 | OP(icode, &ptr, iACC3, FXBUS2(3), C_00000000, C_00000000, EXTIN(3)); | 1988 | * |
1989 | /* Dont connect anything to FXBUS2 1 and 2. These are shared with | 1989 | * Since only 14 of the 16 EXTINs are used, this is not a big problem. |
1990 | * Center/LFE on the SBLive 5.1. The kX driver only changes the | 1990 | * We route AC97L and R to FX capture 14 and 15, SPDIF CD in to FX capture |
1991 | * routing when it detects an SBLive 5.1. | 1991 | * 0 and 3, then the rest of the EXTINs to the corresponding FX capture |
1992 | * | 1992 | * channel. Multitrack recorders will still see the center/lfe output signal |
1993 | * Since only 14 of the 16 EXTINs are used, this is not a big problem. | 1993 | * on the second and third channels. |
1994 | * We route AC97L and R to FX capture 14 and 15, SPDIF CD in to FX capture | 1994 | */ |
1995 | * 0 and 3, then the rest of the EXTINs to the corresponding FX capture | 1995 | OP(icode, &ptr, iACC3, FXBUS2(14), C_00000000, C_00000000, EXTIN(0)); |
1996 | * channel. | 1996 | OP(icode, &ptr, iACC3, FXBUS2(15), C_00000000, C_00000000, EXTIN(1)); |
1997 | */ | 1997 | OP(icode, &ptr, iACC3, FXBUS2(0), C_00000000, C_00000000, EXTIN(2)); |
1998 | for (z = 4; z < 14; z++) { | 1998 | OP(icode, &ptr, iACC3, FXBUS2(3), C_00000000, C_00000000, EXTIN(3)); |
1999 | OP(icode, &ptr, iACC3, FXBUS2(z), C_00000000, C_00000000, EXTIN(z)); | 1999 | for (z = 4; z < 14; z++) |
2000 | OP(icode, &ptr, iACC3, FXBUS2(z), C_00000000, C_00000000, EXTIN(z)); | ||
2001 | } else { | ||
2002 | for (z = 0; z < 16; z++) | ||
2003 | OP(icode, &ptr, iACC3, FXBUS2(z), C_00000000, C_00000000, EXTIN(z)); | ||
2000 | } | 2004 | } |
2005 | |||
2001 | 2006 | ||
2002 | if (gpr > tmp) { | 2007 | if (gpr > tmp) { |
2003 | snd_BUG(); | 2008 | snd_BUG(); |
@@ -2128,7 +2133,6 @@ static int snd_emu10k1_fx8010_info(emu10k1_t *emu, emu10k1_fx8010_info_t *info) | |||
2128 | int res; | 2133 | int res; |
2129 | 2134 | ||
2130 | memset(info, 0, sizeof(info)); | 2135 | memset(info, 0, sizeof(info)); |
2131 | info->card = emu->card_type; | ||
2132 | info->internal_tram_size = emu->fx8010.itram_size; | 2136 | info->internal_tram_size = emu->fx8010.itram_size; |
2133 | info->external_tram_size = emu->fx8010.etram_pages.bytes / 2; | 2137 | info->external_tram_size = emu->fx8010.etram_pages.bytes / 2; |
2134 | fxbus = fxbuses; | 2138 | fxbus = fxbuses; |
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 044663d31aa7..6be82c5fe138 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c | |||
@@ -68,6 +68,7 @@ static int snd_emu10k1_spdif_get_mask(snd_kcontrol_t * kcontrol, | |||
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | #if 0 | ||
71 | static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 72 | static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) |
72 | { | 73 | { |
73 | static char *texts[] = {"44100", "48000", "96000"}; | 74 | static char *texts[] = {"44100", "48000", "96000"}; |
@@ -152,6 +153,7 @@ static snd_kcontrol_new_t snd_audigy_spdif_output_rate = | |||
152 | .get = snd_audigy_spdif_output_rate_get, | 153 | .get = snd_audigy_spdif_output_rate_get, |
153 | .put = snd_audigy_spdif_output_rate_put | 154 | .put = snd_audigy_spdif_output_rate_put |
154 | }; | 155 | }; |
156 | #endif | ||
155 | 157 | ||
156 | static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol, | 158 | static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol, |
157 | snd_ctl_elem_value_t * ucontrol) | 159 | snd_ctl_elem_value_t * ucontrol) |
@@ -791,7 +793,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu) | |||
791 | NULL | 793 | NULL |
792 | }; | 794 | }; |
793 | 795 | ||
794 | if (!emu->no_ac97) { | 796 | if (emu->card_capabilities->ac97_chip) { |
795 | ac97_bus_t *pbus; | 797 | ac97_bus_t *pbus; |
796 | ac97_template_t ac97; | 798 | ac97_template_t ac97; |
797 | static ac97_bus_ops_t ops = { | 799 | static ac97_bus_ops_t ops = { |
@@ -833,7 +835,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu) | |||
833 | for (; *c; c++) | 835 | for (; *c; c++) |
834 | remove_ctl(card, *c); | 836 | remove_ctl(card, *c); |
835 | } else { | 837 | } else { |
836 | if (emu->APS) | 838 | if (emu->card_capabilities->ecard) |
837 | strcpy(emu->card->mixername, "EMU APS"); | 839 | strcpy(emu->card->mixername, "EMU APS"); |
838 | else if (emu->audigy) | 840 | else if (emu->audigy) |
839 | strcpy(emu->card->mixername, "SB Audigy"); | 841 | strcpy(emu->card->mixername, "SB Audigy"); |
@@ -918,7 +920,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu) | |||
918 | mix->attn[0] = 0xffff; | 920 | mix->attn[0] = 0xffff; |
919 | } | 921 | } |
920 | 922 | ||
921 | if (! emu->APS) { /* FIXME: APS has these controls? */ | 923 | if (! emu->card_capabilities->ecard) { /* FIXME: APS has these controls? */ |
922 | /* sb live! and audigy */ | 924 | /* sb live! and audigy */ |
923 | if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == NULL) | 925 | if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == NULL) |
924 | return -ENOMEM; | 926 | return -ENOMEM; |
@@ -935,18 +937,20 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu) | |||
935 | return -ENOMEM; | 937 | return -ENOMEM; |
936 | if ((err = snd_ctl_add(card, kctl))) | 938 | if ((err = snd_ctl_add(card, kctl))) |
937 | return err; | 939 | return err; |
940 | #if 0 | ||
938 | if ((kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu)) == NULL) | 941 | if ((kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu)) == NULL) |
939 | return -ENOMEM; | 942 | return -ENOMEM; |
940 | if ((err = snd_ctl_add(card, kctl))) | 943 | if ((err = snd_ctl_add(card, kctl))) |
941 | return err; | 944 | return err; |
942 | } else if (! emu->APS) { | 945 | #endif |
946 | } else if (! emu->card_capabilities->ecard) { | ||
943 | /* sb live! */ | 947 | /* sb live! */ |
944 | if ((kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu)) == NULL) | 948 | if ((kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu)) == NULL) |
945 | return -ENOMEM; | 949 | return -ENOMEM; |
946 | if ((err = snd_ctl_add(card, kctl))) | 950 | if ((err = snd_ctl_add(card, kctl))) |
947 | return err; | 951 | return err; |
948 | } | 952 | } |
949 | if (emu->audigy && emu->revision == 4) { /* P16V */ | 953 | if (emu->card_capabilities->ca0151_chip) { /* P16V */ |
950 | if ((err = snd_p16v_mixer(emu))) | 954 | if ((err = snd_p16v_mixer(emu))) |
951 | return err; | 955 | return err; |
952 | } | 956 | } |
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index d1c2a02c486b..520b99af5f55 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c | |||
@@ -262,7 +262,7 @@ static unsigned int emu10k1_select_interprom(unsigned int pitch_target) | |||
262 | * | 262 | * |
263 | * returns: cache invalidate size in samples | 263 | * returns: cache invalidate size in samples |
264 | */ | 264 | */ |
265 | static int inline emu10k1_ccis(int stereo, int w_16) | 265 | static inline int emu10k1_ccis(int stereo, int w_16) |
266 | { | 266 | { |
267 | if (w_16) { | 267 | if (w_16) { |
268 | return stereo ? 24 : 26; | 268 | return stereo ? 24 : 26; |
@@ -991,9 +991,7 @@ static void snd_emu10k1_pcm_efx_mixer_notify(emu10k1_t *emu, int idx, int activa | |||
991 | 991 | ||
992 | static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime) | 992 | static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime) |
993 | { | 993 | { |
994 | emu10k1_pcm_t *epcm = runtime->private_data; | 994 | kfree(runtime->private_data); |
995 | |||
996 | kfree(epcm); | ||
997 | } | 995 | } |
998 | 996 | ||
999 | static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) | 997 | static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) |
diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index d990d5eb45a8..cc22707c91fa 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <sound/core.h> | 31 | #include <sound/core.h> |
32 | #include <sound/emu10k1.h> | 32 | #include <sound/emu10k1.h> |
33 | #include "p16v.h" | ||
33 | 34 | ||
34 | static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu, | 35 | static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu, |
35 | snd_info_buffer_t * buffer, | 36 | snd_info_buffer_t * buffer, |
@@ -44,28 +45,34 @@ static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu, | |||
44 | unsigned int status, rate = 0; | 45 | unsigned int status, rate = 0; |
45 | 46 | ||
46 | status = snd_emu10k1_ptr_read(emu, status_reg, 0); | 47 | status = snd_emu10k1_ptr_read(emu, status_reg, 0); |
47 | if (rate_reg > 0) | ||
48 | rate = snd_emu10k1_ptr_read(emu, rate_reg, 0); | ||
49 | 48 | ||
50 | snd_iprintf(buffer, "\n%s\n", title); | 49 | snd_iprintf(buffer, "\n%s\n", title); |
51 | 50 | ||
52 | snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no"); | 51 | if (status != 0xffffffff) { |
53 | snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no"); | 52 | snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no"); |
54 | snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no"); | 53 | snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no"); |
55 | snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]); | 54 | snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no"); |
56 | snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6); | 55 | snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]); |
57 | snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8); | 56 | snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6); |
58 | snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy"); | 57 | snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8); |
59 | snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16); | 58 | snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy"); |
60 | snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]); | 59 | snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16); |
61 | snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]); | 60 | snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]); |
62 | snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]); | 61 | snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]); |
63 | 62 | snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]); | |
64 | if (rate_reg > 0) { | 63 | |
65 | snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off"); | 64 | if (rate_reg > 0) { |
66 | snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off"); | 65 | rate = snd_emu10k1_ptr_read(emu, rate_reg, 0); |
67 | snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", rate & SRCS_ESTSAMPLERATE); | 66 | snd_iprintf(buffer, "S/PDIF Valid : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off"); |
67 | snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off"); | ||
68 | snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off"); | ||
69 | /* From ((Rate * 48000 ) / 262144); */ | ||
70 | snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11); | ||
71 | } | ||
72 | } else { | ||
73 | snd_iprintf(buffer, "No signal detected.\n"); | ||
68 | } | 74 | } |
75 | |||
69 | } | 76 | } |
70 | 77 | ||
71 | static void snd_emu10k1_proc_read(snd_info_entry_t *entry, | 78 | static void snd_emu10k1_proc_read(snd_info_entry_t *entry, |
@@ -182,7 +189,7 @@ static void snd_emu10k1_proc_read(snd_info_entry_t *entry, | |||
182 | 189 | ||
183 | snd_iprintf(buffer, "EMU10K1\n\n"); | 190 | snd_iprintf(buffer, "EMU10K1\n\n"); |
184 | snd_iprintf(buffer, "Card : %s\n", | 191 | snd_iprintf(buffer, "Card : %s\n", |
185 | emu->audigy ? "Audigy" : (emu->APS ? "EMU APS" : "Creative")); | 192 | emu->audigy ? "Audigy" : (emu->card_capabilities->ecard ? "EMU APS" : "Creative")); |
186 | snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size); | 193 | snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size); |
187 | snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2); | 194 | snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2); |
188 | snd_iprintf(buffer, "\n"); | 195 | snd_iprintf(buffer, "\n"); |
@@ -223,15 +230,35 @@ static void snd_emu10k1_proc_read(snd_info_entry_t *entry, | |||
223 | snd_iprintf(buffer, "\nAll FX Outputs :\n"); | 230 | snd_iprintf(buffer, "\nAll FX Outputs :\n"); |
224 | for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++) | 231 | for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++) |
225 | snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]); | 232 | snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]); |
226 | snd_emu10k1_proc_spdif_status(emu, buffer, "S/PDIF Output 0", SPCS0, -1); | 233 | } |
227 | snd_emu10k1_proc_spdif_status(emu, buffer, "S/PDIF Output 1", SPCS1, -1); | 234 | |
228 | snd_emu10k1_proc_spdif_status(emu, buffer, "S/PDIF Output 2/3", SPCS2, -1); | 235 | static void snd_emu10k1_proc_spdif_read(snd_info_entry_t *entry, |
229 | snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF", CDCS, CDSRCS); | 236 | snd_info_buffer_t * buffer) |
230 | snd_emu10k1_proc_spdif_status(emu, buffer, "General purpose S/PDIF", GPSCS, GPSRCS); | 237 | { |
238 | emu10k1_t *emu = entry->private_data; | ||
239 | snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS); | ||
240 | snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS); | ||
241 | #if 0 | ||
231 | val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0); | 242 | val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0); |
232 | snd_iprintf(buffer, "\nZoomed Video\n"); | 243 | snd_iprintf(buffer, "\nZoomed Video\n"); |
233 | snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off"); | 244 | snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off"); |
234 | snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE); | 245 | snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE); |
246 | #endif | ||
247 | } | ||
248 | |||
249 | static void snd_emu10k1_proc_rates_read(snd_info_entry_t *entry, | ||
250 | snd_info_buffer_t * buffer) | ||
251 | { | ||
252 | static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 }; | ||
253 | emu10k1_t *emu = entry->private_data; | ||
254 | unsigned int val, tmp, n; | ||
255 | val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0); | ||
256 | tmp = (val >> 16) & 0x8; | ||
257 | for (n=0;n<4;n++) { | ||
258 | tmp = val >> (16 + (n*4)); | ||
259 | if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]); | ||
260 | else snd_iprintf(buffer, "Channel %d: No input\n", n); | ||
261 | } | ||
235 | } | 262 | } |
236 | 263 | ||
237 | static void snd_emu10k1_proc_acode_read(snd_info_entry_t *entry, | 264 | static void snd_emu10k1_proc_acode_read(snd_info_entry_t *entry, |
@@ -500,32 +527,46 @@ int __devinit snd_emu10k1_proc_init(emu10k1_t * emu) | |||
500 | snd_info_set_text_ops(entry, emu, 1024, snd_emu_proc_io_reg_read); | 527 | snd_info_set_text_ops(entry, emu, 1024, snd_emu_proc_io_reg_read); |
501 | entry->c.text.write_size = 64; | 528 | entry->c.text.write_size = 64; |
502 | entry->c.text.write = snd_emu_proc_io_reg_write; | 529 | entry->c.text.write = snd_emu_proc_io_reg_write; |
530 | entry->mode |= S_IWUSR; | ||
503 | } | 531 | } |
504 | if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) { | 532 | if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) { |
505 | snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read00a); | 533 | snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read00a); |
506 | entry->c.text.write_size = 64; | 534 | entry->c.text.write_size = 64; |
507 | entry->c.text.write = snd_emu_proc_ptr_reg_write00; | 535 | entry->c.text.write = snd_emu_proc_ptr_reg_write00; |
536 | entry->mode |= S_IWUSR; | ||
508 | } | 537 | } |
509 | if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) { | 538 | if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) { |
510 | snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read00b); | 539 | snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read00b); |
511 | entry->c.text.write_size = 64; | 540 | entry->c.text.write_size = 64; |
512 | entry->c.text.write = snd_emu_proc_ptr_reg_write00; | 541 | entry->c.text.write = snd_emu_proc_ptr_reg_write00; |
542 | entry->mode |= S_IWUSR; | ||
513 | } | 543 | } |
514 | if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) { | 544 | if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) { |
515 | snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20a); | 545 | snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20a); |
516 | entry->c.text.write_size = 64; | 546 | entry->c.text.write_size = 64; |
517 | entry->c.text.write = snd_emu_proc_ptr_reg_write20; | 547 | entry->c.text.write = snd_emu_proc_ptr_reg_write20; |
548 | entry->mode |= S_IWUSR; | ||
518 | } | 549 | } |
519 | if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) { | 550 | if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) { |
520 | snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20b); | 551 | snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20b); |
521 | entry->c.text.write_size = 64; | 552 | entry->c.text.write_size = 64; |
522 | entry->c.text.write = snd_emu_proc_ptr_reg_write20; | 553 | entry->c.text.write = snd_emu_proc_ptr_reg_write20; |
554 | entry->mode |= S_IWUSR; | ||
523 | } | 555 | } |
524 | #endif | 556 | #endif |
525 | 557 | ||
526 | if (! snd_card_proc_new(emu->card, "emu10k1", &entry)) | 558 | if (! snd_card_proc_new(emu->card, "emu10k1", &entry)) |
527 | snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_read); | 559 | snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_read); |
528 | 560 | ||
561 | if (emu->card_capabilities->emu10k2_chip) { | ||
562 | if (! snd_card_proc_new(emu->card, "spdif-in", &entry)) | ||
563 | snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_spdif_read); | ||
564 | } | ||
565 | if (emu->card_capabilities->ca0151_chip) { | ||
566 | if (! snd_card_proc_new(emu->card, "capture-rates", &entry)) | ||
567 | snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_rates_read); | ||
568 | } | ||
569 | |||
529 | if (! snd_card_proc_new(emu->card, "voices", &entry)) | 570 | if (! snd_card_proc_new(emu->card, "voices", &entry)) |
530 | snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_voices_read); | 571 | snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_voices_read); |
531 | 572 | ||
diff --git a/sound/pci/emu10k1/irq.c b/sound/pci/emu10k1/irq.c index b81a7cafff39..cd8460d56752 100644 --- a/sound/pci/emu10k1/irq.c +++ b/sound/pci/emu10k1/irq.c | |||
@@ -37,7 +37,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
37 | int handled = 0; | 37 | int handled = 0; |
38 | 38 | ||
39 | while ((status = inl(emu->port + IPR)) != 0) { | 39 | while ((status = inl(emu->port + IPR)) != 0) { |
40 | // printk("irq - status = 0x%x\n", status); | 40 | //printk("emu10k1 irq - status = 0x%x\n", status); |
41 | orig_status = status; | 41 | orig_status = status; |
42 | handled = 1; | 42 | handled = 1; |
43 | if (status & IPR_PCIERROR) { | 43 | if (status & IPR_PCIERROR) { |
@@ -147,9 +147,36 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
147 | snd_emu10k1_intr_disable(emu, INTE_FXDSPENABLE); | 147 | snd_emu10k1_intr_disable(emu, INTE_FXDSPENABLE); |
148 | status &= ~IPR_FXDSP; | 148 | status &= ~IPR_FXDSP; |
149 | } | 149 | } |
150 | if (status & IPR_P16V) { | ||
151 | while ((status2 = inl(emu->port + IPR2)) != 0) { | ||
152 | u32 mask = INTE2_PLAYBACK_CH_0_LOOP; /* Full Loop */ | ||
153 | emu10k1_voice_t *pvoice = &(emu->p16v_voices[0]); | ||
154 | emu10k1_voice_t *cvoice = &(emu->p16v_capture_voice); | ||
155 | |||
156 | //printk(KERN_INFO "status2=0x%x\n", status2); | ||
157 | orig_status2 = status2; | ||
158 | if(status2 & mask) { | ||
159 | if(pvoice->use) { | ||
160 | snd_pcm_period_elapsed(pvoice->epcm->substream); | ||
161 | } else { | ||
162 | snd_printk(KERN_ERR "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n", status2, mask, pvoice, pvoice->use); | ||
163 | } | ||
164 | } | ||
165 | if(status2 & 0x110000) { | ||
166 | //printk(KERN_INFO "capture int found\n"); | ||
167 | if(cvoice->use) { | ||
168 | //printk(KERN_INFO "capture period_elapsed\n"); | ||
169 | snd_pcm_period_elapsed(cvoice->epcm->substream); | ||
170 | } | ||
171 | } | ||
172 | outl(orig_status2, emu->port + IPR2); /* ack all */ | ||
173 | } | ||
174 | status &= ~IPR_P16V; | ||
175 | } | ||
176 | |||
150 | if (status) { | 177 | if (status) { |
151 | unsigned int bits; | 178 | unsigned int bits; |
152 | //snd_printk(KERN_ERR "emu10k1: unhandled interrupt: 0x%08x\n", status); | 179 | snd_printk(KERN_ERR "emu10k1: unhandled interrupt: 0x%08x\n", status); |
153 | //make sure any interrupts we don't handle are disabled: | 180 | //make sure any interrupts we don't handle are disabled: |
154 | bits = INTE_FXDSPENABLE | | 181 | bits = INTE_FXDSPENABLE | |
155 | INTE_PCIERRORENABLE | | 182 | INTE_PCIERRORENABLE | |
@@ -170,20 +197,5 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
170 | } | 197 | } |
171 | outl(orig_status, emu->port + IPR); /* ack all */ | 198 | outl(orig_status, emu->port + IPR); /* ack all */ |
172 | } | 199 | } |
173 | if (emu->audigy && emu->revision == 4) { /* P16V */ | ||
174 | while ((status2 = inl(emu->port + IPR2)) != 0) { | ||
175 | u32 mask = INTE2_PLAYBACK_CH_0_LOOP; /* Full Loop */ | ||
176 | emu10k1_voice_t *pvoice = &(emu->p16v_voices[0]); | ||
177 | orig_status2 = status2; | ||
178 | if(status2 & mask) { | ||
179 | if(pvoice->use) { | ||
180 | snd_pcm_period_elapsed(pvoice->epcm->substream); | ||
181 | } else { | ||
182 | snd_printk(KERN_ERR "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n", status2, mask, pvoice, pvoice->use); | ||
183 | } | ||
184 | } | ||
185 | outl(orig_status2, emu->port + IPR2); /* ack all */ | ||
186 | } | ||
187 | } | ||
188 | return IRQ_RETVAL(handled); | 200 | return IRQ_RETVAL(handled); |
189 | } | 201 | } |
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index d03cb2fefc9e..98f980189892 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> | 2 | * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> |
3 | * Driver p16v chips | 3 | * Driver p16v chips |
4 | * Version: 0.22 | 4 | * Version: 0.25 |
5 | * | 5 | * |
6 | * FEATURES currently supported: | 6 | * FEATURES currently supported: |
7 | * Output fixed at S32_LE, 2 channel to hw:0,0 | 7 | * Output fixed at S32_LE, 2 channel to hw:0,0 |
@@ -41,7 +41,15 @@ | |||
41 | * Integrated with snd-emu10k1 driver. | 41 | * Integrated with snd-emu10k1 driver. |
42 | * 0.22 | 42 | * 0.22 |
43 | * Removed #if 0 ... #endif | 43 | * Removed #if 0 ... #endif |
44 | * | 44 | * 0.23 |
45 | * Implement different capture rates. | ||
46 | * 0.24 | ||
47 | * Implement different capture source channels. | ||
48 | * e.g. When HD Capture source is set to SPDIF, | ||
49 | * setting HD Capture channel to 0 captures from CDROM digital input. | ||
50 | * setting HD Capture channel to 1 captures from SPDIF in. | ||
51 | * 0.25 | ||
52 | * Include capture buffer sizes. | ||
45 | * | 53 | * |
46 | * BUGS: | 54 | * BUGS: |
47 | * Some stability problems when unloading the snd-p16v kernel module. | 55 | * Some stability problems when unloading the snd-p16v kernel module. |
@@ -119,22 +127,41 @@ static snd_pcm_hardware_t snd_p16v_playback_hw = { | |||
119 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 127 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
120 | SNDRV_PCM_INFO_MMAP_VALID), | 128 | SNDRV_PCM_INFO_MMAP_VALID), |
121 | .formats = SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */ | 129 | .formats = SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */ |
122 | .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 , | 130 | .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, |
123 | .rate_min = 48000, | 131 | .rate_min = 44100, |
124 | .rate_max = 192000, | 132 | .rate_max = 192000, |
125 | .channels_min = 8, | 133 | .channels_min = 8, |
126 | .channels_max = 8, | 134 | .channels_max = 8, |
127 | .buffer_bytes_max = (32*1024), | 135 | .buffer_bytes_max = ((65536 - 64) * 8), |
128 | .period_bytes_min = 64, | 136 | .period_bytes_min = 64, |
129 | .period_bytes_max = (16*1024), | 137 | .period_bytes_max = (65536 - 64), |
130 | .periods_min = 2, | 138 | .periods_min = 2, |
131 | .periods_max = 8, | 139 | .periods_max = 8, |
132 | .fifo_size = 0, | 140 | .fifo_size = 0, |
133 | }; | 141 | }; |
134 | 142 | ||
143 | static snd_pcm_hardware_t snd_p16v_capture_hw = { | ||
144 | .info = (SNDRV_PCM_INFO_MMAP | | ||
145 | SNDRV_PCM_INFO_INTERLEAVED | | ||
146 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
147 | SNDRV_PCM_INFO_MMAP_VALID), | ||
148 | .formats = SNDRV_PCM_FMTBIT_S32_LE, | ||
149 | .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, | ||
150 | .rate_min = 44100, | ||
151 | .rate_max = 192000, | ||
152 | .channels_min = 2, | ||
153 | .channels_max = 2, | ||
154 | .buffer_bytes_max = (65536 - 64), | ||
155 | .period_bytes_min = 64, | ||
156 | .period_bytes_max = (65536 - 128) >> 1, /* size has to be N*64 bytes */ | ||
157 | .periods_min = 2, | ||
158 | .periods_max = 2, | ||
159 | .fifo_size = 0, | ||
160 | }; | ||
161 | |||
135 | static void snd_p16v_pcm_free_substream(snd_pcm_runtime_t *runtime) | 162 | static void snd_p16v_pcm_free_substream(snd_pcm_runtime_t *runtime) |
136 | { | 163 | { |
137 | snd_pcm_t *epcm = runtime->private_data; | 164 | emu10k1_pcm_t *epcm = runtime->private_data; |
138 | 165 | ||
139 | if (epcm) { | 166 | if (epcm) { |
140 | //snd_printk("epcm free: %p\n", epcm); | 167 | //snd_printk("epcm free: %p\n", epcm); |
@@ -178,15 +205,63 @@ static int snd_p16v_pcm_open_playback_channel(snd_pcm_substream_t *substream, in | |||
178 | 205 | ||
179 | return 0; | 206 | return 0; |
180 | } | 207 | } |
208 | /* open_capture callback */ | ||
209 | static int snd_p16v_pcm_open_capture_channel(snd_pcm_substream_t *substream, int channel_id) | ||
210 | { | ||
211 | emu10k1_t *emu = snd_pcm_substream_chip(substream); | ||
212 | emu10k1_voice_t *channel = &(emu->p16v_capture_voice); | ||
213 | emu10k1_pcm_t *epcm; | ||
214 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
215 | int err; | ||
216 | |||
217 | epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); | ||
218 | //snd_printk("epcm kcalloc: %p\n", epcm); | ||
219 | |||
220 | if (epcm == NULL) | ||
221 | return -ENOMEM; | ||
222 | epcm->emu = emu; | ||
223 | epcm->substream = substream; | ||
224 | //snd_printk("epcm device=%d, channel_id=%d\n", substream->pcm->device, channel_id); | ||
225 | |||
226 | runtime->private_data = epcm; | ||
227 | runtime->private_free = snd_p16v_pcm_free_substream; | ||
228 | |||
229 | runtime->hw = snd_p16v_capture_hw; | ||
230 | |||
231 | channel->emu = emu; | ||
232 | channel->number = channel_id; | ||
233 | |||
234 | channel->use=1; | ||
235 | //snd_printk("p16v: open channel_id=%d, channel=%p, use=0x%x\n", channel_id, channel, channel->use); | ||
236 | //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); | ||
237 | //channel->interrupt = snd_p16v_pcm_channel_interrupt; | ||
238 | channel->epcm=epcm; | ||
239 | if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) | ||
240 | return err; | ||
241 | |||
242 | return 0; | ||
243 | } | ||
244 | |||
181 | 245 | ||
182 | /* close callback */ | 246 | /* close callback */ |
183 | static int snd_p16v_pcm_close_playback(snd_pcm_substream_t *substream) | 247 | static int snd_p16v_pcm_close_playback(snd_pcm_substream_t *substream) |
184 | { | 248 | { |
185 | emu10k1_t *emu = snd_pcm_substream_chip(substream); | 249 | emu10k1_t *emu = snd_pcm_substream_chip(substream); |
186 | //snd_pcm_runtime_t *runtime = substream->runtime; | 250 | //snd_pcm_runtime_t *runtime = substream->runtime; |
187 | //emu10k1_pcm_t *epcm = runtime->private_data; | 251 | //emu10k1_pcm_t *epcm = runtime->private_data; |
188 | emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0; | 252 | emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0; |
189 | /* FIXME: maybe zero others */ | 253 | /* FIXME: maybe zero others */ |
254 | return 0; | ||
255 | } | ||
256 | |||
257 | /* close callback */ | ||
258 | static int snd_p16v_pcm_close_capture(snd_pcm_substream_t *substream) | ||
259 | { | ||
260 | emu10k1_t *emu = snd_pcm_substream_chip(substream); | ||
261 | //snd_pcm_runtime_t *runtime = substream->runtime; | ||
262 | //emu10k1_pcm_t *epcm = runtime->private_data; | ||
263 | emu->p16v_capture_voice.use=0; | ||
264 | /* FIXME: maybe zero others */ | ||
190 | return 0; | 265 | return 0; |
191 | } | 266 | } |
192 | 267 | ||
@@ -195,36 +270,55 @@ static int snd_p16v_pcm_open_playback_front(snd_pcm_substream_t *substream) | |||
195 | return snd_p16v_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); | 270 | return snd_p16v_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); |
196 | } | 271 | } |
197 | 272 | ||
273 | static int snd_p16v_pcm_open_capture(snd_pcm_substream_t *substream) | ||
274 | { | ||
275 | // Only using channel 0 for now, but the card has 2 channels. | ||
276 | return snd_p16v_pcm_open_capture_channel(substream, 0); | ||
277 | } | ||
278 | |||
198 | /* hw_params callback */ | 279 | /* hw_params callback */ |
199 | static int snd_p16v_pcm_hw_params_playback(snd_pcm_substream_t *substream, | 280 | static int snd_p16v_pcm_hw_params_playback(snd_pcm_substream_t *substream, |
200 | snd_pcm_hw_params_t * hw_params) | 281 | snd_pcm_hw_params_t * hw_params) |
201 | { | 282 | { |
202 | int result; | 283 | int result; |
203 | //snd_printk("hw_params alloc: substream=%p\n", substream); | ||
204 | result = snd_pcm_lib_malloc_pages(substream, | 284 | result = snd_pcm_lib_malloc_pages(substream, |
205 | params_buffer_bytes(hw_params)); | 285 | params_buffer_bytes(hw_params)); |
206 | //snd_printk("hw_params alloc: result=%d\n", result); | ||
207 | //dump_stack(); | ||
208 | return result; | 286 | return result; |
209 | } | 287 | } |
210 | 288 | ||
289 | /* hw_params callback */ | ||
290 | static int snd_p16v_pcm_hw_params_capture(snd_pcm_substream_t *substream, | ||
291 | snd_pcm_hw_params_t * hw_params) | ||
292 | { | ||
293 | int result; | ||
294 | result = snd_pcm_lib_malloc_pages(substream, | ||
295 | params_buffer_bytes(hw_params)); | ||
296 | return result; | ||
297 | } | ||
298 | |||
299 | |||
211 | /* hw_free callback */ | 300 | /* hw_free callback */ |
212 | static int snd_p16v_pcm_hw_free_playback(snd_pcm_substream_t *substream) | 301 | static int snd_p16v_pcm_hw_free_playback(snd_pcm_substream_t *substream) |
213 | { | 302 | { |
214 | int result; | 303 | int result; |
215 | //snd_printk("hw_params free: substream=%p\n", substream); | ||
216 | result = snd_pcm_lib_free_pages(substream); | 304 | result = snd_pcm_lib_free_pages(substream); |
217 | //snd_printk("hw_params free: result=%d\n", result); | ||
218 | //dump_stack(); | ||
219 | return result; | 305 | return result; |
220 | } | 306 | } |
221 | 307 | ||
308 | /* hw_free callback */ | ||
309 | static int snd_p16v_pcm_hw_free_capture(snd_pcm_substream_t *substream) | ||
310 | { | ||
311 | int result; | ||
312 | result = snd_pcm_lib_free_pages(substream); | ||
313 | return result; | ||
314 | } | ||
315 | |||
316 | |||
222 | /* prepare playback callback */ | 317 | /* prepare playback callback */ |
223 | static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) | 318 | static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) |
224 | { | 319 | { |
225 | emu10k1_t *emu = snd_pcm_substream_chip(substream); | 320 | emu10k1_t *emu = snd_pcm_substream_chip(substream); |
226 | snd_pcm_runtime_t *runtime = substream->runtime; | 321 | snd_pcm_runtime_t *runtime = substream->runtime; |
227 | //emu10k1_pcm_t *epcm = runtime->private_data; | ||
228 | int channel = substream->pcm->device - emu->p16v_device_offset; | 322 | int channel = substream->pcm->device - emu->p16v_device_offset; |
229 | u32 *table_base = (u32 *)(emu->p16v_buffer.area+(8*16*channel)); | 323 | u32 *table_base = (u32 *)(emu->p16v_buffer.area+(8*16*channel)); |
230 | u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); | 324 | u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); |
@@ -237,23 +331,21 @@ static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) | |||
237 | tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel); | 331 | tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel); |
238 | switch (runtime->rate) { | 332 | switch (runtime->rate) { |
239 | case 44100: | 333 | case 44100: |
240 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe000) | 0x8000); /* FIXME: This will change the capture rate as well! */ | 334 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe0e0) | 0x8080); |
241 | break; | ||
242 | case 48000: | ||
243 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe000) | 0x0000); /* FIXME: This will change the capture rate as well! */ | ||
244 | break; | 335 | break; |
245 | case 96000: | 336 | case 96000: |
246 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe000) | 0x4000); /* FIXME: This will change the capture rate as well! */ | 337 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe0e0) | 0x4040); |
247 | break; | 338 | break; |
248 | case 192000: | 339 | case 192000: |
249 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe000) | 0x2000); /* FIXME: This will change the capture rate as well! */ | 340 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe0e0) | 0x2020); |
250 | break; | 341 | break; |
342 | case 48000: | ||
251 | default: | 343 | default: |
252 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, 0x0000); /* FIXME: This will change the capture rate as well! */ | 344 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe0e0) | 0x0000); |
253 | break; | 345 | break; |
254 | } | 346 | } |
255 | /* FIXME: Check emu->buffer.size before actually writing to it. */ | 347 | /* FIXME: Check emu->buffer.size before actually writing to it. */ |
256 | for(i=0; i < runtime->periods; i++) { | 348 | for(i=0; i < runtime->periods; i++) { |
257 | table_base[i*2]=runtime->dma_addr+(i*period_size_bytes); | 349 | table_base[i*2]=runtime->dma_addr+(i*period_size_bytes); |
258 | table_base[(i*2)+1]=period_size_bytes<<16; | 350 | table_base[(i*2)+1]=period_size_bytes<<16; |
259 | } | 351 | } |
@@ -262,7 +354,8 @@ static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) | |||
262 | snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); | 354 | snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); |
263 | snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_PTR, channel, 0); | 355 | snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_PTR, channel, 0); |
264 | snd_emu10k1_ptr20_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr); | 356 | snd_emu10k1_ptr20_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr); |
265 | snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes | 357 | //snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes |
358 | snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, 0); // buffer size in bytes | ||
266 | snd_emu10k1_ptr20_write(emu, PLAYBACK_POINTER, channel, 0); | 359 | snd_emu10k1_ptr20_write(emu, PLAYBACK_POINTER, channel, 0); |
267 | snd_emu10k1_ptr20_write(emu, 0x07, channel, 0x0); | 360 | snd_emu10k1_ptr20_write(emu, 0x07, channel, 0x0); |
268 | snd_emu10k1_ptr20_write(emu, 0x08, channel, 0); | 361 | snd_emu10k1_ptr20_write(emu, 0x08, channel, 0); |
@@ -270,6 +363,41 @@ static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) | |||
270 | return 0; | 363 | return 0; |
271 | } | 364 | } |
272 | 365 | ||
366 | /* prepare capture callback */ | ||
367 | static int snd_p16v_pcm_prepare_capture(snd_pcm_substream_t *substream) | ||
368 | { | ||
369 | emu10k1_t *emu = snd_pcm_substream_chip(substream); | ||
370 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
371 | int channel = substream->pcm->device - emu->p16v_device_offset; | ||
372 | u32 tmp; | ||
373 | //printk("prepare capture:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); | ||
374 | tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel); | ||
375 | switch (runtime->rate) { | ||
376 | case 44100: | ||
377 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0x0e00) | 0x0800); | ||
378 | break; | ||
379 | case 96000: | ||
380 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0x0e00) | 0x0400); | ||
381 | break; | ||
382 | case 192000: | ||
383 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0x0e00) | 0x0200); | ||
384 | break; | ||
385 | case 48000: | ||
386 | default: | ||
387 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0x0e00) | 0x0000); | ||
388 | break; | ||
389 | } | ||
390 | /* FIXME: Check emu->buffer.size before actually writing to it. */ | ||
391 | snd_emu10k1_ptr20_write(emu, 0x13, channel, 0); | ||
392 | snd_emu10k1_ptr20_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); | ||
393 | snd_emu10k1_ptr20_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes | ||
394 | snd_emu10k1_ptr20_write(emu, CAPTURE_POINTER, channel, 0); | ||
395 | //snd_emu10k1_ptr20_write(emu, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC or Line in */ | ||
396 | //snd_emu10k1_ptr20_write(emu, EXTENDED_INT_MASK, 0, snd_emu10k1_ptr20_read(emu, EXTENDED_INT_MASK, 0) | (0x110000<<channel)); | ||
397 | |||
398 | return 0; | ||
399 | } | ||
400 | |||
273 | static void snd_p16v_intr_enable(emu10k1_t *emu, unsigned int intrenb) | 401 | static void snd_p16v_intr_enable(emu10k1_t *emu, unsigned int intrenb) |
274 | { | 402 | { |
275 | unsigned long flags; | 403 | unsigned long flags; |
@@ -345,6 +473,36 @@ static int snd_p16v_pcm_trigger_playback(snd_pcm_substream_t *substream, | |||
345 | return result; | 473 | return result; |
346 | } | 474 | } |
347 | 475 | ||
476 | /* trigger_capture callback */ | ||
477 | static int snd_p16v_pcm_trigger_capture(snd_pcm_substream_t *substream, | ||
478 | int cmd) | ||
479 | { | ||
480 | emu10k1_t *emu = snd_pcm_substream_chip(substream); | ||
481 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
482 | emu10k1_pcm_t *epcm = runtime->private_data; | ||
483 | int channel = 0; | ||
484 | int result = 0; | ||
485 | u32 inte = INTE2_CAPTURE_CH_0_LOOP | INTE2_CAPTURE_CH_0_HALF_LOOP; | ||
486 | |||
487 | switch (cmd) { | ||
488 | case SNDRV_PCM_TRIGGER_START: | ||
489 | snd_p16v_intr_enable(emu, inte); | ||
490 | snd_emu10k1_ptr20_write(emu, BASIC_INTERRUPT, 0, snd_emu10k1_ptr20_read(emu, BASIC_INTERRUPT, 0)|(0x100<<channel)); | ||
491 | epcm->running = 1; | ||
492 | break; | ||
493 | case SNDRV_PCM_TRIGGER_STOP: | ||
494 | snd_emu10k1_ptr20_write(emu, BASIC_INTERRUPT, 0, snd_emu10k1_ptr20_read(emu, BASIC_INTERRUPT, 0) & ~(0x100<<channel)); | ||
495 | snd_p16v_intr_disable(emu, inte); | ||
496 | //snd_emu10k1_ptr20_write(emu, EXTENDED_INT_MASK, 0, snd_emu10k1_ptr20_read(emu, EXTENDED_INT_MASK, 0) & ~(0x110000<<channel)); | ||
497 | epcm->running = 0; | ||
498 | break; | ||
499 | default: | ||
500 | result = -EINVAL; | ||
501 | break; | ||
502 | } | ||
503 | return result; | ||
504 | } | ||
505 | |||
348 | /* pointer_playback callback */ | 506 | /* pointer_playback callback */ |
349 | static snd_pcm_uframes_t | 507 | static snd_pcm_uframes_t |
350 | snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream) | 508 | snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream) |
@@ -370,6 +528,31 @@ snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream) | |||
370 | return ptr; | 528 | return ptr; |
371 | } | 529 | } |
372 | 530 | ||
531 | /* pointer_capture callback */ | ||
532 | static snd_pcm_uframes_t | ||
533 | snd_p16v_pcm_pointer_capture(snd_pcm_substream_t *substream) | ||
534 | { | ||
535 | emu10k1_t *emu = snd_pcm_substream_chip(substream); | ||
536 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
537 | emu10k1_pcm_t *epcm = runtime->private_data; | ||
538 | snd_pcm_uframes_t ptr, ptr1, ptr2 = 0; | ||
539 | int channel = 0; | ||
540 | |||
541 | if (!epcm->running) | ||
542 | return 0; | ||
543 | |||
544 | ptr1 = snd_emu10k1_ptr20_read(emu, CAPTURE_POINTER, channel); | ||
545 | ptr2 = bytes_to_frames(runtime, ptr1); | ||
546 | ptr=ptr2; | ||
547 | if (ptr >= runtime->buffer_size) { | ||
548 | ptr -= runtime->buffer_size; | ||
549 | printk("buffer capture limited!\n"); | ||
550 | } | ||
551 | //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate); | ||
552 | |||
553 | return ptr; | ||
554 | } | ||
555 | |||
373 | /* operators */ | 556 | /* operators */ |
374 | static snd_pcm_ops_t snd_p16v_playback_front_ops = { | 557 | static snd_pcm_ops_t snd_p16v_playback_front_ops = { |
375 | .open = snd_p16v_pcm_open_playback_front, | 558 | .open = snd_p16v_pcm_open_playback_front, |
@@ -382,6 +565,18 @@ static snd_pcm_ops_t snd_p16v_playback_front_ops = { | |||
382 | .pointer = snd_p16v_pcm_pointer_playback, | 565 | .pointer = snd_p16v_pcm_pointer_playback, |
383 | }; | 566 | }; |
384 | 567 | ||
568 | static snd_pcm_ops_t snd_p16v_capture_ops = { | ||
569 | .open = snd_p16v_pcm_open_capture, | ||
570 | .close = snd_p16v_pcm_close_capture, | ||
571 | .ioctl = snd_pcm_lib_ioctl, | ||
572 | .hw_params = snd_p16v_pcm_hw_params_capture, | ||
573 | .hw_free = snd_p16v_pcm_hw_free_capture, | ||
574 | .prepare = snd_p16v_pcm_prepare_capture, | ||
575 | .trigger = snd_p16v_pcm_trigger_capture, | ||
576 | .pointer = snd_p16v_pcm_pointer_capture, | ||
577 | }; | ||
578 | |||
579 | |||
385 | int snd_p16v_free(emu10k1_t *chip) | 580 | int snd_p16v_free(emu10k1_t *chip) |
386 | { | 581 | { |
387 | // release the data | 582 | // release the data |
@@ -405,20 +600,22 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) | |||
405 | snd_pcm_t *pcm; | 600 | snd_pcm_t *pcm; |
406 | snd_pcm_substream_t *substream; | 601 | snd_pcm_substream_t *substream; |
407 | int err; | 602 | int err; |
408 | int capture=0; | 603 | int capture=1; |
409 | 604 | ||
410 | //snd_printk("snd_p16v_pcm called. device=%d\n", device); | 605 | //snd_printk("snd_p16v_pcm called. device=%d\n", device); |
411 | emu->p16v_device_offset = device; | 606 | emu->p16v_device_offset = device; |
412 | if (rpcm) | 607 | if (rpcm) |
413 | *rpcm = NULL; | 608 | *rpcm = NULL; |
414 | //if (device == 0) capture=1; | 609 | |
415 | if ((err = snd_pcm_new(emu->card, "p16v", device, 1, capture, &pcm)) < 0) | 610 | if ((err = snd_pcm_new(emu->card, "p16v", device, 1, capture, &pcm)) < 0) |
416 | return err; | 611 | return err; |
417 | 612 | ||
418 | pcm->private_data = emu; | 613 | pcm->private_data = emu; |
419 | pcm->private_free = snd_p16v_pcm_free; | 614 | pcm->private_free = snd_p16v_pcm_free; |
420 | 615 | // Single playback 8 channel device. | |
616 | // Single capture 2 channel device. | ||
421 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_p16v_playback_front_ops); | 617 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_p16v_playback_front_ops); |
618 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_p16v_capture_ops); | ||
422 | 619 | ||
423 | pcm->info_flags = 0; | 620 | pcm->info_flags = 0; |
424 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; | 621 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; |
@@ -431,7 +628,7 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) | |||
431 | if ((err = snd_pcm_lib_preallocate_pages(substream, | 628 | if ((err = snd_pcm_lib_preallocate_pages(substream, |
432 | SNDRV_DMA_TYPE_DEV, | 629 | SNDRV_DMA_TYPE_DEV, |
433 | snd_dma_pci_data(emu->pci), | 630 | snd_dma_pci_data(emu->pci), |
434 | 64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */ | 631 | ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) |
435 | return err; | 632 | return err; |
436 | //snd_printk("preallocate playback substream: err=%d\n", err); | 633 | //snd_printk("preallocate playback substream: err=%d\n", err); |
437 | } | 634 | } |
@@ -442,7 +639,7 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) | |||
442 | if ((err = snd_pcm_lib_preallocate_pages(substream, | 639 | if ((err = snd_pcm_lib_preallocate_pages(substream, |
443 | SNDRV_DMA_TYPE_DEV, | 640 | SNDRV_DMA_TYPE_DEV, |
444 | snd_dma_pci_data(emu->pci), | 641 | snd_dma_pci_data(emu->pci), |
445 | 64*1024, 64*1024)) < 0) | 642 | 65536 - 64, 65536 - 64)) < 0) |
446 | return err; | 643 | return err; |
447 | //snd_printk("preallocate capture substream: err=%d\n", err); | 644 | //snd_printk("preallocate capture substream: err=%d\n", err); |
448 | } | 645 | } |
@@ -694,6 +891,106 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_rear = | |||
694 | .put = snd_p16v_volume_put_spdif_rear | 891 | .put = snd_p16v_volume_put_spdif_rear |
695 | }; | 892 | }; |
696 | 893 | ||
894 | static int snd_p16v_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | ||
895 | { | ||
896 | static char *texts[8] = { "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", "CDIF", "FX", "AC97" }; | ||
897 | |||
898 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
899 | uinfo->count = 1; | ||
900 | uinfo->value.enumerated.items = 8; | ||
901 | if (uinfo->value.enumerated.item > 7) | ||
902 | uinfo->value.enumerated.item = 7; | ||
903 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
904 | return 0; | ||
905 | } | ||
906 | |||
907 | static int snd_p16v_capture_source_get(snd_kcontrol_t * kcontrol, | ||
908 | snd_ctl_elem_value_t * ucontrol) | ||
909 | { | ||
910 | emu10k1_t *emu = snd_kcontrol_chip(kcontrol); | ||
911 | |||
912 | ucontrol->value.enumerated.item[0] = emu->p16v_capture_source; | ||
913 | return 0; | ||
914 | } | ||
915 | |||
916 | static int snd_p16v_capture_source_put(snd_kcontrol_t * kcontrol, | ||
917 | snd_ctl_elem_value_t * ucontrol) | ||
918 | { | ||
919 | emu10k1_t *emu = snd_kcontrol_chip(kcontrol); | ||
920 | unsigned int val; | ||
921 | int change = 0; | ||
922 | u32 mask; | ||
923 | u32 source; | ||
924 | |||
925 | val = ucontrol->value.enumerated.item[0] ; | ||
926 | change = (emu->p16v_capture_source != val); | ||
927 | if (change) { | ||
928 | emu->p16v_capture_source = val; | ||
929 | source = (val << 28) | (val << 24) | (val << 20) | (val << 16); | ||
930 | mask = snd_emu10k1_ptr20_read(emu, BASIC_INTERRUPT, 0) & 0xffff; | ||
931 | snd_emu10k1_ptr20_write(emu, BASIC_INTERRUPT, 0, source | mask); | ||
932 | } | ||
933 | return change; | ||
934 | } | ||
935 | |||
936 | static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata = | ||
937 | { | ||
938 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
939 | .name = "HD Capture source", | ||
940 | .info = snd_p16v_capture_source_info, | ||
941 | .get = snd_p16v_capture_source_get, | ||
942 | .put = snd_p16v_capture_source_put | ||
943 | }; | ||
944 | |||
945 | static int snd_p16v_capture_channel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | ||
946 | { | ||
947 | static char *texts[4] = { "0", "1", "2", "3", }; | ||
948 | |||
949 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
950 | uinfo->count = 1; | ||
951 | uinfo->value.enumerated.items = 4; | ||
952 | if (uinfo->value.enumerated.item > 3) | ||
953 | uinfo->value.enumerated.item = 3; | ||
954 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
955 | return 0; | ||
956 | } | ||
957 | |||
958 | static int snd_p16v_capture_channel_get(snd_kcontrol_t * kcontrol, | ||
959 | snd_ctl_elem_value_t * ucontrol) | ||
960 | { | ||
961 | emu10k1_t *emu = snd_kcontrol_chip(kcontrol); | ||
962 | |||
963 | ucontrol->value.enumerated.item[0] = emu->p16v_capture_channel; | ||
964 | return 0; | ||
965 | } | ||
966 | |||
967 | static int snd_p16v_capture_channel_put(snd_kcontrol_t * kcontrol, | ||
968 | snd_ctl_elem_value_t * ucontrol) | ||
969 | { | ||
970 | emu10k1_t *emu = snd_kcontrol_chip(kcontrol); | ||
971 | unsigned int val; | ||
972 | int change = 0; | ||
973 | u32 tmp; | ||
974 | |||
975 | val = ucontrol->value.enumerated.item[0] ; | ||
976 | change = (emu->p16v_capture_channel != val); | ||
977 | if (change) { | ||
978 | emu->p16v_capture_channel = val; | ||
979 | tmp = snd_emu10k1_ptr20_read(emu, CAPTURE_P16V_SOURCE, 0) & 0xfffc; | ||
980 | snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, tmp | val); | ||
981 | } | ||
982 | return change; | ||
983 | } | ||
984 | |||
985 | static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata = | ||
986 | { | ||
987 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
988 | .name = "HD Capture channel", | ||
989 | .info = snd_p16v_capture_channel_info, | ||
990 | .get = snd_p16v_capture_channel_get, | ||
991 | .put = snd_p16v_capture_channel_put | ||
992 | }; | ||
993 | |||
697 | int snd_p16v_mixer(emu10k1_t *emu) | 994 | int snd_p16v_mixer(emu10k1_t *emu) |
698 | { | 995 | { |
699 | int err; | 996 | int err; |
@@ -731,6 +1028,14 @@ int snd_p16v_mixer(emu10k1_t *emu) | |||
731 | return -ENOMEM; | 1028 | return -ENOMEM; |
732 | if ((err = snd_ctl_add(card, kctl))) | 1029 | if ((err = snd_ctl_add(card, kctl))) |
733 | return err; | 1030 | return err; |
1031 | if ((kctl = snd_ctl_new1(&snd_p16v_capture_source, emu)) == NULL) | ||
1032 | return -ENOMEM; | ||
1033 | if ((err = snd_ctl_add(card, kctl))) | ||
1034 | return err; | ||
1035 | if ((kctl = snd_ctl_new1(&snd_p16v_capture_channel, emu)) == NULL) | ||
1036 | return -ENOMEM; | ||
1037 | if ((err = snd_ctl_add(card, kctl))) | ||
1038 | return err; | ||
734 | return 0; | 1039 | return 0; |
735 | } | 1040 | } |
736 | 1041 | ||
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index f910399db5c3..4e63498a58b2 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c | |||
@@ -2401,7 +2401,7 @@ static struct pci_driver driver = { | |||
2401 | 2401 | ||
2402 | static int __init alsa_card_ens137x_init(void) | 2402 | static int __init alsa_card_ens137x_init(void) |
2403 | { | 2403 | { |
2404 | return pci_module_init(&driver); | 2404 | return pci_register_driver(&driver); |
2405 | } | 2405 | } |
2406 | 2406 | ||
2407 | static void __exit alsa_card_ens137x_exit(void) | 2407 | static void __exit alsa_card_ens137x_exit(void) |
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index b4ca8adf393c..b492777bc30f 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c | |||
@@ -1761,7 +1761,7 @@ static struct pci_driver driver = { | |||
1761 | 1761 | ||
1762 | static int __init alsa_card_es1938_init(void) | 1762 | static int __init alsa_card_es1938_init(void) |
1763 | { | 1763 | { |
1764 | return pci_module_init(&driver); | 1764 | return pci_register_driver(&driver); |
1765 | } | 1765 | } |
1766 | 1766 | ||
1767 | static void __exit alsa_card_es1938_exit(void) | 1767 | static void __exit alsa_card_es1938_exit(void) |
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index faf63ff19c42..ea889b311390 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c | |||
@@ -2559,6 +2559,7 @@ static struct ess_device_list pm_whitelist[] __devinitdata = { | |||
2559 | { TYPE_MAESTRO2E, 0x103c }, | 2559 | { TYPE_MAESTRO2E, 0x103c }, |
2560 | { TYPE_MAESTRO2E, 0x1179 }, | 2560 | { TYPE_MAESTRO2E, 0x1179 }, |
2561 | { TYPE_MAESTRO2E, 0x14c0 }, /* HP omnibook 4150 */ | 2561 | { TYPE_MAESTRO2E, 0x14c0 }, /* HP omnibook 4150 */ |
2562 | { TYPE_MAESTRO2E, 0x1558 }, | ||
2562 | }; | 2563 | }; |
2563 | 2564 | ||
2564 | static struct ess_device_list mpu_blacklist[] __devinitdata = { | 2565 | static struct ess_device_list mpu_blacklist[] __devinitdata = { |
@@ -2795,7 +2796,7 @@ static struct pci_driver driver = { | |||
2795 | 2796 | ||
2796 | static int __init alsa_card_es1968_init(void) | 2797 | static int __init alsa_card_es1968_init(void) |
2797 | { | 2798 | { |
2798 | return pci_module_init(&driver); | 2799 | return pci_register_driver(&driver); |
2799 | } | 2800 | } |
2800 | 2801 | ||
2801 | static void __exit alsa_card_es1968_exit(void) | 2802 | static void __exit alsa_card_es1968_exit(void) |
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 08e7c5a296d5..ff10e637a95e 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c | |||
@@ -195,6 +195,7 @@ struct _snd_fm801 { | |||
195 | 195 | ||
196 | static struct pci_device_id snd_fm801_ids[] = { | 196 | static struct pci_device_id snd_fm801_ids[] = { |
197 | { 0x1319, 0x0801, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* FM801 */ | 197 | { 0x1319, 0x0801, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* FM801 */ |
198 | { 0x5213, 0x0510, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* Gallant Odyssey Sound 4 */ | ||
198 | { 0, } | 199 | { 0, } |
199 | }; | 200 | }; |
200 | 201 | ||
@@ -1468,7 +1469,7 @@ static struct pci_driver driver = { | |||
1468 | 1469 | ||
1469 | static int __init alsa_card_fm801_init(void) | 1470 | static int __init alsa_card_fm801_init(void) |
1470 | { | 1471 | { |
1471 | return pci_module_init(&driver); | 1472 | return pci_register_driver(&driver); |
1472 | } | 1473 | } |
1473 | 1474 | ||
1474 | static void __exit alsa_card_fm801_exit(void) | 1475 | static void __exit alsa_card_fm801_exit(void) |
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index 570a59d33b41..bd8cb33c4fb4 100644 --- a/sound/pci/hda/Makefile +++ b/sound/pci/hda/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | snd-hda-intel-objs := hda_intel.o | 1 | snd-hda-intel-objs := hda_intel.o |
2 | snd-hda-codec-objs := hda_codec.o hda_generic.o patch_realtek.o patch_cmedia.o patch_analog.o | 2 | snd-hda-codec-objs := hda_codec.o hda_generic.o patch_realtek.o patch_cmedia.o patch_analog.o patch_sigmatel.o |
3 | ifdef CONFIG_PROC_FS | 3 | ifdef CONFIG_PROC_FS |
4 | snd-hda-codec-objs += hda_proc.o | 4 | snd-hda-codec-objs += hda_proc.o |
5 | endif | 5 | endif |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 9ed117ac0c09..e2cf02387289 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -49,8 +49,10 @@ struct hda_vendor_id { | |||
49 | /* codec vendor labels */ | 49 | /* codec vendor labels */ |
50 | static struct hda_vendor_id hda_vendor_ids[] = { | 50 | static struct hda_vendor_id hda_vendor_ids[] = { |
51 | { 0x10ec, "Realtek" }, | 51 | { 0x10ec, "Realtek" }, |
52 | { 0x11d4, "Analog Devices" }, | ||
52 | { 0x13f6, "C-Media" }, | 53 | { 0x13f6, "C-Media" }, |
53 | { 0x434d, "C-Media" }, | 54 | { 0x434d, "C-Media" }, |
55 | { 0x8384, "SigmaTel" }, | ||
54 | {} /* terminator */ | 56 | {} /* terminator */ |
55 | }; | 57 | }; |
56 | 58 | ||
@@ -508,7 +510,7 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | |||
508 | /* FIXME: support for multiple AFGs? */ | 510 | /* FIXME: support for multiple AFGs? */ |
509 | codec->afg = look_for_afg_node(codec); | 511 | codec->afg = look_for_afg_node(codec); |
510 | if (! codec->afg) { | 512 | if (! codec->afg) { |
511 | snd_printk(KERN_ERR "hda_codec: no AFG node found\n"); | 513 | snd_printdd("hda_codec: no AFG node found\n"); |
512 | snd_hda_codec_free(codec); | 514 | snd_hda_codec_free(codec); |
513 | return -ENODEV; | 515 | return -ENODEV; |
514 | } | 516 | } |
@@ -548,6 +550,9 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | |||
548 | void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, | 550 | void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, |
549 | int channel_id, int format) | 551 | int channel_id, int format) |
550 | { | 552 | { |
553 | if (! nid) | ||
554 | return; | ||
555 | |||
551 | snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", | 556 | snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", |
552 | nid, stream_tag, channel_id, format); | 557 | nid, stream_tag, channel_id, format); |
553 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, | 558 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, |
@@ -561,9 +566,10 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stre | |||
561 | * amp access functions | 566 | * amp access functions |
562 | */ | 567 | */ |
563 | 568 | ||
564 | #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + (idx) * 32 + (dir) * 64) | 569 | /* FIXME: more better hash key? */ |
570 | #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) | ||
565 | #define INFO_AMP_CAPS (1<<0) | 571 | #define INFO_AMP_CAPS (1<<0) |
566 | #define INFO_AMP_VOL (1<<1) | 572 | #define INFO_AMP_VOL(ch) (1 << (1 + (ch))) |
567 | 573 | ||
568 | /* initialize the hash table */ | 574 | /* initialize the hash table */ |
569 | static void init_amp_hash(struct hda_codec *codec) | 575 | static void init_amp_hash(struct hda_codec *codec) |
@@ -622,28 +628,29 @@ static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) | |||
622 | 628 | ||
623 | /* | 629 | /* |
624 | * read the current volume to info | 630 | * read the current volume to info |
625 | * if the cache exists, read from the cache. | 631 | * if the cache exists, read the cache value. |
626 | */ | 632 | */ |
627 | static void get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, | 633 | static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, |
628 | hda_nid_t nid, int ch, int direction, int index) | 634 | hda_nid_t nid, int ch, int direction, int index) |
629 | { | 635 | { |
630 | u32 val, parm; | 636 | u32 val, parm; |
631 | 637 | ||
632 | if (info->status & (INFO_AMP_VOL << ch)) | 638 | if (info->status & INFO_AMP_VOL(ch)) |
633 | return; | 639 | return info->vol[ch]; |
634 | 640 | ||
635 | parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; | 641 | parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; |
636 | parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; | 642 | parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; |
637 | parm |= index; | 643 | parm |= index; |
638 | val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm); | 644 | val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm); |
639 | info->vol[ch] = val & 0xff; | 645 | info->vol[ch] = val & 0xff; |
640 | info->status |= INFO_AMP_VOL << ch; | 646 | info->status |= INFO_AMP_VOL(ch); |
647 | return info->vol[ch]; | ||
641 | } | 648 | } |
642 | 649 | ||
643 | /* | 650 | /* |
644 | * write the current volume in info to the h/w | 651 | * write the current volume in info to the h/w and update the cache |
645 | */ | 652 | */ |
646 | static void put_vol_mute(struct hda_codec *codec, | 653 | static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, |
647 | hda_nid_t nid, int ch, int direction, int index, int val) | 654 | hda_nid_t nid, int ch, int direction, int index, int val) |
648 | { | 655 | { |
649 | u32 parm; | 656 | u32 parm; |
@@ -653,30 +660,34 @@ static void put_vol_mute(struct hda_codec *codec, | |||
653 | parm |= index << AC_AMP_SET_INDEX_SHIFT; | 660 | parm |= index << AC_AMP_SET_INDEX_SHIFT; |
654 | parm |= val; | 661 | parm |= val; |
655 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm); | 662 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm); |
663 | info->vol[ch] = val; | ||
656 | } | 664 | } |
657 | 665 | ||
658 | /* | 666 | /* |
659 | * read/write AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit. | 667 | * read AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit. |
660 | */ | 668 | */ |
661 | int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int index) | 669 | static int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int index) |
662 | { | 670 | { |
663 | struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); | 671 | struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); |
664 | if (! info) | 672 | if (! info) |
665 | return 0; | 673 | return 0; |
666 | get_vol_mute(codec, info, nid, ch, direction, index); | 674 | return get_vol_mute(codec, info, nid, ch, direction, index); |
667 | return info->vol[ch]; | ||
668 | } | 675 | } |
669 | 676 | ||
670 | int snd_hda_codec_amp_write(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int idx, int val) | 677 | /* |
678 | * update the AMP value, mask = bit mask to set, val = the value | ||
679 | */ | ||
680 | static int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int idx, int mask, int val) | ||
671 | { | 681 | { |
672 | struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); | 682 | struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); |
683 | |||
673 | if (! info) | 684 | if (! info) |
674 | return 0; | 685 | return 0; |
675 | get_vol_mute(codec, info, nid, ch, direction, idx); | 686 | val &= mask; |
687 | val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; | ||
676 | if (info->vol[ch] == val && ! codec->in_resume) | 688 | if (info->vol[ch] == val && ! codec->in_resume) |
677 | return 0; | 689 | return 0; |
678 | put_vol_mute(codec, nid, ch, direction, idx, val); | 690 | put_vol_mute(codec, info, nid, ch, direction, idx, val); |
679 | info->vol[ch] = val; | ||
680 | return 1; | 691 | return 1; |
681 | } | 692 | } |
682 | 693 | ||
@@ -735,21 +746,15 @@ int snd_hda_mixer_amp_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
735 | int chs = get_amp_channels(kcontrol); | 746 | int chs = get_amp_channels(kcontrol); |
736 | int dir = get_amp_direction(kcontrol); | 747 | int dir = get_amp_direction(kcontrol); |
737 | int idx = get_amp_index(kcontrol); | 748 | int idx = get_amp_index(kcontrol); |
738 | int val; | ||
739 | long *valp = ucontrol->value.integer.value; | 749 | long *valp = ucontrol->value.integer.value; |
740 | int change = 0; | 750 | int change = 0; |
741 | 751 | ||
742 | if (chs & 1) { | 752 | if (chs & 1) |
743 | val = *valp & 0x7f; | 753 | change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, |
744 | val |= snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x80; | 754 | 0x7f, *valp); |
745 | change = snd_hda_codec_amp_write(codec, nid, 0, dir, idx, val); | 755 | if (chs & 2) |
746 | valp++; | 756 | change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, |
747 | } | 757 | 0x7f, valp[1]); |
748 | if (chs & 2) { | ||
749 | val = *valp & 0x7f; | ||
750 | val |= snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x80; | ||
751 | change |= snd_hda_codec_amp_write(codec, nid, 1, dir, idx, val); | ||
752 | } | ||
753 | return change; | 758 | return change; |
754 | } | 759 | } |
755 | 760 | ||
@@ -788,21 +793,15 @@ int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
788 | int chs = get_amp_channels(kcontrol); | 793 | int chs = get_amp_channels(kcontrol); |
789 | int dir = get_amp_direction(kcontrol); | 794 | int dir = get_amp_direction(kcontrol); |
790 | int idx = get_amp_index(kcontrol); | 795 | int idx = get_amp_index(kcontrol); |
791 | int val; | ||
792 | long *valp = ucontrol->value.integer.value; | 796 | long *valp = ucontrol->value.integer.value; |
793 | int change = 0; | 797 | int change = 0; |
794 | 798 | ||
795 | if (chs & 1) { | 799 | if (chs & 1) |
796 | val = snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x7f; | 800 | change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, |
797 | val |= *valp ? 0 : 0x80; | 801 | 0x80, *valp ? 0 : 0x80); |
798 | change = snd_hda_codec_amp_write(codec, nid, 0, dir, idx, val); | 802 | if (chs & 2) |
799 | valp++; | 803 | change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, |
800 | } | 804 | 0x80, valp[1] ? 0 : 0x80); |
801 | if (chs & 2) { | ||
802 | val = snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x7f; | ||
803 | val |= *valp ? 0 : 0x80; | ||
804 | change = snd_hda_codec_amp_write(codec, nid, 1, dir, idx, val); | ||
805 | } | ||
806 | return change; | 805 | return change; |
807 | } | 806 | } |
808 | 807 | ||
@@ -1448,10 +1447,6 @@ static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream | |||
1448 | snd_assert(info->nid, return -EINVAL); | 1447 | snd_assert(info->nid, return -EINVAL); |
1449 | info->ops.prepare = hda_pcm_default_prepare; | 1448 | info->ops.prepare = hda_pcm_default_prepare; |
1450 | } | 1449 | } |
1451 | if (info->ops.prepare == NULL) { | ||
1452 | snd_assert(info->nid, return -EINVAL); | ||
1453 | info->ops.prepare = hda_pcm_default_prepare; | ||
1454 | } | ||
1455 | if (info->ops.cleanup == NULL) { | 1450 | if (info->ops.cleanup == NULL) { |
1456 | snd_assert(info->nid, return -EINVAL); | 1451 | snd_assert(info->nid, return -EINVAL); |
1457 | info->ops.cleanup = hda_pcm_default_cleanup; | 1452 | info->ops.cleanup = hda_pcm_default_cleanup; |
@@ -1525,12 +1520,12 @@ int snd_hda_build_pcms(struct hda_bus *bus) | |||
1525 | * | 1520 | * |
1526 | * If no entries are matching, the function returns a negative value. | 1521 | * If no entries are matching, the function returns a negative value. |
1527 | */ | 1522 | */ |
1528 | int snd_hda_check_board_config(struct hda_codec *codec, struct hda_board_config *tbl) | 1523 | int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl) |
1529 | { | 1524 | { |
1530 | struct hda_board_config *c; | 1525 | const struct hda_board_config *c; |
1531 | 1526 | ||
1532 | if (codec->bus->modelname) { | 1527 | if (codec->bus->modelname) { |
1533 | for (c = tbl; c->modelname || c->pci_vendor; c++) { | 1528 | for (c = tbl; c->modelname || c->pci_subvendor; c++) { |
1534 | if (c->modelname && | 1529 | if (c->modelname && |
1535 | ! strcmp(codec->bus->modelname, c->modelname)) { | 1530 | ! strcmp(codec->bus->modelname, c->modelname)) { |
1536 | snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname); | 1531 | snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname); |
@@ -1543,9 +1538,10 @@ int snd_hda_check_board_config(struct hda_codec *codec, struct hda_board_config | |||
1543 | u16 subsystem_vendor, subsystem_device; | 1538 | u16 subsystem_vendor, subsystem_device; |
1544 | pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); | 1539 | pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); |
1545 | pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device); | 1540 | pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device); |
1546 | for (c = tbl; c->modelname || c->pci_vendor; c++) { | 1541 | for (c = tbl; c->modelname || c->pci_subvendor; c++) { |
1547 | if (c->pci_vendor == subsystem_vendor && | 1542 | if (c->pci_subvendor == subsystem_vendor && |
1548 | c->pci_device == subsystem_device) | 1543 | (! c->pci_subdevice /* all match */|| |
1544 | (c->pci_subdevice == subsystem_device))) | ||
1549 | return c->config; | 1545 | return c->config; |
1550 | } | 1546 | } |
1551 | } | 1547 | } |
@@ -1687,11 +1683,12 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o | |||
1687 | snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); | 1683 | snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); |
1688 | /* surrounds */ | 1684 | /* surrounds */ |
1689 | for (i = 1; i < mout->num_dacs; i++) { | 1685 | for (i = 1; i < mout->num_dacs; i++) { |
1690 | if (i == HDA_REAR && chs == 2) /* copy front to rear */ | 1686 | if (chs >= (i + 1) * 2) /* independent out */ |
1691 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, format); | ||
1692 | else if (chs >= (i + 1) * 2) /* independent out */ | ||
1693 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, | 1687 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, |
1694 | format); | 1688 | format); |
1689 | else /* copy front */ | ||
1690 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, | ||
1691 | format); | ||
1695 | } | 1692 | } |
1696 | return 0; | 1693 | return 0; |
1697 | } | 1694 | } |
@@ -1717,6 +1714,105 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o | |||
1717 | return 0; | 1714 | return 0; |
1718 | } | 1715 | } |
1719 | 1716 | ||
1717 | /* | ||
1718 | * Helper for automatic ping configuration | ||
1719 | */ | ||
1720 | /* parse all pin widgets and store the useful pin nids to cfg */ | ||
1721 | int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg) | ||
1722 | { | ||
1723 | hda_nid_t nid, nid_start; | ||
1724 | int i, j, nodes; | ||
1725 | short seq, sequences[4], assoc_line_out; | ||
1726 | |||
1727 | memset(cfg, 0, sizeof(*cfg)); | ||
1728 | |||
1729 | memset(sequences, 0, sizeof(sequences)); | ||
1730 | assoc_line_out = 0; | ||
1731 | |||
1732 | nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); | ||
1733 | for (nid = nid_start; nid < nodes + nid_start; nid++) { | ||
1734 | unsigned int wid_caps = snd_hda_param_read(codec, nid, | ||
1735 | AC_PAR_AUDIO_WIDGET_CAP); | ||
1736 | unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
1737 | unsigned int def_conf; | ||
1738 | short assoc, loc; | ||
1739 | |||
1740 | /* read all default configuration for pin complex */ | ||
1741 | if (wid_type != AC_WID_PIN) | ||
1742 | continue; | ||
1743 | def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
1744 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | ||
1745 | continue; | ||
1746 | loc = get_defcfg_location(def_conf); | ||
1747 | switch (get_defcfg_device(def_conf)) { | ||
1748 | case AC_JACK_LINE_OUT: | ||
1749 | case AC_JACK_SPEAKER: | ||
1750 | seq = get_defcfg_sequence(def_conf); | ||
1751 | assoc = get_defcfg_association(def_conf); | ||
1752 | if (! assoc) | ||
1753 | continue; | ||
1754 | if (! assoc_line_out) | ||
1755 | assoc_line_out = assoc; | ||
1756 | else if (assoc_line_out != assoc) | ||
1757 | continue; | ||
1758 | if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) | ||
1759 | continue; | ||
1760 | cfg->line_out_pins[cfg->line_outs] = nid; | ||
1761 | sequences[cfg->line_outs] = seq; | ||
1762 | cfg->line_outs++; | ||
1763 | break; | ||
1764 | case AC_JACK_HP_OUT: | ||
1765 | cfg->hp_pin = nid; | ||
1766 | break; | ||
1767 | case AC_JACK_MIC_IN: | ||
1768 | if (loc == AC_JACK_LOC_FRONT) | ||
1769 | cfg->input_pins[AUTO_PIN_FRONT_MIC] = nid; | ||
1770 | else | ||
1771 | cfg->input_pins[AUTO_PIN_MIC] = nid; | ||
1772 | break; | ||
1773 | case AC_JACK_LINE_IN: | ||
1774 | if (loc == AC_JACK_LOC_FRONT) | ||
1775 | cfg->input_pins[AUTO_PIN_FRONT_LINE] = nid; | ||
1776 | else | ||
1777 | cfg->input_pins[AUTO_PIN_LINE] = nid; | ||
1778 | break; | ||
1779 | case AC_JACK_CD: | ||
1780 | cfg->input_pins[AUTO_PIN_CD] = nid; | ||
1781 | break; | ||
1782 | case AC_JACK_AUX: | ||
1783 | cfg->input_pins[AUTO_PIN_AUX] = nid; | ||
1784 | break; | ||
1785 | case AC_JACK_SPDIF_OUT: | ||
1786 | cfg->dig_out_pin = nid; | ||
1787 | break; | ||
1788 | case AC_JACK_SPDIF_IN: | ||
1789 | cfg->dig_in_pin = nid; | ||
1790 | break; | ||
1791 | } | ||
1792 | } | ||
1793 | |||
1794 | /* sort by sequence */ | ||
1795 | for (i = 0; i < cfg->line_outs; i++) | ||
1796 | for (j = i + 1; j < cfg->line_outs; j++) | ||
1797 | if (sequences[i] > sequences[j]) { | ||
1798 | seq = sequences[i]; | ||
1799 | sequences[i] = sequences[j]; | ||
1800 | sequences[j] = seq; | ||
1801 | nid = cfg->line_out_pins[i]; | ||
1802 | cfg->line_out_pins[i] = cfg->line_out_pins[j]; | ||
1803 | cfg->line_out_pins[j] = nid; | ||
1804 | } | ||
1805 | |||
1806 | /* Swap surround and CLFE: the association order is front/CLFE/surr/back */ | ||
1807 | if (cfg->line_outs >= 3) { | ||
1808 | nid = cfg->line_out_pins[1]; | ||
1809 | cfg->line_out_pins[1] = cfg->line_out_pins[2]; | ||
1810 | cfg->line_out_pins[2] = nid; | ||
1811 | } | ||
1812 | |||
1813 | return 0; | ||
1814 | } | ||
1815 | |||
1720 | #ifdef CONFIG_PM | 1816 | #ifdef CONFIG_PM |
1721 | /* | 1817 | /* |
1722 | * power management | 1818 | * power management |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index c9e9dc9c7c98..59991560d492 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -75,6 +75,9 @@ enum { | |||
75 | #define AC_VERB_GET_DIGI_CONVERT 0x0f0d | 75 | #define AC_VERB_GET_DIGI_CONVERT 0x0f0d |
76 | #define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f | 76 | #define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f |
77 | /* f10-f1a: GPIO */ | 77 | /* f10-f1a: GPIO */ |
78 | #define AC_VERB_GET_GPIO_DATA 0x0f15 | ||
79 | #define AC_VERB_GET_GPIO_MASK 0x0f16 | ||
80 | #define AC_VERB_GET_GPIO_DIRECTION 0x0f17 | ||
78 | #define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c | 81 | #define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c |
79 | 82 | ||
80 | /* | 83 | /* |
@@ -97,6 +100,9 @@ enum { | |||
97 | #define AC_VERB_SET_DIGI_CONVERT_1 0x70d | 100 | #define AC_VERB_SET_DIGI_CONVERT_1 0x70d |
98 | #define AC_VERB_SET_DIGI_CONVERT_2 0x70e | 101 | #define AC_VERB_SET_DIGI_CONVERT_2 0x70e |
99 | #define AC_VERB_SET_VOLUME_KNOB_CONTROL 0x70f | 102 | #define AC_VERB_SET_VOLUME_KNOB_CONTROL 0x70f |
103 | #define AC_VERB_SET_GPIO_DATA 0x715 | ||
104 | #define AC_VERB_SET_GPIO_MASK 0x716 | ||
105 | #define AC_VERB_SET_GPIO_DIRECTION 0x717 | ||
100 | #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c | 106 | #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c |
101 | #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d | 107 | #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d |
102 | #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e | 108 | #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e |
@@ -176,16 +182,15 @@ enum { | |||
176 | #define AC_PINCAP_OUT (1<<4) /* output capable */ | 182 | #define AC_PINCAP_OUT (1<<4) /* output capable */ |
177 | #define AC_PINCAP_IN (1<<5) /* input capable */ | 183 | #define AC_PINCAP_IN (1<<5) /* input capable */ |
178 | #define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */ | 184 | #define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */ |
179 | #define AC_PINCAP_VREF (7<<8) | 185 | #define AC_PINCAP_VREF (0x37<<8) |
180 | #define AC_PINCAP_VREF_SHIFT 8 | 186 | #define AC_PINCAP_VREF_SHIFT 8 |
181 | #define AC_PINCAP_EAPD (1<<16) /* EAPD capable */ | 187 | #define AC_PINCAP_EAPD (1<<16) /* EAPD capable */ |
182 | /* Vref status (used in pin cap and pin ctl) */ | 188 | /* Vref status (used in pin cap) */ |
183 | #define AC_PIN_VREF_HIZ (1<<0) /* Hi-Z */ | 189 | #define AC_PINCAP_VREF_HIZ (1<<0) /* Hi-Z */ |
184 | #define AC_PIN_VREF_50 (1<<1) /* 50% */ | 190 | #define AC_PINCAP_VREF_50 (1<<1) /* 50% */ |
185 | #define AC_PIN_VREF_GRD (1<<2) /* ground */ | 191 | #define AC_PINCAP_VREF_GRD (1<<2) /* ground */ |
186 | #define AC_PIN_VREF_80 (1<<4) /* 80% */ | 192 | #define AC_PINCAP_VREF_80 (1<<4) /* 80% */ |
187 | #define AC_PIN_VREF_100 (1<<5) /* 100% */ | 193 | #define AC_PINCAP_VREF_100 (1<<5) /* 100% */ |
188 | |||
189 | 194 | ||
190 | /* Amplifier capabilities */ | 195 | /* Amplifier capabilities */ |
191 | #define AC_AMPCAP_OFFSET (0x7f<<0) /* 0dB offset */ | 196 | #define AC_AMPCAP_OFFSET (0x7f<<0) /* 0dB offset */ |
@@ -248,6 +253,11 @@ enum { | |||
248 | 253 | ||
249 | /* Pin widget control - 8bit */ | 254 | /* Pin widget control - 8bit */ |
250 | #define AC_PINCTL_VREFEN (0x7<<0) | 255 | #define AC_PINCTL_VREFEN (0x7<<0) |
256 | #define AC_PINCTL_VREF_HIZ 0 /* Hi-Z */ | ||
257 | #define AC_PINCTL_VREF_50 1 /* 50% */ | ||
258 | #define AC_PINCTL_VREF_GRD 2 /* ground */ | ||
259 | #define AC_PINCTL_VREF_80 4 /* 80% */ | ||
260 | #define AC_PINCTL_VREF_100 5 /* 100% */ | ||
251 | #define AC_PINCTL_IN_EN (1<<5) | 261 | #define AC_PINCTL_IN_EN (1<<5) |
252 | #define AC_PINCTL_OUT_EN (1<<6) | 262 | #define AC_PINCTL_OUT_EN (1<<6) |
253 | #define AC_PINCTL_HP_EN (1<<7) | 263 | #define AC_PINCTL_HP_EN (1<<7) |
@@ -255,7 +265,9 @@ enum { | |||
255 | /* configuration default - 32bit */ | 265 | /* configuration default - 32bit */ |
256 | #define AC_DEFCFG_SEQUENCE (0xf<<0) | 266 | #define AC_DEFCFG_SEQUENCE (0xf<<0) |
257 | #define AC_DEFCFG_DEF_ASSOC (0xf<<4) | 267 | #define AC_DEFCFG_DEF_ASSOC (0xf<<4) |
268 | #define AC_DEFCFG_ASSOC_SHIFT 4 | ||
258 | #define AC_DEFCFG_MISC (0xf<<8) | 269 | #define AC_DEFCFG_MISC (0xf<<8) |
270 | #define AC_DEFCFG_MISC_SHIFT 8 | ||
259 | #define AC_DEFCFG_COLOR (0xf<<12) | 271 | #define AC_DEFCFG_COLOR (0xf<<12) |
260 | #define AC_DEFCFG_COLOR_SHIFT 12 | 272 | #define AC_DEFCFG_COLOR_SHIFT 12 |
261 | #define AC_DEFCFG_CONN_TYPE (0xf<<16) | 273 | #define AC_DEFCFG_CONN_TYPE (0xf<<16) |
@@ -413,7 +425,7 @@ struct hda_bus { | |||
413 | 425 | ||
414 | /* codec linked list */ | 426 | /* codec linked list */ |
415 | struct list_head codec_list; | 427 | struct list_head codec_list; |
416 | struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS]; /* caddr -> codec */ | 428 | struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; /* caddr -> codec */ |
417 | 429 | ||
418 | struct semaphore cmd_mutex; | 430 | struct semaphore cmd_mutex; |
419 | 431 | ||
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 69f7b6c4cf83..2d046abb5911 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -44,7 +44,7 @@ struct hda_gnode { | |||
44 | struct list_head list; | 44 | struct list_head list; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | /* pathc-specific record */ | 47 | /* patch-specific record */ |
48 | struct hda_gspec { | 48 | struct hda_gspec { |
49 | struct hda_gnode *dac_node; /* DAC node */ | 49 | struct hda_gnode *dac_node; /* DAC node */ |
50 | struct hda_gnode *out_pin_node; /* Output pin (Line-Out) node */ | 50 | struct hda_gnode *out_pin_node; /* Output pin (Line-Out) node */ |
@@ -68,8 +68,8 @@ struct hda_gspec { | |||
68 | /* | 68 | /* |
69 | * retrieve the default device type from the default config value | 69 | * retrieve the default device type from the default config value |
70 | */ | 70 | */ |
71 | #define get_defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) | 71 | #define defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) |
72 | #define get_defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) | 72 | #define defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) |
73 | 73 | ||
74 | /* | 74 | /* |
75 | * destructor | 75 | * destructor |
@@ -323,7 +323,7 @@ static struct hda_gnode *parse_output_jack(struct hda_codec *codec, | |||
323 | if (! (node->pin_caps & AC_PINCAP_OUT)) | 323 | if (! (node->pin_caps & AC_PINCAP_OUT)) |
324 | continue; | 324 | continue; |
325 | if (jack_type >= 0) { | 325 | if (jack_type >= 0) { |
326 | if (jack_type != get_defcfg_type(node)) | 326 | if (jack_type != defcfg_type(node)) |
327 | continue; | 327 | continue; |
328 | if (node->wid_caps & AC_WCAP_DIGITAL) | 328 | if (node->wid_caps & AC_WCAP_DIGITAL) |
329 | continue; /* skip SPDIF */ | 329 | continue; /* skip SPDIF */ |
@@ -418,15 +418,15 @@ static int capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc | |||
418 | */ | 418 | */ |
419 | static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl) | 419 | static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl) |
420 | { | 420 | { |
421 | unsigned int location = get_defcfg_location(node); | 421 | unsigned int location = defcfg_location(node); |
422 | switch (get_defcfg_type(node)) { | 422 | switch (defcfg_type(node)) { |
423 | case AC_JACK_LINE_IN: | 423 | case AC_JACK_LINE_IN: |
424 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) | 424 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) |
425 | return "Front Line"; | 425 | return "Front Line"; |
426 | return "Line"; | 426 | return "Line"; |
427 | case AC_JACK_CD: | 427 | case AC_JACK_CD: |
428 | if (pinctl) | 428 | if (pinctl) |
429 | *pinctl |= AC_PIN_VREF_GRD; | 429 | *pinctl |= AC_PINCTL_VREF_GRD; |
430 | return "CD"; | 430 | return "CD"; |
431 | case AC_JACK_AUX: | 431 | case AC_JACK_AUX: |
432 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) | 432 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 959953ca320a..5e0cca36ed57 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -51,6 +51,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | |||
51 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | 51 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
52 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | 52 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
53 | static char *model[SNDRV_CARDS]; | 53 | static char *model[SNDRV_CARDS]; |
54 | static int position_fix[SNDRV_CARDS]; | ||
54 | 55 | ||
55 | module_param_array(index, int, NULL, 0444); | 56 | module_param_array(index, int, NULL, 0444); |
56 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); | 57 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); |
@@ -60,12 +61,17 @@ module_param_array(enable, bool, NULL, 0444); | |||
60 | MODULE_PARM_DESC(enable, "Enable Intel HD audio interface."); | 61 | MODULE_PARM_DESC(enable, "Enable Intel HD audio interface."); |
61 | module_param_array(model, charp, NULL, 0444); | 62 | module_param_array(model, charp, NULL, 0444); |
62 | MODULE_PARM_DESC(model, "Use the given board model."); | 63 | MODULE_PARM_DESC(model, "Use the given board model."); |
64 | module_param_array(position_fix, int, NULL, 0444); | ||
65 | MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = FIFO size, 1 = none, 2 = POSBUF)."); | ||
63 | 66 | ||
64 | MODULE_LICENSE("GPL"); | 67 | MODULE_LICENSE("GPL"); |
65 | MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," | 68 | MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," |
66 | "{Intel, ICH6M}," | 69 | "{Intel, ICH6M}," |
67 | "{Intel, ICH7}," | 70 | "{Intel, ICH7}," |
68 | "{Intel, ESB2}}"); | 71 | "{Intel, ESB2}," |
72 | "{ATI, SB450}," | ||
73 | "{VIA, VT8251}," | ||
74 | "{VIA, VT8237A}}"); | ||
69 | MODULE_DESCRIPTION("Intel HDA driver"); | 75 | MODULE_DESCRIPTION("Intel HDA driver"); |
70 | 76 | ||
71 | #define SFX "hda-intel: " | 77 | #define SFX "hda-intel: " |
@@ -150,7 +156,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; | |||
150 | 156 | ||
151 | /* STATESTS int mask: SD2,SD1,SD0 */ | 157 | /* STATESTS int mask: SD2,SD1,SD0 */ |
152 | #define STATESTS_INT_MASK 0x07 | 158 | #define STATESTS_INT_MASK 0x07 |
153 | #define AZX_MAX_CODECS 3 | 159 | #define AZX_MAX_CODECS 4 |
154 | 160 | ||
155 | /* SD_CTL bits */ | 161 | /* SD_CTL bits */ |
156 | #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ | 162 | #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ |
@@ -183,6 +189,18 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; | |||
183 | #define ICH6_MAX_CORB_ENTRIES 256 | 189 | #define ICH6_MAX_CORB_ENTRIES 256 |
184 | #define ICH6_MAX_RIRB_ENTRIES 256 | 190 | #define ICH6_MAX_RIRB_ENTRIES 256 |
185 | 191 | ||
192 | /* position fix mode */ | ||
193 | enum { | ||
194 | POS_FIX_FIFO, | ||
195 | POS_FIX_NONE, | ||
196 | POS_FIX_POSBUF | ||
197 | }; | ||
198 | |||
199 | /* Defines for ATI HD Audio support in SB450 south bridge */ | ||
200 | #define ATI_SB450_HDAUDIO_PCI_DEVICE_ID 0x437b | ||
201 | #define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42 | ||
202 | #define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02 | ||
203 | |||
186 | 204 | ||
187 | /* | 205 | /* |
188 | * Use CORB/RIRB for communication from/to codecs. | 206 | * Use CORB/RIRB for communication from/to codecs. |
@@ -191,12 +209,6 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; | |||
191 | #define USE_CORB_RIRB | 209 | #define USE_CORB_RIRB |
192 | 210 | ||
193 | /* | 211 | /* |
194 | * Define this if use the position buffer instead of reading SD_LPIB | ||
195 | * It's not used as default since SD_LPIB seems to give more accurate position | ||
196 | */ | ||
197 | /* #define USE_POSBUF */ | ||
198 | |||
199 | /* | ||
200 | */ | 212 | */ |
201 | 213 | ||
202 | typedef struct snd_azx azx_t; | 214 | typedef struct snd_azx azx_t; |
@@ -271,6 +283,10 @@ struct snd_azx { | |||
271 | struct snd_dma_buffer bdl; | 283 | struct snd_dma_buffer bdl; |
272 | struct snd_dma_buffer rb; | 284 | struct snd_dma_buffer rb; |
273 | struct snd_dma_buffer posbuf; | 285 | struct snd_dma_buffer posbuf; |
286 | |||
287 | /* flags */ | ||
288 | int position_fix; | ||
289 | unsigned int initialized: 1; | ||
274 | }; | 290 | }; |
275 | 291 | ||
276 | /* | 292 | /* |
@@ -638,7 +654,7 @@ static void azx_stream_stop(azx_t *chip, azx_dev_t *azx_dev) | |||
638 | */ | 654 | */ |
639 | static void azx_init_chip(azx_t *chip) | 655 | static void azx_init_chip(azx_t *chip) |
640 | { | 656 | { |
641 | unsigned char tcsel_reg; | 657 | unsigned char tcsel_reg, ati_misc_cntl2; |
642 | 658 | ||
643 | /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) | 659 | /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) |
644 | * TCSEL == Traffic Class Select Register, which sets PCI express QOS | 660 | * TCSEL == Traffic Class Select Register, which sets PCI express QOS |
@@ -657,11 +673,20 @@ static void azx_init_chip(azx_t *chip) | |||
657 | /* initialize the codec command I/O */ | 673 | /* initialize the codec command I/O */ |
658 | azx_init_cmd_io(chip); | 674 | azx_init_cmd_io(chip); |
659 | 675 | ||
660 | #ifdef USE_POSBUF | 676 | if (chip->position_fix == POS_FIX_POSBUF) { |
661 | /* program the position buffer */ | 677 | /* program the position buffer */ |
662 | azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); | 678 | azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); |
663 | azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr)); | 679 | azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr)); |
664 | #endif | 680 | } |
681 | |||
682 | /* For ATI SB450 azalia HD audio, we need to enable snoop */ | ||
683 | if (chip->pci->vendor == PCI_VENDOR_ID_ATI && | ||
684 | chip->pci->device == ATI_SB450_HDAUDIO_PCI_DEVICE_ID) { | ||
685 | pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, | ||
686 | &ati_misc_cntl2); | ||
687 | pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, | ||
688 | (ati_misc_cntl2 & 0xf8) | ATI_SB450_HDAUDIO_ENABLE_SNOOP); | ||
689 | } | ||
665 | } | 690 | } |
666 | 691 | ||
667 | 692 | ||
@@ -791,11 +816,12 @@ static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev) | |||
791 | /* upper BDL address */ | 816 | /* upper BDL address */ |
792 | azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); | 817 | azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); |
793 | 818 | ||
794 | #ifdef USE_POSBUF | 819 | if (chip->position_fix == POS_FIX_POSBUF) { |
795 | /* enable the position buffer */ | 820 | /* enable the position buffer */ |
796 | if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) | 821 | if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) |
797 | azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); | 822 | azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); |
798 | #endif | 823 | } |
824 | |||
799 | /* set the interrupt enable bits in the descriptor control register */ | 825 | /* set the interrupt enable bits in the descriptor control register */ |
800 | azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); | 826 | azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); |
801 | 827 | ||
@@ -1036,16 +1062,20 @@ static int azx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) | |||
1036 | 1062 | ||
1037 | static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream) | 1063 | static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream) |
1038 | { | 1064 | { |
1065 | struct azx_pcm *apcm = snd_pcm_substream_chip(substream); | ||
1066 | azx_t *chip = apcm->chip; | ||
1039 | azx_dev_t *azx_dev = get_azx_dev(substream); | 1067 | azx_dev_t *azx_dev = get_azx_dev(substream); |
1040 | unsigned int pos; | 1068 | unsigned int pos; |
1041 | 1069 | ||
1042 | #ifdef USE_POSBUF | 1070 | if (chip->position_fix == POS_FIX_POSBUF) { |
1043 | /* use the position buffer */ | 1071 | /* use the position buffer */ |
1044 | pos = *azx_dev->posbuf; | 1072 | pos = *azx_dev->posbuf; |
1045 | #else | 1073 | } else { |
1046 | /* read LPIB */ | 1074 | /* read LPIB */ |
1047 | pos = azx_sd_readl(azx_dev, SD_LPIB) + azx_dev->fifo_size; | 1075 | pos = azx_sd_readl(azx_dev, SD_LPIB); |
1048 | #endif | 1076 | if (chip->position_fix == POS_FIX_FIFO) |
1077 | pos += azx_dev->fifo_size; | ||
1078 | } | ||
1049 | if (pos >= azx_dev->bufsize) | 1079 | if (pos >= azx_dev->bufsize) |
1050 | pos = 0; | 1080 | pos = 0; |
1051 | return bytes_to_frames(substream->runtime, pos); | 1081 | return bytes_to_frames(substream->runtime, pos); |
@@ -1155,9 +1185,8 @@ static int __devinit azx_init_stream(azx_t *chip) | |||
1155 | azx_dev_t *azx_dev = &chip->azx_dev[i]; | 1185 | azx_dev_t *azx_dev = &chip->azx_dev[i]; |
1156 | azx_dev->bdl = (u32 *)(chip->bdl.area + off); | 1186 | azx_dev->bdl = (u32 *)(chip->bdl.area + off); |
1157 | azx_dev->bdl_addr = chip->bdl.addr + off; | 1187 | azx_dev->bdl_addr = chip->bdl.addr + off; |
1158 | #ifdef USE_POSBUF | 1188 | if (chip->position_fix == POS_FIX_POSBUF) |
1159 | azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); | 1189 | azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); |
1160 | #endif | ||
1161 | /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ | 1190 | /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ |
1162 | azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); | 1191 | azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); |
1163 | /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ | 1192 | /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ |
@@ -1207,7 +1236,7 @@ static int azx_resume(snd_card_t *card) | |||
1207 | */ | 1236 | */ |
1208 | static int azx_free(azx_t *chip) | 1237 | static int azx_free(azx_t *chip) |
1209 | { | 1238 | { |
1210 | if (chip->remap_addr) { | 1239 | if (chip->initialized) { |
1211 | int i; | 1240 | int i; |
1212 | 1241 | ||
1213 | for (i = 0; i < MAX_ICH6_DEV; i++) | 1242 | for (i = 0; i < MAX_ICH6_DEV; i++) |
@@ -1237,10 +1266,8 @@ static int azx_free(azx_t *chip) | |||
1237 | snd_dma_free_pages(&chip->bdl); | 1266 | snd_dma_free_pages(&chip->bdl); |
1238 | if (chip->rb.area) | 1267 | if (chip->rb.area) |
1239 | snd_dma_free_pages(&chip->rb); | 1268 | snd_dma_free_pages(&chip->rb); |
1240 | #ifdef USE_POSBUF | ||
1241 | if (chip->posbuf.area) | 1269 | if (chip->posbuf.area) |
1242 | snd_dma_free_pages(&chip->posbuf); | 1270 | snd_dma_free_pages(&chip->posbuf); |
1243 | #endif | ||
1244 | pci_release_regions(chip->pci); | 1271 | pci_release_regions(chip->pci); |
1245 | pci_disable_device(chip->pci); | 1272 | pci_disable_device(chip->pci); |
1246 | kfree(chip); | 1273 | kfree(chip); |
@@ -1256,7 +1283,8 @@ static int azx_dev_free(snd_device_t *device) | |||
1256 | /* | 1283 | /* |
1257 | * constructor | 1284 | * constructor |
1258 | */ | 1285 | */ |
1259 | static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **rchip) | 1286 | static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, |
1287 | int posfix, azx_t **rchip) | ||
1260 | { | 1288 | { |
1261 | azx_t *chip; | 1289 | azx_t *chip; |
1262 | int err = 0; | 1290 | int err = 0; |
@@ -1283,6 +1311,8 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r | |||
1283 | chip->pci = pci; | 1311 | chip->pci = pci; |
1284 | chip->irq = -1; | 1312 | chip->irq = -1; |
1285 | 1313 | ||
1314 | chip->position_fix = posfix; | ||
1315 | |||
1286 | if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) { | 1316 | if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) { |
1287 | kfree(chip); | 1317 | kfree(chip); |
1288 | pci_disable_device(pci); | 1318 | pci_disable_device(pci); |
@@ -1314,14 +1344,14 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r | |||
1314 | snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); | 1344 | snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); |
1315 | goto errout; | 1345 | goto errout; |
1316 | } | 1346 | } |
1317 | #ifdef USE_POSBUF | 1347 | if (chip->position_fix == POS_FIX_POSBUF) { |
1318 | /* allocate memory for the position buffer */ | 1348 | /* allocate memory for the position buffer */ |
1319 | if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), | 1349 | if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), |
1320 | MAX_ICH6_DEV * 8, &chip->posbuf)) < 0) { | 1350 | MAX_ICH6_DEV * 8, &chip->posbuf)) < 0) { |
1321 | snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); | 1351 | snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); |
1322 | goto errout; | 1352 | goto errout; |
1353 | } | ||
1323 | } | 1354 | } |
1324 | #endif | ||
1325 | /* allocate CORB/RIRB */ | 1355 | /* allocate CORB/RIRB */ |
1326 | if ((err = azx_alloc_cmd_io(chip)) < 0) | 1356 | if ((err = azx_alloc_cmd_io(chip)) < 0) |
1327 | goto errout; | 1357 | goto errout; |
@@ -1332,6 +1362,8 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r | |||
1332 | /* initialize chip */ | 1362 | /* initialize chip */ |
1333 | azx_init_chip(chip); | 1363 | azx_init_chip(chip); |
1334 | 1364 | ||
1365 | chip->initialized = 1; | ||
1366 | |||
1335 | /* codec detection */ | 1367 | /* codec detection */ |
1336 | if (! chip->codec_mask) { | 1368 | if (! chip->codec_mask) { |
1337 | snd_printk(KERN_ERR SFX "no codecs found!\n"); | 1369 | snd_printk(KERN_ERR SFX "no codecs found!\n"); |
@@ -1372,7 +1404,7 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id * | |||
1372 | return -ENOMEM; | 1404 | return -ENOMEM; |
1373 | } | 1405 | } |
1374 | 1406 | ||
1375 | if ((err = azx_create(card, pci, &chip)) < 0) { | 1407 | if ((err = azx_create(card, pci, position_fix[dev], &chip)) < 0) { |
1376 | snd_card_free(card); | 1408 | snd_card_free(card); |
1377 | return err; | 1409 | return err; |
1378 | } | 1410 | } |
@@ -1424,6 +1456,9 @@ static struct pci_device_id azx_ids[] = { | |||
1424 | { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */ | 1456 | { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */ |
1425 | { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */ | 1457 | { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */ |
1426 | { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */ | 1458 | { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */ |
1459 | { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ATI SB450 */ | ||
1460 | { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* VIA VT8251/VT8237A */ | ||
1461 | { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ALI 5461? */ | ||
1427 | { 0, } | 1462 | { 0, } |
1428 | }; | 1463 | }; |
1429 | MODULE_DEVICE_TABLE(pci, azx_ids); | 1464 | MODULE_DEVICE_TABLE(pci, azx_ids); |
@@ -1439,7 +1474,7 @@ static struct pci_driver driver = { | |||
1439 | 1474 | ||
1440 | static int __init alsa_card_azx_init(void) | 1475 | static int __init alsa_card_azx_init(void) |
1441 | { | 1476 | { |
1442 | return pci_module_init(&driver); | 1477 | return pci_register_driver(&driver); |
1443 | } | 1478 | } |
1444 | 1479 | ||
1445 | static void __exit alsa_card_azx_exit(void) | 1480 | static void __exit alsa_card_azx_exit(void) |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 7c7b849875a0..810cfd2d9bba 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -126,11 +126,11 @@ static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; } | |||
126 | struct hda_board_config { | 126 | struct hda_board_config { |
127 | const char *modelname; | 127 | const char *modelname; |
128 | int config; | 128 | int config; |
129 | unsigned short pci_vendor; | 129 | unsigned short pci_subvendor; |
130 | unsigned short pci_device; | 130 | unsigned short pci_subdevice; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | int snd_hda_check_board_config(struct hda_codec *codec, struct hda_board_config *tbl); | 133 | int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl); |
134 | int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew); | 134 | int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew); |
135 | 135 | ||
136 | /* | 136 | /* |
@@ -158,4 +158,35 @@ struct hda_bus_unsolicited { | |||
158 | struct work_struct work; | 158 | struct work_struct work; |
159 | }; | 159 | }; |
160 | 160 | ||
161 | /* | ||
162 | * Helper for automatic ping configuration | ||
163 | */ | ||
164 | |||
165 | enum { | ||
166 | AUTO_PIN_MIC, | ||
167 | AUTO_PIN_FRONT_MIC, | ||
168 | AUTO_PIN_LINE, | ||
169 | AUTO_PIN_FRONT_LINE, | ||
170 | AUTO_PIN_CD, | ||
171 | AUTO_PIN_AUX, | ||
172 | AUTO_PIN_LAST | ||
173 | }; | ||
174 | |||
175 | struct auto_pin_cfg { | ||
176 | int line_outs; | ||
177 | hda_nid_t line_out_pins[4]; /* sorted in the order of Front/Surr/CLFE/Side */ | ||
178 | hda_nid_t hp_pin; | ||
179 | hda_nid_t input_pins[AUTO_PIN_LAST]; | ||
180 | hda_nid_t dig_out_pin; | ||
181 | hda_nid_t dig_in_pin; | ||
182 | }; | ||
183 | |||
184 | #define get_defcfg_connect(cfg) ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) | ||
185 | #define get_defcfg_association(cfg) ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT) | ||
186 | #define get_defcfg_location(cfg) ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) | ||
187 | #define get_defcfg_sequence(cfg) (cfg & AC_DEFCFG_SEQUENCE) | ||
188 | #define get_defcfg_device(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) | ||
189 | |||
190 | int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg); | ||
191 | |||
161 | #endif /* __SOUND_HDA_LOCAL_H */ | 192 | #endif /* __SOUND_HDA_LOCAL_H */ |
diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h index cf6abce42bc9..a5de684b6944 100644 --- a/sound/pci/hda/hda_patch.h +++ b/sound/pci/hda/hda_patch.h | |||
@@ -8,10 +8,13 @@ extern struct hda_codec_preset snd_hda_preset_realtek[]; | |||
8 | extern struct hda_codec_preset snd_hda_preset_cmedia[]; | 8 | extern struct hda_codec_preset snd_hda_preset_cmedia[]; |
9 | /* Analog Devices codecs */ | 9 | /* Analog Devices codecs */ |
10 | extern struct hda_codec_preset snd_hda_preset_analog[]; | 10 | extern struct hda_codec_preset snd_hda_preset_analog[]; |
11 | /* SigmaTel codecs */ | ||
12 | extern struct hda_codec_preset snd_hda_preset_sigmatel[]; | ||
11 | 13 | ||
12 | static const struct hda_codec_preset *hda_preset_tables[] = { | 14 | static const struct hda_codec_preset *hda_preset_tables[] = { |
13 | snd_hda_preset_realtek, | 15 | snd_hda_preset_realtek, |
14 | snd_hda_preset_cmedia, | 16 | snd_hda_preset_cmedia, |
15 | snd_hda_preset_analog, | 17 | snd_hda_preset_analog, |
18 | snd_hda_preset_sigmatel, | ||
16 | NULL | 19 | NULL |
17 | }; | 20 | }; |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 4d5db7faad8d..de1217bd8e68 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
@@ -68,21 +68,27 @@ static void print_amp_caps(snd_info_buffer_t *buffer, | |||
68 | 68 | ||
69 | static void print_amp_vals(snd_info_buffer_t *buffer, | 69 | static void print_amp_vals(snd_info_buffer_t *buffer, |
70 | struct hda_codec *codec, hda_nid_t nid, | 70 | struct hda_codec *codec, hda_nid_t nid, |
71 | int dir, int stereo) | 71 | int dir, int stereo, int indices) |
72 | { | 72 | { |
73 | unsigned int val; | 73 | unsigned int val; |
74 | if (stereo) { | 74 | int i; |
75 | |||
76 | if (dir == HDA_OUTPUT) | ||
77 | dir = AC_AMP_GET_OUTPUT; | ||
78 | else | ||
79 | dir = AC_AMP_GET_INPUT; | ||
80 | for (i = 0; i < indices; i++) { | ||
81 | snd_iprintf(buffer, " ["); | ||
82 | if (stereo) { | ||
83 | val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, | ||
84 | AC_AMP_GET_LEFT | dir | i); | ||
85 | snd_iprintf(buffer, "0x%02x ", val); | ||
86 | } | ||
75 | val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, | 87 | val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, |
76 | AC_AMP_GET_LEFT | | 88 | AC_AMP_GET_RIGHT | dir | i); |
77 | (dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : | 89 | snd_iprintf(buffer, "0x%02x]", val); |
78 | AC_AMP_GET_INPUT)); | ||
79 | snd_iprintf(buffer, "0x%02x ", val); | ||
80 | } | 90 | } |
81 | val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, | 91 | snd_iprintf(buffer, "\n"); |
82 | AC_AMP_GET_RIGHT | | ||
83 | (dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : | ||
84 | AC_AMP_GET_INPUT)); | ||
85 | snd_iprintf(buffer, "0x%02x\n", val); | ||
86 | } | 92 | } |
87 | 93 | ||
88 | static void print_pcm_caps(snd_info_buffer_t *buffer, | 94 | static void print_pcm_caps(snd_info_buffer_t *buffer, |
@@ -157,6 +163,7 @@ static const char *get_jack_color(u32 cfg) | |||
157 | static void print_pin_caps(snd_info_buffer_t *buffer, | 163 | static void print_pin_caps(snd_info_buffer_t *buffer, |
158 | struct hda_codec *codec, hda_nid_t nid) | 164 | struct hda_codec *codec, hda_nid_t nid) |
159 | { | 165 | { |
166 | static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; | ||
160 | static char *jack_types[16] = { | 167 | static char *jack_types[16] = { |
161 | "Line Out", "Speaker", "HP Out", "CD", | 168 | "Line Out", "Speaker", "HP Out", "CD", |
162 | "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand", | 169 | "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand", |
@@ -176,7 +183,8 @@ static void print_pin_caps(snd_info_buffer_t *buffer, | |||
176 | snd_iprintf(buffer, " HP"); | 183 | snd_iprintf(buffer, " HP"); |
177 | snd_iprintf(buffer, "\n"); | 184 | snd_iprintf(buffer, "\n"); |
178 | caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 185 | caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); |
179 | snd_iprintf(buffer, " Pin Default 0x%08x: %s at %s %s\n", caps, | 186 | snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, |
187 | jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], | ||
180 | jack_types[(caps & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT], | 188 | jack_types[(caps & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT], |
181 | jack_locations[(caps >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3], | 189 | jack_locations[(caps >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3], |
182 | get_jack_location(caps)); | 190 | get_jack_location(caps)); |
@@ -215,6 +223,9 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer) | |||
215 | unsigned int wid_caps = snd_hda_param_read(codec, nid, | 223 | unsigned int wid_caps = snd_hda_param_read(codec, nid, |
216 | AC_PAR_AUDIO_WIDGET_CAP); | 224 | AC_PAR_AUDIO_WIDGET_CAP); |
217 | unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 225 | unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
226 | int conn_len = 0; | ||
227 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; | ||
228 | |||
218 | snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, | 229 | snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, |
219 | get_wid_type_name(wid_type), wid_caps); | 230 | get_wid_type_name(wid_type), wid_caps); |
220 | if (wid_caps & AC_WCAP_STEREO) | 231 | if (wid_caps & AC_WCAP_STEREO) |
@@ -229,19 +240,23 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer) | |||
229 | snd_iprintf(buffer, " Amp-Out"); | 240 | snd_iprintf(buffer, " Amp-Out"); |
230 | snd_iprintf(buffer, "\n"); | 241 | snd_iprintf(buffer, "\n"); |
231 | 242 | ||
243 | if (wid_caps & AC_WCAP_CONN_LIST) | ||
244 | conn_len = snd_hda_get_connections(codec, nid, conn, | ||
245 | HDA_MAX_CONNECTIONS); | ||
246 | |||
232 | if (wid_caps & AC_WCAP_IN_AMP) { | 247 | if (wid_caps & AC_WCAP_IN_AMP) { |
233 | snd_iprintf(buffer, " Amp-In caps: "); | 248 | snd_iprintf(buffer, " Amp-In caps: "); |
234 | print_amp_caps(buffer, codec, nid, HDA_INPUT); | 249 | print_amp_caps(buffer, codec, nid, HDA_INPUT); |
235 | snd_iprintf(buffer, " Amp-In vals: "); | 250 | snd_iprintf(buffer, " Amp-In vals: "); |
236 | print_amp_vals(buffer, codec, nid, HDA_INPUT, | 251 | print_amp_vals(buffer, codec, nid, HDA_INPUT, |
237 | wid_caps & AC_WCAP_STEREO); | 252 | wid_caps & AC_WCAP_STEREO, conn_len); |
238 | } | 253 | } |
239 | if (wid_caps & AC_WCAP_OUT_AMP) { | 254 | if (wid_caps & AC_WCAP_OUT_AMP) { |
240 | snd_iprintf(buffer, " Amp-Out caps: "); | 255 | snd_iprintf(buffer, " Amp-Out caps: "); |
241 | print_amp_caps(buffer, codec, nid, HDA_OUTPUT); | 256 | print_amp_caps(buffer, codec, nid, HDA_OUTPUT); |
242 | snd_iprintf(buffer, " Amp-Out vals: "); | 257 | snd_iprintf(buffer, " Amp-Out vals: "); |
243 | print_amp_vals(buffer, codec, nid, HDA_OUTPUT, | 258 | print_amp_vals(buffer, codec, nid, HDA_OUTPUT, |
244 | wid_caps & AC_WCAP_STEREO); | 259 | wid_caps & AC_WCAP_STEREO, 1); |
245 | } | 260 | } |
246 | 261 | ||
247 | if (wid_type == AC_WID_PIN) { | 262 | if (wid_type == AC_WID_PIN) { |
@@ -265,14 +280,17 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer) | |||
265 | } | 280 | } |
266 | 281 | ||
267 | if (wid_caps & AC_WCAP_CONN_LIST) { | 282 | if (wid_caps & AC_WCAP_CONN_LIST) { |
268 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; | 283 | int c, curr = -1; |
269 | int c, conn_len; | 284 | if (conn_len > 1 && wid_type != AC_WID_AUD_MIX) |
270 | conn_len = snd_hda_get_connections(codec, nid, conn, | 285 | curr = snd_hda_codec_read(codec, nid, 0, |
271 | HDA_MAX_CONNECTIONS); | 286 | AC_VERB_GET_CONNECT_SEL, 0); |
272 | snd_iprintf(buffer, " Connection: %d\n", conn_len); | 287 | snd_iprintf(buffer, " Connection: %d\n", conn_len); |
273 | snd_iprintf(buffer, " "); | 288 | snd_iprintf(buffer, " "); |
274 | for (c = 0; c < conn_len; c++) | 289 | for (c = 0; c < conn_len; c++) { |
275 | snd_iprintf(buffer, " 0x%02x", conn[c]); | 290 | snd_iprintf(buffer, " 0x%02x", conn[c]); |
291 | if (c == curr) | ||
292 | snd_iprintf(buffer, "*"); | ||
293 | } | ||
276 | snd_iprintf(buffer, "\n"); | 294 | snd_iprintf(buffer, "\n"); |
277 | } | 295 | } |
278 | } | 296 | } |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 75d23849f71a..2fd05bb84136 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * HD audio interface patch for AD1986A | 2 | * HD audio interface patch for AD1981HD, AD1983, AD1986A |
3 | * | 3 | * |
4 | * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de> | 4 | * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de> |
5 | * | 5 | * |
@@ -27,13 +27,239 @@ | |||
27 | #include "hda_codec.h" | 27 | #include "hda_codec.h" |
28 | #include "hda_local.h" | 28 | #include "hda_local.h" |
29 | 29 | ||
30 | struct ad1986a_spec { | 30 | struct ad198x_spec { |
31 | struct semaphore amp_mutex; /* PCM volume/mute control mutex */ | 31 | struct semaphore amp_mutex; /* PCM volume/mute control mutex */ |
32 | struct hda_multi_out multiout; /* playback */ | 32 | struct hda_multi_out multiout; /* playback */ |
33 | hda_nid_t adc_nid; | ||
34 | const struct hda_input_mux *input_mux; | ||
33 | unsigned int cur_mux; /* capture source */ | 35 | unsigned int cur_mux; /* capture source */ |
36 | unsigned int spdif_route; | ||
37 | snd_kcontrol_new_t *mixers; | ||
38 | const struct hda_verb *init_verbs; | ||
34 | struct hda_pcm pcm_rec[2]; /* PCM information */ | 39 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
35 | }; | 40 | }; |
36 | 41 | ||
42 | /* | ||
43 | * input MUX handling (common part) | ||
44 | */ | ||
45 | static int ad198x_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
46 | { | ||
47 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
48 | struct ad198x_spec *spec = codec->spec; | ||
49 | |||
50 | return snd_hda_input_mux_info(spec->input_mux, uinfo); | ||
51 | } | ||
52 | |||
53 | static int ad198x_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
54 | { | ||
55 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
56 | struct ad198x_spec *spec = codec->spec; | ||
57 | |||
58 | ucontrol->value.enumerated.item[0] = spec->cur_mux; | ||
59 | return 0; | ||
60 | } | ||
61 | |||
62 | static int ad198x_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
63 | { | ||
64 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
65 | struct ad198x_spec *spec = codec->spec; | ||
66 | |||
67 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | ||
68 | spec->adc_nid, &spec->cur_mux); | ||
69 | } | ||
70 | |||
71 | /* | ||
72 | * initialization (common callbacks) | ||
73 | */ | ||
74 | static int ad198x_init(struct hda_codec *codec) | ||
75 | { | ||
76 | struct ad198x_spec *spec = codec->spec; | ||
77 | snd_hda_sequence_write(codec, spec->init_verbs); | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static int ad198x_build_controls(struct hda_codec *codec) | ||
82 | { | ||
83 | struct ad198x_spec *spec = codec->spec; | ||
84 | int err; | ||
85 | |||
86 | err = snd_hda_add_new_ctls(codec, spec->mixers); | ||
87 | if (err < 0) | ||
88 | return err; | ||
89 | if (spec->multiout.dig_out_nid) | ||
90 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | ||
91 | if (err < 0) | ||
92 | return err; | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * Analog playback callbacks | ||
98 | */ | ||
99 | static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
100 | struct hda_codec *codec, | ||
101 | snd_pcm_substream_t *substream) | ||
102 | { | ||
103 | struct ad198x_spec *spec = codec->spec; | ||
104 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | ||
105 | } | ||
106 | |||
107 | static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
108 | struct hda_codec *codec, | ||
109 | unsigned int stream_tag, | ||
110 | unsigned int format, | ||
111 | snd_pcm_substream_t *substream) | ||
112 | { | ||
113 | struct ad198x_spec *spec = codec->spec; | ||
114 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, | ||
115 | format, substream); | ||
116 | } | ||
117 | |||
118 | static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
119 | struct hda_codec *codec, | ||
120 | snd_pcm_substream_t *substream) | ||
121 | { | ||
122 | struct ad198x_spec *spec = codec->spec; | ||
123 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | ||
124 | } | ||
125 | |||
126 | /* | ||
127 | * Digital out | ||
128 | */ | ||
129 | static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
130 | struct hda_codec *codec, | ||
131 | snd_pcm_substream_t *substream) | ||
132 | { | ||
133 | struct ad198x_spec *spec = codec->spec; | ||
134 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | ||
135 | } | ||
136 | |||
137 | static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | ||
138 | struct hda_codec *codec, | ||
139 | snd_pcm_substream_t *substream) | ||
140 | { | ||
141 | struct ad198x_spec *spec = codec->spec; | ||
142 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | * Analog capture | ||
147 | */ | ||
148 | static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
149 | struct hda_codec *codec, | ||
150 | unsigned int stream_tag, | ||
151 | unsigned int format, | ||
152 | snd_pcm_substream_t *substream) | ||
153 | { | ||
154 | struct ad198x_spec *spec = codec->spec; | ||
155 | snd_hda_codec_setup_stream(codec, spec->adc_nid, stream_tag, 0, format); | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
160 | struct hda_codec *codec, | ||
161 | snd_pcm_substream_t *substream) | ||
162 | { | ||
163 | struct ad198x_spec *spec = codec->spec; | ||
164 | snd_hda_codec_setup_stream(codec, spec->adc_nid, 0, 0, 0); | ||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | |||
169 | /* | ||
170 | */ | ||
171 | static struct hda_pcm_stream ad198x_pcm_analog_playback = { | ||
172 | .substreams = 1, | ||
173 | .channels_min = 2, | ||
174 | .channels_max = 6, | ||
175 | .nid = 0, /* fill later */ | ||
176 | .ops = { | ||
177 | .open = ad198x_playback_pcm_open, | ||
178 | .prepare = ad198x_playback_pcm_prepare, | ||
179 | .cleanup = ad198x_playback_pcm_cleanup | ||
180 | }, | ||
181 | }; | ||
182 | |||
183 | static struct hda_pcm_stream ad198x_pcm_analog_capture = { | ||
184 | .substreams = 2, | ||
185 | .channels_min = 2, | ||
186 | .channels_max = 2, | ||
187 | .nid = 0, /* fill later */ | ||
188 | .ops = { | ||
189 | .prepare = ad198x_capture_pcm_prepare, | ||
190 | .cleanup = ad198x_capture_pcm_cleanup | ||
191 | }, | ||
192 | }; | ||
193 | |||
194 | static struct hda_pcm_stream ad198x_pcm_digital_playback = { | ||
195 | .substreams = 1, | ||
196 | .channels_min = 2, | ||
197 | .channels_max = 2, | ||
198 | .nid = 0, /* fill later */ | ||
199 | .ops = { | ||
200 | .open = ad198x_dig_playback_pcm_open, | ||
201 | .close = ad198x_dig_playback_pcm_close | ||
202 | }, | ||
203 | }; | ||
204 | |||
205 | static int ad198x_build_pcms(struct hda_codec *codec) | ||
206 | { | ||
207 | struct ad198x_spec *spec = codec->spec; | ||
208 | struct hda_pcm *info = spec->pcm_rec; | ||
209 | |||
210 | codec->num_pcms = 1; | ||
211 | codec->pcm_info = info; | ||
212 | |||
213 | info->name = "AD198x Analog"; | ||
214 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback; | ||
215 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels; | ||
216 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | ||
217 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture; | ||
218 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nid; | ||
219 | |||
220 | if (spec->multiout.dig_out_nid) { | ||
221 | info++; | ||
222 | codec->num_pcms++; | ||
223 | info->name = "AD198x Digital"; | ||
224 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; | ||
225 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | ||
226 | } | ||
227 | |||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static void ad198x_free(struct hda_codec *codec) | ||
232 | { | ||
233 | kfree(codec->spec); | ||
234 | } | ||
235 | |||
236 | #ifdef CONFIG_PM | ||
237 | static int ad198x_resume(struct hda_codec *codec) | ||
238 | { | ||
239 | struct ad198x_spec *spec = codec->spec; | ||
240 | |||
241 | ad198x_init(codec); | ||
242 | snd_hda_resume_ctls(codec, spec->mixers); | ||
243 | snd_hda_resume_spdif_out(codec); | ||
244 | return 0; | ||
245 | } | ||
246 | #endif | ||
247 | |||
248 | static struct hda_codec_ops ad198x_patch_ops = { | ||
249 | .build_controls = ad198x_build_controls, | ||
250 | .build_pcms = ad198x_build_pcms, | ||
251 | .init = ad198x_init, | ||
252 | .free = ad198x_free, | ||
253 | #ifdef CONFIG_PM | ||
254 | .resume = ad198x_resume, | ||
255 | #endif | ||
256 | }; | ||
257 | |||
258 | |||
259 | /* | ||
260 | * AD1986A specific | ||
261 | */ | ||
262 | |||
37 | #define AD1986A_SPDIF_OUT 0x02 | 263 | #define AD1986A_SPDIF_OUT 0x02 |
38 | #define AD1986A_FRONT_DAC 0x03 | 264 | #define AD1986A_FRONT_DAC 0x03 |
39 | #define AD1986A_SURR_DAC 0x04 | 265 | #define AD1986A_SURR_DAC 0x04 |
@@ -68,7 +294,7 @@ static struct hda_input_mux ad1986a_capture_source = { | |||
68 | static int ad1986a_pcm_amp_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | 294 | static int ad1986a_pcm_amp_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
69 | { | 295 | { |
70 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 296 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
71 | struct ad1986a_spec *ad = codec->spec; | 297 | struct ad198x_spec *ad = codec->spec; |
72 | 298 | ||
73 | down(&ad->amp_mutex); | 299 | down(&ad->amp_mutex); |
74 | snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); | 300 | snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
@@ -79,7 +305,7 @@ static int ad1986a_pcm_amp_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ | |||
79 | static int ad1986a_pcm_amp_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | 305 | static int ad1986a_pcm_amp_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
80 | { | 306 | { |
81 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 307 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
82 | struct ad1986a_spec *ad = codec->spec; | 308 | struct ad198x_spec *ad = codec->spec; |
83 | int i, change = 0; | 309 | int i, change = 0; |
84 | 310 | ||
85 | down(&ad->amp_mutex); | 311 | down(&ad->amp_mutex); |
@@ -92,12 +318,12 @@ static int ad1986a_pcm_amp_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ | |||
92 | return change; | 318 | return change; |
93 | } | 319 | } |
94 | 320 | ||
95 | #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_volume_info | 321 | #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info |
96 | 322 | ||
97 | static int ad1986a_pcm_amp_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | 323 | static int ad1986a_pcm_amp_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
98 | { | 324 | { |
99 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 325 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
100 | struct ad1986a_spec *ad = codec->spec; | 326 | struct ad198x_spec *ad = codec->spec; |
101 | 327 | ||
102 | down(&ad->amp_mutex); | 328 | down(&ad->amp_mutex); |
103 | snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); | 329 | snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); |
@@ -108,7 +334,7 @@ static int ad1986a_pcm_amp_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
108 | static int ad1986a_pcm_amp_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | 334 | static int ad1986a_pcm_amp_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
109 | { | 335 | { |
110 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 336 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
111 | struct ad1986a_spec *ad = codec->spec; | 337 | struct ad198x_spec *ad = codec->spec; |
112 | int i, change = 0; | 338 | int i, change = 0; |
113 | 339 | ||
114 | down(&ad->amp_mutex); | 340 | down(&ad->amp_mutex); |
@@ -122,32 +348,6 @@ static int ad1986a_pcm_amp_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
122 | } | 348 | } |
123 | 349 | ||
124 | /* | 350 | /* |
125 | * input MUX handling | ||
126 | */ | ||
127 | static int ad1986a_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
128 | { | ||
129 | return snd_hda_input_mux_info(&ad1986a_capture_source, uinfo); | ||
130 | } | ||
131 | |||
132 | static int ad1986a_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
133 | { | ||
134 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
135 | struct ad1986a_spec *spec = codec->spec; | ||
136 | |||
137 | ucontrol->value.enumerated.item[0] = spec->cur_mux; | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static int ad1986a_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
142 | { | ||
143 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
144 | struct ad1986a_spec *spec = codec->spec; | ||
145 | |||
146 | return snd_hda_input_mux_put(codec, &ad1986a_capture_source, ucontrol, | ||
147 | AD1986A_ADC, &spec->cur_mux); | ||
148 | } | ||
149 | |||
150 | /* | ||
151 | * mixers | 351 | * mixers |
152 | */ | 352 | */ |
153 | static snd_kcontrol_new_t ad1986a_mixers[] = { | 353 | static snd_kcontrol_new_t ad1986a_mixers[] = { |
@@ -194,9 +394,9 @@ static snd_kcontrol_new_t ad1986a_mixers[] = { | |||
194 | { | 394 | { |
195 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 395 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
196 | .name = "Capture Source", | 396 | .name = "Capture Source", |
197 | .info = ad1986a_mux_enum_info, | 397 | .info = ad198x_mux_enum_info, |
198 | .get = ad1986a_mux_enum_get, | 398 | .get = ad198x_mux_enum_get, |
199 | .put = ad1986a_mux_enum_put, | 399 | .put = ad198x_mux_enum_put, |
200 | }, | 400 | }, |
201 | HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), | 401 | HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), |
202 | { } /* end */ | 402 | { } /* end */ |
@@ -241,183 +441,328 @@ static struct hda_verb ad1986a_init_verbs[] = { | |||
241 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 441 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
242 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 442 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
243 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 443 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
444 | /* HP Pin */ | ||
445 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | ||
446 | /* Front, Surround, CLFE Pins */ | ||
447 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
448 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
449 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
450 | /* Mono Pin */ | ||
451 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
452 | /* Mic Pin */ | ||
453 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | ||
454 | /* Line, Aux, CD, Beep-In Pin */ | ||
455 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
456 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
457 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
458 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
459 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
244 | { } /* end */ | 460 | { } /* end */ |
245 | }; | 461 | }; |
246 | 462 | ||
247 | 463 | ||
248 | static int ad1986a_init(struct hda_codec *codec) | 464 | static int patch_ad1986a(struct hda_codec *codec) |
249 | { | 465 | { |
250 | snd_hda_sequence_write(codec, ad1986a_init_verbs); | 466 | struct ad198x_spec *spec; |
251 | return 0; | ||
252 | } | ||
253 | 467 | ||
254 | static int ad1986a_build_controls(struct hda_codec *codec) | 468 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
255 | { | 469 | if (spec == NULL) |
256 | int err; | 470 | return -ENOMEM; |
471 | |||
472 | init_MUTEX(&spec->amp_mutex); | ||
473 | codec->spec = spec; | ||
474 | |||
475 | spec->multiout.max_channels = 6; | ||
476 | spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); | ||
477 | spec->multiout.dac_nids = ad1986a_dac_nids; | ||
478 | spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; | ||
479 | spec->adc_nid = AD1986A_ADC; | ||
480 | spec->input_mux = &ad1986a_capture_source; | ||
481 | spec->mixers = ad1986a_mixers; | ||
482 | spec->init_verbs = ad1986a_init_verbs; | ||
483 | |||
484 | codec->patch_ops = ad198x_patch_ops; | ||
257 | 485 | ||
258 | err = snd_hda_add_new_ctls(codec, ad1986a_mixers); | ||
259 | if (err < 0) | ||
260 | return err; | ||
261 | err = snd_hda_create_spdif_out_ctls(codec, AD1986A_SPDIF_OUT); | ||
262 | if (err < 0) | ||
263 | return err; | ||
264 | return 0; | 486 | return 0; |
265 | } | 487 | } |
266 | 488 | ||
267 | /* | 489 | /* |
268 | * Analog playback callbacks | 490 | * AD1983 specific |
269 | */ | 491 | */ |
270 | static int ad1986a_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
271 | struct hda_codec *codec, | ||
272 | snd_pcm_substream_t *substream) | ||
273 | { | ||
274 | struct ad1986a_spec *spec = codec->spec; | ||
275 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | ||
276 | } | ||
277 | 492 | ||
278 | static int ad1986a_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 493 | #define AD1983_SPDIF_OUT 0x02 |
279 | struct hda_codec *codec, | 494 | #define AD1983_DAC 0x03 |
280 | unsigned int stream_tag, | 495 | #define AD1983_ADC 0x04 |
281 | unsigned int format, | ||
282 | snd_pcm_substream_t *substream) | ||
283 | { | ||
284 | struct ad1986a_spec *spec = codec->spec; | ||
285 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, | ||
286 | format, substream); | ||
287 | } | ||
288 | 496 | ||
289 | static int ad1986a_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | 497 | static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC }; |
290 | struct hda_codec *codec, | 498 | |
291 | snd_pcm_substream_t *substream) | 499 | static struct hda_input_mux ad1983_capture_source = { |
292 | { | 500 | .num_items = 4, |
293 | struct ad1986a_spec *spec = codec->spec; | 501 | .items = { |
294 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | 502 | { "Mic", 0x0 }, |
295 | } | 503 | { "Line", 0x1 }, |
504 | { "Mix", 0x2 }, | ||
505 | { "Mix Mono", 0x3 }, | ||
506 | }, | ||
507 | }; | ||
296 | 508 | ||
297 | /* | 509 | /* |
298 | * Digital out | 510 | * SPDIF playback route |
299 | */ | 511 | */ |
300 | static int ad1986a_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | 512 | static int ad1983_spdif_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) |
301 | struct hda_codec *codec, | ||
302 | snd_pcm_substream_t *substream) | ||
303 | { | 513 | { |
304 | struct ad1986a_spec *spec = codec->spec; | 514 | static char *texts[] = { "PCM", "ADC" }; |
305 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | 515 | |
516 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
517 | uinfo->count = 1; | ||
518 | uinfo->value.enumerated.items = 2; | ||
519 | if (uinfo->value.enumerated.item > 1) | ||
520 | uinfo->value.enumerated.item = 1; | ||
521 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
522 | return 0; | ||
306 | } | 523 | } |
307 | 524 | ||
308 | static int ad1986a_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | 525 | static int ad1983_spdif_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
309 | struct hda_codec *codec, | ||
310 | snd_pcm_substream_t *substream) | ||
311 | { | 526 | { |
312 | struct ad1986a_spec *spec = codec->spec; | 527 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
313 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | 528 | struct ad198x_spec *spec = codec->spec; |
314 | } | ||
315 | 529 | ||
316 | /* | 530 | ucontrol->value.enumerated.item[0] = spec->spdif_route; |
317 | * Analog capture | ||
318 | */ | ||
319 | static int ad1986a_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
320 | struct hda_codec *codec, | ||
321 | unsigned int stream_tag, | ||
322 | unsigned int format, | ||
323 | snd_pcm_substream_t *substream) | ||
324 | { | ||
325 | snd_hda_codec_setup_stream(codec, AD1986A_ADC, stream_tag, 0, format); | ||
326 | return 0; | 531 | return 0; |
327 | } | 532 | } |
328 | 533 | ||
329 | static int ad1986a_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | 534 | static int ad1983_spdif_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
330 | struct hda_codec *codec, | ||
331 | snd_pcm_substream_t *substream) | ||
332 | { | 535 | { |
333 | snd_hda_codec_setup_stream(codec, AD1986A_ADC, 0, 0, 0); | 536 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
537 | struct ad198x_spec *spec = codec->spec; | ||
538 | |||
539 | if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { | ||
540 | spec->spdif_route = ucontrol->value.enumerated.item[0]; | ||
541 | snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0, | ||
542 | AC_VERB_SET_CONNECT_SEL, spec->spdif_route); | ||
543 | return 1; | ||
544 | } | ||
334 | return 0; | 545 | return 0; |
335 | } | 546 | } |
336 | 547 | ||
337 | 548 | static snd_kcontrol_new_t ad1983_mixers[] = { | |
338 | /* | 549 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), |
339 | */ | 550 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), |
340 | static struct hda_pcm_stream ad1986a_pcm_analog_playback = { | 551 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), |
341 | .substreams = 1, | 552 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), |
342 | .channels_min = 2, | 553 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), |
343 | .channels_max = 6, | 554 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), |
344 | .nid = AD1986A_FRONT_DAC, /* NID to query formats and rates */ | 555 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), |
345 | .ops = { | 556 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), |
346 | .open = ad1986a_playback_pcm_open, | 557 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), |
347 | .prepare = ad1986a_playback_pcm_prepare, | 558 | HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
348 | .cleanup = ad1986a_playback_pcm_cleanup | 559 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
560 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), | ||
561 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT), | ||
562 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT), | ||
563 | HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT), | ||
564 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), | ||
565 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), | ||
566 | { | ||
567 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
568 | .name = "Capture Source", | ||
569 | .info = ad198x_mux_enum_info, | ||
570 | .get = ad198x_mux_enum_get, | ||
571 | .put = ad198x_mux_enum_put, | ||
349 | }, | 572 | }, |
350 | }; | 573 | { |
351 | 574 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
352 | static struct hda_pcm_stream ad1986a_pcm_analog_capture = { | 575 | .name = "IEC958 Playback Route", |
353 | .substreams = 2, | 576 | .info = ad1983_spdif_route_info, |
354 | .channels_min = 2, | 577 | .get = ad1983_spdif_route_get, |
355 | .channels_max = 2, | 578 | .put = ad1983_spdif_route_put, |
356 | .nid = AD1986A_ADC, /* NID to query formats and rates */ | ||
357 | .ops = { | ||
358 | .prepare = ad1986a_capture_pcm_prepare, | ||
359 | .cleanup = ad1986a_capture_pcm_cleanup | ||
360 | }, | 579 | }, |
580 | { } /* end */ | ||
361 | }; | 581 | }; |
362 | 582 | ||
363 | static struct hda_pcm_stream ad1986a_pcm_digital_playback = { | 583 | static struct hda_verb ad1983_init_verbs[] = { |
364 | .substreams = 1, | 584 | /* Front, HP, Mono; mute as default */ |
365 | .channels_min = 2, | 585 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
366 | .channels_max = 2, | 586 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
367 | .nid = AD1986A_SPDIF_OUT, | 587 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
368 | .ops = { | 588 | /* Beep, PCM, Mic, Line-In: mute */ |
369 | .open = ad1986a_dig_playback_pcm_open, | 589 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
370 | .close = ad1986a_dig_playback_pcm_close | 590 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
371 | }, | 591 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, |
592 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
593 | /* Front, HP selectors; from Mix */ | ||
594 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
595 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
596 | /* Mono selector; from Mix */ | ||
597 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
598 | /* Mic selector; Mic */ | ||
599 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
600 | /* Line-in selector: Line-in */ | ||
601 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
602 | /* Mic boost: 0dB */ | ||
603 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
604 | /* Record selector: mic */ | ||
605 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
606 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
607 | /* SPDIF route: PCM */ | ||
608 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
609 | /* Front Pin */ | ||
610 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
611 | /* HP Pin */ | ||
612 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | ||
613 | /* Mono Pin */ | ||
614 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
615 | /* Mic Pin */ | ||
616 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | ||
617 | /* Line Pin */ | ||
618 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
619 | { } /* end */ | ||
372 | }; | 620 | }; |
373 | 621 | ||
374 | static int ad1986a_build_pcms(struct hda_codec *codec) | 622 | static int patch_ad1983(struct hda_codec *codec) |
375 | { | 623 | { |
376 | struct ad1986a_spec *spec = codec->spec; | 624 | struct ad198x_spec *spec; |
377 | struct hda_pcm *info = spec->pcm_rec; | ||
378 | 625 | ||
379 | codec->num_pcms = 2; | 626 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
380 | codec->pcm_info = info; | 627 | if (spec == NULL) |
628 | return -ENOMEM; | ||
381 | 629 | ||
382 | info->name = "AD1986A Analog"; | 630 | init_MUTEX(&spec->amp_mutex); |
383 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad1986a_pcm_analog_playback; | 631 | codec->spec = spec; |
384 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1986a_pcm_analog_capture; | 632 | |
385 | info++; | 633 | spec->multiout.max_channels = 2; |
634 | spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids); | ||
635 | spec->multiout.dac_nids = ad1983_dac_nids; | ||
636 | spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; | ||
637 | spec->adc_nid = AD1983_ADC; | ||
638 | spec->input_mux = &ad1983_capture_source; | ||
639 | spec->mixers = ad1983_mixers; | ||
640 | spec->init_verbs = ad1983_init_verbs; | ||
641 | spec->spdif_route = 0; | ||
386 | 642 | ||
387 | info->name = "AD1986A Digital"; | 643 | codec->patch_ops = ad198x_patch_ops; |
388 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad1986a_pcm_digital_playback; | ||
389 | 644 | ||
390 | return 0; | 645 | return 0; |
391 | } | 646 | } |
392 | 647 | ||
393 | static void ad1986a_free(struct hda_codec *codec) | ||
394 | { | ||
395 | kfree(codec->spec); | ||
396 | } | ||
397 | 648 | ||
398 | #ifdef CONFIG_PM | 649 | /* |
399 | static int ad1986a_resume(struct hda_codec *codec) | 650 | * AD1981 HD specific |
400 | { | 651 | */ |
401 | ad1986a_init(codec); | ||
402 | snd_hda_resume_ctls(codec, ad1986a_mixers); | ||
403 | snd_hda_resume_spdif_out(codec); | ||
404 | return 0; | ||
405 | } | ||
406 | #endif | ||
407 | 652 | ||
408 | static struct hda_codec_ops ad1986a_patch_ops = { | 653 | #define AD1981_SPDIF_OUT 0x02 |
409 | .build_controls = ad1986a_build_controls, | 654 | #define AD1981_DAC 0x03 |
410 | .build_pcms = ad1986a_build_pcms, | 655 | #define AD1981_ADC 0x04 |
411 | .init = ad1986a_init, | 656 | |
412 | .free = ad1986a_free, | 657 | static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC }; |
413 | #ifdef CONFIG_PM | 658 | |
414 | .resume = ad1986a_resume, | 659 | /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */ |
415 | #endif | 660 | static struct hda_input_mux ad1981_capture_source = { |
661 | .num_items = 7, | ||
662 | .items = { | ||
663 | { "Front Mic", 0x0 }, | ||
664 | { "Line", 0x1 }, | ||
665 | { "Mix", 0x2 }, | ||
666 | { "Mix Mono", 0x3 }, | ||
667 | { "CD", 0x4 }, | ||
668 | { "Mic", 0x6 }, | ||
669 | { "Aux", 0x7 }, | ||
670 | }, | ||
416 | }; | 671 | }; |
417 | 672 | ||
418 | static int patch_ad1986a(struct hda_codec *codec) | 673 | static snd_kcontrol_new_t ad1981_mixers[] = { |
674 | HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), | ||
675 | HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), | ||
676 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), | ||
677 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), | ||
678 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), | ||
679 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), | ||
680 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), | ||
681 | HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), | ||
682 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), | ||
683 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), | ||
684 | HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), | ||
685 | HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), | ||
686 | HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT), | ||
687 | HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
688 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), | ||
689 | HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), | ||
690 | HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), | ||
691 | HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), | ||
692 | HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | ||
693 | HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT), | ||
694 | HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT), | ||
695 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT), | ||
696 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), | ||
697 | HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), | ||
698 | { | ||
699 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
700 | .name = "Capture Source", | ||
701 | .info = ad198x_mux_enum_info, | ||
702 | .get = ad198x_mux_enum_get, | ||
703 | .put = ad198x_mux_enum_put, | ||
704 | }, | ||
705 | /* identical with AD1983 */ | ||
706 | { | ||
707 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
708 | .name = "IEC958 Playback Route", | ||
709 | .info = ad1983_spdif_route_info, | ||
710 | .get = ad1983_spdif_route_get, | ||
711 | .put = ad1983_spdif_route_put, | ||
712 | }, | ||
713 | { } /* end */ | ||
714 | }; | ||
715 | |||
716 | static struct hda_verb ad1981_init_verbs[] = { | ||
717 | /* Front, HP, Mono; mute as default */ | ||
718 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
719 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
720 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
721 | /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */ | ||
722 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
723 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
724 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
725 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
726 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
727 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
728 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
729 | /* Front, HP selectors; from Mix */ | ||
730 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
731 | {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
732 | /* Mono selector; from Mix */ | ||
733 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
734 | /* Mic Mixer; select Front Mic */ | ||
735 | {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
736 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
737 | /* Mic boost: 0dB */ | ||
738 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
739 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
740 | /* Record selector: Front mic */ | ||
741 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
742 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
743 | /* SPDIF route: PCM */ | ||
744 | {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
745 | /* Front Pin */ | ||
746 | {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
747 | /* HP Pin */ | ||
748 | {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | ||
749 | /* Mono Pin */ | ||
750 | {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
751 | /* Front & Rear Mic Pins */ | ||
752 | {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | ||
753 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | ||
754 | /* Line Pin */ | ||
755 | {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
756 | /* Digital Beep */ | ||
757 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
758 | /* Line-Out as Input: disabled */ | ||
759 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | ||
760 | { } /* end */ | ||
761 | }; | ||
762 | |||
763 | static int patch_ad1981(struct hda_codec *codec) | ||
419 | { | 764 | { |
420 | struct ad1986a_spec *spec; | 765 | struct ad198x_spec *spec; |
421 | 766 | ||
422 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | 767 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
423 | if (spec == NULL) | 768 | if (spec == NULL) |
@@ -426,20 +771,28 @@ static int patch_ad1986a(struct hda_codec *codec) | |||
426 | init_MUTEX(&spec->amp_mutex); | 771 | init_MUTEX(&spec->amp_mutex); |
427 | codec->spec = spec; | 772 | codec->spec = spec; |
428 | 773 | ||
429 | spec->multiout.max_channels = 6; | 774 | spec->multiout.max_channels = 2; |
430 | spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); | 775 | spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids); |
431 | spec->multiout.dac_nids = ad1986a_dac_nids; | 776 | spec->multiout.dac_nids = ad1981_dac_nids; |
432 | spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; | 777 | spec->multiout.dig_out_nid = AD1981_SPDIF_OUT; |
778 | spec->adc_nid = AD1981_ADC; | ||
779 | spec->input_mux = &ad1981_capture_source; | ||
780 | spec->mixers = ad1981_mixers; | ||
781 | spec->init_verbs = ad1981_init_verbs; | ||
782 | spec->spdif_route = 0; | ||
433 | 783 | ||
434 | codec->patch_ops = ad1986a_patch_ops; | 784 | codec->patch_ops = ad198x_patch_ops; |
435 | 785 | ||
436 | return 0; | 786 | return 0; |
437 | } | 787 | } |
438 | 788 | ||
789 | |||
439 | /* | 790 | /* |
440 | * patch entries | 791 | * patch entries |
441 | */ | 792 | */ |
442 | struct hda_codec_preset snd_hda_preset_analog[] = { | 793 | struct hda_codec_preset snd_hda_preset_analog[] = { |
794 | { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, | ||
795 | { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, | ||
443 | { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, | 796 | { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, |
444 | {} /* terminator */ | 797 | {} /* terminator */ |
445 | }; | 798 | }; |
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index b7cc8e4bffb7..2d6e3e3d0a38 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <sound/core.h> | 29 | #include <sound/core.h> |
30 | #include "hda_codec.h" | 30 | #include "hda_codec.h" |
31 | #include "hda_local.h" | 31 | #include "hda_local.h" |
32 | #define NUM_PINS 11 | ||
32 | 33 | ||
33 | 34 | ||
34 | /* board config type */ | 35 | /* board config type */ |
@@ -38,6 +39,7 @@ enum { | |||
38 | CMI_FULL, /* back 6-jack + front-panel 2-jack */ | 39 | CMI_FULL, /* back 6-jack + front-panel 2-jack */ |
39 | CMI_FULL_DIG, /* back 6-jack + front-panel 2-jack + digital I/O */ | 40 | CMI_FULL_DIG, /* back 6-jack + front-panel 2-jack + digital I/O */ |
40 | CMI_ALLOUT, /* back 5-jack + front-panel 2-jack + digital out */ | 41 | CMI_ALLOUT, /* back 5-jack + front-panel 2-jack + digital out */ |
42 | CMI_AUTO, /* let driver guess it */ | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | struct cmi_spec { | 45 | struct cmi_spec { |
@@ -48,6 +50,8 @@ struct cmi_spec { | |||
48 | 50 | ||
49 | /* playback */ | 51 | /* playback */ |
50 | struct hda_multi_out multiout; | 52 | struct hda_multi_out multiout; |
53 | hda_nid_t dac_nids[4]; /* NID for each DAC */ | ||
54 | int num_dacs; | ||
51 | 55 | ||
52 | /* capture */ | 56 | /* capture */ |
53 | hda_nid_t *adc_nids; | 57 | hda_nid_t *adc_nids; |
@@ -63,8 +67,30 @@ struct cmi_spec { | |||
63 | const struct cmi_channel_mode *channel_modes; | 67 | const struct cmi_channel_mode *channel_modes; |
64 | 68 | ||
65 | struct hda_pcm pcm_rec[2]; /* PCM information */ | 69 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
70 | |||
71 | /* pin deafault configuration */ | ||
72 | hda_nid_t pin_nid[NUM_PINS]; | ||
73 | unsigned int def_conf[NUM_PINS]; | ||
74 | unsigned int pin_def_confs; | ||
75 | |||
76 | /* multichannel pins */ | ||
77 | hda_nid_t multich_pin[4]; /* max 8-channel */ | ||
78 | struct hda_verb multi_init[9]; /* 2 verbs for each pin + terminator */ | ||
66 | }; | 79 | }; |
67 | 80 | ||
81 | /* amp values */ | ||
82 | #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) | ||
83 | #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) | ||
84 | #define AMP_OUT_MUTE 0xb080 | ||
85 | #define AMP_OUT_UNMUTE 0xb000 | ||
86 | #define AMP_OUT_ZERO 0xb000 | ||
87 | /* pinctl values */ | ||
88 | #define PIN_IN 0x20 | ||
89 | #define PIN_VREF80 0x24 | ||
90 | #define PIN_VREF50 0x21 | ||
91 | #define PIN_OUT 0x40 | ||
92 | #define PIN_HP 0xc0 | ||
93 | |||
68 | /* | 94 | /* |
69 | * input MUX | 95 | * input MUX |
70 | */ | 96 | */ |
@@ -102,9 +128,9 @@ static int cmi_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon | |||
102 | /* 3-stack / 2 channel */ | 128 | /* 3-stack / 2 channel */ |
103 | static struct hda_verb cmi9880_ch2_init[] = { | 129 | static struct hda_verb cmi9880_ch2_init[] = { |
104 | /* set line-in PIN for input */ | 130 | /* set line-in PIN for input */ |
105 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | 131 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
106 | /* set mic PIN for input, also enable vref */ | 132 | /* set mic PIN for input, also enable vref */ |
107 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | 133 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
108 | /* route front PCM (DAC1) to HP */ | 134 | /* route front PCM (DAC1) to HP */ |
109 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | 135 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
110 | {} | 136 | {} |
@@ -113,9 +139,9 @@ static struct hda_verb cmi9880_ch2_init[] = { | |||
113 | /* 3-stack / 6 channel */ | 139 | /* 3-stack / 6 channel */ |
114 | static struct hda_verb cmi9880_ch6_init[] = { | 140 | static struct hda_verb cmi9880_ch6_init[] = { |
115 | /* set line-in PIN for output */ | 141 | /* set line-in PIN for output */ |
116 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | 142 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
117 | /* set mic PIN for output */ | 143 | /* set mic PIN for output */ |
118 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | 144 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
119 | /* route front PCM (DAC1) to HP */ | 145 | /* route front PCM (DAC1) to HP */ |
120 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | 146 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
121 | {} | 147 | {} |
@@ -124,9 +150,9 @@ static struct hda_verb cmi9880_ch6_init[] = { | |||
124 | /* 3-stack+front / 8 channel */ | 150 | /* 3-stack+front / 8 channel */ |
125 | static struct hda_verb cmi9880_ch8_init[] = { | 151 | static struct hda_verb cmi9880_ch8_init[] = { |
126 | /* set line-in PIN for output */ | 152 | /* set line-in PIN for output */ |
127 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | 153 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
128 | /* set mic PIN for output */ | 154 | /* set mic PIN for output */ |
129 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | 155 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
130 | /* route rear-surround PCM (DAC4) to HP */ | 156 | /* route rear-surround PCM (DAC4) to HP */ |
131 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x03 }, | 157 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x03 }, |
132 | {} | 158 | {} |
@@ -269,25 +295,27 @@ static hda_nid_t cmi9880_adc_nids[2] = { | |||
269 | */ | 295 | */ |
270 | static struct hda_verb cmi9880_basic_init[] = { | 296 | static struct hda_verb cmi9880_basic_init[] = { |
271 | /* port-D for line out (rear panel) */ | 297 | /* port-D for line out (rear panel) */ |
272 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 298 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
273 | /* port-E for HP out (front panel) */ | 299 | /* port-E for HP out (front panel) */ |
274 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 300 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
275 | /* route front PCM to HP */ | 301 | /* route front PCM to HP */ |
276 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | 302 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
277 | /* port-A for surround (rear panel) */ | 303 | /* port-A for surround (rear panel) */ |
278 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 304 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
279 | /* port-G for CLFE (rear panel) */ | 305 | /* port-G for CLFE (rear panel) */ |
280 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 306 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
307 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
281 | /* port-H for side (rear panel) */ | 308 | /* port-H for side (rear panel) */ |
282 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 309 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
310 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
283 | /* port-C for line-in (rear panel) */ | 311 | /* port-C for line-in (rear panel) */ |
284 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | 312 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
285 | /* port-B for mic-in (rear panel) with vref */ | 313 | /* port-B for mic-in (rear panel) with vref */ |
286 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | 314 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
287 | /* port-F for mic-in (front panel) with vref */ | 315 | /* port-F for mic-in (front panel) with vref */ |
288 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | 316 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
289 | /* CD-in */ | 317 | /* CD-in */ |
290 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | 318 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
291 | /* route front mic to ADC1/2 */ | 319 | /* route front mic to ADC1/2 */ |
292 | { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 }, | 320 | { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 }, |
293 | { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 }, | 321 | { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 }, |
@@ -296,23 +324,27 @@ static struct hda_verb cmi9880_basic_init[] = { | |||
296 | 324 | ||
297 | static struct hda_verb cmi9880_allout_init[] = { | 325 | static struct hda_verb cmi9880_allout_init[] = { |
298 | /* port-D for line out (rear panel) */ | 326 | /* port-D for line out (rear panel) */ |
299 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 327 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
300 | /* port-E for HP out (front panel) */ | 328 | /* port-E for HP out (front panel) */ |
301 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 329 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
302 | /* route front PCM to HP */ | 330 | /* route front PCM to HP */ |
303 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | 331 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
304 | /* port-A for side (rear panel) */ | 332 | /* port-A for side (rear panel) */ |
305 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 333 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
306 | /* port-G for CLFE (rear panel) */ | 334 | /* port-G for CLFE (rear panel) */ |
307 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 335 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
336 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
337 | /* port-H for side (rear panel) */ | ||
338 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | ||
339 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
308 | /* port-C for surround (rear panel) */ | 340 | /* port-C for surround (rear panel) */ |
309 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | 341 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, |
310 | /* port-B for mic-in (rear panel) with vref */ | 342 | /* port-B for mic-in (rear panel) with vref */ |
311 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | 343 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
312 | /* port-F for mic-in (front panel) with vref */ | 344 | /* port-F for mic-in (front panel) with vref */ |
313 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | 345 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
314 | /* CD-in */ | 346 | /* CD-in */ |
315 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | 347 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, |
316 | /* route front mic to ADC1/2 */ | 348 | /* route front mic to ADC1/2 */ |
317 | { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 }, | 349 | { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 }, |
318 | { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 }, | 350 | { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 }, |
@@ -347,6 +379,81 @@ static int cmi9880_build_controls(struct hda_codec *codec) | |||
347 | return 0; | 379 | return 0; |
348 | } | 380 | } |
349 | 381 | ||
382 | /* fill in the multi_dac_nids table, which will decide | ||
383 | which audio widget to use for each channel */ | ||
384 | static int cmi9880_fill_multi_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) | ||
385 | { | ||
386 | struct cmi_spec *spec = codec->spec; | ||
387 | hda_nid_t nid; | ||
388 | int assigned[4]; | ||
389 | int i, j; | ||
390 | |||
391 | /* clear the table, only one c-media dac assumed here */ | ||
392 | memset(spec->dac_nids, 0, sizeof(spec->dac_nids)); | ||
393 | memset(assigned, 0, sizeof(assigned)); | ||
394 | /* check the pins we found */ | ||
395 | for (i = 0; i < cfg->line_outs; i++) { | ||
396 | nid = cfg->line_out_pins[i]; | ||
397 | /* nid 0x0b~0x0e is hardwired to audio widget 0x3~0x6 */ | ||
398 | if (nid >= 0x0b && nid <= 0x0e) { | ||
399 | spec->dac_nids[i] = (nid - 0x0b) + 0x03; | ||
400 | assigned[nid - 0x0b] = 1; | ||
401 | } | ||
402 | } | ||
403 | /* left pin can be connect to any audio widget */ | ||
404 | for (i = 0; i < cfg->line_outs; i++) { | ||
405 | nid = cfg->line_out_pins[i]; | ||
406 | if (nid <= 0x0e) | ||
407 | continue; | ||
408 | /* search for an empty channel */ | ||
409 | for (j = 0; j < cfg->line_outs; j++) { | ||
410 | if (! assigned[j]) { | ||
411 | spec->dac_nids[i] = i + 0x03; | ||
412 | assigned[j] = 1; | ||
413 | break; | ||
414 | } | ||
415 | } | ||
416 | } | ||
417 | spec->num_dacs = cfg->line_outs; | ||
418 | return 0; | ||
419 | } | ||
420 | |||
421 | /* create multi_init table, which is used for multichannel initialization */ | ||
422 | static int cmi9880_fill_multi_init(struct hda_codec *codec, const struct auto_pin_cfg *cfg) | ||
423 | { | ||
424 | struct cmi_spec *spec = codec->spec; | ||
425 | hda_nid_t nid; | ||
426 | int i, j, k, len; | ||
427 | |||
428 | /* clear the table, only one c-media dac assumed here */ | ||
429 | memset(spec->multi_init, 0, sizeof(spec->multi_init)); | ||
430 | for (j = 0, i = 0; i < cfg->line_outs; i++) { | ||
431 | hda_nid_t conn[4]; | ||
432 | nid = cfg->line_out_pins[i]; | ||
433 | /* set as output */ | ||
434 | spec->multi_init[j].nid = nid; | ||
435 | spec->multi_init[j].verb = AC_VERB_SET_PIN_WIDGET_CONTROL; | ||
436 | spec->multi_init[j].param = PIN_OUT; | ||
437 | j++; | ||
438 | if (nid > 0x0e) { | ||
439 | /* set connection */ | ||
440 | spec->multi_init[j].nid = nid; | ||
441 | spec->multi_init[j].verb = AC_VERB_SET_CONNECT_SEL; | ||
442 | spec->multi_init[j].param = 0; | ||
443 | /* find the index in connect list */ | ||
444 | len = snd_hda_get_connections(codec, nid, conn, 4); | ||
445 | for (k = 0; k < len; k++) | ||
446 | if (conn[k] == spec->dac_nids[i]) { | ||
447 | spec->multi_init[j].param = j; | ||
448 | break; | ||
449 | } | ||
450 | j++; | ||
451 | break; | ||
452 | } | ||
453 | } | ||
454 | return 0; | ||
455 | } | ||
456 | |||
350 | static int cmi9880_init(struct hda_codec *codec) | 457 | static int cmi9880_init(struct hda_codec *codec) |
351 | { | 458 | { |
352 | struct cmi_spec *spec = codec->spec; | 459 | struct cmi_spec *spec = codec->spec; |
@@ -354,6 +461,8 @@ static int cmi9880_init(struct hda_codec *codec) | |||
354 | snd_hda_sequence_write(codec, cmi9880_allout_init); | 461 | snd_hda_sequence_write(codec, cmi9880_allout_init); |
355 | else | 462 | else |
356 | snd_hda_sequence_write(codec, cmi9880_basic_init); | 463 | snd_hda_sequence_write(codec, cmi9880_basic_init); |
464 | if (spec->board_config == CMI_AUTO) | ||
465 | snd_hda_sequence_write(codec, spec->multi_init); | ||
357 | return 0; | 466 | return 0; |
358 | } | 467 | } |
359 | 468 | ||
@@ -540,6 +649,7 @@ static struct hda_board_config cmi9880_cfg_tbl[] = { | |||
540 | { .modelname = "full", .config = CMI_FULL }, | 649 | { .modelname = "full", .config = CMI_FULL }, |
541 | { .modelname = "full_dig", .config = CMI_FULL_DIG }, | 650 | { .modelname = "full_dig", .config = CMI_FULL_DIG }, |
542 | { .modelname = "allout", .config = CMI_ALLOUT }, | 651 | { .modelname = "allout", .config = CMI_ALLOUT }, |
652 | { .modelname = "auto", .config = CMI_AUTO }, | ||
543 | {} /* terminator */ | 653 | {} /* terminator */ |
544 | }; | 654 | }; |
545 | 655 | ||
@@ -564,10 +674,14 @@ static int patch_cmi9880(struct hda_codec *codec) | |||
564 | codec->spec = spec; | 674 | codec->spec = spec; |
565 | spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl); | 675 | spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl); |
566 | if (spec->board_config < 0) { | 676 | if (spec->board_config < 0) { |
567 | snd_printd(KERN_INFO "hda_codec: Unknown model for CMI9880\n"); | 677 | snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n"); |
568 | spec->board_config = CMI_FULL_DIG; /* try everything */ | 678 | spec->board_config = CMI_AUTO; /* try everything */ |
569 | } | 679 | } |
570 | 680 | ||
681 | /* copy default DAC NIDs */ | ||
682 | memcpy(spec->dac_nids, cmi9880_dac_nids, sizeof(spec->dac_nids)); | ||
683 | spec->num_dacs = 4; | ||
684 | |||
571 | switch (spec->board_config) { | 685 | switch (spec->board_config) { |
572 | case CMI_MINIMAL: | 686 | case CMI_MINIMAL: |
573 | case CMI_MIN_FP: | 687 | case CMI_MIN_FP: |
@@ -599,10 +713,58 @@ static int patch_cmi9880(struct hda_codec *codec) | |||
599 | spec->input_mux = &cmi9880_no_line_mux; | 713 | spec->input_mux = &cmi9880_no_line_mux; |
600 | spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; | 714 | spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; |
601 | break; | 715 | break; |
716 | case CMI_AUTO: | ||
717 | { | ||
718 | unsigned int port_e, port_f, port_g, port_h; | ||
719 | unsigned int port_spdifi, port_spdifo; | ||
720 | struct auto_pin_cfg cfg; | ||
721 | |||
722 | /* collect pin default configuration */ | ||
723 | port_e = snd_hda_codec_read(codec, 0x0f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
724 | port_f = snd_hda_codec_read(codec, 0x10, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
725 | spec->front_panel = 1; | ||
726 | if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE || | ||
727 | get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) { | ||
728 | port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
729 | port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
730 | spec->surr_switch = 1; | ||
731 | /* no front panel */ | ||
732 | if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE || | ||
733 | get_defcfg_connect(port_h) == AC_JACK_PORT_NONE) { | ||
734 | /* no optional rear panel */ | ||
735 | spec->board_config = CMI_MINIMAL; | ||
736 | spec->front_panel = 0; | ||
737 | spec->num_ch_modes = 2; | ||
738 | } else { | ||
739 | spec->board_config = CMI_MIN_FP; | ||
740 | spec->num_ch_modes = 3; | ||
741 | } | ||
742 | spec->channel_modes = cmi9880_channel_modes; | ||
743 | spec->input_mux = &cmi9880_basic_mux; | ||
744 | spec->multiout.max_channels = cmi9880_channel_modes[0].channels; | ||
745 | } else { | ||
746 | spec->input_mux = &cmi9880_basic_mux; | ||
747 | port_spdifi = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
748 | port_spdifo = snd_hda_codec_read(codec, 0x12, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
749 | if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE) | ||
750 | spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; | ||
751 | if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE) | ||
752 | spec->dig_in_nid = CMI_DIG_IN_NID; | ||
753 | spec->multiout.max_channels = 8; | ||
754 | } | ||
755 | snd_hda_parse_pin_def_config(codec, &cfg); | ||
756 | if (cfg.line_outs) { | ||
757 | spec->multiout.max_channels = cfg.line_outs * 2; | ||
758 | cmi9880_fill_multi_dac_nids(codec, &cfg); | ||
759 | cmi9880_fill_multi_init(codec, &cfg); | ||
760 | } else | ||
761 | snd_printd("patch_cmedia: cannot detect association in defcfg\n"); | ||
762 | break; | ||
763 | } | ||
602 | } | 764 | } |
603 | 765 | ||
604 | spec->multiout.num_dacs = 4; | 766 | spec->multiout.num_dacs = spec->num_dacs; |
605 | spec->multiout.dac_nids = cmi9880_dac_nids; | 767 | spec->multiout.dac_nids = spec->dac_nids; |
606 | 768 | ||
607 | spec->adc_nids = cmi9880_adc_nids; | 769 | spec->adc_nids = cmi9880_adc_nids; |
608 | 770 | ||
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 17c5062423ae..bab89843d850 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -33,38 +33,73 @@ | |||
33 | 33 | ||
34 | /* ALC880 board config type */ | 34 | /* ALC880 board config type */ |
35 | enum { | 35 | enum { |
36 | ALC880_MINIMAL, | ||
37 | ALC880_3ST, | 36 | ALC880_3ST, |
38 | ALC880_3ST_DIG, | 37 | ALC880_3ST_DIG, |
39 | ALC880_5ST, | 38 | ALC880_5ST, |
40 | ALC880_5ST_DIG, | 39 | ALC880_5ST_DIG, |
41 | ALC880_W810, | 40 | ALC880_W810, |
41 | ALC880_Z71V, | ||
42 | ALC880_AUTO, | ||
43 | ALC880_6ST_DIG, | ||
44 | ALC880_F1734, | ||
45 | ALC880_ASUS, | ||
46 | ALC880_ASUS_DIG, | ||
47 | ALC880_ASUS_W1V, | ||
48 | ALC880_UNIWILL_DIG, | ||
49 | #ifdef CONFIG_SND_DEBUG | ||
50 | ALC880_TEST, | ||
51 | #endif | ||
52 | ALC880_MODEL_LAST /* last tag */ | ||
53 | }; | ||
54 | |||
55 | /* ALC260 models */ | ||
56 | enum { | ||
57 | ALC260_BASIC, | ||
58 | ALC260_HP, | ||
59 | ALC260_MODEL_LAST /* last tag */ | ||
42 | }; | 60 | }; |
43 | 61 | ||
62 | /* amp values */ | ||
63 | #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) | ||
64 | #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) | ||
65 | #define AMP_OUT_MUTE 0xb080 | ||
66 | #define AMP_OUT_UNMUTE 0xb000 | ||
67 | #define AMP_OUT_ZERO 0xb000 | ||
68 | /* pinctl values */ | ||
69 | #define PIN_IN 0x20 | ||
70 | #define PIN_VREF80 0x24 | ||
71 | #define PIN_VREF50 0x21 | ||
72 | #define PIN_OUT 0x40 | ||
73 | #define PIN_HP 0xc0 | ||
74 | |||
44 | struct alc_spec { | 75 | struct alc_spec { |
45 | /* codec parameterization */ | 76 | /* codec parameterization */ |
46 | unsigned int front_panel: 1; | 77 | snd_kcontrol_new_t *mixers[3]; /* mixer arrays */ |
47 | |||
48 | snd_kcontrol_new_t* mixers[2]; | ||
49 | unsigned int num_mixers; | 78 | unsigned int num_mixers; |
50 | 79 | ||
51 | struct hda_verb *init_verbs; | 80 | const struct hda_verb *init_verbs[3]; /* initialization verbs |
81 | * don't forget NULL termination! | ||
82 | */ | ||
83 | unsigned int num_init_verbs; | ||
52 | 84 | ||
53 | char* stream_name_analog; | 85 | char *stream_name_analog; /* analog PCM stream */ |
54 | struct hda_pcm_stream *stream_analog_playback; | 86 | struct hda_pcm_stream *stream_analog_playback; |
55 | struct hda_pcm_stream *stream_analog_capture; | 87 | struct hda_pcm_stream *stream_analog_capture; |
56 | 88 | ||
57 | char* stream_name_digital; | 89 | char *stream_name_digital; /* digital PCM stream */ |
58 | struct hda_pcm_stream *stream_digital_playback; | 90 | struct hda_pcm_stream *stream_digital_playback; |
59 | struct hda_pcm_stream *stream_digital_capture; | 91 | struct hda_pcm_stream *stream_digital_capture; |
60 | 92 | ||
61 | /* playback */ | 93 | /* playback */ |
62 | struct hda_multi_out multiout; | 94 | struct hda_multi_out multiout; /* playback set-up |
95 | * max_channels, dacs must be set | ||
96 | * dig_out_nid and hp_nid are optional | ||
97 | */ | ||
63 | 98 | ||
64 | /* capture */ | 99 | /* capture */ |
65 | unsigned int num_adc_nids; | 100 | unsigned int num_adc_nids; |
66 | hda_nid_t *adc_nids; | 101 | hda_nid_t *adc_nids; |
67 | hda_nid_t dig_in_nid; | 102 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
68 | 103 | ||
69 | /* capture source */ | 104 | /* capture source */ |
70 | const struct hda_input_mux *input_mux; | 105 | const struct hda_input_mux *input_mux; |
@@ -75,61 +110,17 @@ struct alc_spec { | |||
75 | int num_channel_mode; | 110 | int num_channel_mode; |
76 | 111 | ||
77 | /* PCM information */ | 112 | /* PCM information */ |
78 | struct hda_pcm pcm_rec[2]; | 113 | struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */ |
79 | }; | ||
80 | |||
81 | /* DAC/ADC assignment */ | ||
82 | |||
83 | static hda_nid_t alc880_dac_nids[4] = { | ||
84 | /* front, rear, clfe, rear_surr */ | ||
85 | 0x02, 0x05, 0x04, 0x03 | ||
86 | }; | ||
87 | |||
88 | static hda_nid_t alc880_w810_dac_nids[3] = { | ||
89 | /* front, rear/surround, clfe */ | ||
90 | 0x02, 0x03, 0x04 | ||
91 | }; | ||
92 | |||
93 | static hda_nid_t alc880_adc_nids[3] = { | ||
94 | /* ADC0-2 */ | ||
95 | 0x07, 0x08, 0x09, | ||
96 | }; | ||
97 | |||
98 | #define ALC880_DIGOUT_NID 0x06 | ||
99 | #define ALC880_DIGIN_NID 0x0a | ||
100 | 114 | ||
101 | static hda_nid_t alc260_dac_nids[1] = { | 115 | struct semaphore bind_mutex; /* for bound controls */ |
102 | /* front */ | ||
103 | 0x02, | ||
104 | }; | ||
105 | 116 | ||
106 | static hda_nid_t alc260_adc_nids[2] = { | 117 | /* dynamic controls, init_verbs and input_mux */ |
107 | /* ADC0-1 */ | 118 | struct auto_pin_cfg autocfg; |
108 | 0x04, 0x05, | 119 | unsigned int num_kctl_alloc, num_kctl_used; |
120 | snd_kcontrol_new_t *kctl_alloc; | ||
121 | struct hda_input_mux private_imux; | ||
109 | }; | 122 | }; |
110 | 123 | ||
111 | #define ALC260_DIGOUT_NID 0x03 | ||
112 | #define ALC260_DIGIN_NID 0x06 | ||
113 | |||
114 | static struct hda_input_mux alc880_capture_source = { | ||
115 | .num_items = 4, | ||
116 | .items = { | ||
117 | { "Mic", 0x0 }, | ||
118 | { "Front Mic", 0x3 }, | ||
119 | { "Line", 0x2 }, | ||
120 | { "CD", 0x4 }, | ||
121 | }, | ||
122 | }; | ||
123 | |||
124 | static struct hda_input_mux alc260_capture_source = { | ||
125 | .num_items = 4, | ||
126 | .items = { | ||
127 | { "Mic", 0x0 }, | ||
128 | { "Front Mic", 0x1 }, | ||
129 | { "Line", 0x2 }, | ||
130 | { "CD", 0x4 }, | ||
131 | }, | ||
132 | }; | ||
133 | 124 | ||
134 | /* | 125 | /* |
135 | * input MUX handling | 126 | * input MUX handling |
@@ -160,6 +151,7 @@ static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon | |||
160 | spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]); | 151 | spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]); |
161 | } | 152 | } |
162 | 153 | ||
154 | |||
163 | /* | 155 | /* |
164 | * channel mode setting | 156 | * channel mode setting |
165 | */ | 157 | */ |
@@ -168,135 +160,18 @@ struct alc_channel_mode { | |||
168 | const struct hda_verb *sequence; | 160 | const struct hda_verb *sequence; |
169 | }; | 161 | }; |
170 | 162 | ||
171 | |||
172 | /* | ||
173 | * channel source setting (2/6 channel selection for 3-stack) | ||
174 | */ | ||
175 | |||
176 | /* | ||
177 | * set the path ways for 2 channel output | ||
178 | * need to set the codec line out and mic 1 pin widgets to inputs | ||
179 | */ | ||
180 | static struct hda_verb alc880_threestack_ch2_init[] = { | ||
181 | /* set pin widget 1Ah (line in) for input */ | ||
182 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
183 | /* set pin widget 18h (mic1) for input, for mic also enable the vref */ | ||
184 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | ||
185 | /* mute the output for Line In PW */ | ||
186 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | ||
187 | /* mute for Mic1 PW */ | ||
188 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | ||
189 | { } /* end */ | ||
190 | }; | ||
191 | |||
192 | /* | ||
193 | * 6ch mode | ||
194 | * need to set the codec line out and mic 1 pin widgets to outputs | ||
195 | */ | ||
196 | static struct hda_verb alc880_threestack_ch6_init[] = { | ||
197 | /* set pin widget 1Ah (line in) for output */ | ||
198 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
199 | /* set pin widget 18h (mic1) for output */ | ||
200 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
201 | /* unmute the output for Line In PW */ | ||
202 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 }, | ||
203 | /* unmute for Mic1 PW */ | ||
204 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 }, | ||
205 | /* for rear channel output using Line In 1 | ||
206 | * set select widget connection (nid = 0x12) - to summer node | ||
207 | * for rear NID = 0x0f...offset 3 in connection list | ||
208 | */ | ||
209 | { 0x12, AC_VERB_SET_CONNECT_SEL, 0x3 }, | ||
210 | /* for Mic1 - retask for center/lfe */ | ||
211 | /* set select widget connection (nid = 0x10) - to summer node for | ||
212 | * front CLFE NID = 0x0e...offset 2 in connection list | ||
213 | */ | ||
214 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x2 }, | ||
215 | { } /* end */ | ||
216 | }; | ||
217 | |||
218 | static struct alc_channel_mode alc880_threestack_modes[2] = { | ||
219 | { 2, alc880_threestack_ch2_init }, | ||
220 | { 6, alc880_threestack_ch6_init }, | ||
221 | }; | ||
222 | |||
223 | |||
224 | /* | ||
225 | * channel source setting (6/8 channel selection for 5-stack) | ||
226 | */ | ||
227 | |||
228 | /* set the path ways for 6 channel output | ||
229 | * need to set the codec line out and mic 1 pin widgets to inputs | ||
230 | */ | ||
231 | static struct hda_verb alc880_fivestack_ch6_init[] = { | ||
232 | /* set pin widget 1Ah (line in) for input */ | ||
233 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | ||
234 | /* mute the output for Line In PW */ | ||
235 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | ||
236 | { } /* end */ | ||
237 | }; | ||
238 | |||
239 | /* need to set the codec line out and mic 1 pin widgets to outputs */ | ||
240 | static struct hda_verb alc880_fivestack_ch8_init[] = { | ||
241 | /* set pin widget 1Ah (line in) for output */ | ||
242 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | ||
243 | /* unmute the output for Line In PW */ | ||
244 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 }, | ||
245 | /* output for surround channel output using Line In 1 */ | ||
246 | /* set select widget connection (nid = 0x12) - to summer node | ||
247 | * for surr_rear NID = 0x0d...offset 1 in connection list | ||
248 | */ | ||
249 | { 0x12, AC_VERB_SET_CONNECT_SEL, 0x1 }, | ||
250 | { } /* end */ | ||
251 | }; | ||
252 | |||
253 | static struct alc_channel_mode alc880_fivestack_modes[2] = { | ||
254 | { 6, alc880_fivestack_ch6_init }, | ||
255 | { 8, alc880_fivestack_ch8_init }, | ||
256 | }; | ||
257 | |||
258 | /* | ||
259 | * channel source setting for W810 system | ||
260 | * | ||
261 | * W810 has rear IO for: | ||
262 | * Front (DAC 02) | ||
263 | * Surround (DAC 03) | ||
264 | * Center/LFE (DAC 04) | ||
265 | * Digital out (06) | ||
266 | * | ||
267 | * The system also has a pair of internal speakers, and a headphone jack. | ||
268 | * These are both connected to Line2 on the codec, hence to DAC 02. | ||
269 | * | ||
270 | * There is a variable resistor to control the speaker or headphone | ||
271 | * volume. This is a hardware-only device without a software API. | ||
272 | * | ||
273 | * Plugging headphones in will disable the internal speakers. This is | ||
274 | * implemented in hardware, not via the driver using jack sense. In | ||
275 | * a similar fashion, plugging into the rear socket marked "front" will | ||
276 | * disable both the speakers and headphones. | ||
277 | * | ||
278 | * For input, there's a microphone jack, and an "audio in" jack. | ||
279 | * These may not do anything useful with this driver yet, because I | ||
280 | * haven't setup any initialization verbs for these yet... | ||
281 | */ | ||
282 | |||
283 | static struct alc_channel_mode alc880_w810_modes[1] = { | ||
284 | { 6, NULL } | ||
285 | }; | ||
286 | |||
287 | /* | ||
288 | */ | ||
289 | static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | 163 | static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) |
290 | { | 164 | { |
291 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 165 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
292 | struct alc_spec *spec = codec->spec; | 166 | struct alc_spec *spec = codec->spec; |
167 | int items = kcontrol->private_value ? (int)kcontrol->private_value : 2; | ||
293 | 168 | ||
294 | snd_assert(spec->channel_mode, return -ENXIO); | 169 | snd_assert(spec->channel_mode, return -ENXIO); |
295 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 170 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
296 | uinfo->count = 1; | 171 | uinfo->count = 1; |
297 | uinfo->value.enumerated.items = 2; | 172 | uinfo->value.enumerated.items = items; |
298 | if (uinfo->value.enumerated.item >= 2) | 173 | if (uinfo->value.enumerated.item >= items) |
299 | uinfo->value.enumerated.item = 1; | 174 | uinfo->value.enumerated.item = items - 1; |
300 | sprintf(uinfo->value.enumerated.name, "%dch", | 175 | sprintf(uinfo->value.enumerated.name, "%dch", |
301 | spec->channel_mode[uinfo->value.enumerated.item].channels); | 176 | spec->channel_mode[uinfo->value.enumerated.item].channels); |
302 | return 0; | 177 | return 0; |
@@ -306,10 +181,16 @@ static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc | |||
306 | { | 181 | { |
307 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 182 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
308 | struct alc_spec *spec = codec->spec; | 183 | struct alc_spec *spec = codec->spec; |
184 | int items = kcontrol->private_value ? (int)kcontrol->private_value : 2; | ||
185 | int i; | ||
309 | 186 | ||
310 | snd_assert(spec->channel_mode, return -ENXIO); | 187 | snd_assert(spec->channel_mode, return -ENXIO); |
311 | ucontrol->value.enumerated.item[0] = | 188 | for (i = 0; i < items; i++) { |
312 | (spec->multiout.max_channels == spec->channel_mode[0].channels) ? 0 : 1; | 189 | if (spec->multiout.max_channels == spec->channel_mode[i].channels) { |
190 | ucontrol->value.enumerated.item[0] = i; | ||
191 | break; | ||
192 | } | ||
193 | } | ||
313 | return 0; | 194 | return 0; |
314 | } | 195 | } |
315 | 196 | ||
@@ -335,21 +216,149 @@ static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc | |||
335 | 216 | ||
336 | 217 | ||
337 | /* | 218 | /* |
219 | * bound volume controls | ||
220 | * | ||
221 | * bind multiple volumes (# indices, from 0) | ||
222 | */ | ||
223 | |||
224 | #define AMP_VAL_IDX_SHIFT 19 | ||
225 | #define AMP_VAL_IDX_MASK (0x0f<<19) | ||
226 | |||
227 | static int alc_bind_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
228 | { | ||
229 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
230 | struct alc_spec *spec = codec->spec; | ||
231 | unsigned long pval; | ||
232 | |||
233 | down(&spec->bind_mutex); | ||
234 | pval = kcontrol->private_value; | ||
235 | kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ | ||
236 | snd_hda_mixer_amp_switch_info(kcontrol, uinfo); | ||
237 | kcontrol->private_value = pval; | ||
238 | up(&spec->bind_mutex); | ||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static int alc_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
243 | { | ||
244 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
245 | struct alc_spec *spec = codec->spec; | ||
246 | unsigned long pval; | ||
247 | |||
248 | down(&spec->bind_mutex); | ||
249 | pval = kcontrol->private_value; | ||
250 | kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ | ||
251 | snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); | ||
252 | kcontrol->private_value = pval; | ||
253 | up(&spec->bind_mutex); | ||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | static int alc_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
258 | { | ||
259 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
260 | struct alc_spec *spec = codec->spec; | ||
261 | unsigned long pval; | ||
262 | int i, indices, change = 0; | ||
263 | |||
264 | down(&spec->bind_mutex); | ||
265 | pval = kcontrol->private_value; | ||
266 | indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; | ||
267 | for (i = 0; i < indices; i++) { | ||
268 | kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT); | ||
269 | change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); | ||
270 | } | ||
271 | kcontrol->private_value = pval; | ||
272 | up(&spec->bind_mutex); | ||
273 | return change; | ||
274 | } | ||
275 | |||
276 | #define ALC_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \ | ||
277 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | ||
278 | .info = alc_bind_switch_info, \ | ||
279 | .get = alc_bind_switch_get, \ | ||
280 | .put = alc_bind_switch_put, \ | ||
281 | .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) } | ||
282 | |||
283 | #define ALC_BIND_MUTE(xname,nid,indices,dir) ALC_BIND_MUTE_MONO(xname,nid,3,indices,dir) | ||
284 | |||
285 | |||
286 | /* | ||
287 | * ALC880 3-stack model | ||
288 | * | ||
289 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | ||
290 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b | ||
291 | * HP = 0x19 | ||
338 | */ | 292 | */ |
339 | 293 | ||
340 | /* 3-stack mode | 294 | static hda_nid_t alc880_dac_nids[4] = { |
341 | * Pin assignment: Front=0x14, Line-In/Rear=0x1a, Mic/CLFE=0x18, F-Mic=0x1b | 295 | /* front, rear, clfe, rear_surr */ |
342 | * HP=0x19 | 296 | 0x02, 0x05, 0x04, 0x03 |
297 | }; | ||
298 | |||
299 | static hda_nid_t alc880_adc_nids[3] = { | ||
300 | /* ADC0-2 */ | ||
301 | 0x07, 0x08, 0x09, | ||
302 | }; | ||
303 | |||
304 | /* The datasheet says the node 0x07 is connected from inputs, | ||
305 | * but it shows zero connection in the real implementation on some devices. | ||
343 | */ | 306 | */ |
344 | static snd_kcontrol_new_t alc880_base_mixer[] = { | 307 | static hda_nid_t alc880_adc_nids_alt[2] = { |
308 | /* ADC1-2 */ | ||
309 | 0x08, 0x09, | ||
310 | }; | ||
311 | |||
312 | #define ALC880_DIGOUT_NID 0x06 | ||
313 | #define ALC880_DIGIN_NID 0x0a | ||
314 | |||
315 | static struct hda_input_mux alc880_capture_source = { | ||
316 | .num_items = 4, | ||
317 | .items = { | ||
318 | { "Mic", 0x0 }, | ||
319 | { "Front Mic", 0x3 }, | ||
320 | { "Line", 0x2 }, | ||
321 | { "CD", 0x4 }, | ||
322 | }, | ||
323 | }; | ||
324 | |||
325 | /* channel source setting (2/6 channel selection for 3-stack) */ | ||
326 | /* 2ch mode */ | ||
327 | static struct hda_verb alc880_threestack_ch2_init[] = { | ||
328 | /* set line-in to input, mute it */ | ||
329 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
330 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
331 | /* set mic-in to input vref 80%, mute it */ | ||
332 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
333 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
334 | { } /* end */ | ||
335 | }; | ||
336 | |||
337 | /* 6ch mode */ | ||
338 | static struct hda_verb alc880_threestack_ch6_init[] = { | ||
339 | /* set line-in to output, unmute it */ | ||
340 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
341 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
342 | /* set mic-in to output, unmute it */ | ||
343 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
344 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
345 | { } /* end */ | ||
346 | }; | ||
347 | |||
348 | static struct alc_channel_mode alc880_threestack_modes[2] = { | ||
349 | { 2, alc880_threestack_ch2_init }, | ||
350 | { 6, alc880_threestack_ch6_init }, | ||
351 | }; | ||
352 | |||
353 | static snd_kcontrol_new_t alc880_three_stack_mixer[] = { | ||
345 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 354 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
346 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 355 | ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
347 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | 356 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
348 | HDA_CODEC_MUTE("Surround Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | 357 | ALC_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
349 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | 358 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
350 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | 359 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
351 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x18, 1, 0x0, HDA_OUTPUT), | 360 | ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
352 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x18, 2, 0x0, HDA_OUTPUT), | 361 | ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
353 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | 362 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
354 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | 363 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
355 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | 364 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
@@ -360,12 +369,25 @@ static snd_kcontrol_new_t alc880_base_mixer[] = { | |||
360 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | 369 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), |
361 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | 370 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
362 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | 371 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
363 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
364 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), | 372 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
373 | { | ||
374 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
375 | .name = "Channel Mode", | ||
376 | .info = alc880_ch_mode_info, | ||
377 | .get = alc880_ch_mode_get, | ||
378 | .put = alc880_ch_mode_put, | ||
379 | }, | ||
380 | { } /* end */ | ||
381 | }; | ||
382 | |||
383 | /* capture mixer elements */ | ||
384 | static snd_kcontrol_new_t alc880_capture_mixer[] = { | ||
365 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | 385 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), |
366 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | 386 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), |
367 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | 387 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), |
368 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | 388 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), |
389 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | ||
390 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | ||
369 | { | 391 | { |
370 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 392 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
371 | /* The multiple "Capture Source" controls confuse alsamixer | 393 | /* The multiple "Capture Source" controls confuse alsamixer |
@@ -374,65 +396,125 @@ static snd_kcontrol_new_t alc880_base_mixer[] = { | |||
374 | */ | 396 | */ |
375 | /* .name = "Capture Source", */ | 397 | /* .name = "Capture Source", */ |
376 | .name = "Input Source", | 398 | .name = "Input Source", |
377 | .count = 2, | 399 | .count = 3, |
378 | .info = alc_mux_enum_info, | 400 | .info = alc_mux_enum_info, |
379 | .get = alc_mux_enum_get, | 401 | .get = alc_mux_enum_get, |
380 | .put = alc_mux_enum_put, | 402 | .put = alc_mux_enum_put, |
381 | }, | 403 | }, |
404 | { } /* end */ | ||
405 | }; | ||
406 | |||
407 | /* capture mixer elements (in case NID 0x07 not available) */ | ||
408 | static snd_kcontrol_new_t alc880_capture_alt_mixer[] = { | ||
409 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | ||
410 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | ||
411 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | ||
412 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | ||
382 | { | 413 | { |
383 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 414 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
384 | .name = "Channel Mode", | 415 | /* The multiple "Capture Source" controls confuse alsamixer |
385 | .info = alc880_ch_mode_info, | 416 | * So call somewhat different.. |
386 | .get = alc880_ch_mode_get, | 417 | * FIXME: the controls appear in the "playback" view! |
387 | .put = alc880_ch_mode_put, | 418 | */ |
419 | /* .name = "Capture Source", */ | ||
420 | .name = "Input Source", | ||
421 | .count = 2, | ||
422 | .info = alc_mux_enum_info, | ||
423 | .get = alc_mux_enum_get, | ||
424 | .put = alc_mux_enum_put, | ||
388 | }, | 425 | }, |
389 | { } /* end */ | 426 | { } /* end */ |
390 | }; | 427 | }; |
391 | 428 | ||
392 | /* 5-stack mode | 429 | |
393 | * Pin assignment: Front=0x14, Rear=0x17, CLFE=0x16 | 430 | |
394 | * Line-In/Side=0x1a, Mic=0x18, F-Mic=0x1b, HP=0x19 | 431 | /* |
432 | * ALC880 5-stack model | ||
433 | * | ||
434 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd) | ||
435 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 | ||
436 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | ||
395 | */ | 437 | */ |
438 | |||
439 | /* additional mixers to alc880_three_stack_mixer */ | ||
396 | static snd_kcontrol_new_t alc880_five_stack_mixer[] = { | 440 | static snd_kcontrol_new_t alc880_five_stack_mixer[] = { |
441 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
442 | ALC_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), | ||
443 | { } /* end */ | ||
444 | }; | ||
445 | |||
446 | /* channel source setting (6/8 channel selection for 5-stack) */ | ||
447 | /* 6ch mode */ | ||
448 | static struct hda_verb alc880_fivestack_ch6_init[] = { | ||
449 | /* set line-in to input, mute it */ | ||
450 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
451 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
452 | { } /* end */ | ||
453 | }; | ||
454 | |||
455 | /* 8ch mode */ | ||
456 | static struct hda_verb alc880_fivestack_ch8_init[] = { | ||
457 | /* set line-in to output, unmute it */ | ||
458 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
459 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
460 | { } /* end */ | ||
461 | }; | ||
462 | |||
463 | static struct alc_channel_mode alc880_fivestack_modes[2] = { | ||
464 | { 6, alc880_fivestack_ch6_init }, | ||
465 | { 8, alc880_fivestack_ch8_init }, | ||
466 | }; | ||
467 | |||
468 | |||
469 | /* | ||
470 | * ALC880 6-stack model | ||
471 | * | ||
472 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f) | ||
473 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, | ||
474 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | ||
475 | */ | ||
476 | |||
477 | static hda_nid_t alc880_6st_dac_nids[4] = { | ||
478 | /* front, rear, clfe, rear_surr */ | ||
479 | 0x02, 0x03, 0x04, 0x05 | ||
480 | }; | ||
481 | |||
482 | static struct hda_input_mux alc880_6stack_capture_source = { | ||
483 | .num_items = 4, | ||
484 | .items = { | ||
485 | { "Mic", 0x0 }, | ||
486 | { "Front Mic", 0x1 }, | ||
487 | { "Line", 0x2 }, | ||
488 | { "CD", 0x4 }, | ||
489 | }, | ||
490 | }; | ||
491 | |||
492 | /* fixed 8-channels */ | ||
493 | static struct alc_channel_mode alc880_sixstack_modes[1] = { | ||
494 | { 8, NULL }, | ||
495 | }; | ||
496 | |||
497 | static snd_kcontrol_new_t alc880_six_stack_mixer[] = { | ||
397 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 498 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
398 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 499 | ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
399 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | 500 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
400 | HDA_CODEC_MUTE("Surround Playback Switch", 0x17, 0x0, HDA_OUTPUT), | 501 | ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
401 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | 502 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
402 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | 503 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
403 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), | 504 | ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
404 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | 505 | ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
405 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | 506 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
406 | HDA_CODEC_MUTE("Side Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | 507 | ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
407 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | 508 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
408 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | 509 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
409 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | 510 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
410 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | 511 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
411 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | 512 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
412 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | 513 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
413 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | 514 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
414 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | 515 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
415 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | 516 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
416 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | 517 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), |
417 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
418 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), | ||
419 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | ||
420 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | ||
421 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | ||
422 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | ||
423 | { | ||
424 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
425 | /* The multiple "Capture Source" controls confuse alsamixer | ||
426 | * So call somewhat different.. | ||
427 | * FIXME: the controls appear in the "playback" view! | ||
428 | */ | ||
429 | /* .name = "Capture Source", */ | ||
430 | .name = "Input Source", | ||
431 | .count = 2, | ||
432 | .info = alc_mux_enum_info, | ||
433 | .get = alc_mux_enum_get, | ||
434 | .put = alc_mux_enum_put, | ||
435 | }, | ||
436 | { | 518 | { |
437 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 519 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
438 | .name = "Channel Mode", | 520 | .name = "Channel Mode", |
@@ -443,39 +525,169 @@ static snd_kcontrol_new_t alc880_five_stack_mixer[] = { | |||
443 | { } /* end */ | 525 | { } /* end */ |
444 | }; | 526 | }; |
445 | 527 | ||
528 | |||
529 | /* | ||
530 | * ALC880 W810 model | ||
531 | * | ||
532 | * W810 has rear IO for: | ||
533 | * Front (DAC 02) | ||
534 | * Surround (DAC 03) | ||
535 | * Center/LFE (DAC 04) | ||
536 | * Digital out (06) | ||
537 | * | ||
538 | * The system also has a pair of internal speakers, and a headphone jack. | ||
539 | * These are both connected to Line2 on the codec, hence to DAC 02. | ||
540 | * | ||
541 | * There is a variable resistor to control the speaker or headphone | ||
542 | * volume. This is a hardware-only device without a software API. | ||
543 | * | ||
544 | * Plugging headphones in will disable the internal speakers. This is | ||
545 | * implemented in hardware, not via the driver using jack sense. In | ||
546 | * a similar fashion, plugging into the rear socket marked "front" will | ||
547 | * disable both the speakers and headphones. | ||
548 | * | ||
549 | * For input, there's a microphone jack, and an "audio in" jack. | ||
550 | * These may not do anything useful with this driver yet, because I | ||
551 | * haven't setup any initialization verbs for these yet... | ||
552 | */ | ||
553 | |||
554 | static hda_nid_t alc880_w810_dac_nids[3] = { | ||
555 | /* front, rear/surround, clfe */ | ||
556 | 0x02, 0x03, 0x04 | ||
557 | }; | ||
558 | |||
559 | /* fixed 6 channels */ | ||
560 | static struct alc_channel_mode alc880_w810_modes[1] = { | ||
561 | { 6, NULL } | ||
562 | }; | ||
563 | |||
564 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | ||
446 | static snd_kcontrol_new_t alc880_w810_base_mixer[] = { | 565 | static snd_kcontrol_new_t alc880_w810_base_mixer[] = { |
447 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 566 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
448 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 567 | ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
449 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | 568 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
450 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), | 569 | ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
451 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | 570 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
452 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | 571 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
453 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), | 572 | ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
454 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | 573 | ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), |
455 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | 574 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
456 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | 575 | { } /* end */ |
457 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | 576 | }; |
458 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), | 577 | |
459 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), | 578 | |
460 | HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), | 579 | /* |
461 | HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), | 580 | * Z710V model |
581 | * | ||
582 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | ||
583 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a | ||
584 | */ | ||
585 | |||
586 | static hda_nid_t alc880_z71v_dac_nids[1] = { | ||
587 | 0x02 | ||
588 | }; | ||
589 | #define ALC880_Z71V_HP_DAC 0x03 | ||
590 | |||
591 | /* fixed 2 channels */ | ||
592 | static struct alc_channel_mode alc880_2_jack_modes[1] = { | ||
593 | { 2, NULL } | ||
594 | }; | ||
595 | |||
596 | static snd_kcontrol_new_t alc880_z71v_mixer[] = { | ||
597 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
598 | ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
599 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
600 | ALC_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | ||
601 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | ||
602 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | ||
603 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
604 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
605 | { } /* end */ | ||
606 | }; | ||
607 | |||
608 | |||
609 | /* FIXME! */ | ||
610 | /* | ||
611 | * ALC880 F1734 model | ||
612 | * | ||
613 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | ||
614 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | ||
615 | */ | ||
616 | |||
617 | static hda_nid_t alc880_f1734_dac_nids[1] = { | ||
618 | 0x03 | ||
619 | }; | ||
620 | #define ALC880_F1734_HP_DAC 0x02 | ||
621 | |||
622 | static snd_kcontrol_new_t alc880_f1734_mixer[] = { | ||
623 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
624 | ALC_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | ||
625 | HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
626 | ALC_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | ||
627 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | ||
628 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | ||
629 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
630 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
631 | { } /* end */ | ||
632 | }; | ||
633 | |||
634 | |||
635 | /* FIXME! */ | ||
636 | /* | ||
637 | * ALC880 ASUS model | ||
638 | * | ||
639 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | ||
640 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | ||
641 | * Mic = 0x18, Line = 0x1a | ||
642 | */ | ||
643 | |||
644 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | ||
645 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | ||
646 | |||
647 | static snd_kcontrol_new_t alc880_asus_mixer[] = { | ||
648 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
649 | ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
650 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
651 | ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | ||
652 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | ||
653 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | ||
654 | ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | ||
655 | ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | ||
656 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | ||
657 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | ||
658 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
659 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
660 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
661 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
462 | { | 662 | { |
463 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 663 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
464 | /* The multiple "Capture Source" controls confuse alsamixer | 664 | .name = "Channel Mode", |
465 | * So call somewhat different.. | 665 | .info = alc880_ch_mode_info, |
466 | * FIXME: the controls appear in the "playback" view! | 666 | .get = alc880_ch_mode_get, |
467 | */ | 667 | .put = alc880_ch_mode_put, |
468 | /* .name = "Capture Source", */ | ||
469 | .name = "Input Source", | ||
470 | .count = 3, | ||
471 | .info = alc_mux_enum_info, | ||
472 | .get = alc_mux_enum_get, | ||
473 | .put = alc_mux_enum_put, | ||
474 | }, | 668 | }, |
475 | { } /* end */ | 669 | { } /* end */ |
476 | }; | 670 | }; |
477 | 671 | ||
672 | /* FIXME! */ | ||
478 | /* | 673 | /* |
674 | * ALC880 ASUS W1V model | ||
675 | * | ||
676 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | ||
677 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | ||
678 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | ||
679 | */ | ||
680 | |||
681 | /* additional mixers to alc880_asus_mixer */ | ||
682 | static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = { | ||
683 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), | ||
684 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | ||
685 | { } /* end */ | ||
686 | }; | ||
687 | |||
688 | |||
689 | /* | ||
690 | * build control elements | ||
479 | */ | 691 | */ |
480 | static int alc_build_controls(struct hda_codec *codec) | 692 | static int alc_build_controls(struct hda_codec *codec) |
481 | { | 693 | { |
@@ -502,227 +714,297 @@ static int alc_build_controls(struct hda_codec *codec) | |||
502 | return 0; | 714 | return 0; |
503 | } | 715 | } |
504 | 716 | ||
717 | |||
505 | /* | 718 | /* |
506 | * initialize the codec volumes, etc | 719 | * initialize the codec volumes, etc |
507 | */ | 720 | */ |
508 | 721 | ||
509 | static struct hda_verb alc880_init_verbs_three_stack[] = { | 722 | /* |
510 | /* Line In pin widget for input */ | 723 | * generic initialization of ADC, input mixers and output mixers |
511 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 724 | */ |
512 | /* CD pin widget for input */ | 725 | static struct hda_verb alc880_volume_init_verbs[] = { |
513 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 726 | /* |
514 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | 727 | * Unmute ADC0-2 and set the default input to mic-in |
515 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | 728 | */ |
516 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | 729 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
517 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | 730 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
518 | /* unmute amp left and right */ | 731 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
519 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | 732 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
520 | /* set connection select to line in (default select for this ADC) */ | 733 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
521 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x02}, | 734 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
522 | /* unmute front mixer amp left (volume = 0) */ | 735 | |
523 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 736 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
524 | /* mute pin widget amp left and right (no gain on this amp) */ | 737 | * mixer widget |
525 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
526 | /* unmute rear mixer amp left and right (volume = 0) */ | ||
527 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
528 | /* mute pin widget amp left and right (no gain on this amp) */ | ||
529 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
530 | /* unmute rear mixer amp left and right (volume = 0) */ | ||
531 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
532 | /* mute pin widget amp left and right (no gain on this amp) */ | ||
533 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
534 | |||
535 | /* using rear surround as the path for headphone output */ | ||
536 | /* unmute rear surround mixer amp left and right (volume = 0) */ | ||
537 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
538 | /* PASD 3 stack boards use the Mic 2 as the headphone output */ | ||
539 | /* need to program the selector associated with the Mic 2 pin widget to | ||
540 | * surround path (index 0x01) for headphone output */ | ||
541 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
542 | /* mute pin widget amp left and right (no gain on this amp) */ | ||
543 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
544 | /* need to retask the Mic 2 pin widget to output */ | ||
545 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | ||
546 | |||
547 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer widget(nid=0x0B) | ||
548 | * to support the input path of analog loopback | ||
549 | * Note: PASD motherboards uses the Line In 2 as the input for front panel | 738 | * Note: PASD motherboards uses the Line In 2 as the input for front panel |
550 | * mic (mic 2) | 739 | * mic (mic 2) |
551 | */ | 740 | */ |
552 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ | 741 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
553 | /* unmute CD */ | 742 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
554 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | 743 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
555 | /* unmute Line In */ | 744 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
556 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | 745 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
557 | /* unmute Mic 1 */ | 746 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
558 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 747 | |
559 | /* unmute Line In 2 (for PASD boards Mic 2) */ | 748 | /* |
560 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | 749 | * Set up output mixers (0x0c - 0x0f) |
561 | |||
562 | /* Unmute input amps for the line out paths to support the output path of | ||
563 | * analog loopback | ||
564 | * the mixers on the output path has 2 inputs, one from the DAC and one | ||
565 | * from the mixer | ||
566 | */ | 750 | */ |
567 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | 751 | /* set vol=0 to output mixers */ |
568 | /* Unmute Front out path */ | 752 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
569 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 753 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
570 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 754 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
571 | /* Unmute Surround (used as HP) out path */ | 755 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
572 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 756 | /* set up input amps for analog loopback */ |
573 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 757 | /* Amp Indices: DAC = 0, mixer = 1 */ |
574 | /* Unmute C/LFE out path */ | 758 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
575 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 759 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
576 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */ | 760 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
577 | /* Unmute rear Surround out path */ | 761 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
578 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 762 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
579 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 763 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
764 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
765 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
580 | 766 | ||
581 | { } | 767 | { } |
582 | }; | 768 | }; |
583 | 769 | ||
584 | static struct hda_verb alc880_init_verbs_five_stack[] = { | 770 | /* |
585 | /* Line In pin widget for input */ | 771 | * 3-stack pin configuration: |
586 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 772 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b |
587 | /* CD pin widget for input */ | 773 | */ |
588 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 774 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { |
589 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | 775 | /* |
590 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | 776 | * preset connection lists of input pins |
591 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | 777 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
592 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | ||
593 | /* unmute amp left and right */ | ||
594 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | ||
595 | /* set connection select to line in (default select for this ADC) */ | ||
596 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
597 | /* unmute front mixer amp left and right (volume = 0) */ | ||
598 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
599 | /* mute pin widget amp left and right (no gain on this amp) */ | ||
600 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
601 | /* five rear and clfe */ | ||
602 | /* unmute rear mixer amp left and right (volume = 0) */ | ||
603 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
604 | /* mute pin widget amp left and right (no gain on this amp) */ | ||
605 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
606 | /* unmute clfe mixer amp left and right (volume = 0) */ | ||
607 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
608 | /* mute pin widget amp left and right (no gain on this amp) */ | ||
609 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
610 | |||
611 | /* using rear surround as the path for headphone output */ | ||
612 | /* unmute rear surround mixer amp left and right (volume = 0) */ | ||
613 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | ||
614 | /* PASD 3 stack boards use the Mic 2 as the headphone output */ | ||
615 | /* need to program the selector associated with the Mic 2 pin widget to | ||
616 | * surround path (index 0x01) for headphone output | ||
617 | */ | ||
618 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
619 | /* mute pin widget amp left and right (no gain on this amp) */ | ||
620 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
621 | /* need to retask the Mic 2 pin widget to output */ | ||
622 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | ||
623 | |||
624 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer | ||
625 | * widget(nid=0x0B) to support the input path of analog loopback | ||
626 | */ | 778 | */ |
627 | /* Note: PASD motherboards uses the Line In 2 as the input for front panel mic (mic 2) */ | 779 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
628 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03*/ | 780 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
629 | /* unmute CD */ | 781 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ |
630 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | 782 | |
631 | /* unmute Line In */ | 783 | /* |
632 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | 784 | * Set pin mode and muting |
633 | /* unmute Mic 1 */ | ||
634 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | ||
635 | /* unmute Line In 2 (for PASD boards Mic 2) */ | ||
636 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | ||
637 | |||
638 | /* Unmute input amps for the line out paths to support the output path of | ||
639 | * analog loopback | ||
640 | * the mixers on the output path has 2 inputs, one from the DAC and | ||
641 | * one from the mixer | ||
642 | */ | 785 | */ |
643 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | 786 | /* set front pin widgets 0x14 for output */ |
644 | /* Unmute Front out path */ | 787 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
645 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 788 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
646 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 789 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
647 | /* Unmute Surround (used as HP) out path */ | 790 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
648 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 791 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
649 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 792 | /* Mic2 (as headphone out) for HP output */ |
650 | /* Unmute C/LFE out path */ | 793 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
651 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 794 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
652 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */ | 795 | /* Line In pin widget for input */ |
653 | /* Unmute rear Surround out path */ | 796 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
654 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 797 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
655 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 798 | /* Line2 (as front mic) pin widget for input and vref at 80% */ |
799 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
800 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
801 | /* CD pin widget for input */ | ||
802 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
656 | 803 | ||
657 | { } | 804 | { } |
658 | }; | 805 | }; |
659 | 806 | ||
660 | static struct hda_verb alc880_w810_init_verbs[] = { | 807 | /* |
661 | /* front channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ | 808 | * 5-stack pin configuration: |
662 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | 809 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, |
663 | 810 | * line-in/side = 0x1a, f-mic = 0x1b | |
664 | /* front channel selector/amp: input 1: capture mix: muted, (no volume selection) */ | 811 | */ |
665 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, | 812 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { |
666 | 813 | /* | |
667 | /* front channel selector/amp: output 0: unmuted, max volume */ | 814 | * preset connection lists of input pins |
668 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 815 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround |
669 | 816 | */ | |
670 | /* front out pin: muted, (no volume selection) */ | 817 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
671 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 818 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ |
672 | |||
673 | /* front out pin: NOT headphone enable, out enable, vref disabled */ | ||
674 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | ||
675 | 819 | ||
820 | /* | ||
821 | * Set pin mode and muting | ||
822 | */ | ||
823 | /* set pin widgets 0x14-0x17 for output */ | ||
824 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
825 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
826 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
827 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
828 | /* unmute pins for output (no gain on this amp) */ | ||
829 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
830 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
831 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
832 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
676 | 833 | ||
677 | /* surround channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ | 834 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
678 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | 835 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
836 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
837 | /* Mic2 (as headphone out) for HP output */ | ||
838 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
839 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
840 | /* Line In pin widget for input */ | ||
841 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
842 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
843 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | ||
844 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
845 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
846 | /* CD pin widget for input */ | ||
847 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
679 | 848 | ||
680 | /* surround channel selector/amp: input 1: capture mix: muted, (no volume selection) */ | 849 | { } |
681 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, | 850 | }; |
682 | 851 | ||
683 | /* surround channel selector/amp: output 0: unmuted, max volume */ | 852 | /* |
684 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 853 | * W810 pin configuration: |
854 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | ||
855 | */ | ||
856 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | ||
857 | /* hphone/speaker input selector: front DAC */ | ||
858 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
685 | 859 | ||
686 | /* surround out pin: muted, (no volume selection) */ | 860 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
687 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 861 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
862 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
863 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
864 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
865 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
688 | 866 | ||
689 | /* surround out pin: NOT headphone enable, out enable, vref disabled */ | 867 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
690 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 868 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
691 | 869 | ||
870 | { } | ||
871 | }; | ||
692 | 872 | ||
693 | /* c/lfe channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ | 873 | /* |
694 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | 874 | * Z71V pin configuration: |
875 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | ||
876 | */ | ||
877 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | ||
878 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
879 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
880 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
881 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
695 | 882 | ||
696 | /* c/lfe channel selector/amp: input 1: capture mix: muted, (no volume selection) */ | 883 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
697 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, | 884 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
885 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
886 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
698 | 887 | ||
699 | /* c/lfe channel selector/amp: output 0: unmuted, max volume */ | 888 | { } |
700 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 889 | }; |
701 | 890 | ||
702 | /* c/lfe out pin: muted, (no volume selection) */ | 891 | /* |
703 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 892 | * 6-stack pin configuration: |
893 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19, | ||
894 | * line = 0x1a, HP = 0x1b | ||
895 | */ | ||
896 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | ||
897 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | ||
898 | |||
899 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
900 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
901 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
902 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
903 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
904 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
905 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
906 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
907 | |||
908 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
909 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
910 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
911 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
912 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
913 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
914 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
915 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
916 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
917 | |||
918 | { } | ||
919 | }; | ||
704 | 920 | ||
705 | /* c/lfe out pin: NOT headphone enable, out enable, vref disabled */ | 921 | /* FIXME! */ |
706 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 922 | /* |
923 | * F1734 pin configuration: | ||
924 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | ||
925 | */ | ||
926 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | ||
927 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
928 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
929 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
930 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
931 | |||
932 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
933 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
934 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
935 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
936 | |||
937 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
938 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
939 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
940 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
941 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
942 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
943 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
944 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
945 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
707 | 946 | ||
947 | { } | ||
948 | }; | ||
708 | 949 | ||
709 | /* hphone/speaker input selector: front DAC */ | 950 | /* FIXME! */ |
710 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | 951 | /* |
952 | * ASUS pin configuration: | ||
953 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | ||
954 | */ | ||
955 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | ||
956 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
957 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
958 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
959 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
960 | |||
961 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
962 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
963 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
964 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
965 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
966 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
967 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
968 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
969 | |||
970 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
971 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
972 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
973 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
974 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
975 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
976 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
977 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
978 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
979 | |||
980 | { } | ||
981 | }; | ||
711 | 982 | ||
712 | /* hphone/speaker out pin: muted, (no volume selection) */ | 983 | /* Enable GPIO mask and set output */ |
713 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 984 | static struct hda_verb alc880_gpio1_init_verbs[] = { |
985 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | ||
986 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | ||
987 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | ||
988 | }; | ||
714 | 989 | ||
715 | /* hphone/speaker out pin: NOT headphone enable, out enable, vref disabled */ | 990 | /* Enable GPIO mask and set output */ |
716 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 991 | static struct hda_verb alc880_gpio2_init_verbs[] = { |
992 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | ||
993 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | ||
994 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | ||
995 | }; | ||
717 | 996 | ||
718 | 997 | ||
719 | { } | 998 | /* |
720 | }; | 999 | */ |
721 | 1000 | ||
722 | static int alc_init(struct hda_codec *codec) | 1001 | static int alc_init(struct hda_codec *codec) |
723 | { | 1002 | { |
724 | struct alc_spec *spec = codec->spec; | 1003 | struct alc_spec *spec = codec->spec; |
725 | snd_hda_sequence_write(codec, spec->init_verbs); | 1004 | unsigned int i; |
1005 | |||
1006 | for (i = 0; i < spec->num_init_verbs; i++) | ||
1007 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | ||
726 | return 0; | 1008 | return 0; |
727 | } | 1009 | } |
728 | 1010 | ||
@@ -736,9 +1018,8 @@ static int alc_resume(struct hda_codec *codec) | |||
736 | int i; | 1018 | int i; |
737 | 1019 | ||
738 | alc_init(codec); | 1020 | alc_init(codec); |
739 | for (i = 0; i < spec->num_mixers; i++) { | 1021 | for (i = 0; i < spec->num_mixers; i++) |
740 | snd_hda_resume_ctls(codec, spec->mixers[i]); | 1022 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
741 | } | ||
742 | if (spec->multiout.dig_out_nid) | 1023 | if (spec->multiout.dig_out_nid) |
743 | snd_hda_resume_spdif_out(codec); | 1024 | snd_hda_resume_spdif_out(codec); |
744 | if (spec->dig_in_nid) | 1025 | if (spec->dig_in_nid) |
@@ -830,7 +1111,7 @@ static struct hda_pcm_stream alc880_pcm_analog_playback = { | |||
830 | .substreams = 1, | 1111 | .substreams = 1, |
831 | .channels_min = 2, | 1112 | .channels_min = 2, |
832 | .channels_max = 8, | 1113 | .channels_max = 8, |
833 | .nid = 0x02, /* NID to query formats and rates */ | 1114 | /* NID is set in alc_build_pcms */ |
834 | .ops = { | 1115 | .ops = { |
835 | .open = alc880_playback_pcm_open, | 1116 | .open = alc880_playback_pcm_open, |
836 | .prepare = alc880_playback_pcm_prepare, | 1117 | .prepare = alc880_playback_pcm_prepare, |
@@ -842,7 +1123,7 @@ static struct hda_pcm_stream alc880_pcm_analog_capture = { | |||
842 | .substreams = 2, | 1123 | .substreams = 2, |
843 | .channels_min = 2, | 1124 | .channels_min = 2, |
844 | .channels_max = 2, | 1125 | .channels_max = 2, |
845 | .nid = 0x07, /* NID to query formats and rates */ | 1126 | /* NID is set in alc_build_pcms */ |
846 | .ops = { | 1127 | .ops = { |
847 | .prepare = alc880_capture_pcm_prepare, | 1128 | .prepare = alc880_capture_pcm_prepare, |
848 | .cleanup = alc880_capture_pcm_cleanup | 1129 | .cleanup = alc880_capture_pcm_cleanup |
@@ -878,7 +1159,9 @@ static int alc_build_pcms(struct hda_codec *codec) | |||
878 | 1159 | ||
879 | info->name = spec->stream_name_analog; | 1160 | info->name = spec->stream_name_analog; |
880 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); | 1161 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
1162 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | ||
881 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); | 1163 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
1164 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | ||
882 | 1165 | ||
883 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | 1166 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
884 | for (i = 0; i < spec->num_channel_mode; i++) { | 1167 | for (i = 0; i < spec->num_channel_mode; i++) { |
@@ -906,7 +1189,18 @@ static int alc_build_pcms(struct hda_codec *codec) | |||
906 | 1189 | ||
907 | static void alc_free(struct hda_codec *codec) | 1190 | static void alc_free(struct hda_codec *codec) |
908 | { | 1191 | { |
909 | kfree(codec->spec); | 1192 | struct alc_spec *spec = codec->spec; |
1193 | unsigned int i; | ||
1194 | |||
1195 | if (! spec) | ||
1196 | return; | ||
1197 | |||
1198 | if (spec->kctl_alloc) { | ||
1199 | for (i = 0; i < spec->num_kctl_used; i++) | ||
1200 | kfree(spec->kctl_alloc[i].name); | ||
1201 | kfree(spec->kctl_alloc); | ||
1202 | } | ||
1203 | kfree(spec); | ||
910 | } | 1204 | } |
911 | 1205 | ||
912 | /* | 1206 | /* |
@@ -921,153 +1215,915 @@ static struct hda_codec_ops alc_patch_ops = { | |||
921 | #endif | 1215 | #endif |
922 | }; | 1216 | }; |
923 | 1217 | ||
1218 | |||
1219 | /* | ||
1220 | * Test configuration for debugging | ||
1221 | * | ||
1222 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | ||
1223 | * enum controls. | ||
1224 | */ | ||
1225 | #ifdef CONFIG_SND_DEBUG | ||
1226 | static hda_nid_t alc880_test_dac_nids[4] = { | ||
1227 | 0x02, 0x03, 0x04, 0x05 | ||
1228 | }; | ||
1229 | |||
1230 | static struct hda_input_mux alc880_test_capture_source = { | ||
1231 | .num_items = 5, | ||
1232 | .items = { | ||
1233 | { "In-1", 0x0 }, | ||
1234 | { "In-2", 0x1 }, | ||
1235 | { "In-3", 0x2 }, | ||
1236 | { "In-4", 0x3 }, | ||
1237 | { "CD", 0x4 }, | ||
1238 | }, | ||
1239 | }; | ||
1240 | |||
1241 | static struct alc_channel_mode alc880_test_modes[4] = { | ||
1242 | { 2, NULL }, | ||
1243 | { 4, NULL }, | ||
1244 | { 6, NULL }, | ||
1245 | { 8, NULL }, | ||
1246 | }; | ||
1247 | |||
1248 | static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
1249 | { | ||
1250 | static char *texts[] = { | ||
1251 | "N/A", "Line Out", "HP Out", | ||
1252 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | ||
1253 | }; | ||
1254 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1255 | uinfo->count = 1; | ||
1256 | uinfo->value.enumerated.items = 8; | ||
1257 | if (uinfo->value.enumerated.item >= 8) | ||
1258 | uinfo->value.enumerated.item = 7; | ||
1259 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
1260 | return 0; | ||
1261 | } | ||
1262 | |||
1263 | static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
1264 | { | ||
1265 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1266 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | ||
1267 | unsigned int pin_ctl, item = 0; | ||
1268 | |||
1269 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | ||
1270 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
1271 | if (pin_ctl & AC_PINCTL_OUT_EN) { | ||
1272 | if (pin_ctl & AC_PINCTL_HP_EN) | ||
1273 | item = 2; | ||
1274 | else | ||
1275 | item = 1; | ||
1276 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | ||
1277 | switch (pin_ctl & AC_PINCTL_VREFEN) { | ||
1278 | case AC_PINCTL_VREF_HIZ: item = 3; break; | ||
1279 | case AC_PINCTL_VREF_50: item = 4; break; | ||
1280 | case AC_PINCTL_VREF_GRD: item = 5; break; | ||
1281 | case AC_PINCTL_VREF_80: item = 6; break; | ||
1282 | case AC_PINCTL_VREF_100: item = 7; break; | ||
1283 | } | ||
1284 | } | ||
1285 | ucontrol->value.enumerated.item[0] = item; | ||
1286 | return 0; | ||
1287 | } | ||
1288 | |||
1289 | static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
1290 | { | ||
1291 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1292 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | ||
1293 | static unsigned int ctls[] = { | ||
1294 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | ||
1295 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | ||
1296 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | ||
1297 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | ||
1298 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | ||
1299 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | ||
1300 | }; | ||
1301 | unsigned int old_ctl, new_ctl; | ||
1302 | |||
1303 | old_ctl = snd_hda_codec_read(codec, nid, 0, | ||
1304 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
1305 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | ||
1306 | if (old_ctl != new_ctl) { | ||
1307 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); | ||
1308 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
1309 | ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000); | ||
1310 | return 1; | ||
1311 | } | ||
1312 | return 0; | ||
1313 | } | ||
1314 | |||
1315 | static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
1316 | { | ||
1317 | static char *texts[] = { | ||
1318 | "Front", "Surround", "CLFE", "Side" | ||
1319 | }; | ||
1320 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1321 | uinfo->count = 1; | ||
1322 | uinfo->value.enumerated.items = 4; | ||
1323 | if (uinfo->value.enumerated.item >= 4) | ||
1324 | uinfo->value.enumerated.item = 3; | ||
1325 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
1326 | return 0; | ||
1327 | } | ||
1328 | |||
1329 | static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
1330 | { | ||
1331 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1332 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | ||
1333 | unsigned int sel; | ||
1334 | |||
1335 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | ||
1336 | ucontrol->value.enumerated.item[0] = sel & 3; | ||
1337 | return 0; | ||
1338 | } | ||
1339 | |||
1340 | static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
1341 | { | ||
1342 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1343 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | ||
1344 | unsigned int sel; | ||
1345 | |||
1346 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | ||
1347 | if (ucontrol->value.enumerated.item[0] != sel) { | ||
1348 | sel = ucontrol->value.enumerated.item[0] & 3; | ||
1349 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); | ||
1350 | return 1; | ||
1351 | } | ||
1352 | return 0; | ||
1353 | } | ||
1354 | |||
1355 | #define PIN_CTL_TEST(xname,nid) { \ | ||
1356 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1357 | .name = xname, \ | ||
1358 | .info = alc_test_pin_ctl_info, \ | ||
1359 | .get = alc_test_pin_ctl_get, \ | ||
1360 | .put = alc_test_pin_ctl_put, \ | ||
1361 | .private_value = nid \ | ||
1362 | } | ||
1363 | |||
1364 | #define PIN_SRC_TEST(xname,nid) { \ | ||
1365 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1366 | .name = xname, \ | ||
1367 | .info = alc_test_pin_src_info, \ | ||
1368 | .get = alc_test_pin_src_get, \ | ||
1369 | .put = alc_test_pin_src_put, \ | ||
1370 | .private_value = nid \ | ||
1371 | } | ||
1372 | |||
1373 | static snd_kcontrol_new_t alc880_test_mixer[] = { | ||
1374 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
1375 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
1376 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | ||
1377 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | ||
1378 | ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
1379 | ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | ||
1380 | ALC_BIND_MUTE("CLFE Playback Volume", 0x0e, 2, HDA_INPUT), | ||
1381 | ALC_BIND_MUTE("Side Playback Volume", 0x0f, 2, HDA_INPUT), | ||
1382 | PIN_CTL_TEST("Front Pin Mode", 0x14), | ||
1383 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | ||
1384 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | ||
1385 | PIN_CTL_TEST("Side Pin Mode", 0x17), | ||
1386 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | ||
1387 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | ||
1388 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | ||
1389 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | ||
1390 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | ||
1391 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | ||
1392 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | ||
1393 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | ||
1394 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
1395 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
1396 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | ||
1397 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | ||
1398 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | ||
1399 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | ||
1400 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | ||
1401 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | ||
1402 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | ||
1403 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | ||
1404 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | ||
1405 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | ||
1406 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), | ||
1407 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), | ||
1408 | { | ||
1409 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1410 | .name = "Input Source", | ||
1411 | .count = 2, | ||
1412 | .info = alc_mux_enum_info, | ||
1413 | .get = alc_mux_enum_get, | ||
1414 | .put = alc_mux_enum_put, | ||
1415 | }, | ||
1416 | { | ||
1417 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1418 | .name = "Channel Mode", | ||
1419 | .info = alc880_ch_mode_info, | ||
1420 | .get = alc880_ch_mode_get, | ||
1421 | .put = alc880_ch_mode_put, | ||
1422 | }, | ||
1423 | { } /* end */ | ||
1424 | }; | ||
1425 | |||
1426 | static struct hda_verb alc880_test_init_verbs[] = { | ||
1427 | /* Unmute inputs of 0x0c - 0x0f */ | ||
1428 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
1429 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
1430 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
1431 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
1432 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
1433 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
1434 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
1435 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
1436 | /* Vol output for 0x0c-0x0f */ | ||
1437 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
1438 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
1439 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
1440 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
1441 | /* Set output pins 0x14-0x17 */ | ||
1442 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
1443 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
1444 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
1445 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
1446 | /* Unmute output pins 0x14-0x17 */ | ||
1447 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1448 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1449 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1450 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1451 | /* Set input pins 0x18-0x1c */ | ||
1452 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
1453 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
1454 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
1455 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
1456 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
1457 | /* Mute input pins 0x18-0x1b */ | ||
1458 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
1459 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
1460 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
1461 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
1462 | /* ADC set up */ | ||
1463 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
1464 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
1465 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
1466 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
1467 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
1468 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
1469 | /* Analog input/passthru */ | ||
1470 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
1471 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
1472 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
1473 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
1474 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
1475 | { } | ||
1476 | }; | ||
1477 | #endif | ||
1478 | |||
924 | /* | 1479 | /* |
925 | */ | 1480 | */ |
926 | 1481 | ||
927 | static struct hda_board_config alc880_cfg_tbl[] = { | 1482 | static struct hda_board_config alc880_cfg_tbl[] = { |
928 | /* Back 3 jack, front 2 jack */ | 1483 | /* Back 3 jack, front 2 jack */ |
929 | { .modelname = "3stack", .config = ALC880_3ST }, | 1484 | { .modelname = "3stack", .config = ALC880_3ST }, |
930 | { .pci_vendor = 0x8086, .pci_device = 0xe200, .config = ALC880_3ST }, | 1485 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST }, |
931 | { .pci_vendor = 0x8086, .pci_device = 0xe201, .config = ALC880_3ST }, | 1486 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST }, |
932 | { .pci_vendor = 0x8086, .pci_device = 0xe202, .config = ALC880_3ST }, | 1487 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST }, |
933 | { .pci_vendor = 0x8086, .pci_device = 0xe203, .config = ALC880_3ST }, | 1488 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST }, |
934 | { .pci_vendor = 0x8086, .pci_device = 0xe204, .config = ALC880_3ST }, | 1489 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST }, |
935 | { .pci_vendor = 0x8086, .pci_device = 0xe205, .config = ALC880_3ST }, | 1490 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST }, |
936 | { .pci_vendor = 0x8086, .pci_device = 0xe206, .config = ALC880_3ST }, | 1491 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST }, |
937 | { .pci_vendor = 0x8086, .pci_device = 0xe207, .config = ALC880_3ST }, | 1492 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST }, |
938 | { .pci_vendor = 0x8086, .pci_device = 0xe208, .config = ALC880_3ST }, | 1493 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST }, |
939 | { .pci_vendor = 0x8086, .pci_device = 0xe209, .config = ALC880_3ST }, | 1494 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST }, |
940 | { .pci_vendor = 0x8086, .pci_device = 0xe20a, .config = ALC880_3ST }, | 1495 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST }, |
941 | { .pci_vendor = 0x8086, .pci_device = 0xe20b, .config = ALC880_3ST }, | 1496 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST }, |
942 | { .pci_vendor = 0x8086, .pci_device = 0xe20c, .config = ALC880_3ST }, | 1497 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST }, |
943 | { .pci_vendor = 0x8086, .pci_device = 0xe20d, .config = ALC880_3ST }, | 1498 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST }, |
944 | { .pci_vendor = 0x8086, .pci_device = 0xe20e, .config = ALC880_3ST }, | 1499 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST }, |
945 | { .pci_vendor = 0x8086, .pci_device = 0xe20f, .config = ALC880_3ST }, | 1500 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST }, |
946 | { .pci_vendor = 0x8086, .pci_device = 0xe210, .config = ALC880_3ST }, | 1501 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST }, |
947 | { .pci_vendor = 0x8086, .pci_device = 0xe211, .config = ALC880_3ST }, | 1502 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST }, |
948 | { .pci_vendor = 0x8086, .pci_device = 0xe214, .config = ALC880_3ST }, | 1503 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST }, |
949 | { .pci_vendor = 0x8086, .pci_device = 0xe302, .config = ALC880_3ST }, | 1504 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST }, |
950 | { .pci_vendor = 0x8086, .pci_device = 0xe303, .config = ALC880_3ST }, | 1505 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST }, |
951 | { .pci_vendor = 0x8086, .pci_device = 0xe304, .config = ALC880_3ST }, | 1506 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST }, |
952 | { .pci_vendor = 0x8086, .pci_device = 0xe306, .config = ALC880_3ST }, | 1507 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST }, |
953 | { .pci_vendor = 0x8086, .pci_device = 0xe307, .config = ALC880_3ST }, | 1508 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST }, |
954 | { .pci_vendor = 0x8086, .pci_device = 0xe404, .config = ALC880_3ST }, | 1509 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST }, |
955 | { .pci_vendor = 0x8086, .pci_device = 0xa101, .config = ALC880_3ST }, | 1510 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST }, |
956 | { .pci_vendor = 0x107b, .pci_device = 0x3031, .config = ALC880_3ST }, | 1511 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST }, |
957 | { .pci_vendor = 0x107b, .pci_device = 0x4036, .config = ALC880_3ST }, | 1512 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST }, |
958 | { .pci_vendor = 0x107b, .pci_device = 0x4037, .config = ALC880_3ST }, | 1513 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST }, |
959 | { .pci_vendor = 0x107b, .pci_device = 0x4038, .config = ALC880_3ST }, | 1514 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST }, |
960 | { .pci_vendor = 0x107b, .pci_device = 0x4040, .config = ALC880_3ST }, | 1515 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST }, |
961 | { .pci_vendor = 0x107b, .pci_device = 0x4041, .config = ALC880_3ST }, | 1516 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST }, |
962 | 1517 | ||
963 | /* Back 3 jack, front 2 jack (Internal add Aux-In) */ | 1518 | /* Back 3 jack, front 2 jack (Internal add Aux-In) */ |
964 | { .pci_vendor = 0x1025, .pci_device = 0xe310, .config = ALC880_3ST }, | 1519 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, |
1520 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, | ||
965 | 1521 | ||
966 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ | 1522 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ |
967 | { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, | 1523 | { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, |
968 | { .pci_vendor = 0x8086, .pci_device = 0xe308, .config = ALC880_3ST_DIG }, | 1524 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG }, |
969 | 1525 | ||
970 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ | 1526 | /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ |
971 | { .pci_vendor = 0x8086, .pci_device = 0xe305, .config = ALC880_3ST_DIG }, | 1527 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG }, |
972 | { .pci_vendor = 0x8086, .pci_device = 0xd402, .config = ALC880_3ST_DIG }, | 1528 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG }, |
973 | { .pci_vendor = 0x1025, .pci_device = 0xe309, .config = ALC880_3ST_DIG }, | 1529 | { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG }, |
974 | 1530 | ||
975 | /* Back 5 jack, front 2 jack */ | 1531 | /* Back 5 jack, front 2 jack */ |
976 | { .modelname = "5stack", .config = ALC880_5ST }, | 1532 | { .modelname = "5stack", .config = ALC880_5ST }, |
977 | { .pci_vendor = 0x107b, .pci_device = 0x3033, .config = ALC880_5ST }, | 1533 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST }, |
978 | { .pci_vendor = 0x107b, .pci_device = 0x4039, .config = ALC880_5ST }, | 1534 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST }, |
979 | { .pci_vendor = 0x107b, .pci_device = 0x3032, .config = ALC880_5ST }, | 1535 | { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST }, |
980 | { .pci_vendor = 0x103c, .pci_device = 0x2a09, .config = ALC880_5ST }, | 1536 | { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST }, |
1537 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST }, | ||
981 | 1538 | ||
982 | /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ | 1539 | /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ |
983 | { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, | 1540 | { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, |
984 | { .pci_vendor = 0x8086, .pci_device = 0xe224, .config = ALC880_5ST_DIG }, | 1541 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG }, |
985 | { .pci_vendor = 0x8086, .pci_device = 0xe400, .config = ALC880_5ST_DIG }, | 1542 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG }, |
986 | { .pci_vendor = 0x8086, .pci_device = 0xe401, .config = ALC880_5ST_DIG }, | 1543 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG }, |
987 | { .pci_vendor = 0x8086, .pci_device = 0xe402, .config = ALC880_5ST_DIG }, | 1544 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG }, |
988 | { .pci_vendor = 0x8086, .pci_device = 0xd400, .config = ALC880_5ST_DIG }, | 1545 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG }, |
989 | { .pci_vendor = 0x8086, .pci_device = 0xd401, .config = ALC880_5ST_DIG }, | 1546 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG }, |
990 | { .pci_vendor = 0x8086, .pci_device = 0xa100, .config = ALC880_5ST_DIG }, | 1547 | { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, |
991 | { .pci_vendor = 0x1565, .pci_device = 0x8202, .config = ALC880_5ST_DIG }, | 1548 | { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, |
1549 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, | ||
1550 | { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, | ||
1551 | { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, | ||
1552 | { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, | ||
992 | 1553 | ||
993 | { .modelname = "w810", .config = ALC880_W810 }, | 1554 | { .modelname = "w810", .config = ALC880_W810 }, |
994 | { .pci_vendor = 0x161f, .pci_device = 0x203d, .config = ALC880_W810 }, | 1555 | { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 }, |
1556 | |||
1557 | { .modelname = "z71v", .config = ALC880_Z71V }, | ||
1558 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, | ||
1559 | |||
1560 | { .modelname = "6statack-digout", .config = ALC880_6ST_DIG }, | ||
1561 | { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, | ||
1562 | { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, | ||
1563 | { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, | ||
1564 | { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG }, | ||
1565 | |||
1566 | { .modelname = "asus", .config = ALC880_ASUS }, | ||
1567 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, | ||
1568 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, | ||
1569 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, | ||
1570 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, | ||
1571 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, | ||
1572 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, | ||
1573 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, | ||
1574 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, | ||
1575 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, | ||
1576 | { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, | ||
1577 | |||
1578 | { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, | ||
1579 | { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, | ||
1580 | |||
1581 | { .modelname = "F1734", .config = ALC880_F1734 }, | ||
1582 | { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, | ||
1583 | |||
1584 | #ifdef CONFIG_SND_DEBUG | ||
1585 | { .modelname = "test", .config = ALC880_TEST }, | ||
1586 | #endif | ||
995 | 1587 | ||
996 | {} | 1588 | {} |
997 | }; | 1589 | }; |
998 | 1590 | ||
1591 | /* | ||
1592 | * configuration template - to be copied to the spec instance | ||
1593 | */ | ||
1594 | struct alc_config_preset { | ||
1595 | snd_kcontrol_new_t *mixers[4]; | ||
1596 | const struct hda_verb *init_verbs[4]; | ||
1597 | unsigned int num_dacs; | ||
1598 | hda_nid_t *dac_nids; | ||
1599 | hda_nid_t dig_out_nid; /* optional */ | ||
1600 | hda_nid_t hp_nid; /* optional */ | ||
1601 | unsigned int num_adc_nids; | ||
1602 | hda_nid_t *adc_nids; | ||
1603 | unsigned int num_channel_mode; | ||
1604 | const struct alc_channel_mode *channel_mode; | ||
1605 | const struct hda_input_mux *input_mux; | ||
1606 | }; | ||
1607 | |||
1608 | static struct alc_config_preset alc880_presets[] = { | ||
1609 | [ALC880_3ST] = { | ||
1610 | .mixers = { alc880_three_stack_mixer }, | ||
1611 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, | ||
1612 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | ||
1613 | .dac_nids = alc880_dac_nids, | ||
1614 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
1615 | .channel_mode = alc880_threestack_modes, | ||
1616 | .input_mux = &alc880_capture_source, | ||
1617 | }, | ||
1618 | [ALC880_3ST_DIG] = { | ||
1619 | .mixers = { alc880_three_stack_mixer }, | ||
1620 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, | ||
1621 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | ||
1622 | .dac_nids = alc880_dac_nids, | ||
1623 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1624 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
1625 | .channel_mode = alc880_threestack_modes, | ||
1626 | .input_mux = &alc880_capture_source, | ||
1627 | }, | ||
1628 | [ALC880_5ST] = { | ||
1629 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, | ||
1630 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, | ||
1631 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | ||
1632 | .dac_nids = alc880_dac_nids, | ||
1633 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), | ||
1634 | .channel_mode = alc880_fivestack_modes, | ||
1635 | .input_mux = &alc880_capture_source, | ||
1636 | }, | ||
1637 | [ALC880_5ST_DIG] = { | ||
1638 | .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, | ||
1639 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, | ||
1640 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | ||
1641 | .dac_nids = alc880_dac_nids, | ||
1642 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1643 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), | ||
1644 | .channel_mode = alc880_fivestack_modes, | ||
1645 | .input_mux = &alc880_capture_source, | ||
1646 | }, | ||
1647 | [ALC880_6ST_DIG] = { | ||
1648 | .mixers = { alc880_six_stack_mixer }, | ||
1649 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, | ||
1650 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), | ||
1651 | .dac_nids = alc880_6st_dac_nids, | ||
1652 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1653 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | ||
1654 | .channel_mode = alc880_sixstack_modes, | ||
1655 | .input_mux = &alc880_6stack_capture_source, | ||
1656 | }, | ||
1657 | [ALC880_W810] = { | ||
1658 | .mixers = { alc880_w810_base_mixer }, | ||
1659 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs }, | ||
1660 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), | ||
1661 | .dac_nids = alc880_w810_dac_nids, | ||
1662 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1663 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | ||
1664 | .channel_mode = alc880_w810_modes, | ||
1665 | .input_mux = &alc880_capture_source, | ||
1666 | }, | ||
1667 | [ALC880_Z71V] = { | ||
1668 | .mixers = { alc880_z71v_mixer }, | ||
1669 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs, | ||
1670 | alc880_gpio2_init_verbs }, | ||
1671 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), | ||
1672 | .dac_nids = alc880_z71v_dac_nids, | ||
1673 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1674 | .hp_nid = 0x03, | ||
1675 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | ||
1676 | .channel_mode = alc880_2_jack_modes, | ||
1677 | .input_mux = &alc880_capture_source, | ||
1678 | }, | ||
1679 | [ALC880_F1734] = { | ||
1680 | .mixers = { alc880_f1734_mixer }, | ||
1681 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, | ||
1682 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), | ||
1683 | .dac_nids = alc880_f1734_dac_nids, | ||
1684 | .hp_nid = 0x02, | ||
1685 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | ||
1686 | .channel_mode = alc880_2_jack_modes, | ||
1687 | .input_mux = &alc880_capture_source, | ||
1688 | }, | ||
1689 | [ALC880_ASUS] = { | ||
1690 | .mixers = { alc880_asus_mixer }, | ||
1691 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, | ||
1692 | alc880_gpio1_init_verbs }, | ||
1693 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | ||
1694 | .dac_nids = alc880_asus_dac_nids, | ||
1695 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | ||
1696 | .channel_mode = alc880_asus_modes, | ||
1697 | .input_mux = &alc880_capture_source, | ||
1698 | }, | ||
1699 | [ALC880_ASUS_DIG] = { | ||
1700 | .mixers = { alc880_asus_mixer }, | ||
1701 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, | ||
1702 | alc880_gpio1_init_verbs }, | ||
1703 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | ||
1704 | .dac_nids = alc880_asus_dac_nids, | ||
1705 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1706 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | ||
1707 | .channel_mode = alc880_asus_modes, | ||
1708 | .input_mux = &alc880_capture_source, | ||
1709 | }, | ||
1710 | [ALC880_ASUS_W1V] = { | ||
1711 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, | ||
1712 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, | ||
1713 | alc880_gpio1_init_verbs }, | ||
1714 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | ||
1715 | .dac_nids = alc880_asus_dac_nids, | ||
1716 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1717 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | ||
1718 | .channel_mode = alc880_asus_modes, | ||
1719 | .input_mux = &alc880_capture_source, | ||
1720 | }, | ||
1721 | [ALC880_UNIWILL_DIG] = { | ||
1722 | .mixers = { alc880_asus_mixer }, | ||
1723 | .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs }, | ||
1724 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | ||
1725 | .dac_nids = alc880_asus_dac_nids, | ||
1726 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1727 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | ||
1728 | .channel_mode = alc880_asus_modes, | ||
1729 | .input_mux = &alc880_capture_source, | ||
1730 | }, | ||
1731 | #ifdef CONFIG_SND_DEBUG | ||
1732 | [ALC880_TEST] = { | ||
1733 | .mixers = { alc880_test_mixer }, | ||
1734 | .init_verbs = { alc880_test_init_verbs }, | ||
1735 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), | ||
1736 | .dac_nids = alc880_test_dac_nids, | ||
1737 | .dig_out_nid = ALC880_DIGOUT_NID, | ||
1738 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), | ||
1739 | .channel_mode = alc880_test_modes, | ||
1740 | .input_mux = &alc880_test_capture_source, | ||
1741 | }, | ||
1742 | #endif | ||
1743 | }; | ||
1744 | |||
1745 | /* | ||
1746 | * Automatic parse of I/O pins from the BIOS configuration | ||
1747 | */ | ||
1748 | |||
1749 | #define NUM_CONTROL_ALLOC 32 | ||
1750 | #define NUM_VERB_ALLOC 32 | ||
1751 | |||
1752 | enum { | ||
1753 | ALC_CTL_WIDGET_VOL, | ||
1754 | ALC_CTL_WIDGET_MUTE, | ||
1755 | ALC_CTL_BIND_MUTE, | ||
1756 | }; | ||
1757 | static snd_kcontrol_new_t alc880_control_templates[] = { | ||
1758 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), | ||
1759 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | ||
1760 | ALC_BIND_MUTE(NULL, 0, 0, 0), | ||
1761 | }; | ||
1762 | |||
1763 | /* add dynamic controls */ | ||
1764 | static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) | ||
1765 | { | ||
1766 | snd_kcontrol_new_t *knew; | ||
1767 | |||
1768 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { | ||
1769 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; | ||
1770 | |||
1771 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ | ||
1772 | if (! knew) | ||
1773 | return -ENOMEM; | ||
1774 | if (spec->kctl_alloc) { | ||
1775 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); | ||
1776 | kfree(spec->kctl_alloc); | ||
1777 | } | ||
1778 | spec->kctl_alloc = knew; | ||
1779 | spec->num_kctl_alloc = num; | ||
1780 | } | ||
1781 | |||
1782 | knew = &spec->kctl_alloc[spec->num_kctl_used]; | ||
1783 | *knew = alc880_control_templates[type]; | ||
1784 | knew->name = kstrdup(name, GFP_KERNEL); | ||
1785 | if (! knew->name) | ||
1786 | return -ENOMEM; | ||
1787 | knew->private_value = val; | ||
1788 | spec->num_kctl_used++; | ||
1789 | return 0; | ||
1790 | } | ||
1791 | |||
1792 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | ||
1793 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | ||
1794 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | ||
1795 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | ||
1796 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | ||
1797 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | ||
1798 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | ||
1799 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | ||
1800 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | ||
1801 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | ||
1802 | #define ALC880_PIN_CD_NID 0x1c | ||
1803 | |||
1804 | /* fill in the dac_nids table from the parsed pin configuration */ | ||
1805 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) | ||
1806 | { | ||
1807 | hda_nid_t nid; | ||
1808 | int assigned[4]; | ||
1809 | int i, j; | ||
1810 | |||
1811 | memset(assigned, 0, sizeof(assigned)); | ||
1812 | |||
1813 | /* check the pins hardwired to audio widget */ | ||
1814 | for (i = 0; i < cfg->line_outs; i++) { | ||
1815 | nid = cfg->line_out_pins[i]; | ||
1816 | if (alc880_is_fixed_pin(nid)) { | ||
1817 | int idx = alc880_fixed_pin_idx(nid); | ||
1818 | spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx); | ||
1819 | assigned[idx] = 1; | ||
1820 | } | ||
1821 | } | ||
1822 | /* left pins can be connect to any audio widget */ | ||
1823 | for (i = 0; i < cfg->line_outs; i++) { | ||
1824 | nid = cfg->line_out_pins[i]; | ||
1825 | if (alc880_is_fixed_pin(nid)) | ||
1826 | continue; | ||
1827 | /* search for an empty channel */ | ||
1828 | for (j = 0; j < cfg->line_outs; j++) { | ||
1829 | if (! assigned[j]) { | ||
1830 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); | ||
1831 | assigned[j] = 1; | ||
1832 | break; | ||
1833 | } | ||
1834 | } | ||
1835 | } | ||
1836 | spec->multiout.num_dacs = cfg->line_outs; | ||
1837 | return 0; | ||
1838 | } | ||
1839 | |||
1840 | /* add playback controls from the parsed DAC table */ | ||
1841 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) | ||
1842 | { | ||
1843 | char name[32]; | ||
1844 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; | ||
1845 | hda_nid_t nid; | ||
1846 | int i, err; | ||
1847 | |||
1848 | for (i = 0; i < cfg->line_outs; i++) { | ||
1849 | if (! spec->multiout.dac_nids[i]) | ||
1850 | continue; | ||
1851 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | ||
1852 | if (i == 2) { | ||
1853 | /* Center/LFE */ | ||
1854 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", | ||
1855 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) | ||
1856 | return err; | ||
1857 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", | ||
1858 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) | ||
1859 | return err; | ||
1860 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", | ||
1861 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) | ||
1862 | return err; | ||
1863 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", | ||
1864 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) | ||
1865 | return err; | ||
1866 | } else { | ||
1867 | sprintf(name, "%s Playback Volume", chname[i]); | ||
1868 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
1869 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | ||
1870 | return err; | ||
1871 | sprintf(name, "%s Playback Switch", chname[i]); | ||
1872 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
1873 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) | ||
1874 | return err; | ||
1875 | } | ||
1876 | } | ||
1877 | |||
1878 | return 0; | ||
1879 | } | ||
1880 | |||
1881 | /* add playback controls for HP output */ | ||
1882 | static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | ||
1883 | { | ||
1884 | hda_nid_t nid; | ||
1885 | int err; | ||
1886 | |||
1887 | if (! pin) | ||
1888 | return 0; | ||
1889 | |||
1890 | if (alc880_is_fixed_pin(pin)) { | ||
1891 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | ||
1892 | if (! spec->multiout.dac_nids[0]) { | ||
1893 | /* use this as the primary output */ | ||
1894 | spec->multiout.dac_nids[0] = nid; | ||
1895 | if (! spec->multiout.num_dacs) | ||
1896 | spec->multiout.num_dacs = 1; | ||
1897 | } else | ||
1898 | /* specify the DAC as the extra HP output */ | ||
1899 | spec->multiout.hp_nid = nid; | ||
1900 | /* control HP volume/switch on the output mixer amp */ | ||
1901 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | ||
1902 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", | ||
1903 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) | ||
1904 | return err; | ||
1905 | if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch", | ||
1906 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) | ||
1907 | return err; | ||
1908 | } else if (alc880_is_multi_pin(pin)) { | ||
1909 | /* set manual connection */ | ||
1910 | if (! spec->multiout.dac_nids[0]) { | ||
1911 | /* use this as the primary output */ | ||
1912 | spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin)); | ||
1913 | if (! spec->multiout.num_dacs) | ||
1914 | spec->multiout.num_dacs = 1; | ||
1915 | } | ||
1916 | /* we have only a switch on HP-out PIN */ | ||
1917 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", | ||
1918 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) | ||
1919 | return err; | ||
1920 | } | ||
1921 | return 0; | ||
1922 | } | ||
1923 | |||
1924 | /* create input playback/capture controls for the given pin */ | ||
1925 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname) | ||
1926 | { | ||
1927 | char name[32]; | ||
1928 | int err, idx; | ||
1929 | |||
1930 | sprintf(name, "%s Playback Volume", ctlname); | ||
1931 | idx = alc880_input_pin_idx(pin); | ||
1932 | if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | ||
1933 | HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0) | ||
1934 | return err; | ||
1935 | sprintf(name, "%s Playback Switch", ctlname); | ||
1936 | if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
1937 | HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0) | ||
1938 | return err; | ||
1939 | return 0; | ||
1940 | } | ||
1941 | |||
1942 | /* create playback/capture controls for input pins */ | ||
1943 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) | ||
1944 | { | ||
1945 | static char *labels[AUTO_PIN_LAST] = { | ||
1946 | "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" | ||
1947 | }; | ||
1948 | struct hda_input_mux *imux = &spec->private_imux; | ||
1949 | int i, err; | ||
1950 | |||
1951 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
1952 | if (alc880_is_input_pin(cfg->input_pins[i])) { | ||
1953 | err = new_analog_input(spec, cfg->input_pins[i], labels[i]); | ||
1954 | if (err < 0) | ||
1955 | return err; | ||
1956 | imux->items[imux->num_items].label = labels[i]; | ||
1957 | imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); | ||
1958 | imux->num_items++; | ||
1959 | } | ||
1960 | } | ||
1961 | return 0; | ||
1962 | } | ||
1963 | |||
1964 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type, | ||
1965 | int dac_idx) | ||
1966 | { | ||
1967 | /* set as output */ | ||
1968 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | ||
1969 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | ||
1970 | /* need the manual connection? */ | ||
1971 | if (alc880_is_multi_pin(nid)) { | ||
1972 | struct alc_spec *spec = codec->spec; | ||
1973 | int idx = alc880_multi_pin_idx(nid); | ||
1974 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | ||
1975 | AC_VERB_SET_CONNECT_SEL, | ||
1976 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | ||
1977 | } | ||
1978 | } | ||
1979 | |||
1980 | static void alc880_auto_init_multi_out(struct hda_codec *codec) | ||
1981 | { | ||
1982 | struct alc_spec *spec = codec->spec; | ||
1983 | int i; | ||
1984 | |||
1985 | for (i = 0; i < spec->autocfg.line_outs; i++) { | ||
1986 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | ||
1987 | alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); | ||
1988 | } | ||
1989 | } | ||
1990 | |||
1991 | static void alc880_auto_init_hp_out(struct hda_codec *codec) | ||
1992 | { | ||
1993 | struct alc_spec *spec = codec->spec; | ||
1994 | hda_nid_t pin; | ||
1995 | |||
1996 | pin = spec->autocfg.hp_pin; | ||
1997 | if (pin) /* connect to front */ | ||
1998 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | ||
1999 | } | ||
2000 | |||
2001 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | ||
2002 | { | ||
2003 | struct alc_spec *spec = codec->spec; | ||
2004 | int i; | ||
2005 | |||
2006 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
2007 | hda_nid_t nid = spec->autocfg.input_pins[i]; | ||
2008 | if (alc880_is_input_pin(nid)) { | ||
2009 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
2010 | i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); | ||
2011 | if (nid != ALC880_PIN_CD_NID) | ||
2012 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
2013 | AMP_OUT_MUTE); | ||
2014 | } | ||
2015 | } | ||
2016 | } | ||
2017 | |||
2018 | /* parse the BIOS configuration and set up the alc_spec */ | ||
2019 | /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ | ||
2020 | static int alc880_parse_auto_config(struct hda_codec *codec) | ||
2021 | { | ||
2022 | struct alc_spec *spec = codec->spec; | ||
2023 | int err; | ||
2024 | |||
2025 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) | ||
2026 | return err; | ||
2027 | if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0) | ||
2028 | return err; | ||
2029 | if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin) | ||
2030 | return 0; /* can't find valid BIOS pin config */ | ||
2031 | if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || | ||
2032 | (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 || | ||
2033 | (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) | ||
2034 | return err; | ||
2035 | |||
2036 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | ||
2037 | |||
2038 | if (spec->autocfg.dig_out_pin) | ||
2039 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | ||
2040 | if (spec->autocfg.dig_in_pin) | ||
2041 | spec->dig_in_nid = ALC880_DIGIN_NID; | ||
2042 | |||
2043 | if (spec->kctl_alloc) | ||
2044 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; | ||
2045 | |||
2046 | spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; | ||
2047 | |||
2048 | spec->input_mux = &spec->private_imux; | ||
2049 | |||
2050 | return 1; | ||
2051 | } | ||
2052 | |||
2053 | /* init callback for auto-configuration model -- overriding the default init */ | ||
2054 | static int alc880_auto_init(struct hda_codec *codec) | ||
2055 | { | ||
2056 | alc_init(codec); | ||
2057 | alc880_auto_init_multi_out(codec); | ||
2058 | alc880_auto_init_hp_out(codec); | ||
2059 | alc880_auto_init_analog_input(codec); | ||
2060 | return 0; | ||
2061 | } | ||
2062 | |||
2063 | /* | ||
2064 | * OK, here we have finally the patch for ALC880 | ||
2065 | */ | ||
2066 | |||
999 | static int patch_alc880(struct hda_codec *codec) | 2067 | static int patch_alc880(struct hda_codec *codec) |
1000 | { | 2068 | { |
1001 | struct alc_spec *spec; | 2069 | struct alc_spec *spec; |
1002 | int board_config; | 2070 | int board_config; |
2071 | int i, err; | ||
1003 | 2072 | ||
1004 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | 2073 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
1005 | if (spec == NULL) | 2074 | if (spec == NULL) |
1006 | return -ENOMEM; | 2075 | return -ENOMEM; |
1007 | 2076 | ||
2077 | init_MUTEX(&spec->bind_mutex); | ||
1008 | codec->spec = spec; | 2078 | codec->spec = spec; |
1009 | 2079 | ||
1010 | board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); | 2080 | board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); |
1011 | if (board_config < 0) { | 2081 | if (board_config < 0 || board_config >= ALC880_MODEL_LAST) { |
1012 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC880\n"); | 2082 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n"); |
1013 | board_config = ALC880_MINIMAL; | 2083 | board_config = ALC880_AUTO; |
1014 | } | 2084 | } |
1015 | 2085 | ||
1016 | switch (board_config) { | 2086 | if (board_config == ALC880_AUTO) { |
1017 | case ALC880_W810: | 2087 | /* automatic parse from the BIOS config */ |
1018 | spec->mixers[spec->num_mixers] = alc880_w810_base_mixer; | 2088 | err = alc880_parse_auto_config(codec); |
1019 | spec->num_mixers++; | 2089 | if (err < 0) { |
1020 | break; | 2090 | alc_free(codec); |
1021 | case ALC880_5ST: | 2091 | return err; |
1022 | case ALC880_5ST_DIG: | 2092 | } else if (! err) { |
1023 | spec->mixers[spec->num_mixers] = alc880_five_stack_mixer; | 2093 | printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n"); |
1024 | spec->num_mixers++; | 2094 | board_config = ALC880_3ST; |
1025 | break; | 2095 | } |
1026 | default: | ||
1027 | spec->mixers[spec->num_mixers] = alc880_base_mixer; | ||
1028 | spec->num_mixers++; | ||
1029 | break; | ||
1030 | } | 2096 | } |
1031 | 2097 | ||
1032 | switch (board_config) { | 2098 | if (board_config != ALC880_AUTO) { |
1033 | case ALC880_3ST_DIG: | 2099 | /* set up from the preset table */ |
1034 | case ALC880_5ST_DIG: | 2100 | const struct alc_config_preset *preset; |
1035 | case ALC880_W810: | ||
1036 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | ||
1037 | break; | ||
1038 | default: | ||
1039 | break; | ||
1040 | } | ||
1041 | 2101 | ||
1042 | switch (board_config) { | 2102 | preset = &alc880_presets[board_config]; |
1043 | case ALC880_3ST: | ||
1044 | case ALC880_3ST_DIG: | ||
1045 | case ALC880_5ST: | ||
1046 | case ALC880_5ST_DIG: | ||
1047 | case ALC880_W810: | ||
1048 | spec->front_panel = 1; | ||
1049 | break; | ||
1050 | default: | ||
1051 | break; | ||
1052 | } | ||
1053 | 2103 | ||
1054 | switch (board_config) { | 2104 | for (i = 0; preset->mixers[i]; i++) { |
1055 | case ALC880_5ST: | 2105 | snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break); |
1056 | case ALC880_5ST_DIG: | 2106 | spec->mixers[spec->num_mixers++] = preset->mixers[i]; |
1057 | spec->init_verbs = alc880_init_verbs_five_stack; | 2107 | } |
1058 | spec->channel_mode = alc880_fivestack_modes; | 2108 | for (i = 0; preset->init_verbs[i]; i++) { |
1059 | spec->num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes); | 2109 | snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break); |
1060 | break; | 2110 | spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; |
1061 | case ALC880_W810: | 2111 | } |
1062 | spec->init_verbs = alc880_w810_init_verbs; | 2112 | |
1063 | spec->channel_mode = alc880_w810_modes; | 2113 | spec->channel_mode = preset->channel_mode; |
1064 | spec->num_channel_mode = ARRAY_SIZE(alc880_w810_modes); | 2114 | spec->num_channel_mode = preset->num_channel_mode; |
1065 | break; | 2115 | |
1066 | default: | 2116 | spec->multiout.max_channels = spec->channel_mode[0].channels; |
1067 | spec->init_verbs = alc880_init_verbs_three_stack; | 2117 | |
1068 | spec->channel_mode = alc880_threestack_modes; | 2118 | spec->multiout.num_dacs = preset->num_dacs; |
1069 | spec->num_channel_mode = ARRAY_SIZE(alc880_threestack_modes); | 2119 | spec->multiout.dac_nids = preset->dac_nids; |
1070 | break; | 2120 | spec->multiout.dig_out_nid = preset->dig_out_nid; |
2121 | spec->multiout.hp_nid = preset->hp_nid; | ||
2122 | |||
2123 | spec->input_mux = preset->input_mux; | ||
2124 | |||
2125 | spec->num_adc_nids = preset->num_adc_nids; | ||
2126 | spec->adc_nids = preset->adc_nids; | ||
1071 | } | 2127 | } |
1072 | 2128 | ||
1073 | spec->stream_name_analog = "ALC880 Analog"; | 2129 | spec->stream_name_analog = "ALC880 Analog"; |
@@ -1078,34 +2134,64 @@ static int patch_alc880(struct hda_codec *codec) | |||
1078 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | 2134 | spec->stream_digital_playback = &alc880_pcm_digital_playback; |
1079 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | 2135 | spec->stream_digital_capture = &alc880_pcm_digital_capture; |
1080 | 2136 | ||
1081 | spec->multiout.max_channels = spec->channel_mode[0].channels; | 2137 | if (! spec->adc_nids && spec->input_mux) { |
1082 | 2138 | /* check whether NID 0x07 is valid */ | |
1083 | switch (board_config) { | 2139 | unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0], |
1084 | case ALC880_W810: | 2140 | AC_PAR_AUDIO_WIDGET_CAP); |
1085 | spec->multiout.num_dacs = ARRAY_SIZE(alc880_w810_dac_nids); | 2141 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ |
1086 | spec->multiout.dac_nids = alc880_w810_dac_nids; | 2142 | if (wcap != AC_WID_AUD_IN) { |
1087 | // No dedicated headphone socket - it's shared with built-in speakers. | 2143 | spec->adc_nids = alc880_adc_nids_alt; |
1088 | break; | 2144 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); |
1089 | default: | 2145 | spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; |
1090 | spec->multiout.num_dacs = ARRAY_SIZE(alc880_dac_nids); | 2146 | spec->num_mixers++; |
1091 | spec->multiout.dac_nids = alc880_dac_nids; | 2147 | } else { |
1092 | spec->multiout.hp_nid = 0x03; /* rear-surround NID */ | 2148 | spec->adc_nids = alc880_adc_nids; |
1093 | break; | 2149 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); |
2150 | spec->mixers[spec->num_mixers] = alc880_capture_mixer; | ||
2151 | spec->num_mixers++; | ||
2152 | } | ||
1094 | } | 2153 | } |
1095 | 2154 | ||
1096 | spec->input_mux = &alc880_capture_source; | ||
1097 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | ||
1098 | spec->adc_nids = alc880_adc_nids; | ||
1099 | |||
1100 | codec->patch_ops = alc_patch_ops; | 2155 | codec->patch_ops = alc_patch_ops; |
2156 | if (board_config == ALC880_AUTO) | ||
2157 | codec->patch_ops.init = alc880_auto_init; | ||
1101 | 2158 | ||
1102 | return 0; | 2159 | return 0; |
1103 | } | 2160 | } |
1104 | 2161 | ||
2162 | |||
1105 | /* | 2163 | /* |
1106 | * ALC260 support | 2164 | * ALC260 support |
1107 | */ | 2165 | */ |
1108 | 2166 | ||
2167 | static hda_nid_t alc260_dac_nids[1] = { | ||
2168 | /* front */ | ||
2169 | 0x02, | ||
2170 | }; | ||
2171 | |||
2172 | static hda_nid_t alc260_adc_nids[1] = { | ||
2173 | /* ADC0 */ | ||
2174 | 0x04, | ||
2175 | }; | ||
2176 | |||
2177 | static hda_nid_t alc260_hp_adc_nids[1] = { | ||
2178 | /* ADC1 */ | ||
2179 | 0x05, | ||
2180 | }; | ||
2181 | |||
2182 | #define ALC260_DIGOUT_NID 0x03 | ||
2183 | #define ALC260_DIGIN_NID 0x06 | ||
2184 | |||
2185 | static struct hda_input_mux alc260_capture_source = { | ||
2186 | .num_items = 4, | ||
2187 | .items = { | ||
2188 | { "Mic", 0x0 }, | ||
2189 | { "Front Mic", 0x1 }, | ||
2190 | { "Line", 0x2 }, | ||
2191 | { "CD", 0x4 }, | ||
2192 | }, | ||
2193 | }; | ||
2194 | |||
1109 | /* | 2195 | /* |
1110 | * This is just place-holder, so there's something for alc_build_pcms to look | 2196 | * This is just place-holder, so there's something for alc_build_pcms to look |
1111 | * at when it calculates the maximum number of channels. ALC260 has no mixer | 2197 | * at when it calculates the maximum number of channels. ALC260 has no mixer |
@@ -1116,11 +2202,9 @@ static struct alc_channel_mode alc260_modes[1] = { | |||
1116 | { 2, NULL }, | 2202 | { 2, NULL }, |
1117 | }; | 2203 | }; |
1118 | 2204 | ||
1119 | snd_kcontrol_new_t alc260_base_mixer[] = { | 2205 | static snd_kcontrol_new_t alc260_base_mixer[] = { |
1120 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | 2206 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
1121 | /* use LINE2 for the output */ | 2207 | ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
1122 | /* HDA_CODEC_MUTE("Front Playback Switch", 0x0f, 0x0, HDA_OUTPUT), */ | ||
1123 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | ||
1124 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | 2208 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
1125 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | 2209 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), |
1126 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | 2210 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), |
@@ -1132,9 +2216,9 @@ snd_kcontrol_new_t alc260_base_mixer[] = { | |||
1132 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | 2216 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), |
1133 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | 2217 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), |
1134 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | 2218 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
1135 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), | 2219 | ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
1136 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | 2220 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
1137 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | 2221 | ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT), |
1138 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), | 2222 | HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), |
1139 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), | 2223 | HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), |
1140 | { | 2224 | { |
@@ -1147,60 +2231,91 @@ snd_kcontrol_new_t alc260_base_mixer[] = { | |||
1147 | { } /* end */ | 2231 | { } /* end */ |
1148 | }; | 2232 | }; |
1149 | 2233 | ||
2234 | static snd_kcontrol_new_t alc260_hp_mixer[] = { | ||
2235 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | ||
2236 | ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), | ||
2237 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | ||
2238 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | ||
2239 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | ||
2240 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | ||
2241 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | ||
2242 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | ||
2243 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | ||
2244 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | ||
2245 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | ||
2246 | ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), | ||
2247 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | ||
2248 | ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT), | ||
2249 | HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), | ||
2250 | HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), | ||
2251 | { | ||
2252 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2253 | .name = "Capture Source", | ||
2254 | .info = alc_mux_enum_info, | ||
2255 | .get = alc_mux_enum_get, | ||
2256 | .put = alc_mux_enum_put, | ||
2257 | }, | ||
2258 | { } /* end */ | ||
2259 | }; | ||
2260 | |||
1150 | static struct hda_verb alc260_init_verbs[] = { | 2261 | static struct hda_verb alc260_init_verbs[] = { |
1151 | /* Line In pin widget for input */ | 2262 | /* Line In pin widget for input */ |
1152 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 2263 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1153 | /* CD pin widget for input */ | 2264 | /* CD pin widget for input */ |
1154 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 2265 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1155 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | 2266 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
1156 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | 2267 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1157 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | 2268 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
1158 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | 2269 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1159 | /* LINE-2 is used for line-out in rear */ | 2270 | /* LINE-2 is used for line-out in rear */ |
1160 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2271 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1161 | /* select line-out */ | 2272 | /* select line-out */ |
1162 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | 2273 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1163 | /* LINE-OUT pin */ | 2274 | /* LINE-OUT pin */ |
1164 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2275 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1165 | /* enable HP */ | 2276 | /* enable HP */ |
1166 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2277 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1167 | /* enable Mono */ | 2278 | /* enable Mono */ |
1168 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2279 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1169 | /* unmute amp left and right */ | 2280 | /* mute capture amp left and right */ |
1170 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | 2281 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1171 | /* set connection select to line in (default select for this ADC) */ | 2282 | /* set connection select to line in (default select for this ADC) */ |
1172 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | 2283 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1173 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | 2284 | /* mute capture amp left and right */ |
1174 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 2285 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1175 | /* mute pin widget amp left and right (no gain on this amp) */ | 2286 | /* set connection select to line in (default select for this ADC) */ |
1176 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 2287 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1177 | /* unmute HP mixer amp left and right (volume = 0) */ | 2288 | /* set vol=0 Line-Out mixer amp left and right */ |
1178 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 2289 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1179 | /* mute pin widget amp left and right (no gain on this amp) */ | 2290 | /* unmute pin widget amp left and right (no gain on this amp) */ |
1180 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 2291 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1181 | /* unmute Mono mixer amp left and right (volume = 0) */ | 2292 | /* set vol=0 HP mixer amp left and right */ |
1182 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 2293 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1183 | /* mute pin widget amp left and right (no gain on this amp) */ | 2294 | /* unmute pin widget amp left and right (no gain on this amp) */ |
1184 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 2295 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1185 | /* mute LINE-2 out */ | 2296 | /* set vol=0 Mono mixer amp left and right */ |
1186 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, | 2297 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
2298 | /* unmute pin widget amp left and right (no gain on this amp) */ | ||
2299 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
2300 | /* unmute LINE-2 out pin */ | ||
2301 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1187 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ | 2302 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ |
1188 | /* unmute CD */ | 2303 | /* mute CD */ |
1189 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | 2304 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
1190 | /* unmute Line In */ | 2305 | /* mute Line In */ |
1191 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | 2306 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
1192 | /* unmute Mic */ | 2307 | /* mute Mic */ |
1193 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2308 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1194 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ | 2309 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
1195 | /* Unmute Front out path */ | 2310 | /* mute Front out path */ |
1196 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2311 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1197 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 2312 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
1198 | /* Unmute Headphone out path */ | 2313 | /* mute Headphone out path */ |
1199 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2314 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1200 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 2315 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
1201 | /* Unmute Mono out path */ | 2316 | /* mute Mono out path */ |
1202 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2317 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1203 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 2318 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
1204 | { } | 2319 | { } |
1205 | }; | 2320 | }; |
1206 | 2321 | ||
@@ -1208,30 +2323,52 @@ static struct hda_pcm_stream alc260_pcm_analog_playback = { | |||
1208 | .substreams = 1, | 2323 | .substreams = 1, |
1209 | .channels_min = 2, | 2324 | .channels_min = 2, |
1210 | .channels_max = 2, | 2325 | .channels_max = 2, |
1211 | .nid = 0x2, | ||
1212 | }; | 2326 | }; |
1213 | 2327 | ||
1214 | static struct hda_pcm_stream alc260_pcm_analog_capture = { | 2328 | static struct hda_pcm_stream alc260_pcm_analog_capture = { |
1215 | .substreams = 1, | 2329 | .substreams = 1, |
1216 | .channels_min = 2, | 2330 | .channels_min = 2, |
1217 | .channels_max = 2, | 2331 | .channels_max = 2, |
1218 | .nid = 0x4, | 2332 | }; |
2333 | |||
2334 | static struct hda_board_config alc260_cfg_tbl[] = { | ||
2335 | { .modelname = "hp", .config = ALC260_HP }, | ||
2336 | { .pci_subvendor = 0x103c, .config = ALC260_HP }, | ||
2337 | {} | ||
1219 | }; | 2338 | }; |
1220 | 2339 | ||
1221 | static int patch_alc260(struct hda_codec *codec) | 2340 | static int patch_alc260(struct hda_codec *codec) |
1222 | { | 2341 | { |
1223 | struct alc_spec *spec; | 2342 | struct alc_spec *spec; |
2343 | int board_config; | ||
1224 | 2344 | ||
1225 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | 2345 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); |
1226 | if (spec == NULL) | 2346 | if (spec == NULL) |
1227 | return -ENOMEM; | 2347 | return -ENOMEM; |
1228 | 2348 | ||
2349 | init_MUTEX(&spec->bind_mutex); | ||
1229 | codec->spec = spec; | 2350 | codec->spec = spec; |
1230 | 2351 | ||
1231 | spec->mixers[spec->num_mixers] = alc260_base_mixer; | 2352 | board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); |
1232 | spec->num_mixers++; | 2353 | if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { |
2354 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n"); | ||
2355 | board_config = ALC260_BASIC; | ||
2356 | } | ||
2357 | |||
2358 | switch (board_config) { | ||
2359 | case ALC260_HP: | ||
2360 | spec->mixers[spec->num_mixers] = alc260_hp_mixer; | ||
2361 | spec->num_mixers++; | ||
2362 | break; | ||
2363 | default: | ||
2364 | spec->mixers[spec->num_mixers] = alc260_base_mixer; | ||
2365 | spec->num_mixers++; | ||
2366 | break; | ||
2367 | } | ||
2368 | |||
2369 | spec->init_verbs[0] = alc260_init_verbs; | ||
2370 | spec->num_init_verbs = 1; | ||
1233 | 2371 | ||
1234 | spec->init_verbs = alc260_init_verbs; | ||
1235 | spec->channel_mode = alc260_modes; | 2372 | spec->channel_mode = alc260_modes; |
1236 | spec->num_channel_mode = ARRAY_SIZE(alc260_modes); | 2373 | spec->num_channel_mode = ARRAY_SIZE(alc260_modes); |
1237 | 2374 | ||
@@ -1244,14 +2381,23 @@ static int patch_alc260(struct hda_codec *codec) | |||
1244 | spec->multiout.dac_nids = alc260_dac_nids; | 2381 | spec->multiout.dac_nids = alc260_dac_nids; |
1245 | 2382 | ||
1246 | spec->input_mux = &alc260_capture_source; | 2383 | spec->input_mux = &alc260_capture_source; |
1247 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | 2384 | switch (board_config) { |
1248 | spec->adc_nids = alc260_adc_nids; | 2385 | case ALC260_HP: |
2386 | spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids); | ||
2387 | spec->adc_nids = alc260_hp_adc_nids; | ||
2388 | break; | ||
2389 | default: | ||
2390 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | ||
2391 | spec->adc_nids = alc260_adc_nids; | ||
2392 | break; | ||
2393 | } | ||
1249 | 2394 | ||
1250 | codec->patch_ops = alc_patch_ops; | 2395 | codec->patch_ops = alc_patch_ops; |
1251 | 2396 | ||
1252 | return 0; | 2397 | return 0; |
1253 | } | 2398 | } |
1254 | 2399 | ||
2400 | |||
1255 | /* | 2401 | /* |
1256 | * ALC882 support | 2402 | * ALC882 support |
1257 | * | 2403 | * |
@@ -1324,15 +2470,15 @@ static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u | |||
1324 | */ | 2470 | */ |
1325 | static snd_kcontrol_new_t alc882_base_mixer[] = { | 2471 | static snd_kcontrol_new_t alc882_base_mixer[] = { |
1326 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 2472 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1327 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 2473 | ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
1328 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | 2474 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
1329 | HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), | 2475 | ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
1330 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | 2476 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1331 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | 2477 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), |
1332 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), | 2478 | ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1333 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | 2479 | ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_OUTPUT), |
1334 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | 2480 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
1335 | HDA_CODEC_MUTE("Side Playback Switch", 0x17, 0x0, HDA_OUTPUT), | 2481 | ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1336 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | 2482 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1337 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | 2483 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1338 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | 2484 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
@@ -1364,89 +2510,80 @@ static snd_kcontrol_new_t alc882_base_mixer[] = { | |||
1364 | 2510 | ||
1365 | static struct hda_verb alc882_init_verbs[] = { | 2511 | static struct hda_verb alc882_init_verbs[] = { |
1366 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | 2512 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
1367 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 2513 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1368 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2514 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2515 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
1369 | /* Rear mixer */ | 2516 | /* Rear mixer */ |
1370 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 2517 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1371 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2518 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2519 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
1372 | /* CLFE mixer */ | 2520 | /* CLFE mixer */ |
1373 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 2521 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1374 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2522 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
2523 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
1375 | /* Side mixer */ | 2524 | /* Side mixer */ |
1376 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 2525 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
1377 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2526 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1378 | 2527 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1379 | /* Front Pin: to output mode */ | 2528 | |
1380 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2529 | /* Front Pin: output 0 (0x0c) */ |
1381 | /* Front Pin: mute amp left and right (no volume) */ | 2530 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1382 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | 2531 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1383 | /* select Front mixer (0x0c, index 0) */ | ||
1384 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | 2532 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1385 | /* Rear Pin */ | 2533 | /* Rear Pin: output 1 (0x0d) */ |
1386 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2534 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1387 | /* Rear Pin: mute amp left and right (no volume) */ | 2535 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1388 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
1389 | /* select Rear mixer (0x0d, index 1) */ | ||
1390 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | 2536 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
1391 | /* CLFE Pin */ | 2537 | /* CLFE Pin: output 2 (0x0e) */ |
1392 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2538 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1393 | /* CLFE Pin: mute amp left and right (no volume) */ | 2539 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1394 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
1395 | /* select CLFE mixer (0x0e, index 2) */ | ||
1396 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | 2540 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
1397 | /* Side Pin */ | 2541 | /* Side Pin: output 3 (0x0f) */ |
1398 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2542 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1399 | /* Side Pin: mute amp left and right (no volume) */ | 2543 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1400 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | ||
1401 | /* select Side mixer (0x0f, index 3) */ | ||
1402 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | 2544 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
1403 | /* Headphone Pin */ | 2545 | /* Mic (rear) pin: input vref at 80% */ |
1404 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | 2546 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1405 | /* Headphone Pin: mute amp left and right (no volume) */ | 2547 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1406 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | 2548 | /* Front Mic pin: input vref at 80% */ |
1407 | /* select Front mixer (0x0c, index 0) */ | 2549 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2550 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
2551 | /* Line In pin: input */ | ||
2552 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
2553 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
2554 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | ||
2555 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2556 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1408 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | 2557 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1409 | /* Mic (rear) pin widget for input and vref at 80% */ | ||
1410 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | ||
1411 | /* Front Mic pin widget for input and vref at 80% */ | ||
1412 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | ||
1413 | /* Line In pin widget for input */ | ||
1414 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | ||
1415 | /* CD pin widget for input */ | 2558 | /* CD pin widget for input */ |
1416 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 2559 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1417 | 2560 | ||
1418 | /* FIXME: use matrix-type input source selection */ | 2561 | /* FIXME: use matrix-type input source selection */ |
1419 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | 2562 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
1420 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | 2563 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
1421 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2564 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1422 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | 2565 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
1423 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | 2566 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
1424 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | 2567 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
1425 | /* Input mixer2 */ | 2568 | /* Input mixer2 */ |
1426 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2569 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1427 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | 2570 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
1428 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | 2571 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
1429 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | 2572 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
1430 | /* Input mixer3 */ | 2573 | /* Input mixer3 */ |
1431 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 2574 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1432 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | 2575 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
1433 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | 2576 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
1434 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | 2577 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
1435 | /* ADC1: unmute amp left and right */ | 2578 | /* ADC1: mute amp left and right */ |
1436 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | 2579 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1437 | /* ADC2: unmute amp left and right */ | 2580 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1438 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | 2581 | /* ADC2: mute amp left and right */ |
1439 | /* ADC3: unmute amp left and right */ | 2582 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1440 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | 2583 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1441 | 2584 | /* ADC3: mute amp left and right */ | |
1442 | /* Unmute front loopback */ | 2585 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1443 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | 2586 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1444 | /* Unmute rear loopback */ | ||
1445 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | ||
1446 | /* Mute CLFE loopback */ | ||
1447 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, | ||
1448 | /* Unmute side loopback */ | ||
1449 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | ||
1450 | 2587 | ||
1451 | { } | 2588 | { } |
1452 | }; | 2589 | }; |
@@ -1459,6 +2596,7 @@ static int patch_alc882(struct hda_codec *codec) | |||
1459 | if (spec == NULL) | 2596 | if (spec == NULL) |
1460 | return -ENOMEM; | 2597 | return -ENOMEM; |
1461 | 2598 | ||
2599 | init_MUTEX(&spec->bind_mutex); | ||
1462 | codec->spec = spec; | 2600 | codec->spec = spec; |
1463 | 2601 | ||
1464 | spec->mixers[spec->num_mixers] = alc882_base_mixer; | 2602 | spec->mixers[spec->num_mixers] = alc882_base_mixer; |
@@ -1466,8 +2604,9 @@ static int patch_alc882(struct hda_codec *codec) | |||
1466 | 2604 | ||
1467 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | 2605 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; |
1468 | spec->dig_in_nid = ALC880_DIGIN_NID; | 2606 | spec->dig_in_nid = ALC880_DIGIN_NID; |
1469 | spec->front_panel = 1; | 2607 | spec->init_verbs[0] = alc882_init_verbs; |
1470 | spec->init_verbs = alc882_init_verbs; | 2608 | spec->num_init_verbs = 1; |
2609 | |||
1471 | spec->channel_mode = alc882_ch_modes; | 2610 | spec->channel_mode = alc882_ch_modes; |
1472 | spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes); | 2611 | spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes); |
1473 | 2612 | ||
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c new file mode 100644 index 000000000000..013be2ea513a --- /dev/null +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -0,0 +1,666 @@ | |||
1 | /* | ||
2 | * Universal Interface for Intel High Definition Audio Codec | ||
3 | * | ||
4 | * HD audio interface patch for SigmaTel STAC92xx | ||
5 | * | ||
6 | * Copyright (c) 2005 Embedded Alley Solutions, Inc. | ||
7 | * <matt@embeddedalley.com> | ||
8 | * | ||
9 | * Based on patch_cmedia.c and patch_realtek.c | ||
10 | * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de> | ||
11 | * | ||
12 | * This driver is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This driver is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | */ | ||
26 | |||
27 | #include <sound/driver.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/slab.h> | ||
31 | #include <linux/pci.h> | ||
32 | #include <sound/core.h> | ||
33 | #include "hda_codec.h" | ||
34 | #include "hda_local.h" | ||
35 | |||
36 | #undef STAC_TEST | ||
37 | |||
38 | struct sigmatel_spec { | ||
39 | /* playback */ | ||
40 | struct hda_multi_out multiout; | ||
41 | hda_nid_t playback_nid; | ||
42 | |||
43 | /* capture */ | ||
44 | hda_nid_t *adc_nids; | ||
45 | unsigned int num_adcs; | ||
46 | hda_nid_t *mux_nids; | ||
47 | unsigned int num_muxes; | ||
48 | hda_nid_t capture_nid; | ||
49 | hda_nid_t dig_in_nid; | ||
50 | |||
51 | /* power management*/ | ||
52 | hda_nid_t *pstate_nids; | ||
53 | unsigned int num_pstates; | ||
54 | |||
55 | /* pin widgets */ | ||
56 | hda_nid_t *pin_nids; | ||
57 | unsigned int num_pins; | ||
58 | #ifdef STAC_TEST | ||
59 | unsigned int *pin_configs; | ||
60 | #endif | ||
61 | |||
62 | /* codec specific stuff */ | ||
63 | struct hda_verb *init; | ||
64 | snd_kcontrol_new_t *mixer; | ||
65 | |||
66 | /* capture source */ | ||
67 | struct hda_input_mux input_mux; | ||
68 | char input_labels[HDA_MAX_NUM_INPUTS][16]; | ||
69 | unsigned int cur_mux[2]; | ||
70 | |||
71 | /* channel mode */ | ||
72 | unsigned int num_ch_modes; | ||
73 | unsigned int cur_ch_mode; | ||
74 | const struct sigmatel_channel_mode *channel_modes; | ||
75 | |||
76 | struct hda_pcm pcm_rec[1]; /* PCM information */ | ||
77 | }; | ||
78 | |||
79 | static hda_nid_t stac9200_adc_nids[1] = { | ||
80 | 0x03, | ||
81 | }; | ||
82 | |||
83 | static hda_nid_t stac9200_mux_nids[1] = { | ||
84 | 0x0c, | ||
85 | }; | ||
86 | |||
87 | static hda_nid_t stac9200_dac_nids[1] = { | ||
88 | 0x02, | ||
89 | }; | ||
90 | |||
91 | static hda_nid_t stac9200_pstate_nids[3] = { | ||
92 | 0x01, 0x02, 0x03, | ||
93 | }; | ||
94 | |||
95 | static hda_nid_t stac9200_pin_nids[8] = { | ||
96 | 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, | ||
97 | }; | ||
98 | |||
99 | static hda_nid_t stac922x_adc_nids[2] = { | ||
100 | 0x06, 0x07, | ||
101 | }; | ||
102 | |||
103 | static hda_nid_t stac922x_mux_nids[2] = { | ||
104 | 0x12, 0x13, | ||
105 | }; | ||
106 | |||
107 | static hda_nid_t stac922x_dac_nids[4] = { | ||
108 | 0x02, 0x03, 0x04, 0x05, | ||
109 | }; | ||
110 | |||
111 | static hda_nid_t stac922x_pstate_nids[8] = { | ||
112 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x11, | ||
113 | }; | ||
114 | |||
115 | static hda_nid_t stac922x_pin_nids[10] = { | ||
116 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | ||
117 | 0x0f, 0x10, 0x11, 0x15, 0x1b, | ||
118 | }; | ||
119 | |||
120 | static int stac92xx_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
121 | { | ||
122 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
123 | struct sigmatel_spec *spec = codec->spec; | ||
124 | return snd_hda_input_mux_info(&spec->input_mux, uinfo); | ||
125 | } | ||
126 | |||
127 | static int stac92xx_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
128 | { | ||
129 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
130 | struct sigmatel_spec *spec = codec->spec; | ||
131 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | ||
132 | |||
133 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static int stac92xx_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
138 | { | ||
139 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
140 | struct sigmatel_spec *spec = codec->spec; | ||
141 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | ||
142 | |||
143 | return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol, | ||
144 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); | ||
145 | } | ||
146 | |||
147 | static struct hda_verb stac9200_ch2_init[] = { | ||
148 | /* set dac0mux for dac converter */ | ||
149 | { 0x07, 0x701, 0x00}, | ||
150 | {} | ||
151 | }; | ||
152 | |||
153 | static struct hda_verb stac922x_ch2_init[] = { | ||
154 | /* set master volume and direct control */ | ||
155 | { 0x16, 0x70f, 0xff}, | ||
156 | {} | ||
157 | }; | ||
158 | |||
159 | struct sigmatel_channel_mode { | ||
160 | unsigned int channels; | ||
161 | const struct hda_verb *sequence; | ||
162 | }; | ||
163 | |||
164 | static snd_kcontrol_new_t stac9200_mixer[] = { | ||
165 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), | ||
166 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), | ||
167 | { | ||
168 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
169 | .name = "Input Source", | ||
170 | .count = 1, | ||
171 | .info = stac92xx_mux_enum_info, | ||
172 | .get = stac92xx_mux_enum_get, | ||
173 | .put = stac92xx_mux_enum_put, | ||
174 | }, | ||
175 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), | ||
176 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), | ||
177 | HDA_CODEC_VOLUME("Input Mux Volume", 0x0c, 0, HDA_OUTPUT), | ||
178 | { } /* end */ | ||
179 | }; | ||
180 | |||
181 | static snd_kcontrol_new_t stac922x_mixer[] = { | ||
182 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x2, 0x0, HDA_OUTPUT), | ||
183 | HDA_CODEC_MUTE("PCM Playback Switch", 0x2, 0x0, HDA_OUTPUT), | ||
184 | { | ||
185 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
186 | .name = "Input Source", | ||
187 | .count = 1, | ||
188 | .info = stac92xx_mux_enum_info, | ||
189 | .get = stac92xx_mux_enum_get, | ||
190 | .put = stac92xx_mux_enum_put, | ||
191 | }, | ||
192 | HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT), | ||
193 | HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT), | ||
194 | HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT), | ||
195 | { } /* end */ | ||
196 | }; | ||
197 | |||
198 | static int stac92xx_build_controls(struct hda_codec *codec) | ||
199 | { | ||
200 | struct sigmatel_spec *spec = codec->spec; | ||
201 | int err; | ||
202 | |||
203 | err = snd_hda_add_new_ctls(codec, spec->mixer); | ||
204 | if (err < 0) | ||
205 | return err; | ||
206 | if (spec->multiout.dig_out_nid) { | ||
207 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | ||
208 | if (err < 0) | ||
209 | return err; | ||
210 | } | ||
211 | if (spec->dig_in_nid) { | ||
212 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | ||
213 | if (err < 0) | ||
214 | return err; | ||
215 | } | ||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | #ifdef STAC_TEST | ||
220 | static unsigned int stac9200_pin_configs[8] = { | ||
221 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, | ||
222 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, | ||
223 | }; | ||
224 | |||
225 | static unsigned int stac922x_pin_configs[14] = { | ||
226 | 0x40000100, 0x40000100, 0x40000100, 0x01114010, | ||
227 | 0x01813122, 0x40000100, 0x01447010, 0x01c47010, | ||
228 | 0x40000100, 0x40000100, | ||
229 | }; | ||
230 | |||
231 | static void stac92xx_set_config_regs(struct hda_codec *codec) | ||
232 | { | ||
233 | int i; | ||
234 | struct sigmatel_spec *spec = codec->spec; | ||
235 | unsigned int pin_cfg; | ||
236 | |||
237 | for (i=0; i < spec->num_pins; i++) { | ||
238 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, | ||
239 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, | ||
240 | spec->pin_configs[i] & 0x000000ff); | ||
241 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, | ||
242 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, | ||
243 | (spec->pin_configs[i] & 0x0000ff00) >> 8); | ||
244 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, | ||
245 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, | ||
246 | (spec->pin_configs[i] & 0x00ff0000) >> 16); | ||
247 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, | ||
248 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | ||
249 | spec->pin_configs[i] >> 24); | ||
250 | pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, | ||
251 | AC_VERB_GET_CONFIG_DEFAULT, | ||
252 | 0x00); | ||
253 | printk("pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); | ||
254 | } | ||
255 | } | ||
256 | #endif | ||
257 | |||
258 | static int stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, unsigned int value) | ||
259 | { | ||
260 | unsigned int pin_ctl; | ||
261 | |||
262 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | ||
263 | AC_VERB_GET_PIN_WIDGET_CONTROL, | ||
264 | 0x00); | ||
265 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
266 | pin_ctl | value); | ||
267 | |||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | static int stac92xx_set_vref(struct hda_codec *codec, hda_nid_t nid) | ||
272 | { | ||
273 | unsigned int vref_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) >> AC_PINCAP_VREF_SHIFT; | ||
274 | unsigned int vref_ctl = AC_PINCTL_VREF_HIZ; | ||
275 | |||
276 | if (vref_caps & AC_PINCAP_VREF_100) | ||
277 | vref_ctl = AC_PINCTL_VREF_100; | ||
278 | else if (vref_caps & AC_PINCAP_VREF_80) | ||
279 | vref_ctl = AC_PINCTL_VREF_80; | ||
280 | else if (vref_caps & AC_PINCAP_VREF_50) | ||
281 | vref_ctl = AC_PINCTL_VREF_50; | ||
282 | else if (vref_caps & AC_PINCAP_VREF_GRD) | ||
283 | vref_ctl = AC_PINCTL_VREF_GRD; | ||
284 | |||
285 | stac92xx_set_pinctl(codec, nid, vref_ctl); | ||
286 | |||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | /* | ||
291 | * retrieve the default device type from the default config value | ||
292 | */ | ||
293 | #define get_defcfg_type(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) | ||
294 | #define get_defcfg_location(cfg) ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) | ||
295 | |||
296 | static int stac92xx_config_pin(struct hda_codec *codec, hda_nid_t nid, unsigned int pin_cfg) | ||
297 | { | ||
298 | struct sigmatel_spec *spec = codec->spec; | ||
299 | u32 location = get_defcfg_location(pin_cfg); | ||
300 | char *label; | ||
301 | const char *type = NULL; | ||
302 | int ainput = 0; | ||
303 | |||
304 | switch(get_defcfg_type(pin_cfg)) { | ||
305 | case AC_JACK_HP_OUT: | ||
306 | /* Enable HP amp */ | ||
307 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_HP_EN); | ||
308 | /* Fall through */ | ||
309 | case AC_JACK_SPDIF_OUT: | ||
310 | case AC_JACK_LINE_OUT: | ||
311 | case AC_JACK_SPEAKER: | ||
312 | /* Enable output */ | ||
313 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | ||
314 | break; | ||
315 | case AC_JACK_SPDIF_IN: | ||
316 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
317 | break; | ||
318 | case AC_JACK_MIC_IN: | ||
319 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) | ||
320 | type = "Front Mic"; | ||
321 | else | ||
322 | type = "Mic"; | ||
323 | ainput = 1; | ||
324 | /* Set vref */ | ||
325 | stac92xx_set_vref(codec, nid); | ||
326 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
327 | break; | ||
328 | case AC_JACK_CD: | ||
329 | type = "CD"; | ||
330 | ainput = 1; | ||
331 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
332 | break; | ||
333 | case AC_JACK_LINE_IN: | ||
334 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) | ||
335 | type = "Front Line"; | ||
336 | else | ||
337 | type = "Line"; | ||
338 | ainput = 1; | ||
339 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
340 | break; | ||
341 | case AC_JACK_AUX: | ||
342 | if ((location & 0x0f) == AC_JACK_LOC_FRONT) | ||
343 | type = "Front Aux"; | ||
344 | else | ||
345 | type = "Aux"; | ||
346 | ainput = 1; | ||
347 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); | ||
348 | break; | ||
349 | } | ||
350 | |||
351 | if (ainput) { | ||
352 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | ||
353 | int i, j, num_cons, index = -1; | ||
354 | if (!type) | ||
355 | type = "Input"; | ||
356 | label = spec->input_labels[spec->input_mux.num_items]; | ||
357 | strcpy(label, type); | ||
358 | spec->input_mux.items[spec->input_mux.num_items].label = label; | ||
359 | for (i=0; i<spec->num_muxes; i++) { | ||
360 | num_cons = snd_hda_get_connections(codec, spec->mux_nids[i], con_lst, HDA_MAX_NUM_INPUTS); | ||
361 | for (j=0; j<num_cons; j++) | ||
362 | if (con_lst[j] == nid) { | ||
363 | index = j; | ||
364 | break; | ||
365 | } | ||
366 | if (index >= 0) | ||
367 | break; | ||
368 | } | ||
369 | spec->input_mux.items[spec->input_mux.num_items].index = index; | ||
370 | spec->input_mux.num_items++; | ||
371 | } | ||
372 | |||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | static int stac92xx_config_pins(struct hda_codec *codec) | ||
377 | { | ||
378 | struct sigmatel_spec *spec = codec->spec; | ||
379 | int i; | ||
380 | unsigned int pin_cfg; | ||
381 | |||
382 | for (i=0; i < spec->num_pins; i++) { | ||
383 | /* Default to disabled */ | ||
384 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, | ||
385 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
386 | 0x00); | ||
387 | |||
388 | pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, | ||
389 | AC_VERB_GET_CONFIG_DEFAULT, | ||
390 | 0x00); | ||
391 | if (((pin_cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) == AC_JACK_PORT_NONE) | ||
392 | continue; /* Move on */ | ||
393 | |||
394 | stac92xx_config_pin(codec, spec->pin_nids[i], pin_cfg); | ||
395 | } | ||
396 | |||
397 | return 0; | ||
398 | } | ||
399 | |||
400 | static int stac92xx_init(struct hda_codec *codec) | ||
401 | { | ||
402 | struct sigmatel_spec *spec = codec->spec; | ||
403 | int i; | ||
404 | |||
405 | for (i=0; i < spec->num_pstates; i++) | ||
406 | snd_hda_codec_write(codec, spec->pstate_nids[i], 0, | ||
407 | AC_VERB_SET_POWER_STATE, 0x00); | ||
408 | |||
409 | mdelay(100); | ||
410 | |||
411 | snd_hda_sequence_write(codec, spec->init); | ||
412 | |||
413 | #ifdef STAC_TEST | ||
414 | stac92xx_set_config_regs(codec); | ||
415 | #endif | ||
416 | |||
417 | stac92xx_config_pins(codec); | ||
418 | |||
419 | return 0; | ||
420 | } | ||
421 | |||
422 | /* | ||
423 | * Analog playback callbacks | ||
424 | */ | ||
425 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
426 | struct hda_codec *codec, | ||
427 | snd_pcm_substream_t *substream) | ||
428 | { | ||
429 | struct sigmatel_spec *spec = codec->spec; | ||
430 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); | ||
431 | } | ||
432 | |||
433 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
434 | struct hda_codec *codec, | ||
435 | unsigned int stream_tag, | ||
436 | unsigned int format, | ||
437 | snd_pcm_substream_t *substream) | ||
438 | { | ||
439 | struct sigmatel_spec *spec = codec->spec; | ||
440 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, | ||
441 | format, substream); | ||
442 | } | ||
443 | |||
444 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
445 | struct hda_codec *codec, | ||
446 | snd_pcm_substream_t *substream) | ||
447 | { | ||
448 | struct sigmatel_spec *spec = codec->spec; | ||
449 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | ||
450 | } | ||
451 | |||
452 | /* | ||
453 | * Digital playback callbacks | ||
454 | */ | ||
455 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
456 | struct hda_codec *codec, | ||
457 | snd_pcm_substream_t *substream) | ||
458 | { | ||
459 | struct sigmatel_spec *spec = codec->spec; | ||
460 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | ||
461 | } | ||
462 | |||
463 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | ||
464 | struct hda_codec *codec, | ||
465 | snd_pcm_substream_t *substream) | ||
466 | { | ||
467 | struct sigmatel_spec *spec = codec->spec; | ||
468 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | ||
469 | } | ||
470 | |||
471 | |||
472 | /* | ||
473 | * Analog capture callbacks | ||
474 | */ | ||
475 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
476 | struct hda_codec *codec, | ||
477 | unsigned int stream_tag, | ||
478 | unsigned int format, | ||
479 | snd_pcm_substream_t *substream) | ||
480 | { | ||
481 | struct sigmatel_spec *spec = codec->spec; | ||
482 | |||
483 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], | ||
484 | stream_tag, 0, format); | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
489 | struct hda_codec *codec, | ||
490 | snd_pcm_substream_t *substream) | ||
491 | { | ||
492 | struct sigmatel_spec *spec = codec->spec; | ||
493 | |||
494 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); | ||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { | ||
499 | .substreams = 1, | ||
500 | .channels_min = 2, | ||
501 | .channels_max = 2, | ||
502 | /* NID is set in stac92xx_build_pcms */ | ||
503 | .ops = { | ||
504 | .open = stac92xx_dig_playback_pcm_open, | ||
505 | .close = stac92xx_dig_playback_pcm_close | ||
506 | }, | ||
507 | }; | ||
508 | |||
509 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { | ||
510 | .substreams = 1, | ||
511 | .channels_min = 2, | ||
512 | .channels_max = 2, | ||
513 | /* NID is set in stac92xx_build_pcms */ | ||
514 | }; | ||
515 | |||
516 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { | ||
517 | .substreams = 1, | ||
518 | .channels_min = 2, | ||
519 | .channels_max = 2, | ||
520 | .nid = 0x02, /* NID to query formats and rates */ | ||
521 | .ops = { | ||
522 | .open = stac92xx_playback_pcm_open, | ||
523 | .prepare = stac92xx_playback_pcm_prepare, | ||
524 | .cleanup = stac92xx_playback_pcm_cleanup | ||
525 | }, | ||
526 | }; | ||
527 | |||
528 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { | ||
529 | .substreams = 2, | ||
530 | .channels_min = 2, | ||
531 | .channels_max = 2, | ||
532 | .nid = 0x06, /* NID to query formats and rates */ | ||
533 | .ops = { | ||
534 | .prepare = stac92xx_capture_pcm_prepare, | ||
535 | .cleanup = stac92xx_capture_pcm_cleanup | ||
536 | }, | ||
537 | }; | ||
538 | |||
539 | static int stac92xx_build_pcms(struct hda_codec *codec) | ||
540 | { | ||
541 | struct sigmatel_spec *spec = codec->spec; | ||
542 | struct hda_pcm *info = spec->pcm_rec; | ||
543 | |||
544 | codec->num_pcms = 1; | ||
545 | codec->pcm_info = info; | ||
546 | |||
547 | info->name = "STAC92xx"; | ||
548 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; | ||
549 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->playback_nid; | ||
550 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; | ||
551 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->capture_nid; | ||
552 | |||
553 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { | ||
554 | codec->num_pcms++; | ||
555 | info++; | ||
556 | info->name = "STAC92xx Digital"; | ||
557 | if (spec->multiout.dig_out_nid) { | ||
558 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; | ||
559 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | ||
560 | } | ||
561 | if (spec->dig_in_nid) { | ||
562 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; | ||
563 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | ||
564 | } | ||
565 | } | ||
566 | |||
567 | return 0; | ||
568 | } | ||
569 | |||
570 | static void stac92xx_free(struct hda_codec *codec) | ||
571 | { | ||
572 | kfree(codec->spec); | ||
573 | } | ||
574 | |||
575 | static struct hda_codec_ops stac92xx_patch_ops = { | ||
576 | .build_controls = stac92xx_build_controls, | ||
577 | .build_pcms = stac92xx_build_pcms, | ||
578 | .init = stac92xx_init, | ||
579 | .free = stac92xx_free, | ||
580 | }; | ||
581 | |||
582 | static int patch_stac9200(struct hda_codec *codec) | ||
583 | { | ||
584 | struct sigmatel_spec *spec; | ||
585 | |||
586 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | ||
587 | if (spec == NULL) | ||
588 | return -ENOMEM; | ||
589 | |||
590 | codec->spec = spec; | ||
591 | |||
592 | spec->multiout.max_channels = 2; | ||
593 | spec->multiout.num_dacs = 1; | ||
594 | spec->multiout.dac_nids = stac9200_dac_nids; | ||
595 | spec->multiout.dig_out_nid = 0x05; | ||
596 | spec->dig_in_nid = 0x04; | ||
597 | spec->adc_nids = stac9200_adc_nids; | ||
598 | spec->mux_nids = stac9200_mux_nids; | ||
599 | spec->num_muxes = 1; | ||
600 | spec->input_mux.num_items = 0; | ||
601 | spec->pstate_nids = stac9200_pstate_nids; | ||
602 | spec->num_pstates = 3; | ||
603 | spec->pin_nids = stac9200_pin_nids; | ||
604 | #ifdef STAC_TEST | ||
605 | spec->pin_configs = stac9200_pin_configs; | ||
606 | #endif | ||
607 | spec->num_pins = 8; | ||
608 | spec->init = stac9200_ch2_init; | ||
609 | spec->mixer = stac9200_mixer; | ||
610 | spec->playback_nid = 0x02; | ||
611 | spec->capture_nid = 0x03; | ||
612 | |||
613 | codec->patch_ops = stac92xx_patch_ops; | ||
614 | |||
615 | return 0; | ||
616 | } | ||
617 | |||
618 | static int patch_stac922x(struct hda_codec *codec) | ||
619 | { | ||
620 | struct sigmatel_spec *spec; | ||
621 | |||
622 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | ||
623 | if (spec == NULL) | ||
624 | return -ENOMEM; | ||
625 | |||
626 | codec->spec = spec; | ||
627 | |||
628 | spec->multiout.max_channels = 2; | ||
629 | spec->multiout.num_dacs = 4; | ||
630 | spec->multiout.dac_nids = stac922x_dac_nids; | ||
631 | spec->multiout.dig_out_nid = 0x08; | ||
632 | spec->dig_in_nid = 0x09; | ||
633 | spec->adc_nids = stac922x_adc_nids; | ||
634 | spec->mux_nids = stac922x_mux_nids; | ||
635 | spec->num_muxes = 2; | ||
636 | spec->input_mux.num_items = 0; | ||
637 | spec->pstate_nids = stac922x_pstate_nids; | ||
638 | spec->num_pstates = 8; | ||
639 | spec->pin_nids = stac922x_pin_nids; | ||
640 | #ifdef STAC_TEST | ||
641 | spec->pin_configs = stac922x_pin_configs; | ||
642 | #endif | ||
643 | spec->num_pins = 10; | ||
644 | spec->init = stac922x_ch2_init; | ||
645 | spec->mixer = stac922x_mixer; | ||
646 | spec->playback_nid = 0x02; | ||
647 | spec->capture_nid = 0x06; | ||
648 | |||
649 | codec->patch_ops = stac92xx_patch_ops; | ||
650 | |||
651 | return 0; | ||
652 | } | ||
653 | |||
654 | /* | ||
655 | * patch entries | ||
656 | */ | ||
657 | struct hda_codec_preset snd_hda_preset_sigmatel[] = { | ||
658 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, | ||
659 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, | ||
660 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, | ||
661 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, | ||
662 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, | ||
663 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, | ||
664 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, | ||
665 | {} /* terminator */ | ||
666 | }; | ||
diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c index 779951725e1e..289b0b5711e4 100644 --- a/sound/pci/ice1712/amp.c +++ b/sound/pci/ice1712/amp.c | |||
@@ -30,16 +30,39 @@ | |||
30 | #include <sound/core.h> | 30 | #include <sound/core.h> |
31 | 31 | ||
32 | #include "ice1712.h" | 32 | #include "ice1712.h" |
33 | #include "envy24ht.h" | ||
33 | #include "amp.h" | 34 | #include "amp.h" |
34 | 35 | ||
36 | static void wm_put(ice1712_t *ice, int reg, unsigned short val) | ||
37 | { | ||
38 | unsigned short cval; | ||
39 | cval = (reg << 9) | val; | ||
40 | snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff); | ||
41 | } | ||
35 | 42 | ||
36 | static int __devinit snd_vt1724_amp_init(ice1712_t *ice) | 43 | static int __devinit snd_vt1724_amp_init(ice1712_t *ice) |
37 | { | 44 | { |
45 | static unsigned short wm_inits[] = { | ||
46 | WM_ATTEN_L, 0x0000, /* 0 db */ | ||
47 | WM_ATTEN_R, 0x0000, /* 0 db */ | ||
48 | WM_DAC_CTRL, 0x0008, /* 24bit I2S */ | ||
49 | WM_INT_CTRL, 0x0001, /* 24bit I2S */ | ||
50 | }; | ||
51 | |||
52 | unsigned int i; | ||
53 | |||
38 | /* only use basic functionality for now */ | 54 | /* only use basic functionality for now */ |
39 | 55 | ||
40 | ice->num_total_dacs = 2; /* only PSDOUT0 is connected */ | 56 | ice->num_total_dacs = 2; /* only PSDOUT0 is connected */ |
41 | ice->num_total_adcs = 2; | 57 | ice->num_total_adcs = 2; |
42 | 58 | ||
59 | /* Chaintech AV-710 has another codecs, which need initialization */ | ||
60 | /* initialize WM8728 codec */ | ||
61 | if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AV710) { | ||
62 | for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2) | ||
63 | wm_put(ice, wm_inits[i], wm_inits[i+1]); | ||
64 | } | ||
65 | |||
43 | return 0; | 66 | return 0; |
44 | } | 67 | } |
45 | 68 | ||
@@ -54,6 +77,13 @@ static int __devinit snd_vt1724_amp_add_controls(ice1712_t *ice) | |||
54 | /* entry point */ | 77 | /* entry point */ |
55 | struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = { | 78 | struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = { |
56 | { | 79 | { |
80 | .subvendor = VT1724_SUBDEVICE_AV710, | ||
81 | .name = "Chaintech AV-710", | ||
82 | .model = "av710", | ||
83 | .chip_init = snd_vt1724_amp_init, | ||
84 | .build_controls = snd_vt1724_amp_add_controls, | ||
85 | }, | ||
86 | { | ||
57 | .subvendor = VT1724_SUBDEVICE_AUDIO2000, | 87 | .subvendor = VT1724_SUBDEVICE_AUDIO2000, |
58 | .name = "AMP Ltd AUDIO2000", | 88 | .name = "AMP Ltd AUDIO2000", |
59 | .model = "amp2000", | 89 | .model = "amp2000", |
diff --git a/sound/pci/ice1712/amp.h b/sound/pci/ice1712/amp.h index d58d43383e83..a0fc89b48122 100644 --- a/sound/pci/ice1712/amp.h +++ b/sound/pci/ice1712/amp.h | |||
@@ -24,9 +24,23 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #define AMP_AUDIO2000_DEVICE_DESC "{AMP Ltd,AUDIO2000}," | 27 | #define AMP_AUDIO2000_DEVICE_DESC "{AMP Ltd,AUDIO2000},"\ |
28 | "{Chaintech,AV-710}," | ||
28 | 29 | ||
30 | #if 0 | ||
29 | #define VT1724_SUBDEVICE_AUDIO2000 0x12142417 /* Advanced Micro Peripherals Ltd AUDIO2000 */ | 31 | #define VT1724_SUBDEVICE_AUDIO2000 0x12142417 /* Advanced Micro Peripherals Ltd AUDIO2000 */ |
32 | #else | ||
33 | #define VT1724_SUBDEVICE_AUDIO2000 0x00030003 /* a dummy ID for AMP Audio2000 */ | ||
34 | #endif | ||
35 | #define VT1724_SUBDEVICE_AV710 0x12142417 /* AV710 - the same ID with Audio2000! */ | ||
36 | |||
37 | /* WM8728 on I2C for AV710 */ | ||
38 | #define WM_DEV 0x36 | ||
39 | |||
40 | #define WM_ATTEN_L 0x00 | ||
41 | #define WM_ATTEN_R 0x01 | ||
42 | #define WM_DAC_CTRL 0x02 | ||
43 | #define WM_INT_CTRL 0x03 | ||
30 | 44 | ||
31 | extern struct snd_ice1712_card_info snd_vt1724_amp_cards[]; | 45 | extern struct snd_ice1712_card_info snd_vt1724_amp_cards[]; |
32 | 46 | ||
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 79fba6be3503..a2545a5b26c4 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c | |||
@@ -2748,7 +2748,7 @@ static struct pci_driver driver = { | |||
2748 | 2748 | ||
2749 | static int __init alsa_card_ice1712_init(void) | 2749 | static int __init alsa_card_ice1712_init(void) |
2750 | { | 2750 | { |
2751 | return pci_module_init(&driver); | 2751 | return pci_register_driver(&driver); |
2752 | } | 2752 | } |
2753 | 2753 | ||
2754 | static void __exit alsa_card_ice1712_exit(void) | 2754 | static void __exit alsa_card_ice1712_exit(void) |
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index 8bb1c58c26a0..5ad4728daa7b 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h | |||
@@ -373,6 +373,11 @@ struct _snd_ice1712 { | |||
373 | unsigned short master[2]; | 373 | unsigned short master[2]; |
374 | unsigned short vol[8]; | 374 | unsigned short vol[8]; |
375 | } aureon; | 375 | } aureon; |
376 | /* AC97 register cache for Phase28 */ | ||
377 | struct phase28_spec { | ||
378 | unsigned short master[2]; | ||
379 | unsigned short vol[8]; | ||
380 | } phase28; | ||
376 | /* Hoontech-specific setting */ | 381 | /* Hoontech-specific setting */ |
377 | struct hoontech_spec { | 382 | struct hoontech_spec { |
378 | unsigned char boxbits[4]; | 383 | unsigned char boxbits[4]; |
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 95500f06f0c6..79b5f12e06fc 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c | |||
@@ -2328,7 +2328,7 @@ static struct pci_driver driver = { | |||
2328 | 2328 | ||
2329 | static int __init alsa_card_ice1724_init(void) | 2329 | static int __init alsa_card_ice1724_init(void) |
2330 | { | 2330 | { |
2331 | return pci_module_init(&driver); | 2331 | return pci_register_driver(&driver); |
2332 | } | 2332 | } |
2333 | 2333 | ||
2334 | static void __exit alsa_card_ice1724_exit(void) | 2334 | static void __exit alsa_card_ice1724_exit(void) |
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c index d1f90832443c..5bf734b04fa0 100644 --- a/sound/pci/ice1712/phase.c +++ b/sound/pci/ice1712/phase.c | |||
@@ -45,6 +45,47 @@ | |||
45 | #include "envy24ht.h" | 45 | #include "envy24ht.h" |
46 | #include "phase.h" | 46 | #include "phase.h" |
47 | 47 | ||
48 | /* WM8770 registers */ | ||
49 | #define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */ | ||
50 | #define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */ | ||
51 | #define WM_DAC_DIG_ATTEN 0x09 /* DAC1-8 digital attenuation */ | ||
52 | #define WM_DAC_DIG_MASTER_ATTEN 0x11 /* DAC master digital attenuation */ | ||
53 | #define WM_PHASE_SWAP 0x12 /* DAC phase */ | ||
54 | #define WM_DAC_CTRL1 0x13 /* DAC control bits */ | ||
55 | #define WM_MUTE 0x14 /* mute controls */ | ||
56 | #define WM_DAC_CTRL2 0x15 /* de-emphasis and zefo-flag */ | ||
57 | #define WM_INT_CTRL 0x16 /* interface control */ | ||
58 | #define WM_MASTER 0x17 /* master clock and mode */ | ||
59 | #define WM_POWERDOWN 0x18 /* power-down controls */ | ||
60 | #define WM_ADC_GAIN 0x19 /* ADC gain L(19)/R(1a) */ | ||
61 | #define WM_ADC_MUX 0x1b /* input MUX */ | ||
62 | #define WM_OUT_MUX1 0x1c /* output MUX */ | ||
63 | #define WM_OUT_MUX2 0x1e /* output MUX */ | ||
64 | #define WM_RESET 0x1f /* software reset */ | ||
65 | |||
66 | |||
67 | /* | ||
68 | * Logarithmic volume values for WM8770 | ||
69 | * Computed as 20 * Log10(255 / x) | ||
70 | */ | ||
71 | static unsigned char wm_vol[256] = { | ||
72 | 127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23, | ||
73 | 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17, | ||
74 | 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13, | ||
75 | 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, | ||
76 | 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, | ||
77 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, | ||
78 | 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | ||
79 | 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, | ||
80 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
81 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
82 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
83 | 0, 0 | ||
84 | }; | ||
85 | |||
86 | #define WM_VOL_MAX (sizeof(wm_vol) - 1) | ||
87 | #define WM_VOL_MUTE 0x8000 | ||
88 | |||
48 | static akm4xxx_t akm_phase22 __devinitdata = { | 89 | static akm4xxx_t akm_phase22 __devinitdata = { |
49 | .type = SND_AK4524, | 90 | .type = SND_AK4524, |
50 | .num_dacs = 2, | 91 | .num_dacs = 2, |
@@ -124,6 +165,684 @@ static unsigned char phase22_eeprom[] __devinitdata = { | |||
124 | 0x00, /* GPIO_STATE2 */ | 165 | 0x00, /* GPIO_STATE2 */ |
125 | }; | 166 | }; |
126 | 167 | ||
168 | static unsigned char phase28_eeprom[] __devinitdata = { | ||
169 | 0x0b, /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */ | ||
170 | 0x80, /* ACLINK: I2S */ | ||
171 | 0xfc, /* I2S: vol, 96k, 24bit, 192k */ | ||
172 | 0xc3, /* SPDIF: out-en, out-int, spdif-in */ | ||
173 | 0xff, /* GPIO_DIR */ | ||
174 | 0xff, /* GPIO_DIR1 */ | ||
175 | 0x5f, /* GPIO_DIR2 */ | ||
176 | 0x00, /* GPIO_MASK */ | ||
177 | 0x00, /* GPIO_MASK1 */ | ||
178 | 0x00, /* GPIO_MASK2 */ | ||
179 | 0x00, /* GPIO_STATE */ | ||
180 | 0x00, /* GPIO_STATE1 */ | ||
181 | 0x00, /* GPIO_STATE2 */ | ||
182 | }; | ||
183 | |||
184 | /* | ||
185 | * write data in the SPI mode | ||
186 | */ | ||
187 | static void phase28_spi_write(ice1712_t *ice, unsigned int cs, unsigned int data, int bits) | ||
188 | { | ||
189 | unsigned int tmp; | ||
190 | int i; | ||
191 | |||
192 | tmp = snd_ice1712_gpio_read(ice); | ||
193 | |||
194 | snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RW|PHASE28_SPI_MOSI|PHASE28_SPI_CLK| | ||
195 | PHASE28_WM_CS)); | ||
196 | tmp |= PHASE28_WM_RW; | ||
197 | tmp &= ~cs; | ||
198 | snd_ice1712_gpio_write(ice, tmp); | ||
199 | udelay(1); | ||
200 | |||
201 | for (i = bits - 1; i >= 0; i--) { | ||
202 | tmp &= ~PHASE28_SPI_CLK; | ||
203 | snd_ice1712_gpio_write(ice, tmp); | ||
204 | udelay(1); | ||
205 | if (data & (1 << i)) | ||
206 | tmp |= PHASE28_SPI_MOSI; | ||
207 | else | ||
208 | tmp &= ~PHASE28_SPI_MOSI; | ||
209 | snd_ice1712_gpio_write(ice, tmp); | ||
210 | udelay(1); | ||
211 | tmp |= PHASE28_SPI_CLK; | ||
212 | snd_ice1712_gpio_write(ice, tmp); | ||
213 | udelay(1); | ||
214 | } | ||
215 | |||
216 | tmp &= ~PHASE28_SPI_CLK; | ||
217 | tmp |= cs; | ||
218 | snd_ice1712_gpio_write(ice, tmp); | ||
219 | udelay(1); | ||
220 | tmp |= PHASE28_SPI_CLK; | ||
221 | snd_ice1712_gpio_write(ice, tmp); | ||
222 | udelay(1); | ||
223 | } | ||
224 | |||
225 | /* | ||
226 | * get the current register value of WM codec | ||
227 | */ | ||
228 | static unsigned short wm_get(ice1712_t *ice, int reg) | ||
229 | { | ||
230 | reg <<= 1; | ||
231 | return ((unsigned short)ice->akm[0].images[reg] << 8) | | ||
232 | ice->akm[0].images[reg + 1]; | ||
233 | } | ||
234 | |||
235 | /* | ||
236 | * set the register value of WM codec | ||
237 | */ | ||
238 | static void wm_put_nocache(ice1712_t *ice, int reg, unsigned short val) | ||
239 | { | ||
240 | phase28_spi_write(ice, PHASE28_WM_CS, (reg << 9) | (val & 0x1ff), 16); | ||
241 | } | ||
242 | |||
243 | /* | ||
244 | * set the register value of WM codec and remember it | ||
245 | */ | ||
246 | static void wm_put(ice1712_t *ice, int reg, unsigned short val) | ||
247 | { | ||
248 | wm_put_nocache(ice, reg, val); | ||
249 | reg <<= 1; | ||
250 | ice->akm[0].images[reg] = val >> 8; | ||
251 | ice->akm[0].images[reg + 1] = val; | ||
252 | } | ||
253 | |||
254 | static void wm_set_vol(ice1712_t *ice, unsigned int index, unsigned short vol, unsigned short master) | ||
255 | { | ||
256 | unsigned char nvol; | ||
257 | |||
258 | if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) | ||
259 | nvol = 0; | ||
260 | else | ||
261 | nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX]; | ||
262 | |||
263 | wm_put(ice, index, nvol); | ||
264 | wm_put_nocache(ice, index, 0x180 | nvol); | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | * DAC mute control | ||
269 | */ | ||
270 | #define wm_pcm_mute_info phase28_mono_bool_info | ||
271 | |||
272 | static int wm_pcm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
273 | { | ||
274 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
275 | |||
276 | down(&ice->gpio_mutex); | ||
277 | ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1; | ||
278 | up(&ice->gpio_mutex); | ||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | static int wm_pcm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
283 | { | ||
284 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
285 | unsigned short nval, oval; | ||
286 | int change; | ||
287 | |||
288 | snd_ice1712_save_gpio_status(ice); | ||
289 | oval = wm_get(ice, WM_MUTE); | ||
290 | nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10); | ||
291 | if ((change = (nval != oval))) | ||
292 | wm_put(ice, WM_MUTE, nval); | ||
293 | snd_ice1712_restore_gpio_status(ice); | ||
294 | |||
295 | return change; | ||
296 | } | ||
297 | |||
298 | /* | ||
299 | * Master volume attenuation mixer control | ||
300 | */ | ||
301 | static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
302 | { | ||
303 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
304 | uinfo->count = 2; | ||
305 | uinfo->value.integer.min = 0; | ||
306 | uinfo->value.integer.max = WM_VOL_MAX; | ||
307 | return 0; | ||
308 | } | ||
309 | |||
310 | static int wm_master_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
311 | { | ||
312 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
313 | int i; | ||
314 | for (i=0; i<2; i++) | ||
315 | ucontrol->value.integer.value[i] = ice->spec.phase28.master[i] & ~WM_VOL_MUTE; | ||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
320 | { | ||
321 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
322 | int ch, change = 0; | ||
323 | |||
324 | snd_ice1712_save_gpio_status(ice); | ||
325 | for (ch = 0; ch < 2; ch++) { | ||
326 | if (ucontrol->value.integer.value[ch] != ice->spec.phase28.master[ch]) { | ||
327 | int dac; | ||
328 | ice->spec.phase28.master[ch] &= WM_VOL_MUTE; | ||
329 | ice->spec.phase28.master[ch] |= ucontrol->value.integer.value[ch]; | ||
330 | for (dac = 0; dac < ice->num_total_dacs; dac += 2) | ||
331 | wm_set_vol(ice, WM_DAC_ATTEN + dac + ch, | ||
332 | ice->spec.phase28.vol[dac + ch], | ||
333 | ice->spec.phase28.master[ch]); | ||
334 | change = 1; | ||
335 | } | ||
336 | } | ||
337 | snd_ice1712_restore_gpio_status(ice); | ||
338 | return change; | ||
339 | } | ||
340 | |||
341 | static int __devinit phase28_init(ice1712_t *ice) | ||
342 | { | ||
343 | static unsigned short wm_inits_phase28[] = { | ||
344 | /* These come first to reduce init pop noise */ | ||
345 | 0x1b, 0x044, /* ADC Mux (AC'97 source) */ | ||
346 | 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */ | ||
347 | 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */ | ||
348 | |||
349 | 0x18, 0x000, /* All power-up */ | ||
350 | |||
351 | 0x16, 0x122, /* I2S, normal polarity, 24bit */ | ||
352 | 0x17, 0x022, /* 256fs, slave mode */ | ||
353 | 0x00, 0, /* DAC1 analog mute */ | ||
354 | 0x01, 0, /* DAC2 analog mute */ | ||
355 | 0x02, 0, /* DAC3 analog mute */ | ||
356 | 0x03, 0, /* DAC4 analog mute */ | ||
357 | 0x04, 0, /* DAC5 analog mute */ | ||
358 | 0x05, 0, /* DAC6 analog mute */ | ||
359 | 0x06, 0, /* DAC7 analog mute */ | ||
360 | 0x07, 0, /* DAC8 analog mute */ | ||
361 | 0x08, 0x100, /* master analog mute */ | ||
362 | 0x09, 0xff, /* DAC1 digital full */ | ||
363 | 0x0a, 0xff, /* DAC2 digital full */ | ||
364 | 0x0b, 0xff, /* DAC3 digital full */ | ||
365 | 0x0c, 0xff, /* DAC4 digital full */ | ||
366 | 0x0d, 0xff, /* DAC5 digital full */ | ||
367 | 0x0e, 0xff, /* DAC6 digital full */ | ||
368 | 0x0f, 0xff, /* DAC7 digital full */ | ||
369 | 0x10, 0xff, /* DAC8 digital full */ | ||
370 | 0x11, 0x1ff, /* master digital full */ | ||
371 | 0x12, 0x000, /* phase normal */ | ||
372 | 0x13, 0x090, /* unmute DAC L/R */ | ||
373 | 0x14, 0x000, /* all unmute */ | ||
374 | 0x15, 0x000, /* no deemphasis, no ZFLG */ | ||
375 | 0x19, 0x000, /* -12dB ADC/L */ | ||
376 | 0x1a, 0x000, /* -12dB ADC/R */ | ||
377 | (unsigned short)-1 | ||
378 | }; | ||
379 | |||
380 | unsigned int tmp; | ||
381 | akm4xxx_t *ak; | ||
382 | unsigned short *p; | ||
383 | int i; | ||
384 | |||
385 | ice->num_total_dacs = 8; | ||
386 | ice->num_total_adcs = 2; | ||
387 | |||
388 | // Initialize analog chips | ||
389 | ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL); | ||
390 | if (!ak) | ||
391 | return -ENOMEM; | ||
392 | ice->akm_codecs = 1; | ||
393 | |||
394 | snd_ice1712_gpio_set_dir(ice, 0x5fffff); /* fix this for the time being */ | ||
395 | |||
396 | /* reset the wm codec as the SPI mode */ | ||
397 | snd_ice1712_save_gpio_status(ice); | ||
398 | snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RESET|PHASE28_WM_CS|PHASE28_HP_SEL)); | ||
399 | |||
400 | tmp = snd_ice1712_gpio_read(ice); | ||
401 | tmp &= ~PHASE28_WM_RESET; | ||
402 | snd_ice1712_gpio_write(ice, tmp); | ||
403 | udelay(1); | ||
404 | tmp |= PHASE28_WM_CS; | ||
405 | snd_ice1712_gpio_write(ice, tmp); | ||
406 | udelay(1); | ||
407 | tmp |= PHASE28_WM_RESET; | ||
408 | snd_ice1712_gpio_write(ice, tmp); | ||
409 | udelay(1); | ||
410 | |||
411 | p = wm_inits_phase28; | ||
412 | for (; *p != (unsigned short)-1; p += 2) | ||
413 | wm_put(ice, p[0], p[1]); | ||
414 | |||
415 | snd_ice1712_restore_gpio_status(ice); | ||
416 | |||
417 | ice->spec.phase28.master[0] = WM_VOL_MUTE; | ||
418 | ice->spec.phase28.master[1] = WM_VOL_MUTE; | ||
419 | for (i = 0; i < ice->num_total_dacs; i++) { | ||
420 | ice->spec.phase28.vol[i] = WM_VOL_MUTE; | ||
421 | wm_set_vol(ice, i, ice->spec.phase28.vol[i], ice->spec.phase28.master[i % 2]); | ||
422 | } | ||
423 | |||
424 | return 0; | ||
425 | } | ||
426 | |||
427 | /* | ||
428 | * DAC volume attenuation mixer control | ||
429 | */ | ||
430 | static int wm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
431 | { | ||
432 | int voices = kcontrol->private_value >> 8; | ||
433 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
434 | uinfo->count = voices; | ||
435 | uinfo->value.integer.min = 0; /* mute (-101dB) */ | ||
436 | uinfo->value.integer.max = 0x7F; /* 0dB */ | ||
437 | return 0; | ||
438 | } | ||
439 | |||
440 | static int wm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
441 | { | ||
442 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
443 | int i, ofs, voices; | ||
444 | |||
445 | voices = kcontrol->private_value >> 8; | ||
446 | ofs = kcontrol->private_value & 0xff; | ||
447 | for (i = 0; i < voices; i++) | ||
448 | ucontrol->value.integer.value[i] = ice->spec.phase28.vol[ofs+i] & ~WM_VOL_MUTE; | ||
449 | return 0; | ||
450 | } | ||
451 | |||
452 | static int wm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
453 | { | ||
454 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
455 | int i, idx, ofs, voices; | ||
456 | int change = 0; | ||
457 | |||
458 | voices = kcontrol->private_value >> 8; | ||
459 | ofs = kcontrol->private_value & 0xff; | ||
460 | snd_ice1712_save_gpio_status(ice); | ||
461 | for (i = 0; i < voices; i++) { | ||
462 | idx = WM_DAC_ATTEN + ofs + i; | ||
463 | if (ucontrol->value.integer.value[i] != ice->spec.phase28.vol[ofs+i]) { | ||
464 | ice->spec.phase28.vol[ofs+i] &= WM_VOL_MUTE; | ||
465 | ice->spec.phase28.vol[ofs+i] |= ucontrol->value.integer.value[i]; | ||
466 | wm_set_vol(ice, idx, ice->spec.phase28.vol[ofs+i], | ||
467 | ice->spec.phase28.master[i]); | ||
468 | change = 1; | ||
469 | } | ||
470 | } | ||
471 | snd_ice1712_restore_gpio_status(ice); | ||
472 | return change; | ||
473 | } | ||
474 | |||
475 | /* | ||
476 | * WM8770 mute control | ||
477 | */ | ||
478 | static int wm_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { | ||
479 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
480 | uinfo->count = kcontrol->private_value >> 8; | ||
481 | uinfo->value.integer.min = 0; | ||
482 | uinfo->value.integer.max = 1; | ||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | static int wm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
487 | { | ||
488 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
489 | int voices, ofs, i; | ||
490 | |||
491 | voices = kcontrol->private_value >> 8; | ||
492 | ofs = kcontrol->private_value & 0xFF; | ||
493 | |||
494 | for (i = 0; i < voices; i++) | ||
495 | ucontrol->value.integer.value[i] = (ice->spec.phase28.vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1; | ||
496 | return 0; | ||
497 | } | ||
498 | |||
499 | static int wm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
500 | { | ||
501 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
502 | int change = 0, voices, ofs, i; | ||
503 | |||
504 | voices = kcontrol->private_value >> 8; | ||
505 | ofs = kcontrol->private_value & 0xFF; | ||
506 | |||
507 | snd_ice1712_save_gpio_status(ice); | ||
508 | for (i = 0; i < voices; i++) { | ||
509 | int val = (ice->spec.phase28.vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1; | ||
510 | if (ucontrol->value.integer.value[i] != val) { | ||
511 | ice->spec.phase28.vol[ofs + i] &= ~WM_VOL_MUTE; | ||
512 | ice->spec.phase28.vol[ofs + i] |= | ||
513 | ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE; | ||
514 | wm_set_vol(ice, ofs + i, ice->spec.phase28.vol[ofs + i], | ||
515 | ice->spec.phase28.master[i]); | ||
516 | change = 1; | ||
517 | } | ||
518 | } | ||
519 | snd_ice1712_restore_gpio_status(ice); | ||
520 | |||
521 | return change; | ||
522 | } | ||
523 | |||
524 | /* | ||
525 | * WM8770 master mute control | ||
526 | */ | ||
527 | static int wm_master_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { | ||
528 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
529 | uinfo->count = 2; | ||
530 | uinfo->value.integer.min = 0; | ||
531 | uinfo->value.integer.max = 1; | ||
532 | return 0; | ||
533 | } | ||
534 | |||
535 | static int wm_master_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
536 | { | ||
537 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
538 | |||
539 | ucontrol->value.integer.value[0] = (ice->spec.phase28.master[0] & WM_VOL_MUTE) ? 0 : 1; | ||
540 | ucontrol->value.integer.value[1] = (ice->spec.phase28.master[1] & WM_VOL_MUTE) ? 0 : 1; | ||
541 | return 0; | ||
542 | } | ||
543 | |||
544 | static int wm_master_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | ||
545 | { | ||
546 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
547 | int change = 0, i; | ||
548 | |||
549 | snd_ice1712_save_gpio_status(ice); | ||
550 | for (i = 0; i < 2; i++) { | ||
551 | int val = (ice->spec.phase28.master[i] & WM_VOL_MUTE) ? 0 : 1; | ||
552 | if (ucontrol->value.integer.value[i] != val) { | ||
553 | int dac; | ||
554 | ice->spec.phase28.master[i] &= ~WM_VOL_MUTE; | ||
555 | ice->spec.phase28.master[i] |= | ||
556 | ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE; | ||
557 | for (dac = 0; dac < ice->num_total_dacs; dac += 2) | ||
558 | wm_set_vol(ice, WM_DAC_ATTEN + dac + i, | ||
559 | ice->spec.phase28.vol[dac + i], | ||
560 | ice->spec.phase28.master[i]); | ||
561 | change = 1; | ||
562 | } | ||
563 | } | ||
564 | snd_ice1712_restore_gpio_status(ice); | ||
565 | |||
566 | return change; | ||
567 | } | ||
568 | |||
569 | /* digital master volume */ | ||
570 | #define PCM_0dB 0xff | ||
571 | #define PCM_RES 128 /* -64dB */ | ||
572 | #define PCM_MIN (PCM_0dB - PCM_RES) | ||
573 | static int wm_pcm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
574 | { | ||
575 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
576 | uinfo->count = 1; | ||
577 | uinfo->value.integer.min = 0; /* mute (-64dB) */ | ||
578 | uinfo->value.integer.max = PCM_RES; /* 0dB */ | ||
579 | return 0; | ||
580 | } | ||
581 | |||
582 | static int wm_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
583 | { | ||
584 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
585 | unsigned short val; | ||
586 | |||
587 | down(&ice->gpio_mutex); | ||
588 | val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; | ||
589 | val = val > PCM_MIN ? (val - PCM_MIN) : 0; | ||
590 | ucontrol->value.integer.value[0] = val; | ||
591 | up(&ice->gpio_mutex); | ||
592 | return 0; | ||
593 | } | ||
594 | |||
595 | static int wm_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
596 | { | ||
597 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
598 | unsigned short ovol, nvol; | ||
599 | int change = 0; | ||
600 | |||
601 | snd_ice1712_save_gpio_status(ice); | ||
602 | nvol = ucontrol->value.integer.value[0]; | ||
603 | nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff; | ||
604 | ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; | ||
605 | if (ovol != nvol) { | ||
606 | wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */ | ||
607 | wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100); /* update */ | ||
608 | change = 1; | ||
609 | } | ||
610 | snd_ice1712_restore_gpio_status(ice); | ||
611 | return change; | ||
612 | } | ||
613 | |||
614 | /* | ||
615 | */ | ||
616 | static int phase28_mono_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) | ||
617 | { | ||
618 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
619 | uinfo->count = 1; | ||
620 | uinfo->value.integer.min = 0; | ||
621 | uinfo->value.integer.max = 1; | ||
622 | return 0; | ||
623 | } | ||
624 | |||
625 | /* | ||
626 | * Deemphasis | ||
627 | */ | ||
628 | #define phase28_deemp_info phase28_mono_bool_info | ||
629 | |||
630 | static int phase28_deemp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
631 | { | ||
632 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
633 | ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf; | ||
634 | return 0; | ||
635 | } | ||
636 | |||
637 | static int phase28_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
638 | { | ||
639 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
640 | int temp, temp2; | ||
641 | temp2 = temp = wm_get(ice, WM_DAC_CTRL2); | ||
642 | if (ucontrol->value.integer.value[0]) | ||
643 | temp |= 0xf; | ||
644 | else | ||
645 | temp &= ~0xf; | ||
646 | if (temp != temp2) { | ||
647 | wm_put(ice, WM_DAC_CTRL2, temp); | ||
648 | return 1; | ||
649 | } | ||
650 | return 0; | ||
651 | } | ||
652 | |||
653 | /* | ||
654 | * ADC Oversampling | ||
655 | */ | ||
656 | static int phase28_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) | ||
657 | { | ||
658 | static char *texts[2] = { "128x", "64x" }; | ||
659 | |||
660 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
661 | uinfo->count = 1; | ||
662 | uinfo->value.enumerated.items = 2; | ||
663 | |||
664 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
665 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
666 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | ||
667 | |||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | static int phase28_oversampling_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
672 | { | ||
673 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
674 | ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8; | ||
675 | return 0; | ||
676 | } | ||
677 | |||
678 | static int phase28_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
679 | { | ||
680 | int temp, temp2; | ||
681 | ice1712_t *ice = snd_kcontrol_chip(kcontrol); | ||
682 | |||
683 | temp2 = temp = wm_get(ice, WM_MASTER); | ||
684 | |||
685 | if (ucontrol->value.enumerated.item[0]) | ||
686 | temp |= 0x8; | ||
687 | else | ||
688 | temp &= ~0x8; | ||
689 | |||
690 | if (temp != temp2) { | ||
691 | wm_put(ice, WM_MASTER, temp); | ||
692 | return 1; | ||
693 | } | ||
694 | return 0; | ||
695 | } | ||
696 | |||
697 | static snd_kcontrol_new_t phase28_dac_controls[] __devinitdata = { | ||
698 | { | ||
699 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
700 | .name = "Master Playback Switch", | ||
701 | .info = wm_master_mute_info, | ||
702 | .get = wm_master_mute_get, | ||
703 | .put = wm_master_mute_put | ||
704 | }, | ||
705 | { | ||
706 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
707 | .name = "Master Playback Volume", | ||
708 | .info = wm_master_vol_info, | ||
709 | .get = wm_master_vol_get, | ||
710 | .put = wm_master_vol_put | ||
711 | }, | ||
712 | { | ||
713 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
714 | .name = "Front Playback Switch", | ||
715 | .info = wm_mute_info, | ||
716 | .get = wm_mute_get, | ||
717 | .put = wm_mute_put, | ||
718 | .private_value = (2 << 8) | 0 | ||
719 | }, | ||
720 | { | ||
721 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
722 | .name = "Front Playback Volume", | ||
723 | .info = wm_vol_info, | ||
724 | .get = wm_vol_get, | ||
725 | .put = wm_vol_put, | ||
726 | .private_value = (2 << 8) | 0 | ||
727 | }, | ||
728 | { | ||
729 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
730 | .name = "Rear Playback Switch", | ||
731 | .info = wm_mute_info, | ||
732 | .get = wm_mute_get, | ||
733 | .put = wm_mute_put, | ||
734 | .private_value = (2 << 8) | 2 | ||
735 | }, | ||
736 | { | ||
737 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
738 | .name = "Rear Playback Volume", | ||
739 | .info = wm_vol_info, | ||
740 | .get = wm_vol_get, | ||
741 | .put = wm_vol_put, | ||
742 | .private_value = (2 << 8) | 2 | ||
743 | }, | ||
744 | { | ||
745 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
746 | .name = "Center Playback Switch", | ||
747 | .info = wm_mute_info, | ||
748 | .get = wm_mute_get, | ||
749 | .put = wm_mute_put, | ||
750 | .private_value = (1 << 8) | 4 | ||
751 | }, | ||
752 | { | ||
753 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
754 | .name = "Center Playback Volume", | ||
755 | .info = wm_vol_info, | ||
756 | .get = wm_vol_get, | ||
757 | .put = wm_vol_put, | ||
758 | .private_value = (1 << 8) | 4 | ||
759 | }, | ||
760 | { | ||
761 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
762 | .name = "LFE Playback Switch", | ||
763 | .info = wm_mute_info, | ||
764 | .get = wm_mute_get, | ||
765 | .put = wm_mute_put, | ||
766 | .private_value = (1 << 8) | 5 | ||
767 | }, | ||
768 | { | ||
769 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
770 | .name = "LFE Playback Volume", | ||
771 | .info = wm_vol_info, | ||
772 | .get = wm_vol_get, | ||
773 | .put = wm_vol_put, | ||
774 | .private_value = (1 << 8) | 5 | ||
775 | }, | ||
776 | { | ||
777 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
778 | .name = "Side Playback Switch", | ||
779 | .info = wm_mute_info, | ||
780 | .get = wm_mute_get, | ||
781 | .put = wm_mute_put, | ||
782 | .private_value = (2 << 8) | 6 | ||
783 | }, | ||
784 | { | ||
785 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
786 | .name = "Side Playback Volume", | ||
787 | .info = wm_vol_info, | ||
788 | .get = wm_vol_get, | ||
789 | .put = wm_vol_put, | ||
790 | .private_value = (2 << 8) | 6 | ||
791 | } | ||
792 | }; | ||
793 | |||
794 | static snd_kcontrol_new_t wm_controls[] __devinitdata = { | ||
795 | { | ||
796 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
797 | .name = "PCM Playback Switch", | ||
798 | .info = wm_pcm_mute_info, | ||
799 | .get = wm_pcm_mute_get, | ||
800 | .put = wm_pcm_mute_put | ||
801 | }, | ||
802 | { | ||
803 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
804 | .name = "PCM Playback Volume", | ||
805 | .info = wm_pcm_vol_info, | ||
806 | .get = wm_pcm_vol_get, | ||
807 | .put = wm_pcm_vol_put | ||
808 | }, | ||
809 | { | ||
810 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
811 | .name = "DAC Deemphasis Switch", | ||
812 | .info = phase28_deemp_info, | ||
813 | .get = phase28_deemp_get, | ||
814 | .put = phase28_deemp_put | ||
815 | }, | ||
816 | { | ||
817 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
818 | .name = "ADC Oversampling", | ||
819 | .info = phase28_oversampling_info, | ||
820 | .get = phase28_oversampling_get, | ||
821 | .put = phase28_oversampling_put | ||
822 | } | ||
823 | }; | ||
824 | |||
825 | static int __devinit phase28_add_controls(ice1712_t *ice) | ||
826 | { | ||
827 | unsigned int i, counts; | ||
828 | int err; | ||
829 | |||
830 | counts = ARRAY_SIZE(phase28_dac_controls); | ||
831 | for (i = 0; i < counts; i++) { | ||
832 | err = snd_ctl_add(ice->card, snd_ctl_new1(&phase28_dac_controls[i], ice)); | ||
833 | if (err < 0) | ||
834 | return err; | ||
835 | } | ||
836 | |||
837 | for (i = 0; i < ARRAY_SIZE(wm_controls); i++) { | ||
838 | err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice)); | ||
839 | if (err < 0) | ||
840 | return err; | ||
841 | } | ||
842 | |||
843 | return 0; | ||
844 | } | ||
845 | |||
127 | struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = { | 846 | struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = { |
128 | { | 847 | { |
129 | .subvendor = VT1724_SUBDEVICE_PHASE22, | 848 | .subvendor = VT1724_SUBDEVICE_PHASE22, |
@@ -134,5 +853,14 @@ struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = { | |||
134 | .eeprom_size = sizeof(phase22_eeprom), | 853 | .eeprom_size = sizeof(phase22_eeprom), |
135 | .eeprom_data = phase22_eeprom, | 854 | .eeprom_data = phase22_eeprom, |
136 | }, | 855 | }, |
856 | { | ||
857 | .subvendor = VT1724_SUBDEVICE_PHASE28, | ||
858 | .name = "Terratec PHASE 28", | ||
859 | .model = "phase28", | ||
860 | .chip_init = phase28_init, | ||
861 | .build_controls = phase28_add_controls, | ||
862 | .eeprom_size = sizeof(phase28_eeprom), | ||
863 | .eeprom_data = phase28_eeprom, | ||
864 | }, | ||
137 | { } /* terminator */ | 865 | { } /* terminator */ |
138 | }; | 866 | }; |
diff --git a/sound/pci/ice1712/phase.h b/sound/pci/ice1712/phase.h index 6230cf16989f..13e841b55488 100644 --- a/sound/pci/ice1712/phase.h +++ b/sound/pci/ice1712/phase.h | |||
@@ -24,11 +24,28 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #define PHASE_DEVICE_DESC "{Terratec,Phase 22}," | 27 | #define PHASE_DEVICE_DESC "{Terratec,Phase 22},"\ |
28 | "{Terratec,Phase 28}," | ||
28 | 29 | ||
29 | #define VT1724_SUBDEVICE_PHASE22 0x3b155011 | 30 | #define VT1724_SUBDEVICE_PHASE22 0x3b155011 |
31 | #define VT1724_SUBDEVICE_PHASE28 0x3b154911 | ||
30 | 32 | ||
31 | /* entry point */ | 33 | /* entry point */ |
32 | extern struct snd_ice1712_card_info snd_vt1724_phase_cards[]; | 34 | extern struct snd_ice1712_card_info snd_vt1724_phase_cards[]; |
33 | 35 | ||
36 | /* PHASE28 GPIO bits */ | ||
37 | #define PHASE28_SPI_MISO (1 << 21) | ||
38 | #define PHASE28_WM_RESET (1 << 20) | ||
39 | #define PHASE28_SPI_CLK (1 << 19) | ||
40 | #define PHASE28_SPI_MOSI (1 << 18) | ||
41 | #define PHASE28_WM_RW (1 << 17) | ||
42 | #define PHASE28_AC97_RESET (1 << 16) | ||
43 | #define PHASE28_DIGITAL_SEL1 (1 << 15) | ||
44 | #define PHASE28_HP_SEL (1 << 14) | ||
45 | #define PHASE28_WM_CS (1 << 12) | ||
46 | #define PHASE28_AC97_COMMIT (1 << 11) | ||
47 | #define PHASE28_AC97_ADDR (1 << 10) | ||
48 | #define PHASE28_AC97_DATA_LOW (1 << 9) | ||
49 | #define PHASE28_AC97_DATA_HIGH (1 << 8) | ||
50 | #define PHASE28_AC97_DATA_MASK 0xFF | ||
34 | #endif /* __SOUND_PHASE */ | 51 | #endif /* __SOUND_PHASE */ |
diff --git a/sound/pci/ice1712/vt1720_mobo.c b/sound/pci/ice1712/vt1720_mobo.c index 3bd92627231c..ab61e383024f 100644 --- a/sound/pci/ice1712/vt1720_mobo.c +++ b/sound/pci/ice1712/vt1720_mobo.c | |||
@@ -110,6 +110,15 @@ struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = { | |||
110 | .eeprom_size = sizeof(k8x800_eeprom), | 110 | .eeprom_size = sizeof(k8x800_eeprom), |
111 | .eeprom_data = k8x800_eeprom, | 111 | .eeprom_data = k8x800_eeprom, |
112 | }, | 112 | }, |
113 | { | ||
114 | .subvendor = VT1720_SUBDEVICE_SN25P, | ||
115 | .name = "Shuttle SN25P", | ||
116 | /* identical with k8x800 */ | ||
117 | .chip_init = k8x800_init, | ||
118 | .build_controls = k8x800_add_controls, | ||
119 | .eeprom_size = sizeof(k8x800_eeprom), | ||
120 | .eeprom_data = k8x800_eeprom, | ||
121 | }, | ||
113 | { } /* terminator */ | 122 | { } /* terminator */ |
114 | }; | 123 | }; |
115 | 124 | ||
diff --git a/sound/pci/ice1712/vt1720_mobo.h b/sound/pci/ice1712/vt1720_mobo.h index f949eb804cae..0b1b0ee1bea7 100644 --- a/sound/pci/ice1712/vt1720_mobo.h +++ b/sound/pci/ice1712/vt1720_mobo.h | |||
@@ -27,12 +27,14 @@ | |||
27 | #define VT1720_MOBO_DEVICE_DESC "{Albatron,K8X800 Pro II},"\ | 27 | #define VT1720_MOBO_DEVICE_DESC "{Albatron,K8X800 Pro II},"\ |
28 | "{Chaintech,ZNF3-150},"\ | 28 | "{Chaintech,ZNF3-150},"\ |
29 | "{Chaintech,ZNF3-250},"\ | 29 | "{Chaintech,ZNF3-250},"\ |
30 | "{Chaintech,9CJS}," | 30 | "{Chaintech,9CJS},"\ |
31 | "{Shuttle,SN25P}," | ||
31 | 32 | ||
32 | #define VT1720_SUBDEVICE_K8X800 0xf217052c | 33 | #define VT1720_SUBDEVICE_K8X800 0xf217052c |
33 | #define VT1720_SUBDEVICE_ZNF3_150 0x0f2741f6 | 34 | #define VT1720_SUBDEVICE_ZNF3_150 0x0f2741f6 |
34 | #define VT1720_SUBDEVICE_ZNF3_250 0x0f2745f6 | 35 | #define VT1720_SUBDEVICE_ZNF3_250 0x0f2745f6 |
35 | #define VT1720_SUBDEVICE_9CJS 0x0f272327 | 36 | #define VT1720_SUBDEVICE_9CJS 0x0f272327 |
37 | #define VT1720_SUBDEVICE_SN25P 0x97123650 | ||
36 | 38 | ||
37 | extern struct snd_ice1712_card_info snd_vt1720_mobo_cards[]; | 39 | extern struct snd_ice1712_card_info snd_vt1720_mobo_cards[]; |
38 | 40 | ||
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 8b33b12fa5dc..cc16f95f9cef 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
@@ -1725,229 +1725,235 @@ static struct ac97_pcm ac97_pcm_defs[] __devinitdata = { | |||
1725 | 1725 | ||
1726 | static struct ac97_quirk ac97_quirks[] __devinitdata = { | 1726 | static struct ac97_quirk ac97_quirks[] __devinitdata = { |
1727 | { | 1727 | { |
1728 | .vendor = 0x0e11, | 1728 | .subvendor = 0x0e11, |
1729 | .device = 0x008a, | 1729 | .subdevice = 0x008a, |
1730 | .name = "Compaq Evo W4000", /* AD1885 */ | 1730 | .name = "Compaq Evo W4000", /* AD1885 */ |
1731 | .type = AC97_TUNE_HP_ONLY | 1731 | .type = AC97_TUNE_HP_ONLY |
1732 | }, | 1732 | }, |
1733 | { | 1733 | { |
1734 | .vendor = 0x0e11, | 1734 | .subvendor = 0x0e11, |
1735 | .device = 0x00b8, | 1735 | .subdevice = 0x00b8, |
1736 | .name = "Compaq Evo D510C", | 1736 | .name = "Compaq Evo D510C", |
1737 | .type = AC97_TUNE_HP_ONLY | 1737 | .type = AC97_TUNE_HP_ONLY |
1738 | }, | 1738 | }, |
1739 | { | 1739 | { |
1740 | .vendor = 0x0e11, | 1740 | .subvendor = 0x0e11, |
1741 | .device = 0x0860, | 1741 | .subdevice = 0x0860, |
1742 | .name = "HP/Compaq nx7010", | 1742 | .name = "HP/Compaq nx7010", |
1743 | .type = AC97_TUNE_MUTE_LED | 1743 | .type = AC97_TUNE_MUTE_LED |
1744 | }, | 1744 | }, |
1745 | { | 1745 | { |
1746 | .vendor = 0x1014, | 1746 | .subvendor = 0x1014, |
1747 | .device = 0x1f00, | 1747 | .subdevice = 0x1f00, |
1748 | .name = "MS-9128", | 1748 | .name = "MS-9128", |
1749 | .type = AC97_TUNE_ALC_JACK | 1749 | .type = AC97_TUNE_ALC_JACK |
1750 | }, | 1750 | }, |
1751 | { | 1751 | { |
1752 | .vendor = 0x1028, | 1752 | .subvendor = 0x1028, |
1753 | .device = 0x00d8, | 1753 | .subdevice = 0x00d8, |
1754 | .name = "Dell Precision 530", /* AD1885 */ | 1754 | .name = "Dell Precision 530", /* AD1885 */ |
1755 | .type = AC97_TUNE_HP_ONLY | 1755 | .type = AC97_TUNE_HP_ONLY |
1756 | }, | 1756 | }, |
1757 | { | 1757 | { |
1758 | .vendor = 0x1028, | 1758 | .subvendor = 0x1028, |
1759 | .device = 0x010d, | 1759 | .subdevice = 0x010d, |
1760 | .name = "Dell", /* which model? AD1885 */ | 1760 | .name = "Dell", /* which model? AD1885 */ |
1761 | .type = AC97_TUNE_HP_ONLY | 1761 | .type = AC97_TUNE_HP_ONLY |
1762 | }, | 1762 | }, |
1763 | { | 1763 | { |
1764 | .vendor = 0x1028, | 1764 | .subvendor = 0x1028, |
1765 | .device = 0x0126, | 1765 | .subdevice = 0x0126, |
1766 | .name = "Dell Optiplex GX260", /* AD1981A */ | 1766 | .name = "Dell Optiplex GX260", /* AD1981A */ |
1767 | .type = AC97_TUNE_HP_ONLY | 1767 | .type = AC97_TUNE_HP_ONLY |
1768 | }, | 1768 | }, |
1769 | { | 1769 | { |
1770 | .vendor = 0x1028, | 1770 | .subvendor = 0x1028, |
1771 | .device = 0x012c, | 1771 | .subdevice = 0x012c, |
1772 | .name = "Dell Precision 650", /* AD1981A */ | 1772 | .name = "Dell Precision 650", /* AD1981A */ |
1773 | .type = AC97_TUNE_HP_ONLY | 1773 | .type = AC97_TUNE_HP_ONLY |
1774 | }, | 1774 | }, |
1775 | { | 1775 | { |
1776 | .vendor = 0x1028, | 1776 | .subvendor = 0x1028, |
1777 | .device = 0x012d, | 1777 | .subdevice = 0x012d, |
1778 | .name = "Dell Precision 450", /* AD1981B*/ | 1778 | .name = "Dell Precision 450", /* AD1981B*/ |
1779 | .type = AC97_TUNE_HP_ONLY | 1779 | .type = AC97_TUNE_HP_ONLY |
1780 | }, | 1780 | }, |
1781 | { | 1781 | { |
1782 | .vendor = 0x1028, | 1782 | .subvendor = 0x1028, |
1783 | .device = 0x0147, | 1783 | .subdevice = 0x0147, |
1784 | .name = "Dell", /* which model? AD1981B*/ | 1784 | .name = "Dell", /* which model? AD1981B*/ |
1785 | .type = AC97_TUNE_HP_ONLY | 1785 | .type = AC97_TUNE_HP_ONLY |
1786 | }, | 1786 | }, |
1787 | { | 1787 | { |
1788 | .vendor = 0x1028, | 1788 | .subvendor = 0x1028, |
1789 | .device = 0x0163, | 1789 | .subdevice = 0x0163, |
1790 | .name = "Dell Unknown", /* STAC9750/51 */ | 1790 | .name = "Dell Unknown", /* STAC9750/51 */ |
1791 | .type = AC97_TUNE_HP_ONLY | 1791 | .type = AC97_TUNE_HP_ONLY |
1792 | }, | 1792 | }, |
1793 | { | 1793 | { |
1794 | .vendor = 0x103c, | 1794 | .subvendor = 0x103c, |
1795 | .device = 0x006d, | 1795 | .subdevice = 0x006d, |
1796 | .name = "HP zv5000", | 1796 | .name = "HP zv5000", |
1797 | .type = AC97_TUNE_MUTE_LED /*AD1981B*/ | 1797 | .type = AC97_TUNE_MUTE_LED /*AD1981B*/ |
1798 | }, | 1798 | }, |
1799 | { /* FIXME: which codec? */ | 1799 | { /* FIXME: which codec? */ |
1800 | .vendor = 0x103c, | 1800 | .subvendor = 0x103c, |
1801 | .device = 0x00c3, | 1801 | .subdevice = 0x00c3, |
1802 | .name = "HP xw6000", | 1802 | .name = "HP xw6000", |
1803 | .type = AC97_TUNE_HP_ONLY | 1803 | .type = AC97_TUNE_HP_ONLY |
1804 | }, | 1804 | }, |
1805 | { | 1805 | { |
1806 | .vendor = 0x103c, | 1806 | .subvendor = 0x103c, |
1807 | .device = 0x088c, | 1807 | .subdevice = 0x088c, |
1808 | .name = "HP nc8000", | 1808 | .name = "HP nc8000", |
1809 | .type = AC97_TUNE_MUTE_LED | 1809 | .type = AC97_TUNE_MUTE_LED |
1810 | }, | 1810 | }, |
1811 | { | 1811 | { |
1812 | .vendor = 0x103c, | 1812 | .subvendor = 0x103c, |
1813 | .device = 0x0890, | 1813 | .subdevice = 0x0890, |
1814 | .name = "HP nc6000", | 1814 | .name = "HP nc6000", |
1815 | .type = AC97_TUNE_MUTE_LED | 1815 | .type = AC97_TUNE_MUTE_LED |
1816 | }, | 1816 | }, |
1817 | { | 1817 | { |
1818 | .vendor = 0x103c, | 1818 | .subvendor = 0x103c, |
1819 | .device = 0x129d, | 1819 | .subdevice = 0x129d, |
1820 | .name = "HP xw8000", | 1820 | .name = "HP xw8000", |
1821 | .type = AC97_TUNE_HP_ONLY | 1821 | .type = AC97_TUNE_HP_ONLY |
1822 | }, | 1822 | }, |
1823 | { | 1823 | { |
1824 | .vendor = 0x103c, | 1824 | .subvendor = 0x103c, |
1825 | .device = 0x12f1, | 1825 | .subdevice = 0x12f1, |
1826 | .name = "HP xw8200", /* AD1981B*/ | 1826 | .name = "HP xw8200", /* AD1981B*/ |
1827 | .type = AC97_TUNE_HP_ONLY | 1827 | .type = AC97_TUNE_HP_ONLY |
1828 | }, | 1828 | }, |
1829 | { | 1829 | { |
1830 | .vendor = 0x103c, | 1830 | .subvendor = 0x103c, |
1831 | .device = 0x12f2, | 1831 | .subdevice = 0x12f2, |
1832 | .name = "HP xw6200", | 1832 | .name = "HP xw6200", |
1833 | .type = AC97_TUNE_HP_ONLY | 1833 | .type = AC97_TUNE_HP_ONLY |
1834 | }, | 1834 | }, |
1835 | { | 1835 | { |
1836 | .vendor = 0x103c, | 1836 | .subvendor = 0x103c, |
1837 | .device = 0x3008, | 1837 | .subdevice = 0x3008, |
1838 | .name = "HP xw4200", /* AD1981B*/ | 1838 | .name = "HP xw4200", /* AD1981B*/ |
1839 | .type = AC97_TUNE_HP_ONLY | 1839 | .type = AC97_TUNE_HP_ONLY |
1840 | }, | 1840 | }, |
1841 | { | 1841 | { |
1842 | .vendor = 0x104d, | 1842 | .subvendor = 0x104d, |
1843 | .device = 0x8197, | 1843 | .subdevice = 0x8197, |
1844 | .name = "Sony S1XP", | 1844 | .name = "Sony S1XP", |
1845 | .type = AC97_TUNE_INV_EAPD | 1845 | .type = AC97_TUNE_INV_EAPD |
1846 | }, | 1846 | }, |
1847 | { | 1847 | { |
1848 | .vendor = 0x1043, | 1848 | .subvendor = 0x1043, |
1849 | .device = 0x80f3, | 1849 | .subdevice = 0x80f3, |
1850 | .name = "ASUS ICH5/AD1985", | 1850 | .name = "ASUS ICH5/AD1985", |
1851 | .type = AC97_TUNE_AD_SHARING | 1851 | .type = AC97_TUNE_AD_SHARING |
1852 | }, | 1852 | }, |
1853 | { | 1853 | { |
1854 | .vendor = 0x10cf, | 1854 | .subvendor = 0x10cf, |
1855 | .device = 0x11c3, | 1855 | .subdevice = 0x11c3, |
1856 | .name = "Fujitsu-Siemens E4010", | 1856 | .name = "Fujitsu-Siemens E4010", |
1857 | .type = AC97_TUNE_HP_ONLY | 1857 | .type = AC97_TUNE_HP_ONLY |
1858 | }, | 1858 | }, |
1859 | { | 1859 | { |
1860 | .vendor = 0x10cf, | 1860 | .subvendor = 0x10cf, |
1861 | .device = 0x1253, | 1861 | .subdevice = 0x1225, |
1862 | .name = "Fujitsu-Siemens T3010", | ||
1863 | .type = AC97_TUNE_HP_ONLY | ||
1864 | }, | ||
1865 | { | ||
1866 | .subvendor = 0x10cf, | ||
1867 | .subdevice = 0x1253, | ||
1862 | .name = "Fujitsu S6210", /* STAC9750/51 */ | 1868 | .name = "Fujitsu S6210", /* STAC9750/51 */ |
1863 | .type = AC97_TUNE_HP_ONLY | 1869 | .type = AC97_TUNE_HP_ONLY |
1864 | }, | 1870 | }, |
1865 | { | 1871 | { |
1866 | .vendor = 0x10f1, | 1872 | .subvendor = 0x10f1, |
1867 | .device = 0x2665, | 1873 | .subdevice = 0x2665, |
1868 | .name = "Fujitsu-Siemens Celsius", /* AD1981? */ | 1874 | .name = "Fujitsu-Siemens Celsius", /* AD1981? */ |
1869 | .type = AC97_TUNE_HP_ONLY | 1875 | .type = AC97_TUNE_HP_ONLY |
1870 | }, | 1876 | }, |
1871 | { | 1877 | { |
1872 | .vendor = 0x10f1, | 1878 | .subvendor = 0x10f1, |
1873 | .device = 0x2885, | 1879 | .subdevice = 0x2885, |
1874 | .name = "AMD64 Mobo", /* ALC650 */ | 1880 | .name = "AMD64 Mobo", /* ALC650 */ |
1875 | .type = AC97_TUNE_HP_ONLY | 1881 | .type = AC97_TUNE_HP_ONLY |
1876 | }, | 1882 | }, |
1877 | { | 1883 | { |
1878 | .vendor = 0x110a, | 1884 | .subvendor = 0x110a, |
1879 | .device = 0x0056, | 1885 | .subdevice = 0x0056, |
1880 | .name = "Fujitsu-Siemens Scenic", /* AD1981? */ | 1886 | .name = "Fujitsu-Siemens Scenic", /* AD1981? */ |
1881 | .type = AC97_TUNE_HP_ONLY | 1887 | .type = AC97_TUNE_HP_ONLY |
1882 | }, | 1888 | }, |
1883 | { | 1889 | { |
1884 | .vendor = 0x11d4, | 1890 | .subvendor = 0x11d4, |
1885 | .device = 0x5375, | 1891 | .subdevice = 0x5375, |
1886 | .name = "ADI AD1985 (discrete)", | 1892 | .name = "ADI AD1985 (discrete)", |
1887 | .type = AC97_TUNE_HP_ONLY | 1893 | .type = AC97_TUNE_HP_ONLY |
1888 | }, | 1894 | }, |
1889 | { | 1895 | { |
1890 | .vendor = 0x1462, | 1896 | .subvendor = 0x1462, |
1891 | .device = 0x5470, | 1897 | .subdevice = 0x5470, |
1892 | .name = "MSI P4 ATX 645 Ultra", | 1898 | .name = "MSI P4 ATX 645 Ultra", |
1893 | .type = AC97_TUNE_HP_ONLY | 1899 | .type = AC97_TUNE_HP_ONLY |
1894 | }, | 1900 | }, |
1895 | { | 1901 | { |
1896 | .vendor = 0x1734, | 1902 | .subvendor = 0x1734, |
1897 | .device = 0x0088, | 1903 | .subdevice = 0x0088, |
1898 | .name = "Fujitsu-Siemens D1522", /* AD1981 */ | 1904 | .name = "Fujitsu-Siemens D1522", /* AD1981 */ |
1899 | .type = AC97_TUNE_HP_ONLY | 1905 | .type = AC97_TUNE_HP_ONLY |
1900 | }, | 1906 | }, |
1901 | { | 1907 | { |
1902 | .vendor = 0x8086, | 1908 | .subvendor = 0x8086, |
1903 | .device = 0x2000, | 1909 | .subdevice = 0x2000, |
1904 | .mask = 0xfff0, | 1910 | .mask = 0xfff0, |
1905 | .name = "Intel ICH5/AD1985", | 1911 | .name = "Intel ICH5/AD1985", |
1906 | .type = AC97_TUNE_AD_SHARING | 1912 | .type = AC97_TUNE_AD_SHARING |
1907 | }, | 1913 | }, |
1908 | { | 1914 | { |
1909 | .vendor = 0x8086, | 1915 | .subvendor = 0x8086, |
1910 | .device = 0x4000, | 1916 | .subdevice = 0x4000, |
1911 | .mask = 0xfff0, | 1917 | .mask = 0xfff0, |
1912 | .name = "Intel ICH5/AD1985", | 1918 | .name = "Intel ICH5/AD1985", |
1913 | .type = AC97_TUNE_AD_SHARING | 1919 | .type = AC97_TUNE_AD_SHARING |
1914 | }, | 1920 | }, |
1915 | { | 1921 | { |
1916 | .vendor = 0x8086, | 1922 | .subvendor = 0x8086, |
1917 | .device = 0x4856, | 1923 | .subdevice = 0x4856, |
1918 | .name = "Intel D845WN (82801BA)", | 1924 | .name = "Intel D845WN (82801BA)", |
1919 | .type = AC97_TUNE_SWAP_HP | 1925 | .type = AC97_TUNE_SWAP_HP |
1920 | }, | 1926 | }, |
1921 | { | 1927 | { |
1922 | .vendor = 0x8086, | 1928 | .subvendor = 0x8086, |
1923 | .device = 0x4d44, | 1929 | .subdevice = 0x4d44, |
1924 | .name = "Intel D850EMV2", /* AD1885 */ | 1930 | .name = "Intel D850EMV2", /* AD1885 */ |
1925 | .type = AC97_TUNE_HP_ONLY | 1931 | .type = AC97_TUNE_HP_ONLY |
1926 | }, | 1932 | }, |
1927 | { | 1933 | { |
1928 | .vendor = 0x8086, | 1934 | .subvendor = 0x8086, |
1929 | .device = 0x4d56, | 1935 | .subdevice = 0x4d56, |
1930 | .name = "Intel ICH/AD1885", | 1936 | .name = "Intel ICH/AD1885", |
1931 | .type = AC97_TUNE_HP_ONLY | 1937 | .type = AC97_TUNE_HP_ONLY |
1932 | }, | 1938 | }, |
1933 | { | 1939 | { |
1934 | .vendor = 0x8086, | 1940 | .subvendor = 0x8086, |
1935 | .device = 0x6000, | 1941 | .subdevice = 0x6000, |
1936 | .mask = 0xfff0, | 1942 | .mask = 0xfff0, |
1937 | .name = "Intel ICH5/AD1985", | 1943 | .name = "Intel ICH5/AD1985", |
1938 | .type = AC97_TUNE_AD_SHARING | 1944 | .type = AC97_TUNE_AD_SHARING |
1939 | }, | 1945 | }, |
1940 | { | 1946 | { |
1941 | .vendor = 0x8086, | 1947 | .subvendor = 0x8086, |
1942 | .device = 0xe000, | 1948 | .subdevice = 0xe000, |
1943 | .mask = 0xfff0, | 1949 | .mask = 0xfff0, |
1944 | .name = "Intel ICH5/AD1985", | 1950 | .name = "Intel ICH5/AD1985", |
1945 | .type = AC97_TUNE_AD_SHARING | 1951 | .type = AC97_TUNE_AD_SHARING |
1946 | }, | 1952 | }, |
1947 | #if 0 /* FIXME: this seems wrong on most boards */ | 1953 | #if 0 /* FIXME: this seems wrong on most boards */ |
1948 | { | 1954 | { |
1949 | .vendor = 0x8086, | 1955 | .subvendor = 0x8086, |
1950 | .device = 0xa000, | 1956 | .subdevice = 0xa000, |
1951 | .mask = 0xfff0, | 1957 | .mask = 0xfff0, |
1952 | .name = "Intel ICH5/AD1985", | 1958 | .name = "Intel ICH5/AD1985", |
1953 | .type = AC97_TUNE_HP_ONLY | 1959 | .type = AC97_TUNE_HP_ONLY |
@@ -2849,7 +2855,7 @@ static struct pci_driver driver = { | |||
2849 | 2855 | ||
2850 | static int __init alsa_card_intel8x0_init(void) | 2856 | static int __init alsa_card_intel8x0_init(void) |
2851 | { | 2857 | { |
2852 | return pci_module_init(&driver); | 2858 | return pci_register_driver(&driver); |
2853 | } | 2859 | } |
2854 | 2860 | ||
2855 | static void __exit alsa_card_intel8x0_exit(void) | 2861 | static void __exit alsa_card_intel8x0_exit(void) |
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 67da096d659b..bb758c77d211 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <sound/pcm.h> | 35 | #include <sound/pcm.h> |
36 | #include <sound/ac97_codec.h> | 36 | #include <sound/ac97_codec.h> |
37 | #include <sound/info.h> | 37 | #include <sound/info.h> |
38 | #include <sound/control.h> | ||
39 | #include <sound/initval.h> | 38 | #include <sound/initval.h> |
40 | 39 | ||
41 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); | 40 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); |
@@ -292,60 +291,9 @@ static struct pci_device_id snd_intel8x0m_ids[] = { | |||
292 | #endif | 291 | #endif |
293 | { 0, } | 292 | { 0, } |
294 | }; | 293 | }; |
295 | static int snd_intel8x0m_switch_default_get(snd_kcontrol_t *kcontrol, | ||
296 | snd_ctl_elem_value_t *ucontrol); | ||
297 | static int snd_intel8x0m_switch_default_put(snd_kcontrol_t *kcontrol, | ||
298 | snd_ctl_elem_value_t *ucontrol); | ||
299 | static int snd_intel8x0m_switch_default_info(snd_kcontrol_t *kcontrol, | ||
300 | snd_ctl_elem_info_t *uinfo); | ||
301 | |||
302 | #define PRIVATE_VALUE_INITIALIZER(r,m) (((r) & 0xffff) << 16 | ((m) & 0xffff)) | ||
303 | #define PRIVATE_VALUE_MASK(control) ((control)->private_value & 0xffff) | ||
304 | #define PRIVATE_VALUE_REG(control) (((control)->private_value >> 16) & 0xffff) | ||
305 | |||
306 | static snd_kcontrol_new_t snd_intel8x0m_mixer_switches[] __devinitdata = { | ||
307 | { .name = "Off-hook Switch", | ||
308 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
309 | .info = snd_intel8x0m_switch_default_info, | ||
310 | .get = snd_intel8x0m_switch_default_get, | ||
311 | .put = snd_intel8x0m_switch_default_put, | ||
312 | .private_value = PRIVATE_VALUE_INITIALIZER(AC97_GPIO_STATUS,AC97_GPIO_LINE1_OH) | ||
313 | } | ||
314 | }; | ||
315 | 294 | ||
316 | MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids); | 295 | MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids); |
317 | 296 | ||
318 | static int snd_intel8x0m_switch_default_info(snd_kcontrol_t *kcontrol, | ||
319 | snd_ctl_elem_info_t *uinfo) | ||
320 | { | ||
321 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
322 | uinfo->count = 1; | ||
323 | uinfo->value.integer.min = 0; | ||
324 | uinfo->value.integer.max = 1; | ||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | static int snd_intel8x0m_switch_default_get(snd_kcontrol_t *kcontrol, | ||
329 | snd_ctl_elem_value_t *ucontrol) | ||
330 | { | ||
331 | unsigned short mask = PRIVATE_VALUE_MASK(kcontrol); | ||
332 | unsigned short reg = PRIVATE_VALUE_REG(kcontrol); | ||
333 | intel8x0_t *chip = snd_kcontrol_chip(kcontrol); | ||
334 | unsigned int status; | ||
335 | status = snd_ac97_read(chip->ac97, reg) & mask ? 1 : 0; | ||
336 | ucontrol->value.integer.value[0] = status; | ||
337 | return 0; | ||
338 | } | ||
339 | static int snd_intel8x0m_switch_default_put(snd_kcontrol_t *kcontrol, | ||
340 | snd_ctl_elem_value_t *ucontrol) | ||
341 | { | ||
342 | unsigned short mask = PRIVATE_VALUE_MASK(kcontrol); | ||
343 | unsigned short reg = PRIVATE_VALUE_REG(kcontrol); | ||
344 | intel8x0_t *chip = snd_kcontrol_chip(kcontrol); | ||
345 | unsigned short new_status = ucontrol->value.integer.value[0] ? mask : ~mask; | ||
346 | return snd_ac97_update_bits(chip->ac97, reg, | ||
347 | mask, new_status); | ||
348 | } | ||
349 | /* | 297 | /* |
350 | * Lowlevel I/O - busmaster | 298 | * Lowlevel I/O - busmaster |
351 | */ | 299 | */ |
@@ -500,6 +448,8 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, | |||
500 | res = 0xffff; | 448 | res = 0xffff; |
501 | } | 449 | } |
502 | } | 450 | } |
451 | if (reg == AC97_GPIO_STATUS) | ||
452 | iagetword(chip, 0); /* clear semaphore */ | ||
503 | return res; | 453 | return res; |
504 | } | 454 | } |
505 | 455 | ||
@@ -698,21 +648,6 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substrea | |||
698 | return bytes_to_frames(substream->runtime, ptr); | 648 | return bytes_to_frames(substream->runtime, ptr); |
699 | } | 649 | } |
700 | 650 | ||
701 | static int snd_intel8x0m_pcm_trigger(snd_pcm_substream_t *substream, int cmd) | ||
702 | { | ||
703 | /* hook off/on on start/stop */ | ||
704 | /* Moved this to mixer control */ | ||
705 | switch (cmd) { | ||
706 | case SNDRV_PCM_TRIGGER_START: | ||
707 | break; | ||
708 | case SNDRV_PCM_TRIGGER_STOP: | ||
709 | break; | ||
710 | default: | ||
711 | return -EINVAL; | ||
712 | } | ||
713 | return snd_intel8x0_pcm_trigger(substream,cmd); | ||
714 | } | ||
715 | |||
716 | static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream) | 651 | static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream) |
717 | { | 652 | { |
718 | intel8x0_t *chip = snd_pcm_substream_chip(substream); | 653 | intel8x0_t *chip = snd_pcm_substream_chip(substream); |
@@ -808,7 +743,7 @@ static snd_pcm_ops_t snd_intel8x0m_playback_ops = { | |||
808 | .hw_params = snd_intel8x0_hw_params, | 743 | .hw_params = snd_intel8x0_hw_params, |
809 | .hw_free = snd_intel8x0_hw_free, | 744 | .hw_free = snd_intel8x0_hw_free, |
810 | .prepare = snd_intel8x0m_pcm_prepare, | 745 | .prepare = snd_intel8x0m_pcm_prepare, |
811 | .trigger = snd_intel8x0m_pcm_trigger, | 746 | .trigger = snd_intel8x0_pcm_trigger, |
812 | .pointer = snd_intel8x0_pcm_pointer, | 747 | .pointer = snd_intel8x0_pcm_pointer, |
813 | }; | 748 | }; |
814 | 749 | ||
@@ -819,7 +754,7 @@ static snd_pcm_ops_t snd_intel8x0m_capture_ops = { | |||
819 | .hw_params = snd_intel8x0_hw_params, | 754 | .hw_params = snd_intel8x0_hw_params, |
820 | .hw_free = snd_intel8x0_hw_free, | 755 | .hw_free = snd_intel8x0_hw_free, |
821 | .prepare = snd_intel8x0m_pcm_prepare, | 756 | .prepare = snd_intel8x0m_pcm_prepare, |
822 | .trigger = snd_intel8x0m_pcm_trigger, | 757 | .trigger = snd_intel8x0_pcm_trigger, |
823 | .pointer = snd_intel8x0_pcm_pointer, | 758 | .pointer = snd_intel8x0_pcm_pointer, |
824 | }; | 759 | }; |
825 | 760 | ||
@@ -947,7 +882,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock) | |||
947 | ac97_t *x97; | 882 | ac97_t *x97; |
948 | int err; | 883 | int err; |
949 | unsigned int glob_sta = 0; | 884 | unsigned int glob_sta = 0; |
950 | unsigned int idx; | ||
951 | static ac97_bus_ops_t ops = { | 885 | static ac97_bus_ops_t ops = { |
952 | .write = snd_intel8x0_codec_write, | 886 | .write = snd_intel8x0_codec_write, |
953 | .read = snd_intel8x0_codec_read, | 887 | .read = snd_intel8x0_codec_read, |
@@ -983,10 +917,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock) | |||
983 | chip->ichd[ICHD_MDMIN].ac97 = x97; | 917 | chip->ichd[ICHD_MDMIN].ac97 = x97; |
984 | chip->ichd[ICHD_MDMOUT].ac97 = x97; | 918 | chip->ichd[ICHD_MDMOUT].ac97 = x97; |
985 | } | 919 | } |
986 | for (idx = 0; idx < ARRAY_SIZE(snd_intel8x0m_mixer_switches); idx++) { | ||
987 | if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_intel8x0m_mixer_switches[idx], chip))) < 0) | ||
988 | goto __err; | ||
989 | } | ||
990 | 920 | ||
991 | chip->in_ac97_init = 0; | 921 | chip->in_ac97_init = 0; |
992 | return 0; | 922 | return 0; |
@@ -1450,7 +1380,7 @@ static struct pci_driver driver = { | |||
1450 | 1380 | ||
1451 | static int __init alsa_card_intel8x0m_init(void) | 1381 | static int __init alsa_card_intel8x0m_init(void) |
1452 | { | 1382 | { |
1453 | return pci_module_init(&driver); | 1383 | return pci_register_driver(&driver); |
1454 | } | 1384 | } |
1455 | 1385 | ||
1456 | static void __exit alsa_card_intel8x0m_exit(void) | 1386 | static void __exit alsa_card_intel8x0m_exit(void) |
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index bb1de2008176..79d8eda54f0d 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c | |||
@@ -2541,7 +2541,7 @@ static struct pci_driver driver = { | |||
2541 | 2541 | ||
2542 | static int __init alsa_card_korg1212_init(void) | 2542 | static int __init alsa_card_korg1212_init(void) |
2543 | { | 2543 | { |
2544 | return pci_module_init(&driver); | 2544 | return pci_register_driver(&driver); |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | static void __exit alsa_card_korg1212_exit(void) | 2547 | static void __exit alsa_card_korg1212_exit(void) |
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 2cf33083d7cc..096f15132853 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c | |||
@@ -779,6 +779,12 @@ struct m3_quirk { | |||
779 | (e.g. for IrDA on Dell Inspirons) */ | 779 | (e.g. for IrDA on Dell Inspirons) */ |
780 | }; | 780 | }; |
781 | 781 | ||
782 | struct m3_hv_quirk { | ||
783 | u16 vendor, device, subsystem_vendor, subsystem_device; | ||
784 | u32 config; /* ALLEGRO_CONFIG hardware volume bits */ | ||
785 | int is_omnibook; /* Do HP OmniBook GPIO magic? */ | ||
786 | }; | ||
787 | |||
782 | struct m3_list { | 788 | struct m3_list { |
783 | int curlen; | 789 | int curlen; |
784 | int mem_addr; | 790 | int mem_addr; |
@@ -828,6 +834,7 @@ struct snd_m3 { | |||
828 | 834 | ||
829 | struct pci_dev *pci; | 835 | struct pci_dev *pci; |
830 | struct m3_quirk *quirk; | 836 | struct m3_quirk *quirk; |
837 | struct m3_hv_quirk *hv_quirk; | ||
831 | 838 | ||
832 | int dacs_active; | 839 | int dacs_active; |
833 | int timer_users; | 840 | int timer_users; |
@@ -851,6 +858,11 @@ struct snd_m3 { | |||
851 | m3_dma_t *substreams; | 858 | m3_dma_t *substreams; |
852 | 859 | ||
853 | spinlock_t reg_lock; | 860 | spinlock_t reg_lock; |
861 | spinlock_t ac97_lock; | ||
862 | |||
863 | snd_kcontrol_t *master_switch; | ||
864 | snd_kcontrol_t *master_volume; | ||
865 | struct tasklet_struct hwvol_tq; | ||
854 | 866 | ||
855 | #ifdef CONFIG_PM | 867 | #ifdef CONFIG_PM |
856 | u16 *suspend_mem; | 868 | u16 *suspend_mem; |
@@ -968,6 +980,71 @@ static struct m3_quirk m3_quirk_list[] = { | |||
968 | { NULL } | 980 | { NULL } |
969 | }; | 981 | }; |
970 | 982 | ||
983 | /* These values came from the Windows driver. */ | ||
984 | static struct m3_hv_quirk m3_hv_quirk_list[] = { | ||
985 | /* Allegro chips */ | ||
986 | { 0x125D, 0x1988, 0x0E11, 0x002E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
987 | { 0x125D, 0x1988, 0x0E11, 0x0094, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
988 | { 0x125D, 0x1988, 0x0E11, 0xB112, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
989 | { 0x125D, 0x1988, 0x0E11, 0xB114, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
990 | { 0x125D, 0x1988, 0x103C, 0x0012, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
991 | { 0x125D, 0x1988, 0x103C, 0x0018, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
992 | { 0x125D, 0x1988, 0x103C, 0x001C, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
993 | { 0x125D, 0x1988, 0x103C, 0x001D, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
994 | { 0x125D, 0x1988, 0x103C, 0x001E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
995 | { 0x125D, 0x1988, 0x107B, 0x3350, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
996 | { 0x125D, 0x1988, 0x10F7, 0x8338, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
997 | { 0x125D, 0x1988, 0x10F7, 0x833C, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
998 | { 0x125D, 0x1988, 0x10F7, 0x833D, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
999 | { 0x125D, 0x1988, 0x10F7, 0x833E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1000 | { 0x125D, 0x1988, 0x10F7, 0x833F, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1001 | { 0x125D, 0x1988, 0x13BD, 0x1018, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1002 | { 0x125D, 0x1988, 0x13BD, 0x1019, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1003 | { 0x125D, 0x1988, 0x13BD, 0x101A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1004 | { 0x125D, 0x1988, 0x14FF, 0x0F03, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1005 | { 0x125D, 0x1988, 0x14FF, 0x0F04, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1006 | { 0x125D, 0x1988, 0x14FF, 0x0F05, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1007 | { 0x125D, 0x1988, 0x156D, 0xB400, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1008 | { 0x125D, 0x1988, 0x156D, 0xB795, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1009 | { 0x125D, 0x1988, 0x156D, 0xB797, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1010 | { 0x125D, 0x1988, 0x156D, 0xC700, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 }, | ||
1011 | { 0x125D, 0x1988, 0x1033, 0x80F1, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1012 | { 0x125D, 0x1988, 0x103C, 0x001A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, /* HP OmniBook 6100 */ | ||
1013 | { 0x125D, 0x1988, 0x107B, 0x340A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1014 | { 0x125D, 0x1988, 0x107B, 0x3450, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1015 | { 0x125D, 0x1988, 0x109F, 0x3134, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1016 | { 0x125D, 0x1988, 0x109F, 0x3161, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1017 | { 0x125D, 0x1988, 0x144D, 0x3280, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1018 | { 0x125D, 0x1988, 0x144D, 0x3281, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1019 | { 0x125D, 0x1988, 0x144D, 0xC002, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1020 | { 0x125D, 0x1988, 0x144D, 0xC003, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1021 | { 0x125D, 0x1988, 0x1509, 0x1740, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1022 | { 0x125D, 0x1988, 0x1610, 0x0010, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, | ||
1023 | { 0x125D, 0x1988, 0x1042, 0x1042, HV_CTRL_ENABLE, 0 }, | ||
1024 | { 0x125D, 0x1988, 0x107B, 0x9500, HV_CTRL_ENABLE, 0 }, | ||
1025 | { 0x125D, 0x1988, 0x14FF, 0x0F06, HV_CTRL_ENABLE, 0 }, | ||
1026 | { 0x125D, 0x1988, 0x1558, 0x8586, HV_CTRL_ENABLE, 0 }, | ||
1027 | { 0x125D, 0x1988, 0x161F, 0x2011, HV_CTRL_ENABLE, 0 }, | ||
1028 | /* Maestro3 chips */ | ||
1029 | { 0x125D, 0x1998, 0x103C, 0x000E, HV_CTRL_ENABLE, 0 }, | ||
1030 | { 0x125D, 0x1998, 0x103C, 0x0010, HV_CTRL_ENABLE, 1 }, /* HP OmniBook 6000 */ | ||
1031 | { 0x125D, 0x1998, 0x103C, 0x0011, HV_CTRL_ENABLE, 1 }, /* HP OmniBook 500 */ | ||
1032 | { 0x125D, 0x1998, 0x103C, 0x001B, HV_CTRL_ENABLE, 0 }, | ||
1033 | { 0x125D, 0x1998, 0x104D, 0x80A6, HV_CTRL_ENABLE, 0 }, | ||
1034 | { 0x125D, 0x1998, 0x104D, 0x80AA, HV_CTRL_ENABLE, 0 }, | ||
1035 | { 0x125D, 0x1998, 0x107B, 0x5300, HV_CTRL_ENABLE, 0 }, | ||
1036 | { 0x125D, 0x1998, 0x110A, 0x1998, HV_CTRL_ENABLE, 0 }, | ||
1037 | { 0x125D, 0x1998, 0x13BD, 0x1015, HV_CTRL_ENABLE, 0 }, | ||
1038 | { 0x125D, 0x1998, 0x13BD, 0x101C, HV_CTRL_ENABLE, 0 }, | ||
1039 | { 0x125D, 0x1998, 0x13BD, 0x1802, HV_CTRL_ENABLE, 0 }, | ||
1040 | { 0x125D, 0x1998, 0x1599, 0x0715, HV_CTRL_ENABLE, 0 }, | ||
1041 | { 0x125D, 0x1998, 0x5643, 0x5643, HV_CTRL_ENABLE, 0 }, | ||
1042 | { 0x125D, 0x199A, 0x144D, 0x3260, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 }, | ||
1043 | { 0x125D, 0x199A, 0x144D, 0x3261, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 }, | ||
1044 | { 0x125D, 0x199A, 0x144D, 0xC000, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 }, | ||
1045 | { 0x125D, 0x199A, 0x144D, 0xC001, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 }, | ||
1046 | { 0 } | ||
1047 | }; | ||
971 | 1048 | ||
972 | /* | 1049 | /* |
973 | * lowlevel functions | 1050 | * lowlevel functions |
@@ -1565,6 +1642,68 @@ static void snd_m3_update_ptr(m3_t *chip, m3_dma_t *s) | |||
1565 | } | 1642 | } |
1566 | } | 1643 | } |
1567 | 1644 | ||
1645 | static void snd_m3_update_hw_volume(unsigned long private_data) | ||
1646 | { | ||
1647 | m3_t *chip = (m3_t *) private_data; | ||
1648 | int x, val; | ||
1649 | unsigned long flags; | ||
1650 | |||
1651 | /* Figure out which volume control button was pushed, | ||
1652 | based on differences from the default register | ||
1653 | values. */ | ||
1654 | x = inb(chip->iobase + SHADOW_MIX_REG_VOICE) & 0xee; | ||
1655 | |||
1656 | /* Reset the volume control registers. */ | ||
1657 | outb(0x88, chip->iobase + SHADOW_MIX_REG_VOICE); | ||
1658 | outb(0x88, chip->iobase + HW_VOL_COUNTER_VOICE); | ||
1659 | outb(0x88, chip->iobase + SHADOW_MIX_REG_MASTER); | ||
1660 | outb(0x88, chip->iobase + HW_VOL_COUNTER_MASTER); | ||
1661 | |||
1662 | if (!chip->master_switch || !chip->master_volume) | ||
1663 | return; | ||
1664 | |||
1665 | /* FIXME: we can't call snd_ac97_* functions since here is in tasklet. */ | ||
1666 | spin_lock_irqsave(&chip->ac97_lock, flags); | ||
1667 | |||
1668 | val = chip->ac97->regs[AC97_MASTER_VOL]; | ||
1669 | switch (x) { | ||
1670 | case 0x88: | ||
1671 | /* mute */ | ||
1672 | val ^= 0x8000; | ||
1673 | chip->ac97->regs[AC97_MASTER_VOL] = val; | ||
1674 | outw(val, chip->iobase + CODEC_DATA); | ||
1675 | outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND); | ||
1676 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
1677 | &chip->master_switch->id); | ||
1678 | break; | ||
1679 | case 0xaa: | ||
1680 | /* volume up */ | ||
1681 | if ((val & 0x7f) > 0) | ||
1682 | val--; | ||
1683 | if ((val & 0x7f00) > 0) | ||
1684 | val -= 0x0100; | ||
1685 | chip->ac97->regs[AC97_MASTER_VOL] = val; | ||
1686 | outw(val, chip->iobase + CODEC_DATA); | ||
1687 | outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND); | ||
1688 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
1689 | &chip->master_volume->id); | ||
1690 | break; | ||
1691 | case 0x66: | ||
1692 | /* volume down */ | ||
1693 | if ((val & 0x7f) < 0x1f) | ||
1694 | val++; | ||
1695 | if ((val & 0x7f00) < 0x1f00) | ||
1696 | val += 0x0100; | ||
1697 | chip->ac97->regs[AC97_MASTER_VOL] = val; | ||
1698 | outw(val, chip->iobase + CODEC_DATA); | ||
1699 | outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND); | ||
1700 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
1701 | &chip->master_volume->id); | ||
1702 | break; | ||
1703 | } | ||
1704 | spin_unlock_irqrestore(&chip->ac97_lock, flags); | ||
1705 | } | ||
1706 | |||
1568 | static irqreturn_t | 1707 | static irqreturn_t |
1569 | snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 1708 | snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
1570 | { | 1709 | { |
@@ -1576,7 +1715,10 @@ snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
1576 | 1715 | ||
1577 | if (status == 0xff) | 1716 | if (status == 0xff) |
1578 | return IRQ_NONE; | 1717 | return IRQ_NONE; |
1579 | 1718 | ||
1719 | if (status & HV_INT_PENDING) | ||
1720 | tasklet_hi_schedule(&chip->hwvol_tq); | ||
1721 | |||
1580 | /* | 1722 | /* |
1581 | * ack an assp int if its running | 1723 | * ack an assp int if its running |
1582 | * and has an int pending | 1724 | * and has an int pending |
@@ -1605,7 +1747,7 @@ snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
1605 | #endif | 1747 | #endif |
1606 | 1748 | ||
1607 | /* ack ints */ | 1749 | /* ack ints */ |
1608 | snd_m3_outw(chip, HOST_INT_STATUS, status); | 1750 | outb(status, chip->iobase + HOST_INT_STATUS); |
1609 | 1751 | ||
1610 | return IRQ_HANDLED; | 1752 | return IRQ_HANDLED; |
1611 | } | 1753 | } |
@@ -1842,24 +1984,32 @@ static unsigned short | |||
1842 | snd_m3_ac97_read(ac97_t *ac97, unsigned short reg) | 1984 | snd_m3_ac97_read(ac97_t *ac97, unsigned short reg) |
1843 | { | 1985 | { |
1844 | m3_t *chip = ac97->private_data; | 1986 | m3_t *chip = ac97->private_data; |
1987 | unsigned long flags; | ||
1988 | unsigned short data; | ||
1845 | 1989 | ||
1846 | if (snd_m3_ac97_wait(chip)) | 1990 | if (snd_m3_ac97_wait(chip)) |
1847 | return 0xffff; | 1991 | return 0xffff; |
1992 | spin_lock_irqsave(&chip->ac97_lock, flags); | ||
1848 | snd_m3_outb(chip, 0x80 | (reg & 0x7f), CODEC_COMMAND); | 1993 | snd_m3_outb(chip, 0x80 | (reg & 0x7f), CODEC_COMMAND); |
1849 | if (snd_m3_ac97_wait(chip)) | 1994 | if (snd_m3_ac97_wait(chip)) |
1850 | return 0xffff; | 1995 | return 0xffff; |
1851 | return snd_m3_inw(chip, CODEC_DATA); | 1996 | data = snd_m3_inw(chip, CODEC_DATA); |
1997 | spin_unlock_irqrestore(&chip->ac97_lock, flags); | ||
1998 | return data; | ||
1852 | } | 1999 | } |
1853 | 2000 | ||
1854 | static void | 2001 | static void |
1855 | snd_m3_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) | 2002 | snd_m3_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) |
1856 | { | 2003 | { |
1857 | m3_t *chip = ac97->private_data; | 2004 | m3_t *chip = ac97->private_data; |
2005 | unsigned long flags; | ||
1858 | 2006 | ||
1859 | if (snd_m3_ac97_wait(chip)) | 2007 | if (snd_m3_ac97_wait(chip)) |
1860 | return; | 2008 | return; |
2009 | spin_lock_irqsave(&chip->ac97_lock, flags); | ||
1861 | snd_m3_outw(chip, val, CODEC_DATA); | 2010 | snd_m3_outw(chip, val, CODEC_DATA); |
1862 | snd_m3_outb(chip, reg & 0x7f, CODEC_COMMAND); | 2011 | snd_m3_outb(chip, reg & 0x7f, CODEC_COMMAND); |
2012 | spin_unlock_irqrestore(&chip->ac97_lock, flags); | ||
1863 | } | 2013 | } |
1864 | 2014 | ||
1865 | 2015 | ||
@@ -1968,6 +2118,7 @@ static int __devinit snd_m3_mixer(m3_t *chip) | |||
1968 | { | 2118 | { |
1969 | ac97_bus_t *pbus; | 2119 | ac97_bus_t *pbus; |
1970 | ac97_template_t ac97; | 2120 | ac97_template_t ac97; |
2121 | snd_ctl_elem_id_t id; | ||
1971 | int err; | 2122 | int err; |
1972 | static ac97_bus_ops_t ops = { | 2123 | static ac97_bus_ops_t ops = { |
1973 | .write = snd_m3_ac97_write, | 2124 | .write = snd_m3_ac97_write, |
@@ -1988,6 +2139,15 @@ static int __devinit snd_m3_mixer(m3_t *chip) | |||
1988 | schedule_timeout(HZ / 10); | 2139 | schedule_timeout(HZ / 10); |
1989 | snd_ac97_write(chip->ac97, AC97_PCM, 0); | 2140 | snd_ac97_write(chip->ac97, AC97_PCM, 0); |
1990 | 2141 | ||
2142 | memset(&id, 0, sizeof(id)); | ||
2143 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
2144 | strcpy(id.name, "Master Playback Switch"); | ||
2145 | chip->master_switch = snd_ctl_find_id(chip->card, &id); | ||
2146 | memset(&id, 0, sizeof(id)); | ||
2147 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
2148 | strcpy(id.name, "Master Playback Volume"); | ||
2149 | chip->master_volume = snd_ctl_find_id(chip->card, &id); | ||
2150 | |||
1991 | return 0; | 2151 | return 0; |
1992 | } | 2152 | } |
1993 | 2153 | ||
@@ -2293,6 +2453,7 @@ static int | |||
2293 | snd_m3_chip_init(m3_t *chip) | 2453 | snd_m3_chip_init(m3_t *chip) |
2294 | { | 2454 | { |
2295 | struct pci_dev *pcidev = chip->pci; | 2455 | struct pci_dev *pcidev = chip->pci; |
2456 | unsigned long io = chip->iobase; | ||
2296 | u32 n; | 2457 | u32 n; |
2297 | u16 w; | 2458 | u16 w; |
2298 | u8 t; /* makes as much sense as 'n', no? */ | 2459 | u8 t; /* makes as much sense as 'n', no? */ |
@@ -2303,8 +2464,27 @@ snd_m3_chip_init(m3_t *chip) | |||
2303 | DISABLE_LEGACY); | 2464 | DISABLE_LEGACY); |
2304 | pci_write_config_word(pcidev, PCI_LEGACY_AUDIO_CTRL, w); | 2465 | pci_write_config_word(pcidev, PCI_LEGACY_AUDIO_CTRL, w); |
2305 | 2466 | ||
2467 | if (chip->hv_quirk && chip->hv_quirk->is_omnibook) { | ||
2468 | /* | ||
2469 | * Volume buttons on some HP OmniBook laptops don't work | ||
2470 | * correctly. This makes them work for the most part. | ||
2471 | * | ||
2472 | * Volume up and down buttons on the laptop side work. | ||
2473 | * Fn+cursor_up (volme up) works. | ||
2474 | * Fn+cursor_down (volume down) doesn't work. | ||
2475 | * Fn+F7 (mute) works acts as volume up. | ||
2476 | */ | ||
2477 | outw(~(GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_MASK); | ||
2478 | outw(inw(io + GPIO_DIRECTION) & ~(GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_DIRECTION); | ||
2479 | outw((GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_DATA); | ||
2480 | outw(0xffff, io + GPIO_MASK); | ||
2481 | } | ||
2306 | pci_read_config_dword(pcidev, PCI_ALLEGRO_CONFIG, &n); | 2482 | pci_read_config_dword(pcidev, PCI_ALLEGRO_CONFIG, &n); |
2307 | n &= REDUCED_DEBOUNCE; | 2483 | n &= ~(HV_CTRL_ENABLE | REDUCED_DEBOUNCE | HV_BUTTON_FROM_GD); |
2484 | if (chip->hv_quirk) | ||
2485 | n |= chip->hv_quirk->config; | ||
2486 | /* For some reason we must always use reduced debounce. */ | ||
2487 | n |= REDUCED_DEBOUNCE; | ||
2308 | n |= PM_CTRL_ENABLE | CLK_DIV_BY_49 | USE_PCI_TIMING; | 2488 | n |= PM_CTRL_ENABLE | CLK_DIV_BY_49 | USE_PCI_TIMING; |
2309 | pci_write_config_dword(pcidev, PCI_ALLEGRO_CONFIG, n); | 2489 | pci_write_config_dword(pcidev, PCI_ALLEGRO_CONFIG, n); |
2310 | 2490 | ||
@@ -2332,6 +2512,12 @@ snd_m3_chip_init(m3_t *chip) | |||
2332 | 2512 | ||
2333 | outb(RUN_ASSP, chip->iobase + ASSP_CONTROL_B); | 2513 | outb(RUN_ASSP, chip->iobase + ASSP_CONTROL_B); |
2334 | 2514 | ||
2515 | outb(0x00, io + HARDWARE_VOL_CTRL); | ||
2516 | outb(0x88, io + SHADOW_MIX_REG_VOICE); | ||
2517 | outb(0x88, io + HW_VOL_COUNTER_VOICE); | ||
2518 | outb(0x88, io + SHADOW_MIX_REG_MASTER); | ||
2519 | outb(0x88, io + HW_VOL_COUNTER_MASTER); | ||
2520 | |||
2335 | return 0; | 2521 | return 0; |
2336 | } | 2522 | } |
2337 | 2523 | ||
@@ -2341,7 +2527,7 @@ snd_m3_enable_ints(m3_t *chip) | |||
2341 | unsigned long io = chip->iobase; | 2527 | unsigned long io = chip->iobase; |
2342 | 2528 | ||
2343 | /* TODO: MPU401 not supported yet */ | 2529 | /* TODO: MPU401 not supported yet */ |
2344 | outw(ASSP_INT_ENABLE /*| MPU401_INT_ENABLE*/, io + HOST_INT_CTRL); | 2530 | outw(ASSP_INT_ENABLE | HV_INT_ENABLE /*| MPU401_INT_ENABLE*/, io + HOST_INT_CTRL); |
2345 | outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE, | 2531 | outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE, |
2346 | io + ASSP_CONTROL_C); | 2532 | io + ASSP_CONTROL_C); |
2347 | } | 2533 | } |
@@ -2367,7 +2553,7 @@ static int snd_m3_free(m3_t *chip) | |||
2367 | kfree(chip->substreams); | 2553 | kfree(chip->substreams); |
2368 | } | 2554 | } |
2369 | if (chip->iobase) { | 2555 | if (chip->iobase) { |
2370 | snd_m3_outw(chip, HOST_INT_CTRL, 0); /* disable ints */ | 2556 | outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */ |
2371 | } | 2557 | } |
2372 | 2558 | ||
2373 | #ifdef CONFIG_PM | 2559 | #ifdef CONFIG_PM |
@@ -2486,7 +2672,7 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, | |||
2486 | m3_t *chip; | 2672 | m3_t *chip; |
2487 | int i, err; | 2673 | int i, err; |
2488 | struct m3_quirk *quirk; | 2674 | struct m3_quirk *quirk; |
2489 | u16 subsystem_vendor, subsystem_device; | 2675 | struct m3_hv_quirk *hv_quirk; |
2490 | static snd_device_ops_t ops = { | 2676 | static snd_device_ops_t ops = { |
2491 | .dev_free = snd_m3_dev_free, | 2677 | .dev_free = snd_m3_dev_free, |
2492 | }; | 2678 | }; |
@@ -2524,18 +2710,25 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, | |||
2524 | chip->pci = pci; | 2710 | chip->pci = pci; |
2525 | chip->irq = -1; | 2711 | chip->irq = -1; |
2526 | 2712 | ||
2527 | pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); | ||
2528 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); | ||
2529 | |||
2530 | for (quirk = m3_quirk_list; quirk->vendor; quirk++) { | 2713 | for (quirk = m3_quirk_list; quirk->vendor; quirk++) { |
2531 | if (subsystem_vendor == quirk->vendor && | 2714 | if (pci->subsystem_vendor == quirk->vendor && |
2532 | subsystem_device == quirk->device) { | 2715 | pci->subsystem_device == quirk->device) { |
2533 | printk(KERN_INFO "maestro3: enabled hack for '%s'\n", quirk->name); | 2716 | printk(KERN_INFO "maestro3: enabled hack for '%s'\n", quirk->name); |
2534 | chip->quirk = quirk; | 2717 | chip->quirk = quirk; |
2535 | break; | 2718 | break; |
2536 | } | 2719 | } |
2537 | } | 2720 | } |
2538 | 2721 | ||
2722 | for (hv_quirk = m3_hv_quirk_list; hv_quirk->vendor; hv_quirk++) { | ||
2723 | if (pci->vendor == hv_quirk->vendor && | ||
2724 | pci->device == hv_quirk->device && | ||
2725 | pci->subsystem_vendor == hv_quirk->subsystem_vendor && | ||
2726 | pci->subsystem_device == hv_quirk->subsystem_device) { | ||
2727 | chip->hv_quirk = hv_quirk; | ||
2728 | break; | ||
2729 | } | ||
2730 | } | ||
2731 | |||
2539 | chip->external_amp = enable_amp; | 2732 | chip->external_amp = enable_amp; |
2540 | if (amp_gpio >= 0 && amp_gpio <= 0x0f) | 2733 | if (amp_gpio >= 0 && amp_gpio <= 0x0f) |
2541 | chip->amp_gpio = amp_gpio; | 2734 | chip->amp_gpio = amp_gpio; |
@@ -2593,6 +2786,9 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, | |||
2593 | return err; | 2786 | return err; |
2594 | } | 2787 | } |
2595 | 2788 | ||
2789 | spin_lock_init(&chip->ac97_lock); | ||
2790 | tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip); | ||
2791 | |||
2596 | if ((err = snd_m3_mixer(chip)) < 0) | 2792 | if ((err = snd_m3_mixer(chip)) < 0) |
2597 | return err; | 2793 | return err; |
2598 | 2794 | ||
@@ -2702,7 +2898,7 @@ static struct pci_driver driver = { | |||
2702 | 2898 | ||
2703 | static int __init alsa_card_m3_init(void) | 2899 | static int __init alsa_card_m3_init(void) |
2704 | { | 2900 | { |
2705 | return pci_module_init(&driver); | 2901 | return pci_register_driver(&driver); |
2706 | } | 2902 | } |
2707 | 2903 | ||
2708 | static void __exit alsa_card_m3_exit(void) | 2904 | static void __exit alsa_card_m3_exit(void) |
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 65bb0f47af2c..082c0d0f73d2 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c | |||
@@ -1431,7 +1431,7 @@ static struct pci_driver driver = { | |||
1431 | 1431 | ||
1432 | static int __init alsa_card_mixart_init(void) | 1432 | static int __init alsa_card_mixart_init(void) |
1433 | { | 1433 | { |
1434 | return pci_module_init(&driver); | 1434 | return pci_register_driver(&driver); |
1435 | } | 1435 | } |
1436 | 1436 | ||
1437 | static void __exit alsa_card_mixart_exit(void) | 1437 | static void __exit alsa_card_mixart_exit(void) |
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 356fbeac6f9e..8a52091f8552 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c | |||
@@ -1645,7 +1645,7 @@ static struct pci_driver driver = { | |||
1645 | 1645 | ||
1646 | static int __init alsa_card_nm256_init(void) | 1646 | static int __init alsa_card_nm256_init(void) |
1647 | { | 1647 | { |
1648 | return pci_module_init(&driver); | 1648 | return pci_register_driver(&driver); |
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | static void __exit alsa_card_nm256_exit(void) | 1651 | static void __exit alsa_card_nm256_exit(void) |
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index b96acd5a57db..b7b554df6705 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c | |||
@@ -2031,7 +2031,7 @@ static struct pci_driver driver = { | |||
2031 | 2031 | ||
2032 | static int __init alsa_card_rme32_init(void) | 2032 | static int __init alsa_card_rme32_init(void) |
2033 | { | 2033 | { |
2034 | return pci_module_init(&driver); | 2034 | return pci_register_driver(&driver); |
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | static void __exit alsa_card_rme32_exit(void) | 2037 | static void __exit alsa_card_rme32_exit(void) |
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 8e2666841d21..10c4f45a913c 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c | |||
@@ -2437,7 +2437,7 @@ static struct pci_driver driver = { | |||
2437 | 2437 | ||
2438 | static int __init alsa_card_rme96_init(void) | 2438 | static int __init alsa_card_rme96_init(void) |
2439 | { | 2439 | { |
2440 | return pci_module_init(&driver); | 2440 | return pci_register_driver(&driver); |
2441 | } | 2441 | } |
2442 | 2442 | ||
2443 | static void __exit alsa_card_rme96_exit(void) | 2443 | static void __exit alsa_card_rme96_exit(void) |
diff --git a/sound/pci/rme9652/Makefile b/sound/pci/rme9652/Makefile index 917374c9cd40..d2c294e136f9 100644 --- a/sound/pci/rme9652/Makefile +++ b/sound/pci/rme9652/Makefile | |||
@@ -5,7 +5,9 @@ | |||
5 | 5 | ||
6 | snd-rme9652-objs := rme9652.o | 6 | snd-rme9652-objs := rme9652.o |
7 | snd-hdsp-objs := hdsp.o | 7 | snd-hdsp-objs := hdsp.o |
8 | snd-hdspm-objs := hdspm.o | ||
8 | 9 | ||
9 | # Toplevel Module Dependency | 10 | # Toplevel Module Dependency |
10 | obj-$(CONFIG_SND_RME9652) += snd-rme9652.o | 11 | obj-$(CONFIG_SND_RME9652) += snd-rme9652.o |
11 | obj-$(CONFIG_SND_HDSP) += snd-hdsp.o | 12 | obj-$(CONFIG_SND_HDSP) += snd-hdsp.o |
13 | obj-$(CONFIG_SND_HDSPM) +=snd-hdspm.o | ||
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 12efbf0fab54..a673cc438b91 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
@@ -559,18 +559,22 @@ static int snd_hammerfall_get_buffer(struct pci_dev *pci, struct snd_dma_buffer | |||
559 | { | 559 | { |
560 | dmab->dev.type = SNDRV_DMA_TYPE_DEV; | 560 | dmab->dev.type = SNDRV_DMA_TYPE_DEV; |
561 | dmab->dev.dev = snd_dma_pci_data(pci); | 561 | dmab->dev.dev = snd_dma_pci_data(pci); |
562 | if (! snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) { | 562 | if (snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) { |
563 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), | 563 | if (dmab->bytes >= size) |
564 | size, dmab) < 0) | 564 | return 0; |
565 | return -ENOMEM; | ||
566 | } | 565 | } |
566 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), | ||
567 | size, dmab) < 0) | ||
568 | return -ENOMEM; | ||
567 | return 0; | 569 | return 0; |
568 | } | 570 | } |
569 | 571 | ||
570 | static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci) | 572 | static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci) |
571 | { | 573 | { |
572 | if (dmab->area) | 574 | if (dmab->area) { |
575 | dmab->dev.dev = NULL; /* make it anonymous */ | ||
573 | snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci)); | 576 | snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci)); |
577 | } | ||
574 | } | 578 | } |
575 | 579 | ||
576 | 580 | ||
@@ -4912,19 +4916,9 @@ static int __devinit hdsp_request_fw_loader(hdsp_t *hdsp) | |||
4912 | release_firmware(fw); | 4916 | release_firmware(fw); |
4913 | return -EINVAL; | 4917 | return -EINVAL; |
4914 | } | 4918 | } |
4915 | #ifdef SNDRV_BIG_ENDIAN | 4919 | |
4916 | { | ||
4917 | int i; | ||
4918 | u32 *src = (u32*)fw->data; | ||
4919 | for (i = 0; i < ARRAY_SIZE(hdsp->firmware_cache); i++, src++) | ||
4920 | hdsp->firmware_cache[i] = ((*src & 0x000000ff) << 16) | | ||
4921 | ((*src & 0x0000ff00) << 8) | | ||
4922 | ((*src & 0x00ff0000) >> 8) | | ||
4923 | ((*src & 0xff000000) >> 16); | ||
4924 | } | ||
4925 | #else | ||
4926 | memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache)); | 4920 | memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache)); |
4927 | #endif | 4921 | |
4928 | release_firmware(fw); | 4922 | release_firmware(fw); |
4929 | 4923 | ||
4930 | hdsp->state |= HDSP_FirmwareCached; | 4924 | hdsp->state |= HDSP_FirmwareCached; |
@@ -5194,7 +5188,7 @@ static struct pci_driver driver = { | |||
5194 | 5188 | ||
5195 | static int __init alsa_card_hdsp_init(void) | 5189 | static int __init alsa_card_hdsp_init(void) |
5196 | { | 5190 | { |
5197 | return pci_module_init(&driver); | 5191 | return pci_register_driver(&driver); |
5198 | } | 5192 | } |
5199 | 5193 | ||
5200 | static void __exit alsa_card_hdsp_exit(void) | 5194 | static void __exit alsa_card_hdsp_exit(void) |
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c new file mode 100644 index 000000000000..9e86d0eb41ce --- /dev/null +++ b/sound/pci/rme9652/hdspm.c | |||
@@ -0,0 +1,3671 @@ | |||
1 | /* -*- linux-c -*- | ||
2 | * | ||
3 | * ALSA driver for RME Hammerfall DSP MADI audio interface(s) | ||
4 | * | ||
5 | * Copyright (c) 2003 Winfried Ritsch (IEM) | ||
6 | * code based on hdsp.c Paul Davis | ||
7 | * Marcus Andersson | ||
8 | * Thomas Charbonnel | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | * | ||
24 | */ | ||
25 | #include <sound/driver.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/delay.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/moduleparam.h> | ||
30 | #include <linux/slab.h> | ||
31 | #include <linux/pci.h> | ||
32 | #include <asm/io.h> | ||
33 | |||
34 | #include <sound/core.h> | ||
35 | #include <sound/control.h> | ||
36 | #include <sound/pcm.h> | ||
37 | #include <sound/info.h> | ||
38 | #include <sound/asoundef.h> | ||
39 | #include <sound/rawmidi.h> | ||
40 | #include <sound/hwdep.h> | ||
41 | #include <sound/initval.h> | ||
42 | |||
43 | #include <sound/hdspm.h> | ||
44 | |||
45 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | ||
46 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | ||
47 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ | ||
48 | |||
49 | /* Disable precise pointer at start */ | ||
50 | static int precise_ptr[SNDRV_CARDS]; | ||
51 | |||
52 | /* Send all playback to line outs */ | ||
53 | static int line_outs_monitor[SNDRV_CARDS]; | ||
54 | |||
55 | /* Enable Analog Outs on Channel 63/64 by default */ | ||
56 | static int enable_monitor[SNDRV_CARDS]; | ||
57 | |||
58 | module_param_array(index, int, NULL, 0444); | ||
59 | MODULE_PARM_DESC(index, "Index value for RME HDSPM interface."); | ||
60 | |||
61 | module_param_array(id, charp, NULL, 0444); | ||
62 | MODULE_PARM_DESC(id, "ID string for RME HDSPM interface."); | ||
63 | |||
64 | module_param_array(enable, bool, NULL, 0444); | ||
65 | MODULE_PARM_DESC(enable, "Enable/disable specific HDSPM soundcards."); | ||
66 | |||
67 | module_param_array(precise_ptr, bool, NULL, 0444); | ||
68 | MODULE_PARM_DESC(precise_ptr, "Enable precise pointer, or disable."); | ||
69 | |||
70 | module_param_array(line_outs_monitor, bool, NULL, 0444); | ||
71 | MODULE_PARM_DESC(line_outs_monitor, | ||
72 | "Send playback streams to analog outs by default."); | ||
73 | |||
74 | module_param_array(enable_monitor, bool, NULL, 0444); | ||
75 | MODULE_PARM_DESC(enable_monitor, | ||
76 | "Enable Analog Out on Channel 63/64 by default."); | ||
77 | |||
78 | MODULE_AUTHOR | ||
79 | ("Winfried Ritsch <ritsch_AT_iem.at>, Paul Davis <paul@linuxaudiosystems.com>, " | ||
80 | "Marcus Andersson, Thomas Charbonnel <thomas@undata.org>"); | ||
81 | MODULE_DESCRIPTION("RME HDSPM"); | ||
82 | MODULE_LICENSE("GPL"); | ||
83 | MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}"); | ||
84 | |||
85 | /* --- Write registers. --- | ||
86 | These are defined as byte-offsets from the iobase value. */ | ||
87 | |||
88 | #define HDSPM_controlRegister 64 | ||
89 | #define HDSPM_interruptConfirmation 96 | ||
90 | #define HDSPM_control2Reg 256 /* not in specs ???????? */ | ||
91 | #define HDSPM_midiDataOut0 352 /* just believe in old code */ | ||
92 | #define HDSPM_midiDataOut1 356 | ||
93 | |||
94 | /* DMA enable for 64 channels, only Bit 0 is relevant */ | ||
95 | #define HDSPM_outputEnableBase 512 /* 512-767 input DMA */ | ||
96 | #define HDSPM_inputEnableBase 768 /* 768-1023 output DMA */ | ||
97 | |||
98 | /* 16 page addresses for each of the 64 channels DMA buffer in and out | ||
99 | (each 64k=16*4k) Buffer must be 4k aligned (which is default i386 ????) */ | ||
100 | #define HDSPM_pageAddressBufferOut 8192 | ||
101 | #define HDSPM_pageAddressBufferIn (HDSPM_pageAddressBufferOut+64*16*4) | ||
102 | |||
103 | #define HDSPM_MADI_mixerBase 32768 /* 32768-65535 for 2x64x64 Fader */ | ||
104 | |||
105 | #define HDSPM_MATRIX_MIXER_SIZE 8192 /* = 2*64*64 * 4 Byte => 32kB */ | ||
106 | |||
107 | /* --- Read registers. --- | ||
108 | These are defined as byte-offsets from the iobase value */ | ||
109 | #define HDSPM_statusRegister 0 | ||
110 | #define HDSPM_statusRegister2 96 | ||
111 | |||
112 | #define HDSPM_midiDataIn0 360 | ||
113 | #define HDSPM_midiDataIn1 364 | ||
114 | |||
115 | /* status is data bytes in MIDI-FIFO (0-128) */ | ||
116 | #define HDSPM_midiStatusOut0 384 | ||
117 | #define HDSPM_midiStatusOut1 388 | ||
118 | #define HDSPM_midiStatusIn0 392 | ||
119 | #define HDSPM_midiStatusIn1 396 | ||
120 | |||
121 | |||
122 | /* the meters are regular i/o-mapped registers, but offset | ||
123 | considerably from the rest. the peak registers are reset | ||
124 | when read; the least-significant 4 bits are full-scale counters; | ||
125 | the actual peak value is in the most-significant 24 bits. | ||
126 | */ | ||
127 | #define HDSPM_MADI_peakrmsbase 4096 /* 4096-8191 2x64x32Bit Meters */ | ||
128 | |||
129 | /* --- Control Register bits --------- */ | ||
130 | #define HDSPM_Start (1<<0) /* start engine */ | ||
131 | |||
132 | #define HDSPM_Latency0 (1<<1) /* buffer size = 2^n */ | ||
133 | #define HDSPM_Latency1 (1<<2) /* where n is defined */ | ||
134 | #define HDSPM_Latency2 (1<<3) /* by Latency{2,1,0} */ | ||
135 | |||
136 | #define HDSPM_ClockModeMaster (1<<4) /* 1=Master, 0=Slave/Autosync */ | ||
137 | |||
138 | #define HDSPM_AudioInterruptEnable (1<<5) /* what do you think ? */ | ||
139 | |||
140 | #define HDSPM_Frequency0 (1<<6) /* 0=44.1kHz/88.2kHz 1=48kHz/96kHz */ | ||
141 | #define HDSPM_Frequency1 (1<<7) /* 0=32kHz/64kHz */ | ||
142 | #define HDSPM_DoubleSpeed (1<<8) /* 0=normal speed, 1=double speed */ | ||
143 | #define HDSPM_QuadSpeed (1<<31) /* quad speed bit, not implemented now */ | ||
144 | |||
145 | #define HDSPM_TX_64ch (1<<10) /* Output 64channel MODE=1, | ||
146 | 56channelMODE=0 */ | ||
147 | |||
148 | #define HDSPM_AutoInp (1<<11) /* Auto Input (takeover) == Safe Mode, | ||
149 | 0=off, 1=on */ | ||
150 | |||
151 | #define HDSPM_InputSelect0 (1<<14) /* Input select 0= optical, 1=coax */ | ||
152 | #define HDSPM_InputSelect1 (1<<15) /* should be 0 */ | ||
153 | |||
154 | #define HDSPM_SyncRef0 (1<<16) /* 0=WOrd, 1=MADI */ | ||
155 | #define HDSPM_SyncRef1 (1<<17) /* should be 0 */ | ||
156 | |||
157 | #define HDSPM_clr_tms (1<<19) /* clear track marker, do not use | ||
158 | AES additional bits in | ||
159 | lower 5 Audiodatabits ??? */ | ||
160 | |||
161 | #define HDSPM_Midi0InterruptEnable (1<<22) | ||
162 | #define HDSPM_Midi1InterruptEnable (1<<23) | ||
163 | |||
164 | #define HDSPM_LineOut (1<<24) /* Analog Out on channel 63/64 on=1, mute=0 */ | ||
165 | |||
166 | |||
167 | /* --- bit helper defines */ | ||
168 | #define HDSPM_LatencyMask (HDSPM_Latency0|HDSPM_Latency1|HDSPM_Latency2) | ||
169 | #define HDSPM_FrequencyMask (HDSPM_Frequency0|HDSPM_Frequency1) | ||
170 | #define HDSPM_InputMask (HDSPM_InputSelect0|HDSPM_InputSelect1) | ||
171 | #define HDSPM_InputOptical 0 | ||
172 | #define HDSPM_InputCoaxial (HDSPM_InputSelect0) | ||
173 | #define HDSPM_SyncRefMask (HDSPM_SyncRef0|HDSPM_SyncRef1) | ||
174 | #define HDSPM_SyncRef_Word 0 | ||
175 | #define HDSPM_SyncRef_MADI (HDSPM_SyncRef0) | ||
176 | |||
177 | #define HDSPM_SYNC_FROM_WORD 0 /* Preferred sync reference */ | ||
178 | #define HDSPM_SYNC_FROM_MADI 1 /* choices - used by "pref_sync_ref" */ | ||
179 | |||
180 | #define HDSPM_Frequency32KHz HDSPM_Frequency0 | ||
181 | #define HDSPM_Frequency44_1KHz HDSPM_Frequency1 | ||
182 | #define HDSPM_Frequency48KHz (HDSPM_Frequency1|HDSPM_Frequency0) | ||
183 | #define HDSPM_Frequency64KHz (HDSPM_DoubleSpeed|HDSPM_Frequency0) | ||
184 | #define HDSPM_Frequency88_2KHz (HDSPM_DoubleSpeed|HDSPM_Frequency1) | ||
185 | #define HDSPM_Frequency96KHz (HDSPM_DoubleSpeed|HDSPM_Frequency1|HDSPM_Frequency0) | ||
186 | |||
187 | /* --- for internal discrimination */ | ||
188 | #define HDSPM_CLOCK_SOURCE_AUTOSYNC 0 /* Sample Clock Sources */ | ||
189 | #define HDSPM_CLOCK_SOURCE_INTERNAL_32KHZ 1 | ||
190 | #define HDSPM_CLOCK_SOURCE_INTERNAL_44_1KHZ 2 | ||
191 | #define HDSPM_CLOCK_SOURCE_INTERNAL_48KHZ 3 | ||
192 | #define HDSPM_CLOCK_SOURCE_INTERNAL_64KHZ 4 | ||
193 | #define HDSPM_CLOCK_SOURCE_INTERNAL_88_2KHZ 5 | ||
194 | #define HDSPM_CLOCK_SOURCE_INTERNAL_96KHZ 6 | ||
195 | #define HDSPM_CLOCK_SOURCE_INTERNAL_128KHZ 7 | ||
196 | #define HDSPM_CLOCK_SOURCE_INTERNAL_176_4KHZ 8 | ||
197 | #define HDSPM_CLOCK_SOURCE_INTERNAL_192KHZ 9 | ||
198 | |||
199 | /* Synccheck Status */ | ||
200 | #define HDSPM_SYNC_CHECK_NO_LOCK 0 | ||
201 | #define HDSPM_SYNC_CHECK_LOCK 1 | ||
202 | #define HDSPM_SYNC_CHECK_SYNC 2 | ||
203 | |||
204 | /* AutoSync References - used by "autosync_ref" control switch */ | ||
205 | #define HDSPM_AUTOSYNC_FROM_WORD 0 | ||
206 | #define HDSPM_AUTOSYNC_FROM_MADI 1 | ||
207 | #define HDSPM_AUTOSYNC_FROM_NONE 2 | ||
208 | |||
209 | /* Possible sources of MADI input */ | ||
210 | #define HDSPM_OPTICAL 0 /* optical */ | ||
211 | #define HDSPM_COAXIAL 1 /* BNC */ | ||
212 | |||
213 | #define hdspm_encode_latency(x) (((x)<<1) & HDSPM_LatencyMask) | ||
214 | #define hdspm_decode_latency(x) (((x) & HDSPM_LatencyMask)>>1) | ||
215 | |||
216 | #define hdspm_encode_in(x) (((x)&0x3)<<14) | ||
217 | #define hdspm_decode_in(x) (((x)>>14)&0x3) | ||
218 | |||
219 | /* --- control2 register bits --- */ | ||
220 | #define HDSPM_TMS (1<<0) | ||
221 | #define HDSPM_TCK (1<<1) | ||
222 | #define HDSPM_TDI (1<<2) | ||
223 | #define HDSPM_JTAG (1<<3) | ||
224 | #define HDSPM_PWDN (1<<4) | ||
225 | #define HDSPM_PROGRAM (1<<5) | ||
226 | #define HDSPM_CONFIG_MODE_0 (1<<6) | ||
227 | #define HDSPM_CONFIG_MODE_1 (1<<7) | ||
228 | /*#define HDSPM_VERSION_BIT (1<<8) not defined any more*/ | ||
229 | #define HDSPM_BIGENDIAN_MODE (1<<9) | ||
230 | #define HDSPM_RD_MULTIPLE (1<<10) | ||
231 | |||
232 | /* --- Status Register bits --- */ | ||
233 | #define HDSPM_audioIRQPending (1<<0) /* IRQ is high and pending */ | ||
234 | #define HDSPM_RX_64ch (1<<1) /* Input 64chan. MODE=1, 56chn. MODE=0 */ | ||
235 | #define HDSPM_AB_int (1<<2) /* InputChannel Opt=0, Coax=1 (like inp0) */ | ||
236 | #define HDSPM_madiLock (1<<3) /* MADI Locked =1, no=0 */ | ||
237 | |||
238 | #define HDSPM_BufferPositionMask 0x000FFC0 /* Bit 6..15 : h/w buffer pointer */ | ||
239 | /* since 64byte accurate last 6 bits | ||
240 | are not used */ | ||
241 | |||
242 | #define HDSPM_madiSync (1<<18) /* MADI is in sync */ | ||
243 | #define HDSPM_DoubleSpeedStatus (1<<19) /* (input) card in double speed */ | ||
244 | |||
245 | #define HDSPM_madiFreq0 (1<<22) /* system freq 0=error */ | ||
246 | #define HDSPM_madiFreq1 (1<<23) /* 1=32, 2=44.1 3=48 */ | ||
247 | #define HDSPM_madiFreq2 (1<<24) /* 4=64, 5=88.2 6=96 */ | ||
248 | #define HDSPM_madiFreq3 (1<<25) /* 7=128, 8=176.4 9=192 */ | ||
249 | |||
250 | #define HDSPM_BufferID (1<<26) /* (Double)Buffer ID toggles with Interrupt */ | ||
251 | #define HDSPM_midi0IRQPending (1<<30) /* MIDI IRQ is pending */ | ||
252 | #define HDSPM_midi1IRQPending (1<<31) /* and aktiv */ | ||
253 | |||
254 | /* --- status bit helpers */ | ||
255 | #define HDSPM_madiFreqMask (HDSPM_madiFreq0|HDSPM_madiFreq1|HDSPM_madiFreq2|HDSPM_madiFreq3) | ||
256 | #define HDSPM_madiFreq32 (HDSPM_madiFreq0) | ||
257 | #define HDSPM_madiFreq44_1 (HDSPM_madiFreq1) | ||
258 | #define HDSPM_madiFreq48 (HDSPM_madiFreq0|HDSPM_madiFreq1) | ||
259 | #define HDSPM_madiFreq64 (HDSPM_madiFreq2) | ||
260 | #define HDSPM_madiFreq88_2 (HDSPM_madiFreq0|HDSPM_madiFreq2) | ||
261 | #define HDSPM_madiFreq96 (HDSPM_madiFreq1|HDSPM_madiFreq2) | ||
262 | #define HDSPM_madiFreq128 (HDSPM_madiFreq0|HDSPM_madiFreq1|HDSPM_madiFreq2) | ||
263 | #define HDSPM_madiFreq176_4 (HDSPM_madiFreq3) | ||
264 | #define HDSPM_madiFreq192 (HDSPM_madiFreq3|HDSPM_madiFreq0) | ||
265 | |||
266 | /* Status2 Register bits */ | ||
267 | |||
268 | #define HDSPM_version0 (1<<0) /* not realy defined but I guess */ | ||
269 | #define HDSPM_version1 (1<<1) /* in former cards it was ??? */ | ||
270 | #define HDSPM_version2 (1<<2) | ||
271 | |||
272 | #define HDSPM_wcLock (1<<3) /* Wordclock is detected and locked */ | ||
273 | #define HDSPM_wcSync (1<<4) /* Wordclock is in sync with systemclock */ | ||
274 | |||
275 | #define HDSPM_wc_freq0 (1<<5) /* input freq detected via autosync */ | ||
276 | #define HDSPM_wc_freq1 (1<<6) /* 001=32, 010==44.1, 011=48, */ | ||
277 | #define HDSPM_wc_freq2 (1<<7) /* 100=64, 101=88.2, 110=96, */ | ||
278 | /* missing Bit for 111=128, 1000=176.4, 1001=192 */ | ||
279 | |||
280 | #define HDSPM_SelSyncRef0 (1<<8) /* Sync Source in slave mode */ | ||
281 | #define HDSPM_SelSyncRef1 (1<<9) /* 000=word, 001=MADI, */ | ||
282 | #define HDSPM_SelSyncRef2 (1<<10) /* 111=no valid signal */ | ||
283 | |||
284 | #define HDSPM_wc_valid (HDSPM_wcLock|HDSPM_wcSync) | ||
285 | |||
286 | #define HDSPM_wcFreqMask (HDSPM_wc_freq0|HDSPM_wc_freq1|HDSPM_wc_freq2) | ||
287 | #define HDSPM_wcFreq32 (HDSPM_wc_freq0) | ||
288 | #define HDSPM_wcFreq44_1 (HDSPM_wc_freq1) | ||
289 | #define HDSPM_wcFreq48 (HDSPM_wc_freq0|HDSPM_wc_freq1) | ||
290 | #define HDSPM_wcFreq64 (HDSPM_wc_freq2) | ||
291 | #define HDSPM_wcFreq88_2 (HDSPM_wc_freq0|HDSPM_wc_freq2) | ||
292 | #define HDSPM_wcFreq96 (HDSPM_wc_freq1|HDSPM_wc_freq2) | ||
293 | |||
294 | |||
295 | #define HDSPM_SelSyncRefMask (HDSPM_SelSyncRef0|HDSPM_SelSyncRef1|HDSPM_SelSyncRef2) | ||
296 | #define HDSPM_SelSyncRef_WORD 0 | ||
297 | #define HDSPM_SelSyncRef_MADI (HDSPM_SelSyncRef0) | ||
298 | #define HDSPM_SelSyncRef_NVALID (HDSPM_SelSyncRef0|HDSPM_SelSyncRef1|HDSPM_SelSyncRef2) | ||
299 | |||
300 | /* Mixer Values */ | ||
301 | #define UNITY_GAIN 32768 /* = 65536/2 */ | ||
302 | #define MINUS_INFINITY_GAIN 0 | ||
303 | |||
304 | /* PCI info */ | ||
305 | #ifndef PCI_VENDOR_ID_XILINX | ||
306 | #define PCI_VENDOR_ID_XILINX 0x10ee | ||
307 | #endif | ||
308 | #ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP | ||
309 | #define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 | ||
310 | #endif | ||
311 | #ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI | ||
312 | #define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6 | ||
313 | #endif | ||
314 | |||
315 | |||
316 | /* Number of channels for different Speed Modes */ | ||
317 | #define MADI_SS_CHANNELS 64 | ||
318 | #define MADI_DS_CHANNELS 32 | ||
319 | #define MADI_QS_CHANNELS 16 | ||
320 | |||
321 | /* the size of a substream (1 mono data stream) */ | ||
322 | #define HDSPM_CHANNEL_BUFFER_SAMPLES (16*1024) | ||
323 | #define HDSPM_CHANNEL_BUFFER_BYTES (4*HDSPM_CHANNEL_BUFFER_SAMPLES) | ||
324 | |||
325 | /* the size of the area we need to allocate for DMA transfers. the | ||
326 | size is the same regardless of the number of channels, and | ||
327 | also the latency to use. | ||
328 | for one direction !!! | ||
329 | */ | ||
330 | #define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES) | ||
331 | #define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024) | ||
332 | |||
333 | typedef struct _hdspm hdspm_t; | ||
334 | typedef struct _hdspm_midi hdspm_midi_t; | ||
335 | |||
336 | struct _hdspm_midi { | ||
337 | hdspm_t *hdspm; | ||
338 | int id; | ||
339 | snd_rawmidi_t *rmidi; | ||
340 | snd_rawmidi_substream_t *input; | ||
341 | snd_rawmidi_substream_t *output; | ||
342 | char istimer; /* timer in use */ | ||
343 | struct timer_list timer; | ||
344 | spinlock_t lock; | ||
345 | int pending; | ||
346 | }; | ||
347 | |||
348 | struct _hdspm { | ||
349 | spinlock_t lock; | ||
350 | snd_pcm_substream_t *capture_substream; /* only one playback */ | ||
351 | snd_pcm_substream_t *playback_substream; /* and/or capture stream */ | ||
352 | |||
353 | char *card_name; /* for procinfo */ | ||
354 | unsigned short firmware_rev; /* dont know if relevant */ | ||
355 | |||
356 | int precise_ptr; /* use precise pointers, to be tested */ | ||
357 | int monitor_outs; /* set up monitoring outs init flag */ | ||
358 | |||
359 | u32 control_register; /* cached value */ | ||
360 | u32 control2_register; /* cached value */ | ||
361 | |||
362 | hdspm_midi_t midi[2]; | ||
363 | struct tasklet_struct midi_tasklet; | ||
364 | |||
365 | size_t period_bytes; | ||
366 | unsigned char ss_channels; /* channels of card in single speed */ | ||
367 | unsigned char ds_channels; /* Double Speed */ | ||
368 | unsigned char qs_channels; /* Quad Speed */ | ||
369 | |||
370 | unsigned char *playback_buffer; /* suitably aligned address */ | ||
371 | unsigned char *capture_buffer; /* suitably aligned address */ | ||
372 | |||
373 | pid_t capture_pid; /* process id which uses capture */ | ||
374 | pid_t playback_pid; /* process id which uses capture */ | ||
375 | int running; /* running status */ | ||
376 | |||
377 | int last_external_sample_rate; /* samplerate mystic ... */ | ||
378 | int last_internal_sample_rate; | ||
379 | int system_sample_rate; | ||
380 | |||
381 | char *channel_map; /* channel map for DS and Quadspeed */ | ||
382 | |||
383 | int dev; /* Hardware vars... */ | ||
384 | int irq; | ||
385 | unsigned long port; | ||
386 | void __iomem *iobase; | ||
387 | |||
388 | int irq_count; /* for debug */ | ||
389 | |||
390 | snd_card_t *card; /* one card */ | ||
391 | snd_pcm_t *pcm; /* has one pcm */ | ||
392 | snd_hwdep_t *hwdep; /* and a hwdep for additional ioctl */ | ||
393 | struct pci_dev *pci; /* and an pci info */ | ||
394 | |||
395 | /* Mixer vars */ | ||
396 | snd_kcontrol_t *playback_mixer_ctls[HDSPM_MAX_CHANNELS]; /* fast alsa mixer */ | ||
397 | snd_kcontrol_t *input_mixer_ctls[HDSPM_MAX_CHANNELS]; /* but input to much, so not used */ | ||
398 | hdspm_mixer_t *mixer; /* full mixer accessable over mixer ioctl or hwdep-device */ | ||
399 | |||
400 | }; | ||
401 | |||
402 | /* These tables map the ALSA channels 1..N to the channels that we | ||
403 | need to use in order to find the relevant channel buffer. RME | ||
404 | refer to this kind of mapping as between "the ADAT channel and | ||
405 | the DMA channel." We index it using the logical audio channel, | ||
406 | and the value is the DMA channel (i.e. channel buffer number) | ||
407 | where the data for that channel can be read/written from/to. | ||
408 | */ | ||
409 | |||
410 | static char channel_map_madi_ss[HDSPM_MAX_CHANNELS] = { | ||
411 | 0, 1, 2, 3, 4, 5, 6, 7, | ||
412 | 8, 9, 10, 11, 12, 13, 14, 15, | ||
413 | 16, 17, 18, 19, 20, 21, 22, 23, | ||
414 | 24, 25, 26, 27, 28, 29, 30, 31, | ||
415 | 32, 33, 34, 35, 36, 37, 38, 39, | ||
416 | 40, 41, 42, 43, 44, 45, 46, 47, | ||
417 | 48, 49, 50, 51, 52, 53, 54, 55, | ||
418 | 56, 57, 58, 59, 60, 61, 62, 63 | ||
419 | }; | ||
420 | |||
421 | static char channel_map_madi_ds[HDSPM_MAX_CHANNELS] = { | ||
422 | 0, 2, 4, 6, 8, 10, 12, 14, | ||
423 | 16, 18, 20, 22, 24, 26, 28, 30, | ||
424 | 32, 34, 36, 38, 40, 42, 44, 46, | ||
425 | 48, 50, 52, 54, 56, 58, 60, 62, | ||
426 | -1, -1, -1, -1, -1, -1, -1, -1, | ||
427 | -1, -1, -1, -1, -1, -1, -1, -1, | ||
428 | -1, -1, -1, -1, -1, -1, -1, -1, | ||
429 | -1, -1, -1, -1, -1, -1, -1, -1 | ||
430 | }; | ||
431 | |||
432 | static char channel_map_madi_qs[HDSPM_MAX_CHANNELS] = { | ||
433 | 0, 4, 8, 12, 16, 20, 24, 28, | ||
434 | 32, 36, 40, 44, 48, 52, 56, 60 | ||
435 | -1, -1, -1, -1, -1, -1, -1, -1, | ||
436 | -1, -1, -1, -1, -1, -1, -1, -1, | ||
437 | -1, -1, -1, -1, -1, -1, -1, -1, | ||
438 | -1, -1, -1, -1, -1, -1, -1, -1, | ||
439 | -1, -1, -1, -1, -1, -1, -1, -1, | ||
440 | -1, -1, -1, -1, -1, -1, -1, -1 | ||
441 | }; | ||
442 | |||
443 | |||
444 | static struct pci_device_id snd_hdspm_ids[] = { | ||
445 | { | ||
446 | .vendor = PCI_VENDOR_ID_XILINX, | ||
447 | .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI, | ||
448 | .subvendor = PCI_ANY_ID, | ||
449 | .subdevice = PCI_ANY_ID, | ||
450 | .class = 0, | ||
451 | .class_mask = 0, | ||
452 | .driver_data = 0}, | ||
453 | {0,} | ||
454 | }; | ||
455 | |||
456 | MODULE_DEVICE_TABLE(pci, snd_hdspm_ids); | ||
457 | |||
458 | /* prototypes */ | ||
459 | static int __devinit snd_hdspm_create_alsa_devices(snd_card_t * card, | ||
460 | hdspm_t * hdspm); | ||
461 | static int __devinit snd_hdspm_create_pcm(snd_card_t * card, | ||
462 | hdspm_t * hdspm); | ||
463 | |||
464 | static inline void snd_hdspm_initialize_midi_flush(hdspm_t * hdspm); | ||
465 | static int hdspm_update_simple_mixer_controls(hdspm_t * hdspm); | ||
466 | static int hdspm_autosync_ref(hdspm_t * hdspm); | ||
467 | static int snd_hdspm_set_defaults(hdspm_t * hdspm); | ||
468 | static void hdspm_set_sgbuf(hdspm_t * hdspm, struct snd_sg_buf *sgbuf, | ||
469 | unsigned int reg, int channels); | ||
470 | |||
471 | /* Write/read to/from HDSPM with Adresses in Bytes | ||
472 | not words but only 32Bit writes are allowed */ | ||
473 | |||
474 | static inline void hdspm_write(hdspm_t * hdspm, unsigned int reg, | ||
475 | unsigned int val) | ||
476 | { | ||
477 | writel(val, hdspm->iobase + reg); | ||
478 | } | ||
479 | |||
480 | static inline unsigned int hdspm_read(hdspm_t * hdspm, unsigned int reg) | ||
481 | { | ||
482 | return readl(hdspm->iobase + reg); | ||
483 | } | ||
484 | |||
485 | /* for each output channel (chan) I have an Input (in) and Playback (pb) Fader | ||
486 | mixer is write only on hardware so we have to cache him for read | ||
487 | each fader is a u32, but uses only the first 16 bit */ | ||
488 | |||
489 | static inline int hdspm_read_in_gain(hdspm_t * hdspm, unsigned int chan, | ||
490 | unsigned int in) | ||
491 | { | ||
492 | if (chan > HDSPM_MIXER_CHANNELS || in > HDSPM_MIXER_CHANNELS) | ||
493 | return 0; | ||
494 | |||
495 | return hdspm->mixer->ch[chan].in[in]; | ||
496 | } | ||
497 | |||
498 | static inline int hdspm_read_pb_gain(hdspm_t * hdspm, unsigned int chan, | ||
499 | unsigned int pb) | ||
500 | { | ||
501 | if (chan > HDSPM_MIXER_CHANNELS || pb > HDSPM_MIXER_CHANNELS) | ||
502 | return 0; | ||
503 | return hdspm->mixer->ch[chan].pb[pb]; | ||
504 | } | ||
505 | |||
506 | static inline int hdspm_write_in_gain(hdspm_t * hdspm, unsigned int chan, | ||
507 | unsigned int in, unsigned short data) | ||
508 | { | ||
509 | if (chan >= HDSPM_MIXER_CHANNELS || in >= HDSPM_MIXER_CHANNELS) | ||
510 | return -1; | ||
511 | |||
512 | hdspm_write(hdspm, | ||
513 | HDSPM_MADI_mixerBase + | ||
514 | ((in + 128 * chan) * sizeof(u32)), | ||
515 | (hdspm->mixer->ch[chan].in[in] = data & 0xFFFF)); | ||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | static inline int hdspm_write_pb_gain(hdspm_t * hdspm, unsigned int chan, | ||
520 | unsigned int pb, unsigned short data) | ||
521 | { | ||
522 | if (chan >= HDSPM_MIXER_CHANNELS || pb >= HDSPM_MIXER_CHANNELS) | ||
523 | return -1; | ||
524 | |||
525 | hdspm_write(hdspm, | ||
526 | HDSPM_MADI_mixerBase + | ||
527 | ((64 + pb + 128 * chan) * sizeof(u32)), | ||
528 | (hdspm->mixer->ch[chan].pb[pb] = data & 0xFFFF)); | ||
529 | return 0; | ||
530 | } | ||
531 | |||
532 | |||
533 | /* enable DMA for specific channels, now available for DSP-MADI */ | ||
534 | static inline void snd_hdspm_enable_in(hdspm_t * hdspm, int i, int v) | ||
535 | { | ||
536 | hdspm_write(hdspm, HDSPM_inputEnableBase + (4 * i), v); | ||
537 | } | ||
538 | |||
539 | static inline void snd_hdspm_enable_out(hdspm_t * hdspm, int i, int v) | ||
540 | { | ||
541 | hdspm_write(hdspm, HDSPM_outputEnableBase + (4 * i), v); | ||
542 | } | ||
543 | |||
544 | /* check if same process is writing and reading */ | ||
545 | static inline int snd_hdspm_use_is_exclusive(hdspm_t * hdspm) | ||
546 | { | ||
547 | unsigned long flags; | ||
548 | int ret = 1; | ||
549 | |||
550 | spin_lock_irqsave(&hdspm->lock, flags); | ||
551 | if ((hdspm->playback_pid != hdspm->capture_pid) && | ||
552 | (hdspm->playback_pid >= 0) && (hdspm->capture_pid >= 0)) { | ||
553 | ret = 0; | ||
554 | } | ||
555 | spin_unlock_irqrestore(&hdspm->lock, flags); | ||
556 | return ret; | ||
557 | } | ||
558 | |||
559 | /* check for external sample rate */ | ||
560 | static inline int hdspm_external_sample_rate(hdspm_t * hdspm) | ||
561 | { | ||
562 | unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); | ||
563 | unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); | ||
564 | unsigned int rate_bits; | ||
565 | int rate = 0; | ||
566 | |||
567 | /* if wordclock has synced freq and wordclock is valid */ | ||
568 | if ((status2 & HDSPM_wcLock) != 0 && | ||
569 | (status & HDSPM_SelSyncRef0) == 0) { | ||
570 | |||
571 | rate_bits = status2 & HDSPM_wcFreqMask; | ||
572 | |||
573 | switch (rate_bits) { | ||
574 | case HDSPM_wcFreq32: | ||
575 | rate = 32000; | ||
576 | break; | ||
577 | case HDSPM_wcFreq44_1: | ||
578 | rate = 44100; | ||
579 | break; | ||
580 | case HDSPM_wcFreq48: | ||
581 | rate = 48000; | ||
582 | break; | ||
583 | case HDSPM_wcFreq64: | ||
584 | rate = 64000; | ||
585 | break; | ||
586 | case HDSPM_wcFreq88_2: | ||
587 | rate = 88200; | ||
588 | break; | ||
589 | case HDSPM_wcFreq96: | ||
590 | rate = 96000; | ||
591 | break; | ||
592 | /* Quadspeed Bit missing ???? */ | ||
593 | default: | ||
594 | rate = 0; | ||
595 | break; | ||
596 | } | ||
597 | } | ||
598 | |||
599 | /* if rate detected and Syncref is Word than have it, word has priority to MADI */ | ||
600 | if (rate != 0 | ||
601 | && (status2 & HDSPM_SelSyncRefMask) == HDSPM_SelSyncRef_WORD) | ||
602 | return rate; | ||
603 | |||
604 | /* maby a madi input (which is taken if sel sync is madi) */ | ||
605 | if (status & HDSPM_madiLock) { | ||
606 | rate_bits = status & HDSPM_madiFreqMask; | ||
607 | |||
608 | switch (rate_bits) { | ||
609 | case HDSPM_madiFreq32: | ||
610 | rate = 32000; | ||
611 | break; | ||
612 | case HDSPM_madiFreq44_1: | ||
613 | rate = 44100; | ||
614 | break; | ||
615 | case HDSPM_madiFreq48: | ||
616 | rate = 48000; | ||
617 | break; | ||
618 | case HDSPM_madiFreq64: | ||
619 | rate = 64000; | ||
620 | break; | ||
621 | case HDSPM_madiFreq88_2: | ||
622 | rate = 88200; | ||
623 | break; | ||
624 | case HDSPM_madiFreq96: | ||
625 | rate = 96000; | ||
626 | break; | ||
627 | case HDSPM_madiFreq128: | ||
628 | rate = 128000; | ||
629 | break; | ||
630 | case HDSPM_madiFreq176_4: | ||
631 | rate = 176400; | ||
632 | break; | ||
633 | case HDSPM_madiFreq192: | ||
634 | rate = 192000; | ||
635 | break; | ||
636 | default: | ||
637 | rate = 0; | ||
638 | break; | ||
639 | } | ||
640 | } | ||
641 | return rate; | ||
642 | } | ||
643 | |||
644 | /* Latency function */ | ||
645 | static inline void hdspm_compute_period_size(hdspm_t * hdspm) | ||
646 | { | ||
647 | hdspm->period_bytes = | ||
648 | 1 << ((hdspm_decode_latency(hdspm->control_register) + 8)); | ||
649 | } | ||
650 | |||
651 | static snd_pcm_uframes_t hdspm_hw_pointer(hdspm_t * hdspm) | ||
652 | { | ||
653 | int position; | ||
654 | |||
655 | position = hdspm_read(hdspm, HDSPM_statusRegister); | ||
656 | |||
657 | if (!hdspm->precise_ptr) { | ||
658 | return (position & HDSPM_BufferID) ? (hdspm->period_bytes / | ||
659 | 4) : 0; | ||
660 | } | ||
661 | |||
662 | /* hwpointer comes in bytes and is 64Bytes accurate (by docu since PCI Burst) | ||
663 | i have experimented that it is at most 64 Byte to much for playing | ||
664 | so substraction of 64 byte should be ok for ALSA, but use it only | ||
665 | for application where you know what you do since if you come to | ||
666 | near with record pointer it can be a disaster */ | ||
667 | |||
668 | position &= HDSPM_BufferPositionMask; | ||
669 | position = ((position - 64) % (2 * hdspm->period_bytes)) / 4; | ||
670 | |||
671 | return position; | ||
672 | } | ||
673 | |||
674 | |||
675 | static inline void hdspm_start_audio(hdspm_t * s) | ||
676 | { | ||
677 | s->control_register |= (HDSPM_AudioInterruptEnable | HDSPM_Start); | ||
678 | hdspm_write(s, HDSPM_controlRegister, s->control_register); | ||
679 | } | ||
680 | |||
681 | static inline void hdspm_stop_audio(hdspm_t * s) | ||
682 | { | ||
683 | s->control_register &= ~(HDSPM_Start | HDSPM_AudioInterruptEnable); | ||
684 | hdspm_write(s, HDSPM_controlRegister, s->control_register); | ||
685 | } | ||
686 | |||
687 | /* should I silence all or only opened ones ? doit all for first even is 4MB*/ | ||
688 | static inline void hdspm_silence_playback(hdspm_t * hdspm) | ||
689 | { | ||
690 | int i; | ||
691 | int n = hdspm->period_bytes; | ||
692 | void *buf = hdspm->playback_buffer; | ||
693 | |||
694 | snd_assert(buf != NULL, return); | ||
695 | |||
696 | for (i = 0; i < HDSPM_MAX_CHANNELS; i++) { | ||
697 | memset(buf, 0, n); | ||
698 | buf += HDSPM_CHANNEL_BUFFER_BYTES; | ||
699 | } | ||
700 | } | ||
701 | |||
702 | static int hdspm_set_interrupt_interval(hdspm_t * s, unsigned int frames) | ||
703 | { | ||
704 | int n; | ||
705 | |||
706 | spin_lock_irq(&s->lock); | ||
707 | |||
708 | frames >>= 7; | ||
709 | n = 0; | ||
710 | while (frames) { | ||
711 | n++; | ||
712 | frames >>= 1; | ||
713 | } | ||
714 | s->control_register &= ~HDSPM_LatencyMask; | ||
715 | s->control_register |= hdspm_encode_latency(n); | ||
716 | |||
717 | hdspm_write(s, HDSPM_controlRegister, s->control_register); | ||
718 | |||
719 | hdspm_compute_period_size(s); | ||
720 | |||
721 | spin_unlock_irq(&s->lock); | ||
722 | |||
723 | return 0; | ||
724 | } | ||
725 | |||
726 | |||
727 | /* dummy set rate lets see what happens */ | ||
728 | static int hdspm_set_rate(hdspm_t * hdspm, int rate, int called_internally) | ||
729 | { | ||
730 | int reject_if_open = 0; | ||
731 | int current_rate; | ||
732 | int rate_bits; | ||
733 | int not_set = 0; | ||
734 | |||
735 | /* ASSUMPTION: hdspm->lock is either set, or there is no need for | ||
736 | it (e.g. during module initialization). | ||
737 | */ | ||
738 | |||
739 | if (!(hdspm->control_register & HDSPM_ClockModeMaster)) { | ||
740 | |||
741 | /* SLAVE --- */ | ||
742 | if (called_internally) { | ||
743 | |||
744 | /* request from ctl or card initialization | ||
745 | just make a warning an remember setting | ||
746 | for future master mode switching */ | ||
747 | |||
748 | snd_printk | ||
749 | (KERN_WARNING "HDSPM: Warning: device is not running as a clock master.\n"); | ||
750 | not_set = 1; | ||
751 | } else { | ||
752 | |||
753 | /* hw_param request while in AutoSync mode */ | ||
754 | int external_freq = | ||
755 | hdspm_external_sample_rate(hdspm); | ||
756 | |||
757 | if ((hdspm_autosync_ref(hdspm) == | ||
758 | HDSPM_AUTOSYNC_FROM_NONE)) { | ||
759 | |||
760 | snd_printk(KERN_WARNING "HDSPM: Detected no Externel Sync \n"); | ||
761 | not_set = 1; | ||
762 | |||
763 | } else if (rate != external_freq) { | ||
764 | |||
765 | snd_printk | ||
766 | (KERN_WARNING "HDSPM: Warning: No AutoSync source for requested rate\n"); | ||
767 | not_set = 1; | ||
768 | } | ||
769 | } | ||
770 | } | ||
771 | |||
772 | current_rate = hdspm->system_sample_rate; | ||
773 | |||
774 | /* Changing between Singe, Double and Quad speed is not | ||
775 | allowed if any substreams are open. This is because such a change | ||
776 | causes a shift in the location of the DMA buffers and a reduction | ||
777 | in the number of available buffers. | ||
778 | |||
779 | Note that a similar but essentially insoluble problem exists for | ||
780 | externally-driven rate changes. All we can do is to flag rate | ||
781 | changes in the read/write routines. | ||
782 | */ | ||
783 | |||
784 | switch (rate) { | ||
785 | case 32000: | ||
786 | if (current_rate > 48000) { | ||
787 | reject_if_open = 1; | ||
788 | } | ||
789 | rate_bits = HDSPM_Frequency32KHz; | ||
790 | break; | ||
791 | case 44100: | ||
792 | if (current_rate > 48000) { | ||
793 | reject_if_open = 1; | ||
794 | } | ||
795 | rate_bits = HDSPM_Frequency44_1KHz; | ||
796 | break; | ||
797 | case 48000: | ||
798 | if (current_rate > 48000) { | ||
799 | reject_if_open = 1; | ||
800 | } | ||
801 | rate_bits = HDSPM_Frequency48KHz; | ||
802 | break; | ||
803 | case 64000: | ||
804 | if (current_rate <= 48000) { | ||
805 | reject_if_open = 1; | ||
806 | } | ||
807 | rate_bits = HDSPM_Frequency64KHz; | ||
808 | break; | ||
809 | case 88200: | ||
810 | if (current_rate <= 48000) { | ||
811 | reject_if_open = 1; | ||
812 | } | ||
813 | rate_bits = HDSPM_Frequency88_2KHz; | ||
814 | break; | ||
815 | case 96000: | ||
816 | if (current_rate <= 48000) { | ||
817 | reject_if_open = 1; | ||
818 | } | ||
819 | rate_bits = HDSPM_Frequency96KHz; | ||
820 | break; | ||
821 | default: | ||
822 | return -EINVAL; | ||
823 | } | ||
824 | |||
825 | if (reject_if_open | ||
826 | && (hdspm->capture_pid >= 0 || hdspm->playback_pid >= 0)) { | ||
827 | snd_printk | ||
828 | (KERN_ERR "HDSPM: cannot change between single- and double-speed mode (capture PID = %d, playback PID = %d)\n", | ||
829 | hdspm->capture_pid, hdspm->playback_pid); | ||
830 | return -EBUSY; | ||
831 | } | ||
832 | |||
833 | hdspm->control_register &= ~HDSPM_FrequencyMask; | ||
834 | hdspm->control_register |= rate_bits; | ||
835 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
836 | |||
837 | if (rate > 64000) | ||
838 | hdspm->channel_map = channel_map_madi_qs; | ||
839 | else if (rate > 48000) | ||
840 | hdspm->channel_map = channel_map_madi_ds; | ||
841 | else | ||
842 | hdspm->channel_map = channel_map_madi_ss; | ||
843 | |||
844 | hdspm->system_sample_rate = rate; | ||
845 | |||
846 | if (not_set != 0) | ||
847 | return -1; | ||
848 | |||
849 | return 0; | ||
850 | } | ||
851 | |||
852 | /* mainly for init to 0 on load */ | ||
853 | static void all_in_all_mixer(hdspm_t * hdspm, int sgain) | ||
854 | { | ||
855 | int i, j; | ||
856 | unsigned int gain = | ||
857 | (sgain > UNITY_GAIN) ? UNITY_GAIN : (sgain < 0) ? 0 : sgain; | ||
858 | |||
859 | for (i = 0; i < HDSPM_MIXER_CHANNELS; i++) | ||
860 | for (j = 0; j < HDSPM_MIXER_CHANNELS; j++) { | ||
861 | hdspm_write_in_gain(hdspm, i, j, gain); | ||
862 | hdspm_write_pb_gain(hdspm, i, j, gain); | ||
863 | } | ||
864 | } | ||
865 | |||
866 | /*---------------------------------------------------------------------------- | ||
867 | MIDI | ||
868 | ----------------------------------------------------------------------------*/ | ||
869 | |||
870 | static inline unsigned char snd_hdspm_midi_read_byte (hdspm_t *hdspm, int id) | ||
871 | { | ||
872 | /* the hardware already does the relevant bit-mask with 0xff */ | ||
873 | if (id) | ||
874 | return hdspm_read(hdspm, HDSPM_midiDataIn1); | ||
875 | else | ||
876 | return hdspm_read(hdspm, HDSPM_midiDataIn0); | ||
877 | } | ||
878 | |||
879 | static inline void snd_hdspm_midi_write_byte (hdspm_t *hdspm, int id, int val) | ||
880 | { | ||
881 | /* the hardware already does the relevant bit-mask with 0xff */ | ||
882 | if (id) | ||
883 | return hdspm_write(hdspm, HDSPM_midiDataOut1, val); | ||
884 | else | ||
885 | return hdspm_write(hdspm, HDSPM_midiDataOut0, val); | ||
886 | } | ||
887 | |||
888 | static inline int snd_hdspm_midi_input_available (hdspm_t *hdspm, int id) | ||
889 | { | ||
890 | if (id) | ||
891 | return (hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xff); | ||
892 | else | ||
893 | return (hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xff); | ||
894 | } | ||
895 | |||
896 | static inline int snd_hdspm_midi_output_possible (hdspm_t *hdspm, int id) | ||
897 | { | ||
898 | int fifo_bytes_used; | ||
899 | |||
900 | if (id) | ||
901 | fifo_bytes_used = hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xff; | ||
902 | else | ||
903 | fifo_bytes_used = hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xff; | ||
904 | |||
905 | if (fifo_bytes_used < 128) | ||
906 | return 128 - fifo_bytes_used; | ||
907 | else | ||
908 | return 0; | ||
909 | } | ||
910 | |||
911 | static inline void snd_hdspm_flush_midi_input (hdspm_t *hdspm, int id) | ||
912 | { | ||
913 | while (snd_hdspm_midi_input_available (hdspm, id)) | ||
914 | snd_hdspm_midi_read_byte (hdspm, id); | ||
915 | } | ||
916 | |||
917 | static int snd_hdspm_midi_output_write (hdspm_midi_t *hmidi) | ||
918 | { | ||
919 | unsigned long flags; | ||
920 | int n_pending; | ||
921 | int to_write; | ||
922 | int i; | ||
923 | unsigned char buf[128]; | ||
924 | |||
925 | /* Output is not interrupt driven */ | ||
926 | |||
927 | spin_lock_irqsave (&hmidi->lock, flags); | ||
928 | if (hmidi->output) { | ||
929 | if (!snd_rawmidi_transmit_empty (hmidi->output)) { | ||
930 | if ((n_pending = snd_hdspm_midi_output_possible (hmidi->hdspm, hmidi->id)) > 0) { | ||
931 | if (n_pending > (int)sizeof (buf)) | ||
932 | n_pending = sizeof (buf); | ||
933 | |||
934 | if ((to_write = snd_rawmidi_transmit (hmidi->output, buf, n_pending)) > 0) { | ||
935 | for (i = 0; i < to_write; ++i) | ||
936 | snd_hdspm_midi_write_byte (hmidi->hdspm, hmidi->id, buf[i]); | ||
937 | } | ||
938 | } | ||
939 | } | ||
940 | } | ||
941 | spin_unlock_irqrestore (&hmidi->lock, flags); | ||
942 | return 0; | ||
943 | } | ||
944 | |||
945 | static int snd_hdspm_midi_input_read (hdspm_midi_t *hmidi) | ||
946 | { | ||
947 | unsigned char buf[128]; /* this buffer is designed to match the MIDI input FIFO size */ | ||
948 | unsigned long flags; | ||
949 | int n_pending; | ||
950 | int i; | ||
951 | |||
952 | spin_lock_irqsave (&hmidi->lock, flags); | ||
953 | if ((n_pending = snd_hdspm_midi_input_available (hmidi->hdspm, hmidi->id)) > 0) { | ||
954 | if (hmidi->input) { | ||
955 | if (n_pending > (int)sizeof (buf)) { | ||
956 | n_pending = sizeof (buf); | ||
957 | } | ||
958 | for (i = 0; i < n_pending; ++i) { | ||
959 | buf[i] = snd_hdspm_midi_read_byte (hmidi->hdspm, hmidi->id); | ||
960 | } | ||
961 | if (n_pending) { | ||
962 | snd_rawmidi_receive (hmidi->input, buf, n_pending); | ||
963 | } | ||
964 | } else { | ||
965 | /* flush the MIDI input FIFO */ | ||
966 | while (n_pending--) { | ||
967 | snd_hdspm_midi_read_byte (hmidi->hdspm, hmidi->id); | ||
968 | } | ||
969 | } | ||
970 | } | ||
971 | hmidi->pending = 0; | ||
972 | if (hmidi->id) { | ||
973 | hmidi->hdspm->control_register |= HDSPM_Midi1InterruptEnable; | ||
974 | } else { | ||
975 | hmidi->hdspm->control_register |= HDSPM_Midi0InterruptEnable; | ||
976 | } | ||
977 | hdspm_write(hmidi->hdspm, HDSPM_controlRegister, hmidi->hdspm->control_register); | ||
978 | spin_unlock_irqrestore (&hmidi->lock, flags); | ||
979 | return snd_hdspm_midi_output_write (hmidi); | ||
980 | } | ||
981 | |||
982 | static void snd_hdspm_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) | ||
983 | { | ||
984 | hdspm_t *hdspm; | ||
985 | hdspm_midi_t *hmidi; | ||
986 | unsigned long flags; | ||
987 | u32 ie; | ||
988 | |||
989 | hmidi = (hdspm_midi_t *) substream->rmidi->private_data; | ||
990 | hdspm = hmidi->hdspm; | ||
991 | ie = hmidi->id ? HDSPM_Midi1InterruptEnable : HDSPM_Midi0InterruptEnable; | ||
992 | spin_lock_irqsave (&hdspm->lock, flags); | ||
993 | if (up) { | ||
994 | if (!(hdspm->control_register & ie)) { | ||
995 | snd_hdspm_flush_midi_input (hdspm, hmidi->id); | ||
996 | hdspm->control_register |= ie; | ||
997 | } | ||
998 | } else { | ||
999 | hdspm->control_register &= ~ie; | ||
1000 | } | ||
1001 | |||
1002 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
1003 | spin_unlock_irqrestore (&hdspm->lock, flags); | ||
1004 | } | ||
1005 | |||
1006 | static void snd_hdspm_midi_output_timer(unsigned long data) | ||
1007 | { | ||
1008 | hdspm_midi_t *hmidi = (hdspm_midi_t *) data; | ||
1009 | unsigned long flags; | ||
1010 | |||
1011 | snd_hdspm_midi_output_write(hmidi); | ||
1012 | spin_lock_irqsave (&hmidi->lock, flags); | ||
1013 | |||
1014 | /* this does not bump hmidi->istimer, because the | ||
1015 | kernel automatically removed the timer when it | ||
1016 | expired, and we are now adding it back, thus | ||
1017 | leaving istimer wherever it was set before. | ||
1018 | */ | ||
1019 | |||
1020 | if (hmidi->istimer) { | ||
1021 | hmidi->timer.expires = 1 + jiffies; | ||
1022 | add_timer(&hmidi->timer); | ||
1023 | } | ||
1024 | |||
1025 | spin_unlock_irqrestore (&hmidi->lock, flags); | ||
1026 | } | ||
1027 | |||
1028 | static void snd_hdspm_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) | ||
1029 | { | ||
1030 | hdspm_midi_t *hmidi; | ||
1031 | unsigned long flags; | ||
1032 | |||
1033 | hmidi = (hdspm_midi_t *) substream->rmidi->private_data; | ||
1034 | spin_lock_irqsave (&hmidi->lock, flags); | ||
1035 | if (up) { | ||
1036 | if (!hmidi->istimer) { | ||
1037 | init_timer(&hmidi->timer); | ||
1038 | hmidi->timer.function = snd_hdspm_midi_output_timer; | ||
1039 | hmidi->timer.data = (unsigned long) hmidi; | ||
1040 | hmidi->timer.expires = 1 + jiffies; | ||
1041 | add_timer(&hmidi->timer); | ||
1042 | hmidi->istimer++; | ||
1043 | } | ||
1044 | } else { | ||
1045 | if (hmidi->istimer && --hmidi->istimer <= 0) { | ||
1046 | del_timer (&hmidi->timer); | ||
1047 | } | ||
1048 | } | ||
1049 | spin_unlock_irqrestore (&hmidi->lock, flags); | ||
1050 | if (up) | ||
1051 | snd_hdspm_midi_output_write(hmidi); | ||
1052 | } | ||
1053 | |||
1054 | static int snd_hdspm_midi_input_open(snd_rawmidi_substream_t * substream) | ||
1055 | { | ||
1056 | hdspm_midi_t *hmidi; | ||
1057 | |||
1058 | hmidi = (hdspm_midi_t *) substream->rmidi->private_data; | ||
1059 | spin_lock_irq (&hmidi->lock); | ||
1060 | snd_hdspm_flush_midi_input (hmidi->hdspm, hmidi->id); | ||
1061 | hmidi->input = substream; | ||
1062 | spin_unlock_irq (&hmidi->lock); | ||
1063 | |||
1064 | return 0; | ||
1065 | } | ||
1066 | |||
1067 | static int snd_hdspm_midi_output_open(snd_rawmidi_substream_t * substream) | ||
1068 | { | ||
1069 | hdspm_midi_t *hmidi; | ||
1070 | |||
1071 | hmidi = (hdspm_midi_t *) substream->rmidi->private_data; | ||
1072 | spin_lock_irq (&hmidi->lock); | ||
1073 | hmidi->output = substream; | ||
1074 | spin_unlock_irq (&hmidi->lock); | ||
1075 | |||
1076 | return 0; | ||
1077 | } | ||
1078 | |||
1079 | static int snd_hdspm_midi_input_close(snd_rawmidi_substream_t * substream) | ||
1080 | { | ||
1081 | hdspm_midi_t *hmidi; | ||
1082 | |||
1083 | snd_hdspm_midi_input_trigger (substream, 0); | ||
1084 | |||
1085 | hmidi = (hdspm_midi_t *) substream->rmidi->private_data; | ||
1086 | spin_lock_irq (&hmidi->lock); | ||
1087 | hmidi->input = NULL; | ||
1088 | spin_unlock_irq (&hmidi->lock); | ||
1089 | |||
1090 | return 0; | ||
1091 | } | ||
1092 | |||
1093 | static int snd_hdspm_midi_output_close(snd_rawmidi_substream_t * substream) | ||
1094 | { | ||
1095 | hdspm_midi_t *hmidi; | ||
1096 | |||
1097 | snd_hdspm_midi_output_trigger (substream, 0); | ||
1098 | |||
1099 | hmidi = (hdspm_midi_t *) substream->rmidi->private_data; | ||
1100 | spin_lock_irq (&hmidi->lock); | ||
1101 | hmidi->output = NULL; | ||
1102 | spin_unlock_irq (&hmidi->lock); | ||
1103 | |||
1104 | return 0; | ||
1105 | } | ||
1106 | |||
1107 | snd_rawmidi_ops_t snd_hdspm_midi_output = | ||
1108 | { | ||
1109 | .open = snd_hdspm_midi_output_open, | ||
1110 | .close = snd_hdspm_midi_output_close, | ||
1111 | .trigger = snd_hdspm_midi_output_trigger, | ||
1112 | }; | ||
1113 | |||
1114 | snd_rawmidi_ops_t snd_hdspm_midi_input = | ||
1115 | { | ||
1116 | .open = snd_hdspm_midi_input_open, | ||
1117 | .close = snd_hdspm_midi_input_close, | ||
1118 | .trigger = snd_hdspm_midi_input_trigger, | ||
1119 | }; | ||
1120 | |||
1121 | static int __devinit snd_hdspm_create_midi (snd_card_t *card, hdspm_t *hdspm, int id) | ||
1122 | { | ||
1123 | int err; | ||
1124 | char buf[32]; | ||
1125 | |||
1126 | hdspm->midi[id].id = id; | ||
1127 | hdspm->midi[id].rmidi = NULL; | ||
1128 | hdspm->midi[id].input = NULL; | ||
1129 | hdspm->midi[id].output = NULL; | ||
1130 | hdspm->midi[id].hdspm = hdspm; | ||
1131 | hdspm->midi[id].istimer = 0; | ||
1132 | hdspm->midi[id].pending = 0; | ||
1133 | spin_lock_init (&hdspm->midi[id].lock); | ||
1134 | |||
1135 | sprintf (buf, "%s MIDI %d", card->shortname, id+1); | ||
1136 | if ((err = snd_rawmidi_new (card, buf, id, 1, 1, &hdspm->midi[id].rmidi)) < 0) | ||
1137 | return err; | ||
1138 | |||
1139 | sprintf (hdspm->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1); | ||
1140 | hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; | ||
1141 | |||
1142 | snd_rawmidi_set_ops (hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdspm_midi_output); | ||
1143 | snd_rawmidi_set_ops (hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_hdspm_midi_input); | ||
1144 | |||
1145 | hdspm->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | | ||
1146 | SNDRV_RAWMIDI_INFO_INPUT | | ||
1147 | SNDRV_RAWMIDI_INFO_DUPLEX; | ||
1148 | |||
1149 | return 0; | ||
1150 | } | ||
1151 | |||
1152 | |||
1153 | static void hdspm_midi_tasklet(unsigned long arg) | ||
1154 | { | ||
1155 | hdspm_t *hdspm = (hdspm_t *)arg; | ||
1156 | |||
1157 | if (hdspm->midi[0].pending) | ||
1158 | snd_hdspm_midi_input_read (&hdspm->midi[0]); | ||
1159 | if (hdspm->midi[1].pending) | ||
1160 | snd_hdspm_midi_input_read (&hdspm->midi[1]); | ||
1161 | } | ||
1162 | |||
1163 | |||
1164 | /*----------------------------------------------------------------------------- | ||
1165 | Status Interface | ||
1166 | ----------------------------------------------------------------------------*/ | ||
1167 | |||
1168 | /* get the system sample rate which is set */ | ||
1169 | |||
1170 | #define HDSPM_SYSTEM_SAMPLE_RATE(xname, xindex) \ | ||
1171 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1172 | .name = xname, \ | ||
1173 | .index = xindex, \ | ||
1174 | .access = SNDRV_CTL_ELEM_ACCESS_READ, \ | ||
1175 | .info = snd_hdspm_info_system_sample_rate, \ | ||
1176 | .get = snd_hdspm_get_system_sample_rate \ | ||
1177 | } | ||
1178 | |||
1179 | static int snd_hdspm_info_system_sample_rate(snd_kcontrol_t * kcontrol, | ||
1180 | snd_ctl_elem_info_t * uinfo) | ||
1181 | { | ||
1182 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
1183 | uinfo->count = 1; | ||
1184 | return 0; | ||
1185 | } | ||
1186 | |||
1187 | static int snd_hdspm_get_system_sample_rate(snd_kcontrol_t * kcontrol, | ||
1188 | snd_ctl_elem_value_t * | ||
1189 | ucontrol) | ||
1190 | { | ||
1191 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1192 | |||
1193 | ucontrol->value.enumerated.item[0] = hdspm->system_sample_rate; | ||
1194 | return 0; | ||
1195 | } | ||
1196 | |||
1197 | #define HDSPM_AUTOSYNC_SAMPLE_RATE(xname, xindex) \ | ||
1198 | { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ | ||
1199 | .name = xname, \ | ||
1200 | .index = xindex, \ | ||
1201 | .access = SNDRV_CTL_ELEM_ACCESS_READ, \ | ||
1202 | .info = snd_hdspm_info_autosync_sample_rate, \ | ||
1203 | .get = snd_hdspm_get_autosync_sample_rate \ | ||
1204 | } | ||
1205 | |||
1206 | static int snd_hdspm_info_autosync_sample_rate(snd_kcontrol_t * kcontrol, | ||
1207 | snd_ctl_elem_info_t * uinfo) | ||
1208 | { | ||
1209 | static char *texts[] = { "32000", "44100", "48000", | ||
1210 | "64000", "88200", "96000", | ||
1211 | "128000", "176400", "192000", | ||
1212 | "None" | ||
1213 | }; | ||
1214 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1215 | uinfo->count = 1; | ||
1216 | uinfo->value.enumerated.items = 10; | ||
1217 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1218 | uinfo->value.enumerated.item = | ||
1219 | uinfo->value.enumerated.items - 1; | ||
1220 | strcpy(uinfo->value.enumerated.name, | ||
1221 | texts[uinfo->value.enumerated.item]); | ||
1222 | return 0; | ||
1223 | } | ||
1224 | |||
1225 | static int snd_hdspm_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, | ||
1226 | snd_ctl_elem_value_t * | ||
1227 | ucontrol) | ||
1228 | { | ||
1229 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1230 | |||
1231 | switch (hdspm_external_sample_rate(hdspm)) { | ||
1232 | case 32000: | ||
1233 | ucontrol->value.enumerated.item[0] = 0; | ||
1234 | break; | ||
1235 | case 44100: | ||
1236 | ucontrol->value.enumerated.item[0] = 1; | ||
1237 | break; | ||
1238 | case 48000: | ||
1239 | ucontrol->value.enumerated.item[0] = 2; | ||
1240 | break; | ||
1241 | case 64000: | ||
1242 | ucontrol->value.enumerated.item[0] = 3; | ||
1243 | break; | ||
1244 | case 88200: | ||
1245 | ucontrol->value.enumerated.item[0] = 4; | ||
1246 | break; | ||
1247 | case 96000: | ||
1248 | ucontrol->value.enumerated.item[0] = 5; | ||
1249 | break; | ||
1250 | case 128000: | ||
1251 | ucontrol->value.enumerated.item[0] = 6; | ||
1252 | break; | ||
1253 | case 176400: | ||
1254 | ucontrol->value.enumerated.item[0] = 7; | ||
1255 | break; | ||
1256 | case 192000: | ||
1257 | ucontrol->value.enumerated.item[0] = 8; | ||
1258 | break; | ||
1259 | |||
1260 | default: | ||
1261 | ucontrol->value.enumerated.item[0] = 9; | ||
1262 | } | ||
1263 | return 0; | ||
1264 | } | ||
1265 | |||
1266 | #define HDSPM_SYSTEM_CLOCK_MODE(xname, xindex) \ | ||
1267 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1268 | .name = xname, \ | ||
1269 | .index = xindex, \ | ||
1270 | .access = SNDRV_CTL_ELEM_ACCESS_READ, \ | ||
1271 | .info = snd_hdspm_info_system_clock_mode, \ | ||
1272 | .get = snd_hdspm_get_system_clock_mode, \ | ||
1273 | } | ||
1274 | |||
1275 | |||
1276 | |||
1277 | static int hdspm_system_clock_mode(hdspm_t * hdspm) | ||
1278 | { | ||
1279 | /* Always reflect the hardware info, rme is never wrong !!!! */ | ||
1280 | |||
1281 | if (hdspm->control_register & HDSPM_ClockModeMaster) | ||
1282 | return 0; | ||
1283 | return 1; | ||
1284 | } | ||
1285 | |||
1286 | static int snd_hdspm_info_system_clock_mode(snd_kcontrol_t * kcontrol, | ||
1287 | snd_ctl_elem_info_t * uinfo) | ||
1288 | { | ||
1289 | static char *texts[] = { "Master", "Slave" }; | ||
1290 | |||
1291 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1292 | uinfo->count = 1; | ||
1293 | uinfo->value.enumerated.items = 2; | ||
1294 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1295 | uinfo->value.enumerated.item = | ||
1296 | uinfo->value.enumerated.items - 1; | ||
1297 | strcpy(uinfo->value.enumerated.name, | ||
1298 | texts[uinfo->value.enumerated.item]); | ||
1299 | return 0; | ||
1300 | } | ||
1301 | |||
1302 | static int snd_hdspm_get_system_clock_mode(snd_kcontrol_t * kcontrol, | ||
1303 | snd_ctl_elem_value_t * ucontrol) | ||
1304 | { | ||
1305 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1306 | |||
1307 | ucontrol->value.enumerated.item[0] = | ||
1308 | hdspm_system_clock_mode(hdspm); | ||
1309 | return 0; | ||
1310 | } | ||
1311 | |||
1312 | #define HDSPM_CLOCK_SOURCE(xname, xindex) \ | ||
1313 | { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ | ||
1314 | .name = xname, \ | ||
1315 | .index = xindex, \ | ||
1316 | .info = snd_hdspm_info_clock_source, \ | ||
1317 | .get = snd_hdspm_get_clock_source, \ | ||
1318 | .put = snd_hdspm_put_clock_source \ | ||
1319 | } | ||
1320 | |||
1321 | static int hdspm_clock_source(hdspm_t * hdspm) | ||
1322 | { | ||
1323 | if (hdspm->control_register & HDSPM_ClockModeMaster) { | ||
1324 | switch (hdspm->system_sample_rate) { | ||
1325 | case 32000: | ||
1326 | return 1; | ||
1327 | case 44100: | ||
1328 | return 2; | ||
1329 | case 48000: | ||
1330 | return 3; | ||
1331 | case 64000: | ||
1332 | return 4; | ||
1333 | case 88200: | ||
1334 | return 5; | ||
1335 | case 96000: | ||
1336 | return 6; | ||
1337 | case 128000: | ||
1338 | return 7; | ||
1339 | case 176400: | ||
1340 | return 8; | ||
1341 | case 192000: | ||
1342 | return 9; | ||
1343 | default: | ||
1344 | return 3; | ||
1345 | } | ||
1346 | } else { | ||
1347 | return 0; | ||
1348 | } | ||
1349 | } | ||
1350 | |||
1351 | static int hdspm_set_clock_source(hdspm_t * hdspm, int mode) | ||
1352 | { | ||
1353 | int rate; | ||
1354 | switch (mode) { | ||
1355 | |||
1356 | case HDSPM_CLOCK_SOURCE_AUTOSYNC: | ||
1357 | if (hdspm_external_sample_rate(hdspm) != 0) { | ||
1358 | hdspm->control_register &= ~HDSPM_ClockModeMaster; | ||
1359 | hdspm_write(hdspm, HDSPM_controlRegister, | ||
1360 | hdspm->control_register); | ||
1361 | return 0; | ||
1362 | } | ||
1363 | return -1; | ||
1364 | case HDSPM_CLOCK_SOURCE_INTERNAL_32KHZ: | ||
1365 | rate = 32000; | ||
1366 | break; | ||
1367 | case HDSPM_CLOCK_SOURCE_INTERNAL_44_1KHZ: | ||
1368 | rate = 44100; | ||
1369 | break; | ||
1370 | case HDSPM_CLOCK_SOURCE_INTERNAL_48KHZ: | ||
1371 | rate = 48000; | ||
1372 | break; | ||
1373 | case HDSPM_CLOCK_SOURCE_INTERNAL_64KHZ: | ||
1374 | rate = 64000; | ||
1375 | break; | ||
1376 | case HDSPM_CLOCK_SOURCE_INTERNAL_88_2KHZ: | ||
1377 | rate = 88200; | ||
1378 | break; | ||
1379 | case HDSPM_CLOCK_SOURCE_INTERNAL_96KHZ: | ||
1380 | rate = 96000; | ||
1381 | break; | ||
1382 | case HDSPM_CLOCK_SOURCE_INTERNAL_128KHZ: | ||
1383 | rate = 128000; | ||
1384 | break; | ||
1385 | case HDSPM_CLOCK_SOURCE_INTERNAL_176_4KHZ: | ||
1386 | rate = 176400; | ||
1387 | break; | ||
1388 | case HDSPM_CLOCK_SOURCE_INTERNAL_192KHZ: | ||
1389 | rate = 192000; | ||
1390 | break; | ||
1391 | |||
1392 | default: | ||
1393 | rate = 44100; | ||
1394 | } | ||
1395 | hdspm->control_register |= HDSPM_ClockModeMaster; | ||
1396 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
1397 | hdspm_set_rate(hdspm, rate, 1); | ||
1398 | return 0; | ||
1399 | } | ||
1400 | |||
1401 | static int snd_hdspm_info_clock_source(snd_kcontrol_t * kcontrol, | ||
1402 | snd_ctl_elem_info_t * uinfo) | ||
1403 | { | ||
1404 | static char *texts[] = { "AutoSync", | ||
1405 | "Internal 32.0 kHz", "Internal 44.1 kHz", | ||
1406 | "Internal 48.0 kHz", | ||
1407 | "Internal 64.0 kHz", "Internal 88.2 kHz", | ||
1408 | "Internal 96.0 kHz", | ||
1409 | "Internal 128.0 kHz", "Internal 176.4 kHz", | ||
1410 | "Internal 192.0 kHz" | ||
1411 | }; | ||
1412 | |||
1413 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1414 | uinfo->count = 1; | ||
1415 | uinfo->value.enumerated.items = 10; | ||
1416 | |||
1417 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1418 | uinfo->value.enumerated.item = | ||
1419 | uinfo->value.enumerated.items - 1; | ||
1420 | |||
1421 | strcpy(uinfo->value.enumerated.name, | ||
1422 | texts[uinfo->value.enumerated.item]); | ||
1423 | |||
1424 | return 0; | ||
1425 | } | ||
1426 | |||
1427 | static int snd_hdspm_get_clock_source(snd_kcontrol_t * kcontrol, | ||
1428 | snd_ctl_elem_value_t * ucontrol) | ||
1429 | { | ||
1430 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1431 | |||
1432 | ucontrol->value.enumerated.item[0] = hdspm_clock_source(hdspm); | ||
1433 | return 0; | ||
1434 | } | ||
1435 | |||
1436 | static int snd_hdspm_put_clock_source(snd_kcontrol_t * kcontrol, | ||
1437 | snd_ctl_elem_value_t * ucontrol) | ||
1438 | { | ||
1439 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1440 | int change; | ||
1441 | int val; | ||
1442 | |||
1443 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
1444 | return -EBUSY; | ||
1445 | val = ucontrol->value.enumerated.item[0]; | ||
1446 | if (val < 0) | ||
1447 | val = 0; | ||
1448 | if (val > 6) | ||
1449 | val = 6; | ||
1450 | spin_lock_irq(&hdspm->lock); | ||
1451 | if (val != hdspm_clock_source(hdspm)) | ||
1452 | change = (hdspm_set_clock_source(hdspm, val) == 0) ? 1 : 0; | ||
1453 | else | ||
1454 | change = 0; | ||
1455 | spin_unlock_irq(&hdspm->lock); | ||
1456 | return change; | ||
1457 | } | ||
1458 | |||
1459 | #define HDSPM_PREF_SYNC_REF(xname, xindex) \ | ||
1460 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1461 | .name = xname, \ | ||
1462 | .index = xindex, \ | ||
1463 | .info = snd_hdspm_info_pref_sync_ref, \ | ||
1464 | .get = snd_hdspm_get_pref_sync_ref, \ | ||
1465 | .put = snd_hdspm_put_pref_sync_ref \ | ||
1466 | } | ||
1467 | |||
1468 | static int hdspm_pref_sync_ref(hdspm_t * hdspm) | ||
1469 | { | ||
1470 | /* Notice that this looks at the requested sync source, | ||
1471 | not the one actually in use. | ||
1472 | */ | ||
1473 | switch (hdspm->control_register & HDSPM_SyncRefMask) { | ||
1474 | case HDSPM_SyncRef_Word: | ||
1475 | return HDSPM_SYNC_FROM_WORD; | ||
1476 | case HDSPM_SyncRef_MADI: | ||
1477 | return HDSPM_SYNC_FROM_MADI; | ||
1478 | } | ||
1479 | |||
1480 | return HDSPM_SYNC_FROM_WORD; | ||
1481 | } | ||
1482 | |||
1483 | static int hdspm_set_pref_sync_ref(hdspm_t * hdspm, int pref) | ||
1484 | { | ||
1485 | hdspm->control_register &= ~HDSPM_SyncRefMask; | ||
1486 | |||
1487 | switch (pref) { | ||
1488 | case HDSPM_SYNC_FROM_MADI: | ||
1489 | hdspm->control_register |= HDSPM_SyncRef_MADI; | ||
1490 | break; | ||
1491 | case HDSPM_SYNC_FROM_WORD: | ||
1492 | hdspm->control_register |= HDSPM_SyncRef_Word; | ||
1493 | break; | ||
1494 | default: | ||
1495 | return -1; | ||
1496 | } | ||
1497 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
1498 | return 0; | ||
1499 | } | ||
1500 | |||
1501 | static int snd_hdspm_info_pref_sync_ref(snd_kcontrol_t * kcontrol, | ||
1502 | snd_ctl_elem_info_t * uinfo) | ||
1503 | { | ||
1504 | static char *texts[] = { "Word", "MADI" }; | ||
1505 | |||
1506 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1507 | uinfo->count = 1; | ||
1508 | |||
1509 | uinfo->value.enumerated.items = 2; | ||
1510 | |||
1511 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1512 | uinfo->value.enumerated.item = | ||
1513 | uinfo->value.enumerated.items - 1; | ||
1514 | strcpy(uinfo->value.enumerated.name, | ||
1515 | texts[uinfo->value.enumerated.item]); | ||
1516 | return 0; | ||
1517 | } | ||
1518 | |||
1519 | static int snd_hdspm_get_pref_sync_ref(snd_kcontrol_t * kcontrol, | ||
1520 | snd_ctl_elem_value_t * ucontrol) | ||
1521 | { | ||
1522 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1523 | |||
1524 | ucontrol->value.enumerated.item[0] = hdspm_pref_sync_ref(hdspm); | ||
1525 | return 0; | ||
1526 | } | ||
1527 | |||
1528 | static int snd_hdspm_put_pref_sync_ref(snd_kcontrol_t * kcontrol, | ||
1529 | snd_ctl_elem_value_t * ucontrol) | ||
1530 | { | ||
1531 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1532 | int change, max; | ||
1533 | unsigned int val; | ||
1534 | |||
1535 | max = 2; | ||
1536 | |||
1537 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
1538 | return -EBUSY; | ||
1539 | |||
1540 | val = ucontrol->value.enumerated.item[0] % max; | ||
1541 | |||
1542 | spin_lock_irq(&hdspm->lock); | ||
1543 | change = (int) val != hdspm_pref_sync_ref(hdspm); | ||
1544 | hdspm_set_pref_sync_ref(hdspm, val); | ||
1545 | spin_unlock_irq(&hdspm->lock); | ||
1546 | return change; | ||
1547 | } | ||
1548 | |||
1549 | #define HDSPM_AUTOSYNC_REF(xname, xindex) \ | ||
1550 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1551 | .name = xname, \ | ||
1552 | .index = xindex, \ | ||
1553 | .access = SNDRV_CTL_ELEM_ACCESS_READ, \ | ||
1554 | .info = snd_hdspm_info_autosync_ref, \ | ||
1555 | .get = snd_hdspm_get_autosync_ref, \ | ||
1556 | } | ||
1557 | |||
1558 | static int hdspm_autosync_ref(hdspm_t * hdspm) | ||
1559 | { | ||
1560 | /* This looks at the autosync selected sync reference */ | ||
1561 | unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); | ||
1562 | |||
1563 | switch (status2 & HDSPM_SelSyncRefMask) { | ||
1564 | |||
1565 | case HDSPM_SelSyncRef_WORD: | ||
1566 | return HDSPM_AUTOSYNC_FROM_WORD; | ||
1567 | |||
1568 | case HDSPM_SelSyncRef_MADI: | ||
1569 | return HDSPM_AUTOSYNC_FROM_MADI; | ||
1570 | |||
1571 | case HDSPM_SelSyncRef_NVALID: | ||
1572 | return HDSPM_AUTOSYNC_FROM_NONE; | ||
1573 | |||
1574 | default: | ||
1575 | return 0; | ||
1576 | } | ||
1577 | |||
1578 | return 0; | ||
1579 | } | ||
1580 | |||
1581 | static int snd_hdspm_info_autosync_ref(snd_kcontrol_t * kcontrol, | ||
1582 | snd_ctl_elem_info_t * uinfo) | ||
1583 | { | ||
1584 | static char *texts[] = { "WordClock", "MADI", "None" }; | ||
1585 | |||
1586 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1587 | uinfo->count = 1; | ||
1588 | uinfo->value.enumerated.items = 3; | ||
1589 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1590 | uinfo->value.enumerated.item = | ||
1591 | uinfo->value.enumerated.items - 1; | ||
1592 | strcpy(uinfo->value.enumerated.name, | ||
1593 | texts[uinfo->value.enumerated.item]); | ||
1594 | return 0; | ||
1595 | } | ||
1596 | |||
1597 | static int snd_hdspm_get_autosync_ref(snd_kcontrol_t * kcontrol, | ||
1598 | snd_ctl_elem_value_t * ucontrol) | ||
1599 | { | ||
1600 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1601 | |||
1602 | ucontrol->value.enumerated.item[0] = hdspm_pref_sync_ref(hdspm); | ||
1603 | return 0; | ||
1604 | } | ||
1605 | |||
1606 | #define HDSPM_LINE_OUT(xname, xindex) \ | ||
1607 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1608 | .name = xname, \ | ||
1609 | .index = xindex, \ | ||
1610 | .info = snd_hdspm_info_line_out, \ | ||
1611 | .get = snd_hdspm_get_line_out, \ | ||
1612 | .put = snd_hdspm_put_line_out \ | ||
1613 | } | ||
1614 | |||
1615 | static int hdspm_line_out(hdspm_t * hdspm) | ||
1616 | { | ||
1617 | return (hdspm->control_register & HDSPM_LineOut) ? 1 : 0; | ||
1618 | } | ||
1619 | |||
1620 | |||
1621 | static int hdspm_set_line_output(hdspm_t * hdspm, int out) | ||
1622 | { | ||
1623 | if (out) | ||
1624 | hdspm->control_register |= HDSPM_LineOut; | ||
1625 | else | ||
1626 | hdspm->control_register &= ~HDSPM_LineOut; | ||
1627 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
1628 | |||
1629 | return 0; | ||
1630 | } | ||
1631 | |||
1632 | static int snd_hdspm_info_line_out(snd_kcontrol_t * kcontrol, | ||
1633 | snd_ctl_elem_info_t * uinfo) | ||
1634 | { | ||
1635 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
1636 | uinfo->count = 1; | ||
1637 | uinfo->value.integer.min = 0; | ||
1638 | uinfo->value.integer.max = 1; | ||
1639 | return 0; | ||
1640 | } | ||
1641 | |||
1642 | static int snd_hdspm_get_line_out(snd_kcontrol_t * kcontrol, | ||
1643 | snd_ctl_elem_value_t * ucontrol) | ||
1644 | { | ||
1645 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1646 | |||
1647 | spin_lock_irq(&hdspm->lock); | ||
1648 | ucontrol->value.integer.value[0] = hdspm_line_out(hdspm); | ||
1649 | spin_unlock_irq(&hdspm->lock); | ||
1650 | return 0; | ||
1651 | } | ||
1652 | |||
1653 | static int snd_hdspm_put_line_out(snd_kcontrol_t * kcontrol, | ||
1654 | snd_ctl_elem_value_t * ucontrol) | ||
1655 | { | ||
1656 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1657 | int change; | ||
1658 | unsigned int val; | ||
1659 | |||
1660 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
1661 | return -EBUSY; | ||
1662 | val = ucontrol->value.integer.value[0] & 1; | ||
1663 | spin_lock_irq(&hdspm->lock); | ||
1664 | change = (int) val != hdspm_line_out(hdspm); | ||
1665 | hdspm_set_line_output(hdspm, val); | ||
1666 | spin_unlock_irq(&hdspm->lock); | ||
1667 | return change; | ||
1668 | } | ||
1669 | |||
1670 | #define HDSPM_TX_64(xname, xindex) \ | ||
1671 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1672 | .name = xname, \ | ||
1673 | .index = xindex, \ | ||
1674 | .info = snd_hdspm_info_tx_64, \ | ||
1675 | .get = snd_hdspm_get_tx_64, \ | ||
1676 | .put = snd_hdspm_put_tx_64 \ | ||
1677 | } | ||
1678 | |||
1679 | static int hdspm_tx_64(hdspm_t * hdspm) | ||
1680 | { | ||
1681 | return (hdspm->control_register & HDSPM_TX_64ch) ? 1 : 0; | ||
1682 | } | ||
1683 | |||
1684 | static int hdspm_set_tx_64(hdspm_t * hdspm, int out) | ||
1685 | { | ||
1686 | if (out) | ||
1687 | hdspm->control_register |= HDSPM_TX_64ch; | ||
1688 | else | ||
1689 | hdspm->control_register &= ~HDSPM_TX_64ch; | ||
1690 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
1691 | |||
1692 | return 0; | ||
1693 | } | ||
1694 | |||
1695 | static int snd_hdspm_info_tx_64(snd_kcontrol_t * kcontrol, | ||
1696 | snd_ctl_elem_info_t * uinfo) | ||
1697 | { | ||
1698 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
1699 | uinfo->count = 1; | ||
1700 | uinfo->value.integer.min = 0; | ||
1701 | uinfo->value.integer.max = 1; | ||
1702 | return 0; | ||
1703 | } | ||
1704 | |||
1705 | static int snd_hdspm_get_tx_64(snd_kcontrol_t * kcontrol, | ||
1706 | snd_ctl_elem_value_t * ucontrol) | ||
1707 | { | ||
1708 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1709 | |||
1710 | spin_lock_irq(&hdspm->lock); | ||
1711 | ucontrol->value.integer.value[0] = hdspm_tx_64(hdspm); | ||
1712 | spin_unlock_irq(&hdspm->lock); | ||
1713 | return 0; | ||
1714 | } | ||
1715 | |||
1716 | static int snd_hdspm_put_tx_64(snd_kcontrol_t * kcontrol, | ||
1717 | snd_ctl_elem_value_t * ucontrol) | ||
1718 | { | ||
1719 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1720 | int change; | ||
1721 | unsigned int val; | ||
1722 | |||
1723 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
1724 | return -EBUSY; | ||
1725 | val = ucontrol->value.integer.value[0] & 1; | ||
1726 | spin_lock_irq(&hdspm->lock); | ||
1727 | change = (int) val != hdspm_tx_64(hdspm); | ||
1728 | hdspm_set_tx_64(hdspm, val); | ||
1729 | spin_unlock_irq(&hdspm->lock); | ||
1730 | return change; | ||
1731 | } | ||
1732 | |||
1733 | #define HDSPM_C_TMS(xname, xindex) \ | ||
1734 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1735 | .name = xname, \ | ||
1736 | .index = xindex, \ | ||
1737 | .info = snd_hdspm_info_c_tms, \ | ||
1738 | .get = snd_hdspm_get_c_tms, \ | ||
1739 | .put = snd_hdspm_put_c_tms \ | ||
1740 | } | ||
1741 | |||
1742 | static int hdspm_c_tms(hdspm_t * hdspm) | ||
1743 | { | ||
1744 | return (hdspm->control_register & HDSPM_clr_tms) ? 1 : 0; | ||
1745 | } | ||
1746 | |||
1747 | static int hdspm_set_c_tms(hdspm_t * hdspm, int out) | ||
1748 | { | ||
1749 | if (out) | ||
1750 | hdspm->control_register |= HDSPM_clr_tms; | ||
1751 | else | ||
1752 | hdspm->control_register &= ~HDSPM_clr_tms; | ||
1753 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
1754 | |||
1755 | return 0; | ||
1756 | } | ||
1757 | |||
1758 | static int snd_hdspm_info_c_tms(snd_kcontrol_t * kcontrol, | ||
1759 | snd_ctl_elem_info_t * uinfo) | ||
1760 | { | ||
1761 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
1762 | uinfo->count = 1; | ||
1763 | uinfo->value.integer.min = 0; | ||
1764 | uinfo->value.integer.max = 1; | ||
1765 | return 0; | ||
1766 | } | ||
1767 | |||
1768 | static int snd_hdspm_get_c_tms(snd_kcontrol_t * kcontrol, | ||
1769 | snd_ctl_elem_value_t * ucontrol) | ||
1770 | { | ||
1771 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1772 | |||
1773 | spin_lock_irq(&hdspm->lock); | ||
1774 | ucontrol->value.integer.value[0] = hdspm_c_tms(hdspm); | ||
1775 | spin_unlock_irq(&hdspm->lock); | ||
1776 | return 0; | ||
1777 | } | ||
1778 | |||
1779 | static int snd_hdspm_put_c_tms(snd_kcontrol_t * kcontrol, | ||
1780 | snd_ctl_elem_value_t * ucontrol) | ||
1781 | { | ||
1782 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1783 | int change; | ||
1784 | unsigned int val; | ||
1785 | |||
1786 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
1787 | return -EBUSY; | ||
1788 | val = ucontrol->value.integer.value[0] & 1; | ||
1789 | spin_lock_irq(&hdspm->lock); | ||
1790 | change = (int) val != hdspm_c_tms(hdspm); | ||
1791 | hdspm_set_c_tms(hdspm, val); | ||
1792 | spin_unlock_irq(&hdspm->lock); | ||
1793 | return change; | ||
1794 | } | ||
1795 | |||
1796 | #define HDSPM_SAFE_MODE(xname, xindex) \ | ||
1797 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1798 | .name = xname, \ | ||
1799 | .index = xindex, \ | ||
1800 | .info = snd_hdspm_info_safe_mode, \ | ||
1801 | .get = snd_hdspm_get_safe_mode, \ | ||
1802 | .put = snd_hdspm_put_safe_mode \ | ||
1803 | } | ||
1804 | |||
1805 | static int hdspm_safe_mode(hdspm_t * hdspm) | ||
1806 | { | ||
1807 | return (hdspm->control_register & HDSPM_AutoInp) ? 1 : 0; | ||
1808 | } | ||
1809 | |||
1810 | static int hdspm_set_safe_mode(hdspm_t * hdspm, int out) | ||
1811 | { | ||
1812 | if (out) | ||
1813 | hdspm->control_register |= HDSPM_AutoInp; | ||
1814 | else | ||
1815 | hdspm->control_register &= ~HDSPM_AutoInp; | ||
1816 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
1817 | |||
1818 | return 0; | ||
1819 | } | ||
1820 | |||
1821 | static int snd_hdspm_info_safe_mode(snd_kcontrol_t * kcontrol, | ||
1822 | snd_ctl_elem_info_t * uinfo) | ||
1823 | { | ||
1824 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
1825 | uinfo->count = 1; | ||
1826 | uinfo->value.integer.min = 0; | ||
1827 | uinfo->value.integer.max = 1; | ||
1828 | return 0; | ||
1829 | } | ||
1830 | |||
1831 | static int snd_hdspm_get_safe_mode(snd_kcontrol_t * kcontrol, | ||
1832 | snd_ctl_elem_value_t * ucontrol) | ||
1833 | { | ||
1834 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1835 | |||
1836 | spin_lock_irq(&hdspm->lock); | ||
1837 | ucontrol->value.integer.value[0] = hdspm_safe_mode(hdspm); | ||
1838 | spin_unlock_irq(&hdspm->lock); | ||
1839 | return 0; | ||
1840 | } | ||
1841 | |||
1842 | static int snd_hdspm_put_safe_mode(snd_kcontrol_t * kcontrol, | ||
1843 | snd_ctl_elem_value_t * ucontrol) | ||
1844 | { | ||
1845 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1846 | int change; | ||
1847 | unsigned int val; | ||
1848 | |||
1849 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
1850 | return -EBUSY; | ||
1851 | val = ucontrol->value.integer.value[0] & 1; | ||
1852 | spin_lock_irq(&hdspm->lock); | ||
1853 | change = (int) val != hdspm_safe_mode(hdspm); | ||
1854 | hdspm_set_safe_mode(hdspm, val); | ||
1855 | spin_unlock_irq(&hdspm->lock); | ||
1856 | return change; | ||
1857 | } | ||
1858 | |||
1859 | #define HDSPM_INPUT_SELECT(xname, xindex) \ | ||
1860 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1861 | .name = xname, \ | ||
1862 | .index = xindex, \ | ||
1863 | .info = snd_hdspm_info_input_select, \ | ||
1864 | .get = snd_hdspm_get_input_select, \ | ||
1865 | .put = snd_hdspm_put_input_select \ | ||
1866 | } | ||
1867 | |||
1868 | static int hdspm_input_select(hdspm_t * hdspm) | ||
1869 | { | ||
1870 | return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0; | ||
1871 | } | ||
1872 | |||
1873 | static int hdspm_set_input_select(hdspm_t * hdspm, int out) | ||
1874 | { | ||
1875 | if (out) | ||
1876 | hdspm->control_register |= HDSPM_InputSelect0; | ||
1877 | else | ||
1878 | hdspm->control_register &= ~HDSPM_InputSelect0; | ||
1879 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
1880 | |||
1881 | return 0; | ||
1882 | } | ||
1883 | |||
1884 | static int snd_hdspm_info_input_select(snd_kcontrol_t * kcontrol, | ||
1885 | snd_ctl_elem_info_t * uinfo) | ||
1886 | { | ||
1887 | static char *texts[] = { "optical", "coaxial" }; | ||
1888 | |||
1889 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
1890 | uinfo->count = 1; | ||
1891 | uinfo->value.enumerated.items = 2; | ||
1892 | |||
1893 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
1894 | uinfo->value.enumerated.item = | ||
1895 | uinfo->value.enumerated.items - 1; | ||
1896 | strcpy(uinfo->value.enumerated.name, | ||
1897 | texts[uinfo->value.enumerated.item]); | ||
1898 | |||
1899 | return 0; | ||
1900 | } | ||
1901 | |||
1902 | static int snd_hdspm_get_input_select(snd_kcontrol_t * kcontrol, | ||
1903 | snd_ctl_elem_value_t * ucontrol) | ||
1904 | { | ||
1905 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1906 | |||
1907 | spin_lock_irq(&hdspm->lock); | ||
1908 | ucontrol->value.enumerated.item[0] = hdspm_input_select(hdspm); | ||
1909 | spin_unlock_irq(&hdspm->lock); | ||
1910 | return 0; | ||
1911 | } | ||
1912 | |||
1913 | static int snd_hdspm_put_input_select(snd_kcontrol_t * kcontrol, | ||
1914 | snd_ctl_elem_value_t * ucontrol) | ||
1915 | { | ||
1916 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1917 | int change; | ||
1918 | unsigned int val; | ||
1919 | |||
1920 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
1921 | return -EBUSY; | ||
1922 | val = ucontrol->value.integer.value[0] & 1; | ||
1923 | spin_lock_irq(&hdspm->lock); | ||
1924 | change = (int) val != hdspm_input_select(hdspm); | ||
1925 | hdspm_set_input_select(hdspm, val); | ||
1926 | spin_unlock_irq(&hdspm->lock); | ||
1927 | return change; | ||
1928 | } | ||
1929 | |||
1930 | /* Simple Mixer | ||
1931 | deprecated since to much faders ??? | ||
1932 | MIXER interface says output (source, destination, value) | ||
1933 | where source > MAX_channels are playback channels | ||
1934 | on MADICARD | ||
1935 | - playback mixer matrix: [channelout+64] [output] [value] | ||
1936 | - input(thru) mixer matrix: [channelin] [output] [value] | ||
1937 | (better do 2 kontrols for seperation ?) | ||
1938 | */ | ||
1939 | |||
1940 | #define HDSPM_MIXER(xname, xindex) \ | ||
1941 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
1942 | .name = xname, \ | ||
1943 | .index = xindex, \ | ||
1944 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | ||
1945 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ | ||
1946 | .info = snd_hdspm_info_mixer, \ | ||
1947 | .get = snd_hdspm_get_mixer, \ | ||
1948 | .put = snd_hdspm_put_mixer \ | ||
1949 | } | ||
1950 | |||
1951 | static int snd_hdspm_info_mixer(snd_kcontrol_t * kcontrol, | ||
1952 | snd_ctl_elem_info_t * uinfo) | ||
1953 | { | ||
1954 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
1955 | uinfo->count = 3; | ||
1956 | uinfo->value.integer.min = 0; | ||
1957 | uinfo->value.integer.max = 65535; | ||
1958 | uinfo->value.integer.step = 1; | ||
1959 | return 0; | ||
1960 | } | ||
1961 | |||
1962 | static int snd_hdspm_get_mixer(snd_kcontrol_t * kcontrol, | ||
1963 | snd_ctl_elem_value_t * ucontrol) | ||
1964 | { | ||
1965 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1966 | int source; | ||
1967 | int destination; | ||
1968 | |||
1969 | source = ucontrol->value.integer.value[0]; | ||
1970 | if (source < 0) | ||
1971 | source = 0; | ||
1972 | else if (source >= 2 * HDSPM_MAX_CHANNELS) | ||
1973 | source = 2 * HDSPM_MAX_CHANNELS - 1; | ||
1974 | |||
1975 | destination = ucontrol->value.integer.value[1]; | ||
1976 | if (destination < 0) | ||
1977 | destination = 0; | ||
1978 | else if (destination >= HDSPM_MAX_CHANNELS) | ||
1979 | destination = HDSPM_MAX_CHANNELS - 1; | ||
1980 | |||
1981 | spin_lock_irq(&hdspm->lock); | ||
1982 | if (source >= HDSPM_MAX_CHANNELS) | ||
1983 | ucontrol->value.integer.value[2] = | ||
1984 | hdspm_read_pb_gain(hdspm, destination, | ||
1985 | source - HDSPM_MAX_CHANNELS); | ||
1986 | else | ||
1987 | ucontrol->value.integer.value[2] = | ||
1988 | hdspm_read_in_gain(hdspm, destination, source); | ||
1989 | |||
1990 | spin_unlock_irq(&hdspm->lock); | ||
1991 | |||
1992 | return 0; | ||
1993 | } | ||
1994 | |||
1995 | static int snd_hdspm_put_mixer(snd_kcontrol_t * kcontrol, | ||
1996 | snd_ctl_elem_value_t * ucontrol) | ||
1997 | { | ||
1998 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
1999 | int change; | ||
2000 | int source; | ||
2001 | int destination; | ||
2002 | int gain; | ||
2003 | |||
2004 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
2005 | return -EBUSY; | ||
2006 | |||
2007 | source = ucontrol->value.integer.value[0]; | ||
2008 | destination = ucontrol->value.integer.value[1]; | ||
2009 | |||
2010 | if (source < 0 || source >= 2 * HDSPM_MAX_CHANNELS) | ||
2011 | return -1; | ||
2012 | if (destination < 0 || destination >= HDSPM_MAX_CHANNELS) | ||
2013 | return -1; | ||
2014 | |||
2015 | gain = ucontrol->value.integer.value[2]; | ||
2016 | |||
2017 | spin_lock_irq(&hdspm->lock); | ||
2018 | |||
2019 | if (source >= HDSPM_MAX_CHANNELS) | ||
2020 | change = gain != hdspm_read_pb_gain(hdspm, destination, | ||
2021 | source - | ||
2022 | HDSPM_MAX_CHANNELS); | ||
2023 | else | ||
2024 | change = | ||
2025 | gain != hdspm_read_in_gain(hdspm, destination, source); | ||
2026 | |||
2027 | if (change) { | ||
2028 | if (source >= HDSPM_MAX_CHANNELS) | ||
2029 | hdspm_write_pb_gain(hdspm, destination, | ||
2030 | source - HDSPM_MAX_CHANNELS, | ||
2031 | gain); | ||
2032 | else | ||
2033 | hdspm_write_in_gain(hdspm, destination, source, | ||
2034 | gain); | ||
2035 | } | ||
2036 | spin_unlock_irq(&hdspm->lock); | ||
2037 | |||
2038 | return change; | ||
2039 | } | ||
2040 | |||
2041 | /* The simple mixer control(s) provide gain control for the | ||
2042 | basic 1:1 mappings of playback streams to output | ||
2043 | streams. | ||
2044 | */ | ||
2045 | |||
2046 | #define HDSPM_PLAYBACK_MIXER \ | ||
2047 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
2048 | .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_WRITE | \ | ||
2049 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ | ||
2050 | .info = snd_hdspm_info_playback_mixer, \ | ||
2051 | .get = snd_hdspm_get_playback_mixer, \ | ||
2052 | .put = snd_hdspm_put_playback_mixer \ | ||
2053 | } | ||
2054 | |||
2055 | static int snd_hdspm_info_playback_mixer(snd_kcontrol_t * kcontrol, | ||
2056 | snd_ctl_elem_info_t * uinfo) | ||
2057 | { | ||
2058 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
2059 | uinfo->count = 1; | ||
2060 | uinfo->value.integer.min = 0; | ||
2061 | uinfo->value.integer.max = 65536; | ||
2062 | uinfo->value.integer.step = 1; | ||
2063 | return 0; | ||
2064 | } | ||
2065 | |||
2066 | static int snd_hdspm_get_playback_mixer(snd_kcontrol_t * kcontrol, | ||
2067 | snd_ctl_elem_value_t * ucontrol) | ||
2068 | { | ||
2069 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
2070 | int channel; | ||
2071 | int mapped_channel; | ||
2072 | |||
2073 | channel = ucontrol->id.index - 1; | ||
2074 | |||
2075 | snd_assert(channel >= 0 | ||
2076 | || channel < HDSPM_MAX_CHANNELS, return -EINVAL); | ||
2077 | |||
2078 | if ((mapped_channel = hdspm->channel_map[channel]) < 0) | ||
2079 | return -EINVAL; | ||
2080 | |||
2081 | spin_lock_irq(&hdspm->lock); | ||
2082 | ucontrol->value.integer.value[0] = | ||
2083 | hdspm_read_pb_gain(hdspm, mapped_channel, mapped_channel); | ||
2084 | spin_unlock_irq(&hdspm->lock); | ||
2085 | |||
2086 | /* snd_printdd("get pb mixer index %d, channel %d, mapped_channel %d, value %d\n", | ||
2087 | ucontrol->id.index, channel, mapped_channel, ucontrol->value.integer.value[0]); | ||
2088 | */ | ||
2089 | |||
2090 | return 0; | ||
2091 | } | ||
2092 | |||
2093 | static int snd_hdspm_put_playback_mixer(snd_kcontrol_t * kcontrol, | ||
2094 | snd_ctl_elem_value_t * ucontrol) | ||
2095 | { | ||
2096 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
2097 | int change; | ||
2098 | int channel; | ||
2099 | int mapped_channel; | ||
2100 | int gain; | ||
2101 | |||
2102 | if (!snd_hdspm_use_is_exclusive(hdspm)) | ||
2103 | return -EBUSY; | ||
2104 | |||
2105 | channel = ucontrol->id.index - 1; | ||
2106 | |||
2107 | snd_assert(channel >= 0 | ||
2108 | || channel < HDSPM_MAX_CHANNELS, return -EINVAL); | ||
2109 | |||
2110 | if ((mapped_channel = hdspm->channel_map[channel]) < 0) | ||
2111 | return -EINVAL; | ||
2112 | |||
2113 | gain = ucontrol->value.integer.value[0]; | ||
2114 | |||
2115 | spin_lock_irq(&hdspm->lock); | ||
2116 | change = | ||
2117 | gain != hdspm_read_pb_gain(hdspm, mapped_channel, | ||
2118 | mapped_channel); | ||
2119 | if (change) | ||
2120 | hdspm_write_pb_gain(hdspm, mapped_channel, mapped_channel, | ||
2121 | gain); | ||
2122 | spin_unlock_irq(&hdspm->lock); | ||
2123 | return change; | ||
2124 | } | ||
2125 | |||
2126 | #define HDSPM_WC_SYNC_CHECK(xname, xindex) \ | ||
2127 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
2128 | .name = xname, \ | ||
2129 | .index = xindex, \ | ||
2130 | .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ | ||
2131 | .info = snd_hdspm_info_sync_check, \ | ||
2132 | .get = snd_hdspm_get_wc_sync_check \ | ||
2133 | } | ||
2134 | |||
2135 | static int snd_hdspm_info_sync_check(snd_kcontrol_t * kcontrol, | ||
2136 | snd_ctl_elem_info_t * uinfo) | ||
2137 | { | ||
2138 | static char *texts[] = { "No Lock", "Lock", "Sync" }; | ||
2139 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2140 | uinfo->count = 1; | ||
2141 | uinfo->value.enumerated.items = 3; | ||
2142 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
2143 | uinfo->value.enumerated.item = | ||
2144 | uinfo->value.enumerated.items - 1; | ||
2145 | strcpy(uinfo->value.enumerated.name, | ||
2146 | texts[uinfo->value.enumerated.item]); | ||
2147 | return 0; | ||
2148 | } | ||
2149 | |||
2150 | static int hdspm_wc_sync_check(hdspm_t * hdspm) | ||
2151 | { | ||
2152 | int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); | ||
2153 | if (status2 & HDSPM_wcLock) { | ||
2154 | if (status2 & HDSPM_wcSync) | ||
2155 | return 2; | ||
2156 | else | ||
2157 | return 1; | ||
2158 | } | ||
2159 | return 0; | ||
2160 | } | ||
2161 | |||
2162 | static int snd_hdspm_get_wc_sync_check(snd_kcontrol_t * kcontrol, | ||
2163 | snd_ctl_elem_value_t * ucontrol) | ||
2164 | { | ||
2165 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
2166 | |||
2167 | ucontrol->value.enumerated.item[0] = hdspm_wc_sync_check(hdspm); | ||
2168 | return 0; | ||
2169 | } | ||
2170 | |||
2171 | |||
2172 | #define HDSPM_MADI_SYNC_CHECK(xname, xindex) \ | ||
2173 | { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ | ||
2174 | .name = xname, \ | ||
2175 | .index = xindex, \ | ||
2176 | .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ | ||
2177 | .info = snd_hdspm_info_sync_check, \ | ||
2178 | .get = snd_hdspm_get_madisync_sync_check \ | ||
2179 | } | ||
2180 | |||
2181 | static int hdspm_madisync_sync_check(hdspm_t * hdspm) | ||
2182 | { | ||
2183 | int status = hdspm_read(hdspm, HDSPM_statusRegister); | ||
2184 | if (status & HDSPM_madiLock) { | ||
2185 | if (status & HDSPM_madiSync) | ||
2186 | return 2; | ||
2187 | else | ||
2188 | return 1; | ||
2189 | } | ||
2190 | return 0; | ||
2191 | } | ||
2192 | |||
2193 | static int snd_hdspm_get_madisync_sync_check(snd_kcontrol_t * kcontrol, | ||
2194 | snd_ctl_elem_value_t * | ||
2195 | ucontrol) | ||
2196 | { | ||
2197 | hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); | ||
2198 | |||
2199 | ucontrol->value.enumerated.item[0] = | ||
2200 | hdspm_madisync_sync_check(hdspm); | ||
2201 | return 0; | ||
2202 | } | ||
2203 | |||
2204 | |||
2205 | |||
2206 | |||
2207 | static snd_kcontrol_new_t snd_hdspm_controls[] = { | ||
2208 | |||
2209 | HDSPM_MIXER("Mixer", 0), | ||
2210 | /* 'Sample Clock Source' complies with the alsa control naming scheme */ | ||
2211 | HDSPM_CLOCK_SOURCE("Sample Clock Source", 0), | ||
2212 | |||
2213 | HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0), | ||
2214 | HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0), | ||
2215 | HDSPM_AUTOSYNC_REF("AutoSync Reference", 0), | ||
2216 | HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0), | ||
2217 | /* 'External Rate' complies with the alsa control naming scheme */ | ||
2218 | HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0), | ||
2219 | HDSPM_WC_SYNC_CHECK("Word Clock Lock Status", 0), | ||
2220 | HDSPM_MADI_SYNC_CHECK("MADI Sync Lock Status", 0), | ||
2221 | HDSPM_LINE_OUT("Line Out", 0), | ||
2222 | HDSPM_TX_64("TX 64 channels mode", 0), | ||
2223 | HDSPM_C_TMS("Clear Track Marker", 0), | ||
2224 | HDSPM_SAFE_MODE("Safe Mode", 0), | ||
2225 | HDSPM_INPUT_SELECT("Input Select", 0), | ||
2226 | }; | ||
2227 | |||
2228 | static snd_kcontrol_new_t snd_hdspm_playback_mixer = HDSPM_PLAYBACK_MIXER; | ||
2229 | |||
2230 | |||
2231 | static int hdspm_update_simple_mixer_controls(hdspm_t * hdspm) | ||
2232 | { | ||
2233 | int i; | ||
2234 | |||
2235 | for (i = hdspm->ds_channels; i < hdspm->ss_channels; ++i) { | ||
2236 | if (hdspm->system_sample_rate > 48000) { | ||
2237 | hdspm->playback_mixer_ctls[i]->vd[0].access = | ||
2238 | SNDRV_CTL_ELEM_ACCESS_INACTIVE | | ||
2239 | SNDRV_CTL_ELEM_ACCESS_READ | | ||
2240 | SNDRV_CTL_ELEM_ACCESS_VOLATILE; | ||
2241 | } else { | ||
2242 | hdspm->playback_mixer_ctls[i]->vd[0].access = | ||
2243 | SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
2244 | SNDRV_CTL_ELEM_ACCESS_VOLATILE; | ||
2245 | } | ||
2246 | snd_ctl_notify(hdspm->card, SNDRV_CTL_EVENT_MASK_VALUE | | ||
2247 | SNDRV_CTL_EVENT_MASK_INFO, | ||
2248 | &hdspm->playback_mixer_ctls[i]->id); | ||
2249 | } | ||
2250 | |||
2251 | return 0; | ||
2252 | } | ||
2253 | |||
2254 | |||
2255 | static int snd_hdspm_create_controls(snd_card_t * card, hdspm_t * hdspm) | ||
2256 | { | ||
2257 | unsigned int idx, limit; | ||
2258 | int err; | ||
2259 | snd_kcontrol_t *kctl; | ||
2260 | |||
2261 | /* add control list first */ | ||
2262 | |||
2263 | for (idx = 0; idx < ARRAY_SIZE(snd_hdspm_controls); idx++) { | ||
2264 | if ((err = | ||
2265 | snd_ctl_add(card, kctl = | ||
2266 | snd_ctl_new1(&snd_hdspm_controls[idx], | ||
2267 | hdspm))) < 0) { | ||
2268 | return err; | ||
2269 | } | ||
2270 | } | ||
2271 | |||
2272 | /* Channel playback mixer as default control | ||
2273 | Note: the whole matrix would be 128*HDSPM_MIXER_CHANNELS Faders, thats to big for any alsamixer | ||
2274 | they are accesible via special IOCTL on hwdep | ||
2275 | and the mixer 2dimensional mixer control */ | ||
2276 | |||
2277 | snd_hdspm_playback_mixer.name = "Chn"; | ||
2278 | limit = HDSPM_MAX_CHANNELS; | ||
2279 | |||
2280 | /* The index values are one greater than the channel ID so that alsamixer | ||
2281 | will display them correctly. We want to use the index for fast lookup | ||
2282 | of the relevant channel, but if we use it at all, most ALSA software | ||
2283 | does the wrong thing with it ... | ||
2284 | */ | ||
2285 | |||
2286 | for (idx = 0; idx < limit; ++idx) { | ||
2287 | snd_hdspm_playback_mixer.index = idx + 1; | ||
2288 | if ((err = snd_ctl_add(card, | ||
2289 | kctl = | ||
2290 | snd_ctl_new1 | ||
2291 | (&snd_hdspm_playback_mixer, | ||
2292 | hdspm)))) { | ||
2293 | return err; | ||
2294 | } | ||
2295 | hdspm->playback_mixer_ctls[idx] = kctl; | ||
2296 | } | ||
2297 | |||
2298 | return 0; | ||
2299 | } | ||
2300 | |||
2301 | /*------------------------------------------------------------ | ||
2302 | /proc interface | ||
2303 | ------------------------------------------------------------*/ | ||
2304 | |||
2305 | static void | ||
2306 | snd_hdspm_proc_read(snd_info_entry_t * entry, snd_info_buffer_t * buffer) | ||
2307 | { | ||
2308 | hdspm_t *hdspm = (hdspm_t *) entry->private_data; | ||
2309 | unsigned int status; | ||
2310 | unsigned int status2; | ||
2311 | char *pref_sync_ref; | ||
2312 | char *autosync_ref; | ||
2313 | char *system_clock_mode; | ||
2314 | char *clock_source; | ||
2315 | char *insel; | ||
2316 | char *syncref; | ||
2317 | int x, x2; | ||
2318 | |||
2319 | status = hdspm_read(hdspm, HDSPM_statusRegister); | ||
2320 | status2 = hdspm_read(hdspm, HDSPM_statusRegister2); | ||
2321 | |||
2322 | snd_iprintf(buffer, "%s (Card #%d) Rev.%x Status2first3bits: %x\n", | ||
2323 | hdspm->card_name, hdspm->card->number + 1, | ||
2324 | hdspm->firmware_rev, | ||
2325 | (status2 & HDSPM_version0) | | ||
2326 | (status2 & HDSPM_version1) | (status2 & | ||
2327 | HDSPM_version2)); | ||
2328 | |||
2329 | snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n", | ||
2330 | hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); | ||
2331 | |||
2332 | snd_iprintf(buffer, "--- System ---\n"); | ||
2333 | |||
2334 | snd_iprintf(buffer, | ||
2335 | "IRQ Pending: Audio=%d, MIDI0=%d, MIDI1=%d, IRQcount=%d\n", | ||
2336 | status & HDSPM_audioIRQPending, | ||
2337 | (status & HDSPM_midi0IRQPending) ? 1 : 0, | ||
2338 | (status & HDSPM_midi1IRQPending) ? 1 : 0, | ||
2339 | hdspm->irq_count); | ||
2340 | snd_iprintf(buffer, | ||
2341 | "HW pointer: id = %d, rawptr = %d (%d->%d) estimated= %ld (bytes)\n", | ||
2342 | ((status & HDSPM_BufferID) ? 1 : 0), | ||
2343 | (status & HDSPM_BufferPositionMask), | ||
2344 | (status & HDSPM_BufferPositionMask) % (2 * | ||
2345 | (int)hdspm-> | ||
2346 | period_bytes), | ||
2347 | ((status & HDSPM_BufferPositionMask) - | ||
2348 | 64) % (2 * (int)hdspm->period_bytes), | ||
2349 | (long) hdspm_hw_pointer(hdspm) * 4); | ||
2350 | |||
2351 | snd_iprintf(buffer, | ||
2352 | "MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n", | ||
2353 | hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF, | ||
2354 | hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF, | ||
2355 | hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, | ||
2356 | hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); | ||
2357 | snd_iprintf(buffer, | ||
2358 | "Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, status2=0x%x\n", | ||
2359 | hdspm->control_register, hdspm->control2_register, | ||
2360 | status, status2); | ||
2361 | |||
2362 | snd_iprintf(buffer, "--- Settings ---\n"); | ||
2363 | |||
2364 | x = 1 << (6 + | ||
2365 | hdspm_decode_latency(hdspm-> | ||
2366 | control_register & | ||
2367 | HDSPM_LatencyMask)); | ||
2368 | |||
2369 | snd_iprintf(buffer, | ||
2370 | "Size (Latency): %d samples (2 periods of %lu bytes)\n", | ||
2371 | x, (unsigned long) hdspm->period_bytes); | ||
2372 | |||
2373 | snd_iprintf(buffer, "Line out: %s, Precise Pointer: %s\n", | ||
2374 | (hdspm-> | ||
2375 | control_register & HDSPM_LineOut) ? "on " : "off", | ||
2376 | (hdspm->precise_ptr) ? "on" : "off"); | ||
2377 | |||
2378 | switch (hdspm->control_register & HDSPM_InputMask) { | ||
2379 | case HDSPM_InputOptical: | ||
2380 | insel = "Optical"; | ||
2381 | break; | ||
2382 | case HDSPM_InputCoaxial: | ||
2383 | insel = "Coaxial"; | ||
2384 | break; | ||
2385 | default: | ||
2386 | insel = "Unkown"; | ||
2387 | } | ||
2388 | |||
2389 | switch (hdspm->control_register & HDSPM_SyncRefMask) { | ||
2390 | case HDSPM_SyncRef_Word: | ||
2391 | syncref = "WordClock"; | ||
2392 | break; | ||
2393 | case HDSPM_SyncRef_MADI: | ||
2394 | syncref = "MADI"; | ||
2395 | break; | ||
2396 | default: | ||
2397 | syncref = "Unkown"; | ||
2398 | } | ||
2399 | snd_iprintf(buffer, "Inputsel = %s, SyncRef = %s\n", insel, | ||
2400 | syncref); | ||
2401 | |||
2402 | snd_iprintf(buffer, | ||
2403 | "ClearTrackMarker = %s, Transmit in %s Channel Mode, Auto Input %s\n", | ||
2404 | (hdspm-> | ||
2405 | control_register & HDSPM_clr_tms) ? "on" : "off", | ||
2406 | (hdspm-> | ||
2407 | control_register & HDSPM_TX_64ch) ? "64" : "56", | ||
2408 | (hdspm-> | ||
2409 | control_register & HDSPM_AutoInp) ? "on" : "off"); | ||
2410 | |||
2411 | switch (hdspm_clock_source(hdspm)) { | ||
2412 | case HDSPM_CLOCK_SOURCE_AUTOSYNC: | ||
2413 | clock_source = "AutoSync"; | ||
2414 | break; | ||
2415 | case HDSPM_CLOCK_SOURCE_INTERNAL_32KHZ: | ||
2416 | clock_source = "Internal 32 kHz"; | ||
2417 | break; | ||
2418 | case HDSPM_CLOCK_SOURCE_INTERNAL_44_1KHZ: | ||
2419 | clock_source = "Internal 44.1 kHz"; | ||
2420 | break; | ||
2421 | case HDSPM_CLOCK_SOURCE_INTERNAL_48KHZ: | ||
2422 | clock_source = "Internal 48 kHz"; | ||
2423 | break; | ||
2424 | case HDSPM_CLOCK_SOURCE_INTERNAL_64KHZ: | ||
2425 | clock_source = "Internal 64 kHz"; | ||
2426 | break; | ||
2427 | case HDSPM_CLOCK_SOURCE_INTERNAL_88_2KHZ: | ||
2428 | clock_source = "Internal 88.2 kHz"; | ||
2429 | break; | ||
2430 | case HDSPM_CLOCK_SOURCE_INTERNAL_96KHZ: | ||
2431 | clock_source = "Internal 96 kHz"; | ||
2432 | break; | ||
2433 | default: | ||
2434 | clock_source = "Error"; | ||
2435 | } | ||
2436 | snd_iprintf(buffer, "Sample Clock Source: %s\n", clock_source); | ||
2437 | if (!(hdspm->control_register & HDSPM_ClockModeMaster)) { | ||
2438 | system_clock_mode = "Slave"; | ||
2439 | } else { | ||
2440 | system_clock_mode = "Master"; | ||
2441 | } | ||
2442 | snd_iprintf(buffer, "System Clock Mode: %s\n", system_clock_mode); | ||
2443 | |||
2444 | switch (hdspm_pref_sync_ref(hdspm)) { | ||
2445 | case HDSPM_SYNC_FROM_WORD: | ||
2446 | pref_sync_ref = "Word Clock"; | ||
2447 | break; | ||
2448 | case HDSPM_SYNC_FROM_MADI: | ||
2449 | pref_sync_ref = "MADI Sync"; | ||
2450 | break; | ||
2451 | default: | ||
2452 | pref_sync_ref = "XXXX Clock"; | ||
2453 | break; | ||
2454 | } | ||
2455 | snd_iprintf(buffer, "Preferred Sync Reference: %s\n", | ||
2456 | pref_sync_ref); | ||
2457 | |||
2458 | snd_iprintf(buffer, "System Clock Frequency: %d\n", | ||
2459 | hdspm->system_sample_rate); | ||
2460 | |||
2461 | |||
2462 | snd_iprintf(buffer, "--- Status:\n"); | ||
2463 | |||
2464 | x = status & HDSPM_madiSync; | ||
2465 | x2 = status2 & HDSPM_wcSync; | ||
2466 | |||
2467 | snd_iprintf(buffer, "Inputs MADI=%s, WordClock=%s\n", | ||
2468 | (status & HDSPM_madiLock) ? (x ? "Sync" : "Lock") : | ||
2469 | "NoLock", | ||
2470 | (status2 & HDSPM_wcLock) ? (x2 ? "Sync" : "Lock") : | ||
2471 | "NoLock"); | ||
2472 | |||
2473 | switch (hdspm_autosync_ref(hdspm)) { | ||
2474 | case HDSPM_AUTOSYNC_FROM_WORD: | ||
2475 | autosync_ref = "Word Clock"; | ||
2476 | break; | ||
2477 | case HDSPM_AUTOSYNC_FROM_MADI: | ||
2478 | autosync_ref = "MADI Sync"; | ||
2479 | break; | ||
2480 | case HDSPM_AUTOSYNC_FROM_NONE: | ||
2481 | autosync_ref = "Input not valid"; | ||
2482 | break; | ||
2483 | default: | ||
2484 | autosync_ref = "---"; | ||
2485 | break; | ||
2486 | } | ||
2487 | snd_iprintf(buffer, | ||
2488 | "AutoSync: Reference= %s, Freq=%d (MADI = %d, Word = %d)\n", | ||
2489 | autosync_ref, hdspm_external_sample_rate(hdspm), | ||
2490 | (status & HDSPM_madiFreqMask) >> 22, | ||
2491 | (status2 & HDSPM_wcFreqMask) >> 5); | ||
2492 | |||
2493 | snd_iprintf(buffer, "Input: %s, Mode=%s\n", | ||
2494 | (status & HDSPM_AB_int) ? "Coax" : "Optical", | ||
2495 | (status & HDSPM_RX_64ch) ? "64 channels" : | ||
2496 | "56 channels"); | ||
2497 | |||
2498 | snd_iprintf(buffer, "\n"); | ||
2499 | } | ||
2500 | |||
2501 | static void __devinit snd_hdspm_proc_init(hdspm_t * hdspm) | ||
2502 | { | ||
2503 | snd_info_entry_t *entry; | ||
2504 | |||
2505 | if (!snd_card_proc_new(hdspm->card, "hdspm", &entry)) | ||
2506 | snd_info_set_text_ops(entry, hdspm, 1024, | ||
2507 | snd_hdspm_proc_read); | ||
2508 | } | ||
2509 | |||
2510 | /*------------------------------------------------------------ | ||
2511 | hdspm intitialize | ||
2512 | ------------------------------------------------------------*/ | ||
2513 | |||
2514 | static int snd_hdspm_set_defaults(hdspm_t * hdspm) | ||
2515 | { | ||
2516 | unsigned int i; | ||
2517 | |||
2518 | /* ASSUMPTION: hdspm->lock is either held, or there is no need to | ||
2519 | hold it (e.g. during module initalization). | ||
2520 | */ | ||
2521 | |||
2522 | /* set defaults: */ | ||
2523 | |||
2524 | hdspm->control_register = HDSPM_ClockModeMaster | /* Master Cloack Mode on */ | ||
2525 | hdspm_encode_latency(7) | /* latency maximum = 8192 samples */ | ||
2526 | HDSPM_InputCoaxial | /* Input Coax not Optical */ | ||
2527 | HDSPM_SyncRef_MADI | /* Madi is syncclock */ | ||
2528 | HDSPM_LineOut | /* Analog output in */ | ||
2529 | HDSPM_TX_64ch | /* transmit in 64ch mode */ | ||
2530 | HDSPM_AutoInp; /* AutoInput chossing (takeover) */ | ||
2531 | |||
2532 | /* ! HDSPM_Frequency0|HDSPM_Frequency1 = 44.1khz */ | ||
2533 | /* ! HDSPM_DoubleSpeed HDSPM_QuadSpeed = normal speed */ | ||
2534 | /* ! HDSPM_clr_tms = do not clear bits in track marks */ | ||
2535 | |||
2536 | hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); | ||
2537 | |||
2538 | #ifdef SNDRV_BIG_ENDIAN | ||
2539 | hdspm->control2_register = HDSPM_BIGENDIAN_MODE; | ||
2540 | #else | ||
2541 | hdspm->control2_register = 0; | ||
2542 | #endif | ||
2543 | |||
2544 | hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register); | ||
2545 | hdspm_compute_period_size(hdspm); | ||
2546 | |||
2547 | /* silence everything */ | ||
2548 | |||
2549 | all_in_all_mixer(hdspm, 0 * UNITY_GAIN); | ||
2550 | |||
2551 | if (line_outs_monitor[hdspm->dev]) { | ||
2552 | |||
2553 | snd_printk(KERN_INFO "HDSPM: sending all playback streams to line outs.\n"); | ||
2554 | |||
2555 | for (i = 0; i < HDSPM_MIXER_CHANNELS; i++) { | ||
2556 | if (hdspm_write_pb_gain(hdspm, i, i, UNITY_GAIN)) | ||
2557 | return -EIO; | ||
2558 | } | ||
2559 | } | ||
2560 | |||
2561 | /* set a default rate so that the channel map is set up. */ | ||
2562 | hdspm->channel_map = channel_map_madi_ss; | ||
2563 | hdspm_set_rate(hdspm, 44100, 1); | ||
2564 | |||
2565 | return 0; | ||
2566 | } | ||
2567 | |||
2568 | |||
2569 | /*------------------------------------------------------------ | ||
2570 | interupt | ||
2571 | ------------------------------------------------------------*/ | ||
2572 | |||
2573 | static irqreturn_t snd_hdspm_interrupt(int irq, void *dev_id, | ||
2574 | struct pt_regs *regs) | ||
2575 | { | ||
2576 | hdspm_t *hdspm = (hdspm_t *) dev_id; | ||
2577 | unsigned int status; | ||
2578 | int audio; | ||
2579 | int midi0; | ||
2580 | int midi1; | ||
2581 | unsigned int midi0status; | ||
2582 | unsigned int midi1status; | ||
2583 | int schedule = 0; | ||
2584 | |||
2585 | status = hdspm_read(hdspm, HDSPM_statusRegister); | ||
2586 | |||
2587 | audio = status & HDSPM_audioIRQPending; | ||
2588 | midi0 = status & HDSPM_midi0IRQPending; | ||
2589 | midi1 = status & HDSPM_midi1IRQPending; | ||
2590 | |||
2591 | if (!audio && !midi0 && !midi1) | ||
2592 | return IRQ_NONE; | ||
2593 | |||
2594 | hdspm_write(hdspm, HDSPM_interruptConfirmation, 0); | ||
2595 | hdspm->irq_count++; | ||
2596 | |||
2597 | midi0status = hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xff; | ||
2598 | midi1status = hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xff; | ||
2599 | |||
2600 | if (audio) { | ||
2601 | |||
2602 | if (hdspm->capture_substream) | ||
2603 | snd_pcm_period_elapsed(hdspm->pcm-> | ||
2604 | streams | ||
2605 | [SNDRV_PCM_STREAM_CAPTURE]. | ||
2606 | substream); | ||
2607 | |||
2608 | if (hdspm->playback_substream) | ||
2609 | snd_pcm_period_elapsed(hdspm->pcm-> | ||
2610 | streams | ||
2611 | [SNDRV_PCM_STREAM_PLAYBACK]. | ||
2612 | substream); | ||
2613 | } | ||
2614 | |||
2615 | if (midi0 && midi0status) { | ||
2616 | /* we disable interrupts for this input until processing is done */ | ||
2617 | hdspm->control_register &= ~HDSPM_Midi0InterruptEnable; | ||
2618 | hdspm_write(hdspm, HDSPM_controlRegister, | ||
2619 | hdspm->control_register); | ||
2620 | hdspm->midi[0].pending = 1; | ||
2621 | schedule = 1; | ||
2622 | } | ||
2623 | if (midi1 && midi1status) { | ||
2624 | /* we disable interrupts for this input until processing is done */ | ||
2625 | hdspm->control_register &= ~HDSPM_Midi1InterruptEnable; | ||
2626 | hdspm_write(hdspm, HDSPM_controlRegister, | ||
2627 | hdspm->control_register); | ||
2628 | hdspm->midi[1].pending = 1; | ||
2629 | schedule = 1; | ||
2630 | } | ||
2631 | if (schedule) | ||
2632 | tasklet_hi_schedule(&hdspm->midi_tasklet); | ||
2633 | return IRQ_HANDLED; | ||
2634 | } | ||
2635 | |||
2636 | /*------------------------------------------------------------ | ||
2637 | pcm interface | ||
2638 | ------------------------------------------------------------*/ | ||
2639 | |||
2640 | |||
2641 | static snd_pcm_uframes_t snd_hdspm_hw_pointer(snd_pcm_substream_t * | ||
2642 | substream) | ||
2643 | { | ||
2644 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2645 | return hdspm_hw_pointer(hdspm); | ||
2646 | } | ||
2647 | |||
2648 | static char *hdspm_channel_buffer_location(hdspm_t * hdspm, | ||
2649 | int stream, int channel) | ||
2650 | { | ||
2651 | int mapped_channel; | ||
2652 | |||
2653 | snd_assert(channel >= 0 | ||
2654 | || channel < HDSPM_MAX_CHANNELS, return NULL); | ||
2655 | |||
2656 | if ((mapped_channel = hdspm->channel_map[channel]) < 0) | ||
2657 | return NULL; | ||
2658 | |||
2659 | if (stream == SNDRV_PCM_STREAM_CAPTURE) { | ||
2660 | return hdspm->capture_buffer + | ||
2661 | mapped_channel * HDSPM_CHANNEL_BUFFER_BYTES; | ||
2662 | } else { | ||
2663 | return hdspm->playback_buffer + | ||
2664 | mapped_channel * HDSPM_CHANNEL_BUFFER_BYTES; | ||
2665 | } | ||
2666 | } | ||
2667 | |||
2668 | |||
2669 | /* dont know why need it ??? */ | ||
2670 | static int snd_hdspm_playback_copy(snd_pcm_substream_t * substream, | ||
2671 | int channel, snd_pcm_uframes_t pos, | ||
2672 | void __user *src, snd_pcm_uframes_t count) | ||
2673 | { | ||
2674 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2675 | char *channel_buf; | ||
2676 | |||
2677 | snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4, | ||
2678 | return -EINVAL); | ||
2679 | |||
2680 | channel_buf = hdspm_channel_buffer_location(hdspm, | ||
2681 | substream->pstr-> | ||
2682 | stream, channel); | ||
2683 | |||
2684 | snd_assert(channel_buf != NULL, return -EIO); | ||
2685 | |||
2686 | return copy_from_user(channel_buf + pos * 4, src, count * 4); | ||
2687 | } | ||
2688 | |||
2689 | static int snd_hdspm_capture_copy(snd_pcm_substream_t * substream, | ||
2690 | int channel, snd_pcm_uframes_t pos, | ||
2691 | void __user *dst, snd_pcm_uframes_t count) | ||
2692 | { | ||
2693 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2694 | char *channel_buf; | ||
2695 | |||
2696 | snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4, | ||
2697 | return -EINVAL); | ||
2698 | |||
2699 | channel_buf = hdspm_channel_buffer_location(hdspm, | ||
2700 | substream->pstr-> | ||
2701 | stream, channel); | ||
2702 | snd_assert(channel_buf != NULL, return -EIO); | ||
2703 | return copy_to_user(dst, channel_buf + pos * 4, count * 4); | ||
2704 | } | ||
2705 | |||
2706 | static int snd_hdspm_hw_silence(snd_pcm_substream_t * substream, | ||
2707 | int channel, snd_pcm_uframes_t pos, | ||
2708 | snd_pcm_uframes_t count) | ||
2709 | { | ||
2710 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2711 | char *channel_buf; | ||
2712 | |||
2713 | channel_buf = | ||
2714 | hdspm_channel_buffer_location(hdspm, substream->pstr->stream, | ||
2715 | channel); | ||
2716 | snd_assert(channel_buf != NULL, return -EIO); | ||
2717 | memset(channel_buf + pos * 4, 0, count * 4); | ||
2718 | return 0; | ||
2719 | } | ||
2720 | |||
2721 | static int snd_hdspm_reset(snd_pcm_substream_t * substream) | ||
2722 | { | ||
2723 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
2724 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2725 | snd_pcm_substream_t *other; | ||
2726 | |||
2727 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
2728 | other = hdspm->capture_substream; | ||
2729 | else | ||
2730 | other = hdspm->playback_substream; | ||
2731 | |||
2732 | if (hdspm->running) | ||
2733 | runtime->status->hw_ptr = hdspm_hw_pointer(hdspm); | ||
2734 | else | ||
2735 | runtime->status->hw_ptr = 0; | ||
2736 | if (other) { | ||
2737 | struct list_head *pos; | ||
2738 | snd_pcm_substream_t *s; | ||
2739 | snd_pcm_runtime_t *oruntime = other->runtime; | ||
2740 | snd_pcm_group_for_each(pos, substream) { | ||
2741 | s = snd_pcm_group_substream_entry(pos); | ||
2742 | if (s == other) { | ||
2743 | oruntime->status->hw_ptr = | ||
2744 | runtime->status->hw_ptr; | ||
2745 | break; | ||
2746 | } | ||
2747 | } | ||
2748 | } | ||
2749 | return 0; | ||
2750 | } | ||
2751 | |||
2752 | static int snd_hdspm_hw_params(snd_pcm_substream_t * substream, | ||
2753 | snd_pcm_hw_params_t * params) | ||
2754 | { | ||
2755 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2756 | int err; | ||
2757 | int i; | ||
2758 | pid_t this_pid; | ||
2759 | pid_t other_pid; | ||
2760 | struct snd_sg_buf *sgbuf; | ||
2761 | |||
2762 | |||
2763 | spin_lock_irq(&hdspm->lock); | ||
2764 | |||
2765 | if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
2766 | this_pid = hdspm->playback_pid; | ||
2767 | other_pid = hdspm->capture_pid; | ||
2768 | } else { | ||
2769 | this_pid = hdspm->capture_pid; | ||
2770 | other_pid = hdspm->playback_pid; | ||
2771 | } | ||
2772 | |||
2773 | if ((other_pid > 0) && (this_pid != other_pid)) { | ||
2774 | |||
2775 | /* The other stream is open, and not by the same | ||
2776 | task as this one. Make sure that the parameters | ||
2777 | that matter are the same. | ||
2778 | */ | ||
2779 | |||
2780 | if (params_rate(params) != hdspm->system_sample_rate) { | ||
2781 | spin_unlock_irq(&hdspm->lock); | ||
2782 | _snd_pcm_hw_param_setempty(params, | ||
2783 | SNDRV_PCM_HW_PARAM_RATE); | ||
2784 | return -EBUSY; | ||
2785 | } | ||
2786 | |||
2787 | if (params_period_size(params) != hdspm->period_bytes / 4) { | ||
2788 | spin_unlock_irq(&hdspm->lock); | ||
2789 | _snd_pcm_hw_param_setempty(params, | ||
2790 | SNDRV_PCM_HW_PARAM_PERIOD_SIZE); | ||
2791 | return -EBUSY; | ||
2792 | } | ||
2793 | |||
2794 | } | ||
2795 | /* We're fine. */ | ||
2796 | spin_unlock_irq(&hdspm->lock); | ||
2797 | |||
2798 | /* how to make sure that the rate matches an externally-set one ? */ | ||
2799 | |||
2800 | spin_lock_irq(&hdspm->lock); | ||
2801 | if ((err = hdspm_set_rate(hdspm, params_rate(params), 0)) < 0) { | ||
2802 | spin_unlock_irq(&hdspm->lock); | ||
2803 | _snd_pcm_hw_param_setempty(params, | ||
2804 | SNDRV_PCM_HW_PARAM_RATE); | ||
2805 | return err; | ||
2806 | } | ||
2807 | spin_unlock_irq(&hdspm->lock); | ||
2808 | |||
2809 | if ((err = | ||
2810 | hdspm_set_interrupt_interval(hdspm, | ||
2811 | params_period_size(params))) < | ||
2812 | 0) { | ||
2813 | _snd_pcm_hw_param_setempty(params, | ||
2814 | SNDRV_PCM_HW_PARAM_PERIOD_SIZE); | ||
2815 | return err; | ||
2816 | } | ||
2817 | |||
2818 | /* Memory allocation, takashi's method, dont know if we should spinlock */ | ||
2819 | /* malloc all buffer even if not enabled to get sure */ | ||
2820 | /* malloc only needed bytes */ | ||
2821 | err = | ||
2822 | snd_pcm_lib_malloc_pages(substream, | ||
2823 | HDSPM_CHANNEL_BUFFER_BYTES * | ||
2824 | params_channels(params)); | ||
2825 | if (err < 0) | ||
2826 | return err; | ||
2827 | |||
2828 | sgbuf = snd_pcm_substream_sgbuf(substream); | ||
2829 | |||
2830 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
2831 | |||
2832 | hdspm_set_sgbuf(hdspm, sgbuf, HDSPM_pageAddressBufferOut, | ||
2833 | params_channels(params)); | ||
2834 | |||
2835 | for (i = 0; i < params_channels(params); ++i) | ||
2836 | snd_hdspm_enable_out(hdspm, i, 1); | ||
2837 | |||
2838 | hdspm->playback_buffer = | ||
2839 | (unsigned char *) substream->runtime->dma_area; | ||
2840 | } else { | ||
2841 | hdspm_set_sgbuf(hdspm, sgbuf, HDSPM_pageAddressBufferIn, | ||
2842 | params_channels(params)); | ||
2843 | |||
2844 | for (i = 0; i < params_channels(params); ++i) | ||
2845 | snd_hdspm_enable_in(hdspm, i, 1); | ||
2846 | |||
2847 | hdspm->capture_buffer = | ||
2848 | (unsigned char *) substream->runtime->dma_area; | ||
2849 | } | ||
2850 | return 0; | ||
2851 | } | ||
2852 | |||
2853 | static int snd_hdspm_hw_free(snd_pcm_substream_t * substream) | ||
2854 | { | ||
2855 | int i; | ||
2856 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2857 | |||
2858 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
2859 | |||
2860 | /* params_channels(params) should be enough, | ||
2861 | but to get sure in case of error */ | ||
2862 | for (i = 0; i < HDSPM_MAX_CHANNELS; ++i) | ||
2863 | snd_hdspm_enable_out(hdspm, i, 0); | ||
2864 | |||
2865 | hdspm->playback_buffer = NULL; | ||
2866 | } else { | ||
2867 | for (i = 0; i < HDSPM_MAX_CHANNELS; ++i) | ||
2868 | snd_hdspm_enable_in(hdspm, i, 0); | ||
2869 | |||
2870 | hdspm->capture_buffer = NULL; | ||
2871 | |||
2872 | } | ||
2873 | |||
2874 | snd_pcm_lib_free_pages(substream); | ||
2875 | |||
2876 | return 0; | ||
2877 | } | ||
2878 | |||
2879 | static int snd_hdspm_channel_info(snd_pcm_substream_t * substream, | ||
2880 | snd_pcm_channel_info_t * info) | ||
2881 | { | ||
2882 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2883 | int mapped_channel; | ||
2884 | |||
2885 | snd_assert(info->channel < HDSPM_MAX_CHANNELS, return -EINVAL); | ||
2886 | |||
2887 | if ((mapped_channel = hdspm->channel_map[info->channel]) < 0) | ||
2888 | return -EINVAL; | ||
2889 | |||
2890 | info->offset = mapped_channel * HDSPM_CHANNEL_BUFFER_BYTES; | ||
2891 | info->first = 0; | ||
2892 | info->step = 32; | ||
2893 | return 0; | ||
2894 | } | ||
2895 | |||
2896 | static int snd_hdspm_ioctl(snd_pcm_substream_t * substream, | ||
2897 | unsigned int cmd, void *arg) | ||
2898 | { | ||
2899 | switch (cmd) { | ||
2900 | case SNDRV_PCM_IOCTL1_RESET: | ||
2901 | { | ||
2902 | return snd_hdspm_reset(substream); | ||
2903 | } | ||
2904 | |||
2905 | case SNDRV_PCM_IOCTL1_CHANNEL_INFO: | ||
2906 | { | ||
2907 | snd_pcm_channel_info_t *info = arg; | ||
2908 | return snd_hdspm_channel_info(substream, info); | ||
2909 | } | ||
2910 | default: | ||
2911 | break; | ||
2912 | } | ||
2913 | |||
2914 | return snd_pcm_lib_ioctl(substream, cmd, arg); | ||
2915 | } | ||
2916 | |||
2917 | static int snd_hdspm_trigger(snd_pcm_substream_t * substream, int cmd) | ||
2918 | { | ||
2919 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
2920 | snd_pcm_substream_t *other; | ||
2921 | int running; | ||
2922 | |||
2923 | spin_lock(&hdspm->lock); | ||
2924 | running = hdspm->running; | ||
2925 | switch (cmd) { | ||
2926 | case SNDRV_PCM_TRIGGER_START: | ||
2927 | running |= 1 << substream->stream; | ||
2928 | break; | ||
2929 | case SNDRV_PCM_TRIGGER_STOP: | ||
2930 | running &= ~(1 << substream->stream); | ||
2931 | break; | ||
2932 | default: | ||
2933 | snd_BUG(); | ||
2934 | spin_unlock(&hdspm->lock); | ||
2935 | return -EINVAL; | ||
2936 | } | ||
2937 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
2938 | other = hdspm->capture_substream; | ||
2939 | else | ||
2940 | other = hdspm->playback_substream; | ||
2941 | |||
2942 | if (other) { | ||
2943 | struct list_head *pos; | ||
2944 | snd_pcm_substream_t *s; | ||
2945 | snd_pcm_group_for_each(pos, substream) { | ||
2946 | s = snd_pcm_group_substream_entry(pos); | ||
2947 | if (s == other) { | ||
2948 | snd_pcm_trigger_done(s, substream); | ||
2949 | if (cmd == SNDRV_PCM_TRIGGER_START) | ||
2950 | running |= 1 << s->stream; | ||
2951 | else | ||
2952 | running &= ~(1 << s->stream); | ||
2953 | goto _ok; | ||
2954 | } | ||
2955 | } | ||
2956 | if (cmd == SNDRV_PCM_TRIGGER_START) { | ||
2957 | if (!(running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) | ||
2958 | && substream->stream == | ||
2959 | SNDRV_PCM_STREAM_CAPTURE) | ||
2960 | hdspm_silence_playback(hdspm); | ||
2961 | } else { | ||
2962 | if (running && | ||
2963 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
2964 | hdspm_silence_playback(hdspm); | ||
2965 | } | ||
2966 | } else { | ||
2967 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
2968 | hdspm_silence_playback(hdspm); | ||
2969 | } | ||
2970 | _ok: | ||
2971 | snd_pcm_trigger_done(substream, substream); | ||
2972 | if (!hdspm->running && running) | ||
2973 | hdspm_start_audio(hdspm); | ||
2974 | else if (hdspm->running && !running) | ||
2975 | hdspm_stop_audio(hdspm); | ||
2976 | hdspm->running = running; | ||
2977 | spin_unlock(&hdspm->lock); | ||
2978 | |||
2979 | return 0; | ||
2980 | } | ||
2981 | |||
2982 | static int snd_hdspm_prepare(snd_pcm_substream_t * substream) | ||
2983 | { | ||
2984 | return 0; | ||
2985 | } | ||
2986 | |||
2987 | static unsigned int period_sizes[] = | ||
2988 | { 64, 128, 256, 512, 1024, 2048, 4096, 8192 }; | ||
2989 | |||
2990 | static snd_pcm_hardware_t snd_hdspm_playback_subinfo = { | ||
2991 | .info = (SNDRV_PCM_INFO_MMAP | | ||
2992 | SNDRV_PCM_INFO_MMAP_VALID | | ||
2993 | SNDRV_PCM_INFO_NONINTERLEAVED | | ||
2994 | SNDRV_PCM_INFO_SYNC_START | SNDRV_PCM_INFO_DOUBLE), | ||
2995 | .formats = SNDRV_PCM_FMTBIT_S32_LE, | ||
2996 | .rates = (SNDRV_PCM_RATE_32000 | | ||
2997 | SNDRV_PCM_RATE_44100 | | ||
2998 | SNDRV_PCM_RATE_48000 | | ||
2999 | SNDRV_PCM_RATE_64000 | | ||
3000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000), | ||
3001 | .rate_min = 32000, | ||
3002 | .rate_max = 96000, | ||
3003 | .channels_min = 1, | ||
3004 | .channels_max = HDSPM_MAX_CHANNELS, | ||
3005 | .buffer_bytes_max = | ||
3006 | HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS, | ||
3007 | .period_bytes_min = (64 * 4), | ||
3008 | .period_bytes_max = (8192 * 4) * HDSPM_MAX_CHANNELS, | ||
3009 | .periods_min = 2, | ||
3010 | .periods_max = 2, | ||
3011 | .fifo_size = 0 | ||
3012 | }; | ||
3013 | |||
3014 | static snd_pcm_hardware_t snd_hdspm_capture_subinfo = { | ||
3015 | .info = (SNDRV_PCM_INFO_MMAP | | ||
3016 | SNDRV_PCM_INFO_MMAP_VALID | | ||
3017 | SNDRV_PCM_INFO_NONINTERLEAVED | | ||
3018 | SNDRV_PCM_INFO_SYNC_START), | ||
3019 | .formats = SNDRV_PCM_FMTBIT_S32_LE, | ||
3020 | .rates = (SNDRV_PCM_RATE_32000 | | ||
3021 | SNDRV_PCM_RATE_44100 | | ||
3022 | SNDRV_PCM_RATE_48000 | | ||
3023 | SNDRV_PCM_RATE_64000 | | ||
3024 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000), | ||
3025 | .rate_min = 32000, | ||
3026 | .rate_max = 96000, | ||
3027 | .channels_min = 1, | ||
3028 | .channels_max = HDSPM_MAX_CHANNELS, | ||
3029 | .buffer_bytes_max = | ||
3030 | HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS, | ||
3031 | .period_bytes_min = (64 * 4), | ||
3032 | .period_bytes_max = (8192 * 4) * HDSPM_MAX_CHANNELS, | ||
3033 | .periods_min = 2, | ||
3034 | .periods_max = 2, | ||
3035 | .fifo_size = 0 | ||
3036 | }; | ||
3037 | |||
3038 | static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = { | ||
3039 | .count = ARRAY_SIZE(period_sizes), | ||
3040 | .list = period_sizes, | ||
3041 | .mask = 0 | ||
3042 | }; | ||
3043 | |||
3044 | |||
3045 | static int snd_hdspm_hw_rule_channels_rate(snd_pcm_hw_params_t * params, | ||
3046 | snd_pcm_hw_rule_t * rule) | ||
3047 | { | ||
3048 | hdspm_t *hdspm = rule->private; | ||
3049 | snd_interval_t *c = | ||
3050 | hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
3051 | snd_interval_t *r = | ||
3052 | hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); | ||
3053 | |||
3054 | if (r->min > 48000) { | ||
3055 | snd_interval_t t = { | ||
3056 | .min = 1, | ||
3057 | .max = hdspm->ds_channels, | ||
3058 | .integer = 1, | ||
3059 | }; | ||
3060 | return snd_interval_refine(c, &t); | ||
3061 | } else if (r->max < 64000) { | ||
3062 | snd_interval_t t = { | ||
3063 | .min = 1, | ||
3064 | .max = hdspm->ss_channels, | ||
3065 | .integer = 1, | ||
3066 | }; | ||
3067 | return snd_interval_refine(c, &t); | ||
3068 | } | ||
3069 | return 0; | ||
3070 | } | ||
3071 | |||
3072 | static int snd_hdspm_hw_rule_rate_channels(snd_pcm_hw_params_t * params, | ||
3073 | snd_pcm_hw_rule_t * rule) | ||
3074 | { | ||
3075 | hdspm_t *hdspm = rule->private; | ||
3076 | snd_interval_t *c = | ||
3077 | hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
3078 | snd_interval_t *r = | ||
3079 | hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); | ||
3080 | |||
3081 | if (c->min <= hdspm->ss_channels) { | ||
3082 | snd_interval_t t = { | ||
3083 | .min = 32000, | ||
3084 | .max = 48000, | ||
3085 | .integer = 1, | ||
3086 | }; | ||
3087 | return snd_interval_refine(r, &t); | ||
3088 | } else if (c->max > hdspm->ss_channels) { | ||
3089 | snd_interval_t t = { | ||
3090 | .min = 64000, | ||
3091 | .max = 96000, | ||
3092 | .integer = 1, | ||
3093 | }; | ||
3094 | |||
3095 | return snd_interval_refine(r, &t); | ||
3096 | } | ||
3097 | return 0; | ||
3098 | } | ||
3099 | |||
3100 | static int snd_hdspm_playback_open(snd_pcm_substream_t * substream) | ||
3101 | { | ||
3102 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
3103 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
3104 | |||
3105 | snd_printdd("Open device substream %d\n", substream->stream); | ||
3106 | |||
3107 | spin_lock_irq(&hdspm->lock); | ||
3108 | |||
3109 | snd_pcm_set_sync(substream); | ||
3110 | |||
3111 | runtime->hw = snd_hdspm_playback_subinfo; | ||
3112 | |||
3113 | if (hdspm->capture_substream == NULL) | ||
3114 | hdspm_stop_audio(hdspm); | ||
3115 | |||
3116 | hdspm->playback_pid = current->pid; | ||
3117 | hdspm->playback_substream = substream; | ||
3118 | |||
3119 | spin_unlock_irq(&hdspm->lock); | ||
3120 | |||
3121 | snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); | ||
3122 | |||
3123 | snd_pcm_hw_constraint_list(runtime, 0, | ||
3124 | SNDRV_PCM_HW_PARAM_PERIOD_SIZE, | ||
3125 | &hw_constraints_period_sizes); | ||
3126 | |||
3127 | snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, | ||
3128 | snd_hdspm_hw_rule_channels_rate, hdspm, | ||
3129 | SNDRV_PCM_HW_PARAM_RATE, -1); | ||
3130 | |||
3131 | snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | ||
3132 | snd_hdspm_hw_rule_rate_channels, hdspm, | ||
3133 | SNDRV_PCM_HW_PARAM_CHANNELS, -1); | ||
3134 | |||
3135 | return 0; | ||
3136 | } | ||
3137 | |||
3138 | static int snd_hdspm_playback_release(snd_pcm_substream_t * substream) | ||
3139 | { | ||
3140 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
3141 | |||
3142 | spin_lock_irq(&hdspm->lock); | ||
3143 | |||
3144 | hdspm->playback_pid = -1; | ||
3145 | hdspm->playback_substream = NULL; | ||
3146 | |||
3147 | spin_unlock_irq(&hdspm->lock); | ||
3148 | |||
3149 | return 0; | ||
3150 | } | ||
3151 | |||
3152 | |||
3153 | static int snd_hdspm_capture_open(snd_pcm_substream_t * substream) | ||
3154 | { | ||
3155 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
3156 | snd_pcm_runtime_t *runtime = substream->runtime; | ||
3157 | |||
3158 | spin_lock_irq(&hdspm->lock); | ||
3159 | snd_pcm_set_sync(substream); | ||
3160 | runtime->hw = snd_hdspm_capture_subinfo; | ||
3161 | |||
3162 | if (hdspm->playback_substream == NULL) | ||
3163 | hdspm_stop_audio(hdspm); | ||
3164 | |||
3165 | hdspm->capture_pid = current->pid; | ||
3166 | hdspm->capture_substream = substream; | ||
3167 | |||
3168 | spin_unlock_irq(&hdspm->lock); | ||
3169 | |||
3170 | snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); | ||
3171 | snd_pcm_hw_constraint_list(runtime, 0, | ||
3172 | SNDRV_PCM_HW_PARAM_PERIOD_SIZE, | ||
3173 | &hw_constraints_period_sizes); | ||
3174 | |||
3175 | snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, | ||
3176 | snd_hdspm_hw_rule_channels_rate, hdspm, | ||
3177 | SNDRV_PCM_HW_PARAM_RATE, -1); | ||
3178 | |||
3179 | snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | ||
3180 | snd_hdspm_hw_rule_rate_channels, hdspm, | ||
3181 | SNDRV_PCM_HW_PARAM_CHANNELS, -1); | ||
3182 | return 0; | ||
3183 | } | ||
3184 | |||
3185 | static int snd_hdspm_capture_release(snd_pcm_substream_t * substream) | ||
3186 | { | ||
3187 | hdspm_t *hdspm = snd_pcm_substream_chip(substream); | ||
3188 | |||
3189 | spin_lock_irq(&hdspm->lock); | ||
3190 | |||
3191 | hdspm->capture_pid = -1; | ||
3192 | hdspm->capture_substream = NULL; | ||
3193 | |||
3194 | spin_unlock_irq(&hdspm->lock); | ||
3195 | return 0; | ||
3196 | } | ||
3197 | |||
3198 | static int snd_hdspm_hwdep_dummy_op(snd_hwdep_t * hw, struct file *file) | ||
3199 | { | ||
3200 | /* we have nothing to initialize but the call is required */ | ||
3201 | return 0; | ||
3202 | } | ||
3203 | |||
3204 | |||
3205 | static int snd_hdspm_hwdep_ioctl(snd_hwdep_t * hw, struct file *file, | ||
3206 | unsigned int cmd, unsigned long arg) | ||
3207 | { | ||
3208 | hdspm_t *hdspm = (hdspm_t *) hw->private_data; | ||
3209 | struct sndrv_hdspm_mixer_ioctl mixer; | ||
3210 | hdspm_config_info_t info; | ||
3211 | hdspm_version_t hdspm_version; | ||
3212 | struct sndrv_hdspm_peak_rms_ioctl rms; | ||
3213 | |||
3214 | switch (cmd) { | ||
3215 | |||
3216 | |||
3217 | case SNDRV_HDSPM_IOCTL_GET_PEAK_RMS: | ||
3218 | if (copy_from_user(&rms, (void __user *)arg, sizeof(rms))) | ||
3219 | return -EFAULT; | ||
3220 | /* maybe there is a chance to memorymap in future so dont touch just copy */ | ||
3221 | if(copy_to_user_fromio((void __user *)rms.peak, | ||
3222 | hdspm->iobase+HDSPM_MADI_peakrmsbase, | ||
3223 | sizeof(hdspm_peak_rms_t)) != 0 ) | ||
3224 | return -EFAULT; | ||
3225 | |||
3226 | break; | ||
3227 | |||
3228 | |||
3229 | case SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO: | ||
3230 | |||
3231 | spin_lock_irq(&hdspm->lock); | ||
3232 | info.pref_sync_ref = | ||
3233 | (unsigned char) hdspm_pref_sync_ref(hdspm); | ||
3234 | info.wordclock_sync_check = | ||
3235 | (unsigned char) hdspm_wc_sync_check(hdspm); | ||
3236 | |||
3237 | info.system_sample_rate = hdspm->system_sample_rate; | ||
3238 | info.autosync_sample_rate = | ||
3239 | hdspm_external_sample_rate(hdspm); | ||
3240 | info.system_clock_mode = | ||
3241 | (unsigned char) hdspm_system_clock_mode(hdspm); | ||
3242 | info.clock_source = | ||
3243 | (unsigned char) hdspm_clock_source(hdspm); | ||
3244 | info.autosync_ref = | ||
3245 | (unsigned char) hdspm_autosync_ref(hdspm); | ||
3246 | info.line_out = (unsigned char) hdspm_line_out(hdspm); | ||
3247 | info.passthru = 0; | ||
3248 | spin_unlock_irq(&hdspm->lock); | ||
3249 | if (copy_to_user((void __user *) arg, &info, sizeof(info))) | ||
3250 | return -EFAULT; | ||
3251 | break; | ||
3252 | |||
3253 | case SNDRV_HDSPM_IOCTL_GET_VERSION: | ||
3254 | hdspm_version.firmware_rev = hdspm->firmware_rev; | ||
3255 | if (copy_to_user((void __user *) arg, &hdspm_version, | ||
3256 | sizeof(hdspm_version))) | ||
3257 | return -EFAULT; | ||
3258 | break; | ||
3259 | |||
3260 | case SNDRV_HDSPM_IOCTL_GET_MIXER: | ||
3261 | if (copy_from_user(&mixer, (void __user *)arg, sizeof(mixer))) | ||
3262 | return -EFAULT; | ||
3263 | if (copy_to_user | ||
3264 | ((void __user *)mixer.mixer, hdspm->mixer, sizeof(hdspm_mixer_t))) | ||
3265 | return -EFAULT; | ||
3266 | break; | ||
3267 | |||
3268 | default: | ||
3269 | return -EINVAL; | ||
3270 | } | ||
3271 | return 0; | ||
3272 | } | ||
3273 | |||
3274 | static snd_pcm_ops_t snd_hdspm_playback_ops = { | ||
3275 | .open = snd_hdspm_playback_open, | ||
3276 | .close = snd_hdspm_playback_release, | ||
3277 | .ioctl = snd_hdspm_ioctl, | ||
3278 | .hw_params = snd_hdspm_hw_params, | ||
3279 | .hw_free = snd_hdspm_hw_free, | ||
3280 | .prepare = snd_hdspm_prepare, | ||
3281 | .trigger = snd_hdspm_trigger, | ||
3282 | .pointer = snd_hdspm_hw_pointer, | ||
3283 | .copy = snd_hdspm_playback_copy, | ||
3284 | .silence = snd_hdspm_hw_silence, | ||
3285 | .page = snd_pcm_sgbuf_ops_page, | ||
3286 | }; | ||
3287 | |||
3288 | static snd_pcm_ops_t snd_hdspm_capture_ops = { | ||
3289 | .open = snd_hdspm_capture_open, | ||
3290 | .close = snd_hdspm_capture_release, | ||
3291 | .ioctl = snd_hdspm_ioctl, | ||
3292 | .hw_params = snd_hdspm_hw_params, | ||
3293 | .hw_free = snd_hdspm_hw_free, | ||
3294 | .prepare = snd_hdspm_prepare, | ||
3295 | .trigger = snd_hdspm_trigger, | ||
3296 | .pointer = snd_hdspm_hw_pointer, | ||
3297 | .copy = snd_hdspm_capture_copy, | ||
3298 | .page = snd_pcm_sgbuf_ops_page, | ||
3299 | }; | ||
3300 | |||
3301 | static int __devinit snd_hdspm_create_hwdep(snd_card_t * card, | ||
3302 | hdspm_t * hdspm) | ||
3303 | { | ||
3304 | snd_hwdep_t *hw; | ||
3305 | int err; | ||
3306 | |||
3307 | if ((err = snd_hwdep_new(card, "HDSPM hwdep", 0, &hw)) < 0) | ||
3308 | return err; | ||
3309 | |||
3310 | hdspm->hwdep = hw; | ||
3311 | hw->private_data = hdspm; | ||
3312 | strcpy(hw->name, "HDSPM hwdep interface"); | ||
3313 | |||
3314 | hw->ops.open = snd_hdspm_hwdep_dummy_op; | ||
3315 | hw->ops.ioctl = snd_hdspm_hwdep_ioctl; | ||
3316 | hw->ops.release = snd_hdspm_hwdep_dummy_op; | ||
3317 | |||
3318 | return 0; | ||
3319 | } | ||
3320 | |||
3321 | |||
3322 | /*------------------------------------------------------------ | ||
3323 | memory interface | ||
3324 | ------------------------------------------------------------*/ | ||
3325 | static int __devinit snd_hdspm_preallocate_memory(hdspm_t * hdspm) | ||
3326 | { | ||
3327 | int err; | ||
3328 | snd_pcm_t *pcm; | ||
3329 | size_t wanted; | ||
3330 | |||
3331 | pcm = hdspm->pcm; | ||
3332 | |||
3333 | wanted = HDSPM_DMA_AREA_BYTES + 4096; /* dont know why, but it works */ | ||
3334 | |||
3335 | if ((err = | ||
3336 | snd_pcm_lib_preallocate_pages_for_all(pcm, | ||
3337 | SNDRV_DMA_TYPE_DEV_SG, | ||
3338 | snd_dma_pci_data(hdspm->pci), | ||
3339 | wanted, | ||
3340 | wanted)) < 0) { | ||
3341 | snd_printdd("Could not preallocate %d Bytes\n", wanted); | ||
3342 | |||
3343 | return err; | ||
3344 | } else | ||
3345 | snd_printdd(" Preallocated %d Bytes\n", wanted); | ||
3346 | |||
3347 | return 0; | ||
3348 | } | ||
3349 | |||
3350 | static int snd_hdspm_memory_free(hdspm_t * hdspm) | ||
3351 | { | ||
3352 | snd_printdd("memory_free_for_all %p\n", hdspm->pcm); | ||
3353 | |||
3354 | snd_pcm_lib_preallocate_free_for_all(hdspm->pcm); | ||
3355 | return 0; | ||
3356 | } | ||
3357 | |||
3358 | |||
3359 | static void hdspm_set_sgbuf(hdspm_t * hdspm, struct snd_sg_buf *sgbuf, | ||
3360 | unsigned int reg, int channels) | ||
3361 | { | ||
3362 | int i; | ||
3363 | for (i = 0; i < (channels * 16); i++) | ||
3364 | hdspm_write(hdspm, reg + 4 * i, | ||
3365 | snd_pcm_sgbuf_get_addr(sgbuf, | ||
3366 | (size_t) 4096 * i)); | ||
3367 | } | ||
3368 | |||
3369 | /* ------------- ALSA Devices ---------------------------- */ | ||
3370 | static int __devinit snd_hdspm_create_pcm(snd_card_t * card, | ||
3371 | hdspm_t * hdspm) | ||
3372 | { | ||
3373 | snd_pcm_t *pcm; | ||
3374 | int err; | ||
3375 | |||
3376 | if ((err = snd_pcm_new(card, hdspm->card_name, 0, 1, 1, &pcm)) < 0) | ||
3377 | return err; | ||
3378 | |||
3379 | hdspm->pcm = pcm; | ||
3380 | pcm->private_data = hdspm; | ||
3381 | strcpy(pcm->name, hdspm->card_name); | ||
3382 | |||
3383 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, | ||
3384 | &snd_hdspm_playback_ops); | ||
3385 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | ||
3386 | &snd_hdspm_capture_ops); | ||
3387 | |||
3388 | pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; | ||
3389 | |||
3390 | if ((err = snd_hdspm_preallocate_memory(hdspm)) < 0) | ||
3391 | return err; | ||
3392 | |||
3393 | return 0; | ||
3394 | } | ||
3395 | |||
3396 | static inline void snd_hdspm_initialize_midi_flush(hdspm_t * hdspm) | ||
3397 | { | ||
3398 | snd_hdspm_flush_midi_input(hdspm, 0); | ||
3399 | snd_hdspm_flush_midi_input(hdspm, 1); | ||
3400 | } | ||
3401 | |||
3402 | static int __devinit snd_hdspm_create_alsa_devices(snd_card_t * card, | ||
3403 | hdspm_t * hdspm) | ||
3404 | { | ||
3405 | int err; | ||
3406 | |||
3407 | snd_printdd("Create card...\n"); | ||
3408 | if ((err = snd_hdspm_create_pcm(card, hdspm)) < 0) | ||
3409 | return err; | ||
3410 | |||
3411 | if ((err = snd_hdspm_create_midi(card, hdspm, 0)) < 0) | ||
3412 | return err; | ||
3413 | |||
3414 | if ((err = snd_hdspm_create_midi(card, hdspm, 1)) < 0) | ||
3415 | return err; | ||
3416 | |||
3417 | if ((err = snd_hdspm_create_controls(card, hdspm)) < 0) | ||
3418 | return err; | ||
3419 | |||
3420 | if ((err = snd_hdspm_create_hwdep(card, hdspm)) < 0) | ||
3421 | return err; | ||
3422 | |||
3423 | snd_printdd("proc init...\n"); | ||
3424 | snd_hdspm_proc_init(hdspm); | ||
3425 | |||
3426 | hdspm->system_sample_rate = -1; | ||
3427 | hdspm->last_external_sample_rate = -1; | ||
3428 | hdspm->last_internal_sample_rate = -1; | ||
3429 | hdspm->playback_pid = -1; | ||
3430 | hdspm->capture_pid = -1; | ||
3431 | hdspm->capture_substream = NULL; | ||
3432 | hdspm->playback_substream = NULL; | ||
3433 | |||
3434 | snd_printdd("Set defaults...\n"); | ||
3435 | if ((err = snd_hdspm_set_defaults(hdspm)) < 0) | ||
3436 | return err; | ||
3437 | |||
3438 | snd_printdd("Update mixer controls...\n"); | ||
3439 | hdspm_update_simple_mixer_controls(hdspm); | ||
3440 | |||
3441 | snd_printdd("Initializeing complete ???\n"); | ||
3442 | |||
3443 | if ((err = snd_card_register(card)) < 0) { | ||
3444 | snd_printk(KERN_ERR "HDSPM: error registering card\n"); | ||
3445 | return err; | ||
3446 | } | ||
3447 | |||
3448 | snd_printdd("... yes now\n"); | ||
3449 | |||
3450 | return 0; | ||
3451 | } | ||
3452 | |||
3453 | static int __devinit snd_hdspm_create(snd_card_t * card, hdspm_t * hdspm, | ||
3454 | int precise_ptr, int enable_monitor) | ||
3455 | { | ||
3456 | struct pci_dev *pci = hdspm->pci; | ||
3457 | int err; | ||
3458 | int i; | ||
3459 | |||
3460 | unsigned long io_extent; | ||
3461 | |||
3462 | hdspm->irq = -1; | ||
3463 | hdspm->irq_count = 0; | ||
3464 | |||
3465 | hdspm->midi[0].rmidi = NULL; | ||
3466 | hdspm->midi[1].rmidi = NULL; | ||
3467 | hdspm->midi[0].input = NULL; | ||
3468 | hdspm->midi[1].input = NULL; | ||
3469 | hdspm->midi[0].output = NULL; | ||
3470 | hdspm->midi[1].output = NULL; | ||
3471 | spin_lock_init(&hdspm->midi[0].lock); | ||
3472 | spin_lock_init(&hdspm->midi[1].lock); | ||
3473 | hdspm->iobase = NULL; | ||
3474 | hdspm->control_register = 0; | ||
3475 | hdspm->control2_register = 0; | ||
3476 | |||
3477 | hdspm->playback_buffer = NULL; | ||
3478 | hdspm->capture_buffer = NULL; | ||
3479 | |||
3480 | for (i = 0; i < HDSPM_MAX_CHANNELS; ++i) | ||
3481 | hdspm->playback_mixer_ctls[i] = NULL; | ||
3482 | hdspm->mixer = NULL; | ||
3483 | |||
3484 | hdspm->card = card; | ||
3485 | |||
3486 | spin_lock_init(&hdspm->lock); | ||
3487 | |||
3488 | tasklet_init(&hdspm->midi_tasklet, | ||
3489 | hdspm_midi_tasklet, (unsigned long) hdspm); | ||
3490 | |||
3491 | pci_read_config_word(hdspm->pci, | ||
3492 | PCI_CLASS_REVISION, &hdspm->firmware_rev); | ||
3493 | |||
3494 | strcpy(card->driver, "HDSPM"); | ||
3495 | strcpy(card->mixername, "Xilinx FPGA"); | ||
3496 | hdspm->card_name = "RME HDSPM MADI"; | ||
3497 | |||
3498 | if ((err = pci_enable_device(pci)) < 0) | ||
3499 | return err; | ||
3500 | |||
3501 | pci_set_master(hdspm->pci); | ||
3502 | |||
3503 | if ((err = pci_request_regions(pci, "hdspm")) < 0) | ||
3504 | return err; | ||
3505 | |||
3506 | hdspm->port = pci_resource_start(pci, 0); | ||
3507 | io_extent = pci_resource_len(pci, 0); | ||
3508 | |||
3509 | snd_printdd("grabbed memory region 0x%lx-0x%lx\n", | ||
3510 | hdspm->port, hdspm->port + io_extent - 1); | ||
3511 | |||
3512 | |||
3513 | if ((hdspm->iobase = ioremap_nocache(hdspm->port, io_extent)) == NULL) { | ||
3514 | snd_printk(KERN_ERR "HDSPM: unable to remap region 0x%lx-0x%lx\n", | ||
3515 | hdspm->port, hdspm->port + io_extent - 1); | ||
3516 | return -EBUSY; | ||
3517 | } | ||
3518 | snd_printdd("remapped region (0x%lx) 0x%lx-0x%lx\n", | ||
3519 | (unsigned long)hdspm->iobase, hdspm->port, | ||
3520 | hdspm->port + io_extent - 1); | ||
3521 | |||
3522 | if (request_irq(pci->irq, snd_hdspm_interrupt, | ||
3523 | SA_INTERRUPT | SA_SHIRQ, "hdspm", | ||
3524 | (void *) hdspm)) { | ||
3525 | snd_printk(KERN_ERR "HDSPM: unable to use IRQ %d\n", pci->irq); | ||
3526 | return -EBUSY; | ||
3527 | } | ||
3528 | |||
3529 | snd_printdd("use IRQ %d\n", pci->irq); | ||
3530 | |||
3531 | hdspm->irq = pci->irq; | ||
3532 | hdspm->precise_ptr = precise_ptr; | ||
3533 | |||
3534 | hdspm->monitor_outs = enable_monitor; | ||
3535 | |||
3536 | snd_printdd("kmalloc Mixer memory of %d Bytes\n", | ||
3537 | sizeof(hdspm_mixer_t)); | ||
3538 | if ((hdspm->mixer = | ||
3539 | (hdspm_mixer_t *) kmalloc(sizeof(hdspm_mixer_t), GFP_KERNEL)) | ||
3540 | == NULL) { | ||
3541 | snd_printk(KERN_ERR "HDSPM: unable to kmalloc Mixer memory of %d Bytes\n", | ||
3542 | (int)sizeof(hdspm_mixer_t)); | ||
3543 | return err; | ||
3544 | } | ||
3545 | |||
3546 | hdspm->ss_channels = MADI_SS_CHANNELS; | ||
3547 | hdspm->ds_channels = MADI_DS_CHANNELS; | ||
3548 | hdspm->qs_channels = MADI_QS_CHANNELS; | ||
3549 | |||
3550 | snd_printdd("create alsa devices.\n"); | ||
3551 | if ((err = snd_hdspm_create_alsa_devices(card, hdspm)) < 0) | ||
3552 | return err; | ||
3553 | |||
3554 | snd_hdspm_initialize_midi_flush(hdspm); | ||
3555 | |||
3556 | return 0; | ||
3557 | } | ||
3558 | |||
3559 | static int snd_hdspm_free(hdspm_t * hdspm) | ||
3560 | { | ||
3561 | |||
3562 | if (hdspm->port) { | ||
3563 | |||
3564 | /* stop th audio, and cancel all interrupts */ | ||
3565 | hdspm->control_register &= | ||
3566 | ~(HDSPM_Start | HDSPM_AudioInterruptEnable | ||
3567 | | HDSPM_Midi0InterruptEnable | | ||
3568 | HDSPM_Midi1InterruptEnable); | ||
3569 | hdspm_write(hdspm, HDSPM_controlRegister, | ||
3570 | hdspm->control_register); | ||
3571 | } | ||
3572 | |||
3573 | if (hdspm->irq >= 0) | ||
3574 | free_irq(hdspm->irq, (void *) hdspm); | ||
3575 | |||
3576 | |||
3577 | if (hdspm->mixer) | ||
3578 | kfree(hdspm->mixer); | ||
3579 | |||
3580 | if (hdspm->iobase) | ||
3581 | iounmap(hdspm->iobase); | ||
3582 | |||
3583 | snd_hdspm_memory_free(hdspm); | ||
3584 | |||
3585 | if (hdspm->port) | ||
3586 | pci_release_regions(hdspm->pci); | ||
3587 | |||
3588 | pci_disable_device(hdspm->pci); | ||
3589 | return 0; | ||
3590 | } | ||
3591 | |||
3592 | static void snd_hdspm_card_free(snd_card_t * card) | ||
3593 | { | ||
3594 | hdspm_t *hdspm = (hdspm_t *) card->private_data; | ||
3595 | |||
3596 | if (hdspm) | ||
3597 | snd_hdspm_free(hdspm); | ||
3598 | } | ||
3599 | |||
3600 | static int __devinit snd_hdspm_probe(struct pci_dev *pci, | ||
3601 | const struct pci_device_id *pci_id) | ||
3602 | { | ||
3603 | static int dev; | ||
3604 | hdspm_t *hdspm; | ||
3605 | snd_card_t *card; | ||
3606 | int err; | ||
3607 | |||
3608 | if (dev >= SNDRV_CARDS) | ||
3609 | return -ENODEV; | ||
3610 | if (!enable[dev]) { | ||
3611 | dev++; | ||
3612 | return -ENOENT; | ||
3613 | } | ||
3614 | |||
3615 | if (!(card = snd_card_new(index[dev], id[dev], | ||
3616 | THIS_MODULE, sizeof(hdspm_t)))) | ||
3617 | return -ENOMEM; | ||
3618 | |||
3619 | hdspm = (hdspm_t *) card->private_data; | ||
3620 | card->private_free = snd_hdspm_card_free; | ||
3621 | hdspm->dev = dev; | ||
3622 | hdspm->pci = pci; | ||
3623 | |||
3624 | if ((err = | ||
3625 | snd_hdspm_create(card, hdspm, precise_ptr[dev], | ||
3626 | enable_monitor[dev])) < 0) { | ||
3627 | snd_card_free(card); | ||
3628 | return err; | ||
3629 | } | ||
3630 | |||
3631 | strcpy(card->shortname, "HDSPM MADI"); | ||
3632 | sprintf(card->longname, "%s at 0x%lx, irq %d", hdspm->card_name, | ||
3633 | hdspm->port, hdspm->irq); | ||
3634 | |||
3635 | if ((err = snd_card_register(card)) < 0) { | ||
3636 | snd_card_free(card); | ||
3637 | return err; | ||
3638 | } | ||
3639 | |||
3640 | pci_set_drvdata(pci, card); | ||
3641 | |||
3642 | dev++; | ||
3643 | return 0; | ||
3644 | } | ||
3645 | |||
3646 | static void __devexit snd_hdspm_remove(struct pci_dev *pci) | ||
3647 | { | ||
3648 | snd_card_free(pci_get_drvdata(pci)); | ||
3649 | pci_set_drvdata(pci, NULL); | ||
3650 | } | ||
3651 | |||
3652 | static struct pci_driver driver = { | ||
3653 | .name = "RME Hammerfall DSP MADI", | ||
3654 | .id_table = snd_hdspm_ids, | ||
3655 | .probe = snd_hdspm_probe, | ||
3656 | .remove = __devexit_p(snd_hdspm_remove), | ||
3657 | }; | ||
3658 | |||
3659 | |||
3660 | static int __init alsa_card_hdspm_init(void) | ||
3661 | { | ||
3662 | return pci_register_driver(&driver); | ||
3663 | } | ||
3664 | |||
3665 | static void __exit alsa_card_hdspm_exit(void) | ||
3666 | { | ||
3667 | pci_unregister_driver(&driver); | ||
3668 | } | ||
3669 | |||
3670 | module_init(alsa_card_hdspm_init) | ||
3671 | module_exit(alsa_card_hdspm_exit) | ||
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 69cd81eaa111..f3037402d58f 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c | |||
@@ -303,18 +303,22 @@ static int snd_hammerfall_get_buffer(struct pci_dev *pci, struct snd_dma_buffer | |||
303 | { | 303 | { |
304 | dmab->dev.type = SNDRV_DMA_TYPE_DEV; | 304 | dmab->dev.type = SNDRV_DMA_TYPE_DEV; |
305 | dmab->dev.dev = snd_dma_pci_data(pci); | 305 | dmab->dev.dev = snd_dma_pci_data(pci); |
306 | if (! snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) { | 306 | if (snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) { |
307 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), | 307 | if (dmab->bytes >= size) |
308 | size, dmab) < 0) | 308 | return 0; |
309 | return -ENOMEM; | ||
310 | } | 309 | } |
310 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), | ||
311 | size, dmab) < 0) | ||
312 | return -ENOMEM; | ||
311 | return 0; | 313 | return 0; |
312 | } | 314 | } |
313 | 315 | ||
314 | static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci) | 316 | static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci) |
315 | { | 317 | { |
316 | if (dmab->area) | 318 | if (dmab->area) { |
319 | dmab->dev.dev = NULL; /* make it anonymous */ | ||
317 | snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci)); | 320 | snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci)); |
321 | } | ||
318 | } | 322 | } |
319 | 323 | ||
320 | 324 | ||
@@ -2664,7 +2668,7 @@ static struct pci_driver driver = { | |||
2664 | 2668 | ||
2665 | static int __init alsa_card_hammerfall_init(void) | 2669 | static int __init alsa_card_hammerfall_init(void) |
2666 | { | 2670 | { |
2667 | return pci_module_init(&driver); | 2671 | return pci_register_driver(&driver); |
2668 | } | 2672 | } |
2669 | 2673 | ||
2670 | static void __exit alsa_card_hammerfall_exit(void) | 2674 | static void __exit alsa_card_hammerfall_exit(void) |
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index cfd2c5fd6ddf..60ecb2bdb65e 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c | |||
@@ -1522,7 +1522,7 @@ static struct pci_driver driver = { | |||
1522 | 1522 | ||
1523 | static int __init alsa_card_sonicvibes_init(void) | 1523 | static int __init alsa_card_sonicvibes_init(void) |
1524 | { | 1524 | { |
1525 | return pci_module_init(&driver); | 1525 | return pci_register_driver(&driver); |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | static void __exit alsa_card_sonicvibes_exit(void) | 1528 | static void __exit alsa_card_sonicvibes_exit(void) |
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index ad58e08d66e2..940d531575c0 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c | |||
@@ -143,7 +143,8 @@ static int __devinit snd_trident_probe(struct pci_dev *pci, | |||
143 | return err; | 143 | return err; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, | 146 | if (trident->device != TRIDENT_DEVICE_ID_SI7018 && |
147 | (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, | ||
147 | trident->midi_port, 1, | 148 | trident->midi_port, 1, |
148 | trident->irq, 0, &trident->rmidi)) < 0) { | 149 | trident->irq, 0, &trident->rmidi)) < 0) { |
149 | snd_card_free(card); | 150 | snd_card_free(card); |
@@ -184,7 +185,7 @@ static struct pci_driver driver = { | |||
184 | 185 | ||
185 | static int __init alsa_card_trident_init(void) | 186 | static int __init alsa_card_trident_init(void) |
186 | { | 187 | { |
187 | return pci_module_init(&driver); | 188 | return pci_register_driver(&driver); |
188 | } | 189 | } |
189 | 190 | ||
190 | static void __exit alsa_card_trident_exit(void) | 191 | static void __exit alsa_card_trident_exit(void) |
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 9b4d74d49f98..42c48f0ce8e8 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c | |||
@@ -101,7 +101,7 @@ MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); | |||
101 | module_param_array(ac97_quirk, charp, NULL, 0444); | 101 | module_param_array(ac97_quirk, charp, NULL, 0444); |
102 | MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); | 102 | MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); |
103 | module_param_array(dxs_support, int, NULL, 0444); | 103 | module_param_array(dxs_support, int, NULL, 0444); |
104 | MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA)"); | 104 | MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); |
105 | 105 | ||
106 | 106 | ||
107 | /* pci ids */ | 107 | /* pci ids */ |
@@ -302,6 +302,7 @@ DEFINE_VIA_REGSET(CAPTURE_8233, 0x60); | |||
302 | #define VIA_DXS_DISABLE 2 | 302 | #define VIA_DXS_DISABLE 2 |
303 | #define VIA_DXS_48K 3 | 303 | #define VIA_DXS_48K 3 |
304 | #define VIA_DXS_NO_VRA 4 | 304 | #define VIA_DXS_NO_VRA 4 |
305 | #define VIA_DXS_SRC 5 | ||
305 | 306 | ||
306 | 307 | ||
307 | /* | 308 | /* |
@@ -380,6 +381,7 @@ struct _snd_via82xx { | |||
380 | struct via_rate_lock rates[2]; /* playback and capture */ | 381 | struct via_rate_lock rates[2]; /* playback and capture */ |
381 | unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ | 382 | unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ |
382 | unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ | 383 | unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ |
384 | unsigned int dxs_src: 1; /* use full SRC capabilities of DXS */ | ||
383 | unsigned int spdif_on: 1; /* only spdif rates work to external DACs */ | 385 | unsigned int spdif_on: 1; /* only spdif rates work to external DACs */ |
384 | 386 | ||
385 | snd_pcm_t *pcms[2]; | 387 | snd_pcm_t *pcms[2]; |
@@ -489,10 +491,8 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, | |||
489 | snd_dma_free_pages(&dev->table); | 491 | snd_dma_free_pages(&dev->table); |
490 | dev->table.area = NULL; | 492 | dev->table.area = NULL; |
491 | } | 493 | } |
492 | if (dev->idx_table) { | 494 | kfree(dev->idx_table); |
493 | kfree(dev->idx_table); | 495 | dev->idx_table = NULL; |
494 | dev->idx_table = NULL; | ||
495 | } | ||
496 | return 0; | 496 | return 0; |
497 | } | 497 | } |
498 | 498 | ||
@@ -924,15 +924,17 @@ static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream) | |||
924 | via82xx_t *chip = snd_pcm_substream_chip(substream); | 924 | via82xx_t *chip = snd_pcm_substream_chip(substream); |
925 | viadev_t *viadev = (viadev_t *)substream->runtime->private_data; | 925 | viadev_t *viadev = (viadev_t *)substream->runtime->private_data; |
926 | snd_pcm_runtime_t *runtime = substream->runtime; | 926 | snd_pcm_runtime_t *runtime = substream->runtime; |
927 | int ac97_rate = chip->dxs_src ? 48000 : runtime->rate; | ||
927 | int rate_changed; | 928 | int rate_changed; |
928 | u32 rbits; | 929 | u32 rbits; |
929 | 930 | ||
930 | if ((rate_changed = via_lock_rate(&chip->rates[0], runtime->rate)) < 0) | 931 | if ((rate_changed = via_lock_rate(&chip->rates[0], ac97_rate)) < 0) |
931 | return rate_changed; | 932 | return rate_changed; |
932 | if (rate_changed) { | 933 | if (rate_changed) { |
933 | snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, | 934 | snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, |
934 | chip->no_vra ? 48000 : runtime->rate); | 935 | chip->no_vra ? 48000 : runtime->rate); |
935 | snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); | 936 | snd_ac97_set_rate(chip->ac97, AC97_SPDIF, |
937 | chip->no_vra ? 48000 : runtime->rate); | ||
936 | } | 938 | } |
937 | if (runtime->rate == 48000) | 939 | if (runtime->rate == 48000) |
938 | rbits = 0xfffff; | 940 | rbits = 0xfffff; |
@@ -1074,6 +1076,12 @@ static int snd_via82xx_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm_subst | |||
1074 | /* fixed DXS playback rate */ | 1076 | /* fixed DXS playback rate */ |
1075 | runtime->hw.rates = SNDRV_PCM_RATE_48000; | 1077 | runtime->hw.rates = SNDRV_PCM_RATE_48000; |
1076 | runtime->hw.rate_min = runtime->hw.rate_max = 48000; | 1078 | runtime->hw.rate_min = runtime->hw.rate_max = 48000; |
1079 | } else if (chip->dxs_src && viadev->reg_offset < 0x40) { | ||
1080 | /* use full SRC capabilities of DXS */ | ||
1081 | runtime->hw.rates = (SNDRV_PCM_RATE_CONTINUOUS | | ||
1082 | SNDRV_PCM_RATE_8000_48000); | ||
1083 | runtime->hw.rate_min = 8000; | ||
1084 | runtime->hw.rate_max = 48000; | ||
1077 | } else if (! ratep->rate) { | 1085 | } else if (! ratep->rate) { |
1078 | int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC; | 1086 | int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC; |
1079 | runtime->hw.rates = chip->ac97->rates[idx]; | 1087 | runtime->hw.rates = chip->ac97->rates[idx]; |
@@ -1550,51 +1558,51 @@ static void snd_via82xx_mixer_free_ac97(ac97_t *ac97) | |||
1550 | 1558 | ||
1551 | static struct ac97_quirk ac97_quirks[] = { | 1559 | static struct ac97_quirk ac97_quirks[] = { |
1552 | { | 1560 | { |
1553 | .vendor = 0x1106, | 1561 | .subvendor = 0x1106, |
1554 | .device = 0x4161, | 1562 | .subdevice = 0x4161, |
1555 | .codec_id = 0x56494161, /* VT1612A */ | 1563 | .codec_id = 0x56494161, /* VT1612A */ |
1556 | .name = "Soltek SL-75DRV5", | 1564 | .name = "Soltek SL-75DRV5", |
1557 | .type = AC97_TUNE_NONE | 1565 | .type = AC97_TUNE_NONE |
1558 | }, | 1566 | }, |
1559 | { /* FIXME: which codec? */ | 1567 | { /* FIXME: which codec? */ |
1560 | .vendor = 0x1106, | 1568 | .subvendor = 0x1106, |
1561 | .device = 0x4161, | 1569 | .subdevice = 0x4161, |
1562 | .name = "ASRock K7VT2", | 1570 | .name = "ASRock K7VT2", |
1563 | .type = AC97_TUNE_HP_ONLY | 1571 | .type = AC97_TUNE_HP_ONLY |
1564 | }, | 1572 | }, |
1565 | { | 1573 | { |
1566 | .vendor = 0x1019, | 1574 | .subvendor = 0x1019, |
1567 | .device = 0x0a81, | 1575 | .subdevice = 0x0a81, |
1568 | .name = "ECS K7VTA3", | 1576 | .name = "ECS K7VTA3", |
1569 | .type = AC97_TUNE_HP_ONLY | 1577 | .type = AC97_TUNE_HP_ONLY |
1570 | }, | 1578 | }, |
1571 | { | 1579 | { |
1572 | .vendor = 0x1019, | 1580 | .subvendor = 0x1019, |
1573 | .device = 0x0a85, | 1581 | .subdevice = 0x0a85, |
1574 | .name = "ECS L7VMM2", | 1582 | .name = "ECS L7VMM2", |
1575 | .type = AC97_TUNE_HP_ONLY | 1583 | .type = AC97_TUNE_HP_ONLY |
1576 | }, | 1584 | }, |
1577 | { | 1585 | { |
1578 | .vendor = 0x1849, | 1586 | .subvendor = 0x1849, |
1579 | .device = 0x3059, | 1587 | .subdevice = 0x3059, |
1580 | .name = "ASRock K7VM2", | 1588 | .name = "ASRock K7VM2", |
1581 | .type = AC97_TUNE_HP_ONLY /* VT1616 */ | 1589 | .type = AC97_TUNE_HP_ONLY /* VT1616 */ |
1582 | }, | 1590 | }, |
1583 | { | 1591 | { |
1584 | .vendor = 0x14cd, | 1592 | .subvendor = 0x14cd, |
1585 | .device = 0x7002, | 1593 | .subdevice = 0x7002, |
1586 | .name = "Unknown", | 1594 | .name = "Unknown", |
1587 | .type = AC97_TUNE_ALC_JACK | 1595 | .type = AC97_TUNE_ALC_JACK |
1588 | }, | 1596 | }, |
1589 | { | 1597 | { |
1590 | .vendor = 0x1071, | 1598 | .subvendor = 0x1071, |
1591 | .device = 0x8590, | 1599 | .subdevice = 0x8590, |
1592 | .name = "Mitac Mobo", | 1600 | .name = "Mitac Mobo", |
1593 | .type = AC97_TUNE_ALC_JACK | 1601 | .type = AC97_TUNE_ALC_JACK |
1594 | }, | 1602 | }, |
1595 | { | 1603 | { |
1596 | .vendor = 0x161f, | 1604 | .subvendor = 0x161f, |
1597 | .device = 0x202b, | 1605 | .subdevice = 0x202b, |
1598 | .name = "Arima Notebook", | 1606 | .name = "Arima Notebook", |
1599 | .type = AC97_TUNE_HP_ONLY, | 1607 | .type = AC97_TUNE_HP_ONLY, |
1600 | }, | 1608 | }, |
@@ -2132,8 +2140,8 @@ static struct via823x_info via823x_cards[] __devinitdata = { | |||
2132 | * auto detection of DXS channel supports. | 2140 | * auto detection of DXS channel supports. |
2133 | */ | 2141 | */ |
2134 | struct dxs_whitelist { | 2142 | struct dxs_whitelist { |
2135 | unsigned short vendor; | 2143 | unsigned short subvendor; |
2136 | unsigned short device; | 2144 | unsigned short subdevice; |
2137 | unsigned short mask; | 2145 | unsigned short mask; |
2138 | short action; /* new dxs_support value */ | 2146 | short action; /* new dxs_support value */ |
2139 | }; | 2147 | }; |
@@ -2141,38 +2149,44 @@ struct dxs_whitelist { | |||
2141 | static int __devinit check_dxs_list(struct pci_dev *pci) | 2149 | static int __devinit check_dxs_list(struct pci_dev *pci) |
2142 | { | 2150 | { |
2143 | static struct dxs_whitelist whitelist[] = { | 2151 | static struct dxs_whitelist whitelist[] = { |
2144 | { .vendor = 0x1005, .device = 0x4710, .action = VIA_DXS_ENABLE }, /* Avance Logic Mobo */ | 2152 | { .subvendor = 0x1005, .subdevice = 0x4710, .action = VIA_DXS_ENABLE }, /* Avance Logic Mobo */ |
2145 | { .vendor = 0x1019, .device = 0x0996, .action = VIA_DXS_48K }, | 2153 | { .subvendor = 0x1019, .subdevice = 0x0996, .action = VIA_DXS_48K }, |
2146 | { .vendor = 0x1019, .device = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */ | 2154 | { .subvendor = 0x1019, .subdevice = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */ |
2147 | { .vendor = 0x1019, .device = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */ | 2155 | { .subvendor = 0x1019, .subdevice = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */ |
2148 | { .vendor = 0x1025, .device = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */ | 2156 | { .subvendor = 0x1025, .subdevice = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */ |
2149 | { .vendor = 0x1043, .device = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/ | 2157 | { .subvendor = 0x1043, .subdevice = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/ |
2150 | { .vendor = 0x1043, .device = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */ | 2158 | { .subvendor = 0x1043, .subdevice = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */ |
2151 | { .vendor = 0x1043, .device = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/ | 2159 | { .subvendor = 0x1043, .subdevice = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/ |
2152 | { .vendor = 0x1071, .device = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */ | 2160 | { .subvendor = 0x1043, .subdevice = 0x812a, .action = VIA_DXS_SRC }, /* ASUS A8V Deluxe */ |
2153 | { .vendor = 0x10cf, .device = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */ | 2161 | { .subvendor = 0x1071, .subdevice = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */ |
2154 | { .vendor = 0x1106, .device = 0x4161, .action = VIA_DXS_NO_VRA }, /* ASRock K7VT2 */ | 2162 | { .subvendor = 0x1071, .subdevice = 0x8399, .action = VIA_DXS_NO_VRA }, /* Umax AB 595T (VIA K8N800A - VT8237) */ |
2155 | { .vendor = 0x1106, .device = 0x4552, .action = VIA_DXS_NO_VRA }, /* QDI Kudoz 7X/600-6AL */ | 2163 | { .subvendor = 0x10cf, .subdevice = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */ |
2156 | { .vendor = 0x1106, .device = 0xaa01, .action = VIA_DXS_NO_VRA }, /* EPIA MII */ | 2164 | { .subvendor = 0x1106, .subdevice = 0x4161, .action = VIA_DXS_NO_VRA }, /* ASRock K7VT2 */ |
2157 | { .vendor = 0x1297, .device = 0xa232, .action = VIA_DXS_ENABLE }, /* Shuttle ?? */ | 2165 | { .subvendor = 0x1106, .subdevice = 0x4552, .action = VIA_DXS_NO_VRA }, /* QDI Kudoz 7X/600-6AL */ |
2158 | { .vendor = 0x1297, .device = 0xc160, .action = VIA_DXS_ENABLE }, /* Shuttle SK41G */ | 2166 | { .subvendor = 0x1106, .subdevice = 0xaa01, .action = VIA_DXS_NO_VRA }, /* EPIA MII */ |
2159 | { .vendor = 0x1458, .device = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */ | 2167 | { .subvendor = 0x1106, .subdevice = 0xc001, .action = VIA_DXS_SRC }, /* Insight P4-ITX */ |
2160 | { .vendor = 0x1462, .device = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */ | 2168 | { .subvendor = 0x1297, .subdevice = 0xa232, .action = VIA_DXS_ENABLE }, /* Shuttle ?? */ |
2161 | { .vendor = 0x1462, .device = 0x5901, .action = VIA_DXS_NO_VRA }, /* MSI KT6 Delta-SR */ | 2169 | { .subvendor = 0x1297, .subdevice = 0xc160, .action = VIA_DXS_ENABLE }, /* Shuttle SK41G */ |
2162 | { .vendor = 0x1462, .device = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */ | 2170 | { .subvendor = 0x1458, .subdevice = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */ |
2163 | { .vendor = 0x1462, .device = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */ | 2171 | { .subvendor = 0x1462, .subdevice = 0x0080, .action = VIA_DXS_SRC }, /* MSI K8T Neo-FIS2R */ |
2164 | { .vendor = 0x147b, .device = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */ | 2172 | { .subvendor = 0x1462, .subdevice = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */ |
2165 | { .vendor = 0x147b, .device = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */ | 2173 | { .subvendor = 0x1462, .subdevice = 0x5901, .action = VIA_DXS_NO_VRA }, /* MSI KT6 Delta-SR */ |
2166 | { .vendor = 0x147b, .device = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */ | 2174 | { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */ |
2167 | { .vendor = 0x147b, .device = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */ | 2175 | { .subvendor = 0x1462, .subdevice = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */ |
2168 | { .vendor = 0x14ff, .device = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */ | 2176 | { .subvendor = 0x147b, .subdevice = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */ |
2169 | { .vendor = 0x1584, .device = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */ | 2177 | { .subvendor = 0x147b, .subdevice = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */ |
2170 | { .vendor = 0x1584, .device = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */ | 2178 | { .subvendor = 0x147b, .subdevice = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */ |
2171 | { .vendor = 0x161f, .device = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */ | 2179 | { .subvendor = 0x147b, .subdevice = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */ |
2172 | { .vendor = 0x161f, .device = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */ | 2180 | { .subvendor = 0x14ff, .subdevice = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */ |
2173 | { .vendor = 0x1631, .device = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */ | 2181 | { .subvendor = 0x14ff, .subdevice = 0x0408, .action = VIA_DXS_NO_VRA }, /* Twinhead mobo */ |
2174 | { .vendor = 0x1695, .device = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ | 2182 | { .subvendor = 0x1584, .subdevice = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */ |
2175 | { .vendor = 0x1849, .device = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ | 2183 | { .subvendor = 0x1584, .subdevice = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */ |
2184 | { .subvendor = 0x161f, .subdevice = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */ | ||
2185 | { .subvendor = 0x161f, .subdevice = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */ | ||
2186 | { .subvendor = 0x1631, .subdevice = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */ | ||
2187 | { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ | ||
2188 | { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ | ||
2189 | { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */ | ||
2176 | { } /* terminator */ | 2190 | { } /* terminator */ |
2177 | }; | 2191 | }; |
2178 | struct dxs_whitelist *w; | 2192 | struct dxs_whitelist *w; |
@@ -2182,14 +2196,14 @@ static int __devinit check_dxs_list(struct pci_dev *pci) | |||
2182 | pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); | 2196 | pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); |
2183 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); | 2197 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); |
2184 | 2198 | ||
2185 | for (w = whitelist; w->vendor; w++) { | 2199 | for (w = whitelist; w->subvendor; w++) { |
2186 | if (w->vendor != subsystem_vendor) | 2200 | if (w->subvendor != subsystem_vendor) |
2187 | continue; | 2201 | continue; |
2188 | if (w->mask) { | 2202 | if (w->mask) { |
2189 | if ((w->mask & subsystem_device) == w->device) | 2203 | if ((w->mask & subsystem_device) == w->subdevice) |
2190 | return w->action; | 2204 | return w->action; |
2191 | } else { | 2205 | } else { |
2192 | if (subsystem_device == w->device) | 2206 | if (subsystem_device == w->subdevice) |
2193 | return w->action; | 2207 | return w->action; |
2194 | } | 2208 | } |
2195 | } | 2209 | } |
@@ -2198,8 +2212,9 @@ static int __devinit check_dxs_list(struct pci_dev *pci) | |||
2198 | * not detected, try 48k rate only to be sure. | 2212 | * not detected, try 48k rate only to be sure. |
2199 | */ | 2213 | */ |
2200 | printk(KERN_INFO "via82xx: Assuming DXS channels with 48k fixed sample rate.\n"); | 2214 | printk(KERN_INFO "via82xx: Assuming DXS channels with 48k fixed sample rate.\n"); |
2201 | printk(KERN_INFO " Please try dxs_support=1 or dxs_support=4 option\n"); | 2215 | printk(KERN_INFO " Please try dxs_support=5 option\n"); |
2202 | printk(KERN_INFO " and report if it works on your machine.\n"); | 2216 | printk(KERN_INFO " and report if it works on your machine.\n"); |
2217 | printk(KERN_INFO " For more details, read ALSA-Configuration.txt.\n"); | ||
2203 | return VIA_DXS_48K; | 2218 | return VIA_DXS_48K; |
2204 | }; | 2219 | }; |
2205 | 2220 | ||
@@ -2288,6 +2303,10 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
2288 | chip->dxs_fixed = 1; | 2303 | chip->dxs_fixed = 1; |
2289 | else if (dxs_support[dev] == VIA_DXS_NO_VRA) | 2304 | else if (dxs_support[dev] == VIA_DXS_NO_VRA) |
2290 | chip->no_vra = 1; | 2305 | chip->no_vra = 1; |
2306 | else if (dxs_support[dev] == VIA_DXS_SRC) { | ||
2307 | chip->no_vra = 1; | ||
2308 | chip->dxs_src = 1; | ||
2309 | } | ||
2291 | } | 2310 | } |
2292 | if ((err = snd_via8233_init_misc(chip, dev)) < 0) | 2311 | if ((err = snd_via8233_init_misc(chip, dev)) < 0) |
2293 | goto __error; | 2312 | goto __error; |
@@ -2334,7 +2353,7 @@ static struct pci_driver driver = { | |||
2334 | 2353 | ||
2335 | static int __init alsa_card_via82xx_init(void) | 2354 | static int __init alsa_card_via82xx_init(void) |
2336 | { | 2355 | { |
2337 | return pci_module_init(&driver); | 2356 | return pci_register_driver(&driver); |
2338 | } | 2357 | } |
2339 | 2358 | ||
2340 | static void __exit alsa_card_via82xx_exit(void) | 2359 | static void __exit alsa_card_via82xx_exit(void) |
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index ea5c6f640159..5896d289f9ac 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c | |||
@@ -352,10 +352,8 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, | |||
352 | snd_dma_free_pages(&dev->table); | 352 | snd_dma_free_pages(&dev->table); |
353 | dev->table.area = NULL; | 353 | dev->table.area = NULL; |
354 | } | 354 | } |
355 | if (dev->idx_table) { | 355 | kfree(dev->idx_table); |
356 | kfree(dev->idx_table); | 356 | dev->idx_table = NULL; |
357 | dev->idx_table = NULL; | ||
358 | } | ||
359 | return 0; | 357 | return 0; |
360 | } | 358 | } |
361 | 359 | ||
@@ -420,7 +418,10 @@ static void snd_via82xx_codec_write(ac97_t *ac97, | |||
420 | { | 418 | { |
421 | via82xx_t *chip = ac97->private_data; | 419 | via82xx_t *chip = ac97->private_data; |
422 | unsigned int xval; | 420 | unsigned int xval; |
423 | 421 | if(reg == AC97_GPIO_STATUS) { | |
422 | outl(val, VIAREG(chip, GPI_STATUS)); | ||
423 | return; | ||
424 | } | ||
424 | xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY; | 425 | xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY; |
425 | xval <<= VIA_REG_AC97_CODEC_ID_SHIFT; | 426 | xval <<= VIA_REG_AC97_CODEC_ID_SHIFT; |
426 | xval |= reg << VIA_REG_AC97_CMD_SHIFT; | 427 | xval |= reg << VIA_REG_AC97_CMD_SHIFT; |
@@ -544,25 +545,6 @@ static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd) | |||
544 | return 0; | 545 | return 0; |
545 | } | 546 | } |
546 | 547 | ||
547 | static int snd_via82xx_modem_pcm_trigger(snd_pcm_substream_t * substream, int cmd) | ||
548 | { | ||
549 | via82xx_t *chip = snd_pcm_substream_chip(substream); | ||
550 | unsigned int val = 0; | ||
551 | switch (cmd) { | ||
552 | case SNDRV_PCM_TRIGGER_START: | ||
553 | val = snd_ac97_read(chip->ac97, AC97_GPIO_STATUS); | ||
554 | outl(val|AC97_GPIO_LINE1_OH, VIAREG(chip, GPI_STATUS)); | ||
555 | break; | ||
556 | case SNDRV_PCM_TRIGGER_STOP: | ||
557 | val = snd_ac97_read(chip->ac97, AC97_GPIO_STATUS); | ||
558 | outl(val&~AC97_GPIO_LINE1_OH, VIAREG(chip, GPI_STATUS)); | ||
559 | break; | ||
560 | default: | ||
561 | break; | ||
562 | } | ||
563 | return snd_via82xx_pcm_trigger(substream, cmd); | ||
564 | } | ||
565 | |||
566 | /* | 548 | /* |
567 | * pointer callbacks | 549 | * pointer callbacks |
568 | */ | 550 | */ |
@@ -806,7 +788,7 @@ static snd_pcm_ops_t snd_via686_playback_ops = { | |||
806 | .hw_params = snd_via82xx_hw_params, | 788 | .hw_params = snd_via82xx_hw_params, |
807 | .hw_free = snd_via82xx_hw_free, | 789 | .hw_free = snd_via82xx_hw_free, |
808 | .prepare = snd_via82xx_pcm_prepare, | 790 | .prepare = snd_via82xx_pcm_prepare, |
809 | .trigger = snd_via82xx_modem_pcm_trigger, | 791 | .trigger = snd_via82xx_pcm_trigger, |
810 | .pointer = snd_via686_pcm_pointer, | 792 | .pointer = snd_via686_pcm_pointer, |
811 | .page = snd_pcm_sgbuf_ops_page, | 793 | .page = snd_pcm_sgbuf_ops_page, |
812 | }; | 794 | }; |
@@ -819,7 +801,7 @@ static snd_pcm_ops_t snd_via686_capture_ops = { | |||
819 | .hw_params = snd_via82xx_hw_params, | 801 | .hw_params = snd_via82xx_hw_params, |
820 | .hw_free = snd_via82xx_hw_free, | 802 | .hw_free = snd_via82xx_hw_free, |
821 | .prepare = snd_via82xx_pcm_prepare, | 803 | .prepare = snd_via82xx_pcm_prepare, |
822 | .trigger = snd_via82xx_modem_pcm_trigger, | 804 | .trigger = snd_via82xx_pcm_trigger, |
823 | .pointer = snd_via686_pcm_pointer, | 805 | .pointer = snd_via686_pcm_pointer, |
824 | .page = snd_pcm_sgbuf_ops_page, | 806 | .page = snd_pcm_sgbuf_ops_page, |
825 | }; | 807 | }; |
@@ -938,7 +920,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip) | |||
938 | * | 920 | * |
939 | */ | 921 | */ |
940 | 922 | ||
941 | static int __devinit snd_via82xx_chip_init(via82xx_t *chip) | 923 | static int snd_via82xx_chip_init(via82xx_t *chip) |
942 | { | 924 | { |
943 | unsigned int val; | 925 | unsigned int val; |
944 | int max_count; | 926 | int max_count; |
@@ -1233,7 +1215,7 @@ static struct pci_driver driver = { | |||
1233 | 1215 | ||
1234 | static int __init alsa_card_via82xx_init(void) | 1216 | static int __init alsa_card_via82xx_init(void) |
1235 | { | 1217 | { |
1236 | return pci_module_init(&driver); | 1218 | return pci_register_driver(&driver); |
1237 | } | 1219 | } |
1238 | 1220 | ||
1239 | static void __exit alsa_card_via82xx_exit(void) | 1221 | static void __exit alsa_card_via82xx_exit(void) |
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index 4ffbb25658a5..dca6bd2c7580 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c | |||
@@ -260,7 +260,7 @@ static struct pci_driver driver = { | |||
260 | 260 | ||
261 | static int __init alsa_card_vx222_init(void) | 261 | static int __init alsa_card_vx222_init(void) |
262 | { | 262 | { |
263 | return pci_module_init(&driver); | 263 | return pci_register_driver(&driver); |
264 | } | 264 | } |
265 | 265 | ||
266 | static void __exit alsa_card_vx222_exit(void) | 266 | static void __exit alsa_card_vx222_exit(void) |
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 9f3ef22df08d..5b5b624b47d0 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c | |||
@@ -360,7 +360,7 @@ static struct pci_driver driver = { | |||
360 | 360 | ||
361 | static int __init alsa_card_ymfpci_init(void) | 361 | static int __init alsa_card_ymfpci_init(void) |
362 | { | 362 | { |
363 | return pci_module_init(&driver); | 363 | return pci_register_driver(&driver); |
364 | } | 364 | } |
365 | 365 | ||
366 | static void __exit alsa_card_ymfpci_exit(void) | 366 | static void __exit alsa_card_ymfpci_exit(void) |
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 05f1629760bc..2ae79610ecb5 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c | |||
@@ -829,9 +829,7 @@ static snd_pcm_hardware_t snd_ymfpci_capture = | |||
829 | 829 | ||
830 | static void snd_ymfpci_pcm_free_substream(snd_pcm_runtime_t *runtime) | 830 | static void snd_ymfpci_pcm_free_substream(snd_pcm_runtime_t *runtime) |
831 | { | 831 | { |
832 | ymfpci_pcm_t *ypcm = runtime->private_data; | 832 | kfree(runtime->private_data); |
833 | |||
834 | kfree(ypcm); | ||
835 | } | 833 | } |
836 | 834 | ||
837 | static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) | 835 | static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) |
@@ -1421,17 +1419,15 @@ static snd_kcontrol_new_t snd_ymfpci_drec_source __devinitdata = { | |||
1421 | 1419 | ||
1422 | static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 1420 | static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) |
1423 | { | 1421 | { |
1424 | unsigned int mask = 1; | ||
1425 | |||
1426 | switch (kcontrol->private_value) { | 1422 | switch (kcontrol->private_value) { |
1427 | case YDSXGR_SPDIFOUTCTRL: break; | 1423 | case YDSXGR_SPDIFOUTCTRL: break; |
1428 | case YDSXGR_SPDIFINCTRL: break; | 1424 | case YDSXGR_SPDIFINCTRL: break; |
1429 | default: return -EINVAL; | 1425 | default: return -EINVAL; |
1430 | } | 1426 | } |
1431 | uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; | 1427 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
1432 | uinfo->count = 1; | 1428 | uinfo->count = 1; |
1433 | uinfo->value.integer.min = 0; | 1429 | uinfo->value.integer.min = 0; |
1434 | uinfo->value.integer.max = mask; | 1430 | uinfo->value.integer.max = 1; |
1435 | return 0; | 1431 | return 0; |
1436 | } | 1432 | } |
1437 | 1433 | ||
@@ -1439,7 +1435,7 @@ static int snd_ymfpci_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1439 | { | 1435 | { |
1440 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); | 1436 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); |
1441 | int reg = kcontrol->private_value; | 1437 | int reg = kcontrol->private_value; |
1442 | unsigned int shift = 0, mask = 1, invert = 0; | 1438 | unsigned int shift = 0, mask = 1; |
1443 | 1439 | ||
1444 | switch (kcontrol->private_value) { | 1440 | switch (kcontrol->private_value) { |
1445 | case YDSXGR_SPDIFOUTCTRL: break; | 1441 | case YDSXGR_SPDIFOUTCTRL: break; |
@@ -1447,8 +1443,6 @@ static int snd_ymfpci_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1447 | default: return -EINVAL; | 1443 | default: return -EINVAL; |
1448 | } | 1444 | } |
1449 | ucontrol->value.integer.value[0] = (snd_ymfpci_readl(chip, reg) >> shift) & mask; | 1445 | ucontrol->value.integer.value[0] = (snd_ymfpci_readl(chip, reg) >> shift) & mask; |
1450 | if (invert) | ||
1451 | ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; | ||
1452 | return 0; | 1446 | return 0; |
1453 | } | 1447 | } |
1454 | 1448 | ||
@@ -1456,7 +1450,7 @@ static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1456 | { | 1450 | { |
1457 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); | 1451 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); |
1458 | int reg = kcontrol->private_value; | 1452 | int reg = kcontrol->private_value; |
1459 | unsigned int shift = 0, mask = 1, invert = 0; | 1453 | unsigned int shift = 0, mask = 1; |
1460 | int change; | 1454 | int change; |
1461 | unsigned int val, oval; | 1455 | unsigned int val, oval; |
1462 | 1456 | ||
@@ -1466,8 +1460,6 @@ static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1466 | default: return -EINVAL; | 1460 | default: return -EINVAL; |
1467 | } | 1461 | } |
1468 | val = (ucontrol->value.integer.value[0] & mask); | 1462 | val = (ucontrol->value.integer.value[0] & mask); |
1469 | if (invert) | ||
1470 | val = mask - val; | ||
1471 | val <<= shift; | 1463 | val <<= shift; |
1472 | spin_lock_irq(&chip->reg_lock); | 1464 | spin_lock_irq(&chip->reg_lock); |
1473 | oval = snd_ymfpci_readl(chip, reg); | 1465 | oval = snd_ymfpci_readl(chip, reg); |
@@ -1487,14 +1479,13 @@ static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1487 | static int snd_ymfpci_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 1479 | static int snd_ymfpci_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) |
1488 | { | 1480 | { |
1489 | unsigned int reg = kcontrol->private_value; | 1481 | unsigned int reg = kcontrol->private_value; |
1490 | unsigned int mask = 16383; | ||
1491 | 1482 | ||
1492 | if (reg < 0x80 || reg >= 0xc0) | 1483 | if (reg < 0x80 || reg >= 0xc0) |
1493 | return -EINVAL; | 1484 | return -EINVAL; |
1494 | uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; | 1485 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
1495 | uinfo->count = 2; | 1486 | uinfo->count = 2; |
1496 | uinfo->value.integer.min = 0; | 1487 | uinfo->value.integer.min = 0; |
1497 | uinfo->value.integer.max = mask; | 1488 | uinfo->value.integer.max = 16383; |
1498 | return 0; | 1489 | return 0; |
1499 | } | 1490 | } |
1500 | 1491 | ||
@@ -1502,7 +1493,7 @@ static int snd_ymfpci_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1502 | { | 1493 | { |
1503 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); | 1494 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); |
1504 | unsigned int reg = kcontrol->private_value; | 1495 | unsigned int reg = kcontrol->private_value; |
1505 | unsigned int shift_left = 0, shift_right = 16, mask = 16383, invert = 0; | 1496 | unsigned int shift_left = 0, shift_right = 16, mask = 16383; |
1506 | unsigned int val; | 1497 | unsigned int val; |
1507 | 1498 | ||
1508 | if (reg < 0x80 || reg >= 0xc0) | 1499 | if (reg < 0x80 || reg >= 0xc0) |
@@ -1512,10 +1503,6 @@ static int snd_ymfpci_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1512 | spin_unlock_irq(&chip->reg_lock); | 1503 | spin_unlock_irq(&chip->reg_lock); |
1513 | ucontrol->value.integer.value[0] = (val >> shift_left) & mask; | 1504 | ucontrol->value.integer.value[0] = (val >> shift_left) & mask; |
1514 | ucontrol->value.integer.value[1] = (val >> shift_right) & mask; | 1505 | ucontrol->value.integer.value[1] = (val >> shift_right) & mask; |
1515 | if (invert) { | ||
1516 | ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; | ||
1517 | ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; | ||
1518 | } | ||
1519 | return 0; | 1506 | return 0; |
1520 | } | 1507 | } |
1521 | 1508 | ||
@@ -1523,7 +1510,7 @@ static int snd_ymfpci_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1523 | { | 1510 | { |
1524 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); | 1511 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); |
1525 | unsigned int reg = kcontrol->private_value; | 1512 | unsigned int reg = kcontrol->private_value; |
1526 | unsigned int shift_left = 0, shift_right = 16, mask = 16383, invert = 0; | 1513 | unsigned int shift_left = 0, shift_right = 16, mask = 16383; |
1527 | int change; | 1514 | int change; |
1528 | unsigned int val1, val2, oval; | 1515 | unsigned int val1, val2, oval; |
1529 | 1516 | ||
@@ -1531,10 +1518,6 @@ static int snd_ymfpci_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
1531 | return -EINVAL; | 1518 | return -EINVAL; |
1532 | val1 = ucontrol->value.integer.value[0] & mask; | 1519 | val1 = ucontrol->value.integer.value[0] & mask; |
1533 | val2 = ucontrol->value.integer.value[1] & mask; | 1520 | val2 = ucontrol->value.integer.value[1] & mask; |
1534 | if (invert) { | ||
1535 | val1 = mask - val1; | ||
1536 | val2 = mask - val2; | ||
1537 | } | ||
1538 | val1 <<= shift_left; | 1521 | val1 <<= shift_left; |
1539 | val2 <<= shift_right; | 1522 | val2 <<= shift_right; |
1540 | spin_lock_irq(&chip->reg_lock); | 1523 | spin_lock_irq(&chip->reg_lock); |
diff --git a/sound/pcmcia/vx/vx_entry.c b/sound/pcmcia/vx/vx_entry.c index 53d8172c52ae..332bbca3dfc4 100644 --- a/sound/pcmcia/vx/vx_entry.c +++ b/sound/pcmcia/vx/vx_entry.c | |||
@@ -68,8 +68,7 @@ static int snd_vxpocket_free(vx_core_t *chip) | |||
68 | if (hw) | 68 | if (hw) |
69 | hw->card_list[vxp->index] = NULL; | 69 | hw->card_list[vxp->index] = NULL; |
70 | chip->card = NULL; | 70 | chip->card = NULL; |
71 | if (chip->dev) | 71 | kfree(chip->dev); |
72 | kfree(chip->dev); | ||
73 | 72 | ||
74 | snd_vx_free_firmware(chip); | 73 | snd_vx_free_firmware(chip); |
75 | kfree(chip); | 74 | kfree(chip); |
diff --git a/sound/sound_core.c b/sound/sound_core.c index 30f75c9288cb..21a69e096225 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c | |||
@@ -65,7 +65,7 @@ extern int msnd_classic_init(void); | |||
65 | extern int msnd_pinnacle_init(void); | 65 | extern int msnd_pinnacle_init(void); |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | struct class_simple *sound_class; | 68 | struct class *sound_class; |
69 | EXPORT_SYMBOL(sound_class); | 69 | EXPORT_SYMBOL(sound_class); |
70 | 70 | ||
71 | /* | 71 | /* |
@@ -174,7 +174,7 @@ static int sound_insert_unit(struct sound_unit **list, struct file_operations *f | |||
174 | 174 | ||
175 | devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor), | 175 | devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor), |
176 | S_IFCHR | mode, s->name); | 176 | S_IFCHR | mode, s->name); |
177 | class_simple_device_add(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor), | 177 | class_device_create(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor), |
178 | NULL, s->name+6); | 178 | NULL, s->name+6); |
179 | return r; | 179 | return r; |
180 | 180 | ||
@@ -198,7 +198,7 @@ static void sound_remove_unit(struct sound_unit **list, int unit) | |||
198 | spin_unlock(&sound_loader_lock); | 198 | spin_unlock(&sound_loader_lock); |
199 | if (p) { | 199 | if (p) { |
200 | devfs_remove(p->name); | 200 | devfs_remove(p->name); |
201 | class_simple_device_remove(MKDEV(SOUND_MAJOR, p->unit_minor)); | 201 | class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor)); |
202 | kfree(p); | 202 | kfree(p); |
203 | } | 203 | } |
204 | } | 204 | } |
@@ -562,7 +562,7 @@ static void __exit cleanup_soundcore(void) | |||
562 | empty */ | 562 | empty */ |
563 | unregister_chrdev(SOUND_MAJOR, "sound"); | 563 | unregister_chrdev(SOUND_MAJOR, "sound"); |
564 | devfs_remove("sound"); | 564 | devfs_remove("sound"); |
565 | class_simple_destroy(sound_class); | 565 | class_destroy(sound_class); |
566 | } | 566 | } |
567 | 567 | ||
568 | static int __init init_soundcore(void) | 568 | static int __init init_soundcore(void) |
@@ -572,7 +572,7 @@ static int __init init_soundcore(void) | |||
572 | return -EBUSY; | 572 | return -EBUSY; |
573 | } | 573 | } |
574 | devfs_mk_dir ("sound"); | 574 | devfs_mk_dir ("sound"); |
575 | sound_class = class_simple_create(THIS_MODULE, "sound"); | 575 | sound_class = class_create(THIS_MODULE, "sound"); |
576 | if (IS_ERR(sound_class)) | 576 | if (IS_ERR(sound_class)) |
577 | return PTR_ERR(sound_class); | 577 | return PTR_ERR(sound_class); |
578 | 578 | ||
diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index 16f3b461627a..60d0b2c66698 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/wait.h> | 22 | #include <linux/wait.h> |
23 | #include <linux/sched.h> | 23 | #include <linux/sched.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/string.h> | ||
25 | #include <sound/core.h> | 26 | #include <sound/core.h> |
26 | #include <sound/emux_synth.h> | 27 | #include <sound/emux_synth.h> |
27 | #include <linux/init.h> | 28 | #include <linux/init.h> |
@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name) | |||
76 | snd_assert(name != NULL, return -EINVAL); | 77 | snd_assert(name != NULL, return -EINVAL); |
77 | 78 | ||
78 | emu->card = card; | 79 | emu->card = card; |
79 | emu->name = snd_kmalloc_strdup(name, GFP_KERNEL); | 80 | emu->name = kstrdup(name, GFP_KERNEL); |
80 | emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL); | 81 | emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL); |
81 | if (emu->voices == NULL) | 82 | if (emu->voices == NULL) |
82 | return -ENOMEM; | 83 | return -ENOMEM; |
diff --git a/sound/synth/emux/emux_effect.c b/sound/synth/emux/emux_effect.c index ec3fc1ba7fca..4764940f11a0 100644 --- a/sound/synth/emux/emux_effect.c +++ b/sound/synth/emux/emux_effect.c | |||
@@ -291,10 +291,8 @@ snd_emux_create_effect(snd_emux_port_t *p) | |||
291 | void | 291 | void |
292 | snd_emux_delete_effect(snd_emux_port_t *p) | 292 | snd_emux_delete_effect(snd_emux_port_t *p) |
293 | { | 293 | { |
294 | if (p->effect) { | 294 | kfree(p->effect); |
295 | kfree(p->effect); | 295 | p->effect = NULL; |
296 | p->effect = NULL; | ||
297 | } | ||
298 | } | 296 | } |
299 | 297 | ||
300 | void | 298 | void |
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig index 9329e992c841..f05d02f5b69f 100644 --- a/sound/usb/Kconfig +++ b/sound/usb/Kconfig | |||
@@ -6,6 +6,7 @@ menu "USB devices" | |||
6 | config SND_USB_AUDIO | 6 | config SND_USB_AUDIO |
7 | tristate "USB Audio/MIDI driver" | 7 | tristate "USB Audio/MIDI driver" |
8 | depends on SND && USB | 8 | depends on SND && USB |
9 | select SND_HWDEP | ||
9 | select SND_RAWMIDI | 10 | select SND_RAWMIDI |
10 | select SND_PCM | 11 | select SND_PCM |
11 | help | 12 | help |
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 84b0bbddbd22..a75695045f29 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -98,7 +98,7 @@ MODULE_PARM_DESC(async_unlink, "Use async unlink mode."); | |||
98 | #define MAX_PACKS 10 | 98 | #define MAX_PACKS 10 |
99 | #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ | 99 | #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ |
100 | #define MAX_URBS 5 /* max. 20ms long packets */ | 100 | #define MAX_URBS 5 /* max. 20ms long packets */ |
101 | #define SYNC_URBS 2 /* always two urbs for sync */ | 101 | #define SYNC_URBS 4 /* always four urbs for sync */ |
102 | #define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ | 102 | #define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ |
103 | 103 | ||
104 | typedef struct snd_usb_substream snd_usb_substream_t; | 104 | typedef struct snd_usb_substream snd_usb_substream_t; |
@@ -177,7 +177,7 @@ struct snd_usb_substream { | |||
177 | unsigned int nurbs; /* # urbs */ | 177 | unsigned int nurbs; /* # urbs */ |
178 | snd_urb_ctx_t dataurb[MAX_URBS]; /* data urb table */ | 178 | snd_urb_ctx_t dataurb[MAX_URBS]; /* data urb table */ |
179 | snd_urb_ctx_t syncurb[SYNC_URBS]; /* sync urb table */ | 179 | snd_urb_ctx_t syncurb[SYNC_URBS]; /* sync urb table */ |
180 | char syncbuf[SYNC_URBS * MAX_PACKS * 4]; /* sync buffer; it's so small - let's get static */ | 180 | char syncbuf[SYNC_URBS * 4]; /* sync buffer; it's so small - let's get static */ |
181 | char *tmpbuf; /* temporary buffer for playback */ | 181 | char *tmpbuf; /* temporary buffer for playback */ |
182 | 182 | ||
183 | u64 formats; /* format bitmasks (all or'ed) */ | 183 | u64 formats; /* format bitmasks (all or'ed) */ |
@@ -251,17 +251,13 @@ static int prepare_capture_sync_urb(snd_usb_substream_t *subs, | |||
251 | { | 251 | { |
252 | unsigned char *cp = urb->transfer_buffer; | 252 | unsigned char *cp = urb->transfer_buffer; |
253 | snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; | 253 | snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; |
254 | int i, offs; | ||
255 | 254 | ||
256 | urb->number_of_packets = ctx->packets; | ||
257 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ | 255 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ |
258 | for (i = offs = 0; i < urb->number_of_packets; i++, offs += 4, cp += 4) { | 256 | urb->iso_frame_desc[0].length = 3; |
259 | urb->iso_frame_desc[i].length = 3; | 257 | urb->iso_frame_desc[0].offset = 0; |
260 | urb->iso_frame_desc[i].offset = offs; | 258 | cp[0] = subs->freqn >> 2; |
261 | cp[0] = subs->freqn >> 2; | 259 | cp[1] = subs->freqn >> 10; |
262 | cp[1] = subs->freqn >> 10; | 260 | cp[2] = subs->freqn >> 18; |
263 | cp[2] = subs->freqn >> 18; | ||
264 | } | ||
265 | return 0; | 261 | return 0; |
266 | } | 262 | } |
267 | 263 | ||
@@ -277,18 +273,14 @@ static int prepare_capture_sync_urb_hs(snd_usb_substream_t *subs, | |||
277 | { | 273 | { |
278 | unsigned char *cp = urb->transfer_buffer; | 274 | unsigned char *cp = urb->transfer_buffer; |
279 | snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; | 275 | snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; |
280 | int i, offs; | ||
281 | 276 | ||
282 | urb->number_of_packets = ctx->packets; | ||
283 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ | 277 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ |
284 | for (i = offs = 0; i < urb->number_of_packets; i++, offs += 4, cp += 4) { | 278 | urb->iso_frame_desc[0].length = 4; |
285 | urb->iso_frame_desc[i].length = 4; | 279 | urb->iso_frame_desc[0].offset = 0; |
286 | urb->iso_frame_desc[i].offset = offs; | 280 | cp[0] = subs->freqn; |
287 | cp[0] = subs->freqn; | 281 | cp[1] = subs->freqn >> 8; |
288 | cp[1] = subs->freqn >> 8; | 282 | cp[2] = subs->freqn >> 16; |
289 | cp[2] = subs->freqn >> 16; | 283 | cp[3] = subs->freqn >> 24; |
290 | cp[3] = subs->freqn >> 24; | ||
291 | } | ||
292 | return 0; | 284 | return 0; |
293 | } | 285 | } |
294 | 286 | ||
@@ -418,15 +410,11 @@ static int prepare_playback_sync_urb(snd_usb_substream_t *subs, | |||
418 | snd_pcm_runtime_t *runtime, | 410 | snd_pcm_runtime_t *runtime, |
419 | struct urb *urb) | 411 | struct urb *urb) |
420 | { | 412 | { |
421 | int i, offs; | ||
422 | snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; | 413 | snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; |
423 | 414 | ||
424 | urb->number_of_packets = ctx->packets; | ||
425 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ | 415 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ |
426 | for (i = offs = 0; i < urb->number_of_packets; i++, offs += 4) { | 416 | urb->iso_frame_desc[0].length = 3; |
427 | urb->iso_frame_desc[i].length = 3; | 417 | urb->iso_frame_desc[0].offset = 0; |
428 | urb->iso_frame_desc[i].offset = offs; | ||
429 | } | ||
430 | return 0; | 418 | return 0; |
431 | } | 419 | } |
432 | 420 | ||
@@ -440,15 +428,11 @@ static int prepare_playback_sync_urb_hs(snd_usb_substream_t *subs, | |||
440 | snd_pcm_runtime_t *runtime, | 428 | snd_pcm_runtime_t *runtime, |
441 | struct urb *urb) | 429 | struct urb *urb) |
442 | { | 430 | { |
443 | int i, offs; | ||
444 | snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; | 431 | snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; |
445 | 432 | ||
446 | urb->number_of_packets = ctx->packets; | ||
447 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ | 433 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ |
448 | for (i = offs = 0; i < urb->number_of_packets; i++, offs += 4) { | 434 | urb->iso_frame_desc[0].length = 4; |
449 | urb->iso_frame_desc[i].length = 4; | 435 | urb->iso_frame_desc[0].offset = 0; |
450 | urb->iso_frame_desc[i].offset = offs; | ||
451 | } | ||
452 | return 0; | 436 | return 0; |
453 | } | 437 | } |
454 | 438 | ||
@@ -462,31 +446,17 @@ static int retire_playback_sync_urb(snd_usb_substream_t *subs, | |||
462 | snd_pcm_runtime_t *runtime, | 446 | snd_pcm_runtime_t *runtime, |
463 | struct urb *urb) | 447 | struct urb *urb) |
464 | { | 448 | { |
465 | int i; | 449 | unsigned int f; |
466 | unsigned int f, found; | ||
467 | unsigned char *cp = urb->transfer_buffer; | ||
468 | unsigned long flags; | 450 | unsigned long flags; |
469 | 451 | ||
470 | found = 0; | 452 | if (urb->iso_frame_desc[0].status == 0 && |
471 | for (i = 0; i < urb->number_of_packets; i++, cp += 4) { | 453 | urb->iso_frame_desc[0].actual_length == 3) { |
472 | if (urb->iso_frame_desc[i].status || | 454 | f = combine_triple((u8*)urb->transfer_buffer) << 2; |
473 | urb->iso_frame_desc[i].actual_length < 3) | 455 | if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) { |
474 | continue; | 456 | spin_lock_irqsave(&subs->lock, flags); |
475 | f = combine_triple(cp) << 2; | 457 | subs->freqm = f; |
476 | #if 0 | 458 | spin_unlock_irqrestore(&subs->lock, flags); |
477 | if (f < subs->freqn - (subs->freqn>>3) || f > subs->freqmax) { | ||
478 | snd_printd(KERN_WARNING "requested frequency %d (%u,%03uHz) out of range (current nominal %d (%u,%03uHz))\n", | ||
479 | f, f >> 14, (f & ((1 << 14) - 1) * 1000) / ((1 << 14) - 1), | ||
480 | subs->freqn, subs->freqn >> 14, (subs->freqn & ((1 << 14) - 1) * 1000) / ((1 << 14) - 1)); | ||
481 | continue; | ||
482 | } | 459 | } |
483 | #endif | ||
484 | found = f; | ||
485 | } | ||
486 | if (found) { | ||
487 | spin_lock_irqsave(&subs->lock, flags); | ||
488 | subs->freqm = found; | ||
489 | spin_unlock_irqrestore(&subs->lock, flags); | ||
490 | } | 460 | } |
491 | 461 | ||
492 | return 0; | 462 | return 0; |
@@ -502,22 +472,17 @@ static int retire_playback_sync_urb_hs(snd_usb_substream_t *subs, | |||
502 | snd_pcm_runtime_t *runtime, | 472 | snd_pcm_runtime_t *runtime, |
503 | struct urb *urb) | 473 | struct urb *urb) |
504 | { | 474 | { |
505 | int i; | 475 | unsigned int f; |
506 | unsigned int found; | ||
507 | unsigned char *cp = urb->transfer_buffer; | ||
508 | unsigned long flags; | 476 | unsigned long flags; |
509 | 477 | ||
510 | found = 0; | 478 | if (urb->iso_frame_desc[0].status == 0 && |
511 | for (i = 0; i < urb->number_of_packets; i++, cp += 4) { | 479 | urb->iso_frame_desc[0].actual_length == 4) { |
512 | if (urb->iso_frame_desc[i].status || | 480 | f = combine_quad((u8*)urb->transfer_buffer) & 0x0fffffff; |
513 | urb->iso_frame_desc[i].actual_length < 4) | 481 | if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) { |
514 | continue; | 482 | spin_lock_irqsave(&subs->lock, flags); |
515 | found = combine_quad(cp) & 0x0fffffff; | 483 | subs->freqm = f; |
516 | } | 484 | spin_unlock_irqrestore(&subs->lock, flags); |
517 | if (found) { | 485 | } |
518 | spin_lock_irqsave(&subs->lock, flags); | ||
519 | subs->freqm = found; | ||
520 | spin_unlock_irqrestore(&subs->lock, flags); | ||
521 | } | 486 | } |
522 | 487 | ||
523 | return 0; | 488 | return 0; |
@@ -600,6 +565,8 @@ static int prepare_playback_urb(snd_usb_substream_t *subs, | |||
600 | /* set the buffer pointer */ | 565 | /* set the buffer pointer */ |
601 | urb->transfer_buffer = runtime->dma_area + subs->hwptr * stride; | 566 | urb->transfer_buffer = runtime->dma_area + subs->hwptr * stride; |
602 | subs->hwptr += offs; | 567 | subs->hwptr += offs; |
568 | if (subs->hwptr == runtime->buffer_size) | ||
569 | subs->hwptr = 0; | ||
603 | } | 570 | } |
604 | spin_unlock_irqrestore(&subs->lock, flags); | 571 | spin_unlock_irqrestore(&subs->lock, flags); |
605 | urb->transfer_buffer_length = offs * stride; | 572 | urb->transfer_buffer_length = offs * stride; |
@@ -892,10 +859,8 @@ static void release_urb_ctx(snd_urb_ctx_t *u) | |||
892 | usb_free_urb(u->urb); | 859 | usb_free_urb(u->urb); |
893 | u->urb = NULL; | 860 | u->urb = NULL; |
894 | } | 861 | } |
895 | if (u->buf) { | 862 | kfree(u->buf); |
896 | kfree(u->buf); | 863 | u->buf = NULL; |
897 | u->buf = NULL; | ||
898 | } | ||
899 | } | 864 | } |
900 | 865 | ||
901 | /* | 866 | /* |
@@ -913,10 +878,8 @@ static void release_substream_urbs(snd_usb_substream_t *subs, int force) | |||
913 | release_urb_ctx(&subs->dataurb[i]); | 878 | release_urb_ctx(&subs->dataurb[i]); |
914 | for (i = 0; i < SYNC_URBS; i++) | 879 | for (i = 0; i < SYNC_URBS; i++) |
915 | release_urb_ctx(&subs->syncurb[i]); | 880 | release_urb_ctx(&subs->syncurb[i]); |
916 | if (subs->tmpbuf) { | 881 | kfree(subs->tmpbuf); |
917 | kfree(subs->tmpbuf); | 882 | subs->tmpbuf = NULL; |
918 | subs->tmpbuf = NULL; | ||
919 | } | ||
920 | subs->nurbs = 0; | 883 | subs->nurbs = 0; |
921 | } | 884 | } |
922 | 885 | ||
@@ -1039,22 +1002,19 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by | |||
1039 | snd_urb_ctx_t *u = &subs->syncurb[i]; | 1002 | snd_urb_ctx_t *u = &subs->syncurb[i]; |
1040 | u->index = i; | 1003 | u->index = i; |
1041 | u->subs = subs; | 1004 | u->subs = subs; |
1042 | u->packets = nrpacks; | 1005 | u->packets = 1; |
1043 | u->urb = usb_alloc_urb(u->packets, GFP_KERNEL); | 1006 | u->urb = usb_alloc_urb(1, GFP_KERNEL); |
1044 | if (! u->urb) { | 1007 | if (! u->urb) { |
1045 | release_substream_urbs(subs, 0); | 1008 | release_substream_urbs(subs, 0); |
1046 | return -ENOMEM; | 1009 | return -ENOMEM; |
1047 | } | 1010 | } |
1048 | u->urb->transfer_buffer = subs->syncbuf + i * nrpacks * 4; | 1011 | u->urb->transfer_buffer = subs->syncbuf + i * 4; |
1049 | u->urb->transfer_buffer_length = nrpacks * 4; | 1012 | u->urb->transfer_buffer_length = 4; |
1050 | u->urb->dev = subs->dev; | 1013 | u->urb->dev = subs->dev; |
1051 | u->urb->pipe = subs->syncpipe; | 1014 | u->urb->pipe = subs->syncpipe; |
1052 | u->urb->transfer_flags = URB_ISO_ASAP; | 1015 | u->urb->transfer_flags = URB_ISO_ASAP; |
1053 | u->urb->number_of_packets = u->packets; | 1016 | u->urb->number_of_packets = 1; |
1054 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH) | 1017 | u->urb->interval = 1 << subs->syncinterval; |
1055 | u->urb->interval = 8; | ||
1056 | else | ||
1057 | u->urb->interval = 1; | ||
1058 | u->urb->context = u; | 1018 | u->urb->context = u; |
1059 | u->urb->complete = snd_usb_complete_callback(snd_complete_sync_urb); | 1019 | u->urb->complete = snd_usb_complete_callback(snd_complete_sync_urb); |
1060 | } | 1020 | } |
@@ -1272,7 +1232,17 @@ static int set_format(snd_usb_substream_t *subs, struct audioformat *fmt) | |||
1272 | subs->syncpipe = usb_rcvisocpipe(dev, ep); | 1232 | subs->syncpipe = usb_rcvisocpipe(dev, ep); |
1273 | else | 1233 | else |
1274 | subs->syncpipe = usb_sndisocpipe(dev, ep); | 1234 | subs->syncpipe = usb_sndisocpipe(dev, ep); |
1275 | subs->syncinterval = get_endpoint(alts, 1)->bRefresh; | 1235 | if (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE && |
1236 | get_endpoint(alts, 1)->bRefresh >= 1 && | ||
1237 | get_endpoint(alts, 1)->bRefresh <= 9) | ||
1238 | subs->syncinterval = get_endpoint(alts, 1)->bRefresh; | ||
1239 | else if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) | ||
1240 | subs->syncinterval = 1; | ||
1241 | else if (get_endpoint(alts, 1)->bInterval >= 1 && | ||
1242 | get_endpoint(alts, 1)->bInterval <= 16) | ||
1243 | subs->syncinterval = get_endpoint(alts, 1)->bInterval - 1; | ||
1244 | else | ||
1245 | subs->syncinterval = 3; | ||
1276 | } | 1246 | } |
1277 | 1247 | ||
1278 | /* always fill max packet size */ | 1248 | /* always fill max packet size */ |
@@ -1990,10 +1960,11 @@ static void proc_dump_substream_status(snd_usb_substream_t *subs, snd_info_buffe | |||
1990 | snd_iprintf(buffer, "%d ", subs->dataurb[i].packets); | 1960 | snd_iprintf(buffer, "%d ", subs->dataurb[i].packets); |
1991 | snd_iprintf(buffer, "]\n"); | 1961 | snd_iprintf(buffer, "]\n"); |
1992 | snd_iprintf(buffer, " Packet Size = %d\n", subs->curpacksize); | 1962 | snd_iprintf(buffer, " Packet Size = %d\n", subs->curpacksize); |
1993 | snd_iprintf(buffer, " Momentary freq = %u Hz\n", | 1963 | snd_iprintf(buffer, " Momentary freq = %u Hz (%#x.%04x)\n", |
1994 | snd_usb_get_speed(subs->dev) == USB_SPEED_FULL | 1964 | snd_usb_get_speed(subs->dev) == USB_SPEED_FULL |
1995 | ? get_full_speed_hz(subs->freqm) | 1965 | ? get_full_speed_hz(subs->freqm) |
1996 | : get_high_speed_hz(subs->freqm)); | 1966 | : get_high_speed_hz(subs->freqm), |
1967 | subs->freqm >> 16, subs->freqm & 0xffff); | ||
1997 | } else { | 1968 | } else { |
1998 | snd_iprintf(buffer, " Status: Stop\n"); | 1969 | snd_iprintf(buffer, " Status: Stop\n"); |
1999 | } | 1970 | } |
@@ -2183,17 +2154,15 @@ static int add_audio_endpoint(snd_usb_audio_t *chip, int stream, struct audiofor | |||
2183 | /* | 2154 | /* |
2184 | * check if the device uses big-endian samples | 2155 | * check if the device uses big-endian samples |
2185 | */ | 2156 | */ |
2186 | static int is_big_endian_format(struct usb_device *dev, struct audioformat *fp) | 2157 | static int is_big_endian_format(snd_usb_audio_t *chip, struct audioformat *fp) |
2187 | { | 2158 | { |
2188 | /* M-Audio */ | 2159 | switch (chip->usb_id) { |
2189 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x0763) { | 2160 | case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */ |
2190 | /* Quattro: captured data only */ | 2161 | if (fp->endpoint & USB_DIR_IN) |
2191 | if (le16_to_cpu(dev->descriptor.idProduct) == 0x2001 && | ||
2192 | fp->endpoint & USB_DIR_IN) | ||
2193 | return 1; | ||
2194 | /* Audiophile USB */ | ||
2195 | if (le16_to_cpu(dev->descriptor.idProduct) == 0x2003) | ||
2196 | return 1; | 2162 | return 1; |
2163 | break; | ||
2164 | case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ | ||
2165 | return 1; | ||
2197 | } | 2166 | } |
2198 | return 0; | 2167 | return 0; |
2199 | } | 2168 | } |
@@ -2207,7 +2176,7 @@ static int is_big_endian_format(struct usb_device *dev, struct audioformat *fp) | |||
2207 | * @format: the format tag (wFormatTag) | 2176 | * @format: the format tag (wFormatTag) |
2208 | * @fmt: the format type descriptor | 2177 | * @fmt: the format type descriptor |
2209 | */ | 2178 | */ |
2210 | static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat *fp, | 2179 | static int parse_audio_format_i_type(snd_usb_audio_t *chip, struct audioformat *fp, |
2211 | int format, unsigned char *fmt) | 2180 | int format, unsigned char *fmt) |
2212 | { | 2181 | { |
2213 | int pcm_format; | 2182 | int pcm_format; |
@@ -2220,12 +2189,12 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat | |||
2220 | switch (format) { | 2189 | switch (format) { |
2221 | case 0: /* some devices don't define this correctly... */ | 2190 | case 0: /* some devices don't define this correctly... */ |
2222 | snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", | 2191 | snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", |
2223 | dev->devnum, fp->iface, fp->altsetting); | 2192 | chip->dev->devnum, fp->iface, fp->altsetting); |
2224 | /* fall-through */ | 2193 | /* fall-through */ |
2225 | case USB_AUDIO_FORMAT_PCM: | 2194 | case USB_AUDIO_FORMAT_PCM: |
2226 | if (sample_width > sample_bytes * 8) { | 2195 | if (sample_width > sample_bytes * 8) { |
2227 | snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n", | 2196 | snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n", |
2228 | dev->devnum, fp->iface, fp->altsetting, | 2197 | chip->dev->devnum, fp->iface, fp->altsetting, |
2229 | sample_width, sample_bytes); | 2198 | sample_width, sample_bytes); |
2230 | } | 2199 | } |
2231 | /* check the format byte size */ | 2200 | /* check the format byte size */ |
@@ -2234,13 +2203,13 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat | |||
2234 | pcm_format = SNDRV_PCM_FORMAT_S8; | 2203 | pcm_format = SNDRV_PCM_FORMAT_S8; |
2235 | break; | 2204 | break; |
2236 | case 2: | 2205 | case 2: |
2237 | if (is_big_endian_format(dev, fp)) | 2206 | if (is_big_endian_format(chip, fp)) |
2238 | pcm_format = SNDRV_PCM_FORMAT_S16_BE; /* grrr, big endian!! */ | 2207 | pcm_format = SNDRV_PCM_FORMAT_S16_BE; /* grrr, big endian!! */ |
2239 | else | 2208 | else |
2240 | pcm_format = SNDRV_PCM_FORMAT_S16_LE; | 2209 | pcm_format = SNDRV_PCM_FORMAT_S16_LE; |
2241 | break; | 2210 | break; |
2242 | case 3: | 2211 | case 3: |
2243 | if (is_big_endian_format(dev, fp)) | 2212 | if (is_big_endian_format(chip, fp)) |
2244 | pcm_format = SNDRV_PCM_FORMAT_S24_3BE; /* grrr, big endian!! */ | 2213 | pcm_format = SNDRV_PCM_FORMAT_S24_3BE; /* grrr, big endian!! */ |
2245 | else | 2214 | else |
2246 | pcm_format = SNDRV_PCM_FORMAT_S24_3LE; | 2215 | pcm_format = SNDRV_PCM_FORMAT_S24_3LE; |
@@ -2250,14 +2219,14 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat | |||
2250 | break; | 2219 | break; |
2251 | default: | 2220 | default: |
2252 | snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n", | 2221 | snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n", |
2253 | dev->devnum, fp->iface, fp->altsetting, sample_width, sample_bytes); | 2222 | chip->dev->devnum, fp->iface, |
2223 | fp->altsetting, sample_width, sample_bytes); | ||
2254 | break; | 2224 | break; |
2255 | } | 2225 | } |
2256 | break; | 2226 | break; |
2257 | case USB_AUDIO_FORMAT_PCM8: | 2227 | case USB_AUDIO_FORMAT_PCM8: |
2258 | /* Dallas DS4201 workaround */ | 2228 | /* Dallas DS4201 workaround */ |
2259 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x04fa && | 2229 | if (chip->usb_id == USB_ID(0x04fa, 0x4201)) |
2260 | le16_to_cpu(dev->descriptor.idProduct) == 0x4201) | ||
2261 | pcm_format = SNDRV_PCM_FORMAT_S8; | 2230 | pcm_format = SNDRV_PCM_FORMAT_S8; |
2262 | else | 2231 | else |
2263 | pcm_format = SNDRV_PCM_FORMAT_U8; | 2232 | pcm_format = SNDRV_PCM_FORMAT_U8; |
@@ -2273,7 +2242,7 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat | |||
2273 | break; | 2242 | break; |
2274 | default: | 2243 | default: |
2275 | snd_printk(KERN_INFO "%d:%u:%d : unsupported format type %d\n", | 2244 | snd_printk(KERN_INFO "%d:%u:%d : unsupported format type %d\n", |
2276 | dev->devnum, fp->iface, fp->altsetting, format); | 2245 | chip->dev->devnum, fp->iface, fp->altsetting, format); |
2277 | break; | 2246 | break; |
2278 | } | 2247 | } |
2279 | return pcm_format; | 2248 | return pcm_format; |
@@ -2290,13 +2259,13 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat | |||
2290 | * @offset: the start offset of descriptor pointing the rate type | 2259 | * @offset: the start offset of descriptor pointing the rate type |
2291 | * (7 for type I and II, 8 for type II) | 2260 | * (7 for type I and II, 8 for type II) |
2292 | */ | 2261 | */ |
2293 | static int parse_audio_format_rates(struct usb_device *dev, struct audioformat *fp, | 2262 | static int parse_audio_format_rates(snd_usb_audio_t *chip, struct audioformat *fp, |
2294 | unsigned char *fmt, int offset) | 2263 | unsigned char *fmt, int offset) |
2295 | { | 2264 | { |
2296 | int nr_rates = fmt[offset]; | 2265 | int nr_rates = fmt[offset]; |
2297 | if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { | 2266 | if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { |
2298 | snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", | 2267 | snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", |
2299 | dev->devnum, fp->iface, fp->altsetting); | 2268 | chip->dev->devnum, fp->iface, fp->altsetting); |
2300 | return -1; | 2269 | return -1; |
2301 | } | 2270 | } |
2302 | 2271 | ||
@@ -2343,7 +2312,7 @@ static int parse_audio_format_rates(struct usb_device *dev, struct audioformat * | |||
2343 | /* | 2312 | /* |
2344 | * parse the format type I and III descriptors | 2313 | * parse the format type I and III descriptors |
2345 | */ | 2314 | */ |
2346 | static int parse_audio_format_i(struct usb_device *dev, struct audioformat *fp, | 2315 | static int parse_audio_format_i(snd_usb_audio_t *chip, struct audioformat *fp, |
2347 | int format, unsigned char *fmt) | 2316 | int format, unsigned char *fmt) |
2348 | { | 2317 | { |
2349 | int pcm_format; | 2318 | int pcm_format; |
@@ -2355,7 +2324,7 @@ static int parse_audio_format_i(struct usb_device *dev, struct audioformat *fp, | |||
2355 | */ | 2324 | */ |
2356 | pcm_format = SNDRV_PCM_FORMAT_S16_LE; | 2325 | pcm_format = SNDRV_PCM_FORMAT_S16_LE; |
2357 | } else { | 2326 | } else { |
2358 | pcm_format = parse_audio_format_i_type(dev, fp, format, fmt); | 2327 | pcm_format = parse_audio_format_i_type(chip, fp, format, fmt); |
2359 | if (pcm_format < 0) | 2328 | if (pcm_format < 0) |
2360 | return -1; | 2329 | return -1; |
2361 | } | 2330 | } |
@@ -2363,16 +2332,16 @@ static int parse_audio_format_i(struct usb_device *dev, struct audioformat *fp, | |||
2363 | fp->channels = fmt[4]; | 2332 | fp->channels = fmt[4]; |
2364 | if (fp->channels < 1) { | 2333 | if (fp->channels < 1) { |
2365 | snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n", | 2334 | snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n", |
2366 | dev->devnum, fp->iface, fp->altsetting, fp->channels); | 2335 | chip->dev->devnum, fp->iface, fp->altsetting, fp->channels); |
2367 | return -1; | 2336 | return -1; |
2368 | } | 2337 | } |
2369 | return parse_audio_format_rates(dev, fp, fmt, 7); | 2338 | return parse_audio_format_rates(chip, fp, fmt, 7); |
2370 | } | 2339 | } |
2371 | 2340 | ||
2372 | /* | 2341 | /* |
2373 | * prase the format type II descriptor | 2342 | * prase the format type II descriptor |
2374 | */ | 2343 | */ |
2375 | static int parse_audio_format_ii(struct usb_device *dev, struct audioformat *fp, | 2344 | static int parse_audio_format_ii(snd_usb_audio_t *chip, struct audioformat *fp, |
2376 | int format, unsigned char *fmt) | 2345 | int format, unsigned char *fmt) |
2377 | { | 2346 | { |
2378 | int brate, framesize; | 2347 | int brate, framesize; |
@@ -2387,7 +2356,7 @@ static int parse_audio_format_ii(struct usb_device *dev, struct audioformat *fp, | |||
2387 | break; | 2356 | break; |
2388 | default: | 2357 | default: |
2389 | snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected. processed as MPEG.\n", | 2358 | snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected. processed as MPEG.\n", |
2390 | dev->devnum, fp->iface, fp->altsetting, format); | 2359 | chip->dev->devnum, fp->iface, fp->altsetting, format); |
2391 | fp->format = SNDRV_PCM_FORMAT_MPEG; | 2360 | fp->format = SNDRV_PCM_FORMAT_MPEG; |
2392 | break; | 2361 | break; |
2393 | } | 2362 | } |
@@ -2396,10 +2365,10 @@ static int parse_audio_format_ii(struct usb_device *dev, struct audioformat *fp, | |||
2396 | framesize = combine_word(&fmt[6]); /* fmt[6,7]: wSamplesPerFrame */ | 2365 | framesize = combine_word(&fmt[6]); /* fmt[6,7]: wSamplesPerFrame */ |
2397 | snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); | 2366 | snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); |
2398 | fp->frame_size = framesize; | 2367 | fp->frame_size = framesize; |
2399 | return parse_audio_format_rates(dev, fp, fmt, 8); /* fmt[8..] sample rates */ | 2368 | return parse_audio_format_rates(chip, fp, fmt, 8); /* fmt[8..] sample rates */ |
2400 | } | 2369 | } |
2401 | 2370 | ||
2402 | static int parse_audio_format(struct usb_device *dev, struct audioformat *fp, | 2371 | static int parse_audio_format(snd_usb_audio_t *chip, struct audioformat *fp, |
2403 | int format, unsigned char *fmt, int stream) | 2372 | int format, unsigned char *fmt, int stream) |
2404 | { | 2373 | { |
2405 | int err; | 2374 | int err; |
@@ -2407,29 +2376,30 @@ static int parse_audio_format(struct usb_device *dev, struct audioformat *fp, | |||
2407 | switch (fmt[3]) { | 2376 | switch (fmt[3]) { |
2408 | case USB_FORMAT_TYPE_I: | 2377 | case USB_FORMAT_TYPE_I: |
2409 | case USB_FORMAT_TYPE_III: | 2378 | case USB_FORMAT_TYPE_III: |
2410 | err = parse_audio_format_i(dev, fp, format, fmt); | 2379 | err = parse_audio_format_i(chip, fp, format, fmt); |
2411 | break; | 2380 | break; |
2412 | case USB_FORMAT_TYPE_II: | 2381 | case USB_FORMAT_TYPE_II: |
2413 | err = parse_audio_format_ii(dev, fp, format, fmt); | 2382 | err = parse_audio_format_ii(chip, fp, format, fmt); |
2414 | break; | 2383 | break; |
2415 | default: | 2384 | default: |
2416 | snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", | 2385 | snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", |
2417 | dev->devnum, fp->iface, fp->altsetting, fmt[3]); | 2386 | chip->dev->devnum, fp->iface, fp->altsetting, fmt[3]); |
2418 | return -1; | 2387 | return -1; |
2419 | } | 2388 | } |
2420 | fp->fmt_type = fmt[3]; | 2389 | fp->fmt_type = fmt[3]; |
2421 | if (err < 0) | 2390 | if (err < 0) |
2422 | return err; | 2391 | return err; |
2423 | #if 1 | 2392 | #if 1 |
2424 | /* FIXME: temporary hack for extigy */ | 2393 | /* FIXME: temporary hack for extigy/audigy 2 nx */ |
2425 | /* extigy apparently supports sample rates other than 48k | 2394 | /* extigy apparently supports sample rates other than 48k |
2426 | * but not in ordinary way. so we enable only 48k atm. | 2395 | * but not in ordinary way. so we enable only 48k atm. |
2427 | */ | 2396 | */ |
2428 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x041e && | 2397 | if (chip->usb_id == USB_ID(0x041e, 0x3000) || |
2429 | le16_to_cpu(dev->descriptor.idProduct) == 0x3000) { | 2398 | chip->usb_id == USB_ID(0x041e, 0x3020)) { |
2430 | if (fmt[3] == USB_FORMAT_TYPE_I && | 2399 | if (fmt[3] == USB_FORMAT_TYPE_I && |
2431 | stream == SNDRV_PCM_STREAM_PLAYBACK && | 2400 | stream == SNDRV_PCM_STREAM_PLAYBACK && |
2432 | fp->rates != SNDRV_PCM_RATE_48000) | 2401 | fp->rates != SNDRV_PCM_RATE_48000 && |
2402 | fp->rates != SNDRV_PCM_RATE_96000) | ||
2433 | return -1; /* use 48k only */ | 2403 | return -1; /* use 48k only */ |
2434 | } | 2404 | } |
2435 | #endif | 2405 | #endif |
@@ -2528,40 +2498,35 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) | |||
2528 | 2498 | ||
2529 | /* some quirks for attributes here */ | 2499 | /* some quirks for attributes here */ |
2530 | 2500 | ||
2531 | /* workaround for AudioTrak Optoplay */ | 2501 | switch (chip->usb_id) { |
2532 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x0a92 && | 2502 | case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */ |
2533 | le16_to_cpu(dev->descriptor.idProduct) == 0x0053) { | ||
2534 | /* Optoplay sets the sample rate attribute although | 2503 | /* Optoplay sets the sample rate attribute although |
2535 | * it seems not supporting it in fact. | 2504 | * it seems not supporting it in fact. |
2536 | */ | 2505 | */ |
2537 | fp->attributes &= ~EP_CS_ATTR_SAMPLE_RATE; | 2506 | fp->attributes &= ~EP_CS_ATTR_SAMPLE_RATE; |
2538 | } | 2507 | break; |
2539 | 2508 | case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ | |
2540 | /* workaround for M-Audio Audiophile USB */ | 2509 | case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ |
2541 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x0763 && | ||
2542 | le16_to_cpu(dev->descriptor.idProduct) == 0x2003) { | ||
2543 | /* doesn't set the sample rate attribute, but supports it */ | 2510 | /* doesn't set the sample rate attribute, but supports it */ |
2544 | fp->attributes |= EP_CS_ATTR_SAMPLE_RATE; | 2511 | fp->attributes |= EP_CS_ATTR_SAMPLE_RATE; |
2545 | } | 2512 | break; |
2546 | 2513 | case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ | |
2514 | case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is | ||
2515 | an older model 77d:223) */ | ||
2547 | /* | 2516 | /* |
2548 | * plantronics headset and Griffin iMic have set adaptive-in | 2517 | * plantronics headset and Griffin iMic have set adaptive-in |
2549 | * although it's really not... | 2518 | * although it's really not... |
2550 | */ | 2519 | */ |
2551 | if ((le16_to_cpu(dev->descriptor.idVendor) == 0x047f && | ||
2552 | le16_to_cpu(dev->descriptor.idProduct) == 0x0ca1) || | ||
2553 | /* Griffin iMic (note that there is an older model 77d:223) */ | ||
2554 | (le16_to_cpu(dev->descriptor.idVendor) == 0x077d && | ||
2555 | le16_to_cpu(dev->descriptor.idProduct) == 0x07af)) { | ||
2556 | fp->ep_attr &= ~EP_ATTR_MASK; | 2520 | fp->ep_attr &= ~EP_ATTR_MASK; |
2557 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) | 2521 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) |
2558 | fp->ep_attr |= EP_ATTR_ADAPTIVE; | 2522 | fp->ep_attr |= EP_ATTR_ADAPTIVE; |
2559 | else | 2523 | else |
2560 | fp->ep_attr |= EP_ATTR_SYNC; | 2524 | fp->ep_attr |= EP_ATTR_SYNC; |
2525 | break; | ||
2561 | } | 2526 | } |
2562 | 2527 | ||
2563 | /* ok, let's parse further... */ | 2528 | /* ok, let's parse further... */ |
2564 | if (parse_audio_format(dev, fp, format, fmt, stream) < 0) { | 2529 | if (parse_audio_format(chip, fp, format, fmt, stream) < 0) { |
2565 | kfree(fp->rate_table); | 2530 | kfree(fp->rate_table); |
2566 | kfree(fp); | 2531 | kfree(fp); |
2567 | continue; | 2532 | continue; |
@@ -2587,7 +2552,7 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) | |||
2587 | * disconnect streams | 2552 | * disconnect streams |
2588 | * called from snd_usb_audio_disconnect() | 2553 | * called from snd_usb_audio_disconnect() |
2589 | */ | 2554 | */ |
2590 | static void snd_usb_stream_disconnect(struct list_head *head, struct usb_driver *driver) | 2555 | static void snd_usb_stream_disconnect(struct list_head *head) |
2591 | { | 2556 | { |
2592 | int idx; | 2557 | int idx; |
2593 | snd_usb_stream_t *as; | 2558 | snd_usb_stream_t *as; |
@@ -2796,7 +2761,7 @@ static int create_ua700_ua25_quirk(snd_usb_audio_t *chip, | |||
2796 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 2761 | .type = QUIRK_MIDI_FIXED_ENDPOINT, |
2797 | .data = &ua25_ep | 2762 | .data = &ua25_ep |
2798 | }; | 2763 | }; |
2799 | if (le16_to_cpu(chip->dev->descriptor.idProduct) == 0x002b) | 2764 | if (chip->usb_id == USB_ID(0x0582, 0x002b)) |
2800 | return snd_usb_create_midi_interface(chip, iface, | 2765 | return snd_usb_create_midi_interface(chip, iface, |
2801 | &ua700_quirk); | 2766 | &ua700_quirk); |
2802 | else | 2767 | else |
@@ -2959,6 +2924,25 @@ static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interfac | |||
2959 | return 0; | 2924 | return 0; |
2960 | } | 2925 | } |
2961 | 2926 | ||
2927 | static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev) | ||
2928 | { | ||
2929 | #if 0 | ||
2930 | /* TODO: enable this when high speed synchronization actually works */ | ||
2931 | u8 buf = 1; | ||
2932 | |||
2933 | snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a, | ||
2934 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, | ||
2935 | 0, 0, &buf, 1, 1000); | ||
2936 | if (buf == 0) { | ||
2937 | snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0x29, | ||
2938 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, | ||
2939 | 1, 2000, NULL, 0, 1000); | ||
2940 | return -ENODEV; | ||
2941 | } | ||
2942 | #endif | ||
2943 | return 0; | ||
2944 | } | ||
2945 | |||
2962 | 2946 | ||
2963 | /* | 2947 | /* |
2964 | * audio-interface quirks | 2948 | * audio-interface quirks |
@@ -3015,8 +2999,8 @@ static void proc_audio_usbid_read(snd_info_entry_t *entry, snd_info_buffer_t *bu | |||
3015 | snd_usb_audio_t *chip = entry->private_data; | 2999 | snd_usb_audio_t *chip = entry->private_data; |
3016 | if (! chip->shutdown) | 3000 | if (! chip->shutdown) |
3017 | snd_iprintf(buffer, "%04x:%04x\n", | 3001 | snd_iprintf(buffer, "%04x:%04x\n", |
3018 | le16_to_cpu(chip->dev->descriptor.idVendor), | 3002 | USB_ID_VENDOR(chip->usb_id), |
3019 | le16_to_cpu(chip->dev->descriptor.idProduct)); | 3003 | USB_ID_PRODUCT(chip->usb_id)); |
3020 | } | 3004 | } |
3021 | 3005 | ||
3022 | static void snd_usb_audio_create_proc(snd_usb_audio_t *chip) | 3006 | static void snd_usb_audio_create_proc(snd_usb_audio_t *chip) |
@@ -3086,8 +3070,11 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
3086 | chip->index = idx; | 3070 | chip->index = idx; |
3087 | chip->dev = dev; | 3071 | chip->dev = dev; |
3088 | chip->card = card; | 3072 | chip->card = card; |
3073 | chip->usb_id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), | ||
3074 | le16_to_cpu(dev->descriptor.idProduct)); | ||
3089 | INIT_LIST_HEAD(&chip->pcm_list); | 3075 | INIT_LIST_HEAD(&chip->pcm_list); |
3090 | INIT_LIST_HEAD(&chip->midi_list); | 3076 | INIT_LIST_HEAD(&chip->midi_list); |
3077 | INIT_LIST_HEAD(&chip->mixer_list); | ||
3091 | 3078 | ||
3092 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 3079 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
3093 | snd_usb_audio_free(chip); | 3080 | snd_usb_audio_free(chip); |
@@ -3097,8 +3084,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
3097 | 3084 | ||
3098 | strcpy(card->driver, "USB-Audio"); | 3085 | strcpy(card->driver, "USB-Audio"); |
3099 | sprintf(component, "USB%04x:%04x", | 3086 | sprintf(component, "USB%04x:%04x", |
3100 | le16_to_cpu(dev->descriptor.idVendor), | 3087 | USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id)); |
3101 | le16_to_cpu(dev->descriptor.idProduct)); | ||
3102 | snd_component_add(card, component); | 3088 | snd_component_add(card, component); |
3103 | 3089 | ||
3104 | /* retrieve the device string as shortname */ | 3090 | /* retrieve the device string as shortname */ |
@@ -3110,8 +3096,8 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
3110 | card->shortname, sizeof(card->shortname)) <= 0) { | 3096 | card->shortname, sizeof(card->shortname)) <= 0) { |
3111 | /* no name available from anywhere, so use ID */ | 3097 | /* no name available from anywhere, so use ID */ |
3112 | sprintf(card->shortname, "USB Device %#04x:%#04x", | 3098 | sprintf(card->shortname, "USB Device %#04x:%#04x", |
3113 | le16_to_cpu(dev->descriptor.idVendor), | 3099 | USB_ID_VENDOR(chip->usb_id), |
3114 | le16_to_cpu(dev->descriptor.idProduct)); | 3100 | USB_ID_PRODUCT(chip->usb_id)); |
3115 | } | 3101 | } |
3116 | } | 3102 | } |
3117 | 3103 | ||
@@ -3142,8 +3128,6 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
3142 | 3128 | ||
3143 | snd_usb_audio_create_proc(chip); | 3129 | snd_usb_audio_create_proc(chip); |
3144 | 3130 | ||
3145 | snd_card_set_dev(card, &dev->dev); | ||
3146 | |||
3147 | *rchip = chip; | 3131 | *rchip = chip; |
3148 | return 0; | 3132 | return 0; |
3149 | } | 3133 | } |
@@ -3169,21 +3153,28 @@ static void *snd_usb_audio_probe(struct usb_device *dev, | |||
3169 | snd_usb_audio_t *chip; | 3153 | snd_usb_audio_t *chip; |
3170 | struct usb_host_interface *alts; | 3154 | struct usb_host_interface *alts; |
3171 | int ifnum; | 3155 | int ifnum; |
3156 | u32 id; | ||
3172 | 3157 | ||
3173 | alts = &intf->altsetting[0]; | 3158 | alts = &intf->altsetting[0]; |
3174 | ifnum = get_iface_desc(alts)->bInterfaceNumber; | 3159 | ifnum = get_iface_desc(alts)->bInterfaceNumber; |
3160 | id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), | ||
3161 | le16_to_cpu(dev->descriptor.idProduct)); | ||
3175 | 3162 | ||
3176 | if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum) | 3163 | if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum) |
3177 | goto __err_val; | 3164 | goto __err_val; |
3178 | 3165 | ||
3179 | /* SB Extigy needs special boot-up sequence */ | 3166 | /* SB Extigy needs special boot-up sequence */ |
3180 | /* if more models come, this will go to the quirk list. */ | 3167 | /* if more models come, this will go to the quirk list. */ |
3181 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x041e && | 3168 | if (id == USB_ID(0x041e, 0x3000)) { |
3182 | le16_to_cpu(dev->descriptor.idProduct) == 0x3000) { | ||
3183 | if (snd_usb_extigy_boot_quirk(dev, intf) < 0) | 3169 | if (snd_usb_extigy_boot_quirk(dev, intf) < 0) |
3184 | goto __err_val; | 3170 | goto __err_val; |
3185 | config = dev->actconfig; | 3171 | config = dev->actconfig; |
3186 | } | 3172 | } |
3173 | /* SB Audigy 2 NX needs its own boot-up magic, too */ | ||
3174 | if (id == USB_ID(0x041e, 0x3020)) { | ||
3175 | if (snd_usb_audigy2nx_boot_quirk(dev) < 0) | ||
3176 | goto __err_val; | ||
3177 | } | ||
3187 | 3178 | ||
3188 | /* | 3179 | /* |
3189 | * found a config. now register to ALSA | 3180 | * found a config. now register to ALSA |
@@ -3213,11 +3204,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev, | |||
3213 | } | 3204 | } |
3214 | for (i = 0; i < SNDRV_CARDS; i++) | 3205 | for (i = 0; i < SNDRV_CARDS; i++) |
3215 | if (enable[i] && ! usb_chip[i] && | 3206 | if (enable[i] && ! usb_chip[i] && |
3216 | (vid[i] == -1 || vid[i] == le16_to_cpu(dev->descriptor.idVendor)) && | 3207 | (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) && |
3217 | (pid[i] == -1 || pid[i] == le16_to_cpu(dev->descriptor.idProduct))) { | 3208 | (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) { |
3218 | if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) { | 3209 | if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) { |
3219 | goto __error; | 3210 | goto __error; |
3220 | } | 3211 | } |
3212 | snd_card_set_dev(chip->card, &intf->dev); | ||
3221 | break; | 3213 | break; |
3222 | } | 3214 | } |
3223 | if (! chip) { | 3215 | if (! chip) { |
@@ -3281,15 +3273,19 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr) | |||
3281 | snd_card_disconnect(card); | 3273 | snd_card_disconnect(card); |
3282 | /* release the pcm resources */ | 3274 | /* release the pcm resources */ |
3283 | list_for_each(p, &chip->pcm_list) { | 3275 | list_for_each(p, &chip->pcm_list) { |
3284 | snd_usb_stream_disconnect(p, &usb_audio_driver); | 3276 | snd_usb_stream_disconnect(p); |
3285 | } | 3277 | } |
3286 | /* release the midi resources */ | 3278 | /* release the midi resources */ |
3287 | list_for_each(p, &chip->midi_list) { | 3279 | list_for_each(p, &chip->midi_list) { |
3288 | snd_usbmidi_disconnect(p, &usb_audio_driver); | 3280 | snd_usbmidi_disconnect(p); |
3281 | } | ||
3282 | /* release mixer resources */ | ||
3283 | list_for_each(p, &chip->mixer_list) { | ||
3284 | snd_usb_mixer_disconnect(p); | ||
3289 | } | 3285 | } |
3290 | usb_chip[chip->index] = NULL; | 3286 | usb_chip[chip->index] = NULL; |
3291 | up(®ister_mutex); | 3287 | up(®ister_mutex); |
3292 | snd_card_free_in_thread(card); | 3288 | snd_card_free(card); |
3293 | } else { | 3289 | } else { |
3294 | up(®ister_mutex); | 3290 | up(®ister_mutex); |
3295 | } | 3291 | } |
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index eecbf19fcb6f..aedb42aaa749 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h | |||
@@ -118,6 +118,11 @@ | |||
118 | /* maximum number of endpoints per interface */ | 118 | /* maximum number of endpoints per interface */ |
119 | #define MIDI_MAX_ENDPOINTS 2 | 119 | #define MIDI_MAX_ENDPOINTS 2 |
120 | 120 | ||
121 | /* handling of USB vendor/product ID pairs as 32-bit numbers */ | ||
122 | #define USB_ID(vendor, product) (((vendor) << 16) | (product)) | ||
123 | #define USB_ID_VENDOR(id) ((id) >> 16) | ||
124 | #define USB_ID_PRODUCT(id) ((u16)(id)) | ||
125 | |||
121 | /* | 126 | /* |
122 | */ | 127 | */ |
123 | 128 | ||
@@ -127,6 +132,7 @@ struct snd_usb_audio { | |||
127 | int index; | 132 | int index; |
128 | struct usb_device *dev; | 133 | struct usb_device *dev; |
129 | snd_card_t *card; | 134 | snd_card_t *card; |
135 | u32 usb_id; | ||
130 | int shutdown; | 136 | int shutdown; |
131 | int num_interfaces; | 137 | int num_interfaces; |
132 | 138 | ||
@@ -136,7 +142,7 @@ struct snd_usb_audio { | |||
136 | struct list_head midi_list; /* list of midi interfaces */ | 142 | struct list_head midi_list; /* list of midi interfaces */ |
137 | int next_midi_device; | 143 | int next_midi_device; |
138 | 144 | ||
139 | unsigned int ignore_ctl_error; /* for mixer */ | 145 | struct list_head mixer_list; /* list of mixer interfaces */ |
140 | }; | 146 | }; |
141 | 147 | ||
142 | /* | 148 | /* |
@@ -219,11 +225,12 @@ void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsub | |||
219 | int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout); | 225 | int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout); |
220 | 226 | ||
221 | int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif); | 227 | int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif); |
228 | void snd_usb_mixer_disconnect(struct list_head *p); | ||
222 | 229 | ||
223 | int snd_usb_create_midi_interface(snd_usb_audio_t *chip, struct usb_interface *iface, const snd_usb_audio_quirk_t *quirk); | 230 | int snd_usb_create_midi_interface(snd_usb_audio_t *chip, struct usb_interface *iface, const snd_usb_audio_quirk_t *quirk); |
224 | void snd_usbmidi_input_stop(struct list_head* p); | 231 | void snd_usbmidi_input_stop(struct list_head* p); |
225 | void snd_usbmidi_input_start(struct list_head* p); | 232 | void snd_usbmidi_input_start(struct list_head* p); |
226 | void snd_usbmidi_disconnect(struct list_head *p, struct usb_driver *driver); | 233 | void snd_usbmidi_disconnect(struct list_head *p); |
227 | 234 | ||
228 | /* | 235 | /* |
229 | * retrieve usb_interface descriptor from the host interface | 236 | * retrieve usb_interface descriptor from the host interface |
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 5d32857ff955..bee70068dce0 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c | |||
@@ -912,7 +912,7 @@ static void snd_usbmidi_free(snd_usb_midi_t* umidi) | |||
912 | /* | 912 | /* |
913 | * Unlinks all URBs (must be done before the usb_device is deleted). | 913 | * Unlinks all URBs (must be done before the usb_device is deleted). |
914 | */ | 914 | */ |
915 | void snd_usbmidi_disconnect(struct list_head* p, struct usb_driver *driver) | 915 | void snd_usbmidi_disconnect(struct list_head* p) |
916 | { | 916 | { |
917 | snd_usb_midi_t* umidi; | 917 | snd_usb_midi_t* umidi; |
918 | int i; | 918 | int i; |
@@ -955,88 +955,87 @@ static snd_rawmidi_substream_t* snd_usbmidi_find_substream(snd_usb_midi_t* umidi | |||
955 | * such as internal control or synthesizer ports. | 955 | * such as internal control or synthesizer ports. |
956 | */ | 956 | */ |
957 | static struct { | 957 | static struct { |
958 | __u16 vendor; | 958 | u32 id; |
959 | __u16 product; | ||
960 | int port; | 959 | int port; |
961 | const char *name_format; | 960 | const char *name_format; |
962 | } snd_usbmidi_port_names[] = { | 961 | } snd_usbmidi_port_names[] = { |
963 | /* Roland UA-100 */ | 962 | /* Roland UA-100 */ |
964 | {0x0582, 0x0000, 2, "%s Control"}, | 963 | { USB_ID(0x0582, 0x0000), 2, "%s Control" }, |
965 | /* Roland SC-8850 */ | 964 | /* Roland SC-8850 */ |
966 | {0x0582, 0x0003, 0, "%s Part A"}, | 965 | { USB_ID(0x0582, 0x0003), 0, "%s Part A" }, |
967 | {0x0582, 0x0003, 1, "%s Part B"}, | 966 | { USB_ID(0x0582, 0x0003), 1, "%s Part B" }, |
968 | {0x0582, 0x0003, 2, "%s Part C"}, | 967 | { USB_ID(0x0582, 0x0003), 2, "%s Part C" }, |
969 | {0x0582, 0x0003, 3, "%s Part D"}, | 968 | { USB_ID(0x0582, 0x0003), 3, "%s Part D" }, |
970 | {0x0582, 0x0003, 4, "%s MIDI 1"}, | 969 | { USB_ID(0x0582, 0x0003), 4, "%s MIDI 1" }, |
971 | {0x0582, 0x0003, 5, "%s MIDI 2"}, | 970 | { USB_ID(0x0582, 0x0003), 5, "%s MIDI 2" }, |
972 | /* Roland U-8 */ | 971 | /* Roland U-8 */ |
973 | {0x0582, 0x0004, 0, "%s MIDI"}, | 972 | { USB_ID(0x0582, 0x0004), 0, "%s MIDI" }, |
974 | {0x0582, 0x0004, 1, "%s Control"}, | 973 | { USB_ID(0x0582, 0x0004), 1, "%s Control" }, |
975 | /* Roland SC-8820 */ | 974 | /* Roland SC-8820 */ |
976 | {0x0582, 0x0007, 0, "%s Part A"}, | 975 | { USB_ID(0x0582, 0x0007), 0, "%s Part A" }, |
977 | {0x0582, 0x0007, 1, "%s Part B"}, | 976 | { USB_ID(0x0582, 0x0007), 1, "%s Part B" }, |
978 | {0x0582, 0x0007, 2, "%s MIDI"}, | 977 | { USB_ID(0x0582, 0x0007), 2, "%s MIDI" }, |
979 | /* Roland SK-500 */ | 978 | /* Roland SK-500 */ |
980 | {0x0582, 0x000b, 0, "%s Part A"}, | 979 | { USB_ID(0x0582, 0x000b), 0, "%s Part A" }, |
981 | {0x0582, 0x000b, 1, "%s Part B"}, | 980 | { USB_ID(0x0582, 0x000b), 1, "%s Part B" }, |
982 | {0x0582, 0x000b, 2, "%s MIDI"}, | 981 | { USB_ID(0x0582, 0x000b), 2, "%s MIDI" }, |
983 | /* Roland SC-D70 */ | 982 | /* Roland SC-D70 */ |
984 | {0x0582, 0x000c, 0, "%s Part A"}, | 983 | { USB_ID(0x0582, 0x000c), 0, "%s Part A" }, |
985 | {0x0582, 0x000c, 1, "%s Part B"}, | 984 | { USB_ID(0x0582, 0x000c), 1, "%s Part B" }, |
986 | {0x0582, 0x000c, 2, "%s MIDI"}, | 985 | { USB_ID(0x0582, 0x000c), 2, "%s MIDI" }, |
987 | /* Edirol UM-880 */ | 986 | /* Edirol UM-880 */ |
988 | {0x0582, 0x0014, 8, "%s Control"}, | 987 | { USB_ID(0x0582, 0x0014), 8, "%s Control" }, |
989 | /* Edirol SD-90 */ | 988 | /* Edirol SD-90 */ |
990 | {0x0582, 0x0016, 0, "%s Part A"}, | 989 | { USB_ID(0x0582, 0x0016), 0, "%s Part A" }, |
991 | {0x0582, 0x0016, 1, "%s Part B"}, | 990 | { USB_ID(0x0582, 0x0016), 1, "%s Part B" }, |
992 | {0x0582, 0x0016, 2, "%s MIDI 1"}, | 991 | { USB_ID(0x0582, 0x0016), 2, "%s MIDI 1" }, |
993 | {0x0582, 0x0016, 3, "%s MIDI 2"}, | 992 | { USB_ID(0x0582, 0x0016), 3, "%s MIDI 2" }, |
994 | /* Edirol UM-550 */ | 993 | /* Edirol UM-550 */ |
995 | {0x0582, 0x0023, 5, "%s Control"}, | 994 | { USB_ID(0x0582, 0x0023), 5, "%s Control" }, |
996 | /* Edirol SD-20 */ | 995 | /* Edirol SD-20 */ |
997 | {0x0582, 0x0027, 0, "%s Part A"}, | 996 | { USB_ID(0x0582, 0x0027), 0, "%s Part A" }, |
998 | {0x0582, 0x0027, 1, "%s Part B"}, | 997 | { USB_ID(0x0582, 0x0027), 1, "%s Part B" }, |
999 | {0x0582, 0x0027, 2, "%s MIDI"}, | 998 | { USB_ID(0x0582, 0x0027), 2, "%s MIDI" }, |
1000 | /* Edirol SD-80 */ | 999 | /* Edirol SD-80 */ |
1001 | {0x0582, 0x0029, 0, "%s Part A"}, | 1000 | { USB_ID(0x0582, 0x0029), 0, "%s Part A" }, |
1002 | {0x0582, 0x0029, 1, "%s Part B"}, | 1001 | { USB_ID(0x0582, 0x0029), 1, "%s Part B" }, |
1003 | {0x0582, 0x0029, 2, "%s MIDI 1"}, | 1002 | { USB_ID(0x0582, 0x0029), 2, "%s MIDI 1" }, |
1004 | {0x0582, 0x0029, 3, "%s MIDI 2"}, | 1003 | { USB_ID(0x0582, 0x0029), 3, "%s MIDI 2" }, |
1005 | /* Edirol UA-700 */ | 1004 | /* Edirol UA-700 */ |
1006 | {0x0582, 0x002b, 0, "%s MIDI"}, | 1005 | { USB_ID(0x0582, 0x002b), 0, "%s MIDI" }, |
1007 | {0x0582, 0x002b, 1, "%s Control"}, | 1006 | { USB_ID(0x0582, 0x002b), 1, "%s Control" }, |
1008 | /* Roland VariOS */ | 1007 | /* Roland VariOS */ |
1009 | {0x0582, 0x002f, 0, "%s MIDI"}, | 1008 | { USB_ID(0x0582, 0x002f), 0, "%s MIDI" }, |
1010 | {0x0582, 0x002f, 1, "%s External MIDI"}, | 1009 | { USB_ID(0x0582, 0x002f), 1, "%s External MIDI" }, |
1011 | {0x0582, 0x002f, 2, "%s Sync"}, | 1010 | { USB_ID(0x0582, 0x002f), 2, "%s Sync" }, |
1012 | /* Edirol PCR */ | 1011 | /* Edirol PCR */ |
1013 | {0x0582, 0x0033, 0, "%s MIDI"}, | 1012 | { USB_ID(0x0582, 0x0033), 0, "%s MIDI" }, |
1014 | {0x0582, 0x0033, 1, "%s 1"}, | 1013 | { USB_ID(0x0582, 0x0033), 1, "%s 1" }, |
1015 | {0x0582, 0x0033, 2, "%s 2"}, | 1014 | { USB_ID(0x0582, 0x0033), 2, "%s 2" }, |
1016 | /* BOSS GS-10 */ | 1015 | /* BOSS GS-10 */ |
1017 | {0x0582, 0x003b, 0, "%s MIDI"}, | 1016 | { USB_ID(0x0582, 0x003b), 0, "%s MIDI" }, |
1018 | {0x0582, 0x003b, 1, "%s Control"}, | 1017 | { USB_ID(0x0582, 0x003b), 1, "%s Control" }, |
1019 | /* Edirol UA-1000 */ | 1018 | /* Edirol UA-1000 */ |
1020 | {0x0582, 0x0044, 0, "%s MIDI"}, | 1019 | { USB_ID(0x0582, 0x0044), 0, "%s MIDI" }, |
1021 | {0x0582, 0x0044, 1, "%s Control"}, | 1020 | { USB_ID(0x0582, 0x0044), 1, "%s Control" }, |
1022 | /* Edirol UR-80 */ | 1021 | /* Edirol UR-80 */ |
1023 | {0x0582, 0x0048, 0, "%s MIDI"}, | 1022 | { USB_ID(0x0582, 0x0048), 0, "%s MIDI" }, |
1024 | {0x0582, 0x0048, 1, "%s 1"}, | 1023 | { USB_ID(0x0582, 0x0048), 1, "%s 1" }, |
1025 | {0x0582, 0x0048, 2, "%s 2"}, | 1024 | { USB_ID(0x0582, 0x0048), 2, "%s 2" }, |
1026 | /* Edirol PCR-A */ | 1025 | /* Edirol PCR-A */ |
1027 | {0x0582, 0x004d, 0, "%s MIDI"}, | 1026 | { USB_ID(0x0582, 0x004d), 0, "%s MIDI" }, |
1028 | {0x0582, 0x004d, 1, "%s 1"}, | 1027 | { USB_ID(0x0582, 0x004d), 1, "%s 1" }, |
1029 | {0x0582, 0x004d, 2, "%s 2"}, | 1028 | { USB_ID(0x0582, 0x004d), 2, "%s 2" }, |
1030 | /* M-Audio MidiSport 8x8 */ | 1029 | /* M-Audio MidiSport 8x8 */ |
1031 | {0x0763, 0x1031, 8, "%s Control"}, | 1030 | { USB_ID(0x0763, 0x1031), 8, "%s Control" }, |
1032 | {0x0763, 0x1033, 8, "%s Control"}, | 1031 | { USB_ID(0x0763, 0x1033), 8, "%s Control" }, |
1033 | /* MOTU Fastlane */ | 1032 | /* MOTU Fastlane */ |
1034 | {0x07fd, 0x0001, 0, "%s MIDI A"}, | 1033 | { USB_ID(0x07fd, 0x0001), 0, "%s MIDI A" }, |
1035 | {0x07fd, 0x0001, 1, "%s MIDI B"}, | 1034 | { USB_ID(0x07fd, 0x0001), 1, "%s MIDI B" }, |
1036 | /* Emagic Unitor8/AMT8/MT4 */ | 1035 | /* Emagic Unitor8/AMT8/MT4 */ |
1037 | {0x086a, 0x0001, 8, "%s Broadcast"}, | 1036 | { USB_ID(0x086a, 0x0001), 8, "%s Broadcast" }, |
1038 | {0x086a, 0x0002, 8, "%s Broadcast"}, | 1037 | { USB_ID(0x086a, 0x0002), 8, "%s Broadcast" }, |
1039 | {0x086a, 0x0003, 4, "%s Broadcast"}, | 1038 | { USB_ID(0x086a, 0x0003), 4, "%s Broadcast" }, |
1040 | }; | 1039 | }; |
1041 | 1040 | ||
1042 | static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, | 1041 | static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, |
@@ -1044,7 +1043,6 @@ static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, | |||
1044 | snd_rawmidi_substream_t** rsubstream) | 1043 | snd_rawmidi_substream_t** rsubstream) |
1045 | { | 1044 | { |
1046 | int i; | 1045 | int i; |
1047 | __u16 vendor, product; | ||
1048 | const char *name_format; | 1046 | const char *name_format; |
1049 | 1047 | ||
1050 | snd_rawmidi_substream_t* substream = snd_usbmidi_find_substream(umidi, stream, number); | 1048 | snd_rawmidi_substream_t* substream = snd_usbmidi_find_substream(umidi, stream, number); |
@@ -1055,11 +1053,8 @@ static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, | |||
1055 | 1053 | ||
1056 | /* TODO: read port name from jack descriptor */ | 1054 | /* TODO: read port name from jack descriptor */ |
1057 | name_format = "%s MIDI %d"; | 1055 | name_format = "%s MIDI %d"; |
1058 | vendor = le16_to_cpu(umidi->chip->dev->descriptor.idVendor); | ||
1059 | product = le16_to_cpu(umidi->chip->dev->descriptor.idProduct); | ||
1060 | for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_names); ++i) { | 1056 | for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_names); ++i) { |
1061 | if (snd_usbmidi_port_names[i].vendor == vendor && | 1057 | if (snd_usbmidi_port_names[i].id == umidi->chip->usb_id && |
1062 | snd_usbmidi_port_names[i].product == product && | ||
1063 | snd_usbmidi_port_names[i].port == number) { | 1058 | snd_usbmidi_port_names[i].port == number) { |
1064 | name_format = snd_usbmidi_port_names[i].name_format; | 1059 | name_format = snd_usbmidi_port_names[i].name_format; |
1065 | break; | 1060 | break; |
@@ -1226,9 +1221,12 @@ static int snd_usbmidi_detect_endpoints(snd_usb_midi_t* umidi, | |||
1226 | struct usb_endpoint_descriptor* epd; | 1221 | struct usb_endpoint_descriptor* epd; |
1227 | int i, out_eps = 0, in_eps = 0; | 1222 | int i, out_eps = 0, in_eps = 0; |
1228 | 1223 | ||
1229 | if (le16_to_cpu(umidi->chip->dev->descriptor.idVendor) == 0x0582) | 1224 | if (USB_ID_VENDOR(umidi->chip->usb_id) == 0x0582) |
1230 | snd_usbmidi_switch_roland_altsetting(umidi); | 1225 | snd_usbmidi_switch_roland_altsetting(umidi); |
1231 | 1226 | ||
1227 | if (endpoint[0].out_ep || endpoint[0].in_ep) | ||
1228 | return 0; | ||
1229 | |||
1232 | intf = umidi->iface; | 1230 | intf = umidi->iface; |
1233 | if (!intf || intf->num_altsetting < 1) | 1231 | if (!intf || intf->num_altsetting < 1) |
1234 | return -ENOENT; | 1232 | return -ENOENT; |
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index 5f1906915aa6..e73c1c9d3e73 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -35,10 +35,11 @@ | |||
35 | #include <linux/usb.h> | 35 | #include <linux/usb.h> |
36 | #include <sound/core.h> | 36 | #include <sound/core.h> |
37 | #include <sound/control.h> | 37 | #include <sound/control.h> |
38 | #include <sound/hwdep.h> | ||
39 | #include <sound/info.h> | ||
38 | 40 | ||
39 | #include "usbaudio.h" | 41 | #include "usbaudio.h" |
40 | 42 | ||
41 | |||
42 | /* | 43 | /* |
43 | */ | 44 | */ |
44 | 45 | ||
@@ -50,6 +51,31 @@ typedef struct usb_audio_term usb_audio_term_t; | |||
50 | typedef struct usb_mixer_elem_info usb_mixer_elem_info_t; | 51 | typedef struct usb_mixer_elem_info usb_mixer_elem_info_t; |
51 | 52 | ||
52 | 53 | ||
54 | struct usb_mixer_interface { | ||
55 | snd_usb_audio_t *chip; | ||
56 | unsigned int ctrlif; | ||
57 | struct list_head list; | ||
58 | unsigned int ignore_ctl_error; | ||
59 | struct urb *urb; | ||
60 | usb_mixer_elem_info_t **id_elems; /* array[256], indexed by unit id */ | ||
61 | |||
62 | /* Sound Blaster remote control stuff */ | ||
63 | enum { | ||
64 | RC_NONE, | ||
65 | RC_EXTIGY, | ||
66 | RC_AUDIGY2NX, | ||
67 | } rc_type; | ||
68 | unsigned long rc_hwdep_open; | ||
69 | u32 rc_code; | ||
70 | wait_queue_head_t rc_waitq; | ||
71 | struct urb *rc_urb; | ||
72 | struct usb_ctrlrequest *rc_setup_packet; | ||
73 | u8 rc_buffer[6]; | ||
74 | |||
75 | u8 audigy2nx_leds[3]; | ||
76 | }; | ||
77 | |||
78 | |||
53 | struct usb_audio_term { | 79 | struct usb_audio_term { |
54 | int id; | 80 | int id; |
55 | int type; | 81 | int type; |
@@ -62,26 +88,26 @@ struct usbmix_name_map; | |||
62 | 88 | ||
63 | struct usb_mixer_build { | 89 | struct usb_mixer_build { |
64 | snd_usb_audio_t *chip; | 90 | snd_usb_audio_t *chip; |
91 | struct usb_mixer_interface *mixer; | ||
65 | unsigned char *buffer; | 92 | unsigned char *buffer; |
66 | unsigned int buflen; | 93 | unsigned int buflen; |
67 | unsigned int ctrlif; | 94 | DECLARE_BITMAP(unitbitmap, 256); |
68 | unsigned short vendor; | ||
69 | unsigned short product; | ||
70 | DECLARE_BITMAP(unitbitmap, 32*32); | ||
71 | usb_audio_term_t oterm; | 95 | usb_audio_term_t oterm; |
72 | const struct usbmix_name_map *map; | 96 | const struct usbmix_name_map *map; |
97 | const struct usbmix_selector_map *selector_map; | ||
73 | }; | 98 | }; |
74 | 99 | ||
75 | struct usb_mixer_elem_info { | 100 | struct usb_mixer_elem_info { |
76 | snd_usb_audio_t *chip; | 101 | struct usb_mixer_interface *mixer; |
77 | unsigned int ctrlif; | 102 | usb_mixer_elem_info_t *next_id_elem; /* list of controls with same id */ |
103 | snd_ctl_elem_id_t *elem_id; | ||
78 | unsigned int id; | 104 | unsigned int id; |
79 | unsigned int control; /* CS or ICN (high byte) */ | 105 | unsigned int control; /* CS or ICN (high byte) */ |
80 | unsigned int cmask; /* channel mask bitmap: 0 = master */ | 106 | unsigned int cmask; /* channel mask bitmap: 0 = master */ |
81 | int channels; | 107 | int channels; |
82 | int val_type; | 108 | int val_type; |
83 | int min, max, res; | 109 | int min, max, res; |
84 | unsigned int initialized: 1; | 110 | u8 initialized; |
85 | }; | 111 | }; |
86 | 112 | ||
87 | 113 | ||
@@ -187,6 +213,21 @@ static int check_ignored_ctl(mixer_build_t *state, int unitid, int control) | |||
187 | return 0; | 213 | return 0; |
188 | } | 214 | } |
189 | 215 | ||
216 | /* get the mapped selector source name */ | ||
217 | static int check_mapped_selector_name(mixer_build_t *state, int unitid, | ||
218 | int index, char *buf, int buflen) | ||
219 | { | ||
220 | const struct usbmix_selector_map *p; | ||
221 | |||
222 | if (! state->selector_map) | ||
223 | return 0; | ||
224 | for (p = state->selector_map; p->id; p++) { | ||
225 | if (p->id == unitid && index < p->count) | ||
226 | return strlcpy(buf, p->names[index], buflen); | ||
227 | } | ||
228 | return 0; | ||
229 | } | ||
230 | |||
190 | /* | 231 | /* |
191 | * find an audio control unit with the given unit id | 232 | * find an audio control unit with the given unit id |
192 | */ | 233 | */ |
@@ -301,16 +342,18 @@ static int get_ctl_value(usb_mixer_elem_info_t *cval, int request, int validx, i | |||
301 | int timeout = 10; | 342 | int timeout = 10; |
302 | 343 | ||
303 | while (timeout-- > 0) { | 344 | while (timeout-- > 0) { |
304 | if (snd_usb_ctl_msg(cval->chip->dev, usb_rcvctrlpipe(cval->chip->dev, 0), | 345 | if (snd_usb_ctl_msg(cval->mixer->chip->dev, |
346 | usb_rcvctrlpipe(cval->mixer->chip->dev, 0), | ||
305 | request, | 347 | request, |
306 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, | 348 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, |
307 | validx, cval->ctrlif | (cval->id << 8), | 349 | validx, cval->mixer->ctrlif | (cval->id << 8), |
308 | buf, val_len, 100) >= 0) { | 350 | buf, val_len, 100) >= 0) { |
309 | *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); | 351 | *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); |
310 | return 0; | 352 | return 0; |
311 | } | 353 | } |
312 | } | 354 | } |
313 | snd_printdd(KERN_ERR "cannot get ctl value: req = 0x%x, wValue = 0x%x, wIndex = 0x%x, type = %d\n", request, validx, cval->ctrlif | (cval->id << 8), cval->val_type); | 355 | snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", |
356 | request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); | ||
314 | return -EINVAL; | 357 | return -EINVAL; |
315 | } | 358 | } |
316 | 359 | ||
@@ -339,13 +382,15 @@ static int set_ctl_value(usb_mixer_elem_info_t *cval, int request, int validx, i | |||
339 | buf[0] = value_set & 0xff; | 382 | buf[0] = value_set & 0xff; |
340 | buf[1] = (value_set >> 8) & 0xff; | 383 | buf[1] = (value_set >> 8) & 0xff; |
341 | while (timeout -- > 0) | 384 | while (timeout -- > 0) |
342 | if (snd_usb_ctl_msg(cval->chip->dev, usb_sndctrlpipe(cval->chip->dev, 0), | 385 | if (snd_usb_ctl_msg(cval->mixer->chip->dev, |
386 | usb_sndctrlpipe(cval->mixer->chip->dev, 0), | ||
343 | request, | 387 | request, |
344 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, | 388 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, |
345 | validx, cval->ctrlif | (cval->id << 8), | 389 | validx, cval->mixer->ctrlif | (cval->id << 8), |
346 | buf, val_len, 100) >= 0) | 390 | buf, val_len, 100) >= 0) |
347 | return 0; | 391 | return 0; |
348 | snd_printdd(KERN_ERR "cannot set ctl value: req = 0x%x, wValue = 0x%x, wIndex = 0x%x, type = %d, data = 0x%x/0x%x\n", request, validx, cval->ctrlif | (cval->id << 8), cval->val_type, buf[0], buf[1]); | 392 | snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", |
393 | request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type, buf[0], buf[1]); | ||
349 | return -EINVAL; | 394 | return -EINVAL; |
350 | } | 395 | } |
351 | 396 | ||
@@ -385,16 +430,22 @@ static int check_matrix_bitmap(unsigned char *bmap, int ich, int och, int num_ou | |||
385 | * if failed, give up and free the control instance. | 430 | * if failed, give up and free the control instance. |
386 | */ | 431 | */ |
387 | 432 | ||
388 | static int add_control_to_empty(snd_card_t *card, snd_kcontrol_t *kctl) | 433 | static int add_control_to_empty(mixer_build_t *state, snd_kcontrol_t *kctl) |
389 | { | 434 | { |
435 | usb_mixer_elem_info_t *cval = kctl->private_data; | ||
390 | int err; | 436 | int err; |
391 | while (snd_ctl_find_id(card, &kctl->id)) | 437 | |
438 | while (snd_ctl_find_id(state->chip->card, &kctl->id)) | ||
392 | kctl->id.index++; | 439 | kctl->id.index++; |
393 | if ((err = snd_ctl_add(card, kctl)) < 0) { | 440 | if ((err = snd_ctl_add(state->chip->card, kctl)) < 0) { |
394 | snd_printd(KERN_ERR "cannot add control (err = %d)\n", err); | 441 | snd_printd(KERN_ERR "cannot add control (err = %d)\n", err); |
395 | snd_ctl_free_one(kctl); | 442 | snd_ctl_free_one(kctl); |
443 | return err; | ||
396 | } | 444 | } |
397 | return err; | 445 | cval->elem_id = &kctl->id; |
446 | cval->next_id_elem = state->mixer->id_elems[cval->id]; | ||
447 | state->mixer->id_elems[cval->id] = cval; | ||
448 | return 0; | ||
398 | } | 449 | } |
399 | 450 | ||
400 | 451 | ||
@@ -572,10 +623,8 @@ static struct usb_feature_control_info audio_feature_info[] = { | |||
572 | /* private_free callback */ | 623 | /* private_free callback */ |
573 | static void usb_mixer_elem_free(snd_kcontrol_t *kctl) | 624 | static void usb_mixer_elem_free(snd_kcontrol_t *kctl) |
574 | { | 625 | { |
575 | if (kctl->private_data) { | 626 | kfree(kctl->private_data); |
576 | kfree(kctl->private_data); | 627 | kctl->private_data = NULL; |
577 | kctl->private_data = NULL; | ||
578 | } | ||
579 | } | 628 | } |
580 | 629 | ||
581 | 630 | ||
@@ -608,7 +657,8 @@ static int get_min_max(usb_mixer_elem_info_t *cval, int default_min) | |||
608 | } | 657 | } |
609 | if (get_ctl_value(cval, GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || | 658 | if (get_ctl_value(cval, GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || |
610 | get_ctl_value(cval, GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { | 659 | get_ctl_value(cval, GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { |
611 | snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", cval->id, cval->ctrlif, cval->control, cval->id); | 660 | snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", |
661 | cval->id, cval->mixer->ctrlif, cval->control, cval->id); | ||
612 | return -EINVAL; | 662 | return -EINVAL; |
613 | } | 663 | } |
614 | if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { | 664 | if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { |
@@ -668,7 +718,7 @@ static int mixer_ctl_feature_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
668 | if (cval->cmask & (1 << c)) { | 718 | if (cval->cmask & (1 << c)) { |
669 | err = get_cur_mix_value(cval, c + 1, &val); | 719 | err = get_cur_mix_value(cval, c + 1, &val); |
670 | if (err < 0) { | 720 | if (err < 0) { |
671 | if (cval->chip->ignore_ctl_error) { | 721 | if (cval->mixer->ignore_ctl_error) { |
672 | ucontrol->value.integer.value[0] = cval->min; | 722 | ucontrol->value.integer.value[0] = cval->min; |
673 | return 0; | 723 | return 0; |
674 | } | 724 | } |
@@ -684,7 +734,7 @@ static int mixer_ctl_feature_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
684 | /* master channel */ | 734 | /* master channel */ |
685 | err = get_cur_mix_value(cval, 0, &val); | 735 | err = get_cur_mix_value(cval, 0, &val); |
686 | if (err < 0) { | 736 | if (err < 0) { |
687 | if (cval->chip->ignore_ctl_error) { | 737 | if (cval->mixer->ignore_ctl_error) { |
688 | ucontrol->value.integer.value[0] = cval->min; | 738 | ucontrol->value.integer.value[0] = cval->min; |
689 | return 0; | 739 | return 0; |
690 | } | 740 | } |
@@ -710,7 +760,7 @@ static int mixer_ctl_feature_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
710 | if (cval->cmask & (1 << c)) { | 760 | if (cval->cmask & (1 << c)) { |
711 | err = get_cur_mix_value(cval, c + 1, &oval); | 761 | err = get_cur_mix_value(cval, c + 1, &oval); |
712 | if (err < 0) { | 762 | if (err < 0) { |
713 | if (cval->chip->ignore_ctl_error) | 763 | if (cval->mixer->ignore_ctl_error) |
714 | return 0; | 764 | return 0; |
715 | return err; | 765 | return err; |
716 | } | 766 | } |
@@ -727,7 +777,7 @@ static int mixer_ctl_feature_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
727 | } else { | 777 | } else { |
728 | /* master channel */ | 778 | /* master channel */ |
729 | err = get_cur_mix_value(cval, 0, &oval); | 779 | err = get_cur_mix_value(cval, 0, &oval); |
730 | if (err < 0 && cval->chip->ignore_ctl_error) | 780 | if (err < 0 && cval->mixer->ignore_ctl_error) |
731 | return 0; | 781 | return 0; |
732 | if (err < 0) | 782 | if (err < 0) |
733 | return err; | 783 | return err; |
@@ -779,8 +829,7 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc, | |||
779 | snd_printk(KERN_ERR "cannot malloc kcontrol\n"); | 829 | snd_printk(KERN_ERR "cannot malloc kcontrol\n"); |
780 | return; | 830 | return; |
781 | } | 831 | } |
782 | cval->chip = state->chip; | 832 | cval->mixer = state->mixer; |
783 | cval->ctrlif = state->ctrlif; | ||
784 | cval->id = unitid; | 833 | cval->id = unitid; |
785 | cval->control = control; | 834 | cval->control = control; |
786 | cval->cmask = ctl_mask; | 835 | cval->cmask = ctl_mask; |
@@ -855,16 +904,21 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc, | |||
855 | /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */ | 904 | /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */ |
856 | /* is not very clear from datasheets */ | 905 | /* is not very clear from datasheets */ |
857 | /* I hope that the min value is -15360 for newer firmware --jk */ | 906 | /* I hope that the min value is -15360 for newer firmware --jk */ |
858 | if (((state->vendor == 0x471 && (state->product == 0x104 || state->product == 0x105 || state->product == 0x101)) || | 907 | switch (state->chip->usb_id) { |
859 | (state->vendor == 0x672 && state->product == 0x1041)) && !strcmp(kctl->id.name, "PCM Playback Volume") && | 908 | case USB_ID(0x0471, 0x0101): |
860 | cval->min == -15616) { | 909 | case USB_ID(0x0471, 0x0104): |
861 | snd_printk("USB Audio: using volume control quirk for the UDA1321/N101 chip\n"); | 910 | case USB_ID(0x0471, 0x0105): |
862 | cval->max = -256; | 911 | case USB_ID(0x0672, 0x1041): |
912 | if (!strcmp(kctl->id.name, "PCM Playback Volume") && | ||
913 | cval->min == -15616) { | ||
914 | snd_printk("using volume control quirk for the UDA1321/N101 chip\n"); | ||
915 | cval->max = -256; | ||
916 | } | ||
863 | } | 917 | } |
864 | 918 | ||
865 | snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", | 919 | snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", |
866 | cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res); | 920 | cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res); |
867 | add_control_to_empty(state->chip->card, kctl); | 921 | add_control_to_empty(state, kctl); |
868 | } | 922 | } |
869 | 923 | ||
870 | 924 | ||
@@ -947,8 +1001,7 @@ static void build_mixer_unit_ctl(mixer_build_t *state, unsigned char *desc, | |||
947 | if (! cval) | 1001 | if (! cval) |
948 | return; | 1002 | return; |
949 | 1003 | ||
950 | cval->chip = state->chip; | 1004 | cval->mixer = state->mixer; |
951 | cval->ctrlif = state->ctrlif; | ||
952 | cval->id = unitid; | 1005 | cval->id = unitid; |
953 | cval->control = in_ch + 1; /* based on 1 */ | 1006 | cval->control = in_ch + 1; /* based on 1 */ |
954 | cval->val_type = USB_MIXER_S16; | 1007 | cval->val_type = USB_MIXER_S16; |
@@ -979,7 +1032,7 @@ static void build_mixer_unit_ctl(mixer_build_t *state, unsigned char *desc, | |||
979 | 1032 | ||
980 | snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n", | 1033 | snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n", |
981 | cval->id, kctl->id.name, cval->channels, cval->min, cval->max); | 1034 | cval->id, kctl->id.name, cval->channels, cval->min, cval->max); |
982 | add_control_to_empty(state->chip->card, kctl); | 1035 | add_control_to_empty(state, kctl); |
983 | } | 1036 | } |
984 | 1037 | ||
985 | 1038 | ||
@@ -1042,7 +1095,7 @@ static int mixer_ctl_procunit_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
1042 | int err, val; | 1095 | int err, val; |
1043 | 1096 | ||
1044 | err = get_cur_ctl_value(cval, cval->control << 8, &val); | 1097 | err = get_cur_ctl_value(cval, cval->control << 8, &val); |
1045 | if (err < 0 && cval->chip->ignore_ctl_error) { | 1098 | if (err < 0 && cval->mixer->ignore_ctl_error) { |
1046 | ucontrol->value.integer.value[0] = cval->min; | 1099 | ucontrol->value.integer.value[0] = cval->min; |
1047 | return 0; | 1100 | return 0; |
1048 | } | 1101 | } |
@@ -1061,7 +1114,7 @@ static int mixer_ctl_procunit_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
1061 | 1114 | ||
1062 | err = get_cur_ctl_value(cval, cval->control << 8, &oval); | 1115 | err = get_cur_ctl_value(cval, cval->control << 8, &oval); |
1063 | if (err < 0) { | 1116 | if (err < 0) { |
1064 | if (cval->chip->ignore_ctl_error) | 1117 | if (cval->mixer->ignore_ctl_error) |
1065 | return 0; | 1118 | return 0; |
1066 | return err; | 1119 | return err; |
1067 | } | 1120 | } |
@@ -1179,9 +1232,6 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char | |||
1179 | } | 1232 | } |
1180 | 1233 | ||
1181 | type = combine_word(&dsc[4]); | 1234 | type = combine_word(&dsc[4]); |
1182 | if (! type) | ||
1183 | return 0; /* undefined? */ | ||
1184 | |||
1185 | for (info = list; info && info->type; info++) | 1235 | for (info = list; info && info->type; info++) |
1186 | if (info->type == type) | 1236 | if (info->type == type) |
1187 | break; | 1237 | break; |
@@ -1199,8 +1249,7 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char | |||
1199 | snd_printk(KERN_ERR "cannot malloc kcontrol\n"); | 1249 | snd_printk(KERN_ERR "cannot malloc kcontrol\n"); |
1200 | return -ENOMEM; | 1250 | return -ENOMEM; |
1201 | } | 1251 | } |
1202 | cval->chip = state->chip; | 1252 | cval->mixer = state->mixer; |
1203 | cval->ctrlif = state->ctrlif; | ||
1204 | cval->id = unitid; | 1253 | cval->id = unitid; |
1205 | cval->control = valinfo->control; | 1254 | cval->control = valinfo->control; |
1206 | cval->val_type = valinfo->val_type; | 1255 | cval->val_type = valinfo->val_type; |
@@ -1241,7 +1290,7 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char | |||
1241 | 1290 | ||
1242 | snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n", | 1291 | snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n", |
1243 | cval->id, kctl->id.name, cval->channels, cval->min, cval->max); | 1292 | cval->id, kctl->id.name, cval->channels, cval->min, cval->max); |
1244 | if ((err = add_control_to_empty(state->chip->card, kctl)) < 0) | 1293 | if ((err = add_control_to_empty(state, kctl)) < 0) |
1245 | return err; | 1294 | return err; |
1246 | } | 1295 | } |
1247 | return 0; | 1296 | return 0; |
@@ -1289,7 +1338,7 @@ static int mixer_ctl_selector_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
1289 | 1338 | ||
1290 | err = get_cur_ctl_value(cval, 0, &val); | 1339 | err = get_cur_ctl_value(cval, 0, &val); |
1291 | if (err < 0) { | 1340 | if (err < 0) { |
1292 | if (cval->chip->ignore_ctl_error) { | 1341 | if (cval->mixer->ignore_ctl_error) { |
1293 | ucontrol->value.enumerated.item[0] = 0; | 1342 | ucontrol->value.enumerated.item[0] = 0; |
1294 | return 0; | 1343 | return 0; |
1295 | } | 1344 | } |
@@ -1308,7 +1357,7 @@ static int mixer_ctl_selector_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t | |||
1308 | 1357 | ||
1309 | err = get_cur_ctl_value(cval, 0, &oval); | 1358 | err = get_cur_ctl_value(cval, 0, &oval); |
1310 | if (err < 0) { | 1359 | if (err < 0) { |
1311 | if (cval->chip->ignore_ctl_error) | 1360 | if (cval->mixer->ignore_ctl_error) |
1312 | return 0; | 1361 | return 0; |
1313 | return err; | 1362 | return err; |
1314 | } | 1363 | } |
@@ -1386,8 +1435,7 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned | |||
1386 | snd_printk(KERN_ERR "cannot malloc kcontrol\n"); | 1435 | snd_printk(KERN_ERR "cannot malloc kcontrol\n"); |
1387 | return -ENOMEM; | 1436 | return -ENOMEM; |
1388 | } | 1437 | } |
1389 | cval->chip = state->chip; | 1438 | cval->mixer = state->mixer; |
1390 | cval->ctrlif = state->ctrlif; | ||
1391 | cval->id = unitid; | 1439 | cval->id = unitid; |
1392 | cval->val_type = USB_MIXER_U8; | 1440 | cval->val_type = USB_MIXER_U8; |
1393 | cval->channels = 1; | 1441 | cval->channels = 1; |
@@ -1415,7 +1463,9 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned | |||
1415 | kfree(cval); | 1463 | kfree(cval); |
1416 | return -ENOMEM; | 1464 | return -ENOMEM; |
1417 | } | 1465 | } |
1418 | if (check_input_term(state, desc[5 + i], &iterm) >= 0) | 1466 | len = check_mapped_selector_name(state, unitid, i, namelist[i], |
1467 | MAX_ITEM_NAME_LEN); | ||
1468 | if (! len && check_input_term(state, desc[5 + i], &iterm) >= 0) | ||
1419 | len = get_term_name(state, &iterm, namelist[i], MAX_ITEM_NAME_LEN, 0); | 1469 | len = get_term_name(state, &iterm, namelist[i], MAX_ITEM_NAME_LEN, 0); |
1420 | if (! len) | 1470 | if (! len) |
1421 | sprintf(namelist[i], "Input %d", i); | 1471 | sprintf(namelist[i], "Input %d", i); |
@@ -1450,7 +1500,7 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned | |||
1450 | 1500 | ||
1451 | snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n", | 1501 | snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n", |
1452 | cval->id, kctl->id.name, num_ins); | 1502 | cval->id, kctl->id.name, num_ins); |
1453 | if ((err = add_control_to_empty(state->chip->card, kctl)) < 0) | 1503 | if ((err = add_control_to_empty(state, kctl)) < 0) |
1454 | return err; | 1504 | return err; |
1455 | 1505 | ||
1456 | return 0; | 1506 | return 0; |
@@ -1493,41 +1543,55 @@ static int parse_audio_unit(mixer_build_t *state, int unitid) | |||
1493 | } | 1543 | } |
1494 | } | 1544 | } |
1495 | 1545 | ||
1546 | static void snd_usb_mixer_free(struct usb_mixer_interface *mixer) | ||
1547 | { | ||
1548 | kfree(mixer->id_elems); | ||
1549 | if (mixer->urb) { | ||
1550 | kfree(mixer->urb->transfer_buffer); | ||
1551 | usb_free_urb(mixer->urb); | ||
1552 | } | ||
1553 | if (mixer->rc_urb) | ||
1554 | usb_free_urb(mixer->rc_urb); | ||
1555 | kfree(mixer->rc_setup_packet); | ||
1556 | kfree(mixer); | ||
1557 | } | ||
1558 | |||
1559 | static int snd_usb_mixer_dev_free(snd_device_t *device) | ||
1560 | { | ||
1561 | struct usb_mixer_interface *mixer = device->device_data; | ||
1562 | snd_usb_mixer_free(mixer); | ||
1563 | return 0; | ||
1564 | } | ||
1565 | |||
1496 | /* | 1566 | /* |
1497 | * create mixer controls | 1567 | * create mixer controls |
1498 | * | 1568 | * |
1499 | * walk through all OUTPUT_TERMINAL descriptors to search for mixers | 1569 | * walk through all OUTPUT_TERMINAL descriptors to search for mixers |
1500 | */ | 1570 | */ |
1501 | int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) | 1571 | static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) |
1502 | { | 1572 | { |
1503 | unsigned char *desc; | 1573 | unsigned char *desc; |
1504 | mixer_build_t state; | 1574 | mixer_build_t state; |
1505 | int err; | 1575 | int err; |
1506 | const struct usbmix_ctl_map *map; | 1576 | const struct usbmix_ctl_map *map; |
1507 | struct usb_device_descriptor *dev = &chip->dev->descriptor; | 1577 | struct usb_host_interface *hostif; |
1508 | struct usb_host_interface *hostif = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0]; | ||
1509 | |||
1510 | strcpy(chip->card->mixername, "USB Mixer"); | ||
1511 | 1578 | ||
1579 | hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; | ||
1512 | memset(&state, 0, sizeof(state)); | 1580 | memset(&state, 0, sizeof(state)); |
1513 | state.chip = chip; | 1581 | state.chip = mixer->chip; |
1582 | state.mixer = mixer; | ||
1514 | state.buffer = hostif->extra; | 1583 | state.buffer = hostif->extra; |
1515 | state.buflen = hostif->extralen; | 1584 | state.buflen = hostif->extralen; |
1516 | state.ctrlif = ctrlif; | ||
1517 | state.vendor = le16_to_cpu(dev->idVendor); | ||
1518 | state.product = le16_to_cpu(dev->idProduct); | ||
1519 | 1585 | ||
1520 | /* check the mapping table */ | 1586 | /* check the mapping table */ |
1521 | for (map = usbmix_ctl_maps; map->vendor; map++) { | 1587 | for (map = usbmix_ctl_maps; map->id; map++) { |
1522 | if (map->vendor == state.vendor && map->product == state.product) { | 1588 | if (map->id == state.chip->usb_id) { |
1523 | state.map = map->map; | 1589 | state.map = map->map; |
1524 | chip->ignore_ctl_error = map->ignore_ctl_error; | 1590 | state.selector_map = map->selector_map; |
1591 | mixer->ignore_ctl_error = map->ignore_ctl_error; | ||
1525 | break; | 1592 | break; |
1526 | } | 1593 | } |
1527 | } | 1594 | } |
1528 | #ifdef IGNORE_CTL_ERROR | ||
1529 | chip->ignore_ctl_error = 1; | ||
1530 | #endif | ||
1531 | 1595 | ||
1532 | desc = NULL; | 1596 | desc = NULL; |
1533 | while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, OUTPUT_TERMINAL)) != NULL) { | 1597 | while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, OUTPUT_TERMINAL)) != NULL) { |
@@ -1543,3 +1607,393 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) | |||
1543 | } | 1607 | } |
1544 | return 0; | 1608 | return 0; |
1545 | } | 1609 | } |
1610 | |||
1611 | static void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, | ||
1612 | int unitid) | ||
1613 | { | ||
1614 | usb_mixer_elem_info_t *info; | ||
1615 | |||
1616 | for (info = mixer->id_elems[unitid]; info; info = info->next_id_elem) | ||
1617 | snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
1618 | info->elem_id); | ||
1619 | } | ||
1620 | |||
1621 | static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer, | ||
1622 | int unitid) | ||
1623 | { | ||
1624 | if (mixer->rc_type == RC_NONE) | ||
1625 | return; | ||
1626 | /* unit ids specific to Extigy/Audigy 2 NX: */ | ||
1627 | switch (unitid) { | ||
1628 | case 0: /* remote control */ | ||
1629 | mixer->rc_urb->dev = mixer->chip->dev; | ||
1630 | usb_submit_urb(mixer->rc_urb, GFP_ATOMIC); | ||
1631 | break; | ||
1632 | case 4: /* digital in jack */ | ||
1633 | case 7: /* line in jacks */ | ||
1634 | case 19: /* speaker out jacks */ | ||
1635 | case 20: /* headphones out jack */ | ||
1636 | break; | ||
1637 | default: | ||
1638 | snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid); | ||
1639 | break; | ||
1640 | } | ||
1641 | } | ||
1642 | |||
1643 | static void snd_usb_mixer_status_complete(struct urb *urb, struct pt_regs *regs) | ||
1644 | { | ||
1645 | struct usb_mixer_interface *mixer = urb->context; | ||
1646 | |||
1647 | if (urb->status == 0) { | ||
1648 | u8 *buf = urb->transfer_buffer; | ||
1649 | int i; | ||
1650 | |||
1651 | for (i = urb->actual_length; i >= 2; buf += 2, i -= 2) { | ||
1652 | snd_printd(KERN_DEBUG "status interrupt: %02x %02x\n", | ||
1653 | buf[0], buf[1]); | ||
1654 | /* ignore any notifications not from the control interface */ | ||
1655 | if ((buf[0] & 0x0f) != 0) | ||
1656 | continue; | ||
1657 | if (!(buf[0] & 0x40)) | ||
1658 | snd_usb_mixer_notify_id(mixer, buf[1]); | ||
1659 | else | ||
1660 | snd_usb_mixer_memory_change(mixer, buf[1]); | ||
1661 | } | ||
1662 | } | ||
1663 | if (urb->status != -ENOENT && urb->status != -ECONNRESET) { | ||
1664 | urb->dev = mixer->chip->dev; | ||
1665 | usb_submit_urb(urb, GFP_ATOMIC); | ||
1666 | } | ||
1667 | } | ||
1668 | |||
1669 | /* create the handler for the optional status interrupt endpoint */ | ||
1670 | static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer) | ||
1671 | { | ||
1672 | struct usb_host_interface *hostif; | ||
1673 | struct usb_endpoint_descriptor *ep; | ||
1674 | void *transfer_buffer; | ||
1675 | int buffer_length; | ||
1676 | unsigned int epnum; | ||
1677 | |||
1678 | hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; | ||
1679 | /* we need one interrupt input endpoint */ | ||
1680 | if (get_iface_desc(hostif)->bNumEndpoints < 1) | ||
1681 | return 0; | ||
1682 | ep = get_endpoint(hostif, 0); | ||
1683 | if ((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN || | ||
1684 | (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) | ||
1685 | return 0; | ||
1686 | |||
1687 | epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | ||
1688 | buffer_length = le16_to_cpu(ep->wMaxPacketSize); | ||
1689 | transfer_buffer = kmalloc(buffer_length, GFP_KERNEL); | ||
1690 | if (!transfer_buffer) | ||
1691 | return -ENOMEM; | ||
1692 | mixer->urb = usb_alloc_urb(0, GFP_KERNEL); | ||
1693 | if (!mixer->urb) { | ||
1694 | kfree(transfer_buffer); | ||
1695 | return -ENOMEM; | ||
1696 | } | ||
1697 | usb_fill_int_urb(mixer->urb, mixer->chip->dev, | ||
1698 | usb_rcvintpipe(mixer->chip->dev, epnum), | ||
1699 | transfer_buffer, buffer_length, | ||
1700 | snd_usb_mixer_status_complete, mixer, ep->bInterval); | ||
1701 | usb_submit_urb(mixer->urb, GFP_KERNEL); | ||
1702 | return 0; | ||
1703 | } | ||
1704 | |||
1705 | static void snd_usb_soundblaster_remote_complete(struct urb *urb, | ||
1706 | struct pt_regs *regs) | ||
1707 | { | ||
1708 | struct usb_mixer_interface *mixer = urb->context; | ||
1709 | /* | ||
1710 | * format of remote control data: | ||
1711 | * Extigy: xx 00 | ||
1712 | * Audigy 2 NX: 06 80 xx 00 00 00 | ||
1713 | */ | ||
1714 | int offset = mixer->rc_type == RC_EXTIGY ? 0 : 2; | ||
1715 | u32 code; | ||
1716 | |||
1717 | if (urb->status < 0 || urb->actual_length <= offset) | ||
1718 | return; | ||
1719 | code = mixer->rc_buffer[offset]; | ||
1720 | /* the Mute button actually changes the mixer control */ | ||
1721 | if (code == 13) | ||
1722 | snd_usb_mixer_notify_id(mixer, 18); | ||
1723 | mixer->rc_code = code; | ||
1724 | wmb(); | ||
1725 | wake_up(&mixer->rc_waitq); | ||
1726 | } | ||
1727 | |||
1728 | static int snd_usb_sbrc_hwdep_open(snd_hwdep_t *hw, struct file *file) | ||
1729 | { | ||
1730 | struct usb_mixer_interface *mixer = hw->private_data; | ||
1731 | |||
1732 | if (test_and_set_bit(0, &mixer->rc_hwdep_open)) | ||
1733 | return -EBUSY; | ||
1734 | return 0; | ||
1735 | } | ||
1736 | |||
1737 | static int snd_usb_sbrc_hwdep_release(snd_hwdep_t *hw, struct file *file) | ||
1738 | { | ||
1739 | struct usb_mixer_interface *mixer = hw->private_data; | ||
1740 | |||
1741 | clear_bit(0, &mixer->rc_hwdep_open); | ||
1742 | smp_mb__after_clear_bit(); | ||
1743 | return 0; | ||
1744 | } | ||
1745 | |||
1746 | static long snd_usb_sbrc_hwdep_read(snd_hwdep_t *hw, char __user *buf, | ||
1747 | long count, loff_t *offset) | ||
1748 | { | ||
1749 | struct usb_mixer_interface *mixer = hw->private_data; | ||
1750 | int err; | ||
1751 | u32 rc_code; | ||
1752 | |||
1753 | if (count != 1 && count != 4) | ||
1754 | return -EINVAL; | ||
1755 | err = wait_event_interruptible(mixer->rc_waitq, | ||
1756 | (rc_code = xchg(&mixer->rc_code, 0)) != 0); | ||
1757 | if (err == 0) { | ||
1758 | if (count == 1) | ||
1759 | err = put_user(rc_code, buf); | ||
1760 | else | ||
1761 | err = put_user(rc_code, (u32 __user *)buf); | ||
1762 | } | ||
1763 | return err < 0 ? err : count; | ||
1764 | } | ||
1765 | |||
1766 | static unsigned int snd_usb_sbrc_hwdep_poll(snd_hwdep_t *hw, struct file *file, | ||
1767 | poll_table *wait) | ||
1768 | { | ||
1769 | struct usb_mixer_interface *mixer = hw->private_data; | ||
1770 | |||
1771 | poll_wait(file, &mixer->rc_waitq, wait); | ||
1772 | return mixer->rc_code ? POLLIN | POLLRDNORM : 0; | ||
1773 | } | ||
1774 | |||
1775 | static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) | ||
1776 | { | ||
1777 | snd_hwdep_t *hwdep; | ||
1778 | int err, len; | ||
1779 | |||
1780 | switch (mixer->chip->usb_id) { | ||
1781 | case USB_ID(0x041e, 0x3000): | ||
1782 | mixer->rc_type = RC_EXTIGY; | ||
1783 | len = 2; | ||
1784 | break; | ||
1785 | case USB_ID(0x041e, 0x3020): | ||
1786 | mixer->rc_type = RC_AUDIGY2NX; | ||
1787 | len = 6; | ||
1788 | break; | ||
1789 | default: | ||
1790 | return 0; | ||
1791 | } | ||
1792 | |||
1793 | init_waitqueue_head(&mixer->rc_waitq); | ||
1794 | err = snd_hwdep_new(mixer->chip->card, "SB remote control", 0, &hwdep); | ||
1795 | if (err < 0) | ||
1796 | return err; | ||
1797 | snprintf(hwdep->name, sizeof(hwdep->name), | ||
1798 | "%s remote control", mixer->chip->card->shortname); | ||
1799 | hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC; | ||
1800 | hwdep->private_data = mixer; | ||
1801 | hwdep->ops.read = snd_usb_sbrc_hwdep_read; | ||
1802 | hwdep->ops.open = snd_usb_sbrc_hwdep_open; | ||
1803 | hwdep->ops.release = snd_usb_sbrc_hwdep_release; | ||
1804 | hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; | ||
1805 | |||
1806 | mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
1807 | if (!mixer->rc_urb) | ||
1808 | return -ENOMEM; | ||
1809 | mixer->rc_setup_packet = kmalloc(sizeof(*mixer->rc_setup_packet), GFP_KERNEL); | ||
1810 | if (!mixer->rc_setup_packet) { | ||
1811 | usb_free_urb(mixer->rc_urb); | ||
1812 | mixer->rc_urb = NULL; | ||
1813 | return -ENOMEM; | ||
1814 | } | ||
1815 | mixer->rc_setup_packet->bRequestType = | ||
1816 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; | ||
1817 | mixer->rc_setup_packet->bRequest = GET_MEM; | ||
1818 | mixer->rc_setup_packet->wValue = cpu_to_le16(0); | ||
1819 | mixer->rc_setup_packet->wIndex = cpu_to_le16(0); | ||
1820 | mixer->rc_setup_packet->wLength = cpu_to_le16(len); | ||
1821 | usb_fill_control_urb(mixer->rc_urb, mixer->chip->dev, | ||
1822 | usb_rcvctrlpipe(mixer->chip->dev, 0), | ||
1823 | (u8*)mixer->rc_setup_packet, mixer->rc_buffer, len, | ||
1824 | snd_usb_soundblaster_remote_complete, mixer); | ||
1825 | return 0; | ||
1826 | } | ||
1827 | |||
1828 | static int snd_audigy2nx_led_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | ||
1829 | { | ||
1830 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
1831 | uinfo->count = 1; | ||
1832 | uinfo->value.integer.min = 0; | ||
1833 | uinfo->value.integer.max = 1; | ||
1834 | return 0; | ||
1835 | } | ||
1836 | |||
1837 | static int snd_audigy2nx_led_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
1838 | { | ||
1839 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); | ||
1840 | int index = kcontrol->private_value; | ||
1841 | |||
1842 | ucontrol->value.integer.value[0] = mixer->audigy2nx_leds[index]; | ||
1843 | return 0; | ||
1844 | } | ||
1845 | |||
1846 | static int snd_audigy2nx_led_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | ||
1847 | { | ||
1848 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); | ||
1849 | int index = kcontrol->private_value; | ||
1850 | int value = ucontrol->value.integer.value[0]; | ||
1851 | int err, changed; | ||
1852 | |||
1853 | if (value > 1) | ||
1854 | return -EINVAL; | ||
1855 | changed = value != mixer->audigy2nx_leds[index]; | ||
1856 | err = snd_usb_ctl_msg(mixer->chip->dev, | ||
1857 | usb_sndctrlpipe(mixer->chip->dev, 0), 0x24, | ||
1858 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, | ||
1859 | value, index + 2, NULL, 0, 100); | ||
1860 | if (err < 0) | ||
1861 | return err; | ||
1862 | mixer->audigy2nx_leds[index] = value; | ||
1863 | return changed; | ||
1864 | } | ||
1865 | |||
1866 | static snd_kcontrol_new_t snd_audigy2nx_controls[] = { | ||
1867 | { | ||
1868 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1869 | .name = "CMSS LED Switch", | ||
1870 | .info = snd_audigy2nx_led_info, | ||
1871 | .get = snd_audigy2nx_led_get, | ||
1872 | .put = snd_audigy2nx_led_put, | ||
1873 | .private_value = 0, | ||
1874 | }, | ||
1875 | { | ||
1876 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1877 | .name = "Power LED Switch", | ||
1878 | .info = snd_audigy2nx_led_info, | ||
1879 | .get = snd_audigy2nx_led_get, | ||
1880 | .put = snd_audigy2nx_led_put, | ||
1881 | .private_value = 1, | ||
1882 | }, | ||
1883 | { | ||
1884 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1885 | .name = "Dolby Digital LED Switch", | ||
1886 | .info = snd_audigy2nx_led_info, | ||
1887 | .get = snd_audigy2nx_led_get, | ||
1888 | .put = snd_audigy2nx_led_put, | ||
1889 | .private_value = 2, | ||
1890 | }, | ||
1891 | }; | ||
1892 | |||
1893 | static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer) | ||
1894 | { | ||
1895 | int i, err; | ||
1896 | |||
1897 | for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) { | ||
1898 | err = snd_ctl_add(mixer->chip->card, | ||
1899 | snd_ctl_new1(&snd_audigy2nx_controls[i], mixer)); | ||
1900 | if (err < 0) | ||
1901 | return err; | ||
1902 | } | ||
1903 | mixer->audigy2nx_leds[1] = 1; /* Power LED is on by default */ | ||
1904 | return 0; | ||
1905 | } | ||
1906 | |||
1907 | static void snd_audigy2nx_proc_read(snd_info_entry_t *entry, | ||
1908 | snd_info_buffer_t *buffer) | ||
1909 | { | ||
1910 | static const struct { | ||
1911 | int unitid; | ||
1912 | const char *name; | ||
1913 | } jacks[] = { | ||
1914 | {4, "dig in "}, | ||
1915 | {7, "line in"}, | ||
1916 | {19, "spk out"}, | ||
1917 | {20, "hph out"}, | ||
1918 | }; | ||
1919 | struct usb_mixer_interface *mixer = entry->private_data; | ||
1920 | int i, err; | ||
1921 | u8 buf[3]; | ||
1922 | |||
1923 | snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname); | ||
1924 | for (i = 0; i < ARRAY_SIZE(jacks); ++i) { | ||
1925 | snd_iprintf(buffer, "%s: ", jacks[i].name); | ||
1926 | err = snd_usb_ctl_msg(mixer->chip->dev, | ||
1927 | usb_rcvctrlpipe(mixer->chip->dev, 0), | ||
1928 | GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | | ||
1929 | USB_RECIP_INTERFACE, 0, | ||
1930 | jacks[i].unitid << 8, buf, 3, 100); | ||
1931 | if (err == 3 && buf[0] == 3) | ||
1932 | snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]); | ||
1933 | else | ||
1934 | snd_iprintf(buffer, "?\n"); | ||
1935 | } | ||
1936 | } | ||
1937 | |||
1938 | int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) | ||
1939 | { | ||
1940 | static snd_device_ops_t dev_ops = { | ||
1941 | .dev_free = snd_usb_mixer_dev_free | ||
1942 | }; | ||
1943 | struct usb_mixer_interface *mixer; | ||
1944 | int err; | ||
1945 | |||
1946 | strcpy(chip->card->mixername, "USB Mixer"); | ||
1947 | |||
1948 | mixer = kcalloc(1, sizeof(*mixer), GFP_KERNEL); | ||
1949 | if (!mixer) | ||
1950 | return -ENOMEM; | ||
1951 | mixer->chip = chip; | ||
1952 | mixer->ctrlif = ctrlif; | ||
1953 | #ifdef IGNORE_CTL_ERROR | ||
1954 | mixer->ignore_ctl_error = 1; | ||
1955 | #endif | ||
1956 | mixer->id_elems = kcalloc(256, sizeof(*mixer->id_elems), GFP_KERNEL); | ||
1957 | if (!mixer->id_elems) { | ||
1958 | kfree(mixer); | ||
1959 | return -ENOMEM; | ||
1960 | } | ||
1961 | |||
1962 | if ((err = snd_usb_mixer_controls(mixer)) < 0 || | ||
1963 | (err = snd_usb_mixer_status_create(mixer)) < 0) | ||
1964 | goto _error; | ||
1965 | |||
1966 | if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0) | ||
1967 | goto _error; | ||
1968 | |||
1969 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) { | ||
1970 | snd_info_entry_t *entry; | ||
1971 | |||
1972 | if ((err = snd_audigy2nx_controls_create(mixer)) < 0) | ||
1973 | goto _error; | ||
1974 | if (!snd_card_proc_new(chip->card, "audigy2nx", &entry)) | ||
1975 | snd_info_set_text_ops(entry, mixer, 1024, | ||
1976 | snd_audigy2nx_proc_read); | ||
1977 | } | ||
1978 | |||
1979 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); | ||
1980 | if (err < 0) | ||
1981 | goto _error; | ||
1982 | list_add(&mixer->list, &chip->mixer_list); | ||
1983 | return 0; | ||
1984 | |||
1985 | _error: | ||
1986 | snd_usb_mixer_free(mixer); | ||
1987 | return err; | ||
1988 | } | ||
1989 | |||
1990 | void snd_usb_mixer_disconnect(struct list_head *p) | ||
1991 | { | ||
1992 | struct usb_mixer_interface *mixer; | ||
1993 | |||
1994 | mixer = list_entry(p, struct usb_mixer_interface, list); | ||
1995 | if (mixer->urb) | ||
1996 | usb_kill_urb(mixer->urb); | ||
1997 | if (mixer->rc_urb) | ||
1998 | usb_kill_urb(mixer->rc_urb); | ||
1999 | } | ||
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c index c69b4b0875f8..f05500b05ec0 100644 --- a/sound/usb/usbmixer_maps.c +++ b/sound/usb/usbmixer_maps.c | |||
@@ -26,10 +26,16 @@ struct usbmix_name_map { | |||
26 | int control; | 26 | int control; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | struct usbmix_selector_map { | ||
30 | int id; | ||
31 | int count; | ||
32 | const char **names; | ||
33 | }; | ||
34 | |||
29 | struct usbmix_ctl_map { | 35 | struct usbmix_ctl_map { |
30 | int vendor; | 36 | u32 id; |
31 | int product; | ||
32 | const struct usbmix_name_map *map; | 37 | const struct usbmix_name_map *map; |
38 | const struct usbmix_selector_map *selector_map; | ||
33 | int ignore_ctl_error; | 39 | int ignore_ctl_error; |
34 | }; | 40 | }; |
35 | 41 | ||
@@ -91,6 +97,96 @@ static struct usbmix_name_map extigy_map[] = { | |||
91 | { 0 } /* terminator */ | 97 | { 0 } /* terminator */ |
92 | }; | 98 | }; |
93 | 99 | ||
100 | /* Sound Blaster MP3+ controls mapping | ||
101 | * The default mixer channels have totally misleading names, | ||
102 | * e.g. no Master and fake PCM volume | ||
103 | * Pavel Mihaylov <bin@bash.info> | ||
104 | */ | ||
105 | static struct usbmix_name_map mp3plus_map[] = { | ||
106 | /* 1: IT pcm */ | ||
107 | /* 2: IT mic */ | ||
108 | /* 3: IT line */ | ||
109 | /* 4: IT digital in */ | ||
110 | /* 5: OT digital out */ | ||
111 | /* 6: OT speaker */ | ||
112 | /* 7: OT pcm capture */ | ||
113 | { 8, "Capture Input Source" }, /* FU, default PCM Capture Source */ | ||
114 | /* (Mic, Input 1 = Line input, Input 2 = Optical input) */ | ||
115 | { 9, "Master Playback" }, /* FU, default Speaker 1 */ | ||
116 | /* { 10, "Mic Capture", 1 }, */ /* FU, Mic Capture */ | ||
117 | /* { 10, "Mic Capture", 2 }, */ /* FU, Mic Capture */ | ||
118 | { 10, "Mic Boost", 7 }, /* FU, default Auto Gain Input */ | ||
119 | { 11, "Line Capture" }, /* FU, default PCM Capture */ | ||
120 | { 12, "Digital In Playback" }, /* FU, default PCM 1 */ | ||
121 | /* { 13, "Mic Playback" }, */ /* FU, default Mic Playback */ | ||
122 | { 14, "Line Playback" }, /* FU, default Speaker */ | ||
123 | /* 15: MU */ | ||
124 | { 0 } /* terminator */ | ||
125 | }; | ||
126 | |||
127 | /* Topology of SB Audigy 2 NX | ||
128 | |||
129 | +----------------------------->EU[27]--+ | ||
130 | | v | ||
131 | | +----------------------------------->SU[29]---->FU[22]-->Dig_OUT[24] | ||
132 | | | ^ | ||
133 | USB_IN[1]-+------------+ +->EU[17]->+->FU[11]-+ | ||
134 | | v | v | | ||
135 | Dig_IN[4]---+->FU[6]-->MU[16]->FU[18]-+->EU[21]->SU[31]----->FU[30]->Hph_OUT[20] | ||
136 | | ^ | | | ||
137 | Lin_IN[7]-+--->FU[8]---+ +->EU[23]->FU[28]------------->Spk_OUT[19] | ||
138 | | | v | ||
139 | +--->FU[12]------------------------------------->SU[14]--->USB_OUT[15] | ||
140 | | ^ | ||
141 | +->FU[13]--------------------------------------+ | ||
142 | */ | ||
143 | static struct usbmix_name_map audigy2nx_map[] = { | ||
144 | /* 1: IT pcm playback */ | ||
145 | /* 4: IT digital in */ | ||
146 | { 6, "Digital In Playback" }, /* FU */ | ||
147 | /* 7: IT line in */ | ||
148 | { 8, "Line Playback" }, /* FU */ | ||
149 | { 11, "What-U-Hear Capture" }, /* FU */ | ||
150 | { 12, "Line Capture" }, /* FU */ | ||
151 | { 13, "Digital In Capture" }, /* FU */ | ||
152 | { 14, "Capture Source" }, /* SU */ | ||
153 | /* 15: OT pcm capture */ | ||
154 | /* 16: MU w/o controls */ | ||
155 | { 17, NULL }, /* DISABLED: EU (for what?) */ | ||
156 | { 18, "Master Playback" }, /* FU */ | ||
157 | /* 19: OT speaker */ | ||
158 | /* 20: OT headphone */ | ||
159 | { 21, NULL }, /* DISABLED: EU (for what?) */ | ||
160 | { 22, "Digital Out Playback" }, /* FU */ | ||
161 | { 23, NULL }, /* DISABLED: EU (for what?) */ | ||
162 | /* 24: OT digital out */ | ||
163 | { 27, NULL }, /* DISABLED: EU (for what?) */ | ||
164 | { 28, "Speaker Playback" }, /* FU */ | ||
165 | { 29, "Digital Out Source" }, /* SU */ | ||
166 | { 30, "Headphone Playback" }, /* FU */ | ||
167 | { 31, "Headphone Source" }, /* SU */ | ||
168 | { 0 } /* terminator */ | ||
169 | }; | ||
170 | |||
171 | static struct usbmix_selector_map audigy2nx_selectors[] = { | ||
172 | { | ||
173 | .id = 14, /* Capture Source */ | ||
174 | .count = 3, | ||
175 | .names = (const char*[]) {"Line", "Digital In", "What-U-Hear"} | ||
176 | }, | ||
177 | { | ||
178 | .id = 29, /* Digital Out Source */ | ||
179 | .count = 3, | ||
180 | .names = (const char*[]) {"Front", "PCM", "Digital In"} | ||
181 | }, | ||
182 | { | ||
183 | .id = 31, /* Headphone Source */ | ||
184 | .count = 2, | ||
185 | .names = (const char*[]) {"Front", "Side"} | ||
186 | }, | ||
187 | { 0 } /* terminator */ | ||
188 | }; | ||
189 | |||
94 | /* LineX FM Transmitter entry - needed to bypass controls bug */ | 190 | /* LineX FM Transmitter entry - needed to bypass controls bug */ |
95 | static struct usbmix_name_map linex_map[] = { | 191 | static struct usbmix_name_map linex_map[] = { |
96 | /* 1: IT pcm */ | 192 | /* 1: IT pcm */ |
@@ -127,9 +223,29 @@ static struct usbmix_name_map justlink_map[] = { | |||
127 | */ | 223 | */ |
128 | 224 | ||
129 | static struct usbmix_ctl_map usbmix_ctl_maps[] = { | 225 | static struct usbmix_ctl_map usbmix_ctl_maps[] = { |
130 | { 0x41e, 0x3000, extigy_map, 1 }, | 226 | { |
131 | { 0x8bb, 0x2702, linex_map, 1 }, | 227 | .id = USB_ID(0x041e, 0x3000), |
132 | { 0xc45, 0x1158, justlink_map, 0 }, | 228 | .map = extigy_map, |
229 | .ignore_ctl_error = 1, | ||
230 | }, | ||
231 | { | ||
232 | .id = USB_ID(0x041e, 0x3010), | ||
233 | .map = mp3plus_map, | ||
234 | }, | ||
235 | { | ||
236 | .id = USB_ID(0x041e, 0x3020), | ||
237 | .map = audigy2nx_map, | ||
238 | .selector_map = audigy2nx_selectors, | ||
239 | }, | ||
240 | { | ||
241 | .id = USB_ID(0x08bb, 0x2702), | ||
242 | .map = linex_map, | ||
243 | .ignore_ctl_error = 1, | ||
244 | }, | ||
245 | { | ||
246 | .id = USB_ID(0x0c45, 0x1158), | ||
247 | .map = justlink_map, | ||
248 | }, | ||
133 | { 0 } /* terminator */ | 249 | { 0 } /* terminator */ |
134 | }; | 250 | }; |
135 | 251 | ||
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h index 88bbd944d4be..f5135641b3e2 100644 --- a/sound/usb/usbquirks.h +++ b/sound/usb/usbquirks.h | |||
@@ -203,11 +203,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
203 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 203 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
204 | .vendor_name = "EDIROL", | 204 | .vendor_name = "EDIROL", |
205 | .product_name = "UM-4", | 205 | .product_name = "UM-4", |
206 | .ifnum = 2, | 206 | .ifnum = QUIRK_ANY_INTERFACE, |
207 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 207 | .type = QUIRK_COMPOSITE, |
208 | .data = & (const snd_usb_midi_endpoint_info_t) { | 208 | .data = (const snd_usb_audio_quirk_t[]) { |
209 | .out_cables = 0x000f, | 209 | { |
210 | .in_cables = 0x000f | 210 | .ifnum = 0, |
211 | .type = QUIRK_IGNORE_INTERFACE | ||
212 | }, | ||
213 | { | ||
214 | .ifnum = 1, | ||
215 | .type = QUIRK_IGNORE_INTERFACE | ||
216 | }, | ||
217 | { | ||
218 | .ifnum = 2, | ||
219 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
220 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
221 | .out_cables = 0x000f, | ||
222 | .in_cables = 0x000f | ||
223 | } | ||
224 | }, | ||
225 | { | ||
226 | .ifnum = -1 | ||
227 | } | ||
211 | } | 228 | } |
212 | } | 229 | } |
213 | }, | 230 | }, |
@@ -216,11 +233,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
216 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 233 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
217 | .vendor_name = "Roland", | 234 | .vendor_name = "Roland", |
218 | .product_name = "SC-8850", | 235 | .product_name = "SC-8850", |
219 | .ifnum = 2, | 236 | .ifnum = QUIRK_ANY_INTERFACE, |
220 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 237 | .type = QUIRK_COMPOSITE, |
221 | .data = & (const snd_usb_midi_endpoint_info_t) { | 238 | .data = (const snd_usb_audio_quirk_t[]) { |
222 | .out_cables = 0x003f, | 239 | { |
223 | .in_cables = 0x003f | 240 | .ifnum = 0, |
241 | .type = QUIRK_IGNORE_INTERFACE | ||
242 | }, | ||
243 | { | ||
244 | .ifnum = 1, | ||
245 | .type = QUIRK_IGNORE_INTERFACE | ||
246 | }, | ||
247 | { | ||
248 | .ifnum = 2, | ||
249 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
250 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
251 | .out_cables = 0x003f, | ||
252 | .in_cables = 0x003f | ||
253 | } | ||
254 | }, | ||
255 | { | ||
256 | .ifnum = -1 | ||
257 | } | ||
224 | } | 258 | } |
225 | } | 259 | } |
226 | }, | 260 | }, |
@@ -229,11 +263,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
229 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 263 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
230 | .vendor_name = "Roland", | 264 | .vendor_name = "Roland", |
231 | .product_name = "U-8", | 265 | .product_name = "U-8", |
232 | .ifnum = 2, | 266 | .ifnum = QUIRK_ANY_INTERFACE, |
233 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 267 | .type = QUIRK_COMPOSITE, |
234 | .data = & (const snd_usb_midi_endpoint_info_t) { | 268 | .data = (const snd_usb_audio_quirk_t[]) { |
235 | .out_cables = 0x0005, | 269 | { |
236 | .in_cables = 0x0005 | 270 | .ifnum = 0, |
271 | .type = QUIRK_IGNORE_INTERFACE | ||
272 | }, | ||
273 | { | ||
274 | .ifnum = 1, | ||
275 | .type = QUIRK_IGNORE_INTERFACE | ||
276 | }, | ||
277 | { | ||
278 | .ifnum = 2, | ||
279 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
280 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
281 | .out_cables = 0x0005, | ||
282 | .in_cables = 0x0005 | ||
283 | } | ||
284 | }, | ||
285 | { | ||
286 | .ifnum = -1 | ||
287 | } | ||
237 | } | 288 | } |
238 | } | 289 | } |
239 | }, | 290 | }, |
@@ -242,11 +293,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
242 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 293 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
243 | .vendor_name = "EDIROL", | 294 | .vendor_name = "EDIROL", |
244 | .product_name = "UM-2", | 295 | .product_name = "UM-2", |
245 | .ifnum = 2, | 296 | .ifnum = QUIRK_ANY_INTERFACE, |
246 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 297 | .type = QUIRK_COMPOSITE, |
247 | .data = & (const snd_usb_midi_endpoint_info_t) { | 298 | .data = (const snd_usb_audio_quirk_t[]) { |
248 | .out_cables = 0x0003, | 299 | { |
249 | .in_cables = 0x0003 | 300 | .ifnum = 0, |
301 | .type = QUIRK_IGNORE_INTERFACE | ||
302 | }, | ||
303 | { | ||
304 | .ifnum = 1, | ||
305 | .type = QUIRK_IGNORE_INTERFACE | ||
306 | }, | ||
307 | { | ||
308 | .ifnum = 2, | ||
309 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
310 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
311 | .out_cables = 0x0003, | ||
312 | .in_cables = 0x0003 | ||
313 | } | ||
314 | }, | ||
315 | { | ||
316 | .ifnum = -1 | ||
317 | } | ||
250 | } | 318 | } |
251 | } | 319 | } |
252 | }, | 320 | }, |
@@ -255,11 +323,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
255 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 323 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
256 | .vendor_name = "Roland", | 324 | .vendor_name = "Roland", |
257 | .product_name = "SC-8820", | 325 | .product_name = "SC-8820", |
258 | .ifnum = 2, | 326 | .ifnum = QUIRK_ANY_INTERFACE, |
259 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 327 | .type = QUIRK_COMPOSITE, |
260 | .data = & (const snd_usb_midi_endpoint_info_t) { | 328 | .data = (const snd_usb_audio_quirk_t[]) { |
261 | .out_cables = 0x0013, | 329 | { |
262 | .in_cables = 0x0013 | 330 | .ifnum = 0, |
331 | .type = QUIRK_IGNORE_INTERFACE | ||
332 | }, | ||
333 | { | ||
334 | .ifnum = 1, | ||
335 | .type = QUIRK_IGNORE_INTERFACE | ||
336 | }, | ||
337 | { | ||
338 | .ifnum = 2, | ||
339 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
340 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
341 | .out_cables = 0x0013, | ||
342 | .in_cables = 0x0013 | ||
343 | } | ||
344 | }, | ||
345 | { | ||
346 | .ifnum = -1 | ||
347 | } | ||
263 | } | 348 | } |
264 | } | 349 | } |
265 | }, | 350 | }, |
@@ -268,11 +353,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
268 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 353 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
269 | .vendor_name = "Roland", | 354 | .vendor_name = "Roland", |
270 | .product_name = "PC-300", | 355 | .product_name = "PC-300", |
271 | .ifnum = 2, | 356 | .ifnum = QUIRK_ANY_INTERFACE, |
272 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 357 | .type = QUIRK_COMPOSITE, |
273 | .data = & (const snd_usb_midi_endpoint_info_t) { | 358 | .data = (const snd_usb_audio_quirk_t[]) { |
274 | .out_cables = 0x0001, | 359 | { |
275 | .in_cables = 0x0001 | 360 | .ifnum = 0, |
361 | .type = QUIRK_IGNORE_INTERFACE | ||
362 | }, | ||
363 | { | ||
364 | .ifnum = 1, | ||
365 | .type = QUIRK_IGNORE_INTERFACE | ||
366 | }, | ||
367 | { | ||
368 | .ifnum = 2, | ||
369 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
370 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
371 | .out_cables = 0x0001, | ||
372 | .in_cables = 0x0001 | ||
373 | } | ||
374 | }, | ||
375 | { | ||
376 | .ifnum = -1 | ||
377 | } | ||
276 | } | 378 | } |
277 | } | 379 | } |
278 | }, | 380 | }, |
@@ -281,11 +383,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
281 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 383 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
282 | .vendor_name = "EDIROL", | 384 | .vendor_name = "EDIROL", |
283 | .product_name = "UM-1", | 385 | .product_name = "UM-1", |
284 | .ifnum = 2, | 386 | .ifnum = QUIRK_ANY_INTERFACE, |
285 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 387 | .type = QUIRK_COMPOSITE, |
286 | .data = & (const snd_usb_midi_endpoint_info_t) { | 388 | .data = (const snd_usb_audio_quirk_t[]) { |
287 | .out_cables = 0x0001, | 389 | { |
288 | .in_cables = 0x0001 | 390 | .ifnum = 0, |
391 | .type = QUIRK_IGNORE_INTERFACE | ||
392 | }, | ||
393 | { | ||
394 | .ifnum = 1, | ||
395 | .type = QUIRK_IGNORE_INTERFACE | ||
396 | }, | ||
397 | { | ||
398 | .ifnum = 2, | ||
399 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
400 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
401 | .out_cables = 0x0001, | ||
402 | .in_cables = 0x0001 | ||
403 | } | ||
404 | }, | ||
405 | { | ||
406 | .ifnum = -1 | ||
407 | } | ||
289 | } | 408 | } |
290 | } | 409 | } |
291 | }, | 410 | }, |
@@ -294,11 +413,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
294 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 413 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
295 | .vendor_name = "Roland", | 414 | .vendor_name = "Roland", |
296 | .product_name = "SK-500", | 415 | .product_name = "SK-500", |
297 | .ifnum = 2, | 416 | .ifnum = QUIRK_ANY_INTERFACE, |
298 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 417 | .type = QUIRK_COMPOSITE, |
299 | .data = & (const snd_usb_midi_endpoint_info_t) { | 418 | .data = (const snd_usb_audio_quirk_t[]) { |
300 | .out_cables = 0x0013, | 419 | { |
301 | .in_cables = 0x0013 | 420 | .ifnum = 0, |
421 | .type = QUIRK_IGNORE_INTERFACE | ||
422 | }, | ||
423 | { | ||
424 | .ifnum = 1, | ||
425 | .type = QUIRK_IGNORE_INTERFACE | ||
426 | }, | ||
427 | { | ||
428 | .ifnum = 2, | ||
429 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
430 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
431 | .out_cables = 0x0013, | ||
432 | .in_cables = 0x0013 | ||
433 | } | ||
434 | }, | ||
435 | { | ||
436 | .ifnum = -1 | ||
437 | } | ||
302 | } | 438 | } |
303 | } | 439 | } |
304 | }, | 440 | }, |
@@ -421,11 +557,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
421 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 557 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
422 | .vendor_name = "EDIROL", | 558 | .vendor_name = "EDIROL", |
423 | .product_name = "SD-90", | 559 | .product_name = "SD-90", |
424 | .ifnum = 2, | 560 | .ifnum = QUIRK_ANY_INTERFACE, |
425 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 561 | .type = QUIRK_COMPOSITE, |
426 | .data = & (const snd_usb_midi_endpoint_info_t) { | 562 | .data = (const snd_usb_audio_quirk_t[]) { |
427 | .out_cables = 0x000f, | 563 | { |
428 | .in_cables = 0x000f | 564 | .ifnum = 0, |
565 | .type = QUIRK_IGNORE_INTERFACE | ||
566 | }, | ||
567 | { | ||
568 | .ifnum = 1, | ||
569 | .type = QUIRK_IGNORE_INTERFACE | ||
570 | }, | ||
571 | { | ||
572 | .ifnum = 2, | ||
573 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
574 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
575 | .out_cables = 0x000f, | ||
576 | .in_cables = 0x000f | ||
577 | } | ||
578 | }, | ||
579 | { | ||
580 | .ifnum = -1 | ||
581 | } | ||
429 | } | 582 | } |
430 | } | 583 | } |
431 | }, | 584 | }, |
@@ -434,11 +587,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
434 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 587 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
435 | .vendor_name = "Roland", | 588 | .vendor_name = "Roland", |
436 | .product_name = "MMP-2", | 589 | .product_name = "MMP-2", |
437 | .ifnum = 2, | 590 | .ifnum = QUIRK_ANY_INTERFACE, |
438 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 591 | .type = QUIRK_COMPOSITE, |
439 | .data = & (const snd_usb_midi_endpoint_info_t) { | 592 | .data = (const snd_usb_audio_quirk_t[]) { |
440 | .out_cables = 0x0001, | 593 | { |
441 | .in_cables = 0x0001 | 594 | .ifnum = 0, |
595 | .type = QUIRK_IGNORE_INTERFACE | ||
596 | }, | ||
597 | { | ||
598 | .ifnum = 1, | ||
599 | .type = QUIRK_IGNORE_INTERFACE | ||
600 | }, | ||
601 | { | ||
602 | .ifnum = 2, | ||
603 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
604 | .data = & (const snd_usb_midi_endpoint_info_t) { | ||
605 | .out_cables = 0x0001, | ||
606 | .in_cables = 0x0001 | ||
607 | } | ||
608 | }, | ||
609 | { | ||
610 | .ifnum = -1 | ||
611 | } | ||
442 | } | 612 | } |
443 | } | 613 | } |
444 | }, | 614 | }, |
@@ -609,15 +779,33 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
609 | } | 779 | } |
610 | }, | 780 | }, |
611 | { | 781 | { |
782 | /* | ||
783 | * This quirk is for the "Advanced Driver" mode. If off, the GS-10 | ||
784 | * has ID 0x003c and is standard compliant, but has only 16-bit PCM | ||
785 | * and no MIDI. | ||
786 | */ | ||
612 | USB_DEVICE_VENDOR_SPEC(0x0582, 0x003b), | 787 | USB_DEVICE_VENDOR_SPEC(0x0582, 0x003b), |
613 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { | 788 | .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { |
614 | .vendor_name = "BOSS", | 789 | .vendor_name = "BOSS", |
615 | .product_name = "GS-10", | 790 | .product_name = "GS-10", |
616 | .ifnum = 3, | 791 | .ifnum = QUIRK_ANY_INTERFACE, |
617 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | 792 | .type = QUIRK_COMPOSITE, |
618 | .data = & (const snd_usb_midi_endpoint_info_t) { | 793 | .data = & (const snd_usb_audio_quirk_t[]) { |
619 | .out_cables = 0x0003, | 794 | { |
620 | .in_cables = 0x0003 | 795 | .ifnum = 1, |
796 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
797 | }, | ||
798 | { | ||
799 | .ifnum = 2, | ||
800 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
801 | }, | ||
802 | { | ||
803 | .ifnum = 3, | ||
804 | .type = QUIRK_MIDI_STANDARD_INTERFACE | ||
805 | }, | ||
806 | { | ||
807 | .ifnum = -1 | ||
808 | } | ||
621 | } | 809 | } |
622 | } | 810 | } |
623 | }, | 811 | }, |
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index b06a267e5dac..e6e6da159671 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c | |||
@@ -1,6 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * usbusy2y.c - ALSA USB US-428 Driver | 2 | * usbusy2y.c - ALSA USB US-428 Driver |
3 | * | 3 | * |
4 | 2005-04-14 Karsten Wiese | ||
5 | Version 0.8.7.2: | ||
6 | Call snd_card_free() instead of snd_card_free_in_thread() to prevent oops with dead keyboard symptom. | ||
7 | Tested ok with kernel 2.6.12-rc2. | ||
8 | |||
4 | 2004-12-14 Karsten Wiese | 9 | 2004-12-14 Karsten Wiese |
5 | Version 0.8.7.1: | 10 | Version 0.8.7.1: |
6 | snd_pcm_open for rawusb pcm-devices now returns -EBUSY if called without rawusb's hwdep device being open. | 11 | snd_pcm_open for rawusb pcm-devices now returns -EBUSY if called without rawusb's hwdep device being open. |
@@ -143,7 +148,7 @@ | |||
143 | 148 | ||
144 | 149 | ||
145 | MODULE_AUTHOR("Karsten Wiese <annabellesgarden@yahoo.de>"); | 150 | MODULE_AUTHOR("Karsten Wiese <annabellesgarden@yahoo.de>"); |
146 | MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.8.7.1"); | 151 | MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.8.7.2"); |
147 | MODULE_LICENSE("GPL"); | 152 | MODULE_LICENSE("GPL"); |
148 | MODULE_SUPPORTED_DEVICE("{{TASCAM(0x1604), "NAME_ALLCAPS"(0x8001)(0x8005)(0x8007) }}"); | 153 | MODULE_SUPPORTED_DEVICE("{{TASCAM(0x1604), "NAME_ALLCAPS"(0x8001)(0x8005)(0x8007) }}"); |
149 | 154 | ||
@@ -430,8 +435,6 @@ static void usX2Y_usb_disconnect(struct usb_device* device, void* ptr) | |||
430 | if (ptr) { | 435 | if (ptr) { |
431 | usX2Ydev_t* usX2Y = usX2Y((snd_card_t*)ptr); | 436 | usX2Ydev_t* usX2Y = usX2Y((snd_card_t*)ptr); |
432 | struct list_head* p; | 437 | struct list_head* p; |
433 | if (usX2Y->chip_status == USX2Y_STAT_CHIP_HUP) // on 2.6.1 kernel snd_usbmidi_disconnect() | ||
434 | return; // calls us back. better leave :-) . | ||
435 | usX2Y->chip.shutdown = 1; | 438 | usX2Y->chip.shutdown = 1; |
436 | usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; | 439 | usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; |
437 | usX2Y_unlinkSeq(&usX2Y->AS04); | 440 | usX2Y_unlinkSeq(&usX2Y->AS04); |
@@ -439,11 +442,11 @@ static void usX2Y_usb_disconnect(struct usb_device* device, void* ptr) | |||
439 | snd_card_disconnect((snd_card_t*)ptr); | 442 | snd_card_disconnect((snd_card_t*)ptr); |
440 | /* release the midi resources */ | 443 | /* release the midi resources */ |
441 | list_for_each(p, &usX2Y->chip.midi_list) { | 444 | list_for_each(p, &usX2Y->chip.midi_list) { |
442 | snd_usbmidi_disconnect(p, &snd_usX2Y_usb_driver); | 445 | snd_usbmidi_disconnect(p); |
443 | } | 446 | } |
444 | if (usX2Y->us428ctls_sharedmem) | 447 | if (usX2Y->us428ctls_sharedmem) |
445 | wake_up(&usX2Y->us428ctls_wait_queue_head); | 448 | wake_up(&usX2Y->us428ctls_wait_queue_head); |
446 | snd_card_free_in_thread((snd_card_t*)ptr); | 449 | snd_card_free((snd_card_t*)ptr); |
447 | } | 450 | } |
448 | } | 451 | } |
449 | 452 | ||
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 4c292e090069..62dfd28b3b07 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c | |||
@@ -401,10 +401,8 @@ static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs) | |||
401 | for (i = 0; i < NRURBS; i++) | 401 | for (i = 0; i < NRURBS; i++) |
402 | usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); | 402 | usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); |
403 | 403 | ||
404 | if (subs->tmpbuf) { | 404 | kfree(subs->tmpbuf); |
405 | kfree(subs->tmpbuf); | 405 | subs->tmpbuf = NULL; |
406 | subs->tmpbuf = NULL; | ||
407 | } | ||
408 | } | 406 | } |
409 | /* | 407 | /* |
410 | * initialize a substream's urbs | 408 | * initialize a substream's urbs |