Skip to contentSkip to conversation

ASoC: Intel: Boards: Add CNL RT274 I2S machine driver

PATCH In review Guneshwor Singh 2 participants 6 messages Mar 15, 2018 – Mar 19, 2018

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

PATCH v2 1/1 ASoC: Intel: Boards: Add CNL RT274 I2S machine driver

Add CNL I2S machine driver using Realtek RT274 codec in I2S mode configured to ssp0.

---
 sound/soc/intel/boards/Kconfig     |  11 ++
 sound/soc/intel/boards/Makefile    |   2 +
 sound/soc/intel/boards/cnl_rt274.c | 232 +++++++++++++++++++++++++++++++++++++
 3 files changed, 245 insertions(+)
 create mode 100644 sound/soc/intel/boards/cnl_rt274.c
sound/soc/intel/boards/Kconfig +11 -0
index 24797482a3d2..822b9143dcb1 100644
@@ -281,6 +281,17 @@ config SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH
 	  Say Y if you have such a device.
 	  If unsure select "N".
 
+config SND_SOC_INTEL_CNL_RT274_MACH
+	tristate "ASoC Audio driver for Cannonlake with RT274 I2S mode"
+	depends on MFD_INTEL_LPSS && ACPI && I2C
+	select SND_SOC_RT274
+	select SND_SOC_DMIC
+	help
+	   This adds support for ASoC machine driver for Cannonlake platform
+	   with RT274 I2S audio codec.
+	   Say Y if you have such a device.
+	   If unsure select "N".
+
 endif ## SND_SOC_INTEL_SKYLAKE
 
 endif ## SND_SOC_INTEL_MACH
sound/soc/intel/boards/Makefile +2 -0
index 92b5507291af..2b49cb6aa84a 100644
@@ -21,6 +21,7 @@ snd-soc-kbl_rt5663_rt5514_max98927-objs := kbl_rt5663_rt5514_max98927.o
 snd-soc-skl_rt286-objs := skl_rt286.o
 snd-skl_nau88l25_max98357a-objs := skl_nau88l25_max98357a.o
 snd-soc-skl_nau88l25_ssm4567-objs := skl_nau88l25_ssm4567.o
+snd-soc-cnl-rt274-objs := cnl_rt274.o
 
 obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o
 obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o
@@ -44,3 +45,4 @@ obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH) += snd-soc-kbl_rt566
 obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o
 obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH) += snd-skl_nau88l25_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH) += snd-soc-skl_nau88l25_ssm4567.o
+obj-$(CONFIG_SND_SOC_INTEL_CNL_RT274_MACH) += snd-soc-cnl-rt274.o
sound/soc/intel/boards/cnl_rt274.c new file +232 -0

232 lines not on this page · raw message

Signature · 1 line
2.16.2
#1 lore raw
Quoted 32 lines
sound/soc/intel/boards/cnl_rt274.c new file +31 -0
+
+static int cnl_rt274_clock_control(struct snd_soc_dapm_widget *w,
+				   struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+	struct snd_soc_card *card = dapm->card;
+	struct snd_soc_dai *codec_dai =
+		snd_soc_card_get_codec_dai(card, RT274_CODEC_DAI);
+	int ret, ratio = 100;
+
+	if (!codec_dai)
+		return -EINVAL;
+
+	/* Codec needs clock for Jack detection and button press */
+	ret = snd_soc_dai_set_sysclk(codec_dai, RT274_SCLK_S_PLL2,
+				     CNL_FREQ_OUT, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec_dai->dev, "set codec sysclk failed: %d\n", ret);
+		return ret;
+	}
+
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		ret = snd_soc_dai_set_bclk_ratio(codec_dai, ratio);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"set bclk ratio failed: %d\n", ret);
+			return ret;
+		}
+
+		ret = snd_soc_dai_set_pll(codec_dai, 0, RT274_PLL2_S_BCLK,
+					  CNL_BE_FIXUP_RATE * ratio,

sound/soc/intel/boards/cnl_rt274.c line 53

Quoted 10 lines
sound/soc/intel/boards/cnl_rt274.c new file +10 -0
+					  CNL_FREQ_OUT);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"enable PLL2 failed: %d\n", ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}

it's not clear to me why you need a clock control? You are not changing anything that really depends on DAPM events, to e.g. take the MCLK down and use a local clock, so could this be moved to hw_params?

sound/soc/intel/boards/cnl_rt274.c line 92

