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