diff mbox

[3/3] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state

Message ID 1516728657-21522-3-git-send-email-abhijeet.kumar@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Abhijeet Kumar Jan. 23, 2018, 5:30 p.m. UTC
From: Abhijeet Kumar <abhijeet.kumar@intel.com>

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 <abhijeet.kumar@intel.com>
---
 sound/soc/codecs/hdac_hdmi.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Takashi Iwai Feb. 12, 2018, 1:04 p.m. UTC | #1
On Tue, 23 Jan 2018 18:30:53 +0100,
<abhijeet.kumar@intel.com> wrote:
> 
> From: Abhijeet Kumar <abhijeet.kumar@intel.com>
> 
> 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 <abhijeet.kumar@intel.com>

I applied the patches 1 and 2 to topic/hda-sync-power branch.  It's
based on 4.16-rc1.

Mark, could you pull that into your intel branch and apply this fix?


thanks,

Takashi


> ---
>  sound/soc/codecs/hdac_hdmi.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
> index f3b4f4dfae6a..4dc9b9b71db9 100644
> --- a/sound/soc/codecs/hdac_hdmi.c
> +++ b/sound/soc/codecs/hdac_hdmi.c
> @@ -716,10 +716,20 @@ 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(&edev->hdac, nid) & AC_WCAP_POWER) {
> -		if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state))
> -			snd_hdac_codec_write(&edev->hdac, nid, 0,
> -				AC_VERB_SET_POWER_STATE, pwr_state);
> +		if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state)) {
> +			for (count = 0; count < 10; count++) {
> +				snd_hdac_codec_read(&edev->hdac, nid, 0,
> +						AC_VERB_SET_POWER_STATE,
> +						pwr_state);
> +				state = snd_hdac_sync_power_state(&edev->hdac,
> +						 nid, pwr_state);
> +				if (!(state & AC_PWRST_ERROR))
> +					break;
> +			}
> +		}
>  	}
>  }
>  
> -- 
> 1.9.1
> 
>
Mark Brown Feb. 14, 2018, 4:20 p.m. UTC | #2
On Tue, Jan 23, 2018 at 11:00:53PM +0530, abhijeet.kumar@intel.com wrote:
> From: Abhijeet Kumar <abhijeet.kumar@intel.com>
> 
> 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.

This doesn't apply after the recent refactoring to move to components -
can you please rebase on current code and resend?  I pulled Takashi's
branch already, it's just this patch needs handling.
Abhijeet Kumar Feb. 15, 2018, 8:30 a.m. UTC | #3
On 2/14/2018 9:50 PM, Mark Brown wrote:
> On Tue, Jan 23, 2018 at 11:00:53PM +0530, abhijeet.kumar@intel.com wrote:
>> From: Abhijeet Kumar <abhijeet.kumar@intel.com>
>>
>> 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.
> This doesn't apply after the recent refactoring to move to components -
> can you please rebase on current code and resend?  I pulled Takashi's
> branch already, it's just this patch needs handling.

Please find the re-based patch here.
https://patchwork.kernel.org/patch/10220549/

Warm Regards,
Abhijeet
diff mbox

Patch

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index f3b4f4dfae6a..4dc9b9b71db9 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -716,10 +716,20 @@  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(&edev->hdac, nid) & AC_WCAP_POWER) {
-		if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state))
-			snd_hdac_codec_write(&edev->hdac, nid, 0,
-				AC_VERB_SET_POWER_STATE, pwr_state);
+		if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state)) {
+			for (count = 0; count < 10; count++) {
+				snd_hdac_codec_read(&edev->hdac, nid, 0,
+						AC_VERB_SET_POWER_STATE,
+						pwr_state);
+				state = snd_hdac_sync_power_state(&edev->hdac,
+						 nid, pwr_state);
+				if (!(state & AC_PWRST_ERROR))
+					break;
+			}
+		}
 	}
 }