This patch adds support to metadata required to do a gapless playback.

Signed-off-by: Srinivas Kandagatla <srinivas.kandaga...@linaro.org>
---
 sound/soc/qcom/qdsp6/q6asm-dai.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
index a493350c8cc2..c4b4684b7824 100644
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -71,6 +71,8 @@ struct q6asm_dai_rtd {
        uint32_t stream_id;
        uint16_t session_id;
        enum stream_state state;
+       uint32_t initial_samples_drop;
+       uint32_t trailing_samples_drop;
 };
 
 struct q6asm_dai_data {
@@ -869,6 +871,28 @@ static int q6asm_dai_compr_set_params(struct 
snd_soc_component *component,
        return 0;
 }
 
+static int q6asm_dai_compr_set_metadata(struct snd_compr_stream *stream,
+                                       struct snd_compr_metadata *metadata)
+{
+       struct snd_compr_runtime *runtime = stream->runtime;
+       struct q6asm_dai_rtd *prtd = runtime->private_data;
+       int ret = 0;
+
+       switch (metadata->key) {
+       case SNDRV_COMPRESS_ENCODER_PADDING:
+               prtd->trailing_samples_drop = metadata->value[0];
+               break;
+       case SNDRV_COMPRESS_ENCODER_DELAY:
+               prtd->initial_samples_drop = metadata->value[0];
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+
+       return ret;
+}
+
 static int q6asm_dai_compr_trigger(struct snd_soc_component *component,
                                   struct snd_compr_stream *stream, int cmd)
 {
@@ -985,6 +1009,7 @@ static struct snd_compress_ops q6asm_dai_compress_ops = {
        .open           = q6asm_dai_compr_open,
        .free           = q6asm_dai_compr_free,
        .set_params     = q6asm_dai_compr_set_params,
+       .set_metadata   = q6asm_dai_compr_set_metadata,
        .pointer        = q6asm_dai_compr_pointer,
        .trigger        = q6asm_dai_compr_trigger,
        .get_caps       = q6asm_dai_compr_get_caps,
-- 
2.21.0

Reply via email to