0001-asound-time64.diff 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. diff -ur a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
  2. --- a/include/uapi/sound/asound.h 2019-10-15 12:26:39.634141383 -0400
  3. +++ b/include/uapi/sound/asound.h 2020-01-30 21:43:56.477450321 -0500
  4. @@ -35,6 +35,8 @@
  5. #include <time.h>
  6. #endif
  7. +#include <asm/byteorder.h>
  8. +
  9. /*
  10. * protocol version
  11. */
  12. @@ -154,7 +156,7 @@
  13. * *
  14. *****************************************************************************/
  15. -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 14)
  16. +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 15)
  17. typedef unsigned long snd_pcm_uframes_t;
  18. typedef signed long snd_pcm_sframes_t;
  19. @@ -301,7 +303,9 @@
  20. #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */
  21. #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */
  22. -
  23. +#if (__BITS_PER_LONG == 32 && defined(__USE_TIME_BITS64)) || defined __KERNEL__
  24. +#define __SND_STRUCT_TIME64
  25. +#endif
  26. typedef int __bitwise snd_pcm_state_t;
  27. #define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */
  28. @@ -317,8 +321,17 @@
  29. enum {
  30. SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000,
  31. - SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000,
  32. - SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000,
  33. + SNDRV_PCM_MMAP_OFFSET_STATUS_OLD = 0x80000000,
  34. + SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD = 0x81000000,
  35. + SNDRV_PCM_MMAP_OFFSET_STATUS_NEW = 0x82000000,
  36. + SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW = 0x83000000,
  37. +#ifdef __SND_STRUCT_TIME64
  38. + SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_NEW,
  39. + SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW,
  40. +#else
  41. + SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_OLD,
  42. + SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD,
  43. +#endif
  44. };
  45. union snd_pcm_sync_id {
  46. @@ -456,8 +469,13 @@
  47. SNDRV_PCM_AUDIO_TSTAMP_TYPE_LAST = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED
  48. };
  49. +#ifndef __KERNEL__
  50. +/* explicit padding avoids incompatibility between i386 and x86-64 */
  51. +typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)] } __time_pad;
  52. +
  53. struct snd_pcm_status {
  54. snd_pcm_state_t state; /* stream state */
  55. + __time_pad pad1; /* align to timespec */
  56. struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */
  57. struct timespec tstamp; /* reference timestamp */
  58. snd_pcm_uframes_t appl_ptr; /* appl ptr */
  59. @@ -473,17 +491,48 @@
  60. __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */
  61. unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */
  62. };
  63. +#endif
  64. -struct snd_pcm_mmap_status {
  65. +/*
  66. + * For mmap operations, we need the 64-bit layout, both for compat mode,
  67. + * and for y2038 compatibility. For 64-bit applications, the two definitions
  68. + * are identical, so we keep the traditional version.
  69. + */
  70. +#ifdef __SND_STRUCT_TIME64
  71. +#define __snd_pcm_mmap_status64 snd_pcm_mmap_status
  72. +#define __snd_pcm_mmap_control64 snd_pcm_mmap_control
  73. +#define __snd_pcm_sync_ptr64 snd_pcm_sync_ptr
  74. +#ifdef __KERNEL__
  75. +#define __snd_timespec64 __kernel_timespec
  76. +#else
  77. +#define __snd_timespec64 timespec
  78. +#endif
  79. +struct __snd_timespec {
  80. + __s32 tv_sec;
  81. + __s32 tv_nsec;
  82. +};
  83. +#else
  84. +#define __snd_pcm_mmap_status snd_pcm_mmap_status
  85. +#define __snd_pcm_mmap_control snd_pcm_mmap_control
  86. +#define __snd_pcm_sync_ptr snd_pcm_sync_ptr
  87. +#define __snd_timespec timespec
  88. +struct __snd_timespec64 {
  89. + __s64 tv_sec;
  90. + __s64 tv_nsec;
  91. +};
  92. +
  93. +#endif
  94. +
  95. +struct __snd_pcm_mmap_status {
  96. snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */
  97. int pad1; /* Needed for 64 bit alignment */
  98. snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */
  99. - struct timespec tstamp; /* Timestamp */
  100. + struct __snd_timespec tstamp; /* Timestamp */
  101. snd_pcm_state_t suspended_state; /* RO: suspended stream state */
  102. - struct timespec audio_tstamp; /* from sample counter or wall clock */
  103. + struct __snd_timespec audio_tstamp; /* from sample counter or wall clock */
  104. };
  105. -struct snd_pcm_mmap_control {
  106. +struct __snd_pcm_mmap_control {
  107. snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
  108. snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
  109. };
  110. @@ -492,14 +541,59 @@
  111. #define SNDRV_PCM_SYNC_PTR_APPL (1<<1) /* get appl_ptr from driver (r/w op) */
  112. #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) /* get avail_min from driver */
  113. -struct snd_pcm_sync_ptr {
  114. +struct __snd_pcm_sync_ptr {
  115. unsigned int flags;
  116. union {
  117. - struct snd_pcm_mmap_status status;
  118. + struct __snd_pcm_mmap_status status;
  119. unsigned char reserved[64];
  120. } s;
  121. union {
  122. - struct snd_pcm_mmap_control control;
  123. + struct __snd_pcm_mmap_control control;
  124. + unsigned char reserved[64];
  125. + } c;
  126. +};
  127. +
  128. +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
  129. +typedef char __pad_before_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)];
  130. +typedef char __pad_after_uframe[0];
  131. +#endif
  132. +
  133. +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
  134. +typedef char __pad_before_uframe[0];
  135. +typedef char __pad_after_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)];
  136. +#endif
  137. +
  138. +struct __snd_pcm_mmap_status64 {
  139. + __s32 state; /* RO: state - SNDRV_PCM_STATE_XXXX */
  140. + __u32 pad1; /* Needed for 64 bit alignment */
  141. + __pad_before_uframe __pad1;
  142. + snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */
  143. + __pad_after_uframe __pad2;
  144. + struct __snd_timespec64 tstamp; /* Timestamp */
  145. + __s32 suspended_state; /* RO: suspended stream state */
  146. + __u32 pad3; /* Needed for 64 bit alignment */
  147. + struct __snd_timespec64 audio_tstamp; /* sample counter or wall clock */
  148. +};
  149. +
  150. +struct __snd_pcm_mmap_control64 {
  151. + __pad_before_uframe __pad1;
  152. + snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
  153. + __pad_before_uframe __pad2;
  154. +
  155. + __pad_before_uframe __pad3;
  156. + snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
  157. + __pad_after_uframe __pad4;
  158. +};
  159. +
  160. +struct __snd_pcm_sync_ptr64 {
  161. + __u32 flags;
  162. + __u32 pad1;
  163. + union {
  164. + struct __snd_pcm_mmap_status64 status;
  165. + unsigned char reserved[64];
  166. + } s;
  167. + union {
  168. + struct __snd_pcm_mmap_control64 control;
  169. unsigned char reserved[64];
  170. } c;
  171. };
  172. @@ -584,6 +678,8 @@
  173. #define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status)
  174. #define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t)
  175. #define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22)
  176. +#define __SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct __snd_pcm_sync_ptr)
  177. +#define __SNDRV_PCM_IOCTL_SYNC_PTR64 _IOWR('A', 0x23, struct __snd_pcm_sync_ptr64)
  178. #define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr)
  179. #define SNDRV_PCM_IOCTL_STATUS_EXT _IOWR('A', 0x24, struct snd_pcm_status)
  180. #define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info)
  181. @@ -614,7 +710,7 @@
  182. * Raw MIDI section - /dev/snd/midi??
  183. */
  184. -#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0)
  185. +#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 1)
  186. enum {
  187. SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
  188. @@ -648,13 +744,16 @@
  189. unsigned char reserved[16]; /* reserved for future use */
  190. };
  191. +#ifndef __KERNEL__
  192. struct snd_rawmidi_status {
  193. int stream;
  194. + __time_pad pad1;
  195. struct timespec tstamp; /* Timestamp */
  196. size_t avail; /* available bytes */
  197. size_t xruns; /* count of overruns since last status (in bytes) */
  198. unsigned char reserved[16]; /* reserved for future use */
  199. };
  200. +#endif
  201. #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int)
  202. #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info)
  203. @@ -667,7 +766,7 @@
  204. * Timer section - /dev/snd/timer
  205. */
  206. -#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6)
  207. +#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7)
  208. enum {
  209. SNDRV_TIMER_CLASS_NONE = -1,
  210. @@ -761,6 +860,7 @@
  211. unsigned char reserved[60]; /* reserved */
  212. };
  213. +#ifndef __KERNEL__
  214. struct snd_timer_status {
  215. struct timespec tstamp; /* Timestamp - last update */
  216. unsigned int resolution; /* current period resolution in ns */
  217. @@ -769,10 +869,11 @@
  218. unsigned int queue; /* used queue size */
  219. unsigned char reserved[64]; /* reserved */
  220. };
  221. +#endif
  222. #define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int)
  223. #define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id)
  224. -#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int)
  225. +#define SNDRV_TIMER_IOCTL_TREAD_OLD _IOW('T', 0x02, int)
  226. #define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo)
  227. #define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams)
  228. #define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus)
  229. @@ -785,6 +886,15 @@
  230. #define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1)
  231. #define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2)
  232. #define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3)
  233. +#define SNDRV_TIMER_IOCTL_TREAD64 _IOW('T', 0xa4, int)
  234. +
  235. +#if __BITS_PER_LONG == 64
  236. +#define SNDRV_TIMER_IOCTL_TREAD SNDRV_TIMER_IOCTL_TREAD_OLD
  237. +#else
  238. +#define SNDRV_TIMER_IOCTL_TREAD ((sizeof(__kernel_long_t) >= sizeof(time_t)) ? \
  239. + SNDRV_TIMER_IOCTL_TREAD_OLD : \
  240. + SNDRV_TIMER_IOCTL_TREAD64)
  241. +#endif
  242. struct snd_timer_read {
  243. unsigned int resolution;
  244. @@ -810,11 +920,15 @@
  245. SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10,
  246. };
  247. +#ifndef __KERNEL__
  248. struct snd_timer_tread {
  249. int event;
  250. + __time_pad pad1;
  251. struct timespec tstamp;
  252. unsigned int val;
  253. + __time_pad pad2;
  254. };
  255. +#endif
  256. /****************************************************************************
  257. * *
  258. @@ -955,8 +1069,7 @@
  259. } bytes;
  260. struct snd_aes_iec958 iec958;
  261. } value; /* RO */
  262. - struct timespec tstamp;
  263. - unsigned char reserved[128-sizeof(struct timespec)];
  264. + unsigned char reserved[128];
  265. };
  266. struct snd_ctl_tlv {