diff options
author | Akshu Agrawal <akshu.agrawal@amd.com> | 2018-08-06 03:27:16 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-08-06 12:02:09 -0400 |
commit | c21c834adb5bc81e7081aa93ac50619c6d060506 (patch) | |
tree | 0773be732393d4125a7395b09ecb2c571da831e8 | |
parent | 662fb3efe7ee835f0eeba6bc63b81e82a97fc312 (diff) |
ASoC: AMD: Set delay value for the capture case
ACP->SYSMEM DMA happens at every I2S->SYSMEM period
completion. Thus, there is delay of x frames till
I2S->SYSMEM reaches a period length. This delay is
communicated to user space.
Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/amd/acp-pcm-dma.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 32f27c5e4d93..e359938e3d7e 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c | |||
@@ -922,6 +922,10 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, | |||
922 | rtd->destination = FROM_BLUETOOTH; | 922 | rtd->destination = FROM_BLUETOOTH; |
923 | rtd->dma_dscr_idx_1 = CAPTURE_START_DMA_DESCR_CH10; | 923 | rtd->dma_dscr_idx_1 = CAPTURE_START_DMA_DESCR_CH10; |
924 | rtd->dma_dscr_idx_2 = CAPTURE_START_DMA_DESCR_CH11; | 924 | rtd->dma_dscr_idx_2 = CAPTURE_START_DMA_DESCR_CH11; |
925 | rtd->byte_cnt_high_reg_offset = | ||
926 | mmACP_I2S_BT_RECEIVE_BYTE_CNT_HIGH; | ||
927 | rtd->byte_cnt_low_reg_offset = | ||
928 | mmACP_I2S_BT_RECEIVE_BYTE_CNT_LOW; | ||
925 | rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_11; | 929 | rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_11; |
926 | adata->capture_i2sbt_stream = substream; | 930 | adata->capture_i2sbt_stream = substream; |
927 | break; | 931 | break; |
@@ -942,6 +946,10 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, | |||
942 | rtd->destination = FROM_ACP_I2S_1; | 946 | rtd->destination = FROM_ACP_I2S_1; |
943 | rtd->dma_dscr_idx_1 = CAPTURE_START_DMA_DESCR_CH14; | 947 | rtd->dma_dscr_idx_1 = CAPTURE_START_DMA_DESCR_CH14; |
944 | rtd->dma_dscr_idx_2 = CAPTURE_START_DMA_DESCR_CH15; | 948 | rtd->dma_dscr_idx_2 = CAPTURE_START_DMA_DESCR_CH15; |
949 | rtd->byte_cnt_high_reg_offset = | ||
950 | mmACP_I2S_RECEIVED_BYTE_CNT_HIGH; | ||
951 | rtd->byte_cnt_low_reg_offset = | ||
952 | mmACP_I2S_RECEIVED_BYTE_CNT_LOW; | ||
945 | rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_15; | 953 | rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_15; |
946 | adata->capture_i2ssp_stream = substream; | 954 | adata->capture_i2ssp_stream = substream; |
947 | } | 955 | } |
@@ -997,7 +1005,7 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) | |||
997 | u32 pos = 0; | 1005 | u32 pos = 0; |
998 | u64 bytescount = 0; | 1006 | u64 bytescount = 0; |
999 | u16 dscr; | 1007 | u16 dscr; |
1000 | u32 period_bytes; | 1008 | u32 period_bytes, delay; |
1001 | 1009 | ||
1002 | struct snd_pcm_runtime *runtime = substream->runtime; | 1010 | struct snd_pcm_runtime *runtime = substream->runtime; |
1003 | struct audio_substream_data *rtd = runtime->private_data; | 1011 | struct audio_substream_data *rtd = runtime->private_data; |
@@ -1012,6 +1020,11 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) | |||
1012 | pos = period_bytes; | 1020 | pos = period_bytes; |
1013 | else | 1021 | else |
1014 | pos = 0; | 1022 | pos = 0; |
1023 | bytescount = acp_get_byte_count(rtd); | ||
1024 | if (bytescount > rtd->bytescount) | ||
1025 | bytescount -= rtd->bytescount; | ||
1026 | delay = do_div(bytescount, period_bytes); | ||
1027 | runtime->delay = bytes_to_frames(runtime, delay); | ||
1015 | } else { | 1028 | } else { |
1016 | buffersize = frames_to_bytes(runtime, runtime->buffer_size); | 1029 | buffersize = frames_to_bytes(runtime, runtime->buffer_size); |
1017 | bytescount = acp_get_byte_count(rtd); | 1030 | bytescount = acp_get_byte_count(rtd); |