History

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().

Cássio Gabriel committed 7 months ago

Commit 2c4fdd01 parent b481eab2 files · +7 −3Browse files

Unified · Split

2 files
  1. sound/soc/sof/compress.c +5 −3
  2. sound/soc/sof/sof-priv.h +2 −0
sound/soc/sof/compress.c+5−3
@@ -255,6 +255,7 @@ static int sof_compr_set_params(struct snd_soc_component *component, · 254 unmodified lines
255255 sstream->sampling_rate = params->codec.sample_rate;
256256 sstream->channels = params->codec.ch_out;
257257 sstream->sample_container_bytes = pcm->params.sample_container_bytes;
258+ sstream->codec_params = params->codec;
258259
259260 spcm->prepared[cstream->direction] = true;
260261
@@ -267,9 +268,10 @@ out: · 6 unmodified lines
267268 static int sof_compr_get_params(struct snd_soc_component *component,
268269 struct snd_compr_stream *cstream, struct snd_codec *params)
269270 {
270− /* TODO: we don't query the supported codecs for now, if the
271− * application asks for an unsupported codec the set_params() will fail.
272− */
271+ struct sof_compr_stream *sstream = cstream->runtime->private_data;
272+
273+ *params = sstream->codec_params;
274+
273275 return 0;
274276 }
275277
sound/soc/sof/sof-priv.h+2−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
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
@@ -111,6 +112,7 @@ struct sof_compr_stream { · 88 unmodified lines
111112 u32 sampling_rate;
112113 u16 channels;
113114 u16 sample_container_bytes;
115+ struct snd_codec codec_params;
114116 size_t posn_offset;
115117 };
116118