aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/core.h28
-rw-r--r--include/sound/version.h2
-rw-r--r--sound/core/device.c4
-rw-r--r--sound/drivers/pcsp/pcsp.c8
-rw-r--r--sound/drivers/pcsp/pcsp.h1
-rw-r--r--sound/drivers/pcsp/pcsp_lib.c95
-rw-r--r--sound/pci/ac97/ac97_patch.c2
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c494
-rw-r--r--sound/pci/ice1712/ice1724.c23
-rw-r--r--sound/ppc/pmac.c2
-rw-r--r--sound/ppc/tumbler.c3
11 files changed, 359 insertions, 303 deletions
diff --git a/include/sound/core.h b/include/sound/core.h
index 1508c4ec1ba9..f632484bc743 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -353,7 +353,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
353 * snd_printk - printk wrapper 353 * snd_printk - printk wrapper
354 * @fmt: format string 354 * @fmt: format string
355 * 355 *
356 * Works like print() but prints the file and the line of the caller 356 * Works like printk() but prints the file and the line of the caller
357 * when configured with CONFIG_SND_VERBOSE_PRINTK. 357 * when configured with CONFIG_SND_VERBOSE_PRINTK.
358 */ 358 */
359#define snd_printk(fmt, args...) \ 359#define snd_printk(fmt, args...) \
@@ -380,18 +380,40 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
380 printk(fmt ,##args) 380 printk(fmt ,##args)
381#endif 381#endif
382 382
383/**
384 * snd_BUG - give a BUG warning message and stack trace
385 *
386 * Calls WARN() if CONFIG_SND_DEBUG is set.
387 * Ignored when CONFIG_SND_DEBUG is not set.
388 */
383#define snd_BUG() WARN(1, "BUG?\n") 389#define snd_BUG() WARN(1, "BUG?\n")
390
391/**
392 * snd_BUG_ON - debugging check macro
393 * @cond: condition to evaluate
394 *
395 * When CONFIG_SND_DEBUG is set, this macro evaluates the given condition,
396 * and call WARN() and returns the value if it's non-zero.
397 *
398 * When CONFIG_SND_DEBUG is not set, this just returns zero, and the given
399 * condition is ignored.
400 *
401 * NOTE: the argument won't be evaluated at all when CONFIG_SND_DEBUG=n.
402 * Thus, don't put any statement that influences on the code behavior,
403 * such as pre/post increment, to the argument of this macro.
404 * If you want to evaluate and give a warning, use standard WARN_ON().
405 */
384#define snd_BUG_ON(cond) WARN((cond), "BUG? (%s)\n", __stringify(cond)) 406#define snd_BUG_ON(cond) WARN((cond), "BUG? (%s)\n", __stringify(cond))
385 407
386#else /* !CONFIG_SND_DEBUG */ 408#else /* !CONFIG_SND_DEBUG */
387 409
388#define snd_printd(fmt, args...) do { } while (0) 410#define snd_printd(fmt, args...) do { } while (0)
389#define snd_BUG() do { } while (0) 411#define snd_BUG() do { } while (0)
390static inline int __snd_bug_on(void) 412static inline int __snd_bug_on(int cond)
391{ 413{
392 return 0; 414 return 0;
393} 415}
394#define snd_BUG_ON(cond) __snd_bug_on() /* always false */ 416#define snd_BUG_ON(cond) __snd_bug_on(0 && (cond)) /* always false */
395 417
396#endif /* CONFIG_SND_DEBUG */ 418#endif /* CONFIG_SND_DEBUG */
397 419
diff --git a/include/sound/version.h b/include/sound/version.h
index 4aafeda88634..2b48237e23bf 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h */ 1/* include/version.h */
2#define CONFIG_SND_VERSION "1.0.18rc3" 2#define CONFIG_SND_VERSION "1.0.18a"
3#define CONFIG_SND_DATE "" 3#define CONFIG_SND_DATE ""
diff --git a/sound/core/device.c b/sound/core/device.c
index c58d8227254c..a67dfac08c03 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -98,7 +98,7 @@ int snd_device_free(struct snd_card *card, void *device_data)
98 kfree(dev); 98 kfree(dev);
99 return 0; 99 return 0;
100 } 100 }
101 snd_printd("device free %p (from %p), not found\n", device_data, 101 snd_printd("device free %p (from %pF), not found\n", device_data,
102 __builtin_return_address(0)); 102 __builtin_return_address(0));
103 return -ENXIO; 103 return -ENXIO;
104} 104}
@@ -135,7 +135,7 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
135 } 135 }
136 return 0; 136 return 0;
137 } 137 }
138 snd_printd("device disconnect %p (from %p), not found\n", device_data, 138 snd_printd("device disconnect %p (from %pF), not found\n", device_data,
139 __builtin_return_address(0)); 139 __builtin_return_address(0));
140 return -ENXIO; 140 return -ENXIO;
141} 141}
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index 1899cf0685bc..2a02f704f366 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -96,7 +96,7 @@ static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev)
96 return -EINVAL; 96 return -EINVAL;
97 97
98 hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 98 hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
99 pcsp_chip.timer.cb_mode = HRTIMER_CB_SOFTIRQ; 99 pcsp_chip.timer.cb_mode = HRTIMER_CB_IRQSAFE_UNLOCKED;
100 pcsp_chip.timer.function = pcsp_do_timer; 100 pcsp_chip.timer.function = pcsp_do_timer;
101 101
102 card = snd_card_new(index, id, THIS_MODULE, 0); 102 card = snd_card_new(index, id, THIS_MODULE, 0);
@@ -188,10 +188,8 @@ static int __devexit pcsp_remove(struct platform_device *dev)
188 188
189static void pcsp_stop_beep(struct snd_pcsp *chip) 189static void pcsp_stop_beep(struct snd_pcsp *chip)
190{ 190{
191 spin_lock_irq(&chip->substream_lock); 191 pcsp_sync_stop(chip);
192 if (!chip->playback_substream) 192 pcspkr_stop_sound();
193 pcspkr_stop_sound();
194 spin_unlock_irq(&chip->substream_lock);
195} 193}
196 194
197#ifdef CONFIG_PM 195#ifdef CONFIG_PM
diff --git a/sound/drivers/pcsp/pcsp.h b/sound/drivers/pcsp/pcsp.h
index 1d661f795e8c..70533a333b5b 100644
--- a/sound/drivers/pcsp/pcsp.h
+++ b/sound/drivers/pcsp/pcsp.h
@@ -77,6 +77,7 @@ struct snd_pcsp {
77extern struct snd_pcsp pcsp_chip; 77extern struct snd_pcsp pcsp_chip;
78 78
79extern enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle); 79extern enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle);
80extern void pcsp_sync_stop(struct snd_pcsp *chip);
80 81
81extern int snd_pcsp_new_pcm(struct snd_pcsp *chip); 82extern int snd_pcsp_new_pcm(struct snd_pcsp *chip);
82extern int snd_pcsp_new_mixer(struct snd_pcsp *chip); 83extern int snd_pcsp_new_mixer(struct snd_pcsp *chip);
diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c
index 1f42e4063118..f8d8470861da 100644
--- a/sound/drivers/pcsp/pcsp_lib.c
+++ b/sound/drivers/pcsp/pcsp_lib.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/moduleparam.h> 10#include <linux/moduleparam.h>
11#include <linux/interrupt.h>
11#include <sound/pcm.h> 12#include <sound/pcm.h>
12#include <asm/io.h> 13#include <asm/io.h>
13#include "pcsp.h" 14#include "pcsp.h"
@@ -19,6 +20,22 @@ MODULE_PARM_DESC(nforce_wa, "Apply NForce chipset workaround "
19 20
20#define DMIX_WANTS_S16 1 21#define DMIX_WANTS_S16 1
21 22
23/*
24 * Call snd_pcm_period_elapsed in a tasklet
25 * This avoids spinlock messes and long-running irq contexts
26 */
27static void pcsp_call_pcm_elapsed(unsigned long priv)
28{
29 if (atomic_read(&pcsp_chip.timer_active)) {
30 struct snd_pcm_substream *substream;
31 substream = pcsp_chip.playback_substream;
32 if (substream)
33 snd_pcm_period_elapsed(substream);
34 }
35}
36
37static DECLARE_TASKLET(pcsp_pcm_tasklet, pcsp_call_pcm_elapsed, 0);
38
22enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle) 39enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
23{ 40{
24 unsigned char timer_cnt, val; 41 unsigned char timer_cnt, val;
@@ -28,41 +45,23 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
28 struct snd_pcm_substream *substream; 45 struct snd_pcm_substream *substream;
29 struct snd_pcm_runtime *runtime; 46 struct snd_pcm_runtime *runtime;
30 struct snd_pcsp *chip = container_of(handle, struct snd_pcsp, timer); 47 struct snd_pcsp *chip = container_of(handle, struct snd_pcsp, timer);
48 unsigned long flags;
31 49
32 if (chip->thalf) { 50 if (chip->thalf) {
33 outb(chip->val61, 0x61); 51 outb(chip->val61, 0x61);
34 chip->thalf = 0; 52 chip->thalf = 0;
35 if (!atomic_read(&chip->timer_active)) 53 if (!atomic_read(&chip->timer_active))
36 return HRTIMER_NORESTART; 54 goto stop;
37 hrtimer_forward(&chip->timer, hrtimer_get_expires(&chip->timer), 55 hrtimer_forward(&chip->timer, hrtimer_get_expires(&chip->timer),
38 ktime_set(0, chip->ns_rem)); 56 ktime_set(0, chip->ns_rem));
39 return HRTIMER_RESTART; 57 return HRTIMER_RESTART;
40 } 58 }
41 59
42 spin_lock_irq(&chip->substream_lock);
43 /* Takashi Iwai says regarding this extra lock:
44
45 If the irq handler handles some data on the DMA buffer, it should
46 do snd_pcm_stream_lock().
47 That protects basically against all races among PCM callbacks, yes.
48 However, there are two remaining issues:
49 1. The substream pointer you try to lock isn't protected _before_
50 this lock yet.
51 2. snd_pcm_period_elapsed() itself acquires the lock.
52 The requirement of another lock is because of 1. When you get
53 chip->playback_substream, it's not protected.
54 Keeping this lock while snd_pcm_period_elapsed() assures the substream
55 is still protected (at least, not released). And the other status is
56 handled properly inside snd_pcm_stream_lock() in
57 snd_pcm_period_elapsed().
58
59 */
60 if (!chip->playback_substream)
61 goto exit_nr_unlock1;
62 substream = chip->playback_substream;
63 snd_pcm_stream_lock(substream);
64 if (!atomic_read(&chip->timer_active)) 60 if (!atomic_read(&chip->timer_active))
65 goto exit_nr_unlock2; 61 goto stop;
62 substream = chip->playback_substream;
63 if (!substream)
64 goto stop;
66 65
67 runtime = substream->runtime; 66 runtime = substream->runtime;
68 fmt_size = snd_pcm_format_physical_width(runtime->format) >> 3; 67 fmt_size = snd_pcm_format_physical_width(runtime->format) >> 3;
@@ -87,6 +86,8 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
87 86
88 period_bytes = snd_pcm_lib_period_bytes(substream); 87 period_bytes = snd_pcm_lib_period_bytes(substream);
89 buffer_bytes = snd_pcm_lib_buffer_bytes(substream); 88 buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
89
90 spin_lock_irqsave(&chip->substream_lock, flags);
90 chip->playback_ptr += PCSP_INDEX_INC() * fmt_size; 91 chip->playback_ptr += PCSP_INDEX_INC() * fmt_size;
91 periods_elapsed = chip->playback_ptr - chip->period_ptr; 92 periods_elapsed = chip->playback_ptr - chip->period_ptr;
92 if (periods_elapsed < 0) { 93 if (periods_elapsed < 0) {
@@ -102,18 +103,15 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
102 * or ALSA will BUG on us. */ 103 * or ALSA will BUG on us. */
103 chip->playback_ptr %= buffer_bytes; 104 chip->playback_ptr %= buffer_bytes;
104 105
105 snd_pcm_stream_unlock(substream);
106
107 if (periods_elapsed) { 106 if (periods_elapsed) {
108 snd_pcm_period_elapsed(substream);
109 chip->period_ptr += periods_elapsed * period_bytes; 107 chip->period_ptr += periods_elapsed * period_bytes;
110 chip->period_ptr %= buffer_bytes; 108 chip->period_ptr %= buffer_bytes;
109 tasklet_schedule(&pcsp_pcm_tasklet);
111 } 110 }
112 111 spin_unlock_irqrestore(&chip->substream_lock, flags);
113 spin_unlock_irq(&chip->substream_lock);
114 112
115 if (!atomic_read(&chip->timer_active)) 113 if (!atomic_read(&chip->timer_active))
116 return HRTIMER_NORESTART; 114 goto stop;
117 115
118 chip->ns_rem = PCSP_PERIOD_NS(); 116 chip->ns_rem = PCSP_PERIOD_NS();
119 ns = (chip->thalf ? PCSP_CALC_NS(timer_cnt) : chip->ns_rem); 117 ns = (chip->thalf ? PCSP_CALC_NS(timer_cnt) : chip->ns_rem);
@@ -122,10 +120,7 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
122 ktime_set(0, ns)); 120 ktime_set(0, ns));
123 return HRTIMER_RESTART; 121 return HRTIMER_RESTART;
124 122
125exit_nr_unlock2: 123 stop:
126 snd_pcm_stream_unlock(substream);
127exit_nr_unlock1:
128 spin_unlock_irq(&chip->substream_lock);
129 return HRTIMER_NORESTART; 124 return HRTIMER_NORESTART;
130} 125}
131 126
@@ -165,26 +160,35 @@ static void pcsp_stop_playing(struct snd_pcsp *chip)
165 spin_unlock(&i8253_lock); 160 spin_unlock(&i8253_lock);
166} 161}
167 162
163/*
164 * Force to stop and sync the stream
165 */
166void pcsp_sync_stop(struct snd_pcsp *chip)
167{
168 local_irq_disable();
169 pcsp_stop_playing(chip);
170 local_irq_enable();
171 hrtimer_cancel(&chip->timer);
172 tasklet_kill(&pcsp_pcm_tasklet);
173}
174
168static int snd_pcsp_playback_close(struct snd_pcm_substream *substream) 175static int snd_pcsp_playback_close(struct snd_pcm_substream *substream)
169{ 176{
170 struct snd_pcsp *chip = snd_pcm_substream_chip(substream); 177 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
171#if PCSP_DEBUG 178#if PCSP_DEBUG
172 printk(KERN_INFO "PCSP: close called\n"); 179 printk(KERN_INFO "PCSP: close called\n");
173#endif 180#endif
174 if (atomic_read(&chip->timer_active)) { 181 pcsp_sync_stop(chip);
175 printk(KERN_ERR "PCSP: timer still active\n");
176 pcsp_stop_playing(chip);
177 }
178 spin_lock_irq(&chip->substream_lock);
179 chip->playback_substream = NULL; 182 chip->playback_substream = NULL;
180 spin_unlock_irq(&chip->substream_lock);
181 return 0; 183 return 0;
182} 184}
183 185
184static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream, 186static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream,
185 struct snd_pcm_hw_params *hw_params) 187 struct snd_pcm_hw_params *hw_params)
186{ 188{
189 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
187 int err; 190 int err;
191 pcsp_sync_stop(chip);
188 err = snd_pcm_lib_malloc_pages(substream, 192 err = snd_pcm_lib_malloc_pages(substream,
189 params_buffer_bytes(hw_params)); 193 params_buffer_bytes(hw_params));
190 if (err < 0) 194 if (err < 0)
@@ -194,9 +198,11 @@ static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream,
194 198
195static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream) 199static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream)
196{ 200{
201 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
197#if PCSP_DEBUG 202#if PCSP_DEBUG
198 printk(KERN_INFO "PCSP: hw_free called\n"); 203 printk(KERN_INFO "PCSP: hw_free called\n");
199#endif 204#endif
205 pcsp_sync_stop(chip);
200 return snd_pcm_lib_free_pages(substream); 206 return snd_pcm_lib_free_pages(substream);
201} 207}
202 208
@@ -212,6 +218,7 @@ static int snd_pcsp_playback_prepare(struct snd_pcm_substream *substream)
212 snd_pcm_lib_period_bytes(substream), 218 snd_pcm_lib_period_bytes(substream),
213 substream->runtime->periods); 219 substream->runtime->periods);
214#endif 220#endif
221 pcsp_sync_stop(chip);
215 chip->playback_ptr = 0; 222 chip->playback_ptr = 0;
216 chip->period_ptr = 0; 223 chip->period_ptr = 0;
217 return 0; 224 return 0;
@@ -242,7 +249,11 @@ static snd_pcm_uframes_t snd_pcsp_playback_pointer(struct snd_pcm_substream
242 *substream) 249 *substream)
243{ 250{
244 struct snd_pcsp *chip = snd_pcm_substream_chip(substream); 251 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
245 return bytes_to_frames(substream->runtime, chip->playback_ptr); 252 unsigned int pos;
253 spin_lock(&chip->substream_lock);
254 pos = chip->playback_ptr;
255 spin_unlock(&chip->substream_lock);
256 return bytes_to_frames(substream->runtime, pos);
246} 257}
247 258
248static struct snd_pcm_hardware snd_pcsp_playback = { 259static struct snd_pcm_hardware snd_pcsp_playback = {
@@ -279,9 +290,7 @@ static int snd_pcsp_playback_open(struct snd_pcm_substream *substream)
279 return -EBUSY; 290 return -EBUSY;
280 } 291 }
281 runtime->hw = snd_pcsp_playback; 292 runtime->hw = snd_pcsp_playback;
282 spin_lock_irq(&chip->substream_lock);
283 chip->playback_substream = substream; 293 chip->playback_substream = substream;
284 spin_unlock_irq(&chip->substream_lock);
285 return 0; 294 return 0;
286} 295}
287 296
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 6e831aff1bd0..2c7cd97d2234 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -2832,6 +2832,8 @@ static int patch_alc655(struct snd_ac97 * ac97)
2832 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ 2832 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
2833 else 2833 else
2834 val |= (1 << 1); /* Pin 47 is spdif input pin */ 2834 val |= (1 << 1); /* Pin 47 is spdif input pin */
2835 /* this seems missing on some hardwares */
2836 ac97->ext_id |= AC97_EI_SPDIF;
2835 } 2837 }
2836 val &= ~(1 << 12); /* vref enable */ 2838 val &= ~(1 << 12); /* vref enable */
2837 snd_ac97_write_cache(ac97, 0x7a, val); 2839 snd_ac97_write_cache(ac97, 0x7a, val);
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index de5ee8f097f6..7958006a1d66 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -69,7 +69,7 @@ MODULE_FIRMWARE(EMU1010_NOTEBOOK_FILENAME);
69 * EMU10K1 init / done 69 * EMU10K1 init / done
70 *************************************************************************/ 70 *************************************************************************/
71 71
72void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int ch) 72void snd_emu10k1_voice_init(struct snd_emu10k1 *emu, int ch)
73{ 73{
74 snd_emu10k1_ptr_write(emu, DCYSUSV, ch, 0); 74 snd_emu10k1_ptr_write(emu, DCYSUSV, ch, 0);
75 snd_emu10k1_ptr_write(emu, IP, ch, 0); 75 snd_emu10k1_ptr_write(emu, IP, ch, 0);
@@ -151,9 +151,9 @@ static unsigned int i2c_adc_init[][2] = {
151 { 0x12, 0x32 }, /* ALC Control 3 */ 151 { 0x12, 0x32 }, /* ALC Control 3 */
152 { 0x13, 0x00 }, /* Noise gate control */ 152 { 0x13, 0x00 }, /* Noise gate control */
153 { 0x14, 0xa6 }, /* Limiter control */ 153 { 0x14, 0xa6 }, /* Limiter control */
154 { 0x15, ADC_MUX_2 }, /* ADC Mixer control. Mic for Audigy 2 ZS Notebook */ 154 { 0x15, ADC_MUX_2 }, /* ADC Mixer control. Mic for A2ZS Notebook */
155}; 155};
156 156
157static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) 157static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
158{ 158{
159 unsigned int silent_page; 159 unsigned int silent_page;
@@ -161,8 +161,8 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
161 u32 tmp; 161 u32 tmp;
162 162
163 /* disable audio and lock cache */ 163 /* disable audio and lock cache */
164 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, 164 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK |
165 emu->port + HCFG); 165 HCFG_MUTEBUTTONENABLE, emu->port + HCFG);
166 166
167 /* reset recording buffers */ 167 /* reset recording buffers */
168 snd_emu10k1_ptr_write(emu, MICBS, 0, ADCBS_BUFSIZE_NONE); 168 snd_emu10k1_ptr_write(emu, MICBS, 0, ADCBS_BUFSIZE_NONE);
@@ -179,7 +179,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
179 snd_emu10k1_ptr_write(emu, SOLEL, 0, 0); 179 snd_emu10k1_ptr_write(emu, SOLEL, 0, 0);
180 snd_emu10k1_ptr_write(emu, SOLEH, 0, 0); 180 snd_emu10k1_ptr_write(emu, SOLEH, 0, 0);
181 181
182 if (emu->audigy){ 182 if (emu->audigy) {
183 /* set SPDIF bypass mode */ 183 /* set SPDIF bypass mode */
184 snd_emu10k1_ptr_write(emu, SPBYPASS, 0, SPBYPASS_FORMAT); 184 snd_emu10k1_ptr_write(emu, SPBYPASS, 0, SPBYPASS_FORMAT);
185 /* enable rear left + rear right AC97 slots */ 185 /* enable rear left + rear right AC97 slots */
@@ -197,12 +197,12 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
197 197
198 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ 198 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
199 /* Hacks for Alice3 to work independent of haP16V driver */ 199 /* Hacks for Alice3 to work independent of haP16V driver */
200 //Setup SRCMulti_I2S SamplingRate 200 /* Setup SRCMulti_I2S SamplingRate */
201 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); 201 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
202 tmp &= 0xfffff1ff; 202 tmp &= 0xfffff1ff;
203 tmp |= (0x2<<9); 203 tmp |= (0x2<<9);
204 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp); 204 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp);
205 205
206 /* Setup SRCSel (Enable Spdif,I2S SRCMulti) */ 206 /* Setup SRCSel (Enable Spdif,I2S SRCMulti) */
207 snd_emu10k1_ptr20_write(emu, SRCSel, 0, 0x14); 207 snd_emu10k1_ptr20_write(emu, SRCSel, 0, 0x14);
208 /* Setup SRCMulti Input Audio Enable */ 208 /* Setup SRCMulti Input Audio Enable */
@@ -217,7 +217,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
217 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */ 217 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */
218 /* Hacks for Alice3 to work independent of haP16V driver */ 218 /* Hacks for Alice3 to work independent of haP16V driver */
219 snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); 219 snd_printk(KERN_INFO "Audigy2 value: Special config.\n");
220 //Setup SRCMulti_I2S SamplingRate 220 /* Setup SRCMulti_I2S SamplingRate */
221 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); 221 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
222 tmp &= 0xfffff1ff; 222 tmp &= 0xfffff1ff;
223 tmp |= (0x2<<9); 223 tmp |= (0x2<<9);
@@ -270,13 +270,13 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
270 size = ARRAY_SIZE(i2c_adc_init); 270 size = ARRAY_SIZE(i2c_adc_init);
271 for (n = 0; n < size; n++) 271 for (n = 0; n < size; n++)
272 snd_emu10k1_i2c_write(emu, i2c_adc_init[n][0], i2c_adc_init[n][1]); 272 snd_emu10k1_i2c_write(emu, i2c_adc_init[n][0], i2c_adc_init[n][1]);
273 for (n=0; n < 4; n++) { 273 for (n = 0; n < 4; n++) {
274 emu->i2c_capture_volume[n][0]= 0xcf; 274 emu->i2c_capture_volume[n][0] = 0xcf;
275 emu->i2c_capture_volume[n][1]= 0xcf; 275 emu->i2c_capture_volume[n][1] = 0xcf;
276 } 276 }
277 } 277 }
278 278
279 279
280 snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); 280 snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr);
281 snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */ 281 snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */
282 snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */ 282 snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */
@@ -313,7 +313,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
313 (emu->model == 0x21 && emu->revision < 6)) 313 (emu->model == 0x21 && emu->revision < 6))
314 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE, emu->port + HCFG); 314 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE, emu->port + HCFG);
315 else 315 else
316 // With on-chip joystick 316 /* With on-chip joystick */
317 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); 317 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
318 318
319 if (enable_ir) { /* enable IR for SB Live */ 319 if (enable_ir) { /* enable IR for SB Live */
@@ -335,9 +335,9 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
335 outl(reg | HCFG_GPOUT1 | HCFG_GPOUT2, emu->port + HCFG); 335 outl(reg | HCFG_GPOUT1 | HCFG_GPOUT2, emu->port + HCFG);
336 udelay(100); 336 udelay(100);
337 outl(reg, emu->port + HCFG); 337 outl(reg, emu->port + HCFG);
338 } 338 }
339 } 339 }
340 340
341 if (emu->card_capabilities->emu_model) { 341 if (emu->card_capabilities->emu_model) {
342 ; /* Disable all access to A_IOCFG for the emu1010 */ 342 ; /* Disable all access to A_IOCFG for the emu1010 */
343 } else if (emu->card_capabilities->i2c_adc) { 343 } else if (emu->card_capabilities->i2c_adc) {
@@ -364,7 +364,7 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu)
364 ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */ 364 ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */
365 } else if (emu->audigy) { 365 } else if (emu->audigy) {
366 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); 366 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG);
367 367
368 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ 368 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
369 /* Unmute Analog now. Set GPO6 to 1 for Apollo. 369 /* Unmute Analog now. Set GPO6 to 1 for Apollo.
370 * This has to be done after init ALice3 I2SOut beyond 48KHz. 370 * This has to be done after init ALice3 I2SOut beyond 48KHz.
@@ -378,12 +378,12 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu)
378 outl(inl(emu->port + A_IOCFG) | 0x0080, emu->port + A_IOCFG); 378 outl(inl(emu->port + A_IOCFG) | 0x0080, emu->port + A_IOCFG);
379 } 379 }
380 } 380 }
381 381
382#if 0 382#if 0
383 { 383 {
384 unsigned int tmp; 384 unsigned int tmp;
385 /* FIXME: the following routine disables LiveDrive-II !! */ 385 /* FIXME: the following routine disables LiveDrive-II !! */
386 // TOSLink detection 386 /* TOSLink detection */
387 emu->tos_link = 0; 387 emu->tos_link = 0;
388 tmp = inl(emu->port + HCFG); 388 tmp = inl(emu->port + HCFG);
389 if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) { 389 if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) {
@@ -400,7 +400,7 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu)
400 snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE); 400 snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE);
401} 401}
402 402
403int snd_emu10k1_done(struct snd_emu10k1 * emu) 403int snd_emu10k1_done(struct snd_emu10k1 *emu)
404{ 404{
405 int ch; 405 int ch;
406 406
@@ -495,7 +495,7 @@ int snd_emu10k1_done(struct snd_emu10k1 * emu)
495 495
496#define EC_LAST_PROMFILE_ADDR 0x2f 496#define EC_LAST_PROMFILE_ADDR 0x2f
497 497
498#define EC_SERIALNUM_ADDR 0x30 /* First word of serial number. The 498#define EC_SERIALNUM_ADDR 0x30 /* First word of serial number. The
499 * can be up to 30 characters in length 499 * can be up to 30 characters in length
500 * and is stored as a NULL-terminated 500 * and is stored as a NULL-terminated
501 * ASCII string. Any unused bytes must be 501 * ASCII string. Any unused bytes must be
@@ -503,8 +503,8 @@ int snd_emu10k1_done(struct snd_emu10k1 * emu)
503#define EC_CHECKSUM_ADDR 0x3f /* Location at which checksum is stored */ 503#define EC_CHECKSUM_ADDR 0x3f /* Location at which checksum is stored */
504 504
505 505
506/* Most of this stuff is pretty self-evident. According to the hardware 506/* Most of this stuff is pretty self-evident. According to the hardware
507 * dudes, we need to leave the ADCCAL bit low in order to avoid a DC 507 * dudes, we need to leave the ADCCAL bit low in order to avoid a DC
508 * offset problem. Weird. 508 * offset problem. Weird.
509 */ 509 */
510#define EC_RAW_RUN_MODE (EC_DACMUTEN | EC_ADCRSTN | EC_TRIM_MUTEN | \ 510#define EC_RAW_RUN_MODE (EC_DACMUTEN | EC_ADCRSTN | EC_TRIM_MUTEN | \
@@ -523,7 +523,7 @@ int snd_emu10k1_done(struct snd_emu10k1 * emu)
523 * register. 523 * register.
524 */ 524 */
525 525
526static void snd_emu10k1_ecard_write(struct snd_emu10k1 * emu, unsigned int value) 526static void snd_emu10k1_ecard_write(struct snd_emu10k1 *emu, unsigned int value)
527{ 527{
528 unsigned short count; 528 unsigned short count;
529 unsigned int data; 529 unsigned int data;
@@ -561,7 +561,7 @@ static void snd_emu10k1_ecard_write(struct snd_emu10k1 * emu, unsigned int value
561 * channel. 561 * channel.
562 */ 562 */
563 563
564static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu, 564static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 *emu,
565 unsigned short gain) 565 unsigned short gain)
566{ 566{
567 unsigned int bit; 567 unsigned int bit;
@@ -574,7 +574,7 @@ static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu,
574 574
575 for (bit = (1 << 15); bit; bit >>= 1) { 575 for (bit = (1 << 15); bit; bit >>= 1) {
576 unsigned int value; 576 unsigned int value;
577 577
578 value = emu->ecard_ctrl & ~(EC_TRIM_CSN | EC_TRIM_SDATA); 578 value = emu->ecard_ctrl & ~(EC_TRIM_CSN | EC_TRIM_SDATA);
579 579
580 if (gain & bit) 580 if (gain & bit)
@@ -589,7 +589,7 @@ static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu,
589 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl); 589 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl);
590} 590}
591 591
592static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu) 592static int snd_emu10k1_ecard_init(struct snd_emu10k1 *emu)
593{ 593{
594 unsigned int hc_value; 594 unsigned int hc_value;
595 595
@@ -598,7 +598,7 @@ static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu)
598 EC_SPDIF0_SELECT(EC_DEFAULT_SPDIF0_SEL) | 598 EC_SPDIF0_SELECT(EC_DEFAULT_SPDIF0_SEL) |
599 EC_SPDIF1_SELECT(EC_DEFAULT_SPDIF1_SEL); 599 EC_SPDIF1_SELECT(EC_DEFAULT_SPDIF1_SEL);
600 600
601 /* Step 0: Set the codec type in the hardware control register 601 /* Step 0: Set the codec type in the hardware control register
602 * and enable audio output */ 602 * and enable audio output */
603 hc_value = inl(emu->port + HCFG); 603 hc_value = inl(emu->port + HCFG);
604 outl(hc_value | HCFG_AUDIOENABLE | HCFG_CODECFORMAT_I2S, emu->port + HCFG); 604 outl(hc_value | HCFG_AUDIOENABLE | HCFG_CODECFORMAT_I2S, emu->port + HCFG);
@@ -629,7 +629,7 @@ static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu)
629 return 0; 629 return 0;
630} 630}
631 631
632static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) 632static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu)
633{ 633{
634 unsigned long special_port; 634 unsigned long special_port;
635 unsigned int value; 635 unsigned int value;
@@ -656,7 +656,7 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu)
656 return 0; 656 return 0;
657} 657}
658 658
659static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename) 659static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, const char *filename)
660{ 660{
661 int err; 661 int err;
662 int n, i; 662 int n, i;
@@ -666,11 +666,12 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
666 unsigned long flags; 666 unsigned long flags;
667 const struct firmware *fw_entry; 667 const struct firmware *fw_entry;
668 668
669 if ((err = request_firmware(&fw_entry, filename, &emu->pci->dev)) != 0) { 669 err = request_firmware(&fw_entry, filename, &emu->pci->dev);
670 snd_printk(KERN_ERR "firmware: %s not found. Err=%d\n",filename, err); 670 if (err != 0) {
671 snd_printk(KERN_ERR "firmware: %s not found. Err = %d\n", filename, err);
671 return err; 672 return err;
672 } 673 }
673 snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size); 674 snd_printk(KERN_INFO "firmware size = 0x%zx\n", fw_entry->size);
674 675
675 /* The FPGA is a Xilinx Spartan IIE XC2S50E */ 676 /* The FPGA is a Xilinx Spartan IIE XC2S50E */
676 /* GPIO7 -> FPGA PGMN 677 /* GPIO7 -> FPGA PGMN
@@ -685,13 +686,13 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
685 outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */ 686 outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */
686 write_post = inl(emu->port + A_IOCFG); 687 write_post = inl(emu->port + A_IOCFG);
687 udelay(100); /* Allow FPGA memory to clean */ 688 udelay(100); /* Allow FPGA memory to clean */
688 for(n = 0; n < fw_entry->size; n++) { 689 for (n = 0; n < fw_entry->size; n++) {
689 value=fw_entry->data[n]; 690 value = fw_entry->data[n];
690 for(i = 0; i < 8; i++) { 691 for (i = 0; i < 8; i++) {
691 reg = 0x80; 692 reg = 0x80;
692 if (value & 0x1) 693 if (value & 0x1)
693 reg = reg | 0x20; 694 reg = reg | 0x20;
694 value = value >> 1; 695 value = value >> 1;
695 outl(reg, emu->port + A_IOCFG); 696 outl(reg, emu->port + A_IOCFG);
696 write_post = inl(emu->port + A_IOCFG); 697 write_post = inl(emu->port + A_IOCFG);
697 outl(reg | 0x40, emu->port + A_IOCFG); 698 outl(reg | 0x40, emu->port + A_IOCFG);
@@ -703,14 +704,14 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
703 write_post = inl(emu->port + A_IOCFG); 704 write_post = inl(emu->port + A_IOCFG);
704 spin_unlock_irqrestore(&emu->emu_lock, flags); 705 spin_unlock_irqrestore(&emu->emu_lock, flags);
705 706
706 release_firmware(fw_entry); 707 release_firmware(fw_entry);
707 return 0; 708 return 0;
708} 709}
709 710
710static int emu1010_firmware_thread(void *data) 711static int emu1010_firmware_thread(void *data)
711{ 712{
712 struct snd_emu10k1 * emu = data; 713 struct snd_emu10k1 *emu = data;
713 int tmp,tmp2; 714 int tmp, tmp2;
714 int reg; 715 int reg;
715 int err; 716 int err;
716 717
@@ -719,50 +720,50 @@ static int emu1010_firmware_thread(void *data)
719 msleep_interruptible(1000); 720 msleep_interruptible(1000);
720 if (kthread_should_stop()) 721 if (kthread_should_stop())
721 break; 722 break;
722 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */ 723 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp); /* IRQ Status */
723 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); /* OPTIONS: Which cards are attached to the EMU */ 724 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg); /* OPTIONS: Which cards are attached to the EMU */
724 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { 725 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) {
725 /* Audio Dock attached */ 726 /* Audio Dock attached */
726 /* Return to Audio Dock programming mode */ 727 /* Return to Audio Dock programming mode */
727 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 728 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
728 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); 729 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK);
729 if (emu->card_capabilities->emu_model == 730 if (emu->card_capabilities->emu_model ==
730 EMU_MODEL_EMU1010) { 731 EMU_MODEL_EMU1010) {
731 if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) { 732 err = snd_emu1010_load_firmware(emu, DOCK_FILENAME);
733 if (err != 0)
732 continue; 734 continue;
733 }
734 } else if (emu->card_capabilities->emu_model == 735 } else if (emu->card_capabilities->emu_model ==
735 EMU_MODEL_EMU1010B) { 736 EMU_MODEL_EMU1010B) {
736 if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { 737 err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME);
738 if (err != 0)
737 continue; 739 continue;
738 }
739 } else if (emu->card_capabilities->emu_model == 740 } else if (emu->card_capabilities->emu_model ==
740 EMU_MODEL_EMU1616) { 741 EMU_MODEL_EMU1616) {
741 if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { 742 err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME);
743 if (err != 0)
742 continue; 744 continue;
743 }
744 } 745 }
745 746
746 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); 747 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0);
747 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg ); 748 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg);
748 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); 749 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n", reg);
749 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 750 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
750 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 751 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
751 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); 752 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg);
752 if ((reg & 0x1f) != 0x15) { 753 if ((reg & 0x1f) != 0x15) {
753 /* FPGA failed to be programmed */ 754 /* FPGA failed to be programmed */
754 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); 755 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", reg);
755 continue; 756 continue;
756 } 757 }
757 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); 758 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n");
758 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp ); 759 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp);
759 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2 ); 760 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2);
760 snd_printk("Audio Dock ver:%d.%d\n",tmp ,tmp2); 761 snd_printk("Audio Dock ver:%d.%d\n", tmp, tmp2);
761 /* Sync clocking between 1010 and Dock */ 762 /* Sync clocking between 1010 and Dock */
762 /* Allow DLL to settle */ 763 /* Allow DLL to settle */
763 msleep(10); 764 msleep(10);
764 /* Unmute all. Default is muted after a firmware load */ 765 /* Unmute all. Default is muted after a firmware load */
765 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); 766 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE);
766 } 767 }
767 } 768 }
768 snd_printk(KERN_INFO "emu1010: firmware thread stopping\n"); 769 snd_printk(KERN_INFO "emu1010: firmware thread stopping\n");
@@ -800,10 +801,10 @@ static int emu1010_firmware_thread(void *data)
800 * 16 x 16-bit playback - snd_emu10k1_fx8010_playback_ops 801 * 16 x 16-bit playback - snd_emu10k1_fx8010_playback_ops
801 * 16 x 32-bit capture - snd_emu10k1_capture_efx_ops 802 * 16 x 32-bit capture - snd_emu10k1_capture_efx_ops
802 */ 803 */
803static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) 804static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
804{ 805{
805 unsigned int i; 806 unsigned int i;
806 int tmp,tmp2; 807 int tmp, tmp2;
807 int reg; 808 int reg;
808 int err; 809 int err;
809 const char *filename = NULL; 810 const char *filename = NULL;
@@ -818,7 +819,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
818 * Lock Tank Memory Cache, 819 * Lock Tank Memory Cache,
819 * Mute all codecs. 820 * Mute all codecs.
820 */ 821 */
821 outl(0x0005a004, emu->port + HCFG); 822 outl(0x0005a004, emu->port + HCFG);
822 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 823 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
823 * Mute all codecs. 824 * Mute all codecs.
824 */ 825 */
@@ -829,25 +830,25 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
829 outl(0x0005a000, emu->port + HCFG); 830 outl(0x0005a000, emu->port + HCFG);
830 831
831 /* Disable 48Volt power to Audio Dock */ 832 /* Disable 48Volt power to Audio Dock */
832 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); 833 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0);
833 834
834 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ 835 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */
835 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 836 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
836 snd_printdd("reg1=0x%x\n",reg); 837 snd_printdd("reg1 = 0x%x\n", reg);
837 if ((reg & 0x3f) == 0x15) { 838 if ((reg & 0x3f) == 0x15) {
838 /* FPGA netlist already present so clear it */ 839 /* FPGA netlist already present so clear it */
839 /* Return to programming mode */ 840 /* Return to programming mode */
840 841
841 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02 ); 842 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02);
842 } 843 }
843 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 844 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
844 snd_printdd("reg2=0x%x\n",reg); 845 snd_printdd("reg2 = 0x%x\n", reg);
845 if ((reg & 0x3f) == 0x15) { 846 if ((reg & 0x3f) == 0x15) {
846 /* FPGA failed to return to programming mode */ 847 /* FPGA failed to return to programming mode */
847 snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n"); 848 snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n");
848 return -ENODEV; 849 return -ENODEV;
849 } 850 }
850 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); 851 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID = 0x%x\n", reg);
851 switch (emu->card_capabilities->emu_model) { 852 switch (emu->card_capabilities->emu_model) {
852 case EMU_MODEL_EMU1010: 853 case EMU_MODEL_EMU1010:
853 filename = HANA_FILENAME; 854 filename = HANA_FILENAME;
@@ -876,25 +877,25 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
876 } 877 }
877 878
878 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 879 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
879 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 880 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
880 if ((reg & 0x3f) != 0x15) { 881 if ((reg & 0x3f) != 0x15) {
881 /* FPGA failed to be programmed */ 882 /* FPGA failed to be programmed */
882 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg); 883 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", reg);
883 return -ENODEV; 884 return -ENODEV;
884 } 885 }
885 886
886 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n"); 887 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n");
887 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp ); 888 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp);
888 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2 ); 889 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2);
889 snd_printk("Hana ver:%d.%d\n",tmp ,tmp2); 890 snd_printk("emu1010: Hana version: %d.%d\n", tmp, tmp2);
890 /* Enable 48Volt power to Audio Dock */ 891 /* Enable 48Volt power to Audio Dock */
891 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON ); 892 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON);
892 893
893 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); 894 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
894 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); 895 snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg);
895 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); 896 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
896 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); 897 snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg);
897 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); 898 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp);
898 /* Optical -> ADAT I/O */ 899 /* Optical -> ADAT I/O */
899 /* 0 : SPDIF 900 /* 0 : SPDIF
900 * 1 : ADAT 901 * 1 : ADAT
@@ -904,41 +905,42 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
904 tmp = 0; 905 tmp = 0;
905 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) | 906 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) |
906 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0); 907 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0);
907 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp ); 908 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp);
908 snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp ); 909 snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp);
909 /* Set no attenuation on Audio Dock pads. */ 910 /* Set no attenuation on Audio Dock pads. */
910 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 ); 911 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00);
911 emu->emu1010.adc_pads = 0x00; 912 emu->emu1010.adc_pads = 0x00;
912 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); 913 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp);
913 /* Unmute Audio dock DACs, Headphone source DAC-4. */ 914 /* Unmute Audio dock DACs, Headphone source DAC-4. */
914 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); 915 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30);
915 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); 916 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);
916 snd_emu1010_fpga_read(emu, EMU_HANA_DAC_PADS, &tmp ); 917 snd_emu1010_fpga_read(emu, EMU_HANA_DAC_PADS, &tmp);
917 /* DAC PADs. */ 918 /* DAC PADs. */
918 snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, 0x0f ); 919 snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, 0x0f);
919 emu->emu1010.dac_pads = 0x0f; 920 emu->emu1010.dac_pads = 0x0f;
920 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); 921 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp);
921 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); 922 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30);
922 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); 923 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp);
923 /* SPDIF Format. Set Consumer mode, 24bit, copy enable */ 924 /* SPDIF Format. Set Consumer mode, 24bit, copy enable */
924 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); 925 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10);
925 /* MIDI routing */ 926 /* MIDI routing */
926 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); 927 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19);
927 /* Unknown. */ 928 /* Unknown. */
928 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); 929 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c);
929 /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); // IRQ Enable: All on */ 930 /* IRQ Enable: Alll on */
931 /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); */
930 /* IRQ Enable: All off */ 932 /* IRQ Enable: All off */
931 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00 ); 933 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00);
932 934
933 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); 935 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
934 snd_printk(KERN_INFO "emu1010: Card options3=0x%x\n",reg); 936 snd_printk(KERN_INFO "emu1010: Card options3 = 0x%x\n", reg);
935 /* Default WCLK set to 48kHz. */ 937 /* Default WCLK set to 48kHz. */
936 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00 ); 938 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00);
937 /* Word Clock source, Internal 48kHz x1 */ 939 /* Word Clock source, Internal 48kHz x1 */
938 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); 940 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K);
939 //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); 941 /* snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X); */
940 /* Audio Dock LEDs. */ 942 /* Audio Dock LEDs. */
941 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); 943 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);
942 944
943#if 0 945#if 0
944 /* For 96kHz */ 946 /* For 96kHz */
@@ -992,7 +994,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
992 * Defaults only, users will set their own values anyways, let's 994 * Defaults only, users will set their own values anyways, let's
993 * just copy/paste. 995 * just copy/paste.
994 */ 996 */
995 997
996 snd_emu1010_fpga_link_dst_src_write(emu, 998 snd_emu1010_fpga_link_dst_src_write(emu,
997 EMU_DST_ALICE2_EMU32_8, EMU_SRC_DOCK_MIC_A1); 999 EMU_DST_ALICE2_EMU32_8, EMU_SRC_DOCK_MIC_A1);
998 snd_emu1010_fpga_link_dst_src_write(emu, 1000 snd_emu1010_fpga_link_dst_src_write(emu,
@@ -1037,19 +1039,19 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
1037 snd_emu1010_fpga_link_dst_src_write(emu, 1039 snd_emu1010_fpga_link_dst_src_write(emu,
1038 EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2); 1040 EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2);
1039#endif 1041#endif
1040 for (i = 0;i < 0x20; i++ ) { 1042 for (i = 0; i < 0x20; i++) {
1041 /* AudioDock Elink <- Silence */ 1043 /* AudioDock Elink <- Silence */
1042 snd_emu1010_fpga_link_dst_src_write(emu, 0x0100+i, EMU_SRC_SILENCE); 1044 snd_emu1010_fpga_link_dst_src_write(emu, 0x0100 + i, EMU_SRC_SILENCE);
1043 } 1045 }
1044 for (i = 0;i < 4; i++) { 1046 for (i = 0; i < 4; i++) {
1045 /* Hana SPDIF Out <- Silence */ 1047 /* Hana SPDIF Out <- Silence */
1046 snd_emu1010_fpga_link_dst_src_write(emu, 0x0200+i, EMU_SRC_SILENCE); 1048 snd_emu1010_fpga_link_dst_src_write(emu, 0x0200 + i, EMU_SRC_SILENCE);
1047 } 1049 }
1048 for (i = 0;i < 7; i++) { 1050 for (i = 0; i < 7; i++) {
1049 /* Hamoa DAC <- Silence */ 1051 /* Hamoa DAC <- Silence */
1050 snd_emu1010_fpga_link_dst_src_write(emu, 0x0300+i, EMU_SRC_SILENCE); 1052 snd_emu1010_fpga_link_dst_src_write(emu, 0x0300 + i, EMU_SRC_SILENCE);
1051 } 1053 }
1052 for (i = 0;i < 7; i++) { 1054 for (i = 0; i < 7; i++) {
1053 /* Hana ADAT Out <- Silence */ 1055 /* Hana ADAT Out <- Silence */
1054 snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE); 1056 snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE);
1055 } 1057 }
@@ -1065,30 +1067,30 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
1065 EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1); 1067 EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1);
1066 snd_emu1010_fpga_link_dst_src_write(emu, 1068 snd_emu1010_fpga_link_dst_src_write(emu,
1067 EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1); 1069 EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1);
1068 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01 ); // Unmute all 1070 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01); /* Unmute all */
1071
1072 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp);
1069 1073
1070 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp );
1071
1072 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, 1074 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave,
1073 * Lock Sound Memory Cache, Lock Tank Memory Cache, 1075 * Lock Sound Memory Cache, Lock Tank Memory Cache,
1074 * Mute all codecs. 1076 * Mute all codecs.
1075 */ 1077 */
1076 outl(0x0000a000, emu->port + HCFG); 1078 outl(0x0000a000, emu->port + HCFG);
1077 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, 1079 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave,
1078 * Lock Sound Memory Cache, Lock Tank Memory Cache, 1080 * Lock Sound Memory Cache, Lock Tank Memory Cache,
1079 * Un-Mute all codecs. 1081 * Un-Mute all codecs.
1080 */ 1082 */
1081 outl(0x0000a001, emu->port + HCFG); 1083 outl(0x0000a001, emu->port + HCFG);
1082 1084
1083 /* Initial boot complete. Now patches */ 1085 /* Initial boot complete. Now patches */
1084 1086
1085 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp ); 1087 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp);
1086 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ 1088 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19); /* MIDI Route */
1087 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ 1089 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c); /* Unknown */
1088 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ 1090 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19); /* MIDI Route */
1089 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ 1091 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c); /* Unknown */
1090 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); 1092 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp);
1091 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif (or 0x11 for aes/ebu) */ 1093 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10); /* SPDIF Format spdif (or 0x11 for aes/ebu) */
1092 1094
1093 /* Start Micro/Audio Dock firmware loader thread */ 1095 /* Start Micro/Audio Dock firmware loader thread */
1094 if (!emu->emu1010.firmware_thread) { 1096 if (!emu->emu1010.firmware_thread) {
@@ -1218,20 +1220,20 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
1218 emu->emu1010.output_source[23] = 28; 1220 emu->emu1010.output_source[23] = 28;
1219 } 1221 }
1220 /* TEMP: Select SPDIF in/out */ 1222 /* TEMP: Select SPDIF in/out */
1221 //snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */ 1223 /* snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); */ /* Output spdif */
1222 1224
1223 /* TEMP: Select 48kHz SPDIF out */ 1225 /* TEMP: Select 48kHz SPDIF out */
1224 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */ 1226 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */
1225 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */ 1227 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */
1226 /* Word Clock source, Internal 48kHz x1 */ 1228 /* Word Clock source, Internal 48kHz x1 */
1227 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); 1229 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K);
1228 //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); 1230 /* snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X); */
1229 emu->emu1010.internal_clock = 1; /* 48000 */ 1231 emu->emu1010.internal_clock = 1; /* 48000 */
1230 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);/* Set LEDs on Audio Dock */ 1232 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12); /* Set LEDs on Audio Dock */
1231 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */ 1233 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */
1232 //snd_emu1010_fpga_write(emu, 0x7, 0x0); /* Mute all */ 1234 /* snd_emu1010_fpga_write(emu, 0x7, 0x0); */ /* Mute all */
1233 //snd_emu1010_fpga_write(emu, 0x7, 0x1); /* Unmute all */ 1235 /* snd_emu1010_fpga_write(emu, 0x7, 0x1); */ /* Unmute all */
1234 //snd_emu1010_fpga_write(emu, 0xe, 0x12); /* Set LEDs on Audio Dock */ 1236 /* snd_emu1010_fpga_write(emu, 0xe, 0x12); */ /* Set LEDs on Audio Dock */
1235 1237
1236 return 0; 1238 return 0;
1237} 1239}
@@ -1247,13 +1249,13 @@ static void free_pm_buffer(struct snd_emu10k1 *emu);
1247static int snd_emu10k1_free(struct snd_emu10k1 *emu) 1249static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1248{ 1250{
1249 if (emu->port) { /* avoid access to already used hardware */ 1251 if (emu->port) { /* avoid access to already used hardware */
1250 snd_emu10k1_fx8010_tram_setup(emu, 0); 1252 snd_emu10k1_fx8010_tram_setup(emu, 0);
1251 snd_emu10k1_done(emu); 1253 snd_emu10k1_done(emu);
1252 snd_emu10k1_free_efx(emu); 1254 snd_emu10k1_free_efx(emu);
1253 } 1255 }
1254 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) { 1256 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) {
1255 /* Disable 48Volt power to Audio Dock */ 1257 /* Disable 48Volt power to Audio Dock */
1256 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); 1258 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0);
1257 } 1259 }
1258 if (emu->emu1010.firmware_thread) 1260 if (emu->emu1010.firmware_thread)
1259 kthread_stop(emu->emu1010.firmware_thread); 1261 kthread_stop(emu->emu1010.firmware_thread);
@@ -1278,7 +1280,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1278#endif 1280#endif
1279 if (emu->port) 1281 if (emu->port)
1280 pci_release_regions(emu->pci); 1282 pci_release_regions(emu->pci);
1281 if (emu->card_capabilities->ca0151_chip) /* P16V */ 1283 if (emu->card_capabilities->ca0151_chip) /* P16V */
1282 snd_p16v_free(emu); 1284 snd_p16v_free(emu);
1283 pci_disable_device(emu->pci); 1285 pci_disable_device(emu->pci);
1284 kfree(emu); 1286 kfree(emu);
@@ -1292,21 +1294,6 @@ static int snd_emu10k1_dev_free(struct snd_device *device)
1292} 1294}
1293 1295
1294static struct snd_emu_chip_details emu_chip_details[] = { 1296static struct snd_emu_chip_details emu_chip_details[] = {
1295 /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/
1296 /* Tested by James@superbug.co.uk 3rd July 2005 */
1297 /* DSP: CA0108-IAT
1298 * DAC: CS4382-KQ
1299 * ADC: Philips 1361T
1300 * AC97: STAC9750
1301 * CA0151: None
1302 */
1303 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102,
1304 .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]",
1305 .id = "Audigy2",
1306 .emu10k2_chip = 1,
1307 .ca0108_chip = 1,
1308 .spk71 = 1,
1309 .ac97_chip = 1} ,
1310 /* Audigy4 (Not PRO) SB0610 */ 1297 /* Audigy4 (Not PRO) SB0610 */
1311 /* Tested by James@superbug.co.uk 4th April 2006 */ 1298 /* Tested by James@superbug.co.uk 4th April 2006 */
1312 /* A_IOCFG bits 1299 /* A_IOCFG bits
@@ -1346,20 +1333,37 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1346 * CA0151: None 1333 * CA0151: None
1347 */ 1334 */
1348 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10211102, 1335 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10211102,
1349 .driver = "Audigy2", .name = "Audigy 4 [SB0610]", 1336 .driver = "Audigy2", .name = "SB Audigy 4 [SB0610]",
1350 .id = "Audigy2", 1337 .id = "Audigy2",
1351 .emu10k2_chip = 1, 1338 .emu10k2_chip = 1,
1352 .ca0108_chip = 1, 1339 .ca0108_chip = 1,
1353 .spk71 = 1, 1340 .spk71 = 1,
1354 .adc_1361t = 1, /* 24 bit capture instead of 16bit */ 1341 .adc_1361t = 1, /* 24 bit capture instead of 16bit */
1355 .ac97_chip = 1} , 1342 .ac97_chip = 1} ,
1343 /* Audigy 2 Value AC3 out does not work yet.
1344 * Need to find out how to turn off interpolators.
1345 */
1346 /* Tested by James@superbug.co.uk 3rd July 2005 */
1347 /* DSP: CA0108-IAT
1348 * DAC: CS4382-KQ
1349 * ADC: Philips 1361T
1350 * AC97: STAC9750
1351 * CA0151: None
1352 */
1353 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102,
1354 .driver = "Audigy2", .name = "SB Audigy 2 Value [SB0400]",
1355 .id = "Audigy2",
1356 .emu10k2_chip = 1,
1357 .ca0108_chip = 1,
1358 .spk71 = 1,
1359 .ac97_chip = 1} ,
1356 /* Audigy 2 ZS Notebook Cardbus card.*/ 1360 /* Audigy 2 ZS Notebook Cardbus card.*/
1357 /* Tested by James@superbug.co.uk 6th November 2006 */ 1361 /* Tested by James@superbug.co.uk 6th November 2006 */
1358 /* Audio output 7.1/Headphones working. 1362 /* Audio output 7.1/Headphones working.
1359 * Digital output working. (AC3 not checked, only PCM) 1363 * Digital output working. (AC3 not checked, only PCM)
1360 * Audio Mic/Line inputs working. 1364 * Audio Mic/Line inputs working.
1361 * Digital input not tested. 1365 * Digital input not tested.
1362 */ 1366 */
1363 /* DSP: Tina2 1367 /* DSP: Tina2
1364 * DAC: Wolfson WM8768/WM8568 1368 * DAC: Wolfson WM8768/WM8568
1365 * ADC: Wolfson WM8775 1369 * ADC: Wolfson WM8775
@@ -1386,7 +1390,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1386 * 1390 *
1387 */ 1391 */
1388 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, 1392 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102,
1389 .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", 1393 .driver = "Audigy2", .name = "SB Audigy 2 ZS Notebook [SB0530]",
1390 .id = "Audigy2", 1394 .id = "Audigy2",
1391 .emu10k2_chip = 1, 1395 .emu10k2_chip = 1,
1392 .ca0108_chip = 1, 1396 .ca0108_chip = 1,
@@ -1396,7 +1400,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1396 .spk71 = 1} , 1400 .spk71 = 1} ,
1397 /* Tested by James@superbug.co.uk 4th Nov 2007. */ 1401 /* Tested by James@superbug.co.uk 4th Nov 2007. */
1398 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102, 1402 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102,
1399 .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]", 1403 .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]",
1400 .id = "EMU1010", 1404 .id = "EMU1010",
1401 .emu10k2_chip = 1, 1405 .emu10k2_chip = 1,
1402 .ca0108_chip = 1, 1406 .ca0108_chip = 1,
@@ -1404,47 +1408,49 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1404 .spk71 = 1 , 1408 .spk71 = 1 ,
1405 .emu_model = EMU_MODEL_EMU1616}, 1409 .emu_model = EMU_MODEL_EMU1616},
1406 /* Tested by James@superbug.co.uk 4th Nov 2007. */ 1410 /* Tested by James@superbug.co.uk 4th Nov 2007. */
1411 /* This is MAEM8960, 0202 is MAEM 8980 */
1407 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102, 1412 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102,
1408 .driver = "Audigy2", .name = "E-mu 1010b PCI [MAEM????]", 1413 .driver = "Audigy2", .name = "E-mu 1010b PCI [MAEM8960]",
1409 .id = "EMU1010", 1414 .id = "EMU1010",
1410 .emu10k2_chip = 1, 1415 .emu10k2_chip = 1,
1411 .ca0108_chip = 1, 1416 .ca0108_chip = 1,
1412 .spk71 = 1, 1417 .spk71 = 1,
1413 .emu_model = EMU_MODEL_EMU1010B}, 1418 .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 new revision */
1414 /* Tested by James@superbug.co.uk 8th July 2005. */ 1419 /* Tested by James@superbug.co.uk 8th July 2005. */
1420 /* This is MAEM8810, 0202 is MAEM8820 */
1415 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, 1421 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
1416 .driver = "Audigy2", .name = "E-mu 1010 [4001]", 1422 .driver = "Audigy2", .name = "E-mu 1010 [MAEM8810]",
1417 .id = "EMU1010", 1423 .id = "EMU1010",
1418 .emu10k2_chip = 1, 1424 .emu10k2_chip = 1,
1419 .ca0102_chip = 1, 1425 .ca0102_chip = 1,
1420 .spk71 = 1, 1426 .spk71 = 1,
1421 .emu_model = EMU_MODEL_EMU1010}, /* Emu 1010 */ 1427 .emu_model = EMU_MODEL_EMU1010}, /* EMU 1010 old revision */
1422 /* EMU0404b */ 1428 /* EMU0404b */
1423 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40021102, 1429 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40021102,
1424 .driver = "Audigy2", .name = "E-mu 0404b [4002]", 1430 .driver = "Audigy2", .name = "E-mu 0404b PCI [MAEM8852]",
1425 .id = "EMU0404", 1431 .id = "EMU0404",
1426 .emu10k2_chip = 1, 1432 .emu10k2_chip = 1,
1427 .ca0108_chip = 1, 1433 .ca0108_chip = 1,
1428 .spk71 = 1, 1434 .spk71 = 1,
1429 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */ 1435 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 new revision */
1430 /* Tested by James@superbug.co.uk 20-3-2007. */ 1436 /* Tested by James@superbug.co.uk 20-3-2007. */
1431 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40021102, 1437 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40021102,
1432 .driver = "Audigy2", .name = "E-mu 0404 [4002]", 1438 .driver = "Audigy2", .name = "E-mu 0404 [MAEM8850]",
1433 .id = "EMU0404", 1439 .id = "EMU0404",
1434 .emu10k2_chip = 1, 1440 .emu10k2_chip = 1,
1435 .ca0102_chip = 1, 1441 .ca0102_chip = 1,
1436 .spk71 = 1, 1442 .spk71 = 1,
1437 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */ 1443 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */
1438 /* Audigy4 (Not PRO) SB0610 */ 1444 /* Note that all E-mu cards require kernel 2.6 or newer. */
1439 {.vendor = 0x1102, .device = 0x0008, 1445 {.vendor = 0x1102, .device = 0x0008,
1440 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 1446 .driver = "Audigy2", .name = "SB Audigy 2 Value [Unknown]",
1441 .id = "Audigy2", 1447 .id = "Audigy2",
1442 .emu10k2_chip = 1, 1448 .emu10k2_chip = 1,
1443 .ca0108_chip = 1, 1449 .ca0108_chip = 1,
1444 .ac97_chip = 1} , 1450 .ac97_chip = 1} ,
1445 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1451 /* Tested by James@superbug.co.uk 3rd July 2005 */
1446 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, 1452 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102,
1447 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", 1453 .driver = "Audigy2", .name = "SB Audigy 4 PRO [SB0380]",
1448 .id = "Audigy2", 1454 .id = "Audigy2",
1449 .emu10k2_chip = 1, 1455 .emu10k2_chip = 1,
1450 .ca0102_chip = 1, 1456 .ca0102_chip = 1,
@@ -1457,7 +1463,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1457 * Just like 0x20021102 1463 * Just like 0x20021102
1458 */ 1464 */
1459 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102, 1465 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102,
1460 .driver = "Audigy2", .name = "Audigy 2 [SB0350b]", 1466 .driver = "Audigy2", .name = "SB Audigy 2 [SB0350b]",
1461 .id = "Audigy2", 1467 .id = "Audigy2",
1462 .emu10k2_chip = 1, 1468 .emu10k2_chip = 1,
1463 .ca0102_chip = 1, 1469 .ca0102_chip = 1,
@@ -1467,7 +1473,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1467 .invert_shared_spdif = 1, /* digital/analog switch swapped */ 1473 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1468 .ac97_chip = 1} , 1474 .ac97_chip = 1} ,
1469 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 1475 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102,
1470 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", 1476 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350]",
1471 .id = "Audigy2", 1477 .id = "Audigy2",
1472 .emu10k2_chip = 1, 1478 .emu10k2_chip = 1,
1473 .ca0102_chip = 1, 1479 .ca0102_chip = 1,
@@ -1477,7 +1483,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1477 .invert_shared_spdif = 1, /* digital/analog switch swapped */ 1483 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1478 .ac97_chip = 1} , 1484 .ac97_chip = 1} ,
1479 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, 1485 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102,
1480 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", 1486 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0360]",
1481 .id = "Audigy2", 1487 .id = "Audigy2",
1482 .emu10k2_chip = 1, 1488 .emu10k2_chip = 1,
1483 .ca0102_chip = 1, 1489 .ca0102_chip = 1,
@@ -1495,7 +1501,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1495 * CA0151: Yes 1501 * CA0151: Yes
1496 */ 1502 */
1497 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, 1503 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102,
1498 .driver = "Audigy2", .name = "Audigy 2 [SB0240]", 1504 .driver = "Audigy2", .name = "SB Audigy 2 [SB0240]",
1499 .id = "Audigy2", 1505 .id = "Audigy2",
1500 .emu10k2_chip = 1, 1506 .emu10k2_chip = 1,
1501 .ca0102_chip = 1, 1507 .ca0102_chip = 1,
@@ -1505,7 +1511,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1505 .adc_1361t = 1, /* 24 bit capture instead of 16bit */ 1511 .adc_1361t = 1, /* 24 bit capture instead of 16bit */
1506 .ac97_chip = 1} , 1512 .ac97_chip = 1} ,
1507 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, 1513 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102,
1508 .driver = "Audigy2", .name = "Audigy 2 EX [1005]", 1514 .driver = "Audigy2", .name = "SB Audigy 2 Platinum EX [SB0280]",
1509 .id = "Audigy2", 1515 .id = "Audigy2",
1510 .emu10k2_chip = 1, 1516 .emu10k2_chip = 1,
1511 .ca0102_chip = 1, 1517 .ca0102_chip = 1,
@@ -1515,7 +1521,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1515 /* Dell OEM/Creative Labs Audigy 2 ZS */ 1521 /* Dell OEM/Creative Labs Audigy 2 ZS */
1516 /* See ALSA bug#1365 */ 1522 /* See ALSA bug#1365 */
1517 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102, 1523 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102,
1518 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0353]", 1524 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0353]",
1519 .id = "Audigy2", 1525 .id = "Audigy2",
1520 .emu10k2_chip = 1, 1526 .emu10k2_chip = 1,
1521 .ca0102_chip = 1, 1527 .ca0102_chip = 1,
@@ -1524,7 +1530,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1524 .spdif_bug = 1, 1530 .spdif_bug = 1,
1525 .ac97_chip = 1} , 1531 .ac97_chip = 1} ,
1526 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, 1532 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
1527 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", 1533 .driver = "Audigy2", .name = "SB Audigy 2 Platinum [SB0240P]",
1528 .id = "Audigy2", 1534 .id = "Audigy2",
1529 .emu10k2_chip = 1, 1535 .emu10k2_chip = 1,
1530 .ca0102_chip = 1, 1536 .ca0102_chip = 1,
@@ -1535,7 +1541,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1535 .adc_1361t = 1, /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */ 1541 .adc_1361t = 1, /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */
1536 .ac97_chip = 1} , 1542 .ac97_chip = 1} ,
1537 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, 1543 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04,
1538 .driver = "Audigy2", .name = "Audigy 2 [Unknown]", 1544 .driver = "Audigy2", .name = "SB Audigy 2 [Unknown]",
1539 .id = "Audigy2", 1545 .id = "Audigy2",
1540 .emu10k2_chip = 1, 1546 .emu10k2_chip = 1,
1541 .ca0102_chip = 1, 1547 .ca0102_chip = 1,
@@ -1543,78 +1549,79 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1543 .spdif_bug = 1, 1549 .spdif_bug = 1,
1544 .ac97_chip = 1} , 1550 .ac97_chip = 1} ,
1545 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, 1551 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102,
1546 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 1552 .driver = "Audigy", .name = "SB Audigy 1 [SB0092]",
1547 .id = "Audigy", 1553 .id = "Audigy",
1548 .emu10k2_chip = 1, 1554 .emu10k2_chip = 1,
1549 .ca0102_chip = 1, 1555 .ca0102_chip = 1,
1550 .ac97_chip = 1} , 1556 .ac97_chip = 1} ,
1551 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102, 1557 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102,
1552 .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", 1558 .driver = "Audigy", .name = "SB Audigy 1 ES [SB0160]",
1553 .id = "Audigy", 1559 .id = "Audigy",
1554 .emu10k2_chip = 1, 1560 .emu10k2_chip = 1,
1555 .ca0102_chip = 1, 1561 .ca0102_chip = 1,
1556 .spdif_bug = 1, 1562 .spdif_bug = 1,
1557 .ac97_chip = 1} , 1563 .ac97_chip = 1} ,
1558 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, 1564 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102,
1559 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 1565 .driver = "Audigy", .name = "SB Audigy 1 [SB0090]",
1560 .id = "Audigy", 1566 .id = "Audigy",
1561 .emu10k2_chip = 1, 1567 .emu10k2_chip = 1,
1562 .ca0102_chip = 1, 1568 .ca0102_chip = 1,
1563 .ac97_chip = 1} , 1569 .ac97_chip = 1} ,
1564 {.vendor = 0x1102, .device = 0x0004, 1570 {.vendor = 0x1102, .device = 0x0004,
1565 .driver = "Audigy", .name = "Audigy 1 [Unknown]", 1571 .driver = "Audigy", .name = "Audigy 1 [Unknown]",
1566 .id = "Audigy", 1572 .id = "Audigy",
1567 .emu10k2_chip = 1, 1573 .emu10k2_chip = 1,
1568 .ca0102_chip = 1, 1574 .ca0102_chip = 1,
1569 .ac97_chip = 1} , 1575 .ac97_chip = 1} ,
1570 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, 1576 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102,
1571 .driver = "EMU10K1", .name = "SBLive! [SB0105]", 1577 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0220]",
1578 .id = "Live",
1579 .emu10k1_chip = 1,
1580 .ac97_chip = 1,
1581 .sblive51 = 1} ,
1582 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806b1102,
1583 .driver = "EMU10K1", .name = "SB Live! [SB0105]",
1572 .id = "Live", 1584 .id = "Live",
1573 .emu10k1_chip = 1, 1585 .emu10k1_chip = 1,
1574 .ac97_chip = 1, 1586 .ac97_chip = 1,
1575 .sblive51 = 1} , 1587 .sblive51 = 1} ,
1576 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, 1588 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806a1102,
1577 .driver = "EMU10K1", .name = "SBLive! Value [SB0103]", 1589 .driver = "EMU10K1", .name = "SB Live! Value [SB0103]",
1578 .id = "Live", 1590 .id = "Live",
1579 .emu10k1_chip = 1, 1591 .emu10k1_chip = 1,
1580 .ac97_chip = 1, 1592 .ac97_chip = 1,
1581 .sblive51 = 1} , 1593 .sblive51 = 1} ,
1582 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, 1594 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102,
1583 .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", 1595 .driver = "EMU10K1", .name = "SB Live! Value [SB0101]",
1584 .id = "Live", 1596 .id = "Live",
1585 .emu10k1_chip = 1, 1597 .emu10k1_chip = 1,
1586 .ac97_chip = 1, 1598 .ac97_chip = 1,
1587 .sblive51 = 1} , 1599 .sblive51 = 1} ,
1588 /* Tested by ALSA bug#1680 26th December 2005 */ 1600 /* Tested by ALSA bug#1680 26th December 2005 */
1589 /* note: It really has SB0220 written on the card. */ 1601 /* note: It really has SB0220 written on the card, */
1602 /* but it's SB0228 according to kx.inf */
1590 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, 1603 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102,
1591 .driver = "EMU10K1", .name = "SB Live 5.1 Dell OEM [SB0220]", 1604 .driver = "EMU10K1", .name = "SB Live! 5.1 Dell OEM [SB0228]",
1592 .id = "Live", 1605 .id = "Live",
1593 .emu10k1_chip = 1, 1606 .emu10k1_chip = 1,
1594 .ac97_chip = 1, 1607 .ac97_chip = 1,
1595 .sblive51 = 1} , 1608 .sblive51 = 1} ,
1596 /* Tested by Thomas Zehetbauer 27th Aug 2005 */ 1609 /* Tested by Thomas Zehetbauer 27th Aug 2005 */
1597 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, 1610 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102,
1598 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", 1611 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0220]",
1599 .id = "Live",
1600 .emu10k1_chip = 1,
1601 .ac97_chip = 1,
1602 .sblive51 = 1} ,
1603 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102,
1604 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]",
1605 .id = "Live", 1612 .id = "Live",
1606 .emu10k1_chip = 1, 1613 .emu10k1_chip = 1,
1607 .ac97_chip = 1, 1614 .ac97_chip = 1,
1608 .sblive51 = 1} , 1615 .sblive51 = 1} ,
1609 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, 1616 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102,
1610 .driver = "EMU10K1", .name = "SB Live 5.1", 1617 .driver = "EMU10K1", .name = "SB Live! 5.1",
1611 .id = "Live", 1618 .id = "Live",
1612 .emu10k1_chip = 1, 1619 .emu10k1_chip = 1,
1613 .ac97_chip = 1, 1620 .ac97_chip = 1,
1614 .sblive51 = 1} , 1621 .sblive51 = 1} ,
1615 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ 1622 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */
1616 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, 1623 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
1617 .driver = "EMU10K1", .name = "SBLive 5.1 [SB0060]", 1624 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0060]",
1618 .id = "Live", 1625 .id = "Live",
1619 .emu10k1_chip = 1, 1626 .emu10k1_chip = 1,
1620 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum 1627 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum
@@ -1622,78 +1629,78 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1622 */ 1629 */
1623 .sblive51 = 1} , 1630 .sblive51 = 1} ,
1624 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, 1631 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102,
1625 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", 1632 .driver = "EMU10K1", .name = "SB Live! Value [CT4850]",
1626 .id = "Live", 1633 .id = "Live",
1627 .emu10k1_chip = 1, 1634 .emu10k1_chip = 1,
1628 .ac97_chip = 1, 1635 .ac97_chip = 1,
1629 .sblive51 = 1} , 1636 .sblive51 = 1} ,
1630 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, 1637 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102,
1631 .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", 1638 .driver = "EMU10K1", .name = "SB Live! Platinum [CT4760P]",
1632 .id = "Live", 1639 .id = "Live",
1633 .emu10k1_chip = 1, 1640 .emu10k1_chip = 1,
1634 .ac97_chip = 1} , 1641 .ac97_chip = 1} ,
1635 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, 1642 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102,
1636 .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", 1643 .driver = "EMU10K1", .name = "SB Live! Value [CT4871]",
1637 .id = "Live", 1644 .id = "Live",
1638 .emu10k1_chip = 1, 1645 .emu10k1_chip = 1,
1639 .ac97_chip = 1, 1646 .ac97_chip = 1,
1640 .sblive51 = 1} , 1647 .sblive51 = 1} ,
1641 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, 1648 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102,
1642 .driver = "EMU10K1", .name = "SBLive! Value [CT4831]", 1649 .driver = "EMU10K1", .name = "SB Live! Value [CT4831]",
1643 .id = "Live", 1650 .id = "Live",
1644 .emu10k1_chip = 1, 1651 .emu10k1_chip = 1,
1645 .ac97_chip = 1, 1652 .ac97_chip = 1,
1646 .sblive51 = 1} , 1653 .sblive51 = 1} ,
1647 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, 1654 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102,
1648 .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", 1655 .driver = "EMU10K1", .name = "SB Live! Value [CT4870]",
1649 .id = "Live", 1656 .id = "Live",
1650 .emu10k1_chip = 1, 1657 .emu10k1_chip = 1,
1651 .ac97_chip = 1, 1658 .ac97_chip = 1,
1652 .sblive51 = 1} , 1659 .sblive51 = 1} ,
1653 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1660 /* Tested by James@superbug.co.uk 3rd July 2005 */
1654 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, 1661 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102,
1655 .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", 1662 .driver = "EMU10K1", .name = "SB Live! Value [CT4832]",
1656 .id = "Live", 1663 .id = "Live",
1657 .emu10k1_chip = 1, 1664 .emu10k1_chip = 1,
1658 .ac97_chip = 1, 1665 .ac97_chip = 1,
1659 .sblive51 = 1} , 1666 .sblive51 = 1} ,
1660 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, 1667 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102,
1661 .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", 1668 .driver = "EMU10K1", .name = "SB Live! Value [CT4830]",
1662 .id = "Live", 1669 .id = "Live",
1663 .emu10k1_chip = 1, 1670 .emu10k1_chip = 1,
1664 .ac97_chip = 1, 1671 .ac97_chip = 1,
1665 .sblive51 = 1} , 1672 .sblive51 = 1} ,
1666 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, 1673 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102,
1667 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", 1674 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]",
1668 .id = "Live", 1675 .id = "Live",
1669 .emu10k1_chip = 1, 1676 .emu10k1_chip = 1,
1670 .ac97_chip = 1, 1677 .ac97_chip = 1,
1671 .sblive51 = 1} , 1678 .sblive51 = 1} ,
1672 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, 1679 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102,
1673 .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", 1680 .driver = "EMU10K1", .name = "SB Live! Value [CT4780]",
1674 .id = "Live", 1681 .id = "Live",
1675 .emu10k1_chip = 1, 1682 .emu10k1_chip = 1,
1676 .ac97_chip = 1, 1683 .ac97_chip = 1,
1677 .sblive51 = 1} , 1684 .sblive51 = 1} ,
1678 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, 1685 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102,
1679 .driver = "EMU10K1", .name = "E-mu APS [4001]", 1686 .driver = "EMU10K1", .name = "E-mu APS [PC545]",
1680 .id = "APS", 1687 .id = "APS",
1681 .emu10k1_chip = 1, 1688 .emu10k1_chip = 1,
1682 .ecard = 1} , 1689 .ecard = 1} ,
1683 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, 1690 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102,
1684 .driver = "EMU10K1", .name = "SBLive! [CT4620]", 1691 .driver = "EMU10K1", .name = "SB Live! [CT4620]",
1685 .id = "Live", 1692 .id = "Live",
1686 .emu10k1_chip = 1, 1693 .emu10k1_chip = 1,
1687 .ac97_chip = 1, 1694 .ac97_chip = 1,
1688 .sblive51 = 1} , 1695 .sblive51 = 1} ,
1689 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, 1696 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102,
1690 .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", 1697 .driver = "EMU10K1", .name = "SB Live! Value [CT4670]",
1691 .id = "Live", 1698 .id = "Live",
1692 .emu10k1_chip = 1, 1699 .emu10k1_chip = 1,
1693 .ac97_chip = 1, 1700 .ac97_chip = 1,
1694 .sblive51 = 1} , 1701 .sblive51 = 1} ,
1695 {.vendor = 0x1102, .device = 0x0002, 1702 {.vendor = 0x1102, .device = 0x0002,
1696 .driver = "EMU10K1", .name = "SB Live [Unknown]", 1703 .driver = "EMU10K1", .name = "SB Live! [Unknown]",
1697 .id = "Live", 1704 .id = "Live",
1698 .emu10k1_chip = 1, 1705 .emu10k1_chip = 1,
1699 .ac97_chip = 1, 1706 .ac97_chip = 1,
@@ -1702,13 +1709,13 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1702}; 1709};
1703 1710
1704int __devinit snd_emu10k1_create(struct snd_card *card, 1711int __devinit snd_emu10k1_create(struct snd_card *card,
1705 struct pci_dev * pci, 1712 struct pci_dev *pci,
1706 unsigned short extin_mask, 1713 unsigned short extin_mask,
1707 unsigned short extout_mask, 1714 unsigned short extout_mask,
1708 long max_cache_bytes, 1715 long max_cache_bytes,
1709 int enable_ir, 1716 int enable_ir,
1710 uint subsystem, 1717 uint subsystem,
1711 struct snd_emu10k1 ** remu) 1718 struct snd_emu10k1 **remu)
1712{ 1719{
1713 struct snd_emu10k1 *emu; 1720 struct snd_emu10k1 *emu;
1714 int idx, err; 1721 int idx, err;
@@ -1718,11 +1725,12 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1718 static struct snd_device_ops ops = { 1725 static struct snd_device_ops ops = {
1719 .dev_free = snd_emu10k1_dev_free, 1726 .dev_free = snd_emu10k1_dev_free,
1720 }; 1727 };
1721 1728
1722 *remu = NULL; 1729 *remu = NULL;
1723 1730
1724 /* enable PCI device */ 1731 /* enable PCI device */
1725 if ((err = pci_enable_device(pci)) < 0) 1732 err = pci_enable_device(pci);
1733 if (err < 0)
1726 return err; 1734 return err;
1727 1735
1728 emu = kzalloc(sizeof(*emu), GFP_KERNEL); 1736 emu = kzalloc(sizeof(*emu), GFP_KERNEL);
@@ -1749,16 +1757,17 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1749 emu->revision = pci->revision; 1757 emu->revision = pci->revision;
1750 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 1758 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
1751 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 1759 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
1752 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); 1760 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);
1753 1761
1754 for (c = emu_chip_details; c->vendor; c++) { 1762 for (c = emu_chip_details; c->vendor; c++) {
1755 if (c->vendor == pci->vendor && c->device == pci->device) { 1763 if (c->vendor == pci->vendor && c->device == pci->device) {
1756 if (subsystem) { 1764 if (subsystem) {
1757 if (c->subsystem && (c->subsystem == subsystem) ) { 1765 if (c->subsystem && (c->subsystem == subsystem))
1758 break; 1766 break;
1759 } else continue; 1767 else
1768 continue;
1760 } else { 1769 } else {
1761 if (c->subsystem && (c->subsystem != emu->serial) ) 1770 if (c->subsystem && (c->subsystem != emu->serial))
1762 continue; 1771 continue;
1763 if (c->revision && c->revision != emu->revision) 1772 if (c->revision && c->revision != emu->revision)
1764 continue; 1773 continue;
@@ -1774,14 +1783,18 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1774 } 1783 }
1775 emu->card_capabilities = c; 1784 emu->card_capabilities = c;
1776 if (c->subsystem && !subsystem) 1785 if (c->subsystem && !subsystem)
1777 snd_printdd("Sound card name=%s\n", c->name); 1786 snd_printdd("Sound card name = %s\n", c->name);
1778 else if (subsystem) 1787 else if (subsystem)
1779 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x. Forced to subsytem=0x%x\n", 1788 snd_printdd("Sound card name = %s, "
1780 c->name, pci->vendor, pci->device, emu->serial, c->subsystem); 1789 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. "
1781 else 1790 "Forced to subsytem = 0x%x\n", c->name,
1782 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x.\n", 1791 pci->vendor, pci->device, emu->serial, c->subsystem);
1783 c->name, pci->vendor, pci->device, emu->serial); 1792 else
1784 1793 snd_printdd("Sound card name = %s, "
1794 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n",
1795 c->name, pci->vendor, pci->device,
1796 emu->serial);
1797
1785 if (!*card->id && c->id) { 1798 if (!*card->id && c->id) {
1786 int i, n = 0; 1799 int i, n = 0;
1787 strlcpy(card->id, c->id, sizeof(card->id)); 1800 strlcpy(card->id, c->id, sizeof(card->id));
@@ -1815,7 +1828,8 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1815 else 1828 else
1816 emu->gpr_base = FXGPREGBASE; 1829 emu->gpr_base = FXGPREGBASE;
1817 1830
1818 if ((err = pci_request_regions(pci, "EMU10K1")) < 0) { 1831 err = pci_request_regions(pci, "EMU10K1");
1832 if (err < 0) {
1819 kfree(emu); 1833 kfree(emu);
1820 pci_disable_device(pci); 1834 pci_disable_device(pci);
1821 return err; 1835 return err;
@@ -1862,21 +1876,25 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1862 emu->enable_ir = enable_ir; 1876 emu->enable_ir = enable_ir;
1863 1877
1864 if (emu->card_capabilities->ca_cardbus_chip) { 1878 if (emu->card_capabilities->ca_cardbus_chip) {
1865 if ((err = snd_emu10k1_cardbus_init(emu)) < 0) 1879 err = snd_emu10k1_cardbus_init(emu);
1880 if (err < 0)
1866 goto error; 1881 goto error;
1867 } 1882 }
1868 if (emu->card_capabilities->ecard) { 1883 if (emu->card_capabilities->ecard) {
1869 if ((err = snd_emu10k1_ecard_init(emu)) < 0) 1884 err = snd_emu10k1_ecard_init(emu);
1885 if (err < 0)
1870 goto error; 1886 goto error;
1871 } else if (emu->card_capabilities->emu_model) { 1887 } else if (emu->card_capabilities->emu_model) {
1872 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { 1888 err = snd_emu10k1_emu1010_init(emu);
1873 snd_emu10k1_free(emu); 1889 if (err < 0) {
1874 return err; 1890 snd_emu10k1_free(emu);
1875 } 1891 return err;
1892 }
1876 } else { 1893 } else {
1877 /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version 1894 /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version
1878 does not support this, it shouldn't do any harm */ 1895 does not support this, it shouldn't do any harm */
1879 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); 1896 snd_emu10k1_ptr_write(emu, AC97SLOT, 0,
1897 AC97SLOT_CNTR|AC97SLOT_LFE);
1880 } 1898 }
1881 1899
1882 /* initialize TRAM setup */ 1900 /* initialize TRAM setup */
@@ -1916,7 +1934,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1916 snd_emu10k1_synth_alloc(emu, 4096); 1934 snd_emu10k1_synth_alloc(emu, 4096);
1917 if (emu->reserved_page) 1935 if (emu->reserved_page)
1918 emu->reserved_page->map_locked = 1; 1936 emu->reserved_page->map_locked = 1;
1919 1937
1920 /* Clear silent pages and set up pointers */ 1938 /* Clear silent pages and set up pointers */
1921 memset(emu->silent_page.area, 0, PAGE_SIZE); 1939 memset(emu->silent_page.area, 0, PAGE_SIZE);
1922 silent_page = emu->silent_page.addr << 1; 1940 silent_page = emu->silent_page.addr << 1;
@@ -1929,19 +1947,23 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1929 emu->voices[idx].number = idx; 1947 emu->voices[idx].number = idx;
1930 } 1948 }
1931 1949
1932 if ((err = snd_emu10k1_init(emu, enable_ir, 0)) < 0) 1950 err = snd_emu10k1_init(emu, enable_ir, 0);
1951 if (err < 0)
1933 goto error; 1952 goto error;
1934#ifdef CONFIG_PM 1953#ifdef CONFIG_PM
1935 if ((err = alloc_pm_buffer(emu)) < 0) 1954 err = alloc_pm_buffer(emu);
1955 if (err < 0)
1936 goto error; 1956 goto error;
1937#endif 1957#endif
1938 1958
1939 /* Initialize the effect engine */ 1959 /* Initialize the effect engine */
1940 if ((err = snd_emu10k1_init_efx(emu)) < 0) 1960 err = snd_emu10k1_init_efx(emu);
1961 if (err < 0)
1941 goto error; 1962 goto error;
1942 snd_emu10k1_audio_enable(emu); 1963 snd_emu10k1_audio_enable(emu);
1943 1964
1944 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) 1965 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops);
1966 if (err < 0)
1945 goto error; 1967 goto error;
1946 1968
1947#ifdef CONFIG_PROC_FS 1969#ifdef CONFIG_PROC_FS
@@ -1981,7 +2003,7 @@ static int __devinit alloc_pm_buffer(struct snd_emu10k1 *emu)
1981 if (emu->audigy) 2003 if (emu->audigy)
1982 size += ARRAY_SIZE(saved_regs_audigy); 2004 size += ARRAY_SIZE(saved_regs_audigy);
1983 emu->saved_ptr = vmalloc(4 * NUM_G * size); 2005 emu->saved_ptr = vmalloc(4 * NUM_G * size);
1984 if (! emu->saved_ptr) 2006 if (!emu->saved_ptr)
1985 return -ENOMEM; 2007 return -ENOMEM;
1986 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) 2008 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0)
1987 return -ENOMEM; 2009 return -ENOMEM;
@@ -2026,7 +2048,7 @@ void snd_emu10k1_resume_init(struct snd_emu10k1 *emu)
2026 if (emu->card_capabilities->ecard) 2048 if (emu->card_capabilities->ecard)
2027 snd_emu10k1_ecard_init(emu); 2049 snd_emu10k1_ecard_init(emu);
2028 else if (emu->card_capabilities->emu_model) 2050 else if (emu->card_capabilities->emu_model)
2029 snd_emu10k1_emu1010_init(emu); 2051 snd_emu10k1_emu1010_init(emu);
2030 else 2052 else
2031 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); 2053 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE);
2032 snd_emu10k1_init(emu, emu->enable_ir, 1); 2054 snd_emu10k1_init(emu, emu->enable_ir, 1);
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 1b3f11702713..0dfa0540ce2c 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -382,23 +382,25 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
382 unsigned char status_mask = 382 unsigned char status_mask =
383 VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX | VT1724_IRQ_MTPCM; 383 VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX | VT1724_IRQ_MTPCM;
384 int handled = 0; 384 int handled = 0;
385#ifdef CONFIG_SND_DEBUG
386 int timeout = 0; 385 int timeout = 0;
387#endif
388 386
389 while (1) { 387 while (1) {
390 status = inb(ICEREG1724(ice, IRQSTAT)); 388 status = inb(ICEREG1724(ice, IRQSTAT));
391 status &= status_mask; 389 status &= status_mask;
392 if (status == 0) 390 if (status == 0)
393 break; 391 break;
394#ifdef CONFIG_SND_DEBUG
395 if (++timeout > 10) { 392 if (++timeout > 10) {
396 printk(KERN_ERR 393 status = inb(ICEREG1724(ice, IRQSTAT));
397 "ice1724: Too long irq loop, status = 0x%x\n", 394 printk(KERN_ERR "ice1724: Too long irq loop, "
398 status); 395 "status = 0x%x\n", status);
396 if (status & VT1724_IRQ_MPU_TX) {
397 printk(KERN_ERR "ice1724: Disabling MPU_TX\n");
398 outb(inb(ICEREG1724(ice, IRQMASK)) |
399 VT1724_IRQ_MPU_TX,
400 ICEREG1724(ice, IRQMASK));
401 }
399 break; 402 break;
400 } 403 }
401#endif
402 handled = 1; 404 handled = 1;
403 if (status & VT1724_IRQ_MPU_TX) { 405 if (status & VT1724_IRQ_MPU_TX) {
404 spin_lock(&ice->reg_lock); 406 spin_lock(&ice->reg_lock);
@@ -2351,7 +2353,6 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2351{ 2353{
2352 struct snd_ice1712 *ice; 2354 struct snd_ice1712 *ice;
2353 int err; 2355 int err;
2354 unsigned char mask;
2355 static struct snd_device_ops ops = { 2356 static struct snd_device_ops ops = {
2356 .dev_free = snd_vt1724_dev_free, 2357 .dev_free = snd_vt1724_dev_free,
2357 }; 2358 };
@@ -2412,9 +2413,9 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2412 return -EIO; 2413 return -EIO;
2413 } 2414 }
2414 2415
2415 /* unmask used interrupts */ 2416 /* MPU_RX and TX irq masks are cleared later dynamically */
2416 mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX; 2417 outb(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX , ICEREG1724(ice, IRQMASK));
2417 outb(mask, ICEREG1724(ice, IRQMASK)); 2418
2418 /* don't handle FIFO overrun/underruns (just yet), 2419 /* don't handle FIFO overrun/underruns (just yet),
2419 * since they cause machine lockups 2420 * since they cause machine lockups
2420 */ 2421 */
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index a38c0c790d2b..af76ee862d27 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -1033,7 +1033,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
1033 } 1033 }
1034 if (of_device_is_compatible(sound, "tumbler")) { 1034 if (of_device_is_compatible(sound, "tumbler")) {
1035 chip->model = PMAC_TUMBLER; 1035 chip->model = PMAC_TUMBLER;
1036 chip->can_capture = 0; /* no capture */ 1036 chip->can_capture = machine_is_compatible("PowerMac4,2");
1037 chip->can_duplex = 0; 1037 chip->can_duplex = 0;
1038 // chip->can_byte_swap = 0; /* FIXME: check this */ 1038 // chip->can_byte_swap = 0; /* FIXME: check this */
1039 chip->num_freqs = ARRAY_SIZE(tumbler_freqs); 1039 chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index f746e15b8481..3eb223385416 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -875,7 +875,8 @@ static struct snd_kcontrol_new snapper_mixers[] __initdata = {
875 .put = tumbler_put_master_switch 875 .put = tumbler_put_master_switch
876 }, 876 },
877 DEFINE_SNAPPER_MIX("PCM Playback Volume", 0, VOL_IDX_PCM), 877 DEFINE_SNAPPER_MIX("PCM Playback Volume", 0, VOL_IDX_PCM),
878 DEFINE_SNAPPER_MIX("PCM Playback Volume", 1, VOL_IDX_PCM2), 878 /* Alternative PCM is assigned to Mic analog loopback on iBook G4 */
879 DEFINE_SNAPPER_MIX("Mic Playback Volume", 0, VOL_IDX_PCM2),
879 DEFINE_SNAPPER_MIX("Monitor Mix Volume", 0, VOL_IDX_ADC), 880 DEFINE_SNAPPER_MIX("Monitor Mix Volume", 0, VOL_IDX_ADC),
880 DEFINE_SNAPPER_MONO("Tone Control - Bass", bass), 881 DEFINE_SNAPPER_MONO("Tone Control - Bass", bass),
881 DEFINE_SNAPPER_MONO("Tone Control - Treble", treble), 882 DEFINE_SNAPPER_MONO("Tone Control - Treble", treble),