[PATCH] ASoC: Intel: Skylake: Fix typo

2018-03-03 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@intel.com>

Spelling mistake in state. So fixing it.

Signed-off-by: Abhijeet Kumar <abhijeet.ku...@intel.com>
---
 sound/soc/intel/skylake/skl-messages.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-messages.c 
b/sound/soc/intel/skylake/skl-messages.c
index 60d76adade43..f161907859f3 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -1210,7 +1210,7 @@ int skl_bind_modules(struct skl_sst *ctx,
 static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe,
enum skl_ipc_pipeline_state state)
 {
-   dev_dbg(ctx->dev, "%s: pipe_satate = %d\n", __func__, state);
+   dev_dbg(ctx->dev, "%s: pipe_state = %d\n", __func__, state);
 
return skl_ipc_set_pipeline_state(>ipc, pipe->ppl_id, state);
 }
-- 
1.9.1



[PATCH] ASoC: Intel: Skylake: Fix typo

2018-03-03 Thread abhijeet . kumar
From: Abhijeet Kumar 

Spelling mistake in state. So fixing it.

Signed-off-by: Abhijeet Kumar 
---
 sound/soc/intel/skylake/skl-messages.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-messages.c 
b/sound/soc/intel/skylake/skl-messages.c
index 60d76adade43..f161907859f3 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -1210,7 +1210,7 @@ int skl_bind_modules(struct skl_sst *ctx,
 static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe,
enum skl_ipc_pipeline_state state)
 {
-   dev_dbg(ctx->dev, "%s: pipe_satate = %d\n", __func__, state);
+   dev_dbg(ctx->dev, "%s: pipe_state = %d\n", __func__, state);
 
return skl_ipc_set_pipeline_state(>ipc, pipe->ppl_id, state);
 }
-- 
1.9.1



[PATCH v2] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state

2018-02-15 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@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.ku...@intel.com>
---
 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..97fcd55205e6 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(>hdev, nid, pwr_state)) {
+   for (count = 0; count < 10; count++) {
+   snd_hdac_codec_read(>hdev, nid, 0,
+   AC_VERB_SET_POWER_STATE,
+   pwr_state);
+   state = snd_hdac_sync_power_state(>hdev,
+   nid, pwr_state);
+   if (!(state & AC_PWRST_ERROR))
+   break;
+   }
+   }
+
}
 }
 
-- 
1.9.1



[PATCH v2] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state

2018-02-15 Thread abhijeet . kumar
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..97fcd55205e6 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(>hdev, nid, pwr_state)) {
+   for (count = 0; count < 10; count++) {
+   snd_hdac_codec_read(>hdev, nid, 0,
+   AC_VERB_SET_POWER_STATE,
+   pwr_state);
+   state = snd_hdac_sync_power_state(>hdev,
+   nid, pwr_state);
+   if (!(state & AC_PWRST_ERROR))
+   break;
+   }
+   }
+
}
 }
 
-- 
1.9.1



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

2018-02-15 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@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.ku...@intel.com>
---
 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

2018-02-15 Thread abhijeet . kumar
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



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

2018-01-23 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@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.ku...@intel.com>
---
 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(>hdac, nid) & AC_WCAP_POWER) {
-   if (!snd_hdac_check_power_state(>hdac, nid, pwr_state))
-   snd_hdac_codec_write(>hdac, 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 3/3] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state

2018-01-23 Thread abhijeet . kumar
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 | 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(>hdac, nid) & AC_WCAP_POWER) {
-   if (!snd_hdac_check_power_state(>hdac, nid, pwr_state))
-   snd_hdac_codec_write(>hdac, 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 2/3] ALSA: hda: Make use of core codec functions to sync power state

2018-01-23 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@intel.com>

Since sync_power_state is moved to core it's better to use the helper
function to ensure the actual power state reaches target instead of
using the local helper functions already exsisting in hda code.

Signed-off-by: Abhijeet Kumar <abhijeet.ku...@intel.com>
---
 sound/pci/hda/hda_codec.c | 28 +---
 sound/pci/hda/hda_local.h |  6 +-
 2 files changed, 6 insertions(+), 28 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e018ecbf78a8..5bc3a7468e17 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2702,32 +2702,6 @@ void snd_hda_codec_set_power_to_all(struct hda_codec 
*codec, hda_nid_t fg,
 }
 EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_to_all);
 
