arch/sim : Audio driver add AUDIOIOC_GETLATENCY ioctl
add AUDIOIOC_GETLATENCY definition, and add reference code in sim alsa. Signed-off-by: libei1 <libei1@xiaomi.com>
This commit is contained in:
parent
cbbeec3183
commit
63774125d9
@ -600,6 +600,38 @@ static int sim_audio_ioctl(struct audio_lowerhalf_s *dev, int cmd,
|
|||||||
audinfo("%s , arg: %s\n", __func__, (char *)arg);
|
audinfo("%s , arg: %s\n", __func__, (char *)arg);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case AUDIOIOC_GETLATENCY:
|
||||||
|
{
|
||||||
|
long *latency = (long *)arg;
|
||||||
|
long remain = 0;
|
||||||
|
dq_entry_t *cur;
|
||||||
|
|
||||||
|
if (!priv->pcm)
|
||||||
|
{
|
||||||
|
ret = -ENXIO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = snd_pcm_delay(priv->pcm, latency);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
remain = priv->aux->nbytes - priv->aux->curbyte;
|
||||||
|
|
||||||
|
for (cur = dq_peek(&priv->pendq); cur; cur = dq_next(cur))
|
||||||
|
{
|
||||||
|
struct ap_buffer_s *apb = (struct ap_buffer_s *)cur;
|
||||||
|
remain += apb->nbytes - apb->curbyte;
|
||||||
|
}
|
||||||
|
|
||||||
|
*latency += remain / priv->frame_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = -ENOTTY;
|
ret = -ENOTTY;
|
||||||
break;
|
break;
|
||||||
|
@ -112,6 +112,7 @@
|
|||||||
#define AUDIOIOC_HWRESET _AUDIOIOC(16)
|
#define AUDIOIOC_HWRESET _AUDIOIOC(16)
|
||||||
#define AUDIOIOC_SETBUFFERINFO _AUDIOIOC(17)
|
#define AUDIOIOC_SETBUFFERINFO _AUDIOIOC(17)
|
||||||
#define AUDIOIOC_SETPARAMTER _AUDIOIOC(18)
|
#define AUDIOIOC_SETPARAMTER _AUDIOIOC(18)
|
||||||
|
#define AUDIOIOC_GETLATENCY _AUDIOIOC(19)
|
||||||
|
|
||||||
/* Audio Device Types *******************************************************/
|
/* Audio Device Types *******************************************************/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user