Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: SOF: compress: return the configured codec from get_params

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>

authored by

Cássio Gabriel and committed by
Mark Brown
2c4fdd05 b481eabe

+7 -3
+5 -3
sound/soc/sof/compress.c
··· 255 255 sstream->sampling_rate = params->codec.sample_rate; 256 256 sstream->channels = params->codec.ch_out; 257 257 sstream->sample_container_bytes = pcm->params.sample_container_bytes; 258 + sstream->codec_params = params->codec; 258 259 259 260 spcm->prepared[cstream->direction] = true; 260 261 ··· 268 267 static int sof_compr_get_params(struct snd_soc_component *component, 269 268 struct snd_compr_stream *cstream, struct snd_codec *params) 270 269 { 271 - /* TODO: we don't query the supported codecs for now, if the 272 - * application asks for an unsupported codec the set_params() will fail. 273 - */ 270 + struct sof_compr_stream *sstream = cstream->runtime->private_data; 271 + 272 + *params = sstream->codec_params; 273 + 274 274 return 0; 275 275 } 276 276
+2
sound/soc/sof/sof-priv.h
··· 17 17 #include <sound/sof/info.h> 18 18 #include <sound/sof/pm.h> 19 19 #include <sound/sof/trace.h> 20 + #include <sound/compress_params.h> 20 21 #include <uapi/sound/sof/fw.h> 21 22 #include <sound/sof/ext_manifest.h> 22 23 ··· 112 111 u32 sampling_rate; 113 112 u16 channels; 114 113 u16 sample_container_bytes; 114 + struct snd_codec codec_params; 115 115 size_t posn_offset; 116 116 }; 117 117