diff options
| author | Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> | 2015-02-13 16:14:03 -0500 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2015-02-20 11:30:03 -0500 |
| commit | 229d043096ea8e58829d37d35767afeac15997f5 (patch) | |
| tree | 36a7c15f53435696812cd8e616769f373400d027 /include/uapi | |
| parent | 0c8d948565490d2a2db9d9a5aec388342c7d38ce (diff) | |
ALSA: core: selection of audio_tstamp type and accuracy reports
Audio timestamps can be extracted from sample counters, wall clocks,
PHC clocks (Ethernet AVB), on-demand synchronized snapshots. This
patch provides the ability to report timestamping capabilities, select
timestamp types and retrieve timestamp accuracy, if supported.
Details can be found in Documentations/sound/alsa/timestamping.txt
This functionality is introduced by reclaiming the reserved_aligned
field introduced by commit9c7066aef4a5eb8e4063de28f06c508bf6f2963a
in snd_pcm_status to provide userspace with selection/query capabilities.
Additional driver_tstamp and audio_tstamp_accuracy fields are also added.
snd_pcm_mmap_status remains a read-only structure with only
the audio timestamp value accessible from user space. The selection
of audio timestamp type is done through snd_pcm_status only
This commit does not impact ABI and does not impact the default
behavior. By default audio timestamp is aligned with hw_pointer and
reports the DMA position. Backwards compatibility is handled by using
the HDAudio wall clock for playback and the hw_ptr for all other
cases.
For timestamp selection a new STATUS_EXT ioctl is introduced with
read/write parameters. Alsa-lib will be modified to make use of
STATUS_EXT.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/uapi')
| -rw-r--r-- | include/uapi/sound/asound.h | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index 0e88e7a0f0eb..acef4e4d2735 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h | |||
| @@ -267,10 +267,17 @@ typedef int __bitwise snd_pcm_subformat_t; | |||
| 267 | #define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 /* playback and capture stream are somewhat correlated */ | 267 | #define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 /* playback and capture stream are somewhat correlated */ |
| 268 | #define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */ | 268 | #define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */ |
| 269 | #define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP 0x00800000 /* period wakeup can be disabled */ | 269 | #define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP 0x00800000 /* period wakeup can be disabled */ |
| 270 | #define SNDRV_PCM_INFO_HAS_WALL_CLOCK 0x01000000 /* has audio wall clock for audio/system time sync */ | 270 | #define SNDRV_PCM_INFO_HAS_WALL_CLOCK 0x01000000 /* (Deprecated)has audio wall clock for audio/system time sync */ |
| 271 | #define SNDRV_PCM_INFO_HAS_LINK_ATIME 0x01000000 /* report hardware link audio time, reset on startup */ | ||
| 272 | #define SNDRV_PCM_INFO_HAS_LINK_ABSOLUTE_ATIME 0x02000000 /* report absolute hardware link audio time, not reset on startup */ | ||
| 273 | #define SNDRV_PCM_INFO_HAS_LINK_ESTIMATED_ATIME 0x04000000 /* report estimated link audio time */ | ||
| 274 | #define SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME 0x08000000 /* report synchronized audio/system time */ | ||
| 275 | |||
| 271 | #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */ | 276 | #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */ |
| 272 | #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */ | 277 | #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */ |
| 273 | 278 | ||
| 279 | |||
| 280 | |||
| 274 | typedef int __bitwise snd_pcm_state_t; | 281 | typedef int __bitwise snd_pcm_state_t; |
| 275 | #define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */ | 282 | #define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */ |
| 276 | #define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) /* stream has a setup */ | 283 | #define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) /* stream has a setup */ |
| @@ -408,6 +415,22 @@ struct snd_pcm_channel_info { | |||
| 408 | unsigned int step; /* samples distance in bits */ | 415 | unsigned int step; /* samples distance in bits */ |
| 409 | }; | 416 | }; |
| 410 | 417 | ||
| 418 | enum { | ||
| 419 | /* | ||
| 420 | * first definition for backwards compatibility only, | ||
| 421 | * maps to wallclock/link time for HDAudio playback and DEFAULT/DMA time for everything else | ||
| 422 | */ | ||
| 423 | SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT = 0, | ||
| 424 | |||
| 425 | /* timestamp definitions */ | ||
| 426 | SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT = 1, /* DMA time, reported as per hw_ptr */ | ||
| 427 | SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK = 2, /* link time reported by sample or wallclock counter, reset on startup */ | ||
| 428 | SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_ABSOLUTE = 3, /* link time reported by sample or wallclock counter, not reset on startup */ | ||
| 429 | SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_ESTIMATED = 4, /* link time estimated indirectly */ | ||
| 430 | SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED = 5, /* link time synchronized with system time */ | ||
| 431 | SNDRV_PCM_AUDIO_TSTAMP_TYPE_LAST = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED | ||
| 432 | }; | ||
| 433 | |||
| 411 | struct snd_pcm_status { | 434 | struct snd_pcm_status { |
| 412 | snd_pcm_state_t state; /* stream state */ | 435 | snd_pcm_state_t state; /* stream state */ |
| 413 | struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */ | 436 | struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */ |
| @@ -419,9 +442,11 @@ struct snd_pcm_status { | |||
| 419 | snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */ | 442 | snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */ |
| 420 | snd_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */ | 443 | snd_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */ |
| 421 | snd_pcm_state_t suspended_state; /* suspended stream state */ | 444 | snd_pcm_state_t suspended_state; /* suspended stream state */ |
| 422 | __u32 reserved_alignment; /* must be filled with zero */ | 445 | __u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */ |
| 423 | struct timespec audio_tstamp; /* from sample counter or wall clock */ | 446 | struct timespec audio_tstamp; /* sample counter, wall clock, PHC or on-demand sync'ed */ |
| 424 | unsigned char reserved[56-sizeof(struct timespec)]; /* must be filled with zero */ | 447 | struct timespec driver_tstamp; /* useful in case reference system tstamp is reported with delay */ |
| 448 | __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ | ||
| 449 | unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */ | ||
| 425 | }; | 450 | }; |
| 426 | 451 | ||
| 427 | struct snd_pcm_mmap_status { | 452 | struct snd_pcm_mmap_status { |
| @@ -534,6 +559,7 @@ enum { | |||
| 534 | #define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t) | 559 | #define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t) |
| 535 | #define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22) | 560 | #define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22) |
| 536 | #define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr) | 561 | #define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr) |
| 562 | #define SNDRV_PCM_IOCTL_STATUS_EXT _IOWR('A', 0x24, struct snd_pcm_status) | ||
| 537 | #define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info) | 563 | #define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info) |
| 538 | #define SNDRV_PCM_IOCTL_PREPARE _IO('A', 0x40) | 564 | #define SNDRV_PCM_IOCTL_PREPARE _IO('A', 0x40) |
| 539 | #define SNDRV_PCM_IOCTL_RESET _IO('A', 0x41) | 565 | #define SNDRV_PCM_IOCTL_RESET _IO('A', 0x41) |
