1#ifndef __SOUND_TIMER_H
2#define __SOUND_TIMER_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <sound/asound.h>
27#include <linux/interrupt.h>
28
29#define snd_timer_chip(timer) ((timer)->private_data)
30
31#define SNDRV_TIMER_DEVICES 16
32
33#define SNDRV_TIMER_DEV_FLG_PCM 0x10000000
34
35#define SNDRV_TIMER_HW_AUTO 0x00000001
36#define SNDRV_TIMER_HW_STOP 0x00000002
37#define SNDRV_TIMER_HW_SLAVE 0x00000004
38#define SNDRV_TIMER_HW_FIRST 0x00000008
39#define SNDRV_TIMER_HW_TASKLET 0x00000010
40
41#define SNDRV_TIMER_IFLG_SLAVE 0x00000001
42#define SNDRV_TIMER_IFLG_RUNNING 0x00000002
43#define SNDRV_TIMER_IFLG_START 0x00000004
44#define SNDRV_TIMER_IFLG_AUTO 0x00000008
45#define SNDRV_TIMER_IFLG_FAST 0x00000010
46#define SNDRV_TIMER_IFLG_CALLBACK 0x00000020
47#define SNDRV_TIMER_IFLG_EXCLUSIVE 0x00000040
48#define SNDRV_TIMER_IFLG_EARLY_EVENT 0x00000080
49
50#define SNDRV_TIMER_FLG_CHANGE 0x00000001
51#define SNDRV_TIMER_FLG_RESCHED 0x00000002
52
53struct snd_timer;
54
55struct snd_timer_hardware {
56
57 unsigned int flags;
58 unsigned long resolution;
59 unsigned long resolution_min;
60 unsigned long resolution_max;
61 unsigned long ticks;
62
63 int (*open) (struct snd_timer * timer);
64 int (*close) (struct snd_timer * timer);
65 unsigned long (*c_resolution) (struct snd_timer * timer);
66 int (*start) (struct snd_timer * timer);
67 int (*stop) (struct snd_timer * timer);
68 int (*set_period) (struct snd_timer * timer, unsigned long period_num, unsigned long period_den);
69 int (*precise_resolution) (struct snd_timer * timer, unsigned long *num, unsigned long *den);
70};
71
72struct snd_timer {
73 int tmr_class;
74 struct snd_card *card;
75 struct module *module;
76 int tmr_device;
77 int tmr_subdevice;
78 char id[64];
79 char name[80];
80 unsigned int flags;
81 int running;
82 unsigned long sticks;
83 void *private_data;
84 void (*private_free) (struct snd_timer *timer);
85 struct snd_timer_hardware hw;
86 spinlock_t lock;
87 struct list_head device_list;
88 struct list_head open_list_head;
89 struct list_head active_list_head;
90 struct list_head ack_list_head;
91 struct list_head sack_list_head;
92 struct tasklet_struct task_queue;
93};
94
95struct snd_timer_instance {
96 struct snd_timer *timer;
97 char *owner;
98 unsigned int flags;
99 void *private_data;
100 void (*private_free) (struct snd_timer_instance *ti);
101 void (*callback) (struct snd_timer_instance *timeri,
102 unsigned long ticks, unsigned long resolution);
103 void (*ccallback) (struct snd_timer_instance * timeri,
104 int event,
105 struct timespec * tstamp,
106 unsigned long resolution);
107 void (*disconnect)(struct snd_timer_instance *timeri);
108 void *callback_data;
109 unsigned long ticks;
110 unsigned long cticks;
111 unsigned long pticks;
112 unsigned long resolution;
113 unsigned long lost;
114 int slave_class;
115 unsigned int slave_id;
116 struct list_head open_list;
117 struct list_head active_list;
118 struct list_head ack_list;
119 struct list_head slave_list_head;
120 struct list_head slave_active_head;
121 struct snd_timer_instance *master;
122};
123
124
125
126
127
128int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, struct snd_timer **rtimer);
129void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp);
130int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer);
131int snd_timer_global_free(struct snd_timer *timer);
132int snd_timer_global_register(struct snd_timer *timer);
133
134int snd_timer_open(struct snd_timer_instance **ti, char *owner, struct snd_timer_id *tid, unsigned int slave_id);
135int snd_timer_close(struct snd_timer_instance *timeri);
136unsigned long snd_timer_resolution(struct snd_timer_instance *timeri);
137int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks);
138int snd_timer_stop(struct snd_timer_instance *timeri);
139int snd_timer_continue(struct snd_timer_instance *timeri);
140int snd_timer_pause(struct snd_timer_instance *timeri);
141
142void snd_timer_interrupt(struct snd_timer *timer, unsigned long ticks_left);
143
144#endif
145