aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2008-05-06 10:57:55 -0400
committerJiri Kosina <jkosina@suse.cz>2008-05-06 10:57:55 -0400
commit7022b15e2a9f878fd5184586064c63352c3dd225 (patch)
tree5365c2f5bc82ae1946636ee8d5cd5d3b7e804f1b /sound/pci
parentaaad2b0c757f3e6e02552cb0bdcd91a5ec0d6305 (diff)
parenta15306365a16380f3bafee9e181ba01231d4acd7 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/Kconfig27
-rw-r--r--sound/pci/Makefile1
-rw-r--r--sound/pci/ac97/ac97_patch.c55
-rw-r--r--sound/pci/ac97/ac97_pcm.c1
-rw-r--r--sound/pci/ad1889.c6
-rw-r--r--sound/pci/ali5451/ali5451.c32
-rw-r--r--sound/pci/als300.c4
-rw-r--r--sound/pci/atiixp.c2
-rw-r--r--sound/pci/atiixp_modem.c2
-rw-r--r--sound/pci/au88x0/au88x0.c2
-rw-r--r--sound/pci/au88x0/au88x0_pcm.c10
-rw-r--r--sound/pci/aw2/Makefile3
-rw-r--r--sound/pci/aw2/aw2-alsa.c794
-rw-r--r--sound/pci/aw2/aw2-saa7146.c465
-rw-r--r--sound/pci/aw2/aw2-saa7146.h105
-rw-r--r--sound/pci/aw2/aw2-tsl.c110
-rw-r--r--sound/pci/aw2/saa7146.h168
-rw-r--r--sound/pci/azt3328.c7
-rw-r--r--sound/pci/ca0106/ca0106_main.c21
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c59
-rw-r--r--sound/pci/cmipci.c13
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c6
-rw-r--r--sound/pci/echoaudio/echoaudio.c7
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c15
-rw-r--r--sound/pci/emu10k1/emu10k1x.c30
-rw-r--r--sound/pci/emu10k1/emuproc.c2
-rw-r--r--sound/pci/ens1370.c9
-rw-r--r--sound/pci/es1938.c5
-rw-r--r--sound/pci/es1968.c42
-rw-r--r--sound/pci/fm801.c8
-rw-r--r--sound/pci/hda/Makefile2
-rw-r--r--sound/pci/hda/hda_codec.c201
-rw-r--r--sound/pci/hda/hda_codec.h13
-rw-r--r--sound/pci/hda/hda_generic.c4
-rw-r--r--sound/pci/hda/hda_intel.c459
-rw-r--r--sound/pci/hda/hda_local.h20
-rw-r--r--sound/pci/hda/hda_patch.h28
-rw-r--r--sound/pci/hda/patch_analog.c581
-rw-r--r--sound/pci/hda/patch_atihdmi.c8
-rw-r--r--sound/pci/hda/patch_cmedia.c13
-rw-r--r--sound/pci/hda/patch_conexant.c68
-rw-r--r--sound/pci/hda/patch_realtek.c1329
-rw-r--r--sound/pci/hda/patch_si3054.c4
-rw-r--r--sound/pci/hda/patch_sigmatel.c393
-rw-r--r--sound/pci/hda/patch_via.c14
-rw-r--r--sound/pci/hda/vmaster.c364
-rw-r--r--sound/pci/ice1712/delta.c22
-rw-r--r--sound/pci/ice1712/delta.h2
-rw-r--r--sound/pci/ice1712/ews.c15
-rw-r--r--sound/pci/ice1712/ews.h4
-rw-r--r--sound/pci/ice1712/hoontech.c21
-rw-r--r--sound/pci/ice1712/ice1712.c45
-rw-r--r--sound/pci/ice1712/ice1712.h17
-rw-r--r--sound/pci/ice1712/ice1724.c430
-rw-r--r--sound/pci/ice1712/juli.c486
-rw-r--r--sound/pci/ice1712/pontis.c4
-rw-r--r--sound/pci/ice1712/prodigy192.c37
-rw-r--r--sound/pci/ice1712/revo.c55
-rw-r--r--sound/pci/intel8x0.c33
-rw-r--r--sound/pci/intel8x0m.c9
-rw-r--r--sound/pci/korg1212/korg1212.c1
-rw-r--r--sound/pci/maestro3.c38
-rw-r--r--sound/pci/nm256/nm256.c4
-rw-r--r--sound/pci/oxygen/cs4362a.h69
-rw-r--r--sound/pci/oxygen/cs4398.h69
-rw-r--r--sound/pci/oxygen/hifier.c36
-rw-r--r--sound/pci/oxygen/oxygen.c129
-rw-r--r--sound/pci/oxygen/oxygen.h23
-rw-r--r--sound/pci/oxygen/oxygen_io.c23
-rw-r--r--sound/pci/oxygen/oxygen_lib.c113
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c217
-rw-r--r--sound/pci/oxygen/oxygen_pcm.c78
-rw-r--r--sound/pci/oxygen/pcm1796.h58
-rw-r--r--sound/pci/oxygen/virtuoso.c594
-rw-r--r--sound/pci/oxygen/wm8785.h45
-rw-r--r--sound/pci/pcxhr/pcxhr.c7
-rw-r--r--sound/pci/pcxhr/pcxhr_core.c33
-rw-r--r--sound/pci/riptide/riptide.c14
-rw-r--r--sound/pci/rme32.c3
-rw-r--r--sound/pci/rme96.c3
-rw-r--r--sound/pci/rme9652/hdsp.c54
-rw-r--r--sound/pci/rme9652/hdspm.c19
-rw-r--r--sound/pci/sis7019.c1
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/via82xx.c2
-rw-r--r--sound/pci/via82xx_modem.c2
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c4
87 files changed, 6229 insertions, 2106 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 812085d521f1..7e4742109572 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -122,6 +122,21 @@ config SND_AU8830
122 To compile this driver as a module, choose M here: the module 122 To compile this driver as a module, choose M here: the module
123 will be called snd-au8830. 123 will be called snd-au8830.
124 124
125config SND_AW2
126 tristate "Emagic Audiowerk 2"
127 depends on SND
128 help
129 Say Y here to include support for Emagic Audiowerk 2 soundcards.
130
131 Supported features: Analog and SPDIF output. Analog or SPDIF input.
132 Note: Switch between analog and digital input does not always work.
133 It can produce continuous noise. The workaround is to switch again
134 (and again) between digital and analog input until it works.
135
136 To compile this driver as a module, choose M here: the module
137 will be called snd-aw2.
138
139
125config SND_AZT3328 140config SND_AZT3328
126 tristate "Aztech AZF3328 / PCI168 (EXPERIMENTAL)" 141 tristate "Aztech AZF3328 / PCI168 (EXPERIMENTAL)"
127 depends on SND && EXPERIMENTAL 142 depends on SND && EXPERIMENTAL
@@ -162,6 +177,7 @@ config SND_CA0106
162 depends on SND 177 depends on SND
163 select SND_AC97_CODEC 178 select SND_AC97_CODEC
164 select SND_RAWMIDI 179 select SND_RAWMIDI
180 select SND_VMASTER
165 help 181 help
166 Say Y here to include support for the Sound Blaster Audigy LS 182 Say Y here to include support for the Sound Blaster Audigy LS
167 and Live 24bit. 183 and Live 24bit.
@@ -499,24 +515,22 @@ config SND_FM801
499config SND_FM801_TEA575X_BOOL 515config SND_FM801_TEA575X_BOOL
500 bool "ForteMedia FM801 + TEA5757 tuner" 516 bool "ForteMedia FM801 + TEA5757 tuner"
501 depends on SND_FM801 517 depends on SND_FM801
518 depends on VIDEO_V4L1=y || VIDEO_V4L1=SND_FM801
502 help 519 help
503 Say Y here to include support for soundcards based on the ForteMedia 520 Say Y here to include support for soundcards based on the ForteMedia
504 FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media 521 FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media
505 Forte SF256-PCS-02) into the snd-fm801 driver. 522 Forte SF256-PCS-02) into the snd-fm801 driver.
506 523
507 This will enable support for the old V4L1 API.
508
509config SND_FM801_TEA575X 524config SND_FM801_TEA575X
510 tristate 525 tristate
511 depends on SND_FM801_TEA575X_BOOL 526 depends on SND_FM801_TEA575X_BOOL
512 default SND_FM801 527 default SND_FM801
513 select VIDEO_V4L1
514 select VIDEO_DEV
515 528
516config SND_HDA_INTEL 529config SND_HDA_INTEL
517 tristate "Intel HD Audio" 530 tristate "Intel HD Audio"
518 depends on SND 531 depends on SND
519 select SND_PCM 532 select SND_PCM
533 select SND_VMASTER
520 help 534 help
521 Say Y here to include support for Intel "High Definition 535 Say Y here to include support for Intel "High Definition
522 Audio" (Azalia) motherboard devices. 536 Audio" (Azalia) motherboard devices.
@@ -680,6 +694,7 @@ config SND_ICE1724
680 depends on SND 694 depends on SND
681 select SND_MPU401_UART 695 select SND_MPU401_UART
682 select SND_AC97_CODEC 696 select SND_AC97_CODEC
697 select SND_VMASTER
683 help 698 help
684 Say Y here to include support for soundcards based on 699 Say Y here to include support for soundcards based on
685 ICE/VT1724/1720 (Envy24HT/PT) chips. 700 ICE/VT1724/1720 (Envy24HT/PT) chips.
@@ -896,12 +911,12 @@ config SND_VIA82XX_MODEM
896 will be called snd-via82xx-modem. 911 will be called snd-via82xx-modem.
897 912
898config SND_VIRTUOSO 913config SND_VIRTUOSO
899 tristate "Asus Virtuoso 200 (Xonar)" 914 tristate "Asus Virtuoso 100/200 (Xonar)"
900 depends on SND 915 depends on SND
901 select SND_OXYGEN_LIB 916 select SND_OXYGEN_LIB
902 help 917 help
903 Say Y here to include support for sound cards based on the 918 Say Y here to include support for sound cards based on the
904 Asus AV200 chip, i.e., Xonar D2 and Xonar D2X. 919 Asus AV100/AV200 chips, i.e., Xonar D2, DX and D2X.
905 920
906 To compile this driver as a module, choose M here: the module 921 To compile this driver as a module, choose M here: the module
907 will be called snd-virtuoso. 922 will be called snd-virtuoso.
diff --git a/sound/pci/Makefile b/sound/pci/Makefile
index 2d42fd28f4e7..85ef14bc8056 100644
--- a/sound/pci/Makefile
+++ b/sound/pci/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_SND) += \
58 ac97/ \ 58 ac97/ \
59 ali5451/ \ 59 ali5451/ \
60 au88x0/ \ 60 au88x0/ \
61 aw2/ \
61 ca0106/ \ 62 ca0106/ \
62 cs46xx/ \ 63 cs46xx/ \
63 cs5535audio/ \ 64 cs5535audio/ \
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 50c637e55ffa..2da89810ca10 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -114,10 +114,9 @@ static int ac97_surround_jack_mode_put(struct snd_kcontrol *kcontrol, struct snd
114 114
115static int ac97_channel_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 115static int ac97_channel_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
116{ 116{
117 static const char *texts[] = { "2ch", "4ch", "6ch" }; 117 static const char *texts[] = { "2ch", "4ch", "6ch", "8ch" };
118 if (kcontrol->private_value) 118 return ac97_enum_text_info(kcontrol, uinfo, texts,
119 return ac97_enum_text_info(kcontrol, uinfo, texts, 2); /* 4ch only */ 119 kcontrol->private_value);
120 return ac97_enum_text_info(kcontrol, uinfo, texts, 3);
121} 120}
122 121
123static int ac97_channel_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 122static int ac97_channel_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
@@ -133,13 +132,8 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
133 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 132 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
134 unsigned char mode = ucontrol->value.enumerated.item[0]; 133 unsigned char mode = ucontrol->value.enumerated.item[0];
135 134
136 if (kcontrol->private_value) { 135 if (mode >= kcontrol->private_value)
137 if (mode >= 2) 136 return -EINVAL;
138 return -EINVAL;
139 } else {
140 if (mode >= 3)
141 return -EINVAL;
142 }
143 137
144 if (mode != ac97->channel_mode) { 138 if (mode != ac97->channel_mode) {
145 ac97->channel_mode = mode; 139 ac97->channel_mode = mode;
@@ -158,6 +152,7 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
158 .get = ac97_surround_jack_mode_get, \ 152 .get = ac97_surround_jack_mode_get, \
159 .put = ac97_surround_jack_mode_put, \ 153 .put = ac97_surround_jack_mode_put, \
160 } 154 }
155/* 6ch */
161#define AC97_CHANNEL_MODE_CTL \ 156#define AC97_CHANNEL_MODE_CTL \
162 { \ 157 { \
163 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -165,7 +160,9 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
165 .info = ac97_channel_mode_info, \ 160 .info = ac97_channel_mode_info, \
166 .get = ac97_channel_mode_get, \ 161 .get = ac97_channel_mode_get, \
167 .put = ac97_channel_mode_put, \ 162 .put = ac97_channel_mode_put, \
163 .private_value = 3, \
168 } 164 }
165/* 4ch */
169#define AC97_CHANNEL_MODE_4CH_CTL \ 166#define AC97_CHANNEL_MODE_4CH_CTL \
170 { \ 167 { \
171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -173,7 +170,17 @@ static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
173 .info = ac97_channel_mode_info, \ 170 .info = ac97_channel_mode_info, \
174 .get = ac97_channel_mode_get, \ 171 .get = ac97_channel_mode_get, \
175 .put = ac97_channel_mode_put, \ 172 .put = ac97_channel_mode_put, \
176 .private_value = 1, \ 173 .private_value = 2, \
174 }
175/* 8ch */
176#define AC97_CHANNEL_MODE_8CH_CTL \
177 { \
178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
179 .name = "Channel Mode", \
180 .info = ac97_channel_mode_info, \
181 .get = ac97_channel_mode_get, \
182 .put = ac97_channel_mode_put, \
183 .private_value = 4, \
177 } 184 }
178 185
179static inline int is_surround_on(struct snd_ac97 *ac97) 186static inline int is_surround_on(struct snd_ac97 *ac97)
@@ -210,6 +217,10 @@ static inline int is_shared_micin(struct snd_ac97 *ac97)
210 return !ac97->indep_surround && !is_clfe_on(ac97); 217 return !ac97->indep_surround && !is_clfe_on(ac97);
211} 218}
212 219
220static inline int alc850_is_aux_back_surround(struct snd_ac97 *ac97)
221{
222 return is_surround_on(ac97);
223}
213 224
214/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ 225/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */
215/* Modified for YMF743 by Keita Maehara <maehara@debian.org> */ 226/* Modified for YMF743 by Keita Maehara <maehara@debian.org> */
@@ -2816,10 +2827,12 @@ static int patch_alc655(struct snd_ac97 * ac97)
2816 2827
2817#define AC97_ALC850_JACK_SELECT 0x76 2828#define AC97_ALC850_JACK_SELECT 0x76
2818#define AC97_ALC850_MISC1 0x7a 2829#define AC97_ALC850_MISC1 0x7a
2830#define AC97_ALC850_MULTICH 0x6a
2819 2831
2820static void alc850_update_jacks(struct snd_ac97 *ac97) 2832static void alc850_update_jacks(struct snd_ac97 *ac97)
2821{ 2833{
2822 int shared; 2834 int shared;
2835 int aux_is_back_surround;
2823 2836
2824 /* shared Line-In / Surround Out */ 2837 /* shared Line-In / Surround Out */
2825 shared = is_shared_surrout(ac97); 2838 shared = is_shared_surrout(ac97);
@@ -2837,13 +2850,18 @@ static void alc850_update_jacks(struct snd_ac97 *ac97)
2837 /* MIC-IN = 1, CENTER-LFE = 5 */ 2850 /* MIC-IN = 1, CENTER-LFE = 5 */
2838 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4, 2851 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
2839 shared ? (5<<4) : (1<<4)); 2852 shared ? (5<<4) : (1<<4));
2853
2854 aux_is_back_surround = alc850_is_aux_back_surround(ac97);
2855 /* Aux is Back Surround */
2856 snd_ac97_update_bits(ac97, AC97_ALC850_MULTICH, 1 << 10,
2857 aux_is_back_surround ? (1<<10) : (0<<10));
2840} 2858}
2841 2859
2842static const struct snd_kcontrol_new snd_ac97_controls_alc850[] = { 2860static const struct snd_kcontrol_new snd_ac97_controls_alc850[] = {
2843 AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), 2861 AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0),
2844 AC97_SINGLE("Mic Front Input Switch", AC97_ALC850_JACK_SELECT, 15, 1, 1), 2862 AC97_SINGLE("Mic Front Input Switch", AC97_ALC850_JACK_SELECT, 15, 1, 1),
2845 AC97_SURROUND_JACK_MODE_CTL, 2863 AC97_SURROUND_JACK_MODE_CTL,
2846 AC97_CHANNEL_MODE_CTL, 2864 AC97_CHANNEL_MODE_8CH_CTL,
2847}; 2865};
2848 2866
2849static int patch_alc850_specific(struct snd_ac97 *ac97) 2867static int patch_alc850_specific(struct snd_ac97 *ac97)
@@ -2869,6 +2887,7 @@ static int patch_alc850(struct snd_ac97 *ac97)
2869 ac97->build_ops = &patch_alc850_ops; 2887 ac97->build_ops = &patch_alc850_ops;
2870 2888
2871 ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */ 2889 ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */
2890 ac97->flags |= AC97_HAS_8CH;
2872 2891
2873 /* assume only page 0 for writing cache */ 2892 /* assume only page 0 for writing cache */
2874 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR); 2893 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
@@ -2878,6 +2897,7 @@ static int patch_alc850(struct snd_ac97 *ac97)
2878 spdif-in monitor off, spdif-in PCM off 2897 spdif-in monitor off, spdif-in PCM off
2879 center on mic off, surround on line-in off 2898 center on mic off, surround on line-in off
2880 duplicate front off 2899 duplicate front off
2900 NB default bit 10=0 = Aux is Capture, not Back Surround
2881 */ 2901 */
2882 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15); 2902 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2883 /* SURR_OUT: on, Surr 1kOhm: on, Surr Amp: off, Front 1kOhm: off 2903 /* SURR_OUT: on, Surr 1kOhm: on, Surr Amp: off, Front 1kOhm: off
@@ -3426,6 +3446,7 @@ static const struct snd_kcontrol_new snd_ac97_controls_vt1617a[] = {
3426int patch_vt1617a(struct snd_ac97 * ac97) 3446int patch_vt1617a(struct snd_ac97 * ac97)
3427{ 3447{
3428 int err = 0; 3448 int err = 0;
3449 int val;
3429 3450
3430 /* we choose to not fail out at this point, but we tell the 3451 /* we choose to not fail out at this point, but we tell the
3431 caller when we return */ 3452 caller when we return */
@@ -3436,7 +3457,13 @@ int patch_vt1617a(struct snd_ac97 * ac97)
3436 /* bring analog power consumption to normal by turning off the 3457 /* bring analog power consumption to normal by turning off the
3437 * headphone amplifier, like WinXP driver for EPIA SP 3458 * headphone amplifier, like WinXP driver for EPIA SP
3438 */ 3459 */
3439 snd_ac97_write_cache(ac97, 0x5c, 0x20); 3460 /* We need to check the bit before writing it.
3461 * On some (many?) hardwares, setting bit actually clears it!
3462 */
3463 val = snd_ac97_read(ac97, 0x5c);
3464 if (!(val & 0x20))
3465 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3466
3440 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ 3467 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3441 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; 3468 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3442 ac97->build_ops = &patch_vt1616_ops; 3469 ac97->build_ops = &patch_vt1616_ops;
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c
index 3674f35c4a79..48cbda9378c5 100644
--- a/sound/pci/ac97/ac97_pcm.c
+++ b/sound/pci/ac97/ac97_pcm.c
@@ -574,7 +574,6 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
574 r = rate > 48000; 574 r = rate > 48000;
575 bus = pcm->bus; 575 bus = pcm->bus;
576 if (cfg == AC97_PCM_CFG_SPDIF) { 576 if (cfg == AC97_PCM_CFG_SPDIF) {
577 int err;
578 for (cidx = 0; cidx < 4; cidx++) 577 for (cidx = 0; cidx < 4; cidx++)
579 if (bus->codec[cidx] && (bus->codec[cidx]->ext_id & AC97_EI_SPDIF)) { 578 if (bus->codec[cidx] && (bus->codec[cidx]->ext_id & AC97_EI_SPDIF)) {
580 err = set_spdif_rate(bus->codec[cidx], rate); 579 err = set_spdif_rate(bus->codec[cidx], rate);
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index a66d5150bb7a..39ec55b57b1e 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -264,10 +264,10 @@ snd_ad1889_ac97_ready(struct snd_ad1889 *chip)
264 mdelay(1); 264 mdelay(1);
265 if (!retry) { 265 if (!retry) {
266 snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n", 266 snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n",
267 __FUNCTION__); 267 __func__);
268 return -EIO; 268 return -EIO;
269 } 269 }
270 ad1889_debug("[%s] ready after %d ms\n", __FUNCTION__, 400 - retry); 270 ad1889_debug("[%s] ready after %d ms\n", __func__, 400 - retry);
271 271
272 return 0; 272 return 0;
273} 273}
@@ -854,8 +854,6 @@ snd_ad1889_free(struct snd_ad1889 *chip)
854 854
855 spin_unlock_irq(&chip->lock); 855 spin_unlock_irq(&chip->lock);
856 856
857 synchronize_irq(chip->irq);
858
859 if (chip->irq >= 0) 857 if (chip->irq >= 0)
860 free_irq(chip->irq, chip); 858 free_irq(chip->irq, chip);
861 859
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 6a905ed9cbd6..1a0fd65ec280 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -1809,26 +1809,26 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol,
1809 struct snd_ctl_elem_value *ucontrol) 1809 struct snd_ctl_elem_value *ucontrol)
1810{ 1810{
1811 struct snd_ali *codec = kcontrol->private_data; 1811 struct snd_ali *codec = kcontrol->private_data;
1812 unsigned int enable; 1812 unsigned int spdif_enable;
1813 1813
1814 enable = ucontrol->value.integer.value[0] ? 1 : 0; 1814 spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
1815 1815
1816 spin_lock_irq(&codec->reg_lock); 1816 spin_lock_irq(&codec->reg_lock);
1817 switch (kcontrol->private_value) { 1817 switch (kcontrol->private_value) {
1818 case 0: 1818 case 0:
1819 enable = (codec->spdif_mask & 0x02) ? 1 : 0; 1819 spdif_enable = (codec->spdif_mask & 0x02) ? 1 : 0;
1820 break; 1820 break;
1821 case 1: 1821 case 1:
1822 enable = ((codec->spdif_mask & 0x02) && 1822 spdif_enable = ((codec->spdif_mask & 0x02) &&
1823 (codec->spdif_mask & 0x04)) ? 1 : 0; 1823 (codec->spdif_mask & 0x04)) ? 1 : 0;
1824 break; 1824 break;
1825 case 2: 1825 case 2:
1826 enable = (codec->spdif_mask & 0x01) ? 1 : 0; 1826 spdif_enable = (codec->spdif_mask & 0x01) ? 1 : 0;
1827 break; 1827 break;
1828 default: 1828 default:
1829 break; 1829 break;
1830 } 1830 }
1831 ucontrol->value.integer.value[0] = enable; 1831 ucontrol->value.integer.value[0] = spdif_enable;
1832 spin_unlock_irq(&codec->reg_lock); 1832 spin_unlock_irq(&codec->reg_lock);
1833 return 0; 1833 return 0;
1834} 1834}
@@ -1837,17 +1837,17 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1837 struct snd_ctl_elem_value *ucontrol) 1837 struct snd_ctl_elem_value *ucontrol)
1838{ 1838{
1839 struct snd_ali *codec = kcontrol->private_data; 1839 struct snd_ali *codec = kcontrol->private_data;
1840 unsigned int change = 0, enable = 0; 1840 unsigned int change = 0, spdif_enable = 0;
1841 1841
1842 enable = ucontrol->value.integer.value[0] ? 1 : 0; 1842 spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
1843 1843
1844 spin_lock_irq(&codec->reg_lock); 1844 spin_lock_irq(&codec->reg_lock);
1845 switch (kcontrol->private_value) { 1845 switch (kcontrol->private_value) {
1846 case 0: 1846 case 0:
1847 change = (codec->spdif_mask & 0x02) ? 1 : 0; 1847 change = (codec->spdif_mask & 0x02) ? 1 : 0;
1848 change = change ^ enable; 1848 change = change ^ spdif_enable;
1849 if (change) { 1849 if (change) {
1850 if (enable) { 1850 if (spdif_enable) {
1851 codec->spdif_mask |= 0x02; 1851 codec->spdif_mask |= 0x02;
1852 snd_ali_enable_spdif_out(codec); 1852 snd_ali_enable_spdif_out(codec);
1853 } else { 1853 } else {
@@ -1859,9 +1859,9 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1859 break; 1859 break;
1860 case 1: 1860 case 1:
1861 change = (codec->spdif_mask & 0x04) ? 1 : 0; 1861 change = (codec->spdif_mask & 0x04) ? 1 : 0;
1862 change = change ^ enable; 1862 change = change ^ spdif_enable;
1863 if (change && (codec->spdif_mask & 0x02)) { 1863 if (change && (codec->spdif_mask & 0x02)) {
1864 if (enable) { 1864 if (spdif_enable) {
1865 codec->spdif_mask |= 0x04; 1865 codec->spdif_mask |= 0x04;
1866 snd_ali_enable_spdif_chnout(codec); 1866 snd_ali_enable_spdif_chnout(codec);
1867 } else { 1867 } else {
@@ -1872,9 +1872,9 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1872 break; 1872 break;
1873 case 2: 1873 case 2:
1874 change = (codec->spdif_mask & 0x01) ? 1 : 0; 1874 change = (codec->spdif_mask & 0x01) ? 1 : 0;
1875 change = change ^ enable; 1875 change = change ^ spdif_enable;
1876 if (change) { 1876 if (change) {
1877 if (enable) { 1877 if (spdif_enable) {
1878 codec->spdif_mask |= 0x01; 1878 codec->spdif_mask |= 0x01;
1879 snd_ali_enable_spdif_in(codec); 1879 snd_ali_enable_spdif_in(codec);
1880 } else { 1880 } else {
@@ -2047,10 +2047,8 @@ static int snd_ali_free(struct snd_ali * codec)
2047{ 2047{
2048 if (codec->hw_initialized) 2048 if (codec->hw_initialized)
2049 snd_ali_disable_address_interrupt(codec); 2049 snd_ali_disable_address_interrupt(codec);
2050 if (codec->irq >= 0) { 2050 if (codec->irq >= 0)
2051 synchronize_irq(codec->irq);
2052 free_irq(codec->irq, codec); 2051 free_irq(codec->irq, codec);
2053 }
2054 if (codec->port) 2052 if (codec->port)
2055 pci_release_regions(codec->pci); 2053 pci_release_regions(codec->pci);
2056 pci_disable_device(codec->pci); 2054 pci_disable_device(codec->pci);
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 0e990a735821..8df6824b51cd 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -92,8 +92,8 @@
92 92
93#if DEBUG_CALLS 93#if DEBUG_CALLS
94#define snd_als300_dbgcalls(format, args...) printk(format, ##args) 94#define snd_als300_dbgcalls(format, args...) printk(format, ##args)
95#define snd_als300_dbgcallenter() printk(KERN_ERR "--> %s\n", __FUNCTION__) 95#define snd_als300_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__)
96#define snd_als300_dbgcallleave() printk(KERN_ERR "<-- %s\n", __FUNCTION__) 96#define snd_als300_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__)
97#else 97#else
98#define snd_als300_dbgcalls(format, args...) 98#define snd_als300_dbgcalls(format, args...)
99#define snd_als300_dbgcallenter() 99#define snd_als300_dbgcallenter()
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 4594186b83ee..457228fb22aa 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1553,7 +1553,7 @@ static int snd_atiixp_free(struct atiixp *chip)
1553 if (chip->irq < 0) 1553 if (chip->irq < 0)
1554 goto __hw_end; 1554 goto __hw_end;
1555 snd_atiixp_chip_stop(chip); 1555 snd_atiixp_chip_stop(chip);
1556 synchronize_irq(chip->irq); 1556
1557 __hw_end: 1557 __hw_end:
1558 if (chip->irq >= 0) 1558 if (chip->irq >= 0)
1559 free_irq(chip->irq, chip); 1559 free_irq(chip->irq, chip);
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index a67a869180d4..d457a32a7939 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1197,7 +1197,7 @@ static int snd_atiixp_free(struct atiixp_modem *chip)
1197 if (chip->irq < 0) 1197 if (chip->irq < 0)
1198 goto __hw_end; 1198 goto __hw_end;
1199 snd_atiixp_chip_stop(chip); 1199 snd_atiixp_chip_stop(chip);
1200 synchronize_irq(chip->irq); 1200
1201 __hw_end: 1201 __hw_end:
1202 if (chip->irq >= 0) 1202 if (chip->irq >= 0)
1203 free_irq(chip->irq, chip); 1203 free_irq(chip->irq, chip);
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 26819e2f5761..68368e490074 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -126,7 +126,6 @@ static int snd_vortex_dev_free(struct snd_device *device)
126 vortex_gameport_unregister(vortex); 126 vortex_gameport_unregister(vortex);
127 vortex_core_shutdown(vortex); 127 vortex_core_shutdown(vortex);
128 // Take down PCI interface. 128 // Take down PCI interface.
129 synchronize_irq(vortex->irq);
130 free_irq(vortex->irq, vortex); 129 free_irq(vortex->irq, vortex);
131 iounmap(vortex->mmio); 130 iounmap(vortex->mmio);
132 pci_release_regions(vortex->pci_dev); 131 pci_release_regions(vortex->pci_dev);
@@ -220,7 +219,6 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
220 return 0; 219 return 0;
221 220
222 alloc_out: 221 alloc_out:
223 synchronize_irq(chip->irq);
224 free_irq(chip->irq, chip); 222 free_irq(chip->irq, chip);
225 irq_out: 223 irq_out:
226 vortex_core_shutdown(chip); 224 vortex_core_shutdown(chip);
diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c
index 526c6c5ecf7b..f9a58b4a30eb 100644
--- a/sound/pci/au88x0/au88x0_pcm.c
+++ b/sound/pci/au88x0/au88x0_pcm.c
@@ -498,14 +498,14 @@ static struct snd_kcontrol_new snd_vortex_mixer_spdif[] __devinitdata = {
498}; 498};
499 499
500/* create a pcm device */ 500/* create a pcm device */
501static int __devinit snd_vortex_new_pcm(vortex_t * chip, int idx, int nr) 501static int __devinit snd_vortex_new_pcm(vortex_t *chip, int idx, int nr)
502{ 502{
503 struct snd_pcm *pcm; 503 struct snd_pcm *pcm;
504 struct snd_kcontrol *kctl; 504 struct snd_kcontrol *kctl;
505 int i; 505 int i;
506 int err, nr_capt; 506 int err, nr_capt;
507 507
508 if ((chip == 0) || (idx < 0) || (idx >= VORTEX_PCM_LAST)) 508 if (!chip || idx < 0 || idx >= VORTEX_PCM_LAST)
509 return -ENODEV; 509 return -ENODEV;
510 510
511 /* idx indicates which kind of PCM device. ADB, SPDIF, I2S and A3D share the 511 /* idx indicates which kind of PCM device. ADB, SPDIF, I2S and A3D share the
@@ -514,9 +514,9 @@ static int __devinit snd_vortex_new_pcm(vortex_t * chip, int idx, int nr)
514 nr_capt = nr; 514 nr_capt = nr;
515 else 515 else
516 nr_capt = 0; 516 nr_capt = 0;
517 if ((err = 517 err = snd_pcm_new(chip->card, vortex_pcm_prettyname[idx], idx, nr,
518 snd_pcm_new(chip->card, vortex_pcm_prettyname[idx], idx, nr, 518 nr_capt, &pcm);
519 nr_capt, &pcm)) < 0) 519 if (err < 0)
520 return err; 520 return err;
521 strcpy(pcm->name, vortex_pcm_name[idx]); 521 strcpy(pcm->name, vortex_pcm_name[idx]);
522 chip->pcm[idx] = pcm; 522 chip->pcm[idx] = pcm;
diff --git a/sound/pci/aw2/Makefile b/sound/pci/aw2/Makefile
new file mode 100644
index 000000000000..842335d3b735
--- /dev/null
+++ b/sound/pci/aw2/Makefile
@@ -0,0 +1,3 @@
1snd-aw2-objs := aw2-alsa.o aw2-saa7146.o
2
3obj-$(CONFIG_SND_AW2) += snd-aw2.o
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
new file mode 100644
index 000000000000..56f87cd33c19
--- /dev/null
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -0,0 +1,794 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 *
6 * This file is part of the Audiowerk2 ALSA driver
7 *
8 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.
11 *
12 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 *****************************************************************************/
23#include <linux/init.h>
24#include <linux/pci.h>
25#include <linux/dma-mapping.h>
26#include <linux/slab.h>
27#include <linux/interrupt.h>
28#include <linux/delay.h>
29#include <asm/io.h>
30#include <sound/core.h>
31#include <sound/initval.h>
32#include <sound/pcm.h>
33#include <sound/pcm_params.h>
34#include <sound/control.h>
35
36#include "saa7146.h"
37#include "aw2-saa7146.h"
38
39MODULE_AUTHOR("Cedric Bregardis <cedric.bregardis@free.fr>, "
40 "Jean-Christian Hassler <jhassler@free.fr>");
41MODULE_DESCRIPTION("Emagic Audiowerk 2 sound driver");
42MODULE_LICENSE("GPL");
43
44/*********************************
45 * DEFINES
46 ********************************/
47#define PCI_VENDOR_ID_SAA7146 0x1131
48#define PCI_DEVICE_ID_SAA7146 0x7146
49
50#define CTL_ROUTE_ANALOG 0
51#define CTL_ROUTE_DIGITAL 1
52
53/*********************************
54 * TYPEDEFS
55 ********************************/
56 /* hardware definition */
57static struct snd_pcm_hardware snd_aw2_playback_hw = {
58 .info = (SNDRV_PCM_INFO_MMAP |
59 SNDRV_PCM_INFO_INTERLEAVED |
60 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID),
61 .formats = SNDRV_PCM_FMTBIT_S16_LE,
62 .rates = SNDRV_PCM_RATE_44100,
63 .rate_min = 44100,
64 .rate_max = 44100,
65 .channels_min = 2,
66 .channels_max = 4,
67 .buffer_bytes_max = 32768,
68 .period_bytes_min = 4096,
69 .period_bytes_max = 32768,
70 .periods_min = 1,
71 .periods_max = 1024,
72};
73
74static struct snd_pcm_hardware snd_aw2_capture_hw = {
75 .info = (SNDRV_PCM_INFO_MMAP |
76 SNDRV_PCM_INFO_INTERLEAVED |
77 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID),
78 .formats = SNDRV_PCM_FMTBIT_S16_LE,
79 .rates = SNDRV_PCM_RATE_44100,
80 .rate_min = 44100,
81 .rate_max = 44100,
82 .channels_min = 2,
83 .channels_max = 2,
84 .buffer_bytes_max = 32768,
85 .period_bytes_min = 4096,
86 .period_bytes_max = 32768,
87 .periods_min = 1,
88 .periods_max = 1024,
89};
90
91struct aw2_pcm_device {
92 struct snd_pcm *pcm;
93 unsigned int stream_number;
94 struct aw2 *chip;
95};
96
97struct aw2 {
98 struct snd_aw2_saa7146 saa7146;
99
100 struct pci_dev *pci;
101 int irq;
102 spinlock_t reg_lock;
103 struct mutex mtx;
104
105 unsigned long iobase_phys;
106 void __iomem *iobase_virt;
107
108 struct snd_card *card;
109
110 struct aw2_pcm_device device_playback[NB_STREAM_PLAYBACK];
111 struct aw2_pcm_device device_capture[NB_STREAM_CAPTURE];
112};
113
114/*********************************
115 * FUNCTION DECLARATIONS
116 ********************************/
117static int __init alsa_card_aw2_init(void);
118static void __exit alsa_card_aw2_exit(void);
119static int snd_aw2_dev_free(struct snd_device *device);
120static int __devinit snd_aw2_create(struct snd_card *card,
121 struct pci_dev *pci, struct aw2 **rchip);
122static int __devinit snd_aw2_probe(struct pci_dev *pci,
123 const struct pci_device_id *pci_id);
124static void __devexit snd_aw2_remove(struct pci_dev *pci);
125static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream);
126static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream);
127static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream);
128static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream);
129static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
130 struct snd_pcm_hw_params *hw_params);
131static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream);
132static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream);
133static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream);
134static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream,
135 int cmd);
136static int snd_aw2_pcm_trigger_capture(struct snd_pcm_substream *substream,
137 int cmd);
138static snd_pcm_uframes_t snd_aw2_pcm_pointer_playback(struct snd_pcm_substream
139 *substream);
140static snd_pcm_uframes_t snd_aw2_pcm_pointer_capture(struct snd_pcm_substream
141 *substream);
142static int __devinit snd_aw2_new_pcm(struct aw2 *chip);
143
144static int snd_aw2_control_switch_capture_info(struct snd_kcontrol *kcontrol,
145 struct snd_ctl_elem_info *uinfo);
146static int snd_aw2_control_switch_capture_get(struct snd_kcontrol *kcontrol,
147 struct snd_ctl_elem_value
148 *ucontrol);
149static int snd_aw2_control_switch_capture_put(struct snd_kcontrol *kcontrol,
150 struct snd_ctl_elem_value
151 *ucontrol);
152
153/*********************************
154 * VARIABLES
155 ********************************/
156static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
157static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
158static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
159
160module_param_array(index, int, NULL, 0444);
161MODULE_PARM_DESC(index, "Index value for Audiowerk2 soundcard.");
162module_param_array(id, charp, NULL, 0444);
163MODULE_PARM_DESC(id, "ID string for the Audiowerk2 soundcard.");
164module_param_array(enable, bool, NULL, 0444);
165MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard.");
166
167static struct pci_device_id snd_aw2_ids[] = {
168 {PCI_VENDOR_ID_SAA7146, PCI_DEVICE_ID_SAA7146, PCI_ANY_ID, PCI_ANY_ID,
169 0, 0, 0},
170 {0}
171};
172
173MODULE_DEVICE_TABLE(pci, snd_aw2_ids);
174
175/* pci_driver definition */
176static struct pci_driver driver = {
177 .name = "Emagic Audiowerk 2",
178 .id_table = snd_aw2_ids,
179 .probe = snd_aw2_probe,
180 .remove = __devexit_p(snd_aw2_remove),
181};
182
183/* operators for playback PCM alsa interface */
184static struct snd_pcm_ops snd_aw2_playback_ops = {
185 .open = snd_aw2_pcm_playback_open,
186 .close = snd_aw2_pcm_playback_close,
187 .ioctl = snd_pcm_lib_ioctl,
188 .hw_params = snd_aw2_pcm_hw_params,
189 .hw_free = snd_aw2_pcm_hw_free,
190 .prepare = snd_aw2_pcm_prepare_playback,
191 .trigger = snd_aw2_pcm_trigger_playback,
192 .pointer = snd_aw2_pcm_pointer_playback,
193};
194
195/* operators for capture PCM alsa interface */
196static struct snd_pcm_ops snd_aw2_capture_ops = {
197 .open = snd_aw2_pcm_capture_open,
198 .close = snd_aw2_pcm_capture_close,
199 .ioctl = snd_pcm_lib_ioctl,
200 .hw_params = snd_aw2_pcm_hw_params,
201 .hw_free = snd_aw2_pcm_hw_free,
202 .prepare = snd_aw2_pcm_prepare_capture,
203 .trigger = snd_aw2_pcm_trigger_capture,
204 .pointer = snd_aw2_pcm_pointer_capture,
205};
206
207static struct snd_kcontrol_new aw2_control __devinitdata = {
208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
209 .name = "PCM Capture Route",
210 .index = 0,
211 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
212 .private_value = 0xffff,
213 .info = snd_aw2_control_switch_capture_info,
214 .get = snd_aw2_control_switch_capture_get,
215 .put = snd_aw2_control_switch_capture_put
216};
217
218/*********************************
219 * FUNCTION IMPLEMENTATIONS
220 ********************************/
221
222/* initialization of the module */
223static int __init alsa_card_aw2_init(void)
224{
225 snd_printdd(KERN_DEBUG "aw2: Load aw2 module\n");
226 return pci_register_driver(&driver);
227}
228
229/* clean up the module */
230static void __exit alsa_card_aw2_exit(void)
231{
232 snd_printdd(KERN_DEBUG "aw2: Unload aw2 module\n");
233 pci_unregister_driver(&driver);
234}
235
236module_init(alsa_card_aw2_init);
237module_exit(alsa_card_aw2_exit);
238
239/* component-destructor */
240static int snd_aw2_dev_free(struct snd_device *device)
241{
242 struct aw2 *chip = device->device_data;
243
244 /* Free hardware */
245 snd_aw2_saa7146_free(&chip->saa7146);
246
247 /* release the irq */
248 if (chip->irq >= 0)
249 free_irq(chip->irq, (void *)chip);
250 /* release the i/o ports & memory */
251 if (chip->iobase_virt)
252 iounmap(chip->iobase_virt);
253
254 pci_release_regions(chip->pci);
255 /* disable the PCI entry */
256 pci_disable_device(chip->pci);
257 /* release the data */
258 kfree(chip);
259
260 return 0;
261}
262
263/* chip-specific constructor */
264static int __devinit snd_aw2_create(struct snd_card *card,
265 struct pci_dev *pci, struct aw2 **rchip)
266{
267 struct aw2 *chip;
268 int err;
269 static struct snd_device_ops ops = {
270 .dev_free = snd_aw2_dev_free,
271 };
272
273 *rchip = NULL;
274
275 /* initialize the PCI entry */
276 err = pci_enable_device(pci);
277 if (err < 0)
278 return err;
279 pci_set_master(pci);
280
281 /* check PCI availability (32bit DMA) */
282 if ((pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) ||
283 (pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0)) {
284 printk(KERN_ERR "aw2: Impossible to set 32bit mask DMA\n");
285 pci_disable_device(pci);
286 return -ENXIO;
287 }
288 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
289 if (chip == NULL) {
290 pci_disable_device(pci);
291 return -ENOMEM;
292 }
293
294 /* initialize the stuff */
295 chip->card = card;
296 chip->pci = pci;
297 chip->irq = -1;
298
299 /* (1) PCI resource allocation */
300 err = pci_request_regions(pci, "Audiowerk2");
301 if (err < 0) {
302 pci_disable_device(pci);
303 kfree(chip);
304 return err;
305 }
306 chip->iobase_phys = pci_resource_start(pci, 0);
307 chip->iobase_virt =
308 ioremap_nocache(chip->iobase_phys,
309 pci_resource_len(pci, 0));
310
311 if (chip->iobase_virt == NULL) {
312 printk(KERN_ERR "aw2: unable to remap memory region");
313 pci_release_regions(pci);
314 pci_disable_device(pci);
315 kfree(chip);
316 return -ENOMEM;
317 }
318
319
320 if (request_irq(pci->irq, snd_aw2_saa7146_interrupt,
321 IRQF_SHARED, "Audiowerk2", chip)) {
322 printk(KERN_ERR "aw2: Cannot grab irq %d\n", pci->irq);
323
324 iounmap(chip->iobase_virt);
325 pci_release_regions(chip->pci);
326 pci_disable_device(chip->pci);
327 kfree(chip);
328 return -EBUSY;
329 }
330 chip->irq = pci->irq;
331
332 /* (2) initialization of the chip hardware */
333 snd_aw2_saa7146_setup(&chip->saa7146, chip->iobase_virt);
334 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
335 if (err < 0) {
336 free_irq(chip->irq, (void *)chip);
337 iounmap(chip->iobase_virt);
338 pci_release_regions(chip->pci);
339 pci_disable_device(chip->pci);
340 kfree(chip);
341 return err;
342 }
343
344 snd_card_set_dev(card, &pci->dev);
345 *rchip = chip;
346
347 printk(KERN_INFO
348 "Audiowerk 2 sound card (saa7146 chipset) detected and "
349 "managed\n");
350 return 0;
351}
352
353/* constructor */
354static int __devinit snd_aw2_probe(struct pci_dev *pci,
355 const struct pci_device_id *pci_id)
356{
357 static int dev;
358 struct snd_card *card;
359 struct aw2 *chip;
360 int err;
361
362 /* (1) Continue if device is not enabled, else inc dev */
363 if (dev >= SNDRV_CARDS)
364 return -ENODEV;
365 if (!enable[dev]) {
366 dev++;
367 return -ENOENT;
368 }
369
370 /* (2) Create card instance */
371 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
372 if (card == NULL)
373 return -ENOMEM;
374
375 /* (3) Create main component */
376 err = snd_aw2_create(card, pci, &chip);
377 if (err < 0) {
378 snd_card_free(card);
379 return err;
380 }
381
382 /* initialize mutex */
383 mutex_init(&chip->mtx);
384 /* init spinlock */
385 spin_lock_init(&chip->reg_lock);
386 /* (4) Define driver ID and name string */
387 strcpy(card->driver, "aw2");
388 strcpy(card->shortname, "Audiowerk2");
389
390 sprintf(card->longname, "%s with SAA7146 irq %i",
391 card->shortname, chip->irq);
392
393 /* (5) Create other components */
394 snd_aw2_new_pcm(chip);
395
396 /* (6) Register card instance */
397 err = snd_card_register(card);
398 if (err < 0) {
399 snd_card_free(card);
400 return err;
401 }
402
403 /* (7) Set PCI driver data */
404 pci_set_drvdata(pci, card);
405
406 dev++;
407 return 0;
408}
409
410/* destructor */
411static void __devexit snd_aw2_remove(struct pci_dev *pci)
412{
413 snd_card_free(pci_get_drvdata(pci));
414 pci_set_drvdata(pci, NULL);
415}
416
417/* open callback */
418static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream)
419{
420 struct snd_pcm_runtime *runtime = substream->runtime;
421
422 snd_printdd(KERN_DEBUG "aw2: Playback_open \n");
423 runtime->hw = snd_aw2_playback_hw;
424 return 0;
425}
426
427/* close callback */
428static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream)
429{
430 return 0;
431
432}
433
434static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream)
435{
436 struct snd_pcm_runtime *runtime = substream->runtime;
437
438 snd_printdd(KERN_DEBUG "aw2: Capture_open \n");
439 runtime->hw = snd_aw2_capture_hw;
440 return 0;
441}
442
443/* close callback */
444static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream)
445{
446 /* TODO: something to do ? */
447 return 0;
448}
449
450 /* hw_params callback */
451static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
452 struct snd_pcm_hw_params *hw_params)
453{
454 return snd_pcm_lib_malloc_pages(substream,
455 params_buffer_bytes(hw_params));
456}
457
458/* hw_free callback */
459static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream)
460{
461 return snd_pcm_lib_free_pages(substream);
462}
463
464/* prepare callback for playback */
465static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream)
466{
467 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
468 struct aw2 *chip = pcm_device->chip;
469 struct snd_pcm_runtime *runtime = substream->runtime;
470 unsigned long period_size, buffer_size;
471
472 mutex_lock(&chip->mtx);
473
474 period_size = snd_pcm_lib_period_bytes(substream);
475 buffer_size = snd_pcm_lib_buffer_bytes(substream);
476
477 snd_aw2_saa7146_pcm_init_playback(&chip->saa7146,
478 pcm_device->stream_number,
479 runtime->dma_addr, period_size,
480 buffer_size);
481
482 /* Define Interrupt callback */
483 snd_aw2_saa7146_define_it_playback_callback(pcm_device->stream_number,
484 (snd_aw2_saa7146_it_cb)
485 snd_pcm_period_elapsed,
486 (void *)substream);
487
488 mutex_unlock(&chip->mtx);
489
490 return 0;
491}
492
493/* prepare callback for capture */
494static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream)
495{
496 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
497 struct aw2 *chip = pcm_device->chip;
498 struct snd_pcm_runtime *runtime = substream->runtime;
499 unsigned long period_size, buffer_size;
500
501 mutex_lock(&chip->mtx);
502
503 period_size = snd_pcm_lib_period_bytes(substream);
504 buffer_size = snd_pcm_lib_buffer_bytes(substream);
505
506 snd_aw2_saa7146_pcm_init_capture(&chip->saa7146,
507 pcm_device->stream_number,
508 runtime->dma_addr, period_size,
509 buffer_size);
510
511 /* Define Interrupt callback */
512 snd_aw2_saa7146_define_it_capture_callback(pcm_device->stream_number,
513 (snd_aw2_saa7146_it_cb)
514 snd_pcm_period_elapsed,
515 (void *)substream);
516
517 mutex_unlock(&chip->mtx);
518
519 return 0;
520}
521
522/* playback trigger callback */
523static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream,
524 int cmd)
525{
526 int status = 0;
527 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
528 struct aw2 *chip = pcm_device->chip;
529 spin_lock(&chip->reg_lock);
530 switch (cmd) {
531 case SNDRV_PCM_TRIGGER_START:
532 snd_aw2_saa7146_pcm_trigger_start_playback(&chip->saa7146,
533 pcm_device->
534 stream_number);
535 break;
536 case SNDRV_PCM_TRIGGER_STOP:
537 snd_aw2_saa7146_pcm_trigger_stop_playback(&chip->saa7146,
538 pcm_device->
539 stream_number);
540 break;
541 default:
542 status = -EINVAL;
543 }
544 spin_unlock(&chip->reg_lock);
545 return status;
546}
547
548/* capture trigger callback */
549static int snd_aw2_pcm_trigger_capture(struct snd_pcm_substream *substream,
550 int cmd)
551{
552 int status = 0;
553 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
554 struct aw2 *chip = pcm_device->chip;
555 spin_lock(&chip->reg_lock);
556 switch (cmd) {
557 case SNDRV_PCM_TRIGGER_START:
558 snd_aw2_saa7146_pcm_trigger_start_capture(&chip->saa7146,
559 pcm_device->
560 stream_number);
561 break;
562 case SNDRV_PCM_TRIGGER_STOP:
563 snd_aw2_saa7146_pcm_trigger_stop_capture(&chip->saa7146,
564 pcm_device->
565 stream_number);
566 break;
567 default:
568 status = -EINVAL;
569 }
570 spin_unlock(&chip->reg_lock);
571 return status;
572}
573
574/* playback pointer callback */
575static snd_pcm_uframes_t snd_aw2_pcm_pointer_playback(struct snd_pcm_substream
576 *substream)
577{
578 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
579 struct aw2 *chip = pcm_device->chip;
580 unsigned int current_ptr;
581
582 /* get the current hardware pointer */
583 struct snd_pcm_runtime *runtime = substream->runtime;
584 current_ptr =
585 snd_aw2_saa7146_get_hw_ptr_playback(&chip->saa7146,
586 pcm_device->stream_number,
587 runtime->dma_area,
588 runtime->buffer_size);
589
590 return bytes_to_frames(substream->runtime, current_ptr);
591}
592
593/* capture pointer callback */
594static snd_pcm_uframes_t snd_aw2_pcm_pointer_capture(struct snd_pcm_substream
595 *substream)
596{
597 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
598 struct aw2 *chip = pcm_device->chip;
599 unsigned int current_ptr;
600
601 /* get the current hardware pointer */
602 struct snd_pcm_runtime *runtime = substream->runtime;
603 current_ptr =
604 snd_aw2_saa7146_get_hw_ptr_capture(&chip->saa7146,
605 pcm_device->stream_number,
606 runtime->dma_area,
607 runtime->buffer_size);
608
609 return bytes_to_frames(substream->runtime, current_ptr);
610}
611
612/* create a pcm device */
613static int __devinit snd_aw2_new_pcm(struct aw2 *chip)
614{
615 struct snd_pcm *pcm_playback_ana;
616 struct snd_pcm *pcm_playback_num;
617 struct snd_pcm *pcm_capture;
618 struct aw2_pcm_device *pcm_device;
619 int err = 0;
620
621 /* Create new Alsa PCM device */
622
623 err = snd_pcm_new(chip->card, "Audiowerk2 analog playback", 0, 1, 0,
624 &pcm_playback_ana);
625 if (err < 0) {
626 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
627 return err;
628 }
629
630 /* Creation ok */
631 pcm_device = &chip->device_playback[NUM_STREAM_PLAYBACK_ANA];
632
633 /* Set PCM device name */
634 strcpy(pcm_playback_ana->name, "Analog playback");
635 /* Associate private data to PCM device */
636 pcm_playback_ana->private_data = pcm_device;
637 /* set operators of PCM device */
638 snd_pcm_set_ops(pcm_playback_ana, SNDRV_PCM_STREAM_PLAYBACK,
639 &snd_aw2_playback_ops);
640 /* store PCM device */
641 pcm_device->pcm = pcm_playback_ana;
642 /* give base chip pointer to our internal pcm device
643 structure */
644 pcm_device->chip = chip;
645 /* Give stream number to PCM device */
646 pcm_device->stream_number = NUM_STREAM_PLAYBACK_ANA;
647
648 /* pre-allocation of buffers */
649 /* Preallocate continuous pages. */
650 err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
651 SNDRV_DMA_TYPE_DEV,
652 snd_dma_pci_data
653 (chip->pci),
654 64 * 1024, 64 * 1024);
655 if (err)
656 printk(KERN_ERR "aw2: snd_pcm_lib_preallocate_pages_for_all "
657 "error (0x%X)\n", err);
658
659 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
660 &pcm_playback_num);
661
662 if (err < 0) {
663 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
664 return err;
665 }
666 /* Creation ok */
667 pcm_device = &chip->device_playback[NUM_STREAM_PLAYBACK_DIG];
668
669 /* Set PCM device name */
670 strcpy(pcm_playback_num->name, "Digital playback");
671 /* Associate private data to PCM device */
672 pcm_playback_num->private_data = pcm_device;
673 /* set operators of PCM device */
674 snd_pcm_set_ops(pcm_playback_num, SNDRV_PCM_STREAM_PLAYBACK,
675 &snd_aw2_playback_ops);
676 /* store PCM device */
677 pcm_device->pcm = pcm_playback_num;
678 /* give base chip pointer to our internal pcm device
679 structure */
680 pcm_device->chip = chip;
681 /* Give stream number to PCM device */
682 pcm_device->stream_number = NUM_STREAM_PLAYBACK_DIG;
683
684 /* pre-allocation of buffers */
685 /* Preallocate continuous pages. */
686 err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
687 SNDRV_DMA_TYPE_DEV,
688 snd_dma_pci_data
689 (chip->pci),
690 64 * 1024, 64 * 1024);
691 if (err)
692 printk(KERN_ERR
693 "aw2: snd_pcm_lib_preallocate_pages_for_all error "
694 "(0x%X)\n", err);
695
696
697
698 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
699 &pcm_capture);
700
701 if (err < 0) {
702 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err);
703 return err;
704 }
705
706 /* Creation ok */
707 pcm_device = &chip->device_capture[NUM_STREAM_CAPTURE_ANA];
708
709 /* Set PCM device name */
710 strcpy(pcm_capture->name, "Capture");
711 /* Associate private data to PCM device */
712 pcm_capture->private_data = pcm_device;
713 /* set operators of PCM device */
714 snd_pcm_set_ops(pcm_capture, SNDRV_PCM_STREAM_CAPTURE,
715 &snd_aw2_capture_ops);
716 /* store PCM device */
717 pcm_device->pcm = pcm_capture;
718 /* give base chip pointer to our internal pcm device
719 structure */
720 pcm_device->chip = chip;
721 /* Give stream number to PCM device */
722 pcm_device->stream_number = NUM_STREAM_CAPTURE_ANA;
723
724 /* pre-allocation of buffers */
725 /* Preallocate continuous pages. */
726 err = snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
727 SNDRV_DMA_TYPE_DEV,
728 snd_dma_pci_data
729 (chip->pci),
730 64 * 1024, 64 * 1024);
731 if (err)
732 printk(KERN_ERR
733 "aw2: snd_pcm_lib_preallocate_pages_for_all error "
734 "(0x%X)\n", err);
735
736
737 /* Create control */
738 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
739 if (err < 0) {
740 printk(KERN_ERR "aw2: snd_ctl_add error (0x%X)\n", err);
741 return err;
742 }
743
744 return 0;
745}
746
747static int snd_aw2_control_switch_capture_info(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_info *uinfo)
749{
750 static char *texts[2] = {
751 "Analog", "Digital"
752 };
753 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
754 uinfo->count = 1;
755 uinfo->value.enumerated.items = 2;
756 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) {
757 uinfo->value.enumerated.item =
758 uinfo->value.enumerated.items - 1;
759 }
760 strcpy(uinfo->value.enumerated.name,
761 texts[uinfo->value.enumerated.item]);
762 return 0;
763}
764
765static int snd_aw2_control_switch_capture_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value
767 *ucontrol)
768{
769 struct aw2 *chip = snd_kcontrol_chip(kcontrol);
770 if (snd_aw2_saa7146_is_using_digital_input(&chip->saa7146))
771 ucontrol->value.enumerated.item[0] = CTL_ROUTE_DIGITAL;
772 else
773 ucontrol->value.enumerated.item[0] = CTL_ROUTE_ANALOG;
774 return 0;
775}
776
777static int snd_aw2_control_switch_capture_put(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value
779 *ucontrol)
780{
781 struct aw2 *chip = snd_kcontrol_chip(kcontrol);
782 int changed = 0;
783 int is_disgital =
784 snd_aw2_saa7146_is_using_digital_input(&chip->saa7146);
785
786 if (((ucontrol->value.integer.value[0] == CTL_ROUTE_DIGITAL)
787 && !is_disgital)
788 || ((ucontrol->value.integer.value[0] == CTL_ROUTE_ANALOG)
789 && is_disgital)) {
790 snd_aw2_saa7146_use_digital_input(&chip->saa7146, !is_disgital);
791 changed = 1;
792 }
793 return changed;
794}
diff --git a/sound/pci/aw2/aw2-saa7146.c b/sound/pci/aw2/aw2-saa7146.c
new file mode 100644
index 000000000000..6a3891ab69dd
--- /dev/null
+++ b/sound/pci/aw2/aw2-saa7146.c
@@ -0,0 +1,465 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 *
6 * This file is part of the Audiowerk2 ALSA driver
7 *
8 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.
11 *
12 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 *****************************************************************************/
23
24#define AW2_SAA7146_M
25
26#include <linux/init.h>
27#include <linux/pci.h>
28#include <linux/slab.h>
29#include <linux/interrupt.h>
30#include <linux/delay.h>
31#include <asm/system.h>
32#include <asm/io.h>
33#include <sound/core.h>
34#include <sound/initval.h>
35#include <sound/pcm.h>
36#include <sound/pcm_params.h>
37
38#include "saa7146.h"
39#include "aw2-saa7146.h"
40
41#include "aw2-tsl.c"
42
43#define WRITEREG(value, addr) writel((value), chip->base_addr + (addr))
44#define READREG(addr) readl(chip->base_addr + (addr))
45
46static struct snd_aw2_saa7146_cb_param
47 arr_substream_it_playback_cb[NB_STREAM_PLAYBACK];
48static struct snd_aw2_saa7146_cb_param
49 arr_substream_it_capture_cb[NB_STREAM_CAPTURE];
50
51static int snd_aw2_saa7146_get_limit(int size);
52
53/* chip-specific destructor */
54int snd_aw2_saa7146_free(struct snd_aw2_saa7146 *chip)
55{
56 /* disable all irqs */
57 WRITEREG(0, IER);
58
59 /* reset saa7146 */
60 WRITEREG((MRST_N << 16), MC1);
61
62 /* Unset base addr */
63 chip->base_addr = NULL;
64
65 return 0;
66}
67
68void snd_aw2_saa7146_setup(struct snd_aw2_saa7146 *chip,
69 void __iomem *pci_base_addr)
70{
71 /* set PCI burst/threshold
72
73 Burst length definition
74 VALUE BURST LENGTH
75 000 1 Dword
76 001 2 Dwords
77 010 4 Dwords
78 011 8 Dwords
79 100 16 Dwords
80 101 32 Dwords
81 110 64 Dwords
82 111 128 Dwords
83
84 Threshold definition
85 VALUE WRITE MODE READ MODE
86 00 1 Dword of valid data 1 empty Dword
87 01 4 Dwords of valid data 4 empty Dwords
88 10 8 Dwords of valid data 8 empty Dwords
89 11 16 Dwords of valid data 16 empty Dwords */
90
91 unsigned int acon2;
92 unsigned int acon1 = 0;
93 int i;
94
95 /* Set base addr */
96 chip->base_addr = pci_base_addr;
97
98 /* disable all irqs */
99 WRITEREG(0, IER);
100
101 /* reset saa7146 */
102 WRITEREG((MRST_N << 16), MC1);
103
104 /* enable audio interface */
105#ifdef __BIG_ENDIAN
106 acon1 |= A1_SWAP;
107 acon1 |= A2_SWAP;
108#endif
109 /* WS0_CTRL, WS0_SYNC: input TSL1, I2S */
110
111 /* At initialization WS1 and WS2 are disbaled (configured as input */
112 acon1 |= 0 * WS1_CTRL;
113 acon1 |= 0 * WS2_CTRL;
114
115 /* WS4 is not used. So it must not restart A2.
116 This is why it is configured as output (force to low) */
117 acon1 |= 3 * WS4_CTRL;
118
119 /* WS3_CTRL, WS3_SYNC: output TSL2, I2S */
120 acon1 |= 2 * WS3_CTRL;
121
122 /* A1 and A2 are active and asynchronous */
123 acon1 |= 3 * AUDIO_MODE;
124 WRITEREG(acon1, ACON1);
125
126 /* The following comes from original windows driver.
127 It is needed to have a correct behavior of input and output
128 simultenously, but I don't know why ! */
129 WRITEREG(3 * (BurstA1_in) + 3 * (ThreshA1_in) +
130 3 * (BurstA1_out) + 3 * (ThreshA1_out) +
131 3 * (BurstA2_out) + 3 * (ThreshA2_out), PCI_BT_A);
132
133 /* enable audio port pins */
134 WRITEREG((EAP << 16) | EAP, MC1);
135
136 /* enable I2C */
137 WRITEREG((EI2C << 16) | EI2C, MC1);
138 /* enable interrupts */
139 WRITEREG(A1_out | A2_out | A1_in | IIC_S | IIC_E, IER);
140
141 /* audio configuration */
142 acon2 = A2_CLKSRC | BCLK1_OEN;
143 WRITEREG(acon2, ACON2);
144
145 /* By default use analog input */
146 snd_aw2_saa7146_use_digital_input(chip, 0);
147
148 /* TSL setup */
149 for (i = 0; i < 8; ++i) {
150 WRITEREG(tsl1[i], TSL1 + (i * 4));
151 WRITEREG(tsl2[i], TSL2 + (i * 4));
152 }
153
154}
155
156void snd_aw2_saa7146_pcm_init_playback(struct snd_aw2_saa7146 *chip,
157 int stream_number,
158 unsigned long dma_addr,
159 unsigned long period_size,
160 unsigned long buffer_size)
161{
162 unsigned long dw_page, dw_limit;
163
164 /* Configure DMA for substream
165 Configuration informations: ALSA has allocated continuous memory
166 pages. So we don't need to use MMU of saa7146.
167 */
168
169 /* No MMU -> nothing to do with PageA1, we only configure the limit of
170 PageAx_out register */
171 /* Disable MMU */
172 dw_page = (0L << 11);
173
174 /* Configure Limit for DMA access.
175 The limit register defines an address limit, which generates
176 an interrupt if passed by the actual PCI address pointer.
177 '0001' means an interrupt will be generated if the lower
178 6 bits (64 bytes) of the PCI address are zero. '0010'
179 defines a limit of 128 bytes, '0011' one of 256 bytes, and
180 so on up to 1 Mbyte defined by '1111'. This interrupt range
181 can be calculated as follows:
182 Range = 2^(5 + Limit) bytes.
183 */
184 dw_limit = snd_aw2_saa7146_get_limit(period_size);
185 dw_page |= (dw_limit << 4);
186
187 if (stream_number == 0) {
188 WRITEREG(dw_page, PageA2_out);
189
190 /* Base address for DMA transfert. */
191 /* This address has been reserved by ALSA. */
192 /* This is a physical address */
193 WRITEREG(dma_addr, BaseA2_out);
194
195 /* Define upper limit for DMA access */
196 WRITEREG(dma_addr + buffer_size, ProtA2_out);
197
198 } else if (stream_number == 1) {
199 WRITEREG(dw_page, PageA1_out);
200
201 /* Base address for DMA transfert. */
202 /* This address has been reserved by ALSA. */
203 /* This is a physical address */
204 WRITEREG(dma_addr, BaseA1_out);
205
206 /* Define upper limit for DMA access */
207 WRITEREG(dma_addr + buffer_size, ProtA1_out);
208 } else {
209 printk(KERN_ERR
210 "aw2: snd_aw2_saa7146_pcm_init_playback: "
211 "Substream number is not 0 or 1 -> not managed\n");
212 }
213}
214
215void snd_aw2_saa7146_pcm_init_capture(struct snd_aw2_saa7146 *chip,
216 int stream_number, unsigned long dma_addr,
217 unsigned long period_size,
218 unsigned long buffer_size)
219{
220 unsigned long dw_page, dw_limit;
221
222 /* Configure DMA for substream
223 Configuration informations: ALSA has allocated continuous memory
224 pages. So we don't need to use MMU of saa7146.
225 */
226
227 /* No MMU -> nothing to do with PageA1, we only configure the limit of
228 PageAx_out register */
229 /* Disable MMU */
230 dw_page = (0L << 11);
231
232 /* Configure Limit for DMA access.
233 The limit register defines an address limit, which generates
234 an interrupt if passed by the actual PCI address pointer.
235 '0001' means an interrupt will be generated if the lower
236 6 bits (64 bytes) of the PCI address are zero. '0010'
237 defines a limit of 128 bytes, '0011' one of 256 bytes, and
238 so on up to 1 Mbyte defined by '1111'. This interrupt range
239 can be calculated as follows:
240 Range = 2^(5 + Limit) bytes.
241 */
242 dw_limit = snd_aw2_saa7146_get_limit(period_size);
243 dw_page |= (dw_limit << 4);
244
245 if (stream_number == 0) {
246 WRITEREG(dw_page, PageA1_in);
247
248 /* Base address for DMA transfert. */
249 /* This address has been reserved by ALSA. */
250 /* This is a physical address */
251 WRITEREG(dma_addr, BaseA1_in);
252
253 /* Define upper limit for DMA access */
254 WRITEREG(dma_addr + buffer_size, ProtA1_in);
255 } else {
256 printk(KERN_ERR
257 "aw2: snd_aw2_saa7146_pcm_init_capture: "
258 "Substream number is not 0 -> not managed\n");
259 }
260}
261
262void snd_aw2_saa7146_define_it_playback_callback(unsigned int stream_number,
263 snd_aw2_saa7146_it_cb
264 p_it_callback,
265 void *p_callback_param)
266{
267 if (stream_number < NB_STREAM_PLAYBACK) {
268 arr_substream_it_playback_cb[stream_number].p_it_callback =
269 (snd_aw2_saa7146_it_cb) p_it_callback;
270 arr_substream_it_playback_cb[stream_number].p_callback_param =
271 (void *)p_callback_param;
272 }
273}
274
275void snd_aw2_saa7146_define_it_capture_callback(unsigned int stream_number,
276 snd_aw2_saa7146_it_cb
277 p_it_callback,
278 void *p_callback_param)
279{
280 if (stream_number < NB_STREAM_CAPTURE) {
281 arr_substream_it_capture_cb[stream_number].p_it_callback =
282 (snd_aw2_saa7146_it_cb) p_it_callback;
283 arr_substream_it_capture_cb[stream_number].p_callback_param =
284 (void *)p_callback_param;
285 }
286}
287
288void snd_aw2_saa7146_pcm_trigger_start_playback(struct snd_aw2_saa7146 *chip,
289 int stream_number)
290{
291 unsigned int acon1 = 0;
292 /* In aw8 driver, dma transfert is always active. It is
293 started and stopped in a larger "space" */
294 acon1 = READREG(ACON1);
295 if (stream_number == 0) {
296 WRITEREG((TR_E_A2_OUT << 16) | TR_E_A2_OUT, MC1);
297
298 /* WS2_CTRL, WS2_SYNC: output TSL2, I2S */
299 acon1 |= 2 * WS2_CTRL;
300 WRITEREG(acon1, ACON1);
301
302 } else if (stream_number == 1) {
303 WRITEREG((TR_E_A1_OUT << 16) | TR_E_A1_OUT, MC1);
304
305 /* WS1_CTRL, WS1_SYNC: output TSL1, I2S */
306 acon1 |= 1 * WS1_CTRL;
307 WRITEREG(acon1, ACON1);
308 }
309}
310
311void snd_aw2_saa7146_pcm_trigger_stop_playback(struct snd_aw2_saa7146 *chip,
312 int stream_number)
313{
314 unsigned int acon1 = 0;
315 acon1 = READREG(ACON1);
316 if (stream_number == 0) {
317 /* WS2_CTRL, WS2_SYNC: output TSL2, I2S */
318 acon1 &= ~(3 * WS2_CTRL);
319 WRITEREG(acon1, ACON1);
320
321 WRITEREG((TR_E_A2_OUT << 16), MC1);
322 } else if (stream_number == 1) {
323 /* WS1_CTRL, WS1_SYNC: output TSL1, I2S */
324 acon1 &= ~(3 * WS1_CTRL);
325 WRITEREG(acon1, ACON1);
326
327 WRITEREG((TR_E_A1_OUT << 16), MC1);
328 }
329}
330
331void snd_aw2_saa7146_pcm_trigger_start_capture(struct snd_aw2_saa7146 *chip,
332 int stream_number)
333{
334 /* In aw8 driver, dma transfert is always active. It is
335 started and stopped in a larger "space" */
336 if (stream_number == 0)
337 WRITEREG((TR_E_A1_IN << 16) | TR_E_A1_IN, MC1);
338}
339
340void snd_aw2_saa7146_pcm_trigger_stop_capture(struct snd_aw2_saa7146 *chip,
341 int stream_number)
342{
343 if (stream_number == 0)
344 WRITEREG((TR_E_A1_IN << 16), MC1);
345}
346
347irqreturn_t snd_aw2_saa7146_interrupt(int irq, void *dev_id)
348{
349 unsigned int isr;
350 unsigned int iicsta;
351 struct snd_aw2_saa7146 *chip = dev_id;
352
353 isr = READREG(ISR);
354 if (!isr)
355 return IRQ_NONE;
356
357 WRITEREG(isr, ISR);
358
359 if (isr & (IIC_S | IIC_E)) {
360 iicsta = READREG(IICSTA);
361 WRITEREG(0x100, IICSTA);
362 }
363
364 if (isr & A1_out) {
365 if (arr_substream_it_playback_cb[1].p_it_callback != NULL) {
366 arr_substream_it_playback_cb[1].
367 p_it_callback(arr_substream_it_playback_cb[1].
368 p_callback_param);
369 }
370 }
371 if (isr & A2_out) {
372 if (arr_substream_it_playback_cb[0].p_it_callback != NULL) {
373 arr_substream_it_playback_cb[0].
374 p_it_callback(arr_substream_it_playback_cb[0].
375 p_callback_param);
376 }
377
378 }
379 if (isr & A1_in) {
380 if (arr_substream_it_capture_cb[0].p_it_callback != NULL) {
381 arr_substream_it_capture_cb[0].
382 p_it_callback(arr_substream_it_capture_cb[0].
383 p_callback_param);
384 }
385 }
386 return IRQ_HANDLED;
387}
388
389unsigned int snd_aw2_saa7146_get_hw_ptr_playback(struct snd_aw2_saa7146 *chip,
390 int stream_number,
391 unsigned char *start_addr,
392 unsigned int buffer_size)
393{
394 long pci_adp = 0;
395 size_t ptr = 0;
396
397 if (stream_number == 0) {
398 pci_adp = READREG(PCI_ADP3);
399 ptr = pci_adp - (long)start_addr;
400
401 if (ptr == buffer_size)
402 ptr = 0;
403 }
404 if (stream_number == 1) {
405 pci_adp = READREG(PCI_ADP1);
406 ptr = pci_adp - (size_t) start_addr;
407
408 if (ptr == buffer_size)
409 ptr = 0;
410 }
411 return ptr;
412}
413
414unsigned int snd_aw2_saa7146_get_hw_ptr_capture(struct snd_aw2_saa7146 *chip,
415 int stream_number,
416 unsigned char *start_addr,
417 unsigned int buffer_size)
418{
419 size_t pci_adp = 0;
420 size_t ptr = 0;
421 if (stream_number == 0) {
422 pci_adp = READREG(PCI_ADP2);
423 ptr = pci_adp - (size_t) start_addr;
424
425 if (ptr == buffer_size)
426 ptr = 0;
427 }
428 return ptr;
429}
430
431void snd_aw2_saa7146_use_digital_input(struct snd_aw2_saa7146 *chip,
432 int use_digital)
433{
434 /* FIXME: switch between analog and digital input does not always work.
435 It can produce a kind of white noise. It seams that received data
436 are inverted sometime (endian inversion). Why ? I don't know, maybe
437 a problem of synchronization... However for the time being I have
438 not found the problem. Workaround: switch again (and again) between
439 digital and analog input until it works. */
440 if (use_digital)
441 WRITEREG(0x40, GPIO_CTRL);
442 else
443 WRITEREG(0x50, GPIO_CTRL);
444}
445
446int snd_aw2_saa7146_is_using_digital_input(struct snd_aw2_saa7146 *chip)
447{
448 unsigned int reg_val = READREG(GPIO_CTRL);
449 if ((reg_val & 0xFF) == 0x40)
450 return 1;
451 else
452 return 0;
453}
454
455
456static int snd_aw2_saa7146_get_limit(int size)
457{
458 int limitsize = 32;
459 int limit = 0;
460 while (limitsize < size) {
461 limitsize *= 2;
462 limit++;
463 }
464 return limit;
465}
diff --git a/sound/pci/aw2/aw2-saa7146.h b/sound/pci/aw2/aw2-saa7146.h
new file mode 100644
index 000000000000..5b35e358937f
--- /dev/null
+++ b/sound/pci/aw2/aw2-saa7146.h
@@ -0,0 +1,105 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 *
6 * This file is part of the Audiowerk2 ALSA driver
7 *
8 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.
11 *
12 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 *****************************************************************************/
23
24#ifndef AW2_SAA7146_H
25#define AW2_SAA7146_H
26
27#define NB_STREAM_PLAYBACK 2
28#define NB_STREAM_CAPTURE 1
29
30#define NUM_STREAM_PLAYBACK_ANA 0
31#define NUM_STREAM_PLAYBACK_DIG 1
32
33#define NUM_STREAM_CAPTURE_ANA 0
34
35typedef void (*snd_aw2_saa7146_it_cb) (void *);
36
37struct snd_aw2_saa7146_cb_param {
38 snd_aw2_saa7146_it_cb p_it_callback;
39 void *p_callback_param;
40};
41
42/* definition of the chip-specific record */
43
44struct snd_aw2_saa7146 {
45 void __iomem *base_addr;
46};
47
48extern void snd_aw2_saa7146_setup(struct snd_aw2_saa7146 *chip,
49 void __iomem *pci_base_addr);
50extern int snd_aw2_saa7146_free(struct snd_aw2_saa7146 *chip);
51
52extern void snd_aw2_saa7146_pcm_init_playback(struct snd_aw2_saa7146 *chip,
53 int stream_number,
54 unsigned long dma_addr,
55 unsigned long period_size,
56 unsigned long buffer_size);
57extern void snd_aw2_saa7146_pcm_init_capture(struct snd_aw2_saa7146 *chip,
58 int stream_number,
59 unsigned long dma_addr,
60 unsigned long period_size,
61 unsigned long buffer_size);
62extern void snd_aw2_saa7146_define_it_playback_callback(unsigned int
63 stream_number,
64 snd_aw2_saa7146_it_cb
65 p_it_callback,
66 void *p_callback_param);
67extern void snd_aw2_saa7146_define_it_capture_callback(unsigned int
68 stream_number,
69 snd_aw2_saa7146_it_cb
70 p_it_callback,
71 void *p_callback_param);
72extern void snd_aw2_saa7146_pcm_trigger_start_capture(struct snd_aw2_saa7146
73 *chip, int stream_number);
74extern void snd_aw2_saa7146_pcm_trigger_stop_capture(struct snd_aw2_saa7146
75 *chip, int stream_number);
76
77extern void snd_aw2_saa7146_pcm_trigger_start_playback(struct snd_aw2_saa7146
78 *chip,
79 int stream_number);
80extern void snd_aw2_saa7146_pcm_trigger_stop_playback(struct snd_aw2_saa7146
81 *chip, int stream_number);
82
83extern irqreturn_t snd_aw2_saa7146_interrupt(int irq, void *dev_id);
84extern unsigned int snd_aw2_saa7146_get_hw_ptr_playback(struct snd_aw2_saa7146
85 *chip,
86 int stream_number,
87 unsigned char
88 *start_addr,
89 unsigned int
90 buffer_size);
91extern unsigned int snd_aw2_saa7146_get_hw_ptr_capture(struct snd_aw2_saa7146
92 *chip,
93 int stream_number,
94 unsigned char
95 *start_addr,
96 unsigned int
97 buffer_size);
98
99extern void snd_aw2_saa7146_use_digital_input(struct snd_aw2_saa7146 *chip,
100 int use_digital);
101
102extern int snd_aw2_saa7146_is_using_digital_input(struct snd_aw2_saa7146
103 *chip);
104
105#endif
diff --git a/sound/pci/aw2/aw2-tsl.c b/sound/pci/aw2/aw2-tsl.c
new file mode 100644
index 000000000000..459b0311ea31
--- /dev/null
+++ b/sound/pci/aw2/aw2-tsl.c
@@ -0,0 +1,110 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 * Copyright 1998 Emagic Soft- und Hardware GmbH
6 * Copyright 2002 Martijn Sipkema
7 *
8 * This file is part of the Audiowerk2 ALSA driver
9 *
10 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.
13 *
14 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 * USA.
23 *
24 *****************************************************************************/
25
26#define TSL_WS0 (1UL << 31)
27#define TSL_WS1 (1UL << 30)
28#define TSL_WS2 (1UL << 29)
29#define TSL_WS3 (1UL << 28)
30#define TSL_WS4 (1UL << 27)
31#define TSL_DIS_A1 (1UL << 24)
32#define TSL_SDW_A1 (1UL << 23)
33#define TSL_SIB_A1 (1UL << 22)
34#define TSL_SF_A1 (1UL << 21)
35#define TSL_LF_A1 (1UL << 20)
36#define TSL_BSEL_A1 (1UL << 17)
37#define TSL_DOD_A1 (1UL << 15)
38#define TSL_LOW_A1 (1UL << 14)
39#define TSL_DIS_A2 (1UL << 11)
40#define TSL_SDW_A2 (1UL << 10)
41#define TSL_SIB_A2 (1UL << 9)
42#define TSL_SF_A2 (1UL << 8)
43#define TSL_LF_A2 (1UL << 7)
44#define TSL_BSEL_A2 (1UL << 4)
45#define TSL_DOD_A2 (1UL << 2)
46#define TSL_LOW_A2 (1UL << 1)
47#define TSL_EOS (1UL << 0)
48
49 /* Audiowerk8 hardware setup: */
50 /* WS0, SD4, TSL1 - Analog/ digital in */
51 /* WS1, SD0, TSL1 - Analog out #1, digital out */
52 /* WS2, SD2, TSL1 - Analog out #2 */
53 /* WS3, SD1, TSL2 - Analog out #3 */
54 /* WS4, SD3, TSL2 - Analog out #4 */
55
56 /* Audiowerk8 timing: */
57 /* Timeslot: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | ... */
58
59 /* A1_INPUT: */
60 /* SD4: <_ADC-L_>-------<_ADC-R_>-------< */
61 /* WS0: _______________/---------------\_ */
62
63 /* A1_OUTPUT: */
64 /* SD0: <_1-L___>-------<_1-R___>-------< */
65 /* WS1: _______________/---------------\_ */
66 /* SD2: >-------<_2-L___>-------<_2-R___> */
67 /* WS2: -------\_______________/--------- */
68
69 /* A2_OUTPUT: */
70 /* SD1: <_3-L___>-------<_3-R___>-------< */
71 /* WS3: _______________/---------------\_ */
72 /* SD3: >-------<_4-L___>-------<_4-R___> */
73 /* WS4: -------\_______________/--------- */
74
75static int tsl1[8] = {
76 1 * TSL_SDW_A1 | 3 * TSL_BSEL_A1 |
77 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_LF_A1,
78
79 1 * TSL_SDW_A1 | 2 * TSL_BSEL_A1 |
80 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1,
81
82 0 * TSL_SDW_A1 | 3 * TSL_BSEL_A1 |
83 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1,
84
85 0 * TSL_SDW_A1 | 2 * TSL_BSEL_A1 |
86 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1,
87
88 1 * TSL_SDW_A1 | 1 * TSL_BSEL_A1 |
89 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0,
90
91 1 * TSL_SDW_A1 | 0 * TSL_BSEL_A1 |
92 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0,
93
94 0 * TSL_SDW_A1 | 1 * TSL_BSEL_A1 |
95 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0,
96
97 0 * TSL_SDW_A1 | 0 * TSL_BSEL_A1 | 0 * TSL_DIS_A1 |
98 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0 | TSL_SF_A1 | TSL_EOS,
99};
100
101static int tsl2[8] = {
102 0 * TSL_SDW_A2 | 3 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_LF_A2,
103 0 * TSL_SDW_A2 | 2 * TSL_BSEL_A2 | 2 * TSL_DOD_A2,
104 0 * TSL_SDW_A2 | 3 * TSL_BSEL_A2 | 2 * TSL_DOD_A2,
105 0 * TSL_SDW_A2 | 2 * TSL_BSEL_A2 | 2 * TSL_DOD_A2,
106 0 * TSL_SDW_A2 | 1 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_WS2,
107 0 * TSL_SDW_A2 | 0 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_WS2,
108 0 * TSL_SDW_A2 | 1 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_WS2,
109 0 * TSL_SDW_A2 | 0 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_WS2 | TSL_EOS
110};
diff --git a/sound/pci/aw2/saa7146.h b/sound/pci/aw2/saa7146.h
new file mode 100644
index 000000000000..ce0ab5f9ee9c
--- /dev/null
+++ b/sound/pci/aw2/saa7146.h
@@ -0,0 +1,168 @@
1/*****************************************************************************
2 *
3 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
4 * Jean-Christian Hassler <jhassler@free.fr>
5 *
6 * This file is part of the Audiowerk2 ALSA driver
7 *
8 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.
11 *
12 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 *****************************************************************************/
23
24/* SAA7146 registers */
25#define PCI_BT_A 0x4C
26#define IICTFR 0x8C
27#define IICSTA 0x90
28#define BaseA1_in 0x94
29#define ProtA1_in 0x98
30#define PageA1_in 0x9C
31#define BaseA1_out 0xA0
32#define ProtA1_out 0xA4
33#define PageA1_out 0xA8
34#define BaseA2_in 0xAC
35#define ProtA2_in 0xB0
36#define PageA2_in 0xB4
37#define BaseA2_out 0xB8
38#define ProtA2_out 0xBC
39#define PageA2_out 0xC0
40#define IER 0xDC
41#define GPIO_CTRL 0xE0
42#define ACON1 0xF4
43#define ACON2 0xF8
44#define MC1 0xFC
45#define MC2 0x100
46#define ISR 0x10C
47#define PSR 0x110
48#define SSR 0x114
49#define PCI_ADP1 0x12C
50#define PCI_ADP2 0x130
51#define PCI_ADP3 0x134
52#define PCI_ADP4 0x138
53#define LEVEL_REP 0x140
54#define FB_BUFFER1 0x144
55#define FB_BUFFER2 0x148
56#define TSL1 0x180
57#define TSL2 0x1C0
58
59#define ME (1UL << 11)
60#define LIMIT (1UL << 4)
61#define PV (1UL << 3)
62
63/* PSR/ISR/IER */
64#define PPEF (1UL << 31)
65#define PABO (1UL << 30)
66#define IIC_S (1UL << 17)
67#define IIC_E (1UL << 16)
68#define A2_in (1UL << 15)
69#define A2_out (1UL << 14)
70#define A1_in (1UL << 13)
71#define A1_out (1UL << 12)
72#define AFOU (1UL << 11)
73#define PIN3 (1UL << 6)
74#define PIN2 (1UL << 5)
75#define PIN1 (1UL << 4)
76#define PIN0 (1UL << 3)
77#define ECS (1UL << 2)
78#define EC3S (1UL << 1)
79#define EC0S (1UL << 0)
80
81/* SSR */
82#define PRQ (1UL << 31)
83#define PMA (1UL << 30)
84#define IIC_EA (1UL << 21)
85#define IIC_EW (1UL << 20)
86#define IIC_ER (1UL << 19)
87#define IIC_EL (1UL << 18)
88#define IIC_EF (1UL << 17)
89#define AF2_in (1UL << 10)
90#define AF2_out (1UL << 9)
91#define AF1_in (1UL << 8)
92#define AF1_out (1UL << 7)
93#define EC5S (1UL << 3)
94#define EC4S (1UL << 2)
95#define EC2S (1UL << 1)
96#define EC1S (1UL << 0)
97
98/* PCI_BT_A */
99#define BurstA1_in (1UL << 26)
100#define ThreshA1_in (1UL << 24)
101#define BurstA1_out (1UL << 18)
102#define ThreshA1_out (1UL << 16)
103#define BurstA2_in (1UL << 10)
104#define ThreshA2_in (1UL << 8)
105#define BurstA2_out (1UL << 2)
106#define ThreshA2_out (1UL << 0)
107
108/* MC1 */
109#define MRST_N (1UL << 15)
110#define EAP (1UL << 9)
111#define EI2C (1UL << 8)
112#define TR_E_A2_OUT (1UL << 3)
113#define TR_E_A2_IN (1UL << 2)
114#define TR_E_A1_OUT (1UL << 1)
115#define TR_E_A1_IN (1UL << 0)
116
117/* MC2 */
118#define UPLD_IIC (1UL << 0)
119
120/* ACON1 */
121#define AUDIO_MODE (1UL << 29)
122#define MAXLEVEL (1UL << 22)
123#define A1_SWAP (1UL << 21)
124#define A2_SWAP (1UL << 20)
125#define WS0_CTRL (1UL << 18)
126#define WS0_SYNC (1UL << 16)
127#define WS1_CTRL (1UL << 14)
128#define WS1_SYNC (1UL << 12)
129#define WS2_CTRL (1UL << 10)
130#define WS2_SYNC (1UL << 8)
131#define WS3_CTRL (1UL << 6)
132#define WS3_SYNC (1UL << 4)
133#define WS4_CTRL (1UL << 2)
134#define WS4_SYNC (1UL << 0)
135
136/* ACON2 */
137#define A1_CLKSRC (1UL << 27)
138#define A2_CLKSRC (1UL << 22)
139#define INVERT_BCLK1 (1UL << 21)
140#define INVERT_BCLK2 (1UL << 20)
141#define BCLK1_OEN (1UL << 19)
142#define BCLK2_OEN (1UL << 18)
143
144/* IICSTA */
145#define IICCC (1UL << 8)
146#define ABORT (1UL << 7)
147#define SPERR (1UL << 6)
148#define APERR (1UL << 5)
149#define DTERR (1UL << 4)
150#define DRERR (1UL << 3)
151#define AL (1UL << 2)
152#define ERR (1UL << 1)
153#define BUSY (1UL << 0)
154
155/* IICTFR */
156#define BYTE2 (1UL << 24)
157#define BYTE1 (1UL << 16)
158#define BYTE0 (1UL << 8)
159#define ATRR2 (1UL << 6)
160#define ATRR1 (1UL << 4)
161#define ATRR0 (1UL << 2)
162#define ERR (1UL << 1)
163#define BUSY (1UL << 0)
164
165#define START 3
166#define CONT 2
167#define STOP 1
168#define NOP 0
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 4e71a55120a0..5f63af6b88a2 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -157,8 +157,8 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}");
157 157
158#if DEBUG_CALLS 158#if DEBUG_CALLS
159#define snd_azf3328_dbgcalls(format, args...) printk(format, ##args) 159#define snd_azf3328_dbgcalls(format, args...) printk(format, ##args)
160#define snd_azf3328_dbgcallenter() printk(KERN_ERR "--> %s\n", __FUNCTION__) 160#define snd_azf3328_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__)
161#define snd_azf3328_dbgcallleave() printk(KERN_ERR "<-- %s\n", __FUNCTION__) 161#define snd_azf3328_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__)
162#else 162#else
163#define snd_azf3328_dbgcalls(format, args...) 163#define snd_azf3328_dbgcalls(format, args...)
164#define snd_azf3328_dbgcallenter() 164#define snd_azf3328_dbgcallenter()
@@ -1514,7 +1514,8 @@ snd_azf3328_free(struct snd_azf3328 *chip)
1514 /* well, at least we know how to disable the timer IRQ */ 1514 /* well, at least we know how to disable the timer IRQ */
1515 snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x00); 1515 snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x00);
1516 1516
1517 synchronize_irq(chip->irq); 1517 if (chip->irq >= 0)
1518 synchronize_irq(chip->irq);
1518__end_hw: 1519__end_hw:
1519 snd_azf3328_free_joystick(chip); 1520 snd_azf3328_free_joystick(chip);
1520 if (chip->irq >= 0) 1521 if (chip->irq >= 0)
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 176e0f0e8058..ecbe79b67e43 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -435,22 +435,22 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
435static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb) 435static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb)
436{ 436{
437 unsigned long flags; 437 unsigned long flags;
438 unsigned int enable; 438 unsigned int intr_enable;
439 439
440 spin_lock_irqsave(&emu->emu_lock, flags); 440 spin_lock_irqsave(&emu->emu_lock, flags);
441 enable = inl(emu->port + INTE) | intrenb; 441 intr_enable = inl(emu->port + INTE) | intrenb;
442 outl(enable, emu->port + INTE); 442 outl(intr_enable, emu->port + INTE);
443 spin_unlock_irqrestore(&emu->emu_lock, flags); 443 spin_unlock_irqrestore(&emu->emu_lock, flags);
444} 444}
445 445
446static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb) 446static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb)
447{ 447{
448 unsigned long flags; 448 unsigned long flags;
449 unsigned int enable; 449 unsigned int intr_enable;
450 450
451 spin_lock_irqsave(&emu->emu_lock, flags); 451 spin_lock_irqsave(&emu->emu_lock, flags);
452 enable = inl(emu->port + INTE) & ~intrenb; 452 intr_enable = inl(emu->port + INTE) & ~intrenb;
453 outl(enable, emu->port + INTE); 453 outl(intr_enable, emu->port + INTE);
454 spin_unlock_irqrestore(&emu->emu_lock, flags); 454 spin_unlock_irqrestore(&emu->emu_lock, flags);
455} 455}
456 456
@@ -1114,6 +1114,8 @@ static int snd_ca0106_free(struct snd_ca0106 *chip)
1114 * So we can fix: snd-malloc: Memory leak? pages not freed = 8 1114 * So we can fix: snd-malloc: Memory leak? pages not freed = 8
1115 */ 1115 */
1116 } 1116 }
1117 if (chip->irq >= 0)
1118 free_irq(chip->irq, chip);
1117 // release the data 1119 // release the data
1118#if 1 1120#if 1
1119 if (chip->buffer.area) 1121 if (chip->buffer.area)
@@ -1123,9 +1125,6 @@ static int snd_ca0106_free(struct snd_ca0106 *chip)
1123 // release the i/o port 1125 // release the i/o port
1124 release_and_free_resource(chip->res_port); 1126 release_and_free_resource(chip->res_port);
1125 1127
1126 // release the irq
1127 if (chip->irq >= 0)
1128 free_irq(chip->irq, chip);
1129 pci_disable_device(chip->pci); 1128 pci_disable_device(chip->pci);
1130 kfree(chip); 1129 kfree(chip);
1131 return 0; 1130 return 0;
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index af736869d9b1..3025ed1b6e1e 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -650,19 +650,55 @@ static int __devinit rename_ctl(struct snd_card *card, const char *src, const ch
650 650
651#define ADD_CTLS(emu, ctls) \ 651#define ADD_CTLS(emu, ctls) \
652 do { \ 652 do { \
653 int i, err; \ 653 int i, _err; \
654 for (i = 0; i < ARRAY_SIZE(ctls); i++) { \ 654 for (i = 0; i < ARRAY_SIZE(ctls); i++) { \
655 err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \ 655 _err = snd_ctl_add(card, snd_ctl_new1(&ctls[i], emu)); \
656 if (err < 0) \ 656 if (_err < 0) \
657 return err; \ 657 return _err; \
658 } \ 658 } \
659 } while (0) 659 } while (0)
660 660
661static __devinitdata
662DECLARE_TLV_DB_SCALE(snd_ca0106_master_db_scale, -6375, 50, 1);
663
664static char *slave_vols[] __devinitdata = {
665 "Analog Front Playback Volume",
666 "Analog Rear Playback Volume",
667 "Analog Center/LFE Playback Volume",
668 "Analog Side Playback Volume",
669 "IEC958 Front Playback Volume",
670 "IEC958 Rear Playback Volume",
671 "IEC958 Center/LFE Playback Volume",
672 "IEC958 Unknown Playback Volume",
673 "CAPTURE feedback Playback Volume",
674 NULL
675};
676
677static char *slave_sws[] __devinitdata = {
678 "Analog Front Playback Switch",
679 "Analog Rear Playback Switch",
680 "Analog Center/LFE Playback Switch",
681 "Analog Side Playback Switch",
682 "IEC958 Playback Switch",
683 NULL
684};
685
686static void __devinit add_slaves(struct snd_card *card,
687 struct snd_kcontrol *master, char **list)
688{
689 for (; *list; list++) {
690 struct snd_kcontrol *slave = ctl_find(card, *list);
691 if (slave)
692 snd_ctl_add_slave(master, slave);
693 }
694}
695
661int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) 696int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
662{ 697{
663 int err; 698 int err;
664 struct snd_card *card = emu->card; 699 struct snd_card *card = emu->card;
665 char **c; 700 char **c;
701 struct snd_kcontrol *vmaster;
666 static char *ca0106_remove_ctls[] = { 702 static char *ca0106_remove_ctls[] = {
667 "Master Mono Playback Switch", 703 "Master Mono Playback Switch",
668 "Master Mono Playback Volume", 704 "Master Mono Playback Volume",
@@ -719,6 +755,21 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
719 } 755 }
720 if (emu->details->spi_dac == 1) 756 if (emu->details->spi_dac == 1)
721 ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls); 757 ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls);
758
759 /* Create virtual master controls */
760 vmaster = snd_ctl_make_virtual_master("Master Playback Volume",
761 snd_ca0106_master_db_scale);
762 if (!vmaster)
763 return -ENOMEM;
764 add_slaves(card, vmaster, slave_vols);
765
766 if (emu->details->spi_dac == 1) {
767 vmaster = snd_ctl_make_virtual_master("Master Playback Switch",
768 NULL);
769 if (!vmaster)
770 return -ENOMEM;
771 add_slaves(card, vmaster, slave_sws);
772 }
722 return 0; 773 return 0;
723} 774}
724 775
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 135f30860753..9971b5b7735b 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -2744,12 +2744,13 @@ static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_devic
2744 } 2744 }
2745 2745
2746 for (idx = 0; idx < CM_SAVED_MIXERS; idx++) { 2746 for (idx = 0; idx < CM_SAVED_MIXERS; idx++) {
2747 struct snd_ctl_elem_id id; 2747 struct snd_ctl_elem_id elem_id;
2748 struct snd_kcontrol *ctl; 2748 struct snd_kcontrol *ctl;
2749 memset(&id, 0, sizeof(id)); 2749 memset(&elem_id, 0, sizeof(elem_id));
2750 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2750 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2751 strcpy(id.name, cm_saved_mixer[idx].name); 2751 strcpy(elem_id.name, cm_saved_mixer[idx].name);
2752 if ((ctl = snd_ctl_find_id(cm->card, &id)) != NULL) 2752 ctl = snd_ctl_find_id(cm->card, &elem_id);
2753 if (ctl)
2753 cm->mixer_res_ctl[idx] = ctl; 2754 cm->mixer_res_ctl[idx] = ctl;
2754 } 2755 }
2755 2756
@@ -2932,8 +2933,6 @@ static int snd_cmipci_free(struct cmipci *cm)
2932 /* reset mixer */ 2933 /* reset mixer */
2933 snd_cmipci_mixer_write(cm, 0, 0); 2934 snd_cmipci_mixer_write(cm, 0, 0);
2934 2935
2935 synchronize_irq(cm->irq);
2936
2937 free_irq(cm->irq, cm); 2936 free_irq(cm->irq, cm);
2938 } 2937 }
2939 2938
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 87ddffcd9d89..e214e567dec8 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -2772,6 +2772,9 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
2772 if (chip->irq >= 0) 2772 if (chip->irq >= 0)
2773 free_irq(chip->irq, chip); 2773 free_irq(chip->irq, chip);
2774 2774
2775 if (chip->active_ctrl)
2776 chip->active_ctrl(chip, -chip->amplifier);
2777
2775 for (idx = 0; idx < 5; idx++) { 2778 for (idx = 0; idx < 5; idx++) {
2776 struct snd_cs46xx_region *region = &chip->region.idx[idx]; 2779 struct snd_cs46xx_region *region = &chip->region.idx[idx];
2777 if (region->remap_addr) 2780 if (region->remap_addr)
@@ -2779,9 +2782,6 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
2779 release_and_free_resource(region->resource); 2782 release_and_free_resource(region->resource);
2780 } 2783 }
2781 2784
2782 if (chip->active_ctrl)
2783 chip->active_ctrl(chip, -chip->amplifier);
2784
2785#ifdef CONFIG_SND_CS46XX_NEW_DSP 2785#ifdef CONFIG_SND_CS46XX_NEW_DSP
2786 if (chip->dsp_spos_instance) { 2786 if (chip->dsp_spos_instance) {
2787 cs46xx_dsp_spos_destroy(chip); 2787 cs46xx_dsp_spos_destroy(chip);
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 90ec090792ba..e16dc92e82fb 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -1852,15 +1852,16 @@ static irqreturn_t snd_echo_interrupt(int irq, void *dev_id)
1852static int snd_echo_free(struct echoaudio *chip) 1852static int snd_echo_free(struct echoaudio *chip)
1853{ 1853{
1854 DE_INIT(("Stop DSP...\n")); 1854 DE_INIT(("Stop DSP...\n"));
1855 if (chip->comm_page) { 1855 if (chip->comm_page)
1856 rest_in_peace(chip); 1856 rest_in_peace(chip);
1857 snd_dma_free_pages(&chip->commpage_dma_buf);
1858 }
1859 DE_INIT(("Stopped.\n")); 1857 DE_INIT(("Stopped.\n"));
1860 1858
1861 if (chip->irq >= 0) 1859 if (chip->irq >= 0)
1862 free_irq(chip->irq, chip); 1860 free_irq(chip->irq, chip);
1863 1861
1862 if (chip->comm_page)
1863 snd_dma_free_pages(&chip->commpage_dma_buf);
1864
1864 if (chip->dsp_registers) 1865 if (chip->dsp_registers)
1865 iounmap(chip->dsp_registers); 1866 iounmap(chip->dsp_registers);
1866 1867
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 9a9b977d3cf1..abde5b901884 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1249,11 +1249,6 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1249 if (emu->port) { /* avoid access to already used hardware */ 1249 if (emu->port) { /* avoid access to already used hardware */
1250 snd_emu10k1_fx8010_tram_setup(emu, 0); 1250 snd_emu10k1_fx8010_tram_setup(emu, 0);
1251 snd_emu10k1_done(emu); 1251 snd_emu10k1_done(emu);
1252 /* remove reserved page */
1253 if (emu->reserved_page) {
1254 snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page);
1255 emu->reserved_page = NULL;
1256 }
1257 snd_emu10k1_free_efx(emu); 1252 snd_emu10k1_free_efx(emu);
1258 } 1253 }
1259 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) { 1254 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) {
@@ -1262,6 +1257,14 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1262 } 1257 }
1263 if (emu->emu1010.firmware_thread) 1258 if (emu->emu1010.firmware_thread)
1264 kthread_stop(emu->emu1010.firmware_thread); 1259 kthread_stop(emu->emu1010.firmware_thread);
1260 if (emu->irq >= 0)
1261 free_irq(emu->irq, emu);
1262 /* remove reserved page */
1263 if (emu->reserved_page) {
1264 snd_emu10k1_synth_free(emu,
1265 (struct snd_util_memblk *)emu->reserved_page);
1266 emu->reserved_page = NULL;
1267 }
1265 if (emu->memhdr) 1268 if (emu->memhdr)
1266 snd_util_memhdr_free(emu->memhdr); 1269 snd_util_memhdr_free(emu->memhdr);
1267 if (emu->silent_page.area) 1270 if (emu->silent_page.area)
@@ -1273,8 +1276,6 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1273#ifdef CONFIG_PM 1276#ifdef CONFIG_PM
1274 free_pm_buffer(emu); 1277 free_pm_buffer(emu);
1275#endif 1278#endif
1276 if (emu->irq >= 0)
1277 free_irq(emu->irq, emu);
1278 if (emu->port) 1279 if (emu->port)
1279 pci_release_regions(emu->pci); 1280 pci_release_regions(emu->pci);
1280 if (emu->card_capabilities->ca0151_chip) /* P16V */ 1281 if (emu->card_capabilities->ca0151_chip) /* P16V */
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 5512abd98bd9..491a4a50f869 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -327,22 +327,22 @@ static void snd_emu10k1x_ptr_write(struct emu10k1x *emu,
327static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb) 327static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb)
328{ 328{
329 unsigned long flags; 329 unsigned long flags;
330 unsigned int enable; 330 unsigned int intr_enable;
331 331
332 spin_lock_irqsave(&emu->emu_lock, flags); 332 spin_lock_irqsave(&emu->emu_lock, flags);
333 enable = inl(emu->port + INTE) | intrenb; 333 intr_enable = inl(emu->port + INTE) | intrenb;
334 outl(enable, emu->port + INTE); 334 outl(intr_enable, emu->port + INTE);
335 spin_unlock_irqrestore(&emu->emu_lock, flags); 335 spin_unlock_irqrestore(&emu->emu_lock, flags);
336} 336}
337 337
338static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb) 338static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb)
339{ 339{
340 unsigned long flags; 340 unsigned long flags;
341 unsigned int enable; 341 unsigned int intr_enable;
342 342
343 spin_lock_irqsave(&emu->emu_lock, flags); 343 spin_lock_irqsave(&emu->emu_lock, flags);
344 enable = inl(emu->port + INTE) & ~intrenb; 344 intr_enable = inl(emu->port + INTE) & ~intrenb;
345 outl(enable, emu->port + INTE); 345 outl(intr_enable, emu->port + INTE);
346 spin_unlock_irqrestore(&emu->emu_lock, flags); 346 spin_unlock_irqrestore(&emu->emu_lock, flags);
347} 347}
348 348
@@ -754,13 +754,13 @@ static int snd_emu10k1x_free(struct emu10k1x *chip)
754 // disable audio 754 // disable audio
755 outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); 755 outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG);
756 756
757 // release the i/o port 757 /* release the irq */
758 release_and_free_resource(chip->res_port);
759
760 // release the irq
761 if (chip->irq >= 0) 758 if (chip->irq >= 0)
762 free_irq(chip->irq, chip); 759 free_irq(chip->irq, chip);
763 760
761 // release the i/o port
762 release_and_free_resource(chip->res_port);
763
764 // release the DMA 764 // release the DMA
765 if (chip->dma_buffer.area) { 765 if (chip->dma_buffer.area) {
766 snd_dma_free_pages(&chip->dma_buffer); 766 snd_dma_free_pages(&chip->dma_buffer);
@@ -795,9 +795,9 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id)
795 795
796 // capture interrupt 796 // capture interrupt
797 if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { 797 if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) {
798 struct emu10k1x_voice *pvoice = &chip->capture_voice; 798 struct emu10k1x_voice *cap_voice = &chip->capture_voice;
799 if (pvoice->use) 799 if (cap_voice->use)
800 snd_emu10k1x_pcm_interrupt(chip, pvoice); 800 snd_emu10k1x_pcm_interrupt(chip, cap_voice);
801 else 801 else
802 snd_emu10k1x_intr_disable(chip, 802 snd_emu10k1x_intr_disable(chip,
803 INTE_CAP_0_LOOP | 803 INTE_CAP_0_LOOP |
diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c
index f3caa3f890c6..216f9748aff5 100644
--- a/sound/pci/emu10k1/emuproc.c
+++ b/sound/pci/emu10k1/emuproc.c
@@ -412,7 +412,7 @@ static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
412 struct snd_info_buffer *buffer) 412 struct snd_info_buffer *buffer)
413{ 413{
414 struct snd_emu10k1 *emu = entry->private_data; 414 struct snd_emu10k1 *emu = entry->private_data;
415 int value; 415 u32 value;
416 unsigned long flags; 416 unsigned long flags;
417 int i; 417 int i;
418 snd_iprintf(buffer, "EMU1010 Registers:\n\n"); 418 snd_iprintf(buffer, "EMU1010 Registers:\n\n");
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 72d85a5ae6a0..fbf1124f7c79 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -1635,20 +1635,20 @@ static int __devinit snd_ensoniq_1371_mixer(struct ensoniq *ensoniq,
1635 if (has_spdif > 0 || 1635 if (has_spdif > 0 ||
1636 (!has_spdif && es1371_quirk_lookup(ensoniq, es1371_spdif_present))) { 1636 (!has_spdif && es1371_quirk_lookup(ensoniq, es1371_spdif_present))) {
1637 struct snd_kcontrol *kctl; 1637 struct snd_kcontrol *kctl;
1638 int i, index = 0; 1638 int i, is_spdif = 0;
1639 1639
1640 ensoniq->spdif_default = ensoniq->spdif_stream = 1640 ensoniq->spdif_default = ensoniq->spdif_stream =
1641 SNDRV_PCM_DEFAULT_CON_SPDIF; 1641 SNDRV_PCM_DEFAULT_CON_SPDIF;
1642 outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS)); 1642 outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS));
1643 1643
1644 if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF) 1644 if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF)
1645 index++; 1645 is_spdif++;
1646 1646
1647 for (i = 0; i < ARRAY_SIZE(snd_es1371_mixer_spdif); i++) { 1647 for (i = 0; i < ARRAY_SIZE(snd_es1371_mixer_spdif); i++) {
1648 kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq); 1648 kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq);
1649 if (!kctl) 1649 if (!kctl)
1650 return -ENOMEM; 1650 return -ENOMEM;
1651 kctl->id.index = index; 1651 kctl->id.index = is_spdif;
1652 err = snd_ctl_add(card, kctl); 1652 err = snd_ctl_add(card, kctl);
1653 if (err < 0) 1653 if (err < 0)
1654 return err; 1654 return err;
@@ -1910,7 +1910,8 @@ static int snd_ensoniq_free(struct ensoniq *ensoniq)
1910 outl(0, ES_REG(ensoniq, CONTROL)); /* switch everything off */ 1910 outl(0, ES_REG(ensoniq, CONTROL)); /* switch everything off */
1911 outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */ 1911 outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */
1912#endif 1912#endif
1913 synchronize_irq(ensoniq->irq); 1913 if (ensoniq->irq >= 0)
1914 synchronize_irq(ensoniq->irq);
1914 pci_set_power_state(ensoniq->pci, 3); 1915 pci_set_power_state(ensoniq->pci, 3);
1915 __hw_end: 1916 __hw_end:
1916#ifdef CHIP1370 1917#ifdef CHIP1370
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 1a314fa99c45..84fac1fbf103 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1488,7 +1488,6 @@ static int es1938_suspend(struct pci_dev *pci, pm_message_t state)
1488 1488
1489 outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ 1489 outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
1490 if (chip->irq >= 0) { 1490 if (chip->irq >= 0) {
1491 synchronize_irq(chip->irq);
1492 free_irq(chip->irq, chip); 1491 free_irq(chip->irq, chip);
1493 chip->irq = -1; 1492 chip->irq = -1;
1494 } 1493 }
@@ -1578,10 +1577,8 @@ static int snd_es1938_free(struct es1938 *chip)
1578 1577
1579 snd_es1938_free_gameport(chip); 1578 snd_es1938_free_gameport(chip);
1580 1579
1581 if (chip->irq >= 0) { 1580 if (chip->irq >= 0)
1582 synchronize_irq(chip->irq);
1583 free_irq(chip->irq, chip); 1581 free_irq(chip->irq, chip);
1584 }
1585 pci_release_regions(chip->pci); 1582 pci_release_regions(chip->pci);
1586 pci_disable_device(chip->pci); 1583 pci_disable_device(chip->pci);
1587 kfree(chip); 1584 kfree(chip);
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 7d911a18c082..1bf298d214b9 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -1827,6 +1827,22 @@ snd_es1968_pcm(struct es1968 *chip, int device)
1827 1827
1828 return 0; 1828 return 0;
1829} 1829}
1830/*
1831 * suppress jitter on some maestros when playing stereo
1832 */
1833static void snd_es1968_suppress_jitter(struct es1968 *chip, struct esschan *es)
1834{
1835 unsigned int cp1;
1836 unsigned int cp2;
1837 unsigned int diff;
1838
1839 cp1 = __apu_get_register(chip, 0, 5);
1840 cp2 = __apu_get_register(chip, 1, 5);
1841 diff = (cp1 > cp2 ? cp1 - cp2 : cp2 - cp1);
1842
1843 if (diff > 1)
1844 __maestro_write(chip, IDR0_DATA_PORT, cp1);
1845}
1830 1846
1831/* 1847/*
1832 * update pointer 1848 * update pointer
@@ -1948,8 +1964,11 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id)
1948 struct esschan *es; 1964 struct esschan *es;
1949 spin_lock(&chip->substream_lock); 1965 spin_lock(&chip->substream_lock);
1950 list_for_each_entry(es, &chip->substream_list, list) { 1966 list_for_each_entry(es, &chip->substream_list, list) {
1951 if (es->running) 1967 if (es->running) {
1952 snd_es1968_update_pcm(chip, es); 1968 snd_es1968_update_pcm(chip, es);
1969 if (es->fmt & ESS_FMT_STEREO)
1970 snd_es1968_suppress_jitter(chip, es);
1971 }
1953 } 1972 }
1954 spin_unlock(&chip->substream_lock); 1973 spin_unlock(&chip->substream_lock);
1955 if (chip->in_measurement) { 1974 if (chip->in_measurement) {
@@ -1972,7 +1991,7 @@ snd_es1968_mixer(struct es1968 *chip)
1972{ 1991{
1973 struct snd_ac97_bus *pbus; 1992 struct snd_ac97_bus *pbus;
1974 struct snd_ac97_template ac97; 1993 struct snd_ac97_template ac97;
1975 struct snd_ctl_elem_id id; 1994 struct snd_ctl_elem_id elem_id;
1976 int err; 1995 int err;
1977 static struct snd_ac97_bus_ops ops = { 1996 static struct snd_ac97_bus_ops ops = {
1978 .write = snd_es1968_ac97_write, 1997 .write = snd_es1968_ac97_write,
@@ -1989,14 +2008,14 @@ snd_es1968_mixer(struct es1968 *chip)
1989 return err; 2008 return err;
1990 2009
1991 /* attach master switch / volumes for h/w volume control */ 2010 /* attach master switch / volumes for h/w volume control */
1992 memset(&id, 0, sizeof(id)); 2011 memset(&elem_id, 0, sizeof(elem_id));
1993 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2012 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1994 strcpy(id.name, "Master Playback Switch"); 2013 strcpy(elem_id.name, "Master Playback Switch");
1995 chip->master_switch = snd_ctl_find_id(chip->card, &id); 2014 chip->master_switch = snd_ctl_find_id(chip->card, &elem_id);
1996 memset(&id, 0, sizeof(id)); 2015 memset(&elem_id, 0, sizeof(elem_id));
1997 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2016 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1998 strcpy(id.name, "Master Playback Volume"); 2017 strcpy(elem_id.name, "Master Playback Volume");
1999 chip->master_volume = snd_ctl_find_id(chip->card, &id); 2018 chip->master_volume = snd_ctl_find_id(chip->card, &elem_id);
2000 2019
2001 return 0; 2020 return 0;
2002} 2021}
@@ -2456,7 +2475,8 @@ static inline void snd_es1968_free_gameport(struct es1968 *chip) { }
2456static int snd_es1968_free(struct es1968 *chip) 2475static int snd_es1968_free(struct es1968 *chip)
2457{ 2476{
2458 if (chip->io_port) { 2477 if (chip->io_port) {
2459 synchronize_irq(chip->irq); 2478 if (chip->irq >= 0)
2479 synchronize_irq(chip->irq);
2460 outw(1, chip->io_port + 0x04); /* clear WP interrupts */ 2480 outw(1, chip->io_port + 0x04); /* clear WP interrupts */
2461 outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */ 2481 outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */
2462 } 2482 }
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 4c300e6149fc..c129f9e2072c 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1285,7 +1285,6 @@ static int wait_for_codec(struct fm801 *chip, unsigned int codec_id,
1285 1285
1286static int snd_fm801_chip_init(struct fm801 *chip, int resume) 1286static int snd_fm801_chip_init(struct fm801 *chip, int resume)
1287{ 1287{
1288 int id;
1289 unsigned short cmdw; 1288 unsigned short cmdw;
1290 1289
1291 if (chip->tea575x_tuner & 0x0010) 1290 if (chip->tea575x_tuner & 0x0010)
@@ -1310,13 +1309,14 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume)
1310 } else { 1309 } else {
1311 /* my card has the secondary codec */ 1310 /* my card has the secondary codec */
1312 /* at address #3, so the loop is inverted */ 1311 /* at address #3, so the loop is inverted */
1313 for (id = 3; id > 0; id--) { 1312 int i;
1314 if (! wait_for_codec(chip, id, AC97_VENDOR_ID1, 1313 for (i = 3; i > 0; i--) {
1314 if (!wait_for_codec(chip, i, AC97_VENDOR_ID1,
1315 msecs_to_jiffies(50))) { 1315 msecs_to_jiffies(50))) {
1316 cmdw = inw(FM801_REG(chip, AC97_DATA)); 1316 cmdw = inw(FM801_REG(chip, AC97_DATA));
1317 if (cmdw != 0xffff && cmdw != 0) { 1317 if (cmdw != 0xffff && cmdw != 0) {
1318 chip->secondary = 1; 1318 chip->secondary = 1;
1319 chip->secondary_addr = id; 1319 chip->secondary_addr = i;
1320 break; 1320 break;
1321 } 1321 }
1322 } 1322 }
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 9e0d8a1268aa..ab0c726d648e 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -2,7 +2,7 @@ snd-hda-intel-y := hda_intel.o
2# since snd-hda-intel is the only driver using hda-codec, 2# since snd-hda-intel is the only driver using hda-codec,
3# merge it into a single module although it was originally 3# merge it into a single module although it was originally
4# designed to be individual modules 4# designed to be individual modules
5snd-hda-intel-y += hda_codec.o vmaster.o 5snd-hda-intel-y += hda_codec.o
6snd-hda-intel-$(CONFIG_PROC_FS) += hda_proc.o 6snd-hda-intel-$(CONFIG_PROC_FS) += hda_proc.o
7snd-hda-intel-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 7snd-hda-intel-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
8snd-hda-intel-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o 8snd-hda-intel-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 37c413923db8..a6be6e3e8716 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -31,6 +31,7 @@
31#include <sound/initval.h> 31#include <sound/initval.h>
32#include "hda_local.h" 32#include "hda_local.h"
33#include <sound/hda_hwdep.h> 33#include <sound/hda_hwdep.h>
34#include "hda_patch.h" /* codec presets */
34 35
35#ifdef CONFIG_SND_HDA_POWER_SAVE 36#ifdef CONFIG_SND_HDA_POWER_SAVE
36/* define this option here to hide as static */ 37/* define this option here to hide as static */
@@ -51,21 +52,50 @@ struct hda_vendor_id {
51 52
52/* codec vendor labels */ 53/* codec vendor labels */
53static struct hda_vendor_id hda_vendor_ids[] = { 54static struct hda_vendor_id hda_vendor_ids[] = {
54 { 0x10ec, "Realtek" }, 55 { 0x1002, "ATI" },
55 { 0x1057, "Motorola" }, 56 { 0x1057, "Motorola" },
57 { 0x1095, "Silicon Image" },
58 { 0x10ec, "Realtek" },
56 { 0x1106, "VIA" }, 59 { 0x1106, "VIA" },
57 { 0x111d, "IDT" }, 60 { 0x111d, "IDT" },
61 { 0x11c1, "LSI" },
58 { 0x11d4, "Analog Devices" }, 62 { 0x11d4, "Analog Devices" },
59 { 0x13f6, "C-Media" }, 63 { 0x13f6, "C-Media" },
60 { 0x14f1, "Conexant" }, 64 { 0x14f1, "Conexant" },
65 { 0x17e8, "Chrontel" },
66 { 0x1854, "LG" },
61 { 0x434d, "C-Media" }, 67 { 0x434d, "C-Media" },
62 { 0x8384, "SigmaTel" }, 68 { 0x8384, "SigmaTel" },
63 {} /* terminator */ 69 {} /* terminator */
64}; 70};
65 71
66/* codec presets */ 72static const struct hda_codec_preset *hda_preset_tables[] = {
67#include "hda_patch.h" 73#ifdef CONFIG_SND_HDA_CODEC_REALTEK
68 74 snd_hda_preset_realtek,
75#endif
76#ifdef CONFIG_SND_HDA_CODEC_CMEDIA
77 snd_hda_preset_cmedia,
78#endif
79#ifdef CONFIG_SND_HDA_CODEC_ANALOG
80 snd_hda_preset_analog,
81#endif
82#ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
83 snd_hda_preset_sigmatel,
84#endif
85#ifdef CONFIG_SND_HDA_CODEC_SI3054
86 snd_hda_preset_si3054,
87#endif
88#ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
89 snd_hda_preset_atihdmi,
90#endif
91#ifdef CONFIG_SND_HDA_CODEC_CONEXANT
92 snd_hda_preset_conexant,
93#endif
94#ifdef CONFIG_SND_HDA_CODEC_VIA
95 snd_hda_preset_via,
96#endif
97 NULL
98};
69 99
70#ifdef CONFIG_SND_HDA_POWER_SAVE 100#ifdef CONFIG_SND_HDA_POWER_SAVE
71static void hda_power_work(struct work_struct *work); 101static void hda_power_work(struct work_struct *work);
@@ -690,6 +720,19 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
690 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); 720 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
691} 721}
692 722
723void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
724{
725 if (!nid)
726 return;
727
728 snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid);
729 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
730#if 0 /* keep the format */
731 msleep(1);
732 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0);
733#endif
734}
735
693/* 736/*
694 * amp access functions 737 * amp access functions
695 */ 738 */
@@ -1037,16 +1080,24 @@ void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
1037} 1080}
1038 1081
1039/* find a mixer control element with the given name */ 1082/* find a mixer control element with the given name */
1040struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, 1083static struct snd_kcontrol *
1041 const char *name) 1084_snd_hda_find_mixer_ctl(struct hda_codec *codec,
1085 const char *name, int idx)
1042{ 1086{
1043 struct snd_ctl_elem_id id; 1087 struct snd_ctl_elem_id id;
1044 memset(&id, 0, sizeof(id)); 1088 memset(&id, 0, sizeof(id));
1045 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1089 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1090 id.index = idx;
1046 strcpy(id.name, name); 1091 strcpy(id.name, name);
1047 return snd_ctl_find_id(codec->bus->card, &id); 1092 return snd_ctl_find_id(codec->bus->card, &id);
1048} 1093}
1049 1094
1095struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
1096 const char *name)
1097{
1098 return _snd_hda_find_mixer_ctl(codec, name, 0);
1099}
1100
1050/* create a virtual master control and add slaves */ 1101/* create a virtual master control and add slaves */
1051int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 1102int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1052 unsigned int *tlv, const char **slaves) 1103 unsigned int *tlv, const char **slaves)
@@ -1481,6 +1532,8 @@ static struct snd_kcontrol_new dig_mixes[] = {
1481 { } /* end */ 1532 { } /* end */
1482}; 1533};
1483 1534
1535#define SPDIF_MAX_IDX 4 /* 4 instances should be enough to probe */
1536
1484/** 1537/**
1485 * snd_hda_create_spdif_out_ctls - create Output SPDIF-related controls 1538 * snd_hda_create_spdif_out_ctls - create Output SPDIF-related controls
1486 * @codec: the HDA codec 1539 * @codec: the HDA codec
@@ -1496,9 +1549,20 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1496 int err; 1549 int err;
1497 struct snd_kcontrol *kctl; 1550 struct snd_kcontrol *kctl;
1498 struct snd_kcontrol_new *dig_mix; 1551 struct snd_kcontrol_new *dig_mix;
1552 int idx;
1499 1553
1554 for (idx = 0; idx < SPDIF_MAX_IDX; idx++) {
1555 if (!_snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch",
1556 idx))
1557 break;
1558 }
1559 if (idx >= SPDIF_MAX_IDX) {
1560 printk(KERN_ERR "hda_codec: too many IEC958 outputs\n");
1561 return -EBUSY;
1562 }
1500 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { 1563 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
1501 kctl = snd_ctl_new1(dig_mix, codec); 1564 kctl = snd_ctl_new1(dig_mix, codec);
1565 kctl->id.index = idx;
1502 kctl->private_value = nid; 1566 kctl->private_value = nid;
1503 err = snd_ctl_add(codec->bus->card, kctl); 1567 err = snd_ctl_add(codec->bus->card, kctl);
1504 if (err < 0) 1568 if (err < 0)
@@ -1512,6 +1576,43 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1512} 1576}
1513 1577
1514/* 1578/*
1579 * SPDIF sharing with analog output
1580 */
1581static int spdif_share_sw_get(struct snd_kcontrol *kcontrol,
1582 struct snd_ctl_elem_value *ucontrol)
1583{
1584 struct hda_multi_out *mout = snd_kcontrol_chip(kcontrol);
1585 ucontrol->value.integer.value[0] = mout->share_spdif;
1586 return 0;
1587}
1588
1589static int spdif_share_sw_put(struct snd_kcontrol *kcontrol,
1590 struct snd_ctl_elem_value *ucontrol)
1591{
1592 struct hda_multi_out *mout = snd_kcontrol_chip(kcontrol);
1593 mout->share_spdif = !!ucontrol->value.integer.value[0];
1594 return 0;
1595}
1596
1597static struct snd_kcontrol_new spdif_share_sw = {
1598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1599 .name = "IEC958 Default PCM Playback Switch",
1600 .info = snd_ctl_boolean_mono_info,
1601 .get = spdif_share_sw_get,
1602 .put = spdif_share_sw_put,
1603};
1604
1605int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
1606 struct hda_multi_out *mout)
1607{
1608 if (!mout->dig_out_nid)
1609 return 0;
1610 /* ATTENTION: here mout is passed as private_data, instead of codec */
1611 return snd_ctl_add(codec->bus->card,
1612 snd_ctl_new1(&spdif_share_sw, mout));
1613}
1614
1615/*
1515 * SPDIF input 1616 * SPDIF input
1516 */ 1617 */
1517 1618
@@ -1595,7 +1696,17 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1595 int err; 1696 int err;
1596 struct snd_kcontrol *kctl; 1697 struct snd_kcontrol *kctl;
1597 struct snd_kcontrol_new *dig_mix; 1698 struct snd_kcontrol_new *dig_mix;
1699 int idx;
1598 1700
1701 for (idx = 0; idx < SPDIF_MAX_IDX; idx++) {
1702 if (!_snd_hda_find_mixer_ctl(codec, "IEC958 Capture Switch",
1703 idx))
1704 break;
1705 }
1706 if (idx >= SPDIF_MAX_IDX) {
1707 printk(KERN_ERR "hda_codec: too many IEC958 inputs\n");
1708 return -EBUSY;
1709 }
1599 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 1710 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1600 kctl = snd_ctl_new1(dig_mix, codec); 1711 kctl = snd_ctl_new1(dig_mix, codec);
1601 kctl->private_value = nid; 1712 kctl->private_value = nid;
@@ -2106,7 +2217,7 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
2106 struct hda_codec *codec, 2217 struct hda_codec *codec,
2107 struct snd_pcm_substream *substream) 2218 struct snd_pcm_substream *substream)
2108{ 2219{
2109 snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0); 2220 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
2110 return 0; 2221 return 0;
2111} 2222}
2112 2223
@@ -2491,7 +2602,7 @@ int snd_hda_multi_out_dig_open(struct hda_codec *codec,
2491 mutex_lock(&codec->spdif_mutex); 2602 mutex_lock(&codec->spdif_mutex);
2492 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP) 2603 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP)
2493 /* already opened as analog dup; reset it once */ 2604 /* already opened as analog dup; reset it once */
2494 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 2605 snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
2495 mout->dig_out_used = HDA_DIG_EXCLUSIVE; 2606 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
2496 mutex_unlock(&codec->spdif_mutex); 2607 mutex_unlock(&codec->spdif_mutex);
2497 return 0; 2608 return 0;
@@ -2526,9 +2637,36 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec,
2526 */ 2637 */
2527int snd_hda_multi_out_analog_open(struct hda_codec *codec, 2638int snd_hda_multi_out_analog_open(struct hda_codec *codec,
2528 struct hda_multi_out *mout, 2639 struct hda_multi_out *mout,
2529 struct snd_pcm_substream *substream) 2640 struct snd_pcm_substream *substream,
2530{ 2641 struct hda_pcm_stream *hinfo)
2531 substream->runtime->hw.channels_max = mout->max_channels; 2642{
2643 struct snd_pcm_runtime *runtime = substream->runtime;
2644 runtime->hw.channels_max = mout->max_channels;
2645 if (mout->dig_out_nid) {
2646 if (!mout->analog_rates) {
2647 mout->analog_rates = hinfo->rates;
2648 mout->analog_formats = hinfo->formats;
2649 mout->analog_maxbps = hinfo->maxbps;
2650 } else {
2651 runtime->hw.rates = mout->analog_rates;
2652 runtime->hw.formats = mout->analog_formats;
2653 hinfo->maxbps = mout->analog_maxbps;
2654 }
2655 if (!mout->spdif_rates) {
2656 snd_hda_query_supported_pcm(codec, mout->dig_out_nid,
2657 &mout->spdif_rates,
2658 &mout->spdif_formats,
2659 &mout->spdif_maxbps);
2660 }
2661 mutex_lock(&codec->spdif_mutex);
2662 if (mout->share_spdif) {
2663 runtime->hw.rates &= mout->spdif_rates;
2664 runtime->hw.formats &= mout->spdif_formats;
2665 if (mout->spdif_maxbps < hinfo->maxbps)
2666 hinfo->maxbps = mout->spdif_maxbps;
2667 }
2668 mutex_unlock(&codec->spdif_mutex);
2669 }
2532 return snd_pcm_hw_constraint_step(substream->runtime, 0, 2670 return snd_pcm_hw_constraint_step(substream->runtime, 0,
2533 SNDRV_PCM_HW_PARAM_CHANNELS, 2); 2671 SNDRV_PCM_HW_PARAM_CHANNELS, 2);
2534} 2672}
@@ -2548,7 +2686,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2548 int i; 2686 int i;
2549 2687
2550 mutex_lock(&codec->spdif_mutex); 2688 mutex_lock(&codec->spdif_mutex);
2551 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { 2689 if (mout->dig_out_nid && mout->share_spdif &&
2690 mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
2552 if (chs == 2 && 2691 if (chs == 2 &&
2553 snd_hda_is_supported_format(codec, mout->dig_out_nid, 2692 snd_hda_is_supported_format(codec, mout->dig_out_nid,
2554 format) && 2693 format) &&
@@ -2558,8 +2697,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2558 stream_tag, format); 2697 stream_tag, format);
2559 } else { 2698 } else {
2560 mout->dig_out_used = 0; 2699 mout->dig_out_used = 0;
2561 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 2700 snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
2562 0, 0, 0);
2563 } 2701 }
2564 } 2702 }
2565 mutex_unlock(&codec->spdif_mutex); 2703 mutex_unlock(&codec->spdif_mutex);
@@ -2601,17 +2739,16 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
2601 int i; 2739 int i;
2602 2740
2603 for (i = 0; i < mout->num_dacs; i++) 2741 for (i = 0; i < mout->num_dacs; i++)
2604 snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0); 2742 snd_hda_codec_cleanup_stream(codec, nids[i]);
2605 if (mout->hp_nid) 2743 if (mout->hp_nid)
2606 snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0); 2744 snd_hda_codec_cleanup_stream(codec, mout->hp_nid);
2607 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 2745 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
2608 if (mout->extra_out_nid[i]) 2746 if (mout->extra_out_nid[i])
2609 snd_hda_codec_setup_stream(codec, 2747 snd_hda_codec_cleanup_stream(codec,
2610 mout->extra_out_nid[i], 2748 mout->extra_out_nid[i]);
2611 0, 0, 0);
2612 mutex_lock(&codec->spdif_mutex); 2749 mutex_lock(&codec->spdif_mutex);
2613 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) { 2750 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) {
2614 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 2751 snd_hda_codec_cleanup_stream(codec, mout->dig_out_nid);
2615 mout->dig_out_used = 0; 2752 mout->dig_out_used = 0;
2616 } 2753 }
2617 mutex_unlock(&codec->spdif_mutex); 2754 mutex_unlock(&codec->spdif_mutex);
@@ -2790,6 +2927,30 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
2790 } 2927 }
2791 } 2928 }
2792 2929
2930 /* FIX-UP:
2931 * If no line-out is defined but multiple HPs are found,
2932 * some of them might be the real line-outs.
2933 */
2934 if (!cfg->line_outs && cfg->hp_outs > 1) {
2935 int i = 0;
2936 while (i < cfg->hp_outs) {
2937 /* The real HPs should have the sequence 0x0f */
2938 if ((sequences_hp[i] & 0x0f) == 0x0f) {
2939 i++;
2940 continue;
2941 }
2942 /* Move it to the line-out table */
2943 cfg->line_out_pins[cfg->line_outs] = cfg->hp_pins[i];
2944 sequences_line_out[cfg->line_outs] = sequences_hp[i];
2945 cfg->line_outs++;
2946 cfg->hp_outs--;
2947 memmove(cfg->hp_pins + i, cfg->hp_pins + i + 1,
2948 sizeof(cfg->hp_pins[0]) * (cfg->hp_outs - i));
2949 memmove(sequences_hp + i - 1, sequences_hp + i,
2950 sizeof(sequences_hp[0]) * (cfg->hp_outs - i));
2951 }
2952 }
2953
2793 /* sort by sequence */ 2954 /* sort by sequence */
2794 sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out, 2955 sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out,
2795 cfg->line_outs); 2956 cfg->line_outs);
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index f14871151be9..dcd390b2bbaa 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -590,11 +590,21 @@ struct hda_pcm_stream {
590 struct hda_pcm_ops ops; 590 struct hda_pcm_ops ops;
591}; 591};
592 592
593/* PCM types */
594enum {
595 HDA_PCM_TYPE_AUDIO,
596 HDA_PCM_TYPE_SPDIF,
597 HDA_PCM_TYPE_HDMI,
598 HDA_PCM_TYPE_MODEM,
599 HDA_PCM_NTYPES
600};
601
593/* for PCM creation */ 602/* for PCM creation */
594struct hda_pcm { 603struct hda_pcm {
595 char *name; 604 char *name;
596 struct hda_pcm_stream stream[2]; 605 struct hda_pcm_stream stream[2];
597 unsigned int is_modem; /* modem codec? */ 606 unsigned int pcm_type; /* HDA_PCM_TYPE_XXX */
607 int device; /* assigned device number */
598}; 608};
599 609
600/* codec information */ 610/* codec information */
@@ -712,6 +722,7 @@ int snd_hda_build_pcms(struct hda_bus *bus);
712void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, 722void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
713 u32 stream_tag, 723 u32 stream_tag,
714 int channel_id, int format); 724 int channel_id, int format);
725void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid);
715unsigned int snd_hda_calc_stream_format(unsigned int rate, 726unsigned int snd_hda_calc_stream_format(unsigned int rate,
716 unsigned int channels, 727 unsigned int channels,
717 unsigned int format, 728 unsigned int format,
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index f9de7c467c25..59e4389c94a4 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -1007,8 +1007,8 @@ static int generic_pcm2_cleanup(struct hda_pcm_stream *hinfo,
1007{ 1007{
1008 struct hda_gspec *spec = codec->spec; 1008 struct hda_gspec *spec = codec->spec;
1009 1009
1010 snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0); 1010 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
1011 snd_hda_codec_setup_stream(codec, spec->dac_node[1]->nid, 0, 0, 0); 1011 snd_hda_codec_cleanup_stream(codec, spec->dac_node[1]->nid);
1012 return 0; 1012 return 0;
1013} 1013}
1014 1014
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 4be36c84b36c..b3a618eb42cd 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -39,6 +39,7 @@
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/module.h> 41#include <linux/module.h>
42#include <linux/dma-mapping.h>
42#include <linux/moduleparam.h> 43#include <linux/moduleparam.h>
43#include <linux/init.h> 44#include <linux/init.h>
44#include <linux/slab.h> 45#include <linux/slab.h>
@@ -185,35 +186,28 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
185 186
186/* max number of SDs */ 187/* max number of SDs */
187/* ICH, ATI and VIA have 4 playback and 4 capture */ 188/* ICH, ATI and VIA have 4 playback and 4 capture */
188#define ICH6_CAPTURE_INDEX 0
189#define ICH6_NUM_CAPTURE 4 189#define ICH6_NUM_CAPTURE 4
190#define ICH6_PLAYBACK_INDEX 4
191#define ICH6_NUM_PLAYBACK 4 190#define ICH6_NUM_PLAYBACK 4
192 191
193/* ULI has 6 playback and 5 capture */ 192/* ULI has 6 playback and 5 capture */
194#define ULI_CAPTURE_INDEX 0
195#define ULI_NUM_CAPTURE 5 193#define ULI_NUM_CAPTURE 5
196#define ULI_PLAYBACK_INDEX 5
197#define ULI_NUM_PLAYBACK 6 194#define ULI_NUM_PLAYBACK 6
198 195
199/* ATI HDMI has 1 playback and 0 capture */ 196/* ATI HDMI has 1 playback and 0 capture */
200#define ATIHDMI_CAPTURE_INDEX 0
201#define ATIHDMI_NUM_CAPTURE 0 197#define ATIHDMI_NUM_CAPTURE 0
202#define ATIHDMI_PLAYBACK_INDEX 0
203#define ATIHDMI_NUM_PLAYBACK 1 198#define ATIHDMI_NUM_PLAYBACK 1
204 199
205/* this number is statically defined for simplicity */ 200/* this number is statically defined for simplicity */
206#define MAX_AZX_DEV 16 201#define MAX_AZX_DEV 16
207 202
208/* max number of fragments - we may use more if allocating more pages for BDL */ 203/* max number of fragments - we may use more if allocating more pages for BDL */
209#define BDL_SIZE PAGE_ALIGN(8192) 204#define BDL_SIZE 4096
210#define AZX_MAX_FRAG (BDL_SIZE / (MAX_AZX_DEV * 16)) 205#define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16)
206#define AZX_MAX_FRAG 32
211/* max buffer size - no h/w limit, you can increase as you like */ 207/* max buffer size - no h/w limit, you can increase as you like */
212#define AZX_MAX_BUF_SIZE (1024*1024*1024) 208#define AZX_MAX_BUF_SIZE (1024*1024*1024)
213/* max number of PCM devics per card */ 209/* max number of PCM devics per card */
214#define AZX_MAX_AUDIO_PCMS 6 210#define AZX_MAX_PCMS 8
215#define AZX_MAX_MODEM_PCMS 2
216#define AZX_MAX_PCMS (AZX_MAX_AUDIO_PCMS + AZX_MAX_MODEM_PCMS)
217 211
218/* RIRB int mask: overrun[2], response[0] */ 212/* RIRB int mask: overrun[2], response[0] */
219#define RIRB_INT_RESPONSE 0x01 213#define RIRB_INT_RESPONSE 0x01
@@ -227,6 +221,9 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
227/* SD_CTL bits */ 221/* SD_CTL bits */
228#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ 222#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
229#define SD_CTL_DMA_START 0x02 /* stream DMA start bit */ 223#define SD_CTL_DMA_START 0x02 /* stream DMA start bit */
224#define SD_CTL_STRIPE (3 << 16) /* stripe control */
225#define SD_CTL_TRAFFIC_PRIO (1 << 18) /* traffic priority */
226#define SD_CTL_DIR (1 << 19) /* bi-directional stream */
230#define SD_CTL_STREAM_TAG_MASK (0xf << 20) 227#define SD_CTL_STREAM_TAG_MASK (0xf << 20)
231#define SD_CTL_STREAM_TAG_SHIFT 20 228#define SD_CTL_STREAM_TAG_SHIFT 20
232 229
@@ -284,12 +281,10 @@ enum {
284 */ 281 */
285 282
286struct azx_dev { 283struct azx_dev {
287 u32 *bdl; /* virtual address of the BDL */ 284 struct snd_dma_buffer bdl; /* BDL buffer */
288 dma_addr_t bdl_addr; /* physical address of the BDL */
289 u32 *posbuf; /* position buffer pointer */ 285 u32 *posbuf; /* position buffer pointer */
290 286
291 unsigned int bufsize; /* size of the play buffer in bytes */ 287 unsigned int bufsize; /* size of the play buffer in bytes */
292 unsigned int fragsize; /* size of each period in bytes */
293 unsigned int frags; /* number for period in the play buffer */ 288 unsigned int frags; /* number for period in the play buffer */
294 unsigned int fifo_size; /* FIFO size */ 289 unsigned int fifo_size; /* FIFO size */
295 290
@@ -350,7 +345,6 @@ struct azx {
350 struct azx_dev *azx_dev; 345 struct azx_dev *azx_dev;
351 346
352 /* PCM */ 347 /* PCM */
353 unsigned int pcm_devs;
354 struct snd_pcm *pcm[AZX_MAX_PCMS]; 348 struct snd_pcm *pcm[AZX_MAX_PCMS];
355 349
356 /* HD codec */ 350 /* HD codec */
@@ -361,8 +355,7 @@ struct azx {
361 struct azx_rb corb; 355 struct azx_rb corb;
362 struct azx_rb rirb; 356 struct azx_rb rirb;
363 357
364 /* BDL, CORB/RIRB and position buffers */ 358 /* CORB/RIRB and position buffers */
365 struct snd_dma_buffer bdl;
366 struct snd_dma_buffer rb; 359 struct snd_dma_buffer rb;
367 struct snd_dma_buffer posbuf; 360 struct snd_dma_buffer posbuf;
368 361
@@ -546,8 +539,9 @@ static void azx_update_rirb(struct azx *chip)
546 if (res_ex & ICH6_RIRB_EX_UNSOL_EV) 539 if (res_ex & ICH6_RIRB_EX_UNSOL_EV)
547 snd_hda_queue_unsol_event(chip->bus, res, res_ex); 540 snd_hda_queue_unsol_event(chip->bus, res, res_ex);
548 else if (chip->rirb.cmds) { 541 else if (chip->rirb.cmds) {
549 chip->rirb.cmds--;
550 chip->rirb.res = res; 542 chip->rirb.res = res;
543 smp_wmb();
544 chip->rirb.cmds--;
551 } 545 }
552 } 546 }
553} 547}
@@ -566,8 +560,10 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
566 azx_update_rirb(chip); 560 azx_update_rirb(chip);
567 spin_unlock_irq(&chip->reg_lock); 561 spin_unlock_irq(&chip->reg_lock);
568 } 562 }
569 if (!chip->rirb.cmds) 563 if (!chip->rirb.cmds) {
564 smp_rmb();
570 return chip->rirb.res; /* the last value */ 565 return chip->rirb.res; /* the last value */
566 }
571 if (time_after(jiffies, timeout)) 567 if (time_after(jiffies, timeout))
572 break; 568 break;
573 if (codec->bus->needs_damn_long_delay) 569 if (codec->bus->needs_damn_long_delay)
@@ -965,30 +961,57 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id)
965/* 961/*
966 * set up BDL entries 962 * set up BDL entries
967 */ 963 */
968static void azx_setup_periods(struct azx_dev *azx_dev) 964static int azx_setup_periods(struct snd_pcm_substream *substream,
965 struct azx_dev *azx_dev)
969{ 966{
970 u32 *bdl = azx_dev->bdl; 967 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
971 dma_addr_t dma_addr = azx_dev->substream->runtime->dma_addr; 968 u32 *bdl;
972 int idx; 969 int i, ofs, periods, period_bytes;
973 970
974 /* reset BDL address */ 971 /* reset BDL address */
975 azx_sd_writel(azx_dev, SD_BDLPL, 0); 972 azx_sd_writel(azx_dev, SD_BDLPL, 0);
976 azx_sd_writel(azx_dev, SD_BDLPU, 0); 973 azx_sd_writel(azx_dev, SD_BDLPU, 0);
977 974
975 period_bytes = snd_pcm_lib_period_bytes(substream);
976 periods = azx_dev->bufsize / period_bytes;
977
978 /* program the initial BDL entries */ 978 /* program the initial BDL entries */
979 for (idx = 0; idx < azx_dev->frags; idx++) { 979 bdl = (u32 *)azx_dev->bdl.area;
980 unsigned int off = idx << 2; /* 4 dword step */ 980 ofs = 0;
981 dma_addr_t addr = dma_addr + idx * azx_dev->fragsize; 981 azx_dev->frags = 0;
982 /* program the address field of the BDL entry */ 982 for (i = 0; i < periods; i++) {
983 bdl[off] = cpu_to_le32((u32)addr); 983 int size, rest;
984 bdl[off+1] = cpu_to_le32(upper_32bit(addr)); 984 if (i >= AZX_MAX_BDL_ENTRIES) {
985 985 snd_printk(KERN_ERR "Too many BDL entries: "
986 /* program the size field of the BDL entry */ 986 "buffer=%d, period=%d\n",
987 bdl[off+2] = cpu_to_le32(azx_dev->fragsize); 987 azx_dev->bufsize, period_bytes);
988 988 /* reset */
989 /* program the IOC to enable interrupt when buffer completes */ 989 azx_sd_writel(azx_dev, SD_BDLPL, 0);
990 bdl[off+3] = cpu_to_le32(0x01); 990 azx_sd_writel(azx_dev, SD_BDLPU, 0);
991 return -EINVAL;
992 }
993 rest = period_bytes;
994 do {
995 dma_addr_t addr = snd_pcm_sgbuf_get_addr(sgbuf, ofs);
996 /* program the address field of the BDL entry */
997 bdl[0] = cpu_to_le32((u32)addr);
998 bdl[1] = cpu_to_le32(upper_32bit(addr));
999 /* program the size field of the BDL entry */
1000 size = PAGE_SIZE - (ofs % PAGE_SIZE);
1001 if (rest < size)
1002 size = rest;
1003 bdl[2] = cpu_to_le32(size);
1004 /* program the IOC to enable interrupt
1005 * only when the whole fragment is processed
1006 */
1007 rest -= size;
1008 bdl[3] = rest ? 0 : cpu_to_le32(0x01);
1009 bdl += 4;
1010 azx_dev->frags++;
1011 ofs += size;
1012 } while (rest > 0);
991 } 1013 }
1014 return 0;
992} 1015}
993 1016
994/* 1017/*
@@ -1037,14 +1060,17 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1037 1060
1038 /* program the BDL address */ 1061 /* program the BDL address */
1039 /* lower BDL address */ 1062 /* lower BDL address */
1040 azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl_addr); 1063 azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
1041 /* upper BDL address */ 1064 /* upper BDL address */
1042 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); 1065 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl.addr));
1043 1066
1044 /* enable the position buffer */ 1067 /* enable the position buffer */
1045 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 1068 if (chip->position_fix == POS_FIX_POSBUF ||
1046 azx_writel(chip, DPLBASE, 1069 chip->position_fix == POS_FIX_AUTO) {
1047 (u32)chip->posbuf.addr |ICH6_DPLBASE_ENABLE); 1070 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
1071 azx_writel(chip, DPLBASE,
1072 (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
1073 }
1048 1074
1049 /* set the interrupt enable bits in the descriptor control register */ 1075 /* set the interrupt enable bits in the descriptor control register */
1050 azx_sd_writel(azx_dev, SD_CTL, 1076 azx_sd_writel(azx_dev, SD_CTL,
@@ -1157,7 +1183,8 @@ static struct snd_pcm_hardware azx_pcm_hw = {
1157 SNDRV_PCM_INFO_MMAP_VALID | 1183 SNDRV_PCM_INFO_MMAP_VALID |
1158 /* No full-resume yet implemented */ 1184 /* No full-resume yet implemented */
1159 /* SNDRV_PCM_INFO_RESUME |*/ 1185 /* SNDRV_PCM_INFO_RESUME |*/
1160 SNDRV_PCM_INFO_PAUSE), 1186 SNDRV_PCM_INFO_PAUSE |
1187 SNDRV_PCM_INFO_SYNC_START),
1161 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1188 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1162 .rates = SNDRV_PCM_RATE_48000, 1189 .rates = SNDRV_PCM_RATE_48000,
1163 .rate_min = 48000, 1190 .rate_min = 48000,
@@ -1219,6 +1246,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1219 spin_unlock_irqrestore(&chip->reg_lock, flags); 1246 spin_unlock_irqrestore(&chip->reg_lock, flags);
1220 1247
1221 runtime->private_data = azx_dev; 1248 runtime->private_data = azx_dev;
1249 snd_pcm_set_sync(substream);
1222 mutex_unlock(&chip->open_mutex); 1250 mutex_unlock(&chip->open_mutex);
1223 return 0; 1251 return 0;
1224} 1252}
@@ -1275,8 +1303,6 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1275 struct snd_pcm_runtime *runtime = substream->runtime; 1303 struct snd_pcm_runtime *runtime = substream->runtime;
1276 1304
1277 azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream); 1305 azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream);
1278 azx_dev->fragsize = snd_pcm_lib_period_bytes(substream);
1279 azx_dev->frags = azx_dev->bufsize / azx_dev->fragsize;
1280 azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate, 1306 azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate,
1281 runtime->channels, 1307 runtime->channels,
1282 runtime->format, 1308 runtime->format,
@@ -1288,10 +1314,10 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1288 return -EINVAL; 1314 return -EINVAL;
1289 } 1315 }
1290 1316
1291 snd_printdd("azx_pcm_prepare: bufsize=0x%x, fragsize=0x%x, " 1317 snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
1292 "format=0x%x\n", 1318 azx_dev->bufsize, azx_dev->format_val);
1293 azx_dev->bufsize, azx_dev->fragsize, azx_dev->format_val); 1319 if (azx_setup_periods(substream, azx_dev) < 0)
1294 azx_setup_periods(azx_dev); 1320 return -EINVAL;
1295 azx_setup_controller(chip, azx_dev); 1321 azx_setup_controller(chip, azx_dev);
1296 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1322 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
1297 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; 1323 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
@@ -1305,37 +1331,94 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1305static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1331static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1306{ 1332{
1307 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1333 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1308 struct azx_dev *azx_dev = get_azx_dev(substream);
1309 struct azx *chip = apcm->chip; 1334 struct azx *chip = apcm->chip;
1310 int err = 0; 1335 struct azx_dev *azx_dev;
1336 struct snd_pcm_substream *s;
1337 int start, nsync = 0, sbits = 0;
1338 int nwait, timeout;
1311 1339
1312 spin_lock(&chip->reg_lock);
1313 switch (cmd) { 1340 switch (cmd) {
1314 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1341 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1315 case SNDRV_PCM_TRIGGER_RESUME: 1342 case SNDRV_PCM_TRIGGER_RESUME:
1316 case SNDRV_PCM_TRIGGER_START: 1343 case SNDRV_PCM_TRIGGER_START:
1317 azx_stream_start(chip, azx_dev); 1344 start = 1;
1318 azx_dev->running = 1;
1319 break; 1345 break;
1320 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1346 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1321 case SNDRV_PCM_TRIGGER_SUSPEND: 1347 case SNDRV_PCM_TRIGGER_SUSPEND:
1322 case SNDRV_PCM_TRIGGER_STOP: 1348 case SNDRV_PCM_TRIGGER_STOP:
1323 azx_stream_stop(chip, azx_dev); 1349 start = 0;
1324 azx_dev->running = 0;
1325 break; 1350 break;
1326 default: 1351 default:
1327 err = -EINVAL; 1352 return -EINVAL;
1353 }
1354
1355 snd_pcm_group_for_each_entry(s, substream) {
1356 if (s->pcm->card != substream->pcm->card)
1357 continue;
1358 azx_dev = get_azx_dev(s);
1359 sbits |= 1 << azx_dev->index;
1360 nsync++;
1361 snd_pcm_trigger_done(s, substream);
1362 }
1363
1364 spin_lock(&chip->reg_lock);
1365 if (nsync > 1) {
1366 /* first, set SYNC bits of corresponding streams */
1367 azx_writel(chip, SYNC, azx_readl(chip, SYNC) | sbits);
1368 }
1369 snd_pcm_group_for_each_entry(s, substream) {
1370 if (s->pcm->card != substream->pcm->card)
1371 continue;
1372 azx_dev = get_azx_dev(s);
1373 if (start)
1374 azx_stream_start(chip, azx_dev);
1375 else
1376 azx_stream_stop(chip, azx_dev);
1377 azx_dev->running = start;
1328 } 1378 }
1329 spin_unlock(&chip->reg_lock); 1379 spin_unlock(&chip->reg_lock);
1330 if (cmd == SNDRV_PCM_TRIGGER_PAUSE_PUSH || 1380 if (start) {
1331 cmd == SNDRV_PCM_TRIGGER_SUSPEND || 1381 if (nsync == 1)
1332 cmd == SNDRV_PCM_TRIGGER_STOP) { 1382 return 0;
1333 int timeout = 5000; 1383 /* wait until all FIFOs get ready */
1334 while ((azx_sd_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START) && 1384 for (timeout = 5000; timeout; timeout--) {
1335 --timeout) 1385 nwait = 0;
1336 ; 1386 snd_pcm_group_for_each_entry(s, substream) {
1387 if (s->pcm->card != substream->pcm->card)
1388 continue;
1389 azx_dev = get_azx_dev(s);
1390 if (!(azx_sd_readb(azx_dev, SD_STS) &
1391 SD_STS_FIFO_READY))
1392 nwait++;
1393 }
1394 if (!nwait)
1395 break;
1396 cpu_relax();
1397 }
1398 } else {
1399 /* wait until all RUN bits are cleared */
1400 for (timeout = 5000; timeout; timeout--) {
1401 nwait = 0;
1402 snd_pcm_group_for_each_entry(s, substream) {
1403 if (s->pcm->card != substream->pcm->card)
1404 continue;
1405 azx_dev = get_azx_dev(s);
1406 if (azx_sd_readb(azx_dev, SD_CTL) &
1407 SD_CTL_DMA_START)
1408 nwait++;
1409 }
1410 if (!nwait)
1411 break;
1412 cpu_relax();
1413 }
1337 } 1414 }
1338 return err; 1415 if (nsync > 1) {
1416 spin_lock(&chip->reg_lock);
1417 /* reset SYNC bits */
1418 azx_writel(chip, SYNC, azx_readl(chip, SYNC) & ~sbits);
1419 spin_unlock(&chip->reg_lock);
1420 }
1421 return 0;
1339} 1422}
1340 1423
1341static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) 1424static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
@@ -1378,6 +1461,7 @@ static struct snd_pcm_ops azx_pcm_ops = {
1378 .prepare = azx_pcm_prepare, 1461 .prepare = azx_pcm_prepare,
1379 .trigger = azx_pcm_trigger, 1462 .trigger = azx_pcm_trigger,
1380 .pointer = azx_pcm_pointer, 1463 .pointer = azx_pcm_pointer,
1464 .page = snd_pcm_sgbuf_ops_page,
1381}; 1465};
1382 1466
1383static void azx_pcm_free(struct snd_pcm *pcm) 1467static void azx_pcm_free(struct snd_pcm *pcm)
@@ -1386,7 +1470,7 @@ static void azx_pcm_free(struct snd_pcm *pcm)
1386} 1470}
1387 1471
1388static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec, 1472static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1389 struct hda_pcm *cpcm, int pcm_dev) 1473 struct hda_pcm *cpcm)
1390{ 1474{
1391 int err; 1475 int err;
1392 struct snd_pcm *pcm; 1476 struct snd_pcm *pcm;
@@ -1400,7 +1484,7 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1400 1484
1401 snd_assert(cpcm->name, return -EINVAL); 1485 snd_assert(cpcm->name, return -EINVAL);
1402 1486
1403 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev, 1487 err = snd_pcm_new(chip->card, cpcm->name, cpcm->device,
1404 cpcm->stream[0].substreams, 1488 cpcm->stream[0].substreams,
1405 cpcm->stream[1].substreams, 1489 cpcm->stream[1].substreams,
1406 &pcm); 1490 &pcm);
@@ -1420,62 +1504,70 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1420 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &azx_pcm_ops); 1504 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &azx_pcm_ops);
1421 if (cpcm->stream[1].substreams) 1505 if (cpcm->stream[1].substreams)
1422 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops); 1506 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops);
1423 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1507 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1424 snd_dma_pci_data(chip->pci), 1508 snd_dma_pci_data(chip->pci),
1425 1024 * 64, 1024 * 1024); 1509 1024 * 64, 1024 * 1024);
1426 chip->pcm[pcm_dev] = pcm; 1510 chip->pcm[cpcm->device] = pcm;
1427 if (chip->pcm_devs < pcm_dev + 1)
1428 chip->pcm_devs = pcm_dev + 1;
1429
1430 return 0; 1511 return 0;
1431} 1512}
1432 1513
1433static int __devinit azx_pcm_create(struct azx *chip) 1514static int __devinit azx_pcm_create(struct azx *chip)
1434{ 1515{
1516 static const char *dev_name[HDA_PCM_NTYPES] = {
1517 "Audio", "SPDIF", "HDMI", "Modem"
1518 };
1519 /* starting device index for each PCM type */
1520 static int dev_idx[HDA_PCM_NTYPES] = {
1521 [HDA_PCM_TYPE_AUDIO] = 0,
1522 [HDA_PCM_TYPE_SPDIF] = 1,
1523 [HDA_PCM_TYPE_HDMI] = 3,
1524 [HDA_PCM_TYPE_MODEM] = 6
1525 };
1526 /* normal audio device indices; not linear to keep compatibility */
1527 static int audio_idx[4] = { 0, 2, 4, 5 };
1435 struct hda_codec *codec; 1528 struct hda_codec *codec;
1436 int c, err; 1529 int c, err;
1437 int pcm_dev; 1530 int num_devs[HDA_PCM_NTYPES];
1438 1531
1439 err = snd_hda_build_pcms(chip->bus); 1532 err = snd_hda_build_pcms(chip->bus);
1440 if (err < 0) 1533 if (err < 0)
1441 return err; 1534 return err;
1442 1535
1443 /* create audio PCMs */ 1536 /* create audio PCMs */
1444 pcm_dev = 0; 1537 memset(num_devs, 0, sizeof(num_devs));
1445 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1446 for (c = 0; c < codec->num_pcms; c++) {
1447 if (codec->pcm_info[c].is_modem)
1448 continue; /* create later */
1449 if (pcm_dev >= AZX_MAX_AUDIO_PCMS) {
1450 snd_printk(KERN_ERR SFX
1451 "Too many audio PCMs\n");
1452 return -EINVAL;
1453 }
1454 err = create_codec_pcm(chip, codec,
1455 &codec->pcm_info[c], pcm_dev);
1456 if (err < 0)
1457 return err;
1458 pcm_dev++;
1459 }
1460 }
1461
1462 /* create modem PCMs */
1463 pcm_dev = AZX_MAX_AUDIO_PCMS;
1464 list_for_each_entry(codec, &chip->bus->codec_list, list) { 1538 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1465 for (c = 0; c < codec->num_pcms; c++) { 1539 for (c = 0; c < codec->num_pcms; c++) {
1466 if (!codec->pcm_info[c].is_modem) 1540 struct hda_pcm *cpcm = &codec->pcm_info[c];
1467 continue; /* already created */ 1541 int type = cpcm->pcm_type;
1468 if (pcm_dev >= AZX_MAX_PCMS) { 1542 switch (type) {
1469 snd_printk(KERN_ERR SFX 1543 case HDA_PCM_TYPE_AUDIO:
1470 "Too many modem PCMs\n"); 1544 if (num_devs[type] >= ARRAY_SIZE(audio_idx)) {
1471 return -EINVAL; 1545 snd_printk(KERN_WARNING
1546 "Too many audio devices\n");
1547 continue;
1548 }
1549 cpcm->device = audio_idx[num_devs[type]];
1550 break;
1551 case HDA_PCM_TYPE_SPDIF:
1552 case HDA_PCM_TYPE_HDMI:
1553 case HDA_PCM_TYPE_MODEM:
1554 if (num_devs[type]) {
1555 snd_printk(KERN_WARNING
1556 "%s already defined\n",
1557 dev_name[type]);
1558 continue;
1559 }
1560 cpcm->device = dev_idx[type];
1561 break;
1562 default:
1563 snd_printk(KERN_WARNING
1564 "Invalid PCM type %d\n", type);
1565 continue;
1472 } 1566 }
1473 err = create_codec_pcm(chip, codec, 1567 num_devs[type]++;
1474 &codec->pcm_info[c], pcm_dev); 1568 err = create_codec_pcm(chip, codec, cpcm);
1475 if (err < 0) 1569 if (err < 0)
1476 return err; 1570 return err;
1477 chip->pcm[pcm_dev]->dev_class = SNDRV_PCM_CLASS_MODEM;
1478 pcm_dev++;
1479 } 1571 }
1480 } 1572 }
1481 return 0; 1573 return 0;
@@ -1502,10 +1594,7 @@ static int __devinit azx_init_stream(struct azx *chip)
1502 * and initialize 1594 * and initialize
1503 */ 1595 */
1504 for (i = 0; i < chip->num_streams; i++) { 1596 for (i = 0; i < chip->num_streams; i++) {
1505 unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4);
1506 struct azx_dev *azx_dev = &chip->azx_dev[i]; 1597 struct azx_dev *azx_dev = &chip->azx_dev[i];
1507 azx_dev->bdl = (u32 *)(chip->bdl.area + off);
1508 azx_dev->bdl_addr = chip->bdl.addr + off;
1509 azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8); 1598 azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
1510 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ 1599 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
1511 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); 1600 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
@@ -1587,13 +1676,12 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1587 int i; 1676 int i;
1588 1677
1589 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1678 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1590 for (i = 0; i < chip->pcm_devs; i++) 1679 for (i = 0; i < AZX_MAX_PCMS; i++)
1591 snd_pcm_suspend_all(chip->pcm[i]); 1680 snd_pcm_suspend_all(chip->pcm[i]);
1592 if (chip->initialized) 1681 if (chip->initialized)
1593 snd_hda_suspend(chip->bus, state); 1682 snd_hda_suspend(chip->bus, state);
1594 azx_stop_chip(chip); 1683 azx_stop_chip(chip);
1595 if (chip->irq >= 0) { 1684 if (chip->irq >= 0) {
1596 synchronize_irq(chip->irq);
1597 free_irq(chip->irq, chip); 1685 free_irq(chip->irq, chip);
1598 chip->irq = -1; 1686 chip->irq = -1;
1599 } 1687 }
@@ -1641,24 +1729,26 @@ static int azx_resume(struct pci_dev *pci)
1641 */ 1729 */
1642static int azx_free(struct azx *chip) 1730static int azx_free(struct azx *chip)
1643{ 1731{
1732 int i;
1733
1644 if (chip->initialized) { 1734 if (chip->initialized) {
1645 int i;
1646 for (i = 0; i < chip->num_streams; i++) 1735 for (i = 0; i < chip->num_streams; i++)
1647 azx_stream_stop(chip, &chip->azx_dev[i]); 1736 azx_stream_stop(chip, &chip->azx_dev[i]);
1648 azx_stop_chip(chip); 1737 azx_stop_chip(chip);
1649 } 1738 }
1650 1739
1651 if (chip->irq >= 0) { 1740 if (chip->irq >= 0)
1652 synchronize_irq(chip->irq);
1653 free_irq(chip->irq, (void*)chip); 1741 free_irq(chip->irq, (void*)chip);
1654 }
1655 if (chip->msi) 1742 if (chip->msi)
1656 pci_disable_msi(chip->pci); 1743 pci_disable_msi(chip->pci);
1657 if (chip->remap_addr) 1744 if (chip->remap_addr)
1658 iounmap(chip->remap_addr); 1745 iounmap(chip->remap_addr);
1659 1746
1660 if (chip->bdl.area) 1747 if (chip->azx_dev) {
1661 snd_dma_free_pages(&chip->bdl); 1748 for (i = 0; i < chip->num_streams; i++)
1749 if (chip->azx_dev[i].bdl.area)
1750 snd_dma_free_pages(&chip->azx_dev[i].bdl);
1751 }
1662 if (chip->rb.area) 1752 if (chip->rb.area)
1663 snd_dma_free_pages(&chip->rb); 1753 snd_dma_free_pages(&chip->rb);
1664 if (chip->posbuf.area) 1754 if (chip->posbuf.area)
@@ -1682,6 +1772,7 @@ static int azx_dev_free(struct snd_device *device)
1682static struct snd_pci_quirk position_fix_list[] __devinitdata = { 1772static struct snd_pci_quirk position_fix_list[] __devinitdata = {
1683 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE), 1773 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
1684 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_NONE), 1774 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_NONE),
1775 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_NONE),
1685 {} 1776 {}
1686}; 1777};
1687 1778
@@ -1740,7 +1831,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1740 struct azx **rchip) 1831 struct azx **rchip)
1741{ 1832{
1742 struct azx *chip; 1833 struct azx *chip;
1743 int err; 1834 int i, err;
1744 unsigned short gcap; 1835 unsigned short gcap;
1745 static struct snd_device_ops ops = { 1836 static struct snd_device_ops ops = {
1746 .dev_free = azx_dev_free, 1837 .dev_free = azx_dev_free,
@@ -1812,38 +1903,35 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1812 gcap = azx_readw(chip, GCAP); 1903 gcap = azx_readw(chip, GCAP);
1813 snd_printdd("chipset global capabilities = 0x%x\n", gcap); 1904 snd_printdd("chipset global capabilities = 0x%x\n", gcap);
1814 1905
1815 if (gcap) { 1906 /* allow 64bit DMA address if supported by H/W */
1816 /* read number of streams from GCAP register instead of using 1907 if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_64BIT_MASK))
1817 * hardcoded value 1908 pci_set_consistent_dma_mask(pci, DMA_64BIT_MASK);
1818 */ 1909
1819 chip->playback_streams = (gcap & (0xF << 12)) >> 12; 1910 /* read number of streams from GCAP register instead of using
1820 chip->capture_streams = (gcap & (0xF << 8)) >> 8; 1911 * hardcoded value
1821 chip->playback_index_offset = chip->capture_streams; 1912 */
1822 chip->capture_index_offset = 0; 1913 chip->capture_streams = (gcap >> 8) & 0x0f;
1823 } else { 1914 chip->playback_streams = (gcap >> 12) & 0x0f;
1915 if (!chip->playback_streams && !chip->capture_streams) {
1824 /* gcap didn't give any info, switching to old method */ 1916 /* gcap didn't give any info, switching to old method */
1825 1917
1826 switch (chip->driver_type) { 1918 switch (chip->driver_type) {
1827 case AZX_DRIVER_ULI: 1919 case AZX_DRIVER_ULI:
1828 chip->playback_streams = ULI_NUM_PLAYBACK; 1920 chip->playback_streams = ULI_NUM_PLAYBACK;
1829 chip->capture_streams = ULI_NUM_CAPTURE; 1921 chip->capture_streams = ULI_NUM_CAPTURE;
1830 chip->playback_index_offset = ULI_PLAYBACK_INDEX;
1831 chip->capture_index_offset = ULI_CAPTURE_INDEX;
1832 break; 1922 break;
1833 case AZX_DRIVER_ATIHDMI: 1923 case AZX_DRIVER_ATIHDMI:
1834 chip->playback_streams = ATIHDMI_NUM_PLAYBACK; 1924 chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
1835 chip->capture_streams = ATIHDMI_NUM_CAPTURE; 1925 chip->capture_streams = ATIHDMI_NUM_CAPTURE;
1836 chip->playback_index_offset = ATIHDMI_PLAYBACK_INDEX;
1837 chip->capture_index_offset = ATIHDMI_CAPTURE_INDEX;
1838 break; 1926 break;
1839 default: 1927 default:
1840 chip->playback_streams = ICH6_NUM_PLAYBACK; 1928 chip->playback_streams = ICH6_NUM_PLAYBACK;
1841 chip->capture_streams = ICH6_NUM_CAPTURE; 1929 chip->capture_streams = ICH6_NUM_CAPTURE;
1842 chip->playback_index_offset = ICH6_PLAYBACK_INDEX;
1843 chip->capture_index_offset = ICH6_CAPTURE_INDEX;
1844 break; 1930 break;
1845 } 1931 }
1846 } 1932 }
1933 chip->capture_index_offset = 0;
1934 chip->playback_index_offset = chip->capture_streams;
1847 chip->num_streams = chip->playback_streams + chip->capture_streams; 1935 chip->num_streams = chip->playback_streams + chip->capture_streams;
1848 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), 1936 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
1849 GFP_KERNEL); 1937 GFP_KERNEL);
@@ -1852,13 +1940,15 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1852 goto errout; 1940 goto errout;
1853 } 1941 }
1854 1942
1855 /* allocate memory for the BDL for each stream */ 1943 for (i = 0; i < chip->num_streams; i++) {
1856 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 1944 /* allocate memory for the BDL for each stream */
1857 snd_dma_pci_data(chip->pci), 1945 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
1858 BDL_SIZE, &chip->bdl); 1946 snd_dma_pci_data(chip->pci),
1859 if (err < 0) { 1947 BDL_SIZE, &chip->azx_dev[i].bdl);
1860 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 1948 if (err < 0) {
1861 goto errout; 1949 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
1950 goto errout;
1951 }
1862 } 1952 }
1863 /* allocate memory for the position buffer */ 1953 /* allocate memory for the position buffer */
1864 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 1954 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
@@ -1994,48 +2084,63 @@ static void __devexit azx_remove(struct pci_dev *pci)
1994 2084
1995/* PCI IDs */ 2085/* PCI IDs */
1996static struct pci_device_id azx_ids[] = { 2086static struct pci_device_id azx_ids[] = {
1997 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */ 2087 /* ICH 6..10 */
1998 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */ 2088 { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH },
1999 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */ 2089 { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH },
2000 { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */ 2090 { PCI_DEVICE(0x8086, 0x269a), .driver_data = AZX_DRIVER_ICH },
2001 { 0x8086, 0x293e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */ 2091 { PCI_DEVICE(0x8086, 0x284b), .driver_data = AZX_DRIVER_ICH },
2002 { 0x8086, 0x293f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH9 */ 2092 { PCI_DEVICE(0x8086, 0x293e), .driver_data = AZX_DRIVER_ICH },
2003 { 0x8086, 0x3a3e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH10 */ 2093 { PCI_DEVICE(0x8086, 0x293f), .driver_data = AZX_DRIVER_ICH },
2004 { 0x8086, 0x3a6e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH10 */ 2094 { PCI_DEVICE(0x8086, 0x3a3e), .driver_data = AZX_DRIVER_ICH },
2005 { 0x8086, 0x811b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SCH }, /* SCH*/ 2095 { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH },
2006 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */ 2096 /* SCH */
2007 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ 2097 { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH },
2008 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */ 2098 /* ATI SB 450/600 */
2009 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */ 2099 { PCI_DEVICE(0x1002, 0x437b), .driver_data = AZX_DRIVER_ATI },
2010 { 0x1002, 0x960f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */ 2100 { PCI_DEVICE(0x1002, 0x4383), .driver_data = AZX_DRIVER_ATI },
2011 { 0x1002, 0xaa00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI R600 HDMI */ 2101 /* ATI HDMI */
2012 { 0x1002, 0xaa08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV630 HDMI */ 2102 { PCI_DEVICE(0x1002, 0x793b), .driver_data = AZX_DRIVER_ATIHDMI },
2013 { 0x1002, 0xaa10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV610 HDMI */ 2103 { PCI_DEVICE(0x1002, 0x7919), .driver_data = AZX_DRIVER_ATIHDMI },
2014 { 0x1002, 0xaa18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV670 HDMI */ 2104 { PCI_DEVICE(0x1002, 0x960f), .driver_data = AZX_DRIVER_ATIHDMI },
2015 { 0x1002, 0xaa20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV635 HDMI */ 2105 { PCI_DEVICE(0x1002, 0xaa00), .driver_data = AZX_DRIVER_ATIHDMI },
2016 { 0x1002, 0xaa28, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV620 HDMI */ 2106 { PCI_DEVICE(0x1002, 0xaa08), .driver_data = AZX_DRIVER_ATIHDMI },
2017 { 0x1002, 0xaa30, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RV770 HDMI */ 2107 { PCI_DEVICE(0x1002, 0xaa10), .driver_data = AZX_DRIVER_ATIHDMI },
2018 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 2108 { PCI_DEVICE(0x1002, 0xaa18), .driver_data = AZX_DRIVER_ATIHDMI },
2019 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 2109 { PCI_DEVICE(0x1002, 0xaa20), .driver_data = AZX_DRIVER_ATIHDMI },
2020 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ 2110 { PCI_DEVICE(0x1002, 0xaa28), .driver_data = AZX_DRIVER_ATIHDMI },
2021 { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP51 */ 2111 { PCI_DEVICE(0x1002, 0xaa30), .driver_data = AZX_DRIVER_ATIHDMI },
2022 { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP55 */ 2112 { PCI_DEVICE(0x1002, 0xaa38), .driver_data = AZX_DRIVER_ATIHDMI },
2023 { 0x10de, 0x03e4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */ 2113 { PCI_DEVICE(0x1002, 0xaa40), .driver_data = AZX_DRIVER_ATIHDMI },
2024 { 0x10de, 0x03f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP61 */ 2114 { PCI_DEVICE(0x1002, 0xaa48), .driver_data = AZX_DRIVER_ATIHDMI },
2025 { 0x10de, 0x044a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */ 2115 /* VIA VT8251/VT8237A */
2026 { 0x10de, 0x044b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP65 */ 2116 { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },
2027 { 0x10de, 0x055c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ 2117 /* SIS966 */
2028 { 0x10de, 0x055d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP67 */ 2118 { PCI_DEVICE(0x1039, 0x7502), .driver_data = AZX_DRIVER_SIS },
2029 { 0x10de, 0x07fc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */ 2119 /* ULI M5461 */
2030 { 0x10de, 0x07fd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP73 */ 2120 { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI },
2031 { 0x10de, 0x0774, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */ 2121 /* NVIDIA MCP */
2032 { 0x10de, 0x0775, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */ 2122 { PCI_DEVICE(0x10de, 0x026c), .driver_data = AZX_DRIVER_NVIDIA },
2033 { 0x10de, 0x0776, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */ 2123 { PCI_DEVICE(0x10de, 0x0371), .driver_data = AZX_DRIVER_NVIDIA },
2034 { 0x10de, 0x0777, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP77 */ 2124 { PCI_DEVICE(0x10de, 0x03e4), .driver_data = AZX_DRIVER_NVIDIA },
2035 { 0x10de, 0x0ac0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */ 2125 { PCI_DEVICE(0x10de, 0x03f0), .driver_data = AZX_DRIVER_NVIDIA },
2036 { 0x10de, 0x0ac1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */ 2126 { PCI_DEVICE(0x10de, 0x044a), .driver_data = AZX_DRIVER_NVIDIA },
2037 { 0x10de, 0x0ac2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */ 2127 { PCI_DEVICE(0x10de, 0x044b), .driver_data = AZX_DRIVER_NVIDIA },
2038 { 0x10de, 0x0ac3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA MCP79 */ 2128 { PCI_DEVICE(0x10de, 0x055c), .driver_data = AZX_DRIVER_NVIDIA },
2129 { PCI_DEVICE(0x10de, 0x055d), .driver_data = AZX_DRIVER_NVIDIA },
2130 { PCI_DEVICE(0x10de, 0x0774), .driver_data = AZX_DRIVER_NVIDIA },
2131 { PCI_DEVICE(0x10de, 0x0775), .driver_data = AZX_DRIVER_NVIDIA },
2132 { PCI_DEVICE(0x10de, 0x0776), .driver_data = AZX_DRIVER_NVIDIA },
2133 { PCI_DEVICE(0x10de, 0x0777), .driver_data = AZX_DRIVER_NVIDIA },
2134 { PCI_DEVICE(0x10de, 0x07fc), .driver_data = AZX_DRIVER_NVIDIA },
2135 { PCI_DEVICE(0x10de, 0x07fd), .driver_data = AZX_DRIVER_NVIDIA },
2136 { PCI_DEVICE(0x10de, 0x0ac0), .driver_data = AZX_DRIVER_NVIDIA },
2137 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
2138 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
2139 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
2140 { PCI_DEVICE(0x10de, 0x0bd4), .driver_data = AZX_DRIVER_NVIDIA },
2141 { PCI_DEVICE(0x10de, 0x0bd5), .driver_data = AZX_DRIVER_NVIDIA },
2142 { PCI_DEVICE(0x10de, 0x0bd6), .driver_data = AZX_DRIVER_NVIDIA },
2143 { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA },
2039 { 0, } 2144 { 0, }
2040}; 2145};
2041MODULE_DEVICE_TABLE(pci, azx_ids); 2146MODULE_DEVICE_TABLE(pci, azx_ids);
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index ad0014ab71f9..5c9e578f7f2d 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -228,8 +228,18 @@ struct hda_multi_out {
228 int max_channels; /* currently supported analog channels */ 228 int max_channels; /* currently supported analog channels */
229 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ 229 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */
230 int no_share_stream; /* don't share a stream with multiple pins */ 230 int no_share_stream; /* don't share a stream with multiple pins */
231 int share_spdif; /* share SPDIF pin */
232 /* PCM information for both analog and SPDIF DACs */
233 unsigned int analog_rates;
234 unsigned int analog_maxbps;
235 u64 analog_formats;
236 unsigned int spdif_rates;
237 unsigned int spdif_maxbps;
238 u64 spdif_formats;
231}; 239};
232 240
241int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
242 struct hda_multi_out *mout);
233int snd_hda_multi_out_dig_open(struct hda_codec *codec, 243int snd_hda_multi_out_dig_open(struct hda_codec *codec,
234 struct hda_multi_out *mout); 244 struct hda_multi_out *mout);
235int snd_hda_multi_out_dig_close(struct hda_codec *codec, 245int snd_hda_multi_out_dig_close(struct hda_codec *codec,
@@ -241,7 +251,8 @@ int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
241 struct snd_pcm_substream *substream); 251 struct snd_pcm_substream *substream);
242int snd_hda_multi_out_analog_open(struct hda_codec *codec, 252int snd_hda_multi_out_analog_open(struct hda_codec *codec,
243 struct hda_multi_out *mout, 253 struct hda_multi_out *mout,
244 struct snd_pcm_substream *substream); 254 struct snd_pcm_substream *substream,
255 struct hda_pcm_stream *hinfo);
245int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, 256int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
246 struct hda_multi_out *mout, 257 struct hda_multi_out *mout,
247 unsigned int stream_tag, 258 unsigned int stream_tag,
@@ -407,11 +418,4 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
407 hda_nid_t nid); 418 hda_nid_t nid);
408#endif /* CONFIG_SND_HDA_POWER_SAVE */ 419#endif /* CONFIG_SND_HDA_POWER_SAVE */
409 420
410/*
411 * virtual master control
412 */
413struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
414 const unsigned int *tlv);
415int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave);
416
417#endif /* __SOUND_HDA_LOCAL_H */ 421#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h
index f5c23bb16d7e..2fdf2358dbc2 100644
--- a/sound/pci/hda/hda_patch.h
+++ b/sound/pci/hda/hda_patch.h
@@ -18,31 +18,3 @@ extern struct hda_codec_preset snd_hda_preset_atihdmi[];
18extern struct hda_codec_preset snd_hda_preset_conexant[]; 18extern struct hda_codec_preset snd_hda_preset_conexant[];
19/* VIA codecs */ 19/* VIA codecs */
20extern struct hda_codec_preset snd_hda_preset_via[]; 20extern struct hda_codec_preset snd_hda_preset_via[];
21
22static const struct hda_codec_preset *hda_preset_tables[] = {
23#ifdef CONFIG_SND_HDA_CODEC_REALTEK
24 snd_hda_preset_realtek,
25#endif
26#ifdef CONFIG_SND_HDA_CODEC_CMEDIA
27 snd_hda_preset_cmedia,
28#endif
29#ifdef CONFIG_SND_HDA_CODEC_ANALOG
30 snd_hda_preset_analog,
31#endif
32#ifdef CONFIG_SND_HDA_CODEC_SIGMATEL
33 snd_hda_preset_sigmatel,
34#endif
35#ifdef CONFIG_SND_HDA_CODEC_SI3054
36 snd_hda_preset_si3054,
37#endif
38#ifdef CONFIG_SND_HDA_CODEC_ATIHDMI
39 snd_hda_preset_atihdmi,
40#endif
41#ifdef CONFIG_SND_HDA_CODEC_CONEXANT
42 snd_hda_preset_conexant,
43#endif
44#ifdef CONFIG_SND_HDA_CODEC_VIA
45 snd_hda_preset_via,
46#endif
47 NULL
48};
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index c8649282c2cf..e0a605adde42 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -28,6 +28,7 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31#include "hda_patch.h"
31 32
32struct ad198x_spec { 33struct ad198x_spec {
33 struct snd_kcontrol_new *mixers[5]; 34 struct snd_kcontrol_new *mixers[5];
@@ -80,7 +81,6 @@ struct ad198x_spec {
80#endif 81#endif
81 /* for virtual master */ 82 /* for virtual master */
82 hda_nid_t vmaster_nid; 83 hda_nid_t vmaster_nid;
83 u32 vmaster_tlv[4];
84 const char **slave_vols; 84 const char **slave_vols;
85 const char **slave_sws; 85 const char **slave_sws;
86}; 86};
@@ -171,6 +171,11 @@ static int ad198x_build_controls(struct hda_codec *codec)
171 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 171 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
172 if (err < 0) 172 if (err < 0)
173 return err; 173 return err;
174 err = snd_hda_create_spdif_share_sw(codec,
175 &spec->multiout);
176 if (err < 0)
177 return err;
178 spec->multiout.share_spdif = 1;
174 } 179 }
175 if (spec->dig_in_nid) { 180 if (spec->dig_in_nid) {
176 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 181 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -180,10 +185,11 @@ static int ad198x_build_controls(struct hda_codec *codec)
180 185
181 /* if we have no master control, let's create it */ 186 /* if we have no master control, let's create it */
182 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 187 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
188 unsigned int vmaster_tlv[4];
183 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 189 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
184 HDA_OUTPUT, spec->vmaster_tlv); 190 HDA_OUTPUT, vmaster_tlv);
185 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 191 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
186 spec->vmaster_tlv, 192 vmaster_tlv,
187 (spec->slave_vols ? 193 (spec->slave_vols ?
188 spec->slave_vols : ad_slave_vols)); 194 spec->slave_vols : ad_slave_vols));
189 if (err < 0) 195 if (err < 0)
@@ -217,7 +223,8 @@ static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
217 struct snd_pcm_substream *substream) 223 struct snd_pcm_substream *substream)
218{ 224{
219 struct ad198x_spec *spec = codec->spec; 225 struct ad198x_spec *spec = codec->spec;
220 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 226 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
227 hinfo);
221} 228}
222 229
223static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 230static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -289,8 +296,7 @@ static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
289 struct snd_pcm_substream *substream) 296 struct snd_pcm_substream *substream)
290{ 297{
291 struct ad198x_spec *spec = codec->spec; 298 struct ad198x_spec *spec = codec->spec;
292 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 299 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
293 0, 0, 0);
294 return 0; 300 return 0;
295} 301}
296 302
@@ -359,6 +365,7 @@ static int ad198x_build_pcms(struct hda_codec *codec)
359 info++; 365 info++;
360 codec->num_pcms++; 366 codec->num_pcms++;
361 info->name = "AD198x Digital"; 367 info->name = "AD198x Digital";
368 info->pcm_type = HDA_PCM_TYPE_SPDIF;
362 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; 369 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
363 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 370 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
364 if (spec->dig_in_nid) { 371 if (spec->dig_in_nid) {
@@ -611,13 +618,19 @@ static struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
611 }, 618 },
612}; 619};
613 620
621static struct hda_input_mux ad1986a_automic_capture_source = {
622 .num_items = 2,
623 .items = {
624 { "Mic", 0x0 },
625 { "Mix", 0x5 },
626 },
627};
628
614static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { 629static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
615 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), 630 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
616 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), 631 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
617 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), 632 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
618 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), 633 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
619 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
620 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
622 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 635 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
623 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 636 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
@@ -641,6 +654,33 @@ static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
641 { } /* end */ 654 { } /* end */
642}; 655};
643 656
657/* re-connect the mic boost input according to the jack sensing */
658static void ad1986a_automic(struct hda_codec *codec)
659{
660 unsigned int present;
661 present = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_PIN_SENSE, 0);
662 /* 0 = 0x1f, 2 = 0x1d, 4 = mixed */
663 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_CONNECT_SEL,
664 (present & AC_PINSENSE_PRESENCE) ? 0 : 2);
665}
666
667#define AD1986A_MIC_EVENT 0x36
668
669static void ad1986a_automic_unsol_event(struct hda_codec *codec,
670 unsigned int res)
671{
672 if ((res >> 26) != AD1986A_MIC_EVENT)
673 return;
674 ad1986a_automic(codec);
675}
676
677static int ad1986a_automic_init(struct hda_codec *codec)
678{
679 ad198x_init(codec);
680 ad1986a_automic(codec);
681 return 0;
682}
683
644/* laptop-automute - 2ch only */ 684/* laptop-automute - 2ch only */
645 685
646static void ad1986a_update_hp(struct hda_codec *codec) 686static void ad1986a_update_hp(struct hda_codec *codec)
@@ -844,6 +884,15 @@ static struct hda_verb ad1986a_eapd_init_verbs[] = {
844 {} 884 {}
845}; 885};
846 886
887static struct hda_verb ad1986a_automic_verbs[] = {
888 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
889 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
890 /*{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},*/
891 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
892 {0x1f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_MIC_EVENT},
893 {}
894};
895
847/* Ultra initialization */ 896/* Ultra initialization */
848static struct hda_verb ad1986a_ultra_init[] = { 897static struct hda_verb ad1986a_ultra_init[] = {
849 /* eapd initialization */ 898 /* eapd initialization */
@@ -986,14 +1035,17 @@ static int patch_ad1986a(struct hda_codec *codec)
986 break; 1035 break;
987 case AD1986A_LAPTOP_EAPD: 1036 case AD1986A_LAPTOP_EAPD:
988 spec->mixers[0] = ad1986a_laptop_eapd_mixers; 1037 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
989 spec->num_init_verbs = 2; 1038 spec->num_init_verbs = 3;
990 spec->init_verbs[1] = ad1986a_eapd_init_verbs; 1039 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1040 spec->init_verbs[2] = ad1986a_automic_verbs;
991 spec->multiout.max_channels = 2; 1041 spec->multiout.max_channels = 2;
992 spec->multiout.num_dacs = 1; 1042 spec->multiout.num_dacs = 1;
993 spec->multiout.dac_nids = ad1986a_laptop_dac_nids; 1043 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
994 if (!is_jack_available(codec, 0x25)) 1044 if (!is_jack_available(codec, 0x25))
995 spec->multiout.dig_out_nid = 0; 1045 spec->multiout.dig_out_nid = 0;
996 spec->input_mux = &ad1986a_laptop_eapd_capture_source; 1046 spec->input_mux = &ad1986a_automic_capture_source;
1047 codec->patch_ops.unsol_event = ad1986a_automic_unsol_event;
1048 codec->patch_ops.init = ad1986a_automic_init;
997 break; 1049 break;
998 case AD1986A_LAPTOP_AUTOMUTE: 1050 case AD1986A_LAPTOP_AUTOMUTE:
999 spec->mixers[0] = ad1986a_laptop_automute_mixers; 1051 spec->mixers[0] = ad1986a_laptop_automute_mixers;
@@ -1365,7 +1417,10 @@ static int ad1981_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1365 1417
1366 if (! ad198x_eapd_put(kcontrol, ucontrol)) 1418 if (! ad198x_eapd_put(kcontrol, ucontrol))
1367 return 0; 1419 return 0;
1368 1420 /* change speaker pin appropriately */
1421 snd_hda_codec_write(codec, 0x05, 0,
1422 AC_VERB_SET_PIN_WIDGET_CONTROL,
1423 spec->cur_eapd ? PIN_OUT : 0);
1369 /* toggle HP mute appropriately */ 1424 /* toggle HP mute appropriately */
1370 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0, 1425 snd_hda_codec_amp_stereo(codec, 0x06, HDA_OUTPUT, 0,
1371 HDA_AMP_MUTE, 1426 HDA_AMP_MUTE,
@@ -2087,6 +2142,10 @@ static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = {
2087 { } /* end */ 2142 { } /* end */
2088}; 2143};
2089 2144
2145static struct snd_kcontrol_new ad1989_spdif_out_mixers[] = {
2146 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
2147 { } /* end */
2148};
2090 2149
2091/* 2150/*
2092 * initialization verbs 2151 * initialization verbs
@@ -2187,6 +2246,13 @@ static struct hda_verb ad1988_spdif_init_verbs[] = {
2187 { } 2246 { }
2188}; 2247};
2189 2248
2249/* AD1989 has no ADC -> SPDIF route */
2250static struct hda_verb ad1989_spdif_init_verbs[] = {
2251 /* SPDIF out pin */
2252 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
2253 { }
2254};
2255
2190/* 2256/*
2191 * verbs for 3stack (+dig) 2257 * verbs for 3stack (+dig)
2192 */ 2258 */
@@ -2894,10 +2960,19 @@ static int patch_ad1988(struct hda_codec *codec)
2894 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; 2960 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers;
2895 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; 2961 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs;
2896 if (spec->multiout.dig_out_nid) { 2962 if (spec->multiout.dig_out_nid) {
2897 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers; 2963 if (codec->vendor_id >= 0x11d4989a) {
2898 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs; 2964 spec->mixers[spec->num_mixers++] =
2965 ad1989_spdif_out_mixers;
2966 spec->init_verbs[spec->num_init_verbs++] =
2967 ad1989_spdif_init_verbs;
2968 } else {
2969 spec->mixers[spec->num_mixers++] =
2970 ad1988_spdif_out_mixers;
2971 spec->init_verbs[spec->num_init_verbs++] =
2972 ad1988_spdif_init_verbs;
2973 }
2899 } 2974 }
2900 if (spec->dig_in_nid) 2975 if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a)
2901 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; 2976 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
2902 2977
2903 codec->patch_ops = ad198x_patch_ops; 2978 codec->patch_ops = ad198x_patch_ops;
@@ -3133,11 +3208,12 @@ static int patch_ad1884(struct hda_codec *codec)
3133 * Lenovo Thinkpad T61/X61 3208 * Lenovo Thinkpad T61/X61
3134 */ 3209 */
3135static struct hda_input_mux ad1984_thinkpad_capture_source = { 3210static struct hda_input_mux ad1984_thinkpad_capture_source = {
3136 .num_items = 3, 3211 .num_items = 4,
3137 .items = { 3212 .items = {
3138 { "Mic", 0x0 }, 3213 { "Mic", 0x0 },
3139 { "Internal Mic", 0x1 }, 3214 { "Internal Mic", 0x1 },
3140 { "Mix", 0x3 }, 3215 { "Mix", 0x3 },
3216 { "Docking-Station", 0x4 },
3141 }, 3217 },
3142}; 3218};
3143 3219
@@ -3268,8 +3344,7 @@ static int ad1984_pcm_dmic_cleanup(struct hda_pcm_stream *hinfo,
3268 struct hda_codec *codec, 3344 struct hda_codec *codec,
3269 struct snd_pcm_substream *substream) 3345 struct snd_pcm_substream *substream)
3270{ 3346{
3271 snd_hda_codec_setup_stream(codec, 0x05 + substream->number, 3347 snd_hda_codec_cleanup_stream(codec, 0x05 + substream->number);
3272 0, 0, 0);
3273 return 0; 3348 return 0;
3274} 3349}
3275 3350
@@ -3356,6 +3431,472 @@ static int patch_ad1984(struct hda_codec *codec)
3356 3431
3357 3432
3358/* 3433/*
3434 * AD1883 / AD1884A / AD1984A / AD1984B
3435 *
3436 * port-B (0x14) - front mic-in
3437 * port-E (0x1c) - rear mic-in
3438 * port-F (0x16) - CD / ext out
3439 * port-C (0x15) - rear line-in
3440 * port-D (0x12) - rear line-out
3441 * port-A (0x11) - front hp-out
3442 *
3443 * AD1984A = AD1884A + digital-mic
3444 * AD1883 = equivalent with AD1984A
3445 * AD1984B = AD1984A + extra SPDIF-out
3446 *
3447 * FIXME:
3448 * We share the single DAC for both HP and line-outs (see AD1884/1984).
3449 */
3450
3451static hda_nid_t ad1884a_dac_nids[1] = {
3452 0x03,
3453};
3454
3455#define ad1884a_adc_nids ad1884_adc_nids
3456#define ad1884a_capsrc_nids ad1884_capsrc_nids
3457
3458#define AD1884A_SPDIF_OUT 0x02
3459
3460static struct hda_input_mux ad1884a_capture_source = {
3461 .num_items = 5,
3462 .items = {
3463 { "Front Mic", 0x0 },
3464 { "Mic", 0x4 },
3465 { "Line", 0x1 },
3466 { "CD", 0x2 },
3467 { "Mix", 0x3 },
3468 },
3469};
3470
3471static struct snd_kcontrol_new ad1884a_base_mixers[] = {
3472 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3473 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3474 HDA_CODEC_MUTE("Headphone Playback Switch", 0x11, 0x0, HDA_OUTPUT),
3475 HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3476 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
3477 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x13, 1, 0x0, HDA_OUTPUT),
3478 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3479 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3480 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3481 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3482 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x01, HDA_INPUT),
3483 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
3484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3485 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3486 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3487 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3488 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3489 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3490 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3491 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
3492 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3493 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3494 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3495 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3496 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3497 {
3498 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3499 /* The multiple "Capture Source" controls confuse alsamixer
3500 * So call somewhat different..
3501 */
3502 /* .name = "Capture Source", */
3503 .name = "Input Source",
3504 .count = 2,
3505 .info = ad198x_mux_enum_info,
3506 .get = ad198x_mux_enum_get,
3507 .put = ad198x_mux_enum_put,
3508 },
3509 /* SPDIF controls */
3510 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
3511 {
3512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3513 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
3514 /* identical with ad1983 */
3515 .info = ad1983_spdif_route_info,
3516 .get = ad1983_spdif_route_get,
3517 .put = ad1983_spdif_route_put,
3518 },
3519 { } /* end */
3520};
3521
3522/*
3523 * initialization verbs
3524 */
3525static struct hda_verb ad1884a_init_verbs[] = {
3526 /* DACs; unmute as default */
3527 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3528 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */
3529 /* Port-A (HP) mixer - route only from analog mixer */
3530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3532 /* Port-A pin */
3533 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3534 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3535 /* Port-D (Line-out) mixer - route only from analog mixer */
3536 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3537 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3538 /* Port-D pin */
3539 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3540 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3541 /* Mono-out mixer - route only from analog mixer */
3542 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3543 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3544 /* Mono-out pin */
3545 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3546 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3547 /* Port-B (front mic) pin */
3548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3550 /* Port-C (rear line-in) pin */
3551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3553 /* Port-E (rear mic) pin */
3554 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3555 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3556 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, /* no boost */
3557 /* Port-F (CD) pin */
3558 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3559 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3560 /* Analog mixer; mute as default */
3561 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3562 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3563 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3564 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3565 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, /* aux */
3566 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
3567 /* Analog Mix output amp */
3568 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3569 /* capture sources */
3570 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
3571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3572 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
3573 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3574 /* SPDIF output amp */
3575 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */
3576 { } /* end */
3577};
3578
3579#ifdef CONFIG_SND_HDA_POWER_SAVE
3580static struct hda_amp_list ad1884a_loopbacks[] = {
3581 { 0x20, HDA_INPUT, 0 }, /* Front Mic */
3582 { 0x20, HDA_INPUT, 1 }, /* Mic */
3583 { 0x20, HDA_INPUT, 2 }, /* CD */
3584 { 0x20, HDA_INPUT, 4 }, /* Docking */
3585 { } /* end */
3586};
3587#endif
3588
3589/*
3590 * Laptop model
3591 *
3592 * Port A: Headphone jack
3593 * Port B: MIC jack
3594 * Port C: Internal MIC
3595 * Port D: Dock Line Out (if enabled)
3596 * Port E: Dock Line In (if enabled)
3597 * Port F: Internal speakers
3598 */
3599
3600static struct hda_input_mux ad1884a_laptop_capture_source = {
3601 .num_items = 4,
3602 .items = {
3603 { "Mic", 0x0 }, /* port-B */
3604 { "Internal Mic", 0x1 }, /* port-C */
3605 { "Dock Mic", 0x4 }, /* port-E */
3606 { "Mix", 0x3 },
3607 },
3608};
3609
3610static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3611 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3612 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3613 HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT),
3614 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3615 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3617 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3618 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3619 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3620 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3621 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3622 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3623 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3624 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3625 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3626 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3627 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3628 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3629 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
3630 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT),
3631 {
3632 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3633 /* The multiple "Capture Source" controls confuse alsamixer
3634 * So call somewhat different..
3635 */
3636 /* .name = "Capture Source", */
3637 .name = "Input Source",
3638 .count = 2,
3639 .info = ad198x_mux_enum_info,
3640 .get = ad198x_mux_enum_get,
3641 .put = ad198x_mux_enum_put,
3642 },
3643 { } /* end */
3644};
3645
3646static struct hda_input_mux ad1884a_mobile_capture_source = {
3647 .num_items = 2,
3648 .items = {
3649 { "Mic", 0x1 }, /* port-C */
3650 { "Mix", 0x3 },
3651 },
3652};
3653
3654static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
3655 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3656 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3657 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3658 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3660 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3661 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3662 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3663 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
3664 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3665 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3666 {
3667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3668 .name = "Capture Source",
3669 .info = ad198x_mux_enum_info,
3670 .get = ad198x_mux_enum_get,
3671 .put = ad198x_mux_enum_put,
3672 },
3673 { } /* end */
3674};
3675
3676/* mute internal speaker if HP is plugged */
3677static void ad1884a_hp_automute(struct hda_codec *codec)
3678{
3679 unsigned int present;
3680
3681 present = snd_hda_codec_read(codec, 0x11, 0,
3682 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
3683 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
3684 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3685 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE,
3686 present ? 0x00 : 0x02);
3687}
3688
3689#define AD1884A_HP_EVENT 0x37
3690
3691/* unsolicited event for HP jack sensing */
3692static void ad1884a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3693{
3694 if ((res >> 26) != AD1884A_HP_EVENT)
3695 return;
3696 ad1884a_hp_automute(codec);
3697}
3698
3699/* initialize jack-sensing, too */
3700static int ad1884a_hp_init(struct hda_codec *codec)
3701{
3702 ad198x_init(codec);
3703 ad1884a_hp_automute(codec);
3704 return 0;
3705}
3706
3707/* additional verbs for laptop model */
3708static struct hda_verb ad1884a_laptop_verbs[] = {
3709 /* Port-A (HP) pin - always unmuted */
3710 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3711 /* Port-F (int speaker) mixer - route only from analog mixer */
3712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3714 /* Port-F pin */
3715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3717 /* analog mix */
3718 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3719 /* unsolicited event for pin-sense */
3720 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3721 { } /* end */
3722};
3723
3724/*
3725 * Thinkpad X300
3726 * 0x11 - HP
3727 * 0x12 - speaker
3728 * 0x14 - mic-in
3729 * 0x17 - built-in mic
3730 */
3731
3732static struct hda_verb ad1984a_thinkpad_verbs[] = {
3733 /* HP unmute */
3734 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3735 /* analog mix */
3736 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3737 /* turn on EAPD */
3738 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3739 /* unsolicited event for pin-sense */
3740 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3741 /* internal mic - dmic */
3742 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3743 /* set magic COEFs for dmic */
3744 {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
3745 {0x01, AC_VERB_SET_PROC_COEF, 0x08},
3746 { } /* end */
3747};
3748
3749static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = {
3750 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3751 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3752 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3753 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3754 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3755 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3756 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3757 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3758 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3759 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
3760 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3761 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3762 {
3763 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3764 .name = "Capture Source",
3765 .info = ad198x_mux_enum_info,
3766 .get = ad198x_mux_enum_get,
3767 .put = ad198x_mux_enum_put,
3768 },
3769 { } /* end */
3770};
3771
3772static struct hda_input_mux ad1984a_thinkpad_capture_source = {
3773 .num_items = 3,
3774 .items = {
3775 { "Mic", 0x0 },
3776 { "Internal Mic", 0x5 },
3777 { "Mix", 0x3 },
3778 },
3779};
3780
3781/* mute internal speaker if HP is plugged */
3782static void ad1984a_thinkpad_automute(struct hda_codec *codec)
3783{
3784 unsigned int present;
3785
3786 present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0)
3787 & AC_PINSENSE_PRESENCE;
3788 snd_hda_codec_amp_stereo(codec, 0x12, HDA_OUTPUT, 0,
3789 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
3790}
3791
3792/* unsolicited event for HP jack sensing */
3793static void ad1984a_thinkpad_unsol_event(struct hda_codec *codec,
3794 unsigned int res)
3795{
3796 if ((res >> 26) != AD1884A_HP_EVENT)
3797 return;
3798 ad1984a_thinkpad_automute(codec);
3799}
3800
3801/* initialize jack-sensing, too */
3802static int ad1984a_thinkpad_init(struct hda_codec *codec)
3803{
3804 ad198x_init(codec);
3805 ad1984a_thinkpad_automute(codec);
3806 return 0;
3807}
3808
3809/*
3810 */
3811
3812enum {
3813 AD1884A_DESKTOP,
3814 AD1884A_LAPTOP,
3815 AD1884A_MOBILE,
3816 AD1884A_THINKPAD,
3817 AD1884A_MODELS
3818};
3819
3820static const char *ad1884a_models[AD1884A_MODELS] = {
3821 [AD1884A_DESKTOP] = "desktop",
3822 [AD1884A_LAPTOP] = "laptop",
3823 [AD1884A_MOBILE] = "mobile",
3824 [AD1884A_THINKPAD] = "thinkpad",
3825};
3826
3827static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3828 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
3829 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
3830 {}
3831};
3832
3833static int patch_ad1884a(struct hda_codec *codec)
3834{
3835 struct ad198x_spec *spec;
3836 int board_config;
3837
3838 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3839 if (spec == NULL)
3840 return -ENOMEM;
3841
3842 mutex_init(&spec->amp_mutex);
3843 codec->spec = spec;
3844
3845 spec->multiout.max_channels = 2;
3846 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
3847 spec->multiout.dac_nids = ad1884a_dac_nids;
3848 spec->multiout.dig_out_nid = AD1884A_SPDIF_OUT;
3849 spec->num_adc_nids = ARRAY_SIZE(ad1884a_adc_nids);
3850 spec->adc_nids = ad1884a_adc_nids;
3851 spec->capsrc_nids = ad1884a_capsrc_nids;
3852 spec->input_mux = &ad1884a_capture_source;
3853 spec->num_mixers = 1;
3854 spec->mixers[0] = ad1884a_base_mixers;
3855 spec->num_init_verbs = 1;
3856 spec->init_verbs[0] = ad1884a_init_verbs;
3857 spec->spdif_route = 0;
3858#ifdef CONFIG_SND_HDA_POWER_SAVE
3859 spec->loopback.amplist = ad1884a_loopbacks;
3860#endif
3861 codec->patch_ops = ad198x_patch_ops;
3862
3863 /* override some parameters */
3864 board_config = snd_hda_check_board_config(codec, AD1884A_MODELS,
3865 ad1884a_models,
3866 ad1884a_cfg_tbl);
3867 switch (board_config) {
3868 case AD1884A_LAPTOP:
3869 spec->mixers[0] = ad1884a_laptop_mixers;
3870 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
3871 spec->multiout.dig_out_nid = 0;
3872 spec->input_mux = &ad1884a_laptop_capture_source;
3873 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3874 codec->patch_ops.init = ad1884a_hp_init;
3875 break;
3876 case AD1884A_MOBILE:
3877 spec->mixers[0] = ad1884a_mobile_mixers;
3878 spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs;
3879 spec->multiout.dig_out_nid = 0;
3880 spec->input_mux = &ad1884a_mobile_capture_source;
3881 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3882 codec->patch_ops.init = ad1884a_hp_init;
3883 break;
3884 case AD1884A_THINKPAD:
3885 spec->mixers[0] = ad1984a_thinkpad_mixers;
3886 spec->init_verbs[spec->num_init_verbs++] =
3887 ad1984a_thinkpad_verbs;
3888 spec->multiout.dig_out_nid = 0;
3889 spec->input_mux = &ad1984a_thinkpad_capture_source;
3890 codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event;
3891 codec->patch_ops.init = ad1984a_thinkpad_init;
3892 break;
3893 }
3894
3895 return 0;
3896}
3897
3898
3899/*
3359 * AD1882 3900 * AD1882
3360 * 3901 *
3361 * port-A - front hp-out 3902 * port-A - front hp-out
@@ -3654,13 +4195,19 @@ static int patch_ad1882(struct hda_codec *codec)
3654 * patch entries 4195 * patch entries
3655 */ 4196 */
3656struct hda_codec_preset snd_hda_preset_analog[] = { 4197struct hda_codec_preset snd_hda_preset_analog[] = {
4198 { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884a },
3657 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 }, 4199 { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
4200 { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884a },
3658 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 }, 4201 { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
4202 { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884a },
4203 { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884a },
3659 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, 4204 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
3660 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, 4205 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
3661 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 }, 4206 { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1984 },
3662 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, 4207 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
3663 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, 4208 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
3664 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 }, 4209 { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
4210 { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
4211 { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
3665 {} /* terminator */ 4212 {} /* terminator */
3666}; 4213};
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index 9a8bb4ce3f8d..12272508b112 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -27,6 +27,7 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include "hda_codec.h" 28#include "hda_codec.h"
29#include "hda_local.h" 29#include "hda_local.h"
30#include "hda_patch.h"
30 31
31struct atihdmi_spec { 32struct atihdmi_spec {
32 struct hda_multi_out multiout; 33 struct hda_multi_out multiout;
@@ -58,6 +59,10 @@ static int atihdmi_build_controls(struct hda_codec *codec)
58static int atihdmi_init(struct hda_codec *codec) 59static int atihdmi_init(struct hda_codec *codec)
59{ 60{
60 snd_hda_sequence_write(codec, atihdmi_basic_init); 61 snd_hda_sequence_write(codec, atihdmi_basic_init);
62 /* SI codec requires to unmute the pin */
63 if (get_wcaps(codec, 0x03) & AC_WCAP_OUT_AMP)
64 snd_hda_codec_write(codec, 0x03, 0, AC_VERB_SET_AMP_GAIN_MUTE,
65 AMP_OUT_UNMUTE);
61 return 0; 66 return 0;
62} 67}
63 68
@@ -112,6 +117,7 @@ static int atihdmi_build_pcms(struct hda_codec *codec)
112 codec->pcm_info = info; 117 codec->pcm_info = info;
113 118
114 info->name = "ATI HDMI"; 119 info->name = "ATI HDMI";
120 info->pcm_type = HDA_PCM_TYPE_HDMI;
115 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = atihdmi_pcm_digital_playback; 121 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = atihdmi_pcm_digital_playback;
116 122
117 return 0; 123 return 0;
@@ -158,5 +164,7 @@ struct hda_codec_preset snd_hda_preset_atihdmi[] = {
158 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 164 { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
159 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi }, 165 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
160 { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi }, 166 { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi },
167 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_atihdmi },
168 { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_atihdmi },
161 {} /* terminator */ 169 {} /* terminator */
162}; 170};
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 3d6097ba1d68..c73ce074a6ea 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -28,6 +28,7 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31#include "hda_patch.h"
31#define NUM_PINS 11 32#define NUM_PINS 11
32 33
33 34
@@ -329,6 +330,11 @@ static int cmi9880_build_controls(struct hda_codec *codec)
329 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 330 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
330 if (err < 0) 331 if (err < 0)
331 return err; 332 return err;
333 err = snd_hda_create_spdif_share_sw(codec,
334 &spec->multiout);
335 if (err < 0)
336 return err;
337 spec->multiout.share_spdif = 1;
332 } 338 }
333 if (spec->dig_in_nid) { 339 if (spec->dig_in_nid) {
334 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 340 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -432,7 +438,8 @@ static int cmi9880_playback_pcm_open(struct hda_pcm_stream *hinfo,
432 struct snd_pcm_substream *substream) 438 struct snd_pcm_substream *substream)
433{ 439{
434 struct cmi_spec *spec = codec->spec; 440 struct cmi_spec *spec = codec->spec;
435 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 441 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
442 hinfo);
436} 443}
437 444
438static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 445static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -506,7 +513,7 @@ static int cmi9880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
506{ 513{
507 struct cmi_spec *spec = codec->spec; 514 struct cmi_spec *spec = codec->spec;
508 515
509 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); 516 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
510 return 0; 517 return 0;
511} 518}
512 519
@@ -571,6 +578,7 @@ static int cmi9880_build_pcms(struct hda_codec *codec)
571 codec->num_pcms++; 578 codec->num_pcms++;
572 info++; 579 info++;
573 info->name = "CMI9880 Digital"; 580 info->name = "CMI9880 Digital";
581 info->pcm_type = HDA_PCM_TYPE_SPDIF;
574 if (spec->multiout.dig_out_nid) { 582 if (spec->multiout.dig_out_nid) {
575 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cmi9880_pcm_digital_playback; 583 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cmi9880_pcm_digital_playback;
576 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 584 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
@@ -603,6 +611,7 @@ static const char *cmi9880_models[CMI_MODELS] = {
603 611
604static struct snd_pci_quirk cmi9880_cfg_tbl[] = { 612static struct snd_pci_quirk cmi9880_cfg_tbl[] = {
605 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG), 613 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", CMI_FULL_DIG),
614 SND_PCI_QUIRK(0x1854, 0x0032, "LG", CMI_FULL_DIG),
606 {} /* terminator */ 615 {} /* terminator */
607}; 616};
608 617
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 7206b30cbf94..36fd85260035 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -27,6 +27,7 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include "hda_codec.h" 28#include "hda_codec.h"
29#include "hda_local.h" 29#include "hda_local.h"
30#include "hda_patch.h"
30 31
31#define CXT_PIN_DIR_IN 0x00 32#define CXT_PIN_DIR_IN 0x00
32#define CXT_PIN_DIR_OUT 0x01 33#define CXT_PIN_DIR_OUT 0x01
@@ -98,7 +99,8 @@ static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
98 struct snd_pcm_substream *substream) 99 struct snd_pcm_substream *substream)
99{ 100{
100 struct conexant_spec *spec = codec->spec; 101 struct conexant_spec *spec = codec->spec;
101 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 102 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
103 hinfo);
102} 104}
103 105
104static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 106static int conexant_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -172,8 +174,7 @@ static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
172 struct snd_pcm_substream *substream) 174 struct snd_pcm_substream *substream)
173{ 175{
174 struct conexant_spec *spec = codec->spec; 176 struct conexant_spec *spec = codec->spec;
175 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 177 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
176 0, 0, 0);
177 return 0; 178 return 0;
178} 179}
179 180
@@ -241,7 +242,7 @@ static int cx5051_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
241 struct snd_pcm_substream *substream) 242 struct snd_pcm_substream *substream)
242{ 243{
243 struct conexant_spec *spec = codec->spec; 244 struct conexant_spec *spec = codec->spec;
244 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0); 245 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
245 spec->cur_adc = 0; 246 spec->cur_adc = 0;
246 return 0; 247 return 0;
247} 248}
@@ -284,6 +285,7 @@ static int conexant_build_pcms(struct hda_codec *codec)
284 info++; 285 info++;
285 codec->num_pcms++; 286 codec->num_pcms++;
286 info->name = "Conexant Digital"; 287 info->name = "Conexant Digital";
288 info->pcm_type = HDA_PCM_TYPE_SPDIF;
287 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 289 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
288 conexant_pcm_digital_playback; 290 conexant_pcm_digital_playback;
289 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 291 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
@@ -371,6 +373,11 @@ static int conexant_build_controls(struct hda_codec *codec)
371 spec->multiout.dig_out_nid); 373 spec->multiout.dig_out_nid);
372 if (err < 0) 374 if (err < 0)
373 return err; 375 return err;
376 err = snd_hda_create_spdif_share_sw(codec,
377 &spec->multiout);
378 if (err < 0)
379 return err;
380 spec->multiout.share_spdif = 1;
374 } 381 }
375 if (spec->dig_in_nid) { 382 if (spec->dig_in_nid) {
376 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid); 383 err = snd_hda_create_spdif_in_ctls(codec,spec->dig_in_nid);
@@ -511,6 +518,14 @@ static struct hda_input_mux cxt5045_capture_source_benq = {
511 } 518 }
512}; 519};
513 520
521static struct hda_input_mux cxt5045_capture_source_hp530 = {
522 .num_items = 2,
523 .items = {
524 { "ExtMic", 0x1 },
525 { "IntMic", 0x2 },
526 }
527};
528
514/* turn on/off EAPD (+ mute HP) as a master switch */ 529/* turn on/off EAPD (+ mute HP) as a master switch */
515static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 530static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol) 531 struct snd_ctl_elem_value *ucontrol)
@@ -639,6 +654,37 @@ static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
639 {} 654 {}
640}; 655};
641 656
657static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
658 {
659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
660 .name = "Capture Source",
661 .info = conexant_mux_enum_info,
662 .get = conexant_mux_enum_get,
663 .put = conexant_mux_enum_put
664 },
665 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
666 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
667 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
668 HDA_CODEC_MUTE("Ext Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
669 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
670 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
671 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
672 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
673 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
674 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
675 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
676 {
677 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
678 .name = "Master Playback Switch",
679 .info = cxt_eapd_info,
680 .get = cxt_eapd_get,
681 .put = cxt5045_hp_master_sw_put,
682 .private_value = 0x10,
683 },
684
685 {}
686};
687
642static struct hda_verb cxt5045_init_verbs[] = { 688static struct hda_verb cxt5045_init_verbs[] = {
643 /* Line in, Mic */ 689 /* Line in, Mic */
644 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 690 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
@@ -833,6 +879,7 @@ enum {
833 CXT5045_LAPTOP_MICSENSE, 879 CXT5045_LAPTOP_MICSENSE,
834 CXT5045_LAPTOP_HPMICSENSE, 880 CXT5045_LAPTOP_HPMICSENSE,
835 CXT5045_BENQ, 881 CXT5045_BENQ,
882 CXT5045_LAPTOP_HP530,
836#ifdef CONFIG_SND_DEBUG 883#ifdef CONFIG_SND_DEBUG
837 CXT5045_TEST, 884 CXT5045_TEST,
838#endif 885#endif
@@ -844,6 +891,7 @@ static const char *cxt5045_models[CXT5045_MODELS] = {
844 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 891 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
845 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 892 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
846 [CXT5045_BENQ] = "benq", 893 [CXT5045_BENQ] = "benq",
894 [CXT5045_LAPTOP_HP530] = "laptop-hp530",
847#ifdef CONFIG_SND_DEBUG 895#ifdef CONFIG_SND_DEBUG
848 [CXT5045_TEST] = "test", 896 [CXT5045_TEST] = "test",
849#endif 897#endif
@@ -857,7 +905,7 @@ static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
857 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE), 905 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
858 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE), 906 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
859 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE), 907 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
860 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HPSENSE), 908 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
861 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE), 909 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE),
862 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 910 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
863 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 911 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
@@ -941,6 +989,14 @@ static int patch_cxt5045(struct hda_codec *codec)
941 spec->num_mixers = 2; 989 spec->num_mixers = 2;
942 codec->patch_ops.init = cxt5045_init; 990 codec->patch_ops.init = cxt5045_init;
943 break; 991 break;
992 case CXT5045_LAPTOP_HP530:
993 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
994 spec->input_mux = &cxt5045_capture_source_hp530;
995 spec->num_init_verbs = 2;
996 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
997 spec->mixers[0] = cxt5045_mixers_hp530;
998 codec->patch_ops.init = cxt5045_init;
999 break;
944#ifdef CONFIG_SND_DEBUG 1000#ifdef CONFIG_SND_DEBUG
945 case CXT5045_TEST: 1001 case CXT5045_TEST:
946 spec->input_mux = &cxt5045_test_capture_source; 1002 spec->input_mux = &cxt5045_test_capture_source;
@@ -1537,7 +1593,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec)
1537 new_adc = spec->adc_nids[spec->cur_adc_idx]; 1593 new_adc = spec->adc_nids[spec->cur_adc_idx];
1538 if (spec->cur_adc && spec->cur_adc != new_adc) { 1594 if (spec->cur_adc && spec->cur_adc != new_adc) {
1539 /* stream is running, let's swap the current ADC */ 1595 /* stream is running, let's swap the current ADC */
1540 snd_hda_codec_setup_stream(codec, spec->cur_adc, 0, 0, 0); 1596 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
1541 spec->cur_adc = new_adc; 1597 spec->cur_adc = new_adc;
1542 snd_hda_codec_setup_stream(codec, new_adc, 1598 snd_hda_codec_setup_stream(codec, new_adc,
1543 spec->cur_adc_stream_tag, 0, 1599 spec->cur_adc_stream_tag, 0,
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 33282f9c01c7..6d4df45e81e0 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -30,6 +30,7 @@
30#include <sound/core.h> 30#include <sound/core.h>
31#include "hda_codec.h" 31#include "hda_codec.h"
32#include "hda_local.h" 32#include "hda_local.h"
33#include "hda_patch.h"
33 34
34#define ALC880_FRONT_EVENT 0x01 35#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02 36#define ALC880_DCVOL_EVENT 0x02
@@ -59,6 +60,7 @@ enum {
59 ALC880_TCL_S700, 60 ALC880_TCL_S700,
60 ALC880_LG, 61 ALC880_LG,
61 ALC880_LG_LW, 62 ALC880_LG_LW,
63 ALC880_MEDION_RIM,
62#ifdef CONFIG_SND_DEBUG 64#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST, 65 ALC880_TEST,
64#endif 66#endif
@@ -97,16 +99,19 @@ enum {
97 ALC262_SONY_ASSAMD, 99 ALC262_SONY_ASSAMD,
98 ALC262_BENQ_T31, 100 ALC262_BENQ_T31,
99 ALC262_ULTRA, 101 ALC262_ULTRA,
102 ALC262_LENOVO_3000,
100 ALC262_AUTO, 103 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */ 104 ALC262_MODEL_LAST /* last tag */
102}; 105};
103 106
104/* ALC268 models */ 107/* ALC268 models */
105enum { 108enum {
109 ALC267_QUANTA_IL1,
106 ALC268_3ST, 110 ALC268_3ST,
107 ALC268_TOSHIBA, 111 ALC268_TOSHIBA,
108 ALC268_ACER, 112 ALC268_ACER,
109 ALC268_DELL, 113 ALC268_DELL,
114 ALC268_ZEPTO,
110#ifdef CONFIG_SND_DEBUG 115#ifdef CONFIG_SND_DEBUG
111 ALC268_TEST, 116 ALC268_TEST,
112#endif 117#endif
@@ -195,10 +200,11 @@ enum {
195 ALC883_LENOVO_NB0763, 200 ALC883_LENOVO_NB0763,
196 ALC888_LENOVO_MS7195_DIG, 201 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66, 202 ALC883_HAIER_W66,
198 ALC888_6ST_HP,
199 ALC888_3ST_HP, 203 ALC888_3ST_HP,
200 ALC888_6ST_DELL, 204 ALC888_6ST_DELL,
201 ALC883_MITAC, 205 ALC883_MITAC,
206 ALC883_CLEVO_M720,
207 ALC883_FUJITSU_PI2515,
202 ALC883_AUTO, 208 ALC883_AUTO,
203 ALC883_MODEL_LAST, 209 ALC883_MODEL_LAST,
204}; 210};
@@ -237,6 +243,7 @@ struct alc_spec {
237 /* capture */ 243 /* capture */
238 unsigned int num_adc_nids; 244 unsigned int num_adc_nids;
239 hda_nid_t *adc_nids; 245 hda_nid_t *adc_nids;
246 hda_nid_t *capsrc_nids;
240 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 247 hda_nid_t dig_in_nid; /* digital-in NID; optional */
241 248
242 /* capture source */ 249 /* capture source */
@@ -270,7 +277,6 @@ struct alc_spec {
270 277
271 /* for virtual master */ 278 /* for virtual master */
272 hda_nid_t vmaster_nid; 279 hda_nid_t vmaster_nid;
273 u32 vmaster_tlv[4];
274#ifdef CONFIG_SND_HDA_POWER_SAVE 280#ifdef CONFIG_SND_HDA_POWER_SAVE
275 struct hda_loopback_check loopback; 281 struct hda_loopback_check loopback;
276#endif 282#endif
@@ -290,6 +296,7 @@ struct alc_config_preset {
290 hda_nid_t hp_nid; /* optional */ 296 hda_nid_t hp_nid; /* optional */
291 unsigned int num_adc_nids; 297 unsigned int num_adc_nids;
292 hda_nid_t *adc_nids; 298 hda_nid_t *adc_nids;
299 hda_nid_t *capsrc_nids;
293 hda_nid_t dig_in_nid; 300 hda_nid_t dig_in_nid;
294 unsigned int num_channel_mode; 301 unsigned int num_channel_mode;
295 const struct hda_channel_mode *channel_mode; 302 const struct hda_channel_mode *channel_mode;
@@ -336,9 +343,10 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
336 struct alc_spec *spec = codec->spec; 343 struct alc_spec *spec = codec->spec;
337 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 344 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
338 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 345 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
346 hda_nid_t nid = spec->capsrc_nids ?
347 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
339 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol, 348 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
340 spec->adc_nids[adc_idx], 349 nid, &spec->cur_mux[adc_idx]);
341 &spec->cur_mux[adc_idx]);
342} 350}
343 351
344 352
@@ -707,6 +715,7 @@ static void setup_preset(struct alc_spec *spec,
707 715
708 spec->num_adc_nids = preset->num_adc_nids; 716 spec->num_adc_nids = preset->num_adc_nids;
709 spec->adc_nids = preset->adc_nids; 717 spec->adc_nids = preset->adc_nids;
718 spec->capsrc_nids = preset->capsrc_nids;
710 spec->dig_in_nid = preset->dig_in_nid; 719 spec->dig_in_nid = preset->dig_in_nid;
711 720
712 spec->unsol_event = preset->unsol_event; 721 spec->unsol_event = preset->unsol_event;
@@ -741,7 +750,6 @@ static struct hda_verb alc_gpio3_init_verbs[] = {
741static void alc_sku_automute(struct hda_codec *codec) 750static void alc_sku_automute(struct hda_codec *codec)
742{ 751{
743 struct alc_spec *spec = codec->spec; 752 struct alc_spec *spec = codec->spec;
744 unsigned int mute;
745 unsigned int present; 753 unsigned int present;
746 unsigned int hp_nid = spec->autocfg.hp_pins[0]; 754 unsigned int hp_nid = spec->autocfg.hp_pins[0];
747 unsigned int sp_nid = spec->autocfg.speaker_pins[0]; 755 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
@@ -751,16 +759,8 @@ static void alc_sku_automute(struct hda_codec *codec)
751 present = snd_hda_codec_read(codec, hp_nid, 0, 759 present = snd_hda_codec_read(codec, hp_nid, 0,
752 AC_VERB_GET_PIN_SENSE, 0); 760 AC_VERB_GET_PIN_SENSE, 0);
753 spec->jack_present = (present & 0x80000000) != 0; 761 spec->jack_present = (present & 0x80000000) != 0;
754 if (spec->jack_present) { 762 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
755 /* mute internal speaker */ 763 spec->jack_present ? 0 : PIN_OUT);
756 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
757 HDA_AMP_MUTE, HDA_AMP_MUTE);
758 } else {
759 /* unmute internal speaker if necessary */
760 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
761 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
762 HDA_AMP_MUTE, mute);
763 }
764} 764}
765 765
766/* unsolicited event for HP jack sensing */ 766/* unsolicited event for HP jack sensing */
@@ -1319,11 +1319,19 @@ static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1319 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 1319 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1324 { } /* end */ 1324 { } /* end */
1325}; 1325};
1326 1326
1327static struct hda_input_mux alc880_f1734_capture_source = {
1328 .num_items = 2,
1329 .items = {
1330 { "Mic", 0x1 },
1331 { "CD", 0x4 },
1332 },
1333};
1334
1327 1335
1328/* 1336/*
1329 * ALC880 ASUS model 1337 * ALC880 ASUS model
@@ -1516,6 +1524,11 @@ static int alc_build_controls(struct hda_codec *codec)
1516 spec->multiout.dig_out_nid); 1524 spec->multiout.dig_out_nid);
1517 if (err < 0) 1525 if (err < 0)
1518 return err; 1526 return err;
1527 err = snd_hda_create_spdif_share_sw(codec,
1528 &spec->multiout);
1529 if (err < 0)
1530 return err;
1531 spec->multiout.share_spdif = 1;
1519 } 1532 }
1520 if (spec->dig_in_nid) { 1533 if (spec->dig_in_nid) {
1521 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 1534 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -1525,10 +1538,11 @@ static int alc_build_controls(struct hda_codec *codec)
1525 1538
1526 /* if we have no master control, let's create it */ 1539 /* if we have no master control, let's create it */
1527 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 1540 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1541 unsigned int vmaster_tlv[4];
1528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 1542 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1529 HDA_OUTPUT, spec->vmaster_tlv); 1543 HDA_OUTPUT, vmaster_tlv);
1530 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 1544 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1531 spec->vmaster_tlv, alc_slave_vols); 1545 vmaster_tlv, alc_slave_vols);
1532 if (err < 0) 1546 if (err < 0)
1533 return err; 1547 return err;
1534 } 1548 }
@@ -1882,7 +1896,7 @@ static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1882 present = snd_hda_codec_read(codec, 0x14, 0, 1896 present = snd_hda_codec_read(codec, 0x14, 0,
1883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1897 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1884 bits = present ? HDA_AMP_MUTE : 0; 1898 bits = present ? HDA_AMP_MUTE : 0;
1885 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits); 1899 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
1886} 1900}
1887 1901
1888static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 1902static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -1915,6 +1929,7 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1915 * HP = 0x14, speaker-out = 0x15, mic = 0x18 1929 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1916 */ 1930 */
1917static struct hda_verb alc880_pin_f1734_init_verbs[] = { 1931static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1932 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
1918 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, 1933 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1919 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, 1934 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1920 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, 1935 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
@@ -1927,7 +1942,7 @@ static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1927 1942
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1943 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1944 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1947 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1948 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -1935,6 +1950,9 @@ static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1950 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1951 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1937 1952
1953 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
1954 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
1955
1938 { } 1956 { }
1939}; 1957};
1940 1958
@@ -2258,6 +2276,75 @@ static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2258 alc880_lg_lw_automute(codec); 2276 alc880_lg_lw_automute(codec);
2259} 2277}
2260 2278
2279static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2280 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2281 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2284 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2285 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2286 { } /* end */
2287};
2288
2289static struct hda_input_mux alc880_medion_rim_capture_source = {
2290 .num_items = 2,
2291 .items = {
2292 { "Mic", 0x0 },
2293 { "Internal Mic", 0x1 },
2294 },
2295};
2296
2297static struct hda_verb alc880_medion_rim_init_verbs[] = {
2298 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2299
2300 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302
2303 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2304 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2305 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2306 /* Mic2 (as headphone out) for HP output */
2307 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2308 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2309 /* Internal Speaker */
2310 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2311 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2312
2313 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2314 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2315
2316 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2317 { }
2318};
2319
2320/* toggle speaker-output according to the hp-jack state */
2321static void alc880_medion_rim_automute(struct hda_codec *codec)
2322{
2323 unsigned int present;
2324 unsigned char bits;
2325
2326 present = snd_hda_codec_read(codec, 0x14, 0,
2327 AC_VERB_GET_PIN_SENSE, 0)
2328 & AC_PINSENSE_PRESENCE;
2329 bits = present ? HDA_AMP_MUTE : 0;
2330 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2331 HDA_AMP_MUTE, bits);
2332 if (present)
2333 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2334 else
2335 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2336}
2337
2338static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2339 unsigned int res)
2340{
2341 /* Looks like the unsol event is incompatible with the standard
2342 * definition. 4bit tag is placed at 28 bit!
2343 */
2344 if ((res >> 28) == ALC880_HP_EVENT)
2345 alc880_medion_rim_automute(codec);
2346}
2347
2261#ifdef CONFIG_SND_HDA_POWER_SAVE 2348#ifdef CONFIG_SND_HDA_POWER_SAVE
2262static struct hda_amp_list alc880_loopbacks[] = { 2349static struct hda_amp_list alc880_loopbacks[] = {
2263 { 0x0b, HDA_INPUT, 0 }, 2350 { 0x0b, HDA_INPUT, 0 },
@@ -2318,7 +2405,8 @@ static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2318 struct snd_pcm_substream *substream) 2405 struct snd_pcm_substream *substream)
2319{ 2406{
2320 struct alc_spec *spec = codec->spec; 2407 struct alc_spec *spec = codec->spec;
2321 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 2408 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2409 hinfo);
2322} 2410}
2323 2411
2324static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2412static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -2392,8 +2480,8 @@ static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2392{ 2480{
2393 struct alc_spec *spec = codec->spec; 2481 struct alc_spec *spec = codec->spec;
2394 2482
2395 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], 2483 snd_hda_codec_cleanup_stream(codec,
2396 0, 0, 0); 2484 spec->adc_nids[substream->number + 1]);
2397 return 0; 2485 return 0;
2398} 2486}
2399 2487
@@ -2498,6 +2586,7 @@ static int alc_build_pcms(struct hda_codec *codec)
2498 codec->num_pcms = 2; 2586 codec->num_pcms = 2;
2499 info = spec->pcm_rec + 1; 2587 info = spec->pcm_rec + 1;
2500 info->name = spec->stream_name_digital; 2588 info->name = spec->stream_name_digital;
2589 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2501 if (spec->multiout.dig_out_nid && 2590 if (spec->multiout.dig_out_nid &&
2502 spec->stream_digital_playback) { 2591 spec->stream_digital_playback) {
2503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 2592 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
@@ -2560,6 +2649,7 @@ static void alc_free(struct hda_codec *codec)
2560 kfree(spec->kctl_alloc); 2649 kfree(spec->kctl_alloc);
2561 } 2650 }
2562 kfree(spec); 2651 kfree(spec);
2652 codec->spec = NULL; /* to be sure */
2563} 2653}
2564 2654
2565/* 2655/*
@@ -2862,6 +2952,7 @@ static const char *alc880_models[ALC880_MODEL_LAST] = {
2862 [ALC880_F1734] = "F1734", 2952 [ALC880_F1734] = "F1734",
2863 [ALC880_LG] = "lg", 2953 [ALC880_LG] = "lg",
2864 [ALC880_LG_LW] = "lg-lw", 2954 [ALC880_LG_LW] = "lg-lw",
2955 [ALC880_MEDION_RIM] = "medion",
2865#ifdef CONFIG_SND_DEBUG 2956#ifdef CONFIG_SND_DEBUG
2866 [ALC880_TEST] = "test", 2957 [ALC880_TEST] = "test",
2867#endif 2958#endif
@@ -2913,6 +3004,7 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
2913 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), 3004 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2914 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), 3005 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2915 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), 3006 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3007 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
2916 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), 3008 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2917 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), 3009 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2918 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), 3010 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
@@ -3057,7 +3149,9 @@ static struct alc_config_preset alc880_presets[] = {
3057 .hp_nid = 0x02, 3149 .hp_nid = 0x02,
3058 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 3150 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3059 .channel_mode = alc880_2_jack_modes, 3151 .channel_mode = alc880_2_jack_modes,
3060 .input_mux = &alc880_capture_source, 3152 .input_mux = &alc880_f1734_capture_source,
3153 .unsol_event = alc880_uniwill_p53_unsol_event,
3154 .init_hook = alc880_uniwill_p53_hp_automute,
3061 }, 3155 },
3062 [ALC880_ASUS] = { 3156 [ALC880_ASUS] = {
3063 .mixers = { alc880_asus_mixer }, 3157 .mixers = { alc880_asus_mixer },
@@ -3205,6 +3299,20 @@ static struct alc_config_preset alc880_presets[] = {
3205 .unsol_event = alc880_lg_lw_unsol_event, 3299 .unsol_event = alc880_lg_lw_unsol_event,
3206 .init_hook = alc880_lg_lw_automute, 3300 .init_hook = alc880_lg_lw_automute,
3207 }, 3301 },
3302 [ALC880_MEDION_RIM] = {
3303 .mixers = { alc880_medion_rim_mixer },
3304 .init_verbs = { alc880_volume_init_verbs,
3305 alc880_medion_rim_init_verbs,
3306 alc_gpio2_init_verbs },
3307 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3308 .dac_nids = alc880_dac_nids,
3309 .dig_out_nid = ALC880_DIGOUT_NID,
3310 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3311 .channel_mode = alc880_2_jack_modes,
3312 .input_mux = &alc880_medion_rim_capture_source,
3313 .unsol_event = alc880_medion_rim_unsol_event,
3314 .init_hook = alc880_medion_rim_automute,
3315 },
3208#ifdef CONFIG_SND_DEBUG 3316#ifdef CONFIG_SND_DEBUG
3209 [ALC880_TEST] = { 3317 [ALC880_TEST] = {
3210 .mixers = { alc880_test_mixer }, 3318 .mixers = { alc880_test_mixer },
@@ -3467,15 +3575,21 @@ static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3467 return 0; 3575 return 0;
3468} 3576}
3469 3577
3470static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, 3578static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3471 hda_nid_t nid, int pin_type, 3579 unsigned int pin_type)
3472 int dac_idx)
3473{ 3580{
3474 /* set as output */
3475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3581 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3476 pin_type); 3582 pin_type);
3583 /* unmute pin */
3477 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3584 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3478 AMP_OUT_UNMUTE); 3585 AMP_OUT_UNMUTE);
3586}
3587
3588static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3589 hda_nid_t nid, int pin_type,
3590 int dac_idx)
3591{
3592 alc_set_pin_output(codec, nid, pin_type);
3479 /* need the manual connection? */ 3593 /* need the manual connection? */
3480 if (alc880_is_multi_pin(nid)) { 3594 if (alc880_is_multi_pin(nid)) {
3481 struct alc_spec *spec = codec->spec; 3595 struct alc_spec *spec = codec->spec;
@@ -3597,9 +3711,12 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
3597/* additional initialization for auto-configuration model */ 3711/* additional initialization for auto-configuration model */
3598static void alc880_auto_init(struct hda_codec *codec) 3712static void alc880_auto_init(struct hda_codec *codec)
3599{ 3713{
3714 struct alc_spec *spec = codec->spec;
3600 alc880_auto_init_multi_out(codec); 3715 alc880_auto_init_multi_out(codec);
3601 alc880_auto_init_extra_out(codec); 3716 alc880_auto_init_extra_out(codec);
3602 alc880_auto_init_analog_input(codec); 3717 alc880_auto_init_analog_input(codec);
3718 if (spec->unsol_event)
3719 alc_sku_automute(codec);
3603} 3720}
3604 3721
3605/* 3722/*
@@ -4795,11 +4912,7 @@ static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4795 hda_nid_t nid, int pin_type, 4912 hda_nid_t nid, int pin_type,
4796 int sel_idx) 4913 int sel_idx)
4797{ 4914{
4798 /* set as output */ 4915 alc_set_pin_output(codec, nid, pin_type);
4799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4800 pin_type);
4801 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4802 AMP_OUT_UNMUTE);
4803 /* need the manual connection? */ 4916 /* need the manual connection? */
4804 if (nid >= 0x12) { 4917 if (nid >= 0x12) {
4805 int idx = nid - 0x12; 4918 int idx = nid - 0x12;
@@ -4929,7 +5042,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4929 /* check whether NID 0x04 is valid */ 5042 /* check whether NID 0x04 is valid */
4930 wcap = get_wcaps(codec, 0x04); 5043 wcap = get_wcaps(codec, 0x04);
4931 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 5044 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4932 if (wcap != AC_WID_AUD_IN) { 5045 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
4933 spec->adc_nids = alc260_adc_nids_alt; 5046 spec->adc_nids = alc260_adc_nids_alt;
4934 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); 5047 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4935 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; 5048 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
@@ -4946,8 +5059,11 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4946/* additional initialization for auto-configuration model */ 5059/* additional initialization for auto-configuration model */
4947static void alc260_auto_init(struct hda_codec *codec) 5060static void alc260_auto_init(struct hda_codec *codec)
4948{ 5061{
5062 struct alc_spec *spec = codec->spec;
4949 alc260_auto_init_multi_out(codec); 5063 alc260_auto_init_multi_out(codec);
4950 alc260_auto_init_analog_input(codec); 5064 alc260_auto_init_analog_input(codec);
5065 if (spec->unsol_event)
5066 alc_sku_automute(codec);
4951} 5067}
4952 5068
4953#ifdef CONFIG_SND_HDA_POWER_SAVE 5069#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -5204,6 +5320,9 @@ static hda_nid_t alc882_dac_nids[4] = {
5204#define alc882_adc_nids alc880_adc_nids 5320#define alc882_adc_nids alc880_adc_nids
5205#define alc882_adc_nids_alt alc880_adc_nids_alt 5321#define alc882_adc_nids_alt alc880_adc_nids_alt
5206 5322
5323static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5324static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5325
5207/* input MUX */ 5326/* input MUX */
5208/* FIXME: should be a matrix-type input source selection */ 5327/* FIXME: should be a matrix-type input source selection */
5209 5328
@@ -5226,15 +5345,11 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5226 struct alc_spec *spec = codec->spec; 5345 struct alc_spec *spec = codec->spec;
5227 const struct hda_input_mux *imux = spec->input_mux; 5346 const struct hda_input_mux *imux = spec->input_mux;
5228 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 5347 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5229 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; 5348 hda_nid_t nid = spec->capsrc_nids ?
5230 hda_nid_t nid; 5349 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
5231 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 5350 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5232 unsigned int i, idx; 5351 unsigned int i, idx;
5233 5352
5234 if (spec->num_adc_nids < 3)
5235 nid = capture_mixers[adc_idx + 1];
5236 else
5237 nid = capture_mixers[adc_idx];
5238 idx = ucontrol->value.enumerated.item[0]; 5353 idx = ucontrol->value.enumerated.item[0];
5239 if (idx >= imux->num_items) 5354 if (idx >= imux->num_items)
5240 idx = imux->num_items - 1; 5355 idx = imux->num_items - 1;
@@ -6111,6 +6226,7 @@ static struct alc_config_preset alc882_presets[] = {
6111 .dig_out_nid = ALC882_DIGOUT_NID, 6226 .dig_out_nid = ALC882_DIGOUT_NID,
6112 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 6227 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6113 .adc_nids = alc882_adc_nids, 6228 .adc_nids = alc882_adc_nids,
6229 .capsrc_nids = alc882_capsrc_nids,
6114 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), 6230 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6115 .channel_mode = alc882_3ST_6ch_modes, 6231 .channel_mode = alc882_3ST_6ch_modes,
6116 .need_dac_fix = 1, 6232 .need_dac_fix = 1,
@@ -6127,6 +6243,7 @@ static struct alc_config_preset alc882_presets[] = {
6127 .dig_out_nid = ALC882_DIGOUT_NID, 6243 .dig_out_nid = ALC882_DIGOUT_NID,
6128 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 6244 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6129 .adc_nids = alc882_adc_nids, 6245 .adc_nids = alc882_adc_nids,
6246 .capsrc_nids = alc882_capsrc_nids,
6130 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), 6247 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6131 .channel_mode = alc882_3ST_6ch_modes, 6248 .channel_mode = alc882_3ST_6ch_modes,
6132 .need_dac_fix = 1, 6249 .need_dac_fix = 1,
@@ -6182,15 +6299,11 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6182 struct alc_spec *spec = codec->spec; 6299 struct alc_spec *spec = codec->spec;
6183 int idx; 6300 int idx;
6184 6301
6302 alc_set_pin_output(codec, nid, pin_type);
6185 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6303 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6186 idx = 4; 6304 idx = 4;
6187 else 6305 else
6188 idx = spec->multiout.dac_nids[dac_idx] - 2; 6306 idx = spec->multiout.dac_nids[dac_idx] - 2;
6189
6190 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6191 pin_type);
6192 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6193 AMP_OUT_UNMUTE);
6194 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 6307 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6195 6308
6196} 6309}
@@ -6219,6 +6332,9 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec)
6219 if (pin) /* connect to front */ 6332 if (pin) /* connect to front */
6220 /* use dac 0 */ 6333 /* use dac 0 */
6221 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 6334 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6335 pin = spec->autocfg.speaker_pins[0];
6336 if (pin)
6337 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
6222} 6338}
6223 6339
6224#define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 6340#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -6231,16 +6347,21 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
6231 6347
6232 for (i = 0; i < AUTO_PIN_LAST; i++) { 6348 for (i = 0; i < AUTO_PIN_LAST; i++) {
6233 hda_nid_t nid = spec->autocfg.input_pins[i]; 6349 hda_nid_t nid = spec->autocfg.input_pins[i];
6234 if (alc882_is_input_pin(nid)) { 6350 unsigned int vref;
6235 snd_hda_codec_write(codec, nid, 0, 6351 if (!nid)
6236 AC_VERB_SET_PIN_WIDGET_CONTROL, 6352 continue;
6237 i <= AUTO_PIN_FRONT_MIC ? 6353 vref = PIN_IN;
6238 PIN_VREF80 : PIN_IN); 6354 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6239 if (nid != ALC882_PIN_CD_NID) 6355 if (snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) &
6240 snd_hda_codec_write(codec, nid, 0, 6356 AC_PINCAP_VREF_80)
6241 AC_VERB_SET_AMP_GAIN_MUTE, 6357 vref = PIN_VREF80;
6242 AMP_OUT_MUTE);
6243 } 6358 }
6359 snd_hda_codec_write(codec, nid, 0,
6360 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6361 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6362 snd_hda_codec_write(codec, nid, 0,
6363 AC_VERB_SET_AMP_GAIN_MUTE,
6364 AMP_OUT_MUTE);
6244 } 6365 }
6245} 6366}
6246 6367
@@ -6294,11 +6415,16 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
6294/* additional initialization for auto-configuration model */ 6415/* additional initialization for auto-configuration model */
6295static void alc882_auto_init(struct hda_codec *codec) 6416static void alc882_auto_init(struct hda_codec *codec)
6296{ 6417{
6418 struct alc_spec *spec = codec->spec;
6297 alc882_auto_init_multi_out(codec); 6419 alc882_auto_init_multi_out(codec);
6298 alc882_auto_init_hp_out(codec); 6420 alc882_auto_init_hp_out(codec);
6299 alc882_auto_init_analog_input(codec); 6421 alc882_auto_init_analog_input(codec);
6422 if (spec->unsol_event)
6423 alc_sku_automute(codec);
6300} 6424}
6301 6425
6426static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6427
6302static int patch_alc882(struct hda_codec *codec) 6428static int patch_alc882(struct hda_codec *codec)
6303{ 6429{
6304 struct alc_spec *spec; 6430 struct alc_spec *spec;
@@ -6328,6 +6454,11 @@ static int patch_alc882(struct hda_codec *codec)
6328 board_config = ALC885_MBP3; 6454 board_config = ALC885_MBP3;
6329 break; 6455 break;
6330 default: 6456 default:
6457 /* ALC889A is handled better as ALC888-compatible */
6458 if (codec->revision_id == 0x100103) {
6459 alc_free(codec);
6460 return patch_alc883(codec);
6461 }
6331 printk(KERN_INFO "hda_codec: Unknown model for ALC882, " 6462 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6332 "trying auto-probe from BIOS...\n"); 6463 "trying auto-probe from BIOS...\n");
6333 board_config = ALC882_AUTO; 6464 board_config = ALC882_AUTO;
@@ -6372,12 +6503,14 @@ static int patch_alc882(struct hda_codec *codec)
6372 if (wcap != AC_WID_AUD_IN) { 6503 if (wcap != AC_WID_AUD_IN) {
6373 spec->adc_nids = alc882_adc_nids_alt; 6504 spec->adc_nids = alc882_adc_nids_alt;
6374 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 6505 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6506 spec->capsrc_nids = alc882_capsrc_nids_alt;
6375 spec->mixers[spec->num_mixers] = 6507 spec->mixers[spec->num_mixers] =
6376 alc882_capture_alt_mixer; 6508 alc882_capture_alt_mixer;
6377 spec->num_mixers++; 6509 spec->num_mixers++;
6378 } else { 6510 } else {
6379 spec->adc_nids = alc882_adc_nids; 6511 spec->adc_nids = alc882_adc_nids;
6380 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); 6512 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6513 spec->capsrc_nids = alc882_capsrc_nids;
6381 spec->mixers[spec->num_mixers] = alc882_capture_mixer; 6514 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6382 spec->num_mixers++; 6515 spec->num_mixers++;
6383 } 6516 }
@@ -6412,7 +6545,7 @@ static int patch_alc882(struct hda_codec *codec)
6412 6545
6413static hda_nid_t alc883_dac_nids[4] = { 6546static hda_nid_t alc883_dac_nids[4] = {
6414 /* front, rear, clfe, rear_surr */ 6547 /* front, rear, clfe, rear_surr */
6415 0x02, 0x04, 0x03, 0x05 6548 0x02, 0x03, 0x04, 0x05
6416}; 6549};
6417 6550
6418static hda_nid_t alc883_adc_nids[2] = { 6551static hda_nid_t alc883_adc_nids[2] = {
@@ -6420,6 +6553,8 @@ static hda_nid_t alc883_adc_nids[2] = {
6420 0x08, 0x09, 6553 0x08, 0x09,
6421}; 6554};
6422 6555
6556static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6557
6423/* input MUX */ 6558/* input MUX */
6424/* FIXME: should be a matrix-type input source selection */ 6559/* FIXME: should be a matrix-type input source selection */
6425 6560
@@ -6451,35 +6586,18 @@ static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6451 }, 6586 },
6452}; 6587};
6453 6588
6589static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6590 .num_items = 2,
6591 .items = {
6592 { "Mic", 0x0 },
6593 { "Int Mic", 0x1 },
6594 },
6595};
6596
6454#define alc883_mux_enum_info alc_mux_enum_info 6597#define alc883_mux_enum_info alc_mux_enum_info
6455#define alc883_mux_enum_get alc_mux_enum_get 6598#define alc883_mux_enum_get alc_mux_enum_get
6456 6599/* ALC883 has the ALC882-type input selection */
6457static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol, 6600#define alc883_mux_enum_put alc882_mux_enum_put
6458 struct snd_ctl_elem_value *ucontrol)
6459{
6460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6461 struct alc_spec *spec = codec->spec;
6462 const struct hda_input_mux *imux = spec->input_mux;
6463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6464 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
6465 hda_nid_t nid = capture_mixers[adc_idx];
6466 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6467 unsigned int i, idx;
6468
6469 idx = ucontrol->value.enumerated.item[0];
6470 if (idx >= imux->num_items)
6471 idx = imux->num_items - 1;
6472 if (*cur_val == idx)
6473 return 0;
6474 for (i = 0; i < imux->num_items; i++) {
6475 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6476 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
6477 imux->items[i].index,
6478 HDA_AMP_MUTE, v);
6479 }
6480 *cur_val = idx;
6481 return 1;
6482}
6483 6601
6484/* 6602/*
6485 * 2ch mode 6603 * 2ch mode
@@ -6638,6 +6756,60 @@ static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6638 { } /* end */ 6756 { } /* end */
6639}; 6757};
6640 6758
6759static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
6760 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6761 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6762 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6763 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6765 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6766 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6767 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6768 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6769 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6770 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6771 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6772 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6773 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6774 {
6775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6776 /* .name = "Capture Source", */
6777 .name = "Input Source",
6778 .count = 2,
6779 .info = alc883_mux_enum_info,
6780 .get = alc883_mux_enum_get,
6781 .put = alc883_mux_enum_put,
6782 },
6783 { } /* end */
6784};
6785
6786static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6787 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6788 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6789 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6790 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6792 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6794 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6795 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6796 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6797 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6798 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6799 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6800 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6801 {
6802 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6803 /* .name = "Capture Source", */
6804 .name = "Input Source",
6805 .count = 2,
6806 .info = alc883_mux_enum_info,
6807 .get = alc883_mux_enum_get,
6808 .put = alc883_mux_enum_put,
6809 },
6810 { } /* end */
6811};
6812
6641static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { 6813static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6642 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 6814 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6643 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 6815 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -6787,6 +6959,9 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6788 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6963 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6964 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6790 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 6965 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6791 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 6966 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6792 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 6967 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
@@ -6878,124 +7053,6 @@ static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6878 { } /* end */ 7053 { } /* end */
6879}; 7054};
6880 7055
6881static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6885 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6887 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6888 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6889 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6891 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6898 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6901 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6902 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6903 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6904 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6905 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6906 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6907 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6908 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6909 {
6910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6911 /* .name = "Capture Source", */
6912 .name = "Input Source",
6913 .count = 2,
6914 .info = alc883_mux_enum_info,
6915 .get = alc883_mux_enum_get,
6916 .put = alc883_mux_enum_put,
6917 },
6918 { } /* end */
6919};
6920
6921static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6922 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6923 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6924 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6925 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6926 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6927 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6928 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6929 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6941 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6942 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6943 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6944 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6945 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6946 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6947 {
6948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6949 /* .name = "Capture Source", */
6950 .name = "Input Source",
6951 .count = 2,
6952 .info = alc883_mux_enum_info,
6953 .get = alc883_mux_enum_get,
6954 .put = alc883_mux_enum_put,
6955 },
6956 { } /* end */
6957};
6958
6959static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6961 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6963 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6968 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6969 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6970 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6973 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6974 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6978 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6979 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6981 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6982 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6984 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6985 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6986 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6987 {
6988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6989 /* .name = "Capture Source", */
6990 .name = "Input Source",
6991 .count = 2,
6992 .info = alc883_mux_enum_info,
6993 .get = alc883_mux_enum_get,
6994 .put = alc883_mux_enum_put,
6995 },
6996 { } /* end */
6997};
6998
6999static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { 7056static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7000 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 7057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7001 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 7058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -7171,6 +7228,35 @@ static struct hda_verb alc883_mitac_verbs[] = {
7171 { } /* end */ 7228 { } /* end */
7172}; 7229};
7173 7230
7231static struct hda_verb alc883_clevo_m720_verbs[] = {
7232 /* HP */
7233 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7235 /* Int speaker */
7236 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7238
7239 /* enable unsolicited event */
7240 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7241 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
7242
7243 { } /* end */
7244};
7245
7246static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7247 /* HP */
7248 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7250 /* Subwoofer */
7251 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7253
7254 /* enable unsolicited event */
7255 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7256
7257 { } /* end */
7258};
7259
7174static struct hda_verb alc883_tagra_verbs[] = { 7260static struct hda_verb alc883_tagra_verbs[] = {
7175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7261 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7262 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7227,26 +7313,14 @@ static struct hda_verb alc883_haier_w66_verbs[] = {
7227 { } /* end */ 7313 { } /* end */
7228}; 7314};
7229 7315
7230static struct hda_verb alc888_6st_hp_verbs[] = {
7231 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7232 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7233 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7234 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7235 { }
7236};
7237
7238static struct hda_verb alc888_3st_hp_verbs[] = { 7316static struct hda_verb alc888_3st_hp_verbs[] = {
7239 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ 7317 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7240 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ 7318 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7241 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ 7319 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7242 { } 7320 { }
7243}; 7321};
7244 7322
7245static struct hda_verb alc888_6st_dell_verbs[] = { 7323static struct hda_verb alc888_6st_dell_verbs[] = {
7246 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7248 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7249 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7250 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 7324 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7251 { } 7325 { }
7252}; 7326};
@@ -7354,6 +7428,68 @@ static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7354 alc883_tagra_automute(codec); 7428 alc883_tagra_automute(codec);
7355} 7429}
7356 7430
7431/* toggle speaker-output according to the hp-jack state */
7432static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
7433{
7434 unsigned int present;
7435 unsigned char bits;
7436
7437 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7438 & AC_PINSENSE_PRESENCE;
7439 bits = present ? HDA_AMP_MUTE : 0;
7440 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7441 HDA_AMP_MUTE, bits);
7442}
7443
7444static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7445{
7446 unsigned int present;
7447
7448 present = snd_hda_codec_read(codec, 0x18, 0,
7449 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7450 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7451 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7452}
7453
7454static void alc883_clevo_m720_automute(struct hda_codec *codec)
7455{
7456 alc883_clevo_m720_hp_automute(codec);
7457 alc883_clevo_m720_mic_automute(codec);
7458}
7459
7460static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
7461 unsigned int res)
7462{
7463 switch (res >> 26) {
7464 case ALC880_HP_EVENT:
7465 alc883_clevo_m720_hp_automute(codec);
7466 break;
7467 case ALC880_MIC_EVENT:
7468 alc883_clevo_m720_mic_automute(codec);
7469 break;
7470 }
7471}
7472
7473/* toggle speaker-output according to the hp-jack state */
7474static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7475{
7476 unsigned int present;
7477 unsigned char bits;
7478
7479 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7480 & AC_PINSENSE_PRESENCE;
7481 bits = present ? HDA_AMP_MUTE : 0;
7482 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7483 HDA_AMP_MUTE, bits);
7484}
7485
7486static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7487 unsigned int res)
7488{
7489 if ((res >> 26) == ALC880_HP_EVENT)
7490 alc883_2ch_fujitsu_pi2515_automute(codec);
7491}
7492
7357static void alc883_haier_w66_automute(struct hda_codec *codec) 7493static void alc883_haier_w66_automute(struct hda_codec *codec)
7358{ 7494{
7359 unsigned int present; 7495 unsigned int present;
@@ -7587,10 +7723,11 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
7587 [ALC883_LENOVO_NB0763] = "lenovo-nb0763", 7723 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7588 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", 7724 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7589 [ALC883_HAIER_W66] = "haier-w66", 7725 [ALC883_HAIER_W66] = "haier-w66",
7590 [ALC888_6ST_HP] = "6stack-hp",
7591 [ALC888_3ST_HP] = "3stack-hp", 7726 [ALC888_3ST_HP] = "3stack-hp",
7592 [ALC888_6ST_DELL] = "6stack-dell", 7727 [ALC888_6ST_DELL] = "6stack-dell",
7593 [ALC883_MITAC] = "mitac", 7728 [ALC883_MITAC] = "mitac",
7729 [ALC883_CLEVO_M720] = "clevo-m720",
7730 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
7594 [ALC883_AUTO] = "auto", 7731 [ALC883_AUTO] = "auto",
7595}; 7732};
7596 7733
@@ -7604,7 +7741,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
7604 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 7741 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7605 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 7742 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7606 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 7743 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7607 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP), 7744 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
7608 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 7745 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7609 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 7746 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7610 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), 7747 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
@@ -7614,7 +7751,9 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
7614 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), 7751 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7615 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), 7752 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7616 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), 7753 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7754 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
7617 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), 7755 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7756 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
7618 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), 7757 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7619 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), 7758 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7620 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), 7759 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
@@ -7627,13 +7766,17 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
7627 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 7766 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7628 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 7767 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7629 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), 7768 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7769 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
7630 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 7770 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7631 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), 7771 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7632 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), 7772 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7633 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 7773 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7774 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7775 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
7634 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 7776 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7635 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 7777 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7636 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 7778 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7779 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
7637 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), 7780 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7638 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7781 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7639 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7782 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
@@ -7652,8 +7795,6 @@ static struct alc_config_preset alc883_presets[] = {
7652 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7795 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7653 .dac_nids = alc883_dac_nids, 7796 .dac_nids = alc883_dac_nids,
7654 .dig_out_nid = ALC883_DIGOUT_NID, 7797 .dig_out_nid = ALC883_DIGOUT_NID,
7655 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7656 .adc_nids = alc883_adc_nids,
7657 .dig_in_nid = ALC883_DIGIN_NID, 7798 .dig_in_nid = ALC883_DIGIN_NID,
7658 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7799 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7659 .channel_mode = alc883_3ST_2ch_modes, 7800 .channel_mode = alc883_3ST_2ch_modes,
@@ -7665,8 +7806,6 @@ static struct alc_config_preset alc883_presets[] = {
7665 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7666 .dac_nids = alc883_dac_nids, 7807 .dac_nids = alc883_dac_nids,
7667 .dig_out_nid = ALC883_DIGOUT_NID, 7808 .dig_out_nid = ALC883_DIGOUT_NID,
7668 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7669 .adc_nids = alc883_adc_nids,
7670 .dig_in_nid = ALC883_DIGIN_NID, 7809 .dig_in_nid = ALC883_DIGIN_NID,
7671 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7810 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7672 .channel_mode = alc883_3ST_6ch_modes, 7811 .channel_mode = alc883_3ST_6ch_modes,
@@ -7678,8 +7817,6 @@ static struct alc_config_preset alc883_presets[] = {
7678 .init_verbs = { alc883_init_verbs }, 7817 .init_verbs = { alc883_init_verbs },
7679 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7818 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7680 .dac_nids = alc883_dac_nids, 7819 .dac_nids = alc883_dac_nids,
7681 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7682 .adc_nids = alc883_adc_nids,
7683 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7820 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7684 .channel_mode = alc883_3ST_6ch_modes, 7821 .channel_mode = alc883_3ST_6ch_modes,
7685 .need_dac_fix = 1, 7822 .need_dac_fix = 1,
@@ -7691,8 +7828,6 @@ static struct alc_config_preset alc883_presets[] = {
7691 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7828 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7692 .dac_nids = alc883_dac_nids, 7829 .dac_nids = alc883_dac_nids,
7693 .dig_out_nid = ALC883_DIGOUT_NID, 7830 .dig_out_nid = ALC883_DIGOUT_NID,
7694 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7695 .adc_nids = alc883_adc_nids,
7696 .dig_in_nid = ALC883_DIGIN_NID, 7831 .dig_in_nid = ALC883_DIGIN_NID,
7697 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 7832 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7698 .channel_mode = alc883_sixstack_modes, 7833 .channel_mode = alc883_sixstack_modes,
@@ -7704,8 +7839,6 @@ static struct alc_config_preset alc883_presets[] = {
7704 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7839 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7705 .dac_nids = alc883_dac_nids, 7840 .dac_nids = alc883_dac_nids,
7706 .dig_out_nid = ALC883_DIGOUT_NID, 7841 .dig_out_nid = ALC883_DIGOUT_NID,
7707 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7708 .adc_nids = alc883_adc_nids,
7709 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7842 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7710 .channel_mode = alc883_3ST_6ch_modes, 7843 .channel_mode = alc883_3ST_6ch_modes,
7711 .need_dac_fix = 1, 7844 .need_dac_fix = 1,
@@ -7719,8 +7852,6 @@ static struct alc_config_preset alc883_presets[] = {
7719 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7852 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7720 .dac_nids = alc883_dac_nids, 7853 .dac_nids = alc883_dac_nids,
7721 .dig_out_nid = ALC883_DIGOUT_NID, 7854 .dig_out_nid = ALC883_DIGOUT_NID,
7722 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7723 .adc_nids = alc883_adc_nids,
7724 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7855 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7725 .channel_mode = alc883_3ST_2ch_modes, 7856 .channel_mode = alc883_3ST_2ch_modes,
7726 .input_mux = &alc883_capture_source, 7857 .input_mux = &alc883_capture_source,
@@ -7737,8 +7868,6 @@ static struct alc_config_preset alc883_presets[] = {
7737 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, 7868 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7738 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7869 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7739 .dac_nids = alc883_dac_nids, 7870 .dac_nids = alc883_dac_nids,
7740 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7741 .adc_nids = alc883_adc_nids,
7742 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7871 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7743 .channel_mode = alc883_3ST_2ch_modes, 7872 .channel_mode = alc883_3ST_2ch_modes,
7744 .input_mux = &alc883_capture_source, 7873 .input_mux = &alc883_capture_source,
@@ -7749,8 +7878,6 @@ static struct alc_config_preset alc883_presets[] = {
7749 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7878 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7750 .dac_nids = alc883_dac_nids, 7879 .dac_nids = alc883_dac_nids,
7751 .dig_out_nid = ALC883_DIGOUT_NID, 7880 .dig_out_nid = ALC883_DIGOUT_NID,
7752 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7753 .adc_nids = alc883_adc_nids,
7754 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7881 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7755 .channel_mode = alc883_3ST_2ch_modes, 7882 .channel_mode = alc883_3ST_2ch_modes,
7756 .input_mux = &alc883_capture_source, 7883 .input_mux = &alc883_capture_source,
@@ -7764,8 +7891,6 @@ static struct alc_config_preset alc883_presets[] = {
7764 alc883_medion_eapd_verbs }, 7891 alc883_medion_eapd_verbs },
7765 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7892 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7766 .dac_nids = alc883_dac_nids, 7893 .dac_nids = alc883_dac_nids,
7767 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7768 .adc_nids = alc883_adc_nids,
7769 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 7894 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7770 .channel_mode = alc883_sixstack_modes, 7895 .channel_mode = alc883_sixstack_modes,
7771 .input_mux = &alc883_capture_source, 7896 .input_mux = &alc883_capture_source,
@@ -7776,8 +7901,6 @@ static struct alc_config_preset alc883_presets[] = {
7776 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7901 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7777 .dac_nids = alc883_dac_nids, 7902 .dac_nids = alc883_dac_nids,
7778 .dig_out_nid = ALC883_DIGOUT_NID, 7903 .dig_out_nid = ALC883_DIGOUT_NID,
7779 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7780 .adc_nids = alc883_adc_nids,
7781 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7904 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7782 .channel_mode = alc883_3ST_2ch_modes, 7905 .channel_mode = alc883_3ST_2ch_modes,
7783 .input_mux = &alc883_capture_source, 7906 .input_mux = &alc883_capture_source,
@@ -7789,19 +7912,27 @@ static struct alc_config_preset alc883_presets[] = {
7789 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, 7912 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7790 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7913 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7791 .dac_nids = alc883_dac_nids, 7914 .dac_nids = alc883_dac_nids,
7792 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7793 .adc_nids = alc883_adc_nids,
7794 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7915 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7795 .channel_mode = alc883_3ST_2ch_modes, 7916 .channel_mode = alc883_3ST_2ch_modes,
7796 .input_mux = &alc883_capture_source, 7917 .input_mux = &alc883_capture_source,
7797 }, 7918 },
7919 [ALC883_CLEVO_M720] = {
7920 .mixers = { alc883_clevo_m720_mixer },
7921 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
7922 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7923 .dac_nids = alc883_dac_nids,
7924 .dig_out_nid = ALC883_DIGOUT_NID,
7925 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7926 .channel_mode = alc883_3ST_2ch_modes,
7927 .input_mux = &alc883_capture_source,
7928 .unsol_event = alc883_clevo_m720_unsol_event,
7929 .init_hook = alc883_clevo_m720_automute,
7930 },
7798 [ALC883_LENOVO_101E_2ch] = { 7931 [ALC883_LENOVO_101E_2ch] = {
7799 .mixers = { alc883_lenovo_101e_2ch_mixer}, 7932 .mixers = { alc883_lenovo_101e_2ch_mixer},
7800 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, 7933 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7801 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7934 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7802 .dac_nids = alc883_dac_nids, 7935 .dac_nids = alc883_dac_nids,
7803 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7804 .adc_nids = alc883_adc_nids,
7805 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7936 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7806 .channel_mode = alc883_3ST_2ch_modes, 7937 .channel_mode = alc883_3ST_2ch_modes,
7807 .input_mux = &alc883_lenovo_101e_capture_source, 7938 .input_mux = &alc883_lenovo_101e_capture_source,
@@ -7813,8 +7944,6 @@ static struct alc_config_preset alc883_presets[] = {
7813 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, 7944 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7814 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7945 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7815 .dac_nids = alc883_dac_nids, 7946 .dac_nids = alc883_dac_nids,
7816 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7817 .adc_nids = alc883_adc_nids,
7818 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7947 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7819 .channel_mode = alc883_3ST_2ch_modes, 7948 .channel_mode = alc883_3ST_2ch_modes,
7820 .need_dac_fix = 1, 7949 .need_dac_fix = 1,
@@ -7828,8 +7957,6 @@ static struct alc_config_preset alc883_presets[] = {
7828 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7957 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7829 .dac_nids = alc883_dac_nids, 7958 .dac_nids = alc883_dac_nids,
7830 .dig_out_nid = ALC883_DIGOUT_NID, 7959 .dig_out_nid = ALC883_DIGOUT_NID,
7831 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7832 .adc_nids = alc883_adc_nids,
7833 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), 7960 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7834 .channel_mode = alc883_3ST_6ch_modes, 7961 .channel_mode = alc883_3ST_6ch_modes,
7835 .need_dac_fix = 1, 7962 .need_dac_fix = 1,
@@ -7843,47 +7970,28 @@ static struct alc_config_preset alc883_presets[] = {
7843 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7970 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7844 .dac_nids = alc883_dac_nids, 7971 .dac_nids = alc883_dac_nids,
7845 .dig_out_nid = ALC883_DIGOUT_NID, 7972 .dig_out_nid = ALC883_DIGOUT_NID,
7846 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7847 .adc_nids = alc883_adc_nids,
7848 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 7973 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7849 .channel_mode = alc883_3ST_2ch_modes, 7974 .channel_mode = alc883_3ST_2ch_modes,
7850 .input_mux = &alc883_capture_source, 7975 .input_mux = &alc883_capture_source,
7851 .unsol_event = alc883_haier_w66_unsol_event, 7976 .unsol_event = alc883_haier_w66_unsol_event,
7852 .init_hook = alc883_haier_w66_automute, 7977 .init_hook = alc883_haier_w66_automute,
7853 },
7854 [ALC888_6ST_HP] = {
7855 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7856 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7857 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7858 .dac_nids = alc883_dac_nids,
7859 .dig_out_nid = ALC883_DIGOUT_NID,
7860 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7861 .adc_nids = alc883_adc_nids,
7862 .dig_in_nid = ALC883_DIGIN_NID,
7863 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7864 .channel_mode = alc883_sixstack_modes,
7865 .input_mux = &alc883_capture_source,
7866 }, 7978 },
7867 [ALC888_3ST_HP] = { 7979 [ALC888_3ST_HP] = {
7868 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer }, 7980 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7869 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, 7981 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7870 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7982 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7871 .dac_nids = alc883_dac_nids, 7983 .dac_nids = alc883_dac_nids,
7872 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7873 .adc_nids = alc883_adc_nids,
7874 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), 7984 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7875 .channel_mode = alc888_3st_hp_modes, 7985 .channel_mode = alc888_3st_hp_modes,
7876 .need_dac_fix = 1, 7986 .need_dac_fix = 1,
7877 .input_mux = &alc883_capture_source, 7987 .input_mux = &alc883_capture_source,
7878 }, 7988 },
7879 [ALC888_6ST_DELL] = { 7989 [ALC888_6ST_DELL] = {
7880 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer }, 7990 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7881 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, 7991 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7882 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 7992 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7883 .dac_nids = alc883_dac_nids, 7993 .dac_nids = alc883_dac_nids,
7884 .dig_out_nid = ALC883_DIGOUT_NID, 7994 .dig_out_nid = ALC883_DIGOUT_NID,
7885 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7886 .adc_nids = alc883_adc_nids,
7887 .dig_in_nid = ALC883_DIGIN_NID, 7995 .dig_in_nid = ALC883_DIGIN_NID,
7888 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 7996 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7889 .channel_mode = alc883_sixstack_modes, 7997 .channel_mode = alc883_sixstack_modes,
@@ -7896,14 +8004,25 @@ static struct alc_config_preset alc883_presets[] = {
7896 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, 8004 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7897 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 8005 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7898 .dac_nids = alc883_dac_nids, 8006 .dac_nids = alc883_dac_nids,
7899 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7900 .adc_nids = alc883_adc_nids,
7901 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8007 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7902 .channel_mode = alc883_3ST_2ch_modes, 8008 .channel_mode = alc883_3ST_2ch_modes,
7903 .input_mux = &alc883_capture_source, 8009 .input_mux = &alc883_capture_source,
7904 .unsol_event = alc883_mitac_unsol_event, 8010 .unsol_event = alc883_mitac_unsol_event,
7905 .init_hook = alc883_mitac_automute, 8011 .init_hook = alc883_mitac_automute,
7906 }, 8012 },
8013 [ALC883_FUJITSU_PI2515] = {
8014 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8015 .init_verbs = { alc883_init_verbs,
8016 alc883_2ch_fujitsu_pi2515_verbs},
8017 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8018 .dac_nids = alc883_dac_nids,
8019 .dig_out_nid = ALC883_DIGOUT_NID,
8020 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8021 .channel_mode = alc883_3ST_2ch_modes,
8022 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8023 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8024 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8025 },
7907}; 8026};
7908 8027
7909 8028
@@ -7918,15 +8037,11 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7918 struct alc_spec *spec = codec->spec; 8037 struct alc_spec *spec = codec->spec;
7919 int idx; 8038 int idx;
7920 8039
8040 alc_set_pin_output(codec, nid, pin_type);
7921 if (spec->multiout.dac_nids[dac_idx] == 0x25) 8041 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7922 idx = 4; 8042 idx = 4;
7923 else 8043 else
7924 idx = spec->multiout.dac_nids[dac_idx] - 2; 8044 idx = spec->multiout.dac_nids[dac_idx] - 2;
7925
7926 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7927 pin_type);
7928 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7929 AMP_OUT_UNMUTE);
7930 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 8045 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7931 8046
7932} 8047}
@@ -7955,6 +8070,9 @@ static void alc883_auto_init_hp_out(struct hda_codec *codec)
7955 if (pin) /* connect to front */ 8070 if (pin) /* connect to front */
7956 /* use dac 0 */ 8071 /* use dac 0 */
7957 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 8072 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
8073 pin = spec->autocfg.speaker_pins[0];
8074 if (pin)
8075 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
7958} 8076}
7959 8077
7960#define alc883_is_input_pin(nid) alc880_is_input_pin(nid) 8078#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -8006,9 +8124,12 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
8006/* additional initialization for auto-configuration model */ 8124/* additional initialization for auto-configuration model */
8007static void alc883_auto_init(struct hda_codec *codec) 8125static void alc883_auto_init(struct hda_codec *codec)
8008{ 8126{
8127 struct alc_spec *spec = codec->spec;
8009 alc883_auto_init_multi_out(codec); 8128 alc883_auto_init_multi_out(codec);
8010 alc883_auto_init_hp_out(codec); 8129 alc883_auto_init_hp_out(codec);
8011 alc883_auto_init_analog_input(codec); 8130 alc883_auto_init_analog_input(codec);
8131 if (spec->unsol_event)
8132 alc_sku_automute(codec);
8012} 8133}
8013 8134
8014static int patch_alc883(struct hda_codec *codec) 8135static int patch_alc883(struct hda_codec *codec)
@@ -8057,10 +8178,9 @@ static int patch_alc883(struct hda_codec *codec)
8057 spec->stream_digital_playback = &alc883_pcm_digital_playback; 8178 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8058 spec->stream_digital_capture = &alc883_pcm_digital_capture; 8179 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8059 8180
8060 if (!spec->adc_nids && spec->input_mux) { 8181 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8061 spec->adc_nids = alc883_adc_nids; 8182 spec->adc_nids = alc883_adc_nids;
8062 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 8183 spec->capsrc_nids = alc883_capsrc_nids;
8063 }
8064 8184
8065 spec->vmaster_nid = 0x0c; 8185 spec->vmaster_nid = 0x0c;
8066 8186
@@ -8085,6 +8205,8 @@ static int patch_alc883(struct hda_codec *codec)
8085#define alc262_dac_nids alc260_dac_nids 8205#define alc262_dac_nids alc260_dac_nids
8086#define alc262_adc_nids alc882_adc_nids 8206#define alc262_adc_nids alc882_adc_nids
8087#define alc262_adc_nids_alt alc882_adc_nids_alt 8207#define alc262_adc_nids_alt alc882_adc_nids_alt
8208#define alc262_capsrc_nids alc882_capsrc_nids
8209#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
8088 8210
8089#define alc262_modes alc260_modes 8211#define alc262_modes alc260_modes
8090#define alc262_capture_source alc882_capture_source 8212#define alc262_capture_source alc882_capture_source
@@ -8585,7 +8707,8 @@ static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8585 8707
8586/* 8708/*
8587 * fujitsu model 8709 * fujitsu model
8588 * 0x14 = headphone/spdif-out, 0x15 = internal speaker 8710 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8711 * 0x1b = port replicator headphone out
8589 */ 8712 */
8590 8713
8591#define ALC_HP_EVENT 0x37 8714#define ALC_HP_EVENT 0x37
@@ -8593,6 +8716,14 @@ static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8593static struct hda_verb alc262_fujitsu_unsol_verbs[] = { 8716static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8594 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, 8717 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8721 {}
8722};
8723
8724static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
8725 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8596 {} 8727 {}
8597}; 8728};
8598 8729
@@ -8633,12 +8764,16 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8633 unsigned int mute; 8764 unsigned int mute;
8634 8765
8635 if (force || !spec->sense_updated) { 8766 if (force || !spec->sense_updated) {
8636 unsigned int present; 8767 unsigned int present_int_hp, present_dock_hp;
8637 /* need to execute and sync at first */ 8768 /* need to execute and sync at first */
8638 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 8769 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8639 present = snd_hda_codec_read(codec, 0x14, 0, 8770 present_int_hp = snd_hda_codec_read(codec, 0x14, 0,
8640 AC_VERB_GET_PIN_SENSE, 0); 8771 AC_VERB_GET_PIN_SENSE, 0);
8641 spec->jack_present = (present & 0x80000000) != 0; 8772 snd_hda_codec_read(codec, 0x1B, 0, AC_VERB_SET_PIN_SENSE, 0);
8773 present_dock_hp = snd_hda_codec_read(codec, 0x1b, 0,
8774 AC_VERB_GET_PIN_SENSE, 0);
8775 spec->jack_present = (present_int_hp & 0x80000000) != 0;
8776 spec->jack_present |= (present_dock_hp & 0x80000000) != 0;
8642 spec->sense_updated = 1; 8777 spec->sense_updated = 1;
8643 } 8778 }
8644 if (spec->jack_present) { 8779 if (spec->jack_present) {
@@ -8672,6 +8807,46 @@ static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8672 }, 8807 },
8673}; 8808};
8674 8809
8810/* mute/unmute internal speaker according to the hp jack and mute state */
8811static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
8812{
8813 struct alc_spec *spec = codec->spec;
8814 unsigned int mute;
8815
8816 if (force || !spec->sense_updated) {
8817 unsigned int present_int_hp;
8818 /* need to execute and sync at first */
8819 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8820 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
8821 AC_VERB_GET_PIN_SENSE, 0);
8822 spec->jack_present = (present_int_hp & 0x80000000) != 0;
8823 spec->sense_updated = 1;
8824 }
8825 if (spec->jack_present) {
8826 /* mute internal speaker */
8827 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8828 HDA_AMP_MUTE, HDA_AMP_MUTE);
8829 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8830 HDA_AMP_MUTE, HDA_AMP_MUTE);
8831 } else {
8832 /* unmute internal speaker if necessary */
8833 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8834 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8835 HDA_AMP_MUTE, mute);
8836 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8837 HDA_AMP_MUTE, mute);
8838 }
8839}
8840
8841/* unsolicited event for HP jack sensing */
8842static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
8843 unsigned int res)
8844{
8845 if ((res >> 26) != ALC_HP_EVENT)
8846 return;
8847 alc262_lenovo_3000_automute(codec, 1);
8848}
8849
8675/* bind hp and internal speaker mute (with plug check) */ 8850/* bind hp and internal speaker mute (with plug check) */
8676static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 8851static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8677 struct snd_ctl_elem_value *ucontrol) 8852 struct snd_ctl_elem_value *ucontrol)
@@ -8680,12 +8855,13 @@ static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8680 long *valp = ucontrol->value.integer.value; 8855 long *valp = ucontrol->value.integer.value;
8681 int change; 8856 int change;
8682 8857
8683 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 8858 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8684 HDA_AMP_MUTE, 8859 HDA_AMP_MUTE,
8685 valp[0] ? 0 : HDA_AMP_MUTE); 8860 valp ? 0 : HDA_AMP_MUTE);
8686 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 8861 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8687 HDA_AMP_MUTE, 8862 HDA_AMP_MUTE,
8688 valp[1] ? 0 : HDA_AMP_MUTE); 8863 valp ? 0 : HDA_AMP_MUTE);
8864
8689 if (change) 8865 if (change)
8690 alc262_fujitsu_automute(codec, 0); 8866 alc262_fujitsu_automute(codec, 0);
8691 return change; 8867 return change;
@@ -8703,6 +8879,46 @@ static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
8703 }, 8879 },
8704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8882 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
8883 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
8884 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8887 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8888 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8889 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8890 { } /* end */
8891};
8892
8893/* bind hp and internal speaker mute (with plug check) */
8894static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
8895 struct snd_ctl_elem_value *ucontrol)
8896{
8897 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8898 long *valp = ucontrol->value.integer.value;
8899 int change;
8900
8901 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8902 HDA_AMP_MUTE,
8903 valp ? 0 : HDA_AMP_MUTE);
8904
8905 if (change)
8906 alc262_lenovo_3000_automute(codec, 0);
8907 return change;
8908}
8909
8910static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
8911 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
8912 {
8913 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8914 .name = "Master Playback Switch",
8915 .info = snd_hda_mixer_amp_switch_info,
8916 .get = snd_hda_mixer_amp_switch_get,
8917 .put = alc262_lenovo_3000_master_sw_put,
8918 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8919 },
8920 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8921 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 8922 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 8924 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
@@ -8730,59 +8946,72 @@ static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8730 8946
8731/* Samsung Q1 Ultra Vista model setup */ 8947/* Samsung Q1 Ultra Vista model setup */
8732static struct snd_kcontrol_new alc262_ultra_mixer[] = { 8948static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8733 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 8949 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8734 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 8950 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
8735 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8736 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 8951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8737 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8738 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), 8953 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8954 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
8739 { } /* end */ 8955 { } /* end */
8740}; 8956};
8741 8957
8742static struct hda_verb alc262_ultra_verbs[] = { 8958static struct hda_verb alc262_ultra_verbs[] = {
8743 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 8959 /* output mixer */
8960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8962 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8963 /* speaker */
8964 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8967 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8968 /* HP */
8744 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 8969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8745 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 8970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8746 /* Mic is on Node 0x19 */ 8971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8747 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 8972 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8748 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01}, 8973 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 8974 /* internal mic */
8750 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, 8975 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 8976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8752 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01}, 8977 /* ADC, choose mic */
8753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 8978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8980 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8981 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8982 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
8987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
8754 {} 8988 {}
8755}; 8989};
8756 8990
8757static struct hda_input_mux alc262_ultra_capture_source = {
8758 .num_items = 1,
8759 .items = {
8760 { "Mic", 0x1 },
8761 },
8762};
8763
8764/* mute/unmute internal speaker according to the hp jack and mute state */ 8991/* mute/unmute internal speaker according to the hp jack and mute state */
8765static void alc262_ultra_automute(struct hda_codec *codec) 8992static void alc262_ultra_automute(struct hda_codec *codec)
8766{ 8993{
8767 struct alc_spec *spec = codec->spec; 8994 struct alc_spec *spec = codec->spec;
8768 unsigned int mute; 8995 unsigned int mute;
8769 unsigned int present;
8770 8996
8771 /* need to execute and sync at first */ 8997 mute = 0;
8772 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 8998 /* auto-mute only when HP is used as HP */
8773 present = snd_hda_codec_read(codec, 0x15, 0, 8999 if (!spec->cur_mux[0]) {
8774 AC_VERB_GET_PIN_SENSE, 0); 9000 unsigned int present;
8775 spec->jack_present = (present & 0x80000000) != 0; 9001 /* need to execute and sync at first */
8776 if (spec->jack_present) { 9002 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8777 /* mute internal speaker */ 9003 present = snd_hda_codec_read(codec, 0x15, 0,
8778 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 9004 AC_VERB_GET_PIN_SENSE, 0);
8779 HDA_AMP_MUTE, HDA_AMP_MUTE); 9005 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
8780 } else { 9006 if (spec->jack_present)
8781 /* unmute internal speaker if necessary */ 9007 mute = HDA_AMP_MUTE;
8782 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8783 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8784 HDA_AMP_MUTE, mute);
8785 } 9008 }
9009 /* mute/unmute internal speaker */
9010 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9011 HDA_AMP_MUTE, mute);
9012 /* mute/unmute HP */
9013 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9014 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
8786} 9015}
8787 9016
8788/* unsolicited event for HP jack sensing */ 9017/* unsolicited event for HP jack sensing */
@@ -8794,6 +9023,45 @@ static void alc262_ultra_unsol_event(struct hda_codec *codec,
8794 alc262_ultra_automute(codec); 9023 alc262_ultra_automute(codec);
8795} 9024}
8796 9025
9026static struct hda_input_mux alc262_ultra_capture_source = {
9027 .num_items = 2,
9028 .items = {
9029 { "Mic", 0x1 },
9030 { "Headphone", 0x7 },
9031 },
9032};
9033
9034static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9035 struct snd_ctl_elem_value *ucontrol)
9036{
9037 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9038 struct alc_spec *spec = codec->spec;
9039 int ret;
9040
9041 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9042 if (!ret)
9043 return 0;
9044 /* reprogram the HP pin as mic or HP according to the input source */
9045 snd_hda_codec_write_cache(codec, 0x15, 0,
9046 AC_VERB_SET_PIN_WIDGET_CONTROL,
9047 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9048 alc262_ultra_automute(codec); /* mute/unmute HP */
9049 return ret;
9050}
9051
9052static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9053 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9054 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9055 {
9056 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9057 .name = "Capture Source",
9058 .info = alc882_mux_enum_info,
9059 .get = alc882_mux_enum_get,
9060 .put = alc262_ultra_mux_enum_put,
9061 },
9062 { } /* end */
9063};
9064
8797/* add playback controls from the parsed DAC table */ 9065/* add playback controls from the parsed DAC table */
8798static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, 9066static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8799 const struct auto_pin_cfg *cfg) 9067 const struct auto_pin_cfg *cfg)
@@ -9185,9 +9453,12 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
9185/* init callback for auto-configuration model -- overriding the default init */ 9453/* init callback for auto-configuration model -- overriding the default init */
9186static void alc262_auto_init(struct hda_codec *codec) 9454static void alc262_auto_init(struct hda_codec *codec)
9187{ 9455{
9456 struct alc_spec *spec = codec->spec;
9188 alc262_auto_init_multi_out(codec); 9457 alc262_auto_init_multi_out(codec);
9189 alc262_auto_init_hp_out(codec); 9458 alc262_auto_init_hp_out(codec);
9190 alc262_auto_init_analog_input(codec); 9459 alc262_auto_init_analog_input(codec);
9460 if (spec->unsol_event)
9461 alc_sku_automute(codec);
9191} 9462}
9192 9463
9193/* 9464/*
@@ -9206,6 +9477,7 @@ static const char *alc262_models[ALC262_MODEL_LAST] = {
9206 [ALC262_BENQ_T31] = "benq-t31", 9477 [ALC262_BENQ_T31] = "benq-t31",
9207 [ALC262_SONY_ASSAMD] = "sony-assamd", 9478 [ALC262_SONY_ASSAMD] = "sony-assamd",
9208 [ALC262_ULTRA] = "ultra", 9479 [ALC262_ULTRA] = "ultra",
9480 [ALC262_LENOVO_3000] = "lenovo-3000",
9209 [ALC262_AUTO] = "auto", 9481 [ALC262_AUTO] = "auto",
9210}; 9482};
9211 9483
@@ -9241,6 +9513,8 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
9241 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 9513 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9242 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), 9514 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
9243 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 9515 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9516 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
9517 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
9244 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 9518 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9245 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), 9519 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
9246 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), 9520 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
@@ -9390,18 +9664,32 @@ static struct alc_config_preset alc262_presets[] = {
9390 .init_hook = alc262_hippo_automute, 9664 .init_hook = alc262_hippo_automute,
9391 }, 9665 },
9392 [ALC262_ULTRA] = { 9666 [ALC262_ULTRA] = {
9393 .mixers = { alc262_ultra_mixer }, 9667 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9394 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs }, 9668 .init_verbs = { alc262_ultra_verbs },
9395 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 9669 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9396 .dac_nids = alc262_dac_nids, 9670 .dac_nids = alc262_dac_nids,
9397 .hp_nid = 0x03,
9398 .dig_out_nid = ALC262_DIGOUT_NID,
9399 .num_channel_mode = ARRAY_SIZE(alc262_modes), 9671 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9400 .channel_mode = alc262_modes, 9672 .channel_mode = alc262_modes,
9401 .input_mux = &alc262_ultra_capture_source, 9673 .input_mux = &alc262_ultra_capture_source,
9674 .adc_nids = alc262_adc_nids, /* ADC0 */
9675 .capsrc_nids = alc262_capsrc_nids,
9676 .num_adc_nids = 1, /* single ADC */
9402 .unsol_event = alc262_ultra_unsol_event, 9677 .unsol_event = alc262_ultra_unsol_event,
9403 .init_hook = alc262_ultra_automute, 9678 .init_hook = alc262_ultra_automute,
9404 }, 9679 },
9680 [ALC262_LENOVO_3000] = {
9681 .mixers = { alc262_lenovo_3000_mixer },
9682 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9683 alc262_lenovo_3000_unsol_verbs },
9684 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9685 .dac_nids = alc262_dac_nids,
9686 .hp_nid = 0x03,
9687 .dig_out_nid = ALC262_DIGOUT_NID,
9688 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9689 .channel_mode = alc262_modes,
9690 .input_mux = &alc262_fujitsu_capture_source,
9691 .unsol_event = alc262_lenovo_3000_unsol_event,
9692 },
9405}; 9693};
9406 9694
9407static int patch_alc262(struct hda_codec *codec) 9695static int patch_alc262(struct hda_codec *codec)
@@ -9472,12 +9760,14 @@ static int patch_alc262(struct hda_codec *codec)
9472 if (wcap != AC_WID_AUD_IN) { 9760 if (wcap != AC_WID_AUD_IN) {
9473 spec->adc_nids = alc262_adc_nids_alt; 9761 spec->adc_nids = alc262_adc_nids_alt;
9474 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 9762 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
9763 spec->capsrc_nids = alc262_capsrc_nids_alt;
9475 spec->mixers[spec->num_mixers] = 9764 spec->mixers[spec->num_mixers] =
9476 alc262_capture_alt_mixer; 9765 alc262_capture_alt_mixer;
9477 spec->num_mixers++; 9766 spec->num_mixers++;
9478 } else { 9767 } else {
9479 spec->adc_nids = alc262_adc_nids; 9768 spec->adc_nids = alc262_adc_nids;
9480 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); 9769 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9770 spec->capsrc_nids = alc262_capsrc_nids;
9481 spec->mixers[spec->num_mixers] = alc262_capture_mixer; 9771 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9482 spec->num_mixers++; 9772 spec->num_mixers++;
9483 } 9773 }
@@ -9517,6 +9807,8 @@ static hda_nid_t alc268_adc_nids_alt[1] = {
9517 0x08 9807 0x08
9518}; 9808};
9519 9809
9810static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
9811
9520static struct snd_kcontrol_new alc268_base_mixer[] = { 9812static struct snd_kcontrol_new alc268_base_mixer[] = {
9521 /* output mixer control */ 9813 /* output mixer control */
9522 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), 9814 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
@@ -9529,6 +9821,22 @@ static struct snd_kcontrol_new alc268_base_mixer[] = {
9529 { } 9821 { }
9530}; 9822};
9531 9823
9824/* bind Beep switches of both NID 0x0f and 0x10 */
9825static struct hda_bind_ctls alc268_bind_beep_sw = {
9826 .ops = &snd_hda_bind_sw,
9827 .values = {
9828 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
9829 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
9830 0
9831 },
9832};
9833
9834static struct snd_kcontrol_new alc268_beep_mixer[] = {
9835 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
9836 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
9837 { }
9838};
9839
9532static struct hda_verb alc268_eapd_verbs[] = { 9840static struct hda_verb alc268_eapd_verbs[] = {
9533 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 9841 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9534 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 9842 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
@@ -9613,8 +9921,12 @@ static struct snd_kcontrol_new alc268_acer_mixer[] = {
9613}; 9921};
9614 9922
9615static struct hda_verb alc268_acer_verbs[] = { 9923static struct hda_verb alc268_acer_verbs[] = {
9924 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
9925 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 9926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9617 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 9927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9618 9930
9619 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 9931 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9620 { } 9932 { }
@@ -9685,6 +9997,64 @@ static void alc268_dell_unsol_event(struct hda_codec *codec,
9685 9997
9686#define alc268_dell_init_hook alc268_dell_automute 9998#define alc268_dell_init_hook alc268_dell_automute
9687 9999
10000static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10001 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10002 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10003 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10006 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10007 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10008 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10009 { }
10010};
10011
10012static struct hda_verb alc267_quanta_il1_verbs[] = {
10013 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10014 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10015 { }
10016};
10017
10018static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10019{
10020 unsigned int present;
10021
10022 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10023 & AC_PINSENSE_PRESENCE;
10024 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10025 present ? 0 : PIN_OUT);
10026}
10027
10028static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10029{
10030 unsigned int present;
10031
10032 present = snd_hda_codec_read(codec, 0x18, 0,
10033 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10034 snd_hda_codec_write(codec, 0x23, 0,
10035 AC_VERB_SET_CONNECT_SEL,
10036 present ? 0x00 : 0x01);
10037}
10038
10039static void alc267_quanta_il1_automute(struct hda_codec *codec)
10040{
10041 alc267_quanta_il1_hp_automute(codec);
10042 alc267_quanta_il1_mic_automute(codec);
10043}
10044
10045static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10046 unsigned int res)
10047{
10048 switch (res >> 26) {
10049 case ALC880_HP_EVENT:
10050 alc267_quanta_il1_hp_automute(codec);
10051 break;
10052 case ALC880_MIC_EVENT:
10053 alc267_quanta_il1_mic_automute(codec);
10054 break;
10055 }
10056}
10057
9688/* 10058/*
9689 * generic initialization of ADC, input mixers and output mixers 10059 * generic initialization of ADC, input mixers and output mixers
9690 */ 10060 */
@@ -9725,7 +10095,11 @@ static struct hda_verb alc268_base_init_verbs[] = {
9725 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10095 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10096 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9727 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10097 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9728 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 10098
10099 /* set PCBEEP vol = 0, mute connections */
10100 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10101 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10102 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9729 10103
9730 /* Unmute Selector 23h,24h and set the default input to mic-in */ 10104 /* Unmute Selector 23h,24h and set the default input to mic-in */
9731 10105
@@ -9764,29 +10138,17 @@ static struct hda_verb alc268_volume_init_verbs[] = {
9764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9765 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 10139 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9766 10140
9767 /* set PCBEEP vol = 0 */ 10141 /* set PCBEEP vol = 0, mute connections */
9768 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))}, 10142 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10144 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9769 10145
9770 { } 10146 { }
9771}; 10147};
9772 10148
9773#define alc268_mux_enum_info alc_mux_enum_info 10149#define alc268_mux_enum_info alc_mux_enum_info
9774#define alc268_mux_enum_get alc_mux_enum_get 10150#define alc268_mux_enum_get alc_mux_enum_get
9775 10151#define alc268_mux_enum_put alc_mux_enum_put
9776static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9777 struct snd_ctl_elem_value *ucontrol)
9778{
9779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9780 struct alc_spec *spec = codec->spec;
9781
9782 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9783 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9784 hda_nid_t nid = capture_mixers[adc_idx];
9785
9786 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9787 nid,
9788 &spec->cur_mux[adc_idx]);
9789}
9790 10152
9791static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { 10153static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9792 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), 10154 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
@@ -9836,13 +10198,17 @@ static struct hda_input_mux alc268_capture_source = {
9836 }, 10198 },
9837}; 10199};
9838 10200
10201static struct hda_input_mux alc268_acer_capture_source = {
10202 .num_items = 3,
10203 .items = {
10204 { "Mic", 0x0 },
10205 { "Internal Mic", 0x6 },
10206 { "Line", 0x2 },
10207 },
10208};
10209
9839#ifdef CONFIG_SND_DEBUG 10210#ifdef CONFIG_SND_DEBUG
9840static struct snd_kcontrol_new alc268_test_mixer[] = { 10211static struct snd_kcontrol_new alc268_test_mixer[] = {
9841 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9842 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9843 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9845
9846 /* Volume widgets */ 10212 /* Volume widgets */
9847 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), 10213 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9848 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), 10214 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
@@ -9981,6 +10347,10 @@ static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9981 case 0x1c: 10347 case 0x1c:
9982 idx1 = 3; /* CD */ 10348 idx1 = 3; /* CD */
9983 break; 10349 break;
10350 case 0x12:
10351 case 0x13:
10352 idx1 = 6; /* digital mics */
10353 break;
9984 default: 10354 default:
9985 continue; 10355 continue;
9986 } 10356 }
@@ -10073,6 +10443,9 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
10073 if (spec->kctl_alloc) 10443 if (spec->kctl_alloc)
10074 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 10444 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10075 10445
10446 if (spec->autocfg.speaker_pins[0] != 0x1d)
10447 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10448
10076 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs; 10449 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10077 spec->num_mux_defs = 1; 10450 spec->num_mux_defs = 1;
10078 spec->input_mux = &spec->private_imux; 10451 spec->input_mux = &spec->private_imux;
@@ -10091,20 +10464,25 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
10091/* init callback for auto-configuration model -- overriding the default init */ 10464/* init callback for auto-configuration model -- overriding the default init */
10092static void alc268_auto_init(struct hda_codec *codec) 10465static void alc268_auto_init(struct hda_codec *codec)
10093{ 10466{
10467 struct alc_spec *spec = codec->spec;
10094 alc268_auto_init_multi_out(codec); 10468 alc268_auto_init_multi_out(codec);
10095 alc268_auto_init_hp_out(codec); 10469 alc268_auto_init_hp_out(codec);
10096 alc268_auto_init_mono_speaker_out(codec); 10470 alc268_auto_init_mono_speaker_out(codec);
10097 alc268_auto_init_analog_input(codec); 10471 alc268_auto_init_analog_input(codec);
10472 if (spec->unsol_event)
10473 alc_sku_automute(codec);
10098} 10474}
10099 10475
10100/* 10476/*
10101 * configuration and preset 10477 * configuration and preset
10102 */ 10478 */
10103static const char *alc268_models[ALC268_MODEL_LAST] = { 10479static const char *alc268_models[ALC268_MODEL_LAST] = {
10480 [ALC267_QUANTA_IL1] = "quanta-il1",
10104 [ALC268_3ST] = "3stack", 10481 [ALC268_3ST] = "3stack",
10105 [ALC268_TOSHIBA] = "toshiba", 10482 [ALC268_TOSHIBA] = "toshiba",
10106 [ALC268_ACER] = "acer", 10483 [ALC268_ACER] = "acer",
10107 [ALC268_DELL] = "dell", 10484 [ALC268_DELL] = "dell",
10485 [ALC268_ZEPTO] = "zepto",
10108#ifdef CONFIG_SND_DEBUG 10486#ifdef CONFIG_SND_DEBUG
10109 [ALC268_TEST] = "test", 10487 [ALC268_TEST] = "test",
10110#endif 10488#endif
@@ -10112,6 +10490,7 @@ static const char *alc268_models[ALC268_MODEL_LAST] = {
10112}; 10490};
10113 10491
10114static struct snd_pci_quirk alc268_cfg_tbl[] = { 10492static struct snd_pci_quirk alc268_cfg_tbl[] = {
10493 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
10115 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), 10494 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
10116 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), 10495 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
10117 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), 10496 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
@@ -10122,17 +10501,36 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
10122 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), 10501 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
10123 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), 10502 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
10124 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 10503 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
10504 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
10505 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
10125 {} 10506 {}
10126}; 10507};
10127 10508
10128static struct alc_config_preset alc268_presets[] = { 10509static struct alc_config_preset alc268_presets[] = {
10510 [ALC267_QUANTA_IL1] = {
10511 .mixers = { alc267_quanta_il1_mixer },
10512 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10513 alc267_quanta_il1_verbs },
10514 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10515 .dac_nids = alc268_dac_nids,
10516 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10517 .adc_nids = alc268_adc_nids_alt,
10518 .hp_nid = 0x03,
10519 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10520 .channel_mode = alc268_modes,
10521 .input_mux = &alc268_capture_source,
10522 .unsol_event = alc267_quanta_il1_unsol_event,
10523 .init_hook = alc267_quanta_il1_automute,
10524 },
10129 [ALC268_3ST] = { 10525 [ALC268_3ST] = {
10130 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, 10526 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10527 alc268_beep_mixer },
10131 .init_verbs = { alc268_base_init_verbs }, 10528 .init_verbs = { alc268_base_init_verbs },
10132 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10529 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10133 .dac_nids = alc268_dac_nids, 10530 .dac_nids = alc268_dac_nids,
10134 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10531 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10135 .adc_nids = alc268_adc_nids_alt, 10532 .adc_nids = alc268_adc_nids_alt,
10533 .capsrc_nids = alc268_capsrc_nids,
10136 .hp_nid = 0x03, 10534 .hp_nid = 0x03,
10137 .dig_out_nid = ALC268_DIGOUT_NID, 10535 .dig_out_nid = ALC268_DIGOUT_NID,
10138 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10536 .num_channel_mode = ARRAY_SIZE(alc268_modes),
@@ -10140,13 +10538,15 @@ static struct alc_config_preset alc268_presets[] = {
10140 .input_mux = &alc268_capture_source, 10538 .input_mux = &alc268_capture_source,
10141 }, 10539 },
10142 [ALC268_TOSHIBA] = { 10540 [ALC268_TOSHIBA] = {
10143 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer }, 10541 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10542 alc268_beep_mixer },
10144 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10543 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10145 alc268_toshiba_verbs }, 10544 alc268_toshiba_verbs },
10146 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10545 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10147 .dac_nids = alc268_dac_nids, 10546 .dac_nids = alc268_dac_nids,
10148 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10547 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10149 .adc_nids = alc268_adc_nids_alt, 10548 .adc_nids = alc268_adc_nids_alt,
10549 .capsrc_nids = alc268_capsrc_nids,
10150 .hp_nid = 0x03, 10550 .hp_nid = 0x03,
10151 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10551 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10152 .channel_mode = alc268_modes, 10552 .channel_mode = alc268_modes,
@@ -10155,22 +10555,24 @@ static struct alc_config_preset alc268_presets[] = {
10155 .init_hook = alc268_toshiba_automute, 10555 .init_hook = alc268_toshiba_automute,
10156 }, 10556 },
10157 [ALC268_ACER] = { 10557 [ALC268_ACER] = {
10158 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer }, 10558 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10559 alc268_beep_mixer },
10159 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10560 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10160 alc268_acer_verbs }, 10561 alc268_acer_verbs },
10161 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10562 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10162 .dac_nids = alc268_dac_nids, 10563 .dac_nids = alc268_dac_nids,
10163 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10564 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10164 .adc_nids = alc268_adc_nids_alt, 10565 .adc_nids = alc268_adc_nids_alt,
10566 .capsrc_nids = alc268_capsrc_nids,
10165 .hp_nid = 0x02, 10567 .hp_nid = 0x02,
10166 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10568 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10167 .channel_mode = alc268_modes, 10569 .channel_mode = alc268_modes,
10168 .input_mux = &alc268_capture_source, 10570 .input_mux = &alc268_acer_capture_source,
10169 .unsol_event = alc268_acer_unsol_event, 10571 .unsol_event = alc268_acer_unsol_event,
10170 .init_hook = alc268_acer_init_hook, 10572 .init_hook = alc268_acer_init_hook,
10171 }, 10573 },
10172 [ALC268_DELL] = { 10574 [ALC268_DELL] = {
10173 .mixers = { alc268_dell_mixer }, 10575 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
10174 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 10576 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10175 alc268_dell_verbs }, 10577 alc268_dell_verbs },
10176 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 10578 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -10182,6 +10584,24 @@ static struct alc_config_preset alc268_presets[] = {
10182 .init_hook = alc268_dell_init_hook, 10584 .init_hook = alc268_dell_init_hook,
10183 .input_mux = &alc268_capture_source, 10585 .input_mux = &alc268_capture_source,
10184 }, 10586 },
10587 [ALC268_ZEPTO] = {
10588 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10589 alc268_beep_mixer },
10590 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10591 alc268_toshiba_verbs },
10592 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10593 .dac_nids = alc268_dac_nids,
10594 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10595 .adc_nids = alc268_adc_nids_alt,
10596 .capsrc_nids = alc268_capsrc_nids,
10597 .hp_nid = 0x03,
10598 .dig_out_nid = ALC268_DIGOUT_NID,
10599 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10600 .channel_mode = alc268_modes,
10601 .input_mux = &alc268_capture_source,
10602 .unsol_event = alc268_toshiba_unsol_event,
10603 .init_hook = alc268_toshiba_automute
10604 },
10185#ifdef CONFIG_SND_DEBUG 10605#ifdef CONFIG_SND_DEBUG
10186 [ALC268_TEST] = { 10606 [ALC268_TEST] = {
10187 .mixers = { alc268_test_mixer, alc268_capture_mixer }, 10607 .mixers = { alc268_test_mixer, alc268_capture_mixer },
@@ -10191,6 +10611,7 @@ static struct alc_config_preset alc268_presets[] = {
10191 .dac_nids = alc268_dac_nids, 10611 .dac_nids = alc268_dac_nids,
10192 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), 10612 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10193 .adc_nids = alc268_adc_nids_alt, 10613 .adc_nids = alc268_adc_nids_alt,
10614 .capsrc_nids = alc268_capsrc_nids,
10194 .hp_nid = 0x03, 10615 .hp_nid = 0x03,
10195 .dig_out_nid = ALC268_DIGOUT_NID, 10616 .dig_out_nid = ALC268_DIGOUT_NID,
10196 .num_channel_mode = ARRAY_SIZE(alc268_modes), 10617 .num_channel_mode = ARRAY_SIZE(alc268_modes),
@@ -10247,13 +10668,22 @@ static int patch_alc268(struct hda_codec *codec)
10247 spec->stream_name_digital = "ALC268 Digital"; 10668 spec->stream_name_digital = "ALC268 Digital";
10248 spec->stream_digital_playback = &alc268_pcm_digital_playback; 10669 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10249 10670
10671 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10672 /* override the amp caps for beep generator */
10673 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10674 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10675 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10676 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10677 (0 << AC_AMPCAP_MUTE_SHIFT));
10678
10250 if (!spec->adc_nids && spec->input_mux) { 10679 if (!spec->adc_nids && spec->input_mux) {
10251 /* check whether NID 0x07 is valid */ 10680 /* check whether NID 0x07 is valid */
10252 unsigned int wcap = get_wcaps(codec, 0x07); 10681 unsigned int wcap = get_wcaps(codec, 0x07);
10682 int i;
10253 10683
10254 /* get type */ 10684 /* get type */
10255 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 10685 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10256 if (wcap != AC_WID_AUD_IN) { 10686 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
10257 spec->adc_nids = alc268_adc_nids_alt; 10687 spec->adc_nids = alc268_adc_nids_alt;
10258 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); 10688 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10259 spec->mixers[spec->num_mixers] = 10689 spec->mixers[spec->num_mixers] =
@@ -10266,6 +10696,12 @@ static int patch_alc268(struct hda_codec *codec)
10266 alc268_capture_mixer; 10696 alc268_capture_mixer;
10267 spec->num_mixers++; 10697 spec->num_mixers++;
10268 } 10698 }
10699 spec->capsrc_nids = alc268_capsrc_nids;
10700 /* set default input source */
10701 for (i = 0; i < spec->num_adc_nids; i++)
10702 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10703 0, AC_VERB_SET_CONNECT_SEL,
10704 spec->input_mux->items[0].index);
10269 } 10705 }
10270 10706
10271 spec->vmaster_nid = 0x02; 10707 spec->vmaster_nid = 0x02;
@@ -10539,9 +10975,12 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
10539/* init callback for auto-configuration model -- overriding the default init */ 10975/* init callback for auto-configuration model -- overriding the default init */
10540static void alc269_auto_init(struct hda_codec *codec) 10976static void alc269_auto_init(struct hda_codec *codec)
10541{ 10977{
10978 struct alc_spec *spec = codec->spec;
10542 alc269_auto_init_multi_out(codec); 10979 alc269_auto_init_multi_out(codec);
10543 alc269_auto_init_hp_out(codec); 10980 alc269_auto_init_hp_out(codec);
10544 alc269_auto_init_analog_input(codec); 10981 alc269_auto_init_analog_input(codec);
10982 if (spec->unsol_event)
10983 alc_sku_automute(codec);
10545} 10984}
10546 10985
10547/* 10986/*
@@ -11463,13 +11902,10 @@ static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11463 hda_nid_t nid, 11902 hda_nid_t nid,
11464 int pin_type, int dac_idx) 11903 int pin_type, int dac_idx)
11465{ 11904{
11466 /* set as output */
11467
11468 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 11905 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11469 pin_type); 11906 pin_type);
11470 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, 11907 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11471 AMP_OUT_UNMUTE); 11908 AMP_OUT_UNMUTE);
11472
11473} 11909}
11474 11910
11475static void alc861_auto_init_multi_out(struct hda_codec *codec) 11911static void alc861_auto_init_multi_out(struct hda_codec *codec)
@@ -11496,6 +11932,9 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
11496 if (pin) /* connect to front */ 11932 if (pin) /* connect to front */
11497 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, 11933 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11498 spec->multiout.dac_nids[0]); 11934 spec->multiout.dac_nids[0]);
11935 pin = spec->autocfg.speaker_pins[0];
11936 if (pin)
11937 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
11499} 11938}
11500 11939
11501static void alc861_auto_init_analog_input(struct hda_codec *codec) 11940static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -11568,9 +12007,12 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
11568/* additional initialization for auto-configuration model */ 12007/* additional initialization for auto-configuration model */
11569static void alc861_auto_init(struct hda_codec *codec) 12008static void alc861_auto_init(struct hda_codec *codec)
11570{ 12009{
12010 struct alc_spec *spec = codec->spec;
11571 alc861_auto_init_multi_out(codec); 12011 alc861_auto_init_multi_out(codec);
11572 alc861_auto_init_hp_out(codec); 12012 alc861_auto_init_hp_out(codec);
11573 alc861_auto_init_analog_input(codec); 12013 alc861_auto_init_analog_input(codec);
12014 if (spec->unsol_event)
12015 alc_sku_automute(codec);
11574} 12016}
11575 12017
11576#ifdef CONFIG_SND_HDA_POWER_SAVE 12018#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -11822,6 +12264,8 @@ static hda_nid_t alc861vd_adc_nids[1] = {
11822 0x09, 12264 0x09,
11823}; 12265};
11824 12266
12267static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12268
11825/* input MUX */ 12269/* input MUX */
11826/* FIXME: should be a matrix-type input source selection */ 12270/* FIXME: should be a matrix-type input source selection */
11827static struct hda_input_mux alc861vd_capture_source = { 12271static struct hda_input_mux alc861vd_capture_source = {
@@ -11835,11 +12279,10 @@ static struct hda_input_mux alc861vd_capture_source = {
11835}; 12279};
11836 12280
11837static struct hda_input_mux alc861vd_dallas_capture_source = { 12281static struct hda_input_mux alc861vd_dallas_capture_source = {
11838 .num_items = 3, 12282 .num_items = 2,
11839 .items = { 12283 .items = {
11840 { "Front Mic", 0x0 }, 12284 { "Ext Mic", 0x0 },
11841 { "ATAPI Mic", 0x1 }, 12285 { "Int Mic", 0x1 },
11842 { "Line In", 0x5 },
11843 }, 12286 },
11844}; 12287};
11845 12288
@@ -11853,33 +12296,8 @@ static struct hda_input_mux alc861vd_hp_capture_source = {
11853 12296
11854#define alc861vd_mux_enum_info alc_mux_enum_info 12297#define alc861vd_mux_enum_info alc_mux_enum_info
11855#define alc861vd_mux_enum_get alc_mux_enum_get 12298#define alc861vd_mux_enum_get alc_mux_enum_get
11856 12299/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
11857static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol, 12300#define alc861vd_mux_enum_put alc882_mux_enum_put
11858 struct snd_ctl_elem_value *ucontrol)
11859{
11860 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11861 struct alc_spec *spec = codec->spec;
11862 const struct hda_input_mux *imux = spec->input_mux;
11863 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11864 static hda_nid_t capture_mixers[1] = { 0x22 };
11865 hda_nid_t nid = capture_mixers[adc_idx];
11866 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11867 unsigned int i, idx;
11868
11869 idx = ucontrol->value.enumerated.item[0];
11870 if (idx >= imux->num_items)
11871 idx = imux->num_items - 1;
11872 if (*cur_val == idx)
11873 return 0;
11874 for (i = 0; i < imux->num_items; i++) {
11875 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11876 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11877 imux->items[i].index,
11878 HDA_AMP_MUTE, v);
11879 }
11880 *cur_val = idx;
11881 return 1;
11882}
11883 12301
11884/* 12302/*
11885 * 2ch mode 12303 * 2ch mode
@@ -12034,20 +12452,22 @@ static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12034 { } /* end */ 12452 { } /* end */
12035}; 12453};
12036 12454
12037/* Pin assignment: Front=0x14, HP = 0x15, 12455/* Pin assignment: Speaker=0x14, HP = 0x15,
12038 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d 12456 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
12039 */ 12457 */
12040static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { 12458static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12041 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12459 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 12460 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
12043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), 12461 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12044 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 12462 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12045 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12463 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12046 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12464 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12047 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 12465 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12048 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 12466 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT), 12467 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT), 12468 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12469 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12470 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
12051 { } /* end */ 12471 { } /* end */
12052}; 12472};
12053 12473
@@ -12348,6 +12768,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12348 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ 12768 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
12349 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), 12769 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
12350 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 12770 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
12771 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
12351 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 12772 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
12352 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), 12773 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12353 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), 12774 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
@@ -12362,8 +12783,6 @@ static struct alc_config_preset alc861vd_presets[] = {
12362 alc861vd_3stack_init_verbs }, 12783 alc861vd_3stack_init_verbs },
12363 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 12784 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12364 .dac_nids = alc660vd_dac_nids, 12785 .dac_nids = alc660vd_dac_nids,
12365 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12366 .adc_nids = alc861vd_adc_nids,
12367 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12786 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12368 .channel_mode = alc861vd_3stack_2ch_modes, 12787 .channel_mode = alc861vd_3stack_2ch_modes,
12369 .input_mux = &alc861vd_capture_source, 12788 .input_mux = &alc861vd_capture_source,
@@ -12375,8 +12794,6 @@ static struct alc_config_preset alc861vd_presets[] = {
12375 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 12794 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12376 .dac_nids = alc660vd_dac_nids, 12795 .dac_nids = alc660vd_dac_nids,
12377 .dig_out_nid = ALC861VD_DIGOUT_NID, 12796 .dig_out_nid = ALC861VD_DIGOUT_NID,
12378 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12379 .adc_nids = alc861vd_adc_nids,
12380 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12797 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12381 .channel_mode = alc861vd_3stack_2ch_modes, 12798 .channel_mode = alc861vd_3stack_2ch_modes,
12382 .input_mux = &alc861vd_capture_source, 12799 .input_mux = &alc861vd_capture_source,
@@ -12421,8 +12838,6 @@ static struct alc_config_preset alc861vd_presets[] = {
12421 alc861vd_lenovo_unsol_verbs }, 12838 alc861vd_lenovo_unsol_verbs },
12422 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), 12839 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12423 .dac_nids = alc660vd_dac_nids, 12840 .dac_nids = alc660vd_dac_nids,
12424 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12425 .adc_nids = alc861vd_adc_nids,
12426 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12841 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12427 .channel_mode = alc861vd_3stack_2ch_modes, 12842 .channel_mode = alc861vd_3stack_2ch_modes,
12428 .input_mux = &alc861vd_capture_source, 12843 .input_mux = &alc861vd_capture_source,
@@ -12434,8 +12849,6 @@ static struct alc_config_preset alc861vd_presets[] = {
12434 .init_verbs = { alc861vd_dallas_verbs }, 12849 .init_verbs = { alc861vd_dallas_verbs },
12435 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 12850 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12436 .dac_nids = alc861vd_dac_nids, 12851 .dac_nids = alc861vd_dac_nids,
12437 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12438 .adc_nids = alc861vd_adc_nids,
12439 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12852 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12440 .channel_mode = alc861vd_3stack_2ch_modes, 12853 .channel_mode = alc861vd_3stack_2ch_modes,
12441 .input_mux = &alc861vd_dallas_capture_source, 12854 .input_mux = &alc861vd_dallas_capture_source,
@@ -12447,9 +12860,7 @@ static struct alc_config_preset alc861vd_presets[] = {
12447 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, 12860 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12448 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), 12861 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12449 .dac_nids = alc861vd_dac_nids, 12862 .dac_nids = alc861vd_dac_nids,
12450 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12451 .dig_out_nid = ALC861VD_DIGOUT_NID, 12863 .dig_out_nid = ALC861VD_DIGOUT_NID,
12452 .adc_nids = alc861vd_adc_nids,
12453 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), 12864 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12454 .channel_mode = alc861vd_3stack_2ch_modes, 12865 .channel_mode = alc861vd_3stack_2ch_modes,
12455 .input_mux = &alc861vd_hp_capture_source, 12866 .input_mux = &alc861vd_hp_capture_source,
@@ -12464,11 +12875,7 @@ static struct alc_config_preset alc861vd_presets[] = {
12464static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, 12875static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12465 hda_nid_t nid, int pin_type, int dac_idx) 12876 hda_nid_t nid, int pin_type, int dac_idx)
12466{ 12877{
12467 /* set as output */ 12878 alc_set_pin_output(codec, nid, pin_type);
12468 snd_hda_codec_write(codec, nid, 0,
12469 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12470 snd_hda_codec_write(codec, nid, 0,
12471 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12472} 12879}
12473 12880
12474static void alc861vd_auto_init_multi_out(struct hda_codec *codec) 12881static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
@@ -12495,6 +12902,9 @@ static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12495 pin = spec->autocfg.hp_pins[0]; 12902 pin = spec->autocfg.hp_pins[0];
12496 if (pin) /* connect to front and use dac 0 */ 12903 if (pin) /* connect to front and use dac 0 */
12497 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 12904 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12905 pin = spec->autocfg.speaker_pins[0];
12906 if (pin)
12907 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
12498} 12908}
12499 12909
12500#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) 12910#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -12698,9 +13108,12 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
12698/* additional initialization for auto-configuration model */ 13108/* additional initialization for auto-configuration model */
12699static void alc861vd_auto_init(struct hda_codec *codec) 13109static void alc861vd_auto_init(struct hda_codec *codec)
12700{ 13110{
13111 struct alc_spec *spec = codec->spec;
12701 alc861vd_auto_init_multi_out(codec); 13112 alc861vd_auto_init_multi_out(codec);
12702 alc861vd_auto_init_hp_out(codec); 13113 alc861vd_auto_init_hp_out(codec);
12703 alc861vd_auto_init_analog_input(codec); 13114 alc861vd_auto_init_analog_input(codec);
13115 if (spec->unsol_event)
13116 alc_sku_automute(codec);
12704} 13117}
12705 13118
12706static int patch_alc861vd(struct hda_codec *codec) 13119static int patch_alc861vd(struct hda_codec *codec)
@@ -12751,6 +13164,7 @@ static int patch_alc861vd(struct hda_codec *codec)
12751 13164
12752 spec->adc_nids = alc861vd_adc_nids; 13165 spec->adc_nids = alc861vd_adc_nids;
12753 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 13166 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
13167 spec->capsrc_nids = alc861vd_capsrc_nids;
12754 13168
12755 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer; 13169 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12756 spec->num_mixers++; 13170 spec->num_mixers++;
@@ -12792,9 +13206,11 @@ static hda_nid_t alc662_adc_nids[1] = {
12792 /* ADC1-2 */ 13206 /* ADC1-2 */
12793 0x09, 13207 0x09,
12794}; 13208};
13209
13210static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
13211
12795/* input MUX */ 13212/* input MUX */
12796/* FIXME: should be a matrix-type input source selection */ 13213/* FIXME: should be a matrix-type input source selection */
12797
12798static struct hda_input_mux alc662_capture_source = { 13214static struct hda_input_mux alc662_capture_source = {
12799 .num_items = 4, 13215 .num_items = 4,
12800 .items = { 13216 .items = {
@@ -12823,33 +13239,8 @@ static struct hda_input_mux alc662_eeepc_capture_source = {
12823 13239
12824#define alc662_mux_enum_info alc_mux_enum_info 13240#define alc662_mux_enum_info alc_mux_enum_info
12825#define alc662_mux_enum_get alc_mux_enum_get 13241#define alc662_mux_enum_get alc_mux_enum_get
13242#define alc662_mux_enum_put alc882_mux_enum_put
12826 13243
12827static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12828 struct snd_ctl_elem_value *ucontrol)
12829{
12830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12831 struct alc_spec *spec = codec->spec;
12832 const struct hda_input_mux *imux = spec->input_mux;
12833 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
12834 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
12835 hda_nid_t nid = capture_mixers[adc_idx];
12836 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12837 unsigned int i, idx;
12838
12839 idx = ucontrol->value.enumerated.item[0];
12840 if (idx >= imux->num_items)
12841 idx = imux->num_items - 1;
12842 if (*cur_val == idx)
12843 return 0;
12844 for (i = 0; i < imux->num_items; i++) {
12845 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12846 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12847 imux->items[i].index,
12848 HDA_AMP_MUTE, v);
12849 }
12850 *cur_val = idx;
12851 return 1;
12852}
12853/* 13244/*
12854 * 2ch mode 13245 * 2ch mode
12855 */ 13246 */
@@ -12918,13 +13309,13 @@ static struct hda_channel_mode alc662_5stack_modes[2] = {
12918static struct snd_kcontrol_new alc662_base_mixer[] = { 13309static struct snd_kcontrol_new alc662_base_mixer[] = {
12919 /* output mixer control */ 13310 /* output mixer control */
12920 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), 13311 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12921 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT), 13312 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), 13313 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12923 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT), 13314 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
12924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 13315 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12925 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 13316 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12926 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), 13317 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
12927 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), 13318 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
12928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13319 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12929 13320
12930 /*Input mixer control */ 13321 /*Input mixer control */
@@ -12941,7 +13332,7 @@ static struct snd_kcontrol_new alc662_base_mixer[] = {
12941 13332
12942static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { 13333static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12943 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13334 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12944 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), 13335 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
12945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13336 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13337 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13338 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
@@ -12958,13 +13349,13 @@ static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12958 13349
12959static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { 13350static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12960 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13351 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12961 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), 13352 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
12962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13353 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12963 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), 13354 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
12964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 13355 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), 13356 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), 13357 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
12967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), 13358 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
12968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 13359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 13360 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 13361 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
@@ -13313,6 +13704,7 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
13313}; 13704};
13314 13705
13315static struct snd_pci_quirk alc662_cfg_tbl[] = { 13706static struct snd_pci_quirk alc662_cfg_tbl[] = {
13707 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
13316 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), 13708 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
13317 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), 13709 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
13318 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), 13710 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
@@ -13326,8 +13718,6 @@ static struct alc_config_preset alc662_presets[] = {
13326 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13718 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13327 .dac_nids = alc662_dac_nids, 13719 .dac_nids = alc662_dac_nids,
13328 .dig_out_nid = ALC662_DIGOUT_NID, 13720 .dig_out_nid = ALC662_DIGOUT_NID,
13329 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13330 .adc_nids = alc662_adc_nids,
13331 .dig_in_nid = ALC662_DIGIN_NID, 13721 .dig_in_nid = ALC662_DIGIN_NID,
13332 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 13722 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13333 .channel_mode = alc662_3ST_2ch_modes, 13723 .channel_mode = alc662_3ST_2ch_modes,
@@ -13340,8 +13730,6 @@ static struct alc_config_preset alc662_presets[] = {
13340 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13730 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13341 .dac_nids = alc662_dac_nids, 13731 .dac_nids = alc662_dac_nids,
13342 .dig_out_nid = ALC662_DIGOUT_NID, 13732 .dig_out_nid = ALC662_DIGOUT_NID,
13343 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13344 .adc_nids = alc662_adc_nids,
13345 .dig_in_nid = ALC662_DIGIN_NID, 13733 .dig_in_nid = ALC662_DIGIN_NID,
13346 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 13734 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13347 .channel_mode = alc662_3ST_6ch_modes, 13735 .channel_mode = alc662_3ST_6ch_modes,
@@ -13354,8 +13742,6 @@ static struct alc_config_preset alc662_presets[] = {
13354 .init_verbs = { alc662_init_verbs }, 13742 .init_verbs = { alc662_init_verbs },
13355 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13743 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13356 .dac_nids = alc662_dac_nids, 13744 .dac_nids = alc662_dac_nids,
13357 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13358 .adc_nids = alc662_adc_nids,
13359 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 13745 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13360 .channel_mode = alc662_3ST_6ch_modes, 13746 .channel_mode = alc662_3ST_6ch_modes,
13361 .need_dac_fix = 1, 13747 .need_dac_fix = 1,
@@ -13368,8 +13754,6 @@ static struct alc_config_preset alc662_presets[] = {
13368 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13754 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13369 .dac_nids = alc662_dac_nids, 13755 .dac_nids = alc662_dac_nids,
13370 .dig_out_nid = ALC662_DIGOUT_NID, 13756 .dig_out_nid = ALC662_DIGOUT_NID,
13371 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13372 .adc_nids = alc662_adc_nids,
13373 .dig_in_nid = ALC662_DIGIN_NID, 13757 .dig_in_nid = ALC662_DIGIN_NID,
13374 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), 13758 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13375 .channel_mode = alc662_5stack_modes, 13759 .channel_mode = alc662_5stack_modes,
@@ -13380,8 +13764,6 @@ static struct alc_config_preset alc662_presets[] = {
13380 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, 13764 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13381 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13765 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13382 .dac_nids = alc662_dac_nids, 13766 .dac_nids = alc662_dac_nids,
13383 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13384 .adc_nids = alc662_adc_nids,
13385 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 13767 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13386 .channel_mode = alc662_3ST_2ch_modes, 13768 .channel_mode = alc662_3ST_2ch_modes,
13387 .input_mux = &alc662_lenovo_101e_capture_source, 13769 .input_mux = &alc662_lenovo_101e_capture_source,
@@ -13394,8 +13776,6 @@ static struct alc_config_preset alc662_presets[] = {
13394 alc662_eeepc_sue_init_verbs }, 13776 alc662_eeepc_sue_init_verbs },
13395 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13777 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13396 .dac_nids = alc662_dac_nids, 13778 .dac_nids = alc662_dac_nids,
13397 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13398 .adc_nids = alc662_adc_nids,
13399 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), 13779 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13400 .channel_mode = alc662_3ST_2ch_modes, 13780 .channel_mode = alc662_3ST_2ch_modes,
13401 .input_mux = &alc662_eeepc_capture_source, 13781 .input_mux = &alc662_eeepc_capture_source,
@@ -13409,8 +13789,6 @@ static struct alc_config_preset alc662_presets[] = {
13409 alc662_eeepc_ep20_sue_init_verbs }, 13789 alc662_eeepc_ep20_sue_init_verbs },
13410 .num_dacs = ARRAY_SIZE(alc662_dac_nids), 13790 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13411 .dac_nids = alc662_dac_nids, 13791 .dac_nids = alc662_dac_nids,
13412 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13413 .adc_nids = alc662_adc_nids,
13414 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), 13792 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13415 .channel_mode = alc662_3ST_6ch_modes, 13793 .channel_mode = alc662_3ST_6ch_modes,
13416 .input_mux = &alc662_lenovo_101e_capture_source, 13794 .input_mux = &alc662_lenovo_101e_capture_source,
@@ -13556,11 +13934,7 @@ static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13556 hda_nid_t nid, int pin_type, 13934 hda_nid_t nid, int pin_type,
13557 int dac_idx) 13935 int dac_idx)
13558{ 13936{
13559 /* set as output */ 13937 alc_set_pin_output(codec, nid, pin_type);
13560 snd_hda_codec_write(codec, nid, 0,
13561 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13562 snd_hda_codec_write(codec, nid, 0,
13563 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13564 /* need the manual connection? */ 13938 /* need the manual connection? */
13565 if (alc880_is_multi_pin(nid)) { 13939 if (alc880_is_multi_pin(nid)) {
13566 struct alc_spec *spec = codec->spec; 13940 struct alc_spec *spec = codec->spec;
@@ -13595,6 +13969,9 @@ static void alc662_auto_init_hp_out(struct hda_codec *codec)
13595 if (pin) /* connect to front */ 13969 if (pin) /* connect to front */
13596 /* use dac 0 */ 13970 /* use dac 0 */
13597 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 13971 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13972 pin = spec->autocfg.speaker_pins[0];
13973 if (pin)
13974 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
13598} 13975}
13599 13976
13600#define alc662_is_input_pin(nid) alc880_is_input_pin(nid) 13977#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -13672,9 +14049,12 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
13672/* additional initialization for auto-configuration model */ 14049/* additional initialization for auto-configuration model */
13673static void alc662_auto_init(struct hda_codec *codec) 14050static void alc662_auto_init(struct hda_codec *codec)
13674{ 14051{
14052 struct alc_spec *spec = codec->spec;
13675 alc662_auto_init_multi_out(codec); 14053 alc662_auto_init_multi_out(codec);
13676 alc662_auto_init_hp_out(codec); 14054 alc662_auto_init_hp_out(codec);
13677 alc662_auto_init_analog_input(codec); 14055 alc662_auto_init_analog_input(codec);
14056 if (spec->unsol_event)
14057 alc_sku_automute(codec);
13678} 14058}
13679 14059
13680static int patch_alc662(struct hda_codec *codec) 14060static int patch_alc662(struct hda_codec *codec)
@@ -13722,10 +14102,9 @@ static int patch_alc662(struct hda_codec *codec)
13722 spec->stream_digital_playback = &alc662_pcm_digital_playback; 14102 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13723 spec->stream_digital_capture = &alc662_pcm_digital_capture; 14103 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13724 14104
13725 if (!spec->adc_nids && spec->input_mux) { 14105 spec->adc_nids = alc662_adc_nids;
13726 spec->adc_nids = alc662_adc_nids; 14106 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13727 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 14107 spec->capsrc_nids = alc662_capsrc_nids;
13728 }
13729 14108
13730 spec->vmaster_nid = 0x02; 14109 spec->vmaster_nid = 0x02;
13731 14110
@@ -13761,6 +14140,8 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
13761 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 14140 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
13762 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 14141 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
13763 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 14142 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
14143 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
14144 .patch = patch_alc882 }, /* should be patch_alc883() in future */
13764 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 14145 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
13765 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, 14146 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
13766 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 14147 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index d22f5a6b850f..9332b63e406c 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -28,7 +28,7 @@
28#include <sound/core.h> 28#include <sound/core.h>
29#include "hda_codec.h" 29#include "hda_codec.h"
30#include "hda_local.h" 30#include "hda_local.h"
31 31#include "hda_patch.h"
32 32
33/* si3054 verbs */ 33/* si3054 verbs */
34#define SI3054_VERB_READ_NODE 0x900 34#define SI3054_VERB_READ_NODE 0x900
@@ -206,7 +206,7 @@ static int si3054_build_pcms(struct hda_codec *codec)
206 info->name = "Si3054 Modem"; 206 info->name = "Si3054 Modem";
207 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm; 207 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = si3054_pcm;
208 info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm; 208 info->stream[SNDRV_PCM_STREAM_CAPTURE] = si3054_pcm;
209 info->is_modem = 1; 209 info->pcm_type = HDA_PCM_TYPE_MODEM;
210 return 0; 210 return 0;
211} 211}
212 212
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index caf48edaa921..393f7fd2b1be 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -32,6 +32,7 @@
32#include <sound/asoundef.h> 32#include <sound/asoundef.h>
33#include "hda_codec.h" 33#include "hda_codec.h"
34#include "hda_local.h" 34#include "hda_local.h"
35#include "hda_patch.h"
35 36
36#define NUM_CONTROL_ALLOC 32 37#define NUM_CONTROL_ALLOC 32
37#define STAC_PWR_EVENT 0x20 38#define STAC_PWR_EVENT 0x20
@@ -39,6 +40,7 @@
39 40
40enum { 41enum {
41 STAC_REF, 42 STAC_REF,
43 STAC_9200_OQO,
42 STAC_9200_DELL_D21, 44 STAC_9200_DELL_D21,
43 STAC_9200_DELL_D22, 45 STAC_9200_DELL_D22,
44 STAC_9200_DELL_D23, 46 STAC_9200_DELL_D23,
@@ -50,6 +52,7 @@ enum {
50 STAC_9200_DELL_M26, 52 STAC_9200_DELL_M26,
51 STAC_9200_DELL_M27, 53 STAC_9200_DELL_M27,
52 STAC_9200_GATEWAY, 54 STAC_9200_GATEWAY,
55 STAC_9200_PANASONIC,
53 STAC_9200_MODELS 56 STAC_9200_MODELS
54}; 57};
55 58
@@ -63,11 +66,14 @@ enum {
63 66
64enum { 67enum {
65 STAC_92HD73XX_REF, 68 STAC_92HD73XX_REF,
69 STAC_DELL_M6,
66 STAC_92HD73XX_MODELS 70 STAC_92HD73XX_MODELS
67}; 71};
68 72
69enum { 73enum {
70 STAC_92HD71BXX_REF, 74 STAC_92HD71BXX_REF,
75 STAC_DELL_M4_1,
76 STAC_DELL_M4_2,
71 STAC_92HD71BXX_MODELS 77 STAC_92HD71BXX_MODELS
72}; 78};
73 79
@@ -123,6 +129,7 @@ struct sigmatel_spec {
123 unsigned int hp_detect: 1; 129 unsigned int hp_detect: 1;
124 130
125 /* gpio lines */ 131 /* gpio lines */
132 unsigned int eapd_mask;
126 unsigned int gpio_mask; 133 unsigned int gpio_mask;
127 unsigned int gpio_dir; 134 unsigned int gpio_dir;
128 unsigned int gpio_data; 135 unsigned int gpio_data;
@@ -135,6 +142,7 @@ struct sigmatel_spec {
135 /* power management */ 142 /* power management */
136 unsigned int num_pwrs; 143 unsigned int num_pwrs;
137 hda_nid_t *pwr_nids; 144 hda_nid_t *pwr_nids;
145 hda_nid_t *dac_list;
138 146
139 /* playback */ 147 /* playback */
140 struct hda_input_mux *mono_mux; 148 struct hda_input_mux *mono_mux;
@@ -173,6 +181,7 @@ struct sigmatel_spec {
173 /* i/o switches */ 181 /* i/o switches */
174 unsigned int io_switch[2]; 182 unsigned int io_switch[2];
175 unsigned int clfe_swap; 183 unsigned int clfe_swap;
184 unsigned int hp_switch;
176 unsigned int aloopback; 185 unsigned int aloopback;
177 186
178 struct hda_pcm pcm_rec[2]; /* PCM information */ 187 struct hda_pcm pcm_rec[2]; /* PCM information */
@@ -184,9 +193,6 @@ struct sigmatel_spec {
184 struct hda_input_mux private_dimux; 193 struct hda_input_mux private_dimux;
185 struct hda_input_mux private_imux; 194 struct hda_input_mux private_imux;
186 struct hda_input_mux private_mono_mux; 195 struct hda_input_mux private_mono_mux;
187
188 /* virtual master */
189 unsigned int vmaster_tlv[4];
190}; 196};
191 197
192static hda_nid_t stac9200_adc_nids[1] = { 198static hda_nid_t stac9200_adc_nids[1] = {
@@ -244,7 +250,7 @@ static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
244 0x1c, 250 0x1c,
245}; 251};
246 252
247static hda_nid_t stac92hd71bxx_dac_nids[2] = { 253static hda_nid_t stac92hd71bxx_dac_nids[1] = {
248 0x10, /*0x11, */ 254 0x10, /*0x11, */
249}; 255};
250 256
@@ -290,6 +296,10 @@ static hda_nid_t stac927x_mux_nids[3] = {
290 0x15, 0x16, 0x17 296 0x15, 0x16, 0x17
291}; 297};
292 298
299static hda_nid_t stac927x_dac_nids[6] = {
300 0x02, 0x03, 0x04, 0x05, 0x06, 0
301};
302
293static hda_nid_t stac927x_dmux_nids[1] = { 303static hda_nid_t stac927x_dmux_nids[1] = {
294 0x1b, 304 0x1b,
295}; 305};
@@ -331,10 +341,10 @@ static hda_nid_t stac922x_pin_nids[10] = {
331 0x0f, 0x10, 0x11, 0x15, 0x1b, 341 0x0f, 0x10, 0x11, 0x15, 0x1b,
332}; 342};
333 343
334static hda_nid_t stac92hd73xx_pin_nids[12] = { 344static hda_nid_t stac92hd73xx_pin_nids[13] = {
335 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 345 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
336 0x0f, 0x10, 0x11, 0x12, 0x13, 346 0x0f, 0x10, 0x11, 0x12, 0x13,
337 0x14, 0x22 347 0x14, 0x1e, 0x22
338}; 348};
339 349
340static hda_nid_t stac92hd71bxx_pin_nids[10] = { 350static hda_nid_t stac92hd71bxx_pin_nids[10] = {
@@ -527,6 +537,43 @@ static struct hda_verb stac92hd73xx_6ch_core_init[] = {
527 {} 537 {}
528}; 538};
529 539
540static struct hda_verb dell_eq_core_init[] = {
541 /* set master volume to max value without distortion
542 * and direct control */
543 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
544 /* setup audio connections */
545 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
546 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
547 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
548 /* setup adcs to point to mixer */
549 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
550 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
551 /* setup import muxs */
552 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
553 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
554 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
555 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
556 {}
557};
558
559static struct hda_verb dell_m6_core_init[] = {
560 /* set master volume and direct control */
561 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
562 /* setup audio connections */
563 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
564 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
565 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
566 /* setup adcs to point to mixer */
567 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
568 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
569 /* setup import muxs */
570 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
571 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
572 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
573 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
574 {}
575};
576
530static struct hda_verb stac92hd73xx_8ch_core_init[] = { 577static struct hda_verb stac92hd73xx_8ch_core_init[] = {
531 /* set master volume and direct control */ 578 /* set master volume and direct control */
532 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 579 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
@@ -910,6 +957,11 @@ static int stac92xx_build_controls(struct hda_codec *codec)
910 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 957 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
911 if (err < 0) 958 if (err < 0)
912 return err; 959 return err;
960 err = snd_hda_create_spdif_share_sw(codec,
961 &spec->multiout);
962 if (err < 0)
963 return err;
964 spec->multiout.share_spdif = 1;
913 } 965 }
914 if (spec->dig_in_nid) { 966 if (spec->dig_in_nid) {
915 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 967 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -919,10 +971,11 @@ static int stac92xx_build_controls(struct hda_codec *codec)
919 971
920 /* if we have no master control, let's create it */ 972 /* if we have no master control, let's create it */
921 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 973 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
974 unsigned int vmaster_tlv[4];
922 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], 975 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
923 HDA_OUTPUT, spec->vmaster_tlv); 976 HDA_OUTPUT, vmaster_tlv);
924 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 977 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
925 spec->vmaster_tlv, slave_vols); 978 vmaster_tlv, slave_vols);
926 if (err < 0) 979 if (err < 0)
927 return err; 980 return err;
928 } 981 }
@@ -1052,9 +1105,15 @@ static unsigned int dell9200_m27_pin_configs[8] = {
1052 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, 1105 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1053}; 1106};
1054 1107
1108static unsigned int oqo9200_pin_configs[8] = {
1109 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1110 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1111};
1112
1055 1113
1056static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { 1114static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1057 [STAC_REF] = ref9200_pin_configs, 1115 [STAC_REF] = ref9200_pin_configs,
1116 [STAC_9200_OQO] = oqo9200_pin_configs,
1058 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, 1117 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1059 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, 1118 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1060 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, 1119 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
@@ -1065,10 +1124,12 @@ static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1065 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, 1124 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1066 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, 1125 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1067 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, 1126 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1127 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1068}; 1128};
1069 1129
1070static const char *stac9200_models[STAC_9200_MODELS] = { 1130static const char *stac9200_models[STAC_9200_MODELS] = {
1071 [STAC_REF] = "ref", 1131 [STAC_REF] = "ref",
1132 [STAC_9200_OQO] = "oqo",
1072 [STAC_9200_DELL_D21] = "dell-d21", 1133 [STAC_9200_DELL_D21] = "dell-d21",
1073 [STAC_9200_DELL_D22] = "dell-d22", 1134 [STAC_9200_DELL_D22] = "dell-d22",
1074 [STAC_9200_DELL_D23] = "dell-d23", 1135 [STAC_9200_DELL_D23] = "dell-d23",
@@ -1080,6 +1141,7 @@ static const char *stac9200_models[STAC_9200_MODELS] = {
1080 [STAC_9200_DELL_M26] = "dell-m26", 1141 [STAC_9200_DELL_M26] = "dell-m26",
1081 [STAC_9200_DELL_M27] = "dell-m27", 1142 [STAC_9200_DELL_M27] = "dell-m27",
1082 [STAC_9200_GATEWAY] = "gateway", 1143 [STAC_9200_GATEWAY] = "gateway",
1144 [STAC_9200_PANASONIC] = "panasonic",
1083}; 1145};
1084 1146
1085static struct snd_pci_quirk stac9200_cfg_tbl[] = { 1147static struct snd_pci_quirk stac9200_cfg_tbl[] = {
@@ -1146,13 +1208,15 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, 1208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1147 "unknown Dell", STAC_9200_DELL_M26), 1209 "unknown Dell", STAC_9200_DELL_M26),
1148 /* Panasonic */ 1210 /* Panasonic */
1149 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF), 1211 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1150 /* Gateway machines needs EAPD to be set on resume */ 1212 /* Gateway machines needs EAPD to be set on resume */
1151 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY), 1213 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1152 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", 1214 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1153 STAC_9200_GATEWAY), 1215 STAC_9200_GATEWAY),
1154 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", 1216 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1155 STAC_9200_GATEWAY), 1217 STAC_9200_GATEWAY),
1218 /* OQO Mobile */
1219 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1156 {} /* terminator */ 1220 {} /* terminator */
1157}; 1221};
1158 1222
@@ -1202,24 +1266,48 @@ static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1202 {} /* terminator */ 1266 {} /* terminator */
1203}; 1267};
1204 1268
1205static unsigned int ref92hd73xx_pin_configs[12] = { 1269static unsigned int ref92hd73xx_pin_configs[13] = {
1206 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, 1270 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1207 0x0181302e, 0x01014010, 0x01014020, 0x01014030, 1271 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1208 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, 1272 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1273 0x01452050,
1274};
1275
1276static unsigned int dell_m6_pin_configs[13] = {
1277 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1278 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1279 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1280 0x4f0000f0,
1209}; 1281};
1210 1282
1211static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { 1283static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1212 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, 1284 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1285 [STAC_DELL_M6] = dell_m6_pin_configs,
1213}; 1286};
1214 1287
1215static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1288static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1216 [STAC_92HD73XX_REF] = "ref", 1289 [STAC_92HD73XX_REF] = "ref",
1290 [STAC_DELL_M6] = "dell-m6",
1217}; 1291};
1218 1292
1219static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { 1293static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1220 /* SigmaTel reference board */ 1294 /* SigmaTel reference board */
1221 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1295 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1222 "DFI LanParty", STAC_92HD73XX_REF), 1296 "DFI LanParty", STAC_92HD73XX_REF),
1297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1298 "unknown Dell", STAC_DELL_M6),
1299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1300 "unknown Dell", STAC_DELL_M6),
1301 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1302 "unknown Dell", STAC_DELL_M6),
1303 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1304 "unknown Dell", STAC_DELL_M6),
1305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1306 "unknown Dell", STAC_DELL_M6),
1307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1308 "unknown Dell", STAC_DELL_M6),
1309 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1310 "unknown Dell", STAC_DELL_M6),
1223 {} /* terminator */ 1311 {} /* terminator */
1224}; 1312};
1225 1313
@@ -1229,18 +1317,56 @@ static unsigned int ref92hd71bxx_pin_configs[10] = {
1229 0x90a000f0, 0x01452050, 1317 0x90a000f0, 0x01452050,
1230}; 1318};
1231 1319
1320static unsigned int dell_m4_1_pin_configs[13] = {
1321 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1322 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1323 0x40f000f0, 0x4f0000f0,
1324};
1325
1326static unsigned int dell_m4_2_pin_configs[13] = {
1327 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1328 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1329 0x40f000f0, 0x044413b0,
1330};
1331
1232static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { 1332static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1233 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, 1333 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1334 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1335 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1234}; 1336};
1235 1337
1236static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { 1338static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1237 [STAC_92HD71BXX_REF] = "ref", 1339 [STAC_92HD71BXX_REF] = "ref",
1340 [STAC_DELL_M4_1] = "dell-m4-1",
1341 [STAC_DELL_M4_2] = "dell-m4-2",
1238}; 1342};
1239 1343
1240static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { 1344static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1241 /* SigmaTel reference board */ 1345 /* SigmaTel reference board */
1242 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1346 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1243 "DFI LanParty", STAC_92HD71BXX_REF), 1347 "DFI LanParty", STAC_92HD71BXX_REF),
1348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1349 "unknown Dell", STAC_DELL_M4_1),
1350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1351 "unknown Dell", STAC_DELL_M4_1),
1352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1353 "unknown Dell", STAC_DELL_M4_1),
1354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1355 "unknown Dell", STAC_DELL_M4_1),
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1357 "unknown Dell", STAC_DELL_M4_1),
1358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1359 "unknown Dell", STAC_DELL_M4_1),
1360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1361 "unknown Dell", STAC_DELL_M4_1),
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1363 "unknown Dell", STAC_DELL_M4_2),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1365 "unknown Dell", STAC_DELL_M4_2),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1367 "unknown Dell", STAC_DELL_M4_2),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1369 "unknown Dell", STAC_DELL_M4_2),
1244 {} /* terminator */ 1370 {} /* terminator */
1245}; 1371};
1246 1372
@@ -1733,7 +1859,8 @@ static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1733 struct snd_pcm_substream *substream) 1859 struct snd_pcm_substream *substream)
1734{ 1860{
1735 struct sigmatel_spec *spec = codec->spec; 1861 struct sigmatel_spec *spec = codec->spec;
1736 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 1862 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1863 hinfo);
1737} 1864}
1738 1865
1739static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 1866static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -1807,7 +1934,7 @@ static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1807{ 1934{
1808 struct sigmatel_spec *spec = codec->spec; 1935 struct sigmatel_spec *spec = codec->spec;
1809 1936
1810 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); 1937 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
1811 return 0; 1938 return 0;
1812} 1939}
1813 1940
@@ -1889,6 +2016,7 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
1889 codec->num_pcms++; 2016 codec->num_pcms++;
1890 info++; 2017 info++;
1891 info->name = "STAC92xx Digital"; 2018 info->name = "STAC92xx Digital";
2019 info->pcm_type = HDA_PCM_TYPE_SPDIF;
1892 if (spec->multiout.dig_out_nid) { 2020 if (spec->multiout.dig_out_nid) {
1893 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; 2021 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1894 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 2022 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
@@ -1925,6 +2053,34 @@ static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int
1925 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 2053 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1926} 2054}
1927 2055
2056#define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2057
2058static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2059 struct snd_ctl_elem_value *ucontrol)
2060{
2061 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2062 struct sigmatel_spec *spec = codec->spec;
2063
2064 ucontrol->value.integer.value[0] = spec->hp_switch;
2065 return 0;
2066}
2067
2068static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2069 struct snd_ctl_elem_value *ucontrol)
2070{
2071 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2072 struct sigmatel_spec *spec = codec->spec;
2073
2074 spec->hp_switch = ucontrol->value.integer.value[0];
2075
2076 /* check to be sure that the ports are upto date with
2077 * switch changes
2078 */
2079 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2080
2081 return 1;
2082}
2083
1928#define stac92xx_io_switch_info snd_ctl_boolean_mono_info 2084#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1929 2085
1930static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2086static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
@@ -1996,6 +2152,15 @@ static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
1996 return 1; 2152 return 1;
1997} 2153}
1998 2154
2155#define STAC_CODEC_HP_SWITCH(xname) \
2156 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2157 .name = xname, \
2158 .index = 0, \
2159 .info = stac92xx_hp_switch_info, \
2160 .get = stac92xx_hp_switch_get, \
2161 .put = stac92xx_hp_switch_put, \
2162 }
2163
1999#define STAC_CODEC_IO_SWITCH(xname, xpval) \ 2164#define STAC_CODEC_IO_SWITCH(xname, xpval) \
2000 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2165 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2001 .name = xname, \ 2166 .name = xname, \
@@ -2020,6 +2185,7 @@ enum {
2020 STAC_CTL_WIDGET_VOL, 2185 STAC_CTL_WIDGET_VOL,
2021 STAC_CTL_WIDGET_MUTE, 2186 STAC_CTL_WIDGET_MUTE,
2022 STAC_CTL_WIDGET_MONO_MUX, 2187 STAC_CTL_WIDGET_MONO_MUX,
2188 STAC_CTL_WIDGET_HP_SWITCH,
2023 STAC_CTL_WIDGET_IO_SWITCH, 2189 STAC_CTL_WIDGET_IO_SWITCH,
2024 STAC_CTL_WIDGET_CLFE_SWITCH 2190 STAC_CTL_WIDGET_CLFE_SWITCH
2025}; 2191};
@@ -2028,6 +2194,7 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2028 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 2194 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2029 HDA_CODEC_MUTE(NULL, 0, 0, 0), 2195 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2030 STAC_MONO_MUX, 2196 STAC_MONO_MUX,
2197 STAC_CODEC_HP_SWITCH(NULL),
2031 STAC_CODEC_IO_SWITCH(NULL, 0), 2198 STAC_CODEC_IO_SWITCH(NULL, 0),
2032 STAC_CODEC_CLFE_SWITCH(NULL, 0), 2199 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2033}; 2200};
@@ -2222,6 +2389,29 @@ static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_
2222 return 0; 2389 return 0;
2223} 2390}
2224 2391
2392static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2393{
2394 if (!spec->multiout.hp_nid)
2395 spec->multiout.hp_nid = nid;
2396 else if (spec->multiout.num_dacs > 4) {
2397 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2398 return 1;
2399 } else {
2400 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2401 spec->multiout.num_dacs++;
2402 }
2403 return 0;
2404}
2405
2406static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2407{
2408 if (is_in_dac_nids(spec, nid))
2409 return 1;
2410 if (spec->multiout.hp_nid == nid)
2411 return 1;
2412 return 0;
2413}
2414
2225/* add playback controls from the parsed DAC table */ 2415/* add playback controls from the parsed DAC table */
2226static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, 2416static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2227 const struct auto_pin_cfg *cfg) 2417 const struct auto_pin_cfg *cfg)
@@ -2236,7 +2426,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2236 unsigned int wid_caps, pincap; 2426 unsigned int wid_caps, pincap;
2237 2427
2238 2428
2239 for (i = 0; i < cfg->line_outs; i++) { 2429 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2240 if (!spec->multiout.dac_nids[i]) 2430 if (!spec->multiout.dac_nids[i])
2241 continue; 2431 continue;
2242 2432
@@ -2269,6 +2459,14 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2269 } 2459 }
2270 } 2460 }
2271 2461
2462 if (cfg->hp_outs > 1) {
2463 err = stac92xx_add_control(spec,
2464 STAC_CTL_WIDGET_HP_SWITCH,
2465 "Headphone as Line Out Switch", 0);
2466 if (err < 0)
2467 return err;
2468 }
2469
2272 if (spec->line_switch) { 2470 if (spec->line_switch) {
2273 nid = cfg->input_pins[AUTO_PIN_LINE]; 2471 nid = cfg->input_pins[AUTO_PIN_LINE];
2274 pincap = snd_hda_param_read(codec, nid, 2472 pincap = snd_hda_param_read(codec, nid,
@@ -2284,10 +2482,11 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2284 2482
2285 if (spec->mic_switch) { 2483 if (spec->mic_switch) {
2286 unsigned int def_conf; 2484 unsigned int def_conf;
2287 nid = cfg->input_pins[AUTO_PIN_MIC]; 2485 unsigned int mic_pin = AUTO_PIN_MIC;
2486again:
2487 nid = cfg->input_pins[mic_pin];
2288 def_conf = snd_hda_codec_read(codec, nid, 0, 2488 def_conf = snd_hda_codec_read(codec, nid, 0,
2289 AC_VERB_GET_CONFIG_DEFAULT, 0); 2489 AC_VERB_GET_CONFIG_DEFAULT, 0);
2290
2291 /* some laptops have an internal analog microphone 2490 /* some laptops have an internal analog microphone
2292 * which can't be used as a output */ 2491 * which can't be used as a output */
2293 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { 2492 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
@@ -2297,38 +2496,22 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2297 err = stac92xx_add_control(spec, 2496 err = stac92xx_add_control(spec,
2298 STAC_CTL_WIDGET_IO_SWITCH, 2497 STAC_CTL_WIDGET_IO_SWITCH,
2299 "Mic as Output Switch", (nid << 8) | 1); 2498 "Mic as Output Switch", (nid << 8) | 1);
2499 nid = snd_hda_codec_read(codec, nid, 0,
2500 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2501 if (!check_in_dac_nids(spec, nid))
2502 add_spec_dacs(spec, nid);
2300 if (err < 0) 2503 if (err < 0)
2301 return err; 2504 return err;
2302 } 2505 }
2506 } else if (mic_pin == AUTO_PIN_MIC) {
2507 mic_pin = AUTO_PIN_FRONT_MIC;
2508 goto again;
2303 } 2509 }
2304 } 2510 }
2305 2511
2306 return 0; 2512 return 0;
2307} 2513}
2308 2514
2309static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2310{
2311 if (is_in_dac_nids(spec, nid))
2312 return 1;
2313 if (spec->multiout.hp_nid == nid)
2314 return 1;
2315 return 0;
2316}
2317
2318static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2319{
2320 if (!spec->multiout.hp_nid)
2321 spec->multiout.hp_nid = nid;
2322 else if (spec->multiout.num_dacs > 4) {
2323 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2324 return 1;
2325 } else {
2326 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2327 spec->multiout.num_dacs++;
2328 }
2329 return 0;
2330}
2331
2332/* add playback controls for Speaker and HP outputs */ 2515/* add playback controls for Speaker and HP outputs */
2333static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, 2516static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2334 struct auto_pin_cfg *cfg) 2517 struct auto_pin_cfg *cfg)
@@ -2378,12 +2561,8 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2378 return err; 2561 return err;
2379 } 2562 }
2380 if (spec->multiout.hp_nid) { 2563 if (spec->multiout.hp_nid) {
2381 const char *pfx; 2564 err = create_controls(spec, "Headphone",
2382 if (old_num_dacs == spec->multiout.num_dacs) 2565 spec->multiout.hp_nid, 3);
2383 pfx = "Master";
2384 else
2385 pfx = "Headphone";
2386 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
2387 if (err < 0) 2566 if (err < 0)
2388 return err; 2567 return err;
2389 } 2568 }
@@ -2745,7 +2924,7 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2745 */ 2924 */
2746 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { 2925 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2747 hda_nid_t pin = spec->autocfg.speaker_pins[i]; 2926 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2748 unsigned long wcaps = get_wcaps(codec, pin); 2927 unsigned int wcaps = get_wcaps(codec, pin);
2749 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); 2928 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2750 if (wcaps == AC_WCAP_OUT_AMP) 2929 if (wcaps == AC_WCAP_OUT_AMP)
2751 /* found a mono speaker with an amp, must be lfe */ 2930 /* found a mono speaker with an amp, must be lfe */
@@ -2756,12 +2935,12 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2756 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { 2935 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2757 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { 2936 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2758 hda_nid_t pin = spec->autocfg.line_out_pins[i]; 2937 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2759 unsigned long cfg; 2938 unsigned int defcfg;
2760 cfg = snd_hda_codec_read(codec, pin, 0, 2939 defcfg = snd_hda_codec_read(codec, pin, 0,
2761 AC_VERB_GET_CONFIG_DEFAULT, 2940 AC_VERB_GET_CONFIG_DEFAULT,
2762 0x00); 2941 0x00);
2763 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) { 2942 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
2764 unsigned long wcaps = get_wcaps(codec, pin); 2943 unsigned int wcaps = get_wcaps(codec, pin);
2765 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); 2944 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2766 if (wcaps == AC_WCAP_OUT_AMP) 2945 if (wcaps == AC_WCAP_OUT_AMP)
2767 /* found a mono speaker with an amp, 2946 /* found a mono speaker with an amp,
@@ -2866,6 +3045,19 @@ static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
2866 return 0; /* nid is not a HP-Out */ 3045 return 0; /* nid is not a HP-Out */
2867}; 3046};
2868 3047
3048static void stac92xx_power_down(struct hda_codec *codec)
3049{
3050 struct sigmatel_spec *spec = codec->spec;
3051
3052 /* power down inactive DACs */
3053 hda_nid_t *dac;
3054 for (dac = spec->dac_list; *dac; dac++)
3055 if (!is_in_dac_nids(spec, *dac) &&
3056 spec->multiout.hp_nid != *dac)
3057 snd_hda_codec_write_cache(codec, *dac, 0,
3058 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3059}
3060
2869static int stac92xx_init(struct hda_codec *codec) 3061static int stac92xx_init(struct hda_codec *codec)
2870{ 3062{
2871 struct sigmatel_spec *spec = codec->spec; 3063 struct sigmatel_spec *spec = codec->spec;
@@ -2909,16 +3101,21 @@ static int stac92xx_init(struct hda_codec *codec)
2909 ? STAC_HP_EVENT : STAC_PWR_EVENT; 3101 ? STAC_HP_EVENT : STAC_PWR_EVENT;
2910 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i], 3102 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
2911 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 3103 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3104 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3105 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
2912 /* outputs are only ports capable of power management 3106 /* outputs are only ports capable of power management
2913 * any attempts on powering down a input port cause the 3107 * any attempts on powering down a input port cause the
2914 * referenced VREF to act quirky. 3108 * referenced VREF to act quirky.
2915 */ 3109 */
2916 if (pinctl & AC_PINCTL_IN_EN) 3110 if (pinctl & AC_PINCTL_IN_EN)
2917 continue; 3111 continue;
3112 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED)
3113 continue;
2918 enable_pin_detect(codec, spec->pwr_nids[i], event | i); 3114 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
2919 codec->patch_ops.unsol_event(codec, (event | i) << 26); 3115 codec->patch_ops.unsol_event(codec, (event | i) << 26);
2920 } 3116 }
2921 3117 if (spec->dac_list)
3118 stac92xx_power_down(codec);
2922 if (cfg->dig_out_pin) 3119 if (cfg->dig_out_pin)
2923 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, 3120 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
2924 AC_PINCTL_OUT_EN); 3121 AC_PINCTL_OUT_EN);
@@ -3014,6 +3211,7 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3014{ 3211{
3015 struct sigmatel_spec *spec = codec->spec; 3212 struct sigmatel_spec *spec = codec->spec;
3016 struct auto_pin_cfg *cfg = &spec->autocfg; 3213 struct auto_pin_cfg *cfg = &spec->autocfg;
3214 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3017 int i, presence; 3215 int i, presence;
3018 3216
3019 presence = 0; 3217 presence = 0;
@@ -3024,26 +3222,42 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3024 for (i = 0; i < cfg->hp_outs; i++) { 3222 for (i = 0; i < cfg->hp_outs; i++) {
3025 if (presence) 3223 if (presence)
3026 break; 3224 break;
3225 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3226 break;
3027 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); 3227 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3028 } 3228 }
3029 3229
3030 if (presence) { 3230 if (presence) {
3031 /* disable lineouts, enable hp */ 3231 /* disable lineouts, enable hp */
3232 if (spec->hp_switch)
3233 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3032 for (i = 0; i < cfg->line_outs; i++) 3234 for (i = 0; i < cfg->line_outs; i++)
3033 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], 3235 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3034 AC_PINCTL_OUT_EN); 3236 AC_PINCTL_OUT_EN);
3035 for (i = 0; i < cfg->speaker_outs; i++) 3237 for (i = 0; i < cfg->speaker_outs; i++)
3036 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], 3238 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3037 AC_PINCTL_OUT_EN); 3239 AC_PINCTL_OUT_EN);
3240 if (spec->eapd_mask)
3241 stac_gpio_set(codec, spec->gpio_mask,
3242 spec->gpio_dir, spec->gpio_data &
3243 ~spec->eapd_mask);
3038 } else { 3244 } else {
3039 /* enable lineouts, disable hp */ 3245 /* enable lineouts, disable hp */
3246 if (spec->hp_switch)
3247 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3040 for (i = 0; i < cfg->line_outs; i++) 3248 for (i = 0; i < cfg->line_outs; i++)
3041 stac92xx_set_pinctl(codec, cfg->line_out_pins[i], 3249 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3042 AC_PINCTL_OUT_EN); 3250 AC_PINCTL_OUT_EN);
3043 for (i = 0; i < cfg->speaker_outs; i++) 3251 for (i = 0; i < cfg->speaker_outs; i++)
3044 stac92xx_set_pinctl(codec, cfg->speaker_pins[i], 3252 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3045 AC_PINCTL_OUT_EN); 3253 AC_PINCTL_OUT_EN);
3254 if (spec->eapd_mask)
3255 stac_gpio_set(codec, spec->gpio_mask,
3256 spec->gpio_dir, spec->gpio_data |
3257 spec->eapd_mask);
3046 } 3258 }
3259 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3260 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3047} 3261}
3048 3262
3049static void stac92xx_pin_sense(struct hda_codec *codec, int idx) 3263static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
@@ -3091,6 +3305,9 @@ static int stac92xx_resume(struct hda_codec *codec)
3091 spec->gpio_dir, spec->gpio_data); 3305 spec->gpio_dir, spec->gpio_data);
3092 snd_hda_codec_resume_amp(codec); 3306 snd_hda_codec_resume_amp(codec);
3093 snd_hda_codec_resume_cache(codec); 3307 snd_hda_codec_resume_cache(codec);
3308 /* power down inactive DACs */
3309 if (spec->dac_list)
3310 stac92xx_power_down(codec);
3094 /* invoke unsolicited event to reset the HP state */ 3311 /* invoke unsolicited event to reset the HP state */
3095 if (spec->hp_detect) 3312 if (spec->hp_detect)
3096 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); 3313 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
@@ -3147,12 +3364,18 @@ static int patch_stac9200(struct hda_codec *codec)
3147 spec->num_adcs = 1; 3364 spec->num_adcs = 1;
3148 spec->num_pwrs = 0; 3365 spec->num_pwrs = 0;
3149 3366
3150 if (spec->board_config == STAC_9200_GATEWAY) 3367 if (spec->board_config == STAC_9200_GATEWAY ||
3368 spec->board_config == STAC_9200_OQO)
3151 spec->init = stac9200_eapd_init; 3369 spec->init = stac9200_eapd_init;
3152 else 3370 else
3153 spec->init = stac9200_core_init; 3371 spec->init = stac9200_core_init;
3154 spec->mixer = stac9200_mixer; 3372 spec->mixer = stac9200_mixer;
3155 3373
3374 if (spec->board_config == STAC_9200_PANASONIC) {
3375 spec->gpio_mask = spec->gpio_dir = 0x09;
3376 spec->gpio_data = 0x00;
3377 }
3378
3156 err = stac9200_parse_auto_config(codec); 3379 err = stac9200_parse_auto_config(codec);
3157 if (err < 0) { 3380 if (err < 0) {
3158 stac92xx_free(codec); 3381 stac92xx_free(codec);
@@ -3293,6 +3516,7 @@ again:
3293 3516
3294 switch (spec->multiout.num_dacs) { 3517 switch (spec->multiout.num_dacs) {
3295 case 0x3: /* 6 Channel */ 3518 case 0x3: /* 6 Channel */
3519 spec->multiout.hp_nid = 0x17;
3296 spec->mixer = stac92hd73xx_6ch_mixer; 3520 spec->mixer = stac92hd73xx_6ch_mixer;
3297 spec->init = stac92hd73xx_6ch_core_init; 3521 spec->init = stac92hd73xx_6ch_core_init;
3298 break; 3522 break;
@@ -3318,13 +3542,42 @@ again:
3318 3542
3319 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); 3543 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3320 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); 3544 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3321 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3322 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); 3545 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3323 spec->dinput_mux = &stac92hd73xx_dmux; 3546 spec->dinput_mux = &stac92hd73xx_dmux;
3324 /* GPIO0 High = Enable EAPD */ 3547 /* GPIO0 High = Enable EAPD */
3325 spec->gpio_mask = spec->gpio_dir = 0x1; 3548 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3326 spec->gpio_data = 0x01; 3549 spec->gpio_data = 0x01;
3327 3550
3551 switch (spec->board_config) {
3552 case STAC_DELL_M6:
3553 spec->init = dell_eq_core_init;
3554 switch (codec->subsystem_id) {
3555 case 0x1028025e: /* Analog Mics */
3556 case 0x1028025f:
3557 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3558 spec->num_dmics = 0;
3559 break;
3560 case 0x10280271: /* Digital Mics */
3561 case 0x10280272:
3562 spec->init = dell_m6_core_init;
3563 /* fall-through */
3564 case 0x10280254:
3565 case 0x10280255:
3566 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3567 spec->num_dmics = 1;
3568 break;
3569 case 0x10280256: /* Both */
3570 case 0x10280057:
3571 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3572 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3573 spec->num_dmics = 1;
3574 break;
3575 }
3576 break;
3577 default:
3578 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3579 }
3580
3328 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); 3581 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3329 spec->pwr_nids = stac92hd73xx_pwr_nids; 3582 spec->pwr_nids = stac92hd73xx_pwr_nids;
3330 3583
@@ -3398,7 +3651,10 @@ again:
3398 spec->aloopback_shift = 0; 3651 spec->aloopback_shift = 0;
3399 3652
3400 /* GPIO0 High = EAPD */ 3653 /* GPIO0 High = EAPD */
3401 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1; 3654 spec->gpio_mask = 0x01;
3655 spec->gpio_dir = 0x01;
3656 spec->gpio_mask = 0x01;
3657 spec->gpio_data = 0x01;
3402 3658
3403 spec->mux_nids = stac92hd71bxx_mux_nids; 3659 spec->mux_nids = stac92hd71bxx_mux_nids;
3404 spec->adc_nids = stac92hd71bxx_adc_nids; 3660 spec->adc_nids = stac92hd71bxx_adc_nids;
@@ -3413,7 +3669,7 @@ again:
3413 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); 3669 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3414 spec->pwr_nids = stac92hd71bxx_pwr_nids; 3670 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3415 3671
3416 spec->multiout.num_dacs = 2; 3672 spec->multiout.num_dacs = 1;
3417 spec->multiout.hp_nid = 0x11; 3673 spec->multiout.hp_nid = 0x11;
3418 spec->multiout.dac_nids = stac92hd71bxx_dac_nids; 3674 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3419 3675
@@ -3577,13 +3833,14 @@ static int patch_stac927x(struct hda_codec *codec)
3577 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); 3833 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3578 spec->mux_nids = stac927x_mux_nids; 3834 spec->mux_nids = stac927x_mux_nids;
3579 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); 3835 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3836 spec->dac_list = stac927x_dac_nids;
3580 spec->multiout.dac_nids = spec->dac_nids; 3837 spec->multiout.dac_nids = spec->dac_nids;
3581 3838
3582 switch (spec->board_config) { 3839 switch (spec->board_config) {
3583 case STAC_D965_3ST: 3840 case STAC_D965_3ST:
3584 case STAC_D965_5ST: 3841 case STAC_D965_5ST:
3585 /* GPIO0 High = Enable EAPD */ 3842 /* GPIO0 High = Enable EAPD */
3586 spec->gpio_mask = spec->gpio_dir = 0x01; 3843 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
3587 spec->gpio_data = 0x01; 3844 spec->gpio_data = 0x01;
3588 spec->num_dmics = 0; 3845 spec->num_dmics = 0;
3589 3846
@@ -3591,14 +3848,23 @@ static int patch_stac927x(struct hda_codec *codec)
3591 spec->mixer = stac927x_mixer; 3848 spec->mixer = stac927x_mixer;
3592 break; 3849 break;
3593 case STAC_DELL_BIOS: 3850 case STAC_DELL_BIOS:
3851 switch (codec->subsystem_id) {
3852 case 0x10280209:
3853 case 0x1028022e:
3854 /* correct the device field to SPDIF out */
3855 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3856 break;
3857 };
3858 /* configure the analog microphone on some laptops */
3859 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3594 /* correct the front output jack as a hp out */ 3860 /* correct the front output jack as a hp out */
3595 stac92xx_set_config_reg(codec, 0x0f, 0x02270110); 3861 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3596 /* correct the front input jack as a mic */ 3862 /* correct the front input jack as a mic */
3597 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130); 3863 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3598 /* fallthru */ 3864 /* fallthru */
3599 case STAC_DELL_3ST: 3865 case STAC_DELL_3ST:
3600 /* GPIO2 High = Enable EAPD */ 3866 /* GPIO2 High = Enable EAPD */
3601 spec->gpio_mask = spec->gpio_dir = 0x04; 3867 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
3602 spec->gpio_data = 0x04; 3868 spec->gpio_data = 0x04;
3603 spec->dmic_nids = stac927x_dmic_nids; 3869 spec->dmic_nids = stac927x_dmic_nids;
3604 spec->num_dmics = STAC927X_NUM_DMICS; 3870 spec->num_dmics = STAC927X_NUM_DMICS;
@@ -3610,7 +3876,7 @@ static int patch_stac927x(struct hda_codec *codec)
3610 break; 3876 break;
3611 default: 3877 default:
3612 /* GPIO0 High = Enable EAPD */ 3878 /* GPIO0 High = Enable EAPD */
3613 spec->gpio_mask = spec->gpio_dir = 0x1; 3879 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3614 spec->gpio_data = 0x01; 3880 spec->gpio_data = 0x01;
3615 spec->num_dmics = 0; 3881 spec->num_dmics = 0;
3616 3882
@@ -3714,6 +3980,7 @@ static int patch_stac9205(struct hda_codec *codec)
3714 (AC_USRSP_EN | STAC_HP_EVENT)); 3980 (AC_USRSP_EN | STAC_HP_EVENT));
3715 3981
3716 spec->gpio_dir = 0x0b; 3982 spec->gpio_dir = 0x0b;
3983 spec->eapd_mask = 0x01;
3717 spec->gpio_mask = 0x1b; 3984 spec->gpio_mask = 0x1b;
3718 spec->gpio_mute = 0x10; 3985 spec->gpio_mute = 0x10;
3719 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, 3986 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
@@ -3723,7 +3990,7 @@ static int patch_stac9205(struct hda_codec *codec)
3723 break; 3990 break;
3724 default: 3991 default:
3725 /* GPIO0 High = EAPD */ 3992 /* GPIO0 High = EAPD */
3726 spec->gpio_mask = spec->gpio_dir = 0x1; 3993 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3727 spec->gpio_data = 0x01; 3994 spec->gpio_data = 0x01;
3728 break; 3995 break;
3729 } 3996 }
@@ -4022,6 +4289,8 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4022 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, 4289 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4023 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, 4290 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4024 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, 4291 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4292 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4293 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
4025 /* The following does not take into account .id=0x83847661 when subsys = 4294 /* The following does not take into account .id=0x83847661 when subsys =
4026 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are 4295 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4027 * currently not fully supported. 4296 * currently not fully supported.
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 4e5dd4cf36f5..52b1d81a26f7 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -39,7 +39,7 @@
39#include <sound/core.h> 39#include <sound/core.h>
40#include "hda_codec.h" 40#include "hda_codec.h"
41#include "hda_local.h" 41#include "hda_local.h"
42 42#include "hda_patch.h"
43 43
44/* amp values */ 44/* amp values */
45#define AMP_VAL_IDX_SHIFT 19 45#define AMP_VAL_IDX_SHIFT 19
@@ -357,7 +357,8 @@ static int via_playback_pcm_open(struct hda_pcm_stream *hinfo,
357 struct snd_pcm_substream *substream) 357 struct snd_pcm_substream *substream)
358{ 358{
359 struct via_spec *spec = codec->spec; 359 struct via_spec *spec = codec->spec;
360 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 360 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
361 hinfo);
361} 362}
362 363
363static int via_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 364static int via_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -430,8 +431,7 @@ static int via_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
430 struct snd_pcm_substream *substream) 431 struct snd_pcm_substream *substream)
431{ 432{
432 struct via_spec *spec = codec->spec; 433 struct via_spec *spec = codec->spec;
433 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 434 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
434 0, 0, 0);
435 return 0; 435 return 0;
436} 436}
437 437
@@ -493,6 +493,11 @@ static int via_build_controls(struct hda_codec *codec)
493 spec->multiout.dig_out_nid); 493 spec->multiout.dig_out_nid);
494 if (err < 0) 494 if (err < 0)
495 return err; 495 return err;
496 err = snd_hda_create_spdif_share_sw(codec,
497 &spec->multiout);
498 if (err < 0)
499 return err;
500 spec->multiout.share_spdif = 1;
496 } 501 }
497 if (spec->dig_in_nid) { 502 if (spec->dig_in_nid) {
498 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 503 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -523,6 +528,7 @@ static int via_build_pcms(struct hda_codec *codec)
523 codec->num_pcms++; 528 codec->num_pcms++;
524 info++; 529 info++;
525 info->name = spec->stream_name_digital; 530 info->name = spec->stream_name_digital;
531 info->pcm_type = HDA_PCM_TYPE_SPDIF;
526 if (spec->multiout.dig_out_nid) { 532 if (spec->multiout.dig_out_nid) {
527 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 533 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
528 *(spec->stream_digital_playback); 534 *(spec->stream_digital_playback);
diff --git a/sound/pci/hda/vmaster.c b/sound/pci/hda/vmaster.c
deleted file mode 100644
index 2da49d20a1fc..000000000000
--- a/sound/pci/hda/vmaster.c
+++ /dev/null
@@ -1,364 +0,0 @@
1/*
2 * Virtual master and slave controls
3 *
4 * Copyright (c) 2008 by Takashi Iwai <tiwai@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
9 *
10 */
11
12#include <linux/slab.h>
13#include <sound/core.h>
14#include <sound/control.h>
15
16/*
17 * a subset of information returned via ctl info callback
18 */
19struct link_ctl_info {
20 int type; /* value type */
21 int count; /* item count */
22 int min_val, max_val; /* min, max values */
23};
24
25/*
26 * link master - this contains a list of slave controls that are
27 * identical types, i.e. info returns the same value type and value
28 * ranges, but may have different number of counts.
29 *
30 * The master control is so far only mono volume/switch for simplicity.
31 * The same value will be applied to all slaves.
32 */
33struct link_master {
34 struct list_head slaves;
35 struct link_ctl_info info;
36 int val; /* the master value */
37};
38
39/*
40 * link slave - this contains a slave control element
41 *
42 * It fakes the control callbacsk with additional attenuation by the
43 * master control. A slave may have either one or two channels.
44 */
45
46struct link_slave {
47 struct list_head list;
48 struct link_master *master;
49 struct link_ctl_info info;
50 int vals[2]; /* current values */
51 struct snd_kcontrol slave; /* the copy of original control entry */
52};
53
54/* get the slave ctl info and save the initial values */
55static int slave_init(struct link_slave *slave)
56{
57 struct snd_ctl_elem_info *uinfo;
58 struct snd_ctl_elem_value *uctl;
59 int err, ch;
60
61 if (slave->info.count)
62 return 0; /* already initialized */
63
64 uinfo = kmalloc(sizeof(*uinfo), GFP_KERNEL);
65 if (!uinfo)
66 return -ENOMEM;
67 uinfo->id = slave->slave.id;
68 err = slave->slave.info(&slave->slave, uinfo);
69 if (err < 0) {
70 kfree(uinfo);
71 return err;
72 }
73 slave->info.type = uinfo->type;
74 slave->info.count = uinfo->count;
75 if (slave->info.count > 2 ||
76 (slave->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER &&
77 slave->info.type != SNDRV_CTL_ELEM_TYPE_BOOLEAN)) {
78 snd_printk(KERN_ERR "invalid slave element\n");
79 kfree(uinfo);
80 return -EINVAL;
81 }
82 slave->info.min_val = uinfo->value.integer.min;
83 slave->info.max_val = uinfo->value.integer.max;
84 kfree(uinfo);
85
86 uctl = kmalloc(sizeof(*uctl), GFP_KERNEL);
87 if (!uctl)
88 return -ENOMEM;
89 uctl->id = slave->slave.id;
90 err = slave->slave.get(&slave->slave, uctl);
91 for (ch = 0; ch < slave->info.count; ch++)
92 slave->vals[ch] = uctl->value.integer.value[ch];
93 kfree(uctl);
94 return 0;
95}
96
97/* initialize master volume */
98static int master_init(struct link_master *master)
99{
100 struct link_slave *slave;
101
102 if (master->info.count)
103 return 0; /* already initialized */
104
105 list_for_each_entry(slave, &master->slaves, list) {
106 int err = slave_init(slave);
107 if (err < 0)
108 return err;
109 master->info = slave->info;
110 master->info.count = 1; /* always mono */
111 /* set full volume as default (= no attenuation) */
112 master->val = master->info.max_val;
113 return 0;
114 }
115 return -ENOENT;
116}
117
118static int slave_get_val(struct link_slave *slave,
119 struct snd_ctl_elem_value *ucontrol)
120{
121 int err, ch;
122
123 err = slave_init(slave);
124 if (err < 0)
125 return err;
126 for (ch = 0; ch < slave->info.count; ch++)
127 ucontrol->value.integer.value[ch] = slave->vals[ch];
128 return 0;
129}
130
131static int slave_put_val(struct link_slave *slave,
132 struct snd_ctl_elem_value *ucontrol)
133{
134 int err, ch, vol;
135
136 err = master_init(slave->master);
137 if (err < 0)
138 return err;
139
140 switch (slave->info.type) {
141 case SNDRV_CTL_ELEM_TYPE_BOOLEAN:
142 for (ch = 0; ch < slave->info.count; ch++)
143 ucontrol->value.integer.value[ch] &=
144 !!slave->master->val;
145 break;
146 case SNDRV_CTL_ELEM_TYPE_INTEGER:
147 for (ch = 0; ch < slave->info.count; ch++) {
148 /* max master volume is supposed to be 0 dB */
149 vol = ucontrol->value.integer.value[ch];
150 vol += slave->master->val - slave->master->info.max_val;
151 if (vol < slave->info.min_val)
152 vol = slave->info.min_val;
153 else if (vol > slave->info.max_val)
154 vol = slave->info.max_val;
155 ucontrol->value.integer.value[ch] = vol;
156 }
157 break;
158 }
159 return slave->slave.put(&slave->slave, ucontrol);
160}
161
162/*
163 * ctl callbacks for slaves
164 */
165static int slave_info(struct snd_kcontrol *kcontrol,
166 struct snd_ctl_elem_info *uinfo)
167{
168 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
169 return slave->slave.info(&slave->slave, uinfo);
170}
171
172static int slave_get(struct snd_kcontrol *kcontrol,
173 struct snd_ctl_elem_value *ucontrol)
174{
175 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
176 return slave_get_val(slave, ucontrol);
177}
178
179static int slave_put(struct snd_kcontrol *kcontrol,
180 struct snd_ctl_elem_value *ucontrol)
181{
182 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
183 int err, ch, changed = 0;
184
185 err = slave_init(slave);
186 if (err < 0)
187 return err;
188 for (ch = 0; ch < slave->info.count; ch++) {
189 if (slave->vals[ch] != ucontrol->value.integer.value[ch]) {
190 changed = 1;
191 slave->vals[ch] = ucontrol->value.integer.value[ch];
192 }
193 }
194 if (!changed)
195 return 0;
196 return slave_put_val(slave, ucontrol);
197}
198
199static int slave_tlv_cmd(struct snd_kcontrol *kcontrol,
200 int op_flag, unsigned int size,
201 unsigned int __user *tlv)
202{
203 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
204 /* FIXME: this assumes that the max volume is 0 dB */
205 return slave->slave.tlv.c(&slave->slave, op_flag, size, tlv);
206}
207
208static void slave_free(struct snd_kcontrol *kcontrol)
209{
210 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
211 if (slave->slave.private_free)
212 slave->slave.private_free(&slave->slave);
213 if (slave->master)
214 list_del(&slave->list);
215 kfree(slave);
216}
217
218/*
219 * Add a slave control to the group with the given master control
220 *
221 * All slaves must be the same type (returning the same information
222 * via info callback). The fucntion doesn't check it, so it's your
223 * responsibility.
224 *
225 * Also, some additional limitations:
226 * - at most two channels
227 * - logarithmic volume control (dB level), no linear volume
228 * - master can only attenuate the volume, no gain
229 */
230int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave)
231{
232 struct link_master *master_link = snd_kcontrol_chip(master);
233 struct link_slave *srec;
234
235 srec = kzalloc(sizeof(*srec) +
236 slave->count * sizeof(*slave->vd), GFP_KERNEL);
237 if (!srec)
238 return -ENOMEM;
239 srec->slave = *slave;
240 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd));
241 srec->master = master_link;
242
243 /* override callbacks */
244 slave->info = slave_info;
245 slave->get = slave_get;
246 slave->put = slave_put;
247 if (slave->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)
248 slave->tlv.c = slave_tlv_cmd;
249 slave->private_data = srec;
250 slave->private_free = slave_free;
251
252 list_add_tail(&srec->list, &master_link->slaves);
253 return 0;
254}
255
256/*
257 * ctl callbacks for master controls
258 */
259static int master_info(struct snd_kcontrol *kcontrol,
260 struct snd_ctl_elem_info *uinfo)
261{
262 struct link_master *master = snd_kcontrol_chip(kcontrol);
263 int ret;
264
265 ret = master_init(master);
266 if (ret < 0)
267 return ret;
268 uinfo->type = master->info.type;
269 uinfo->count = master->info.count;
270 uinfo->value.integer.min = master->info.min_val;
271 uinfo->value.integer.max = master->info.max_val;
272 return 0;
273}
274
275static int master_get(struct snd_kcontrol *kcontrol,
276 struct snd_ctl_elem_value *ucontrol)
277{
278 struct link_master *master = snd_kcontrol_chip(kcontrol);
279 int err = master_init(master);
280 if (err < 0)
281 return err;
282 ucontrol->value.integer.value[0] = master->val;
283 return 0;
284}
285
286static int master_put(struct snd_kcontrol *kcontrol,
287 struct snd_ctl_elem_value *ucontrol)
288{
289 struct link_master *master = snd_kcontrol_chip(kcontrol);
290 struct link_slave *slave;
291 struct snd_ctl_elem_value *uval;
292 int err, old_val;
293
294 err = master_init(master);
295 if (err < 0)
296 return err;
297 old_val = master->val;
298 if (ucontrol->value.integer.value[0] == old_val)
299 return 0;
300
301 uval = kmalloc(sizeof(*uval), GFP_KERNEL);
302 if (!uval)
303 return -ENOMEM;
304 list_for_each_entry(slave, &master->slaves, list) {
305 master->val = old_val;
306 uval->id = slave->slave.id;
307 slave_get_val(slave, uval);
308 master->val = ucontrol->value.integer.value[0];
309 slave_put_val(slave, uval);
310 }
311 kfree(uval);
312 return 1;
313}
314
315static void master_free(struct snd_kcontrol *kcontrol)
316{
317 struct link_master *master = snd_kcontrol_chip(kcontrol);
318 struct link_slave *slave;
319
320 list_for_each_entry(slave, &master->slaves, list)
321 slave->master = NULL;
322 kfree(master);
323}
324
325
326/*
327 * Create a virtual master control with the given name
328 */
329struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
330 const unsigned int *tlv)
331{
332 struct link_master *master;
333 struct snd_kcontrol *kctl;
334 struct snd_kcontrol_new knew;
335
336 memset(&knew, 0, sizeof(knew));
337 knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
338 knew.name = name;
339 knew.info = master_info;
340
341 master = kzalloc(sizeof(*master), GFP_KERNEL);
342 if (!master)
343 return NULL;
344 INIT_LIST_HEAD(&master->slaves);
345
346 kctl = snd_ctl_new1(&knew, master);
347 if (!kctl) {
348 kfree(master);
349 return NULL;
350 }
351 /* override some callbacks */
352 kctl->info = master_info;
353 kctl->get = master_get;
354 kctl->put = master_put;
355 kctl->private_free = master_free;
356
357 /* additional (constant) TLV read */
358 if (tlv) {
359 /* FIXME: this assumes that the max volume is 0 dB */
360 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
361 kctl->tlv.p = tlv;
362 }
363 return kctl;
364}
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index efd180b40e56..0ed96c178059 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * ALSA driver for ICEnsemble ICE1712 (Envy24) 2 * ALSA driver for ICEnsemble ICE1712 (Envy24)
3 * 3 *
4 * Lowlevel functions for M-Audio Delta 1010, 44, 66, Dio2496, Audiophile 4 * Lowlevel functions for M-Audio Delta 1010, 1010E, 44, 66, 66E, Dio2496,
5 * Digigram VX442 5 * Audiophile, Digigram VX442
6 * 6 *
7 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> 7 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
8 * 8 *
@@ -86,6 +86,7 @@ static unsigned char ap_cs8427_codec_select(struct snd_ice1712 *ice)
86 unsigned char tmp; 86 unsigned char tmp;
87 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA); 87 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
88 switch (ice->eeprom.subvendor) { 88 switch (ice->eeprom.subvendor) {
89 case ICE1712_SUBDEVICE_DELTA1010E:
89 case ICE1712_SUBDEVICE_DELTA1010LT: 90 case ICE1712_SUBDEVICE_DELTA1010LT:
90 tmp &= ~ICE1712_DELTA_1010LT_CS; 91 tmp &= ~ICE1712_DELTA_1010LT_CS;
91 tmp |= ICE1712_DELTA_1010LT_CCLK | ICE1712_DELTA_1010LT_CS_CS8427; 92 tmp |= ICE1712_DELTA_1010LT_CCLK | ICE1712_DELTA_1010LT_CS_CS8427;
@@ -109,6 +110,7 @@ static unsigned char ap_cs8427_codec_select(struct snd_ice1712 *ice)
109static void ap_cs8427_codec_deassert(struct snd_ice1712 *ice, unsigned char tmp) 110static void ap_cs8427_codec_deassert(struct snd_ice1712 *ice, unsigned char tmp)
110{ 111{
111 switch (ice->eeprom.subvendor) { 112 switch (ice->eeprom.subvendor) {
113 case ICE1712_SUBDEVICE_DELTA1010E:
112 case ICE1712_SUBDEVICE_DELTA1010LT: 114 case ICE1712_SUBDEVICE_DELTA1010LT:
113 tmp &= ~ICE1712_DELTA_1010LT_CS; 115 tmp &= ~ICE1712_DELTA_1010LT_CS;
114 tmp |= ICE1712_DELTA_1010LT_CS_NONE; 116 tmp |= ICE1712_DELTA_1010LT_CS_NONE;
@@ -534,6 +536,14 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
534 int err; 536 int err;
535 struct snd_akm4xxx *ak; 537 struct snd_akm4xxx *ak;
536 538
539 if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010 &&
540 ice->eeprom.gpiodir == 0x7b)
541 ice->eeprom.subvendor = ICE1712_SUBDEVICE_DELTA1010E;
542
543 if (ice->eeprom.subvendor == ICE1712_SUBDEVICE_DELTA66 &&
544 ice->eeprom.gpiodir == 0xfb)
545 ice->eeprom.subvendor = ICE1712_SUBDEVICE_DELTA66E;
546
537 /* determine I2C, DACs and ADCs */ 547 /* determine I2C, DACs and ADCs */
538 switch (ice->eeprom.subvendor) { 548 switch (ice->eeprom.subvendor) {
539 case ICE1712_SUBDEVICE_AUDIOPHILE: 549 case ICE1712_SUBDEVICE_AUDIOPHILE:
@@ -550,6 +560,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
550 ice->num_total_adcs = ice->omni ? 8 : 4; 560 ice->num_total_adcs = ice->omni ? 8 : 4;
551 break; 561 break;
552 case ICE1712_SUBDEVICE_DELTA1010: 562 case ICE1712_SUBDEVICE_DELTA1010:
563 case ICE1712_SUBDEVICE_DELTA1010E:
553 case ICE1712_SUBDEVICE_DELTA1010LT: 564 case ICE1712_SUBDEVICE_DELTA1010LT:
554 case ICE1712_SUBDEVICE_MEDIASTATION: 565 case ICE1712_SUBDEVICE_MEDIASTATION:
555 ice->num_total_dacs = 8; 566 ice->num_total_dacs = 8;
@@ -559,6 +570,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
559 ice->num_total_dacs = 4; /* two AK4324 codecs */ 570 ice->num_total_dacs = 4; /* two AK4324 codecs */
560 break; 571 break;
561 case ICE1712_SUBDEVICE_VX442: 572 case ICE1712_SUBDEVICE_VX442:
573 case ICE1712_SUBDEVICE_DELTA66E: /* omni not suported yet */
562 ice->num_total_dacs = 4; 574 ice->num_total_dacs = 4;
563 ice->num_total_adcs = 4; 575 ice->num_total_adcs = 4;
564 break; 576 break;
@@ -568,8 +580,10 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
568 switch (ice->eeprom.subvendor) { 580 switch (ice->eeprom.subvendor) {
569 case ICE1712_SUBDEVICE_AUDIOPHILE: 581 case ICE1712_SUBDEVICE_AUDIOPHILE:
570 case ICE1712_SUBDEVICE_DELTA410: 582 case ICE1712_SUBDEVICE_DELTA410:
583 case ICE1712_SUBDEVICE_DELTA1010E:
571 case ICE1712_SUBDEVICE_DELTA1010LT: 584 case ICE1712_SUBDEVICE_DELTA1010LT:
572 case ICE1712_SUBDEVICE_VX442: 585 case ICE1712_SUBDEVICE_VX442:
586 case ICE1712_SUBDEVICE_DELTA66E:
573 if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) { 587 if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
574 snd_printk(KERN_ERR "unable to create I2C bus\n"); 588 snd_printk(KERN_ERR "unable to create I2C bus\n");
575 return err; 589 return err;
@@ -601,6 +615,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
601 /* no analog? */ 615 /* no analog? */
602 switch (ice->eeprom.subvendor) { 616 switch (ice->eeprom.subvendor) {
603 case ICE1712_SUBDEVICE_DELTA1010: 617 case ICE1712_SUBDEVICE_DELTA1010:
618 case ICE1712_SUBDEVICE_DELTA1010E:
604 case ICE1712_SUBDEVICE_DELTADIO2496: 619 case ICE1712_SUBDEVICE_DELTADIO2496:
605 case ICE1712_SUBDEVICE_MEDIASTATION: 620 case ICE1712_SUBDEVICE_MEDIASTATION:
606 return 0; 621 return 0;
@@ -627,6 +642,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
627 err = snd_ice1712_akm4xxx_init(ak, &akm_delta44, &akm_delta44_priv, ice); 642 err = snd_ice1712_akm4xxx_init(ak, &akm_delta44, &akm_delta44_priv, ice);
628 break; 643 break;
629 case ICE1712_SUBDEVICE_VX442: 644 case ICE1712_SUBDEVICE_VX442:
645 case ICE1712_SUBDEVICE_DELTA66E:
630 err = snd_ice1712_akm4xxx_init(ak, &akm_vx442, &akm_vx442_priv, ice); 646 err = snd_ice1712_akm4xxx_init(ak, &akm_vx442, &akm_vx442_priv, ice);
631 break; 647 break;
632 default: 648 default:
@@ -674,6 +690,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice)
674 if (err < 0) 690 if (err < 0)
675 return err; 691 return err;
676 break; 692 break;
693 case ICE1712_SUBDEVICE_DELTA1010E:
677 case ICE1712_SUBDEVICE_DELTA1010LT: 694 case ICE1712_SUBDEVICE_DELTA1010LT:
678 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta1010lt_wordclock_select, ice)); 695 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_delta1010lt_wordclock_select, ice));
679 if (err < 0) 696 if (err < 0)
@@ -716,6 +733,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice)
716 case ICE1712_SUBDEVICE_DELTA44: 733 case ICE1712_SUBDEVICE_DELTA44:
717 case ICE1712_SUBDEVICE_DELTA66: 734 case ICE1712_SUBDEVICE_DELTA66:
718 case ICE1712_SUBDEVICE_VX442: 735 case ICE1712_SUBDEVICE_VX442:
736 case ICE1712_SUBDEVICE_DELTA66E:
719 err = snd_ice1712_akm4xxx_build_controls(ice); 737 err = snd_ice1712_akm4xxx_build_controls(ice);
720 if (err < 0) 738 if (err < 0)
721 return err; 739 return err;
diff --git a/sound/pci/ice1712/delta.h b/sound/pci/ice1712/delta.h
index 26ea05a32f56..ea7116c304c0 100644
--- a/sound/pci/ice1712/delta.h
+++ b/sound/pci/ice1712/delta.h
@@ -36,8 +36,10 @@
36 "{Lionstracs,Mediastation}," 36 "{Lionstracs,Mediastation},"
37 37
38#define ICE1712_SUBDEVICE_DELTA1010 0x121430d6 38#define ICE1712_SUBDEVICE_DELTA1010 0x121430d6
39#define ICE1712_SUBDEVICE_DELTA1010E 0xff1430d6
39#define ICE1712_SUBDEVICE_DELTADIO2496 0x121431d6 40#define ICE1712_SUBDEVICE_DELTADIO2496 0x121431d6
40#define ICE1712_SUBDEVICE_DELTA66 0x121432d6 41#define ICE1712_SUBDEVICE_DELTA66 0x121432d6
42#define ICE1712_SUBDEVICE_DELTA66E 0xff1432d6
41#define ICE1712_SUBDEVICE_DELTA44 0x121433d6 43#define ICE1712_SUBDEVICE_DELTA44 0x121433d6
42#define ICE1712_SUBDEVICE_AUDIOPHILE 0x121434d6 44#define ICE1712_SUBDEVICE_AUDIOPHILE 0x121434d6
43#define ICE1712_SUBDEVICE_DELTA410 0x121438d6 45#define ICE1712_SUBDEVICE_DELTA410 0x121438d6
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 064760d2a027..013fc4f04822 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -238,6 +238,7 @@ static void snd_ice1712_ews_cs8404_spdif_write(struct snd_ice1712 *ice, unsigned
238 case ICE1712_SUBDEVICE_EWS88MT: 238 case ICE1712_SUBDEVICE_EWS88MT:
239 case ICE1712_SUBDEVICE_EWS88MT_NEW: 239 case ICE1712_SUBDEVICE_EWS88MT_NEW:
240 case ICE1712_SUBDEVICE_PHASE88: 240 case ICE1712_SUBDEVICE_PHASE88:
241 case ICE1712_SUBDEVICE_TS88:
241 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_CS8404], &bits, 1) 242 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_CS8404], &bits, 1)
242 != 1) 243 != 1)
243 goto _error; 244 goto _error;
@@ -433,6 +434,7 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
433 case ICE1712_SUBDEVICE_EWS88MT: 434 case ICE1712_SUBDEVICE_EWS88MT:
434 case ICE1712_SUBDEVICE_EWS88MT_NEW: 435 case ICE1712_SUBDEVICE_EWS88MT_NEW:
435 case ICE1712_SUBDEVICE_PHASE88: 436 case ICE1712_SUBDEVICE_PHASE88:
437 case ICE1712_SUBDEVICE_TS88:
436 ice->num_total_dacs = 8; 438 ice->num_total_dacs = 8;
437 ice->num_total_adcs = 8; 439 ice->num_total_adcs = 8;
438 break; 440 break;
@@ -475,6 +477,8 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
475 case ICE1712_SUBDEVICE_EWS88MT: 477 case ICE1712_SUBDEVICE_EWS88MT:
476 case ICE1712_SUBDEVICE_EWS88MT_NEW: 478 case ICE1712_SUBDEVICE_EWS88MT_NEW:
477 case ICE1712_SUBDEVICE_PHASE88: 479 case ICE1712_SUBDEVICE_PHASE88:
480 case ICE1712_SUBDEVICE_TS88:
481
478 err = snd_i2c_device_create(ice->i2c, "CS8404", 482 err = snd_i2c_device_create(ice->i2c, "CS8404",
479 ICE1712_EWS88MT_CS8404_ADDR, 483 ICE1712_EWS88MT_CS8404_ADDR,
480 &spec->i2cdevs[EWS_I2C_CS8404]); 484 &spec->i2cdevs[EWS_I2C_CS8404]);
@@ -518,6 +522,7 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
518 case ICE1712_SUBDEVICE_EWS88MT: 522 case ICE1712_SUBDEVICE_EWS88MT:
519 case ICE1712_SUBDEVICE_EWS88MT_NEW: 523 case ICE1712_SUBDEVICE_EWS88MT_NEW:
520 case ICE1712_SUBDEVICE_PHASE88: 524 case ICE1712_SUBDEVICE_PHASE88:
525 case ICE1712_SUBDEVICE_TS88:
521 case ICE1712_SUBDEVICE_EWS88D: 526 case ICE1712_SUBDEVICE_EWS88D:
522 /* set up CS8404 */ 527 /* set up CS8404 */
523 ice->spdif.ops.open = ews88_open_spdif; 528 ice->spdif.ops.open = ews88_open_spdif;
@@ -547,6 +552,7 @@ static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
547 case ICE1712_SUBDEVICE_EWS88MT: 552 case ICE1712_SUBDEVICE_EWS88MT:
548 case ICE1712_SUBDEVICE_EWS88MT_NEW: 553 case ICE1712_SUBDEVICE_EWS88MT_NEW:
549 case ICE1712_SUBDEVICE_PHASE88: 554 case ICE1712_SUBDEVICE_PHASE88:
555 case ICE1712_SUBDEVICE_TS88:
550 err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice); 556 err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice);
551 break; 557 break;
552 case ICE1712_SUBDEVICE_EWX2496: 558 case ICE1712_SUBDEVICE_EWX2496:
@@ -973,6 +979,7 @@ static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
973 case ICE1712_SUBDEVICE_EWS88MT: 979 case ICE1712_SUBDEVICE_EWS88MT:
974 case ICE1712_SUBDEVICE_EWS88MT_NEW: 980 case ICE1712_SUBDEVICE_EWS88MT_NEW:
975 case ICE1712_SUBDEVICE_PHASE88: 981 case ICE1712_SUBDEVICE_PHASE88:
982 case ICE1712_SUBDEVICE_TS88:
976 case ICE1712_SUBDEVICE_DMX6FIRE: 983 case ICE1712_SUBDEVICE_DMX6FIRE:
977 err = snd_ice1712_akm4xxx_build_controls(ice); 984 err = snd_ice1712_akm4xxx_build_controls(ice);
978 if (err < 0) 985 if (err < 0)
@@ -992,6 +999,7 @@ static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
992 case ICE1712_SUBDEVICE_EWS88MT: 999 case ICE1712_SUBDEVICE_EWS88MT:
993 case ICE1712_SUBDEVICE_EWS88MT_NEW: 1000 case ICE1712_SUBDEVICE_EWS88MT_NEW:
994 case ICE1712_SUBDEVICE_PHASE88: 1001 case ICE1712_SUBDEVICE_PHASE88:
1002 case ICE1712_SUBDEVICE_TS88:
995 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice)); 1003 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice));
996 if (err < 0) 1004 if (err < 0)
997 return err; 1005 return err;
@@ -1049,6 +1057,13 @@ struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
1049 .build_controls = snd_ice1712_ews_add_controls, 1057 .build_controls = snd_ice1712_ews_add_controls,
1050 }, 1058 },
1051 { 1059 {
1060 .subvendor = ICE1712_SUBDEVICE_TS88,
1061 .name = "terrasoniq TS88",
1062 .model = "phase88",
1063 .chip_init = snd_ice1712_ews_init,
1064 .build_controls = snd_ice1712_ews_add_controls,
1065 },
1066 {
1052 .subvendor = ICE1712_SUBDEVICE_EWS88D, 1067 .subvendor = ICE1712_SUBDEVICE_EWS88D,
1053 .name = "TerraTec EWS88D", 1068 .name = "TerraTec EWS88D",
1054 .model = "ews88d", 1069 .model = "ews88d",
diff --git a/sound/pci/ice1712/ews.h b/sound/pci/ice1712/ews.h
index e4ed1b475b08..1c443718af03 100644
--- a/sound/pci/ice1712/ews.h
+++ b/sound/pci/ice1712/ews.h
@@ -30,7 +30,8 @@
30 "{TerraTec,EWS 88MT},"\ 30 "{TerraTec,EWS 88MT},"\
31 "{TerraTec,EWS 88D},"\ 31 "{TerraTec,EWS 88D},"\
32 "{TerraTec,DMX 6Fire},"\ 32 "{TerraTec,DMX 6Fire},"\
33 "{TerraTec,Phase 88}," 33 "{TerraTec,Phase 88}," \
34 "{terrasoniq,TS 88},"
34 35
35#define ICE1712_SUBDEVICE_EWX2496 0x3b153011 36#define ICE1712_SUBDEVICE_EWX2496 0x3b153011
36#define ICE1712_SUBDEVICE_EWS88MT 0x3b151511 37#define ICE1712_SUBDEVICE_EWS88MT 0x3b151511
@@ -38,6 +39,7 @@
38#define ICE1712_SUBDEVICE_EWS88D 0x3b152b11 39#define ICE1712_SUBDEVICE_EWS88D 0x3b152b11
39#define ICE1712_SUBDEVICE_DMX6FIRE 0x3b153811 40#define ICE1712_SUBDEVICE_DMX6FIRE 0x3b153811
40#define ICE1712_SUBDEVICE_PHASE88 0x3b155111 41#define ICE1712_SUBDEVICE_PHASE88 0x3b155111
42#define ICE1712_SUBDEVICE_TS88 0x3b157c11
41 43
42/* entry point */ 44/* entry point */
43extern struct snd_ice1712_card_info snd_ice1712_ews_cards[]; 45extern struct snd_ice1712_card_info snd_ice1712_ews_cards[];
diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
index cf5c7c0898fd..6914189073a4 100644
--- a/sound/pci/ice1712/hoontech.c
+++ b/sound/pci/ice1712/hoontech.c
@@ -208,6 +208,19 @@ static int __devinit snd_ice1712_hoontech_init(struct snd_ice1712 *ice)
208 /* ICE1712_STDSP24_MUTE | 208 /* ICE1712_STDSP24_MUTE |
209 ICE1712_STDSP24_INSEL | 209 ICE1712_STDSP24_INSEL |
210 ICE1712_STDSP24_DAREAR; */ 210 ICE1712_STDSP24_DAREAR; */
211 /* These boxconfigs have caused problems in the past.
212 * The code is not optimal, but should now enable a working config to
213 * be achieved.
214 * ** MIDI IN can only be configured on one box **
215 * ICE1712_STDSP24_BOX_MIDI1 needs to be set for that box.
216 * Tests on a ADAC2000 box suggest the box config flags do not
217 * work as would be expected, and the inputs are crossed.
218 * Setting ICE1712_STDSP24_BOX_MIDI1 and ICE1712_STDSP24_BOX_MIDI2
219 * on the same box connects MIDI-In to both 401 uarts; both outputs
220 * are then active on all boxes.
221 * The default config here sets up everything on the first box.
222 * Alan Horstmann 5.2.2008
223 */
211 spec->boxconfig[0] = ICE1712_STDSP24_BOX_CHN1 | 224 spec->boxconfig[0] = ICE1712_STDSP24_BOX_CHN1 |
212 ICE1712_STDSP24_BOX_CHN2 | 225 ICE1712_STDSP24_BOX_CHN2 |
213 ICE1712_STDSP24_BOX_CHN3 | 226 ICE1712_STDSP24_BOX_CHN3 |
@@ -223,14 +236,14 @@ static int __devinit snd_ice1712_hoontech_init(struct snd_ice1712 *ice)
223 (spec->config & ICE1712_STDSP24_MUTE) ? 1 : 0); 236 (spec->config & ICE1712_STDSP24_MUTE) ? 1 : 0);
224 snd_ice1712_stdsp24_insel(ice, 237 snd_ice1712_stdsp24_insel(ice,
225 (spec->config & ICE1712_STDSP24_INSEL) ? 1 : 0); 238 (spec->config & ICE1712_STDSP24_INSEL) ? 1 : 0);
226 for (box = 0; box < 1; box++) { 239 for (box = 0; box < 4; box++) {
227 if (spec->boxconfig[box] & ICE1712_STDSP24_BOX_MIDI2) 240 if (spec->boxconfig[box] & ICE1712_STDSP24_BOX_MIDI2)
228 snd_ice1712_stdsp24_midi2(ice, 1); 241 snd_ice1712_stdsp24_midi2(ice, 1);
229 for (chn = 0; chn < 4; chn++) 242 for (chn = 0; chn < 4; chn++)
230 snd_ice1712_stdsp24_box_channel(ice, box, chn, 243 snd_ice1712_stdsp24_box_channel(ice, box, chn,
231 (spec->boxconfig[box] & (1 << chn)) ? 1 : 0); 244 (spec->boxconfig[box] & (1 << chn)) ? 1 : 0);
232 snd_ice1712_stdsp24_box_midi(ice, box, 245 if (spec->boxconfig[box] & ICE1712_STDSP24_BOX_MIDI1)
233 (spec->boxconfig[box] & ICE1712_STDSP24_BOX_MIDI1) ? 1 : 0); 246 snd_ice1712_stdsp24_box_midi(ice, box, 1);
234 } 247 }
235 248
236 return 0; 249 return 0;
@@ -322,6 +335,8 @@ struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
322 .name = "Hoontech SoundTrack Audio DSP24", 335 .name = "Hoontech SoundTrack Audio DSP24",
323 .model = "dsp24", 336 .model = "dsp24",
324 .chip_init = snd_ice1712_hoontech_init, 337 .chip_init = snd_ice1712_hoontech_init,
338 .mpu401_1_name = "MIDI-1 Hoontech/STA DSP24",
339 .mpu401_2_name = "MIDI-2 Hoontech/STA DSP24",
325 }, 340 },
326 { 341 {
327 .subvendor = ICE1712_SUBDEVICE_STDSP24_VALUE, /* a dummy id */ 342 .subvendor = ICE1712_SUBDEVICE_STDSP24_VALUE, /* a dummy id */
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index df292af67381..29d449d73c98 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -1297,11 +1297,14 @@ static void snd_ice1712_update_volume(struct snd_ice1712 *ice, int index)
1297static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1297static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1298{ 1298{
1299 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1299 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1300 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1300 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
1301 kcontrol->private_value;
1301 1302
1302 spin_lock_irq(&ice->reg_lock); 1303 spin_lock_irq(&ice->reg_lock);
1303 ucontrol->value.integer.value[0] = !((ice->pro_volumes[index] >> 15) & 1); 1304 ucontrol->value.integer.value[0] =
1304 ucontrol->value.integer.value[1] = !((ice->pro_volumes[index] >> 31) & 1); 1305 !((ice->pro_volumes[priv_idx] >> 15) & 1);
1306 ucontrol->value.integer.value[1] =
1307 !((ice->pro_volumes[priv_idx] >> 31) & 1);
1305 spin_unlock_irq(&ice->reg_lock); 1308 spin_unlock_irq(&ice->reg_lock);
1306 return 0; 1309 return 0;
1307} 1310}
@@ -1309,16 +1312,17 @@ static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struc
1309static int snd_ice1712_pro_mixer_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1312static int snd_ice1712_pro_mixer_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1310{ 1313{
1311 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1314 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1312 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1315 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
1316 kcontrol->private_value;
1313 unsigned int nval, change; 1317 unsigned int nval, change;
1314 1318
1315 nval = (ucontrol->value.integer.value[0] ? 0 : 0x00008000) | 1319 nval = (ucontrol->value.integer.value[0] ? 0 : 0x00008000) |
1316 (ucontrol->value.integer.value[1] ? 0 : 0x80000000); 1320 (ucontrol->value.integer.value[1] ? 0 : 0x80000000);
1317 spin_lock_irq(&ice->reg_lock); 1321 spin_lock_irq(&ice->reg_lock);
1318 nval |= ice->pro_volumes[index] & ~0x80008000; 1322 nval |= ice->pro_volumes[priv_idx] & ~0x80008000;
1319 change = nval != ice->pro_volumes[index]; 1323 change = nval != ice->pro_volumes[priv_idx];
1320 ice->pro_volumes[index] = nval; 1324 ice->pro_volumes[priv_idx] = nval;
1321 snd_ice1712_update_volume(ice, index); 1325 snd_ice1712_update_volume(ice, priv_idx);
1322 spin_unlock_irq(&ice->reg_lock); 1326 spin_unlock_irq(&ice->reg_lock);
1323 return change; 1327 return change;
1324} 1328}
@@ -1335,11 +1339,14 @@ static int snd_ice1712_pro_mixer_volume_info(struct snd_kcontrol *kcontrol, stru
1335static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1339static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1336{ 1340{
1337 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1341 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1338 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1342 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
1343 kcontrol->private_value;
1339 1344
1340 spin_lock_irq(&ice->reg_lock); 1345 spin_lock_irq(&ice->reg_lock);
1341 ucontrol->value.integer.value[0] = (ice->pro_volumes[index] >> 0) & 127; 1346 ucontrol->value.integer.value[0] =
1342 ucontrol->value.integer.value[1] = (ice->pro_volumes[index] >> 16) & 127; 1347 (ice->pro_volumes[priv_idx] >> 0) & 127;
1348 ucontrol->value.integer.value[1] =
1349 (ice->pro_volumes[priv_idx] >> 16) & 127;
1343 spin_unlock_irq(&ice->reg_lock); 1350 spin_unlock_irq(&ice->reg_lock);
1344 return 0; 1351 return 0;
1345} 1352}
@@ -1347,16 +1354,17 @@ static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struc
1347static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1354static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1348{ 1355{
1349 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1356 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1350 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1357 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) +
1358 kcontrol->private_value;
1351 unsigned int nval, change; 1359 unsigned int nval, change;
1352 1360
1353 nval = (ucontrol->value.integer.value[0] & 127) | 1361 nval = (ucontrol->value.integer.value[0] & 127) |
1354 ((ucontrol->value.integer.value[1] & 127) << 16); 1362 ((ucontrol->value.integer.value[1] & 127) << 16);
1355 spin_lock_irq(&ice->reg_lock); 1363 spin_lock_irq(&ice->reg_lock);
1356 nval |= ice->pro_volumes[index] & ~0x007f007f; 1364 nval |= ice->pro_volumes[priv_idx] & ~0x007f007f;
1357 change = nval != ice->pro_volumes[index]; 1365 change = nval != ice->pro_volumes[priv_idx];
1358 ice->pro_volumes[index] = nval; 1366 ice->pro_volumes[priv_idx] = nval;
1359 snd_ice1712_update_volume(ice, index); 1367 snd_ice1712_update_volume(ice, priv_idx);
1360 spin_unlock_irq(&ice->reg_lock); 1368 spin_unlock_irq(&ice->reg_lock);
1361 return change; 1369 return change;
1362} 1370}
@@ -2482,10 +2490,9 @@ static int snd_ice1712_free(struct snd_ice1712 *ice)
2482 outb(0xff, ICEREG(ice, IRQMASK)); 2490 outb(0xff, ICEREG(ice, IRQMASK));
2483 /* --- */ 2491 /* --- */
2484 __hw_end: 2492 __hw_end:
2485 if (ice->irq >= 0) { 2493 if (ice->irq >= 0)
2486 synchronize_irq(ice->irq);
2487 free_irq(ice->irq, ice); 2494 free_irq(ice->irq, ice);
2488 } 2495
2489 if (ice->port) 2496 if (ice->port)
2490 pci_release_regions(ice->pci); 2497 pci_release_regions(ice->pci);
2491 snd_ice1712_akm4xxx_free(ice); 2498 snd_ice1712_akm4xxx_free(ice);
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index 303cffe08bd8..3208901c740e 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -367,6 +367,15 @@ struct snd_ice1712 {
367 367
368 /* other board-specific data */ 368 /* other board-specific data */
369 void *spec; 369 void *spec;
370
371 /* VT172x specific */
372 int pro_rate_default;
373 int (*is_spdif_master)(struct snd_ice1712 *ice);
374 unsigned int (*get_rate)(struct snd_ice1712 *ice);
375 void (*set_rate)(struct snd_ice1712 *ice, unsigned int rate);
376 unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate);
377 void (*set_spdif_clock)(struct snd_ice1712 *ice);
378
370}; 379};
371 380
372 381
@@ -429,10 +438,14 @@ int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
429static inline void snd_ice1712_gpio_write_bits(struct snd_ice1712 *ice, 438static inline void snd_ice1712_gpio_write_bits(struct snd_ice1712 *ice,
430 unsigned int mask, unsigned int bits) 439 unsigned int mask, unsigned int bits)
431{ 440{
441 unsigned val;
442
432 ice->gpio.direction |= mask; 443 ice->gpio.direction |= mask;
433 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); 444 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
434 snd_ice1712_gpio_set_mask(ice, ~mask); 445 val = snd_ice1712_gpio_read(ice);
435 snd_ice1712_gpio_write(ice, mask & bits); 446 val &= ~mask;
447 val |= mask & bits;
448 snd_ice1712_gpio_write(ice, val);
436} 449}
437 450
438static inline int snd_ice1712_gpio_read_bits(struct snd_ice1712 *ice, 451static inline int snd_ice1712_gpio_read_bits(struct snd_ice1712 *ice,
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index f533850ec6e7..67350901772c 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -106,15 +106,19 @@ static unsigned int PRO_RATE_DEFAULT = 44100;
106 * Basic I/O 106 * Basic I/O
107 */ 107 */
108 108
109/*
110 * default rates, default clock routines
111 */
112
109/* check whether the clock mode is spdif-in */ 113/* check whether the clock mode is spdif-in */
110static inline int is_spdif_master(struct snd_ice1712 *ice) 114static inline int stdclock_is_spdif_master(struct snd_ice1712 *ice)
111{ 115{
112 return (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER) ? 1 : 0; 116 return (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER) ? 1 : 0;
113} 117}
114 118
115static inline int is_pro_rate_locked(struct snd_ice1712 *ice) 119static inline int is_pro_rate_locked(struct snd_ice1712 *ice)
116{ 120{
117 return is_spdif_master(ice) || PRO_RATE_LOCKED; 121 return ice->is_spdif_master(ice) || PRO_RATE_LOCKED;
118} 122}
119 123
120/* 124/*
@@ -219,6 +223,32 @@ static unsigned int snd_vt1724_get_gpio_data(struct snd_ice1712 *ice)
219} 223}
220 224
221/* 225/*
226 * MPU401 accessor
227 */
228static unsigned char snd_vt1724_mpu401_read(struct snd_mpu401 *mpu,
229 unsigned long addr)
230{
231 /* fix status bits to the standard position */
232 /* only RX_EMPTY and TX_FULL are checked */
233 if (addr == MPU401C(mpu))
234 return (inb(addr) & 0x0c) << 4;
235 else
236 return inb(addr);
237}
238
239static void snd_vt1724_mpu401_write(struct snd_mpu401 *mpu,
240 unsigned char data, unsigned long addr)
241{
242 if (addr == MPU401C(mpu)) {
243 if (data == MPU401_ENTER_UART)
244 outb(0x01, addr);
245 /* what else? */
246 } else
247 outb(data, addr);
248}
249
250
251/*
222 * Interrupt handler 252 * Interrupt handler
223 */ 253 */
224 254
@@ -226,24 +256,53 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
226{ 256{
227 struct snd_ice1712 *ice = dev_id; 257 struct snd_ice1712 *ice = dev_id;
228 unsigned char status; 258 unsigned char status;
259 unsigned char status_mask =
260 VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX | VT1724_IRQ_MTPCM;
229 int handled = 0; 261 int handled = 0;
262#ifdef CONFIG_SND_DEBUG
263 int timeout = 0;
264#endif
230 265
231 while (1) { 266 while (1) {
232 status = inb(ICEREG1724(ice, IRQSTAT)); 267 status = inb(ICEREG1724(ice, IRQSTAT));
268 status &= status_mask;
233 if (status == 0) 269 if (status == 0)
234 break; 270 break;
235 271#ifdef CONFIG_SND_DEBUG
272 if (++timeout > 10) {
273 printk(KERN_ERR
274 "ice1724: Too long irq loop, status = 0x%x\n",
275 status);
276 break;
277 }
278#endif
236 handled = 1; 279 handled = 1;
237 /* these should probably be separated at some point, 280 if (status & VT1724_IRQ_MPU_TX) {
238 * but as we don't currently have MPU support on the board
239 * I will leave it
240 */
241 if ((status & VT1724_IRQ_MPU_RX)||(status & VT1724_IRQ_MPU_TX)) {
242 if (ice->rmidi[0]) 281 if (ice->rmidi[0])
243 snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data); 282 snd_mpu401_uart_interrupt_tx(irq,
244 outb(status & (VT1724_IRQ_MPU_RX|VT1724_IRQ_MPU_TX), ICEREG1724(ice, IRQSTAT)); 283 ice->rmidi[0]->private_data);
245 status &= ~(VT1724_IRQ_MPU_RX|VT1724_IRQ_MPU_TX); 284 else /* disable TX to be sure */
285 outb(inb(ICEREG1724(ice, IRQMASK)) |
286 VT1724_IRQ_MPU_TX,
287 ICEREG1724(ice, IRQMASK));
288 /* Due to mysterical reasons, MPU_TX is always
289 * generated (and can't be cleared) when a PCM
290 * playback is going. So let's ignore at the
291 * next loop.
292 */
293 status_mask &= ~VT1724_IRQ_MPU_TX;
246 } 294 }
295 if (status & VT1724_IRQ_MPU_RX) {
296 if (ice->rmidi[0])
297 snd_mpu401_uart_interrupt(irq,
298 ice->rmidi[0]->private_data);
299 else /* disable RX to be sure */
300 outb(inb(ICEREG1724(ice, IRQMASK)) |
301 VT1724_IRQ_MPU_RX,
302 ICEREG1724(ice, IRQMASK));
303 }
304 /* ack MPU irq */
305 outb(status, ICEREG1724(ice, IRQSTAT));
247 if (status & VT1724_IRQ_MTPCM) { 306 if (status & VT1724_IRQ_MTPCM) {
248 /* 307 /*
249 * Multi-track PCM 308 * Multi-track PCM
@@ -391,51 +450,61 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
391#define DMA_PAUSES (VT1724_RDMA0_PAUSE|VT1724_PDMA0_PAUSE|VT1724_RDMA1_PAUSE|\ 450#define DMA_PAUSES (VT1724_RDMA0_PAUSE|VT1724_PDMA0_PAUSE|VT1724_RDMA1_PAUSE|\
392 VT1724_PDMA1_PAUSE|VT1724_PDMA2_PAUSE|VT1724_PDMA3_PAUSE|VT1724_PDMA4_PAUSE) 451 VT1724_PDMA1_PAUSE|VT1724_PDMA2_PAUSE|VT1724_PDMA3_PAUSE|VT1724_PDMA4_PAUSE)
393 452
394static int get_max_rate(struct snd_ice1712 *ice) 453static const unsigned int stdclock_rate_list[16] = {
454 48000, 24000, 12000, 9600, 32000, 16000, 8000, 96000, 44100,
455 22050, 11025, 88200, 176400, 0, 192000, 64000
456};
457
458static unsigned int stdclock_get_rate(struct snd_ice1712 *ice)
459{
460 unsigned int rate;
461 rate = stdclock_rate_list[inb(ICEMT1724(ice, RATE)) & 15];
462 return rate;
463}
464
465static void stdclock_set_rate(struct snd_ice1712 *ice, unsigned int rate)
395{ 466{
467 int i;
468 for (i = 0; i < ARRAY_SIZE(stdclock_rate_list); i++) {
469 if (stdclock_rate_list[i] == rate) {
470 outb(i, ICEMT1724(ice, RATE));
471 return;
472 }
473 }
474}
475
476static unsigned char stdclock_set_mclk(struct snd_ice1712 *ice,
477 unsigned int rate)
478{
479 unsigned char val, old;
480 /* check MT02 */
396 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { 481 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) {
397 if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720) 482 val = old = inb(ICEMT1724(ice, I2S_FORMAT));
398 return 192000; 483 if (rate > 96000)
484 val |= VT1724_MT_I2S_MCLK_128X; /* 128x MCLK */
399 else 485 else
400 return 96000; 486 val &= ~VT1724_MT_I2S_MCLK_128X; /* 256x MCLK */
401 } else 487 if (val != old) {
402 return 48000; 488 outb(val, ICEMT1724(ice, I2S_FORMAT));
489 /* master clock changed */
490 return 1;
491 }
492 }
493 /* no change in master clock */
494 return 0;
403} 495}
404 496
405static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, 497static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
406 int force) 498 int force)
407{ 499{
408 unsigned long flags; 500 unsigned long flags;
409 unsigned char val, old; 501 unsigned char mclk_change;
410 unsigned int i, mclk_change; 502 unsigned int i, old_rate;
411 503
412 if (rate > get_max_rate(ice)) 504 if (rate > ice->hw_rates->list[ice->hw_rates->count - 1])
413 return; 505 return;
414
415 switch (rate) {
416 case 8000: val = 6; break;
417 case 9600: val = 3; break;
418 case 11025: val = 10; break;
419 case 12000: val = 2; break;
420 case 16000: val = 5; break;
421 case 22050: val = 9; break;
422 case 24000: val = 1; break;
423 case 32000: val = 4; break;
424 case 44100: val = 8; break;
425 case 48000: val = 0; break;
426 case 64000: val = 15; break;
427 case 88200: val = 11; break;
428 case 96000: val = 7; break;
429 case 176400: val = 12; break;
430 case 192000: val = 14; break;
431 default:
432 snd_BUG();
433 val = 0;
434 break;
435 }
436
437 spin_lock_irqsave(&ice->reg_lock, flags); 506 spin_lock_irqsave(&ice->reg_lock, flags);
438 if ((inb(ICEMT1724(ice, DMA_CONTROL)) & DMA_STARTS) || 507 if ((inb(ICEMT1724(ice, DMA_CONTROL)) & DMA_STARTS) ||
439 (inb(ICEMT1724(ice, DMA_PAUSE)) & DMA_PAUSES)) { 508 (inb(ICEMT1724(ice, DMA_PAUSE)) & DMA_PAUSES)) {
440 /* running? we cannot change the rate now... */ 509 /* running? we cannot change the rate now... */
441 spin_unlock_irqrestore(&ice->reg_lock, flags); 510 spin_unlock_irqrestore(&ice->reg_lock, flags);
@@ -446,9 +515,9 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
446 return; 515 return;
447 } 516 }
448 517
449 old = inb(ICEMT1724(ice, RATE)); 518 old_rate = ice->get_rate(ice);
450 if (force || old != val) 519 if (force || (old_rate != rate))
451 outb(val, ICEMT1724(ice, RATE)); 520 ice->set_rate(ice, rate);
452 else if (rate == ice->cur_rate) { 521 else if (rate == ice->cur_rate) {
453 spin_unlock_irqrestore(&ice->reg_lock, flags); 522 spin_unlock_irqrestore(&ice->reg_lock, flags);
454 return; 523 return;
@@ -456,19 +525,9 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
456 525
457 ice->cur_rate = rate; 526 ice->cur_rate = rate;
458 527
459 /* check MT02 */ 528 /* setting master clock */
460 mclk_change = 0; 529 mclk_change = ice->set_mclk(ice, rate);
461 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { 530
462 val = old = inb(ICEMT1724(ice, I2S_FORMAT));
463 if (rate > 96000)
464 val |= VT1724_MT_I2S_MCLK_128X; /* 128x MCLK */
465 else
466 val &= ~VT1724_MT_I2S_MCLK_128X; /* 256x MCLK */
467 if (val != old) {
468 outb(val, ICEMT1724(ice, I2S_FORMAT));
469 mclk_change = 1;
470 }
471 }
472 spin_unlock_irqrestore(&ice->reg_lock, flags); 531 spin_unlock_irqrestore(&ice->reg_lock, flags);
473 532
474 if (mclk_change && ice->gpio.i2s_mclk_changed) 533 if (mclk_change && ice->gpio.i2s_mclk_changed)
@@ -727,43 +786,32 @@ static const struct snd_pcm_hardware snd_vt1724_2ch_stereo =
727/* 786/*
728 * set rate constraints 787 * set rate constraints
729 */ 788 */
730static int set_rate_constraints(struct snd_ice1712 *ice, 789static void set_std_hw_rates(struct snd_ice1712 *ice)
731 struct snd_pcm_substream *substream)
732{ 790{
733 struct snd_pcm_runtime *runtime = substream->runtime;
734 if (ice->hw_rates) {
735 /* hardware specific */
736 runtime->hw.rate_min = ice->hw_rates->list[0];
737 runtime->hw.rate_max = ice->hw_rates->list[ice->hw_rates->count - 1];
738 runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
739 return snd_pcm_hw_constraint_list(runtime, 0,
740 SNDRV_PCM_HW_PARAM_RATE,
741 ice->hw_rates);
742 }
743 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { 791 if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) {
744 /* I2S */ 792 /* I2S */
745 /* VT1720 doesn't support more than 96kHz */ 793 /* VT1720 doesn't support more than 96kHz */
746 if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720) 794 if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720)
747 return snd_pcm_hw_constraint_list(runtime, 0, 795 ice->hw_rates = &hw_constraints_rates_192;
748 SNDRV_PCM_HW_PARAM_RATE, 796 else
749 &hw_constraints_rates_192); 797 ice->hw_rates = &hw_constraints_rates_96;
750 else { 798 } else {
751 runtime->hw.rates = SNDRV_PCM_RATE_KNOT |
752 SNDRV_PCM_RATE_8000_96000;
753 runtime->hw.rate_max = 96000;
754 return snd_pcm_hw_constraint_list(runtime, 0,
755 SNDRV_PCM_HW_PARAM_RATE,
756 &hw_constraints_rates_96);
757 }
758 } else if (ice->ac97) {
759 /* ACLINK */ 799 /* ACLINK */
760 runtime->hw.rate_max = 48000; 800 ice->hw_rates = &hw_constraints_rates_48;
761 runtime->hw.rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000;
762 return snd_pcm_hw_constraint_list(runtime, 0,
763 SNDRV_PCM_HW_PARAM_RATE,
764 &hw_constraints_rates_48);
765 } 801 }
766 return 0; 802}
803
804static int set_rate_constraints(struct snd_ice1712 *ice,
805 struct snd_pcm_substream *substream)
806{
807 struct snd_pcm_runtime *runtime = substream->runtime;
808
809 runtime->hw.rate_min = ice->hw_rates->list[0];
810 runtime->hw.rate_max = ice->hw_rates->list[ice->hw_rates->count - 1];
811 runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
812 return snd_pcm_hw_constraint_list(runtime, 0,
813 SNDRV_PCM_HW_PARAM_RATE,
814 ice->hw_rates);
767} 815}
768 816
769/* multi-channel playback needs alignment 8x32bit regardless of the channels 817/* multi-channel playback needs alignment 8x32bit regardless of the channels
@@ -824,7 +872,7 @@ static int snd_vt1724_playback_pro_close(struct snd_pcm_substream *substream)
824 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 872 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
825 873
826 if (PRO_RATE_RESET) 874 if (PRO_RATE_RESET)
827 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 875 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
828 ice->playback_pro_substream = NULL; 876 ice->playback_pro_substream = NULL;
829 877
830 return 0; 878 return 0;
@@ -835,7 +883,7 @@ static int snd_vt1724_capture_pro_close(struct snd_pcm_substream *substream)
835 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 883 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
836 884
837 if (PRO_RATE_RESET) 885 if (PRO_RATE_RESET)
838 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 886 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
839 ice->capture_pro_substream = NULL; 887 ice->capture_pro_substream = NULL;
840 return 0; 888 return 0;
841} 889}
@@ -970,6 +1018,8 @@ static int snd_vt1724_playback_spdif_open(struct snd_pcm_substream *substream)
970 VT1724_BUFFER_ALIGN); 1018 VT1724_BUFFER_ALIGN);
971 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1019 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
972 VT1724_BUFFER_ALIGN); 1020 VT1724_BUFFER_ALIGN);
1021 if (ice->spdif.ops.open)
1022 ice->spdif.ops.open(ice, substream);
973 return 0; 1023 return 0;
974} 1024}
975 1025
@@ -978,8 +1028,10 @@ static int snd_vt1724_playback_spdif_close(struct snd_pcm_substream *substream)
978 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1028 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
979 1029
980 if (PRO_RATE_RESET) 1030 if (PRO_RATE_RESET)
981 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 1031 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
982 ice->playback_con_substream = NULL; 1032 ice->playback_con_substream = NULL;
1033 if (ice->spdif.ops.close)
1034 ice->spdif.ops.close(ice, substream);
983 1035
984 return 0; 1036 return 0;
985} 1037}
@@ -1002,6 +1054,8 @@ static int snd_vt1724_capture_spdif_open(struct snd_pcm_substream *substream)
1002 VT1724_BUFFER_ALIGN); 1054 VT1724_BUFFER_ALIGN);
1003 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1055 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1004 VT1724_BUFFER_ALIGN); 1056 VT1724_BUFFER_ALIGN);
1057 if (ice->spdif.ops.open)
1058 ice->spdif.ops.open(ice, substream);
1005 return 0; 1059 return 0;
1006} 1060}
1007 1061
@@ -1010,8 +1064,10 @@ static int snd_vt1724_capture_spdif_close(struct snd_pcm_substream *substream)
1010 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1064 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1011 1065
1012 if (PRO_RATE_RESET) 1066 if (PRO_RATE_RESET)
1013 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 1067 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1014 ice->capture_con_substream = NULL; 1068 ice->capture_con_substream = NULL;
1069 if (ice->spdif.ops.close)
1070 ice->spdif.ops.close(ice, substream);
1015 1071
1016 return 0; 1072 return 0;
1017} 1073}
@@ -1154,7 +1210,7 @@ static int snd_vt1724_playback_indep_close(struct snd_pcm_substream *substream)
1154 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 1210 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
1155 1211
1156 if (PRO_RATE_RESET) 1212 if (PRO_RATE_RESET)
1157 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); 1213 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 0);
1158 ice->playback_con_substream_ds[substream->number] = NULL; 1214 ice->playback_con_substream_ds[substream->number] = NULL;
1159 ice->pcm_reserved[substream->number] = NULL; 1215 ice->pcm_reserved[substream->number] = NULL;
1160 1216
@@ -1572,50 +1628,18 @@ int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol,
1572static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol, 1628static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
1573 struct snd_ctl_elem_info *uinfo) 1629 struct snd_ctl_elem_info *uinfo)
1574{ 1630{
1575 static const char * const texts_1724[] = {
1576 "8000", /* 0: 6 */
1577 "9600", /* 1: 3 */
1578 "11025", /* 2: 10 */
1579 "12000", /* 3: 2 */
1580 "16000", /* 4: 5 */
1581 "22050", /* 5: 9 */
1582 "24000", /* 6: 1 */
1583 "32000", /* 7: 4 */
1584 "44100", /* 8: 8 */
1585 "48000", /* 9: 0 */
1586 "64000", /* 10: 15 */
1587 "88200", /* 11: 11 */
1588 "96000", /* 12: 7 */
1589 "176400", /* 13: 12 */
1590 "192000", /* 14: 14 */
1591 "IEC958 Input", /* 15: -- */
1592 };
1593 static const char * const texts_1720[] = {
1594 "8000", /* 0: 6 */
1595 "9600", /* 1: 3 */
1596 "11025", /* 2: 10 */
1597 "12000", /* 3: 2 */
1598 "16000", /* 4: 5 */
1599 "22050", /* 5: 9 */
1600 "24000", /* 6: 1 */
1601 "32000", /* 7: 4 */
1602 "44100", /* 8: 8 */
1603 "48000", /* 9: 0 */
1604 "64000", /* 10: 15 */
1605 "88200", /* 11: 11 */
1606 "96000", /* 12: 7 */
1607 "IEC958 Input", /* 13: -- */
1608 };
1609 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1631 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1610 1632
1611 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1633 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1612 uinfo->count = 1; 1634 uinfo->count = 1;
1613 uinfo->value.enumerated.items = ice->vt1720 ? 14 : 16; 1635 uinfo->value.enumerated.items = ice->hw_rates->count + 1;
1614 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1636 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1615 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1637 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
1616 strcpy(uinfo->value.enumerated.name, 1638 if (uinfo->value.enumerated.item == uinfo->value.enumerated.items - 1)
1617 ice->vt1720 ? texts_1720[uinfo->value.enumerated.item] : 1639 strcpy(uinfo->value.enumerated.name, "IEC958 Input");
1618 texts_1724[uinfo->value.enumerated.item]); 1640 else
1641 sprintf(uinfo->value.enumerated.name, "%d",
1642 ice->hw_rates->list[uinfo->value.enumerated.item]);
1619 return 0; 1643 return 0;
1620} 1644}
1621 1645
@@ -1623,68 +1647,79 @@ static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol *kcontrol,
1623 struct snd_ctl_elem_value *ucontrol) 1647 struct snd_ctl_elem_value *ucontrol)
1624{ 1648{
1625 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1649 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1626 static const unsigned char xlate[16] = { 1650 unsigned int i, rate;
1627 9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 13, 255, 14, 10
1628 };
1629 unsigned char val;
1630 1651
1631 spin_lock_irq(&ice->reg_lock); 1652 spin_lock_irq(&ice->reg_lock);
1632 if (is_spdif_master(ice)) { 1653 if (ice->is_spdif_master(ice)) {
1633 ucontrol->value.enumerated.item[0] = ice->vt1720 ? 13 : 15; 1654 ucontrol->value.enumerated.item[0] = ice->hw_rates->count;
1634 } else { 1655 } else {
1635 val = xlate[inb(ICEMT1724(ice, RATE)) & 15]; 1656 rate = ice->get_rate(ice);
1636 if (val == 255) { 1657 ucontrol->value.enumerated.item[0] = 0;
1637 snd_BUG(); 1658 for (i = 0; i < ice->hw_rates->count; i++) {
1638 val = 0; 1659 if (ice->hw_rates->list[i] == rate) {
1660 ucontrol->value.enumerated.item[0] = i;
1661 break;
1662 }
1639 } 1663 }
1640 ucontrol->value.enumerated.item[0] = val;
1641 } 1664 }
1642 spin_unlock_irq(&ice->reg_lock); 1665 spin_unlock_irq(&ice->reg_lock);
1643 return 0; 1666 return 0;
1644} 1667}
1645 1668
1669/* setting clock to external - SPDIF */
1670static void stdclock_set_spdif_clock(struct snd_ice1712 *ice)
1671{
1672 unsigned char oval;
1673 unsigned char i2s_oval;
1674 oval = inb(ICEMT1724(ice, RATE));
1675 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
1676 /* setting 256fs */
1677 i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT));
1678 outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X, ICEMT1724(ice, I2S_FORMAT));
1679}
1680
1646static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol, 1681static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1647 struct snd_ctl_elem_value *ucontrol) 1682 struct snd_ctl_elem_value *ucontrol)
1648{ 1683{
1649 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 1684 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
1650 unsigned char oval; 1685 unsigned int old_rate, new_rate;
1651 int rate; 1686 unsigned int item = ucontrol->value.enumerated.item[0];
1652 int change = 0; 1687 unsigned int spdif = ice->hw_rates->count;
1653 int spdif = ice->vt1720 ? 13 : 15; 1688
1689 if (item > spdif)
1690 return -EINVAL;
1654 1691
1655 spin_lock_irq(&ice->reg_lock); 1692 spin_lock_irq(&ice->reg_lock);
1656 oval = inb(ICEMT1724(ice, RATE)); 1693 if (ice->is_spdif_master(ice))
1657 if (ucontrol->value.enumerated.item[0] == spdif) { 1694 old_rate = 0;
1658 unsigned char i2s_oval; 1695 else
1659 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE)); 1696 old_rate = ice->get_rate(ice);
1660 /* setting 256fs */ 1697 if (item == spdif) {
1661 i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT)); 1698 /* switching to external clock via SPDIF */
1662 outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X, 1699 ice->set_spdif_clock(ice);
1663 ICEMT1724(ice, I2S_FORMAT)); 1700 new_rate = 0;
1664 } else { 1701 } else {
1665 rate = rates[ucontrol->value.integer.value[0] % 15]; 1702 /* internal on-card clock */
1666 if (rate <= get_max_rate(ice)) { 1703 new_rate = ice->hw_rates->list[item];
1667 PRO_RATE_DEFAULT = rate; 1704 ice->pro_rate_default = new_rate;
1668 spin_unlock_irq(&ice->reg_lock); 1705 spin_unlock_irq(&ice->reg_lock);
1669 snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 1); 1706 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1);
1670 spin_lock_irq(&ice->reg_lock); 1707 spin_lock_irq(&ice->reg_lock);
1671 }
1672 } 1708 }
1673 change = inb(ICEMT1724(ice, RATE)) != oval;
1674 spin_unlock_irq(&ice->reg_lock); 1709 spin_unlock_irq(&ice->reg_lock);
1675 1710
1676 if ((oval & VT1724_SPDIF_MASTER) != 1711 /* the first reset to the SPDIF master mode? */
1677 (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER)) { 1712 if (old_rate != new_rate && !new_rate) {
1678 /* notify akm chips as well */ 1713 /* notify akm chips as well */
1679 if (is_spdif_master(ice)) { 1714 unsigned int i;
1680 unsigned int i; 1715 if (ice->gpio.set_pro_rate)
1681 for (i = 0; i < ice->akm_codecs; i++) { 1716 ice->gpio.set_pro_rate(ice, 0);
1682 if (ice->akm[i].ops.set_rate_val) 1717 for (i = 0; i < ice->akm_codecs; i++) {
1683 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0); 1718 if (ice->akm[i].ops.set_rate_val)
1684 } 1719 ice->akm[i].ops.set_rate_val(&ice->akm[i], 0);
1685 } 1720 }
1686 } 1721 }
1687 return change; 1722 return old_rate != new_rate;
1688} 1723}
1689 1724
1690static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = { 1725static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = {
@@ -2065,12 +2100,16 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2065 2100
2066 2101
2067 2102
2068static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice) 2103static void __devinit snd_vt1724_chip_reset(struct snd_ice1712 *ice)
2069{ 2104{
2070 outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); 2105 outb(VT1724_RESET , ICEREG1724(ice, CONTROL));
2071 udelay(200); 2106 msleep(10);
2072 outb(0, ICEREG1724(ice, CONTROL)); 2107 outb(0, ICEREG1724(ice, CONTROL));
2073 udelay(200); 2108 msleep(10);
2109}
2110
2111static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice)
2112{
2074 outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG)); 2113 outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG));
2075 outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG)); 2114 outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG));
2076 outb(ice->eeprom.data[ICE_EEP2_I2S], ICEREG1724(ice, I2S_FEATURES)); 2115 outb(ice->eeprom.data[ICE_EEP2_I2S], ICEREG1724(ice, I2S_FEATURES));
@@ -2169,10 +2208,8 @@ static int snd_vt1724_free(struct snd_ice1712 *ice)
2169 outb(0xff, ICEREG1724(ice, IRQMASK)); 2208 outb(0xff, ICEREG1724(ice, IRQMASK));
2170 /* --- */ 2209 /* --- */
2171 __hw_end: 2210 __hw_end:
2172 if (ice->irq >= 0) { 2211 if (ice->irq >= 0)
2173 synchronize_irq(ice->irq);
2174 free_irq(ice->irq, ice); 2212 free_irq(ice->irq, ice);
2175 }
2176 pci_release_regions(ice->pci); 2213 pci_release_regions(ice->pci);
2177 snd_ice1712_akm4xxx_free(ice); 2214 snd_ice1712_akm4xxx_free(ice);
2178 pci_disable_device(ice->pci); 2215 pci_disable_device(ice->pci);
@@ -2243,6 +2280,7 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2243 2280
2244 ice->irq = pci->irq; 2281 ice->irq = pci->irq;
2245 2282
2283 snd_vt1724_chip_reset(ice);
2246 if (snd_vt1724_read_eeprom(ice, modelname) < 0) { 2284 if (snd_vt1724_read_eeprom(ice, modelname) < 0) {
2247 snd_vt1724_free(ice); 2285 snd_vt1724_free(ice);
2248 return -EIO; 2286 return -EIO;
@@ -2253,10 +2291,7 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2253 } 2291 }
2254 2292
2255 /* unmask used interrupts */ 2293 /* unmask used interrupts */
2256 if (! (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401)) 2294 mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX;
2257 mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX;
2258 else
2259 mask = 0;
2260 outb(mask, ICEREG1724(ice, IRQMASK)); 2295 outb(mask, ICEREG1724(ice, IRQMASK));
2261 /* don't handle FIFO overrun/underruns (just yet), 2296 /* don't handle FIFO overrun/underruns (just yet),
2262 * since they cause machine lockups 2297 * since they cause machine lockups
@@ -2335,6 +2370,19 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2335 * was called so in ice1712 driver, and vt1724 driver is derived from 2370 * was called so in ice1712 driver, and vt1724 driver is derived from
2336 * ice1712 driver. 2371 * ice1712 driver.
2337 */ 2372 */
2373 ice->pro_rate_default = PRO_RATE_DEFAULT;
2374 if (!ice->is_spdif_master)
2375 ice->is_spdif_master = stdclock_is_spdif_master;
2376 if (!ice->get_rate)
2377 ice->get_rate = stdclock_get_rate;
2378 if (!ice->set_rate)
2379 ice->set_rate = stdclock_set_rate;
2380 if (!ice->set_mclk)
2381 ice->set_mclk = stdclock_set_mclk;
2382 if (!ice->set_spdif_clock)
2383 ice->set_spdif_clock = stdclock_set_spdif_clock;
2384 if (!ice->hw_rates)
2385 set_std_hw_rates(ice);
2338 2386
2339 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) { 2387 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) {
2340 snd_card_free(card); 2388 snd_card_free(card);
@@ -2377,14 +2425,28 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2377 2425
2378 if (! c->no_mpu401) { 2426 if (! c->no_mpu401) {
2379 if (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401) { 2427 if (ice->eeprom.data[ICE_EEP2_SYSCONF] & VT1724_CFG_MPU401) {
2428 struct snd_mpu401 *mpu;
2380 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712, 2429 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712,
2381 ICEREG1724(ice, MPU_CTRL), 2430 ICEREG1724(ice, MPU_CTRL),
2382 MPU401_INFO_INTEGRATED, 2431 (MPU401_INFO_INTEGRATED |
2432 MPU401_INFO_NO_ACK |
2433 MPU401_INFO_TX_IRQ),
2383 ice->irq, 0, 2434 ice->irq, 0,
2384 &ice->rmidi[0])) < 0) { 2435 &ice->rmidi[0])) < 0) {
2385 snd_card_free(card); 2436 snd_card_free(card);
2386 return err; 2437 return err;
2387 } 2438 }
2439 mpu = ice->rmidi[0]->private_data;
2440 mpu->read = snd_vt1724_mpu401_read;
2441 mpu->write = snd_vt1724_mpu401_write;
2442 /* unmask MPU RX/TX irqs */
2443 outb(inb(ICEREG1724(ice, IRQMASK)) &
2444 ~(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX),
2445 ICEREG1724(ice, IRQMASK));
2446 /* set watermarks */
2447 outb(VT1724_MPU_RX_FIFO | 0x1,
2448 ICEREG1724(ice, MPU_FIFO_WM));
2449 outb(0x1, ICEREG1724(ice, MPU_FIFO_WM));
2388 } 2450 }
2389 } 2451 }
2390 2452
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index e8038c0ceb72..b4e0c16852a6 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -4,6 +4,8 @@
4 * Lowlevel functions for ESI Juli@ cards 4 * Lowlevel functions for ESI Juli@ cards
5 * 5 *
6 * Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz> 6 * Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz>
7 * 2008 Pavel Hofman <dustin@seznam.cz>
8 *
7 * 9 *
8 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -27,11 +29,11 @@
27#include <linux/init.h> 29#include <linux/init.h>
28#include <linux/slab.h> 30#include <linux/slab.h>
29#include <sound/core.h> 31#include <sound/core.h>
32#include <sound/tlv.h>
30 33
31#include "ice1712.h" 34#include "ice1712.h"
32#include "envy24ht.h" 35#include "envy24ht.h"
33#include "juli.h" 36#include "juli.h"
34
35struct juli_spec { 37struct juli_spec {
36 struct ak4114 *ak4114; 38 struct ak4114 *ak4114;
37 unsigned int analog: 1; 39 unsigned int analog: 1;
@@ -44,6 +46,32 @@ struct juli_spec {
44#define AK4358_ADDR 0x22 /* DAC */ 46#define AK4358_ADDR 0x22 /* DAC */
45 47
46/* 48/*
49 * Juli does not use the standard ICE1724 clock scheme. Juli's ice1724 chip is
50 * supplied by external clock provided by Xilinx array and MK73-1 PLL frequency
51 * multiplier. Actual frequency is set by ice1724 GPIOs hooked to the Xilinx.
52 *
53 * The clock circuitry is supplied by the two ice1724 crystals. This
54 * arrangement allows to generate independent clock signal for AK4114's input
55 * rate detection circuit. As a result, Juli, unlike most other
56 * ice1724+ak4114-based cards, detects spdif input rate correctly.
57 * This fact is applied in the driver, allowing to modify PCM stream rate
58 * parameter according to the actual input rate.
59 *
60 * Juli uses the remaining three stereo-channels of its DAC to optionally
61 * monitor analog input, digital input, and digital output. The corresponding
62 * I2S signals are routed by Xilinx, controlled by GPIOs.
63 *
64 * The master mute is implemented using output muting transistors (GPIO) in
65 * combination with smuting the DAC.
66 *
67 * The card itself has no HW master volume control, implemented using the
68 * vmaster control.
69 *
70 * TODO:
71 * researching and fixing the input monitors
72 */
73
74/*
47 * GPIO pins 75 * GPIO pins
48 */ 76 */
49#define GPIO_FREQ_MASK (3<<0) 77#define GPIO_FREQ_MASK (3<<0)
@@ -55,17 +83,82 @@ struct juli_spec {
55#define GPIO_MULTI_2X (1<<2) 83#define GPIO_MULTI_2X (1<<2)
56#define GPIO_MULTI_1X (2<<2) /* also external */ 84#define GPIO_MULTI_1X (2<<2) /* also external */
57#define GPIO_MULTI_HALF (3<<2) 85#define GPIO_MULTI_HALF (3<<2)
58#define GPIO_INTERNAL_CLOCK (1<<4) 86#define GPIO_INTERNAL_CLOCK (1<<4) /* 0 = external, 1 = internal */
87#define GPIO_CLOCK_MASK (1<<4)
59#define GPIO_ANALOG_PRESENT (1<<5) /* RO only: 0 = present */ 88#define GPIO_ANALOG_PRESENT (1<<5) /* RO only: 0 = present */
60#define GPIO_RXMCLK_SEL (1<<7) /* must be 0 */ 89#define GPIO_RXMCLK_SEL (1<<7) /* must be 0 */
61#define GPIO_AK5385A_CKS0 (1<<8) 90#define GPIO_AK5385A_CKS0 (1<<8)
62#define GPIO_AK5385A_DFS0 (1<<9) /* swapped with DFS1 according doc? */ 91#define GPIO_AK5385A_DFS1 (1<<9)
63#define GPIO_AK5385A_DFS1 (1<<10) 92#define GPIO_AK5385A_DFS0 (1<<10)
64#define GPIO_DIGOUT_MONITOR (1<<11) /* 1 = active */ 93#define GPIO_DIGOUT_MONITOR (1<<11) /* 1 = active */
65#define GPIO_DIGIN_MONITOR (1<<12) /* 1 = active */ 94#define GPIO_DIGIN_MONITOR (1<<12) /* 1 = active */
66#define GPIO_ANAIN_MONITOR (1<<13) /* 1 = active */ 95#define GPIO_ANAIN_MONITOR (1<<13) /* 1 = active */
67#define GPIO_AK5385A_MCLK (1<<14) /* must be 0 */ 96#define GPIO_AK5385A_CKS1 (1<<14) /* must be 0 */
68#define GPIO_MUTE_CONTROL (1<<15) /* 0 = off, 1 = on */ 97#define GPIO_MUTE_CONTROL (1<<15) /* output mute, 1 = muted */
98
99#define GPIO_RATE_MASK (GPIO_FREQ_MASK | GPIO_MULTI_MASK | \
100 GPIO_CLOCK_MASK)
101#define GPIO_AK5385A_MASK (GPIO_AK5385A_CKS0 | GPIO_AK5385A_DFS0 | \
102 GPIO_AK5385A_DFS1 | GPIO_AK5385A_CKS1)
103
104#define JULI_PCM_RATE (SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
105 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
106 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | \
107 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | \
108 SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000)
109
110#define GPIO_RATE_16000 (GPIO_FREQ_32KHZ | GPIO_MULTI_HALF | \
111 GPIO_INTERNAL_CLOCK)
112#define GPIO_RATE_22050 (GPIO_FREQ_44KHZ | GPIO_MULTI_HALF | \
113 GPIO_INTERNAL_CLOCK)
114#define GPIO_RATE_24000 (GPIO_FREQ_48KHZ | GPIO_MULTI_HALF | \
115 GPIO_INTERNAL_CLOCK)
116#define GPIO_RATE_32000 (GPIO_FREQ_32KHZ | GPIO_MULTI_1X | \
117 GPIO_INTERNAL_CLOCK)
118#define GPIO_RATE_44100 (GPIO_FREQ_44KHZ | GPIO_MULTI_1X | \
119 GPIO_INTERNAL_CLOCK)
120#define GPIO_RATE_48000 (GPIO_FREQ_48KHZ | GPIO_MULTI_1X | \
121 GPIO_INTERNAL_CLOCK)
122#define GPIO_RATE_64000 (GPIO_FREQ_32KHZ | GPIO_MULTI_2X | \
123 GPIO_INTERNAL_CLOCK)
124#define GPIO_RATE_88200 (GPIO_FREQ_44KHZ | GPIO_MULTI_2X | \
125 GPIO_INTERNAL_CLOCK)
126#define GPIO_RATE_96000 (GPIO_FREQ_48KHZ | GPIO_MULTI_2X | \
127 GPIO_INTERNAL_CLOCK)
128#define GPIO_RATE_176400 (GPIO_FREQ_44KHZ | GPIO_MULTI_4X | \
129 GPIO_INTERNAL_CLOCK)
130#define GPIO_RATE_192000 (GPIO_FREQ_48KHZ | GPIO_MULTI_4X | \
131 GPIO_INTERNAL_CLOCK)
132
133/*
134 * Initial setup of the conversion array GPIO <-> rate
135 */
136static unsigned int juli_rates[] = {
137 16000, 22050, 24000, 32000,
138 44100, 48000, 64000, 88200,
139 96000, 176400, 192000,
140};
141
142static unsigned int gpio_vals[] = {
143 GPIO_RATE_16000, GPIO_RATE_22050, GPIO_RATE_24000, GPIO_RATE_32000,
144 GPIO_RATE_44100, GPIO_RATE_48000, GPIO_RATE_64000, GPIO_RATE_88200,
145 GPIO_RATE_96000, GPIO_RATE_176400, GPIO_RATE_192000,
146};
147
148static struct snd_pcm_hw_constraint_list juli_rates_info = {
149 .count = ARRAY_SIZE(juli_rates),
150 .list = juli_rates,
151 .mask = 0,
152};
153
154static int get_gpio_val(int rate)
155{
156 int i;
157 for (i = 0; i < ARRAY_SIZE(juli_rates); i++)
158 if (juli_rates[i] == rate)
159 return gpio_vals[i];
160 return 0;
161}
69 162
70static void juli_ak4114_write(void *private_data, unsigned char reg, unsigned char val) 163static void juli_ak4114_write(void *private_data, unsigned char reg, unsigned char val)
71{ 164{
@@ -78,6 +171,27 @@ static unsigned char juli_ak4114_read(void *private_data, unsigned char reg)
78} 171}
79 172
80/* 173/*
174 * If SPDIF capture and slaved to SPDIF-IN, setting runtime rate
175 * to the external rate
176 */
177static void juli_spdif_in_open(struct snd_ice1712 *ice,
178 struct snd_pcm_substream *substream)
179{
180 struct juli_spec *spec = ice->spec;
181 struct snd_pcm_runtime *runtime = substream->runtime;
182 int rate;
183
184 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
185 !ice->is_spdif_master(ice))
186 return;
187 rate = snd_ak4114_external_rate(spec->ak4114);
188 if (rate >= runtime->hw.rate_min && rate <= runtime->hw.rate_max) {
189 runtime->hw.rate_min = rate;
190 runtime->hw.rate_max = rate;
191 }
192}
193
194/*
81 * AK4358 section 195 * AK4358 section
82 */ 196 */
83 197
@@ -99,57 +213,285 @@ static void juli_akm_write(struct snd_akm4xxx *ak, int chip,
99} 213}
100 214
101/* 215/*
102 * change the rate of envy24HT, AK4358 216 * change the rate of envy24HT, AK4358, AK5385
103 */ 217 */
104static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) 218static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
105{ 219{
106 unsigned char old, tmp, dfs; 220 unsigned char old, tmp, ak4358_dfs;
221 unsigned int ak5385_pins, old_gpio, new_gpio;
222 struct snd_ice1712 *ice = ak->private_data[0];
223 struct juli_spec *spec = ice->spec;
107 224
108 if (rate == 0) /* no hint - S/PDIF input is master, simply return */ 225 if (rate == 0) /* no hint - S/PDIF input is master or the new spdif
226 input rate undetected, simply return */
109 return; 227 return;
110 228
111 /* adjust DFS on codecs */ 229 /* adjust DFS on codecs */
112 if (rate > 96000) 230 if (rate > 96000) {
113 dfs = 2; 231 ak4358_dfs = 2;
114 else if (rate > 48000) 232 ak5385_pins = GPIO_AK5385A_DFS1 | GPIO_AK5385A_CKS0;
115 dfs = 1; 233 } else if (rate > 48000) {
116 else 234 ak4358_dfs = 1;
117 dfs = 0; 235 ak5385_pins = GPIO_AK5385A_DFS0;
118 236 } else {
237 ak4358_dfs = 0;
238 ak5385_pins = 0;
239 }
240 /* AK5385 first, since it requires cold reset affecting both codecs */
241 old_gpio = ice->gpio.get_data(ice);
242 new_gpio = (old_gpio & ~GPIO_AK5385A_MASK) | ak5385_pins;
243 /* printk(KERN_DEBUG "JULI - ak5385 set_rate_val: new gpio 0x%x\n",
244 new_gpio); */
245 ice->gpio.set_data(ice, new_gpio);
246
247 /* cold reset */
248 old = inb(ICEMT1724(ice, AC97_CMD));
249 outb(old | VT1724_AC97_COLD, ICEMT1724(ice, AC97_CMD));
250 udelay(1);
251 outb(old & ~VT1724_AC97_COLD, ICEMT1724(ice, AC97_CMD));
252
253 /* AK4358 */
254 /* set new value, reset DFS */
119 tmp = snd_akm4xxx_get(ak, 0, 2); 255 tmp = snd_akm4xxx_get(ak, 0, 2);
120 old = (tmp >> 4) & 0x03;
121 if (old == dfs)
122 return;
123 /* reset DFS */
124 snd_akm4xxx_reset(ak, 1); 256 snd_akm4xxx_reset(ak, 1);
125 tmp = snd_akm4xxx_get(ak, 0, 2); 257 tmp = snd_akm4xxx_get(ak, 0, 2);
126 tmp &= ~(0x03 << 4); 258 tmp &= ~(0x03 << 4);
127 tmp |= dfs << 4; 259 tmp |= ak4358_dfs << 4;
128 snd_akm4xxx_set(ak, 0, 2, tmp); 260 snd_akm4xxx_set(ak, 0, 2, tmp);
129 snd_akm4xxx_reset(ak, 0); 261 snd_akm4xxx_reset(ak, 0);
262
263 /* reinit ak4114 */
264 snd_ak4114_reinit(spec->ak4114);
130} 265}
131 266
267#define AK_DAC(xname, xch) { .name = xname, .num_channels = xch }
268#define PCM_VOLUME "PCM Playback Volume"
269#define MONITOR_AN_IN_VOLUME "Monitor Analog In Volume"
270#define MONITOR_DIG_IN_VOLUME "Monitor Digital In Volume"
271#define MONITOR_DIG_OUT_VOLUME "Monitor Digital Out Volume"
272
273static const struct snd_akm4xxx_dac_channel juli_dac[] = {
274 AK_DAC(PCM_VOLUME, 2),
275 AK_DAC(MONITOR_AN_IN_VOLUME, 2),
276 AK_DAC(MONITOR_DIG_OUT_VOLUME, 2),
277 AK_DAC(MONITOR_DIG_IN_VOLUME, 2),
278};
279
280
132static struct snd_akm4xxx akm_juli_dac __devinitdata = { 281static struct snd_akm4xxx akm_juli_dac __devinitdata = {
133 .type = SND_AK4358, 282 .type = SND_AK4358,
134 .num_dacs = 2, 283 .num_dacs = 8, /* DAC1 - analog out
284 DAC2 - analog in monitor
285 DAC3 - digital out monitor
286 DAC4 - digital in monitor
287 */
135 .ops = { 288 .ops = {
136 .lock = juli_akm_lock, 289 .lock = juli_akm_lock,
137 .unlock = juli_akm_unlock, 290 .unlock = juli_akm_unlock,
138 .write = juli_akm_write, 291 .write = juli_akm_write,
139 .set_rate_val = juli_akm_set_rate_val 292 .set_rate_val = juli_akm_set_rate_val
293 },
294 .dac_info = juli_dac,
295};
296
297#define juli_mute_info snd_ctl_boolean_mono_info
298
299static int juli_mute_get(struct snd_kcontrol *kcontrol,
300 struct snd_ctl_elem_value *ucontrol)
301{
302 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
303 unsigned int val;
304 val = ice->gpio.get_data(ice) & (unsigned int) kcontrol->private_value;
305 if (kcontrol->private_value == GPIO_MUTE_CONTROL)
306 /* val 0 = signal on */
307 ucontrol->value.integer.value[0] = (val) ? 0 : 1;
308 else
309 /* val 1 = signal on */
310 ucontrol->value.integer.value[0] = (val) ? 1 : 0;
311 return 0;
312}
313
314static int juli_mute_put(struct snd_kcontrol *kcontrol,
315 struct snd_ctl_elem_value *ucontrol)
316{
317 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
318 unsigned int old_gpio, new_gpio;
319 old_gpio = ice->gpio.get_data(ice);
320 if (ucontrol->value.integer.value[0]) {
321 /* unmute */
322 if (kcontrol->private_value == GPIO_MUTE_CONTROL) {
323 /* 0 = signal on */
324 new_gpio = old_gpio & ~GPIO_MUTE_CONTROL;
325 /* un-smuting DAC */
326 snd_akm4xxx_write(ice->akm, 0, 0x01, 0x01);
327 } else
328 /* 1 = signal on */
329 new_gpio = old_gpio |
330 (unsigned int) kcontrol->private_value;
331 } else {
332 /* mute */
333 if (kcontrol->private_value == GPIO_MUTE_CONTROL) {
334 /* 1 = signal off */
335 new_gpio = old_gpio | GPIO_MUTE_CONTROL;
336 /* smuting DAC */
337 snd_akm4xxx_write(ice->akm, 0, 0x01, 0x03);
338 } else
339 /* 0 = signal off */
340 new_gpio = old_gpio &
341 ~((unsigned int) kcontrol->private_value);
342 }
343 /* printk("JULI - mute/unmute: control_value: 0x%x, old_gpio: 0x%x, \
344 new_gpio 0x%x\n",
345 (unsigned int)ucontrol->value.integer.value[0], old_gpio,
346 new_gpio); */
347 if (old_gpio != new_gpio) {
348 ice->gpio.set_data(ice, new_gpio);
349 return 1;
350 }
351 /* no change */
352 return 0;
353}
354
355static struct snd_kcontrol_new juli_mute_controls[] __devinitdata = {
356 {
357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
358 .name = "Master Playback Switch",
359 .info = juli_mute_info,
360 .get = juli_mute_get,
361 .put = juli_mute_put,
362 .private_value = GPIO_MUTE_CONTROL,
363 },
364 /* Although the following functionality respects the succint NDA'd
365 * documentation from the card manufacturer, and the same way of
366 * operation is coded in OSS Juli driver, only Digital Out monitor
367 * seems to work. Surprisingly, Analog input monitor outputs Digital
368 * output data. The two are independent, as enabling both doubles
369 * volume of the monitor sound.
370 *
371 * Checking traces on the board suggests the functionality described
372 * by the manufacturer is correct - I2S from ADC and AK4114
373 * go to ICE as well as to Xilinx, I2S inputs of DAC2,3,4 (the monitor
374 * inputs) are fed from Xilinx.
375 *
376 * I even checked traces on board and coded a support in driver for
377 * an alternative possiblity - the unused I2S ICE output channels
378 * switched to HW-IN/SPDIF-IN and providing the monitoring signal to
379 * the DAC - to no avail. The I2S outputs seem to be unconnected.
380 *
381 * The windows driver supports the monitoring correctly.
382 */
383 {
384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
385 .name = "Monitor Analog In Switch",
386 .info = juli_mute_info,
387 .get = juli_mute_get,
388 .put = juli_mute_put,
389 .private_value = GPIO_ANAIN_MONITOR,
390 },
391 {
392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
393 .name = "Monitor Digital Out Switch",
394 .info = juli_mute_info,
395 .get = juli_mute_get,
396 .put = juli_mute_put,
397 .private_value = GPIO_DIGOUT_MONITOR,
398 },
399 {
400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
401 .name = "Monitor Digital In Switch",
402 .info = juli_mute_info,
403 .get = juli_mute_get,
404 .put = juli_mute_put,
405 .private_value = GPIO_DIGIN_MONITOR,
406 },
407};
408
409
410static void ak4358_proc_regs_read(struct snd_info_entry *entry,
411 struct snd_info_buffer *buffer)
412{
413 struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data;
414 int reg, val;
415 for (reg = 0; reg <= 0xf; reg++) {
416 val = snd_akm4xxx_get(ice->akm, 0, reg);
417 snd_iprintf(buffer, "0x%02x = 0x%02x\n", reg, val);
140 } 418 }
419}
420
421static void ak4358_proc_init(struct snd_ice1712 *ice)
422{
423 struct snd_info_entry *entry;
424 if (!snd_card_proc_new(ice->card, "ak4358_codec", &entry))
425 snd_info_set_text_ops(entry, ice, ak4358_proc_regs_read);
426}
427
428static char *slave_vols[] __devinitdata = {
429 PCM_VOLUME,
430 MONITOR_AN_IN_VOLUME,
431 MONITOR_DIG_IN_VOLUME,
432 MONITOR_DIG_OUT_VOLUME,
433 NULL
141}; 434};
142 435
436static __devinitdata
437DECLARE_TLV_DB_SCALE(juli_master_db_scale, -6350, 50, 1);
438
439static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card,
440 const char *name)
441{
442 struct snd_ctl_elem_id sid;
443 memset(&sid, 0, sizeof(sid));
444 /* FIXME: strcpy is bad. */
445 strcpy(sid.name, name);
446 sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
447 return snd_ctl_find_id(card, &sid);
448}
449
450static void __devinit add_slaves(struct snd_card *card,
451 struct snd_kcontrol *master, char **list)
452{
453 for (; *list; list++) {
454 struct snd_kcontrol *slave = ctl_find(card, *list);
455 /* printk(KERN_DEBUG "add_slaves - %s\n", *list); */
456 if (slave) {
457 /* printk(KERN_DEBUG "slave %s found\n", *list); */
458 snd_ctl_add_slave(master, slave);
459 }
460 }
461}
462
143static int __devinit juli_add_controls(struct snd_ice1712 *ice) 463static int __devinit juli_add_controls(struct snd_ice1712 *ice)
144{ 464{
145 struct juli_spec *spec = ice->spec; 465 struct juli_spec *spec = ice->spec;
146 int err; 466 int err;
467 unsigned int i;
468 struct snd_kcontrol *vmaster;
469
147 err = snd_ice1712_akm4xxx_build_controls(ice); 470 err = snd_ice1712_akm4xxx_build_controls(ice);
148 if (err < 0) 471 if (err < 0)
149 return err; 472 return err;
473
474 for (i = 0; i < ARRAY_SIZE(juli_mute_controls); i++) {
475 err = snd_ctl_add(ice->card,
476 snd_ctl_new1(&juli_mute_controls[i], ice));
477 if (err < 0)
478 return err;
479 }
480 /* Create virtual master control */
481 vmaster = snd_ctl_make_virtual_master("Master Playback Volume",
482 juli_master_db_scale);
483 if (!vmaster)
484 return -ENOMEM;
485 add_slaves(ice->card, vmaster, slave_vols);
486 err = snd_ctl_add(ice->card, vmaster);
487 if (err < 0)
488 return err;
489
150 /* only capture SPDIF over AK4114 */ 490 /* only capture SPDIF over AK4114 */
151 err = snd_ak4114_build(spec->ak4114, NULL, 491 err = snd_ak4114_build(spec->ak4114, NULL,
152 ice->pcm_pro->streams[SNDRV_PCM_STREAM_CAPTURE].substream); 492 ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
493
494 ak4358_proc_init(ice);
153 if (err < 0) 495 if (err < 0)
154 return err; 496 return err;
155 return 0; 497 return 0;
@@ -158,6 +500,74 @@ static int __devinit juli_add_controls(struct snd_ice1712 *ice)
158/* 500/*
159 * initialize the chip 501 * initialize the chip
160 */ 502 */
503
504static inline int juli_is_spdif_master(struct snd_ice1712 *ice)
505{
506 return (ice->gpio.get_data(ice) & GPIO_INTERNAL_CLOCK) ? 0 : 1;
507}
508
509static unsigned int juli_get_rate(struct snd_ice1712 *ice)
510{
511 int i;
512 unsigned char result;
513
514 result = ice->gpio.get_data(ice) & GPIO_RATE_MASK;
515 for (i = 0; i < ARRAY_SIZE(gpio_vals); i++)
516 if (gpio_vals[i] == result)
517 return juli_rates[i];
518 return 0;
519}
520
521/* setting new rate */
522static void juli_set_rate(struct snd_ice1712 *ice, unsigned int rate)
523{
524 unsigned int old, new;
525 unsigned char val;
526
527 old = ice->gpio.get_data(ice);
528 new = (old & ~GPIO_RATE_MASK) | get_gpio_val(rate);
529 /* printk(KERN_DEBUG "JULI - set_rate: old %x, new %x\n",
530 old & GPIO_RATE_MASK,
531 new & GPIO_RATE_MASK); */
532
533 ice->gpio.set_data(ice, new);
534 /* switching to external clock - supplied by external circuits */
535 val = inb(ICEMT1724(ice, RATE));
536 outb(val | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
537}
538
539static inline unsigned char juli_set_mclk(struct snd_ice1712 *ice,
540 unsigned int rate)
541{
542 /* no change in master clock */
543 return 0;
544}
545
546/* setting clock to external - SPDIF */
547static void juli_set_spdif_clock(struct snd_ice1712 *ice)
548{
549 unsigned int old;
550 old = ice->gpio.get_data(ice);
551 /* external clock (= 0), multiply 1x, 48kHz */
552 ice->gpio.set_data(ice, (old & ~GPIO_RATE_MASK) | GPIO_MULTI_1X |
553 GPIO_FREQ_48KHZ);
554}
555
556/* Called when ak4114 detects change in the input SPDIF stream */
557static void juli_ak4114_change(struct ak4114 *ak4114, unsigned char c0,
558 unsigned char c1)
559{
560 struct snd_ice1712 *ice = ak4114->change_callback_private;
561 int rate;
562 if (ice->is_spdif_master(ice) && c1) {
563 /* only for SPDIF master mode, rate was changed */
564 rate = snd_ak4114_external_rate(ak4114);
565 /* printk(KERN_DEBUG "ak4114 - input rate changed to %d\n",
566 rate); */
567 juli_akm_set_rate_val(ice->akm, rate);
568 }
569}
570
161static int __devinit juli_init(struct snd_ice1712 *ice) 571static int __devinit juli_init(struct snd_ice1712 *ice)
162{ 572{
163 static const unsigned char ak4114_init_vals[] = { 573 static const unsigned char ak4114_init_vals[] = {
@@ -187,6 +597,11 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
187 ice, &spec->ak4114); 597 ice, &spec->ak4114);
188 if (err < 0) 598 if (err < 0)
189 return err; 599 return err;
600 /* callback for codecs rate setting */
601 spec->ak4114->change_callback = juli_ak4114_change;
602 spec->ak4114->change_callback_private = ice;
603 /* AK4114 in Juli can detect external rate correctly */
604 spec->ak4114->check_flags = 0;
190 605
191#if 0 606#if 0
192 /* it seems that the analog doughter board detection does not work 607 /* it seems that the analog doughter board detection does not work
@@ -210,6 +625,15 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
210 return err; 625 return err;
211 } 626 }
212 627
628 /* juli is clocked by Xilinx array */
629 ice->hw_rates = &juli_rates_info;
630 ice->is_spdif_master = juli_is_spdif_master;
631 ice->get_rate = juli_get_rate;
632 ice->set_rate = juli_set_rate;
633 ice->set_mclk = juli_set_mclk;
634 ice->set_spdif_clock = juli_set_spdif_clock;
635
636 ice->spdif.ops.open = juli_spdif_in_open;
213 return 0; 637 return 0;
214} 638}
215 639
@@ -220,18 +644,20 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
220 */ 644 */
221 645
222static unsigned char juli_eeprom[] __devinitdata = { 646static unsigned char juli_eeprom[] __devinitdata = {
223 [ICE_EEP2_SYSCONF] = 0x20, /* clock 512, mpu401, 1xADC, 1xDACs */ 647 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, 1xADC, 1xDACs,
648 SPDIF in */
224 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 649 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
225 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 650 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
226 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 651 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
227 [ICE_EEP2_GPIO_DIR] = 0x9f, 652 [ICE_EEP2_GPIO_DIR] = 0x9f, /* 5, 6:inputs; 7, 4-0 outputs*/
228 [ICE_EEP2_GPIO_DIR1] = 0xff, 653 [ICE_EEP2_GPIO_DIR1] = 0xff,
229 [ICE_EEP2_GPIO_DIR2] = 0x7f, 654 [ICE_EEP2_GPIO_DIR2] = 0x7f,
230 [ICE_EEP2_GPIO_MASK] = 0x9f, 655 [ICE_EEP2_GPIO_MASK] = 0x60, /* 5, 6: locked; 7, 4-0 writable */
231 [ICE_EEP2_GPIO_MASK1] = 0xff, 656 [ICE_EEP2_GPIO_MASK1] = 0x00, /* 0-7 writable */
232 [ICE_EEP2_GPIO_MASK2] = 0x7f, 657 [ICE_EEP2_GPIO_MASK2] = 0x7f,
233 [ICE_EEP2_GPIO_STATE] = 0x16, /* internal clock, multiple 1x, 48kHz */ 658 [ICE_EEP2_GPIO_STATE] = GPIO_FREQ_48KHZ | GPIO_MULTI_1X |
234 [ICE_EEP2_GPIO_STATE1] = 0x80, /* mute */ 659 GPIO_INTERNAL_CLOCK, /* internal clock, multiple 1x, 48kHz*/
660 [ICE_EEP2_GPIO_STATE1] = 0x00, /* unmuted */
235 [ICE_EEP2_GPIO_STATE2] = 0x00, 661 [ICE_EEP2_GPIO_STATE2] = 0x00,
236}; 662};
237 663
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 4945c81e8a96..203cdc1bf8da 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -246,7 +246,7 @@ static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_val
246 wm_put(ice, WM_ADC_MUX, nval); 246 wm_put(ice, WM_ADC_MUX, nval);
247 } 247 }
248 mutex_unlock(&ice->gpio_mutex); 248 mutex_unlock(&ice->gpio_mutex);
249 return 0; 249 return change;
250} 250}
251 251
252/* 252/*
@@ -450,7 +450,7 @@ static int cs_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
450 change = 1; 450 change = 1;
451 } 451 }
452 mutex_unlock(&ice->gpio_mutex); 452 mutex_unlock(&ice->gpio_mutex);
453 return 0; 453 return change;
454} 454}
455 455
456 456
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 48cf40a8f32a..48d3679292a7 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -319,12 +319,11 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
319/* 319/*
320 * Handler for setting correct codec rate - called when rate change is detected 320 * Handler for setting correct codec rate - called when rate change is detected
321 */ 321 */
322static void stac9460_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) 322static void stac9460_set_rate_val(struct snd_ice1712 *ice, unsigned int rate)
323{ 323{
324 unsigned char old, new; 324 unsigned char old, new;
325 int idx; 325 int idx;
326 unsigned char changed[7]; 326 unsigned char changed[7];
327 struct snd_ice1712 *ice = ak->private_data[0];
328 struct prodigy192_spec *spec = ice->spec; 327 struct prodigy192_spec *spec = ice->spec;
329 328
330 if (rate == 0) /* no hint - S/PDIF input is master, simply return */ 329 if (rate == 0) /* no hint - S/PDIF input is master, simply return */
@@ -357,16 +356,6 @@ static void stac9460_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
357 mutex_unlock(&spec->mute_mutex); 356 mutex_unlock(&spec->mute_mutex);
358} 357}
359 358
360/* using akm infrastructure for setting rate of the codec */
361static struct snd_akm4xxx akmlike_stac9460 __devinitdata = {
362 .type = NON_AKM, /* special value */
363 .num_adcs = 6, /* not used in any way, just for completeness */
364 .num_dacs = 2,
365 .ops = {
366 .set_rate_val = stac9460_set_rate_val
367 }
368};
369
370 359
371static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0); 360static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
372static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); 361static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
@@ -642,12 +631,19 @@ static int prodigy192_ak4114_init(struct snd_ice1712 *ice)
642 0x41, 0x02, 0x2c, 0x00, 0x00 631 0x41, 0x02, 0x2c, 0x00, 0x00
643 }; 632 };
644 struct prodigy192_spec *spec = ice->spec; 633 struct prodigy192_spec *spec = ice->spec;
634 int err;
645 635
646 return snd_ak4114_create(ice->card, 636 err = snd_ak4114_create(ice->card,
647 prodigy192_ak4114_read, 637 prodigy192_ak4114_read,
648 prodigy192_ak4114_write, 638 prodigy192_ak4114_write,
649 ak4114_init_vals, ak4114_init_txcsb, 639 ak4114_init_vals, ak4114_init_txcsb,
650 ice, &spec->ak4114); 640 ice, &spec->ak4114);
641 if (err < 0)
642 return err;
643 /* AK4114 in Prodigy192 cannot detect external rate correctly.
644 * No reason to stop capture stream due to incorrect checks */
645 spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
646 return 0;
651} 647}
652 648
653static void stac9460_proc_regs_read(struct snd_info_entry *entry, 649static void stac9460_proc_regs_read(struct snd_info_entry *entry,
@@ -743,7 +739,6 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
743 }; 739 };
744 const unsigned short *p; 740 const unsigned short *p;
745 int err = 0; 741 int err = 0;
746 struct snd_akm4xxx *ak;
747 struct prodigy192_spec *spec; 742 struct prodigy192_spec *spec;
748 743
749 /* prodigy 192 */ 744 /* prodigy 192 */
@@ -761,15 +756,7 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
761 p = stac_inits_prodigy; 756 p = stac_inits_prodigy;
762 for (; *p != (unsigned short)-1; p += 2) 757 for (; *p != (unsigned short)-1; p += 2)
763 stac9460_put(ice, p[0], p[1]); 758 stac9460_put(ice, p[0], p[1]);
764 /* reusing the akm codecs infrastructure, 759 ice->gpio.set_pro_rate = stac9460_set_rate_val;
765 * for setting rate on stac9460 */
766 ak = ice->akm = kmalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
767 if (!ak)
768 return -ENOMEM;
769 ice->akm_codecs = 1;
770 err = snd_ice1712_akm4xxx_init(ak, &akmlike_stac9460, NULL, ice);
771 if (err < 0)
772 return err;
773 760
774 /* MI/ODI/O add on card with AK4114 */ 761 /* MI/ODI/O add on card with AK4114 */
775 if (prodigy192_miodio_exists(ice)) { 762 if (prodigy192_miodio_exists(ice)) {
@@ -825,10 +812,6 @@ struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {
825 .build_controls = prodigy192_add_controls, 812 .build_controls = prodigy192_add_controls,
826 .eeprom_size = sizeof(prodigy71_eeprom), 813 .eeprom_size = sizeof(prodigy71_eeprom),
827 .eeprom_data = prodigy71_eeprom, 814 .eeprom_data = prodigy71_eeprom,
828 /* the current MPU401 code loops infinitely
829 * when opening midi device
830 */
831 .no_mpu401 = 1,
832 }, 815 },
833 { } /* terminator */ 816 { } /* terminator */
834}; 817};
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index 301bf929acd9..4d2631434dc8 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -322,17 +322,23 @@ static struct snd_pt2258 ptc_revo51_volume;
322static void ap192_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) 322static void ap192_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
323{ 323{
324 struct snd_ice1712 *ice = ak->private_data[0]; 324 struct snd_ice1712 *ice = ak->private_data[0];
325 int dfs;
325 326
326 revo_set_rate_val(ak, rate); 327 revo_set_rate_val(ak, rate);
327 328
328#if 1 /* FIXME: do we need this procedure? */ 329 /* reset CKS */
329 /* reset DFS pin of AK5385A for ADC, too */ 330 snd_ice1712_gpio_write_bits(ice, 1 << 8, rate > 96000 ? 1 << 8 : 0);
330 /* DFS0 (pin 18) -- GPIO10 pin 77 */ 331 /* reset DFS pins of AK5385A for ADC, too */
331 snd_ice1712_save_gpio_status(ice); 332 if (rate > 96000)
332 snd_ice1712_gpio_write_bits(ice, 1 << 10, 333 dfs = 2;
333 rate > 48000 ? (1 << 10) : 0); 334 else if (rate > 48000)
334 snd_ice1712_restore_gpio_status(ice); 335 dfs = 1;
335#endif 336 else
337 dfs = 0;
338 snd_ice1712_gpio_write_bits(ice, 3 << 9, dfs << 9);
339 /* reset ADC */
340 snd_ice1712_gpio_write_bits(ice, 1 << 11, 0);
341 snd_ice1712_gpio_write_bits(ice, 1 << 11, 1 << 11);
336} 342}
337 343
338static const struct snd_akm4xxx_dac_channel ap192_dac[] = { 344static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
@@ -353,28 +359,20 @@ static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
353 .cif = 0, 359 .cif = 0,
354 .data_mask = VT1724_REVO_CDOUT, 360 .data_mask = VT1724_REVO_CDOUT,
355 .clk_mask = VT1724_REVO_CCLK, 361 .clk_mask = VT1724_REVO_CCLK,
356 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS3, 362 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
357 .cs_addr = VT1724_REVO_CS3, 363 .cs_addr = VT1724_REVO_CS1,
358 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS3, 364 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
359 .add_flags = VT1724_REVO_CCLK, /* high at init */ 365 .add_flags = VT1724_REVO_CCLK, /* high at init */
360 .mask_flags = 0, 366 .mask_flags = 0,
361}; 367};
362 368
363#if 0
364/* FIXME: ak4114 makes the sound much lower due to some confliction,
365 * so let's disable it right now...
366 */
367#define BUILD_AK4114_AP192
368#endif
369
370#ifdef BUILD_AK4114_AP192
371/* AK4114 support on Audiophile 192 */ 369/* AK4114 support on Audiophile 192 */
372/* CDTO (pin 32) -- GPIO2 pin 52 370/* CDTO (pin 32) -- GPIO2 pin 52
373 * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358) 371 * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358)
374 * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358) 372 * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358)
375 * CSN (pin 35) -- GPIO7 pin 59 373 * CSN (pin 35) -- GPIO7 pin 59
376 */ 374 */
377#define AK4114_ADDR 0x00 375#define AK4114_ADDR 0x02
378 376
379static void write_data(struct snd_ice1712 *ice, unsigned int gpio, 377static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
380 unsigned int data, int idx) 378 unsigned int data, int idx)
@@ -428,7 +426,7 @@ static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
428 tmp = snd_ice1712_gpio_read(ice); 426 tmp = snd_ice1712_gpio_read(ice);
429 tmp |= VT1724_REVO_CCLK; /* high at init */ 427 tmp |= VT1724_REVO_CCLK; /* high at init */
430 tmp |= VT1724_REVO_CS0; 428 tmp |= VT1724_REVO_CS0;
431 tmp &= ~VT1724_REVO_CS3; 429 tmp &= ~VT1724_REVO_CS1;
432 snd_ice1712_gpio_write(ice, tmp); 430 snd_ice1712_gpio_write(ice, tmp);
433 udelay(1); 431 udelay(1);
434 return tmp; 432 return tmp;
@@ -436,7 +434,7 @@ static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
436 434
437static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp) 435static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
438{ 436{
439 tmp |= VT1724_REVO_CS3; 437 tmp |= VT1724_REVO_CS1;
440 tmp |= VT1724_REVO_CS0; 438 tmp |= VT1724_REVO_CS0;
441 snd_ice1712_gpio_write(ice, tmp); 439 snd_ice1712_gpio_write(ice, tmp);
442 udelay(1); 440 udelay(1);
@@ -485,13 +483,17 @@ static int __devinit ap192_ak4114_init(struct snd_ice1712 *ice)
485 struct ak4114 *ak; 483 struct ak4114 *ak;
486 int err; 484 int err;
487 485
488 return snd_ak4114_create(ice->card, 486 err = snd_ak4114_create(ice->card,
489 ap192_ak4114_read, 487 ap192_ak4114_read,
490 ap192_ak4114_write, 488 ap192_ak4114_write,
491 ak4114_init_vals, ak4114_init_txcsb, 489 ak4114_init_vals, ak4114_init_txcsb,
492 ice, &ak); 490 ice, &ak);
491 /* AK4114 in Revo cannot detect external rate correctly.
492 * No reason to stop capture stream due to incorrect checks */
493 ak->check_flags = AK4114_CHECK_NO_RATE;
494
495 return 0; /* error ignored; it's no fatal error */
493} 496}
494#endif /* BUILD_AK4114_AP192 */
495 497
496static int __devinit revo_init(struct snd_ice1712 *ice) 498static int __devinit revo_init(struct snd_ice1712 *ice)
497{ 499{
@@ -557,6 +559,9 @@ static int __devinit revo_init(struct snd_ice1712 *ice)
557 if (err < 0) 559 if (err < 0)
558 return err; 560 return err;
559 561
562 /* unmute all codecs */
563 snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE,
564 VT1724_REVO_MUTE);
560 break; 565 break;
561 } 566 }
562 567
@@ -588,11 +593,9 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
588 err = snd_ice1712_akm4xxx_build_controls(ice); 593 err = snd_ice1712_akm4xxx_build_controls(ice);
589 if (err < 0) 594 if (err < 0)
590 return err; 595 return err;
591#ifdef BUILD_AK4114_AP192
592 err = ap192_ak4114_init(ice); 596 err = ap192_ak4114_init(ice);
593 if (err < 0) 597 if (err < 0)
594 return err; 598 return err;
595#endif
596 break; 599 break;
597 } 600 }
598 return 0; 601 return 0;
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index c52abd0bf22e..048d99e25ab0 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -155,7 +155,8 @@ DEFINE_REGSET(SP, 0x60); /* SPDIF out */
155#define ICH_PCM_SPDIF_69 0x80000000 /* s/pdif pcm on slots 6&9 */ 155#define ICH_PCM_SPDIF_69 0x80000000 /* s/pdif pcm on slots 6&9 */
156#define ICH_PCM_SPDIF_1011 0xc0000000 /* s/pdif pcm on slots 10&11 */ 156#define ICH_PCM_SPDIF_1011 0xc0000000 /* s/pdif pcm on slots 10&11 */
157#define ICH_PCM_20BIT 0x00400000 /* 20-bit samples (ICH4) */ 157#define ICH_PCM_20BIT 0x00400000 /* 20-bit samples (ICH4) */
158#define ICH_PCM_246_MASK 0x00300000 /* 6 channels (not all chips) */ 158#define ICH_PCM_246_MASK 0x00300000 /* chan mask (not all chips) */
159#define ICH_PCM_8 0x00300000 /* 8 channels (not all chips) */
159#define ICH_PCM_6 0x00200000 /* 6 channels (not all chips) */ 160#define ICH_PCM_6 0x00200000 /* 6 channels (not all chips) */
160#define ICH_PCM_4 0x00100000 /* 4 channels (not all chips) */ 161#define ICH_PCM_4 0x00100000 /* 4 channels (not all chips) */
161#define ICH_PCM_2 0x00000000 /* 2 channels (stereo) */ 162#define ICH_PCM_2 0x00000000 /* 2 channels (stereo) */
@@ -382,6 +383,7 @@ struct intel8x0 {
382 383
383 unsigned multi4: 1, 384 unsigned multi4: 1,
384 multi6: 1, 385 multi6: 1,
386 multi8 :1,
385 dra: 1, 387 dra: 1,
386 smp20bit: 1; 388 smp20bit: 1;
387 unsigned in_ac97_init: 1, 389 unsigned in_ac97_init: 1,
@@ -997,6 +999,8 @@ static void snd_intel8x0_setup_pcm_out(struct intel8x0 *chip,
997 cnt |= ICH_PCM_4; 999 cnt |= ICH_PCM_4;
998 else if (runtime->channels == 6) 1000 else if (runtime->channels == 6)
999 cnt |= ICH_PCM_6; 1001 cnt |= ICH_PCM_6;
1002 else if (runtime->channels == 8)
1003 cnt |= ICH_PCM_8;
1000 if (chip->device_type == DEVICE_NFORCE) { 1004 if (chip->device_type == DEVICE_NFORCE) {
1001 /* reset to 2ch once to keep the 6 channel data in alignment, 1005 /* reset to 2ch once to keep the 6 channel data in alignment,
1002 * to start from Front Left always 1006 * to start from Front Left always
@@ -1106,6 +1110,16 @@ static struct snd_pcm_hw_constraint_list hw_constraints_channels6 = {
1106 .mask = 0, 1110 .mask = 0,
1107}; 1111};
1108 1112
1113static unsigned int channels8[] = {
1114 2, 4, 6, 8,
1115};
1116
1117static struct snd_pcm_hw_constraint_list hw_constraints_channels8 = {
1118 .count = ARRAY_SIZE(channels8),
1119 .list = channels8,
1120 .mask = 0,
1121};
1122
1109static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev) 1123static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev)
1110{ 1124{
1111 struct intel8x0 *chip = snd_pcm_substream_chip(substream); 1125 struct intel8x0 *chip = snd_pcm_substream_chip(substream);
@@ -1136,7 +1150,12 @@ static int snd_intel8x0_playback_open(struct snd_pcm_substream *substream)
1136 if (err < 0) 1150 if (err < 0)
1137 return err; 1151 return err;
1138 1152
1139 if (chip->multi6) { 1153 if (chip->multi8) {
1154 runtime->hw.channels_max = 8;
1155 snd_pcm_hw_constraint_list(runtime, 0,
1156 SNDRV_PCM_HW_PARAM_CHANNELS,
1157 &hw_constraints_channels8);
1158 } else if (chip->multi6) {
1140 runtime->hw.channels_max = 6; 1159 runtime->hw.channels_max = 6;
1141 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 1160 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
1142 &hw_constraints_channels6); 1161 &hw_constraints_channels6);
@@ -2203,8 +2222,11 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
2203 } 2222 }
2204 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) { 2223 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_PCM_SLEFT)) {
2205 chip->multi4 = 1; 2224 chip->multi4 = 1;
2206 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE)) 2225 if (pbus->pcms[0].r[0].slots & (1 << AC97_SLOT_LFE)) {
2207 chip->multi6 = 1; 2226 chip->multi6 = 1;
2227 if (chip->ac97[0]->flags & AC97_HAS_8CH)
2228 chip->multi8 = 1;
2229 }
2208 } 2230 }
2209 if (pbus->pcms[0].r[1].rslots[0]) { 2231 if (pbus->pcms[0].r[1].rslots[0]) {
2210 chip->dra = 1; 2232 chip->dra = 1;
@@ -2446,7 +2468,7 @@ static int snd_intel8x0_free(struct intel8x0 *chip)
2446 pci_write_config_dword(chip->pci, 0x4c, val); 2468 pci_write_config_dword(chip->pci, 0x4c, val);
2447 } 2469 }
2448 /* --- */ 2470 /* --- */
2449 synchronize_irq(chip->irq); 2471
2450 __hw_end: 2472 __hw_end:
2451 if (chip->irq >= 0) 2473 if (chip->irq >= 0)
2452 free_irq(chip->irq, chip); 2474 free_irq(chip->irq, chip);
@@ -2495,7 +2517,6 @@ static int intel8x0_suspend(struct pci_dev *pci, pm_message_t state)
2495 chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); 2517 chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
2496 2518
2497 if (chip->irq >= 0) { 2519 if (chip->irq >= 0) {
2498 synchronize_irq(chip->irq);
2499 free_irq(chip->irq, chip); 2520 free_irq(chip->irq, chip);
2500 chip->irq = -1; 2521 chip->irq = -1;
2501 } 2522 }
@@ -2648,7 +2669,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2648 t = stop_time.tv_sec - start_time.tv_sec; 2669 t = stop_time.tv_sec - start_time.tv_sec;
2649 t *= 1000000; 2670 t *= 1000000;
2650 t += stop_time.tv_usec - start_time.tv_usec; 2671 t += stop_time.tv_usec - start_time.tv_usec;
2651 printk(KERN_INFO "%s: measured %lu usecs\n", __FUNCTION__, t); 2672 printk(KERN_INFO "%s: measured %lu usecs\n", __func__, t);
2652 if (t == 0) { 2673 if (t == 0) {
2653 snd_printk(KERN_ERR "?? calculation error..\n"); 2674 snd_printk(KERN_ERR "?? calculation error..\n");
2654 return; 2675 return;
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index cadda8d6b70f..faf674e671ac 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -985,17 +985,15 @@ static int snd_intel8x0_free(struct intel8x0m *chip)
985 /* reset channels */ 985 /* reset channels */
986 for (i = 0; i < chip->bdbars_count; i++) 986 for (i = 0; i < chip->bdbars_count; i++)
987 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); 987 iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
988 /* --- */ 988 __hw_end:
989 synchronize_irq(chip->irq); 989 if (chip->irq >= 0)
990 __hw_end: 990 free_irq(chip->irq, chip);
991 if (chip->bdbars.area) 991 if (chip->bdbars.area)
992 snd_dma_free_pages(&chip->bdbars); 992 snd_dma_free_pages(&chip->bdbars);
993 if (chip->addr) 993 if (chip->addr)
994 pci_iounmap(chip->pci, chip->addr); 994 pci_iounmap(chip->pci, chip->addr);
995 if (chip->bmaddr) 995 if (chip->bmaddr)
996 pci_iounmap(chip->pci, chip->bmaddr); 996 pci_iounmap(chip->pci, chip->bmaddr);
997 if (chip->irq >= 0)
998 free_irq(chip->irq, chip);
999 pci_release_regions(chip->pci); 997 pci_release_regions(chip->pci);
1000 pci_disable_device(chip->pci); 998 pci_disable_device(chip->pci);
1001 kfree(chip); 999 kfree(chip);
@@ -1017,7 +1015,6 @@ static int intel8x0m_suspend(struct pci_dev *pci, pm_message_t state)
1017 snd_pcm_suspend_all(chip->pcm[i]); 1015 snd_pcm_suspend_all(chip->pcm[i]);
1018 snd_ac97_suspend(chip->ac97); 1016 snd_ac97_suspend(chip->ac97);
1019 if (chip->irq >= 0) { 1017 if (chip->irq >= 0) {
1020 synchronize_irq(chip->irq);
1021 free_irq(chip->irq, chip); 1018 free_irq(chip->irq, chip);
1022 chip->irq = -1; 1019 chip->irq = -1;
1023 } 1020 }
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 10c713d9ac49..f4c85b52bde3 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2102,7 +2102,6 @@ snd_korg1212_free(struct snd_korg1212 *korg1212)
2102 snd_korg1212_TurnOffIdleMonitor(korg1212); 2102 snd_korg1212_TurnOffIdleMonitor(korg1212);
2103 2103
2104 if (korg1212->irq >= 0) { 2104 if (korg1212->irq >= 0) {
2105 synchronize_irq(korg1212->irq);
2106 snd_korg1212_DisableCardInterrupts(korg1212); 2105 snd_korg1212_DisableCardInterrupts(korg1212);
2107 free_irq(korg1212->irq, korg1212); 2106 free_irq(korg1212->irq, korg1212);
2108 korg1212->irq = -1; 2107 korg1212->irq = -1;
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 04fa0a68416c..a536c59fbea1 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2068,7 +2068,7 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
2068{ 2068{
2069 struct snd_ac97_bus *pbus; 2069 struct snd_ac97_bus *pbus;
2070 struct snd_ac97_template ac97; 2070 struct snd_ac97_template ac97;
2071 struct snd_ctl_elem_id id; 2071 struct snd_ctl_elem_id elem_id;
2072 int err; 2072 int err;
2073 static struct snd_ac97_bus_ops ops = { 2073 static struct snd_ac97_bus_ops ops = {
2074 .write = snd_m3_ac97_write, 2074 .write = snd_m3_ac97_write,
@@ -2088,14 +2088,14 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
2088 schedule_timeout_uninterruptible(msecs_to_jiffies(100)); 2088 schedule_timeout_uninterruptible(msecs_to_jiffies(100));
2089 snd_ac97_write(chip->ac97, AC97_PCM, 0); 2089 snd_ac97_write(chip->ac97, AC97_PCM, 0);
2090 2090
2091 memset(&id, 0, sizeof(id)); 2091 memset(&elem_id, 0, sizeof(elem_id));
2092 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2092 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2093 strcpy(id.name, "Master Playback Switch"); 2093 strcpy(elem_id.name, "Master Playback Switch");
2094 chip->master_switch = snd_ctl_find_id(chip->card, &id); 2094 chip->master_switch = snd_ctl_find_id(chip->card, &elem_id);
2095 memset(&id, 0, sizeof(id)); 2095 memset(&elem_id, 0, sizeof(elem_id));
2096 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2096 elem_id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2097 strcpy(id.name, "Master Playback Volume"); 2097 strcpy(elem_id.name, "Master Playback Volume");
2098 chip->master_volume = snd_ctl_find_id(chip->card, &id); 2098 chip->master_volume = snd_ctl_find_id(chip->card, &elem_id);
2099 2099
2100 return 0; 2100 return 0;
2101} 2101}
@@ -2542,10 +2542,8 @@ static int snd_m3_free(struct snd_m3 *chip)
2542 vfree(chip->suspend_mem); 2542 vfree(chip->suspend_mem);
2543#endif 2543#endif
2544 2544
2545 if (chip->irq >= 0) { 2545 if (chip->irq >= 0)
2546 synchronize_irq(chip->irq);
2547 free_irq(chip->irq, chip); 2546 free_irq(chip->irq, chip);
2548 }
2549 2547
2550 if (chip->iobase) 2548 if (chip->iobase)
2551 pci_release_regions(chip->pci); 2549 pci_release_regions(chip->pci);
@@ -2569,7 +2567,7 @@ static int m3_suspend(struct pci_dev *pci, pm_message_t state)
2569{ 2567{
2570 struct snd_card *card = pci_get_drvdata(pci); 2568 struct snd_card *card = pci_get_drvdata(pci);
2571 struct snd_m3 *chip = card->private_data; 2569 struct snd_m3 *chip = card->private_data;
2572 int i, index; 2570 int i, dsp_index;
2573 2571
2574 if (chip->suspend_mem == NULL) 2572 if (chip->suspend_mem == NULL)
2575 return 0; 2573 return 0;
@@ -2583,12 +2581,12 @@ static int m3_suspend(struct pci_dev *pci, pm_message_t state)
2583 snd_m3_assp_halt(chip); 2581 snd_m3_assp_halt(chip);
2584 2582
2585 /* save dsp image */ 2583 /* save dsp image */
2586 index = 0; 2584 dsp_index = 0;
2587 for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++) 2585 for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++)
2588 chip->suspend_mem[index++] = 2586 chip->suspend_mem[dsp_index++] =
2589 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_CODE, i); 2587 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_CODE, i);
2590 for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++) 2588 for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++)
2591 chip->suspend_mem[index++] = 2589 chip->suspend_mem[dsp_index++] =
2592 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i); 2590 snd_m3_assp_read(chip, MEMTYPE_INTERNAL_DATA, i);
2593 2591
2594 pci_disable_device(pci); 2592 pci_disable_device(pci);
@@ -2601,7 +2599,7 @@ static int m3_resume(struct pci_dev *pci)
2601{ 2599{
2602 struct snd_card *card = pci_get_drvdata(pci); 2600 struct snd_card *card = pci_get_drvdata(pci);
2603 struct snd_m3 *chip = card->private_data; 2601 struct snd_m3 *chip = card->private_data;
2604 int i, index; 2602 int i, dsp_index;
2605 2603
2606 if (chip->suspend_mem == NULL) 2604 if (chip->suspend_mem == NULL)
2607 return 0; 2605 return 0;
@@ -2625,13 +2623,13 @@ static int m3_resume(struct pci_dev *pci)
2625 snd_m3_ac97_reset(chip); 2623 snd_m3_ac97_reset(chip);
2626 2624
2627 /* restore dsp image */ 2625 /* restore dsp image */
2628 index = 0; 2626 dsp_index = 0;
2629 for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++) 2627 for (i = REV_B_CODE_MEMORY_BEGIN; i <= REV_B_CODE_MEMORY_END; i++)
2630 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, i, 2628 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_CODE, i,
2631 chip->suspend_mem[index++]); 2629 chip->suspend_mem[dsp_index++]);
2632 for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++) 2630 for (i = REV_B_DATA_MEMORY_BEGIN ; i <= REV_B_DATA_MEMORY_END; i++)
2633 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, i, 2631 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, i,
2634 chip->suspend_mem[index++]); 2632 chip->suspend_mem[dsp_index++]);
2635 2633
2636 /* tell the dma engine to restart itself */ 2634 /* tell the dma engine to restart itself */
2637 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, 2635 snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA,
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 7ac654e381da..7efb838d18a6 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1439,7 +1439,7 @@ static int snd_nm256_free(struct nm256 *chip)
1439 snd_nm256_capture_stop(chip); 1439 snd_nm256_capture_stop(chip);
1440 1440
1441 if (chip->irq >= 0) 1441 if (chip->irq >= 0)
1442 synchronize_irq(chip->irq); 1442 free_irq(chip->irq, chip);
1443 1443
1444 if (chip->cport) 1444 if (chip->cport)
1445 iounmap(chip->cport); 1445 iounmap(chip->cport);
@@ -1447,8 +1447,6 @@ static int snd_nm256_free(struct nm256 *chip)
1447 iounmap(chip->buffer); 1447 iounmap(chip->buffer);
1448 release_and_free_resource(chip->res_cport); 1448 release_and_free_resource(chip->res_cport);
1449 release_and_free_resource(chip->res_buffer); 1449 release_and_free_resource(chip->res_buffer);
1450 if (chip->irq >= 0)
1451 free_irq(chip->irq, chip);
1452 1450
1453 pci_disable_device(chip->pci); 1451 pci_disable_device(chip->pci);
1454 kfree(chip->ac97_regs); 1452 kfree(chip->ac97_regs);
diff --git a/sound/pci/oxygen/cs4362a.h b/sound/pci/oxygen/cs4362a.h
new file mode 100644
index 000000000000..6a4fedf5e1ec
--- /dev/null
+++ b/sound/pci/oxygen/cs4362a.h
@@ -0,0 +1,69 @@
1/* register 01h */
2#define CS4362A_PDN 0x01
3#define CS4362A_DAC1_DIS 0x02
4#define CS4362A_DAC2_DIS 0x04
5#define CS4362A_DAC3_DIS 0x08
6#define CS4362A_MCLKDIV 0x20
7#define CS4362A_FREEZE 0x40
8#define CS4362A_CPEN 0x80
9/* register 02h */
10#define CS4362A_DIF_MASK 0x70
11#define CS4362A_DIF_LJUST 0x00
12#define CS4362A_DIF_I2S 0x10
13#define CS4362A_DIF_RJUST_16 0x20
14#define CS4362A_DIF_RJUST_24 0x30
15#define CS4362A_DIF_RJUST_20 0x40
16#define CS4362A_DIF_RJUST_18 0x50
17/* register 03h */
18#define CS4362A_MUTEC_MASK 0x03
19#define CS4362A_MUTEC_6 0x00
20#define CS4362A_MUTEC_1 0x01
21#define CS4362A_MUTEC_3 0x03
22#define CS4362A_AMUTE 0x04
23#define CS4362A_MUTEC_POL 0x08
24#define CS4362A_RMP_UP 0x10
25#define CS4362A_SNGLVOL 0x20
26#define CS4362A_ZERO_CROSS 0x40
27#define CS4362A_SOFT_RAMP 0x80
28/* register 04h */
29#define CS4362A_RMP_DN 0x01
30#define CS4362A_DEM_MASK 0x06
31#define CS4362A_DEM_NONE 0x00
32#define CS4362A_DEM_44100 0x02
33#define CS4362A_DEM_48000 0x04
34#define CS4362A_DEM_32000 0x06
35#define CS4362A_FILT_SEL 0x10
36/* register 05h */
37#define CS4362A_INV_A1 0x01
38#define CS4362A_INV_B1 0x02
39#define CS4362A_INV_A2 0x04
40#define CS4362A_INV_B2 0x08
41#define CS4362A_INV_A3 0x10
42#define CS4362A_INV_B3 0x20
43/* register 06h */
44#define CS4362A_FM_MASK 0x03
45#define CS4362A_FM_SINGLE 0x00
46#define CS4362A_FM_DOUBLE 0x01
47#define CS4362A_FM_QUAD 0x02
48#define CS4362A_FM_DSD 0x03
49#define CS4362A_ATAPI_MASK 0x7c
50#define CS4362A_ATAPI_B_MUTE 0x00
51#define CS4362A_ATAPI_B_R 0x04
52#define CS4362A_ATAPI_B_L 0x08
53#define CS4362A_ATAPI_B_LR 0x0c
54#define CS4362A_ATAPI_A_MUTE 0x00
55#define CS4362A_ATAPI_A_R 0x10
56#define CS4362A_ATAPI_A_L 0x20
57#define CS4362A_ATAPI_A_LR 0x30
58#define CS4362A_ATAPI_MIX_LR_VOL 0x40
59#define CS4362A_A_EQ_B 0x80
60/* register 07h */
61#define CS4362A_VOL_MASK 0x7f
62#define CS4362A_MUTE 0x80
63/* register 08h: like 07h */
64/* registers 09h..0Bh: like 06h..08h */
65/* registers 0Ch..0Eh: like 06h..08h */
66/* register 12h */
67#define CS4362A_REV_MASK 0x07
68#define CS4362A_PART_MASK 0xf8
69#define CS4362A_PART_CS4362A 0x50
diff --git a/sound/pci/oxygen/cs4398.h b/sound/pci/oxygen/cs4398.h
new file mode 100644
index 000000000000..5faf5efc8826
--- /dev/null
+++ b/sound/pci/oxygen/cs4398.h
@@ -0,0 +1,69 @@
1/* register 1 */
2#define CS4398_REV_MASK 0x07
3#define CS4398_PART_MASK 0xf8
4#define CS4398_PART_CS4398 0x70
5/* register 2 */
6#define CS4398_FM_MASK 0x03
7#define CS4398_FM_SINGLE 0x00
8#define CS4398_FM_DOUBLE 0x01
9#define CS4398_FM_QUAD 0x02
10#define CS4398_FM_DSD 0x03
11#define CS4398_DEM_MASK 0x0c
12#define CS4398_DEM_NONE 0x00
13#define CS4398_DEM_44100 0x04
14#define CS4398_DEM_48000 0x08
15#define CS4398_DEM_32000 0x0c
16#define CS4398_DIF_MASK 0x70
17#define CS4398_DIF_LJUST 0x00
18#define CS4398_DIF_I2S 0x10
19#define CS4398_DIF_RJUST_16 0x20
20#define CS4398_DIF_RJUST_24 0x30
21#define CS4398_DIF_RJUST_20 0x40
22#define CS4398_DIF_RJUST_18 0x50
23#define CS4398_DSD_SRC 0x80
24/* register 3 */
25#define CS4398_ATAPI_MASK 0x1f
26#define CS4398_ATAPI_B_MUTE 0x00
27#define CS4398_ATAPI_B_R 0x01
28#define CS4398_ATAPI_B_L 0x02
29#define CS4398_ATAPI_B_LR 0x03
30#define CS4398_ATAPI_A_MUTE 0x00
31#define CS4398_ATAPI_A_R 0x04
32#define CS4398_ATAPI_A_L 0x08
33#define CS4398_ATAPI_A_LR 0x0c
34#define CS4398_ATAPI_MIX_LR_VOL 0x10
35#define CS4398_INVERT_B 0x20
36#define CS4398_INVERT_A 0x40
37#define CS4398_VOL_B_EQ_A 0x80
38/* register 4 */
39#define CS4398_MUTEP_MASK 0x03
40#define CS4398_MUTEP_AUTO 0x00
41#define CS4398_MUTEP_LOW 0x02
42#define CS4398_MUTEP_HIGH 0x03
43#define CS4398_MUTE_B 0x08
44#define CS4398_MUTE_A 0x10
45#define CS4398_MUTEC_A_EQ_B 0x20
46#define CS4398_DAMUTE 0x40
47#define CS4398_PAMUTE 0x80
48/* register 5 */
49#define CS4398_VOL_A_MASK 0xff
50/* register 6 */
51#define CS4398_VOL_B_MASK 0xff
52/* register 7 */
53#define CS4398_DIR_DSD 0x01
54#define CS4398_FILT_SEL 0x04
55#define CS4398_RMP_DN 0x10
56#define CS4398_RMP_UP 0x20
57#define CS4398_ZERO_CROSS 0x40
58#define CS4398_SOFT_RAMP 0x80
59/* register 8 */
60#define CS4398_MCLKDIV3 0x08
61#define CS4398_MCLKDIV2 0x10
62#define CS4398_FREEZE 0x20
63#define CS4398_CPEN 0x40
64#define CS4398_PDN 0x80
65/* register 9 */
66#define CS4398_DSD_PM_EN 0x01
67#define CS4398_DSD_PM_MODE 0x02
68#define CS4398_INVALID_DSD 0x04
69#define CS4398_STATIC_DSD 0x08
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c
index 666f69a3312e..090dd4354a28 100644
--- a/sound/pci/oxygen/hifier.c
+++ b/sound/pci/oxygen/hifier.c
@@ -66,12 +66,12 @@ static void hifier_init(struct oxygen *chip)
66{ 66{
67 struct hifier_data *data = chip->model_data; 67 struct hifier_data *data = chip->model_data;
68 68
69 data->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; 69 data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
70 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); 70 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
71 ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2); 71 ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2);
72 ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM); 72 ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM);
73 ak4396_write(chip, AK4396_LCH_ATT, 0xff); 73 ak4396_write(chip, AK4396_LCH_ATT, 0);
74 ak4396_write(chip, AK4396_RCH_ATT, 0xff); 74 ak4396_write(chip, AK4396_RCH_ATT, 0);
75 75
76 snd_component_add(chip->card, "AK4396"); 76 snd_component_add(chip->card, "AK4396");
77 snd_component_add(chip->card, "CS5340"); 77 snd_component_add(chip->card, "CS5340");
@@ -127,22 +127,8 @@ static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
127 127
128static int hifier_control_filter(struct snd_kcontrol_new *template) 128static int hifier_control_filter(struct snd_kcontrol_new *template)
129{ 129{
130 if (!strcmp(template->name, "Master Playback Volume")) { 130 if (!strcmp(template->name, "Stereo Upmixing"))
131 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
132 template->tlv.p = ak4396_db_scale;
133 } else if (!strcmp(template->name, "Stereo Upmixing")) {
134 return 1; /* stereo only - we don't need upmixing */ 131 return 1; /* stereo only - we don't need upmixing */
135 } else if (!strcmp(template->name,
136 SNDRV_CTL_NAME_IEC958("", CAPTURE, MASK)) ||
137 !strcmp(template->name,
138 SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT))) {
139 return 1; /* no digital input */
140 }
141 return 0;
142}
143
144static int hifier_mixer_init(struct oxygen *chip)
145{
146 return 0; 132 return 0;
147} 133}
148 134
@@ -153,18 +139,20 @@ static const struct oxygen_model model_hifier = {
153 .owner = THIS_MODULE, 139 .owner = THIS_MODULE,
154 .init = hifier_init, 140 .init = hifier_init,
155 .control_filter = hifier_control_filter, 141 .control_filter = hifier_control_filter,
156 .mixer_init = hifier_mixer_init,
157 .cleanup = hifier_cleanup, 142 .cleanup = hifier_cleanup,
158 .set_dac_params = set_ak4396_params, 143 .set_dac_params = set_ak4396_params,
159 .set_adc_params = set_cs5340_params, 144 .set_adc_params = set_cs5340_params,
160 .update_dac_volume = update_ak4396_volume, 145 .update_dac_volume = update_ak4396_volume,
161 .update_dac_mute = update_ak4396_mute, 146 .update_dac_mute = update_ak4396_mute,
147 .dac_tlv = ak4396_db_scale,
162 .model_data_size = sizeof(struct hifier_data), 148 .model_data_size = sizeof(struct hifier_data),
149 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
150 PLAYBACK_1_TO_SPDIF |
151 CAPTURE_0_FROM_I2S_1,
163 .dac_channels = 2, 152 .dac_channels = 2,
164 .used_channels = OXYGEN_CHANNEL_A | 153 .dac_volume_min = 0,
165 OXYGEN_CHANNEL_SPDIF | 154 .dac_volume_max = 255,
166 OXYGEN_CHANNEL_MULTICH, 155 .function_flags = OXYGEN_FUNCTION_SPI,
167 .function_flags = 0,
168 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 156 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
169 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 157 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
170}; 158};
@@ -181,7 +169,7 @@ static int __devinit hifier_probe(struct pci_dev *pci,
181 ++dev; 169 ++dev;
182 return -ENOENT; 170 return -ENOENT;
183 } 171 }
184 err = oxygen_pci_probe(pci, index[dev], id[dev], 0, &model_hifier); 172 err = oxygen_pci_probe(pci, index[dev], id[dev], &model_hifier);
185 if (err >= 0) 173 if (err >= 0)
186 ++dev; 174 ++dev;
187 return err; 175 return err;
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index 9a9941bb0460..63f185c1ed1e 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -39,7 +39,7 @@
39#include <sound/tlv.h> 39#include <sound/tlv.h>
40#include "oxygen.h" 40#include "oxygen.h"
41#include "ak4396.h" 41#include "ak4396.h"
42#include "cm9780.h" 42#include "wm8785.h"
43 43
44MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); 44MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
45MODULE_DESCRIPTION("C-Media CMI8788 driver"); 45MODULE_DESCRIPTION("C-Media CMI8788 driver");
@@ -78,49 +78,6 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids);
78#define GPIO_AK5385_DFS_DOUBLE 0x0001 78#define GPIO_AK5385_DFS_DOUBLE 0x0001
79#define GPIO_AK5385_DFS_QUAD 0x0002 79#define GPIO_AK5385_DFS_QUAD 0x0002
80 80
81#define GPIO_LINE_MUTE CM9780_GPO0
82
83#define WM8785_R0 0
84#define WM8785_R1 1
85#define WM8785_R2 2
86#define WM8785_R7 7
87
88/* R0 */
89#define WM8785_MCR_MASK 0x007
90#define WM8785_MCR_SLAVE 0x000
91#define WM8785_MCR_MASTER_128 0x001
92#define WM8785_MCR_MASTER_192 0x002
93#define WM8785_MCR_MASTER_256 0x003
94#define WM8785_MCR_MASTER_384 0x004
95#define WM8785_MCR_MASTER_512 0x005
96#define WM8785_MCR_MASTER_768 0x006
97#define WM8785_OSR_MASK 0x018
98#define WM8785_OSR_SINGLE 0x000
99#define WM8785_OSR_DOUBLE 0x008
100#define WM8785_OSR_QUAD 0x010
101#define WM8785_FORMAT_MASK 0x060
102#define WM8785_FORMAT_RJUST 0x000
103#define WM8785_FORMAT_LJUST 0x020
104#define WM8785_FORMAT_I2S 0x040
105#define WM8785_FORMAT_DSP 0x060
106/* R1 */
107#define WM8785_WL_MASK 0x003
108#define WM8785_WL_16 0x000
109#define WM8785_WL_20 0x001
110#define WM8785_WL_24 0x002
111#define WM8785_WL_32 0x003
112#define WM8785_LRP 0x004
113#define WM8785_BCLKINV 0x008
114#define WM8785_LRSWAP 0x010
115#define WM8785_DEVNO_MASK 0x0e0
116/* R2 */
117#define WM8785_HPFR 0x001
118#define WM8785_HPFL 0x002
119#define WM8785_SDODIS 0x004
120#define WM8785_PWRDNR 0x008
121#define WM8785_PWRDNL 0x010
122#define WM8785_TDM_MASK 0x1c0
123
124struct generic_data { 81struct generic_data {
125 u8 ak4396_ctl2; 82 u8 ak4396_ctl2;
126}; 83};
@@ -155,7 +112,7 @@ static void ak4396_init(struct oxygen *chip)
155 struct generic_data *data = chip->model_data; 112 struct generic_data *data = chip->model_data;
156 unsigned int i; 113 unsigned int i;
157 114
158 data->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; 115 data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
159 for (i = 0; i < 4; ++i) { 116 for (i = 0; i < 4; ++i) {
160 ak4396_write(chip, i, 117 ak4396_write(chip, i,
161 AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); 118 AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
@@ -163,8 +120,8 @@ static void ak4396_init(struct oxygen *chip)
163 AK4396_CONTROL_2, data->ak4396_ctl2); 120 AK4396_CONTROL_2, data->ak4396_ctl2);
164 ak4396_write(chip, i, 121 ak4396_write(chip, i,
165 AK4396_CONTROL_3, AK4396_PCM); 122 AK4396_CONTROL_3, AK4396_PCM);
166 ak4396_write(chip, i, AK4396_LCH_ATT, 0xff); 123 ak4396_write(chip, i, AK4396_LCH_ATT, 0);
167 ak4396_write(chip, i, AK4396_RCH_ATT, 0xff); 124 ak4396_write(chip, i, AK4396_RCH_ATT, 0);
168 } 125 }
169 snd_component_add(chip->card, "AK4396"); 126 snd_component_add(chip->card, "AK4396");
170} 127}
@@ -185,23 +142,16 @@ static void wm8785_init(struct oxygen *chip)
185 snd_component_add(chip->card, "WM8785"); 142 snd_component_add(chip->card, "WM8785");
186} 143}
187 144
188static void cmi9780_init(struct oxygen *chip)
189{
190 oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE);
191}
192
193static void generic_init(struct oxygen *chip) 145static void generic_init(struct oxygen *chip)
194{ 146{
195 ak4396_init(chip); 147 ak4396_init(chip);
196 wm8785_init(chip); 148 wm8785_init(chip);
197 cmi9780_init(chip);
198} 149}
199 150
200static void meridian_init(struct oxygen *chip) 151static void meridian_init(struct oxygen *chip)
201{ 152{
202 ak4396_init(chip); 153 ak4396_init(chip);
203 ak5385_init(chip); 154 ak5385_init(chip);
204 cmi9780_init(chip);
205} 155}
206 156
207static void generic_cleanup(struct oxygen *chip) 157static void generic_cleanup(struct oxygen *chip)
@@ -297,59 +247,32 @@ static void set_ak5385_params(struct oxygen *chip,
297 value, GPIO_AK5385_DFS_MASK); 247 value, GPIO_AK5385_DFS_MASK);
298} 248}
299 249
300static void cmi9780_switch_hook(struct oxygen *chip, unsigned int codec,
301 unsigned int reg, int mute)
302{
303 if (codec != 0)
304 return;
305 switch (reg) {
306 case AC97_LINE:
307 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
308 mute ? GPIO_LINE_MUTE : 0,
309 GPIO_LINE_MUTE);
310 break;
311 case AC97_MIC:
312 case AC97_CD:
313 case AC97_AUX:
314 if (!mute)
315 oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS,
316 GPIO_LINE_MUTE);
317 break;
318 }
319}
320
321static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); 250static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
322 251
323static int ak4396_control_filter(struct snd_kcontrol_new *template)
324{
325 if (!strcmp(template->name, "Master Playback Volume")) {
326 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
327 template->tlv.p = ak4396_db_scale;
328 }
329 return 0;
330}
331
332static const struct oxygen_model model_generic = { 252static const struct oxygen_model model_generic = {
333 .shortname = "C-Media CMI8788", 253 .shortname = "C-Media CMI8788",
334 .longname = "C-Media Oxygen HD Audio", 254 .longname = "C-Media Oxygen HD Audio",
335 .chip = "CMI8788", 255 .chip = "CMI8788",
336 .owner = THIS_MODULE, 256 .owner = THIS_MODULE,
337 .init = generic_init, 257 .init = generic_init,
338 .control_filter = ak4396_control_filter,
339 .cleanup = generic_cleanup, 258 .cleanup = generic_cleanup,
340 .set_dac_params = set_ak4396_params, 259 .set_dac_params = set_ak4396_params,
341 .set_adc_params = set_wm8785_params, 260 .set_adc_params = set_wm8785_params,
342 .update_dac_volume = update_ak4396_volume, 261 .update_dac_volume = update_ak4396_volume,
343 .update_dac_mute = update_ak4396_mute, 262 .update_dac_mute = update_ak4396_mute,
344 .ac97_switch_hook = cmi9780_switch_hook, 263 .dac_tlv = ak4396_db_scale,
345 .model_data_size = sizeof(struct generic_data), 264 .model_data_size = sizeof(struct generic_data),
265 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
266 PLAYBACK_1_TO_SPDIF |
267 PLAYBACK_2_TO_AC97_1 |
268 CAPTURE_0_FROM_I2S_1 |
269 CAPTURE_1_FROM_SPDIF |
270 CAPTURE_2_FROM_AC97_1,
346 .dac_channels = 8, 271 .dac_channels = 8,
347 .used_channels = OXYGEN_CHANNEL_A | 272 .dac_volume_min = 0,
348 OXYGEN_CHANNEL_C | 273 .dac_volume_max = 255,
349 OXYGEN_CHANNEL_SPDIF | 274 .function_flags = OXYGEN_FUNCTION_SPI |
350 OXYGEN_CHANNEL_MULTICH | 275 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
351 OXYGEN_CHANNEL_AC97,
352 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5,
353 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 276 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
354 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 277 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
355}; 278};
@@ -359,21 +282,25 @@ static const struct oxygen_model model_meridian = {
359 .chip = "CMI8788", 282 .chip = "CMI8788",
360 .owner = THIS_MODULE, 283 .owner = THIS_MODULE,
361 .init = meridian_init, 284 .init = meridian_init,
362 .control_filter = ak4396_control_filter,
363 .cleanup = generic_cleanup, 285 .cleanup = generic_cleanup,
364 .set_dac_params = set_ak4396_params, 286 .set_dac_params = set_ak4396_params,
365 .set_adc_params = set_ak5385_params, 287 .set_adc_params = set_ak5385_params,
366 .update_dac_volume = update_ak4396_volume, 288 .update_dac_volume = update_ak4396_volume,
367 .update_dac_mute = update_ak4396_mute, 289 .update_dac_mute = update_ak4396_mute,
368 .ac97_switch_hook = cmi9780_switch_hook, 290 .dac_tlv = ak4396_db_scale,
369 .model_data_size = sizeof(struct generic_data), 291 .model_data_size = sizeof(struct generic_data),
292 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
293 PLAYBACK_1_TO_SPDIF |
294 PLAYBACK_2_TO_AC97_1 |
295 CAPTURE_0_FROM_I2S_2 |
296 CAPTURE_1_FROM_SPDIF |
297 CAPTURE_2_FROM_AC97_1,
370 .dac_channels = 8, 298 .dac_channels = 8,
371 .used_channels = OXYGEN_CHANNEL_B | 299 .dac_volume_min = 0,
372 OXYGEN_CHANNEL_C | 300 .dac_volume_max = 255,
373 OXYGEN_CHANNEL_SPDIF | 301 .misc_flags = OXYGEN_MISC_MIDI,
374 OXYGEN_CHANNEL_MULTICH | 302 .function_flags = OXYGEN_FUNCTION_SPI |
375 OXYGEN_CHANNEL_AC97, 303 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
376 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5,
377 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 304 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
378 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 305 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
379}; 306};
@@ -392,7 +319,7 @@ static int __devinit generic_oxygen_probe(struct pci_dev *pci,
392 return -ENOENT; 319 return -ENOENT;
393 } 320 }
394 is_meridian = pci_id->driver_data; 321 is_meridian = pci_id->driver_data;
395 err = oxygen_pci_probe(pci, index[dev], id[dev], is_meridian, 322 err = oxygen_pci_probe(pci, index[dev], id[dev],
396 is_meridian ? &model_meridian : &model_generic); 323 is_meridian ? &model_meridian : &model_generic);
397 if (err >= 0) 324 if (err >= 0)
398 ++dev; 325 ++dev;
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index ad50fb8b206b..a71c6e059260 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -16,6 +16,16 @@
16#define PCM_AC97 5 16#define PCM_AC97 5
17#define PCM_COUNT 6 17#define PCM_COUNT 6
18 18
19/* model-specific configuration of outputs/inputs */
20#define PLAYBACK_0_TO_I2S 0x001
21#define PLAYBACK_1_TO_SPDIF 0x004
22#define PLAYBACK_2_TO_AC97_1 0x008
23#define CAPTURE_0_FROM_I2S_1 0x010
24#define CAPTURE_0_FROM_I2S_2 0x020
25#define CAPTURE_1_FROM_SPDIF 0x080
26#define CAPTURE_2_FROM_I2S_2 0x100
27#define CAPTURE_2_FROM_AC97_1 0x200
28
19enum { 29enum {
20 CONTROL_SPDIF_PCM, 30 CONTROL_SPDIF_PCM,
21 CONTROL_SPDIF_INPUT_BITS, 31 CONTROL_SPDIF_INPUT_BITS,
@@ -87,12 +97,16 @@ struct oxygen_model {
87 struct snd_pcm_hw_params *params); 97 struct snd_pcm_hw_params *params);
88 void (*update_dac_volume)(struct oxygen *chip); 98 void (*update_dac_volume)(struct oxygen *chip);
89 void (*update_dac_mute)(struct oxygen *chip); 99 void (*update_dac_mute)(struct oxygen *chip);
90 void (*ac97_switch_hook)(struct oxygen *chip, unsigned int codec,
91 unsigned int reg, int mute);
92 void (*gpio_changed)(struct oxygen *chip); 100 void (*gpio_changed)(struct oxygen *chip);
101 void (*ac97_switch)(struct oxygen *chip,
102 unsigned int reg, unsigned int mute);
103 const unsigned int *dac_tlv;
93 size_t model_data_size; 104 size_t model_data_size;
105 unsigned int pcm_dev_cfg;
94 u8 dac_channels; 106 u8 dac_channels;
95 u8 used_channels; 107 u8 dac_volume_min;
108 u8 dac_volume_max;
109 u8 misc_flags;
96 u8 function_flags; 110 u8 function_flags;
97 u16 dac_i2s_format; 111 u16 dac_i2s_format;
98 u16 adc_i2s_format; 112 u16 adc_i2s_format;
@@ -100,7 +114,7 @@ struct oxygen_model {
100 114
101/* oxygen_lib.c */ 115/* oxygen_lib.c */
102 116
103int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, int midi, 117int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
104 const struct oxygen_model *model); 118 const struct oxygen_model *model);
105void oxygen_pci_remove(struct pci_dev *pci); 119void oxygen_pci_remove(struct pci_dev *pci);
106 120
@@ -137,6 +151,7 @@ void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
137 unsigned int index, u16 data, u16 mask); 151 unsigned int index, u16 data, u16 mask);
138 152
139void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data); 153void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data);
154void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data);
140 155
141static inline void oxygen_set_bits8(struct oxygen *chip, 156static inline void oxygen_set_bits8(struct oxygen *chip,
142 unsigned int reg, u8 value) 157 unsigned int reg, u8 value)
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c
index 74e23ef9c946..5569606ee87f 100644
--- a/sound/pci/oxygen/oxygen_io.c
+++ b/sound/pci/oxygen/oxygen_io.c
@@ -190,12 +190,31 @@ void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data)
190 --count; 190 --count;
191 } 191 }
192 192
193 spin_lock_irq(&chip->reg_lock);
194 oxygen_write8(chip, OXYGEN_SPI_DATA1, data); 193 oxygen_write8(chip, OXYGEN_SPI_DATA1, data);
195 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); 194 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8);
196 if (control & OXYGEN_SPI_DATA_LENGTH_3) 195 if (control & OXYGEN_SPI_DATA_LENGTH_3)
197 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); 196 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16);
198 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); 197 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control);
199 spin_unlock_irq(&chip->reg_lock);
200} 198}
201EXPORT_SYMBOL(oxygen_write_spi); 199EXPORT_SYMBOL(oxygen_write_spi);
200
201void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data)
202{
203 unsigned long timeout;
204
205 /* should not need more than about 300 us */
206 timeout = jiffies + msecs_to_jiffies(1);
207 do {
208 if (!(oxygen_read16(chip, OXYGEN_2WIRE_BUS_STATUS)
209 & OXYGEN_2WIRE_BUSY))
210 break;
211 udelay(1);
212 cond_resched();
213 } while (time_after_eq(timeout, jiffies));
214
215 oxygen_write8(chip, OXYGEN_2WIRE_MAP, map);
216 oxygen_write8(chip, OXYGEN_2WIRE_DATA, data);
217 oxygen_write8(chip, OXYGEN_2WIRE_CONTROL,
218 device | OXYGEN_2WIRE_DIR_WRITE);
219}
220EXPORT_SYMBOL(oxygen_write_i2c);
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 78c21155218e..897697d43506 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -221,7 +221,8 @@ static void oxygen_init(struct oxygen *chip)
221 221
222 chip->dac_routing = 1; 222 chip->dac_routing = 1;
223 for (i = 0; i < 8; ++i) 223 for (i = 0; i < 8; ++i)
224 chip->dac_volume[i] = 0xff; 224 chip->dac_volume[i] = chip->model->dac_volume_min;
225 chip->dac_mute = 1;
225 chip->spdif_playback_enable = 1; 226 chip->spdif_playback_enable = 1;
226 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL | 227 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL |
227 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT); 228 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT);
@@ -240,12 +241,12 @@ static void oxygen_init(struct oxygen *chip)
240 chip->has_ac97_0 = (i & OXYGEN_AC97_CODEC_0) != 0; 241 chip->has_ac97_0 = (i & OXYGEN_AC97_CODEC_0) != 0;
241 chip->has_ac97_1 = (i & OXYGEN_AC97_CODEC_1) != 0; 242 chip->has_ac97_1 = (i & OXYGEN_AC97_CODEC_1) != 0;
242 243
243 oxygen_set_bits8(chip, OXYGEN_FUNCTION,
244 OXYGEN_FUNCTION_RESET_CODEC |
245 chip->model->function_flags);
246 oxygen_write8_masked(chip, OXYGEN_FUNCTION, 244 oxygen_write8_masked(chip, OXYGEN_FUNCTION,
247 OXYGEN_FUNCTION_SPI, 245 OXYGEN_FUNCTION_RESET_CODEC |
248 OXYGEN_FUNCTION_2WIRE_SPI_MASK); 246 chip->model->function_flags,
247 OXYGEN_FUNCTION_RESET_CODEC |
248 OXYGEN_FUNCTION_2WIRE_SPI_MASK |
249 OXYGEN_FUNCTION_ENABLE_SPI_4_5);
249 oxygen_write8(chip, OXYGEN_DMA_STATUS, 0); 250 oxygen_write8(chip, OXYGEN_DMA_STATUS, 0);
250 oxygen_write8(chip, OXYGEN_DMA_PAUSE, 0); 251 oxygen_write8(chip, OXYGEN_DMA_PAUSE, 0);
251 oxygen_write8(chip, OXYGEN_PLAY_CHANNELS, 252 oxygen_write8(chip, OXYGEN_PLAY_CHANNELS,
@@ -253,11 +254,13 @@ static void oxygen_init(struct oxygen *chip)
253 OXYGEN_DMA_A_BURST_8 | 254 OXYGEN_DMA_A_BURST_8 |
254 OXYGEN_DMA_MULTICH_BURST_8); 255 OXYGEN_DMA_MULTICH_BURST_8);
255 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); 256 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
256 oxygen_write8_masked(chip, OXYGEN_MISC, 0, 257 oxygen_write8_masked(chip, OXYGEN_MISC,
258 chip->model->misc_flags,
257 OXYGEN_MISC_WRITE_PCI_SUBID | 259 OXYGEN_MISC_WRITE_PCI_SUBID |
258 OXYGEN_MISC_REC_C_FROM_SPDIF | 260 OXYGEN_MISC_REC_C_FROM_SPDIF |
259 OXYGEN_MISC_REC_B_FROM_AC97 | 261 OXYGEN_MISC_REC_B_FROM_AC97 |
260 OXYGEN_MISC_REC_A_FROM_MULTICH); 262 OXYGEN_MISC_REC_A_FROM_MULTICH |
263 OXYGEN_MISC_MIDI);
261 oxygen_write8(chip, OXYGEN_REC_FORMAT, 264 oxygen_write8(chip, OXYGEN_REC_FORMAT,
262 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_A_SHIFT) | 265 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_A_SHIFT) |
263 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_B_SHIFT) | 266 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_B_SHIFT) |
@@ -267,35 +270,49 @@ static void oxygen_init(struct oxygen *chip)
267 (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT)); 270 (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT));
268 oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2); 271 oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2);
269 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, 272 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT,
270 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST | 273 OXYGEN_RATE_48000 | chip->model->dac_i2s_format |
271 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 | 274 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
272 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
273 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
274 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
275 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
276 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
277 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
278 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST |
279 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 |
280 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); 275 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
276 if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
277 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
278 OXYGEN_RATE_48000 | chip->model->adc_i2s_format |
279 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
280 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
281 else
282 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
283 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
284 if (chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_2 |
285 CAPTURE_2_FROM_I2S_2))
286 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
287 OXYGEN_RATE_48000 | chip->model->adc_i2s_format |
288 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
289 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
290 else
291 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
292 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
281 oxygen_write16(chip, OXYGEN_I2S_C_FORMAT, 293 oxygen_write16(chip, OXYGEN_I2S_C_FORMAT,
282 OXYGEN_RATE_48000 | OXYGEN_I2S_FORMAT_LJUST | 294 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
283 OXYGEN_I2S_MCLK_128 | OXYGEN_I2S_BITS_16 | 295 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
284 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); 296 OXYGEN_SPDIF_OUT_ENABLE |
285 oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL, 297 OXYGEN_SPDIF_LOOPBACK);
286 OXYGEN_SPDIF_SENSE_MASK | 298 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
287 OXYGEN_SPDIF_LOCK_MASK | 299 oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
288 OXYGEN_SPDIF_RATE_MASK | 300 OXYGEN_SPDIF_SENSE_MASK |
289 OXYGEN_SPDIF_LOCK_PAR | 301 OXYGEN_SPDIF_LOCK_MASK |
290 OXYGEN_SPDIF_IN_CLOCK_96, 302 OXYGEN_SPDIF_RATE_MASK |
291 OXYGEN_SPDIF_OUT_ENABLE | 303 OXYGEN_SPDIF_LOCK_PAR |
292 OXYGEN_SPDIF_LOOPBACK | 304 OXYGEN_SPDIF_IN_CLOCK_96,
293 OXYGEN_SPDIF_SENSE_MASK | 305 OXYGEN_SPDIF_SENSE_MASK |
294 OXYGEN_SPDIF_LOCK_MASK | 306 OXYGEN_SPDIF_LOCK_MASK |
295 OXYGEN_SPDIF_RATE_MASK | 307 OXYGEN_SPDIF_RATE_MASK |
296 OXYGEN_SPDIF_SENSE_PAR | 308 OXYGEN_SPDIF_SENSE_PAR |
297 OXYGEN_SPDIF_LOCK_PAR | 309 OXYGEN_SPDIF_LOCK_PAR |
298 OXYGEN_SPDIF_IN_CLOCK_MASK); 310 OXYGEN_SPDIF_IN_CLOCK_MASK);
311 else
312 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
313 OXYGEN_SPDIF_SENSE_MASK |
314 OXYGEN_SPDIF_LOCK_MASK |
315 OXYGEN_SPDIF_RATE_MASK);
299 oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits); 316 oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits);
300 oxygen_clear_bits8(chip, OXYGEN_MPU401_CONTROL, OXYGEN_MPU401_LOOPBACK); 317 oxygen_clear_bits8(chip, OXYGEN_MPU401_CONTROL, OXYGEN_MPU401_LOOPBACK);
301 oxygen_write8(chip, OXYGEN_GPI_INTERRUPT_MASK, 0); 318 oxygen_write8(chip, OXYGEN_GPI_INTERRUPT_MASK, 0);
@@ -318,9 +335,12 @@ static void oxygen_init(struct oxygen *chip)
318 (2 << OXYGEN_A_MONITOR_ROUTE_2_SHIFT) | 335 (2 << OXYGEN_A_MONITOR_ROUTE_2_SHIFT) |
319 (3 << OXYGEN_A_MONITOR_ROUTE_3_SHIFT)); 336 (3 << OXYGEN_A_MONITOR_ROUTE_3_SHIFT));
320 337
321 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 338 if (chip->has_ac97_0 | chip->has_ac97_1)
322 OXYGEN_AC97_INT_READ_DONE | 339 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK,
323 OXYGEN_AC97_INT_WRITE_DONE); 340 OXYGEN_AC97_INT_READ_DONE |
341 OXYGEN_AC97_INT_WRITE_DONE);
342 else
343 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0);
324 oxygen_write32(chip, OXYGEN_AC97_OUT_CONFIG, 0); 344 oxygen_write32(chip, OXYGEN_AC97_OUT_CONFIG, 0);
325 oxygen_write32(chip, OXYGEN_AC97_IN_CONFIG, 0); 345 oxygen_write32(chip, OXYGEN_AC97_IN_CONFIG, 0);
326 if (!(chip->has_ac97_0 | chip->has_ac97_1)) 346 if (!(chip->has_ac97_0 | chip->has_ac97_1))
@@ -351,6 +371,8 @@ static void oxygen_init(struct oxygen *chip)
351 oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000); 371 oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000);
352 oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080); 372 oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080);
353 oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080); 373 oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080);
374 oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS,
375 CM9780_GPO0);
354 /* power down unused ADCs and DACs */ 376 /* power down unused ADCs and DACs */
355 oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN, 377 oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN,
356 AC97_PD_PR0 | AC97_PD_PR1); 378 AC97_PD_PR0 | AC97_PD_PR1);
@@ -388,10 +410,8 @@ static void oxygen_card_free(struct snd_card *card)
388 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0); 410 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
389 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); 411 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
390 spin_unlock_irq(&chip->reg_lock); 412 spin_unlock_irq(&chip->reg_lock);
391 if (chip->irq >= 0) { 413 if (chip->irq >= 0)
392 free_irq(chip->irq, chip); 414 free_irq(chip->irq, chip);
393 synchronize_irq(chip->irq);
394 }
395 flush_scheduled_work(); 415 flush_scheduled_work();
396 chip->model->cleanup(chip); 416 chip->model->cleanup(chip);
397 mutex_destroy(&chip->mutex); 417 mutex_destroy(&chip->mutex);
@@ -400,7 +420,7 @@ static void oxygen_card_free(struct snd_card *card)
400} 420}
401 421
402int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, 422int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
403 int midi, const struct oxygen_model *model) 423 const struct oxygen_model *model)
404{ 424{
405 struct snd_card *card; 425 struct snd_card *card;
406 struct oxygen *chip; 426 struct oxygen *chip;
@@ -472,9 +492,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
472 if (err < 0) 492 if (err < 0)
473 goto err_card; 493 goto err_card;
474 494
475 oxygen_write8_masked(chip, OXYGEN_MISC, 495 if (model->misc_flags & OXYGEN_MISC_MIDI) {
476 midi ? OXYGEN_MISC_MIDI : 0, OXYGEN_MISC_MIDI);
477 if (midi) {
478 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI, 496 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
479 chip->addr + OXYGEN_MPU401, 497 chip->addr + OXYGEN_MPU401,
480 MPU401_INFO_INTEGRATED, 0, 0, 498 MPU401_INFO_INTEGRATED, 0, 0,
@@ -486,7 +504,10 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
486 oxygen_proc_init(chip); 504 oxygen_proc_init(chip);
487 505
488 spin_lock_irq(&chip->reg_lock); 506 spin_lock_irq(&chip->reg_lock);
489 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT | OXYGEN_INT_AC97; 507 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
508 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
509 if (chip->has_ac97_0 | chip->has_ac97_1)
510 chip->interrupt_mask |= OXYGEN_INT_AC97;
490 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); 511 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
491 spin_unlock_irq(&chip->reg_lock); 512 spin_unlock_irq(&chip->reg_lock);
492 513
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index a8e4623415d9..cc0cddadd589 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -32,8 +32,8 @@ static int dac_volume_info(struct snd_kcontrol *ctl,
32 32
33 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 33 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
34 info->count = chip->model->dac_channels; 34 info->count = chip->model->dac_channels;
35 info->value.integer.min = 0; 35 info->value.integer.min = chip->model->dac_volume_min;
36 info->value.integer.max = 0xff; 36 info->value.integer.max = chip->model->dac_volume_max;
37 return 0; 37 return 0;
38} 38}
39 39
@@ -446,6 +446,50 @@ static int spdif_loopback_put(struct snd_kcontrol *ctl,
446 return changed; 446 return changed;
447} 447}
448 448
449static int monitor_volume_info(struct snd_kcontrol *ctl,
450 struct snd_ctl_elem_info *info)
451{
452 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
453 info->count = 1;
454 info->value.integer.min = 0;
455 info->value.integer.max = 1;
456 return 0;
457}
458
459static int monitor_get(struct snd_kcontrol *ctl,
460 struct snd_ctl_elem_value *value)
461{
462 struct oxygen *chip = ctl->private_data;
463 u8 bit = ctl->private_value;
464 int invert = ctl->private_value & (1 << 8);
465
466 value->value.integer.value[0] =
467 !!invert ^ !!(oxygen_read8(chip, OXYGEN_ADC_MONITOR) & bit);
468 return 0;
469}
470
471static int monitor_put(struct snd_kcontrol *ctl,
472 struct snd_ctl_elem_value *value)
473{
474 struct oxygen *chip = ctl->private_data;
475 u8 bit = ctl->private_value;
476 int invert = ctl->private_value & (1 << 8);
477 u8 oldreg, newreg;
478 int changed;
479
480 spin_lock_irq(&chip->reg_lock);
481 oldreg = oxygen_read8(chip, OXYGEN_ADC_MONITOR);
482 if ((!!value->value.integer.value[0] ^ !!invert) != 0)
483 newreg = oldreg | bit;
484 else
485 newreg = oldreg & ~bit;
486 changed = newreg != oldreg;
487 if (changed)
488 oxygen_write8(chip, OXYGEN_ADC_MONITOR, newreg);
489 spin_unlock_irq(&chip->reg_lock);
490 return changed;
491}
492
449static int ac97_switch_get(struct snd_kcontrol *ctl, 493static int ac97_switch_get(struct snd_kcontrol *ctl,
450 struct snd_ctl_elem_value *value) 494 struct snd_ctl_elem_value *value)
451{ 495{
@@ -466,6 +510,21 @@ static int ac97_switch_get(struct snd_kcontrol *ctl,
466 return 0; 510 return 0;
467} 511}
468 512
513static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
514{
515 unsigned int priv_idx = chip->controls[control]->private_value & 0xff;
516 u16 value;
517
518 value = oxygen_read_ac97(chip, 0, priv_idx);
519 if (!(value & 0x8000)) {
520 oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000);
521 if (chip->model->ac97_switch)
522 chip->model->ac97_switch(chip, priv_idx, 0x8000);
523 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
524 &chip->controls[control]->id);
525 }
526}
527
469static int ac97_switch_put(struct snd_kcontrol *ctl, 528static int ac97_switch_put(struct snd_kcontrol *ctl,
470 struct snd_ctl_elem_value *value) 529 struct snd_ctl_elem_value *value)
471{ 530{
@@ -487,9 +546,24 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
487 change = newreg != oldreg; 546 change = newreg != oldreg;
488 if (change) { 547 if (change) {
489 oxygen_write_ac97(chip, codec, index, newreg); 548 oxygen_write_ac97(chip, codec, index, newreg);
490 if (bitnr == 15 && chip->model->ac97_switch_hook) 549 if (codec == 0 && chip->model->ac97_switch)
491 chip->model->ac97_switch_hook(chip, codec, index, 550 chip->model->ac97_switch(chip, index, newreg & 0x8000);
492 newreg & 0x8000); 551 if (index == AC97_LINE) {
552 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
553 newreg & 0x8000 ?
554 CM9780_GPO0 : 0, CM9780_GPO0);
555 if (!(newreg & 0x8000)) {
556 mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
557 mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
558 mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
559 }
560 } else if ((index == AC97_MIC || index == AC97_CD ||
561 index == AC97_VIDEO || index == AC97_AUX) &&
562 bitnr == 15 && !(newreg & 0x8000)) {
563 mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
564 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
565 CM9780_GPO0, CM9780_GPO0);
566 }
493 } 567 }
494 mutex_unlock(&chip->mutex); 568 mutex_unlock(&chip->mutex);
495 return change; 569 return change;
@@ -608,6 +682,7 @@ static int ac97_fp_rec_volume_put(struct snd_kcontrol *ctl,
608 .private_value = ((codec) << 24) | (index), \ 682 .private_value = ((codec) << 24) | (index), \
609 } 683 }
610 684
685static DECLARE_TLV_DB_SCALE(monitor_db_scale, -1000, 1000, 0);
611static DECLARE_TLV_DB_SCALE(ac97_db_scale, -3450, 150, 0); 686static DECLARE_TLV_DB_SCALE(ac97_db_scale, -3450, 150, 0);
612static DECLARE_TLV_DB_SCALE(ac97_rec_db_scale, 0, 150, 0); 687static DECLARE_TLV_DB_SCALE(ac97_rec_db_scale, 0, 150, 0);
613 688
@@ -667,6 +742,9 @@ static const struct snd_kcontrol_new controls[] = {
667 .get = spdif_pcm_get, 742 .get = spdif_pcm_get,
668 .put = spdif_pcm_put, 743 .put = spdif_pcm_put,
669 }, 744 },
745};
746
747static const struct snd_kcontrol_new spdif_input_controls[] = {
670 { 748 {
671 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 749 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
672 .device = 1, 750 .device = 1,
@@ -692,11 +770,118 @@ static const struct snd_kcontrol_new controls[] = {
692 }, 770 },
693}; 771};
694 772
773static const struct {
774 unsigned int pcm_dev;
775 struct snd_kcontrol_new controls[2];
776} monitor_controls[] = {
777 {
778 .pcm_dev = CAPTURE_0_FROM_I2S_1,
779 .controls = {
780 {
781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
782 .name = "Analog Input Monitor Switch",
783 .info = snd_ctl_boolean_mono_info,
784 .get = monitor_get,
785 .put = monitor_put,
786 .private_value = OXYGEN_ADC_MONITOR_A,
787 },
788 {
789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
790 .name = "Analog Input Monitor Volume",
791 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
792 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
793 .info = monitor_volume_info,
794 .get = monitor_get,
795 .put = monitor_put,
796 .private_value = OXYGEN_ADC_MONITOR_A_HALF_VOL
797 | (1 << 8),
798 .tlv = { .p = monitor_db_scale, },
799 },
800 },
801 },
802 {
803 .pcm_dev = CAPTURE_0_FROM_I2S_2,
804 .controls = {
805 {
806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
807 .name = "Analog Input Monitor Switch",
808 .info = snd_ctl_boolean_mono_info,
809 .get = monitor_get,
810 .put = monitor_put,
811 .private_value = OXYGEN_ADC_MONITOR_B,
812 },
813 {
814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
815 .name = "Analog Input Monitor Volume",
816 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
817 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
818 .info = monitor_volume_info,
819 .get = monitor_get,
820 .put = monitor_put,
821 .private_value = OXYGEN_ADC_MONITOR_B_HALF_VOL
822 | (1 << 8),
823 .tlv = { .p = monitor_db_scale, },
824 },
825 },
826 },
827 {
828 .pcm_dev = CAPTURE_2_FROM_I2S_2,
829 .controls = {
830 {
831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
832 .name = "Analog Input Monitor Switch",
833 .index = 1,
834 .info = snd_ctl_boolean_mono_info,
835 .get = monitor_get,
836 .put = monitor_put,
837 .private_value = OXYGEN_ADC_MONITOR_B,
838 },
839 {
840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
841 .name = "Analog Input Monitor Volume",
842 .index = 1,
843 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
844 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
845 .info = monitor_volume_info,
846 .get = monitor_get,
847 .put = monitor_put,
848 .private_value = OXYGEN_ADC_MONITOR_B_HALF_VOL
849 | (1 << 8),
850 .tlv = { .p = monitor_db_scale, },
851 },
852 },
853 },
854 {
855 .pcm_dev = CAPTURE_1_FROM_SPDIF,
856 .controls = {
857 {
858 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
859 .name = "Digital Input Monitor Switch",
860 .info = snd_ctl_boolean_mono_info,
861 .get = monitor_get,
862 .put = monitor_put,
863 .private_value = OXYGEN_ADC_MONITOR_C,
864 },
865 {
866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
867 .name = "Digital Input Monitor Volume",
868 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
869 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
870 .info = monitor_volume_info,
871 .get = monitor_get,
872 .put = monitor_put,
873 .private_value = OXYGEN_ADC_MONITOR_C_HALF_VOL
874 | (1 << 8),
875 .tlv = { .p = monitor_db_scale, },
876 },
877 },
878 },
879};
880
695static const struct snd_kcontrol_new ac97_controls[] = { 881static const struct snd_kcontrol_new ac97_controls[] = {
696 AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC), 882 AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC),
697 AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1), 883 AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1),
698 AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0), 884 AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0),
699 AC97_VOLUME("Line Capture Volume", 0, AC97_LINE),
700 AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1), 885 AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1),
701 AC97_VOLUME("CD Capture Volume", 0, AC97_CD), 886 AC97_VOLUME("CD Capture Volume", 0, AC97_CD),
702 AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1), 887 AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1),
@@ -756,6 +941,11 @@ static int add_controls(struct oxygen *chip,
756 return err; 941 return err;
757 if (err == 1) 942 if (err == 1)
758 continue; 943 continue;
944 if (!strcmp(template.name, "Master Playback Volume") &&
945 chip->model->dac_tlv) {
946 template.tlv.p = chip->model->dac_tlv;
947 template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
948 }
759 ctl = snd_ctl_new1(&template, chip); 949 ctl = snd_ctl_new1(&template, chip);
760 if (!ctl) 950 if (!ctl)
761 return -ENOMEM; 951 return -ENOMEM;
@@ -773,11 +963,26 @@ static int add_controls(struct oxygen *chip,
773 963
774int oxygen_mixer_init(struct oxygen *chip) 964int oxygen_mixer_init(struct oxygen *chip)
775{ 965{
966 unsigned int i;
776 int err; 967 int err;
777 968
778 err = add_controls(chip, controls, ARRAY_SIZE(controls)); 969 err = add_controls(chip, controls, ARRAY_SIZE(controls));
779 if (err < 0) 970 if (err < 0)
780 return err; 971 return err;
972 if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) {
973 err = add_controls(chip, spdif_input_controls,
974 ARRAY_SIZE(spdif_input_controls));
975 if (err < 0)
976 return err;
977 }
978 for (i = 0; i < ARRAY_SIZE(monitor_controls); ++i) {
979 if (!(chip->model->pcm_dev_cfg & monitor_controls[i].pcm_dev))
980 continue;
981 err = add_controls(chip, monitor_controls[i].controls,
982 ARRAY_SIZE(monitor_controls[i].controls));
983 if (err < 0)
984 return err;
985 }
781 if (chip->has_ac97_0) { 986 if (chip->has_ac97_0) {
782 err = add_controls(chip, ac97_controls, 987 err = add_controls(chip, ac97_controls,
783 ARRAY_SIZE(ac97_controls)); 988 ARRAY_SIZE(ac97_controls));
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c
index b70046aca657..b17c405e069d 100644
--- a/sound/pci/oxygen/oxygen_pcm.c
+++ b/sound/pci/oxygen/oxygen_pcm.c
@@ -119,7 +119,7 @@ static int oxygen_open(struct snd_pcm_substream *substream,
119 119
120 runtime->private_data = (void *)(uintptr_t)channel; 120 runtime->private_data = (void *)(uintptr_t)channel;
121 if (channel == PCM_B && chip->has_ac97_1 && 121 if (channel == PCM_B && chip->has_ac97_1 &&
122 (chip->model->used_channels & OXYGEN_CHANNEL_AC97)) 122 (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1))
123 runtime->hw = oxygen_ac97_hardware; 123 runtime->hw = oxygen_ac97_hardware;
124 else 124 else
125 runtime->hw = *oxygen_hardware[channel]; 125 runtime->hw = *oxygen_hardware[channel];
@@ -365,7 +365,7 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
365 return err; 365 return err;
366 366
367 is_ac97 = chip->has_ac97_1 && 367 is_ac97 = chip->has_ac97_1 &&
368 (chip->model->used_channels & OXYGEN_CHANNEL_AC97); 368 (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
369 369
370 spin_lock_irq(&chip->reg_lock); 370 spin_lock_irq(&chip->reg_lock);
371 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, 371 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
@@ -640,34 +640,39 @@ int oxygen_pcm_init(struct oxygen *chip)
640 int outs, ins; 640 int outs, ins;
641 int err; 641 int err;
642 642
643 outs = 1; /* OXYGEN_CHANNEL_MULTICH is always used */ 643 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_0_TO_I2S);
644 ins = !!(chip->model->used_channels & (OXYGEN_CHANNEL_A | 644 ins = !!(chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_1 |
645 OXYGEN_CHANNEL_B)); 645 CAPTURE_0_FROM_I2S_2));
646 err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm); 646 if (outs | ins) {
647 if (err < 0) 647 err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm);
648 return err; 648 if (err < 0)
649 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_multich_ops); 649 return err;
650 if (chip->model->used_channels & OXYGEN_CHANNEL_A) 650 if (outs)
651 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, 651 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
652 &oxygen_rec_a_ops); 652 &oxygen_multich_ops);
653 else if (chip->model->used_channels & OXYGEN_CHANNEL_B) 653 if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1)
654 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, 654 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
655 &oxygen_rec_b_ops); 655 &oxygen_rec_a_ops);
656 pcm->private_data = chip; 656 else if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_2)
657 pcm->private_free = oxygen_pcm_free; 657 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
658 strcpy(pcm->name, "Analog"); 658 &oxygen_rec_b_ops);
659 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, 659 pcm->private_data = chip;
660 SNDRV_DMA_TYPE_DEV, 660 pcm->private_free = oxygen_pcm_free;
661 snd_dma_pci_data(chip->pci), 661 strcpy(pcm->name, "Analog");
662 512 * 1024, 2048 * 1024); 662 if (outs)
663 if (ins) 663 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
664 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 664 SNDRV_DMA_TYPE_DEV,
665 SNDRV_DMA_TYPE_DEV, 665 snd_dma_pci_data(chip->pci),
666 snd_dma_pci_data(chip->pci), 666 512 * 1024, 2048 * 1024);
667 128 * 1024, 256 * 1024); 667 if (ins)
668 668 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
669 outs = !!(chip->model->used_channels & OXYGEN_CHANNEL_SPDIF); 669 SNDRV_DMA_TYPE_DEV,
670 ins = !!(chip->model->used_channels & OXYGEN_CHANNEL_C); 670 snd_dma_pci_data(chip->pci),
671 128 * 1024, 256 * 1024);
672 }
673
674 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_1_TO_SPDIF);
675 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF);
671 if (outs | ins) { 676 if (outs | ins) {
672 err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm); 677 err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm);
673 if (err < 0) 678 if (err < 0)
@@ -686,12 +691,13 @@ int oxygen_pcm_init(struct oxygen *chip)
686 128 * 1024, 256 * 1024); 691 128 * 1024, 256 * 1024);
687 } 692 }
688 693
689 outs = chip->has_ac97_1 && 694 if (chip->has_ac97_1) {
690 (chip->model->used_channels & OXYGEN_CHANNEL_AC97); 695 outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_2_TO_AC97_1);
691 ins = outs || 696 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1);
692 (chip->model->used_channels & (OXYGEN_CHANNEL_A | 697 } else {
693 OXYGEN_CHANNEL_B)) 698 outs = 0;
694 == (OXYGEN_CHANNEL_A | OXYGEN_CHANNEL_B); 699 ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_I2S_2);
700 }
695 if (outs | ins) { 701 if (outs | ins) {
696 err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2", 702 err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2",
697 2, outs, ins, &pcm); 703 2, outs, ins, &pcm);
diff --git a/sound/pci/oxygen/pcm1796.h b/sound/pci/oxygen/pcm1796.h
new file mode 100644
index 000000000000..698bf46c710c
--- /dev/null
+++ b/sound/pci/oxygen/pcm1796.h
@@ -0,0 +1,58 @@
1#ifndef PCM1796_H_INCLUDED
2#define PCM1796_H_INCLUDED
3
4/* register 16 */
5#define PCM1796_ATL_MASK 0xff
6/* register 17 */
7#define PCM1796_ATR_MASK 0xff
8/* register 18 */
9#define PCM1796_MUTE 0x01
10#define PCM1796_DME 0x02
11#define PCM1796_DMF_MASK 0x0c
12#define PCM1796_DMF_DISABLED 0x00
13#define PCM1796_DMF_48 0x04
14#define PCM1796_DMF_441 0x08
15#define PCM1796_DMF_32 0x0c
16#define PCM1796_FMT_MASK 0x70
17#define PCM1796_FMT_16_RJUST 0x00
18#define PCM1796_FMT_20_RJUST 0x10
19#define PCM1796_FMT_24_RJUST 0x20
20#define PCM1796_FMT_24_LJUST 0x30
21#define PCM1796_FMT_16_I2S 0x40
22#define PCM1796_FMT_24_I2S 0x50
23#define PCM1796_ATLD 0x80
24/* register 19 */
25#define PCM1796_INZD 0x01
26#define PCM1796_FLT_MASK 0x02
27#define PCM1796_FLT_SHARP 0x00
28#define PCM1796_FLT_SLOW 0x02
29#define PCM1796_DFMS 0x04
30#define PCM1796_OPE 0x10
31#define PCM1796_ATS_MASK 0x60
32#define PCM1796_ATS_1 0x00
33#define PCM1796_ATS_2 0x20
34#define PCM1796_ATS_4 0x40
35#define PCM1796_ATS_8 0x60
36#define PCM1796_REV 0x80
37/* register 20 */
38#define PCM1796_OS_MASK 0x03
39#define PCM1796_OS_64 0x00
40#define PCM1796_OS_32 0x01
41#define PCM1796_OS_128 0x02
42#define PCM1796_CHSL_MASK 0x04
43#define PCM1796_CHSL_LEFT 0x00
44#define PCM1796_CHSL_RIGHT 0x04
45#define PCM1796_MONO 0x08
46#define PCM1796_DFTH 0x10
47#define PCM1796_DSD 0x20
48#define PCM1796_SRST 0x40
49/* register 21 */
50#define PCM1796_PCMZ 0x01
51#define PCM1796_DZ_MASK 0x06
52/* register 22 */
53#define PCM1796_ZFGL 0x01
54#define PCM1796_ZFGR 0x02
55/* register 23 */
56#define PCM1796_ID_MASK 0x1f
57
58#endif
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index d163397b85cc..7f84fa5deca2 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -18,6 +18,9 @@
18 */ 18 */
19 19
20/* 20/*
21 * Xonar D2/D2X
22 * ------------
23 *
21 * CMI8788: 24 * CMI8788:
22 * 25 *
23 * SPI 0 -> 1st PCM1796 (front) 26 * SPI 0 -> 1st PCM1796 (front)
@@ -30,10 +33,33 @@
30 * GPIO 5 <- external power present (D2X only) 33 * GPIO 5 <- external power present (D2X only)
31 * GPIO 7 -> ALT 34 * GPIO 7 -> ALT
32 * GPIO 8 -> enable output to speakers 35 * GPIO 8 -> enable output to speakers
36 */
37
38/*
39 * Xonar DX
40 * --------
41 *
42 * CMI8788:
43 *
44 * I²C <-> CS4398 (front)
45 * <-> CS4362A (surround, center/LFE, back)
46 *
47 * GPI 0 <- external power present
33 * 48 *
34 * CM9780: 49 * GPIO 0 -> enable output to speakers
50 * GPIO 1 -> enable front panel I/O
51 * GPIO 2 -> M0 of CS5361
52 * GPIO 3 -> M1 of CS5361
53 * GPIO 8 -> route input jack to line-in (0) or mic-in (1)
35 * 54 *
36 * GPIO 0 -> enable AC'97 bypass (line in -> ADC) 55 * CS4398:
56 *
57 * AD0 <- 1
58 * AD1 <- 1
59 *
60 * CS4362A:
61 *
62 * AD0 <- 0
37 */ 63 */
38 64
39#include <linux/pci.h> 65#include <linux/pci.h>
@@ -47,11 +73,14 @@
47#include <sound/tlv.h> 73#include <sound/tlv.h>
48#include "oxygen.h" 74#include "oxygen.h"
49#include "cm9780.h" 75#include "cm9780.h"
76#include "pcm1796.h"
77#include "cs4398.h"
78#include "cs4362a.h"
50 79
51MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); 80MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
52MODULE_DESCRIPTION("Asus AV200 driver"); 81MODULE_DESCRIPTION("Asus AVx00 driver");
53MODULE_LICENSE("GPL"); 82MODULE_LICENSE("GPL");
54MODULE_SUPPORTED_DEVICE("{{Asus,AV200}}"); 83MODULE_SUPPORTED_DEVICE("{{Asus,AV100},{Asus,AV200}}");
55 84
56static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 85static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
57static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 86static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
@@ -64,80 +93,44 @@ MODULE_PARM_DESC(id, "ID string");
64module_param_array(enable, bool, NULL, 0444); 93module_param_array(enable, bool, NULL, 0444);
65MODULE_PARM_DESC(enable, "enable card"); 94MODULE_PARM_DESC(enable, "enable card");
66 95
96enum {
97 MODEL_D2,
98 MODEL_D2X,
99 MODEL_DX,
100};
101
67static struct pci_device_id xonar_ids[] __devinitdata = { 102static struct pci_device_id xonar_ids[] __devinitdata = {
68 { OXYGEN_PCI_SUBID(0x1043, 0x8269) }, /* Asus Xonar D2 */ 103 { OXYGEN_PCI_SUBID(0x1043, 0x8269), .driver_data = MODEL_D2 },
69 { OXYGEN_PCI_SUBID(0x1043, 0x82b7) }, /* Asus Xonar D2X */ 104 { OXYGEN_PCI_SUBID(0x1043, 0x8275), .driver_data = MODEL_DX },
105 { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X },
70 { } 106 { }
71}; 107};
72MODULE_DEVICE_TABLE(pci, xonar_ids); 108MODULE_DEVICE_TABLE(pci, xonar_ids);
73 109
74 110
75#define GPIO_CS5381_M_MASK 0x000c 111#define GPIO_CS53x1_M_MASK 0x000c
76#define GPIO_CS5381_M_SINGLE 0x0000 112#define GPIO_CS53x1_M_SINGLE 0x0000
77#define GPIO_CS5381_M_DOUBLE 0x0004 113#define GPIO_CS53x1_M_DOUBLE 0x0004
78#define GPIO_CS5381_M_QUAD 0x0008 114#define GPIO_CS53x1_M_QUAD 0x0008
79#define GPIO_EXT_POWER 0x0020 115
80#define GPIO_ALT 0x0080 116#define GPIO_D2X_EXT_POWER 0x0020
81#define GPIO_OUTPUT_ENABLE 0x0100 117#define GPIO_D2_ALT 0x0080
82 118#define GPIO_D2_OUTPUT_ENABLE 0x0100
83#define GPIO_LINE_MUTE CM9780_GPO0 119
84 120#define GPI_DX_EXT_POWER 0x01
85/* register 16 */ 121#define GPIO_DX_OUTPUT_ENABLE 0x0001
86#define PCM1796_ATL_MASK 0xff 122#define GPIO_DX_FRONT_PANEL 0x0002
87/* register 17 */ 123#define GPIO_DX_INPUT_ROUTE 0x0100
88#define PCM1796_ATR_MASK 0xff 124
89/* register 18 */ 125#define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */
90#define PCM1796_MUTE 0x01 126#define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */
91#define PCM1796_DME 0x02
92#define PCM1796_DMF_MASK 0x0c
93#define PCM1796_DMF_DISABLED 0x00
94#define PCM1796_DMF_48 0x04
95#define PCM1796_DMF_441 0x08
96#define PCM1796_DMF_32 0x0c
97#define PCM1796_FMT_MASK 0x70
98#define PCM1796_FMT_16_RJUST 0x00
99#define PCM1796_FMT_20_RJUST 0x10
100#define PCM1796_FMT_24_RJUST 0x20
101#define PCM1796_FMT_24_LJUST 0x30
102#define PCM1796_FMT_16_I2S 0x40
103#define PCM1796_FMT_24_I2S 0x50
104#define PCM1796_ATLD 0x80
105/* register 19 */
106#define PCM1796_INZD 0x01
107#define PCM1796_FLT_MASK 0x02
108#define PCM1796_FLT_SHARP 0x00
109#define PCM1796_FLT_SLOW 0x02
110#define PCM1796_DFMS 0x04
111#define PCM1796_OPE 0x10
112#define PCM1796_ATS_MASK 0x60
113#define PCM1796_ATS_1 0x00
114#define PCM1796_ATS_2 0x20
115#define PCM1796_ATS_4 0x40
116#define PCM1796_ATS_8 0x60
117#define PCM1796_REV 0x80
118/* register 20 */
119#define PCM1796_OS_MASK 0x03
120#define PCM1796_OS_64 0x00
121#define PCM1796_OS_32 0x01
122#define PCM1796_OS_128 0x02
123#define PCM1796_CHSL_MASK 0x04
124#define PCM1796_CHSL_LEFT 0x00
125#define PCM1796_CHSL_RIGHT 0x04
126#define PCM1796_MONO 0x08
127#define PCM1796_DFTH 0x10
128#define PCM1796_DSD 0x20
129#define PCM1796_SRST 0x40
130/* register 21 */
131#define PCM1796_PCMZ 0x01
132#define PCM1796_DZ_MASK 0x06
133/* register 22 */
134#define PCM1796_ZFGL 0x01
135#define PCM1796_ZFGR 0x02
136/* register 23 */
137#define PCM1796_ID_MASK 0x1f
138 127
139struct xonar_data { 128struct xonar_data {
140 u8 is_d2x; 129 unsigned int anti_pop_delay;
130 u16 output_enable_bit;
131 u8 ext_power_reg;
132 u8 ext_power_int_reg;
133 u8 ext_power_bit;
141 u8 has_power; 134 u8 has_power;
142}; 135};
143 136
@@ -156,62 +149,157 @@ static void pcm1796_write(struct oxygen *chip, unsigned int codec,
156 (reg << 8) | value); 149 (reg << 8) | value);
157} 150}
158 151
159static void xonar_init(struct oxygen *chip) 152static void cs4398_write(struct oxygen *chip, u8 reg, u8 value)
153{
154 oxygen_write_i2c(chip, I2C_DEVICE_CS4398, reg, value);
155}
156
157static void cs4362a_write(struct oxygen *chip, u8 reg, u8 value)
158{
159 oxygen_write_i2c(chip, I2C_DEVICE_CS4362A, reg, value);
160}
161
162static void xonar_common_init(struct oxygen *chip)
163{
164 struct xonar_data *data = chip->model_data;
165
166 if (data->ext_power_reg) {
167 oxygen_set_bits8(chip, data->ext_power_int_reg,
168 data->ext_power_bit);
169 chip->interrupt_mask |= OXYGEN_INT_GPIO;
170 data->has_power = !!(oxygen_read8(chip, data->ext_power_reg)
171 & data->ext_power_bit);
172 }
173 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_CS53x1_M_MASK);
174 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
175 GPIO_CS53x1_M_SINGLE, GPIO_CS53x1_M_MASK);
176 oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC);
177 msleep(data->anti_pop_delay);
178 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, data->output_enable_bit);
179 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit);
180}
181
182static void xonar_d2_init(struct oxygen *chip)
160{ 183{
161 struct xonar_data *data = chip->model_data; 184 struct xonar_data *data = chip->model_data;
162 unsigned int i; 185 unsigned int i;
163 186
164 data->is_d2x = chip->pci->subsystem_device == 0x82b7; 187 data->anti_pop_delay = 300;
188 data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE;
165 189
166 for (i = 0; i < 4; ++i) { 190 for (i = 0; i < 4; ++i) {
167 pcm1796_write(chip, i, 18, PCM1796_FMT_24_LJUST | PCM1796_ATLD); 191 pcm1796_write(chip, i, 18, PCM1796_MUTE | PCM1796_DMF_DISABLED |
192 PCM1796_FMT_24_LJUST | PCM1796_ATLD);
168 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); 193 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1);
169 pcm1796_write(chip, i, 20, PCM1796_OS_64); 194 pcm1796_write(chip, i, 20, PCM1796_OS_64);
170 pcm1796_write(chip, i, 21, 0); 195 pcm1796_write(chip, i, 21, 0);
171 pcm1796_write(chip, i, 16, 0xff); /* set ATL/ATR after ATLD */ 196 pcm1796_write(chip, i, 16, 0x0f); /* set ATL/ATR after ATLD */
172 pcm1796_write(chip, i, 17, 0xff); 197 pcm1796_write(chip, i, 17, 0x0f);
173 } 198 }
174 199
175 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 200 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT);
176 GPIO_CS5381_M_MASK | GPIO_ALT); 201 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT);
177 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 202
178 GPIO_CS5381_M_SINGLE, 203 xonar_common_init(chip);
179 GPIO_CS5381_M_MASK | GPIO_ALT);
180 if (data->is_d2x) {
181 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL,
182 GPIO_EXT_POWER);
183 oxygen_set_bits16(chip, OXYGEN_GPIO_INTERRUPT_MASK,
184 GPIO_EXT_POWER);
185 chip->interrupt_mask |= OXYGEN_INT_GPIO;
186 data->has_power = !!(oxygen_read16(chip, OXYGEN_GPIO_DATA)
187 & GPIO_EXT_POWER);
188 }
189 oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC);
190 oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE);
191 msleep(300);
192 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE);
193 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE);
194 204
195 snd_component_add(chip->card, "PCM1796"); 205 snd_component_add(chip->card, "PCM1796");
196 snd_component_add(chip->card, "CS5381"); 206 snd_component_add(chip->card, "CS5381");
197} 207}
198 208
209static void xonar_d2x_init(struct oxygen *chip)
210{
211 struct xonar_data *data = chip->model_data;
212
213 data->ext_power_reg = OXYGEN_GPIO_DATA;
214 data->ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK;
215 data->ext_power_bit = GPIO_D2X_EXT_POWER;
216 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2X_EXT_POWER);
217 xonar_d2_init(chip);
218}
219
220static void xonar_dx_init(struct oxygen *chip)
221{
222 struct xonar_data *data = chip->model_data;
223
224 data->anti_pop_delay = 800;
225 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE;
226 data->ext_power_reg = OXYGEN_GPI_DATA;
227 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK;
228 data->ext_power_bit = GPI_DX_EXT_POWER;
229
230 oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS,
231 OXYGEN_2WIRE_LENGTH_8 |
232 OXYGEN_2WIRE_INTERRUPT_MASK |
233 OXYGEN_2WIRE_SPEED_FAST);
234
235 /* set CPEN (control port mode) and power down */
236 cs4398_write(chip, 8, CS4398_CPEN | CS4398_PDN);
237 cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN);
238 /* configure */
239 cs4398_write(chip, 2, CS4398_FM_SINGLE |
240 CS4398_DEM_NONE | CS4398_DIF_LJUST);
241 cs4398_write(chip, 3, CS4398_ATAPI_B_R | CS4398_ATAPI_A_L);
242 cs4398_write(chip, 4, CS4398_MUTEP_LOW | CS4398_PAMUTE);
243 cs4398_write(chip, 5, 0xfe);
244 cs4398_write(chip, 6, 0xfe);
245 cs4398_write(chip, 7, CS4398_RMP_DN | CS4398_RMP_UP |
246 CS4398_ZERO_CROSS | CS4398_SOFT_RAMP);
247 cs4362a_write(chip, 0x02, CS4362A_DIF_LJUST);
248 cs4362a_write(chip, 0x03, CS4362A_MUTEC_6 | CS4362A_AMUTE |
249 CS4362A_RMP_UP | CS4362A_ZERO_CROSS | CS4362A_SOFT_RAMP);
250 cs4362a_write(chip, 0x04, CS4362A_RMP_DN | CS4362A_DEM_NONE);
251 cs4362a_write(chip, 0x05, 0);
252 cs4362a_write(chip, 0x06, CS4362A_FM_SINGLE |
253 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L);
254 cs4362a_write(chip, 0x07, 0x7f | CS4362A_MUTE);
255 cs4362a_write(chip, 0x08, 0x7f | CS4362A_MUTE);
256 cs4362a_write(chip, 0x09, CS4362A_FM_SINGLE |
257 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L);
258 cs4362a_write(chip, 0x0a, 0x7f | CS4362A_MUTE);
259 cs4362a_write(chip, 0x0b, 0x7f | CS4362A_MUTE);
260 cs4362a_write(chip, 0x0c, CS4362A_FM_SINGLE |
261 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L);
262 cs4362a_write(chip, 0x0d, 0x7f | CS4362A_MUTE);
263 cs4362a_write(chip, 0x0e, 0x7f | CS4362A_MUTE);
264 /* clear power down */
265 cs4398_write(chip, 8, CS4398_CPEN);
266 cs4362a_write(chip, 0x01, CS4362A_CPEN);
267
268 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL,
269 GPIO_DX_FRONT_PANEL | GPIO_DX_INPUT_ROUTE);
270 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA,
271 GPIO_DX_FRONT_PANEL | GPIO_DX_INPUT_ROUTE);
272
273 xonar_common_init(chip);
274
275 snd_component_add(chip->card, "CS4398");
276 snd_component_add(chip->card, "CS4362A");
277 snd_component_add(chip->card, "CS5361");
278}
279
199static void xonar_cleanup(struct oxygen *chip) 280static void xonar_cleanup(struct oxygen *chip)
200{ 281{
201 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE); 282 struct xonar_data *data = chip->model_data;
283
284 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit);
285}
286
287static void xonar_dx_cleanup(struct oxygen *chip)
288{
289 xonar_cleanup(chip);
290 cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN);
291 oxygen_clear_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC);
202} 292}
203 293
204static void set_pcm1796_params(struct oxygen *chip, 294static void set_pcm1796_params(struct oxygen *chip,
205 struct snd_pcm_hw_params *params) 295 struct snd_pcm_hw_params *params)
206{ 296{
207#if 0
208 unsigned int i; 297 unsigned int i;
209 u8 value; 298 u8 value;
210 299
211 value = params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64; 300 value = params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64;
212 for (i = 0; i < 4; ++i) 301 for (i = 0; i < 4; ++i)
213 pcm1796_write(chip, i, 20, value); 302 pcm1796_write(chip, i, 20, value);
214#endif
215} 303}
216 304
217static void update_pcm1796_volume(struct oxygen *chip) 305static void update_pcm1796_volume(struct oxygen *chip)
@@ -236,19 +324,73 @@ static void update_pcm1796_mute(struct oxygen *chip)
236 pcm1796_write(chip, i, 18, value); 324 pcm1796_write(chip, i, 18, value);
237} 325}
238 326
239static void set_cs5381_params(struct oxygen *chip, 327static void set_cs53x1_params(struct oxygen *chip,
240 struct snd_pcm_hw_params *params) 328 struct snd_pcm_hw_params *params)
241{ 329{
242 unsigned int value; 330 unsigned int value;
243 331
244 if (params_rate(params) <= 54000) 332 if (params_rate(params) <= 54000)
245 value = GPIO_CS5381_M_SINGLE; 333 value = GPIO_CS53x1_M_SINGLE;
246 else if (params_rate(params) <= 108000) 334 else if (params_rate(params) <= 108000)
247 value = GPIO_CS5381_M_DOUBLE; 335 value = GPIO_CS53x1_M_DOUBLE;
248 else 336 else
249 value = GPIO_CS5381_M_QUAD; 337 value = GPIO_CS53x1_M_QUAD;
250 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 338 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
251 value, GPIO_CS5381_M_MASK); 339 value, GPIO_CS53x1_M_MASK);
340}
341
342static void set_cs43xx_params(struct oxygen *chip,
343 struct snd_pcm_hw_params *params)
344{
345 u8 fm_cs4398, fm_cs4362a;
346
347 fm_cs4398 = CS4398_DEM_NONE | CS4398_DIF_LJUST;
348 fm_cs4362a = CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L;
349 if (params_rate(params) <= 50000) {
350 fm_cs4398 |= CS4398_FM_SINGLE;
351 fm_cs4362a |= CS4362A_FM_SINGLE;
352 } else if (params_rate(params) <= 100000) {
353 fm_cs4398 |= CS4398_FM_DOUBLE;
354 fm_cs4362a |= CS4362A_FM_DOUBLE;
355 } else {
356 fm_cs4398 |= CS4398_FM_QUAD;
357 fm_cs4362a |= CS4362A_FM_QUAD;
358 }
359 cs4398_write(chip, 2, fm_cs4398);
360 cs4362a_write(chip, 0x06, fm_cs4362a);
361 cs4362a_write(chip, 0x09, fm_cs4362a);
362 cs4362a_write(chip, 0x0c, fm_cs4362a);
363}
364
365static void update_cs4362a_volumes(struct oxygen *chip)
366{
367 u8 mute;
368
369 mute = chip->dac_mute ? CS4362A_MUTE : 0;
370 cs4362a_write(chip, 7, (127 - chip->dac_volume[2]) | mute);
371 cs4362a_write(chip, 8, (127 - chip->dac_volume[3]) | mute);
372 cs4362a_write(chip, 10, (127 - chip->dac_volume[4]) | mute);
373 cs4362a_write(chip, 11, (127 - chip->dac_volume[5]) | mute);
374 cs4362a_write(chip, 13, (127 - chip->dac_volume[6]) | mute);
375 cs4362a_write(chip, 14, (127 - chip->dac_volume[7]) | mute);
376}
377
378static void update_cs43xx_volume(struct oxygen *chip)
379{
380 cs4398_write(chip, 5, (127 - chip->dac_volume[0]) * 2);
381 cs4398_write(chip, 6, (127 - chip->dac_volume[1]) * 2);
382 update_cs4362a_volumes(chip);
383}
384
385static void update_cs43xx_mute(struct oxygen *chip)
386{
387 u8 reg;
388
389 reg = CS4398_MUTEP_LOW | CS4398_PAMUTE;
390 if (chip->dac_mute)
391 reg |= CS4398_MUTE_B | CS4398_MUTE_A;
392 cs4398_write(chip, 4, reg);
393 update_cs4362a_volumes(chip);
252} 394}
253 395
254static void xonar_gpio_changed(struct oxygen *chip) 396static void xonar_gpio_changed(struct oxygen *chip)
@@ -256,10 +398,8 @@ static void xonar_gpio_changed(struct oxygen *chip)
256 struct xonar_data *data = chip->model_data; 398 struct xonar_data *data = chip->model_data;
257 u8 has_power; 399 u8 has_power;
258 400
259 if (!data->is_d2x) 401 has_power = !!(oxygen_read8(chip, data->ext_power_reg)
260 return; 402 & data->ext_power_bit);
261 has_power = !!(oxygen_read16(chip, OXYGEN_GPIO_DATA)
262 & GPIO_EXT_POWER);
263 if (has_power != data->has_power) { 403 if (has_power != data->has_power) {
264 data->has_power = has_power; 404 data->has_power = has_power;
265 if (has_power) { 405 if (has_power) {
@@ -272,66 +412,13 @@ static void xonar_gpio_changed(struct oxygen *chip)
272 } 412 }
273} 413}
274 414
275static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
276{
277 unsigned int index = chip->controls[control]->private_value & 0xff;
278 u16 value;
279
280 value = oxygen_read_ac97(chip, 0, index);
281 if (!(value & 0x8000)) {
282 oxygen_write_ac97(chip, 0, index, value | 0x8000);
283 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
284 &chip->controls[control]->id);
285 }
286}
287
288static void xonar_ac97_switch_hook(struct oxygen *chip, unsigned int codec,
289 unsigned int reg, int mute)
290{
291 if (codec != 0)
292 return;
293 /* line-in is exclusive */
294 switch (reg) {
295 case AC97_LINE:
296 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
297 mute ? GPIO_LINE_MUTE : 0,
298 GPIO_LINE_MUTE);
299 if (!mute) {
300 mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
301 mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
302 mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
303 }
304 break;
305 case AC97_MIC:
306 case AC97_CD:
307 case AC97_VIDEO:
308 case AC97_AUX:
309 if (!mute) {
310 oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS,
311 GPIO_LINE_MUTE);
312 mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
313 }
314 break;
315 }
316}
317
318static int pcm1796_volume_info(struct snd_kcontrol *ctl,
319 struct snd_ctl_elem_info *info)
320{
321 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
322 info->count = 8;
323 info->value.integer.min = 0x0f;
324 info->value.integer.max = 0xff;
325 return 0;
326}
327
328static int alt_switch_get(struct snd_kcontrol *ctl, 415static int alt_switch_get(struct snd_kcontrol *ctl,
329 struct snd_ctl_elem_value *value) 416 struct snd_ctl_elem_value *value)
330{ 417{
331 struct oxygen *chip = ctl->private_data; 418 struct oxygen *chip = ctl->private_data;
332 419
333 value->value.integer.value[0] = 420 value->value.integer.value[0] =
334 !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_ALT); 421 !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_D2_ALT);
335 return 0; 422 return 0;
336} 423}
337 424
@@ -345,9 +432,9 @@ static int alt_switch_put(struct snd_kcontrol *ctl,
345 spin_lock_irq(&chip->reg_lock); 432 spin_lock_irq(&chip->reg_lock);
346 old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); 433 old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA);
347 if (value->value.integer.value[0]) 434 if (value->value.integer.value[0])
348 new_bits = old_bits | GPIO_ALT; 435 new_bits = old_bits | GPIO_D2_ALT;
349 else 436 else
350 new_bits = old_bits & ~GPIO_ALT; 437 new_bits = old_bits & ~GPIO_D2_ALT;
351 changed = new_bits != old_bits; 438 changed = new_bits != old_bits;
352 if (changed) 439 if (changed)
353 oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits); 440 oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits);
@@ -363,20 +450,68 @@ static const struct snd_kcontrol_new alt_switch = {
363 .put = alt_switch_put, 450 .put = alt_switch_put,
364}; 451};
365 452
453static int front_panel_get(struct snd_kcontrol *ctl,
454 struct snd_ctl_elem_value *value)
455{
456 struct oxygen *chip = ctl->private_data;
457
458 value->value.integer.value[0] =
459 !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DX_FRONT_PANEL);
460 return 0;
461}
462
463static int front_panel_put(struct snd_kcontrol *ctl,
464 struct snd_ctl_elem_value *value)
465{
466 struct oxygen *chip = ctl->private_data;
467 u16 old_reg, new_reg;
468
469 spin_lock_irq(&chip->reg_lock);
470 old_reg = oxygen_read16(chip, OXYGEN_GPIO_DATA);
471 if (value->value.integer.value[0])
472 new_reg = old_reg | GPIO_DX_FRONT_PANEL;
473 else
474 new_reg = old_reg & ~GPIO_DX_FRONT_PANEL;
475 oxygen_write16(chip, OXYGEN_GPIO_DATA, new_reg);
476 spin_unlock_irq(&chip->reg_lock);
477 return old_reg != new_reg;
478}
479
480static const struct snd_kcontrol_new front_panel_switch = {
481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
482 .name = "Front Panel Switch",
483 .info = snd_ctl_boolean_mono_info,
484 .get = front_panel_get,
485 .put = front_panel_put,
486};
487
488static void xonar_dx_ac97_switch(struct oxygen *chip,
489 unsigned int reg, unsigned int mute)
490{
491 if (reg == AC97_LINE) {
492 spin_lock_irq(&chip->reg_lock);
493 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
494 mute ? GPIO_DX_INPUT_ROUTE : 0,
495 GPIO_DX_INPUT_ROUTE);
496 spin_unlock_irq(&chip->reg_lock);
497 }
498}
499
366static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -12000, 50, 0); 500static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -12000, 50, 0);
501static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -12700, 100, 0);
367 502
368static int xonar_control_filter(struct snd_kcontrol_new *template) 503static int xonar_d2_control_filter(struct snd_kcontrol_new *template)
369{ 504{
370 if (!strcmp(template->name, "Master Playback Volume")) { 505 if (!strncmp(template->name, "CD Capture ", 11))
371 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
372 template->info = pcm1796_volume_info,
373 template->tlv.p = pcm1796_db_scale;
374 } else if (!strncmp(template->name, "CD Capture ", 11)) {
375 /* CD in is actually connected to the video in pin */ 506 /* CD in is actually connected to the video in pin */
376 template->private_value ^= AC97_CD ^ AC97_VIDEO; 507 template->private_value ^= AC97_CD ^ AC97_VIDEO;
377 } else if (!strcmp(template->name, "Line Capture Volume")) { 508 return 0;
378 return 1; /* line-in bypasses the AC'97 mixer */ 509}
379 } 510
511static int xonar_dx_control_filter(struct snd_kcontrol_new *template)
512{
513 if (!strncmp(template->name, "CD Capture ", 11))
514 return 1; /* no CD input */
380 return 0; 515 return 0;
381} 516}
382 517
@@ -385,30 +520,96 @@ static int xonar_mixer_init(struct oxygen *chip)
385 return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); 520 return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip));
386} 521}
387 522
388static const struct oxygen_model model_xonar = { 523static int xonar_dx_mixer_init(struct oxygen *chip)
389 .shortname = "Asus AV200", 524{
390 .longname = "Asus Virtuoso 200", 525 return snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip));
391 .chip = "AV200", 526}
392 .owner = THIS_MODULE, 527
393 .init = xonar_init, 528static const struct oxygen_model xonar_models[] = {
394 .control_filter = xonar_control_filter, 529 [MODEL_D2] = {
395 .mixer_init = xonar_mixer_init, 530 .shortname = "Xonar D2",
396 .cleanup = xonar_cleanup, 531 .longname = "Asus Virtuoso 200",
397 .set_dac_params = set_pcm1796_params, 532 .chip = "AV200",
398 .set_adc_params = set_cs5381_params, 533 .owner = THIS_MODULE,
399 .update_dac_volume = update_pcm1796_volume, 534 .init = xonar_d2_init,
400 .update_dac_mute = update_pcm1796_mute, 535 .control_filter = xonar_d2_control_filter,
401 .ac97_switch_hook = xonar_ac97_switch_hook, 536 .mixer_init = xonar_mixer_init,
402 .gpio_changed = xonar_gpio_changed, 537 .cleanup = xonar_cleanup,
403 .model_data_size = sizeof(struct xonar_data), 538 .set_dac_params = set_pcm1796_params,
404 .dac_channels = 8, 539 .set_adc_params = set_cs53x1_params,
405 .used_channels = OXYGEN_CHANNEL_B | 540 .update_dac_volume = update_pcm1796_volume,
406 OXYGEN_CHANNEL_C | 541 .update_dac_mute = update_pcm1796_mute,
407 OXYGEN_CHANNEL_SPDIF | 542 .dac_tlv = pcm1796_db_scale,
408 OXYGEN_CHANNEL_MULTICH, 543 .model_data_size = sizeof(struct xonar_data),
409 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5, 544 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
410 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 545 PLAYBACK_1_TO_SPDIF |
411 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 546 CAPTURE_0_FROM_I2S_2 |
547 CAPTURE_1_FROM_SPDIF,
548 .dac_channels = 8,
549 .dac_volume_min = 0x0f,
550 .dac_volume_max = 0xff,
551 .misc_flags = OXYGEN_MISC_MIDI,
552 .function_flags = OXYGEN_FUNCTION_SPI |
553 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
554 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
555 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
556 },
557 [MODEL_D2X] = {
558 .shortname = "Xonar D2X",
559 .longname = "Asus Virtuoso 200",
560 .chip = "AV200",
561 .owner = THIS_MODULE,
562 .init = xonar_d2x_init,
563 .control_filter = xonar_d2_control_filter,
564 .mixer_init = xonar_mixer_init,
565 .cleanup = xonar_cleanup,
566 .set_dac_params = set_pcm1796_params,
567 .set_adc_params = set_cs53x1_params,
568 .update_dac_volume = update_pcm1796_volume,
569 .update_dac_mute = update_pcm1796_mute,
570 .gpio_changed = xonar_gpio_changed,
571 .dac_tlv = pcm1796_db_scale,
572 .model_data_size = sizeof(struct xonar_data),
573 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
574 PLAYBACK_1_TO_SPDIF |
575 CAPTURE_0_FROM_I2S_2 |
576 CAPTURE_1_FROM_SPDIF,
577 .dac_channels = 8,
578 .dac_volume_min = 0x0f,
579 .dac_volume_max = 0xff,
580 .misc_flags = OXYGEN_MISC_MIDI,
581 .function_flags = OXYGEN_FUNCTION_SPI |
582 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
583 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
584 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
585 },
586 [MODEL_DX] = {
587 .shortname = "Xonar DX",
588 .longname = "Asus Virtuoso 100",
589 .chip = "AV200",
590 .owner = THIS_MODULE,
591 .init = xonar_dx_init,
592 .control_filter = xonar_dx_control_filter,
593 .mixer_init = xonar_dx_mixer_init,
594 .cleanup = xonar_dx_cleanup,
595 .set_dac_params = set_cs43xx_params,
596 .set_adc_params = set_cs53x1_params,
597 .update_dac_volume = update_cs43xx_volume,
598 .update_dac_mute = update_cs43xx_mute,
599 .gpio_changed = xonar_gpio_changed,
600 .ac97_switch = xonar_dx_ac97_switch,
601 .dac_tlv = cs4362a_db_scale,
602 .model_data_size = sizeof(struct xonar_data),
603 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
604 PLAYBACK_1_TO_SPDIF |
605 CAPTURE_0_FROM_I2S_2,
606 .dac_channels = 8,
607 .dac_volume_min = 0,
608 .dac_volume_max = 127,
609 .function_flags = OXYGEN_FUNCTION_2WIRE,
610 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
611 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
612 },
412}; 613};
413 614
414static int __devinit xonar_probe(struct pci_dev *pci, 615static int __devinit xonar_probe(struct pci_dev *pci,
@@ -423,7 +624,8 @@ static int __devinit xonar_probe(struct pci_dev *pci,
423 ++dev; 624 ++dev;
424 return -ENOENT; 625 return -ENOENT;
425 } 626 }
426 err = oxygen_pci_probe(pci, index[dev], id[dev], 1, &model_xonar); 627 err = oxygen_pci_probe(pci, index[dev], id[dev],
628 &xonar_models[pci_id->driver_data]);
427 if (err >= 0) 629 if (err >= 0)
428 ++dev; 630 ++dev;
429 return err; 631 return err;
diff --git a/sound/pci/oxygen/wm8785.h b/sound/pci/oxygen/wm8785.h
new file mode 100644
index 000000000000..8c23e315ae66
--- /dev/null
+++ b/sound/pci/oxygen/wm8785.h
@@ -0,0 +1,45 @@
1#ifndef WM8785_H_INCLUDED
2#define WM8785_H_INCLUDED
3
4#define WM8785_R0 0
5#define WM8785_R1 1
6#define WM8785_R2 2
7#define WM8785_R7 7
8
9/* R0 */
10#define WM8785_MCR_MASK 0x007
11#define WM8785_MCR_SLAVE 0x000
12#define WM8785_MCR_MASTER_128 0x001
13#define WM8785_MCR_MASTER_192 0x002
14#define WM8785_MCR_MASTER_256 0x003
15#define WM8785_MCR_MASTER_384 0x004
16#define WM8785_MCR_MASTER_512 0x005
17#define WM8785_MCR_MASTER_768 0x006
18#define WM8785_OSR_MASK 0x018
19#define WM8785_OSR_SINGLE 0x000
20#define WM8785_OSR_DOUBLE 0x008
21#define WM8785_OSR_QUAD 0x010
22#define WM8785_FORMAT_MASK 0x060
23#define WM8785_FORMAT_RJUST 0x000
24#define WM8785_FORMAT_LJUST 0x020
25#define WM8785_FORMAT_I2S 0x040
26#define WM8785_FORMAT_DSP 0x060
27/* R1 */
28#define WM8785_WL_MASK 0x003
29#define WM8785_WL_16 0x000
30#define WM8785_WL_20 0x001
31#define WM8785_WL_24 0x002
32#define WM8785_WL_32 0x003
33#define WM8785_LRP 0x004
34#define WM8785_BCLKINV 0x008
35#define WM8785_LRSWAP 0x010
36#define WM8785_DEVNO_MASK 0x0e0
37/* R2 */
38#define WM8785_HPFR 0x001
39#define WM8785_HPFL 0x002
40#define WM8785_SDODIS 0x004
41#define WM8785_PWRDNR 0x008
42#define WM8785_PWRDNL 0x010
43#define WM8785_TDM_MASK 0x1c0
44
45#endif
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 9d5bb76229a8..7fdcdc8c6b64 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -458,7 +458,7 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
458 458
459 snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%zx) subs(%d)\n", 459 snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%zx) subs(%d)\n",
460 is_capture ? 'c' : 'p', 460 is_capture ? 'c' : 'p',
461 chip->chip_idx, (void*)subs->runtime->dma_addr, 461 chip->chip_idx, (void *)(long)subs->runtime->dma_addr,
462 subs->runtime->dma_bytes, subs->number); 462 subs->runtime->dma_bytes, subs->number);
463 463
464 pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); 464 pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS);
@@ -626,7 +626,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
626#ifdef CONFIG_SND_DEBUG_DETECT 626#ifdef CONFIG_SND_DEBUG_DETECT
627 do_gettimeofday(&my_tv2); 627 do_gettimeofday(&my_tv2);
628 snd_printdd("***TRIGGER TASKLET*** TIME = %ld (err = %x)\n", 628 snd_printdd("***TRIGGER TASKLET*** TIME = %ld (err = %x)\n",
629 my_tv2.tv_usec - my_tv1.tv_usec, err); 629 (long)(my_tv2.tv_usec - my_tv1.tv_usec), err);
630#endif 630#endif
631} 631}
632 632
@@ -846,7 +846,6 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
846 struct pcxhr_mgr *mgr = chip->mgr; 846 struct pcxhr_mgr *mgr = chip->mgr;
847 struct snd_pcm_runtime *runtime = subs->runtime; 847 struct snd_pcm_runtime *runtime = subs->runtime;
848 struct pcxhr_stream *stream; 848 struct pcxhr_stream *stream;
849 int is_capture;
850 849
851 mutex_lock(&mgr->setup_mutex); 850 mutex_lock(&mgr->setup_mutex);
852 851
@@ -856,12 +855,10 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
856 if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) { 855 if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) {
857 snd_printdd("pcxhr_open playback chip%d subs%d\n", 856 snd_printdd("pcxhr_open playback chip%d subs%d\n",
858 chip->chip_idx, subs->number); 857 chip->chip_idx, subs->number);
859 is_capture = 0;
860 stream = &chip->playback_stream[subs->number]; 858 stream = &chip->playback_stream[subs->number];
861 } else { 859 } else {
862 snd_printdd("pcxhr_open capture chip%d subs%d\n", 860 snd_printdd("pcxhr_open capture chip%d subs%d\n",
863 chip->chip_idx, subs->number); 861 chip->chip_idx, subs->number);
864 is_capture = 1;
865 if (mgr->mono_capture) 862 if (mgr->mono_capture)
866 runtime->hw.channels_max = 1; 863 runtime->hw.channels_max = 1;
867 else 864 else
diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c
index c4e415d07380..78aa81feaa4a 100644
--- a/sound/pci/pcxhr/pcxhr_core.c
+++ b/sound/pci/pcxhr/pcxhr_core.c
@@ -897,7 +897,7 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, int capture_m
897#ifdef CONFIG_SND_DEBUG_DETECT 897#ifdef CONFIG_SND_DEBUG_DETECT
898 do_gettimeofday(&my_tv2); 898 do_gettimeofday(&my_tv2);
899 snd_printdd("***SET PIPE STATE*** TIME = %ld (err = %x)\n", 899 snd_printdd("***SET PIPE STATE*** TIME = %ld (err = %x)\n",
900 my_tv2.tv_usec - my_tv1.tv_usec, err); 900 (long)(my_tv2.tv_usec - my_tv1.tv_usec), err);
901#endif 901#endif
902 return 0; 902 return 0;
903} 903}
@@ -1005,30 +1005,37 @@ void pcxhr_msg_tasklet(unsigned long arg)
1005 int nb_stream = (prmh->stat[i] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD; 1005 int nb_stream = (prmh->stat[i] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD;
1006 int pipe = prmh->stat[i] & MASK_FIRST_FIELD; 1006 int pipe = prmh->stat[i] & MASK_FIRST_FIELD;
1007 int is_capture = prmh->stat[i] & 0x400000; 1007 int is_capture = prmh->stat[i] & 0x400000;
1008 u32 err; 1008 u32 err2;
1009 1009
1010 if (prmh->stat[i] & 0x800000) { /* if BIT_END */ 1010 if (prmh->stat[i] & 0x800000) { /* if BIT_END */
1011 snd_printdd("TASKLET : End%sPipe %d\n", 1011 snd_printdd("TASKLET : End%sPipe %d\n",
1012 is_capture ? "Record" : "Play", pipe); 1012 is_capture ? "Record" : "Play", pipe);
1013 } 1013 }
1014 i++; 1014 i++;
1015 err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; 1015 err2 = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1];
1016 if (err) 1016 if (err2)
1017 pcxhr_handle_async_err(mgr, err, PCXHR_ERR_PIPE, 1017 pcxhr_handle_async_err(mgr, err2,
1018 PCXHR_ERR_PIPE,
1018 pipe, is_capture); 1019 pipe, is_capture);
1019 i += 2; 1020 i += 2;
1020 for (j = 0; j < nb_stream; j++) { 1021 for (j = 0; j < nb_stream; j++) {
1021 err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; 1022 err2 = prmh->stat[i] ?
1022 if (err) 1023 prmh->stat[i] : prmh->stat[i+1];
1023 pcxhr_handle_async_err(mgr, err, PCXHR_ERR_STREAM, 1024 if (err2)
1024 pipe, is_capture); 1025 pcxhr_handle_async_err(mgr, err2,
1026 PCXHR_ERR_STREAM,
1027 pipe,
1028 is_capture);
1025 i += 2; 1029 i += 2;
1026 } 1030 }
1027 for (j = 0; j < nb_audio; j++) { 1031 for (j = 0; j < nb_audio; j++) {
1028 err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; 1032 err2 = prmh->stat[i] ?
1029 if (err) 1033 prmh->stat[i] : prmh->stat[i+1];
1030 pcxhr_handle_async_err(mgr, err, PCXHR_ERR_AUDIO, 1034 if (err2)
1031 pipe, is_capture); 1035 pcxhr_handle_async_err(mgr, err2,
1036 PCXHR_ERR_AUDIO,
1037 pipe,
1038 is_capture);
1032 i += 2; 1039 i += 2;
1033 } 1040 }
1034 } 1041 }
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 9408b1eeec40..979f7da641ce 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1630,14 +1630,14 @@ static int snd_riptide_playback_open(struct snd_pcm_substream *substream)
1630 struct snd_riptide *chip = snd_pcm_substream_chip(substream); 1630 struct snd_riptide *chip = snd_pcm_substream_chip(substream);
1631 struct snd_pcm_runtime *runtime = substream->runtime; 1631 struct snd_pcm_runtime *runtime = substream->runtime;
1632 struct pcmhw *data; 1632 struct pcmhw *data;
1633 int index = substream->number; 1633 int sub_num = substream->number;
1634 1634
1635 chip->playback_substream[index] = substream; 1635 chip->playback_substream[sub_num] = substream;
1636 runtime->hw = snd_riptide_playback; 1636 runtime->hw = snd_riptide_playback;
1637 data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL); 1637 data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL);
1638 data->paths = lbus_play_paths[index]; 1638 data->paths = lbus_play_paths[sub_num];
1639 data->id = play_ids[index]; 1639 data->id = play_ids[sub_num];
1640 data->source = play_sources[index]; 1640 data->source = play_sources[sub_num];
1641 data->intdec[0] = 0xff; 1641 data->intdec[0] = 0xff;
1642 data->intdec[1] = 0xff; 1642 data->intdec[1] = 0xff;
1643 data->state = ST_STOP; 1643 data->state = ST_STOP;
@@ -1670,10 +1670,10 @@ static int snd_riptide_playback_close(struct snd_pcm_substream *substream)
1670{ 1670{
1671 struct snd_riptide *chip = snd_pcm_substream_chip(substream); 1671 struct snd_riptide *chip = snd_pcm_substream_chip(substream);
1672 struct pcmhw *data = get_pcmhwdev(substream); 1672 struct pcmhw *data = get_pcmhwdev(substream);
1673 int index = substream->number; 1673 int sub_num = substream->number;
1674 1674
1675 substream->runtime->private_data = NULL; 1675 substream->runtime->private_data = NULL;
1676 chip->playback_substream[index] = NULL; 1676 chip->playback_substream[sub_num] = NULL;
1677 kfree(data); 1677 kfree(data);
1678 return 0; 1678 return 0;
1679} 1679}
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index df184aabce84..e7ef3a1a25a8 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -1350,7 +1350,8 @@ static int __devinit snd_rme32_create(struct rme32 * rme32)
1350 return err; 1350 return err;
1351 rme32->port = pci_resource_start(rme32->pci, 0); 1351 rme32->port = pci_resource_start(rme32->pci, 0);
1352 1352
1353 if ((rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE)) == 0) { 1353 rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE);
1354 if (!rme32->iobase) {
1354 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", 1355 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n",
1355 rme32->port, rme32->port + RME32_IO_SIZE - 1); 1356 rme32->port, rme32->port + RME32_IO_SIZE - 1);
1356 return -ENOMEM; 1357 return -ENOMEM;
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index fb0a4ee8bc02..3fdd488d0975 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -1559,7 +1559,8 @@ snd_rme96_create(struct rme96 *rme96)
1559 return err; 1559 return err;
1560 rme96->port = pci_resource_start(rme96->pci, 0); 1560 rme96->port = pci_resource_start(rme96->pci, 0);
1561 1561
1562 if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) { 1562 rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE);
1563 if (!rme96->iobase) {
1563 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1); 1564 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
1564 return -ENOMEM; 1565 return -ENOMEM;
1565 } 1566 }
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 1be84f22d0de..4d6fbb36ab8a 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -318,6 +318,10 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
318#define HDSP_midi1IRQPending (1<<31) 318#define HDSP_midi1IRQPending (1<<31)
319 319
320#define HDSP_spdifFrequencyMask (HDSP_spdifFrequency0|HDSP_spdifFrequency1|HDSP_spdifFrequency2) 320#define HDSP_spdifFrequencyMask (HDSP_spdifFrequency0|HDSP_spdifFrequency1|HDSP_spdifFrequency2)
321#define HDSP_spdifFrequencyMask_9632 (HDSP_spdifFrequency0|\
322 HDSP_spdifFrequency1|\
323 HDSP_spdifFrequency2|\
324 HDSP_spdifFrequency3)
321 325
322#define HDSP_spdifFrequency32KHz (HDSP_spdifFrequency0) 326#define HDSP_spdifFrequency32KHz (HDSP_spdifFrequency0)
323#define HDSP_spdifFrequency44_1KHz (HDSP_spdifFrequency1) 327#define HDSP_spdifFrequency44_1KHz (HDSP_spdifFrequency1)
@@ -328,7 +332,9 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
328#define HDSP_spdifFrequency96KHz (HDSP_spdifFrequency2|HDSP_spdifFrequency1) 332#define HDSP_spdifFrequency96KHz (HDSP_spdifFrequency2|HDSP_spdifFrequency1)
329 333
330/* This is for H9632 cards */ 334/* This is for H9632 cards */
331#define HDSP_spdifFrequency128KHz HDSP_spdifFrequencyMask 335#define HDSP_spdifFrequency128KHz (HDSP_spdifFrequency0|\
336 HDSP_spdifFrequency1|\
337 HDSP_spdifFrequency2)
332#define HDSP_spdifFrequency176_4KHz HDSP_spdifFrequency3 338#define HDSP_spdifFrequency176_4KHz HDSP_spdifFrequency3
333#define HDSP_spdifFrequency192KHz (HDSP_spdifFrequency3|HDSP_spdifFrequency0) 339#define HDSP_spdifFrequency192KHz (HDSP_spdifFrequency3|HDSP_spdifFrequency0)
334 340
@@ -885,28 +891,15 @@ static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp)
885 return ret; 891 return ret;
886} 892}
887 893
888static int hdsp_external_sample_rate (struct hdsp *hdsp)
889{
890 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
891 unsigned int rate_bits = status2 & HDSP_systemFrequencyMask;
892
893 switch (rate_bits) {
894 case HDSP_systemFrequency32: return 32000;
895 case HDSP_systemFrequency44_1: return 44100;
896 case HDSP_systemFrequency48: return 48000;
897 case HDSP_systemFrequency64: return 64000;
898 case HDSP_systemFrequency88_2: return 88200;
899 case HDSP_systemFrequency96: return 96000;
900 default:
901 return 0;
902 }
903}
904
905static int hdsp_spdif_sample_rate(struct hdsp *hdsp) 894static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
906{ 895{
907 unsigned int status = hdsp_read(hdsp, HDSP_statusRegister); 896 unsigned int status = hdsp_read(hdsp, HDSP_statusRegister);
908 unsigned int rate_bits = (status & HDSP_spdifFrequencyMask); 897 unsigned int rate_bits = (status & HDSP_spdifFrequencyMask);
909 898
899 /* For the 9632, the mask is different */
900 if (hdsp->io_type == H9632)
901 rate_bits = (status & HDSP_spdifFrequencyMask_9632);
902
910 if (status & HDSP_SPDIFErrorFlag) 903 if (status & HDSP_SPDIFErrorFlag)
911 return 0; 904 return 0;
912 905
@@ -933,6 +926,31 @@ static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
933 return 0; 926 return 0;
934} 927}
935 928
929static int hdsp_external_sample_rate(struct hdsp *hdsp)
930{
931 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register);
932 unsigned int rate_bits = status2 & HDSP_systemFrequencyMask;
933
934 /* For the 9632 card, there seems to be no bit for indicating external
935 * sample rate greater than 96kHz. The card reports the corresponding
936 * single speed. So the best means seems to get spdif rate when
937 * autosync reference is spdif */
938 if (hdsp->io_type == H9632 &&
939 hdsp_autosync_ref(hdsp) == HDSP_AUTOSYNC_FROM_SPDIF)
940 return hdsp_spdif_sample_rate(hdsp);
941
942 switch (rate_bits) {
943 case HDSP_systemFrequency32: return 32000;
944 case HDSP_systemFrequency44_1: return 44100;
945 case HDSP_systemFrequency48: return 48000;
946 case HDSP_systemFrequency64: return 64000;
947 case HDSP_systemFrequency88_2: return 88200;
948 case HDSP_systemFrequency96: return 96000;
949 default:
950 return 0;
951 }
952}
953
936static void hdsp_compute_period_size(struct hdsp *hdsp) 954static void hdsp_compute_period_size(struct hdsp *hdsp)
937{ 955{
938 hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8)); 956 hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8));
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 9a19ae6a64d9..ab423bc82342 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -540,7 +540,8 @@ static void hdspm_set_sgbuf(struct hdspm * hdspm, struct snd_sg_buf *sgbuf,
540 540
541static inline int HDSPM_bit2freq(int n) 541static inline int HDSPM_bit2freq(int n)
542{ 542{
543 static int bit2freq_tab[] = { 0, 32000, 44100, 48000, 64000, 88200, 543 static const int bit2freq_tab[] = {
544 0, 32000, 44100, 48000, 64000, 88200,
544 96000, 128000, 176400, 192000 }; 545 96000, 128000, 176400, 192000 };
545 if (n < 1 || n > 9) 546 if (n < 1 || n > 9)
546 return 0; 547 return 0;
@@ -582,7 +583,7 @@ static inline int hdspm_read_pb_gain(struct hdspm * hdspm, unsigned int chan,
582 return hdspm->mixer->ch[chan].pb[pb]; 583 return hdspm->mixer->ch[chan].pb[pb];
583} 584}
584 585
585static inline int hdspm_write_in_gain(struct hdspm * hdspm, unsigned int chan, 586static int hdspm_write_in_gain(struct hdspm *hdspm, unsigned int chan,
586 unsigned int in, unsigned short data) 587 unsigned int in, unsigned short data)
587{ 588{
588 if (chan >= HDSPM_MIXER_CHANNELS || in >= HDSPM_MIXER_CHANNELS) 589 if (chan >= HDSPM_MIXER_CHANNELS || in >= HDSPM_MIXER_CHANNELS)
@@ -595,7 +596,7 @@ static inline int hdspm_write_in_gain(struct hdspm * hdspm, unsigned int chan,
595 return 0; 596 return 0;
596} 597}
597 598
598static inline int hdspm_write_pb_gain(struct hdspm * hdspm, unsigned int chan, 599static int hdspm_write_pb_gain(struct hdspm *hdspm, unsigned int chan,
599 unsigned int pb, unsigned short data) 600 unsigned int pb, unsigned short data)
600{ 601{
601 if (chan >= HDSPM_MIXER_CHANNELS || pb >= HDSPM_MIXER_CHANNELS) 602 if (chan >= HDSPM_MIXER_CHANNELS || pb >= HDSPM_MIXER_CHANNELS)
@@ -621,7 +622,7 @@ static inline void snd_hdspm_enable_out(struct hdspm * hdspm, int i, int v)
621} 622}
622 623
623/* check if same process is writing and reading */ 624/* check if same process is writing and reading */
624static inline int snd_hdspm_use_is_exclusive(struct hdspm * hdspm) 625static int snd_hdspm_use_is_exclusive(struct hdspm *hdspm)
625{ 626{
626 unsigned long flags; 627 unsigned long flags;
627 int ret = 1; 628 int ret = 1;
@@ -636,7 +637,7 @@ static inline int snd_hdspm_use_is_exclusive(struct hdspm * hdspm)
636} 637}
637 638
638/* check for external sample rate */ 639/* check for external sample rate */
639static inline int hdspm_external_sample_rate(struct hdspm * hdspm) 640static int hdspm_external_sample_rate(struct hdspm *hdspm)
640{ 641{
641 if (hdspm->is_aes32) { 642 if (hdspm->is_aes32) {
642 unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); 643 unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
@@ -787,7 +788,7 @@ static inline void hdspm_stop_audio(struct hdspm * s)
787} 788}
788 789
789/* should I silence all or only opened ones ? doit all for first even is 4MB*/ 790/* should I silence all or only opened ones ? doit all for first even is 4MB*/
790static inline void hdspm_silence_playback(struct hdspm * hdspm) 791static void hdspm_silence_playback(struct hdspm *hdspm)
791{ 792{
792 int i; 793 int i;
793 int n = hdspm->period_bytes; 794 int n = hdspm->period_bytes;
@@ -1028,9 +1029,9 @@ static inline void snd_hdspm_midi_write_byte (struct hdspm *hdspm, int id,
1028{ 1029{
1029 /* the hardware already does the relevant bit-mask with 0xff */ 1030 /* the hardware already does the relevant bit-mask with 0xff */
1030 if (id) 1031 if (id)
1031 return hdspm_write(hdspm, HDSPM_midiDataOut1, val); 1032 hdspm_write(hdspm, HDSPM_midiDataOut1, val);
1032 else 1033 else
1033 return hdspm_write(hdspm, HDSPM_midiDataOut0, val); 1034 hdspm_write(hdspm, HDSPM_midiDataOut0, val);
1034} 1035}
1035 1036
1036static inline int snd_hdspm_midi_input_available (struct hdspm *hdspm, int id) 1037static inline int snd_hdspm_midi_input_available (struct hdspm *hdspm, int id)
@@ -1057,7 +1058,7 @@ static inline int snd_hdspm_midi_output_possible (struct hdspm *hdspm, int id)
1057 return 0; 1058 return 0;
1058} 1059}
1059 1060
1060static inline void snd_hdspm_flush_midi_input (struct hdspm *hdspm, int id) 1061static void snd_hdspm_flush_midi_input(struct hdspm *hdspm, int id)
1061{ 1062{
1062 while (snd_hdspm_midi_input_available (hdspm, id)) 1063 while (snd_hdspm_midi_input_available (hdspm, id))
1063 snd_hdspm_midi_read_byte (hdspm, id); 1064 snd_hdspm_midi_read_byte (hdspm, id);
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index 742f1180c39e..df2007e3be7c 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -1194,7 +1194,6 @@ static int sis_suspend(struct pci_dev *pci, pm_message_t state)
1194 /* snd_pcm_suspend_all() stopped all channels, so we're quiescent. 1194 /* snd_pcm_suspend_all() stopped all channels, so we're quiescent.
1195 */ 1195 */
1196 if (sis->irq >= 0) { 1196 if (sis->irq >= 0) {
1197 synchronize_irq(sis->irq);
1198 free_irq(sis->irq, sis); 1197 free_irq(sis->irq, sis);
1199 sis->irq = -1; 1198 sis->irq = -1;
1200 } 1199 }
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 71138ff9b310..bbcee2c09ae4 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3676,6 +3676,8 @@ static int snd_trident_free(struct snd_trident *trident)
3676 else if (trident->device == TRIDENT_DEVICE_ID_SI7018) { 3676 else if (trident->device == TRIDENT_DEVICE_ID_SI7018) {
3677 outl(0, TRID_REG(trident, SI_SERIAL_INTF_CTRL)); 3677 outl(0, TRID_REG(trident, SI_SERIAL_INTF_CTRL));
3678 } 3678 }
3679 if (trident->irq >= 0)
3680 free_irq(trident->irq, trident);
3679 if (trident->tlb.buffer.area) { 3681 if (trident->tlb.buffer.area) {
3680 outl(0, TRID_REG(trident, NX_TLBC)); 3682 outl(0, TRID_REG(trident, NX_TLBC));
3681 if (trident->tlb.memhdr) 3683 if (trident->tlb.memhdr)
@@ -3685,8 +3687,6 @@ static int snd_trident_free(struct snd_trident *trident)
3685 vfree(trident->tlb.shadow_entries); 3687 vfree(trident->tlb.shadow_entries);
3686 snd_dma_free_pages(&trident->tlb.buffer); 3688 snd_dma_free_pages(&trident->tlb.buffer);
3687 } 3689 }
3688 if (trident->irq >= 0)
3689 free_irq(trident->irq, trident);
3690 pci_release_regions(trident->pci); 3690 pci_release_regions(trident->pci);
3691 pci_disable_device(trident->pci); 3691 pci_disable_device(trident->pci);
3692 kfree(trident); 3692 kfree(trident);
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index a756be661f9a..b585cc3e4c47 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2236,7 +2236,7 @@ static int snd_via82xx_free(struct via82xx *chip)
2236 /* disable interrupts */ 2236 /* disable interrupts */
2237 for (i = 0; i < chip->num_devs; i++) 2237 for (i = 0; i < chip->num_devs; i++)
2238 snd_via82xx_channel_reset(chip, &chip->devs[i]); 2238 snd_via82xx_channel_reset(chip, &chip->devs[i]);
2239 synchronize_irq(chip->irq); 2239
2240 if (chip->irq >= 0) 2240 if (chip->irq >= 0)
2241 free_irq(chip->irq, chip); 2241 free_irq(chip->irq, chip);
2242 __end_hw: 2242 __end_hw:
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index f5df1c79bee1..31f64ee39882 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1075,7 +1075,7 @@ static int snd_via82xx_free(struct via82xx_modem *chip)
1075 /* disable interrupts */ 1075 /* disable interrupts */
1076 for (i = 0; i < chip->num_devs; i++) 1076 for (i = 0; i < chip->num_devs; i++)
1077 snd_via82xx_channel_reset(chip, &chip->devs[i]); 1077 snd_via82xx_channel_reset(chip, &chip->devs[i]);
1078 synchronize_irq(chip->irq); 1078
1079 __end_hw: 1079 __end_hw:
1080 if (chip->irq >= 0) 1080 if (chip->irq >= 0)
1081 free_irq(chip->irq, chip); 1081 free_irq(chip->irq, chip);
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 42c1eb7d35f5..29b3056c5109 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -2249,6 +2249,8 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
2249#ifdef CONFIG_PM 2249#ifdef CONFIG_PM
2250 vfree(chip->saved_regs); 2250 vfree(chip->saved_regs);
2251#endif 2251#endif
2252 if (chip->irq >= 0)
2253 free_irq(chip->irq, chip);
2252 release_and_free_resource(chip->mpu_res); 2254 release_and_free_resource(chip->mpu_res);
2253 release_and_free_resource(chip->fm_res); 2255 release_and_free_resource(chip->fm_res);
2254 snd_ymfpci_free_gameport(chip); 2256 snd_ymfpci_free_gameport(chip);
@@ -2257,8 +2259,6 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
2257 if (chip->work_ptr.area) 2259 if (chip->work_ptr.area)
2258 snd_dma_free_pages(&chip->work_ptr); 2260 snd_dma_free_pages(&chip->work_ptr);
2259 2261
2260 if (chip->irq >= 0)
2261 free_irq(chip->irq, chip);
2262 release_and_free_resource(chip->res_reg_area); 2262 release_and_free_resource(chip->res_reg_area);
2263 2263
2264 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); 2264 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);