[PATCH] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state
From: Abhijeet KumarIn usecases like hot plug-unplug DP panel or modeset during a playback, sometimes we observe no audio after codec resets. During no audio condition, we have noticed that the power state of the pin or the connector is D3. Optimizing the way we set the power mitigates the issue. With this changes the verb is sent to set the power state and waits until actual state reaches target state. Thus ensuring power state is set. Signed-off-by: Abhijeet Kumar --- sound/soc/codecs/hdac_hdmi.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index dba6f4c5074a..0483afc40db6 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -718,10 +718,22 @@ static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev, static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, hda_nid_t nid, unsigned int pwr_state) { + int count; + unsigned int state; + if (get_wcaps(>hdev, nid) & AC_WCAP_POWER) { - if (!snd_hdac_check_power_state(>hdev, nid, pwr_state)) - snd_hdac_codec_write(>hdev, nid, 0, - AC_VERB_SET_POWER_STATE, pwr_state); + if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) { + for (count = 0; count < 10; count++) { + snd_hdac_codec_read(>hdac, nid, 0, + AC_VERB_SET_POWER_STATE, + pwr_state); + state = snd_hdac_sync_power_state(>hdac, + nid, pwr_state); + if (!(state & AC_PWRST_ERROR)) + break; + } + } + } } -- 1.9.1
[PATCH] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state
From: Abhijeet Kumar In usecases like hot plug-unplug DP panel or modeset during a playback, sometimes we observe no audio after codec resets. During no audio condition, we have noticed that the power state of the pin or the connector is D3. Optimizing the way we set the power mitigates the issue. With this changes the verb is sent to set the power state and waits until actual state reaches target state. Thus ensuring power state is set. Signed-off-by: Abhijeet Kumar --- sound/soc/codecs/hdac_hdmi.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index dba6f4c5074a..0483afc40db6 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -718,10 +718,22 @@ static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev, static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, hda_nid_t nid, unsigned int pwr_state) { + int count; + unsigned int state; + if (get_wcaps(>hdev, nid) & AC_WCAP_POWER) { - if (!snd_hdac_check_power_state(>hdev, nid, pwr_state)) - snd_hdac_codec_write(>hdev, nid, 0, - AC_VERB_SET_POWER_STATE, pwr_state); + if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) { + for (count = 0; count < 10; count++) { + snd_hdac_codec_read(>hdac, nid, 0, + AC_VERB_SET_POWER_STATE, + pwr_state); + state = snd_hdac_sync_power_state(>hdac, + nid, pwr_state); + if (!(state & AC_PWRST_ERROR)) + break; + } + } + } } -- 1.9.1
Re: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
On Fri, 12 Jan 2018 11:37:28 +0100, Kumar, Abhijeet wrote: > > > It's better, but doesn't guarantee that the node reached the given power > > state. codec_read assures that the verb is sent and the codec gives the > > response. But it means only the target state gets updated, and doesn't > > mean that the actual state reached. > > Thanks Takashi for replying. I guess, I should make use of return value from > codec_read and retry if power state is not set properly! I'll make those > changes and update again. And just wondering, how does hdmi_codec_prepare() > and hdmi_codec_complete() gurantee while powering up and down the afg ? There are two power states in the codec node: the target and the actual. By setting the power state, the target is set, but the actual state change may still take some time. In such a case, you'd need to wait until the actual state reaches. See hda_sync_power_state() in the hda legacy. Takashi
Re: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
On Fri, 12 Jan 2018 11:37:28 +0100, Kumar, Abhijeet wrote: > > > It's better, but doesn't guarantee that the node reached the given power > > state. codec_read assures that the verb is sent and the codec gives the > > response. But it means only the target state gets updated, and doesn't > > mean that the actual state reached. > > Thanks Takashi for replying. I guess, I should make use of return value from > codec_read and retry if power state is not set properly! I'll make those > changes and update again. And just wondering, how does hdmi_codec_prepare() > and hdmi_codec_complete() gurantee while powering up and down the afg ? There are two power states in the codec node: the target and the actual. By setting the power state, the target is set, but the actual state change may still take some time. In such a case, you'd need to wait until the actual state reaches. See hda_sync_power_state() in the hda legacy. Takashi
RE: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
> It's better, but doesn't guarantee that the node reached the given power > state. codec_read assures that the verb is sent and the codec gives the > response. But it means only the target state gets updated, and doesn't mean > that the actual state reached. Thanks Takashi for replying. I guess, I should make use of return value from codec_read and retry if power state is not set properly! I'll make those changes and update again. And just wondering, how does hdmi_codec_prepare() and hdmi_codec_complete() gurantee while powering up and down the afg ? Warm Regards, Abhijeet
RE: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
> It's better, but doesn't guarantee that the node reached the given power > state. codec_read assures that the verb is sent and the codec gives the > response. But it means only the target state gets updated, and doesn't mean > that the actual state reached. Thanks Takashi for replying. I guess, I should make use of return value from codec_read and retry if power state is not set properly! I'll make those changes and update again. And just wondering, how does hdmi_codec_prepare() and hdmi_codec_complete() gurantee while powering up and down the afg ? Warm Regards, Abhijeet
Re: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
On Fri, 12 Jan 2018 09:25:54 +0100, Kumar, Abhijeet wrote: > > > > On 1/12/2018 11:16 AM, Vinod Koul wrote: > > On Thu, Jan 11, 2018 at 05:04:27PM +0530, abhijeet.ku...@intel.com wrote: > >> From: Abhijeet Kumar> >> > >> When we change the resolution of DP pannel or hot plug-unplug it while > >> playing an audio clip,sometimes we observe a silent playback(no audio). > > can you rephrase this please > done please review v2! > >> During no audio condition, we have noticed that the power state of the > >> pin or the connector is D3. Optimzing the way we set the power could > >> mitigate the issue.With this changes the verb is sent to set the power > > space after . > > > >> state and response is received. Thus ensuring power state is set. > > am not sure I fully understood the problem here > > This appears to be an timing issue, while performing a stress test, we > found out that sometimes either pin or converters are not powered > up. Thus ensuring it that the power state is set correctly. > > > > >> Signed-off-by: Abhijeet Kumar > >> --- > >> sound/soc/codecs/hdac_hdmi.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c > >> index f3b4f4dfae6a..e24caecf0a4f 100644 > >> --- a/sound/soc/codecs/hdac_hdmi.c > >> +++ b/sound/soc/codecs/hdac_hdmi.c > >> @@ -718,7 +718,7 @@ static void hdac_hdmi_set_power_state(struct > >> hdac_ext_device *edev, > >> { > >>if (get_wcaps(>hdac, nid) & AC_WCAP_POWER) { > >>if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) > >> - snd_hdac_codec_write(>hdac, nid, 0, > >> + snd_hdac_codec_read(>hdac, nid, 0, > > how does read help instead of write? > > Indeed i'm making use of read instead of write to send the set command. > > But unlike codec_write, codec_read send the verb synchronously. Maybe > if you read the comment while powering up and down in > hdmi_codec_prepare and hdmi_codec_complete you would understand > better. > > "codec_read is preferred over codec_write to set the power state. > > This way verb is send to set the power state and response is > received. So setting power state is ensured without using loop to read > the state." It's better, but doesn't guarantee that the node reached the given power state. codec_read assures that the verb is sent and the codec gives the response. But it means only the target state gets updated, and doesn't mean that the actual state reached. thanks, Takashi
Re: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
On Fri, 12 Jan 2018 09:25:54 +0100, Kumar, Abhijeet wrote: > > > > On 1/12/2018 11:16 AM, Vinod Koul wrote: > > On Thu, Jan 11, 2018 at 05:04:27PM +0530, abhijeet.ku...@intel.com wrote: > >> From: Abhijeet Kumar > >> > >> When we change the resolution of DP pannel or hot plug-unplug it while > >> playing an audio clip,sometimes we observe a silent playback(no audio). > > can you rephrase this please > done please review v2! > >> During no audio condition, we have noticed that the power state of the > >> pin or the connector is D3. Optimzing the way we set the power could > >> mitigate the issue.With this changes the verb is sent to set the power > > space after . > > > >> state and response is received. Thus ensuring power state is set. > > am not sure I fully understood the problem here > > This appears to be an timing issue, while performing a stress test, we > found out that sometimes either pin or converters are not powered > up. Thus ensuring it that the power state is set correctly. > > > > >> Signed-off-by: Abhijeet Kumar > >> --- > >> sound/soc/codecs/hdac_hdmi.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c > >> index f3b4f4dfae6a..e24caecf0a4f 100644 > >> --- a/sound/soc/codecs/hdac_hdmi.c > >> +++ b/sound/soc/codecs/hdac_hdmi.c > >> @@ -718,7 +718,7 @@ static void hdac_hdmi_set_power_state(struct > >> hdac_ext_device *edev, > >> { > >>if (get_wcaps(>hdac, nid) & AC_WCAP_POWER) { > >>if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) > >> - snd_hdac_codec_write(>hdac, nid, 0, > >> + snd_hdac_codec_read(>hdac, nid, 0, > > how does read help instead of write? > > Indeed i'm making use of read instead of write to send the set command. > > But unlike codec_write, codec_read send the verb synchronously. Maybe > if you read the comment while powering up and down in > hdmi_codec_prepare and hdmi_codec_complete you would understand > better. > > "codec_read is preferred over codec_write to set the power state. > > This way verb is send to set the power state and response is > received. So setting power state is ensured without using loop to read > the state." It's better, but doesn't guarantee that the node reached the given power state. codec_read assures that the verb is sent and the codec gives the response. But it means only the target state gets updated, and doesn't mean that the actual state reached. thanks, Takashi
RE: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
> can you rephrase this please done please review v2! https://patchwork.kernel.org/patch/10159791/ > am not sure I fully understood the problem here This appears to be an timing issue, while performing a stress test, we found out that sometimes either pin or converters are not powered up. Thus ensuring it that the power state is set correctly. > how does read help instead of write? Indeed i'm making use of read instead of write to send the set command. But unlike codec_write, codec_read send the verb synchronously. Maybe if you read the comment while powering up and down afg in hdmi_codec_prepare and hdmi_codec_complete you would understand better. "codec_read is preferred over codec_write to set the power state. This way verb is send to set the power state and response is received. So setting power state is ensured without using loop to read the state." -Original Message- From: Koul, Vinod Sent: Friday, January 12, 2018 11:17 AM To: Kumar, Abhijeet <abhijeet.ku...@intel.com> Cc: Liam Girdwood <lgirdw...@gmail.com>; Mark Brown <broo...@kernel.org>; Jaroslav Kysela <pe...@perex.cz>; Takashi Iwai <ti...@suse.com>; Kp, Jeeja <jeeja...@intel.com>; Prusty, Subhransu S <subhransu.s.pru...@intel.com>; Singh, Guneshwor O <guneshwor.o.si...@intel.com>; Tayal, SandeepX <sandeepx.ta...@intel.com>; alsa-de...@alsa-project.org; linux-kernel@vger.kernel.org Subject: Re: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state On Thu, Jan 11, 2018 at 05:04:27PM +0530, abhijeet.ku...@intel.com wrote: > From: Abhijeet Kumar <abhijeet.ku...@intel.com> > > When we change the resolution of DP pannel or hot plug-unplug it while > playing an audio clip,sometimes we observe a silent playback(no audio). can you rephrase this please > During no audio condition, we have noticed that the power state of the > pin or the connector is D3. Optimzing the way we set the power could > mitigate the issue.With this changes the verb is sent to set the power space after . > state and response is received. Thus ensuring power state is set. am not sure I fully understood the problem here > > Signed-off-by: Abhijeet Kumar <abhijeet.ku...@intel.com> > --- > sound/soc/codecs/hdac_hdmi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/soc/codecs/hdac_hdmi.c > b/sound/soc/codecs/hdac_hdmi.c index f3b4f4dfae6a..e24caecf0a4f 100644 > --- a/sound/soc/codecs/hdac_hdmi.c > +++ b/sound/soc/codecs/hdac_hdmi.c > @@ -718,7 +718,7 @@ static void hdac_hdmi_set_power_state(struct > hdac_ext_device *edev, { > if (get_wcaps(>hdac, nid) & AC_WCAP_POWER) { > if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) > - snd_hdac_codec_write(>hdac, nid, 0, > + snd_hdac_codec_read(>hdac, nid, 0, how does read help instead of write? -- ~Vinod
RE: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
> can you rephrase this please done please review v2! https://patchwork.kernel.org/patch/10159791/ > am not sure I fully understood the problem here This appears to be an timing issue, while performing a stress test, we found out that sometimes either pin or converters are not powered up. Thus ensuring it that the power state is set correctly. > how does read help instead of write? Indeed i'm making use of read instead of write to send the set command. But unlike codec_write, codec_read send the verb synchronously. Maybe if you read the comment while powering up and down afg in hdmi_codec_prepare and hdmi_codec_complete you would understand better. "codec_read is preferred over codec_write to set the power state. This way verb is send to set the power state and response is received. So setting power state is ensured without using loop to read the state." -Original Message- From: Koul, Vinod Sent: Friday, January 12, 2018 11:17 AM To: Kumar, Abhijeet Cc: Liam Girdwood ; Mark Brown ; Jaroslav Kysela ; Takashi Iwai ; Kp, Jeeja ; Prusty, Subhransu S ; Singh, Guneshwor O ; Tayal, SandeepX ; alsa-de...@alsa-project.org; linux-kernel@vger.kernel.org Subject: Re: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state On Thu, Jan 11, 2018 at 05:04:27PM +0530, abhijeet.ku...@intel.com wrote: > From: Abhijeet Kumar > > When we change the resolution of DP pannel or hot plug-unplug it while > playing an audio clip,sometimes we observe a silent playback(no audio). can you rephrase this please > During no audio condition, we have noticed that the power state of the > pin or the connector is D3. Optimzing the way we set the power could > mitigate the issue.With this changes the verb is sent to set the power space after . > state and response is received. Thus ensuring power state is set. am not sure I fully understood the problem here > > Signed-off-by: Abhijeet Kumar > --- > sound/soc/codecs/hdac_hdmi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/soc/codecs/hdac_hdmi.c > b/sound/soc/codecs/hdac_hdmi.c index f3b4f4dfae6a..e24caecf0a4f 100644 > --- a/sound/soc/codecs/hdac_hdmi.c > +++ b/sound/soc/codecs/hdac_hdmi.c > @@ -718,7 +718,7 @@ static void hdac_hdmi_set_power_state(struct > hdac_ext_device *edev, { > if (get_wcaps(>hdac, nid) & AC_WCAP_POWER) { > if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) > - snd_hdac_codec_write(>hdac, nid, 0, > + snd_hdac_codec_read(>hdac, nid, 0, how does read help instead of write? -- ~Vinod
Re: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
On Thu, Jan 11, 2018 at 05:04:27PM +0530, abhijeet.ku...@intel.com wrote: > From: Abhijeet Kumar> > When we change the resolution of DP pannel or hot plug-unplug it while > playing an audio clip,sometimes we observe a silent playback(no audio). can you rephrase this please > During no audio condition, we have noticed that the power state of the > pin or the connector is D3. Optimzing the way we set the power could > mitigate the issue.With this changes the verb is sent to set the power space after . > state and response is received. Thus ensuring power state is set. am not sure I fully understood the problem here > > Signed-off-by: Abhijeet Kumar > --- > sound/soc/codecs/hdac_hdmi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c > index f3b4f4dfae6a..e24caecf0a4f 100644 > --- a/sound/soc/codecs/hdac_hdmi.c > +++ b/sound/soc/codecs/hdac_hdmi.c > @@ -718,7 +718,7 @@ static void hdac_hdmi_set_power_state(struct > hdac_ext_device *edev, > { > if (get_wcaps(>hdac, nid) & AC_WCAP_POWER) { > if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) > - snd_hdac_codec_write(>hdac, nid, 0, > + snd_hdac_codec_read(>hdac, nid, 0, how does read help instead of write? -- ~Vinod
Re: [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
On Thu, Jan 11, 2018 at 05:04:27PM +0530, abhijeet.ku...@intel.com wrote: > From: Abhijeet Kumar > > When we change the resolution of DP pannel or hot plug-unplug it while > playing an audio clip,sometimes we observe a silent playback(no audio). can you rephrase this please > During no audio condition, we have noticed that the power state of the > pin or the connector is D3. Optimzing the way we set the power could > mitigate the issue.With this changes the verb is sent to set the power space after . > state and response is received. Thus ensuring power state is set. am not sure I fully understood the problem here > > Signed-off-by: Abhijeet Kumar > --- > sound/soc/codecs/hdac_hdmi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c > index f3b4f4dfae6a..e24caecf0a4f 100644 > --- a/sound/soc/codecs/hdac_hdmi.c > +++ b/sound/soc/codecs/hdac_hdmi.c > @@ -718,7 +718,7 @@ static void hdac_hdmi_set_power_state(struct > hdac_ext_device *edev, > { > if (get_wcaps(>hdac, nid) & AC_WCAP_POWER) { > if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) > - snd_hdac_codec_write(>hdac, nid, 0, > + snd_hdac_codec_read(>hdac, nid, 0, how does read help instead of write? -- ~Vinod
[PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
From: Abhijeet KumarWhen we change the resolution of DP pannel or hot plug-unplug it while playing an audio clip,sometimes we observe a silent playback(no audio). During no audio condition, we have noticed that the power state of the pin or the connector is D3. Optimzing the way we set the power could mitigate the issue.With this changes the verb is sent to set the power state and response is received. Thus ensuring power state is set. Signed-off-by: Abhijeet Kumar --- sound/soc/codecs/hdac_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index f3b4f4dfae6a..e24caecf0a4f 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -718,7 +718,7 @@ static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, { if (get_wcaps(>hdac, nid) & AC_WCAP_POWER) { if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) - snd_hdac_codec_write(>hdac, nid, 0, + snd_hdac_codec_read(>hdac, nid, 0, AC_VERB_SET_POWER_STATE, pwr_state); } } -- 1.9.1
[PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state
From: Abhijeet Kumar When we change the resolution of DP pannel or hot plug-unplug it while playing an audio clip,sometimes we observe a silent playback(no audio). During no audio condition, we have noticed that the power state of the pin or the connector is D3. Optimzing the way we set the power could mitigate the issue.With this changes the verb is sent to set the power state and response is received. Thus ensuring power state is set. Signed-off-by: Abhijeet Kumar --- sound/soc/codecs/hdac_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index f3b4f4dfae6a..e24caecf0a4f 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -718,7 +718,7 @@ static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, { if (get_wcaps(>hdac, nid) & AC_WCAP_POWER) { if (!snd_hdac_check_power_state(>hdac, nid, pwr_state)) - snd_hdac_codec_write(>hdac, nid, 0, + snd_hdac_codec_read(>hdac, nid, 0, AC_VERB_SET_POWER_STATE, pwr_state); } } -- 1.9.1