0001
0002 #ifndef __SOUND_TIMER_H
0003 #define __SOUND_TIMER_H
0004
0005
0006
0007
0008
0009
0010
0011 #include <sound/asound.h>
0012 #include <linux/interrupt.h>
0013
0014 #define snd_timer_chip(timer) ((timer)->private_data)
0015
0016 #define SNDRV_TIMER_DEVICES 16
0017
0018 #define SNDRV_TIMER_DEV_FLG_PCM 0x10000000
0019
0020 #define SNDRV_TIMER_HW_AUTO 0x00000001
0021 #define SNDRV_TIMER_HW_STOP 0x00000002
0022 #define SNDRV_TIMER_HW_SLAVE 0x00000004
0023 #define SNDRV_TIMER_HW_FIRST 0x00000008
0024 #define SNDRV_TIMER_HW_WORK 0x00000010
0025
0026 #define SNDRV_TIMER_IFLG_SLAVE 0x00000001
0027 #define SNDRV_TIMER_IFLG_RUNNING 0x00000002
0028 #define SNDRV_TIMER_IFLG_START 0x00000004
0029 #define SNDRV_TIMER_IFLG_AUTO 0x00000008
0030 #define SNDRV_TIMER_IFLG_FAST 0x00000010
0031 #define SNDRV_TIMER_IFLG_CALLBACK 0x00000020
0032 #define SNDRV_TIMER_IFLG_EXCLUSIVE 0x00000040
0033 #define SNDRV_TIMER_IFLG_EARLY_EVENT 0x00000080
0034
0035 #define SNDRV_TIMER_FLG_CHANGE 0x00000001
0036 #define SNDRV_TIMER_FLG_RESCHED 0x00000002
0037
0038 struct snd_timer;
0039
0040 struct snd_timer_hardware {
0041
0042 unsigned int flags;
0043 unsigned long resolution;
0044 unsigned long resolution_min;
0045 unsigned long resolution_max;
0046 unsigned long ticks;
0047
0048 int (*open) (struct snd_timer * timer);
0049 int (*close) (struct snd_timer * timer);
0050 unsigned long (*c_resolution) (struct snd_timer * timer);
0051 int (*start) (struct snd_timer * timer);
0052 int (*stop) (struct snd_timer * timer);
0053 int (*set_period) (struct snd_timer * timer, unsigned long period_num, unsigned long period_den);
0054 int (*precise_resolution) (struct snd_timer * timer, unsigned long *num, unsigned long *den);
0055 };
0056
0057 struct snd_timer {
0058 int tmr_class;
0059 struct snd_card *card;
0060 struct module *module;
0061 int tmr_device;
0062 int tmr_subdevice;
0063 char id[64];
0064 char name[80];
0065 unsigned int flags;
0066 int running;
0067 unsigned long sticks;
0068 void *private_data;
0069 void (*private_free) (struct snd_timer *timer);
0070 struct snd_timer_hardware hw;
0071 spinlock_t lock;
0072 struct list_head device_list;
0073 struct list_head open_list_head;
0074 struct list_head active_list_head;
0075 struct list_head ack_list_head;
0076 struct list_head sack_list_head;
0077 struct work_struct task_work;
0078 int max_instances;
0079 int num_instances;
0080 };
0081
0082 struct snd_timer_instance {
0083 struct snd_timer *timer;
0084 char *owner;
0085 unsigned int flags;
0086 void *private_data;
0087 void (*private_free) (struct snd_timer_instance *ti);
0088 void (*callback) (struct snd_timer_instance *timeri,
0089 unsigned long ticks, unsigned long resolution);
0090 void (*ccallback) (struct snd_timer_instance * timeri,
0091 int event,
0092 struct timespec64 * tstamp,
0093 unsigned long resolution);
0094 void (*disconnect)(struct snd_timer_instance *timeri);
0095 void *callback_data;
0096 unsigned long ticks;
0097 unsigned long cticks;
0098 unsigned long pticks;
0099 unsigned long resolution;
0100 unsigned long lost;
0101 int slave_class;
0102 unsigned int slave_id;
0103 struct list_head open_list;
0104 struct list_head active_list;
0105 struct list_head ack_list;
0106 struct list_head slave_list_head;
0107 struct list_head slave_active_head;
0108 struct snd_timer_instance *master;
0109 };
0110
0111
0112
0113
0114
0115 int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, struct snd_timer **rtimer);
0116 void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp);
0117 int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer);
0118 int snd_timer_global_free(struct snd_timer *timer);
0119 int snd_timer_global_register(struct snd_timer *timer);
0120
0121 struct snd_timer_instance *snd_timer_instance_new(const char *owner);
0122 void snd_timer_instance_free(struct snd_timer_instance *timeri);
0123 int snd_timer_open(struct snd_timer_instance *timeri, struct snd_timer_id *tid, unsigned int slave_id);
0124 void snd_timer_close(struct snd_timer_instance *timeri);
0125 unsigned long snd_timer_resolution(struct snd_timer_instance *timeri);
0126 int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks);
0127 int snd_timer_stop(struct snd_timer_instance *timeri);
0128 int snd_timer_continue(struct snd_timer_instance *timeri);
0129 int snd_timer_pause(struct snd_timer_instance *timeri);
0130
0131 void snd_timer_interrupt(struct snd_timer *timer, unsigned long ticks_left);
0132
0133 #endif