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 <manish@codeaurora.org>
This commit is contained in:
Manish Dewangan 2017-01-24 19:14:58 +05:30
parent 55ae10ad57
commit df38388af0
2 changed files with 44 additions and 3 deletions

View file

@ -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

View file

@ -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;