aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/pcm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sound/pcm.h')
-rw-r--r--include/sound/pcm.h66
1 files changed, 64 insertions, 2 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index c0ddb7e69c28..0cb7f3f5df7b 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -60,6 +60,9 @@ struct snd_pcm_hardware {
60 60
61struct snd_pcm_substream; 61struct snd_pcm_substream;
62 62
63struct snd_pcm_audio_tstamp_config; /* definitions further down */
64struct snd_pcm_audio_tstamp_report;
65
63struct snd_pcm_ops { 66struct snd_pcm_ops {
64 int (*open)(struct snd_pcm_substream *substream); 67 int (*open)(struct snd_pcm_substream *substream);
65 int (*close)(struct snd_pcm_substream *substream); 68 int (*close)(struct snd_pcm_substream *substream);
@@ -71,8 +74,10 @@ struct snd_pcm_ops {
71 int (*prepare)(struct snd_pcm_substream *substream); 74 int (*prepare)(struct snd_pcm_substream *substream);
72 int (*trigger)(struct snd_pcm_substream *substream, int cmd); 75 int (*trigger)(struct snd_pcm_substream *substream, int cmd);
73 snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream); 76 snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream);
74 int (*wall_clock)(struct snd_pcm_substream *substream, 77 int (*get_time_info)(struct snd_pcm_substream *substream,
75 struct timespec *audio_ts); 78 struct timespec *system_ts, struct timespec *audio_ts,
79 struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
80 struct snd_pcm_audio_tstamp_report *audio_tstamp_report);
76 int (*copy)(struct snd_pcm_substream *substream, int channel, 81 int (*copy)(struct snd_pcm_substream *substream, int channel,
77 snd_pcm_uframes_t pos, 82 snd_pcm_uframes_t pos,
78 void __user *buf, snd_pcm_uframes_t count); 83 void __user *buf, snd_pcm_uframes_t count);
@@ -281,6 +286,58 @@ struct snd_pcm_hw_constraint_ranges {
281 286
282struct snd_pcm_hwptr_log; 287struct snd_pcm_hwptr_log;
283 288
289/*
290 * userspace-provided audio timestamp config to kernel,
291 * structure is for internal use only and filled with dedicated unpack routine
292 */
293struct snd_pcm_audio_tstamp_config {
294 /* 5 of max 16 bits used */
295 u32 type_requested:4;
296 u32 report_delay:1; /* add total delay to A/D or D/A */
297};
298
299static inline void snd_pcm_unpack_audio_tstamp_config(__u32 data,
300 struct snd_pcm_audio_tstamp_config *config)
301{
302 config->type_requested = data & 0xF;
303 config->report_delay = (data >> 4) & 1;
304}
305
306/*
307 * kernel-provided audio timestamp report to user-space
308 * structure is for internal use only and read by dedicated pack routine
309 */
310struct snd_pcm_audio_tstamp_report {
311 /* 6 of max 16 bits used for bit-fields */
312
313 /* for backwards compatibility */
314 u32 valid:1;
315
316 /* actual type if hardware could not support requested timestamp */
317 u32 actual_type:4;
318
319 /* accuracy represented in ns units */
320 u32 accuracy_report:1; /* 0 if accuracy unknown, 1 if accuracy field is valid */
321 u32 accuracy; /* up to 4.29s, will be packed in separate field */
322};
323
324static inline void snd_pcm_pack_audio_tstamp_report(__u32 *data, __u32 *accuracy,
325 const struct snd_pcm_audio_tstamp_report *report)
326{
327 u32 tmp;
328
329 tmp = report->accuracy_report;
330 tmp <<= 4;
331 tmp |= report->actual_type;
332 tmp <<= 1;
333 tmp |= report->valid;
334
335 *data &= 0xffff; /* zero-clear MSBs */
336 *data |= (tmp << 16);
337 *accuracy = report->accuracy;
338}
339
340
284struct snd_pcm_runtime { 341struct snd_pcm_runtime {
285 /* -- Status -- */ 342 /* -- Status -- */
286 struct snd_pcm_substream *trigger_master; 343 struct snd_pcm_substream *trigger_master;
@@ -361,6 +418,11 @@ struct snd_pcm_runtime {
361 418
362 struct snd_dma_buffer *dma_buffer_p; /* allocated buffer */ 419 struct snd_dma_buffer *dma_buffer_p; /* allocated buffer */
363 420
421 /* -- audio timestamp config -- */
422 struct snd_pcm_audio_tstamp_config audio_tstamp_config;
423 struct snd_pcm_audio_tstamp_report audio_tstamp_report;
424 struct timespec driver_tstamp;
425
364#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) 426#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
365 /* -- OSS things -- */ 427 /* -- OSS things -- */
366 struct snd_pcm_oss_runtime oss; 428 struct snd_pcm_oss_runtime oss;