Quoted 10 lines
sound/soc/intel/boards/cnl_rt274.c new file +10 -0
+static const struct snd_soc_dapm_route cnl_map[] = {
+	{"Headphone Jack", NULL, "HPO Pin"},
+	{"MIC", NULL, "Mic Jack"},
+	{"DMic", NULL, "SoC DMIC"},
+	{"DMIC01 Rx", NULL, "Capture"},
+	{"dmic01_hifi", NULL, "DMIC01 Rx"},
+
+	{"AIF1 Playback", NULL, "ssp0 Tx"},
+	{"ssp0 Tx", NULL, "codec1_out"},
+	{"ssp0 Tx", NULL, "codec0_out"},

I get the routes to connect firmware widgets to codec ones, but why do we need SSP0 TX-> codec1_out? shouldn't this be part of the topology?

Quoted 30 lines
sound/soc/intel/boards/cnl_rt274.c new file +30 -0
+
+	{"ssp0 Rx", NULL, "AIF1 Capture"},
+	{"codec0_in", NULL, "ssp0 Rx"},
+
+	{"Headphone Jack", NULL, "Platform Clock"},
+	{"Mic Jack", NULL, "Platform Clock"},
+};
+
+static	struct snd_soc_jack_pin cnl_headset_pins[] = {
+	{
+		.pin = "Mic Jack",
+		.mask = SND_JACK_MICROPHONE,
+	},
+	{
+		.pin = "Headphone Jack",
+		.mask = SND_JACK_HEADPHONE,
+	},
+};
+
+static struct snd_soc_jack cnl_headset;
+
+static int cnl_rt274_init(struct snd_soc_pcm_runtime *runtime)
+{
+	struct snd_soc_card *card = runtime->card;
+	struct snd_soc_dai *codec_dai = runtime->codec_dai;
+	struct snd_soc_component *component = codec_dai->component;
+	int ret;
+
+	ret = snd_soc_card_jack_new(runtime->card, "Headset",
+		SND_JACK_HEADSET, &cnl_headset,

sound/soc/intel/boards/cnl_rt274.c line 132

Quoted 10 lines
sound/soc/intel/boards/cnl_rt274.c new file +10 -0
+		cnl_headset_pins, ARRAY_SIZE(cnl_headset_pins));
+	if (ret)
+		return ret;
+
+	ret = snd_soc_component_set_jack(component, &cnl_headset, NULL);
+	if (ret)
+		return ret;
+
+	/* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
+	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0xf, 4, 24);

what are the 4 slots used for?

#2 lore raw

Hi Pierre,

Quoted 37 lines · Pierre-Louis Bossart
Quoted 37 lines
sound/soc/intel/boards/cnl_rt274.c new file +36 -0
+
+static int cnl_rt274_clock_control(struct snd_soc_dapm_widget *w,
+				   struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+	struct snd_soc_card *card = dapm->card;
+	struct snd_soc_dai *codec_dai =
+		snd_soc_card_get_codec_dai(card, RT274_CODEC_DAI);
+	int ret, ratio = 100;
+
+	if (!codec_dai)
+		return -EINVAL;
+
+	/* Codec needs clock for Jack detection and button press */
+	ret = snd_soc_dai_set_sysclk(codec_dai, RT274_SCLK_S_PLL2,
+				     CNL_FREQ_OUT, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec_dai->dev, "set codec sysclk failed: %d\n", ret);
+		return ret;
+	}
+
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		ret = snd_soc_dai_set_bclk_ratio(codec_dai, ratio);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"set bclk ratio failed: %d\n", ret);
+			return ret;
+		}
+
+		ret = snd_soc_dai_set_pll(codec_dai, 0, RT274_PLL2_S_BCLK,
+					  CNL_BE_FIXUP_RATE * ratio,
+					  CNL_FREQ_OUT);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"enable PLL2 failed: %d\n", ret);
+			return ret;
Quoted 8 lines

sound/soc/intel/boards/cnl_rt274.c line 53

Quoted 5 lines
sound/soc/intel/boards/cnl_rt274.c new file +5 -0
+		}
+	}
+
+	return 0;
+}

it's not clear to me why you need a clock control? You are not changing anything that really depends on DAPM events, to e.g. take the MCLK down and use a local clock, so could this be moved to hw_params?

Yes, we can do in hw_params too. When we implemented it we thought during simultaneous playback and capture, hw_params will be called twice but clock clock event will be called just once.

It does not harm to call twice as done in other machine drivers. Do you suggest to move it to hw_params?

