]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: SOF: compress: return the configured codec from get_params
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Wed, 25 Mar 2026 20:05:11 +0000 (17:05 -0300)
committerMark Brown <broonie@kernel.org>
Mon, 6 Apr 2026 12:11:57 +0000 (13:11 +0100)
The SOF compressed offload path accepts codec parameters in
sof_compr_set_params() and forwards them to firmware as
extended data in the SOF IPC stream params message.

However, sof_compr_get_params() still returns success without
filling the snd_codec structure. Since the compress core allocates
that structure zeroed and copies it back to userspace on success,
SNDRV_COMPRESS_GET_PARAMS returns an all-zero codec description
even after the stream has been configured successfully.

The stale TODO in this callback conflates get_params() with capability
discovery. Supported codec enumeration belongs in get_caps() and
get_codec_caps(). get_params() should report the current codec settings.

Cache the codec accepted by sof_compr_set_params() in the per-stream SOF
compress state and return it from sof_compr_get_params().

Fixes: 6324cf901e14 ("ASoC: SOF: compr: Add compress ops implementation")
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260325-sof-compr-get-params-v1-1-0758815f13c7@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/compress.c
sound/soc/sof/sof-priv.h

index 3dbc05bf3b79171b3fe9063d4f04beee36074f4a..f4c3e10e6344d438e4af0ab501886459c589c2b3 100644 (file)
@@ -255,6 +255,7 @@ static int sof_compr_set_params(struct snd_soc_component *component,
        sstream->sampling_rate = params->codec.sample_rate;
        sstream->channels = params->codec.ch_out;
        sstream->sample_container_bytes = pcm->params.sample_container_bytes;
+       sstream->codec_params = params->codec;
 
        spcm->prepared[cstream->direction] = true;
 
@@ -267,9 +268,10 @@ out:
 static int sof_compr_get_params(struct snd_soc_component *component,
                                struct snd_compr_stream *cstream, struct snd_codec *params)
 {
-       /* TODO: we don't query the supported codecs for now, if the
-        * application asks for an unsupported codec the set_params() will fail.
-        */
+       struct sof_compr_stream *sstream = cstream->runtime->private_data;
+
+       *params = sstream->codec_params;
+
        return 0;
 }
 
index 693d063830faeda9646a6a2e9534c6102c35e75a..38753b088fc1ddf88974257d958a87520c92bed2 100644 (file)
@@ -17,6 +17,7 @@
 #include <sound/sof/info.h>
 #include <sound/sof/pm.h>
 #include <sound/sof/trace.h>
+#include <sound/compress_params.h>
 #include <uapi/sound/sof/fw.h>
 #include <sound/sof/ext_manifest.h>
 
@@ -111,6 +112,7 @@ struct sof_compr_stream {
        u32 sampling_rate;
        u16 channels;
        u16 sample_container_bytes;
+       struct snd_codec codec_params;
        size_t posn_offset;
 };