Skip to content

Commit c3f4c47

Browse files
committed
ASoC: SOF: ipc4-compress: Implement get_caps callback
Parse the codec_info from fw_config message if present and return the supported codecs by the booted firmware. If the codec_info is missing then only set the information regarding to fragment sizes, numbers. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent bb461f2 commit c3f4c47

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

sound/soc/sof/ipc4-compress.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,57 @@ static int sof_ipc4_compr_free(struct snd_soc_component *component,
157157
return err;
158158
}
159159

160+
#define SOF_IPC4_CODEC_INFO_GET_ID(value) ((value) & 0xff)
161+
#define SOF_IPC4_CODEC_INFO_GET_DIR(value) (((value) >> 16) & 0xff)
162+
163+
struct sof_ipc4_codec_info_data {
164+
u32 count;
165+
u32 items[];
166+
} __packed __aligned(4);
167+
168+
static int sof_ipc4_compr_get_caps(struct snd_soc_component *component,
169+
struct snd_compr_stream *cstream,
170+
struct snd_compr_caps *caps)
171+
{
172+
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
173+
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
174+
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
175+
struct sof_ipc4_codec_info_data *fw_caps = ipc4_data->codec_info;
176+
struct snd_sof_pcm *spcm;
177+
int i;
178+
179+
spcm = snd_sof_find_spcm_dai(component, rtd);
180+
if (!spcm)
181+
return -EINVAL;
182+
183+
spcm_dbg(spcm, cstream->direction, "Entry: get_caps\n");
184+
185+
/* No codec information available, only fill the fragment information */
186+
if (!fw_caps)
187+
goto out;
188+
189+
for (i = 0; i < fw_caps->count; i++) {
190+
int dir = SOF_IPC4_CODEC_INFO_GET_DIR(fw_caps->items[i]);
191+
192+
if (dir == cstream->direction) {
193+
int id = SOF_IPC4_CODEC_INFO_GET_ID(fw_caps->items[i]);
194+
195+
spcm_dbg(spcm, cstream->direction, "codec#%d: %d\n",
196+
caps->num_codecs, id);
197+
caps->codecs[caps->num_codecs++] = id;
198+
}
199+
}
200+
201+
out:
202+
caps->direction = cstream->direction;
203+
caps->min_fragment_size = 3 * 1024;
204+
caps->max_fragment_size = 16 * 1024;
205+
caps->min_fragments = 4;
206+
caps->max_fragments = 8;
207+
208+
return 0;
209+
}
210+
160211
static int sof_ipc4_compr_alloc_pages(struct device *dev,
161212
struct snd_soc_component *component,
162213
struct snd_compr_stream *cstream)
@@ -535,6 +586,7 @@ static int sof_ipc4_compr_pointer(struct snd_soc_component *component,
535586
const struct snd_compress_ops sof_ipc4_compressed_ops = {
536587
.open = sof_ipc4_compr_open,
537588
.free = sof_ipc4_compr_free,
589+
.get_caps = sof_ipc4_compr_get_caps,
538590
.set_params = sof_ipc4_compr_set_params,
539591
.get_params = sof_ipc4_compr_get_params,
540592
.trigger = sof_ipc4_compr_trigger,

0 commit comments

Comments
 (0)