Quoted 4 lines
Quoted 4 lines
sound/soc/intel/boards/cnl_rt274.c new file +4 -0
+static const struct snd_soc_dapm_route cnl_map[] = {
+	{"Headphone Jack", NULL, "HPO Pin"},
+	{"MIC", NULL, "Mic Jack"},
+	{"DMic", NULL, "SoC DMIC"},
Quoted 8 lines

sound/soc/intel/boards/cnl_rt274.c line 92

Quoted 6 lines
sound/soc/intel/boards/cnl_rt274.c new file +6 -0
+	{"DMIC01 Rx", NULL, "Capture"},
+	{"dmic01_hifi", NULL, "DMIC01 Rx"},
+
+	{"AIF1 Playback", NULL, "ssp0 Tx"},
+	{"ssp0 Tx", NULL, "codec1_out"},
+	{"ssp0 Tx", NULL, "codec0_out"},

I get the routes to connect firmware widgets to codec ones, but why do we need SSP0 TX-> codec1_out? shouldn't this be part of the topology?

We still have routes for BEs defined here. Only FE ones come from topology.

Quoted 33 lines
Quoted 33 lines
sound/soc/intel/boards/cnl_rt274.c new file +33 -0
+
+	{"ssp0 Rx", NULL, "AIF1 Capture"},
+	{"codec0_in", NULL, "ssp0 Rx"},
+
+	{"Headphone Jack", NULL, "Platform Clock"},
+	{"Mic Jack", NULL, "Platform Clock"},
+};
+
+static	struct snd_soc_jack_pin cnl_headset_pins[] = {
+	{
+		.pin = "Mic Jack",
+		.mask = SND_JACK_MICROPHONE,
+	},
+	{
+		.pin = "Headphone Jack",
+		.mask = SND_JACK_HEADPHONE,
+	},
+};
+
+static struct snd_soc_jack cnl_headset;
+
+static int cnl_rt274_init(struct snd_soc_pcm_runtime *runtime)
+{
+	struct snd_soc_card *card = runtime->card;
+	struct snd_soc_dai *codec_dai = runtime->codec_dai;
+	struct snd_soc_component *component = codec_dai->component;
+	int ret;
+
+	ret = snd_soc_card_jack_new(runtime->card, "Headset",
+		SND_JACK_HEADSET, &cnl_headset,
+		cnl_headset_pins, ARRAY_SIZE(cnl_headset_pins));
+	if (ret)
+		return ret;
Quoted 8 lines

sound/soc/intel/boards/cnl_rt274.c line 132

Quoted 7 lines
sound/soc/intel/boards/cnl_rt274.c new file +7 -0
+
+	ret = snd_soc_component_set_jack(component, &cnl_headset, NULL);
+	if (ret)
+		return ret;
+
+	/* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
+	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0xf, 4, 24);

what are the 4 slots used for?

Ah, this is a mistake. Thanks for pointing out. It should be snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 2, 24) as we do not have speakers on rt274. Will correct in v3.

Quoted 1 line
#3 lore raw
Quoted 49 lines · Guneshwor Singh

Hi Pierre,

Quoted 37 lines · Pierre-Louis Bossart
Quoted 37 lines
sound/soc/intel/boards/cnl_rt274.c new file +36 -0
+
+static int cnl_rt274_clock_control(struct snd_soc_dapm_widget *w,
+				   struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+	struct snd_soc_card *card = dapm->card;
+	struct snd_soc_dai *codec_dai =
+		snd_soc_card_get_codec_dai(card, RT274_CODEC_DAI);
+	int ret, ratio = 100;
+
+	if (!codec_dai)
+		return -EINVAL;
+
+	/* Codec needs clock for Jack detection and button press */
+	ret = snd_soc_dai_set_sysclk(codec_dai, RT274_SCLK_S_PLL2,
+				     CNL_FREQ_OUT, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec_dai->dev, "set codec sysclk failed: %d\n", ret);
+		return ret;
+	}
+
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		ret = snd_soc_dai_set_bclk_ratio(codec_dai, ratio);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"set bclk ratio failed: %d\n", ret);
+			return ret;
+		}
+
+		ret = snd_soc_dai_set_pll(codec_dai, 0, RT274_PLL2_S_BCLK,
+					  CNL_BE_FIXUP_RATE * ratio,
+					  CNL_FREQ_OUT);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"enable PLL2 failed: %d\n", ret);
+			return ret;
Quoted 8 lines

sound/soc/intel/boards/cnl_rt274.c line 53

