Skip to content

Commit

Permalink
Merge pull request #136 from tlauda/topic/host_pointer_init
Browse files Browse the repository at this point in the history
host: do not initialize pointer every trigger start
  • Loading branch information
lgirdwood committed Jul 20, 2018
2 parents f4ab702 + c12a84e commit 956585e
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/audio/host.c
Expand Up @@ -83,6 +83,7 @@ struct host_data {
uint32_t next_inc;
uint32_t period_bytes;
uint32_t period_count;
uint32_t pointer_init;

/* stream info */
struct sof_ipc_stream_posn posn; /* TODO: update this */
Expand Down Expand Up @@ -425,6 +426,22 @@ static int create_local_elems(struct comp_dev *dev)
return -ENOMEM;
}

/*
* Host DMA will copy the first period once it is started, automatically.
* Here update the pointers to reflect the real case.
*/
static void host_pointer_init(struct comp_dev *dev)
{
struct host_data *hd = comp_get_drvdata(dev);

/* not required for capture streams */
if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK)
comp_update_buffer_produce(hd->dma_buffer,
hd->period_bytes);

hd->pointer_init = 1;
}

/* used to pass standard and bespoke commands (with data) to component */
static int host_trigger(struct comp_dev *dev, int cmd)
{
Expand Down Expand Up @@ -452,15 +469,8 @@ static int host_trigger(struct comp_dev *dev, int cmd)
goto out;
}

/*
* host dma will copy the first period once it is started,
* automatically.
* Here update the pointers to reflect the real case.
*/
if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK) {
comp_update_buffer_produce(hd->dma_buffer,
hd->period_bytes);
}
if (!hd->pointer_init)
host_pointer_init(dev);
break;
default:
break;
Expand Down Expand Up @@ -540,6 +550,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)

/* init posn data. TODO: other fields */
hd->posn.comp_id = comp->id;
hd->pointer_init = 0;
dev->state = COMP_STATE_READY;
dev->is_dma_connected = 1;
return dev;
Expand Down Expand Up @@ -712,6 +723,7 @@ static int host_prepare(struct comp_dev *dev)
*hd->host_pos = 0;
hd->report_pos = 0;
hd->split_remaining = 0;
hd->pointer_init = 0;
dev->position = 0;

return 0;
Expand Down Expand Up @@ -815,6 +827,7 @@ static int host_reset(struct comp_dev *dev)
#endif

host_pointer_reset(dev);
hd->pointer_init = 0;
hd->host_pos = NULL;
hd->source = NULL;
hd->sink = NULL;
Expand Down

0 comments on commit 956585e

Please sign in to comment.