From: Lars-Peter Clausen <lars@metafoo.de>
To: Bard Liao <bardliao@realtek.com>
Cc: Oder Chiou <oder_chiou@realtek.com>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"swarren@nvidia.com" <swarren@nvidia.com>,
"swarren@wwwdotorg.org" <swarren@wwwdotorg.org>,
"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Flove <flove@realtek.com>
Subject: Re: [PATCH] ASoC: rt5640: change widgetsequencefordepop
Date: Tue, 06 Aug 2013 13:31:04 +0200 [thread overview]
Message-ID: <5200DE78.5060409@metafoo.de> (raw)
In-Reply-To: <1121E117AD4ECE49880A389A396215BB935C692E81@rtitmbs7.realtek.com.tw>
On 08/06/2013 01:04 PM, Bard Liao wrote:
>> -----Original Message-----
>> From: Lars-Peter Clausen [mailto:lars@metafoo.de]
>> Sent: Tuesday, August 06, 2013 6:17 PM
>> To: Bard Liao
>> Cc: Mark Brown; Oder Chiou; alsa-devel@alsa-project.org;
>> swarren@nvidia.com; swarren@wwwdotorg.org; lgirdwood@gmail.com; Flove
>> Subject: Re: [alsa-devel] [PATCH] ASoC: rt5640: change
>> widgetsequencefordepop
>>
>> On 08/06/2013 12:07 PM, Bard Liao wrote:
>>>> -----Original Message-----
>>>> From: Lars-Peter Clausen [mailto:lars@metafoo.de]
>>>> Sent: Tuesday, August 06, 2013 5:36 PM
>>>> To: Bard Liao
>>>> Cc: Mark Brown; Oder Chiou; alsa-devel@alsa-project.org;
>>>> swarren@nvidia.com; swarren@wwwdotorg.org; lgirdwood@gmail.com;
>> Flove
>>>> Subject: Re: [alsa-devel] [PATCH] ASoC: rt5640: change
>>>> widgetsequencefordepop
>>>>
>>>> On 08/06/2013 11:13 AM, Bard Liao wrote:
>>>>>>> I think I need to use SND_SOC_DAPM_SWITCH with
>>>>>> SOC_DAPM_SINGLE_AUTODISABLE for this control.
>>>>>>> Am I right?
>>>>>>> I am trying to do that, but meet a problem.
>>>>>>> If I set speaker switch unmute before playing music, dapm will
>>>>>>> mute it
>>>>>> automatically in power on sequence.
>>>>>>> The only way I can unmute speaker is set speaker switch unmute
>>>>>>> while
>>>>>> playing music.
>>>>>>
>>>>>> DAPM should unmute the switch on power up and mute it on power
>> down.
>>>>>> The Speaker Channel Switch control has the invert flag set did you
>>>>>> also set the invert flag for the new autodisable control?
>>>>>
>>>>> Yes, the related code is as below.
>>>>> static const struct snd_kcontrol_new spk_l_enable_control =
>>>>> SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5640_SPK_VOL,
>>>>> RT5640_L_MUTE_SFT, 1, 1);
>>>>>
>>>>> static const struct snd_kcontrol_new spk_r_enable_control =
>>>>> SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5640_SPK_VOL,
>>>>> RT5640_R_MUTE_SFT, 1, 1);
>>>>>
>>>>> SND_SOC_DAPM_SWITCH("Speaker L Playback", SND_SOC_NOPM, 0,
>> 0,
>>>>> &spk_l_enable_control),
>>>>> SND_SOC_DAPM_SWITCH("Speaker R Playback", SND_SOC_NOPM,
>> 0, 0,
>>>>> &spk_r_enable_control),
>>>>
>>>> Looks good. Maybe I got the invert = 1 case wrong somewhere. Can you
>>>> add a couple of printks and send me the result?
>>>
>>> The result is as below.
>>>
>>> [ 9.418738] new control: Speaker R Playback Switch 1
>>> [ 9.423949] new control: Speaker L Playback Switch 1
>>>
>>> root@tegra-ubuntu:/home/ubuntu# amixer cset name="Speaker L Playback
>>> Switch" 0 numid=25,iface=MIXER,name='Speaker L Playback Switch'
>>> ; type=BOOLEAN,access=rw------,values=1
>>> : values=off
>>> root@tegra-ubuntu:/home/ubuntu# dmesg -c [ 163.717158] Speaker L
>>> Playback Switch->on_val = 1 root@tegra-ubuntu:/home/ubuntu#
>>> root@tegra-ubuntu:/home/ubuntu# amixer cset name="Speaker L Playback
>>> Switch" 1 numid=25,iface=MIXER,name='Speaker L Playback Switch'
>>> ; type=BOOLEAN,access=rw------,values=1
>>> : values=on
>>> root@tegra-ubuntu:/home/ubuntu#
>>> root@tegra-ubuntu:/home/ubuntu# dmesg -c [ 174.482833] Speaker L
>>> Playback Switch->on_val = 0
>>
>> That looks right, right? on_val is what is going to be written to the control's
>> register. And in your case this needs to be 0 for unmute and 1 for mute. So why
>> would DAPM mute the control on power-up?
>
> I think the issue is that the on_val is set to be off_val in dapm_kcontrol_data_alloc.
> And if I launch "amixer cget name="Speaker L Playback Switch" after the system boot up immediately it will show values=on.
> I think it should show values=off, since the dapm path is actually disconnected.
> If I launch " amixer cset name="Speaker L Playback Switch" 1", the dapm path will be connected.
> But dapm_kcontrol_set_value will return false in if (data->value == value) condition.
> So the on_val will not be set in dapm_kcontrol_set_value, and will equal to off_val still.
> If I set "Speaker L Playback Switch" off and on, the issue will disappear.
Makes sense. So this should fix it, I guess:
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -229,6 +229,8 @@ static int dapm_kcontrol_data_alloc(struct
template.id = snd_soc_dapm_kcontrol;
template.name = kcontrol->id.name;
+ data->value = template.on_val;
+
data->widget = snd_soc_dapm_new_control(widget->dapm,
&template);
if (!data->widget) {
next prev parent reply other threads:[~2013-08-06 11:30 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-05 4:19 [PATCH] ASoC: rt5640: change widget sequence for depop bardliao
2013-08-05 14:48 ` Mark Brown
2013-08-05 17:21 ` Lars-Peter Clausen
2013-08-05 17:58 ` Mark Brown
2013-08-06 8:07 ` [PATCH] ASoC: rt5640: change widget sequencefordepop Bard Liao
2013-08-06 8:45 ` Lars-Peter Clausen
2013-08-06 9:13 ` [PATCH] ASoC: rt5640: change widgetsequencefordepop Bard Liao
2013-08-06 9:35 ` Lars-Peter Clausen
2013-08-06 10:07 ` Bard Liao
2013-08-06 10:16 ` Lars-Peter Clausen
2013-08-06 11:04 ` Bard Liao
2013-08-06 11:31 ` Lars-Peter Clausen [this message]
2013-08-07 1:32 ` Bard Liao
2013-08-07 5:40 ` Bard Liao
2013-08-07 7:45 ` Lars-Peter Clausen
2013-08-07 8:03 ` Bard Liao
2013-08-07 8:26 ` Lars-Peter Clausen
2013-08-07 8:31 ` Bard Liao
2013-08-07 9:36 ` Mark Brown
2013-08-07 10:47 ` Lars-Peter Clausen
2013-08-07 13:05 ` Mark Brown
2013-08-09 9:05 ` Bard Liao
2013-08-09 13:37 ` Lars-Peter Clausen
2013-08-09 14:58 ` Mark Brown
2013-08-12 7:27 ` Bard Liao
2013-08-05 17:17 ` [PATCH] ASoC: rt5640: change widget sequence for depop Stephen Warren
2013-08-05 17:19 ` Lars-Peter Clausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5200DE78.5060409@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=bardliao@realtek.com \
--cc=broonie@kernel.org \
--cc=flove@realtek.com \
--cc=lgirdwood@gmail.com \
--cc=oder_chiou@realtek.com \
--cc=swarren@nvidia.com \
--cc=swarren@wwwdotorg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).