Quoted 5 lines
sound/soc/intel/boards/cnl_rt274.c new file +5 -0
+		}
+	}
+
+	return 0;
+}

it's not clear to me why you need a clock control? You are not changing anything that really depends on DAPM events, to e.g. take the MCLK down and use a local clock, so could this be moved to hw_params?

Quoted 3 lines

Yes, we can do in hw_params too. When we implemented it we thought during simultaneous playback and capture, hw_params will be called twice but clock clock event will be called just once.

Yes, I remember this discussion but what's missing here is that PLL is always set to the max value, in most cases we fall back to a local clock to save power a bit. And it's probably wrong to leave a PLL on if the clock reference is turned off on the SOC side.

Quoted 17 lines

It does not harm to call twice as done in other machine drivers. Do you suggest to move it to hw_params?

Quoted 4 lines
Quoted 4 lines
sound/soc/intel/boards/cnl_rt274.c new file +4 -0
+static const struct snd_soc_dapm_route cnl_map[] = {
+	{"Headphone Jack", NULL, "HPO Pin"},
+	{"MIC", NULL, "Mic Jack"},
+	{"DMic", NULL, "SoC DMIC"},
Quoted 8 lines

sound/soc/intel/boards/cnl_rt274.c line 92

Quoted 6 lines
sound/soc/intel/boards/cnl_rt274.c new file +6 -0
+	{"DMIC01 Rx", NULL, "Capture"},
+	{"dmic01_hifi", NULL, "DMIC01 Rx"},
+
+	{"AIF1 Playback", NULL, "ssp0 Tx"},
+	{"ssp0 Tx", NULL, "codec1_out"},
+	{"ssp0 Tx", NULL, "codec0_out"},

I get the routes to connect firmware widgets to codec ones, but why do we need SSP0 TX-> codec1_out? shouldn't this be part of the topology?

Quoted 2 lines

We still have routes for BEs defined here. Only FE ones come from topology.

The comment was about the codec1_out->SSP0 TX. Why is this hard-coded? You would only need SSP0 TX->AIF1 playback

Quoted 43 lines
Quoted 34 lines
Quoted 34 lines
sound/soc/intel/boards/cnl_rt274.c new file +33 -0
+
+	{"ssp0 Rx", NULL, "AIF1 Capture"},
+	{"codec0_in", NULL, "ssp0 Rx"},
+
+	{"Headphone Jack", NULL, "Platform Clock"},
+	{"Mic Jack", NULL, "Platform Clock"},
+};
+
+static	struct snd_soc_jack_pin cnl_headset_pins[] = {
+	{
+		.pin = "Mic Jack",
+		.mask = SND_JACK_MICROPHONE,
+	},
+	{
+		.pin = "Headphone Jack",
+		.mask = SND_JACK_HEADPHONE,
+	},
+};
+
+static struct snd_soc_jack cnl_headset;
+
+static int cnl_rt274_init(struct snd_soc_pcm_runtime *runtime)
+{
+	struct snd_soc_card *card = runtime->card;
+	struct snd_soc_dai *codec_dai = runtime->codec_dai;
+	struct snd_soc_component *component = codec_dai->component;
+	int ret;
+
+	ret = snd_soc_card_jack_new(runtime->card, "Headset",
+		SND_JACK_HEADSET, &cnl_headset,
+		cnl_headset_pins, ARRAY_SIZE(cnl_headset_pins));
+	if (ret)
+		return ret;
Quoted 8 lines

sound/soc/intel/boards/cnl_rt274.c line 132

Quoted 7 lines
sound/soc/intel/boards/cnl_rt274.c new file +7 -0
+
+	ret = snd_soc_component_set_jack(component, &cnl_headset, NULL);
+	if (ret)
+		return ret;
+
+	/* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
+	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0xf, 4, 24);

what are the 4 slots used for?

Quoted 3 lines

Ah, this is a mistake. Thanks for pointing out. It should be snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 2, 24) as we do not have speakers on rt274. Will correct in v3.

then it also begs the question why you needed to have both codec0_out and codec1_out mentioned above - same issue really about hard-coding things that should be topology defined.

Quoted 7 lines
Quoted 2 lines

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw
Quoted 50 lines · Pierre-Louis Bossart
Quoted 49 lines · Guneshwor Singh

Hi Pierre,

Quoted 45 lines · Pierre-Louis Bossart
Quoted 32 lines
sound/soc/intel/boards/cnl_rt274.c new file +31 -0
+
+static int cnl_rt274_clock_control(struct snd_soc_dapm_widget *w,
+				   struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+	struct snd_soc_card *card = dapm->card;
+	struct snd_soc_dai *codec_dai =
+		snd_soc_card_get_codec_dai(card, RT274_CODEC_DAI);
+	int ret, ratio = 100;
+
+	if (!codec_dai)
+		return -EINVAL;
+
+	/* Codec needs clock for Jack detection and button press */
+	ret = snd_soc_dai_set_sysclk(codec_dai, RT274_SCLK_S_PLL2,
+				     CNL_FREQ_OUT, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec_dai->dev, "set codec sysclk failed: %d\n", ret);
+		return ret;
+	}
+
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		ret = snd_soc_dai_set_bclk_ratio(codec_dai, ratio);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"set bclk ratio failed: %d\n", ret);
+			return ret;
+		}
+
+		ret = snd_soc_dai_set_pll(codec_dai, 0, RT274_PLL2_S_BCLK,
+					  CNL_BE_FIXUP_RATE * ratio,

sound/soc/intel/boards/cnl_rt274.c line 53

Quoted 10 lines
sound/soc/intel/boards/cnl_rt274.c new file +10 -0
+					  CNL_FREQ_OUT);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"enable PLL2 failed: %d\n", ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}

