Skip to contentSkip to conversation

Add period size constraint for Atom Chromebook

PATCH Superseded Brent Lu 3 participants 9 messages Jul 30, 2020

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Brent Lu

author
#0 lore raw

v2 cover Add period size constraint for Atom Chromebook

Two different constraints are implemented: one is in platform's CPU DAI to enforce period sizes which are already used in Android BSP. The other is in Atom Chromebook's machine driver to use 240 as period size.

Changes since v1:
-Add comma at the end of media_period_size array declaration.

Brent Lu (1):
ASoC: intel: atom: Add period size constraint

Yu-Hsuan Hsu (1):
ASoC: Intel: Add period size constraint on strago board

 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 15 +++++++++++++++
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 +++++++++++++-
 sound/soc/intel/boards/cht_bsw_rt5645.c      | 14 +++++++++++++-
 3 files changed, 41 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/2 ASoC: intel: atom: Add period size constraint

Use constraint to enforce the period sizes which are validated in Android BSP.

---
 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +15 -0
index 49b9f18..70100ef 100644
@@ -300,6 +300,16 @@ static void power_down_sst(struct sst_runtime_stream *stream)
 	stream->ops->power(sst->dev, false);
 }
 
+static const unsigned int media_period_size[] = {
+	/* sizes validated on Android platform */
+	240, 320, 960, 3072,
+};
+
+static const struct snd_pcm_hw_constraint_list constraints_media_period_size = {
+	.count = ARRAY_SIZE(media_period_size),
+	.list  = media_period_size,
+};
+
 static int sst_media_open(struct snd_pcm_substream *substream,
 		struct snd_soc_dai *dai)
 {
@@ -333,6 +343,11 @@ static int sst_media_open(struct snd_pcm_substream *substream,
 	if (ret_val < 0)
 		return ret_val;
 
+	/* Avoid using period size which is not validated */
+	snd_pcm_hw_constraint_list(substream->runtime, 0,
+			SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
+			&constraints_media_period_size);
+
 	/* Make sure, that the period size is always even */
 	snd_pcm_hw_constraint_step(substream->runtime, 0,
 			   SNDRV_PCM_HW_PARAM_PERIODS, 2);
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v2 2/2 ASoC: Intel: Add period size constraint on strago board

In reply to Brent Lu

From: Yu-Hsuan Hsu <[email protected]>

The CRAS server does not set the period size in hw_param so ALSA will calculate a value for period size which is based on the buffer size and other parameters. The value may not always be aligned with Atom's dsp design so a constraint is added to make sure the board always has a good value.

Cyan uses chtmax98090 and others(banon, celes, edgar, kefka...) use rt5650.

---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 +++++++++++++-
 sound/soc/intel/boards/cht_bsw_rt5645.c      | 14 +++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +13 -1
index 835e9bd..bf67254 100644
@@ -283,8 +283,20 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
 
 static int cht_aif1_startup(struct snd_pcm_substream *substream)
 {
-	return snd_pcm_hw_constraint_single(substream->runtime,
+	int err;
+
+	/* Set period size to 240 to align with Atom design */
+	err = snd_pcm_hw_constraint_minmax(substream->runtime,
+			SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 240, 240);
+	if (err < 0)
+		return err;
+
+	err = snd_pcm_hw_constraint_single(substream->runtime,
 			SNDRV_PCM_HW_PARAM_RATE, 48000);
+	if (err < 0)
+		return err;
+
+	return 0;
 }
 
 static int cht_max98090_headset_init(struct snd_soc_component *component)
sound/soc/intel/boards/cht_bsw_rt5645.c +13 -1
index b53c024..6e62f0d 100644
@@ -414,8 +414,20 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
 
 static int cht_aif1_startup(struct snd_pcm_substream *substream)
 {
-	return snd_pcm_hw_constraint_single(substream->runtime,
+	int err;
+
+	/* Set period size to 240 to align with Atom design */
+	err = snd_pcm_hw_constraint_minmax(substream->runtime,
+			SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 240, 240);
+	if (err < 0)
+		return err;
+
+	err = snd_pcm_hw_constraint_single(substream->runtime,
 			SNDRV_PCM_HW_PARAM_RATE, 48000);
+	if (err < 0)
+		return err;
+
+	return 0;
 }
 
 static const struct snd_soc_ops cht_aif1_ops = {
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH v2 2/2] ASoC: Intel: Add period size constraint on strago board

Quoted 10 lines · Brent Lu

From: Yu-Hsuan Hsu <[email protected]>

The CRAS server does not set the period size in hw_param so ALSA will calculate a value for period size which is based on the buffer size and other parameters. The value may not always be aligned with Atom's dsp design so a constraint is added to make sure the board always has a good value.

Cyan uses chtmax98090 and others(banon, celes, edgar, kefka...) use rt5650.

Actually one more comment here.
Can you split per machine driver?

Quoted 2 lines
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 +++++++++++++-
 sound/soc/intel/boards/cht_bsw_rt5645.c      | 14 +++++++++++++-
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#4 lore raw

RE: [PATCH v2 2/2] ASoC: Intel: Add period size constraint on strago board

Quoted 9 lines · Brent Lu
Quoted 8 lines

From: Yu-Hsuan Hsu <[email protected]>

The CRAS server does not set the period size in hw_param so ALSA will calculate a value for period size which is based on the buffer size and other parameters. The value may not always be aligned with Atom's dsp design so a constraint is added to make sure the board always has a good value.

Quoted 6 lines
Quoted 2 lines

Cyan uses chtmax98090 and others(banon, celes, edgar, kefka...) use rt5650.

Actually one more comment here.
Can you split per machine driver?

It adds constraints on BSW Chromebooks for same purpose. I don't see the benefit to split it.

Regards,
Brent

Quoted 7 lines
Quoted 2 lines
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 +++++++++++++-
 sound/soc/intel/boards/cht_bsw_rt5645.c      | 14 +++++++++++++-

--
With Best Regards,
Andy Shevchenko

#5 lore raw

Re: [PATCH v2 2/2] ASoC: Intel: Add period size constraint on strago board

Quoted 12 lines · Brent
Quoted 12 lines · Brent Lu
Quoted 10 lines

From: Yu-Hsuan Hsu <[email protected]>

The CRAS server does not set the period size in hw_param so ALSA will calculate a value for period size which is based on the buffer size and other parameters. The value may not always be aligned with Atom's dsp design so a constraint is added to make sure the board always has a good value.

Cyan uses chtmax98090 and others(banon, celes, edgar, kefka...) use rt5650.

Quoted 6 lines
Quoted 3 lines

Actually one more comment here.
Can you split per machine driver?

It adds constraints on BSW Chromebooks for same purpose. I don't see the benefit to split it.

I didn't get this.

Purpose of splitting this to two is to keep track on per driver basis what has had happen there.

But it's minor and up to maintainers, of course.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw
In reply to Brent Lu
Quoted 6 lines · Brent Lu

Two different constraints are implemented: one is in platform's CPU DAI to enforce period sizes which are already used in Android BSP. The other is in Atom Chromebook's machine driver to use 240 as period size.

Changes since v1:
-Add comma at the end of media_period_size array declaration.

You missed my tags, any reason why?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw
In reply to Brent Lu
Quoted 7 lines · Brent Lu

Two different constraints are implemented: one is in platform's CPU DAI to enforce period sizes which are already used in Android BSP. The other is in Atom Chromebook's machine driver to use 240 as period size.

Changes since v1:
-Add comma at the end of media_period_size array declaration.

Is it a hardware restriction? Unless it's a must for some hardware issues, enforcing such a small period size is nothing but a drawback for a system without CRAS.

thanks,

Takashi

Quoted 15 lines

Brent Lu (1):
ASoC: intel: atom: Add period size constraint

Yu-Hsuan Hsu (1):
ASoC: Intel: Add period size constraint on strago board

 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 15 +++++++++++++++
 sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 +++++++++++++-
 sound/soc/intel/boards/cht_bsw_rt5645.c      | 14 +++++++++++++-
 3 files changed, 41 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
author
#8 lore raw
Quoted 11 lines
Quoted 7 lines

Two different constraints are implemented: one is in platform's CPU DAI to enforce period sizes which are already used in Android BSP. The other is in Atom Chromebook's machine driver to use 240 as period size.

Changes since v1:
-Add comma at the end of media_period_size array declaration.

Is it a hardware restriction? Unless it's a must for some hardware issues, enforcing such a small period size is nothing but a drawback for a system without CRAS.

Hi Takashi,

This patch is cherry-picked from Chrome's branch which is originally implemented by google. They found this value works best with CRAS and these two machine drivers are for Chromebooks. Other BSW machine drivers are untouched.

Regards,
Brent

Quoted 21 lines

thanks,

Takashi

Quoted 15 lines

Brent Lu (1):
ASoC: intel: atom: Add period size constraint

Yu-Hsuan Hsu (1):
ASoC: Intel: Add period size constraint on strago board

 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 15 +++++++++++++++
sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 +++++++++++++-
 sound/soc/intel/boards/cht_bsw_rt5645.c      | 14 +++++++++++++-
 3 files changed, 41 insertions(+), 2 deletions(-)

--
2.7.4