aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2010-08-04 09:14:38 -0400
committerJiri Kosina <jkosina@suse.cz>2010-08-04 09:14:38 -0400
commitd790d4d583aeaed9fc6f8a9f4d9f8ce6b1c15c7f (patch)
tree854ab394486288d40fa8179cbfaf66e8bdc44b0f /sound
parent73b2c7165b76b20eb1290e7efebc33cfd21db1ca (diff)
parent3a09b1be53d23df780a0cd0e4087a05e2ca4a00c (diff)
Merge branch 'master' into for-next
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/asihpi/hpi6205.c22
-rw-r--r--sound/pci/hda/hda_codec.c27
-rw-r--r--sound/pci/hda/hda_codec.h5
-rw-r--r--sound/pci/hda/patch_hdmi.c13
-rw-r--r--sound/pci/hda/patch_nvhdmi.c3
-rw-r--r--sound/pci/hda/patch_realtek.c96
-rw-r--r--sound/soc/au1x/psc-i2s.c2
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/wm8727.c2
-rw-r--r--sound/soc/codecs/wm8776.c1
-rw-r--r--sound/soc/codecs/wm8988.c1
-rw-r--r--sound/soc/davinci/davinci-mcasp.c2
-rw-r--r--sound/soc/fsl/mpc5200_dma.h2
-rw-r--r--sound/soc/sh/fsi.c27
-rw-r--r--sound/usb/clock.c12
-rw-r--r--sound/usb/endpoint.c1
-rw-r--r--sound/usb/format.c104
-rw-r--r--sound/usb/helper.h4
-rw-r--r--sound/usb/mixer.c32
19 files changed, 260 insertions, 100 deletions
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index e89991ea3543..3b4413448226 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -941,11 +941,11 @@ static void outstream_host_buffer_free(struct hpi_adapter_obj *pao,
941 941
942} 942}
943 943
944static long outstream_get_space_available(struct hpi_hostbuffer_status 944static u32 outstream_get_space_available(struct hpi_hostbuffer_status
945 *status) 945 *status)
946{ 946{
947 return status->size_in_bytes - ((long)(status->host_index) - 947 return status->size_in_bytes - (status->host_index -
948 (long)(status->dSP_index)); 948 status->dSP_index);
949} 949}
950 950
951static void outstream_write(struct hpi_adapter_obj *pao, 951static void outstream_write(struct hpi_adapter_obj *pao,
@@ -954,7 +954,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
954 struct hpi_hw_obj *phw = pao->priv; 954 struct hpi_hw_obj *phw = pao->priv;
955 struct bus_master_interface *interface = phw->p_interface_buffer; 955 struct bus_master_interface *interface = phw->p_interface_buffer;
956 struct hpi_hostbuffer_status *status; 956 struct hpi_hostbuffer_status *status;
957 long space_available; 957 u32 space_available;
958 958
959 if (!phw->outstream_host_buffer_size[phm->obj_index]) { 959 if (!phw->outstream_host_buffer_size[phm->obj_index]) {
960 /* there is no BBM buffer, write via message */ 960 /* there is no BBM buffer, write via message */
@@ -1007,7 +1007,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
1007 } 1007 }
1008 1008
1009 space_available = outstream_get_space_available(status); 1009 space_available = outstream_get_space_available(status);
1010 if (space_available < (long)phm->u.d.u.data.data_size) { 1010 if (space_available < phm->u.d.u.data.data_size) {
1011 phr->error = HPI_ERROR_INVALID_DATASIZE; 1011 phr->error = HPI_ERROR_INVALID_DATASIZE;
1012 return; 1012 return;
1013 } 1013 }
@@ -1018,7 +1018,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
1018 && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> 1018 && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm->
1019 obj_index])) { 1019 obj_index])) {
1020 u8 *p_bbm_data; 1020 u8 *p_bbm_data;
1021 long l_first_write; 1021 u32 l_first_write;
1022 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; 1022 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data;
1023 1023
1024 if (hpios_locked_mem_get_virt_addr(&phw-> 1024 if (hpios_locked_mem_get_virt_addr(&phw->
@@ -1248,9 +1248,9 @@ static void instream_start(struct hpi_adapter_obj *pao,
1248 hw_message(pao, phm, phr); 1248 hw_message(pao, phm, phr);
1249} 1249}
1250 1250
1251static long instream_get_bytes_available(struct hpi_hostbuffer_status *status) 1251static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status)
1252{ 1252{
1253 return (long)(status->dSP_index) - (long)(status->host_index); 1253 return status->dSP_index - status->host_index;
1254} 1254}
1255 1255
1256static void instream_read(struct hpi_adapter_obj *pao, 1256static void instream_read(struct hpi_adapter_obj *pao,
@@ -1259,9 +1259,9 @@ static void instream_read(struct hpi_adapter_obj *pao,
1259 struct hpi_hw_obj *phw = pao->priv; 1259 struct hpi_hw_obj *phw = pao->priv;
1260 struct bus_master_interface *interface = phw->p_interface_buffer; 1260 struct bus_master_interface *interface = phw->p_interface_buffer;
1261 struct hpi_hostbuffer_status *status; 1261 struct hpi_hostbuffer_status *status;
1262 long data_available; 1262 u32 data_available;
1263 u8 *p_bbm_data; 1263 u8 *p_bbm_data;
1264 long l_first_read; 1264 u32 l_first_read;
1265 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; 1265 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data;
1266 1266
1267 if (!phw->instream_host_buffer_size[phm->obj_index]) { 1267 if (!phw->instream_host_buffer_size[phm->obj_index]) {
@@ -1272,7 +1272,7 @@ static void instream_read(struct hpi_adapter_obj *pao,
1272 1272
1273 status = &interface->instream_host_buffer_status[phm->obj_index]; 1273 status = &interface->instream_host_buffer_status[phm->obj_index];
1274 data_available = instream_get_bytes_available(status); 1274 data_available = instream_get_bytes_available(status);
1275 if (data_available < (long)phm->u.d.u.data.data_size) { 1275 if (data_available < phm->u.d.u.data.data_size) {
1276 phr->error = HPI_ERROR_INVALID_DATASIZE; 1276 phr->error = HPI_ERROR_INVALID_DATASIZE;
1277 return; 1277 return;
1278 } 1278 }
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index a3d638c8c1fd..ba2098d20ccc 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -784,6 +784,9 @@ static int read_pin_defaults(struct hda_codec *codec)
784 pin->nid = nid; 784 pin->nid = nid;
785 pin->cfg = snd_hda_codec_read(codec, nid, 0, 785 pin->cfg = snd_hda_codec_read(codec, nid, 0,
786 AC_VERB_GET_CONFIG_DEFAULT, 0); 786 AC_VERB_GET_CONFIG_DEFAULT, 0);
787 pin->ctrl = snd_hda_codec_read(codec, nid, 0,
788 AC_VERB_GET_PIN_WIDGET_CONTROL,
789 0);
787 } 790 }
788 return 0; 791 return 0;
789} 792}
@@ -912,15 +915,38 @@ static void restore_pincfgs(struct hda_codec *codec)
912void snd_hda_shutup_pins(struct hda_codec *codec) 915void snd_hda_shutup_pins(struct hda_codec *codec)
913{ 916{
914 int i; 917 int i;
918 /* don't shut up pins when unloading the driver; otherwise it breaks
919 * the default pin setup at the next load of the driver
920 */
921 if (codec->bus->shutdown)
922 return;
915 for (i = 0; i < codec->init_pins.used; i++) { 923 for (i = 0; i < codec->init_pins.used; i++) {
916 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); 924 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
917 /* use read here for syncing after issuing each verb */ 925 /* use read here for syncing after issuing each verb */
918 snd_hda_codec_read(codec, pin->nid, 0, 926 snd_hda_codec_read(codec, pin->nid, 0,
919 AC_VERB_SET_PIN_WIDGET_CONTROL, 0); 927 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
920 } 928 }
929 codec->pins_shutup = 1;
921} 930}
922EXPORT_SYMBOL_HDA(snd_hda_shutup_pins); 931EXPORT_SYMBOL_HDA(snd_hda_shutup_pins);
923 932
933/* Restore the pin controls cleared previously via snd_hda_shutup_pins() */
934static void restore_shutup_pins(struct hda_codec *codec)
935{
936 int i;
937 if (!codec->pins_shutup)
938 return;
939 if (codec->bus->shutdown)
940 return;
941 for (i = 0; i < codec->init_pins.used; i++) {
942 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
943 snd_hda_codec_write(codec, pin->nid, 0,
944 AC_VERB_SET_PIN_WIDGET_CONTROL,
945 pin->ctrl);
946 }
947 codec->pins_shutup = 0;
948}
949
924static void init_hda_cache(struct hda_cache_rec *cache, 950static void init_hda_cache(struct hda_cache_rec *cache,
925 unsigned int record_size); 951 unsigned int record_size);
926static void free_hda_cache(struct hda_cache_rec *cache); 952static void free_hda_cache(struct hda_cache_rec *cache);
@@ -2907,6 +2933,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
2907 codec->afg ? codec->afg : codec->mfg, 2933 codec->afg ? codec->afg : codec->mfg,
2908 AC_PWRST_D0); 2934 AC_PWRST_D0);
2909 restore_pincfgs(codec); /* restore all current pin configs */ 2935 restore_pincfgs(codec); /* restore all current pin configs */
2936 restore_shutup_pins(codec);
2910 hda_exec_init_verbs(codec); 2937 hda_exec_init_verbs(codec);
2911 if (codec->patch_ops.resume) 2938 if (codec->patch_ops.resume)
2912 codec->patch_ops.resume(codec); 2939 codec->patch_ops.resume(codec);
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 49e939e7e5cd..5991d14e1ec0 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -821,6 +821,7 @@ struct hda_codec {
821 unsigned int pin_amp_workaround:1; /* pin out-amp takes index 821 unsigned int pin_amp_workaround:1; /* pin out-amp takes index
822 * (e.g. Conexant codecs) 822 * (e.g. Conexant codecs)
823 */ 823 */
824 unsigned int pins_shutup:1; /* pins are shut up */
824 unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */ 825 unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */
825#ifdef CONFIG_SND_HDA_POWER_SAVE 826#ifdef CONFIG_SND_HDA_POWER_SAVE
826 unsigned int power_on :1; /* current (global) power-state */ 827 unsigned int power_on :1; /* current (global) power-state */
@@ -897,7 +898,9 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec);
897/* the struct for codec->pin_configs */ 898/* the struct for codec->pin_configs */
898struct hda_pincfg { 899struct hda_pincfg {
899 hda_nid_t nid; 900 hda_nid_t nid;
900 unsigned int cfg; 901 unsigned char ctrl; /* current pin control value */
902 unsigned char pad; /* reserved */
903 unsigned int cfg; /* default configuration */
901}; 904};
902 905
903unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid); 906unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid);
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 86067ee78632..2fc53961054e 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -52,6 +52,10 @@ struct hdmi_spec {
52 */ 52 */
53 struct hda_multi_out multiout; 53 struct hda_multi_out multiout;
54 unsigned int codec_type; 54 unsigned int codec_type;
55
56 /* misc flags */
57 /* PD bit indicates only the update, not the current state */
58 unsigned int old_pin_detect:1;
55}; 59};
56 60
57 61
@@ -616,6 +620,9 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
616 * Unsolicited events 620 * Unsolicited events
617 */ 621 */
618 622
623static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
624 struct hdmi_eld *eld);
625
619static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) 626static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
620{ 627{
621 struct hdmi_spec *spec = codec->spec; 628 struct hdmi_spec *spec = codec->spec;
@@ -632,6 +639,12 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
632 if (index < 0) 639 if (index < 0)
633 return; 640 return;
634 641
642 if (spec->old_pin_detect) {
643 if (pind)
644 hdmi_present_sense(codec, tag, &spec->sink_eld[index]);
645 pind = spec->sink_eld[index].monitor_present;
646 }
647
635 spec->sink_eld[index].monitor_present = pind; 648 spec->sink_eld[index].monitor_present = pind;
636 spec->sink_eld[index].eld_valid = eldv; 649 spec->sink_eld[index].eld_valid = eldv;
637 650
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c
index 3c10c0b149f4..b0652acee9b2 100644
--- a/sound/pci/hda/patch_nvhdmi.c
+++ b/sound/pci/hda/patch_nvhdmi.c
@@ -478,6 +478,7 @@ static int patch_nvhdmi_8ch_89(struct hda_codec *codec)
478 478
479 codec->spec = spec; 479 codec->spec = spec;
480 spec->codec_type = HDA_CODEC_NVIDIA_MCP89; 480 spec->codec_type = HDA_CODEC_NVIDIA_MCP89;
481 spec->old_pin_detect = 1;
481 482
482 if (hdmi_parse_codec(codec) < 0) { 483 if (hdmi_parse_codec(codec) < 0) {
483 codec->spec = NULL; 484 codec->spec = NULL;
@@ -508,6 +509,7 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
508 spec->multiout.max_channels = 8; 509 spec->multiout.max_channels = 8;
509 spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; 510 spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x;
510 spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; 511 spec->codec_type = HDA_CODEC_NVIDIA_MCP7X;
512 spec->old_pin_detect = 1;
511 513
512 codec->patch_ops = nvhdmi_patch_ops_8ch_7x; 514 codec->patch_ops = nvhdmi_patch_ops_8ch_7x;
513 515
@@ -528,6 +530,7 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec)
528 spec->multiout.max_channels = 2; 530 spec->multiout.max_channels = 2;
529 spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; 531 spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x;
530 spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; 532 spec->codec_type = HDA_CODEC_NVIDIA_MCP7X;
533 spec->old_pin_detect = 1;
531 534
532 codec->patch_ops = nvhdmi_patch_ops_2ch; 535 codec->patch_ops = nvhdmi_patch_ops_2ch;
533 536
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fc767b6b4785..596ea2f12cf6 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1267,6 +1267,8 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec)
1267 unsigned nid = 0; 1267 unsigned nid = 0;
1268 struct alc_spec *spec = codec->spec; 1268 struct alc_spec *spec = codec->spec;
1269 1269
1270 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1271
1270 ass = codec->subsystem_id & 0xffff; 1272 ass = codec->subsystem_id & 0xffff;
1271 if (ass != codec->bus->pci->subsystem_device && (ass & 1)) 1273 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1272 goto do_sku; 1274 goto do_sku;
@@ -2547,7 +2549,7 @@ static struct snd_kcontrol_new alc_beep_mixer[] = {
2547static int alc_build_controls(struct hda_codec *codec) 2549static int alc_build_controls(struct hda_codec *codec)
2548{ 2550{
2549 struct alc_spec *spec = codec->spec; 2551 struct alc_spec *spec = codec->spec;
2550 struct snd_kcontrol *kctl; 2552 struct snd_kcontrol *kctl = NULL;
2551 struct snd_kcontrol_new *knew; 2553 struct snd_kcontrol_new *knew;
2552 int i, j, err; 2554 int i, j, err;
2553 unsigned int u; 2555 unsigned int u;
@@ -2619,16 +2621,18 @@ static int alc_build_controls(struct hda_codec *codec)
2619 } 2621 }
2620 2622
2621 /* assign Capture Source enums to NID */ 2623 /* assign Capture Source enums to NID */
2622 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); 2624 if (spec->capsrc_nids || spec->adc_nids) {
2623 if (!kctl) 2625 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2624 kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); 2626 if (!kctl)
2625 for (i = 0; kctl && i < kctl->count; i++) { 2627 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2626 hda_nid_t *nids = spec->capsrc_nids; 2628 for (i = 0; kctl && i < kctl->count; i++) {
2627 if (!nids) 2629 hda_nid_t *nids = spec->capsrc_nids;
2628 nids = spec->adc_nids; 2630 if (!nids)
2629 err = snd_hda_add_nid(codec, kctl, i, nids[i]); 2631 nids = spec->adc_nids;
2630 if (err < 0) 2632 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2631 return err; 2633 if (err < 0)
2634 return err;
2635 }
2632 } 2636 }
2633 if (spec->cap_mixer) { 2637 if (spec->cap_mixer) {
2634 const char *kname = kctl ? kctl->id.name : NULL; 2638 const char *kname = kctl ? kctl->id.name : NULL;
@@ -5176,8 +5180,24 @@ static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5176#ifdef CONFIG_SND_HDA_INPUT_BEEP 5180#ifdef CONFIG_SND_HDA_INPUT_BEEP
5177#define set_beep_amp(spec, nid, idx, dir) \ 5181#define set_beep_amp(spec, nid, idx, dir) \
5178 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) 5182 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
5183
5184static struct snd_pci_quirk beep_white_list[] = {
5185 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
5186 {}
5187};
5188
5189static inline int has_cdefine_beep(struct hda_codec *codec)
5190{
5191 struct alc_spec *spec = codec->spec;
5192 const struct snd_pci_quirk *q;
5193 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5194 if (q)
5195 return q->value;
5196 return spec->cdefine.enable_pcbeep;
5197}
5179#else 5198#else
5180#define set_beep_amp(spec, nid, idx, dir) /* NOP */ 5199#define set_beep_amp(spec, nid, idx, dir) /* NOP */
5200#define has_cdefine_beep(codec) 0
5181#endif 5201#endif
5182 5202
5183/* 5203/*
@@ -6948,7 +6968,7 @@ static struct hda_input_mux mb5_capture_source = {
6948 .num_items = 3, 6968 .num_items = 3,
6949 .items = { 6969 .items = {
6950 { "Mic", 0x1 }, 6970 { "Mic", 0x1 },
6951 { "Line", 0x2 }, 6971 { "Line", 0x7 },
6952 { "CD", 0x4 }, 6972 { "CD", 0x4 },
6953 }, 6973 },
6954}; 6974};
@@ -7469,8 +7489,8 @@ static struct snd_kcontrol_new alc885_mb5_mixer[] = {
7469 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT), 7489 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7470 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT), 7490 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7471 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT), 7491 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7472 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 7492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7473 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 7493 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 7494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7475 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 7495 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7476 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT), 7496 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
@@ -7853,10 +7873,9 @@ static struct hda_verb alc885_mb5_init_verbs[] = {
7853 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 7873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 7874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7855 7875
7856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7876 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
7857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 7877 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
7858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 7878 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
7859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7860 { } 7879 { }
7861}; 7880};
7862 7881
@@ -9485,6 +9504,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9485 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), 9504 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
9486 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91), 9505 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
9487 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5), 9506 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
9507 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
9488 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2, 9508 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9489 * so apparently no perfect solution yet 9509 * so apparently no perfect solution yet
9490 */ 9510 */
@@ -10562,10 +10582,12 @@ static int patch_alc882(struct hda_codec *codec)
10562 } 10582 }
10563 } 10583 }
10564 10584
10565 err = snd_hda_attach_beep_device(codec, 0x1); 10585 if (has_cdefine_beep(codec)) {
10566 if (err < 0) { 10586 err = snd_hda_attach_beep_device(codec, 0x1);
10567 alc_free(codec); 10587 if (err < 0) {
10568 return err; 10588 alc_free(codec);
10589 return err;
10590 }
10569 } 10591 }
10570 10592
10571 if (board_config != ALC882_AUTO) 10593 if (board_config != ALC882_AUTO)
@@ -10615,7 +10637,7 @@ static int patch_alc882(struct hda_codec *codec)
10615 10637
10616 set_capture_mixer(codec); 10638 set_capture_mixer(codec);
10617 10639
10618 if (spec->cdefine.enable_pcbeep) 10640 if (has_cdefine_beep(codec))
10619 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 10641 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10620 10642
10621 if (board_config == ALC882_AUTO) 10643 if (board_config == ALC882_AUTO)
@@ -12431,7 +12453,7 @@ static int patch_alc262(struct hda_codec *codec)
12431 } 12453 }
12432 } 12454 }
12433 12455
12434 if (!spec->no_analog) { 12456 if (!spec->no_analog && has_cdefine_beep(codec)) {
12435 err = snd_hda_attach_beep_device(codec, 0x1); 12457 err = snd_hda_attach_beep_device(codec, 0x1);
12436 if (err < 0) { 12458 if (err < 0) {
12437 alc_free(codec); 12459 alc_free(codec);
@@ -12482,7 +12504,7 @@ static int patch_alc262(struct hda_codec *codec)
12482 } 12504 }
12483 if (!spec->cap_mixer && !spec->no_analog) 12505 if (!spec->cap_mixer && !spec->no_analog)
12484 set_capture_mixer(codec); 12506 set_capture_mixer(codec);
12485 if (!spec->no_analog && spec->cdefine.enable_pcbeep) 12507 if (!spec->no_analog && has_cdefine_beep(codec))
12486 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 12508 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
12487 12509
12488 spec->vmaster_nid = 0x0c; 12510 spec->vmaster_nid = 0x0c;
@@ -14454,10 +14476,12 @@ static int patch_alc269(struct hda_codec *codec)
14454 } 14476 }
14455 } 14477 }
14456 14478
14457 err = snd_hda_attach_beep_device(codec, 0x1); 14479 if (has_cdefine_beep(codec)) {
14458 if (err < 0) { 14480 err = snd_hda_attach_beep_device(codec, 0x1);
14459 alc_free(codec); 14481 if (err < 0) {
14460 return err; 14482 alc_free(codec);
14483 return err;
14484 }
14461 } 14485 }
14462 14486
14463 if (board_config != ALC269_AUTO) 14487 if (board_config != ALC269_AUTO)
@@ -14490,7 +14514,7 @@ static int patch_alc269(struct hda_codec *codec)
14490 14514
14491 if (!spec->cap_mixer) 14515 if (!spec->cap_mixer)
14492 set_capture_mixer(codec); 14516 set_capture_mixer(codec);
14493 if (spec->cdefine.enable_pcbeep) 14517 if (has_cdefine_beep(codec))
14494 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 14518 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
14495 14519
14496 if (board_config == ALC269_AUTO) 14520 if (board_config == ALC269_AUTO)
@@ -18687,10 +18711,12 @@ static int patch_alc662(struct hda_codec *codec)
18687 } 18711 }
18688 } 18712 }
18689 18713
18690 err = snd_hda_attach_beep_device(codec, 0x1); 18714 if (has_cdefine_beep(codec)) {
18691 if (err < 0) { 18715 err = snd_hda_attach_beep_device(codec, 0x1);
18692 alc_free(codec); 18716 if (err < 0) {
18693 return err; 18717 alc_free(codec);
18718 return err;
18719 }
18694 } 18720 }
18695 18721
18696 if (board_config != ALC662_AUTO) 18722 if (board_config != ALC662_AUTO)
@@ -18712,7 +18738,7 @@ static int patch_alc662(struct hda_codec *codec)
18712 if (!spec->cap_mixer) 18738 if (!spec->cap_mixer)
18713 set_capture_mixer(codec); 18739 set_capture_mixer(codec);
18714 18740
18715 if (spec->cdefine.enable_pcbeep) { 18741 if (has_cdefine_beep(codec)) {
18716 switch (codec->vendor_id) { 18742 switch (codec->vendor_id) {
18717 case 0x10ec0662: 18743 case 0x10ec0662:
18718 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 18744 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c
index 495be6e71931..24454c98d0ee 100644
--- a/sound/soc/au1x/psc-i2s.c
+++ b/sound/soc/au1x/psc-i2s.c
@@ -300,7 +300,7 @@ struct snd_soc_dai au1xpsc_i2s_dai = {
300}; 300};
301EXPORT_SYMBOL(au1xpsc_i2s_dai); 301EXPORT_SYMBOL(au1xpsc_i2s_dai);
302 302
303static int __init au1xpsc_i2s_drvprobe(struct platform_device *pdev) 303static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev)
304{ 304{
305 struct resource *r; 305 struct resource *r;
306 unsigned long sel; 306 unsigned long sel;
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 31ac5538fe7e..5da30eb6ad00 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -83,8 +83,8 @@ config SND_SOC_ALL_CODECS
83 83
84config SND_SOC_WM_HUBS 84config SND_SOC_WM_HUBS
85 tristate 85 tristate
86 default y if SND_SOC_WM8993=y 86 default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y
87 default m if SND_SOC_WM8993=m 87 default m if SND_SOC_WM8993=m || SND_SOC_WM8994=m
88 88
89config SND_SOC_AC97_CODEC 89config SND_SOC_AC97_CODEC
90 tristate 90 tristate
diff --git a/sound/soc/codecs/wm8727.c b/sound/soc/codecs/wm8727.c
index 1072621e93fd..9d1df2628136 100644
--- a/sound/soc/codecs/wm8727.c
+++ b/sound/soc/codecs/wm8727.c
@@ -127,6 +127,8 @@ static __devinit int wm8727_platform_probe(struct platform_device *pdev)
127 goto err_codec; 127 goto err_codec;
128 } 128 }
129 129
130 return 0;
131
130err_codec: 132err_codec:
131 snd_soc_unregister_codec(codec); 133 snd_soc_unregister_codec(codec);
132err: 134err:
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index 7e4a627b4c7e..4e212ed62ea6 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -94,7 +94,6 @@ SOC_DAPM_SINGLE("Bypass Switch", WM8776_OUTMUX, 2, 1, 0),
94 94
95static const struct snd_soc_dapm_widget wm8776_dapm_widgets[] = { 95static const struct snd_soc_dapm_widget wm8776_dapm_widgets[] = {
96SND_SOC_DAPM_INPUT("AUX"), 96SND_SOC_DAPM_INPUT("AUX"),
97SND_SOC_DAPM_INPUT("AUX"),
98 97
99SND_SOC_DAPM_INPUT("AIN1"), 98SND_SOC_DAPM_INPUT("AIN1"),
100SND_SOC_DAPM_INPUT("AIN2"), 99SND_SOC_DAPM_INPUT("AIN2"),
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c
index 0417dae32e6f..19ad590ca0b3 100644
--- a/sound/soc/codecs/wm8988.c
+++ b/sound/soc/codecs/wm8988.c
@@ -885,7 +885,6 @@ static int wm8988_register(struct wm8988_priv *wm8988,
885 ret = snd_soc_register_dai(&wm8988_dai); 885 ret = snd_soc_register_dai(&wm8988_dai);
886 if (ret != 0) { 886 if (ret != 0) {
887 dev_err(codec->dev, "Failed to register DAI: %d\n", ret); 887 dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
888 snd_soc_unregister_codec(codec);
889 goto err_codec; 888 goto err_codec;
890 } 889 }
891 890
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 79f0f4ad242c..d3955096d872 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -612,7 +612,6 @@ static void davinci_hw_common_param(struct davinci_audio_dev *dev, int stream)
612 NUMDMA_MASK); 612 NUMDMA_MASK);
613 mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, 613 mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL,
614 ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK); 614 ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK);
615 mcasp_set_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
616 } 615 }
617 616
618 if (dev->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { 617 if (dev->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) {
@@ -623,7 +622,6 @@ static void davinci_hw_common_param(struct davinci_audio_dev *dev, int stream)
623 NUMDMA_MASK); 622 NUMDMA_MASK);
624 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, 623 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL,
625 ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK); 624 ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK);
626 mcasp_set_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
627 } 625 }
628} 626}
629 627
diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h
index 22208b373fb9..e1ec6d91ea38 100644
--- a/sound/soc/fsl/mpc5200_dma.h
+++ b/sound/soc/fsl/mpc5200_dma.h
@@ -73,7 +73,7 @@ struct psc_dma {
73}; 73};
74 74
75/* Utility for retrieving psc_dma_stream structure from a substream */ 75/* Utility for retrieving psc_dma_stream structure from a substream */
76inline struct psc_dma_stream * 76static inline struct psc_dma_stream *
77to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma) 77to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma)
78{ 78{
79 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) 79 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 3396a0db06ba..ec4acac49ebd 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -683,20 +683,15 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
683 683
684 /* clock inversion (CKG2) */ 684 /* clock inversion (CKG2) */
685 data = 0; 685 data = 0;
686 switch (SH_FSI_INVERSION_MASK & flags) { 686 if (SH_FSI_LRM_INV & flags)
687 case SH_FSI_LRM_INV: 687 data |= 1 << 12;
688 data = 1 << 12; 688 if (SH_FSI_BRM_INV & flags)
689 break; 689 data |= 1 << 8;
690 case SH_FSI_BRM_INV: 690 if (SH_FSI_LRS_INV & flags)
691 data = 1 << 8; 691 data |= 1 << 4;
692 break; 692 if (SH_FSI_BRS_INV & flags)
693 case SH_FSI_LRS_INV: 693 data |= 1 << 0;
694 data = 1 << 4; 694
695 break;
696 case SH_FSI_BRS_INV:
697 data = 1 << 0;
698 break;
699 }
700 fsi_reg_write(fsi, CKG2, data); 695 fsi_reg_write(fsi, CKG2, data);
701 696
702 /* do fmt, di fmt */ 697 /* do fmt, di fmt */
@@ -726,15 +721,15 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
726 break; 721 break;
727 case SH_FSI_FMT_TDM: 722 case SH_FSI_FMT_TDM:
728 msg = "TDM"; 723 msg = "TDM";
729 data = CR_FMT(CR_TDM) | (fsi->chan - 1);
730 fsi->chan = is_play ? 724 fsi->chan = is_play ?
731 SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags); 725 SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags);
726 data = CR_FMT(CR_TDM) | (fsi->chan - 1);
732 break; 727 break;
733 case SH_FSI_FMT_TDM_DELAY: 728 case SH_FSI_FMT_TDM_DELAY:
734 msg = "TDM Delay"; 729 msg = "TDM Delay";
735 data = CR_FMT(CR_TDM_D) | (fsi->chan - 1);
736 fsi->chan = is_play ? 730 fsi->chan = is_play ?
737 SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags); 731 SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags);
732 data = CR_FMT(CR_TDM_D) | (fsi->chan - 1);
738 break; 733 break;
739 default: 734 default:
740 dev_err(dai->dev, "unknown format.\n"); 735 dev_err(dai->dev, "unknown format.\n");
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index b7aadd614c70..b5855114667e 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -103,7 +103,8 @@ static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_i
103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), 103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0),
104 UAC2_CS_CUR, 104 UAC2_CS_CUR,
105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
106 UAC2_CX_CLOCK_SELECTOR << 8, selector_id << 8, 106 UAC2_CX_CLOCK_SELECTOR << 8,
107 snd_usb_ctrl_intf(chip) | (selector_id << 8),
107 &buf, sizeof(buf), 1000); 108 &buf, sizeof(buf), 1000);
108 109
109 if (ret < 0) 110 if (ret < 0)
@@ -120,7 +121,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)
120 121
121 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 122 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
122 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 123 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
123 UAC2_CS_CONTROL_CLOCK_VALID << 8, source_id << 8, 124 UAC2_CS_CONTROL_CLOCK_VALID << 8,
125 snd_usb_ctrl_intf(chip) | (source_id << 8),
124 &data, sizeof(data), 1000); 126 &data, sizeof(data), 1000);
125 127
126 if (err < 0) { 128 if (err < 0) {
@@ -269,7 +271,8 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
269 data[3] = rate >> 24; 271 data[3] = rate >> 24;
270 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, 272 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR,
271 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, 273 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
272 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 274 UAC2_CS_CONTROL_SAM_FREQ << 8,
275 snd_usb_ctrl_intf(chip) | (clock << 8),
273 data, sizeof(data), 1000)) < 0) { 276 data, sizeof(data), 1000)) < 0) {
274 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", 277 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n",
275 dev->devnum, iface, fmt->altsetting, rate); 278 dev->devnum, iface, fmt->altsetting, rate);
@@ -278,7 +281,8 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
278 281
279 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 282 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
280 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 283 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
281 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 284 UAC2_CS_CONTROL_SAM_FREQ << 8,
285 snd_usb_ctrl_intf(chip) | (clock << 8),
282 data, sizeof(data), 1000)) < 0) { 286 data, sizeof(data), 1000)) < 0) {
283 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", 287 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n",
284 dev->devnum, iface, fmt->altsetting); 288 dev->devnum, iface, fmt->altsetting);
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 9593b91452b9..6f6596cf2b19 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -427,6 +427,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
427 if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream, alts) < 0) { 427 if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream, alts) < 0) {
428 kfree(fp->rate_table); 428 kfree(fp->rate_table);
429 kfree(fp); 429 kfree(fp);
430 fp = NULL;
430 continue; 431 continue;
431 } 432 }
432 433
diff --git a/sound/usb/format.c b/sound/usb/format.c
index 5367cd1e52d9..30364aba79cc 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -206,6 +206,60 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
206} 206}
207 207
208/* 208/*
209 * Helper function to walk the array of sample rate triplets reported by
210 * the device. The problem is that we need to parse whole array first to
211 * get to know how many sample rates we have to expect.
212 * Then fp->rate_table can be allocated and filled.
213 */
214static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
215 const unsigned char *data)
216{
217 int i, nr_rates = 0;
218
219 fp->rates = fp->rate_min = fp->rate_max = 0;
220
221 for (i = 0; i < nr_triplets; i++) {
222 int min = combine_quad(&data[2 + 12 * i]);
223 int max = combine_quad(&data[6 + 12 * i]);
224 int res = combine_quad(&data[10 + 12 * i]);
225 int rate;
226
227 if ((max < 0) || (min < 0) || (res < 0) || (max < min))
228 continue;
229
230 /*
231 * for ranges with res == 1, we announce a continuous sample
232 * rate range, and this function should return 0 for no further
233 * parsing.
234 */
235 if (res == 1) {
236 fp->rate_min = min;
237 fp->rate_max = max;
238 fp->rates = SNDRV_PCM_RATE_CONTINUOUS;
239 return 0;
240 }
241
242 for (rate = min; rate <= max; rate += res) {
243 if (fp->rate_table)
244 fp->rate_table[nr_rates] = rate;
245 if (!fp->rate_min || rate < fp->rate_min)
246 fp->rate_min = rate;
247 if (!fp->rate_max || rate > fp->rate_max)
248 fp->rate_max = rate;
249 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
250
251 nr_rates++;
252
253 /* avoid endless loop */
254 if (res == 0)
255 break;
256 }
257 }
258
259 return nr_rates;
260}
261
262/*
209 * parse the format descriptor and stores the possible sample rates 263 * parse the format descriptor and stores the possible sample rates
210 * on the audioformat table (audio class v2). 264 * on the audioformat table (audio class v2).
211 */ 265 */
@@ -215,13 +269,20 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
215{ 269{
216 struct usb_device *dev = chip->dev; 270 struct usb_device *dev = chip->dev;
217 unsigned char tmp[2], *data; 271 unsigned char tmp[2], *data;
218 int i, nr_rates, data_size, ret = 0; 272 int nr_triplets, data_size, ret = 0;
219 int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock); 273 int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock);
220 274
275 if (clock < 0) {
276 snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n",
277 __func__, clock);
278 goto err;
279 }
280
221 /* get the number of sample rates first by only fetching 2 bytes */ 281 /* get the number of sample rates first by only fetching 2 bytes */
222 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 282 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
223 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 283 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
224 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 284 UAC2_CS_CONTROL_SAM_FREQ << 8,
285 snd_usb_ctrl_intf(chip) | (clock << 8),
225 tmp, sizeof(tmp), 1000); 286 tmp, sizeof(tmp), 1000);
226 287
227 if (ret < 0) { 288 if (ret < 0) {
@@ -230,8 +291,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
230 goto err; 291 goto err;
231 } 292 }
232 293
233 nr_rates = (tmp[1] << 8) | tmp[0]; 294 nr_triplets = (tmp[1] << 8) | tmp[0];
234 data_size = 2 + 12 * nr_rates; 295 data_size = 2 + 12 * nr_triplets;
235 data = kzalloc(data_size, GFP_KERNEL); 296 data = kzalloc(data_size, GFP_KERNEL);
236 if (!data) { 297 if (!data) {
237 ret = -ENOMEM; 298 ret = -ENOMEM;
@@ -241,7 +302,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
241 /* now get the full information */ 302 /* now get the full information */
242 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 303 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
243 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 304 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
244 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 305 UAC2_CS_CONTROL_SAM_FREQ << 8,
306 snd_usb_ctrl_intf(chip) | (clock << 8),
245 data, data_size, 1000); 307 data, data_size, 1000);
246 308
247 if (ret < 0) { 309 if (ret < 0) {
@@ -251,26 +313,28 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
251 goto err_free; 313 goto err_free;
252 } 314 }
253 315
254 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); 316 /* Call the triplet parser, and make sure fp->rate_table is NULL.
317 * We just use the return value to know how many sample rates we
318 * will have to deal with. */
319 kfree(fp->rate_table);
320 fp->rate_table = NULL;
321 fp->nr_rates = parse_uac2_sample_rate_range(fp, nr_triplets, data);
322
323 if (fp->nr_rates == 0) {
324 /* SNDRV_PCM_RATE_CONTINUOUS */
325 ret = 0;
326 goto err_free;
327 }
328
329 fp->rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL);
255 if (!fp->rate_table) { 330 if (!fp->rate_table) {
256 ret = -ENOMEM; 331 ret = -ENOMEM;
257 goto err_free; 332 goto err_free;
258 } 333 }
259 334
260 fp->nr_rates = 0; 335 /* Call the triplet parser again, but this time, fp->rate_table is
261 fp->rate_min = fp->rate_max = 0; 336 * allocated, so the rates will be stored */
262 337 parse_uac2_sample_rate_range(fp, nr_triplets, data);
263 for (i = 0; i < nr_rates; i++) {
264 int rate = combine_quad(&data[2 + 12 * i]);
265
266 fp->rate_table[fp->nr_rates] = rate;
267 if (!fp->rate_min || rate < fp->rate_min)
268 fp->rate_min = rate;
269 if (!fp->rate_max || rate > fp->rate_max)
270 fp->rate_max = rate;
271 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
272 fp->nr_rates++;
273 }
274 338
275err_free: 339err_free:
276 kfree(data); 340 kfree(data);
diff --git a/sound/usb/helper.h b/sound/usb/helper.h
index a6b0e51b3a9a..09bd943c43bf 100644
--- a/sound/usb/helper.h
+++ b/sound/usb/helper.h
@@ -28,5 +28,9 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,
28#define snd_usb_get_speed(dev) ((dev)->speed) 28#define snd_usb_get_speed(dev) ((dev)->speed)
29#endif 29#endif
30 30
31static inline int snd_usb_ctrl_intf(struct snd_usb_audio *chip)
32{
33 return get_iface_desc(chip->ctrl_intf)->bInterfaceNumber;
34}
31 35
32#endif /* __USBAUDIO_HELPER_H */ 36#endif /* __USBAUDIO_HELPER_H */
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index a060d005e209..736d134cc03c 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -297,20 +297,27 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v
297 297
298static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) 298static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
299{ 299{
300 unsigned char buf[14]; /* enough space for one range of 4 bytes */ 300 unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */
301 unsigned char *val; 301 unsigned char *val;
302 int ret; 302 int ret, size;
303 __u8 bRequest; 303 __u8 bRequest;
304 304
305 bRequest = (request == UAC_GET_CUR) ? 305 if (request == UAC_GET_CUR) {
306 UAC2_CS_CUR : UAC2_CS_RANGE; 306 bRequest = UAC2_CS_CUR;
307 size = sizeof(__u16);
308 } else {
309 bRequest = UAC2_CS_RANGE;
310 size = sizeof(buf);
311 }
312
313 memset(buf, 0, sizeof(buf));
307 314
308 ret = snd_usb_ctl_msg(cval->mixer->chip->dev, 315 ret = snd_usb_ctl_msg(cval->mixer->chip->dev,
309 usb_rcvctrlpipe(cval->mixer->chip->dev, 0), 316 usb_rcvctrlpipe(cval->mixer->chip->dev, 0),
310 bRequest, 317 bRequest,
311 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 318 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
312 validx, cval->mixer->ctrlif | (cval->id << 8), 319 validx, cval->mixer->ctrlif | (cval->id << 8),
313 buf, sizeof(buf), 1000); 320 buf, size, 1000);
314 321
315 if (ret < 0) { 322 if (ret < 0) {
316 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 323 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
@@ -318,6 +325,8 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
318 return ret; 325 return ret;
319 } 326 }
320 327
328 /* FIXME: how should we handle multiple triplets here? */
329
321 switch (request) { 330 switch (request) {
322 case UAC_GET_CUR: 331 case UAC_GET_CUR:
323 val = buf; 332 val = buf;
@@ -1098,6 +1107,19 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1098 } 1107 }
1099 break; 1108 break;
1100 1109
1110 case USB_ID(0x046d, 0x0809):
1111 case USB_ID(0x046d, 0x0991):
1112 /* Most audio usb devices lie about volume resolution.
1113 * Most Logitech webcams have res = 384.
1114 * Proboly there is some logitech magic behind this number --fishor
1115 */
1116 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
1117 snd_printk(KERN_INFO
1118 "set resolution quirk: cval->res = 384\n");
1119 cval->res = 384;
1120 }
1121 break;
1122
1101 } 1123 }
1102 1124
1103 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", 1125 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",