Skip to content

Commit 5f118b7

Browse files
btian1kv2019i
authored andcommitted
copier: use separate function for multi endpoint and module copy
Copier_copy left code is for multi endpoint and module copy, move it to a separate function. Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
1 parent 5fdecbc commit 5f118b7

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

src/audio/copier/copier.c

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -467,40 +467,13 @@ static int do_conversion_copy(struct comp_dev *dev,
467467
return 0;
468468
}
469469

470-
/* Copier has one input and one or more outputs. Maximum of one gateway can be connected
471-
* to copier or no gateway connected at all. Gateway can only be connected to either input
472-
* pin 0 (the only input) or output pin 0. With or without connected gateway it is also
473-
* possible to have component(s) connected on input and/or output pins.
474-
*
475-
* A special exception is a multichannel ALH gateway case. These are multiple gateways
476-
* but should be treated like a single gateway to satisfy rules above. Data from such
477-
* gateways has to be multiplexed into single stream (for input gateways) or demultiplexed
478-
* from single stream (for output gateways) so such gateways work kind of like a single
479-
* gateway, i.e., produce/consume single stream.
480-
*/
481-
static int copier_copy(struct comp_dev *dev)
470+
static int do_multi_endpoint_module_copy(struct copier_data *cd, struct comp_dev *dev)
482471
{
483-
struct copier_data *cd = comp_get_drvdata(dev);
484472
struct comp_buffer *src, *sink;
485473
struct comp_buffer __sparse_cache *src_c, *sink_c;
486474
struct comp_copy_limits processed_data;
487475
struct list_item *sink_list;
488-
int ret = 0;
489-
490-
comp_dbg(dev, "copier_copy()");
491-
492-
switch (dev->ipc_config.type) {
493-
case SOF_COMP_HOST:
494-
if (!cd->ipc_gtw)
495-
return do_endpoint_copy(dev);
496-
break;
497-
case SOF_COMP_DAI:
498-
if (cd->endpoint_num == 1)
499-
return do_endpoint_copy(dev);
500-
break;
501-
default:
502-
break;
503-
}
476+
int ret = 0;
504477

505478
processed_data.source_bytes = 0;
506479

@@ -540,7 +513,7 @@ static int copier_copy(struct comp_dev *dev)
540513
}
541514
}
542515

543-
/* zero or more components on outputs */
516+
/* zero or more components on outputs, module copy case */
544517
list_for_item(sink_list, &dev->bsink_list) {
545518
struct comp_dev *sink_dev;
546519

@@ -571,6 +544,39 @@ static int copier_copy(struct comp_dev *dev)
571544
return ret;
572545
}
573546

547+
/* Copier has one input and one or more outputs. Maximum of one gateway can be connected
548+
* to copier or no gateway connected at all. Gateway can only be connected to either input
549+
* pin 0 (the only input) or output pin 0. With or without connected gateway it is also
550+
* possible to have component(s) connected on input and/or output pins.
551+
*
552+
* A special exception is a multichannel ALH gateway case. These are multiple gateways
553+
* but should be treated like a single gateway to satisfy rules above. Data from such
554+
* gateways has to be multiplexed into single stream (for input gateways) or demultiplexed
555+
* from single stream (for output gateways) so such gateways work kind of like a single
556+
* gateway, i.e., produce/consume single stream.
557+
*/
558+
static int copier_copy(struct comp_dev *dev)
559+
{
560+
struct copier_data *cd = comp_get_drvdata(dev);
561+
562+
comp_dbg(dev, "copier_copy()");
563+
564+
switch (dev->ipc_config.type) {
565+
case SOF_COMP_HOST:
566+
if (!cd->ipc_gtw)
567+
return do_endpoint_copy(dev);
568+
break;
569+
case SOF_COMP_DAI:
570+
if (cd->endpoint_num == 1)
571+
return dai_common_copy(cd->dd[0], dev, cd->converter);
572+
break;
573+
default:
574+
break;
575+
}
576+
/* handle multi-endpoint and module copy */
577+
return do_multi_endpoint_module_copy(cd, dev);
578+
}
579+
574580
/* configure the DMA params */
575581
static int copier_params(struct comp_dev *dev, struct sof_ipc_stream_params *params)
576582
{

0 commit comments

Comments
 (0)