aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-10-27 03:50:43 -0400
committerTakashi Iwai <tiwai@suse.de>2008-10-27 03:50:43 -0400
commit4fc85e451ff5e9b6ccd7f5cac7f65684755370e2 (patch)
tree08b0802d18eb23a6f4fea7394a856352836fcec6 /sound
parent9f50bbad8fc3b0f9fd453ab1e2716b3106d89b13 (diff)
parent67679b1fd166da8398e70b7dbffe12cfccf9c7bf (diff)
Merge branch 'topic/misc-next' into topic/misc
Diffstat (limited to 'sound')
-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/hda/patch_realtek.c88
-rw-r--r--sound/pci/hda/patch_sigmatel.c2
-rw-r--r--sound/pci/ice1712/ice1724.c20
-rw-r--r--sound/soc/codecs/Kconfig2
-rw-r--r--sound/soc/codecs/tlv320aic23.c10
11 files changed, 405 insertions, 321 deletions
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..87219bf0a35e 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;
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 e341f3f83b6a..40f95f549d2b 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, chip->timer.expires, 55 hrtimer_forward(&chip->timer, chip->timer.expires,
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);
@@ -121,10 +119,7 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
121 hrtimer_forward(&chip->timer, chip->timer.expires, ktime_set(0, ns)); 119 hrtimer_forward(&chip->timer, chip->timer.expires, ktime_set(0, ns));
122 return HRTIMER_RESTART; 120 return HRTIMER_RESTART;
123 121
124exit_nr_unlock2: 122 stop:
125 snd_pcm_stream_unlock(substream);
126exit_nr_unlock1:
127 spin_unlock_irq(&chip->substream_lock);
128 return HRTIMER_NORESTART; 123 return HRTIMER_NORESTART;
129} 124}
130 125
@@ -164,26 +159,35 @@ static void pcsp_stop_playing(struct snd_pcsp *chip)
164 spin_unlock(&i8253_lock); 159 spin_unlock(&i8253_lock);
165} 160}
166 161
162/*
163 * Force to stop and sync the stream
164 */
165void pcsp_sync_stop(struct snd_pcsp *chip)
166{
167 local_irq_disable();
168 pcsp_stop_playing(chip);
169 local_irq_enable();
170 hrtimer_cancel(&chip->timer);
171 tasklet_kill(&pcsp_pcm_tasklet);
172}
173
167static int snd_pcsp_playback_close(struct snd_pcm_substream *substream) 174static int snd_pcsp_playback_close(struct snd_pcm_substream *substream)
168{ 175{
169 struct snd_pcsp *chip = snd_pcm_substream_chip(substream); 176 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
170#if PCSP_DEBUG 177#if PCSP_DEBUG
171 printk(KERN_INFO "PCSP: close called\n"); 178 printk(KERN_INFO "PCSP: close called\n");
172#endif 179#endif
173 if (atomic_read(&chip->timer_active)) { 180 pcsp_sync_stop(chip);
174 printk(KERN_ERR "PCSP: timer still active\n");
175 pcsp_stop_playing(chip);
176 }
177 spin_lock_irq(&chip->substream_lock);
178 chip->playback_substream = NULL; 181 chip->playback_substream = NULL;
179 spin_unlock_irq(&chip->substream_lock);
180 return 0; 182 return 0;
181} 183}
182 184
183static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream, 185static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream,
184 struct snd_pcm_hw_params *hw_params) 186 struct snd_pcm_hw_params *hw_params)
185{ 187{
188 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
186 int err; 189 int err;
190 pcsp_sync_stop(chip);
187 err = snd_pcm_lib_malloc_pages(substream, 191 err = snd_pcm_lib_malloc_pages(substream,
188 params_buffer_bytes(hw_params)); 192 params_buffer_bytes(hw_params));
189 if (err < 0) 193 if (err < 0)
@@ -193,9 +197,11 @@ static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream,
193 197
194static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream) 198static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream)
195{ 199{
200 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
196#if PCSP_DEBUG 201#if PCSP_DEBUG
197 printk(KERN_INFO "PCSP: hw_free called\n"); 202 printk(KERN_INFO "PCSP: hw_free called\n");
198#endif 203#endif
204 pcsp_sync_stop(chip);
199 return snd_pcm_lib_free_pages(substream); 205 return snd_pcm_lib_free_pages(substream);
200} 206}
201 207
@@ -211,6 +217,7 @@ static int snd_pcsp_playback_prepare(struct snd_pcm_substream *substream)
211 snd_pcm_lib_period_bytes(substream), 217 snd_pcm_lib_period_bytes(substream),
212 substream->runtime->periods); 218 substream->runtime->periods);
213#endif 219#endif
220 pcsp_sync_stop(chip);
214 chip->playback_ptr = 0; 221 chip->playback_ptr = 0;
215 chip->period_ptr = 0; 222 chip->period_ptr = 0;
216 return 0; 223 return 0;
@@ -241,7 +248,11 @@ static snd_pcm_uframes_t snd_pcsp_playback_pointer(struct snd_pcm_substream
241 *substream) 248 *substream)
242{ 249{
243 struct snd_pcsp *chip = snd_pcm_substream_chip(substream); 250 struct snd_pcsp *chip = snd_pcm_substream_chip(substream);
244 return bytes_to_frames(substream->runtime, chip->playback_ptr); 251 unsigned int pos;
252 spin_lock(&chip->substream_lock);
253 pos = chip->playback_ptr;
254 spin_unlock(&chip->substream_lock);
255 return bytes_to_frames(substream->runtime, pos);
245} 256}
246 257
247static struct snd_pcm_hardware snd_pcsp_playback = { 258static struct snd_pcm_hardware snd_pcsp_playback = {
@@ -278,9 +289,7 @@ static int snd_pcsp_playback_open(struct snd_pcm_substream *substream)
278 return -EBUSY; 289 return -EBUSY;
279 } 290 }
280 runtime->hw = snd_pcsp_playback; 291 runtime->hw = snd_pcsp_playback;
281 spin_lock_irq(&chip->substream_lock);
282 chip->playback_substream = substream; 292 chip->playback_substream = substream;
283 spin_unlock_irq(&chip->substream_lock);
284 return 0; 293 return 0;
285} 294}
286 295
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 2f283ea6ad9a..dee7ebabccee 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,
@@ -1466,7 +1472,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1466 .spdif_bug = 1, 1472 .spdif_bug = 1,
1467 .ac97_chip = 1} , 1473 .ac97_chip = 1} ,
1468 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 1474 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102,
1469 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", 1475 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350]",
1470 .id = "Audigy2", 1476 .id = "Audigy2",
1471 .emu10k2_chip = 1, 1477 .emu10k2_chip = 1,
1472 .ca0102_chip = 1, 1478 .ca0102_chip = 1,
@@ -1475,7 +1481,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1475 .spdif_bug = 1, 1481 .spdif_bug = 1,
1476 .ac97_chip = 1} , 1482 .ac97_chip = 1} ,
1477 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, 1483 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102,
1478 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", 1484 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0360]",
1479 .id = "Audigy2", 1485 .id = "Audigy2",
1480 .emu10k2_chip = 1, 1486 .emu10k2_chip = 1,
1481 .ca0102_chip = 1, 1487 .ca0102_chip = 1,
@@ -1492,7 +1498,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1492 * CA0151: Yes 1498 * CA0151: Yes
1493 */ 1499 */
1494 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, 1500 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102,
1495 .driver = "Audigy2", .name = "Audigy 2 [SB0240]", 1501 .driver = "Audigy2", .name = "SB Audigy 2 [SB0240]",
1496 .id = "Audigy2", 1502 .id = "Audigy2",
1497 .emu10k2_chip = 1, 1503 .emu10k2_chip = 1,
1498 .ca0102_chip = 1, 1504 .ca0102_chip = 1,
@@ -1502,7 +1508,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1502 .adc_1361t = 1, /* 24 bit capture instead of 16bit */ 1508 .adc_1361t = 1, /* 24 bit capture instead of 16bit */
1503 .ac97_chip = 1} , 1509 .ac97_chip = 1} ,
1504 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, 1510 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102,
1505 .driver = "Audigy2", .name = "Audigy 2 EX [1005]", 1511 .driver = "Audigy2", .name = "SB Audigy 2 Platinum EX [SB0280]",
1506 .id = "Audigy2", 1512 .id = "Audigy2",
1507 .emu10k2_chip = 1, 1513 .emu10k2_chip = 1,
1508 .ca0102_chip = 1, 1514 .ca0102_chip = 1,
@@ -1512,7 +1518,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1512 /* Dell OEM/Creative Labs Audigy 2 ZS */ 1518 /* Dell OEM/Creative Labs Audigy 2 ZS */
1513 /* See ALSA bug#1365 */ 1519 /* See ALSA bug#1365 */
1514 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102, 1520 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102,
1515 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0353]", 1521 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0353]",
1516 .id = "Audigy2", 1522 .id = "Audigy2",
1517 .emu10k2_chip = 1, 1523 .emu10k2_chip = 1,
1518 .ca0102_chip = 1, 1524 .ca0102_chip = 1,
@@ -1521,7 +1527,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1521 .spdif_bug = 1, 1527 .spdif_bug = 1,
1522 .ac97_chip = 1} , 1528 .ac97_chip = 1} ,
1523 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, 1529 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
1524 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", 1530 .driver = "Audigy2", .name = "SB Audigy 2 Platinum [SB0240P]",
1525 .id = "Audigy2", 1531 .id = "Audigy2",
1526 .emu10k2_chip = 1, 1532 .emu10k2_chip = 1,
1527 .ca0102_chip = 1, 1533 .ca0102_chip = 1,
@@ -1532,7 +1538,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1532 .adc_1361t = 1, /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */ 1538 .adc_1361t = 1, /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */
1533 .ac97_chip = 1} , 1539 .ac97_chip = 1} ,
1534 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, 1540 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04,
1535 .driver = "Audigy2", .name = "Audigy 2 [Unknown]", 1541 .driver = "Audigy2", .name = "SB Audigy 2 [Unknown]",
1536 .id = "Audigy2", 1542 .id = "Audigy2",
1537 .emu10k2_chip = 1, 1543 .emu10k2_chip = 1,
1538 .ca0102_chip = 1, 1544 .ca0102_chip = 1,
@@ -1540,78 +1546,79 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1540 .spdif_bug = 1, 1546 .spdif_bug = 1,
1541 .ac97_chip = 1} , 1547 .ac97_chip = 1} ,
1542 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, 1548 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102,
1543 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 1549 .driver = "Audigy", .name = "SB Audigy 1 [SB0092]",
1544 .id = "Audigy", 1550 .id = "Audigy",
1545 .emu10k2_chip = 1, 1551 .emu10k2_chip = 1,
1546 .ca0102_chip = 1, 1552 .ca0102_chip = 1,
1547 .ac97_chip = 1} , 1553 .ac97_chip = 1} ,
1548 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102, 1554 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102,
1549 .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", 1555 .driver = "Audigy", .name = "SB Audigy 1 ES [SB0160]",
1550 .id = "Audigy", 1556 .id = "Audigy",
1551 .emu10k2_chip = 1, 1557 .emu10k2_chip = 1,
1552 .ca0102_chip = 1, 1558 .ca0102_chip = 1,
1553 .spdif_bug = 1, 1559 .spdif_bug = 1,
1554 .ac97_chip = 1} , 1560 .ac97_chip = 1} ,
1555 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, 1561 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102,
1556 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 1562 .driver = "Audigy", .name = "SB Audigy 1 [SB0090]",
1557 .id = "Audigy", 1563 .id = "Audigy",
1558 .emu10k2_chip = 1, 1564 .emu10k2_chip = 1,
1559 .ca0102_chip = 1, 1565 .ca0102_chip = 1,
1560 .ac97_chip = 1} , 1566 .ac97_chip = 1} ,
1561 {.vendor = 0x1102, .device = 0x0004, 1567 {.vendor = 0x1102, .device = 0x0004,
1562 .driver = "Audigy", .name = "Audigy 1 [Unknown]", 1568 .driver = "Audigy", .name = "Audigy 1 [Unknown]",
1563 .id = "Audigy", 1569 .id = "Audigy",
1564 .emu10k2_chip = 1, 1570 .emu10k2_chip = 1,
1565 .ca0102_chip = 1, 1571 .ca0102_chip = 1,
1566 .ac97_chip = 1} , 1572 .ac97_chip = 1} ,
1567 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, 1573 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102,
1568 .driver = "EMU10K1", .name = "SBLive! [SB0105]", 1574 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0220]",
1575 .id = "Live",
1576 .emu10k1_chip = 1,
1577 .ac97_chip = 1,
1578 .sblive51 = 1} ,
1579 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806b1102,
1580 .driver = "EMU10K1", .name = "SB Live! [SB0105]",
1569 .id = "Live", 1581 .id = "Live",
1570 .emu10k1_chip = 1, 1582 .emu10k1_chip = 1,
1571 .ac97_chip = 1, 1583 .ac97_chip = 1,
1572 .sblive51 = 1} , 1584 .sblive51 = 1} ,
1573 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, 1585 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806a1102,
1574 .driver = "EMU10K1", .name = "SBLive! Value [SB0103]", 1586 .driver = "EMU10K1", .name = "SB Live! Value [SB0103]",
1575 .id = "Live", 1587 .id = "Live",
1576 .emu10k1_chip = 1, 1588 .emu10k1_chip = 1,
1577 .ac97_chip = 1, 1589 .ac97_chip = 1,
1578 .sblive51 = 1} , 1590 .sblive51 = 1} ,
1579 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, 1591 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102,
1580 .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", 1592 .driver = "EMU10K1", .name = "SB Live! Value [SB0101]",
1581 .id = "Live", 1593 .id = "Live",
1582 .emu10k1_chip = 1, 1594 .emu10k1_chip = 1,
1583 .ac97_chip = 1, 1595 .ac97_chip = 1,
1584 .sblive51 = 1} , 1596 .sblive51 = 1} ,
1585 /* Tested by ALSA bug#1680 26th December 2005 */ 1597 /* Tested by ALSA bug#1680 26th December 2005 */
1586 /* note: It really has SB0220 written on the card. */ 1598 /* note: It really has SB0220 written on the card, */
1599 /* but it's SB0228 according to kx.inf */
1587 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, 1600 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102,
1588 .driver = "EMU10K1", .name = "SB Live 5.1 Dell OEM [SB0220]", 1601 .driver = "EMU10K1", .name = "SB Live! 5.1 Dell OEM [SB0228]",
1589 .id = "Live", 1602 .id = "Live",
1590 .emu10k1_chip = 1, 1603 .emu10k1_chip = 1,
1591 .ac97_chip = 1, 1604 .ac97_chip = 1,
1592 .sblive51 = 1} , 1605 .sblive51 = 1} ,
1593 /* Tested by Thomas Zehetbauer 27th Aug 2005 */ 1606 /* Tested by Thomas Zehetbauer 27th Aug 2005 */
1594 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, 1607 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102,
1595 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", 1608 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0220]",
1596 .id = "Live",
1597 .emu10k1_chip = 1,
1598 .ac97_chip = 1,
1599 .sblive51 = 1} ,
1600 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102,
1601 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]",
1602 .id = "Live", 1609 .id = "Live",
1603 .emu10k1_chip = 1, 1610 .emu10k1_chip = 1,
1604 .ac97_chip = 1, 1611 .ac97_chip = 1,
1605 .sblive51 = 1} , 1612 .sblive51 = 1} ,
1606 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, 1613 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102,
1607 .driver = "EMU10K1", .name = "SB Live 5.1", 1614 .driver = "EMU10K1", .name = "SB Live! 5.1",
1608 .id = "Live", 1615 .id = "Live",
1609 .emu10k1_chip = 1, 1616 .emu10k1_chip = 1,
1610 .ac97_chip = 1, 1617 .ac97_chip = 1,
1611 .sblive51 = 1} , 1618 .sblive51 = 1} ,
1612 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ 1619 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */
1613 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, 1620 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
1614 .driver = "EMU10K1", .name = "SBLive 5.1 [SB0060]", 1621 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0060]",
1615 .id = "Live", 1622 .id = "Live",
1616 .emu10k1_chip = 1, 1623 .emu10k1_chip = 1,
1617 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum 1624 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum
@@ -1619,78 +1626,78 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1619 */ 1626 */
1620 .sblive51 = 1} , 1627 .sblive51 = 1} ,
1621 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, 1628 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102,
1622 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", 1629 .driver = "EMU10K1", .name = "SB Live! Value [CT4850]",
1623 .id = "Live", 1630 .id = "Live",
1624 .emu10k1_chip = 1, 1631 .emu10k1_chip = 1,
1625 .ac97_chip = 1, 1632 .ac97_chip = 1,
1626 .sblive51 = 1} , 1633 .sblive51 = 1} ,
1627 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, 1634 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102,
1628 .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", 1635 .driver = "EMU10K1", .name = "SB Live! Platinum [CT4760P]",
1629 .id = "Live", 1636 .id = "Live",
1630 .emu10k1_chip = 1, 1637 .emu10k1_chip = 1,
1631 .ac97_chip = 1} , 1638 .ac97_chip = 1} ,
1632 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, 1639 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102,
1633 .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", 1640 .driver = "EMU10K1", .name = "SB Live! Value [CT4871]",
1634 .id = "Live", 1641 .id = "Live",
1635 .emu10k1_chip = 1, 1642 .emu10k1_chip = 1,
1636 .ac97_chip = 1, 1643 .ac97_chip = 1,
1637 .sblive51 = 1} , 1644 .sblive51 = 1} ,
1638 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, 1645 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102,
1639 .driver = "EMU10K1", .name = "SBLive! Value [CT4831]", 1646 .driver = "EMU10K1", .name = "SB Live! Value [CT4831]",
1640 .id = "Live", 1647 .id = "Live",
1641 .emu10k1_chip = 1, 1648 .emu10k1_chip = 1,
1642 .ac97_chip = 1, 1649 .ac97_chip = 1,
1643 .sblive51 = 1} , 1650 .sblive51 = 1} ,
1644 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, 1651 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102,
1645 .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", 1652 .driver = "EMU10K1", .name = "SB Live! Value [CT4870]",
1646 .id = "Live", 1653 .id = "Live",
1647 .emu10k1_chip = 1, 1654 .emu10k1_chip = 1,
1648 .ac97_chip = 1, 1655 .ac97_chip = 1,
1649 .sblive51 = 1} , 1656 .sblive51 = 1} ,
1650 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1657 /* Tested by James@superbug.co.uk 3rd July 2005 */
1651 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, 1658 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102,
1652 .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", 1659 .driver = "EMU10K1", .name = "SB Live! Value [CT4832]",
1653 .id = "Live", 1660 .id = "Live",
1654 .emu10k1_chip = 1, 1661 .emu10k1_chip = 1,
1655 .ac97_chip = 1, 1662 .ac97_chip = 1,
1656 .sblive51 = 1} , 1663 .sblive51 = 1} ,
1657 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, 1664 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102,
1658 .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", 1665 .driver = "EMU10K1", .name = "SB Live! Value [CT4830]",
1659 .id = "Live", 1666 .id = "Live",
1660 .emu10k1_chip = 1, 1667 .emu10k1_chip = 1,
1661 .ac97_chip = 1, 1668 .ac97_chip = 1,
1662 .sblive51 = 1} , 1669 .sblive51 = 1} ,
1663 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, 1670 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102,
1664 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", 1671 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]",
1665 .id = "Live", 1672 .id = "Live",
1666 .emu10k1_chip = 1, 1673 .emu10k1_chip = 1,
1667 .ac97_chip = 1, 1674 .ac97_chip = 1,
1668 .sblive51 = 1} , 1675 .sblive51 = 1} ,
1669 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, 1676 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102,
1670 .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", 1677 .driver = "EMU10K1", .name = "SB Live! Value [CT4780]",
1671 .id = "Live", 1678 .id = "Live",
1672 .emu10k1_chip = 1, 1679 .emu10k1_chip = 1,
1673 .ac97_chip = 1, 1680 .ac97_chip = 1,
1674 .sblive51 = 1} , 1681 .sblive51 = 1} ,
1675 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, 1682 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102,
1676 .driver = "EMU10K1", .name = "E-mu APS [4001]", 1683 .driver = "EMU10K1", .name = "E-mu APS [PC545]",
1677 .id = "APS", 1684 .id = "APS",
1678 .emu10k1_chip = 1, 1685 .emu10k1_chip = 1,
1679 .ecard = 1} , 1686 .ecard = 1} ,
1680 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, 1687 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102,
1681 .driver = "EMU10K1", .name = "SBLive! [CT4620]", 1688 .driver = "EMU10K1", .name = "SB Live! [CT4620]",
1682 .id = "Live", 1689 .id = "Live",
1683 .emu10k1_chip = 1, 1690 .emu10k1_chip = 1,
1684 .ac97_chip = 1, 1691 .ac97_chip = 1,
1685 .sblive51 = 1} , 1692 .sblive51 = 1} ,
1686 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, 1693 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102,
1687 .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", 1694 .driver = "EMU10K1", .name = "SB Live! Value [CT4670]",
1688 .id = "Live", 1695 .id = "Live",
1689 .emu10k1_chip = 1, 1696 .emu10k1_chip = 1,
1690 .ac97_chip = 1, 1697 .ac97_chip = 1,
1691 .sblive51 = 1} , 1698 .sblive51 = 1} ,
1692 {.vendor = 0x1102, .device = 0x0002, 1699 {.vendor = 0x1102, .device = 0x0002,
1693 .driver = "EMU10K1", .name = "SB Live [Unknown]", 1700 .driver = "EMU10K1", .name = "SB Live! [Unknown]",
1694 .id = "Live", 1701 .id = "Live",
1695 .emu10k1_chip = 1, 1702 .emu10k1_chip = 1,
1696 .ac97_chip = 1, 1703 .ac97_chip = 1,
@@ -1699,13 +1706,13 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1699}; 1706};
1700 1707
1701int __devinit snd_emu10k1_create(struct snd_card *card, 1708int __devinit snd_emu10k1_create(struct snd_card *card,
1702 struct pci_dev * pci, 1709 struct pci_dev *pci,
1703 unsigned short extin_mask, 1710 unsigned short extin_mask,
1704 unsigned short extout_mask, 1711 unsigned short extout_mask,
1705 long max_cache_bytes, 1712 long max_cache_bytes,
1706 int enable_ir, 1713 int enable_ir,
1707 uint subsystem, 1714 uint subsystem,
1708 struct snd_emu10k1 ** remu) 1715 struct snd_emu10k1 **remu)
1709{ 1716{
1710 struct snd_emu10k1 *emu; 1717 struct snd_emu10k1 *emu;
1711 int idx, err; 1718 int idx, err;
@@ -1715,11 +1722,12 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1715 static struct snd_device_ops ops = { 1722 static struct snd_device_ops ops = {
1716 .dev_free = snd_emu10k1_dev_free, 1723 .dev_free = snd_emu10k1_dev_free,
1717 }; 1724 };
1718 1725
1719 *remu = NULL; 1726 *remu = NULL;
1720 1727
1721 /* enable PCI device */ 1728 /* enable PCI device */
1722 if ((err = pci_enable_device(pci)) < 0) 1729 err = pci_enable_device(pci);
1730 if (err < 0)
1723 return err; 1731 return err;
1724 1732
1725 emu = kzalloc(sizeof(*emu), GFP_KERNEL); 1733 emu = kzalloc(sizeof(*emu), GFP_KERNEL);
@@ -1746,16 +1754,17 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1746 emu->revision = pci->revision; 1754 emu->revision = pci->revision;
1747 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 1755 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
1748 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 1756 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
1749 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); 1757 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);
1750 1758
1751 for (c = emu_chip_details; c->vendor; c++) { 1759 for (c = emu_chip_details; c->vendor; c++) {
1752 if (c->vendor == pci->vendor && c->device == pci->device) { 1760 if (c->vendor == pci->vendor && c->device == pci->device) {
1753 if (subsystem) { 1761 if (subsystem) {
1754 if (c->subsystem && (c->subsystem == subsystem) ) { 1762 if (c->subsystem && (c->subsystem == subsystem))
1755 break; 1763 break;
1756 } else continue; 1764 else
1765 continue;
1757 } else { 1766 } else {
1758 if (c->subsystem && (c->subsystem != emu->serial) ) 1767 if (c->subsystem && (c->subsystem != emu->serial))
1759 continue; 1768 continue;
1760 if (c->revision && c->revision != emu->revision) 1769 if (c->revision && c->revision != emu->revision)
1761 continue; 1770 continue;
@@ -1771,14 +1780,18 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1771 } 1780 }
1772 emu->card_capabilities = c; 1781 emu->card_capabilities = c;
1773 if (c->subsystem && !subsystem) 1782 if (c->subsystem && !subsystem)
1774 snd_printdd("Sound card name=%s\n", c->name); 1783 snd_printdd("Sound card name = %s\n", c->name);
1775 else if (subsystem) 1784 else if (subsystem)
1776 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x. Forced to subsytem=0x%x\n", 1785 snd_printdd("Sound card name = %s, "
1777 c->name, pci->vendor, pci->device, emu->serial, c->subsystem); 1786 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. "
1778 else 1787 "Forced to subsytem = 0x%x\n", c->name,
1779 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x.\n", 1788 pci->vendor, pci->device, emu->serial, c->subsystem);
1780 c->name, pci->vendor, pci->device, emu->serial); 1789 else
1781 1790 snd_printdd("Sound card name = %s, "
1791 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n",
1792 c->name, pci->vendor, pci->device,
1793 emu->serial);
1794
1782 if (!*card->id && c->id) { 1795 if (!*card->id && c->id) {
1783 int i, n = 0; 1796 int i, n = 0;
1784 strlcpy(card->id, c->id, sizeof(card->id)); 1797 strlcpy(card->id, c->id, sizeof(card->id));
@@ -1812,7 +1825,8 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1812 else 1825 else
1813 emu->gpr_base = FXGPREGBASE; 1826 emu->gpr_base = FXGPREGBASE;
1814 1827
1815 if ((err = pci_request_regions(pci, "EMU10K1")) < 0) { 1828 err = pci_request_regions(pci, "EMU10K1");
1829 if (err < 0) {
1816 kfree(emu); 1830 kfree(emu);
1817 pci_disable_device(pci); 1831 pci_disable_device(pci);
1818 return err; 1832 return err;
@@ -1859,21 +1873,25 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1859 emu->enable_ir = enable_ir; 1873 emu->enable_ir = enable_ir;
1860 1874
1861 if (emu->card_capabilities->ca_cardbus_chip) { 1875 if (emu->card_capabilities->ca_cardbus_chip) {
1862 if ((err = snd_emu10k1_cardbus_init(emu)) < 0) 1876 err = snd_emu10k1_cardbus_init(emu);
1877 if (err < 0)
1863 goto error; 1878 goto error;
1864 } 1879 }
1865 if (emu->card_capabilities->ecard) { 1880 if (emu->card_capabilities->ecard) {
1866 if ((err = snd_emu10k1_ecard_init(emu)) < 0) 1881 err = snd_emu10k1_ecard_init(emu);
1882 if (err < 0)
1867 goto error; 1883 goto error;
1868 } else if (emu->card_capabilities->emu_model) { 1884 } else if (emu->card_capabilities->emu_model) {
1869 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { 1885 err = snd_emu10k1_emu1010_init(emu);
1870 snd_emu10k1_free(emu); 1886 if (err < 0) {
1871 return err; 1887 snd_emu10k1_free(emu);
1872 } 1888 return err;
1889 }
1873 } else { 1890 } else {
1874 /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version 1891 /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version
1875 does not support this, it shouldn't do any harm */ 1892 does not support this, it shouldn't do any harm */
1876 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); 1893 snd_emu10k1_ptr_write(emu, AC97SLOT, 0,
1894 AC97SLOT_CNTR|AC97SLOT_LFE);
1877 } 1895 }
1878 1896
1879 /* initialize TRAM setup */ 1897 /* initialize TRAM setup */
@@ -1913,7 +1931,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1913 snd_emu10k1_synth_alloc(emu, 4096); 1931 snd_emu10k1_synth_alloc(emu, 4096);
1914 if (emu->reserved_page) 1932 if (emu->reserved_page)
1915 emu->reserved_page->map_locked = 1; 1933 emu->reserved_page->map_locked = 1;
1916 1934
1917 /* Clear silent pages and set up pointers */ 1935 /* Clear silent pages and set up pointers */
1918 memset(emu->silent_page.area, 0, PAGE_SIZE); 1936 memset(emu->silent_page.area, 0, PAGE_SIZE);
1919 silent_page = emu->silent_page.addr << 1; 1937 silent_page = emu->silent_page.addr << 1;
@@ -1926,19 +1944,23 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1926 emu->voices[idx].number = idx; 1944 emu->voices[idx].number = idx;
1927 } 1945 }
1928 1946
1929 if ((err = snd_emu10k1_init(emu, enable_ir, 0)) < 0) 1947 err = snd_emu10k1_init(emu, enable_ir, 0);
1948 if (err < 0)
1930 goto error; 1949 goto error;
1931#ifdef CONFIG_PM 1950#ifdef CONFIG_PM
1932 if ((err = alloc_pm_buffer(emu)) < 0) 1951 err = alloc_pm_buffer(emu);
1952 if (err < 0)
1933 goto error; 1953 goto error;
1934#endif 1954#endif
1935 1955
1936 /* Initialize the effect engine */ 1956 /* Initialize the effect engine */
1937 if ((err = snd_emu10k1_init_efx(emu)) < 0) 1957 err = snd_emu10k1_init_efx(emu);
1958 if (err < 0)
1938 goto error; 1959 goto error;
1939 snd_emu10k1_audio_enable(emu); 1960 snd_emu10k1_audio_enable(emu);
1940 1961
1941 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) 1962 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops);
1963 if (err < 0)
1942 goto error; 1964 goto error;
1943 1965
1944#ifdef CONFIG_PROC_FS 1966#ifdef CONFIG_PROC_FS
@@ -1978,7 +2000,7 @@ static int __devinit alloc_pm_buffer(struct snd_emu10k1 *emu)
1978 if (emu->audigy) 2000 if (emu->audigy)
1979 size += ARRAY_SIZE(saved_regs_audigy); 2001 size += ARRAY_SIZE(saved_regs_audigy);
1980 emu->saved_ptr = vmalloc(4 * NUM_G * size); 2002 emu->saved_ptr = vmalloc(4 * NUM_G * size);
1981 if (! emu->saved_ptr) 2003 if (!emu->saved_ptr)
1982 return -ENOMEM; 2004 return -ENOMEM;
1983 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) 2005 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0)
1984 return -ENOMEM; 2006 return -ENOMEM;
@@ -2023,7 +2045,7 @@ void snd_emu10k1_resume_init(struct snd_emu10k1 *emu)
2023 if (emu->card_capabilities->ecard) 2045 if (emu->card_capabilities->ecard)
2024 snd_emu10k1_ecard_init(emu); 2046 snd_emu10k1_ecard_init(emu);
2025 else if (emu->card_capabilities->emu_model) 2047 else if (emu->card_capabilities->emu_model)
2026 snd_emu10k1_emu1010_init(emu); 2048 snd_emu10k1_emu1010_init(emu);
2027 else 2049 else
2028 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); 2050 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE);
2029 snd_emu10k1_init(emu, emu->enable_ir, 1); 2051 snd_emu10k1_init(emu, emu->enable_ir, 1);
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0b6e682c46d0..e72707cb60a3 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -822,6 +822,27 @@ static void alc_sku_automute(struct hda_codec *codec)
822 spec->jack_present ? 0 : PIN_OUT); 822 spec->jack_present ? 0 : PIN_OUT);
823} 823}
824 824
825static void alc_mic_automute(struct hda_codec *codec)
826{
827 struct alc_spec *spec = codec->spec;
828 unsigned int present;
829 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
830 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
831 unsigned int mix_nid = spec->capsrc_nids[0];
832 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
833
834 capsrc_idx_mic = mic_nid - 0x18;
835 capsrc_idx_fmic = fmic_nid - 0x18;
836 present = snd_hda_codec_read(codec, mic_nid, 0,
837 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
838 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
839 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
840 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
841 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
842 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
843 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
844}
845
825/* unsolicited event for HP jack sensing */ 846/* unsolicited event for HP jack sensing */
826static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 847static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
827{ 848{
@@ -829,10 +850,17 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
829 res >>= 28; 850 res >>= 28;
830 else 851 else
831 res >>= 26; 852 res >>= 26;
832 if (res != ALC880_HP_EVENT) 853 if (res == ALC880_HP_EVENT)
833 return; 854 alc_sku_automute(codec);
855
856 if (res == ALC880_MIC_EVENT)
857 alc_mic_automute(codec);
858}
834 859
860static void alc_inithook(struct hda_codec *codec)
861{
835 alc_sku_automute(codec); 862 alc_sku_automute(codec);
863 alc_mic_automute(codec);
836} 864}
837 865
838/* additional initialization for ALC888 variants */ 866/* additional initialization for ALC888 variants */
@@ -1018,10 +1046,17 @@ do_sku:
1018 else 1046 else
1019 return; 1047 return;
1020 } 1048 }
1049 if (spec->autocfg.hp_pins[0])
1050 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1051 AC_VERB_SET_UNSOLICITED_ENABLE,
1052 AC_USRSP_EN | ALC880_HP_EVENT);
1021 1053
1022 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, 1054 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1023 AC_VERB_SET_UNSOLICITED_ENABLE, 1055 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1024 AC_USRSP_EN | ALC880_HP_EVENT); 1056 snd_hda_codec_write(codec,
1057 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1058 AC_VERB_SET_UNSOLICITED_ENABLE,
1059 AC_USRSP_EN | ALC880_MIC_EVENT);
1025 1060
1026 spec->unsol_event = alc_sku_unsol_event; 1061 spec->unsol_event = alc_sku_unsol_event;
1027} 1062}
@@ -3808,7 +3843,7 @@ static void alc880_auto_init(struct hda_codec *codec)
3808 alc880_auto_init_extra_out(codec); 3843 alc880_auto_init_extra_out(codec);
3809 alc880_auto_init_analog_input(codec); 3844 alc880_auto_init_analog_input(codec);
3810 if (spec->unsol_event) 3845 if (spec->unsol_event)
3811 alc_sku_automute(codec); 3846 alc_inithook(codec);
3812} 3847}
3813 3848
3814/* 3849/*
@@ -5219,7 +5254,7 @@ static void alc260_auto_init(struct hda_codec *codec)
5219 alc260_auto_init_multi_out(codec); 5254 alc260_auto_init_multi_out(codec);
5220 alc260_auto_init_analog_input(codec); 5255 alc260_auto_init_analog_input(codec);
5221 if (spec->unsol_event) 5256 if (spec->unsol_event)
5222 alc_sku_automute(codec); 5257 alc_inithook(codec);
5223} 5258}
5224 5259
5225#ifdef CONFIG_SND_HDA_POWER_SAVE 5260#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -6629,7 +6664,7 @@ static void alc882_auto_init(struct hda_codec *codec)
6629 alc882_auto_init_analog_input(codec); 6664 alc882_auto_init_analog_input(codec);
6630 alc882_auto_init_input_src(codec); 6665 alc882_auto_init_input_src(codec);
6631 if (spec->unsol_event) 6666 if (spec->unsol_event)
6632 alc_sku_automute(codec); 6667 alc_inithook(codec);
6633} 6668}
6634 6669
6635static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ 6670static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
@@ -8306,8 +8341,8 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8306 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8341 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8307 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8342 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8308 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8343 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8344 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8309 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8345 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8310 SND_PCI_QUIRK(0x1043, 0x8317, "Asus M90V", ALC888_ASUS_M90V),
8311 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8346 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8312 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8347 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8313 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 8348 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
@@ -8758,7 +8793,7 @@ static void alc883_auto_init(struct hda_codec *codec)
8758 alc883_auto_init_analog_input(codec); 8793 alc883_auto_init_analog_input(codec);
8759 alc883_auto_init_input_src(codec); 8794 alc883_auto_init_input_src(codec);
8760 if (spec->unsol_event) 8795 if (spec->unsol_event)
8761 alc_sku_automute(codec); 8796 alc_inithook(codec);
8762} 8797}
8763 8798
8764static int patch_alc883(struct hda_codec *codec) 8799static int patch_alc883(struct hda_codec *codec)
@@ -8802,8 +8837,13 @@ static int patch_alc883(struct hda_codec *codec)
8802 8837
8803 switch (codec->vendor_id) { 8838 switch (codec->vendor_id) {
8804 case 0x10ec0888: 8839 case 0x10ec0888:
8805 spec->stream_name_analog = "ALC888 Analog"; 8840 if (codec->revision_id == 0x100101) {
8806 spec->stream_name_digital = "ALC888 Digital"; 8841 spec->stream_name_analog = "ALC1200 Analog";
8842 spec->stream_name_digital = "ALC1200 Digital";
8843 } else {
8844 spec->stream_name_analog = "ALC888 Analog";
8845 spec->stream_name_digital = "ALC888 Digital";
8846 }
8807 break; 8847 break;
8808 case 0x10ec0889: 8848 case 0x10ec0889:
8809 spec->stream_name_analog = "ALC889 Analog"; 8849 spec->stream_name_analog = "ALC889 Analog";
@@ -10285,7 +10325,7 @@ static void alc262_auto_init(struct hda_codec *codec)
10285 alc262_auto_init_analog_input(codec); 10325 alc262_auto_init_analog_input(codec);
10286 alc262_auto_init_input_src(codec); 10326 alc262_auto_init_input_src(codec);
10287 if (spec->unsol_event) 10327 if (spec->unsol_event)
10288 alc_sku_automute(codec); 10328 alc_inithook(codec);
10289} 10329}
10290 10330
10291/* 10331/*
@@ -10343,7 +10383,7 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
10343 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), 10383 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
10344 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", 10384 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
10345 ALC262_TOSHIBA_RX1), 10385 ALC262_TOSHIBA_RX1),
10346 SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06), 10386 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
10347 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 10387 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
10348 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), 10388 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
10349 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 10389 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
@@ -11417,7 +11457,7 @@ static void alc268_auto_init(struct hda_codec *codec)
11417 alc268_auto_init_mono_speaker_out(codec); 11457 alc268_auto_init_mono_speaker_out(codec);
11418 alc268_auto_init_analog_input(codec); 11458 alc268_auto_init_analog_input(codec);
11419 if (spec->unsol_event) 11459 if (spec->unsol_event)
11420 alc_sku_automute(codec); 11460 alc_inithook(codec);
11421} 11461}
11422 11462
11423/* 11463/*
@@ -12200,7 +12240,7 @@ static void alc269_auto_init(struct hda_codec *codec)
12200 alc269_auto_init_hp_out(codec); 12240 alc269_auto_init_hp_out(codec);
12201 alc269_auto_init_analog_input(codec); 12241 alc269_auto_init_analog_input(codec);
12202 if (spec->unsol_event) 12242 if (spec->unsol_event)
12203 alc_sku_automute(codec); 12243 alc_inithook(codec);
12204} 12244}
12205 12245
12206/* 12246/*
@@ -13281,7 +13321,7 @@ static void alc861_auto_init(struct hda_codec *codec)
13281 alc861_auto_init_hp_out(codec); 13321 alc861_auto_init_hp_out(codec);
13282 alc861_auto_init_analog_input(codec); 13322 alc861_auto_init_analog_input(codec);
13283 if (spec->unsol_event) 13323 if (spec->unsol_event)
13284 alc_sku_automute(codec); 13324 alc_inithook(codec);
13285} 13325}
13286 13326
13287#ifdef CONFIG_SND_HDA_POWER_SAVE 13327#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -14393,7 +14433,7 @@ static void alc861vd_auto_init(struct hda_codec *codec)
14393 alc861vd_auto_init_analog_input(codec); 14433 alc861vd_auto_init_analog_input(codec);
14394 alc861vd_auto_init_input_src(codec); 14434 alc861vd_auto_init_input_src(codec);
14395 if (spec->unsol_event) 14435 if (spec->unsol_event)
14396 alc_sku_automute(codec); 14436 alc_inithook(codec);
14397} 14437}
14398 14438
14399static int patch_alc861vd(struct hda_codec *codec) 14439static int patch_alc861vd(struct hda_codec *codec)
@@ -15667,7 +15707,7 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
15667 15707
15668static struct snd_pci_quirk alc662_cfg_tbl[] = { 15708static struct snd_pci_quirk alc662_cfg_tbl[] = {
15669 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), 15709 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
15670 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V), 15710 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
15671 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), 15711 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
15672 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), 15712 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
15673 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), 15713 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
@@ -15680,6 +15720,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
15680 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), 15720 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15681 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), 15721 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15682 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1), 15722 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
15723 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
15683 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2), 15724 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15684 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), 15725 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15685 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), 15726 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
@@ -16223,7 +16264,7 @@ static void alc662_auto_init(struct hda_codec *codec)
16223 alc662_auto_init_analog_input(codec); 16264 alc662_auto_init_analog_input(codec);
16224 alc662_auto_init_input_src(codec); 16265 alc662_auto_init_input_src(codec);
16225 if (spec->unsol_event) 16266 if (spec->unsol_event)
16226 alc_sku_automute(codec); 16267 alc_inithook(codec);
16227} 16268}
16228 16269
16229static int patch_alc662(struct hda_codec *codec) 16270static int patch_alc662(struct hda_codec *codec)
@@ -16268,6 +16309,9 @@ static int patch_alc662(struct hda_codec *codec)
16268 if (codec->vendor_id == 0x10ec0663) { 16309 if (codec->vendor_id == 0x10ec0663) {
16269 spec->stream_name_analog = "ALC663 Analog"; 16310 spec->stream_name_analog = "ALC663 Analog";
16270 spec->stream_name_digital = "ALC663 Digital"; 16311 spec->stream_name_digital = "ALC663 Digital";
16312 } else if (codec->vendor_id == 0x10ec0272) {
16313 spec->stream_name_analog = "ALC272 Analog";
16314 spec->stream_name_digital = "ALC272 Digital";
16271 } else { 16315 } else {
16272 spec->stream_name_analog = "ALC662 Analog"; 16316 spec->stream_name_analog = "ALC662 Analog";
16273 spec->stream_name_digital = "ALC662 Digital"; 16317 spec->stream_name_digital = "ALC662 Digital";
@@ -16305,6 +16349,7 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
16305 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, 16349 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
16306 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, 16350 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
16307 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, 16351 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
16352 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
16308 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 16353 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
16309 .patch = patch_alc861 }, 16354 .patch = patch_alc861 },
16310 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 16355 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
@@ -16323,7 +16368,10 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
16323 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 16368 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
16324 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 16369 .patch = patch_alc882 }, /* should be patch_alc883() in future */
16325 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 16370 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
16371 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
16326 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 16372 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
16373 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16374 .patch = patch_alc883 },
16327 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 16375 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
16328 {} /* terminator */ 16376 {} /* terminator */
16329}; 16377};
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index c59065513118..a2ac7205d45d 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -2816,7 +2816,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2816 static const char *chname[4] = { 2816 static const char *chname[4] = {
2817 "Front", "Surround", NULL /*CLFE*/, "Side" 2817 "Front", "Surround", NULL /*CLFE*/, "Side"
2818 }; 2818 };
2819 hda_nid_t nid; 2819 hda_nid_t nid = 0;
2820 int i, err; 2820 int i, err;
2821 2821
2822 struct sigmatel_spec *spec = codec->spec; 2822 struct sigmatel_spec *spec = codec->spec;
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 1b3f11702713..79a9cd0881f7 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,7 @@ 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; 2356 /* unsigned char mask; */
2355 static struct snd_device_ops ops = { 2357 static struct snd_device_ops ops = {
2356 .dev_free = snd_vt1724_dev_free, 2358 .dev_free = snd_vt1724_dev_free,
2357 }; 2359 };
@@ -2413,8 +2415,10 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2413 } 2415 }
2414 2416
2415 /* unmask used interrupts */ 2417 /* unmask used interrupts */
2418#if 0 /* these are enabled/disabled dynamically */
2416 mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX; 2419 mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX;
2417 outb(mask, ICEREG1724(ice, IRQMASK)); 2420 outb(mask, ICEREG1724(ice, IRQMASK));
2421#endif
2418 /* don't handle FIFO overrun/underruns (just yet), 2422 /* don't handle FIFO overrun/underruns (just yet),
2419 * since they cause machine lockups 2423 * since they cause machine lockups
2420 */ 2424 */
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 4975d8573e4f..38a0e3b620a7 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -68,7 +68,7 @@ config SND_SOC_TLV320AIC23
68 depends on I2C 68 depends on I2C
69 69
70config SND_SOC_TLV320AIC26 70config SND_SOC_TLV320AIC26
71 tristate "TI TLV320AIC26 Codec support" 71 tristate "TI TLV320AIC26 Codec support" if SND_SOC_OF_SIMPLE
72 depends on SPI 72 depends on SPI
73 73
74config SND_SOC_TLV320AIC3X 74config SND_SOC_TLV320AIC3X
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
index bac7815e00fb..44308dac9e18 100644
--- a/sound/soc/codecs/tlv320aic23.c
+++ b/sound/soc/codecs/tlv320aic23.c
@@ -84,7 +84,7 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg,
84 unsigned int value) 84 unsigned int value)
85{ 85{
86 86
87 u8 data; 87 u8 data[2];
88 88
89 /* TLV320AIC23 has 7 bit address and 9 bits of data 89 /* TLV320AIC23 has 7 bit address and 9 bits of data
90 * so we need to switch one data bit into reg and rest 90 * so we need to switch one data bit into reg and rest
@@ -96,12 +96,12 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg,
96 return -1; 96 return -1;
97 } 97 }
98 98
99 data = (reg << 1) | (value >> 8 & 0x01); 99 data[0] = (reg << 1) | (value >> 8 & 0x01);
100 data[1] = value & 0xff;
100 101
101 tlv320aic23_write_reg_cache(codec, reg, value); 102 tlv320aic23_write_reg_cache(codec, reg, value);
102 103
103 if (codec->hw_write(codec->control_data, data, 104 if (codec->hw_write(codec->control_data, data, 2) == 2)
104 (value & 0xff)) == 0)
105 return 0; 105 return 0;
106 106
107 printk(KERN_ERR "%s cannot write %03x to register R%d\n", __func__, 107 printk(KERN_ERR "%s cannot write %03x to register R%d\n", __func__,
@@ -674,7 +674,7 @@ static int tlv320aic23_probe(struct platform_device *pdev)
674 674
675 tlv320aic23_socdev = socdev; 675 tlv320aic23_socdev = socdev;
676#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 676#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
677 codec->hw_write = (hw_write_t) i2c_smbus_write_byte_data; 677 codec->hw_write = (hw_write_t) i2c_master_send;
678 codec->hw_read = NULL; 678 codec->hw_read = NULL;
679 ret = i2c_add_driver(&tlv320aic23_i2c_driver); 679 ret = i2c_add_driver(&tlv320aic23_i2c_driver);
680 if (ret != 0) 680 if (ret != 0)