From 8a4c586f7baee37937b745cff387d679c59f716d Mon Sep 17 00:00:00 2001 From: Manish Dewangan Date: Tue, 20 Dec 2016 17:02:42 +0530 Subject: ASoC: msm: qdsp6v2: Get path delay support in compress path Compress driver changes to query DSP path delay. CRs-Fixed: 1112258 Change-Id: I68d40daa0fa59c9a39d83ffc8517b0852a57ae05 Signed-off-by: Manish Dewangan --- include/uapi/sound/compress_offload.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/uapi/sound') diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index e04ccf0b6e8b..ef7ab49583da 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -138,14 +138,18 @@ struct snd_compr_audio_info { * end of the track * @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the * beginning of the track + * @SNDRV_COMPRESS_PATH_DELAY: dsp path delay in microseconds */ enum sndrv_compress_encoder { SNDRV_COMPRESS_ENCODER_PADDING = 1, SNDRV_COMPRESS_ENCODER_DELAY = 2, SNDRV_COMPRESS_MIN_BLK_SIZE = 3, SNDRV_COMPRESS_MAX_BLK_SIZE = 4, + SNDRV_COMPRESS_PATH_DELAY = 5, }; +#define SNDRV_COMPRESS_PATH_DELAY SNDRV_COMPRESS_PATH_DELAY + /** * struct snd_compr_metadata - compressed stream metadata * @key: key id -- cgit v1.2.3 From df38388af0e15a7e47192518f74c7a434d46b231 Mon Sep 17 00:00:00 2001 From: Manish Dewangan Date: Tue, 24 Jan 2017 19:14:58 +0530 Subject: ASoC: msm: qdsp6v2: Support to configure render mode Update compress driver to support configuration of render mode. CRs-Fixed: 1112258 Change-Id: Iac8c3a3d2df6180c9982c352b1c00ce7a624c167 Signed-off-by: Manish Dewangan --- include/uapi/sound/compress_offload.h | 5 ++++ sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c | 42 +++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) (limited to 'include/uapi/sound') diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index ef7ab49583da..b52056ecb155 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -132,6 +132,8 @@ struct snd_compr_audio_info { uint32_t reserved[15]; } __attribute__((packed, aligned(4))); +#define SNDRV_COMPRESS_RENDER_MODE_AUDIO_MASTER 0 +#define SNDRV_COMPRESS_RENDER_MODE_STC_MASTER 1 /** * enum sndrv_compress_encoder * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the @@ -139,6 +141,7 @@ struct snd_compr_audio_info { * @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the * beginning of the track * @SNDRV_COMPRESS_PATH_DELAY: dsp path delay in microseconds + * @SNDRV_COMPRESS_RENDER_MODE: dsp render mode (audio master or stc) */ enum sndrv_compress_encoder { SNDRV_COMPRESS_ENCODER_PADDING = 1, @@ -146,9 +149,11 @@ enum sndrv_compress_encoder { SNDRV_COMPRESS_MIN_BLK_SIZE = 3, SNDRV_COMPRESS_MAX_BLK_SIZE = 4, SNDRV_COMPRESS_PATH_DELAY = 5, + SNDRV_COMPRESS_RENDER_MODE = 6, }; #define SNDRV_COMPRESS_PATH_DELAY SNDRV_COMPRESS_PATH_DELAY +#define SNDRV_COMPRESS_RENDER_MODE SNDRV_COMPRESS_RENDER_MODE /** * struct snd_compr_metadata - compressed stream metadata diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c index 125254ac4def..0f9f2889200e 100644 --- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c @@ -160,6 +160,8 @@ struct msm_compr_audio { uint32_t stream_available; uint32_t next_stream; + uint32_t run_mode; + uint64_t marker_timestamp; struct msm_compr_gapless_state gapless_state; @@ -215,6 +217,34 @@ static int msm_compr_send_dec_params(struct snd_compr_stream *cstream, struct msm_compr_dec_params *dec_params, int stream_id); +static int msm_compr_set_render_mode(struct msm_compr_audio *prtd, + uint32_t render_mode) { + int ret = -EINVAL; + struct audio_client *ac = prtd->audio_client; + + pr_debug("%s, got render mode %u\n", __func__, render_mode); + + if (render_mode == SNDRV_COMPRESS_RENDER_MODE_AUDIO_MASTER) { + render_mode = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_DEFAULT; + } else if (render_mode == SNDRV_COMPRESS_RENDER_MODE_STC_MASTER) { + render_mode = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_LOCAL_STC; + prtd->run_mode = ASM_SESSION_CMD_RUN_STARTIME_RUN_WITH_DELAY; + } else { + pr_err("%s, Invalid render mode %u\n", __func__, + render_mode); + ret = -EINVAL; + goto exit; + } + + ret = q6asm_send_mtmx_strtr_render_mode(ac, render_mode); + if (ret) { + pr_err("%s, Render mode can't be set error %d\n", __func__, + ret); + } +exit: + return ret; +} + static int msm_compr_set_volume(struct snd_compr_stream *cstream, uint32_t volume_l, uint32_t volume_r) { @@ -1963,7 +1993,7 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd) msm_compr_read_buffer(prtd); } /* issue RUN command for the stream */ - q6asm_run_nowait(prtd->audio_client, 0, 0, 0); + q6asm_run_nowait(prtd->audio_client, prtd->run_mode, 0, 0); break; case SNDRV_PCM_TRIGGER_STOP: spin_lock_irqsave(&prtd->lock, flags); @@ -2047,7 +2077,8 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd) prtd->gapless_state.gapless_transition); if (!prtd->gapless_state.gapless_transition) { atomic_set(&prtd->start, 1); - q6asm_run_nowait(prtd->audio_client, 0, 0, 0); + q6asm_run_nowait(prtd->audio_client, prtd->run_mode, + 0, 0); } break; case SND_COMPR_TRIGGER_PARTIAL_DRAIN: @@ -2717,11 +2748,14 @@ static int msm_compr_set_metadata(struct snd_compr_stream *cstream, return -EINVAL; } - if (prtd->compr_passthr != LEGACY_PCM) { + if (((metadata->key == SNDRV_COMPRESS_ENCODER_PADDING) || + (metadata->key == SNDRV_COMPRESS_ENCODER_DELAY)) && + (prtd->compr_passthr != LEGACY_PCM)) { pr_debug("%s: No trailing silence for compress_type[%d]\n", __func__, prtd->compr_passthr); return 0; } + ac = prtd->audio_client; if (metadata->key == SNDRV_COMPRESS_ENCODER_PADDING) { pr_debug("%s, got encoder padding %u", __func__, metadata->value[0]); @@ -2729,6 +2763,8 @@ static int msm_compr_set_metadata(struct snd_compr_stream *cstream, } else if (metadata->key == SNDRV_COMPRESS_ENCODER_DELAY) { pr_debug("%s, got encoder delay %u", __func__, metadata->value[0]); prtd->gapless_state.initial_samples_drop = metadata->value[0]; + } else if (metadata->key == SNDRV_COMPRESS_RENDER_MODE) { + return msm_compr_set_render_mode(prtd, metadata->value[0]); } return 0; -- cgit v1.2.3 From bbbea003e7008b8497a57f5b0f446e11177c48c3 Mon Sep 17 00:00:00 2001 From: Manish Dewangan Date: Thu, 9 Feb 2017 11:08:27 +0530 Subject: ASoC: msm: qdsp6v2: Support to configure clk recovery mode Update compress driver to support configuration of DSP clock recovery mode. Supported modes are auto and none. In auto mode DSP does clock recovery based on avtimer and device drift otherwise it ignores drift. CRs-Fixed: 1112258 Change-Id: I4b6b37c08be422e38b7f0bf625712d5e2b0dc0f3 Signed-off-by: Manish Dewangan --- include/uapi/sound/compress_offload.h | 7 +++++++ sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'include/uapi/sound') diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index b52056ecb155..efe4ee86023e 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -134,6 +134,10 @@ struct snd_compr_audio_info { #define SNDRV_COMPRESS_RENDER_MODE_AUDIO_MASTER 0 #define SNDRV_COMPRESS_RENDER_MODE_STC_MASTER 1 + +#define SNDRV_COMPRESS_CLK_REC_MODE_NONE 0 +#define SNDRV_COMPRESS_CLK_REC_MODE_AUTO 1 + /** * enum sndrv_compress_encoder * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the @@ -142,6 +146,7 @@ struct snd_compr_audio_info { * beginning of the track * @SNDRV_COMPRESS_PATH_DELAY: dsp path delay in microseconds * @SNDRV_COMPRESS_RENDER_MODE: dsp render mode (audio master or stc) + * @SNDRV_COMPRESS_CLK_REC_MODE: clock recovery mode ( none or auto) */ enum sndrv_compress_encoder { SNDRV_COMPRESS_ENCODER_PADDING = 1, @@ -150,10 +155,12 @@ enum sndrv_compress_encoder { SNDRV_COMPRESS_MAX_BLK_SIZE = 4, SNDRV_COMPRESS_PATH_DELAY = 5, SNDRV_COMPRESS_RENDER_MODE = 6, + SNDRV_COMPRESS_CLK_REC_MODE = 7, }; #define SNDRV_COMPRESS_PATH_DELAY SNDRV_COMPRESS_PATH_DELAY #define SNDRV_COMPRESS_RENDER_MODE SNDRV_COMPRESS_RENDER_MODE +#define SNDRV_COMPRESS_CLK_REC_MODE SNDRV_COMPRESS_CLK_REC_MODE /** * struct snd_compr_metadata - compressed stream metadata diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c index 0f9f2889200e..73cc9b546db6 100644 --- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c @@ -245,6 +245,33 @@ exit: return ret; } +static int msm_compr_set_clk_rec_mode(struct audio_client *ac, + uint32_t clk_rec_mode) { + int ret = -EINVAL; + + pr_debug("%s, got clk rec mode %u\n", __func__, clk_rec_mode); + + if (clk_rec_mode == SNDRV_COMPRESS_CLK_REC_MODE_NONE) { + clk_rec_mode = ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_NONE; + } else if (clk_rec_mode == SNDRV_COMPRESS_CLK_REC_MODE_AUTO) { + clk_rec_mode = ASM_SESSION_MTMX_STRTR_PARAM_CLK_REC_AUTO; + } else { + pr_err("%s, Invalid clk rec_mode mode %u\n", __func__, + clk_rec_mode); + ret = -EINVAL; + goto exit; + } + + ret = q6asm_send_mtmx_strtr_clk_rec_mode(ac, clk_rec_mode); + if (ret) { + pr_err("%s, clk rec mode can't be set, error %d\n", __func__, + ret); + } + +exit: + return ret; +} + static int msm_compr_set_volume(struct snd_compr_stream *cstream, uint32_t volume_l, uint32_t volume_r) { @@ -2765,6 +2792,8 @@ static int msm_compr_set_metadata(struct snd_compr_stream *cstream, prtd->gapless_state.initial_samples_drop = metadata->value[0]; } else if (metadata->key == SNDRV_COMPRESS_RENDER_MODE) { return msm_compr_set_render_mode(prtd, metadata->value[0]); + } else if (metadata->key == SNDRV_COMPRESS_CLK_REC_MODE) { + return msm_compr_set_clk_rec_mode(ac, metadata->value[0]); } return 0; -- cgit v1.2.3 From 479baf1cf79281be0b59c5b672707bfed8ac7be8 Mon Sep 17 00:00:00 2001 From: Manish Dewangan Date: Mon, 6 Feb 2017 11:57:10 +0530 Subject: ASoC: msm: qdsp6v2: Support to configure render window Update compress driver to support configuration of DSP render window. Render window is used by DSP to take rendering decision. i.e whether input frame should be rendered, dropped or repeated. CRs-Fixed: 1112258 Change-Id: Ib1b9100ab87878d2e2da93e2b86ca68fb9dd97a9 Signed-off-by: Manish Dewangan --- include/uapi/sound/compress_offload.h | 3 ++ sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c | 45 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'include/uapi/sound') diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index efe4ee86023e..f3f5d5634245 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -147,6 +147,7 @@ struct snd_compr_audio_info { * @SNDRV_COMPRESS_PATH_DELAY: dsp path delay in microseconds * @SNDRV_COMPRESS_RENDER_MODE: dsp render mode (audio master or stc) * @SNDRV_COMPRESS_CLK_REC_MODE: clock recovery mode ( none or auto) + * @SNDRV_COMPRESS_RENDER_WINDOW: render window */ enum sndrv_compress_encoder { SNDRV_COMPRESS_ENCODER_PADDING = 1, @@ -156,11 +157,13 @@ enum sndrv_compress_encoder { SNDRV_COMPRESS_PATH_DELAY = 5, SNDRV_COMPRESS_RENDER_MODE = 6, SNDRV_COMPRESS_CLK_REC_MODE = 7, + SNDRV_COMPRESS_RENDER_WINDOW = 8, }; #define SNDRV_COMPRESS_PATH_DELAY SNDRV_COMPRESS_PATH_DELAY #define SNDRV_COMPRESS_RENDER_MODE SNDRV_COMPRESS_RENDER_MODE #define SNDRV_COMPRESS_CLK_REC_MODE SNDRV_COMPRESS_CLK_REC_MODE +#define SNDRV_COMPRESS_RENDER_WINDOW SNDRV_COMPRESS_RENDER_WINDOW /** * struct snd_compr_metadata - compressed stream metadata diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c index 73cc9b546db6..0d1dc4133fc8 100644 --- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c @@ -272,6 +272,44 @@ exit: return ret; } +static int msm_compr_set_render_window(struct audio_client *ac, + uint32_t ws_lsw, uint32_t ws_msw, + uint32_t we_lsw, uint32_t we_msw) +{ + int ret = -EINVAL; + struct asm_session_mtmx_strtr_param_window_v2_t asm_mtmx_strtr_window; + uint32_t param_id; + + pr_debug("%s, ws_lsw 0x%x ws_msw 0x%x we_lsw 0x%x we_ms 0x%x\n", + __func__, ws_lsw, ws_msw, we_lsw, we_msw); + + memset(&asm_mtmx_strtr_window, 0, + sizeof(struct asm_session_mtmx_strtr_param_window_v2_t)); + asm_mtmx_strtr_window.window_lsw = ws_lsw; + asm_mtmx_strtr_window.window_msw = ws_msw; + param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_START_V2; + ret = q6asm_send_mtmx_strtr_window(ac, &asm_mtmx_strtr_window, + param_id); + if (ret) { + pr_err("%s, start window can't be set error %d\n", __func__, + ret); + goto exit; + } + + asm_mtmx_strtr_window.window_lsw = we_lsw; + asm_mtmx_strtr_window.window_msw = we_msw; + param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_END_V2; + ret = q6asm_send_mtmx_strtr_window(ac, &asm_mtmx_strtr_window, + param_id); + if (ret) { + pr_err("%s, end window can't be set error %d\n", __func__, + ret); + } + +exit: + return ret; +} + static int msm_compr_set_volume(struct snd_compr_stream *cstream, uint32_t volume_l, uint32_t volume_r) { @@ -2794,6 +2832,13 @@ static int msm_compr_set_metadata(struct snd_compr_stream *cstream, return msm_compr_set_render_mode(prtd, metadata->value[0]); } else if (metadata->key == SNDRV_COMPRESS_CLK_REC_MODE) { return msm_compr_set_clk_rec_mode(ac, metadata->value[0]); + } else if (metadata->key == SNDRV_COMPRESS_RENDER_WINDOW) { + return msm_compr_set_render_window( + ac, + metadata->value[0], + metadata->value[1], + metadata->value[2], + metadata->value[3]); } return 0; -- cgit v1.2.3 From 9da92fae0365f8962ef4ea48051edb4e6f16c2df Mon Sep 17 00:00:00 2001 From: Manish Dewangan Date: Wed, 15 Feb 2017 10:27:32 +0530 Subject: ASoC: msm: qdsp6v2: Support to set session start delay Update compress driver to support session start delay. Userspace can use this param to delay start of playback session. CRs-Fixed: 1112258 Change-Id: I0b31a4bae12f9f2b1f8a3e003909741529458772 Signed-off-by: Manish Dewangan --- include/uapi/sound/compress_offload.h | 3 +++ sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'include/uapi/sound') diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index f3f5d5634245..98b422ac7dcb 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -148,6 +148,7 @@ struct snd_compr_audio_info { * @SNDRV_COMPRESS_RENDER_MODE: dsp render mode (audio master or stc) * @SNDRV_COMPRESS_CLK_REC_MODE: clock recovery mode ( none or auto) * @SNDRV_COMPRESS_RENDER_WINDOW: render window + * @SNDRV_COMPRESS_START_DELAY: start delay */ enum sndrv_compress_encoder { SNDRV_COMPRESS_ENCODER_PADDING = 1, @@ -158,12 +159,14 @@ enum sndrv_compress_encoder { SNDRV_COMPRESS_RENDER_MODE = 6, SNDRV_COMPRESS_CLK_REC_MODE = 7, SNDRV_COMPRESS_RENDER_WINDOW = 8, + SNDRV_COMPRESS_START_DELAY = 9, }; #define SNDRV_COMPRESS_PATH_DELAY SNDRV_COMPRESS_PATH_DELAY #define SNDRV_COMPRESS_RENDER_MODE SNDRV_COMPRESS_RENDER_MODE #define SNDRV_COMPRESS_CLK_REC_MODE SNDRV_COMPRESS_CLK_REC_MODE #define SNDRV_COMPRESS_RENDER_WINDOW SNDRV_COMPRESS_RENDER_WINDOW +#define SNDRV_COMPRESS_START_DELAY SNDRV_COMPRESS_START_DELAY /** * struct snd_compr_metadata - compressed stream metadata diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c index 0d1dc4133fc8..b4de66ae43c5 100644 --- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c @@ -161,6 +161,8 @@ struct msm_compr_audio { uint32_t next_stream; uint32_t run_mode; + uint32_t start_delay_lsw; + uint32_t start_delay_msw; uint64_t marker_timestamp; @@ -2058,7 +2060,8 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd) msm_compr_read_buffer(prtd); } /* issue RUN command for the stream */ - q6asm_run_nowait(prtd->audio_client, prtd->run_mode, 0, 0); + q6asm_run_nowait(prtd->audio_client, prtd->run_mode, + prtd->start_delay_msw, prtd->start_delay_lsw); break; case SNDRV_PCM_TRIGGER_STOP: spin_lock_irqsave(&prtd->lock, flags); @@ -2839,6 +2842,9 @@ static int msm_compr_set_metadata(struct snd_compr_stream *cstream, metadata->value[1], metadata->value[2], metadata->value[3]); + } else if (metadata->key == SNDRV_COMPRESS_START_DELAY) { + prtd->start_delay_lsw = metadata->value[0]; + prtd->start_delay_msw = metadata->value[1]; } return 0; -- cgit v1.2.3