-/*
- * wait until the state is reached, returns the current state
- */
-static unsigned int hda_sync_power_state(struct hda_codec *codec,
-hda_nid_t fg,
-unsigned int power_state)
-{
-   unsigned long end_time = jiffies + msecs_to_jiffies(500);
-   unsigned int state, actual_state;
-
-   for (;;) {
-   state = snd_hda_codec_read(codec, fg, 0,
-  AC_VERB_GET_POWER_STATE, 0);
-   if (state & AC_PWRST_ERROR)
-   break;
-   actual_state = (state >> 4) & 0x0f;
-   if (actual_state == power_state)
-   break;
-   if (time_after_eq(jiffies, end_time))
-   break;
-   /* wait until the codec reachs to the target state */
-   msleep(1);
-   }
-   return state;
-}
-
 /**
  * snd_hda_codec_eapd_power_filter - A power filter callback for EAPD
  * @codec: the HDA codec
@@ -2790,7 +2764,7 @@ static unsigned int hda_set_power_state(struct hda_codec 
*codec,
   state);
snd_hda_codec_set_power_to_all(codec, fg, power_state);
}
-   state = hda_sync_power_state(codec, fg, power_state);
+   state = snd_hda_sync_power_state(codec, fg, power_state);
if (!(state & AC_PWRST_ERROR))
break;
}
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 5b5c324c99b9..321e78baa63c 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -622,7 +622,11 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
 {
return snd_hdac_check_power_state(>core, nid, target_state);
 }
-
+static inline bool snd_hda_sync_power_state(struct hda_codec *codec,
+  hda_nid_t nid, unsigned int target_state)
+{
+   return snd_hdac_sync_power_state(>core, nid, target_state);
+}
 unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec,
 hda_nid_t nid,
 unsigned int power_state);
-- 
1.9.1



[PATCH 1/3] ALSA: hda: Copying sync power state helper to core

2018-01-23 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@intel.com>

The current sync_power_state is local to hda code, moving it
core so that other users apart from hda legacy can use it.
The helper function ensures the actual state reaches the target state.

Signed-off-by: Abhijeet Kumar <abhijeet.ku...@intel.com>
---
 include/sound/hdaudio.h |  2 ++
 sound/hda/hdac_device.c | 35 +++
 2 files changed, 37 insertions(+)

diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 68169e3749de..4c93ff5301bd 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -146,6 +146,8 @@ int snd_hdac_codec_write(struct hdac_device *hdac, 
hda_nid_t nid,
int flags, unsigned int verb, unsigned int parm);
 bool snd_hdac_check_power_state(struct hdac_device *hdac,
hda_nid_t nid, unsigned int target_state);
+unsigned int snd_hdac_sync_power_state(struct hdac_device *hdac,
+ hda_nid_t nid, unsigned int target_state);
 /**
  * snd_hdac_read_parm - read a codec parameter
  * @codec: the codec object
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index 06f845e293cb..7ba100bb1c3f 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -3,6 +3,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1064,3 +1065,37 @@ bool snd_hdac_check_power_state(struct hdac_device *hdac,
return (state == target_state);
 }
 EXPORT_SYMBOL_GPL(snd_hdac_check_power_state);
+/**
+ * snd_hdac_sync_power_state - wait until actual power state matches
+ * with the target state
+ *
+ * @hdac: the HDAC device
+ * @nid: NID to send the command
+ * @target_state: target state to check for
+ *
+ * Return power state or PS_ERROR if codec rejects GET verb.
+ */
+unsigned int snd_hdac_sync_power_state(struct hdac_device *codec,
+   hda_nid_t nid, unsigned int power_state)
+{
+   unsigned long end_time = jiffies + msecs_to_jiffies(500);
+   unsigned int state, actual_state, count;
+
+   for (count = 0; count < 500; count++) {
+   state = snd_hdac_codec_read(codec, nid, 0,
+   AC_VERB_GET_POWER_STATE, 0);
+   if (state & AC_PWRST_ERROR) {
+   msleep(20);
+   break;
+   }
+   actual_state = (state >> 4) & 0x0f;
+   if (actual_state == power_state)
+   break;
+   if (time_after_eq(jiffies, end_time))
+   break;
+   /* wait until the codec reachs to the target state */
+   msleep(1);
+   }
+   return state;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_sync_power_state);
-- 
1.9.1



[PATCH 2/3] ALSA: hda: Make use of core codec functions to sync power state

2018-01-23 Thread abhijeet . kumar
From: Abhijeet Kumar 

Since sync_power_state is moved to core it's better to use the helper
function to ensure the actual power state reaches target instead of
using the local helper functions already exsisting in hda code.

