ASoC: amd: Adds rate and channel constraints for capture in Stoney rt5645
diff mbox

Message ID 1513572020-7689-1-git-send-email-akshu.agrawal@amd.com
State New
Headers show

Commit Message

Agrawal, Akshu Dec. 18, 2017, 4:40 a.m. UTC
Constraints are added as we support 48Khz and dual channels.

Change-Id: Ib705f1101f5e2ab5c04f9526b10795a45a32debc
Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
---
 sound/soc/amd/acp-rt5645.c | 49 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 3 deletions(-)

Comments

Mark Brown Dec. 19, 2017, 9:31 a.m. UTC | #1
On Mon, Dec 18, 2017 at 10:10:20AM +0530, Akshu Agrawal wrote:

> Constraints are added as we support 48Khz and dual channels.

Why is this platform more resticted than other platforms - what's the
limitation here?

> Change-Id: Ib705f1101f5e2ab5c04f9526b10795a45a32debc

Don't include noise like this in upstream submissions, it makes no sense
outside your internal environment.

> +#define DUAL_CHANNEL		2

Do we really need a macro for this?
Agrawal, Akshu Dec. 19, 2017, 9:55 a.m. UTC | #2
On 12/19/2017 3:01 PM, Mark Brown wrote:
> On Mon, Dec 18, 2017 at 10:10:20AM +0530, Akshu Agrawal wrote:
> 
>> Constraints are added as we support 48Khz and dual channels.
> 
> Why is this platform more resticted than other platforms - what's the
> limitation here?

The above restrictions are for capture. In Stoney host we are supporting 
8 channels and 96Khz for playback and 2 channels and 48Khz for capture.

> 
>> Change-Id: Ib705f1101f5e2ab5c04f9526b10795a45a32debc
> 
> Don't include noise like this in upstream submissions, it makes no sense
> outside your internal environment.

ok sure, will remove it.

> 
>> +#define DUAL_CHANNEL		2
> 
> Do we really need a macro for this?
> 

Not required, will remove it too.
Mark Brown Dec. 19, 2017, 10:01 a.m. UTC | #3
On Tue, Dec 19, 2017 at 03:25:16PM +0530, Agrawal, Akshu wrote:
> On 12/19/2017 3:01 PM, Mark Brown wrote:
> > On Mon, Dec 18, 2017 at 10:10:20AM +0530, Akshu Agrawal wrote:

> > > Constraints are added as we support 48Khz and dual channels.

> > Why is this platform more resticted than other platforms - what's the
> > limitation here?

> The above restrictions are for capture. In Stoney host we are supporting 8
> channels and 96Khz for playback and 2 channels and 48Khz for capture.

So this is just a different SoC not a board?  Why not just register a
DAI with the appropriate constraints rather than add extra constraints
in hw_params?

Patch
diff mbox

diff --git a/sound/soc/amd/acp-rt5645.c b/sound/soc/amd/acp-rt5645.c
index 941aed6..f3f96c6 100644
--- a/sound/soc/amd/acp-rt5645.c
+++ b/sound/soc/amd/acp-rt5645.c
@@ -40,6 +40,7 @@ 
 #include "../codecs/rt5645.h"
 
 #define CZ_PLAT_CLK 24000000
+#define DUAL_CHANNEL		2
 
 static struct snd_soc_jack cz_jack;
 
@@ -91,8 +92,50 @@  static int cz_init(struct snd_soc_pcm_runtime *rtd)
 	return 0;
 }
 
-static struct snd_soc_ops cz_aif1_ops = {
+static const unsigned int channels[] = {
+	DUAL_CHANNEL,
+};
+
+static const unsigned int rates[] = {
+	48000,
+};
+
+static const struct snd_pcm_hw_constraint_list constraints_rates = {
+	.count = ARRAY_SIZE(rates),
+	.list  = rates,
+	.mask = 0,
+};
+
+static const struct snd_pcm_hw_constraint_list constraints_channels = {
+	.count = ARRAY_SIZE(channels),
+	.list = channels,
+	.mask = 0,
+};
+
+static int cz_fe_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+
+	/*
+	 * On this platform for PCM device we support stereo
+	 */
+
+	runtime->hw.channels_max = DUAL_CHANNEL;
+	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
+				   &constraints_channels);
+	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+				   &constraints_rates);
+
+	return 0;
+}
+
+static struct snd_soc_ops cz_aif1_play_ops = {
+	.hw_params = cz_aif1_hw_params,
+};
+
+static struct snd_soc_ops cz_aif1_cap_ops = {
 	.hw_params = cz_aif1_hw_params,
+	.startup = cz_fe_startup,
 };
 
 static struct snd_soc_dai_link cz_dai_rt5650[] = {
@@ -106,7 +149,7 @@  static int cz_init(struct snd_soc_pcm_runtime *rtd)
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.init = cz_init,
-		.ops = &cz_aif1_ops,
+		.ops = &cz_aif1_play_ops,
 	},
 	{
 		.name = "amd-rt5645-cap",
@@ -117,7 +160,7 @@  static int cz_init(struct snd_soc_pcm_runtime *rtd)
 		.codec_name = "i2c-10EC5650:00",
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
-		.ops = &cz_aif1_ops,
+		.ops = &cz_aif1_cap_ops,
 	},
 };