sound/core/seq/seq_timer.h
Source file repositories/reference/linux-study-clean/sound/core/seq/seq_timer.h
File Facts
- System
- Linux kernel
- Corpus path
sound/core/seq/seq_timer.h- Extension
.h- Size
- 4060 bytes
- Lines
- 135
- Domain
- Driver Families
- Bucket
- sound/core
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sound/timer.hsound/seq_kernel.h
Detected Declarations
struct snd_seq_timer_tickstruct snd_seq_timerstruct snd_seq_queuefunction snd_seq_timer_update_tickfunction snd_seq_compare_tick_timefunction snd_seq_compare_real_timefunction snd_seq_sanity_real_timefunction snd_seq_inc_real_timefunction snd_seq_inc_time_nsec
Annotated Snippet
struct snd_seq_timer_tick {
snd_seq_tick_time_t cur_tick; /* current tick */
unsigned long resolution; /* time per tick in nsec */
unsigned long fraction; /* current time per tick in nsec */
};
struct snd_seq_timer {
/* ... tempo / offset / running state */
unsigned int running:1, /* running state of queue */
initialized:1; /* timer is initialized */
unsigned int tempo; /* current tempo, us/tick */
int ppq; /* time resolution, ticks/quarter */
snd_seq_real_time_t cur_time; /* current time */
struct snd_seq_timer_tick tick; /* current tick */
int tick_updated;
int type; /* timer type */
struct snd_timer_id alsa_id; /* ALSA's timer ID */
struct snd_timer_instance *timeri; /* timer instance */
unsigned int ticks;
unsigned long preferred_resolution; /* timer resolution, ticks/sec */
unsigned int skew;
unsigned int skew_base;
unsigned int tempo_base;
struct timespec64 last_update; /* time of last clock update, used for interpolation */
spinlock_t lock;
};
/* create new timer (constructor) */
struct snd_seq_timer *snd_seq_timer_new(void);
/* delete timer (destructor) */
void snd_seq_timer_delete(struct snd_seq_timer **tmr);
/* */
static inline void snd_seq_timer_update_tick(struct snd_seq_timer_tick *tick,
unsigned long resolution)
{
if (tick->resolution > 0) {
tick->fraction += resolution;
tick->cur_tick += (unsigned int)(tick->fraction / tick->resolution);
tick->fraction %= tick->resolution;
}
}
/* compare timestamp between events */
/* return 1 if a >= b; otherwise return 0 */
static inline int snd_seq_compare_tick_time(snd_seq_tick_time_t *a, snd_seq_tick_time_t *b)
{
/* compare ticks */
return (*a >= *b);
}
static inline int snd_seq_compare_real_time(snd_seq_real_time_t *a, snd_seq_real_time_t *b)
{
/* compare real time */
if (a->tv_sec > b->tv_sec)
return 1;
if ((a->tv_sec == b->tv_sec) && (a->tv_nsec >= b->tv_nsec))
return 1;
return 0;
}
static inline void snd_seq_sanity_real_time(snd_seq_real_time_t *tm)
{
while (tm->tv_nsec >= 1000000000) {
/* roll-over */
tm->tv_nsec -= 1000000000;
tm->tv_sec++;
}
}
/* increment timestamp */
static inline void snd_seq_inc_real_time(snd_seq_real_time_t *tm, snd_seq_real_time_t *inc)
{
tm->tv_sec += inc->tv_sec;
tm->tv_nsec += inc->tv_nsec;
snd_seq_sanity_real_time(tm);
}
Annotation
- Immediate include surface: `sound/timer.h`, `sound/seq_kernel.h`.
- Detected declarations: `struct snd_seq_timer_tick`, `struct snd_seq_timer`, `struct snd_seq_queue`, `function snd_seq_timer_update_tick`, `function snd_seq_compare_tick_time`, `function snd_seq_compare_real_time`, `function snd_seq_sanity_real_time`, `function snd_seq_inc_real_time`, `function snd_seq_inc_time_nsec`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.