mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
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
59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef __SPRD_PCM_DMA_H
|
|
#define __SPRD_PCM_DMA_H
|
|
|
|
#define DRV_NAME "sprd_pcm_dma"
|
|
#define SPRD_PCM_CHANNEL_MAX 2
|
|
|
|
extern const struct snd_compress_ops sprd_platform_compress_ops;
|
|
|
|
struct sprd_pcm_dma_params {
|
|
dma_addr_t dev_phys[SPRD_PCM_CHANNEL_MAX];
|
|
u32 datawidth[SPRD_PCM_CHANNEL_MAX];
|
|
u32 fragment_len[SPRD_PCM_CHANNEL_MAX];
|
|
const char *chan_name[SPRD_PCM_CHANNEL_MAX];
|
|
};
|
|
|
|
struct sprd_compr_playinfo {
|
|
int total_time;
|
|
int current_time;
|
|
int total_data_length;
|
|
u64 current_data_offset;
|
|
};
|
|
|
|
struct sprd_compr_params {
|
|
u32 direction;
|
|
u32 rate;
|
|
u32 sample_rate;
|
|
u32 channels;
|
|
u32 format;
|
|
u32 period;
|
|
u32 periods;
|
|
u32 info_phys;
|
|
u32 info_size;
|
|
};
|
|
|
|
struct sprd_compr_callback {
|
|
void (*drain_notify)(void *data);
|
|
void *drain_data;
|
|
};
|
|
|
|
struct sprd_compr_ops {
|
|
int (*open)(int str_id, struct sprd_compr_callback *cb);
|
|
int (*close)(int str_id);
|
|
int (*start)(int str_id);
|
|
int (*stop)(int str_id);
|
|
int (*pause)(int str_id);
|
|
int (*pause_release)(int str_id);
|
|
int (*drain)(u64 received_total);
|
|
int (*set_params)(int str_id, struct sprd_compr_params *params);
|
|
};
|
|
|
|
struct sprd_compr_data {
|
|
struct sprd_compr_ops *ops;
|
|
struct sprd_pcm_dma_params *dma_params;
|
|
};
|
|
|
|
#endif /* __SPRD_PCM_DMA_H */
|