Skip to content

Commit c1f0f29

Browse files
CassivsGabriellisgregkh
authored andcommitted
ASoC: SOF: compress: return the configured codec from get_params
[ Upstream commit 2c4fdd0 ] 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: 6324cf9 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 26ded83 commit c1f0f29

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

sound/soc/sof/compress.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ static int sof_compr_set_params(struct snd_soc_component *component,
247247
sstream->sampling_rate = params->codec.sample_rate;
248248
sstream->channels = params->codec.ch_out;
249249
sstream->sample_container_bytes = pcm->params.sample_container_bytes;
250+
sstream->codec_params = params->codec;
250251

251252
spcm->prepared[cstream->direction] = true;
252253

@@ -259,9 +260,10 @@ static int sof_compr_set_params(struct snd_soc_component *component,
259260
static int sof_compr_get_params(struct snd_soc_component *component,
260261
struct snd_compr_stream *cstream, struct snd_codec *params)
261262
{
262-
/* TODO: we don't query the supported codecs for now, if the
263-
* application asks for an unsupported codec the set_params() will fail.
264-
*/
263+
struct sof_compr_stream *sstream = cstream->runtime->private_data;
264+
265+
*params = sstream->codec_params;
266+
265267
return 0;
266268
}
267269

sound/soc/sof/sof-priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <sound/sof/info.h>
1818
#include <sound/sof/pm.h>
1919
#include <sound/sof/trace.h>
20+
#include <sound/compress_params.h>
2021
#include <uapi/sound/sof/fw.h>
2122
#include <sound/sof/ext_manifest.h>
2223

@@ -119,6 +120,7 @@ struct sof_compr_stream {
119120
u32 sampling_rate;
120121
u16 channels;
121122
u16 sample_container_bytes;
123+
struct snd_codec codec_params;
122124
size_t posn_offset;
123125
};
124126

0 commit comments

Comments
 (0)