Signed-off-by: Abhijeet Kumar 
---
 sound/pci/hda/hda_codec.c | 28 +---
 sound/pci/hda/hda_local.h |  6 +-
 2 files changed, 6 insertions(+), 28 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e018ecbf78a8..5bc3a7468e17 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2702,32 +2702,6 @@ void snd_hda_codec_set_power_to_all(struct hda_codec 
*codec, hda_nid_t fg,
 }
 EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_to_all);
 
-/*
- * wait until the state is reached, returns the current state
- */
-static unsigned int hda_sync_power_state(struct hda_codec *codec,
-hda_nid_t fg,
-unsigned int power_state)
-{
-   unsigned long end_time = jiffies + msecs_to_jiffies(500);
-   unsigned int state, actual_state;
-
-   for (;;) {
-   state = snd_hda_codec_read(codec, fg, 0,
-  AC_VERB_GET_POWER_STATE, 0);
-   if (state & AC_PWRST_ERROR)
-   break;
-   actual_state = (state >> 4) & 0x0f;
-   if (actual_state == power_state)
-   break;
-   if (time_after_eq(jiffies, end_time))
-   break;
-   /* wait until the codec reachs to the target state */
-   msleep(1);
-   }
-   return state;
-}
-
 /**
  * snd_hda_codec_eapd_power_filter - A power filter callback for EAPD
  * @codec: the HDA codec
@@ -2790,7 +2764,7 @@ static unsigned int hda_set_power_state(struct hda_codec 
*codec,
   state);
snd_hda_codec_set_power_to_all(codec, fg, power_state);
}
-   state = hda_sync_power_state(codec, fg, power_state);
+   state = snd_hda_sync_power_state(codec, fg, power_state);
if (!(state & AC_PWRST_ERROR))
break;
}
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 5b5c324c99b9..321e78baa63c 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -622,7 +622,11 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
 {
return snd_hdac_check_power_state(>core, nid, target_state);
 }
-
+static inline bool snd_hda_sync_power_state(struct hda_codec *codec,
+  hda_nid_t nid, unsigned int target_state)
+{
+   return snd_hdac_sync_power_state(>core, nid, target_state);
+}
 unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec,
 hda_nid_t nid,
 unsigned int power_state);
-- 
1.9.1



[PATCH 1/3] ALSA: hda: Copying sync power state helper to core

2018-01-23 Thread abhijeet . kumar
From: Abhijeet Kumar 

The current sync_power_state is local to hda code, moving it
core so that other users apart from hda legacy can use it.
The helper function ensures the actual state reaches the target state.

Signed-off-by: Abhijeet Kumar 
---
 include/sound/hdaudio.h |  2 ++
 sound/hda/hdac_device.c | 35 +++
 2 files changed, 37 insertions(+)

diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 68169e3749de..4c93ff5301bd 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -146,6 +146,8 @@ int snd_hdac_codec_write(struct hdac_device *hdac, 
hda_nid_t nid,
int flags, unsigned int verb, unsigned int parm);
 bool snd_hdac_check_power_state(struct hdac_device *hdac,
hda_nid_t nid, unsigned int target_state);
+unsigned int snd_hdac_sync_power_state(struct hdac_device *hdac,
+ hda_nid_t nid, unsigned int target_state);
 /**
  * snd_hdac_read_parm - read a codec parameter
  * @codec: the codec object
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index 06f845e293cb..7ba100bb1c3f 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -3,6 +3,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1064,3 +1065,37 @@ bool snd_hdac_check_power_state(struct hdac_device *hdac,
return (state == target_state);
 }
 EXPORT_SYMBOL_GPL(snd_hdac_check_power_state);
+/**
+ * snd_hdac_sync_power_state - wait until actual power state matches
+ * with the target state
+ *
+ * @hdac: the HDAC device
+ * @nid: NID to send the command
+ * @target_state: target state to check for
+ *
+ * Return power state or PS_ERROR if codec rejects GET verb.
+ */
+unsigned int snd_hdac_sync_power_state(struct hdac_device *codec,
+   hda_nid_t nid, unsigned int power_state)
+{
+   unsigned long end_time = jiffies + msecs_to_jiffies(500);
+   unsigned int state, actual_state, count;
+
+   for (count = 0; count < 500; count++) {
+   state = snd_hdac_codec_read(codec, nid, 0,
+   AC_VERB_GET_POWER_STATE, 0);
+   if (state & AC_PWRST_ERROR) {
+   msleep(20);
+   break;
+   }
+   actual_state = (state >> 4) & 0x0f;
+   if (actual_state == power_state)
+   break;
+   if (time_after_eq(jiffies, end_time))
+   break;
+   /* wait until the codec reachs to the target state */
+   msleep(1);
+   }
+   return state;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_sync_power_state);
-- 
1.9.1



