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 }
0 commit comments