ASoc: msm: qdspv2: Clock recovery support in compress driver

Support for clock recovery in compress driver.

Userspace app can issue clock recovery command with a positive value
to advance the clock or a negative value to delay the clock.

CRs-Fixed: 2036899
Change-Id: Iacfc18afe6723edea84ed3382ac62810fcadb31a
Signed-off-by: Manish Dewangan <manish@codeaurora.org>
This commit is contained in:
Manish Dewangan 2017-04-17 15:01:32 +05:30 committed by Gerrit - the friendly Code Review server
parent 761f20e31b
commit 0c775d66f1
2 changed files with 48 additions and 0 deletions

View file

@ -149,6 +149,8 @@ struct snd_compr_audio_info {
* @SNDRV_COMPRESS_CLK_REC_MODE: clock recovery mode ( none or auto)
* @SNDRV_COMPRESS_RENDER_WINDOW: render window
* @SNDRV_COMPRESS_START_DELAY: start delay
* @SNDRV_COMPRESS_ENABLE_ADJUST_SESSION_CLOCK: enable dsp drift correction
* @SNDRV_COMPRESS_ADJUST_SESSION_CLOCK: set drift correction value
*/
enum sndrv_compress_encoder {
SNDRV_COMPRESS_ENCODER_PADDING = 1,
@ -160,6 +162,8 @@ enum sndrv_compress_encoder {
SNDRV_COMPRESS_CLK_REC_MODE = 7,
SNDRV_COMPRESS_RENDER_WINDOW = 8,
SNDRV_COMPRESS_START_DELAY = 9,
SNDRV_COMPRESS_ENABLE_ADJUST_SESSION_CLOCK = 10,
SNDRV_COMPRESS_ADJUST_SESSION_CLOCK = 11,
};
#define SNDRV_COMPRESS_PATH_DELAY SNDRV_COMPRESS_PATH_DELAY
@ -167,6 +171,9 @@ enum sndrv_compress_encoder {
#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
#define SNDRV_COMPRESS_ENABLE_ADJUST_SESSION_CLOCK \
SNDRV_COMPRESS_ENABLE_ADJUST_SESSION_CLOCK
#define SNDRV_COMPRESS_ADJUST_SESSION_CLOCK SNDRV_COMPRESS_ADJUST_SESSION_CLOCK
/**
* struct snd_compr_metadata - compressed stream metadata

View file

@ -313,6 +313,39 @@ exit:
return ret;
}
static int msm_compr_enable_adjust_session_clock(struct audio_client *ac,
bool enable)
{
int ret;
pr_debug("%s, enable adjust_session %d\n", __func__, enable);
ret = q6asm_send_mtmx_strtr_enable_adjust_session_clock(ac, enable);
if (ret)
pr_err("%s, adjust session clock can't be set error %d\n",
__func__, ret);
return ret;
}
static int msm_compr_adjust_session_clock(struct audio_client *ac,
uint32_t adjust_session_lsw, uint32_t adjust_session_msw)
{
int ret;
pr_debug("%s, adjust_session_time_msw 0x%x adjust_session_time_lsw 0x%x\n",
__func__, adjust_session_msw, adjust_session_lsw);
ret = q6asm_adjust_session_clock(ac,
adjust_session_lsw,
adjust_session_msw);
if (ret)
pr_err("%s, adjust session clock can't be set error %d\n",
__func__, ret);
return ret;
}
static int msm_compr_set_volume(struct snd_compr_stream *cstream,
uint32_t volume_l, uint32_t volume_r)
{
@ -2911,6 +2944,14 @@ static int msm_compr_set_metadata(struct snd_compr_stream *cstream,
} else if (metadata->key == SNDRV_COMPRESS_START_DELAY) {
prtd->start_delay_lsw = metadata->value[0];
prtd->start_delay_msw = metadata->value[1];
} else if (metadata->key ==
SNDRV_COMPRESS_ENABLE_ADJUST_SESSION_CLOCK) {
return msm_compr_enable_adjust_session_clock(ac,
metadata->value[0]);
} else if (metadata->key == SNDRV_COMPRESS_ADJUST_SESSION_CLOCK) {
return msm_compr_adjust_session_clock(ac,
metadata->value[0],
metadata->value[1]);
}
return 0;