[PATCH v2] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state

2018-01-12 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@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. 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 <abhijeet.ku...@intel.com>
---
Changes in v2:
- update commit message

 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 v2] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state

2018-01-12 Thread abhijeet . kumar
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. 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 
---
Changes in v2:
- update commit message

 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 v2] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state

2018-01-12 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@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. 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 <abhijeet.ku...@intel.com>
---
Changes in v2:
- update commit message

 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 v2] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state

2018-01-12 Thread abhijeet . kumar
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. 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 
---
Changes in v2:
- update commit message

 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

2018-01-11 Thread abhijeet . kumar
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).

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 <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,
AC_VERB_SET_POWER_STATE, pwr_state);
}
 }
-- 
1.9.1



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

2018-01-11 Thread abhijeet . kumar
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



[PATCH] ASoC: nau8825: fix issue that pop noise when start capture

2017-12-11 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@intel.com>

In skylake platform, we hear a loud pop noise(0 dB) at start of
audio capture power up sequence. This patch removes the pop noise
from the recording by adding a delay before enabling ADC.

Signed-off-by: Abhijeet Kumar <abhijeet.ku...@intel.com>
---
 sound/soc/codecs/nau8825.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 714ce17da717..e853a6dfd33b 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -905,6 +905,7 @@ static int nau8825_adc_event(struct snd_soc_dapm_widget *w,
 
switch (event) {
case SND_SOC_DAPM_POST_PMU:
+   msleep(125);
regmap_update_bits(nau8825->regmap, NAU8825_REG_ENA_CTRL,
NAU8825_ENABLE_ADC, NAU8825_ENABLE_ADC);
break;
-- 
1.9.1



[PATCH] ASoC: nau8825: fix issue that pop noise when start capture

2017-12-11 Thread abhijeet . kumar
From: Abhijeet Kumar 

In skylake platform, we hear a loud pop noise(0 dB) at start of
audio capture power up sequence. This patch removes the pop noise
from the recording by adding a delay before enabling ADC.

Signed-off-by: Abhijeet Kumar 
---
 sound/soc/codecs/nau8825.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 714ce17da717..e853a6dfd33b 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -905,6 +905,7 @@ static int nau8825_adc_event(struct snd_soc_dapm_widget *w,
 
switch (event) {
case SND_SOC_DAPM_POST_PMU:
+   msleep(125);
regmap_update_bits(nau8825->regmap, NAU8825_REG_ENA_CTRL,
NAU8825_ENABLE_ADC, NAU8825_ENABLE_ADC);
break;
-- 
1.9.1



[PATCH] Bluettoth: btusb: Prevent USB devices to autosuspend while setting interface

2017-11-15 Thread abhijeet . kumar
From: Abhijeet Kumar <abhijeet.ku...@intel.com>

Runtime resume USB device in order to ensure that PM framework knows
that the we might be using the device in a short time and doesn't
autosuspend the device while we update it's interface.

Signed-off-by: Abhijeet Kumar <abhijeet.ku...@intel.com>
---
 drivers/bluetooth/btusb.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 7a5c06aaa181..588aabf991be 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1444,6 +1444,12 @@ static void btusb_work(struct work_struct *work)
data->sco_skb = NULL;
spin_unlock_irqrestore(>rxlock, flags);
 
+/*
+ *Letting runtime PM know that we wish to use
+ *the device in a short time.
+ */
+ pm_runtime_get(>udev->dev);
+
if (__set_isoc_interface(hdev, new_alts) < 0)
return;
}
-- 
1.9.1



[PATCH] Bluettoth: btusb: Prevent USB devices to autosuspend while setting interface

2017-11-15 Thread abhijeet . kumar
From: Abhijeet Kumar 

Runtime resume USB device in order to ensure that PM framework knows
that the we might be using the device in a short time and doesn't
autosuspend the device while we update it's interface.

Signed-off-by: Abhijeet Kumar 
---
 drivers/bluetooth/btusb.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 7a5c06aaa181..588aabf991be 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1444,6 +1444,12 @@ static void btusb_work(struct work_struct *work)
data->sco_skb = NULL;
spin_unlock_irqrestore(>rxlock, flags);
 
+/*
+ *Letting runtime PM know that we wish to use
+ *the device in a short time.
+ */
+ pm_runtime_get(>udev->dev);
+
if (__set_isoc_interface(hdev, new_alts) < 0)
return;
}
-- 
1.9.1