ASoC: q6dsp: q6apm-dai: Add trigger/pointer compress DAI callbacks
Add q6apm trigger and pointer compress DAI callbacks to support compress offload playback. Co-developed-by: Mohammad Rafi Shaik <quic_mohs@quicinc.com> Signed-off-by: Mohammad Rafi Shaik <quic_mohs@quicinc.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20230619101653.9750-10-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
c0c87738a1
commit
c337bf33c4
@ -568,11 +568,78 @@ static int q6apm_dai_compr_get_codec_caps(struct snd_soc_component *component,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int q6apm_dai_compr_pointer(struct snd_soc_component *component,
|
||||
struct snd_compr_stream *stream,
|
||||
struct snd_compr_tstamp *tstamp)
|
||||
{
|
||||
struct snd_compr_runtime *runtime = stream->runtime;
|
||||
struct q6apm_dai_rtd *prtd = runtime->private_data;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&prtd->lock, flags);
|
||||
tstamp->copied_total = prtd->copied_total;
|
||||
tstamp->byte_offset = prtd->copied_total % prtd->pcm_size;
|
||||
spin_unlock_irqrestore(&prtd->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int q6apm_dai_compr_trigger(struct snd_soc_component *component,
|
||||
struct snd_compr_stream *stream, int cmd)
|
||||
{
|
||||
struct snd_compr_runtime *runtime = stream->runtime;
|
||||
struct q6apm_dai_rtd *prtd = runtime->private_data;
|
||||
int ret = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||
ret = q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, NO_TIMESTAMP);
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||
break;
|
||||
case SND_COMPR_TRIGGER_NEXT_TRACK:
|
||||
prtd->next_track = true;
|
||||
break;
|
||||
case SND_COMPR_TRIGGER_DRAIN:
|
||||
case SND_COMPR_TRIGGER_PARTIAL_DRAIN:
|
||||
prtd->notify_on_drain = true;
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int q6apm_dai_compr_ack(struct snd_soc_component *component, struct snd_compr_stream *stream,
|
||||
size_t count)
|
||||
{
|
||||
struct snd_compr_runtime *runtime = stream->runtime;
|
||||
struct q6apm_dai_rtd *prtd = runtime->private_data;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&prtd->lock, flags);
|
||||
prtd->bytes_received += count;
|
||||
spin_unlock_irqrestore(&prtd->lock, flags);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct snd_compress_ops q6apm_dai_compress_ops = {
|
||||
.open = q6apm_dai_compr_open,
|
||||
.free = q6apm_dai_compr_free,
|
||||
.get_caps = q6apm_dai_compr_get_caps,
|
||||
.get_codec_caps = q6apm_dai_compr_get_codec_caps,
|
||||
.pointer = q6apm_dai_compr_pointer,
|
||||
.trigger = q6apm_dai_compr_trigger,
|
||||
.ack = q6apm_dai_compr_ack,
|
||||
};
|
||||
|
||||
static const struct snd_soc_component_driver q6apm_fe_dai_component = {
|
||||
|
@ -46,6 +46,7 @@
|
||||
|
||||
#define APM_MAX_SESSIONS 8
|
||||
#define APM_LAST_BUFFER_FLAG BIT(30)
|
||||
#define NO_TIMESTAMP 0xFF00
|
||||
|
||||
struct q6apm {
|
||||
struct device *dev;
|
||||
|
Loading…
x
Reference in New Issue
Block a user