diff options
Diffstat (limited to 'include/sound/control.h')
-rw-r--r-- | include/sound/control.h | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/include/sound/control.h b/include/sound/control.h new file mode 100644 index 000000000000..7b9444cd02f4 --- /dev/null +++ b/include/sound/control.h | |||
@@ -0,0 +1,162 @@ | |||
1 | #ifndef __SOUND_CONTROL_H | ||
2 | #define __SOUND_CONTROL_H | ||
3 | |||
4 | /* | ||
5 | * Header file for control interface | ||
6 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> | ||
7 | * | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <sound/asound.h> | ||
26 | |||
27 | typedef struct sndrv_aes_iec958 snd_aes_iec958_t; | ||
28 | typedef struct sndrv_ctl_card_info snd_ctl_card_info_t; | ||
29 | typedef enum sndrv_ctl_elem_type snd_ctl_elem_type_t; | ||
30 | typedef enum sndrv_ctl_elem_iface snd_ctl_elem_iface_t; | ||
31 | typedef struct sndrv_ctl_elem_id snd_ctl_elem_id_t; | ||
32 | typedef struct sndrv_ctl_elem_list snd_ctl_elem_list_t; | ||
33 | typedef struct sndrv_ctl_elem_info snd_ctl_elem_info_t; | ||
34 | typedef struct sndrv_ctl_elem_value snd_ctl_elem_value_t; | ||
35 | typedef enum sndrv_ctl_event_type snd_ctl_event_type_t; | ||
36 | typedef struct sndrv_ctl_event snd_ctl_event_t; | ||
37 | |||
38 | #define snd_kcontrol_chip(kcontrol) ((kcontrol)->private_data) | ||
39 | |||
40 | typedef int (snd_kcontrol_info_t) (snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo); | ||
41 | typedef int (snd_kcontrol_get_t) (snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); | ||
42 | typedef int (snd_kcontrol_put_t) (snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); | ||
43 | |||
44 | typedef struct _snd_kcontrol_new { | ||
45 | snd_ctl_elem_iface_t iface; /* interface identifier */ | ||
46 | unsigned int device; /* device/client number */ | ||
47 | unsigned int subdevice; /* subdevice (substream) number */ | ||
48 | unsigned char *name; /* ASCII name of item */ | ||
49 | unsigned int index; /* index of item */ | ||
50 | unsigned int access; /* access rights */ | ||
51 | unsigned int count; /* count of same elements */ | ||
52 | snd_kcontrol_info_t *info; | ||
53 | snd_kcontrol_get_t *get; | ||
54 | snd_kcontrol_put_t *put; | ||
55 | unsigned long private_value; | ||
56 | } snd_kcontrol_new_t; | ||
57 | |||
58 | typedef struct _snd_kcontrol_volatile { | ||
59 | snd_ctl_file_t *owner; /* locked */ | ||
60 | pid_t owner_pid; | ||
61 | unsigned int access; /* access rights */ | ||
62 | } snd_kcontrol_volatile_t; | ||
63 | |||
64 | struct _snd_kcontrol { | ||
65 | struct list_head list; /* list of controls */ | ||
66 | snd_ctl_elem_id_t id; | ||
67 | unsigned int count; /* count of same elements */ | ||
68 | snd_kcontrol_info_t *info; | ||
69 | snd_kcontrol_get_t *get; | ||
70 | snd_kcontrol_put_t *put; | ||
71 | unsigned long private_value; | ||
72 | void *private_data; | ||
73 | void (*private_free)(snd_kcontrol_t *kcontrol); | ||
74 | snd_kcontrol_volatile_t vd[0]; /* volatile data */ | ||
75 | }; | ||
76 | |||
77 | #define snd_kcontrol(n) list_entry(n, snd_kcontrol_t, list) | ||
78 | |||
79 | typedef struct _snd_kctl_event { | ||
80 | struct list_head list; /* list of events */ | ||
81 | snd_ctl_elem_id_t id; | ||
82 | unsigned int mask; | ||
83 | } snd_kctl_event_t; | ||
84 | |||
85 | #define snd_kctl_event(n) list_entry(n, snd_kctl_event_t, list) | ||
86 | |||
87 | struct _snd_ctl_file { | ||
88 | struct list_head list; /* list of all control files */ | ||
89 | snd_card_t *card; | ||
90 | pid_t pid; | ||
91 | int prefer_pcm_subdevice; | ||
92 | int prefer_rawmidi_subdevice; | ||
93 | wait_queue_head_t change_sleep; | ||
94 | spinlock_t read_lock; | ||
95 | struct fasync_struct *fasync; | ||
96 | int subscribed; /* read interface is activated */ | ||
97 | struct list_head events; /* waiting events for read */ | ||
98 | }; | ||
99 | |||
100 | #define snd_ctl_file(n) list_entry(n, snd_ctl_file_t, list) | ||
101 | |||
102 | typedef int (*snd_kctl_ioctl_func_t) (snd_card_t * card, | ||
103 | snd_ctl_file_t * control, | ||
104 | unsigned int cmd, unsigned long arg); | ||
105 | |||
106 | void snd_ctl_notify(snd_card_t * card, unsigned int mask, snd_ctl_elem_id_t * id); | ||
107 | |||
108 | snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * kcontrol, unsigned int access); | ||
109 | snd_kcontrol_t *snd_ctl_new1(snd_kcontrol_new_t * kcontrolnew, void * private_data); | ||
110 | void snd_ctl_free_one(snd_kcontrol_t * kcontrol); | ||
111 | int snd_ctl_add(snd_card_t * card, snd_kcontrol_t * kcontrol); | ||
112 | int snd_ctl_remove(snd_card_t * card, snd_kcontrol_t * kcontrol); | ||
113 | int snd_ctl_remove_id(snd_card_t * card, snd_ctl_elem_id_t *id); | ||
114 | int snd_ctl_rename_id(snd_card_t * card, snd_ctl_elem_id_t *src_id, snd_ctl_elem_id_t *dst_id); | ||
115 | snd_kcontrol_t *snd_ctl_find_numid(snd_card_t * card, unsigned int numid); | ||
116 | snd_kcontrol_t *snd_ctl_find_id(snd_card_t * card, snd_ctl_elem_id_t *id); | ||
117 | |||
118 | int snd_ctl_create(snd_card_t *card); | ||
119 | |||
120 | int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn); | ||
121 | int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn); | ||
122 | #ifdef CONFIG_COMPAT | ||
123 | int snd_ctl_register_ioctl_compat(snd_kctl_ioctl_func_t fcn); | ||
124 | int snd_ctl_unregister_ioctl_compat(snd_kctl_ioctl_func_t fcn); | ||
125 | #else | ||
126 | #define snd_ctl_register_ioctl_compat(fcn) | ||
127 | #define snd_ctl_unregister_ioctl_compat(fcn) | ||
128 | #endif | ||
129 | |||
130 | int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t *control); | ||
131 | int snd_ctl_elem_write(snd_card_t *card, snd_ctl_file_t *file, snd_ctl_elem_value_t *control); | ||
132 | |||
133 | static inline unsigned int snd_ctl_get_ioffnum(snd_kcontrol_t *kctl, snd_ctl_elem_id_t *id) | ||
134 | { | ||
135 | return id->numid - kctl->id.numid; | ||
136 | } | ||
137 | |||
138 | static inline unsigned int snd_ctl_get_ioffidx(snd_kcontrol_t *kctl, snd_ctl_elem_id_t *id) | ||
139 | { | ||
140 | return id->index - kctl->id.index; | ||
141 | } | ||
142 | |||
143 | static inline unsigned int snd_ctl_get_ioff(snd_kcontrol_t *kctl, snd_ctl_elem_id_t *id) | ||
144 | { | ||
145 | if (id->numid) { | ||
146 | return snd_ctl_get_ioffnum(kctl, id); | ||
147 | } else { | ||
148 | return snd_ctl_get_ioffidx(kctl, id); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | static inline snd_ctl_elem_id_t *snd_ctl_build_ioff(snd_ctl_elem_id_t *dst_id, | ||
153 | snd_kcontrol_t *src_kctl, | ||
154 | unsigned int offset) | ||
155 | { | ||
156 | *dst_id = src_kctl->id; | ||
157 | dst_id->index += offset; | ||
158 | dst_id->numid += offset; | ||
159 | return dst_id; | ||
160 | } | ||
161 | |||
162 | #endif /* __SOUND_CONTROL_H */ | ||