ASoC: codecs: hda: Switch to new stream-format interface
authorCezary Rojewski <cezary.rojewski@intel.com>
Fri, 17 Nov 2023 12:06:02 +0000 (13:06 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 27 Nov 2023 16:28:11 +0000 (17:28 +0100)
To provide option for selecting different bit-per-sample than just the
maximum one, use the new format calculation mechanism.

While at it, complete PCM stream initialization with subformat options.

Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20231117120610.1755254-9-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/soc/codecs/hda-dai.c
sound/soc/codecs/hda.c

index 5371ff0862618038fe7e704ac12a8d3f5302b191..7bd7ddcd810f2c25554b83ee9ae581fd7b0c05e1 100644 (file)
@@ -76,13 +76,16 @@ static int hda_codec_dai_prepare(struct snd_pcm_substream *substream, struct snd
        struct hdac_stream *stream;
        struct hda_codec *codec;
        unsigned int format;
+       unsigned int bits;
        int ret;
 
        codec = dev_to_hda_codec(dai->dev);
        stream = substream->runtime->private_data;
        stream_info = snd_soc_dai_get_dma_data(dai, substream);
-       format = snd_hdac_calc_stream_format(runtime->rate, runtime->channels, runtime->format,
-                                            runtime->sample_bits, 0);
+
+       bits = snd_hdac_stream_format_bits(runtime->format, runtime->subformat,
+                                          stream_info->maxbps);
+       format = snd_hdac_stream_format(runtime->channels, bits, runtime->rate);
 
        ret = snd_hda_codec_prepare(codec, stream_info, stream->stream_tag, format, substream);
        if (ret < 0) {
index d57b043d6bfefee2caeba910fd33a236e041aa4c..d2117e36ddd107704e7685d783e777eaf93b6b4b 100644 (file)
@@ -52,6 +52,7 @@ static int hda_codec_create_dais(struct hda_codec *codec, int pcm_count,
                stream->channels_max = pcm->stream[dir].channels_max;
                stream->rates = pcm->stream[dir].rates;
                stream->formats = pcm->stream[dir].formats;
+               stream->subformats = pcm->stream[dir].subformats;
                stream->sig_bits = pcm->stream[dir].maxbps;
 
 capture_dais:
@@ -71,6 +72,7 @@ capture_dais:
                stream->channels_max = pcm->stream[dir].channels_max;
                stream->rates = pcm->stream[dir].rates;
                stream->formats = pcm->stream[dir].formats;
+               stream->subformats = pcm->stream[dir].subformats;
                stream->sig_bits = pcm->stream[dir].maxbps;
        }