aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/timer.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/sound/timer.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/sound/timer.h')
-rw-r--r--include/sound/timer.h157
1 files changed, 157 insertions, 0 deletions
diff --git a/include/sound/timer.h b/include/sound/timer.h
new file mode 100644
index 000000000000..57fde990606e
--- /dev/null
+++ b/include/sound/timer.h
@@ -0,0 +1,157 @@
1#ifndef __SOUND_TIMER_H
2#define __SOUND_TIMER_H
3
4/*
5 * Timer abstract layer
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>,
7 * Abramo Bagnara <abramo@alsa-project.org>
8 *
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26#include <sound/asound.h>
27#include <linux/interrupt.h>
28
29typedef enum sndrv_timer_class snd_timer_class_t;
30typedef enum sndrv_timer_slave_class snd_timer_slave_class_t;
31typedef enum sndrv_timer_global snd_timer_global_t;
32typedef struct sndrv_timer_id snd_timer_id_t;
33typedef struct sndrv_timer_ginfo snd_timer_ginfo_t;
34typedef struct sndrv_timer_gparams snd_timer_gparams_t;
35typedef struct sndrv_timer_gstatus snd_timer_gstatus_t;
36typedef struct sndrv_timer_select snd_timer_select_t;
37typedef struct sndrv_timer_info snd_timer_info_t;
38typedef struct sndrv_timer_params snd_timer_params_t;
39typedef struct sndrv_timer_status snd_timer_status_t;
40typedef struct sndrv_timer_read snd_timer_read_t;
41typedef struct sndrv_timer_tread snd_timer_tread_t;
42
43#define snd_timer_chip(timer) ((timer)->private_data)
44
45#define SNDRV_TIMER_DEVICES 16
46
47#define SNDRV_TIMER_DEV_FLG_PCM 0x10000000
48
49#define SNDRV_TIMER_HW_AUTO 0x00000001 /* auto trigger is supported */
50#define SNDRV_TIMER_HW_STOP 0x00000002 /* call stop before start */
51#define SNDRV_TIMER_HW_SLAVE 0x00000004 /* only slave timer (variable resolution) */
52#define SNDRV_TIMER_HW_FIRST 0x00000008 /* first tick can be incomplete */
53#define SNDRV_TIMER_HW_TASKLET 0x00000010 /* timer is called from tasklet */
54
55#define SNDRV_TIMER_IFLG_SLAVE 0x00000001
56#define SNDRV_TIMER_IFLG_RUNNING 0x00000002
57#define SNDRV_TIMER_IFLG_START 0x00000004
58#define SNDRV_TIMER_IFLG_AUTO 0x00000008 /* auto restart */
59#define SNDRV_TIMER_IFLG_FAST 0x00000010 /* fast callback (do not use tasklet) */
60#define SNDRV_TIMER_IFLG_CALLBACK 0x00000020 /* timer callback is active */
61#define SNDRV_TIMER_IFLG_EXCLUSIVE 0x00000040 /* exclusive owner - no more instances */
62#define SNDRV_TIMER_IFLG_EARLY_EVENT 0x00000080 /* write early event to the poll queue */
63
64#define SNDRV_TIMER_FLG_CHANGE 0x00000001
65#define SNDRV_TIMER_FLG_RESCHED 0x00000002 /* need reschedule */
66
67typedef void (*snd_timer_callback_t) (snd_timer_instance_t * timeri, unsigned long ticks, unsigned long resolution);
68typedef void (*snd_timer_ccallback_t) (snd_timer_instance_t * timeri, enum sndrv_timer_event event,
69 struct timespec * tstamp, unsigned long resolution);
70
71struct _snd_timer_hardware {
72 /* -- must be filled with low-level driver */
73 unsigned int flags; /* various flags */
74 unsigned long resolution; /* average timer resolution for one tick in nsec */
75 unsigned long resolution_min; /* minimal resolution */
76 unsigned long resolution_max; /* maximal resolution */
77 unsigned long ticks; /* max timer ticks per interrupt */
78 /* -- low-level functions -- */
79 int (*open) (snd_timer_t * timer);
80 int (*close) (snd_timer_t * timer);
81 unsigned long (*c_resolution) (snd_timer_t * timer);
82 int (*start) (snd_timer_t * timer);
83 int (*stop) (snd_timer_t * timer);
84 int (*set_period) (snd_timer_t * timer, unsigned long period_num, unsigned long period_den);
85 int (*precise_resolution) (snd_timer_t * timer, unsigned long *num, unsigned long *den);
86};
87
88struct _snd_timer {
89 snd_timer_class_t tmr_class;
90 snd_card_t *card;
91 int tmr_device;
92 int tmr_subdevice;
93 char id[64];
94 char name[80];
95 unsigned int flags;
96 int running; /* running instances */
97 unsigned long sticks; /* schedule ticks */
98 void *private_data;
99 void (*private_free) (snd_timer_t *timer);
100 struct _snd_timer_hardware hw;
101 spinlock_t lock;
102 struct list_head device_list;
103 struct list_head open_list_head;
104 struct list_head active_list_head;
105 struct list_head ack_list_head;
106 struct list_head sack_list_head; /* slow ack list head */
107 struct tasklet_struct task_queue;
108};
109
110struct _snd_timer_instance {
111 snd_timer_t * timer;
112 char *owner;
113 unsigned int flags;
114 void *private_data;
115 void (*private_free) (snd_timer_instance_t *ti);
116 snd_timer_callback_t callback;
117 snd_timer_ccallback_t ccallback;
118 void *callback_data;
119 unsigned long ticks; /* auto-load ticks when expired */
120 unsigned long cticks; /* current ticks */
121 unsigned long pticks; /* accumulated ticks for callback */
122 unsigned long resolution; /* current resolution for tasklet */
123 unsigned long lost; /* lost ticks */
124 snd_timer_slave_class_t slave_class;
125 unsigned int slave_id;
126 struct list_head open_list;
127 struct list_head active_list;
128 struct list_head ack_list;
129 struct list_head slave_list_head;
130 struct list_head slave_active_head;
131 snd_timer_instance_t *master;
132};
133
134/*
135 * Registering
136 */
137
138extern int snd_timer_new(snd_card_t *card, char *id, snd_timer_id_t *tid, snd_timer_t ** rtimer);
139extern void snd_timer_notify(snd_timer_t *timer, enum sndrv_timer_event event, struct timespec *tstamp);
140extern int snd_timer_global_new(char *id, int device, snd_timer_t **rtimer);
141extern int snd_timer_global_free(snd_timer_t *timer);
142extern int snd_timer_global_register(snd_timer_t *timer);
143extern int snd_timer_global_unregister(snd_timer_t *timer);
144
145extern int snd_timer_open(snd_timer_instance_t ** ti, char *owner, snd_timer_id_t *tid, unsigned int slave_id);
146extern int snd_timer_close(snd_timer_instance_t * timeri);
147extern unsigned long snd_timer_resolution(snd_timer_instance_t * timeri);
148extern int snd_timer_start(snd_timer_instance_t * timeri, unsigned int ticks);
149extern int snd_timer_stop(snd_timer_instance_t * timeri);
150extern int snd_timer_continue(snd_timer_instance_t * timeri);
151extern int snd_timer_pause(snd_timer_instance_t * timeri);
152
153extern void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left);
154
155extern unsigned int snd_timer_system_resolution(void);
156
157#endif /* __SOUND_TIMER_H */