Skip to content

Commit 1ccdf07

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 0c45d72 commit 1ccdf07

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
@@ -216,6 +217,14 @@ __cold static int copier_init(struct processing_module *mod)
216217
}
217218
break;
218219
#endif
220+
case ipc4_qemu_output_class:
221+
case ipc4_qemu_input_class:
222+
ret = copier_qemugtw_create(mod, copier, dev->pipeline);
223+
if (ret < 0) {
224+
comp_err(dev, "unable to create QEMU gateway");
225+
goto error;
226+
}
227+
break;
219228
default:
220229
comp_err(dev, "unsupported dma type %x", (uint32_t)node_id.f.dma_type);
221230
ret = -EINVAL;
@@ -251,11 +260,14 @@ __cold static int copier_free(struct processing_module *mod)
251260

252261
switch (dev->ipc_config.type) {
253262
case SOF_COMP_HOST:
254-
if (!cd->ipc_gtw)
263+
if (cd->qemu_gtw) {
264+
copier_qemugtw_free(mod);
265+
} else if (!cd->ipc_gtw) {
255266
copier_host_free(mod);
256-
else
267+
} else {
257268
/* handle gtw case */
258269
copier_ipcgtw_free(mod);
270+
}
259271
break;
260272
case SOF_COMP_DAI:
261273
copier_dai_free(mod);
@@ -287,7 +299,9 @@ static int copier_prepare(struct processing_module *mod,
287299

288300
switch (dev->ipc_config.type) {
289301
case SOF_COMP_HOST:
290-
if (!cd->ipc_gtw) {
302+
if (cd->qemu_gtw) {
303+
/* do nothing */
304+
} else if (!cd->ipc_gtw) {
291305
ret = host_common_prepare(cd->hd);
292306
if (ret < 0)
293307
return ret;
@@ -310,8 +324,9 @@ static int copier_prepare(struct processing_module *mod,
310324
&cd->config.out_fmt, ipc4_gtw_none,
311325
ipc4_bidirection, DUMMY_CHMAP);
312326
if (!cd->converter[0]) {
313-
comp_err(dev, "can't support for in format %d, out format %d",
314-
cd->config.base.audio_fmt.depth, cd->config.out_fmt.depth);
327+
comp_err(dev, "can't support for in format %d (valid %d) out format %d (valid %d)",
328+
cd->config.base.audio_fmt.depth, cd->config.base.audio_fmt.valid_bit_depth,
329+
cd->config.out_fmt.depth, cd->config.out_fmt.valid_bit_depth);
315330
return -EINVAL;
316331
}
317332
}
@@ -332,7 +347,9 @@ static int copier_reset(struct processing_module *mod)
332347

333348
switch (dev->ipc_config.type) {
334349
case SOF_COMP_HOST:
335-
if (!cd->ipc_gtw)
350+
if (cd->qemu_gtw)
351+
copier_qemugtw_reset(dev);
352+
else if (!cd->ipc_gtw)
336353
host_common_reset(cd->hd, dev->state);
337354
else
338355
copier_ipcgtw_reset(dev);
@@ -374,7 +391,9 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
374391

375392
switch (dev->ipc_config.type) {
376393
case SOF_COMP_HOST:
377-
if (!cd->ipc_gtw) {
394+
if (cd->qemu_gtw) {
395+
/* do nothing */
396+
} else if (!cd->ipc_gtw) {
378397
ret = host_common_trigger(cd->hd, dev, cmd);
379398
if (ret < 0)
380399
return ret;
@@ -673,6 +692,9 @@ static int copier_process(struct processing_module *mod,
673692

674693
switch (dev->ipc_config.type) {
675694
case SOF_COMP_HOST:
695+
if (cd->qemu_gtw)
696+
return copier_qemugtw_process(dev);
697+
676698
if (!cd->ipc_gtw)
677699
return host_common_copy(cd->hd, dev, copier_host_dma_cb);
678700

@@ -706,7 +728,9 @@ static int copier_params(struct processing_module *mod)
706728
for (i = 0; i < cd->endpoint_num; i++) {
707729
switch (dev->ipc_config.type) {
708730
case SOF_COMP_HOST:
709-
if (!cd->ipc_gtw)
731+
if (cd->qemu_gtw)
732+
ret = copier_qemugtw_params(cd->qemugtw_data, dev, params);
733+
else if (!cd->ipc_gtw)
710734
ret = copier_host_params(cd, dev, params);
711735
else
712736
/* handle gtw case */
@@ -932,7 +956,7 @@ __cold static int copier_get_configuration(struct processing_module *mod,
932956

933957
assert_can_be_cold();
934958

935-
if (cd->ipc_gtw)
959+
if (cd->ipc_gtw || cd->qemu_gtw)
936960
return 0;
937961

938962
switch (config_id) {
@@ -1029,9 +1053,11 @@ static uint64_t copier_get_processed_data(struct comp_dev *dev, uint32_t stream_
10291053
switch (dev->ipc_config.type) {
10301054
case SOF_COMP_HOST:
10311055
source = dev->direction == SOF_IPC_STREAM_PLAYBACK;
1032-
/* only support host, not support ipcgtw case */
1033-
if (!cd->ipc_gtw && source == input)
1056+
/* support host and qemugtw gateway cases */
1057+
if (!cd->ipc_gtw && !cd->qemu_gtw && source == input)
10341058
ret = cd->hd->total_data_processed;
1059+
else if (cd->qemu_gtw && source == input)
1060+
ret = input ? cd->input_total_data_processed : cd->output_total_data_processed;
10351061
break;
10361062
case SOF_COMP_DAI:
10371063
source = dev->direction == SOF_IPC_STREAM_CAPTURE;
@@ -1066,7 +1092,7 @@ static int copier_position(struct comp_dev *dev, struct sof_ipc_stream_posn *pos
10661092
switch (dev->ipc_config.type) {
10671093
case SOF_COMP_HOST:
10681094
/* only support host not support gtw case */
1069-
if (!cd->ipc_gtw) {
1095+
if (!cd->ipc_gtw && !cd->qemu_gtw) {
10701096
posn->host_posn = cd->hd->local_pos;
10711097
ret = posn->host_posn;
10721098
}

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)