From a110f4ef810ee29d810876df725f41d66629733e Mon Sep 17 00:00:00 2001 From: Marek Belisko Date: Wed, 9 Mar 2011 21:46:20 +0100 Subject: ASoC: mini2440: Fix uda134x codec problem. ASoC audio for mini2440 platform in current kenrel doesn't work. First problem is samsung_asoc_dma device is missing in initialization. Next problem is with codec. Codec is initialized but never probed because no platform_device exist for codec driver. It leads to errors during codec binding to asoc dai. Next problem was platform data which was passed from board to asoc main driver but not passed to codec when called codec_soc_probe(). Following patch should fix issues. But not sure if in correct way. Please review. Signed-off-by: Marek Belisko Acked-by: Liam Girdwood Signed-off-by: Mark Brown Cc: stable@kernel.org diff --git a/arch/arm/mach-s3c2440/mach-mini2440.c b/arch/arm/mach-s3c2440/mach-mini2440.c index f62bb4c..7c3fb07 100644 --- a/arch/arm/mach-s3c2440/mach-mini2440.c +++ b/arch/arm/mach-s3c2440/mach-mini2440.c @@ -506,6 +506,11 @@ static struct i2c_board_info mini2440_i2c_devs[] __initdata = { }, }; +static struct platform_device uda1340_codec = { + .name = "uda134x-codec", + .id = -1, +}; + static struct platform_device *mini2440_devices[] __initdata = { &s3c_device_ohci, &s3c_device_wdt, @@ -521,7 +526,9 @@ static struct platform_device *mini2440_devices[] __initdata = { &s3c_device_nand, &s3c_device_sdi, &s3c_device_iis, + &uda1340_codec, &mini2440_audio, + &samsung_asoc_dma, }; static void __init mini2440_map_io(void) diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index e76847a..48ffd40 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c @@ -486,7 +486,8 @@ static struct snd_soc_dai_driver uda134x_dai = { static int uda134x_soc_probe(struct snd_soc_codec *codec) { struct uda134x_priv *uda134x; - struct uda134x_platform_data *pd = dev_get_drvdata(codec->card->dev); + struct uda134x_platform_data *pd = codec->card->dev->platform_data; + int ret; printk(KERN_INFO "UDA134X SoC Audio Codec\n"); diff --git a/sound/soc/samsung/s3c24xx_uda134x.c b/sound/soc/samsung/s3c24xx_uda134x.c index 3cb7007..dc9d551 100644 --- a/sound/soc/samsung/s3c24xx_uda134x.c +++ b/sound/soc/samsung/s3c24xx_uda134x.c @@ -219,7 +219,7 @@ static struct snd_soc_ops s3c24xx_uda134x_ops = { static struct snd_soc_dai_link s3c24xx_uda134x_dai_link = { .name = "UDA134X", .stream_name = "UDA134X", - .codec_name = "uda134x-hifi", + .codec_name = "uda134x-codec", .codec_dai_name = "uda134x-hifi", .cpu_dai_name = "s3c24xx-iis", .ops = &s3c24xx_uda134x_ops, @@ -314,6 +314,7 @@ static int s3c24xx_uda134x_probe(struct platform_device *pdev) platform_set_drvdata(s3c24xx_uda134x_snd_device, &snd_soc_s3c24xx_uda134x); + platform_device_add_data(s3c24xx_uda134x_snd_device, &s3c24xx_uda134x, sizeof(s3c24xx_uda134x)); ret = platform_device_add(s3c24xx_uda134x_snd_device); if (ret) { printk(KERN_ERR "S3C24XX_UDA134X SoC Audio: Unable to add\n"); -- cgit v0.10.2 From b1a56b331aec59be04f25ac99694d855d591c539 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 16 Mar 2011 18:18:53 +0000 Subject: ASoC: Remove bogus check for register validity in debugfs write Since not all registers need to be cached and the cache is entirely optional anyway we shouldn't be checking that a register is in the cached range. If the register is invalid then the actual I/O code can determine that and report an error. Similarly, the step size can and should be enforced by the lower level code if it's important. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 17efacd..4dda589 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -259,8 +259,6 @@ static ssize_t codec_reg_write_file(struct file *file, while (*start == ' ') start++; reg = simple_strtoul(start, &start, 16); - if ((reg >= codec->driver->reg_cache_size) || (reg % step)) - return -EINVAL; while (*start == ' ') start++; if (strict_strtoul(start, 16, &value)) -- cgit v0.10.2 From 977a6ef3c0cb622b572fb8e2e5088dbe09521375 Mon Sep 17 00:00:00 2001 From: Xiaochen Wang Date: Fri, 18 Mar 2011 16:29:25 +0800 Subject: sound: read i_size with i_size_read() Convert direct read of inode->i_size to using i_size_read(). i_size_read is guaranteed to return a valid value and its caller does not need to use addtional locking. Signed-off-by: Xiaochen Wang Signed-off-by: Takashi Iwai diff --git a/sound/sound_firmware.c b/sound/sound_firmware.c index 340a0bc..7e96249 100644 --- a/sound/sound_firmware.c +++ b/sound/sound_firmware.c @@ -19,7 +19,7 @@ static int do_mod_firmware_load(const char *fn, char **fp) printk(KERN_INFO "Unable to load '%s'.\n", fn); return 0; } - l = filp->f_path.dentry->d_inode->i_size; + l = i_size_read(filp->f_path.dentry->d_inode); if (l <= 0 || l > 131072) { printk(KERN_INFO "Invalid firmware '%s'\n", fn); -- cgit v0.10.2 From 3ffc1222bd2c30b0ef2d3a797b0e0070c7c61a98 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 21 Mar 2011 12:00:00 +0100 Subject: ALSA: usb - Remove trailing spaces from USB card name strings Some USB devices give trailing spaces in strings returned from usb_string(). This confuses the automatic card-id creation, resulting always in "default". This patch fixes the behavior by removing trailing spaces. Signed-off-by: Takashi Iwai diff --git a/sound/usb/card.c b/sound/usb/card.c index 40722f8..a90662a 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -283,6 +284,15 @@ static int snd_usb_audio_dev_free(struct snd_device *device) return snd_usb_audio_free(chip); } +static void remove_trailing_spaces(char *str) +{ + char *p; + + if (!*str) + return; + for (p = str + strlen(str) - 1; p >= str && isspace(*p); p--) + *p = 0; +} /* * create a chip instance and set its names. @@ -351,7 +361,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, snd_component_add(card, component); /* retrieve the device string as shortname */ - if (quirk && quirk->product_name) { + if (quirk && quirk->product_name && *quirk->product_name) { strlcpy(card->shortname, quirk->product_name, sizeof(card->shortname)); } else { if (!dev->descriptor.iProduct || @@ -363,9 +373,10 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, USB_ID_PRODUCT(chip->usb_id)); } } + remove_trailing_spaces(card->shortname); /* retrieve the vendor and device strings as longname */ - if (quirk && quirk->vendor_name) { + if (quirk && quirk->vendor_name && *quirk->vendor_name) { len = strlcpy(card->longname, quirk->vendor_name, sizeof(card->longname)); } else { if (dev->descriptor.iManufacturer) @@ -375,8 +386,11 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, len = 0; /* we don't really care if there isn't any vendor string */ } - if (len > 0) - strlcat(card->longname, " ", sizeof(card->longname)); + if (len > 0) { + remove_trailing_spaces(card->longname); + if (*card->longname) + strlcat(card->longname, " ", sizeof(card->longname)); + } strlcat(card->longname, card->shortname, sizeof(card->longname)); -- cgit v0.10.2 From 75eb1c311da47d32ba47825226e110df703b35d0 Mon Sep 17 00:00:00 2001 From: Andres Mejia Date: Sun, 20 Mar 2011 14:07:40 -0400 Subject: ALSA: hda - Set EAPD for Realtek ALC665 Set EAPD for Realtek ALC665 (Vendor Id: 0x10eSet EAPD for Realtek ALC665 (Vendor Id: 0x10ec0665). Signed-off-by: Andres Mejia Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f1a03f2..28f95d1 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1265,6 +1265,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) case 0x10ec0660: case 0x10ec0662: case 0x10ec0663: + case 0x10ec0665: case 0x10ec0862: case 0x10ec0889: set_eapd(codec, 0x14, 1); @@ -4240,6 +4241,7 @@ static void alc_power_eapd(struct hda_codec *codec) case 0x10ec0660: case 0x10ec0662: case 0x10ec0663: + case 0x10ec0665: case 0x10ec0862: case 0x10ec0889: set_eapd(codec, 0x14, 0); -- cgit v0.10.2 From bff5fbf50bd498c217994bd2d41a53ac3141185a Mon Sep 17 00:00:00 2001 From: Lydia Wang Date: Tue, 22 Mar 2011 16:21:38 +0800 Subject: ALSA: hda - VIA: Fix stereo mixer recording no sound issue Modify function via_mux_enum_put() to fix stereo mixer recording no sound issue. Signed-off-by: Lydia Wang Cc: Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 63b0054..5bc9bd9 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1101,6 +1101,7 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol, struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct via_spec *spec = codec->spec; unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + int ret; if (!spec->mux_nids[adc_idx]) return -EINVAL; @@ -1109,12 +1110,14 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol, AC_VERB_GET_POWER_STATE, 0x00) != AC_PWRST_D0) snd_hda_codec_write(codec, spec->mux_nids[adc_idx], 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); - /* update jack power state */ - set_jack_power_state(codec); - return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, + ret = snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); + /* update jack power state */ + set_jack_power_state(codec); + + return ret; } static int via_independent_hp_info(struct snd_kcontrol *kcontrol, -- cgit v0.10.2 From ce0e5a9e81fbb153ee15ca60246c6722f07fc546 Mon Sep 17 00:00:00 2001 From: Lydia Wang Date: Tue, 22 Mar 2011 16:22:37 +0800 Subject: ALSA: hda - VIA: Fix independent headphone no sound issue Modify via_independent_hp_put() function to support VT1718S and VT1812 codecs, and fix independent headphone no sound issue. Signed-off-by: Lydia Wang Cc: Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 5bc9bd9..2f605e5 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1191,8 +1191,16 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol, /* Get Independent Mode index of headphone pin widget */ spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel ? 1 : 0; - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel); + if (spec->codec_type == VT1718S) + snd_hda_codec_write(codec, nid, 0, + AC_VERB_SET_CONNECT_SEL, pinsel ? 2 : 0); + else + snd_hda_codec_write(codec, nid, 0, + AC_VERB_SET_CONNECT_SEL, pinsel); + if (spec->codec_type == VT1812) + snd_hda_codec_write(codec, 0x35, 0, + AC_VERB_SET_CONNECT_SEL, pinsel); if (spec->multiout.hp_nid && spec->multiout.hp_nid != spec->multiout.dac_nids[HDA_FRONT]) snd_hda_codec_setup_stream(codec, spec->multiout.hp_nid, @@ -1211,6 +1219,8 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol, activate_ctl(codec, "Headphone Playback Switch", spec->hp_independent_mode); } + /* update jack power state */ + set_jack_power_state(codec); return 0; } -- cgit v0.10.2 From ab657e0cacc39d88145871c6a3c844597c02d406 Mon Sep 17 00:00:00 2001 From: Lydia Wang Date: Tue, 22 Mar 2011 16:23:23 +0800 Subject: ALSA: hda - VIA: Add missing support for VT1718S in A-A path Modify mute_aa_path() function to support VT1718S codec. Signed-off-by: Lydia Wang Cc: Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 2f605e5..23e58f0 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1323,6 +1323,11 @@ static void mute_aa_path(struct hda_codec *codec, int mute) start_idx = 2; end_idx = 4; break; + case VT1718S: + nid_mixer = 0x21; + start_idx = 1; + end_idx = 3; + break; default: return; } -- cgit v0.10.2 From 169222813eec8403c76394fb7b35ecab98e3c607 Mon Sep 17 00:00:00 2001 From: Lydia Wang Date: Tue, 22 Mar 2011 16:24:10 +0800 Subject: ALSA: hda - VIA: Fix invalid A-A path volume adjust issue Modify vt_auto_create_analog_input_ctls() function to fix invalid a-a path volume adjust issue for VT1708S, VT1702 and VT1716S codecs. Signed-off-by: Lydia Wang Cc: Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 23e58f0..299a18b 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -2456,7 +2456,14 @@ static int vt_auto_create_analog_input_ctls(struct hda_codec *codec, else type_idx = 0; label = hda_get_autocfg_input_label(codec, cfg, i); - err = via_new_analog_input(spec, label, type_idx, idx, cap_nid); + if (spec->codec_type == VT1708S || + spec->codec_type == VT1702 || + spec->codec_type == VT1716S) + err = via_new_analog_input(spec, label, type_idx, + idx+1, cap_nid); + else + err = via_new_analog_input(spec, label, type_idx, + idx, cap_nid); if (err < 0) return err; snd_hda_add_imux_item(imux, label, idx, NULL); -- cgit v0.10.2 From 0341ccd7557fecafe6a79c55158670cf629d269e Mon Sep 17 00:00:00 2001 From: Lydia Wang Date: Tue, 22 Mar 2011 16:25:03 +0800 Subject: ALSA: hda - VIA: Fix codec type for VT1708BCE at the right timing Add get_codec_type() in via_new_spec() function to make sure getting correct codec type before building mixer controls. Signed-off-by: Lydia Wang Cc: Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 299a18b..269bb36 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -159,6 +159,7 @@ struct via_spec { #endif }; +static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec); static struct via_spec * via_new_spec(struct hda_codec *codec) { struct via_spec *spec; @@ -169,6 +170,10 @@ static struct via_spec * via_new_spec(struct hda_codec *codec) codec->spec = spec; spec->codec = codec; + spec->codec_type = get_codec_type(codec); + /* VT1708BCE & VT1708S are almost same */ + if (spec->codec_type == VT1708BCE) + spec->codec_type = VT1708S; return spec; } @@ -2203,10 +2208,6 @@ static int via_init(struct hda_codec *codec) for (i = 0; i < spec->num_iverbs; i++) snd_hda_sequence_write(codec, spec->init_verbs[i]); - spec->codec_type = get_codec_type(codec); - if (spec->codec_type == VT1708BCE) - spec->codec_type = VT1708S; /* VT1708BCE & VT1708S are almost - same */ /* Lydia Add for EAPD enable */ if (!spec->dig_in_nid) { /* No Digital In connection */ if (spec->dig_in_pin) { -- cgit v0.10.2 From 970f630f5adcefb2841338929e209d970001d919 Mon Sep 17 00:00:00 2001 From: Lydia Wang Date: Tue, 22 Mar 2011 16:25:56 +0800 Subject: ALSA: hda - VIA: Correct stream names for VT1818S Correct stream names of analog playback and capture streams for VT1818S. Signed-off-by: Lydia Wang Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 269bb36..7e317f9 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -4173,6 +4173,11 @@ static int patch_vt1708S(struct hda_codec *codec) spec->stream_name_analog = "VT1708BCE Analog"; spec->stream_name_digital = "VT1708BCE Digital"; } + /* correct names for VT1818S */ + if (codec->vendor_id == 0x11060440) { + spec->stream_name_analog = "VT1818S Analog"; + spec->stream_name_digital = "VT1818S Digital"; + } return 0; } -- cgit v0.10.2 From ee3c35c0827de02de414d08b2ddcbb910c2263ab Mon Sep 17 00:00:00 2001 From: Lydia Wang Date: Tue, 22 Mar 2011 16:26:36 +0800 Subject: ALSA: hda - VIA: Fix VT1708 can't build up Headphone control issue Since VT1708 didn't support the control of getting connection number, building of headphone control will fail in via_hp_build() function. Signed-off-by: Lydia Wang Cc: Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 7e317f9..1371b57c 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1266,9 +1266,12 @@ static int via_hp_build(struct hda_codec *codec) break; } - nums = snd_hda_get_connections(codec, nid, conn, HDA_MAX_CONNECTIONS); - if (nums <= 1) - return 0; + if (spec->codec_type != VT1708) { + nums = snd_hda_get_connections(codec, nid, + conn, HDA_MAX_CONNECTIONS); + if (nums <= 1) + return 0; + } knew = via_clone_control(spec, &via_hp_mixer[0]); if (knew == NULL) -- cgit v0.10.2 From 333802e90d3f0366c4a1cb767e2783d2e1df73a8 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 22 Mar 2011 12:02:33 +0000 Subject: ASoC: Support !REGULATOR build for sgtl5000 The regulator is optional depending on board design. Signed-off-by: Mark Brown Acked-by: Liam Girdwood diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 1f7217f..ff29380 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -772,6 +772,7 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, return 0; } +#ifdef CONFIG_REGULATOR static int ldo_regulator_is_enabled(struct regulator_dev *dev) { struct ldo_regulator *ldo = rdev_get_drvdata(dev); @@ -901,6 +902,19 @@ static int ldo_regulator_remove(struct snd_soc_codec *codec) return 0; } +#else +static int ldo_regulator_register(struct snd_soc_codec *codec, + struct regulator_init_data *init_data, + int voltage) +{ + return -EINVAL; +} + +static int ldo_regulator_remove(struct snd_soc_codec *codec) +{ + return 0; +} +#endif /* * set dac bias -- cgit v0.10.2 From 5a8826463c19b0d1a2fc60b2adac0ec318047844 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Wed, 23 Mar 2011 08:35:07 +0100 Subject: ALSA: HDA: Realtek: Avoid unnecessary volume control index on Surround/Side Similar to commit 7e59e097c09b82760bb0fe08b0fa2b704d76c3f4, this patch avoids unnecessary volume control indices for more Realtek auto-parsers, e g the ALC66x family, on the "Surround" and "Side" controls. These indices cause these volume controls to be ignored by PulseAudio and vmaster and should be removed whenever possible. Cc: stable@kernel.org Reported-by: Jan Losinski Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 28f95d1..5d582de 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -16008,9 +16008,12 @@ static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec, return err; } else { const char *name = pfx; - if (!name) + int index = i; + if (!name) { name = chname[i]; - err = __alc861_create_out_sw(codec, name, nid, i, 3); + index = 0; + } + err = __alc861_create_out_sw(codec, name, nid, index, 3); if (err < 0) return err; } @@ -17161,16 +17164,19 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, return err; } else { const char *name = pfx; - if (!name) + int index = i; + if (!name) { name = chname[i]; + index = 0; + } err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, - name, i, + name, index, HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); if (err < 0) return err; err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, - name, i, + name, index, HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); if (err < 0) @@ -19219,12 +19225,15 @@ static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec, return err; } else { const char *name = pfx; - if (!name) + int index = i; + if (!name) { name = chname[i]; - err = __alc662_add_vol_ctl(spec, name, nid, i, 3); + index = 0; + } + err = __alc662_add_vol_ctl(spec, name, nid, index, 3); if (err < 0) return err; - err = __alc662_add_sw_ctl(spec, name, mix, i, 3); + err = __alc662_add_sw_ctl(spec, name, mix, index, 3); if (err < 0) return err; } -- cgit v0.10.2