ASoC: Intel: boards: kbl_da7219_max98927: add dai_trigger function
Subsystems (3)
PATCH 1/1 ASoC: Intel: boards: kbl_da7219_max98927: add dai_trigger function
From: Mac Chiang <[email protected]>
amplifier feedback is not modeled as being dependent on any active output. Even when there is no playback happening, parts of the graph, specifically the IV sense->speaker protection->output remains active and this prevents the DSP from entering low-power states.
This patch suggest a machine driver level approach where the speaker pins are enabled/disabled dynamically depending on stream start/stop events. DPAM graph representations show the feedback loop is indeed disabled and low-power states can be reached.
--- sound/soc/intel/boards/kbl_da7219_max98927.c | 73 +++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)
sound/soc/intel/boards/kbl_da7219_max98927.c +71 -2
@@ -219,8 +219,60 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,return 0 ; } +static int kabylake_ssp0_trigger (struct snd_pcm_substream *substream,int cmd) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +int j, ret; + +for (j =0 ; j < rtd->num_codecs; j++) { +struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; +const char *name = codec_dai->component->name; +struct snd_soc_component *component = codec_dai->component; +struct snd_soc_dapm_context *dapm = +snd_soc_component_get_dapm (component); +char pin_name[20 ]; + +if (strcmp (name,MAX98927_DEV0_NAME ) && +strcmp (name,MAX98927_DEV1_NAME ) && +strcmp (name,MAX98373_DEV0_NAME ) && +strcmp (name,MAX98373_DEV1_NAME )) +continue ; + +snprintf (pin_name,ARRAY_SIZE (pin_name),"%s Spk" , + codec_dai->component->name_prefix); + +switch (cmd) { +case SNDRV_PCM_TRIGGER_START : +case SNDRV_PCM_TRIGGER_RESUME : +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : + ret =snd_soc_dapm_enable_pin (dapm, pin_name); +if (ret) { +dev_err (rtd->dev,"failed to enable %s: %d\n" , + pin_name, ret); +return ret; + } +snd_soc_dapm_sync (dapm); +break ; +case SNDRV_PCM_TRIGGER_STOP : +case SNDRV_PCM_TRIGGER_SUSPEND : +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : + ret =snd_soc_dapm_disable_pin (dapm, pin_name); +if (ret) { +dev_err (rtd->dev,"failed to disable %s: %d\n" , + pin_name, ret); +return ret; + } +snd_soc_dapm_sync (dapm); +break ; + } + } + +return 0 ; +} +static struct snd_soc_ops kabylake_ssp0_ops = { .hw_params = kabylake_ssp0_hw_params, + .trigger = kabylake_ssp0_trigger, }; static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
@@ -950,6 +1002,7 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) {struct kbl_codec_private *ctx =snd_soc_card_get_drvdata (card);struct kbl_hdmi_pcm *pcm; +struct snd_soc_dapm_context *dapm = &card->dapm;struct snd_soc_component *component =NULL ;int err, i =0 ;char jack_name[NAME_SIZE ];
@@ -976,9 +1029,25 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)if (!component)return -EINVAL ; -return hdac_hdmi_jack_port_init (component, &card->dapm); -return 0 ; + err =hdac_hdmi_jack_port_init (component, &card->dapm); + +if (err <0 ) +return err; + + err =snd_soc_dapm_disable_pin (dapm,"Left Spk" ); +if (err) { +dev_err (card->dev,"failed to disable Left Spk: %d\n" , err); +return err; + } + + err =snd_soc_dapm_disable_pin (dapm,"Right Spk" ); +if (err) { +dev_err (card->dev,"failed to disable Right Spk: %d\n" , err); +return err; + } + +return snd_soc_dapm_sync (dapm); }/* kabylake audio machine driver for SPT + DA7219 */
Signature · 1 line
2.7.4
Quoted 7 lines · On 5/2/19 2:06 AM, [email protected] wrote:
From: Mac Chiang <[email protected]>
amplifier feedback is not modeled as being dependent on any active output. Even when there is no playback happening, parts of the graph, specifically the IV
sense->speakerprotection->outputremains active and this prevents the DSP from entering low-power states.
Quoted 8 lines
This patch suggest a machine driver level approach where the speaker pins are enabled/disabled dynamically depending on stream start/stop events. DPAM graph representations show the feedback loop is indeed disabled and low-power states can be reached.
Signed-off-by Jenny TC <[email protected]>Signed-off-by Harshapriya.n <[email protected]>Signed-off-by Mac Chiang <[email protected]>
I am confused here.
There was a first patch sent on March 1, then updates posted by Jenny TC with a v3 that I acked on March 8, but there's also a v4 on April 1.
So is this the same as v4? if yes why did you drop the change log or not add a note it's a resend? If no, what has changed?
Quoted 106 lines
--- sound/soc/intel/boards/kbl_da7219_max98927.c | 73 +++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)sound/soc/intel/boards/kbl_da7219_max98927.c +71
-2@@ -219,8 +219,60 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,return 0 ; } +static int kabylake_ssp0_trigger (struct snd_pcm_substream *substream,int cmd) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +int j, ret; + +for (j =0 ; j < rtd->num_codecs; j++) { +struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; +const char *name = codec_dai->component->name; +struct snd_soc_component *component = codec_dai->component; +struct snd_soc_dapm_context *dapm = +snd_soc_component_get_dapm (component); +char pin_name[20 ]; + +if (strcmp (name,MAX98927_DEV0_NAME ) && +strcmp (name,MAX98927_DEV1_NAME ) && +strcmp (name,MAX98373_DEV0_NAME ) && +strcmp (name,MAX98373_DEV1_NAME )) +continue ; + +snprintf (pin_name,ARRAY_SIZE (pin_name),"%s Spk" , + codec_dai->component->name_prefix); + +switch (cmd) { +case SNDRV_PCM_TRIGGER_START : +case SNDRV_PCM_TRIGGER_RESUME : +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : + ret =snd_soc_dapm_enable_pin (dapm, pin_name); +if (ret) { +dev_err (rtd->dev,"failed to enable %s: %d\n" , + pin_name, ret); +return ret; + } +snd_soc_dapm_sync (dapm); +break ; +case SNDRV_PCM_TRIGGER_STOP : +case SNDRV_PCM_TRIGGER_SUSPEND : +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : + ret =snd_soc_dapm_disable_pin (dapm, pin_name); +if (ret) { +dev_err (rtd->dev,"failed to disable %s: %d\n" , + pin_name, ret); +return ret; + } +snd_soc_dapm_sync (dapm); +break ; + } + } + +return 0 ; +} +static struct snd_soc_ops kabylake_ssp0_ops = { .hw_params = kabylake_ssp0_hw_params, + .trigger = kabylake_ssp0_trigger, }; static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,@@ -950,6 +1002,7 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) {struct kbl_codec_private *ctx =snd_soc_card_get_drvdata (card);struct kbl_hdmi_pcm *pcm; +struct snd_soc_dapm_context *dapm = &card->dapm;struct snd_soc_component *component =NULL ;int err, i =0 ;char jack_name[NAME_SIZE ];@@ -976,9 +1029,25 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)if (!component)return -EINVAL ; -return hdac_hdmi_jack_port_init (component, &card->dapm); -return 0 ; + err =hdac_hdmi_jack_port_init (component, &card->dapm); + +if (err <0 ) +return err; + + err =snd_soc_dapm_disable_pin (dapm,"Left Spk" ); +if (err) { +dev_err (card->dev,"failed to disable Left Spk: %d\n" , err); +return err; + } + + err =snd_soc_dapm_disable_pin (dapm,"Right Spk" ); +if (err) { +dev_err (card->dev,"failed to disable Right Spk: %d\n" , err); +return err; + } + +return snd_soc_dapm_sync (dapm); }/* kabylake audio machine driver for SPT + DA7219 */
Quoted 16 lines
Quoted 7 lines
From: Mac Chiang <[email protected]>
amplifier feedback is not modeled as being dependent on any active output. Even when there is no playback happening, parts of the graph, specifically the IV
sense->speakerprotection->outputremains active and this prevents the DSP from entering low-power states.Quoted 8 lines
This patch suggest a machine driver level approach where the speaker pins are enabled/disabled dynamically depending on stream start/stop events. DPAM graph representations show the feedback loop is indeed disabled and low-power states can be reached.
Signed-off-by Jenny TC <[email protected]>Signed-off-by Harshapriya.n <[email protected]>Signed-off-by Mac Chiang <[email protected]>
Quoted 5 lines
I am confused here.
There was a first patch sent on March 1, then updates posted by Jenny TC with a v3 that I acked on March 8, but there's also a v4 on April 1.
So is this the same as v4? if yes why did you drop the change log or not add a note it's a resend? If no, what has changed?
Yes, it's the same as v4. I pick up it directly and should notice the change log missing. Sorry for spam this, I just resend it[patch resend] with change log manually.
Quoted 107 lines
Quoted 107 lines
--- sound/soc/intel/boards/kbl_da7219_max98927.c | 73 +++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)sound/soc/intel/boards/kbl_da7219_max98927.c +71
-3@@ -219,8 +219,60 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,return 0 ; } +static int kabylake_ssp0_trigger (struct snd_pcm_substream *substream, +int cmd) { +struct snd_soc_pcm_runtime *rtd = substream->private_data; +int j, ret; + +for (j =0 ; j < rtd->num_codecs; j++) { +struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; +const char *name = codec_dai->component->name; +struct snd_soc_component *component = codec_dai->component; +struct snd_soc_dapm_context *dapm = +snd_soc_component_get_dapm (component); +char pin_name[20 ]; + +if (strcmp (name,MAX98927_DEV0_NAME ) && +strcmp (name,MAX98927_DEV1_NAME ) && +strcmp (name,MAX98373_DEV0_NAME ) && +strcmp (name,MAX98373_DEV1_NAME )) +continue ; + +snprintf (pin_name,ARRAY_SIZE (pin_name),"%s Spk" , + codec_dai->component->name_prefix); + +switch (cmd) { +case SNDRV_PCM_TRIGGER_START : +case SNDRV_PCM_TRIGGER_RESUME : +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : + ret =snd_soc_dapm_enable_pin (dapm, pin_name); +if (ret) { +dev_err (rtd->dev,"failed to enable %s: %d\n" , + pin_name, ret); +return ret; + } +snd_soc_dapm_sync (dapm); +break ; +case SNDRV_PCM_TRIGGER_STOP : +case SNDRV_PCM_TRIGGER_SUSPEND : +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : + ret =snd_soc_dapm_disable_pin (dapm, pin_name); +if (ret) { +dev_err (rtd->dev,"failed to disable %s: %d\n" , + pin_name, ret); +return ret; + } +snd_soc_dapm_sync (dapm); +break ; + } + } + +return 0 ; +} +static struct snd_soc_ops kabylake_ssp0_ops = { .hw_params = kabylake_ssp0_hw_params, + .trigger = kabylake_ssp0_trigger, }; static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, @@ -950,6 +1002,7 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; + struct snd_soc_dapm_context *dapm = &card->dapm; struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE];@@ -976,9 +1029,25 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)if (!component)return -EINVAL ; -return hdac_hdmi_jack_port_init (component, &card->dapm); -return 0 ; + err =hdac_hdmi_jack_port_init (component, &card->dapm); + +if (err <0 ) +return err; + + err =snd_soc_dapm_disable_pin (dapm,"Left Spk" ); +if (err) { +dev_err (card->dev,"failed to disable Left Spk: %d\n" , err); +return err; + } + + err =snd_soc_dapm_disable_pin (dapm,"Right Spk" ); +if (err) { +dev_err (card->dev,"failed to disable Right Spk: %d\n" , err); +return err; + } + +return snd_soc_dapm_sync (dapm); }/* kabylake audio machine driver for SPT + DA7219 */