it's not clear to me why you need a clock control? You are not changing anything that really depends on DAPM events, to e.g. take the MCLK down and use a local clock, so could this be moved to hw_params?

Quoted 9 lines
Quoted 3 lines

Yes, we can do in hw_params too. When we implemented it we thought during simultaneous playback and capture, hw_params will be called twice but clock clock event will be called just once.

Yes, I remember this discussion but what's missing here is that PLL is always set to the max value, in most cases we fall back to a local clock to save power a bit. And it's probably wrong to leave a PLL on if the clock reference is turned off on the SOC side.

Ok, got you. I should do stop in else part of it something like

else

	snd_soc_dai_set_pll(codec_dai, 0, RT274_PLL2_S_BCLK, 0, 0);
Quoted 17 lines
Quoted 17 lines

It does not harm to call twice as done in other machine drivers. Do you suggest to move it to hw_params?

Quoted 12 lines

sound/soc/intel/boards/cnl_rt274.c line 92

Quoted 10 lines
sound/soc/intel/boards/cnl_rt274.c new file +10 -0
+static const struct snd_soc_dapm_route cnl_map[] = {
+	{"Headphone Jack", NULL, "HPO Pin"},
+	{"MIC", NULL, "Mic Jack"},
+	{"DMic", NULL, "SoC DMIC"},
+	{"DMIC01 Rx", NULL, "Capture"},
+	{"dmic01_hifi", NULL, "DMIC01 Rx"},
+
+	{"AIF1 Playback", NULL, "ssp0 Tx"},
+	{"ssp0 Tx", NULL, "codec1_out"},
+	{"ssp0 Tx", NULL, "codec0_out"},

I get the routes to connect firmware widgets to codec ones, but why do we need SSP0 TX-> codec1_out? shouldn't this be part of the topology?

Quoted 6 lines
Quoted 2 lines

We still have routes for BEs defined here. Only FE ones come from topology.

The comment was about the codec1_out->SSP0 TX. Why is this hard-coded? You would only need SSP0 TX->AIF1 playback

Yes, to maintain similarity with other Intel machine drivers this was done. All routes of BE widgets are hard-coded. The same can be done from topology too. Let me remove these including codec0_in from here in v3.

Quoted 43 lines
Quoted 43 lines
Quoted 42 lines
Quoted 31 lines
sound/soc/intel/boards/cnl_rt274.c new file +30 -0
+
+	{"ssp0 Rx", NULL, "AIF1 Capture"},
+	{"codec0_in", NULL, "ssp0 Rx"},
+
+	{"Headphone Jack", NULL, "Platform Clock"},
+	{"Mic Jack", NULL, "Platform Clock"},
+};
+
+static	struct snd_soc_jack_pin cnl_headset_pins[] = {
+	{
+		.pin = "Mic Jack",
+		.mask = SND_JACK_MICROPHONE,
+	},
+	{
+		.pin = "Headphone Jack",
+		.mask = SND_JACK_HEADPHONE,
+	},
+};
+
+static struct snd_soc_jack cnl_headset;
+
+static int cnl_rt274_init(struct snd_soc_pcm_runtime *runtime)
+{
+	struct snd_soc_card *card = runtime->card;
+	struct snd_soc_dai *codec_dai = runtime->codec_dai;
+	struct snd_soc_component *component = codec_dai->component;
+	int ret;
+
+	ret = snd_soc_card_jack_new(runtime->card, "Headset",
+		SND_JACK_HEADSET, &cnl_headset,

sound/soc/intel/boards/cnl_rt274.c line 132

Quoted 10 lines
sound/soc/intel/boards/cnl_rt274.c new file +10 -0
+		cnl_headset_pins, ARRAY_SIZE(cnl_headset_pins));
+	if (ret)
+		return ret;
+
+	ret = snd_soc_component_set_jack(component, &cnl_headset, NULL);
+	if (ret)
+		return ret;
+
+	/* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
+	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0xf, 4, 24);

what are the 4 slots used for?

Quoted 7 lines
Quoted 3 lines

Ah, this is a mistake. Thanks for pointing out. It should be snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 2, 24) as we do not have speakers on rt274. Will correct in v3.

then it also begs the question why you needed to have both codec0_out and codec1_out mentioned above - same issue really about hard-coding things that should be topology defined.

It should by only codec0_out (codec1_out shouldn't be there at all).

Thanks for the review!

Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw
Quoted 61 lines · Guneshwor Singh
Quoted 50 lines · Pierre-Louis Bossart
Quoted 49 lines · Guneshwor Singh

Hi Pierre,

Quoted 45 lines · Pierre-Louis Bossart
Quoted 32 lines
sound/soc/intel/boards/cnl_rt274.c new file +31 -0
+
+static int cnl_rt274_clock_control(struct snd_soc_dapm_widget *w,
+				   struct snd_kcontrol *k, int event)
+{
+	struct snd_soc_dapm_context *dapm = w->dapm;
+	struct snd_soc_card *card = dapm->card;
+	struct snd_soc_dai *codec_dai =
+		snd_soc_card_get_codec_dai(card, RT274_CODEC_DAI);
+	int ret, ratio = 100;
+
+	if (!codec_dai)
+		return -EINVAL;
+
+	/* Codec needs clock for Jack detection and button press */
+	ret = snd_soc_dai_set_sysclk(codec_dai, RT274_SCLK_S_PLL2,
+				     CNL_FREQ_OUT, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(codec_dai->dev, "set codec sysclk failed: %d\n", ret);
+		return ret;
+	}
+
+	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		ret = snd_soc_dai_set_bclk_ratio(codec_dai, ratio);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"set bclk ratio failed: %d\n", ret);
+			return ret;
+		}
+
+		ret = snd_soc_dai_set_pll(codec_dai, 0, RT274_PLL2_S_BCLK,
+					  CNL_BE_FIXUP_RATE * ratio,

sound/soc/intel/boards/cnl_rt274.c line 53

Quoted 10 lines
sound/soc/intel/boards/cnl_rt274.c new file +10 -0
+					  CNL_FREQ_OUT);
+		if (ret) {
+			dev_err(codec_dai->dev,
+				"enable PLL2 failed: %d\n", ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}

it's not clear to me why you need a clock control? You are not changing anything that really depends on DAPM events, to e.g. take the MCLK down and use a local clock, so could this be moved to hw_params?

Quoted 9 lines
Quoted 3 lines

Yes, we can do in hw_params too. When we implemented it we thought during simultaneous playback and capture, hw_params will be called twice but clock clock event will be called just once.

Yes, I remember this discussion but what's missing here is that PLL is always set to the max value, in most cases we fall back to a local clock to save power a bit. And it's probably wrong to leave a PLL on if the clock reference is turned off on the SOC side.

Quoted 4 lines

Ok, got you. I should do stop in else part of it something like

else

	snd_soc_dai_set_pll(codec_dai, 0, RT274_PLL2_S_BCLK, 0, 0);

something like that yes, but likely using an internal codec clock source for e.g. jack detection.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

sound/soc/intel/boards/cnl_rt274.c line 132

Quoted 2 lines
sound/soc/intel/boards/cnl_rt274.c new file +2 -0
+	/* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
+	ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0xf, 4, 24);

what are the 4 slots used for?

Ah, this is a mistake. Thanks for pointing out. It should be snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 0x3, 2, 24) as we do not have speakers on rt274. Will correct in v3.

Quoted 5 lines
Quoted 3 lines

then it also begs the question why you needed to have both codec0_out and codec1_out mentioned above - same issue really about hard-coding things that should be topology defined.

It should by only codec0_out (codec1_out shouldn't be there at all).

SSP0 is the BE so this need to be hard-codec. codec0_out is a topology item to me and should not be in a machine driver.