aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-10-10 11:49:49 +0200
committerJaroslav Kysela <perex@suse.cz>2005-11-04 13:17:47 +0100
commit07799e756c76ecd52cb01a812ba48b7d8ac67633 (patch)
tree5b6a006d90e631e6b70264aba355314a7cedbbe5
parent7c22f1aaa23370bf9ba2dd3abbccbed70dced216 (diff)
[ALSA] Use getnstimeofday()
Modules: Documentation,PCM Midlevel,Timer Midlevel,ALSA Core Use the standard getnstimeofday() function instead of ALSA's own one. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl3
-rw-r--r--include/sound/core.h23
-rw-r--r--include/sound/pcm.h3
-rw-r--r--sound/core/pcm_lib.c2
-rw-r--r--sound/core/pcm_native.c14
-rw-r--r--sound/core/timer.c6
6 files changed, 10 insertions, 41 deletions
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
index f3a2fdca9ad..ab3dfe074fb 100644
--- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
@@ -2190,8 +2190,7 @@ struct _snd_pcm_runtime {
unsigned int rate_den;
/* -- SW params -- */
- int tstamp_timespec; /* use timeval (0) or timespec (1) */
- snd_pcm_tstamp_t tstamp_mode; /* mmap timestamp is updated */
+ struct timespec tstamp_mode; /* mmap timestamp is updated */
unsigned int period_step;
unsigned int sleep_min; /* min ticks to sleep */
snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */
diff --git a/include/sound/core.h b/include/sound/core.h
index f0f54407fe5..fa8f4c9492c 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -29,7 +29,6 @@
#include <linux/pm.h> /* pm_message_t */
/* Typedef's */
-typedef struct timespec snd_timestamp_t;
typedef struct sndrv_interval snd_interval_t;
typedef enum sndrv_card_type snd_card_type;
typedef struct sndrv_xferi snd_xferi_t;
@@ -464,28 +463,6 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
#endif
-static inline void snd_timestamp_now(struct timespec *tstamp, int timespec)
-{
- struct timeval val;
- /* FIXME: use a linear time source */
- do_gettimeofday(&val);
- tstamp->tv_sec = val.tv_sec;
- tstamp->tv_nsec = val.tv_usec;
- if (timespec)
- tstamp->tv_nsec *= 1000L;
-}
-
-static inline void snd_timestamp_zero(struct timespec *tstamp)
-{
- tstamp->tv_sec = 0;
- tstamp->tv_nsec = 0;
-}
-
-static inline int snd_timestamp_null(struct timespec *tstamp)
-{
- return tstamp->tv_sec == 0 && tstamp->tv_nsec == 0;
-}
-
#define SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0)) /* 3.8.1a */
/* for easier backward-porting */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 2b23a596707..acc4fa9d5ab 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -281,7 +281,7 @@ typedef struct {
struct _snd_pcm_runtime {
/* -- Status -- */
snd_pcm_substream_t *trigger_master;
- snd_timestamp_t trigger_tstamp; /* trigger timestamp */
+ struct timespec trigger_tstamp; /* trigger timestamp */
int overrange;
snd_pcm_uframes_t avail_max;
snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */
@@ -306,7 +306,6 @@ struct _snd_pcm_runtime {
unsigned int rate_den;
/* -- SW params -- */
- int tstamp_timespec; /* use timeval (0) or timespec (1) */
snd_pcm_tstamp_t tstamp_mode; /* mmap timestamp is updated */
unsigned int period_step;
unsigned int sleep_min; /* min ticks to sleep */
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index dfc5f45f274..3dbf9bf2ac1 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -152,7 +152,7 @@ static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(snd_pcm_substream_t *s
if (pos == SNDRV_PCM_POS_XRUN)
return pos; /* XRUN */
if (runtime->tstamp_mode & SNDRV_PCM_TSTAMP_MMAP)
- snd_timestamp_now((snd_timestamp_t*)&runtime->status->tstamp, runtime->tstamp_timespec);
+ getnstimeofday((struct timespec *)&runtime->status->tstamp);
#ifdef CONFIG_SND_DEBUG
if (pos >= runtime->buffer_size) {
snd_printk(KERN_ERR "BUG: stream = %i, pos = 0x%lx, buffer size = 0x%lx, period size = 0x%lx\n", substream->stream, pos, runtime->buffer_size, runtime->period_size);
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index e6e2b70314c..a1924f12d8f 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -565,9 +565,9 @@ int snd_pcm_status(snd_pcm_substream_t *substream,
if (runtime->tstamp_mode & SNDRV_PCM_TSTAMP_MMAP)
status->tstamp = runtime->status->tstamp;
else
- snd_timestamp_now(&status->tstamp, runtime->tstamp_timespec);
+ getnstimeofday(&status->tstamp);
} else
- snd_timestamp_now(&status->tstamp, runtime->tstamp_timespec);
+ getnstimeofday(&status->tstamp);
status->appl_ptr = runtime->control->appl_ptr;
status->hw_ptr = runtime->status->hw_ptr;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -652,7 +652,7 @@ static void snd_pcm_trigger_tstamp(snd_pcm_substream_t *substream)
if (runtime->trigger_master == NULL)
return;
if (runtime->trigger_master == substream) {
- snd_timestamp_now(&runtime->trigger_tstamp, runtime->tstamp_timespec);
+ getnstimeofday(&runtime->trigger_tstamp);
} else {
snd_pcm_trigger_tstamp(runtime->trigger_master);
runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp;
@@ -2446,14 +2446,8 @@ static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream,
return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0;
case SNDRV_PCM_IOCTL_INFO:
return snd_pcm_info_user(substream, arg);
- case SNDRV_PCM_IOCTL_TSTAMP:
- {
- int xarg;
- if (get_user(xarg, (int __user *)arg))
- return -EFAULT;
- substream->runtime->tstamp_timespec = xarg ? 1 : 0;
+ case SNDRV_PCM_IOCTL_TSTAMP: /* just for compatibility */
return 0;
- }
case SNDRV_PCM_IOCTL_HW_REFINE:
return snd_pcm_hw_refine_user(substream, arg);
case SNDRV_PCM_IOCTL_HW_PARAMS:
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 128916c6608..8ecec9134ac 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -385,7 +385,7 @@ static void snd_timer_notify1(snd_timer_instance_t *ti, enum sndrv_timer_event e
struct list_head *n;
struct timespec tstamp;
- snd_timestamp_now(&tstamp, 1);
+ getnstimeofday(&tstamp);
snd_assert(event >= SNDRV_TIMER_EVENT_START && event <= SNDRV_TIMER_EVENT_PAUSE, return);
if (event == SNDRV_TIMER_EVENT_START || event == SNDRV_TIMER_EVENT_CONTINUE)
resolution = snd_timer_resolution(ti);
@@ -1156,14 +1156,14 @@ static void snd_timer_user_tinterrupt(snd_timer_instance_t *timeri,
struct timespec tstamp;
int prev, append = 0;
- snd_timestamp_zero(&tstamp);
+ memset(&tstamp, 0, sizeof(tstamp));
spin_lock(&tu->qlock);
if ((tu->filter & ((1 << SNDRV_TIMER_EVENT_RESOLUTION)|(1 << SNDRV_TIMER_EVENT_TICK))) == 0) {
spin_unlock(&tu->qlock);
return;
}
if (tu->last_resolution != resolution || ticks > 0)
- snd_timestamp_now(&tstamp, 1);
+ getnstimeofday(&tstamp);
if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && tu->last_resolution != resolution) {
r1.event = SNDRV_TIMER_EVENT_RESOLUTION;
r1.tstamp = tstamp;