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().
Unified · Split
| @@ -255,6 +255,7 @@ static int sof_compr_set_params(struct snd_soc_component *component, · 254 unmodified lines | ||
| 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 | |
| @@ -267,9 +268,10 @@ out: · 6 unmodified lines | ||
| 267 | 268 | static int sof_compr_get_params(struct snd_soc_component *component, |
| 268 | 269 | struct snd_compr_stream *cstream, struct snd_codec *params) |
| 269 | 270 | { |
| 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 | + | |
| 273 | 275 | return 0; |
| 274 | 276 | } |
| 275 | 277 | |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | ||
| 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 | |
| @@ -111,6 +112,7 @@ struct sof_compr_stream { · 88 unmodified lines | ||
| 111 | 112 | u32 sampling_rate; |
| 112 | 113 | u16 channels; |
| 113 | 114 | u16 sample_container_bytes; |
| 115 | + struct snd_codec codec_params; | |
| 114 | 116 | size_t posn_offset; |
| 115 | 117 | }; |
| 116 | 118 | |