Skip to content

Commit 956585e

Browse files
authored
Merge pull request #136 from tlauda/topic/host_pointer_init
host: do not initialize pointer every trigger start
2 parents f4ab702 + c12a84e commit 956585e

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

src/audio/host.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct host_data {
8383
uint32_t next_inc;
8484
uint32_t period_bytes;
8585
uint32_t period_count;
86+
uint32_t pointer_init;
8687

8788
/* stream info */
8889
struct sof_ipc_stream_posn posn; /* TODO: update this */
@@ -425,6 +426,22 @@ static int create_local_elems(struct comp_dev *dev)
425426
return -ENOMEM;
426427
}
427428

429+
/*
430+
* Host DMA will copy the first period once it is started, automatically.
431+
* Here update the pointers to reflect the real case.
432+
*/
433+
static void host_pointer_init(struct comp_dev *dev)
434+
{
435+
struct host_data *hd = comp_get_drvdata(dev);
436+
437+
/* not required for capture streams */
438+
if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK)
439+
comp_update_buffer_produce(hd->dma_buffer,
440+
hd->period_bytes);
441+
442+
hd->pointer_init = 1;
443+
}
444+
428445
/* used to pass standard and bespoke commands (with data) to component */
429446
static int host_trigger(struct comp_dev *dev, int cmd)
430447
{
@@ -452,15 +469,8 @@ static int host_trigger(struct comp_dev *dev, int cmd)
452469
goto out;
453470
}
454471

455-
/*
456-
* host dma will copy the first period once it is started,
457-
* automatically.
458-
* Here update the pointers to reflect the real case.
459-
*/
460-
if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK) {
461-
comp_update_buffer_produce(hd->dma_buffer,
462-
hd->period_bytes);
463-
}
472+
if (!hd->pointer_init)
473+
host_pointer_init(dev);
464474
break;
465475
default:
466476
break;
@@ -540,6 +550,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
540550

541551
/* init posn data. TODO: other fields */
542552
hd->posn.comp_id = comp->id;
553+
hd->pointer_init = 0;
543554
dev->state = COMP_STATE_READY;
544555
dev->is_dma_connected = 1;
545556
return dev;
@@ -712,6 +723,7 @@ static int host_prepare(struct comp_dev *dev)
712723
*hd->host_pos = 0;
713724
hd->report_pos = 0;
714725
hd->split_remaining = 0;
726+
hd->pointer_init = 0;
715727
dev->position = 0;
716728

717729
return 0;
@@ -815,6 +827,7 @@ static int host_reset(struct comp_dev *dev)
815827
#endif
816828

817829
host_pointer_reset(dev);
830+
hd->pointer_init = 0;
818831
hd->host_pos = NULL;
819832
hd->source = NULL;
820833
hd->sink = NULL;

0 commit comments

Comments
 (0)