Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz
Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com,
	pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com,
	Cezary Rojewski <cezary.rojewski@intel.com>
Subject: [RFC PATCH 16/17] ASoC: Intel: avs: Unhardcode HDAudio BE DAI drivers description
Date: Fri, 11 Aug 2023 18:48:52 +0200	[thread overview]
Message-ID: <20230811164853.1797547-17-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20230811164853.1797547-1-cezary.rojewski@intel.com>

To not expose more than in fact is supported by the codec, update CPU
DAI initialization procedure to rely on codec capabilities instead of
hardcoding them. This includes subformat which is currently ignored.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/pcm.c | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index fa9d3292fe82..31737133b991 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -1413,27 +1413,6 @@ int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned l
 	return avs_soc_component_register(adev->dev, name, &avs_component_driver, cpus, cpu_count);
 }
 
-/* HD-Audio CPU DAI template */
-static const struct snd_soc_dai_driver hda_cpu_dai = {
-	.ops = &avs_dai_hda_be_ops,
-	.playback = {
-		.channels_min	= 1,
-		.channels_max	= 8,
-		.rates		= SNDRV_PCM_RATE_8000_192000,
-		.formats	= SNDRV_PCM_FMTBIT_S16_LE |
-				  SNDRV_PCM_FMTBIT_S24_LE |
-				  SNDRV_PCM_FMTBIT_S32_LE,
-	},
-	.capture = {
-		.channels_min	= 1,
-		.channels_max	= 8,
-		.rates		= SNDRV_PCM_RATE_8000_192000,
-		.formats	= SNDRV_PCM_FMTBIT_S16_LE |
-				  SNDRV_PCM_FMTBIT_S24_LE |
-				  SNDRV_PCM_FMTBIT_S32_LE,
-	},
-};
-
 static void avs_component_hda_unregister_dais(struct snd_soc_component *component)
 {
 	struct snd_soc_acpi_mach *mach;
@@ -1490,8 +1469,8 @@ static int avs_component_hda_probe(struct snd_soc_component *component)
 	for (i = 0; i < pcm_count; i++, pcm = list_next_entry(pcm, list)) {
 		struct snd_soc_dai *dai;
 
-		memcpy(&dais[i], &hda_cpu_dai, sizeof(*dais));
 		dais[i].id = i;
+		dais[i].ops = &avs_dai_hda_be_ops;
 		dais[i].name = devm_kasprintf(component->dev, GFP_KERNEL,
 					      "%s-cpu%d", cname, i);
 		if (!dais[i].name) {
@@ -1507,6 +1486,13 @@ static int avs_component_hda_probe(struct snd_soc_component *component)
 				ret = -ENOMEM;
 				goto exit;
 			}
+
+			dais[i].playback.formats = pcm->stream[0].formats;
+			dais[i].playback.subformats = pcm->stream[0].subformats;
+			dais[i].playback.rates = pcm->stream[0].rates;
+			dais[i].playback.channels_min = pcm->stream[0].channels_min;
+			dais[i].playback.channels_max = pcm->stream[0].channels_max;
+			dais[i].playback.sig_bits = pcm->stream[0].maxbps;
 		}
 
 		if (pcm->stream[1].substreams) {
@@ -1517,6 +1503,13 @@ static int avs_component_hda_probe(struct snd_soc_component *component)
 				ret = -ENOMEM;
 				goto exit;
 			}
+
+			dais[i].capture.formats = pcm->stream[1].formats;
+			dais[i].capture.subformats = pcm->stream[1].subformats;
+			dais[i].capture.rates = pcm->stream[1].rates;
+			dais[i].capture.channels_min = pcm->stream[1].channels_min;
+			dais[i].capture.channels_max = pcm->stream[1].channels_max;
+			dais[i].capture.sig_bits = pcm->stream[1].maxbps;
 		}
 
 		dai = snd_soc_register_dai(component, &dais[i], false);
-- 
2.25.1


  parent reply	other threads:[~2023-08-11 16:54 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11 16:48 [RFC PATCH 00/17] ALSA/ASoC: hda: Address format selection limitations and ambiguity Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 01/17] ALSA: pcm: Introduce MSBITS subformat interface Cezary Rojewski
2023-08-14 14:35   ` Takashi Iwai
2023-08-14 15:04     ` Cezary Rojewski
2023-08-22 15:03   ` Jaroslav Kysela
2023-08-22 15:07     ` Takashi Iwai
2023-08-22 15:29       ` Jaroslav Kysela
2023-08-22 15:38         ` Takashi Iwai
2023-08-22 19:03           ` Jaroslav Kysela
2023-08-23  8:11             ` Cezary Rojewski
2023-08-23  9:10               ` Jaroslav Kysela
2023-08-23  9:53                 ` Takashi Iwai
2023-08-23 10:00                   ` Jaroslav Kysela
2023-08-23 10:20                     ` Amadeusz Sławiński
2023-08-23 10:47                       ` Jaroslav Kysela
2023-08-23 11:08                         ` Takashi Iwai
2023-08-23 13:42                           ` Jaroslav Kysela
2023-08-23 16:29                             ` Amadeusz Sławiński
2023-08-23 17:42                               ` Kai Vehmanen
2023-08-24  7:31                               ` Jaroslav Kysela
2023-09-08 14:36                                 ` Cezary Rojewski
2023-09-11  7:35                                   ` Jaroslav Kysela
2023-09-11  8:43                                     ` Cezary Rojewski
2023-09-11 15:45                                       ` Cezary Rojewski
2023-09-12 16:30                                         ` Jaroslav Kysela
2023-09-13  7:44                                           ` Cezary Rojewski
2023-09-13  8:06                                             ` Jaroslav Kysela
2023-08-22 15:30       ` Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 02/17] ALSA: pcm: Honor subformat when configuring substream Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 03/17] ALSA: hda: Honor subformat when querying PCMs Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 04/17] ASoC: pcm: Honor subformat when configuring runtime Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 05/17] ALSA: hda: Upgrade stream-format infrastructure Cezary Rojewski
2023-08-14 14:41   ` Takashi Iwai
2023-08-14 14:47     ` Cezary Rojewski
2023-08-14 14:59       ` Takashi Iwai
2023-08-11 16:48 ` [RFC PATCH 06/17] ALSA: hda: Switch to new stream-format interface Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 07/17] ALSA: hda/hdmi: " Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 08/17] ALSA: hda/ca0132: " Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 09/17] ASoC: codecs: hda: " Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 10/17] ASoC: codecs: hdac_hda: " Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 11/17] ASoC: codecs: hdac_hdmi: " Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 12/17] ASoC: Intel Skylake: " Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 13/17] ASoC: SOF: Intel: " Cezary Rojewski
2023-08-11 18:21   ` Pierre-Louis Bossart
2023-08-14 10:51     ` Cezary Rojewski
2023-08-14 14:01       ` Pierre-Louis Bossart
2023-08-14 15:02         ` Cezary Rojewski
2023-08-14 17:02           ` Pierre-Louis Bossart
2023-08-11 16:48 ` [RFC PATCH 14/17] ASoC: Intel: avs: " Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 15/17] ALSA: hda: Drop snd_hdac_calc_stream_format() Cezary Rojewski
2023-08-11 16:48 ` Cezary Rojewski [this message]
2023-08-11 16:48 ` [RFC PATCH 17/17] ASoC: Intel: avs: Kill S24_LE in HDAudio streaming Cezary Rojewski
2023-08-21  7:49   ` Amadeusz Sławiński

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230811164853.1797547-17-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox