aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi
diff options
context:
space:
mode:
authorJoris Verhaegen <verhaegen@google.com>2025-09-05 10:12:54 +0100
committerTakashi Iwai <tiwai@suse.de>2025-09-08 09:33:24 +0200
commit2c92e2fbe9e22cefdae87d8a0d654691ee4c1957 (patch)
tree0032145739c373c5599212dfadb29eca5b69671e /include/uapi
parentALSA: scarlett2: Add Vocaster speaker/headphone mute controls (diff)
downloadlinux-2c92e2fbe9e22cefdae87d8a0d654691ee4c1957.tar.gz
linux-2c92e2fbe9e22cefdae87d8a0d654691ee4c1957.zip
ALSA: compress_offload: Add 64-bit safe timestamp infrastructure
The copied_total field in struct snd_compr_tstamp is a 32-bit value that can overflow on long-running high-bitrate streams, leading to incorrect calculations for buffer availablility. This patch adds a 64-bit safe timestamping mechanism. A new UAPI struct, snd_compr_tstamp64, is added which uses 64-bit types for byte counters. The relevant ops structures across the ASoC and core compress code are updated to use this new struct. ASoC drivers are updated to use u64 counters. Internal timestamps being u64 now, a compatibility function is added to convert the 64-bit timestamp back to the 32-bit format for legacy ioctl callers. Reviewed-by: Miller Liang <millerliang@google.com> Tested-by: Joris Verhaegen <verhaegen@google.com> Signed-off-by: Joris Verhaegen <verhaegen@google.com> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.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-2-verhaegen@google.com
Diffstat (limited to 'include/uapi')
-rw-r--r--include/uapi/sound/compress_offload.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h
index d62eb93af0ed..abd0ea3f86ee 100644
--- a/include/uapi/sound/compress_offload.h
+++ b/include/uapi/sound/compress_offload.h
@@ -57,6 +57,25 @@ struct snd_compr_tstamp {
} __attribute__((packed, aligned(4)));
/**
+ * struct snd_compr_tstamp64 - timestamp descriptor with fields in 64 bit
+ * @byte_offset: Byte offset in ring buffer to DSP
+ * @copied_total: Total number of bytes copied from/to ring buffer to/by DSP
+ * @pcm_frames: Frames decoded or encoded by DSP. This field will evolve by
+ * large steps and should only be used to monitor encoding/decoding
+ * progress. It shall not be used for timing estimates.
+ * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
+ * output/input. This field should be used for A/V sync or time estimates.
+ * @sampling_rate: sampling rate of audio
+ */
+struct snd_compr_tstamp64 {
+ __u32 byte_offset;
+ __u64 copied_total;
+ __u64 pcm_frames;
+ __u64 pcm_io_frames;
+ __u32 sampling_rate;
+} __attribute__((packed, aligned(4)));
+
+/**
* struct snd_compr_avail - avail descriptor
* @avail: Number of bytes available in ring buffer for writing/reading
* @tstamp: timestamp information