aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/core/vmaster.c18
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pcm.c2
-rw-r--r--sound/pci/hda/hda_codec.c70
-rw-r--r--sound/pci/hda/hda_codec.h1
-rw-r--r--sound/pci/hda/hda_eld.c41
-rw-r--r--sound/pci/hda/hda_intel.c5
-rw-r--r--sound/pci/hda/hda_local.h19
-rw-r--r--sound/pci/hda/patch_cirrus.c55
-rw-r--r--sound/pci/hda/patch_conexant.c1
-rw-r--r--sound/pci/hda/patch_hdmi.c59
-rw-r--r--sound/pci/hda/patch_realtek.c114
-rw-r--r--sound/pci/hda/patch_sigmatel.c119
-rw-r--r--sound/pci/hda/patch_via.c76
-rw-r--r--sound/pci/intel8x0.c58
-rw-r--r--sound/pci/lx6464es/lx_core.c23
-rw-r--r--sound/pci/lx6464es/lx_core.h3
-rw-r--r--sound/pci/rme9652/hdspm.c2
-rw-r--r--sound/pci/sis7019.c64
-rw-r--r--sound/ppc/snd_ps3.c2
-rw-r--r--sound/soc/atmel/Kconfig21
-rw-r--r--sound/soc/atmel/Makefile4
-rw-r--r--sound/soc/atmel/playpaq_wm8510.c473
-rw-r--r--sound/soc/codecs/Kconfig2
-rw-r--r--sound/soc/codecs/ad1836.h2
-rw-r--r--sound/soc/codecs/adau1373.c2
-rw-r--r--sound/soc/codecs/cs4270.c10
-rw-r--r--sound/soc/codecs/cs4271.c8
-rw-r--r--sound/soc/codecs/cs42l51.c2
-rw-r--r--sound/soc/codecs/jz4740.c1
-rw-r--r--sound/soc/codecs/max9877.c10
-rw-r--r--sound/soc/codecs/rt5631.c2
-rw-r--r--sound/soc/codecs/sgtl5000.c2
-rw-r--r--sound/soc/codecs/sta32x.c63
-rw-r--r--sound/soc/codecs/sta32x.h1
-rw-r--r--sound/soc/codecs/uda1380.c4
-rw-r--r--sound/soc/codecs/wm8731.c1
-rw-r--r--sound/soc/codecs/wm8753.c3
-rw-r--r--sound/soc/codecs/wm8958-dsp2.c2
-rw-r--r--sound/soc/codecs/wm8962.c4
-rw-r--r--sound/soc/codecs/wm8993.c2
-rw-r--r--sound/soc/codecs/wm8994.c62
-rw-r--r--sound/soc/codecs/wm8996.c1
-rw-r--r--sound/soc/codecs/wm9081.c10
-rw-r--r--sound/soc/codecs/wm9090.c6
-rw-r--r--sound/soc/codecs/wm_hubs.c2
-rw-r--r--sound/soc/fsl/fsl_ssi.c1
-rw-r--r--sound/soc/fsl/mpc8610_hpcd.c24
-rw-r--r--sound/soc/imx/Kconfig2
-rw-r--r--sound/soc/kirkwood/Kconfig3
-rw-r--r--sound/soc/mxs/mxs-pcm.c3
-rw-r--r--sound/soc/mxs/mxs-sgtl5000.c1
-rw-r--r--sound/soc/nuc900/nuc900-ac97.c3
-rw-r--r--sound/soc/pxa/Kconfig3
-rw-r--r--sound/soc/pxa/hx4700.c5
-rw-r--r--sound/soc/samsung/jive_wm8750.c3
-rw-r--r--sound/soc/samsung/smdk2443_wm9710.c1
-rw-r--r--sound/soc/samsung/smdk_wm8994.c1
-rw-r--r--sound/soc/samsung/speyside.c2
-rw-r--r--sound/soc/soc-core.c6
-rw-r--r--sound/soc/soc-utils.c31
-rw-r--r--sound/usb/mixer.c110
-rw-r--r--sound/usb/quirks-table.h31
-rw-r--r--sound/usb/quirks.c7
63 files changed, 784 insertions, 885 deletions
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index 5dbab38d04af..130cfe677d60 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -52,6 +52,7 @@ struct link_slave {
52 struct link_ctl_info info; 52 struct link_ctl_info info;
53 int vals[2]; /* current values */ 53 int vals[2]; /* current values */
54 unsigned int flags; 54 unsigned int flags;
55 struct snd_kcontrol *kctl; /* original kcontrol pointer */
55 struct snd_kcontrol slave; /* the copy of original control entry */ 56 struct snd_kcontrol slave; /* the copy of original control entry */
56}; 57};
57 58
@@ -252,6 +253,7 @@ int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave,
252 slave->count * sizeof(*slave->vd), GFP_KERNEL); 253 slave->count * sizeof(*slave->vd), GFP_KERNEL);
253 if (!srec) 254 if (!srec)
254 return -ENOMEM; 255 return -ENOMEM;
256 srec->kctl = slave;
255 srec->slave = *slave; 257 srec->slave = *slave;
256 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd)); 258 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd));
257 srec->master = master_link; 259 srec->master = master_link;
@@ -333,10 +335,18 @@ static int master_put(struct snd_kcontrol *kcontrol,
333static void master_free(struct snd_kcontrol *kcontrol) 335static void master_free(struct snd_kcontrol *kcontrol)
334{ 336{
335 struct link_master *master = snd_kcontrol_chip(kcontrol); 337 struct link_master *master = snd_kcontrol_chip(kcontrol);
336 struct link_slave *slave; 338 struct link_slave *slave, *n;
337 339
338 list_for_each_entry(slave, &master->slaves, list) 340 /* free all slave links and retore the original slave kctls */
339 slave->master = NULL; 341 list_for_each_entry_safe(slave, n, &master->slaves, list) {
342 struct snd_kcontrol *sctl = slave->kctl;
343 struct list_head olist = sctl->list;
344 memcpy(sctl, &slave->slave, sizeof(*sctl));
345 memcpy(sctl->vd, slave->slave.vd,
346 sctl->count * sizeof(*sctl->vd));
347 sctl->list = olist; /* keep the current linked-list */
348 kfree(slave);
349 }
340 kfree(master); 350 kfree(master);
341} 351}
342 352
diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c
index e083122ca55a..dbf94b189e75 100644
--- a/sound/pci/cs5535audio/cs5535audio_pcm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pcm.c
@@ -148,7 +148,7 @@ static int cs5535audio_build_dma_packets(struct cs5535audio *cs5535au,
148 struct cs5535audio_dma_desc *desc = 148 struct cs5535audio_dma_desc *desc =
149 &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[i]; 149 &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[i];
150 desc->addr = cpu_to_le32(addr); 150 desc->addr = cpu_to_le32(addr);
151 desc->size = cpu_to_le32(period_bytes); 151 desc->size = cpu_to_le16(period_bytes);
152 desc->ctlreserved = cpu_to_le16(PRD_EOP); 152 desc->ctlreserved = cpu_to_le16(PRD_EOP);
153 desc_addr += sizeof(struct cs5535audio_dma_desc); 153 desc_addr += sizeof(struct cs5535audio_dma_desc);
154 addr += period_bytes; 154 addr += period_bytes;
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 916a1863af73..4562e9de6a1a 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2331,6 +2331,39 @@ int snd_hda_codec_reset(struct hda_codec *codec)
2331 return 0; 2331 return 0;
2332} 2332}
2333 2333
2334typedef int (*map_slave_func_t)(void *, struct snd_kcontrol *);
2335
2336/* apply the function to all matching slave ctls in the mixer list */
2337static int map_slaves(struct hda_codec *codec, const char * const *slaves,
2338 map_slave_func_t func, void *data)
2339{
2340 struct hda_nid_item *items;
2341 const char * const *s;
2342 int i, err;
2343
2344 items = codec->mixers.list;
2345 for (i = 0; i < codec->mixers.used; i++) {
2346 struct snd_kcontrol *sctl = items[i].kctl;
2347 if (!sctl || !sctl->id.name ||
2348 sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER)
2349 continue;
2350 for (s = slaves; *s; s++) {
2351 if (!strcmp(sctl->id.name, *s)) {
2352 err = func(data, sctl);
2353 if (err)
2354 return err;
2355 break;
2356 }
2357 }
2358 }
2359 return 0;
2360}
2361
2362static int check_slave_present(void *data, struct snd_kcontrol *sctl)
2363{
2364 return 1;
2365}
2366
2334/** 2367/**
2335 * snd_hda_add_vmaster - create a virtual master control and add slaves 2368 * snd_hda_add_vmaster - create a virtual master control and add slaves
2336 * @codec: HD-audio codec 2369 * @codec: HD-audio codec
@@ -2351,12 +2384,10 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
2351 unsigned int *tlv, const char * const *slaves) 2384 unsigned int *tlv, const char * const *slaves)
2352{ 2385{
2353 struct snd_kcontrol *kctl; 2386 struct snd_kcontrol *kctl;
2354 const char * const *s;
2355 int err; 2387 int err;
2356 2388
2357 for (s = slaves; *s && !snd_hda_find_mixer_ctl(codec, *s); s++) 2389 err = map_slaves(codec, slaves, check_slave_present, NULL);
2358 ; 2390 if (err != 1) {
2359 if (!*s) {
2360 snd_printdd("No slave found for %s\n", name); 2391 snd_printdd("No slave found for %s\n", name);
2361 return 0; 2392 return 0;
2362 } 2393 }
@@ -2367,23 +2398,10 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
2367 if (err < 0) 2398 if (err < 0)
2368 return err; 2399 return err;
2369 2400
2370 for (s = slaves; *s; s++) { 2401 err = map_slaves(codec, slaves, (map_slave_func_t)snd_ctl_add_slave,
2371 struct snd_kcontrol *sctl; 2402 kctl);
2372 int i = 0; 2403 if (err < 0)
2373 for (;;) { 2404 return err;
2374 sctl = _snd_hda_find_mixer_ctl(codec, *s, i);
2375 if (!sctl) {
2376 if (!i)
2377 snd_printdd("Cannot find slave %s, "
2378 "skipped\n", *s);
2379 break;
2380 }
2381 err = snd_ctl_add_slave(kctl, sctl);
2382 if (err < 0)
2383 return err;
2384 i++;
2385 }
2386 }
2387 return 0; 2405 return 0;
2388} 2406}
2389EXPORT_SYMBOL_HDA(snd_hda_add_vmaster); 2407EXPORT_SYMBOL_HDA(snd_hda_add_vmaster);
@@ -4028,9 +4046,9 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
4028 4046
4029 /* Search for codec ID */ 4047 /* Search for codec ID */
4030 for (q = tbl; q->subvendor; q++) { 4048 for (q = tbl; q->subvendor; q++) {
4031 unsigned long vendorid = (q->subdevice) | (q->subvendor << 16); 4049 unsigned int mask = 0xffff0000 | q->subdevice_mask;
4032 4050 unsigned int id = (q->subdevice | (q->subvendor << 16)) & mask;
4033 if (vendorid == codec->subsystem_id) 4051 if ((codec->subsystem_id & mask) == id)
4034 break; 4052 break;
4035 } 4053 }
4036 4054
@@ -4752,6 +4770,7 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
4752 memset(sequences_hp, 0, sizeof(sequences_hp)); 4770 memset(sequences_hp, 0, sizeof(sequences_hp));
4753 assoc_line_out = 0; 4771 assoc_line_out = 0;
4754 4772
4773 codec->ignore_misc_bit = true;
4755 end_nid = codec->start_nid + codec->num_nodes; 4774 end_nid = codec->start_nid + codec->num_nodes;
4756 for (nid = codec->start_nid; nid < end_nid; nid++) { 4775 for (nid = codec->start_nid; nid < end_nid; nid++) {
4757 unsigned int wid_caps = get_wcaps(codec, nid); 4776 unsigned int wid_caps = get_wcaps(codec, nid);
@@ -4767,6 +4786,9 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
4767 continue; 4786 continue;
4768 4787
4769 def_conf = snd_hda_codec_get_pincfg(codec, nid); 4788 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4789 if (!(get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) &
4790 AC_DEFCFG_MISC_NO_PRESENCE))
4791 codec->ignore_misc_bit = false;
4770 conn = get_defcfg_connect(def_conf); 4792 conn = get_defcfg_connect(def_conf);
4771 if (conn == AC_JACK_PORT_NONE) 4793 if (conn == AC_JACK_PORT_NONE)
4772 continue; 4794 continue;
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 755f2b0f9d8e..564471169cae 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -854,6 +854,7 @@ struct hda_codec {
854 unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */ 854 unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */
855 unsigned int pins_shutup:1; /* pins are shut up */ 855 unsigned int pins_shutup:1; /* pins are shut up */
856 unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */ 856 unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */
857 unsigned int ignore_misc_bit:1; /* ignore MISC_NO_PRESENCE bit */
857#ifdef CONFIG_SND_HDA_POWER_SAVE 858#ifdef CONFIG_SND_HDA_POWER_SAVE
858 unsigned int power_on :1; /* current (global) power-state */ 859 unsigned int power_on :1; /* current (global) power-state */
859 unsigned int power_transition :1; /* power-state in transition */ 860 unsigned int power_transition :1; /* power-state in transition */
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
index 1c8ddf547a2d..c1da422e085a 100644
--- a/sound/pci/hda/hda_eld.c
+++ b/sound/pci/hda/hda_eld.c
@@ -297,10 +297,18 @@ static int hdmi_update_eld(struct hdmi_eld *e,
297 buf + ELD_FIXED_BYTES + mnl + 3 * i); 297 buf + ELD_FIXED_BYTES + mnl + 3 * i);
298 } 298 }
299 299
300 /*
301 * HDMI sink's ELD info cannot always be retrieved for now, e.g.
302 * in console or for audio devices. Assume the highest speakers
303 * configuration, to _not_ prohibit multi-channel audio playback.
304 */
305 if (!e->spk_alloc)
306 e->spk_alloc = 0xffff;
307
308 e->eld_valid = true;
300 return 0; 309 return 0;
301 310
302out_fail: 311out_fail:
303 e->eld_ver = 0;
304 return -EINVAL; 312 return -EINVAL;
305} 313}
306 314
@@ -323,9 +331,6 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
323 * ELD is valid, actual eld_size is assigned in hdmi_update_eld() 331 * ELD is valid, actual eld_size is assigned in hdmi_update_eld()
324 */ 332 */
325 333
326 if (!eld->eld_valid)
327 return -ENOENT;
328
329 size = snd_hdmi_get_eld_size(codec, nid); 334 size = snd_hdmi_get_eld_size(codec, nid);
330 if (size == 0) { 335 if (size == 0) {
331 /* wfg: workaround for ASUS P5E-VM HDMI board */ 336 /* wfg: workaround for ASUS P5E-VM HDMI board */
@@ -342,18 +347,28 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
342 347
343 for (i = 0; i < size; i++) { 348 for (i = 0; i < size; i++) {
344 unsigned int val = hdmi_get_eld_data(codec, nid, i); 349 unsigned int val = hdmi_get_eld_data(codec, nid, i);
350 /*
351 * Graphics driver might be writing to ELD buffer right now.
352 * Just abort. The caller will repoll after a while.
353 */
345 if (!(val & AC_ELDD_ELD_VALID)) { 354 if (!(val & AC_ELDD_ELD_VALID)) {
346 if (!i) {
347 snd_printd(KERN_INFO
348 "HDMI: invalid ELD data\n");
349 ret = -EINVAL;
350 goto error;
351 }
352 snd_printd(KERN_INFO 355 snd_printd(KERN_INFO
353 "HDMI: invalid ELD data byte %d\n", i); 356 "HDMI: invalid ELD data byte %d\n", i);
354 val = 0; 357 ret = -EINVAL;
355 } else 358 goto error;
356 val &= AC_ELDD_ELD_DATA; 359 }
360 val &= AC_ELDD_ELD_DATA;
361 /*
362 * The first byte cannot be zero. This can happen on some DVI
363 * connections. Some Intel chips may also need some 250ms delay
364 * to return non-zero ELD data, even when the graphics driver
365 * correctly writes ELD content before setting ELD_valid bit.
366 */
367 if (!val && !i) {
368 snd_printdd(KERN_INFO "HDMI: 0 ELD data\n");
369 ret = -EINVAL;
370 goto error;
371 }
357 buf[i] = val; 372 buf[i] = val;
358 } 373 }
359 374
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 096507d2ca9a..c2f79e63124d 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -2507,8 +2507,8 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = {
2507 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), 2507 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
2508 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB), 2508 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB),
2509 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB), 2509 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB),
2510 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS 1101HA", POS_FIX_LPIB),
2510 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), 2511 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB),
2511 SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB),
2512 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB), 2512 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB),
2513 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB), 2513 SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
2514 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), 2514 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB),
@@ -2971,7 +2971,8 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
2971 /* SCH */ 2971 /* SCH */
2972 { PCI_DEVICE(0x8086, 0x811b), 2972 { PCI_DEVICE(0x8086, 0x811b),
2973 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 2973 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
2974 AZX_DCAPS_BUFSIZE}, 2974 AZX_DCAPS_BUFSIZE | AZX_DCAPS_POSFIX_LPIB }, /* Poulsbo */
2975 /* ICH */
2975 { PCI_DEVICE(0x8086, 0x2668), 2976 { PCI_DEVICE(0x8086, 0x2668),
2976 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC | 2977 .driver_data = AZX_DRIVER_ICH | AZX_DCAPS_OLD_SSYNC |
2977 AZX_DCAPS_BUFSIZE }, /* ICH6 */ 2978 AZX_DCAPS_BUFSIZE }, /* ICH6 */
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index dcbea0da0fa2..618ddad17236 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -510,13 +510,15 @@ int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
510 510
511static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid) 511static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
512{ 512{
513 return (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT) && 513 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT))
514 /* disable MISC_NO_PRESENCE check because it may break too 514 return false;
515 * many devices 515 if (!codec->ignore_misc_bit &&
516 */ 516 (get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid)) &
517 /*(get_defcfg_misc(snd_hda_codec_get_pincfg(codec, nid) & 517 AC_DEFCFG_MISC_NO_PRESENCE))
518 AC_DEFCFG_MISC_NO_PRESENCE)) &&*/ 518 return false;
519 (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP); 519 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
520 return false;
521 return true;
520} 522}
521 523
522/* flags for hda_nid_item */ 524/* flags for hda_nid_item */
@@ -651,6 +653,9 @@ struct hdmi_eld {
651 int spk_alloc; 653 int spk_alloc;
652 int sad_count; 654 int sad_count;
653 struct cea_sad sad[ELD_MAX_SAD]; 655 struct cea_sad sad[ELD_MAX_SAD];
656 /*
657 * all fields above eld_buffer will be cleared before updating ELD
658 */
654 char eld_buffer[ELD_MAX_SIZE]; 659 char eld_buffer[ELD_MAX_SIZE];
655#ifdef CONFIG_PROC_FS 660#ifdef CONFIG_PROC_FS
656 struct snd_info_entry *proc_entry; 661 struct snd_info_entry *proc_entry;
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 2a2d8645ba09..70a7abda7e22 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -58,6 +58,8 @@ struct cs_spec {
58 unsigned int gpio_mask; 58 unsigned int gpio_mask;
59 unsigned int gpio_dir; 59 unsigned int gpio_dir;
60 unsigned int gpio_data; 60 unsigned int gpio_data;
61 unsigned int gpio_eapd_hp; /* EAPD GPIO bit for headphones */
62 unsigned int gpio_eapd_speaker; /* EAPD GPIO bit for speakers */
61 63
62 struct hda_pcm pcm_rec[2]; /* PCM information */ 64 struct hda_pcm pcm_rec[2]; /* PCM information */
63 65
@@ -76,6 +78,7 @@ enum {
76 CS420X_MBP53, 78 CS420X_MBP53,
77 CS420X_MBP55, 79 CS420X_MBP55,
78 CS420X_IMAC27, 80 CS420X_IMAC27,
81 CS420X_APPLE,
79 CS420X_AUTO, 82 CS420X_AUTO,
80 CS420X_MODELS 83 CS420X_MODELS
81}; 84};
@@ -237,6 +240,15 @@ static int cs_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
237 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); 240 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
238} 241}
239 242
243static void cs_update_input_select(struct hda_codec *codec)
244{
245 struct cs_spec *spec = codec->spec;
246 if (spec->cur_adc)
247 snd_hda_codec_write(codec, spec->cur_adc, 0,
248 AC_VERB_SET_CONNECT_SEL,
249 spec->adc_idx[spec->cur_input]);
250}
251
240/* 252/*
241 * Analog capture 253 * Analog capture
242 */ 254 */
@@ -250,6 +262,7 @@ static int cs_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
250 spec->cur_adc = spec->adc_nid[spec->cur_input]; 262 spec->cur_adc = spec->adc_nid[spec->cur_input];
251 spec->cur_adc_stream_tag = stream_tag; 263 spec->cur_adc_stream_tag = stream_tag;
252 spec->cur_adc_format = format; 264 spec->cur_adc_format = format;
265 cs_update_input_select(codec);
253 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); 266 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
254 return 0; 267 return 0;
255} 268}
@@ -689,10 +702,8 @@ static int change_cur_input(struct hda_codec *codec, unsigned int idx,
689 spec->cur_adc_stream_tag, 0, 702 spec->cur_adc_stream_tag, 0,
690 spec->cur_adc_format); 703 spec->cur_adc_format);
691 } 704 }
692 snd_hda_codec_write(codec, spec->cur_adc, 0,
693 AC_VERB_SET_CONNECT_SEL,
694 spec->adc_idx[idx]);
695 spec->cur_input = idx; 705 spec->cur_input = idx;
706 cs_update_input_select(codec);
696 return 1; 707 return 1;
697} 708}
698 709
@@ -920,10 +931,9 @@ static void cs_automute(struct hda_codec *codec)
920 spdif_present ? 0 : PIN_OUT); 931 spdif_present ? 0 : PIN_OUT);
921 } 932 }
922 } 933 }
923 if (spec->board_config == CS420X_MBP53 || 934 if (spec->gpio_eapd_hp) {
924 spec->board_config == CS420X_MBP55 || 935 unsigned int gpio = hp_present ?
925 spec->board_config == CS420X_IMAC27) { 936 spec->gpio_eapd_hp : spec->gpio_eapd_speaker;
926 unsigned int gpio = hp_present ? 0x02 : 0x08;
927 snd_hda_codec_write(codec, 0x01, 0, 937 snd_hda_codec_write(codec, 0x01, 0,
928 AC_VERB_SET_GPIO_DATA, gpio); 938 AC_VERB_SET_GPIO_DATA, gpio);
929 } 939 }
@@ -973,10 +983,7 @@ static void cs_automic(struct hda_codec *codec)
973 } else { 983 } else {
974 spec->cur_input = spec->last_input; 984 spec->cur_input = spec->last_input;
975 } 985 }
976 986 cs_update_input_select(codec);
977 snd_hda_codec_write_cache(codec, spec->cur_adc, 0,
978 AC_VERB_SET_CONNECT_SEL,
979 spec->adc_idx[spec->cur_input]);
980 } else { 987 } else {
981 if (present) 988 if (present)
982 change_cur_input(codec, spec->automic_idx, 0); 989 change_cur_input(codec, spec->automic_idx, 0);
@@ -1073,9 +1080,7 @@ static void init_input(struct hda_codec *codec)
1073 cs_automic(codec); 1080 cs_automic(codec);
1074 else { 1081 else {
1075 spec->cur_adc = spec->adc_nid[spec->cur_input]; 1082 spec->cur_adc = spec->adc_nid[spec->cur_input];
1076 snd_hda_codec_write(codec, spec->cur_adc, 0, 1083 cs_update_input_select(codec);
1077 AC_VERB_SET_CONNECT_SEL,
1078 spec->adc_idx[spec->cur_input]);
1079 } 1084 }
1080 } else { 1085 } else {
1081 change_cur_input(codec, spec->cur_input, 1); 1086 change_cur_input(codec, spec->cur_input, 1);
@@ -1273,6 +1278,7 @@ static const char * const cs420x_models[CS420X_MODELS] = {
1273 [CS420X_MBP53] = "mbp53", 1278 [CS420X_MBP53] = "mbp53",
1274 [CS420X_MBP55] = "mbp55", 1279 [CS420X_MBP55] = "mbp55",
1275 [CS420X_IMAC27] = "imac27", 1280 [CS420X_IMAC27] = "imac27",
1281 [CS420X_APPLE] = "apple",
1276 [CS420X_AUTO] = "auto", 1282 [CS420X_AUTO] = "auto",
1277}; 1283};
1278 1284
@@ -1282,7 +1288,13 @@ static const struct snd_pci_quirk cs420x_cfg_tbl[] = {
1282 SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55), 1288 SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55),
1283 SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), 1289 SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55),
1284 SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), 1290 SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55),
1285 SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), 1291 /* this conflicts with too many other models */
1292 /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/
1293 {} /* terminator */
1294};
1295
1296static const struct snd_pci_quirk cs420x_codec_cfg_tbl[] = {
1297 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE),
1286 {} /* terminator */ 1298 {} /* terminator */
1287}; 1299};
1288 1300
@@ -1364,6 +1376,10 @@ static int patch_cs420x(struct hda_codec *codec)
1364 spec->board_config = 1376 spec->board_config =
1365 snd_hda_check_board_config(codec, CS420X_MODELS, 1377 snd_hda_check_board_config(codec, CS420X_MODELS,
1366 cs420x_models, cs420x_cfg_tbl); 1378 cs420x_models, cs420x_cfg_tbl);
1379 if (spec->board_config < 0)
1380 spec->board_config =
1381 snd_hda_check_board_codec_sid_config(codec,
1382 CS420X_MODELS, NULL, cs420x_codec_cfg_tbl);
1367 if (spec->board_config >= 0) 1383 if (spec->board_config >= 0)
1368 fix_pincfg(codec, spec->board_config, cs_pincfgs); 1384 fix_pincfg(codec, spec->board_config, cs_pincfgs);
1369 1385
@@ -1371,10 +1387,11 @@ static int patch_cs420x(struct hda_codec *codec)
1371 case CS420X_IMAC27: 1387 case CS420X_IMAC27:
1372 case CS420X_MBP53: 1388 case CS420X_MBP53:
1373 case CS420X_MBP55: 1389 case CS420X_MBP55:
1374 /* GPIO1 = headphones */ 1390 case CS420X_APPLE:
1375 /* GPIO3 = speakers */ 1391 spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */
1376 spec->gpio_mask = 0x0a; 1392 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */
1377 spec->gpio_dir = 0x0a; 1393 spec->gpio_mask = spec->gpio_dir =
1394 spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
1378 break; 1395 break;
1379 } 1396 }
1380 1397
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 5e706e4d1737..0de21193a2b0 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -3062,7 +3062,6 @@ static const struct snd_pci_quirk cxt5066_cfg_tbl[] = {
3062 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), 3062 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS),
3063 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 3063 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD),
3064 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), 3064 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5),
3065 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5),
3066 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 3065 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
3067 CXT5066_LAPTOP), 3066 CXT5066_LAPTOP),
3068 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), 3067 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5),
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 81b7b791b3c3..c505fd5d338c 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -65,7 +65,11 @@ struct hdmi_spec_per_pin {
65 hda_nid_t pin_nid; 65 hda_nid_t pin_nid;
66 int num_mux_nids; 66 int num_mux_nids;
67 hda_nid_t mux_nids[HDA_MAX_CONNECTIONS]; 67 hda_nid_t mux_nids[HDA_MAX_CONNECTIONS];
68
69 struct hda_codec *codec;
68 struct hdmi_eld sink_eld; 70 struct hdmi_eld sink_eld;
71 struct delayed_work work;
72 int repoll_count;
69}; 73};
70 74
71struct hdmi_spec { 75struct hdmi_spec {
@@ -745,8 +749,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, int pin_idx,
745 * Unsolicited events 749 * Unsolicited events
746 */ 750 */
747 751
748static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, 752static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
749 struct hdmi_eld *eld);
750 753
751static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) 754static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
752{ 755{
@@ -755,7 +758,6 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
755 int pd = !!(res & AC_UNSOL_RES_PD); 758 int pd = !!(res & AC_UNSOL_RES_PD);
756 int eldv = !!(res & AC_UNSOL_RES_ELDV); 759 int eldv = !!(res & AC_UNSOL_RES_ELDV);
757 int pin_idx; 760 int pin_idx;
758 struct hdmi_eld *eld;
759 761
760 printk(KERN_INFO 762 printk(KERN_INFO
761 "HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 763 "HDMI hot plug event: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
@@ -764,17 +766,8 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
764 pin_idx = pin_nid_to_pin_index(spec, pin_nid); 766 pin_idx = pin_nid_to_pin_index(spec, pin_nid);
765 if (pin_idx < 0) 767 if (pin_idx < 0)
766 return; 768 return;
767 eld = &spec->pins[pin_idx].sink_eld;
768
769 hdmi_present_sense(codec, pin_nid, eld);
770 769
771 /* 770 hdmi_present_sense(&spec->pins[pin_idx], 1);
772 * HDMI sink's ELD info cannot always be retrieved for now, e.g.
773 * in console or for audio devices. Assume the highest speakers
774 * configuration, to _not_ prohibit multi-channel audio playback.
775 */
776 if (!eld->spk_alloc)
777 eld->spk_alloc = 0xffff;
778} 771}
779 772
780static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) 773static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
@@ -968,9 +961,11 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
968 return 0; 961 return 0;
969} 962}
970 963
971static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, 964static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
972 struct hdmi_eld *eld)
973{ 965{
966 struct hda_codec *codec = per_pin->codec;
967 struct hdmi_eld *eld = &per_pin->sink_eld;
968 hda_nid_t pin_nid = per_pin->pin_nid;
974 /* 969 /*
975 * Always execute a GetPinSense verb here, even when called from 970 * Always execute a GetPinSense verb here, even when called from
976 * hdmi_intrinsic_event; for some NVIDIA HW, the unsolicited 971 * hdmi_intrinsic_event; for some NVIDIA HW, the unsolicited
@@ -980,26 +975,42 @@ static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
980 * the unsolicited response to avoid custom WARs. 975 * the unsolicited response to avoid custom WARs.
981 */ 976 */
982 int present = snd_hda_pin_sense(codec, pin_nid); 977 int present = snd_hda_pin_sense(codec, pin_nid);
978 bool eld_valid = false;
983 979
984 memset(eld, 0, sizeof(*eld)); 980 memset(eld, 0, offsetof(struct hdmi_eld, eld_buffer));
985 981
986 eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); 982 eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
987 if (eld->monitor_present) 983 if (eld->monitor_present)
988 eld->eld_valid = !!(present & AC_PINSENSE_ELDV); 984 eld_valid = !!(present & AC_PINSENSE_ELDV);
989 else
990 eld->eld_valid = 0;
991 985
992 printk(KERN_INFO 986 printk(KERN_INFO
993 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 987 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
994 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); 988 codec->addr, pin_nid, eld->monitor_present, eld_valid);
995 989
996 if (eld->eld_valid) 990 if (eld_valid) {
997 if (!snd_hdmi_get_eld(eld, codec, pin_nid)) 991 if (!snd_hdmi_get_eld(eld, codec, pin_nid))
998 snd_hdmi_show_eld(eld); 992 snd_hdmi_show_eld(eld);
993 else if (repoll) {
994 queue_delayed_work(codec->bus->workq,
995 &per_pin->work,
996 msecs_to_jiffies(300));
997 }
998 }
999 999
1000 snd_hda_input_jack_report(codec, pin_nid); 1000 snd_hda_input_jack_report(codec, pin_nid);
1001} 1001}
1002 1002
1003static void hdmi_repoll_eld(struct work_struct *work)
1004{
1005 struct hdmi_spec_per_pin *per_pin =
1006 container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work);
1007
1008 if (per_pin->repoll_count++ > 6)
1009 per_pin->repoll_count = 0;
1010
1011 hdmi_present_sense(per_pin, per_pin->repoll_count);
1012}
1013
1003static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) 1014static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
1004{ 1015{
1005 struct hdmi_spec *spec = codec->spec; 1016 struct hdmi_spec *spec = codec->spec;
@@ -1228,7 +1239,7 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
1228 if (err < 0) 1239 if (err < 0)
1229 return err; 1240 return err;
1230 1241
1231 hdmi_present_sense(codec, per_pin->pin_nid, &per_pin->sink_eld); 1242 hdmi_present_sense(per_pin, 0);
1232 return 0; 1243 return 0;
1233} 1244}
1234 1245
@@ -1279,6 +1290,8 @@ static int generic_hdmi_init(struct hda_codec *codec)
1279 AC_VERB_SET_UNSOLICITED_ENABLE, 1290 AC_VERB_SET_UNSOLICITED_ENABLE,
1280 AC_USRSP_EN | pin_nid); 1291 AC_USRSP_EN | pin_nid);
1281 1292
1293 per_pin->codec = codec;
1294 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld);
1282 snd_hda_eld_proc_new(codec, eld, pin_idx); 1295 snd_hda_eld_proc_new(codec, eld, pin_idx);
1283 } 1296 }
1284 return 0; 1297 return 0;
@@ -1293,10 +1306,12 @@ static void generic_hdmi_free(struct hda_codec *codec)
1293 struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; 1306 struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
1294 struct hdmi_eld *eld = &per_pin->sink_eld; 1307 struct hdmi_eld *eld = &per_pin->sink_eld;
1295 1308
1309 cancel_delayed_work(&per_pin->work);
1296 snd_hda_eld_proc_free(codec, eld); 1310 snd_hda_eld_proc_free(codec, eld);
1297 } 1311 }
1298 snd_hda_input_jack_free(codec); 1312 snd_hda_input_jack_free(codec);
1299 1313
1314 flush_workqueue(codec->bus->workq);
1300 kfree(spec); 1315 kfree(spec);
1301} 1316}
1302 1317
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index a24e068a021b..1d07e8fa2433 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -277,6 +277,12 @@ static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
277 return false; 277 return false;
278} 278}
279 279
280static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
281{
282 return spec->capsrc_nids ?
283 spec->capsrc_nids[idx] : spec->adc_nids[idx];
284}
285
280/* select the given imux item; either unmute exclusively or select the route */ 286/* select the given imux item; either unmute exclusively or select the route */
281static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, 287static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
282 unsigned int idx, bool force) 288 unsigned int idx, bool force)
@@ -284,13 +290,15 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
284 struct alc_spec *spec = codec->spec; 290 struct alc_spec *spec = codec->spec;
285 const struct hda_input_mux *imux; 291 const struct hda_input_mux *imux;
286 unsigned int mux_idx; 292 unsigned int mux_idx;
287 int i, type; 293 int i, type, num_conns;
288 hda_nid_t nid; 294 hda_nid_t nid;
289 295
290 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 296 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
291 imux = &spec->input_mux[mux_idx]; 297 imux = &spec->input_mux[mux_idx];
292 if (!imux->num_items && mux_idx > 0) 298 if (!imux->num_items && mux_idx > 0)
293 imux = &spec->input_mux[0]; 299 imux = &spec->input_mux[0];
300 if (!imux->num_items)
301 return 0;
294 302
295 if (idx >= imux->num_items) 303 if (idx >= imux->num_items)
296 idx = imux->num_items - 1; 304 idx = imux->num_items - 1;
@@ -303,20 +311,20 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
303 adc_idx = spec->dyn_adc_idx[idx]; 311 adc_idx = spec->dyn_adc_idx[idx];
304 } 312 }
305 313
306 nid = spec->capsrc_nids ? 314 nid = get_capsrc(spec, adc_idx);
307 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
308 315
309 /* no selection? */ 316 /* no selection? */
310 if (snd_hda_get_conn_list(codec, nid, NULL) <= 1) 317 num_conns = snd_hda_get_conn_list(codec, nid, NULL);
318 if (num_conns <= 1)
311 return 1; 319 return 1;
312 320
313 type = get_wcaps_type(get_wcaps(codec, nid)); 321 type = get_wcaps_type(get_wcaps(codec, nid));
314 if (type == AC_WID_AUD_MIX) { 322 if (type == AC_WID_AUD_MIX) {
315 /* Matrix-mixer style (e.g. ALC882) */ 323 /* Matrix-mixer style (e.g. ALC882) */
316 for (i = 0; i < imux->num_items; i++) { 324 int active = imux->items[idx].index;
317 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; 325 for (i = 0; i < num_conns; i++) {
318 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 326 unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE;
319 imux->items[i].index, 327 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i,
320 HDA_AMP_MUTE, v); 328 HDA_AMP_MUTE, v);
321 } 329 }
322 } else { 330 } else {
@@ -1053,8 +1061,19 @@ static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec)
1053 spec->imux_pins[2] = spec->dock_mic_pin; 1061 spec->imux_pins[2] = spec->dock_mic_pin;
1054 for (i = 0; i < 3; i++) { 1062 for (i = 0; i < 3; i++) {
1055 strcpy(imux->items[i].label, texts[i]); 1063 strcpy(imux->items[i].label, texts[i]);
1056 if (spec->imux_pins[i]) 1064 if (spec->imux_pins[i]) {
1065 hda_nid_t pin = spec->imux_pins[i];
1066 int c;
1067 for (c = 0; c < spec->num_adc_nids; c++) {
1068 hda_nid_t cap = get_capsrc(spec, c);
1069 int idx = get_connection_index(codec, cap, pin);
1070 if (idx >= 0) {
1071 imux->items[i].index = idx;
1072 break;
1073 }
1074 }
1057 imux->num_items = i + 1; 1075 imux->num_items = i + 1;
1076 }
1058 } 1077 }
1059 spec->num_mux_defs = 1; 1078 spec->num_mux_defs = 1;
1060 spec->input_mux = imux; 1079 spec->input_mux = imux;
@@ -1451,7 +1470,7 @@ static void alc_apply_fixup(struct hda_codec *codec, int action)
1451 switch (fix->type) { 1470 switch (fix->type) {
1452 case ALC_FIXUP_SKU: 1471 case ALC_FIXUP_SKU:
1453 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku) 1472 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1454 break;; 1473 break;
1455 snd_printdd(KERN_INFO "hda_codec: %s: " 1474 snd_printdd(KERN_INFO "hda_codec: %s: "
1456 "Apply sku override for %s\n", 1475 "Apply sku override for %s\n",
1457 codec->chip_name, modelname); 1476 codec->chip_name, modelname);
@@ -1956,10 +1975,8 @@ static int alc_build_controls(struct hda_codec *codec)
1956 if (!kctl) 1975 if (!kctl)
1957 kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); 1976 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
1958 for (i = 0; kctl && i < kctl->count; i++) { 1977 for (i = 0; kctl && i < kctl->count; i++) {
1959 const hda_nid_t *nids = spec->capsrc_nids; 1978 err = snd_hda_add_nid(codec, kctl, i,
1960 if (!nids) 1979 get_capsrc(spec, i));
1961 nids = spec->adc_nids;
1962 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
1963 if (err < 0) 1980 if (err < 0)
1964 return err; 1981 return err;
1965 } 1982 }
@@ -2614,6 +2631,8 @@ static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
2614 case AUTO_PIN_SPEAKER_OUT: 2631 case AUTO_PIN_SPEAKER_OUT:
2615 if (cfg->line_outs == 1) 2632 if (cfg->line_outs == 1)
2616 return "Speaker"; 2633 return "Speaker";
2634 if (cfg->line_outs == 2)
2635 return ch ? "Bass Speaker" : "Speaker";
2617 break; 2636 break;
2618 case AUTO_PIN_HP_OUT: 2637 case AUTO_PIN_HP_OUT:
2619 /* for multi-io case, only the primary out */ 2638 /* for multi-io case, only the primary out */
@@ -2746,8 +2765,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
2746 } 2765 }
2747 2766
2748 for (c = 0; c < num_adcs; c++) { 2767 for (c = 0; c < num_adcs; c++) {
2749 hda_nid_t cap = spec->capsrc_nids ? 2768 hda_nid_t cap = get_capsrc(spec, c);
2750 spec->capsrc_nids[c] : spec->adc_nids[c];
2751 idx = get_connection_index(codec, cap, pin); 2769 idx = get_connection_index(codec, cap, pin);
2752 if (idx >= 0) { 2770 if (idx >= 0) {
2753 spec->imux_pins[imux->num_items] = pin; 2771 spec->imux_pins[imux->num_items] = pin;
@@ -2888,7 +2906,7 @@ static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
2888 if (!nid) 2906 if (!nid)
2889 continue; 2907 continue;
2890 if (found_in_nid_list(nid, spec->multiout.dac_nids, 2908 if (found_in_nid_list(nid, spec->multiout.dac_nids,
2891 spec->multiout.num_dacs)) 2909 ARRAY_SIZE(spec->private_dac_nids)))
2892 continue; 2910 continue;
2893 if (found_in_nid_list(nid, spec->multiout.hp_out_nid, 2911 if (found_in_nid_list(nid, spec->multiout.hp_out_nid,
2894 ARRAY_SIZE(spec->multiout.hp_out_nid))) 2912 ARRAY_SIZE(spec->multiout.hp_out_nid)))
@@ -2909,6 +2927,7 @@ static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
2909 return 0; 2927 return 0;
2910} 2928}
2911 2929
2930/* return 0 if no possible DAC is found, 1 if one or more found */
2912static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs, 2931static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs,
2913 const hda_nid_t *pins, hda_nid_t *dacs) 2932 const hda_nid_t *pins, hda_nid_t *dacs)
2914{ 2933{
@@ -2926,7 +2945,7 @@ static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs,
2926 if (!dacs[i]) 2945 if (!dacs[i])
2927 dacs[i] = alc_auto_look_for_dac(codec, pins[i]); 2946 dacs[i] = alc_auto_look_for_dac(codec, pins[i]);
2928 } 2947 }
2929 return 0; 2948 return 1;
2930} 2949}
2931 2950
2932static int alc_auto_fill_multi_ios(struct hda_codec *codec, 2951static int alc_auto_fill_multi_ios(struct hda_codec *codec,
@@ -2936,7 +2955,7 @@ static int alc_auto_fill_multi_ios(struct hda_codec *codec,
2936static int alc_auto_fill_dac_nids(struct hda_codec *codec) 2955static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2937{ 2956{
2938 struct alc_spec *spec = codec->spec; 2957 struct alc_spec *spec = codec->spec;
2939 const struct auto_pin_cfg *cfg = &spec->autocfg; 2958 struct auto_pin_cfg *cfg = &spec->autocfg;
2940 bool redone = false; 2959 bool redone = false;
2941 int i; 2960 int i;
2942 2961
@@ -2947,6 +2966,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2947 spec->multiout.extra_out_nid[0] = 0; 2966 spec->multiout.extra_out_nid[0] = 0;
2948 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); 2967 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids));
2949 spec->multiout.dac_nids = spec->private_dac_nids; 2968 spec->multiout.dac_nids = spec->private_dac_nids;
2969 spec->multi_ios = 0;
2950 2970
2951 /* fill hard-wired DACs first */ 2971 /* fill hard-wired DACs first */
2952 if (!redone) { 2972 if (!redone) {
@@ -2980,10 +3000,12 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
2980 for (i = 0; i < cfg->line_outs; i++) { 3000 for (i = 0; i < cfg->line_outs; i++) {
2981 if (spec->private_dac_nids[i]) 3001 if (spec->private_dac_nids[i])
2982 spec->multiout.num_dacs++; 3002 spec->multiout.num_dacs++;
2983 else 3003 else {
2984 memmove(spec->private_dac_nids + i, 3004 memmove(spec->private_dac_nids + i,
2985 spec->private_dac_nids + i + 1, 3005 spec->private_dac_nids + i + 1,
2986 sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); 3006 sizeof(hda_nid_t) * (cfg->line_outs - i - 1));
3007 spec->private_dac_nids[cfg->line_outs - 1] = 0;
3008 }
2987 } 3009 }
2988 3010
2989 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 3011 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
@@ -3005,9 +3027,28 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3005 if (cfg->line_out_type != AUTO_PIN_HP_OUT) 3027 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
3006 alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins, 3028 alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins,
3007 spec->multiout.hp_out_nid); 3029 spec->multiout.hp_out_nid);
3008 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) 3030 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3009 alc_auto_fill_extra_dacs(codec, cfg->speaker_outs, cfg->speaker_pins, 3031 int err = alc_auto_fill_extra_dacs(codec, cfg->speaker_outs,
3010 spec->multiout.extra_out_nid); 3032 cfg->speaker_pins,
3033 spec->multiout.extra_out_nid);
3034 /* if no speaker volume is assigned, try again as the primary
3035 * output
3036 */
3037 if (!err && cfg->speaker_outs > 0 &&
3038 cfg->line_out_type == AUTO_PIN_HP_OUT) {
3039 cfg->hp_outs = cfg->line_outs;
3040 memcpy(cfg->hp_pins, cfg->line_out_pins,
3041 sizeof(cfg->hp_pins));
3042 cfg->line_outs = cfg->speaker_outs;
3043 memcpy(cfg->line_out_pins, cfg->speaker_pins,
3044 sizeof(cfg->speaker_pins));
3045 cfg->speaker_outs = 0;
3046 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
3047 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
3048 redone = false;
3049 goto again;
3050 }
3051 }
3011 3052
3012 return 0; 3053 return 0;
3013} 3054}
@@ -3157,7 +3198,8 @@ static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
3157} 3198}
3158 3199
3159static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, 3200static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
3160 hda_nid_t dac, const char *pfx) 3201 hda_nid_t dac, const char *pfx,
3202 int cidx)
3161{ 3203{
3162 struct alc_spec *spec = codec->spec; 3204 struct alc_spec *spec = codec->spec;
3163 hda_nid_t sw, vol; 3205 hda_nid_t sw, vol;
@@ -3173,15 +3215,15 @@ static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
3173 if (is_ctl_used(spec->sw_ctls, val)) 3215 if (is_ctl_used(spec->sw_ctls, val))
3174 return 0; /* already created */ 3216 return 0; /* already created */
3175 mark_ctl_usage(spec->sw_ctls, val); 3217 mark_ctl_usage(spec->sw_ctls, val);
3176 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val); 3218 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, cidx, val);
3177 } 3219 }
3178 3220
3179 sw = alc_look_for_out_mute_nid(codec, pin, dac); 3221 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3180 vol = alc_look_for_out_vol_nid(codec, pin, dac); 3222 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3181 err = alc_auto_add_stereo_vol(codec, pfx, 0, vol); 3223 err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol);
3182 if (err < 0) 3224 if (err < 0)
3183 return err; 3225 return err;
3184 err = alc_auto_add_stereo_sw(codec, pfx, 0, sw); 3226 err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw);
3185 if (err < 0) 3227 if (err < 0)
3186 return err; 3228 return err;
3187 return 0; 3229 return 0;
@@ -3222,16 +3264,21 @@ static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins,
3222 hda_nid_t dac = *dacs; 3264 hda_nid_t dac = *dacs;
3223 if (!dac) 3265 if (!dac)
3224 dac = spec->multiout.dac_nids[0]; 3266 dac = spec->multiout.dac_nids[0];
3225 return alc_auto_create_extra_out(codec, *pins, dac, pfx); 3267 return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0);
3226 } 3268 }
3227 3269
3228 if (dacs[num_pins - 1]) { 3270 if (dacs[num_pins - 1]) {
3229 /* OK, we have a multi-output system with individual volumes */ 3271 /* OK, we have a multi-output system with individual volumes */
3230 for (i = 0; i < num_pins; i++) { 3272 for (i = 0; i < num_pins; i++) {
3231 snprintf(name, sizeof(name), "%s %s", 3273 if (num_pins >= 3) {
3232 pfx, channel_name[i]); 3274 snprintf(name, sizeof(name), "%s %s",
3233 err = alc_auto_create_extra_out(codec, pins[i], dacs[i], 3275 pfx, channel_name[i]);
3234 name); 3276 err = alc_auto_create_extra_out(codec, pins[i], dacs[i],
3277 name, 0);
3278 } else {
3279 err = alc_auto_create_extra_out(codec, pins[i], dacs[i],
3280 pfx, i);
3281 }
3235 if (err < 0) 3282 if (err < 0)
3236 return err; 3283 return err;
3237 } 3284 }
@@ -3693,8 +3740,7 @@ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
3693 if (!pin) 3740 if (!pin)
3694 return 0; 3741 return 0;
3695 for (i = 0; i < spec->num_adc_nids; i++) { 3742 for (i = 0; i < spec->num_adc_nids; i++) {
3696 hda_nid_t cap = spec->capsrc_nids ? 3743 hda_nid_t cap = get_capsrc(spec, i);
3697 spec->capsrc_nids[i] : spec->adc_nids[i];
3698 int idx; 3744 int idx;
3699 3745
3700 idx = get_connection_index(codec, cap, pin); 3746 idx = get_connection_index(codec, cap, pin);
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 4e715fefebef..616678fde486 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -95,6 +95,7 @@ enum {
95 STAC_92HD83XXX_REF, 95 STAC_92HD83XXX_REF,
96 STAC_92HD83XXX_PWR_REF, 96 STAC_92HD83XXX_PWR_REF,
97 STAC_DELL_S14, 97 STAC_DELL_S14,
98 STAC_DELL_VOSTRO_3500,
98 STAC_92HD83XXX_HP, 99 STAC_92HD83XXX_HP,
99 STAC_92HD83XXX_HP_cNB11_INTQUAD, 100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
100 STAC_HP_DV7_4000, 101 STAC_HP_DV7_4000,
@@ -214,6 +215,7 @@ struct sigmatel_spec {
214 unsigned int gpio_mute; 215 unsigned int gpio_mute;
215 unsigned int gpio_led; 216 unsigned int gpio_led;
216 unsigned int gpio_led_polarity; 217 unsigned int gpio_led_polarity;
218 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
217 unsigned int vref_led; 219 unsigned int vref_led;
218 220
219 /* stream */ 221 /* stream */
@@ -226,7 +228,6 @@ struct sigmatel_spec {
226 228
227 /* power management */ 229 /* power management */
228 unsigned int num_pwrs; 230 unsigned int num_pwrs;
229 const unsigned int *pwr_mapping;
230 const hda_nid_t *pwr_nids; 231 const hda_nid_t *pwr_nids;
231 const hda_nid_t *dac_list; 232 const hda_nid_t *dac_list;
232 233
@@ -373,18 +374,15 @@ static const unsigned long stac92hd73xx_capvols[] = {
373 374
374#define STAC92HD83_DAC_COUNT 3 375#define STAC92HD83_DAC_COUNT 3
375 376
376static const hda_nid_t stac92hd83xxx_pwr_nids[4] = { 377static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
377 0xa, 0xb, 0xd, 0xe, 378 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
379 0x0f, 0x10
378}; 380};
379 381
380static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { 382static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
381 0x1e, 0, 383 0x1e, 0,
382}; 384};
383 385
384static const unsigned int stac92hd83xxx_pwr_mapping[4] = {
385 0x03, 0x0c, 0x20, 0x40,
386};
387
388static const hda_nid_t stac92hd83xxx_dmic_nids[] = { 386static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
389 0x11, 0x20, 387 0x11, 0x20,
390}; 388};
@@ -1644,6 +1642,8 @@ static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1644 "Alienware M17x", STAC_ALIENWARE_M17X), 1642 "Alienware M17x", STAC_ALIENWARE_M17X),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a, 1643 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1646 "Alienware M17x", STAC_ALIENWARE_M17X), 1644 "Alienware M17x", STAC_ALIENWARE_M17X),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
1646 "Alienware M17x", STAC_ALIENWARE_M17X),
1647 {} /* terminator */ 1647 {} /* terminator */
1648}; 1648};
1649 1649
@@ -1659,6 +1659,12 @@ static const unsigned int dell_s14_pin_configs[10] = {
1659 0x40f000f0, 0x40f000f0, 1659 0x40f000f0, 0x40f000f0,
1660}; 1660};
1661 1661
1662static const unsigned int dell_vostro_3500_pin_configs[10] = {
1663 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1664 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1665 0x400000f4, 0x400000f5,
1666};
1667
1662static const unsigned int hp_dv7_4000_pin_configs[10] = { 1668static const unsigned int hp_dv7_4000_pin_configs[10] = {
1663 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110, 1669 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1664 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140, 1670 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
@@ -1675,6 +1681,7 @@ static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1675 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, 1681 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1676 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, 1682 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1677 [STAC_DELL_S14] = dell_s14_pin_configs, 1683 [STAC_DELL_S14] = dell_s14_pin_configs,
1684 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
1678 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs, 1685 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
1679 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs, 1686 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
1680}; 1687};
@@ -1684,6 +1691,7 @@ static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1684 [STAC_92HD83XXX_REF] = "ref", 1691 [STAC_92HD83XXX_REF] = "ref",
1685 [STAC_92HD83XXX_PWR_REF] = "mic-ref", 1692 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1686 [STAC_DELL_S14] = "dell-s14", 1693 [STAC_DELL_S14] = "dell-s14",
1694 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
1687 [STAC_92HD83XXX_HP] = "hp", 1695 [STAC_92HD83XXX_HP] = "hp",
1688 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad", 1696 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
1689 [STAC_HP_DV7_4000] = "hp-dv7-4000", 1697 [STAC_HP_DV7_4000] = "hp-dv7-4000",
@@ -1697,6 +1705,8 @@ static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1697 "DFI LanParty", STAC_92HD83XXX_REF), 1705 "DFI LanParty", STAC_92HD83XXX_REF),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, 1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1699 "unknown Dell", STAC_DELL_S14), 1707 "unknown Dell", STAC_DELL_S14),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1709 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
1700 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600, 1710 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
1701 "HP", STAC_92HD83XXX_HP), 1711 "HP", STAC_92HD83XXX_HP),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656, 1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
@@ -4309,12 +4319,10 @@ static void stac_store_hints(struct hda_codec *codec)
4309 spec->eapd_switch = val; 4319 spec->eapd_switch = val;
4310 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity); 4320 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4311 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) { 4321 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4312 if (spec->gpio_led <= 8) { 4322 spec->gpio_mask |= spec->gpio_led;
4313 spec->gpio_mask |= spec->gpio_led; 4323 spec->gpio_dir |= spec->gpio_led;
4314 spec->gpio_dir |= spec->gpio_led; 4324 if (spec->gpio_led_polarity)
4315 if (spec->gpio_led_polarity) 4325 spec->gpio_data |= spec->gpio_led;
4316 spec->gpio_data |= spec->gpio_led;
4317 }
4318 } 4326 }
4319} 4327}
4320 4328
@@ -4432,7 +4440,9 @@ static int stac92xx_init(struct hda_codec *codec)
4432 int pinctl, def_conf; 4440 int pinctl, def_conf;
4433 4441
4434 /* power on when no jack detection is available */ 4442 /* power on when no jack detection is available */
4435 if (!spec->hp_detect) { 4443 /* or when the VREF is used for controlling LED */
4444 if (!spec->hp_detect ||
4445 spec->vref_mute_led_nid == nid) {
4436 stac_toggle_power_map(codec, nid, 1); 4446 stac_toggle_power_map(codec, nid, 1);
4437 continue; 4447 continue;
4438 } 4448 }
@@ -4459,8 +4469,12 @@ static int stac92xx_init(struct hda_codec *codec)
4459 stac_toggle_power_map(codec, nid, 1); 4469 stac_toggle_power_map(codec, nid, 1);
4460 continue; 4470 continue;
4461 } 4471 }
4462 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) 4472 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
4463 stac_issue_unsol_event(codec, nid); 4473 stac_issue_unsol_event(codec, nid);
4474 continue;
4475 }
4476 /* none of the above, turn the port OFF */
4477 stac_toggle_power_map(codec, nid, 0);
4464 } 4478 }
4465 4479
4466 /* sync mute LED */ 4480 /* sync mute LED */
@@ -4716,11 +4730,7 @@ static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4716 if (idx >= spec->num_pwrs) 4730 if (idx >= spec->num_pwrs)
4717 return; 4731 return;
4718 4732
4719 /* several codecs have two power down bits */ 4733 idx = 1 << idx;
4720 if (spec->pwr_mapping)
4721 idx = spec->pwr_mapping[idx];
4722 else
4723 idx = 1 << idx;
4724 4734
4725 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; 4735 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4726 if (enable) 4736 if (enable)
@@ -4904,8 +4914,14 @@ static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
4904 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", 4914 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
4905 &spec->gpio_led_polarity, 4915 &spec->gpio_led_polarity,
4906 &spec->gpio_led) == 2) { 4916 &spec->gpio_led) == 2) {
4907 if (spec->gpio_led < 4) 4917 unsigned int max_gpio;
4918 max_gpio = snd_hda_param_read(codec, codec->afg,
4919 AC_PAR_GPIO_CAP);
4920 max_gpio &= AC_GPIO_IO_COUNT;
4921 if (spec->gpio_led < max_gpio)
4908 spec->gpio_led = 1 << spec->gpio_led; 4922 spec->gpio_led = 1 << spec->gpio_led;
4923 else
4924 spec->vref_mute_led_nid = spec->gpio_led;
4909 return 1; 4925 return 1;
4910 } 4926 }
4911 if (sscanf(dev->name, "HP_Mute_LED_%d", 4927 if (sscanf(dev->name, "HP_Mute_LED_%d",
@@ -4913,6 +4929,12 @@ static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
4913 set_hp_led_gpio(codec); 4929 set_hp_led_gpio(codec);
4914 return 1; 4930 return 1;
4915 } 4931 }
4932 /* BIOS bug: unfilled OEM string */
4933 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
4934 set_hp_led_gpio(codec);
4935 spec->gpio_led_polarity = 1;
4936 return 1;
4937 }
4916 } 4938 }
4917 4939
4918 /* 4940 /*
@@ -5034,29 +5056,12 @@ static int stac92xx_pre_resume(struct hda_codec *codec)
5034 struct sigmatel_spec *spec = codec->spec; 5056 struct sigmatel_spec *spec = codec->spec;
5035 5057
5036 /* sync mute LED */ 5058 /* sync mute LED */
5037 if (spec->gpio_led) { 5059 if (spec->vref_mute_led_nid)
5038 if (spec->gpio_led <= 8) { 5060 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5039 stac_gpio_set(codec, spec->gpio_mask, 5061 spec->vref_led);
5040 spec->gpio_dir, spec->gpio_data); 5062 else if (spec->gpio_led)
5041 } else { 5063 stac_gpio_set(codec, spec->gpio_mask,
5042 stac_vrefout_set(codec, 5064 spec->gpio_dir, spec->gpio_data);
5043 spec->gpio_led, spec->vref_led);
5044 }
5045 }
5046 return 0;
5047}
5048
5049static int stac92xx_post_suspend(struct hda_codec *codec)
5050{
5051 struct sigmatel_spec *spec = codec->spec;
5052 if (spec->gpio_led > 8) {
5053 /* with vref-out pin used for mute led control
5054 * codec AFG is prevented from D3 state, but on
5055 * system suspend it can (and should) be used
5056 */
5057 snd_hda_codec_read(codec, codec->afg, 0,
5058 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5059 }
5060 return 0; 5065 return 0;
5061} 5066}
5062 5067
@@ -5067,7 +5072,7 @@ static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5067 struct sigmatel_spec *spec = codec->spec; 5072 struct sigmatel_spec *spec = codec->spec;
5068 5073
5069 if (power_state == AC_PWRST_D3) { 5074 if (power_state == AC_PWRST_D3) {
5070 if (spec->gpio_led > 8) { 5075 if (spec->vref_mute_led_nid) {
5071 /* with vref-out pin used for mute led control 5076 /* with vref-out pin used for mute led control
5072 * codec AFG is prevented from D3 state 5077 * codec AFG is prevented from D3 state
5073 */ 5078 */
@@ -5120,7 +5125,7 @@ static int stac92xx_update_led_status(struct hda_codec *codec)
5120 } 5125 }
5121 } 5126 }
5122 /*polarity defines *not* muted state level*/ 5127 /*polarity defines *not* muted state level*/
5123 if (spec->gpio_led <= 8) { 5128 if (!spec->vref_mute_led_nid) {
5124 if (muted) 5129 if (muted)
5125 spec->gpio_data &= ~spec->gpio_led; /* orange */ 5130 spec->gpio_data &= ~spec->gpio_led; /* orange */
5126 else 5131 else
@@ -5138,7 +5143,8 @@ static int stac92xx_update_led_status(struct hda_codec *codec)
5138 muted_lvl = spec->gpio_led_polarity ? 5143 muted_lvl = spec->gpio_led_polarity ?
5139 AC_PINCTL_VREF_GRD : AC_PINCTL_VREF_HIZ; 5144 AC_PINCTL_VREF_GRD : AC_PINCTL_VREF_HIZ;
5140 spec->vref_led = muted ? muted_lvl : notmtd_lvl; 5145 spec->vref_led = muted ? muted_lvl : notmtd_lvl;
5141 stac_vrefout_set(codec, spec->gpio_led, spec->vref_led); 5146 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5147 spec->vref_led);
5142 } 5148 }
5143 return 0; 5149 return 0;
5144} 5150}
@@ -5618,9 +5624,6 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
5618 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e); 5624 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5619 } 5625 }
5620 5626
5621 /* reset pin power-down; Windows may leave these bits after reboot */
5622 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7EC, 0);
5623 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7ED, 0);
5624 codec->no_trigger_sense = 1; 5627 codec->no_trigger_sense = 1;
5625 codec->spec = spec; 5628 codec->spec = spec;
5626 5629
@@ -5630,7 +5633,6 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
5630 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; 5633 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5631 spec->digbeep_nid = 0x21; 5634 spec->digbeep_nid = 0x21;
5632 spec->pwr_nids = stac92hd83xxx_pwr_nids; 5635 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5633 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5634 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); 5636 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5635 spec->multiout.dac_nids = spec->dac_nids; 5637 spec->multiout.dac_nids = spec->dac_nids;
5636 spec->init = stac92hd83xxx_core_init; 5638 spec->init = stac92hd83xxx_core_init;
@@ -5647,9 +5649,6 @@ again:
5647 stac92xx_set_config_regs(codec, 5649 stac92xx_set_config_regs(codec,
5648 stac92hd83xxx_brd_tbl[spec->board_config]); 5650 stac92hd83xxx_brd_tbl[spec->board_config]);
5649 5651
5650 if (spec->board_config != STAC_92HD83XXX_PWR_REF)
5651 spec->num_pwrs = 0;
5652
5653 codec->patch_ops = stac92xx_patch_ops; 5652 codec->patch_ops = stac92xx_patch_ops;
5654 5653
5655 if (find_mute_led_gpio(codec, 0)) 5654 if (find_mute_led_gpio(codec, 0))
@@ -5659,15 +5658,13 @@ again:
5659 5658
5660#ifdef CONFIG_SND_HDA_POWER_SAVE 5659#ifdef CONFIG_SND_HDA_POWER_SAVE
5661 if (spec->gpio_led) { 5660 if (spec->gpio_led) {
5662 if (spec->gpio_led <= 8) { 5661 if (!spec->vref_mute_led_nid) {
5663 spec->gpio_mask |= spec->gpio_led; 5662 spec->gpio_mask |= spec->gpio_led;
5664 spec->gpio_dir |= spec->gpio_led; 5663 spec->gpio_dir |= spec->gpio_led;
5665 spec->gpio_data |= spec->gpio_led; 5664 spec->gpio_data |= spec->gpio_led;
5666 } else { 5665 } else {
5667 codec->patch_ops.set_power_state = 5666 codec->patch_ops.set_power_state =
5668 stac92xx_set_power_state; 5667 stac92xx_set_power_state;
5669 codec->patch_ops.post_suspend =
5670 stac92xx_post_suspend;
5671 } 5668 }
5672 codec->patch_ops.pre_resume = stac92xx_pre_resume; 5669 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5673 codec->patch_ops.check_power_status = 5670 codec->patch_ops.check_power_status =
@@ -5858,8 +5855,6 @@ again:
5858 (codec->revision_id & 0xf) == 1) 5855 (codec->revision_id & 0xf) == 1)
5859 spec->stream_delay = 40; /* 40 milliseconds */ 5856 spec->stream_delay = 40; /* 40 milliseconds */
5860 5857
5861 /* no output amps */
5862 spec->num_pwrs = 0;
5863 /* disable VSW */ 5858 /* disable VSW */
5864 spec->init = stac92hd71bxx_core_init; 5859 spec->init = stac92hd71bxx_core_init;
5865 unmute_init++; 5860 unmute_init++;
@@ -5874,8 +5869,6 @@ again:
5874 if ((codec->revision_id & 0xf) == 1) 5869 if ((codec->revision_id & 0xf) == 1)
5875 spec->stream_delay = 40; /* 40 milliseconds */ 5870 spec->stream_delay = 40; /* 40 milliseconds */
5876 5871
5877 /* no output amps */
5878 spec->num_pwrs = 0;
5879 /* fallthru */ 5872 /* fallthru */
5880 default: 5873 default:
5881 spec->init = stac92hd71bxx_core_init; 5874 spec->init = stac92hd71bxx_core_init;
@@ -5978,15 +5971,13 @@ again:
5978 5971
5979#ifdef CONFIG_SND_HDA_POWER_SAVE 5972#ifdef CONFIG_SND_HDA_POWER_SAVE
5980 if (spec->gpio_led) { 5973 if (spec->gpio_led) {
5981 if (spec->gpio_led <= 8) { 5974 if (!spec->vref_mute_led_nid) {
5982 spec->gpio_mask |= spec->gpio_led; 5975 spec->gpio_mask |= spec->gpio_led;
5983 spec->gpio_dir |= spec->gpio_led; 5976 spec->gpio_dir |= spec->gpio_led;
5984 spec->gpio_data |= spec->gpio_led; 5977 spec->gpio_data |= spec->gpio_led;
5985 } else { 5978 } else {
5986 codec->patch_ops.set_power_state = 5979 codec->patch_ops.set_power_state =
5987 stac92xx_set_power_state; 5980 stac92xx_set_power_state;
5988 codec->patch_ops.post_suspend =
5989 stac92xx_post_suspend;
5990 } 5981 }
5991 codec->patch_ops.pre_resume = stac92xx_pre_resume; 5982 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5992 codec->patch_ops.check_power_status = 5983 codec->patch_ops.check_power_status =
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 431c0d417eeb..b5137629f8e9 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -208,6 +208,7 @@ struct via_spec {
208 /* work to check hp jack state */ 208 /* work to check hp jack state */
209 struct hda_codec *codec; 209 struct hda_codec *codec;
210 struct delayed_work vt1708_hp_work; 210 struct delayed_work vt1708_hp_work;
211 int hp_work_active;
211 int vt1708_jack_detect; 212 int vt1708_jack_detect;
212 int vt1708_hp_present; 213 int vt1708_hp_present;
213 214
@@ -305,27 +306,35 @@ enum {
305static void analog_low_current_mode(struct hda_codec *codec); 306static void analog_low_current_mode(struct hda_codec *codec);
306static bool is_aa_path_mute(struct hda_codec *codec); 307static bool is_aa_path_mute(struct hda_codec *codec);
307 308
308static void vt1708_start_hp_work(struct via_spec *spec) 309#define hp_detect_with_aa(codec) \
310 (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
311 !is_aa_path_mute(codec))
312
313static void vt1708_stop_hp_work(struct via_spec *spec)
309{ 314{
310 if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) 315 if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0)
311 return; 316 return;
312 snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 317 if (spec->hp_work_active) {
313 !spec->vt1708_jack_detect); 318 snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 1);
314 if (!delayed_work_pending(&spec->vt1708_hp_work)) 319 cancel_delayed_work_sync(&spec->vt1708_hp_work);
315 schedule_delayed_work(&spec->vt1708_hp_work, 320 spec->hp_work_active = 0;
316 msecs_to_jiffies(100)); 321 }
317} 322}
318 323
319static void vt1708_stop_hp_work(struct via_spec *spec) 324static void vt1708_update_hp_work(struct via_spec *spec)
320{ 325{
321 if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) 326 if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0)
322 return; 327 return;
323 if (snd_hda_get_bool_hint(spec->codec, "analog_loopback_hp_detect") == 1 328 if (spec->vt1708_jack_detect &&
324 && !is_aa_path_mute(spec->codec)) 329 (spec->active_streams || hp_detect_with_aa(spec->codec))) {
325 return; 330 if (!spec->hp_work_active) {
326 snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 331 snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, 0);
327 !spec->vt1708_jack_detect); 332 schedule_delayed_work(&spec->vt1708_hp_work,
328 cancel_delayed_work_sync(&spec->vt1708_hp_work); 333 msecs_to_jiffies(100));
334 spec->hp_work_active = 1;
335 }
336 } else if (!hp_detect_with_aa(spec->codec))
337 vt1708_stop_hp_work(spec);
329} 338}
330 339
331static void set_widgets_power_state(struct hda_codec *codec) 340static void set_widgets_power_state(struct hda_codec *codec)
@@ -343,12 +352,7 @@ static int analog_input_switch_put(struct snd_kcontrol *kcontrol,
343 352
344 set_widgets_power_state(codec); 353 set_widgets_power_state(codec);
345 analog_low_current_mode(snd_kcontrol_chip(kcontrol)); 354 analog_low_current_mode(snd_kcontrol_chip(kcontrol));
346 if (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1) { 355 vt1708_update_hp_work(codec->spec);
347 if (is_aa_path_mute(codec))
348 vt1708_start_hp_work(codec->spec);
349 else
350 vt1708_stop_hp_work(codec->spec);
351 }
352 return change; 356 return change;
353} 357}
354 358
@@ -1154,7 +1158,7 @@ static int via_playback_multi_pcm_prepare(struct hda_pcm_stream *hinfo,
1154 spec->cur_dac_stream_tag = stream_tag; 1158 spec->cur_dac_stream_tag = stream_tag;
1155 spec->cur_dac_format = format; 1159 spec->cur_dac_format = format;
1156 mutex_unlock(&spec->config_mutex); 1160 mutex_unlock(&spec->config_mutex);
1157 vt1708_start_hp_work(spec); 1161 vt1708_update_hp_work(spec);
1158 return 0; 1162 return 0;
1159} 1163}
1160 1164
@@ -1174,7 +1178,7 @@ static int via_playback_hp_pcm_prepare(struct hda_pcm_stream *hinfo,
1174 spec->cur_hp_stream_tag = stream_tag; 1178 spec->cur_hp_stream_tag = stream_tag;
1175 spec->cur_hp_format = format; 1179 spec->cur_hp_format = format;
1176 mutex_unlock(&spec->config_mutex); 1180 mutex_unlock(&spec->config_mutex);
1177 vt1708_start_hp_work(spec); 1181 vt1708_update_hp_work(spec);
1178 return 0; 1182 return 0;
1179} 1183}
1180 1184
@@ -1188,7 +1192,7 @@ static int via_playback_multi_pcm_cleanup(struct hda_pcm_stream *hinfo,
1188 snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 1192 snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1189 spec->active_streams &= ~STREAM_MULTI_OUT; 1193 spec->active_streams &= ~STREAM_MULTI_OUT;
1190 mutex_unlock(&spec->config_mutex); 1194 mutex_unlock(&spec->config_mutex);
1191 vt1708_stop_hp_work(spec); 1195 vt1708_update_hp_work(spec);
1192 return 0; 1196 return 0;
1193} 1197}
1194 1198
@@ -1203,7 +1207,7 @@ static int via_playback_hp_pcm_cleanup(struct hda_pcm_stream *hinfo,
1203 snd_hda_codec_setup_stream(codec, spec->hp_dac_nid, 0, 0, 0); 1207 snd_hda_codec_setup_stream(codec, spec->hp_dac_nid, 0, 0, 0);
1204 spec->active_streams &= ~STREAM_INDEP_HP; 1208 spec->active_streams &= ~STREAM_INDEP_HP;
1205 mutex_unlock(&spec->config_mutex); 1209 mutex_unlock(&spec->config_mutex);
1206 vt1708_stop_hp_work(spec); 1210 vt1708_update_hp_work(spec);
1207 return 0; 1211 return 0;
1208} 1212}
1209 1213
@@ -1645,7 +1649,8 @@ static void via_hp_automute(struct hda_codec *codec)
1645 int nums; 1649 int nums;
1646 struct via_spec *spec = codec->spec; 1650 struct via_spec *spec = codec->spec;
1647 1651
1648 if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0]) 1652 if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0] &&
1653 (spec->codec_type != VT1708 || spec->vt1708_jack_detect))
1649 present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); 1654 present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
1650 1655
1651 if (spec->smart51_enabled) 1656 if (spec->smart51_enabled)
@@ -2612,8 +2617,6 @@ static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol,
2612 2617
2613 if (spec->codec_type != VT1708) 2618 if (spec->codec_type != VT1708)
2614 return 0; 2619 return 0;
2615 spec->vt1708_jack_detect =
2616 !((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1);
2617 ucontrol->value.integer.value[0] = spec->vt1708_jack_detect; 2620 ucontrol->value.integer.value[0] = spec->vt1708_jack_detect;
2618 return 0; 2621 return 0;
2619} 2622}
@@ -2623,18 +2626,22 @@ static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol,
2623{ 2626{
2624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2625 struct via_spec *spec = codec->spec; 2628 struct via_spec *spec = codec->spec;
2626 int change; 2629 int val;
2627 2630
2628 if (spec->codec_type != VT1708) 2631 if (spec->codec_type != VT1708)
2629 return 0; 2632 return 0;
2630 spec->vt1708_jack_detect = ucontrol->value.integer.value[0]; 2633 val = !!ucontrol->value.integer.value[0];
2631 change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8)) 2634 if (spec->vt1708_jack_detect == val)
2632 == !spec->vt1708_jack_detect; 2635 return 0;
2633 if (spec->vt1708_jack_detect) { 2636 spec->vt1708_jack_detect = val;
2637 if (spec->vt1708_jack_detect &&
2638 snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") != 1) {
2634 mute_aa_path(codec, 1); 2639 mute_aa_path(codec, 1);
2635 notify_aa_path_ctls(codec); 2640 notify_aa_path_ctls(codec);
2636 } 2641 }
2637 return change; 2642 via_hp_automute(codec);
2643 vt1708_update_hp_work(spec);
2644 return 1;
2638} 2645}
2639 2646
2640static const struct snd_kcontrol_new vt1708_jack_detect_ctl = { 2647static const struct snd_kcontrol_new vt1708_jack_detect_ctl = {
@@ -2771,6 +2778,7 @@ static int via_init(struct hda_codec *codec)
2771 via_auto_init_unsol_event(codec); 2778 via_auto_init_unsol_event(codec);
2772 2779
2773 via_hp_automute(codec); 2780 via_hp_automute(codec);
2781 vt1708_update_hp_work(spec);
2774 2782
2775 return 0; 2783 return 0;
2776} 2784}
@@ -2787,7 +2795,9 @@ static void vt1708_update_hp_jack_state(struct work_struct *work)
2787 spec->vt1708_hp_present ^= 1; 2795 spec->vt1708_hp_present ^= 1;
2788 via_hp_automute(spec->codec); 2796 via_hp_automute(spec->codec);
2789 } 2797 }
2790 vt1708_start_hp_work(spec); 2798 if (spec->vt1708_jack_detect)
2799 schedule_delayed_work(&spec->vt1708_hp_work,
2800 msecs_to_jiffies(100));
2791} 2801}
2792 2802
2793static int get_mux_nids(struct hda_codec *codec) 2803static int get_mux_nids(struct hda_codec *codec)
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 29e312597f20..11718b49b2e2 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1077,6 +1077,13 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs
1077 } 1077 }
1078 if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV)) 1078 if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV))
1079 continue; 1079 continue;
1080
1081 /* IO read operation is very expensive inside virtual machine
1082 * as it is emulated. The probability that subsequent PICB read
1083 * will return different result is high enough to loop till
1084 * timeout here.
1085 * Same CIV is strict enough condition to be sure that PICB
1086 * is valid inside VM on emulated card. */
1080 if (chip->inside_vm) 1087 if (chip->inside_vm)
1081 break; 1088 break;
1082 if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) 1089 if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
@@ -2930,6 +2937,45 @@ static unsigned int sis_codec_bits[3] = {
2930 ICH_PCR, ICH_SCR, ICH_SIS_TCR 2937 ICH_PCR, ICH_SCR, ICH_SIS_TCR
2931}; 2938};
2932 2939
2940static int __devinit snd_intel8x0_inside_vm(struct pci_dev *pci)
2941{
2942 int result = inside_vm;
2943 char *msg = NULL;
2944
2945 /* check module parameter first (override detection) */
2946 if (result >= 0) {
2947 msg = result ? "enable (forced) VM" : "disable (forced) VM";
2948 goto fini;
2949 }
2950
2951 /* detect KVM and Parallels virtual environments */
2952 result = kvm_para_available();
2953#ifdef X86_FEATURE_HYPERVISOR
2954 result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR);
2955#endif
2956 if (!result)
2957 goto fini;
2958
2959 /* check for known (emulated) devices */
2960 if (pci->subsystem_vendor == 0x1af4 &&
2961 pci->subsystem_device == 0x1100) {
2962 /* KVM emulated sound, PCI SSID: 1af4:1100 */
2963 msg = "enable KVM";
2964 } else if (pci->subsystem_vendor == 0x1ab8) {
2965 /* Parallels VM emulated sound, PCI SSID: 1ab8:xxxx */
2966 msg = "enable Parallels VM";
2967 } else {
2968 msg = "disable (unknown or VT-d) VM";
2969 result = 0;
2970 }
2971
2972fini:
2973 if (msg != NULL)
2974 printk(KERN_INFO "intel8x0: %s optimization\n", msg);
2975
2976 return result;
2977}
2978
2933static int __devinit snd_intel8x0_create(struct snd_card *card, 2979static int __devinit snd_intel8x0_create(struct snd_card *card,
2934 struct pci_dev *pci, 2980 struct pci_dev *pci,
2935 unsigned long device_type, 2981 unsigned long device_type,
@@ -2997,9 +3043,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2997 if (xbox) 3043 if (xbox)
2998 chip->xbox = 1; 3044 chip->xbox = 1;
2999 3045
3000 chip->inside_vm = inside_vm; 3046 chip->inside_vm = snd_intel8x0_inside_vm(pci);
3001 if (inside_vm)
3002 printk(KERN_INFO "intel8x0: enable KVM optimization\n");
3003 3047
3004 if (pci->vendor == PCI_VENDOR_ID_INTEL && 3048 if (pci->vendor == PCI_VENDOR_ID_INTEL &&
3005 pci->device == PCI_DEVICE_ID_INTEL_440MX) 3049 pci->device == PCI_DEVICE_ID_INTEL_440MX)
@@ -3243,14 +3287,6 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
3243 buggy_irq = 0; 3287 buggy_irq = 0;
3244 } 3288 }
3245 3289
3246 if (inside_vm < 0) {
3247 /* detect KVM and Parallels virtual environments */
3248 inside_vm = kvm_para_available();
3249#if defined(__i386__) || defined(__x86_64__)
3250 inside_vm = inside_vm || boot_cpu_has(X86_FEATURE_HYPERVISOR);
3251#endif
3252 }
3253
3254 if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, 3290 if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data,
3255 &chip)) < 0) { 3291 &chip)) < 0) {
3256 snd_card_free(card); 3292 snd_card_free(card);
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
index 5c8717e29eeb..8c3e7fcefd99 100644
--- a/sound/pci/lx6464es/lx_core.c
+++ b/sound/pci/lx6464es/lx_core.c
@@ -78,10 +78,15 @@ unsigned long lx_dsp_reg_read(struct lx6464es *chip, int port)
78 return ioread32(address); 78 return ioread32(address);
79} 79}
80 80
81void lx_dsp_reg_readbuf(struct lx6464es *chip, int port, u32 *data, u32 len) 81static void lx_dsp_reg_readbuf(struct lx6464es *chip, int port, u32 *data,
82 u32 len)
82{ 83{
83 void __iomem *address = lx_dsp_register(chip, port); 84 u32 __iomem *address = lx_dsp_register(chip, port);
84 memcpy_fromio(data, address, len*sizeof(u32)); 85 int i;
86
87 /* we cannot use memcpy_fromio */
88 for (i = 0; i != len; ++i)
89 data[i] = ioread32(address + i);
85} 90}
86 91
87 92
@@ -91,11 +96,15 @@ void lx_dsp_reg_write(struct lx6464es *chip, int port, unsigned data)
91 iowrite32(data, address); 96 iowrite32(data, address);
92} 97}
93 98
94void lx_dsp_reg_writebuf(struct lx6464es *chip, int port, const u32 *data, 99static void lx_dsp_reg_writebuf(struct lx6464es *chip, int port,
95 u32 len) 100 const u32 *data, u32 len)
96{ 101{
97 void __iomem *address = lx_dsp_register(chip, port); 102 u32 __iomem *address = lx_dsp_register(chip, port);
98 memcpy_toio(address, data, len*sizeof(u32)); 103 int i;
104
105 /* we cannot use memcpy_to */
106 for (i = 0; i != len; ++i)
107 iowrite32(data[i], address + i);
99} 108}
100 109
101 110
diff --git a/sound/pci/lx6464es/lx_core.h b/sound/pci/lx6464es/lx_core.h
index 1dd562980b6c..4d7ff797a646 100644
--- a/sound/pci/lx6464es/lx_core.h
+++ b/sound/pci/lx6464es/lx_core.h
@@ -72,10 +72,7 @@ enum {
72}; 72};
73 73
74unsigned long lx_dsp_reg_read(struct lx6464es *chip, int port); 74unsigned long lx_dsp_reg_read(struct lx6464es *chip, int port);
75void lx_dsp_reg_readbuf(struct lx6464es *chip, int port, u32 *data, u32 len);
76void lx_dsp_reg_write(struct lx6464es *chip, int port, unsigned data); 75void lx_dsp_reg_write(struct lx6464es *chip, int port, unsigned data);
77void lx_dsp_reg_writebuf(struct lx6464es *chip, int port, const u32 *data,
78 u32 len);
79 76
80/* plx register access */ 77/* plx register access */
81enum { 78enum {
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index e760adad9523..19ee2203cbb5 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -6518,7 +6518,7 @@ static int __devinit snd_hdspm_create(struct snd_card *card,
6518 hdspm->io_type = AES32; 6518 hdspm->io_type = AES32;
6519 hdspm->card_name = "RME AES32"; 6519 hdspm->card_name = "RME AES32";
6520 hdspm->midiPorts = 2; 6520 hdspm->midiPorts = 2;
6521 } else if ((hdspm->firmware_rev == 0xd5) || 6521 } else if ((hdspm->firmware_rev == 0xd2) ||
6522 ((hdspm->firmware_rev >= 0xc8) && 6522 ((hdspm->firmware_rev >= 0xc8) &&
6523 (hdspm->firmware_rev <= 0xcf))) { 6523 (hdspm->firmware_rev <= 0xcf))) {
6524 hdspm->io_type = MADI; 6524 hdspm->io_type = MADI;
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index a391e622a192..28dfafb56dd1 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -41,6 +41,7 @@ MODULE_SUPPORTED_DEVICE("{{SiS,SiS7019 Audio Accelerator}}");
41static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 41static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
42static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 42static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
43static int enable = 1; 43static int enable = 1;
44static int codecs = 1;
44 45
45module_param(index, int, 0444); 46module_param(index, int, 0444);
46MODULE_PARM_DESC(index, "Index value for SiS7019 Audio Accelerator."); 47MODULE_PARM_DESC(index, "Index value for SiS7019 Audio Accelerator.");
@@ -48,6 +49,8 @@ module_param(id, charp, 0444);
48MODULE_PARM_DESC(id, "ID string for SiS7019 Audio Accelerator."); 49MODULE_PARM_DESC(id, "ID string for SiS7019 Audio Accelerator.");
49module_param(enable, bool, 0444); 50module_param(enable, bool, 0444);
50MODULE_PARM_DESC(enable, "Enable SiS7019 Audio Accelerator."); 51MODULE_PARM_DESC(enable, "Enable SiS7019 Audio Accelerator.");
52module_param(codecs, int, 0444);
53MODULE_PARM_DESC(codecs, "Set bit to indicate that codec number is expected to be present (default 1)");
51 54
52static DEFINE_PCI_DEVICE_TABLE(snd_sis7019_ids) = { 55static DEFINE_PCI_DEVICE_TABLE(snd_sis7019_ids) = {
53 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x7019) }, 56 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x7019) },
@@ -140,6 +143,9 @@ struct sis7019 {
140 dma_addr_t silence_dma_addr; 143 dma_addr_t silence_dma_addr;
141}; 144};
142 145
146/* These values are also used by the module param 'codecs' to indicate
147 * which codecs should be present.
148 */
143#define SIS_PRIMARY_CODEC_PRESENT 0x0001 149#define SIS_PRIMARY_CODEC_PRESENT 0x0001
144#define SIS_SECONDARY_CODEC_PRESENT 0x0002 150#define SIS_SECONDARY_CODEC_PRESENT 0x0002
145#define SIS_TERTIARY_CODEC_PRESENT 0x0004 151#define SIS_TERTIARY_CODEC_PRESENT 0x0004
@@ -1078,6 +1084,7 @@ static int sis_chip_init(struct sis7019 *sis)
1078{ 1084{
1079 unsigned long io = sis->ioport; 1085 unsigned long io = sis->ioport;
1080 void __iomem *ioaddr = sis->ioaddr; 1086 void __iomem *ioaddr = sis->ioaddr;
1087 unsigned long timeout;
1081 u16 status; 1088 u16 status;
1082 int count; 1089 int count;
1083 int i; 1090 int i;
@@ -1104,21 +1111,45 @@ static int sis_chip_init(struct sis7019 *sis)
1104 while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count) 1111 while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count)
1105 udelay(1); 1112 udelay(1);
1106 1113
1114 /* Command complete, we can let go of the semaphore now.
1115 */
1116 outl(SIS_AC97_SEMA_RELEASE, io + SIS_AC97_SEMA);
1117 if (!count)
1118 return -EIO;
1119
1107 /* Now that we've finished the reset, find out what's attached. 1120 /* Now that we've finished the reset, find out what's attached.
1121 * There are some codec/board combinations that take an extremely
1122 * long time to come up. 350+ ms has been observed in the field,
1123 * so we'll give them up to 500ms.
1108 */ 1124 */
1109 status = inl(io + SIS_AC97_STATUS); 1125 sis->codecs_present = 0;
1110 if (status & SIS_AC97_STATUS_CODEC_READY) 1126 timeout = msecs_to_jiffies(500) + jiffies;
1111 sis->codecs_present |= SIS_PRIMARY_CODEC_PRESENT; 1127 while (time_before_eq(jiffies, timeout)) {
1112 if (status & SIS_AC97_STATUS_CODEC2_READY) 1128 status = inl(io + SIS_AC97_STATUS);
1113 sis->codecs_present |= SIS_SECONDARY_CODEC_PRESENT; 1129 if (status & SIS_AC97_STATUS_CODEC_READY)
1114 if (status & SIS_AC97_STATUS_CODEC3_READY) 1130 sis->codecs_present |= SIS_PRIMARY_CODEC_PRESENT;
1115 sis->codecs_present |= SIS_TERTIARY_CODEC_PRESENT; 1131 if (status & SIS_AC97_STATUS_CODEC2_READY)
1116 1132 sis->codecs_present |= SIS_SECONDARY_CODEC_PRESENT;
1117 /* All done, let go of the semaphore, and check for errors 1133 if (status & SIS_AC97_STATUS_CODEC3_READY)
1134 sis->codecs_present |= SIS_TERTIARY_CODEC_PRESENT;
1135
1136 if (sis->codecs_present == codecs)
1137 break;
1138
1139 msleep(1);
1140 }
1141
1142 /* All done, check for errors.
1118 */ 1143 */
1119 outl(SIS_AC97_SEMA_RELEASE, io + SIS_AC97_SEMA); 1144 if (!sis->codecs_present) {
1120 if (!sis->codecs_present || !count) 1145 printk(KERN_ERR "sis7019: could not find any codecs\n");
1121 return -EIO; 1146 return -EIO;
1147 }
1148
1149 if (sis->codecs_present != codecs) {
1150 printk(KERN_WARNING "sis7019: missing codecs, found %0x, expected %0x\n",
1151 sis->codecs_present, codecs);
1152 }
1122 1153
1123 /* Let the hardware know that the audio driver is alive, 1154 /* Let the hardware know that the audio driver is alive,
1124 * and enable PCM slots on the AC-link for L/R playback (3 & 4) and 1155 * and enable PCM slots on the AC-link for L/R playback (3 & 4) and
@@ -1390,6 +1421,17 @@ static int __devinit snd_sis7019_probe(struct pci_dev *pci,
1390 if (!enable) 1421 if (!enable)
1391 goto error_out; 1422 goto error_out;
1392 1423
1424 /* The user can specify which codecs should be present so that we
1425 * can wait for them to show up if they are slow to recover from
1426 * the AC97 cold reset. We default to a single codec, the primary.
1427 *
1428 * We assume that SIS_PRIMARY_*_PRESENT matches bits 0-2.
1429 */
1430 codecs &= SIS_PRIMARY_CODEC_PRESENT | SIS_SECONDARY_CODEC_PRESENT |
1431 SIS_TERTIARY_CODEC_PRESENT;
1432 if (!codecs)
1433 codecs = SIS_PRIMARY_CODEC_PRESENT;
1434
1393 rc = snd_card_create(index, id, THIS_MODULE, sizeof(*sis), &card); 1435 rc = snd_card_create(index, id, THIS_MODULE, sizeof(*sis), &card);
1394 if (rc < 0) 1436 if (rc < 0)
1395 goto error_out; 1437 goto error_out;
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c
index a3ce1b22620d..1aa52eff526a 100644
--- a/sound/ppc/snd_ps3.c
+++ b/sound/ppc/snd_ps3.c
@@ -876,7 +876,7 @@ static void __devinit snd_ps3_audio_set_base_addr(uint64_t ioaddr_start)
876 (0x0fUL << 12) | 876 (0x0fUL << 12) |
877 (PS3_AUDIO_IOID); 877 (PS3_AUDIO_IOID);
878 878
879 ret = lv1_gpu_attribute(0x100, 0x007, val, 0, 0); 879 ret = lv1_gpu_attribute(0x100, 0x007, val);
880 if (ret) 880 if (ret)
881 pr_info("%s: gpu_attribute failed %d\n", __func__, 881 pr_info("%s: gpu_attribute failed %d\n", __func__,
882 ret); 882 ret);
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
index bee3c94f58b0..d1fcc816ce97 100644
--- a/sound/soc/atmel/Kconfig
+++ b/sound/soc/atmel/Kconfig
@@ -1,6 +1,6 @@
1config SND_ATMEL_SOC 1config SND_ATMEL_SOC
2 tristate "SoC Audio for the Atmel System-on-Chip" 2 tristate "SoC Audio for the Atmel System-on-Chip"
3 depends on ARCH_AT91 || AVR32 3 depends on ARCH_AT91
4 help 4 help
5 Say Y or M if you want to add support for codecs attached to 5 Say Y or M if you want to add support for codecs attached to
6 the ATMEL SSC interface. You will also need 6 the ATMEL SSC interface. You will also need
@@ -24,25 +24,6 @@ config SND_AT91_SOC_SAM9G20_WM8731
24 Say Y if you want to add support for SoC audio on WM8731-based 24 Say Y if you want to add support for SoC audio on WM8731-based
25 AT91sam9g20 evaluation board. 25 AT91sam9g20 evaluation board.
26 26
27config SND_AT32_SOC_PLAYPAQ
28 tristate "SoC Audio support for PlayPaq with WM8510"
29 depends on SND_ATMEL_SOC && BOARD_PLAYPAQ && AT91_PROGRAMMABLE_CLOCKS
30 select SND_ATMEL_SOC_SSC
31 select SND_SOC_WM8510
32 help
33 Say Y or M here if you want to add support for SoC audio
34 on the LRS PlayPaq.
35
36config SND_AT32_SOC_PLAYPAQ_SLAVE
37 bool "Run CODEC on PlayPaq in slave mode"
38 depends on SND_AT32_SOC_PLAYPAQ
39 default n
40 help
41 Say Y if you want to run with the AT32 SSC generating the BCLK
42 and FRAME signals on the PlayPaq. Unless you want to play
43 with the AT32 as the SSC master, you probably want to say N here,
44 as this will give you better sound quality.
45
46config SND_AT91_SOC_AFEB9260 27config SND_AT91_SOC_AFEB9260
47 tristate "SoC Audio support for AFEB9260 board" 28 tristate "SoC Audio support for AFEB9260 board"
48 depends on ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC 29 depends on ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC
diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile
index e7ea56bd5f82..a5c0bf19da78 100644
--- a/sound/soc/atmel/Makefile
+++ b/sound/soc/atmel/Makefile
@@ -8,9 +8,5 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o
8# AT91 Machine Support 8# AT91 Machine Support
9snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o 9snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o
10 10
11# AT32 Machine Support
12snd-soc-playpaq-objs := playpaq_wm8510.o
13
14obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o 11obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
15obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
16obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o 12obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
diff --git a/sound/soc/atmel/playpaq_wm8510.c b/sound/soc/atmel/playpaq_wm8510.c
deleted file mode 100644
index 73ae99ad4578..000000000000
--- a/sound/soc/atmel/playpaq_wm8510.c
+++ /dev/null
@@ -1,473 +0,0 @@
1/* sound/soc/at32/playpaq_wm8510.c
2 * ASoC machine driver for PlayPaq using WM8510 codec
3 *
4 * Copyright (C) 2008 Long Range Systems
5 * Geoffrey Wossum <gwossum@acm.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This code is largely inspired by sound/soc/at91/eti_b1_wm8731.c
12 *
13 * NOTE: If you don't have the AT32 enhanced portmux configured (which
14 * isn't currently in the mainline or Atmel patched kernel), you will
15 * need to set the MCLK pin (PA30) to peripheral A in your board initialization
16 * code. Something like:
17 * at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0);
18 *
19 */
20
21/* #define DEBUG */
22
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/kernel.h>
26#include <linux/errno.h>
27#include <linux/clk.h>
28#include <linux/timer.h>
29#include <linux/interrupt.h>
30#include <linux/platform_device.h>
31
32#include <sound/core.h>
33#include <sound/pcm.h>
34#include <sound/pcm_params.h>
35#include <sound/soc.h>
36
37#include <mach/at32ap700x.h>
38#include <mach/portmux.h>
39
40#include "../codecs/wm8510.h"
41#include "atmel-pcm.h"
42#include "atmel_ssc_dai.h"
43
44
45/*-------------------------------------------------------------------------*\
46 * constants
47\*-------------------------------------------------------------------------*/
48#define MCLK_PIN GPIO_PIN_PA(30)
49#define MCLK_PERIPH GPIO_PERIPH_A
50
51
52/*-------------------------------------------------------------------------*\
53 * data types
54\*-------------------------------------------------------------------------*/
55/* SSC clocking data */
56struct ssc_clock_data {
57 /* CMR div */
58 unsigned int cmr_div;
59
60 /* Frame period (as needed by xCMR.PERIOD) */
61 unsigned int period;
62
63 /* The SSC clock rate these settings where calculated for */
64 unsigned long ssc_rate;
65};
66
67
68/*-------------------------------------------------------------------------*\
69 * module data
70\*-------------------------------------------------------------------------*/
71static struct clk *_gclk0;
72static struct clk *_pll0;
73
74#define CODEC_CLK (_gclk0)
75
76
77/*-------------------------------------------------------------------------*\
78 * Sound SOC operations
79\*-------------------------------------------------------------------------*/
80#if defined CONFIG_SND_AT32_SOC_PLAYPAQ_SLAVE
81static struct ssc_clock_data playpaq_wm8510_calc_ssc_clock(
82 struct snd_pcm_hw_params *params,
83 struct snd_soc_dai *cpu_dai)
84{
85 struct at32_ssc_info *ssc_p = snd_soc_dai_get_drvdata(cpu_dai);
86 struct ssc_device *ssc = ssc_p->ssc;
87 struct ssc_clock_data cd;
88 unsigned int rate, width_bits, channels;
89 unsigned int bitrate, ssc_div;
90 unsigned actual_rate;
91
92
93 /*
94 * Figure out required bitrate
95 */
96 rate = params_rate(params);
97 channels = params_channels(params);
98 width_bits = snd_pcm_format_physical_width(params_format(params));
99 bitrate = rate * width_bits * channels;
100
101
102 /*
103 * Figure out required SSC divider and period for required bitrate
104 */
105 cd.ssc_rate = clk_get_rate(ssc->clk);
106 ssc_div = cd.ssc_rate / bitrate;
107 cd.cmr_div = ssc_div / 2;
108 if (ssc_div & 1) {
109 /* round cmr_div up */
110 cd.cmr_div++;
111 }
112 cd.period = width_bits - 1;
113
114
115 /*
116 * Find actual rate, compare to requested rate
117 */
118 actual_rate = (cd.ssc_rate / (cd.cmr_div * 2)) / (2 * (cd.period + 1));
119 pr_debug("playpaq_wm8510: Request rate = %u, actual rate = %u\n",
120 rate, actual_rate);
121
122
123 return cd;
124}
125#endif /* CONFIG_SND_AT32_SOC_PLAYPAQ_SLAVE */
126
127
128
129static int playpaq_wm8510_hw_params(struct snd_pcm_substream *substream,
130 struct snd_pcm_hw_params *params)
131{
132 struct snd_soc_pcm_runtime *rtd = substream->private_data;
133 struct snd_soc_dai *codec_dai = rtd->codec_dai;
134 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
135 struct at32_ssc_info *ssc_p = snd_soc_dai_get_drvdata(cpu_dai);
136 struct ssc_device *ssc = ssc_p->ssc;
137 unsigned int pll_out = 0, bclk = 0, mclk_div = 0;
138 int ret;
139
140
141 /* Due to difficulties with getting the correct clocks from the AT32's
142 * PLL0, we're going to let the CODEC be in charge of all the clocks
143 */
144#if !defined CONFIG_SND_AT32_SOC_PLAYPAQ_SLAVE
145 const unsigned int fmt = (SND_SOC_DAIFMT_I2S |
146 SND_SOC_DAIFMT_NB_NF |
147 SND_SOC_DAIFMT_CBM_CFM);
148#else
149 struct ssc_clock_data cd;
150 const unsigned int fmt = (SND_SOC_DAIFMT_I2S |
151 SND_SOC_DAIFMT_NB_NF |
152 SND_SOC_DAIFMT_CBS_CFS);
153#endif
154
155 if (ssc == NULL) {
156 pr_warning("playpaq_wm8510_hw_params: ssc is NULL!\n");
157 return -EINVAL;
158 }
159
160
161 /*
162 * Figure out PLL and BCLK dividers for WM8510
163 */
164 switch (params_rate(params)) {
165 case 48000:
166 pll_out = 24576000;
167 mclk_div = WM8510_MCLKDIV_2;
168 bclk = WM8510_BCLKDIV_8;
169 break;
170
171 case 44100:
172 pll_out = 22579200;
173 mclk_div = WM8510_MCLKDIV_2;
174 bclk = WM8510_BCLKDIV_8;
175 break;
176
177 case 22050:
178 pll_out = 22579200;
179 mclk_div = WM8510_MCLKDIV_4;
180 bclk = WM8510_BCLKDIV_8;
181 break;
182
183 case 16000:
184 pll_out = 24576000;
185 mclk_div = WM8510_MCLKDIV_6;
186 bclk = WM8510_BCLKDIV_8;
187 break;
188
189 case 11025:
190 pll_out = 22579200;
191 mclk_div = WM8510_MCLKDIV_8;
192 bclk = WM8510_BCLKDIV_8;
193 break;
194
195 case 8000:
196 pll_out = 24576000;
197 mclk_div = WM8510_MCLKDIV_12;
198 bclk = WM8510_BCLKDIV_8;
199 break;
200
201 default:
202 pr_warning("playpaq_wm8510: Unsupported sample rate %d\n",
203 params_rate(params));
204 return -EINVAL;
205 }
206
207
208 /*
209 * set CPU and CODEC DAI configuration
210 */
211 ret = snd_soc_dai_set_fmt(codec_dai, fmt);
212 if (ret < 0) {
213 pr_warning("playpaq_wm8510: "
214 "Failed to set CODEC DAI format (%d)\n",
215 ret);
216 return ret;
217 }
218 ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
219 if (ret < 0) {
220 pr_warning("playpaq_wm8510: "
221 "Failed to set CPU DAI format (%d)\n",
222 ret);
223 return ret;
224 }
225
226
227 /*
228 * Set CPU clock configuration
229 */
230#if defined CONFIG_SND_AT32_SOC_PLAYPAQ_SLAVE
231 cd = playpaq_wm8510_calc_ssc_clock(params, cpu_dai);
232 pr_debug("playpaq_wm8510: cmr_div = %d, period = %d\n",
233 cd.cmr_div, cd.period);
234 ret = snd_soc_dai_set_clkdiv(cpu_dai, AT32_SSC_CMR_DIV, cd.cmr_div);
235 if (ret < 0) {
236 pr_warning("playpaq_wm8510: Failed to set CPU CMR_DIV (%d)\n",
237 ret);
238 return ret;
239 }
240 ret = snd_soc_dai_set_clkdiv(cpu_dai, AT32_SSC_TCMR_PERIOD,
241 cd.period);
242 if (ret < 0) {
243 pr_warning("playpaq_wm8510: "
244 "Failed to set CPU transmit period (%d)\n",
245 ret);
246 return ret;
247 }
248#endif /* CONFIG_SND_AT32_SOC_PLAYPAQ_SLAVE */
249
250
251 /*
252 * Set CODEC clock configuration
253 */
254 pr_debug("playpaq_wm8510: "
255 "pll_in = %ld, pll_out = %u, bclk = %x, mclk = %x\n",
256 clk_get_rate(CODEC_CLK), pll_out, bclk, mclk_div);
257
258
259#if !defined CONFIG_SND_AT32_SOC_PLAYPAQ_SLAVE
260 ret = snd_soc_dai_set_clkdiv(codec_dai, WM8510_BCLKDIV, bclk);
261 if (ret < 0) {
262 pr_warning
263 ("playpaq_wm8510: Failed to set CODEC DAI BCLKDIV (%d)\n",
264 ret);
265 return ret;
266 }
267#endif /* CONFIG_SND_AT32_SOC_PLAYPAQ_SLAVE */
268
269
270 ret = snd_soc_dai_set_pll(codec_dai, 0, 0,
271 clk_get_rate(CODEC_CLK), pll_out);
272 if (ret < 0) {
273 pr_warning("playpaq_wm8510: Failed to set CODEC DAI PLL (%d)\n",
274 ret);
275 return ret;
276 }
277
278
279 ret = snd_soc_dai_set_clkdiv(codec_dai, WM8510_MCLKDIV, mclk_div);
280 if (ret < 0) {
281 pr_warning("playpaq_wm8510: Failed to set CODEC MCLKDIV (%d)\n",
282 ret);
283 return ret;
284 }
285
286
287 return 0;
288}
289
290
291
292static struct snd_soc_ops playpaq_wm8510_ops = {
293 .hw_params = playpaq_wm8510_hw_params,
294};
295
296
297
298static const struct snd_soc_dapm_widget playpaq_dapm_widgets[] = {
299 SND_SOC_DAPM_MIC("Int Mic", NULL),
300 SND_SOC_DAPM_SPK("Ext Spk", NULL),
301};
302
303
304
305static const struct snd_soc_dapm_route intercon[] = {
306 /* speaker connected to SPKOUT */
307 {"Ext Spk", NULL, "SPKOUTP"},
308 {"Ext Spk", NULL, "SPKOUTN"},
309
310 {"Mic Bias", NULL, "Int Mic"},
311 {"MICN", NULL, "Mic Bias"},
312 {"MICP", NULL, "Mic Bias"},
313};
314
315
316
317static int playpaq_wm8510_init(struct snd_soc_pcm_runtime *rtd)
318{
319 struct snd_soc_codec *codec = rtd->codec;
320 struct snd_soc_dapm_context *dapm = &codec->dapm;
321 int i;
322
323 /*
324 * Add DAPM widgets
325 */
326 for (i = 0; i < ARRAY_SIZE(playpaq_dapm_widgets); i++)
327 snd_soc_dapm_new_control(dapm, &playpaq_dapm_widgets[i]);
328
329
330
331 /*
332 * Setup audio path interconnects
333 */
334 snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
335
336
337
338 /* always connected pins */
339 snd_soc_dapm_enable_pin(dapm, "Int Mic");
340 snd_soc_dapm_enable_pin(dapm, "Ext Spk");
341
342
343
344 /* Make CSB show PLL rate */
345 snd_soc_dai_set_clkdiv(rtd->codec_dai, WM8510_OPCLKDIV,
346 WM8510_OPCLKDIV_1 | 4);
347
348 return 0;
349}
350
351
352
353static struct snd_soc_dai_link playpaq_wm8510_dai = {
354 .name = "WM8510",
355 .stream_name = "WM8510 PCM",
356 .cpu_dai_name= "atmel-ssc-dai.0",
357 .platform_name = "atmel-pcm-audio",
358 .codec_name = "wm8510-codec.0-0x1a",
359 .codec_dai_name = "wm8510-hifi",
360 .init = playpaq_wm8510_init,
361 .ops = &playpaq_wm8510_ops,
362};
363
364
365
366static struct snd_soc_card snd_soc_playpaq = {
367 .name = "LRS_PlayPaq_WM8510",
368 .dai_link = &playpaq_wm8510_dai,
369 .num_links = 1,
370};
371
372static struct platform_device *playpaq_snd_device;
373
374
375static int __init playpaq_asoc_init(void)
376{
377 int ret = 0;
378
379 /*
380 * Configure MCLK for WM8510
381 */
382 _gclk0 = clk_get(NULL, "gclk0");
383 if (IS_ERR(_gclk0)) {
384 _gclk0 = NULL;
385 ret = PTR_ERR(_gclk0);
386 goto err_gclk0;
387 }
388 _pll0 = clk_get(NULL, "pll0");
389 if (IS_ERR(_pll0)) {
390 _pll0 = NULL;
391 ret = PTR_ERR(_pll0);
392 goto err_pll0;
393 }
394 ret = clk_set_parent(_gclk0, _pll0);
395 if (ret) {
396 pr_warning("snd-soc-playpaq: "
397 "Failed to set PLL0 as parent for DAC clock\n");
398 goto err_set_clk;
399 }
400 clk_set_rate(CODEC_CLK, 12000000);
401 clk_enable(CODEC_CLK);
402
403#if defined CONFIG_AT32_ENHANCED_PORTMUX
404 at32_select_periph(MCLK_PIN, MCLK_PERIPH, 0);
405#endif
406
407
408 /*
409 * Create and register platform device
410 */
411 playpaq_snd_device = platform_device_alloc("soc-audio", 0);
412 if (playpaq_snd_device == NULL) {
413 ret = -ENOMEM;
414 goto err_device_alloc;
415 }
416
417 platform_set_drvdata(playpaq_snd_device, &snd_soc_playpaq);
418
419 ret = platform_device_add(playpaq_snd_device);
420 if (ret) {
421 pr_warning("playpaq_wm8510: platform_device_add failed (%d)\n",
422 ret);
423 goto err_device_add;
424 }
425
426 return 0;
427
428
429err_device_add:
430 if (playpaq_snd_device != NULL) {
431 platform_device_put(playpaq_snd_device);
432 playpaq_snd_device = NULL;
433 }
434err_device_alloc:
435err_set_clk:
436 if (_pll0 != NULL) {
437 clk_put(_pll0);
438 _pll0 = NULL;
439 }
440err_pll0:
441 if (_gclk0 != NULL) {
442 clk_put(_gclk0);
443 _gclk0 = NULL;
444 }
445 return ret;
446}
447
448
449static void __exit playpaq_asoc_exit(void)
450{
451 if (_gclk0 != NULL) {
452 clk_put(_gclk0);
453 _gclk0 = NULL;
454 }
455 if (_pll0 != NULL) {
456 clk_put(_pll0);
457 _pll0 = NULL;
458 }
459
460#if defined CONFIG_AT32_ENHANCED_PORTMUX
461 at32_free_pin(MCLK_PIN);
462#endif
463
464 platform_device_unregister(playpaq_snd_device);
465 playpaq_snd_device = NULL;
466}
467
468module_init(playpaq_asoc_init);
469module_exit(playpaq_asoc_exit);
470
471MODULE_AUTHOR("Geoffrey Wossum <gwossum@acm.org>");
472MODULE_DESCRIPTION("ASoC machine driver for LRS PlayPaq");
473MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 4584514d93d4..fa787d45d74a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -33,7 +33,7 @@ config SND_SOC_ALL_CODECS
33 select SND_SOC_CX20442 33 select SND_SOC_CX20442
34 select SND_SOC_DA7210 if I2C 34 select SND_SOC_DA7210 if I2C
35 select SND_SOC_DFBMCS320 35 select SND_SOC_DFBMCS320
36 select SND_SOC_JZ4740_CODEC if SOC_JZ4740 36 select SND_SOC_JZ4740_CODEC
37 select SND_SOC_LM4857 if I2C 37 select SND_SOC_LM4857 if I2C
38 select SND_SOC_MAX98088 if I2C 38 select SND_SOC_MAX98088 if I2C
39 select SND_SOC_MAX98095 if I2C 39 select SND_SOC_MAX98095 if I2C
diff --git a/sound/soc/codecs/ad1836.h b/sound/soc/codecs/ad1836.h
index 444747f0db26..dd7be0dbbc58 100644
--- a/sound/soc/codecs/ad1836.h
+++ b/sound/soc/codecs/ad1836.h
@@ -34,7 +34,7 @@
34 34
35#define AD1836_ADC_CTRL2 13 35#define AD1836_ADC_CTRL2 13
36#define AD1836_ADC_WORD_LEN_MASK 0x30 36#define AD1836_ADC_WORD_LEN_MASK 0x30
37#define AD1836_ADC_WORD_OFFSET 5 37#define AD1836_ADC_WORD_OFFSET 4
38#define AD1836_ADC_SERFMT_MASK (7 << 6) 38#define AD1836_ADC_SERFMT_MASK (7 << 6)
39#define AD1836_ADC_SERFMT_PCK256 (0x4 << 6) 39#define AD1836_ADC_SERFMT_PCK256 (0x4 << 6)
40#define AD1836_ADC_SERFMT_PCK128 (0x5 << 6) 40#define AD1836_ADC_SERFMT_PCK128 (0x5 << 6)
diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c
index 1ccf8dd47576..45c63028b40d 100644
--- a/sound/soc/codecs/adau1373.c
+++ b/sound/soc/codecs/adau1373.c
@@ -245,7 +245,7 @@ static const char *adau1373_bass_hpf_cutoff_text[] = {
245}; 245};
246 246
247static const unsigned int adau1373_bass_tlv[] = { 247static const unsigned int adau1373_bass_tlv[] = {
248 TLV_DB_RANGE_HEAD(4), 248 TLV_DB_RANGE_HEAD(3),
249 0, 2, TLV_DB_SCALE_ITEM(-600, 600, 1), 249 0, 2, TLV_DB_SCALE_ITEM(-600, 600, 1),
250 3, 4, TLV_DB_SCALE_ITEM(950, 250, 0), 250 3, 4, TLV_DB_SCALE_ITEM(950, 250, 0),
251 5, 7, TLV_DB_SCALE_ITEM(1400, 150, 0), 251 5, 7, TLV_DB_SCALE_ITEM(1400, 150, 0),
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index f1f237ecec2a..73f46eb459f1 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -601,7 +601,6 @@ static int cs4270_soc_suspend(struct snd_soc_codec *codec, pm_message_t mesg)
601static int cs4270_soc_resume(struct snd_soc_codec *codec) 601static int cs4270_soc_resume(struct snd_soc_codec *codec)
602{ 602{
603 struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); 603 struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec);
604 struct i2c_client *i2c_client = to_i2c_client(codec->dev);
605 int reg; 604 int reg;
606 605
607 regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies), 606 regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies),
@@ -612,14 +611,7 @@ static int cs4270_soc_resume(struct snd_soc_codec *codec)
612 ndelay(500); 611 ndelay(500);
613 612
614 /* first restore the entire register cache ... */ 613 /* first restore the entire register cache ... */
615 for (reg = CS4270_FIRSTREG; reg <= CS4270_LASTREG; reg++) { 614 snd_soc_cache_sync(codec);
616 u8 val = snd_soc_read(codec, reg);
617
618 if (i2c_smbus_write_byte_data(i2c_client, reg, val)) {
619 dev_err(codec->dev, "i2c write failed\n");
620 return -EIO;
621 }
622 }
623 615
624 /* ... then disable the power-down bits */ 616 /* ... then disable the power-down bits */
625 reg = snd_soc_read(codec, CS4270_PWRCTL); 617 reg = snd_soc_read(codec, CS4270_PWRCTL);
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index 23d1bd5dadda..69fde1506fe1 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -434,7 +434,8 @@ static int cs4271_soc_suspend(struct snd_soc_codec *codec, pm_message_t mesg)
434{ 434{
435 int ret; 435 int ret;
436 /* Set power-down bit */ 436 /* Set power-down bit */
437 ret = snd_soc_update_bits(codec, CS4271_MODE2, 0, CS4271_MODE2_PDN); 437 ret = snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN,
438 CS4271_MODE2_PDN);
438 if (ret < 0) 439 if (ret < 0)
439 return ret; 440 return ret;
440 return 0; 441 return 0;
@@ -501,8 +502,9 @@ static int cs4271_probe(struct snd_soc_codec *codec)
501 return ret; 502 return ret;
502 } 503 }
503 504
504 ret = snd_soc_update_bits(codec, CS4271_MODE2, 0, 505 ret = snd_soc_update_bits(codec, CS4271_MODE2,
505 CS4271_MODE2_PDN | CS4271_MODE2_CPEN); 506 CS4271_MODE2_PDN | CS4271_MODE2_CPEN,
507 CS4271_MODE2_PDN | CS4271_MODE2_CPEN);
506 if (ret < 0) 508 if (ret < 0)
507 return ret; 509 return ret;
508 ret = snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0); 510 ret = snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0);
diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c
index 8c3c8205d19e..1ee66361f61b 100644
--- a/sound/soc/codecs/cs42l51.c
+++ b/sound/soc/codecs/cs42l51.c
@@ -555,7 +555,7 @@ static int cs42l51_probe(struct snd_soc_codec *codec)
555 555
556static struct snd_soc_codec_driver soc_codec_device_cs42l51 = { 556static struct snd_soc_codec_driver soc_codec_device_cs42l51 = {
557 .probe = cs42l51_probe, 557 .probe = cs42l51_probe,
558 .reg_cache_size = CS42L51_NUMREGS, 558 .reg_cache_size = CS42L51_NUMREGS + 1,
559 .reg_word_size = sizeof(u8), 559 .reg_word_size = sizeof(u8),
560}; 560};
561 561
diff --git a/sound/soc/codecs/jz4740.c b/sound/soc/codecs/jz4740.c
index e373f8f06907..3e1f4e172bfb 100644
--- a/sound/soc/codecs/jz4740.c
+++ b/sound/soc/codecs/jz4740.c
@@ -15,6 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/io.h>
18 19
19#include <linux/delay.h> 20#include <linux/delay.h>
20 21
diff --git a/sound/soc/codecs/max9877.c b/sound/soc/codecs/max9877.c
index 9e7e964a5fa3..dcf6f2a1600a 100644
--- a/sound/soc/codecs/max9877.c
+++ b/sound/soc/codecs/max9877.c
@@ -106,13 +106,13 @@ static int max9877_set_2reg(struct snd_kcontrol *kcontrol,
106 unsigned int mask = mc->max; 106 unsigned int mask = mc->max;
107 unsigned int val = (ucontrol->value.integer.value[0] & mask); 107 unsigned int val = (ucontrol->value.integer.value[0] & mask);
108 unsigned int val2 = (ucontrol->value.integer.value[1] & mask); 108 unsigned int val2 = (ucontrol->value.integer.value[1] & mask);
109 unsigned int change = 1; 109 unsigned int change = 0;
110 110
111 if (((max9877_regs[reg] >> shift) & mask) == val) 111 if (((max9877_regs[reg] >> shift) & mask) != val)
112 change = 0; 112 change = 1;
113 113
114 if (((max9877_regs[reg2] >> shift) & mask) == val2) 114 if (((max9877_regs[reg2] >> shift) & mask) != val2)
115 change = 0; 115 change = 1;
116 116
117 if (change) { 117 if (change) {
118 max9877_regs[reg] &= ~(mask << shift); 118 max9877_regs[reg] &= ~(mask << shift);
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c
index 27a078cbb6eb..4646e808b90a 100644
--- a/sound/soc/codecs/rt5631.c
+++ b/sound/soc/codecs/rt5631.c
@@ -177,7 +177,7 @@ static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -95625, 375, 0);
177static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); 177static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
178/* {0, +20, +24, +30, +35, +40, +44, +50, +52}dB */ 178/* {0, +20, +24, +30, +35, +40, +44, +50, +52}dB */
179static unsigned int mic_bst_tlv[] = { 179static unsigned int mic_bst_tlv[] = {
180 TLV_DB_RANGE_HEAD(6), 180 TLV_DB_RANGE_HEAD(7),
181 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 181 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
182 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 182 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
183 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 183 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index d15695d1c273..bbcf921166f7 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -365,7 +365,7 @@ static const DECLARE_TLV_DB_SCALE(capture_6db_attenuate, -600, 600, 0);
365 365
366/* tlv for mic gain, 0db 20db 30db 40db */ 366/* tlv for mic gain, 0db 20db 30db 40db */
367static const unsigned int mic_gain_tlv[] = { 367static const unsigned int mic_gain_tlv[] = {
368 TLV_DB_RANGE_HEAD(4), 368 TLV_DB_RANGE_HEAD(2),
369 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 369 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
370 1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0), 370 1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0),
371}; 371};
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index bb82408ab8e1..d2f37152f940 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -76,6 +76,8 @@ struct sta32x_priv {
76 76
77 unsigned int mclk; 77 unsigned int mclk;
78 unsigned int format; 78 unsigned int format;
79
80 u32 coef_shadow[STA32X_COEF_COUNT];
79}; 81};
80 82
81static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12700, 50, 1); 83static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12700, 50, 1);
@@ -227,6 +229,7 @@ static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol,
227 struct snd_ctl_elem_value *ucontrol) 229 struct snd_ctl_elem_value *ucontrol)
228{ 230{
229 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 231 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
232 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
230 int numcoef = kcontrol->private_value >> 16; 233 int numcoef = kcontrol->private_value >> 16;
231 int index = kcontrol->private_value & 0xffff; 234 int index = kcontrol->private_value & 0xffff;
232 unsigned int cfud; 235 unsigned int cfud;
@@ -239,6 +242,11 @@ static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol,
239 snd_soc_write(codec, STA32X_CFUD, cfud); 242 snd_soc_write(codec, STA32X_CFUD, cfud);
240 243
241 snd_soc_write(codec, STA32X_CFADDR2, index); 244 snd_soc_write(codec, STA32X_CFADDR2, index);
245 for (i = 0; i < numcoef && (index + i < STA32X_COEF_COUNT); i++)
246 sta32x->coef_shadow[index + i] =
247 (ucontrol->value.bytes.data[3 * i] << 16)
248 | (ucontrol->value.bytes.data[3 * i + 1] << 8)
249 | (ucontrol->value.bytes.data[3 * i + 2]);
242 for (i = 0; i < 3 * numcoef; i++) 250 for (i = 0; i < 3 * numcoef; i++)
243 snd_soc_write(codec, STA32X_B1CF1 + i, 251 snd_soc_write(codec, STA32X_B1CF1 + i,
244 ucontrol->value.bytes.data[i]); 252 ucontrol->value.bytes.data[i]);
@@ -252,6 +260,48 @@ static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol,
252 return 0; 260 return 0;
253} 261}
254 262
263int sta32x_sync_coef_shadow(struct snd_soc_codec *codec)
264{
265 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
266 unsigned int cfud;
267 int i;
268
269 /* preserve reserved bits in STA32X_CFUD */
270 cfud = snd_soc_read(codec, STA32X_CFUD) & 0xf0;
271
272 for (i = 0; i < STA32X_COEF_COUNT; i++) {
273 snd_soc_write(codec, STA32X_CFADDR2, i);
274 snd_soc_write(codec, STA32X_B1CF1,
275 (sta32x->coef_shadow[i] >> 16) & 0xff);
276 snd_soc_write(codec, STA32X_B1CF2,
277 (sta32x->coef_shadow[i] >> 8) & 0xff);
278 snd_soc_write(codec, STA32X_B1CF3,
279 (sta32x->coef_shadow[i]) & 0xff);
280 /* chip documentation does not say if the bits are
281 * self-clearing, so do it explicitly */
282 snd_soc_write(codec, STA32X_CFUD, cfud);
283 snd_soc_write(codec, STA32X_CFUD, cfud | 0x01);
284 }
285 return 0;
286}
287
288int sta32x_cache_sync(struct snd_soc_codec *codec)
289{
290 unsigned int mute;
291 int rc;
292
293 if (!codec->cache_sync)
294 return 0;
295
296 /* mute during register sync */
297 mute = snd_soc_read(codec, STA32X_MMUTE);
298 snd_soc_write(codec, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE);
299 sta32x_sync_coef_shadow(codec);
300 rc = snd_soc_cache_sync(codec);
301 snd_soc_write(codec, STA32X_MMUTE, mute);
302 return rc;
303}
304
255#define SINGLE_COEF(xname, index) \ 305#define SINGLE_COEF(xname, index) \
256{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 306{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
257 .info = sta32x_coefficient_info, \ 307 .info = sta32x_coefficient_info, \
@@ -661,7 +711,7 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec,
661 return ret; 711 return ret;
662 } 712 }
663 713
664 snd_soc_cache_sync(codec); 714 sta32x_cache_sync(codec);
665 } 715 }
666 716
667 /* Power up to mute */ 717 /* Power up to mute */
@@ -790,6 +840,17 @@ static int sta32x_probe(struct snd_soc_codec *codec)
790 STA32X_CxCFG_OM_MASK, 840 STA32X_CxCFG_OM_MASK,
791 2 << STA32X_CxCFG_OM_SHIFT); 841 2 << STA32X_CxCFG_OM_SHIFT);
792 842
843 /* initialize coefficient shadow RAM with reset values */
844 for (i = 4; i <= 49; i += 5)
845 sta32x->coef_shadow[i] = 0x400000;
846 for (i = 50; i <= 54; i++)
847 sta32x->coef_shadow[i] = 0x7fffff;
848 sta32x->coef_shadow[55] = 0x5a9df7;
849 sta32x->coef_shadow[56] = 0x7fffff;
850 sta32x->coef_shadow[59] = 0x7fffff;
851 sta32x->coef_shadow[60] = 0x400000;
852 sta32x->coef_shadow[61] = 0x400000;
853
793 sta32x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 854 sta32x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
794 /* Bias level configuration will have done an extra enable */ 855 /* Bias level configuration will have done an extra enable */
795 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); 856 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
diff --git a/sound/soc/codecs/sta32x.h b/sound/soc/codecs/sta32x.h
index b97ee5a75667..d8e32a6262ee 100644
--- a/sound/soc/codecs/sta32x.h
+++ b/sound/soc/codecs/sta32x.h
@@ -19,6 +19,7 @@
19/* STA326 register addresses */ 19/* STA326 register addresses */
20 20
21#define STA32X_REGISTER_COUNT 0x2d 21#define STA32X_REGISTER_COUNT 0x2d
22#define STA32X_COEF_COUNT 62
22 23
23#define STA32X_CONFA 0x00 24#define STA32X_CONFA 0x00
24#define STA32X_CONFB 0x01 25#define STA32X_CONFB 0x01
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index c5ca8cfea60f..0441893e270e 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -863,13 +863,13 @@ static struct i2c_driver uda1380_i2c_driver = {
863 863
864static int __init uda1380_modinit(void) 864static int __init uda1380_modinit(void)
865{ 865{
866 int ret; 866 int ret = 0;
867#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 867#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
868 ret = i2c_add_driver(&uda1380_i2c_driver); 868 ret = i2c_add_driver(&uda1380_i2c_driver);
869 if (ret != 0) 869 if (ret != 0)
870 pr_err("Failed to register UDA1380 I2C driver: %d\n", ret); 870 pr_err("Failed to register UDA1380 I2C driver: %d\n", ret);
871#endif 871#endif
872 return 0; 872 return ret;
873} 873}
874module_init(uda1380_modinit); 874module_init(uda1380_modinit);
875 875
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 7e5ec03f6f8d..a7c9ae17fc7e 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -453,6 +453,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec,
453 snd_soc_write(codec, WM8731_PWR, 0xffff); 453 snd_soc_write(codec, WM8731_PWR, 0xffff);
454 regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), 454 regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies),
455 wm8731->supplies); 455 wm8731->supplies);
456 codec->cache_sync = 1;
456 break; 457 break;
457 } 458 }
458 codec->dapm.bias_level = level; 459 codec->dapm.bias_level = level;
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index a9504710bb69..3a629d0d690e 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -190,6 +190,9 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
190 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); 190 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
191 u16 ioctl; 191 u16 ioctl;
192 192
193 if (wm8753->dai_func == ucontrol->value.integer.value[0])
194 return 0;
195
193 if (codec->active) 196 if (codec->active)
194 return -EBUSY; 197 return -EBUSY;
195 198
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index 0293763debe5..5a14d5c0e0e1 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -60,6 +60,8 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
60 } 60 }
61 61
62 if (memcmp(fw->data, "WMFW", 4) != 0) { 62 if (memcmp(fw->data, "WMFW", 4) != 0) {
63 memcpy(&data32, fw->data, sizeof(data32));
64 data32 = be32_to_cpu(data32);
63 dev_err(codec->dev, "%s: firmware has bad file magic %08x\n", 65 dev_err(codec->dev, "%s: firmware has bad file magic %08x\n",
64 name, data32); 66 name, data32);
65 goto err; 67 goto err;
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 91d3c6dbeba3..53edd9a8c758 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -1973,7 +1973,7 @@ static int wm8962_reset(struct snd_soc_codec *codec)
1973static const DECLARE_TLV_DB_SCALE(inpga_tlv, -2325, 75, 0); 1973static const DECLARE_TLV_DB_SCALE(inpga_tlv, -2325, 75, 0);
1974static const DECLARE_TLV_DB_SCALE(mixin_tlv, -1500, 300, 0); 1974static const DECLARE_TLV_DB_SCALE(mixin_tlv, -1500, 300, 0);
1975static const unsigned int mixinpga_tlv[] = { 1975static const unsigned int mixinpga_tlv[] = {
1976 TLV_DB_RANGE_HEAD(7), 1976 TLV_DB_RANGE_HEAD(5),
1977 0, 1, TLV_DB_SCALE_ITEM(0, 600, 0), 1977 0, 1, TLV_DB_SCALE_ITEM(0, 600, 0),
1978 2, 2, TLV_DB_SCALE_ITEM(1300, 1300, 0), 1978 2, 2, TLV_DB_SCALE_ITEM(1300, 1300, 0),
1979 3, 4, TLV_DB_SCALE_ITEM(1800, 200, 0), 1979 3, 4, TLV_DB_SCALE_ITEM(1800, 200, 0),
@@ -1988,7 +1988,7 @@ static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
1988static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1); 1988static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
1989static const DECLARE_TLV_DB_SCALE(hp_tlv, -700, 100, 0); 1989static const DECLARE_TLV_DB_SCALE(hp_tlv, -700, 100, 0);
1990static const unsigned int classd_tlv[] = { 1990static const unsigned int classd_tlv[] = {
1991 TLV_DB_RANGE_HEAD(7), 1991 TLV_DB_RANGE_HEAD(2),
1992 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), 1992 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
1993 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), 1993 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0),
1994}; 1994};
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index eec8e1435116..d1a142f48b09 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -512,7 +512,7 @@ static const DECLARE_TLV_DB_SCALE(drc_comp_threash, -4500, 75, 0);
512static const DECLARE_TLV_DB_SCALE(drc_comp_amp, -2250, 75, 0); 512static const DECLARE_TLV_DB_SCALE(drc_comp_amp, -2250, 75, 0);
513static const DECLARE_TLV_DB_SCALE(drc_min_tlv, -1800, 600, 0); 513static const DECLARE_TLV_DB_SCALE(drc_min_tlv, -1800, 600, 0);
514static const unsigned int drc_max_tlv[] = { 514static const unsigned int drc_max_tlv[] = {
515 TLV_DB_RANGE_HEAD(4), 515 TLV_DB_RANGE_HEAD(2),
516 0, 2, TLV_DB_SCALE_ITEM(1200, 600, 0), 516 0, 2, TLV_DB_SCALE_ITEM(1200, 600, 0),
517 3, 3, TLV_DB_SCALE_ITEM(3600, 0, 0), 517 3, 3, TLV_DB_SCALE_ITEM(3600, 0, 0),
518}; 518};
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 6b73efd26991..d0c545b73d78 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -56,7 +56,7 @@ static int wm8994_retune_mobile_base[] = {
56static int wm8994_readable(struct snd_soc_codec *codec, unsigned int reg) 56static int wm8994_readable(struct snd_soc_codec *codec, unsigned int reg)
57{ 57{
58 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 58 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
59 struct wm8994 *control = wm8994->control_data; 59 struct wm8994 *control = codec->control_data;
60 60
61 switch (reg) { 61 switch (reg) {
62 case WM8994_GPIO_1: 62 case WM8994_GPIO_1:
@@ -1325,15 +1325,15 @@ SND_SOC_DAPM_DAC("DAC1R", NULL, WM8994_POWER_MANAGEMENT_5, 0, 0),
1325}; 1325};
1326 1326
1327static const struct snd_soc_dapm_widget wm8994_adc_revd_widgets[] = { 1327static const struct snd_soc_dapm_widget wm8994_adc_revd_widgets[] = {
1328SND_SOC_DAPM_MUX_E("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux, 1328SND_SOC_DAPM_VIRT_MUX_E("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux,
1329 adc_mux_ev, SND_SOC_DAPM_PRE_PMU), 1329 adc_mux_ev, SND_SOC_DAPM_PRE_PMU),
1330SND_SOC_DAPM_MUX_E("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux, 1330SND_SOC_DAPM_VIRT_MUX_E("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux,
1331 adc_mux_ev, SND_SOC_DAPM_PRE_PMU), 1331 adc_mux_ev, SND_SOC_DAPM_PRE_PMU),
1332}; 1332};
1333 1333
1334static const struct snd_soc_dapm_widget wm8994_adc_widgets[] = { 1334static const struct snd_soc_dapm_widget wm8994_adc_widgets[] = {
1335SND_SOC_DAPM_MUX("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux), 1335SND_SOC_DAPM_VIRT_MUX("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux),
1336SND_SOC_DAPM_MUX("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux), 1336SND_SOC_DAPM_VIRT_MUX("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux),
1337}; 1337};
1338 1338
1339static const struct snd_soc_dapm_widget wm8994_dapm_widgets[] = { 1339static const struct snd_soc_dapm_widget wm8994_dapm_widgets[] = {
@@ -2357,6 +2357,11 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
2357 bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT; 2357 bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT;
2358 2358
2359 lrclk = bclk_rate / params_rate(params); 2359 lrclk = bclk_rate / params_rate(params);
2360 if (!lrclk) {
2361 dev_err(dai->dev, "Unable to generate LRCLK from %dHz BCLK\n",
2362 bclk_rate);
2363 return -EINVAL;
2364 }
2360 dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", 2365 dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n",
2361 lrclk, bclk_rate / lrclk); 2366 lrclk, bclk_rate / lrclk);
2362 2367
@@ -3030,19 +3035,34 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
3030{ 3035{
3031 struct wm8994_priv *wm8994 = data; 3036 struct wm8994_priv *wm8994 = data;
3032 struct snd_soc_codec *codec = wm8994->codec; 3037 struct snd_soc_codec *codec = wm8994->codec;
3033 int reg; 3038 int reg, count;
3034 3039
3035 reg = snd_soc_read(codec, WM8958_MIC_DETECT_3); 3040 /* We may occasionally read a detection without an impedence
3036 if (reg < 0) { 3041 * range being provided - if that happens loop again.
3037 dev_err(codec->dev, "Failed to read mic detect status: %d\n", 3042 */
3038 reg); 3043 count = 10;
3039 return IRQ_NONE; 3044 do {
3040 } 3045 reg = snd_soc_read(codec, WM8958_MIC_DETECT_3);
3046 if (reg < 0) {
3047 dev_err(codec->dev,
3048 "Failed to read mic detect status: %d\n",
3049 reg);
3050 return IRQ_NONE;
3051 }
3041 3052
3042 if (!(reg & WM8958_MICD_VALID)) { 3053 if (!(reg & WM8958_MICD_VALID)) {
3043 dev_dbg(codec->dev, "Mic detect data not valid\n"); 3054 dev_dbg(codec->dev, "Mic detect data not valid\n");
3044 goto out; 3055 goto out;
3045 } 3056 }
3057
3058 if (!(reg & WM8958_MICD_STS) || (reg & WM8958_MICD_LVL_MASK))
3059 break;
3060
3061 msleep(1);
3062 } while (count--);
3063
3064 if (count == 0)
3065 dev_warn(codec->dev, "No impedence range reported for jack\n");
3046 3066
3047#ifndef CONFIG_SND_SOC_WM8994_MODULE 3067#ifndef CONFIG_SND_SOC_WM8994_MODULE
3048 trace_snd_soc_jack_irq(dev_name(codec->dev)); 3068 trace_snd_soc_jack_irq(dev_name(codec->dev));
@@ -3163,6 +3183,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3163 switch (wm8994->revision) { 3183 switch (wm8994->revision) {
3164 case 0: 3184 case 0:
3165 case 1: 3185 case 1:
3186 case 2:
3187 case 3:
3166 wm8994->hubs.dcs_codes_l = -9; 3188 wm8994->hubs.dcs_codes_l = -9;
3167 wm8994->hubs.dcs_codes_r = -5; 3189 wm8994->hubs.dcs_codes_r = -5;
3168 break; 3190 break;
@@ -3180,9 +3202,9 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3180 3202
3181 wm8994_request_irq(codec->control_data, WM8994_IRQ_FIFOS_ERR, 3203 wm8994_request_irq(codec->control_data, WM8994_IRQ_FIFOS_ERR,
3182 wm8994_fifo_error, "FIFO error", codec); 3204 wm8994_fifo_error, "FIFO error", codec);
3183 wm8994_request_irq(wm8994->control_data, WM8994_IRQ_TEMP_WARN, 3205 wm8994_request_irq(codec->control_data, WM8994_IRQ_TEMP_WARN,
3184 wm8994_temp_warn, "Thermal warning", codec); 3206 wm8994_temp_warn, "Thermal warning", codec);
3185 wm8994_request_irq(wm8994->control_data, WM8994_IRQ_TEMP_SHUT, 3207 wm8994_request_irq(codec->control_data, WM8994_IRQ_TEMP_SHUT,
3186 wm8994_temp_shut, "Thermal shutdown", codec); 3208 wm8994_temp_shut, "Thermal shutdown", codec);
3187 3209
3188 ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_DCS_DONE, 3210 ret = wm8994_request_irq(codec->control_data, WM8994_IRQ_DCS_DONE,
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c
index 645c980d6b80..a33b04d17195 100644
--- a/sound/soc/codecs/wm8996.c
+++ b/sound/soc/codecs/wm8996.c
@@ -1968,6 +1968,7 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai,
1968 break; 1968 break;
1969 case 24576000: 1969 case 24576000:
1970 ratediv = WM8996_SYSCLK_DIV; 1970 ratediv = WM8996_SYSCLK_DIV;
1971 wm8996->sysclk /= 2;
1971 case 12288000: 1972 case 12288000:
1972 snd_soc_update_bits(codec, WM8996_AIF_RATE, 1973 snd_soc_update_bits(codec, WM8996_AIF_RATE,
1973 WM8996_SYSCLK_RATE, WM8996_SYSCLK_RATE); 1974 WM8996_SYSCLK_RATE, WM8996_SYSCLK_RATE);
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c
index 3cd35a02c28c..4a398c3bfe84 100644
--- a/sound/soc/codecs/wm9081.c
+++ b/sound/soc/codecs/wm9081.c
@@ -807,7 +807,6 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec,
807 mdelay(100); 807 mdelay(100);
808 808
809 /* Normal bias enable & soft start off */ 809 /* Normal bias enable & soft start off */
810 reg |= WM9081_BIAS_ENA;
811 reg &= ~WM9081_VMID_RAMP; 810 reg &= ~WM9081_VMID_RAMP;
812 snd_soc_write(codec, WM9081_VMID_CONTROL, reg); 811 snd_soc_write(codec, WM9081_VMID_CONTROL, reg);
813 812
@@ -818,7 +817,7 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec,
818 } 817 }
819 818
820 /* VMID 2*240k */ 819 /* VMID 2*240k */
821 reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1); 820 reg = snd_soc_read(codec, WM9081_VMID_CONTROL);
822 reg &= ~WM9081_VMID_SEL_MASK; 821 reg &= ~WM9081_VMID_SEL_MASK;
823 reg |= 0x04; 822 reg |= 0x04;
824 snd_soc_write(codec, WM9081_VMID_CONTROL, reg); 823 snd_soc_write(codec, WM9081_VMID_CONTROL, reg);
@@ -830,14 +829,15 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec,
830 break; 829 break;
831 830
832 case SND_SOC_BIAS_OFF: 831 case SND_SOC_BIAS_OFF:
833 /* Startup bias source */ 832 /* Startup bias source and disable bias */
834 reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1); 833 reg = snd_soc_read(codec, WM9081_BIAS_CONTROL_1);
835 reg |= WM9081_BIAS_SRC; 834 reg |= WM9081_BIAS_SRC;
835 reg &= ~WM9081_BIAS_ENA;
836 snd_soc_write(codec, WM9081_BIAS_CONTROL_1, reg); 836 snd_soc_write(codec, WM9081_BIAS_CONTROL_1, reg);
837 837
838 /* Disable VMID and biases with soft ramping */ 838 /* Disable VMID with soft ramping */
839 reg = snd_soc_read(codec, WM9081_VMID_CONTROL); 839 reg = snd_soc_read(codec, WM9081_VMID_CONTROL);
840 reg &= ~(WM9081_VMID_SEL_MASK | WM9081_BIAS_ENA); 840 reg &= ~WM9081_VMID_SEL_MASK;
841 reg |= WM9081_VMID_RAMP; 841 reg |= WM9081_VMID_RAMP;
842 snd_soc_write(codec, WM9081_VMID_CONTROL, reg); 842 snd_soc_write(codec, WM9081_VMID_CONTROL, reg);
843 843
diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c
index 2b5252c9e377..f94c06057c64 100644
--- a/sound/soc/codecs/wm9090.c
+++ b/sound/soc/codecs/wm9090.c
@@ -177,19 +177,19 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec)
177} 177}
178 178
179static const unsigned int in_tlv[] = { 179static const unsigned int in_tlv[] = {
180 TLV_DB_RANGE_HEAD(6), 180 TLV_DB_RANGE_HEAD(3),
181 0, 0, TLV_DB_SCALE_ITEM(-600, 0, 0), 181 0, 0, TLV_DB_SCALE_ITEM(-600, 0, 0),
182 1, 3, TLV_DB_SCALE_ITEM(-350, 350, 0), 182 1, 3, TLV_DB_SCALE_ITEM(-350, 350, 0),
183 4, 6, TLV_DB_SCALE_ITEM(600, 600, 0), 183 4, 6, TLV_DB_SCALE_ITEM(600, 600, 0),
184}; 184};
185static const unsigned int mix_tlv[] = { 185static const unsigned int mix_tlv[] = {
186 TLV_DB_RANGE_HEAD(4), 186 TLV_DB_RANGE_HEAD(2),
187 0, 2, TLV_DB_SCALE_ITEM(-1200, 300, 0), 187 0, 2, TLV_DB_SCALE_ITEM(-1200, 300, 0),
188 3, 3, TLV_DB_SCALE_ITEM(0, 0, 0), 188 3, 3, TLV_DB_SCALE_ITEM(0, 0, 0),
189}; 189};
190static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0); 190static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0);
191static const unsigned int spkboost_tlv[] = { 191static const unsigned int spkboost_tlv[] = {
192 TLV_DB_RANGE_HEAD(7), 192 TLV_DB_RANGE_HEAD(2),
193 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), 193 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
194 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), 194 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0),
195}; 195};
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 84f33d4ea2cd..48e61e912400 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -40,7 +40,7 @@ static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0);
40static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1); 40static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1);
41static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0); 41static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0);
42static const unsigned int spkboost_tlv[] = { 42static const unsigned int spkboost_tlv[] = {
43 TLV_DB_RANGE_HEAD(7), 43 TLV_DB_RANGE_HEAD(2),
44 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), 44 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
45 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), 45 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0),
46}; 46};
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 0268cf989736..83c4bd5b2dd7 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -694,6 +694,7 @@ static int __devinit fsl_ssi_probe(struct platform_device *pdev)
694 694
695 /* Initialize the the device_attribute structure */ 695 /* Initialize the the device_attribute structure */
696 dev_attr = &ssi_private->dev_attr; 696 dev_attr = &ssi_private->dev_attr;
697 sysfs_attr_init(&dev_attr->attr);
697 dev_attr->attr.name = "statistics"; 698 dev_attr->attr.name = "statistics";
698 dev_attr->attr.mode = S_IRUGO; 699 dev_attr->attr.mode = S_IRUGO;
699 dev_attr->show = fsl_sysfs_ssi_show; 700 dev_attr->show = fsl_sysfs_ssi_show;
diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c
index 31af405bda84..ae49f1c78c6d 100644
--- a/sound/soc/fsl/mpc8610_hpcd.c
+++ b/sound/soc/fsl/mpc8610_hpcd.c
@@ -392,7 +392,8 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
392 } 392 }
393 393
394 if (strcasecmp(sprop, "i2s-slave") == 0) { 394 if (strcasecmp(sprop, "i2s-slave") == 0) {
395 machine_data->dai_format = SND_SOC_DAIFMT_I2S; 395 machine_data->dai_format =
396 SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM;
396 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; 397 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
397 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; 398 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
398 399
@@ -409,31 +410,38 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
409 } 410 }
410 machine_data->clk_frequency = be32_to_cpup(iprop); 411 machine_data->clk_frequency = be32_to_cpup(iprop);
411 } else if (strcasecmp(sprop, "i2s-master") == 0) { 412 } else if (strcasecmp(sprop, "i2s-master") == 0) {
412 machine_data->dai_format = SND_SOC_DAIFMT_I2S; 413 machine_data->dai_format =
414 SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS;
413 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; 415 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
414 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; 416 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
415 } else if (strcasecmp(sprop, "lj-slave") == 0) { 417 } else if (strcasecmp(sprop, "lj-slave") == 0) {
416 machine_data->dai_format = SND_SOC_DAIFMT_LEFT_J; 418 machine_data->dai_format =
419 SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM;
417 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; 420 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
418 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; 421 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
419 } else if (strcasecmp(sprop, "lj-master") == 0) { 422 } else if (strcasecmp(sprop, "lj-master") == 0) {
420 machine_data->dai_format = SND_SOC_DAIFMT_LEFT_J; 423 machine_data->dai_format =
424 SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBS_CFS;
421 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; 425 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
422 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; 426 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
423 } else if (strcasecmp(sprop, "rj-slave") == 0) { 427 } else if (strcasecmp(sprop, "rj-slave") == 0) {
424 machine_data->dai_format = SND_SOC_DAIFMT_RIGHT_J; 428 machine_data->dai_format =
429 SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBM_CFM;
425 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; 430 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
426 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; 431 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
427 } else if (strcasecmp(sprop, "rj-master") == 0) { 432 } else if (strcasecmp(sprop, "rj-master") == 0) {
428 machine_data->dai_format = SND_SOC_DAIFMT_RIGHT_J; 433 machine_data->dai_format =
434 SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBS_CFS;
429 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; 435 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
430 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; 436 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
431 } else if (strcasecmp(sprop, "ac97-slave") == 0) { 437 } else if (strcasecmp(sprop, "ac97-slave") == 0) {
432 machine_data->dai_format = SND_SOC_DAIFMT_AC97; 438 machine_data->dai_format =
439 SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBM_CFM;
433 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; 440 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
434 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; 441 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
435 } else if (strcasecmp(sprop, "ac97-master") == 0) { 442 } else if (strcasecmp(sprop, "ac97-master") == 0) {
436 machine_data->dai_format = SND_SOC_DAIFMT_AC97; 443 machine_data->dai_format =
444 SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBS_CFS;
437 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; 445 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
438 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; 446 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
439 } else { 447 } else {
diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig
index b133bfcc5848..738391757f2c 100644
--- a/sound/soc/imx/Kconfig
+++ b/sound/soc/imx/Kconfig
@@ -28,7 +28,7 @@ config SND_MXC_SOC_WM1133_EV1
28 28
29config SND_SOC_MX27VIS_AIC32X4 29config SND_SOC_MX27VIS_AIC32X4
30 tristate "SoC audio support for Visstrim M10 boards" 30 tristate "SoC audio support for Visstrim M10 boards"
31 depends on MACH_IMX27_VISSTRIM_M10 31 depends on MACH_IMX27_VISSTRIM_M10 && I2C
32 select SND_SOC_TLV320AIC32X4 32 select SND_SOC_TLV320AIC32X4
33 select SND_MXC_SOC_MX2 33 select SND_MXC_SOC_MX2
34 help 34 help
diff --git a/sound/soc/kirkwood/Kconfig b/sound/soc/kirkwood/Kconfig
index 8f49e165f4d1..c62d715235e2 100644
--- a/sound/soc/kirkwood/Kconfig
+++ b/sound/soc/kirkwood/Kconfig
@@ -12,6 +12,7 @@ config SND_KIRKWOOD_SOC_I2S
12config SND_KIRKWOOD_SOC_OPENRD 12config SND_KIRKWOOD_SOC_OPENRD
13 tristate "SoC Audio support for Kirkwood Openrd Client" 13 tristate "SoC Audio support for Kirkwood Openrd Client"
14 depends on SND_KIRKWOOD_SOC && (MACH_OPENRD_CLIENT || MACH_OPENRD_ULTIMATE) 14 depends on SND_KIRKWOOD_SOC && (MACH_OPENRD_CLIENT || MACH_OPENRD_ULTIMATE)
15 depends on I2C
15 select SND_KIRKWOOD_SOC_I2S 16 select SND_KIRKWOOD_SOC_I2S
16 select SND_SOC_CS42L51 17 select SND_SOC_CS42L51
17 help 18 help
@@ -20,7 +21,7 @@ config SND_KIRKWOOD_SOC_OPENRD
20 21
21config SND_KIRKWOOD_SOC_T5325 22config SND_KIRKWOOD_SOC_T5325
22 tristate "SoC Audio support for HP t5325" 23 tristate "SoC Audio support for HP t5325"
23 depends on SND_KIRKWOOD_SOC && MACH_T5325 24 depends on SND_KIRKWOOD_SOC && MACH_T5325 && I2C
24 select SND_KIRKWOOD_SOC_I2S 25 select SND_KIRKWOOD_SOC_I2S
25 select SND_SOC_ALC5623 26 select SND_SOC_ALC5623
26 help 27 help
diff --git a/sound/soc/mxs/mxs-pcm.c b/sound/soc/mxs/mxs-pcm.c
index dea5aa4aa647..f39d7dd9fbcb 100644
--- a/sound/soc/mxs/mxs-pcm.c
+++ b/sound/soc/mxs/mxs-pcm.c
@@ -357,3 +357,6 @@ static void __exit snd_mxs_pcm_exit(void)
357 platform_driver_unregister(&mxs_pcm_driver); 357 platform_driver_unregister(&mxs_pcm_driver);
358} 358}
359module_exit(snd_mxs_pcm_exit); 359module_exit(snd_mxs_pcm_exit);
360
361MODULE_LICENSE("GPL");
362MODULE_ALIAS("platform:mxs-pcm-audio");
diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c
index 7fbeaec06eb4..1c57f6630a48 100644
--- a/sound/soc/mxs/mxs-sgtl5000.c
+++ b/sound/soc/mxs/mxs-sgtl5000.c
@@ -171,3 +171,4 @@ module_exit(mxs_sgtl5000_exit);
171MODULE_AUTHOR("Freescale Semiconductor, Inc."); 171MODULE_AUTHOR("Freescale Semiconductor, Inc.");
172MODULE_DESCRIPTION("MXS ALSA SoC Machine driver"); 172MODULE_DESCRIPTION("MXS ALSA SoC Machine driver");
173MODULE_LICENSE("GPL"); 173MODULE_LICENSE("GPL");
174MODULE_ALIAS("platform:mxs-sgtl5000");
diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c
index 9c0edad90d8b..a4e3237956e2 100644
--- a/sound/soc/nuc900/nuc900-ac97.c
+++ b/sound/soc/nuc900/nuc900-ac97.c
@@ -365,7 +365,8 @@ static int __devinit nuc900_ac97_drvprobe(struct platform_device *pdev)
365 if (ret) 365 if (ret)
366 goto out3; 366 goto out3;
367 367
368 mfp_set_groupg(nuc900_audio->dev); /* enbale ac97 multifunction pin*/ 368 /* enbale ac97 multifunction pin */
369 mfp_set_groupg(nuc900_audio->dev, "nuc900-audio");
369 370
370 return 0; 371 return 0;
371 372
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index ffd2242e305f..a0f7d3cfa470 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -151,6 +151,7 @@ config SND_SOC_ZYLONITE
151config SND_SOC_RAUMFELD 151config SND_SOC_RAUMFELD
152 tristate "SoC Audio support Raumfeld audio adapter" 152 tristate "SoC Audio support Raumfeld audio adapter"
153 depends on SND_PXA2XX_SOC && (MACH_RAUMFELD_SPEAKER || MACH_RAUMFELD_CONNECTOR) 153 depends on SND_PXA2XX_SOC && (MACH_RAUMFELD_SPEAKER || MACH_RAUMFELD_CONNECTOR)
154 depends on I2C && SPI_MASTER
154 select SND_PXA_SOC_SSP 155 select SND_PXA_SOC_SSP
155 select SND_SOC_CS4270 156 select SND_SOC_CS4270
156 select SND_SOC_AK4104 157 select SND_SOC_AK4104
@@ -159,7 +160,7 @@ config SND_SOC_RAUMFELD
159 160
160config SND_PXA2XX_SOC_HX4700 161config SND_PXA2XX_SOC_HX4700
161 tristate "SoC Audio support for HP iPAQ hx4700" 162 tristate "SoC Audio support for HP iPAQ hx4700"
162 depends on SND_PXA2XX_SOC && MACH_H4700 163 depends on SND_PXA2XX_SOC && MACH_H4700 && I2C
163 select SND_PXA2XX_SOC_I2S 164 select SND_PXA2XX_SOC_I2S
164 select SND_SOC_AK4641 165 select SND_SOC_AK4641
165 help 166 help
diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c
index 65c124831a00..c664e33fb6d7 100644
--- a/sound/soc/pxa/hx4700.c
+++ b/sound/soc/pxa/hx4700.c
@@ -209,9 +209,10 @@ static int __devinit hx4700_audio_probe(struct platform_device *pdev)
209 snd_soc_card_hx4700.dev = &pdev->dev; 209 snd_soc_card_hx4700.dev = &pdev->dev;
210 ret = snd_soc_register_card(&snd_soc_card_hx4700); 210 ret = snd_soc_register_card(&snd_soc_card_hx4700);
211 if (ret) 211 if (ret)
212 return ret; 212 gpio_free_array(hx4700_audio_gpios,
213 ARRAY_SIZE(hx4700_audio_gpios));
213 214
214 return 0; 215 return ret;
215} 216}
216 217
217static int __devexit hx4700_audio_remove(struct platform_device *pdev) 218static int __devexit hx4700_audio_remove(struct platform_device *pdev)
diff --git a/sound/soc/samsung/jive_wm8750.c b/sound/soc/samsung/jive_wm8750.c
index 1826acf20f7c..8e523fd9189e 100644
--- a/sound/soc/samsung/jive_wm8750.c
+++ b/sound/soc/samsung/jive_wm8750.c
@@ -101,7 +101,6 @@ static int jive_wm8750_init(struct snd_soc_pcm_runtime *rtd)
101{ 101{
102 struct snd_soc_codec *codec = rtd->codec; 102 struct snd_soc_codec *codec = rtd->codec;
103 struct snd_soc_dapm_context *dapm = &codec->dapm; 103 struct snd_soc_dapm_context *dapm = &codec->dapm;
104 int err;
105 104
106 /* These endpoints are not being used. */ 105 /* These endpoints are not being used. */
107 snd_soc_dapm_nc_pin(dapm, "LINPUT2"); 106 snd_soc_dapm_nc_pin(dapm, "LINPUT2");
@@ -131,7 +130,7 @@ static struct snd_soc_card snd_soc_machine_jive = {
131 .dai_link = &jive_dai, 130 .dai_link = &jive_dai,
132 .num_links = 1, 131 .num_links = 1,
133 132
134 .dapm_widgtets = wm8750_dapm_widgets, 133 .dapm_widgets = wm8750_dapm_widgets,
135 .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), 134 .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets),
136 .dapm_routes = audio_map, 135 .dapm_routes = audio_map,
137 .num_dapm_routes = ARRAY_SIZE(audio_map), 136 .num_dapm_routes = ARRAY_SIZE(audio_map),
diff --git a/sound/soc/samsung/smdk2443_wm9710.c b/sound/soc/samsung/smdk2443_wm9710.c
index 3a0dbfc793f0..8bd1dc5706bf 100644
--- a/sound/soc/samsung/smdk2443_wm9710.c
+++ b/sound/soc/samsung/smdk2443_wm9710.c
@@ -12,6 +12,7 @@
12 * 12 *
13 */ 13 */
14 14
15#include <linux/module.h>
15#include <sound/soc.h> 16#include <sound/soc.h>
16 17
17static struct snd_soc_card smdk2443; 18static struct snd_soc_card smdk2443;
diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c
index f75e43997d5b..ad9ac42522e2 100644
--- a/sound/soc/samsung/smdk_wm8994.c
+++ b/sound/soc/samsung/smdk_wm8994.c
@@ -9,6 +9,7 @@
9 9
10#include "../codecs/wm8994.h" 10#include "../codecs/wm8994.h"
11#include <sound/pcm_params.h> 11#include <sound/pcm_params.h>
12#include <linux/module.h>
12 13
13 /* 14 /*
14 * Default CFG switch settings to use this driver: 15 * Default CFG switch settings to use this driver:
diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c
index 85bf541a771d..4b8e35410eb1 100644
--- a/sound/soc/samsung/speyside.c
+++ b/sound/soc/samsung/speyside.c
@@ -191,7 +191,7 @@ static int speyside_late_probe(struct snd_soc_card *card)
191 snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Mic"); 191 snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Mic");
192 snd_soc_dapm_ignore_suspend(&card->dapm, "Main AMIC"); 192 snd_soc_dapm_ignore_suspend(&card->dapm, "Main AMIC");
193 snd_soc_dapm_ignore_suspend(&card->dapm, "Main DMIC"); 193 snd_soc_dapm_ignore_suspend(&card->dapm, "Main DMIC");
194 snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker"); 194 snd_soc_dapm_ignore_suspend(&card->dapm, "Main Speaker");
195 snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Output"); 195 snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Output");
196 snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Input"); 196 snd_soc_dapm_ignore_suspend(&card->dapm, "WM1250 Input");
197 197
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a5d3685a5d38..a25fa63ce9a2 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -709,6 +709,12 @@ int snd_soc_resume(struct device *dev)
709 struct snd_soc_card *card = dev_get_drvdata(dev); 709 struct snd_soc_card *card = dev_get_drvdata(dev);
710 int i, ac97_control = 0; 710 int i, ac97_control = 0;
711 711
712 /* If the initialization of this soc device failed, there is no codec
713 * associated with it. Just bail out in this case.
714 */
715 if (list_empty(&card->codec_dev_list))
716 return 0;
717
712 /* AC97 devices might have other drivers hanging off them so 718 /* AC97 devices might have other drivers hanging off them so
713 * need to resume immediately. Other drivers don't have that 719 * need to resume immediately. Other drivers don't have that
714 * problem and may take a substantial amount of time to resume 720 * problem and may take a substantial amount of time to resume
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c
index 0c12b98484bd..4220bb0f2730 100644
--- a/sound/soc/soc-utils.c
+++ b/sound/soc/soc-utils.c
@@ -58,7 +58,36 @@ int snd_soc_params_to_bclk(struct snd_pcm_hw_params *params)
58} 58}
59EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk); 59EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk);
60 60
61static struct snd_soc_platform_driver dummy_platform; 61static const struct snd_pcm_hardware dummy_dma_hardware = {
62 .formats = 0xffffffff,
63 .channels_min = 1,
64 .channels_max = UINT_MAX,
65
66 /* Random values to keep userspace happy when checking constraints */
67 .info = SNDRV_PCM_INFO_INTERLEAVED |
68 SNDRV_PCM_INFO_BLOCK_TRANSFER,
69 .buffer_bytes_max = 128*1024,
70 .period_bytes_min = PAGE_SIZE,
71 .period_bytes_max = PAGE_SIZE*2,
72 .periods_min = 2,
73 .periods_max = 128,
74};
75
76static int dummy_dma_open(struct snd_pcm_substream *substream)
77{
78 snd_soc_set_runtime_hwparams(substream, &dummy_dma_hardware);
79
80 return 0;
81}
82
83static struct snd_pcm_ops dummy_dma_ops = {
84 .open = dummy_dma_open,
85 .ioctl = snd_pcm_lib_ioctl,
86};
87
88static struct snd_soc_platform_driver dummy_platform = {
89 .ops = &dummy_dma_ops,
90};
62 91
63static __devinit int snd_soc_dummy_probe(struct platform_device *pdev) 92static __devinit int snd_soc_dummy_probe(struct platform_device *pdev)
64{ 93{
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 60f65ace7474..ab23869c01bb 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -765,10 +765,61 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
765 * interface to ALSA control for feature/mixer units 765 * interface to ALSA control for feature/mixer units
766 */ 766 */
767 767
768/* volume control quirks */
769static void volume_control_quirks(struct usb_mixer_elem_info *cval,
770 struct snd_kcontrol *kctl)
771{
772 switch (cval->mixer->chip->usb_id) {
773 case USB_ID(0x0471, 0x0101):
774 case USB_ID(0x0471, 0x0104):
775 case USB_ID(0x0471, 0x0105):
776 case USB_ID(0x0672, 0x1041):
777 /* quirk for UDA1321/N101.
778 * note that detection between firmware 2.1.1.7 (N101)
779 * and later 2.1.1.21 is not very clear from datasheets.
780 * I hope that the min value is -15360 for newer firmware --jk
781 */
782 if (!strcmp(kctl->id.name, "PCM Playback Volume") &&
783 cval->min == -15616) {
784 snd_printk(KERN_INFO
785 "set volume quirk for UDA1321/N101 chip\n");
786 cval->max = -256;
787 }
788 break;
789
790 case USB_ID(0x046d, 0x09a4):
791 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
792 snd_printk(KERN_INFO
793 "set volume quirk for QuickCam E3500\n");
794 cval->min = 6080;
795 cval->max = 8768;
796 cval->res = 192;
797 }
798 break;
799
800 case USB_ID(0x046d, 0x0808):
801 case USB_ID(0x046d, 0x0809):
802 case USB_ID(0x046d, 0x081d): /* HD Webcam c510 */
803 case USB_ID(0x046d, 0x0991):
804 /* Most audio usb devices lie about volume resolution.
805 * Most Logitech webcams have res = 384.
806 * Proboly there is some logitech magic behind this number --fishor
807 */
808 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
809 snd_printk(KERN_INFO
810 "set resolution quirk: cval->res = 384\n");
811 cval->res = 384;
812 }
813 break;
814
815 }
816}
817
768/* 818/*
769 * retrieve the minimum and maximum values for the specified control 819 * retrieve the minimum and maximum values for the specified control
770 */ 820 */
771static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) 821static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
822 int default_min, struct snd_kcontrol *kctl)
772{ 823{
773 /* for failsafe */ 824 /* for failsafe */
774 cval->min = default_min; 825 cval->min = default_min;
@@ -844,6 +895,9 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
844 cval->initialized = 1; 895 cval->initialized = 1;
845 } 896 }
846 897
898 if (kctl)
899 volume_control_quirks(cval, kctl);
900
847 /* USB descriptions contain the dB scale in 1/256 dB unit 901 /* USB descriptions contain the dB scale in 1/256 dB unit
848 * while ALSA TLV contains in 1/100 dB unit 902 * while ALSA TLV contains in 1/100 dB unit
849 */ 903 */
@@ -864,6 +918,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
864 return 0; 918 return 0;
865} 919}
866 920
921#define get_min_max(cval, def) get_min_max_with_quirks(cval, def, NULL)
867 922
868/* get a feature/mixer unit info */ 923/* get a feature/mixer unit info */
869static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 924static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
@@ -882,7 +937,7 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
882 uinfo->value.integer.max = 1; 937 uinfo->value.integer.max = 1;
883 } else { 938 } else {
884 if (!cval->initialized) { 939 if (!cval->initialized) {
885 get_min_max(cval, 0); 940 get_min_max_with_quirks(cval, 0, kcontrol);
886 if (cval->initialized && cval->dBmin >= cval->dBmax) { 941 if (cval->initialized && cval->dBmin >= cval->dBmax) {
887 kcontrol->vd[0].access &= 942 kcontrol->vd[0].access &=
888 ~(SNDRV_CTL_ELEM_ACCESS_TLV_READ | 943 ~(SNDRV_CTL_ELEM_ACCESS_TLV_READ |
@@ -1045,9 +1100,6 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1045 cval->ch_readonly = readonly_mask; 1100 cval->ch_readonly = readonly_mask;
1046 } 1101 }
1047 1102
1048 /* get min/max values */
1049 get_min_max(cval, 0);
1050
1051 /* if all channels in the mask are marked read-only, make the control 1103 /* if all channels in the mask are marked read-only, make the control
1052 * read-only. set_cur_mix_value() will check the mask again and won't 1104 * read-only. set_cur_mix_value() will check the mask again and won't
1053 * issue write commands to read-only channels. */ 1105 * issue write commands to read-only channels. */
@@ -1069,6 +1121,9 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1069 len = snd_usb_copy_string_desc(state, nameid, 1121 len = snd_usb_copy_string_desc(state, nameid,
1070 kctl->id.name, sizeof(kctl->id.name)); 1122 kctl->id.name, sizeof(kctl->id.name));
1071 1123
1124 /* get min/max values */
1125 get_min_max_with_quirks(cval, 0, kctl);
1126
1072 switch (control) { 1127 switch (control) {
1073 case UAC_FU_MUTE: 1128 case UAC_FU_MUTE:
1074 case UAC_FU_VOLUME: 1129 case UAC_FU_VOLUME:
@@ -1118,51 +1173,6 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1118 break; 1173 break;
1119 } 1174 }
1120 1175
1121 /* volume control quirks */
1122 switch (state->chip->usb_id) {
1123 case USB_ID(0x0471, 0x0101):
1124 case USB_ID(0x0471, 0x0104):
1125 case USB_ID(0x0471, 0x0105):
1126 case USB_ID(0x0672, 0x1041):
1127 /* quirk for UDA1321/N101.
1128 * note that detection between firmware 2.1.1.7 (N101)
1129 * and later 2.1.1.21 is not very clear from datasheets.
1130 * I hope that the min value is -15360 for newer firmware --jk
1131 */
1132 if (!strcmp(kctl->id.name, "PCM Playback Volume") &&
1133 cval->min == -15616) {
1134 snd_printk(KERN_INFO
1135 "set volume quirk for UDA1321/N101 chip\n");
1136 cval->max = -256;
1137 }
1138 break;
1139
1140 case USB_ID(0x046d, 0x09a4):
1141 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
1142 snd_printk(KERN_INFO
1143 "set volume quirk for QuickCam E3500\n");
1144 cval->min = 6080;
1145 cval->max = 8768;
1146 cval->res = 192;
1147 }
1148 break;
1149
1150 case USB_ID(0x046d, 0x0808):
1151 case USB_ID(0x046d, 0x0809):
1152 case USB_ID(0x046d, 0x0991):
1153 /* Most audio usb devices lie about volume resolution.
1154 * Most Logitech webcams have res = 384.
1155 * Proboly there is some logitech magic behind this number --fishor
1156 */
1157 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
1158 snd_printk(KERN_INFO
1159 "set resolution quirk: cval->res = 384\n");
1160 cval->res = 384;
1161 }
1162 break;
1163
1164 }
1165
1166 range = (cval->max - cval->min) / cval->res; 1176 range = (cval->max - cval->min) / cval->res;
1167 /* Are there devices with volume range more than 255? I use a bit more 1177 /* Are there devices with volume range more than 255? I use a bit more
1168 * to be sure. 384 is a resolution magic number found on Logitech 1178 * to be sure. 384 is a resolution magic number found on Logitech
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index b61945f3af9e..32d2a21f2e3b 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -1633,6 +1633,37 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1633 } 1633 }
1634}, 1634},
1635{ 1635{
1636 /* Roland GAIA SH-01 */
1637 USB_DEVICE(0x0582, 0x0111),
1638 .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
1639 .vendor_name = "Roland",
1640 .product_name = "GAIA",
1641 .ifnum = QUIRK_ANY_INTERFACE,
1642 .type = QUIRK_COMPOSITE,
1643 .data = (const struct snd_usb_audio_quirk[]) {
1644 {
1645 .ifnum = 0,
1646 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1647 },
1648 {
1649 .ifnum = 1,
1650 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1651 },
1652 {
1653 .ifnum = 2,
1654 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1655 .data = &(const struct snd_usb_midi_endpoint_info) {
1656 .out_cables = 0x0003,
1657 .in_cables = 0x0003
1658 }
1659 },
1660 {
1661 .ifnum = -1
1662 }
1663 }
1664 }
1665},
1666{
1636 USB_DEVICE(0x0582, 0x0113), 1667 USB_DEVICE(0x0582, 0x0113),
1637 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 1668 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1638 /* .vendor_name = "BOSS", */ 1669 /* .vendor_name = "BOSS", */
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 2e5bc7344026..a3ddac0deffd 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -137,12 +137,12 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
137 return -ENOMEM; 137 return -ENOMEM;
138 } 138 }
139 if (fp->nr_rates > 0) { 139 if (fp->nr_rates > 0) {
140 rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL); 140 rate_table = kmemdup(fp->rate_table,
141 sizeof(int) * fp->nr_rates, GFP_KERNEL);
141 if (!rate_table) { 142 if (!rate_table) {
142 kfree(fp); 143 kfree(fp);
143 return -ENOMEM; 144 return -ENOMEM;
144 } 145 }
145 memcpy(rate_table, fp->rate_table, sizeof(int) * fp->nr_rates);
146 fp->rate_table = rate_table; 146 fp->rate_table = rate_table;
147 } 147 }
148 148
@@ -224,10 +224,9 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
224 if (altsd->bNumEndpoints != 1) 224 if (altsd->bNumEndpoints != 1)
225 return -ENXIO; 225 return -ENXIO;
226 226
227 fp = kmalloc(sizeof(*fp), GFP_KERNEL); 227 fp = kmemdup(&ua_format, sizeof(*fp), GFP_KERNEL);
228 if (!fp) 228 if (!fp)
229 return -ENOMEM; 229 return -ENOMEM;
230 memcpy(fp, &ua_format, sizeof(*fp));
231 230
232 fp->iface = altsd->bInterfaceNumber; 231 fp->iface = altsd->bInterfaceNumber;
233 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 232 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;