Skip to contentSkip to conversation

ASoC: Intel: Boards: cml_da7219_max98390: set TDM format configuration

PATCH In review [email protected] 2 participants 2 messages Apr 15, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: Boards: cml_da7219_max98390: set TDM format configuration

From: Mac Chiang <[email protected]>

add tx/rx 2 channels, 32bits support

---
 sound/soc/intel/boards/bxt_da7219_max98357a.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
sound/soc/intel/boards/bxt_da7219_max98357a.c +25 -0
index 9ffef39..515379cd 100644
@@ -253,6 +253,30 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
 	return ret;
 }
 
+static int max98390_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai;
+	int j;
+
+	for_each_rtd_codec_dais(rtd, j, codec_dai) {
+		if (!strcmp(codec_dai->component->name, MAX98390_DEV0_NAME)) {
+			/* DEV0 tdm slot configuration */
+			snd_soc_dai_set_tdm_slot(codec_dai, 0x1, 3, 2, 32);
+		}
+		if (!strcmp(codec_dai->component->name, MAX98390_DEV1_NAME)) {
+			/* DEV1 tdm slot configuration */
+			snd_soc_dai_set_tdm_slot(codec_dai, 0x2, 3, 2, 32);
+		}
+	}
+	return 0;
+}
+
+struct snd_soc_ops max_98390_ops = {
+	.hw_params = max98390_hw_params,
+};
+
 static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct bxt_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
@@ -813,6 +837,7 @@ static int broxton_audio_probe(struct platform_device *pdev)
 				if (ctx->spkamp == SPKAMP_MAX98390) {
 					broxton_dais[i].codecs = max98390_codec;
 					broxton_dais[i].num_codecs = ARRAY_SIZE(max98390_codec);
+					broxton_dais[i].ops = &max_98390_ops;
 					broxton_dais[i].dpcm_capture = 1;
 				}
 			}
Signature · 1 line
2.7.4
#1 lore raw
Quoted 3 lines · On 4/15/21 1:59 AM, [email protected] wrote:

From: Mac Chiang <[email protected]>

add tx/rx 2 channels, 32bits support

If this is on CML, how would the 32 bits work?

you would be trying to generate a 48000*32*2=3072000Hz bit clock.

The base clock is 24 MHz, that's not an integer division.

I see you've used the same 32-bit value in the topology but I really don't get how this might work. Please tell me you are not using the M/N dividers, or if you do that you understand the impact the non-regular duty cycle will have on audio quality.

Quoted 50 lines
---
  sound/soc/intel/boards/bxt_da7219_max98357a.c | 25 +++++++++++++++++++++++++
  1 file changed, 25 insertions(+)
sound/soc/intel/boards/bxt_da7219_max98357a.c +25 -0
index 9ffef39..515379cd 100644
@@ -253,6 +253,30 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
  	return ret;
  }
 
+static int max98390_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai;
+	int j;
+
+	for_each_rtd_codec_dais(rtd, j, codec_dai) {
+		if (!strcmp(codec_dai->component->name, MAX98390_DEV0_NAME)) {
+			/* DEV0 tdm slot configuration */
+			snd_soc_dai_set_tdm_slot(codec_dai, 0x1, 3, 2, 32);
+		}
+		if (!strcmp(codec_dai->component->name, MAX98390_DEV1_NAME)) {
+			/* DEV1 tdm slot configuration */
+			snd_soc_dai_set_tdm_slot(codec_dai, 0x2, 3, 2, 32);
+		}
+	}
+	return 0;
+}
+
+struct snd_soc_ops max_98390_ops = {
+	.hw_params = max98390_hw_params,
+};
+
  static int broxton_hdmi_init(struct snd_soc_pcm_runtime *rtd)
  {
  	struct bxt_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
@@ -813,6 +837,7 @@ static int broxton_audio_probe(struct platform_device *pdev)
  				if (ctx->spkamp == SPKAMP_MAX98390) {
  					broxton_dais[i].codecs = max98390_codec;
  					broxton_dais[i].num_codecs = ARRAY_SIZE(max98390_codec);
+					broxton_dais[i].ops = &max_98390_ops;
  					broxton_dais[i].dpcm_capture = 1;
  				}
  			}