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 14/17] ASoC: Intel: avs: Switch to new stream-format interface
Date: Fri, 11 Aug 2023 18:48:50 +0200	[thread overview]
Message-ID: <20230811164853.1797547-15-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20230811164853.1797547-1-cezary.rojewski@intel.com>

To provide option for selecting different bit-per-sample than just the
maximum one, use the new format calculation mechanism.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/loader.c |  4 ++--
 sound/soc/intel/avs/path.c   |  2 +-
 sound/soc/intel/avs/pcm.c    | 19 ++++++++++++++-----
 sound/soc/intel/avs/probes.c |  3 +--
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/sound/soc/intel/avs/loader.c b/sound/soc/intel/avs/loader.c
index b81b555846e6..2c682e844d22 100644
--- a/sound/soc/intel/avs/loader.c
+++ b/sound/soc/intel/avs/loader.c
@@ -373,7 +373,7 @@ int avs_hda_load_basefw(struct avs_dev *adev, struct firmware *fw)
 	hstream = hdac_stream(estream);
 
 	/* code loading performed with default format */
-	sdfmt = snd_hdac_calc_stream_format(48000, 1, SNDRV_PCM_FORMAT_S32_LE, 32, 0);
+	sdfmt = snd_hdac_stream_format(1, 32, 48000);
 	ret = snd_hdac_dsp_prepare(hstream, sdfmt, fw->size, &dmab);
 	if (ret < 0)
 		goto release_stream;
@@ -440,7 +440,7 @@ int avs_hda_load_library(struct avs_dev *adev, struct firmware *lib, u32 id)
 	stream = hdac_stream(estream);
 
 	/* code loading performed with default format */
-	sdfmt = snd_hdac_calc_stream_format(48000, 1, SNDRV_PCM_FORMAT_S32_LE, 32, 0);
+	sdfmt = snd_hdac_stream_format(1, 32, 48000);
 	ret = snd_hdac_dsp_prepare(stream, sdfmt, lib->size, &dmab);
 	if (ret < 0)
 		goto release_stream;
diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c
index 494e357e3b12..0475aa9c85ce 100644
--- a/sound/soc/intel/avs/path.c
+++ b/sound/soc/intel/avs/path.c
@@ -88,7 +88,7 @@ static bool avs_test_hw_params(struct snd_pcm_hw_params *params,
 	return (params_rate(params) == fmt->sampling_freq &&
 		params_channels(params) == fmt->num_channels &&
 		params_physical_width(params) == fmt->bit_depth &&
-		params_width(params) == fmt->valid_bit_depth);
+		params_bps(params) == fmt->valid_bit_depth);
 }
 
 static struct avs_tplg_path *
diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index 7f38cfc86492..fa9d3292fe82 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -336,20 +336,25 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn
 {
 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct hdac_ext_stream *link_stream = runtime->private_data;
+	struct snd_soc_pcm_stream *stream_info;
+	struct hdac_ext_stream *link_stream;
 	struct hdac_ext_link *link;
 	struct hda_codec *codec;
 	struct hdac_bus *bus;
 	unsigned int format_val;
+	unsigned int bps;
 	int ret;
 
+	link_stream = runtime->private_data;
 	if (link_stream->link_prepared)
 		return 0;
 
 	codec = dev_to_hda_codec(asoc_rtd_to_codec(rtd, 0)->dev);
 	bus = &codec->bus->core;
-	format_val = snd_hdac_calc_stream_format(runtime->rate, runtime->channels, runtime->format,
-						 runtime->sample_bits, 0);
+	stream_info = snd_soc_dai_get_pcm_stream(dai, substream->stream);
+	bps = snd_hdac_stream_format_bps(runtime->format, runtime->subformat,
+					 stream_info->sig_bits);
+	format_val = snd_hdac_stream_format(runtime->channels, bps, runtime->rate);
 
 	snd_hdac_ext_stream_reset(link_stream);
 	snd_hdac_ext_stream_setup(link_stream, format_val);
@@ -602,11 +607,13 @@ static int avs_dai_fe_hw_free(struct snd_pcm_substream *substream, struct snd_so
 static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct snd_soc_pcm_stream *stream_info;
 	struct avs_dma_data *data;
 	struct avs_dev *adev = to_avs_dev(dai->dev);
 	struct hdac_ext_stream *host_stream;
 	struct hdac_bus *bus;
 	unsigned int format_val;
+	unsigned int bps;
 	int ret;
 
 	data = snd_soc_dai_get_dma_data(dai, substream);
@@ -618,8 +625,10 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so
 	bus = hdac_stream(host_stream)->bus;
 	snd_hdac_stream_reset(hdac_stream(host_stream));
 
-	format_val = snd_hdac_calc_stream_format(runtime->rate, runtime->channels, runtime->format,
-						 runtime->sample_bits, 0);
+	stream_info = snd_soc_dai_get_pcm_stream(dai, substream->stream);
+	bps = snd_hdac_stream_format_bps(runtime->format, runtime->subformat,
+					 stream_info->sig_bits);
+	format_val = snd_hdac_stream_format(runtime->channels, bps, runtime->rate);
 
 	ret = snd_hdac_stream_set_params(hdac_stream(host_stream), format_val);
 	if (ret < 0)
diff --git a/sound/soc/intel/avs/probes.c b/sound/soc/intel/avs/probes.c
index 275928281c6c..1e67b6549be7 100644
--- a/sound/soc/intel/avs/probes.c
+++ b/sound/soc/intel/avs/probes.c
@@ -140,8 +140,7 @@ static int avs_probe_compr_set_params(struct snd_compr_stream *cstream,
 	bps = snd_pcm_format_physical_width(format);
 	if (bps < 0)
 		return bps;
-	format_val = snd_hdac_calc_stream_format(params->codec.sample_rate, params->codec.ch_out,
-						 format, bps, 0);
+	format_val = snd_hdac_stream_format(params->codec.ch_out, bps, params->codec.sample_rate);
 	ret = snd_hdac_stream_set_params(hdac_stream(host_stream), format_val);
 	if (ret < 0)
 		return ret;
-- 
2.25.1


  parent reply	other threads:[~2023-08-11 16:53 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 ` Cezary Rojewski [this message]
2023-08-11 16:48 ` [RFC PATCH 15/17] ALSA: hda: Drop snd_hdac_calc_stream_format() Cezary Rojewski
2023-08-11 16:48 ` [RFC PATCH 16/17] ASoC: Intel: avs: Unhardcode HDAudio BE DAI drivers description Cezary Rojewski
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-15-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