Skip to content

Commit 2c693bc

Browse files
committed
copier: implement qemu gateway type for userspace testing
Add a new QEMU gateway implementation to the copier component to facilitate userspace pipeline testing. This allows the copier to interface directly with the QEMU test environment, handling input and output classes specific to QEMU. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent ea9bdcd commit 2c693bc

6 files changed

Lines changed: 420 additions & 13 deletions

File tree

src/audio/copier/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_local_sources(sof copier.c copier_hifi.c copier_generic.c copier_host.c copier_dai.c)
1+
add_local_sources(sof copier.c copier_hifi.c copier_generic.c copier_host.c copier_dai.c copier_qemugtw.c)
22
if(CONFIG_IPC4_GATEWAY)
33
add_local_sources(sof
44
copier_ipcgtw.c

src/audio/copier/copier.c

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "host_copier.h"
4040
#include "dai_copier.h"
4141
#include "ipcgtw_copier.h"
42+
#include "qemugtw_copier.h"
4243
#if CONFIG_INTEL_ADSP_MIC_PRIVACY
4344
#include <zephyr/drivers/mic_privacy/intel/mic_privacy.h>
4445
#endif
@@ -218,6 +219,14 @@ __cold static int copier_init(struct processing_module *mod)
218219
}
219220
break;
220221
#endif
222+
case ipc4_qemu_output_class:
223+
case ipc4_qemu_input_class:
224+
ret = copier_qemugtw_create(mod, copier, dev->pipeline);
225+
if (ret < 0) {
226+
comp_err(dev, "unable to create QEMU gateway");
227+
goto error;
228+
}
229+
break;
221230
default:
222231
comp_err(dev, "unsupported dma type %x", (uint32_t)node_id.f.dma_type);
223232
ret = -EINVAL;
@@ -253,11 +262,14 @@ __cold static int copier_free(struct processing_module *mod)
253262

