From bbbea003e7008b8497a57f5b0f446e11177c48c3 Mon Sep 17 00:00:00 2001 From: Manish Dewangan Date: Thu, 9 Feb 2017 11:08:27 +0530 Subject: [PATCH] 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(+) 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;