[Sound-open-firmware] [PATCH 1/2] dai: add stream_format to dai_data for codec stream
Adding stream_format to indicate the stream format that the dai buffer is using, which will be used for volume copy functions mapping.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com --- src/audio/dai.c | 9 +++++++++ src/platform/baytrail/include/platform/platform.h | 3 +++ 2 files changed, 12 insertions(+)
diff --git a/src/audio/dai.c b/src/audio/dai.c index 7bbde08..64e4761 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -59,6 +59,7 @@ struct dai_data { struct dma_sg_config config;
int direction; + uint32_t stream_format; struct dai *ssp; struct dma *dma;
@@ -162,6 +163,8 @@ static struct comp_dev *dai_new_ssp(uint32_t type, uint32_t index, if (dd->chan < 0) goto error;
+ dd->stream_format = PLATFORM_SSP_STREAM_FORMAT; + /* set up callback */ //if (dd->ssp->plat_data.flags & DAI_FLAGS_IRQ_CB) dma_set_cb(dd->dma, dd->chan, DMA_IRQ_TYPE_LLIST, dai_dma_cb, dev); @@ -217,6 +220,9 @@ static int dai_playback_params(struct comp_dev *dev, dma_period_desc = &dma_buffer->desc.sink_period; dma_buffer->params = *params;
+ /* set it to dai stream format, for volume func correct mapping */ + dma_buffer->params.pcm.format = dd->stream_format; + if (list_is_empty(&config->elem_list)) { /* set up cyclic list of DMA elems */ for (i = 0; i < dma_period_desc->number; i++) { @@ -275,6 +281,9 @@ static int dai_capture_params(struct comp_dev *dev, dma_period_desc = &dma_buffer->desc.source_period; dma_buffer->params = *params;
+ /* set it to dai stream format, for volume func correct mapping */ + dma_buffer->params.pcm.format = dd->stream_format; + if (list_is_empty(&config->elem_list)) { /* set up cyclic list of DMA elems */ for (i = 0; i < dma_period_desc->number; i++) { diff --git a/src/platform/baytrail/include/platform/platform.h b/src/platform/baytrail/include/platform/platform.h index b1bfbf2..f86019d 100644 --- a/src/platform/baytrail/include/platform/platform.h +++ b/src/platform/baytrail/include/platform/platform.h @@ -38,6 +38,9 @@ /* default static pipeline SSP port - not used for dynamic pipes */ #define PLATFORM_SSP_PORT 2
+/* default SSP stream format - need aligned with codec setting*/ +#define PLATFORM_SSP_STREAM_FORMAT STREAM_FORMAT_S24_4LE + /* IPC Interrupt */ #define PLATFORM_IPC_INTERUPT IRQ_NUM_EXT_IA
When the host buffer is not 1ms aligned and splitting happens, the increment is not period size, this wrong pointer will make pcm data missed/clipped and sound noisy.
Changing to use the actual size last dma copy consumed, local_elem->size, to fix the issue.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com --- src/audio/host.c | 120 +++++++++++++++++++++++++++---------------------------- 1 file changed, 60 insertions(+), 60 deletions(-)
diff --git a/src/audio/host.c b/src/audio/host.c index f339bc2..fe43cf8 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -117,6 +117,37 @@ static void host_dma_cb_playback(struct comp_dev *dev,
trace_host("Cpp");
+ /* update buffer positions */ + dma_buffer = hd->dma_buffer; + + dma_buffer->w_ptr += local_elem->size; + + if (dma_buffer->w_ptr >= dma_buffer->end_addr) + dma_buffer->w_ptr = dma_buffer->addr; + +#if 0 + trace_value((uint32_t)(hd->dma_buffer->w_ptr - hd->dma_buffer->addr)); +#endif + + /* recalc available buffer space */ + comp_update_buffer(hd->dma_buffer); + + /* new local period, update host buffer position blks */ + hd->host_pos_blks += local_elem->size; + + /* buffer overlap ? */ + if (hd->host_pos_blks >= hd->host_size) + hd->host_pos_blks = 0; + if (hd->host_pos) + *hd->host_pos = hd->host_pos_blks; + + /* send IPC message to driver if needed */ + hd->host_period_pos += local_elem->size; + if (hd->host_period_pos >= hd->host_period_bytes) { + hd->host_period_pos = 0; + ipc_stream_send_notification(dev, &hd->cp); + } + /* are we dealing with a split transfer */ if (hd->split_remaining) {
@@ -161,36 +192,6 @@ static void host_dma_cb_playback(struct comp_dev *dev, } }
- /* update buffer positions */ - dma_buffer = hd->dma_buffer; - - dma_buffer->w_ptr += hd->period->size; - - if (dma_buffer->w_ptr >= dma_buffer->end_addr) - dma_buffer->w_ptr = dma_buffer->addr; -#if 0 - trace_value((uint32_t)(hd->dma_buffer->w_ptr - hd->dma_buffer->addr)); -#endif - - /* new local period, update host buffer position blks */ - hd->host_pos_blks += hd->period->size; - - /* buffer overlap ? */ - if (hd->host_pos_blks >= hd->host_size) - hd->host_pos_blks = 0; - if (hd->host_pos) - *hd->host_pos = hd->host_pos_blks; - - /* recalc available buffer space */ - comp_update_buffer(hd->dma_buffer); - - /* send IPC message to driver if needed */ - hd->host_period_pos += hd->period->size; - if (hd->host_period_pos >= hd->host_period_bytes) { - hd->host_period_pos = 0; - ipc_stream_send_notification(dev, &hd->cp); - } - /* let any waiters know we have completed */ wait_completed(&hd->complete); } @@ -215,6 +216,35 @@ static void host_dma_cb_capture(struct comp_dev *dev,
trace_host("Cpc");
+ /* update buffer positions */ + dma_buffer = hd->dma_buffer; + hd->dma_buffer->r_ptr += local_elem->size; + + if (dma_buffer->r_ptr >= dma_buffer->end_addr) + dma_buffer->r_ptr = dma_buffer->addr; +#if 0 + trace_value((uint32_t)(hd->dma_buffer->r_ptr - hd->dma_buffer->addr)); +#endif + + /* new local period, update host buffer position blks */ + hd->host_pos_blks += local_elem->size; + + /* buffer overlap ? */ + if (hd->host_pos_blks >= hd->host_size) + hd->host_pos_blks = 0; + if (hd->host_pos) + *hd->host_pos = hd->host_pos_blks; + + /* recalc available buffer space */ + comp_update_buffer(hd->dma_buffer); + + /* send IPC message to driver if needed */ + hd->host_period_pos += local_elem->size; + if (hd->host_period_pos >= hd->host_period_bytes) { + hd->host_period_pos = 0; + ipc_stream_send_notification(dev, &hd->cp); + } + /* are we dealing with a split transfer */ if (hd->split_remaining) {
@@ -259,36 +289,6 @@ static void host_dma_cb_capture(struct comp_dev *dev, } }
- /* update buffer positions */ - dma_buffer = hd->dma_buffer; - hd->dma_buffer->r_ptr += hd->period->size; - - if (dma_buffer->r_ptr >= dma_buffer->end_addr) - dma_buffer->r_ptr = dma_buffer->addr; -#if 0 - trace_value((uint32_t)(hd->dma_buffer->r_ptr - hd->dma_buffer->addr)); -#endif - - - /* new local period, update host buffer position blks */ - hd->host_pos_blks += hd->period->size; - - /* buffer overlap ? */ - if (hd->host_pos_blks >= hd->host_size) - hd->host_pos_blks = 0; - if (hd->host_pos) - *hd->host_pos = hd->host_pos_blks; - - /* recalc available buffer space */ - comp_update_buffer(hd->dma_buffer); - - /* send IPC message to driver if needed */ - hd->host_period_pos += hd->period->size; - if (hd->host_period_pos >= hd->host_period_bytes) { - hd->host_period_pos = 0; - ipc_stream_send_notification(dev, &hd->cp); - } - /* let any waiters know we have completed */ wait_completed(&hd->complete); }
On Thu, 2016-12-29 at 17:29 +0800, Keyon Jie wrote:
Adding stream_format to indicate the stream format that the dai buffer is using, which will be used for volume copy functions mapping.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com
Both applied.
Liam
participants (2)
-
Keyon Jie
-
Liam Girdwood