254263
switch (dev->ipc_config.type) {
255264
case SOF_COMP_HOST:
256-
if (!cd->ipc_gtw)
265+
if (cd->qemu_gtw) {
266+
copier_qemugtw_free(mod);
267+
} else if (!cd->ipc_gtw) {
257268
copier_host_free(mod);
258-
else
269+
} else {
259270
/* handle gtw case */
260271
copier_ipcgtw_free(mod);
272+
}
261273
break;
262274
case SOF_COMP_DAI:
263275
copier_dai_free(mod);
@@ -289,7 +301,9 @@ static int copier_prepare(struct processing_module *mod,
289301

290302
switch (dev->ipc_config.type) {
291303
case SOF_COMP_HOST:
292-
if (!cd->ipc_gtw) {
304+
if (cd->qemu_gtw) {
305+
/* do nothing */
306+
} else if (!cd->ipc_gtw) {
293307
ret = host_common_prepare(cd->hd);
294308
if (ret < 0)
295309
return ret;
@@ -312,8 +326,9 @@ static int copier_prepare(struct processing_module *mod,
312326
&cd->config.out_fmt, ipc4_gtw_none,
313327
ipc4_bidirection, DUMMY_CHMAP);
314328
if (!cd->converter[0]) {
315-
comp_err(dev, "can't support for in format %d, out format %d",
316-
cd->config.base.audio_fmt.depth, cd->config.out_fmt.depth);
329+
comp_err(dev, "can't support for in format %d (valid %d) out format %d (valid %d)",
330+
cd->config.base.audio_fmt.depth, cd->config.base.audio_fmt.valid_bit_depth,
331+
cd->config.out_fmt.depth, cd->config.out_fmt.valid_bit_depth);
317332
return -EINVAL;
318333
}
319334
}
@@ -334,7 +349,9 @@ static int copier_reset(struct processing_module *mod)
334349

335350
switch (dev->ipc_config.type) {
336351
case SOF_COMP_HOST:
337-
if (!cd->ipc_gtw)
352+
if (cd->qemu_gtw)
353+
copier_qemugtw_reset(dev);
354+
else if (!cd->ipc_gtw)
338355
host_common_reset(cd->hd, dev->state);
339356
else
340357
copier_ipcgtw_reset(dev);
@@ -376,7 +393,9 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
376393

377394
switch (dev->ipc_config.type) {
378395
case SOF_COMP_HOST:
379-
if (!cd->ipc_gtw) {
396+
if (cd->qemu_gtw) {
397+
/* do nothing */
398+
} else if (!cd->ipc_gtw) {
380399
ret = host_common_trigger(cd->hd, dev, cmd);
381400
if (ret < 0)
382401
return ret;
@@ -675,6 +694,9 @@ static int copier_process(struct processing_module *mod,
675694

676695
switch (dev->ipc_config.type) {
677696
case SOF_COMP_HOST:
697+
if (cd->qemu_gtw)
698+
return copier_qemugtw_process(dev);
699+
678700
if (!cd->ipc_gtw)
679701
return host_common_copy(cd->hd, dev, copier_host_dma_cb);
680702

@@ -708,7 +730,9 @@ static int copier_params(struct processing_module *mod)
708730
for (i = 0; i < cd->endpoint_num; i++) {
709731
switch (dev->ipc_config.type) {
710732
case SOF_COMP_HOST:
711-
if (!cd->ipc_gtw)
733+
if (cd->qemu_gtw)
734+
ret = copier_qemugtw_params(cd->qemugtw_data, dev, params);
735+
else if (!cd->ipc_gtw)
712736
ret = copier_host_params(cd, dev, params);
713737
else
714738
/* handle gtw case */
@@ -934,7 +958,7 @@ __cold static int copier_get_configuration(struct processing_module *mod,
934958

935959
assert_can_be_cold();
936960

937-
if (cd->ipc_gtw)
961+
if (cd->ipc_gtw || cd->qemu_gtw)
938962
return 0;
939963

940964
switch (config_id) {
@@ -1031,9 +1055,11 @@ static uint64_t copier_get_processed_data(struct comp_dev *dev, uint32_t stream_
10311055
switch (dev->ipc_config.type) {
10321056
case SOF_COMP_HOST:
10331057
source = dev->direction == SOF_IPC_STREAM_PLAYBACK;
1034-
/* only support host, not support ipcgtw case */
1035-
if (!cd->ipc_gtw && source == input)
1058+
/* support host and qemugtw gateway cases */
1059+
if (!cd->ipc_gtw && !cd->qemu_gtw && source == input)
10361060
ret = cd->hd->total_data_processed;
1061+
else if (cd->qemu_gtw && source == input)
1062+
ret = input ? cd->input_total_data_processed : cd->output_total_data_processed;
10371063
break;
10381064
case SOF_COMP_DAI:
10391065
source = dev->direction == SOF_IPC_STREAM_CAPTURE;
@@ -1068,7 +1094,7 @@ static int copier_position(struct comp_dev *dev, struct sof_ipc_stream_posn *pos
10681094
switch (dev->ipc_config.type) {
10691095
case SOF_COMP_HOST:
10701096
/* only support host not support gtw case */
1071-
if (!cd->ipc_gtw) {
1097+
if (!cd->ipc_gtw && !cd->qemu_gtw) {
10721098
posn->host_posn = cd->hd->local_pos;
10731099
ret = posn->host_posn;
10741100
}

src/audio/copier/copier.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,12 @@ struct copier_data {
263263
uint64_t output_total_data_processed;
264264
struct host_data *hd;
265265
bool ipc_gtw;
266+
bool qemu_gtw;
266267
struct dai_data *dd[IPC4_ALH_MAX_NUMBER_OF_GTW];
267268
uint32_t channels[IPC4_ALH_MAX_NUMBER_OF_GTW];
268269
uint32_t chan_map[IPC4_ALH_MAX_NUMBER_OF_GTW];
269270
struct ipcgtw_data *ipcgtw_data;
271+
struct qemugtw_data *qemugtw_data;
270272
#if CONFIG_INTEL_ADSP_MIC_PRIVACY
271273
struct mic_privacy_data *mic_priv;
272274
#endif

src/audio/copier/copier_generic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ pcm_converter_func get_converter_func(const struct ipc4_audio_format *in_fmt,
526526
if (in_fmt->s_type == IPC4_TYPE_MSB_INTEGER && in_valid == SOF_IPC_FRAME_S24_4LE) {
527527
switch (type) {
528528
case ipc4_gtw_host:
529+
case ipc4_gtw_qemu:
529530
if (dir == ipc4_playback)
530531
in_valid = SOF_IPC_FRAME_S24_4LE_MSB;
531532
break;
@@ -544,6 +545,7 @@ pcm_converter_func get_converter_func(const struct ipc4_audio_format *in_fmt,
544545
if (out_fmt->s_type == IPC4_TYPE_MSB_INTEGER && out_valid == SOF_IPC_FRAME_S24_4LE) {
545546
switch (type) {
546547
case ipc4_gtw_host:
548+
case ipc4_gtw_qemu:
547549
if (dir == ipc4_capture)
548550
out_valid = SOF_IPC_FRAME_S24_4LE_MSB;
549551
break;

0 commit comments

Comments
 (0)