summaryrefslogtreecommitdiff
path: root/sound/core
diff options
context:
space:
mode:
authorJoris Verhaegen <verhaegen@google.com>2025-09-05 10:12:55 +0100
committerTakashi Iwai <tiwai@suse.de>2025-09-08 09:33:24 +0200
commitf20a53974f79619d0ef6c9f17bb8693499fb6ebb (patch)
tree41985e4258f18283390376ce46e20e9f0202b203 /sound/core
parent2c92e2fbe9e22cefdae87d8a0d654691ee4c1957 (diff)
ALSA: compress_offload: Add SNDRV_COMPRESS_TSTAMP64 ioctl
The previous patch introduced the internal infrastructure for handling 64-bit timestamps. This patch exposes this capability to user-space. Define the new ioctl command SNDRV_COMPRESS_TSTAMP64, which allows applications to fetch the overflow-safe struct snd_compr_tstamp64. The ioctl dispatch table is updated to handle the new command by calling a new snd_compr_tstamp64 handler, while the legacy path is renamed to snd_compr_tstamp32 for clarity. This patch bumps the SNDRV_COMPRESS_VERSION to 0.4.0. Reviewed-by: Miller Liang <millerliang@google.com> Tested-by: Joris Verhaegen <verhaegen@google.com> Signed-off-by: Joris Verhaegen <verhaegen@google.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Mark Brown <broonie@kernel.org> Acked-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250905091301.2711705-3-verhaegen@google.com
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/compress_offload.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index d3164aa07158..445220fdb6a0 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -736,18 +736,23 @@ snd_compr_set_metadata(struct snd_compr_stream *stream, unsigned long arg)
return retval;
}
-static inline int
-snd_compr_tstamp(struct snd_compr_stream *stream, unsigned long arg)
+static inline int snd_compr_tstamp(struct snd_compr_stream *stream,
+ unsigned long arg, bool is_32bit)
{
struct snd_compr_tstamp64 tstamp64 = { 0 };
struct snd_compr_tstamp tstamp32 = { 0 };
+ const void *copy_from = &tstamp64;
+ size_t copy_size = sizeof(tstamp64);
int ret;
ret = snd_compr_update_tstamp(stream, &tstamp64);
if (ret == 0) {
- snd_compr_tstamp32_from_64(&tstamp32, &tstamp64);
- ret = copy_to_user((struct snd_compr_tstamp __user *)arg,
- &tstamp32, sizeof(tstamp32)) ?
+ if (is_32bit) {
+ snd_compr_tstamp32_from_64(&tstamp32, &tstamp64);
+ copy_from = &tstamp32;
+ copy_size = sizeof(tstamp32);
+ }
+ ret = copy_to_user((void __user *)arg, copy_from, copy_size) ?
-EFAULT :
0;
}
@@ -1327,7 +1332,9 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
switch (cmd) {
case SNDRV_COMPRESS_TSTAMP:
- return snd_compr_tstamp(stream, arg);
+ return snd_compr_tstamp(stream, arg, true);
+ case SNDRV_COMPRESS_TSTAMP64:
+ return snd_compr_tstamp(stream, arg, false);
case SNDRV_COMPRESS_AVAIL:
return snd_compr_ioctl_avail(stream, arg);
case SNDRV_COMPRESS_PAUSE: