Skip to content

Commit e424b87

Browse files
ranj063lgirdwood
authored andcommitted
audio: copier: Split up module copier and multi-endpoint copies
In preparation for converting the copier to use the module interface, split up the multi-endpoint DAI copy and the module copier copy cases. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
1 parent 1a96df1 commit e424b87

1 file changed

Lines changed: 46 additions & 31 deletions

File tree

src/audio/copier/copier.c

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,24 @@ static int copier_copy_to_sinks(struct copier_data *cd, struct comp_dev *dev,
564564
return ret;
565565
}
566566

567-
static int do_multi_endpoint_module_copy(struct copier_data *cd, struct comp_dev *dev)
567+
static int copier_module_copy(struct copier_data *cd, struct comp_dev *dev)
568+
{
569+
struct comp_buffer __sparse_cache *src_c;
570+
struct comp_copy_limits processed_data;
571+
struct comp_buffer *src;
572+
int ret;
573+
574+
src = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
575+
src_c = buffer_acquire(src);
576+
577+
ret = copier_copy_to_sinks(cd, dev, src_c, &processed_data);
578+
579+
buffer_release(src_c);
580+
581+
return ret;
582+
}
583+
584+
static int copier_multi_endpoint_dai_copy(struct copier_data *cd, struct comp_dev *dev)
568585
{
569586
struct comp_buffer __sparse_cache *src_c, *sink_c;
570587
struct comp_copy_limits processed_data;
@@ -573,44 +590,38 @@ static int do_multi_endpoint_module_copy(struct copier_data *cd, struct comp_dev
573590

574591
processed_data.source_bytes = 0;
575592

576-
if (cd->endpoint_num && !cd->bsource_buffer) {
593+
if (!cd->bsource_buffer) {
577594
/* gateway(s) as input */
578595
ret = do_endpoint_copy(dev);
579596
if (ret < 0)
580597
return ret;
581598

582599
src_c = buffer_acquire(get_endpoint_buffer(cd));
583-
} else {
584-
/* component as input */
585-
if (list_is_empty(&dev->bsource_list)) {
586-
comp_err(dev, "No source buffer bound");
587-
return -EINVAL;
588-
}
600+
ret = copier_copy_to_sinks(cd, dev, src_c, &processed_data);
601+
buffer_release(src_c);
589602

590-
src = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
591-
src_c = buffer_acquire(src);
603+
return ret;
604+
}
592605

593-
if (cd->endpoint_num) {
594-
/* gateway(s) on output */
595-
sink_c = buffer_acquire(get_endpoint_buffer(cd));
596-
ret = do_conversion_copy(dev, cd, src_c, sink_c, &processed_data);
597-
buffer_release(sink_c);
606+
/* component as input */
607+
if (list_is_empty(&dev->bsource_list)) {
608+
comp_err(dev, "No source buffer bound");
609+
return -EINVAL;
610+
}
598611

599-
if (ret < 0) {
600-
buffer_release(src_c);
601-
return ret;
602-
}
612+
src = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
613+
src_c = buffer_acquire(src);
603614

604-
ret = do_endpoint_copy(dev);
605-
if (ret < 0) {
606-
buffer_release(src_c);
607-
return ret;
608-
}
609-
}
610-
}
615+
/* gateway(s) on output */
616+
sink_c = buffer_acquire(get_endpoint_buffer(cd));
617+
ret = do_conversion_copy(dev, cd, src_c, sink_c, &processed_data);
618+
buffer_release(sink_c);
611619

612-
ret = copier_copy_to_sinks(cd, dev, src_c, &processed_data);
620+
if (ret < 0)
621+
goto err;
613622

623+
ret = do_endpoint_copy(dev);
624+
err:
614625
buffer_release(src_c);
615626

616627
return ret;
@@ -638,16 +649,20 @@ static int copier_copy(struct comp_dev *dev)
638649
case SOF_COMP_HOST:
639650
if (!cd->ipc_gtw)
640651
return do_endpoint_copy(dev);
641-
break;
652+
653+
/* do nothing in the gateway copier case */
654+
return 0;
642655
case SOF_COMP_DAI:
643656
if (cd->endpoint_num == 1)
644657
return dai_common_copy(cd->dd[0], dev, cd->converter);
645-
break;
658+
659+
return copier_multi_endpoint_dai_copy(cd, dev);
646660
default:
647661
break;
648662
}
649-
/* handle multi-endpoint and module copy */
650-
return do_multi_endpoint_module_copy(cd, dev);
663+
664+
/* module copier case */
665+
return copier_module_copy(cd, dev);
651666
}
652667

653668
static int copier_mod_params(struct processing_module *mod)

0 commit comments

Comments
 (0)