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