remove [64] cleanup TODO
[trinity.git] / ioctls / snd.c
blob69f2d64cf90855f2c1cdc071f94e23081cebb4b1
1 #include "config.h"
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <inttypes.h>
6 #include <linux/types.h>
7 #include <linux/ioctl.h>
8 #include <sound/asound.h>
9 #include <sound/asound_fm.h>
10 #include <sound/asequencer.h>
11 #include <sound/hdsp.h>
12 #include <sound/hdspm.h>
13 #include <sound/sb16_csp.h>
14 #include <sound/sfnt_info.h>
15 #ifdef USE_SNDDRV_COMPRESS_OFFLOAD
16 #include <sound/compress_offload.h>
17 #endif
19 /* would use this, but the header uses DECLARE_BITMAP() from the kernel */
20 /* #include <sound/emu10k1.h> */
22 #include "ioctls.h"
23 #include "utils.h"
25 /* include/sound/hda_hwdep.h */
26 struct hda_verb_ioctl {
27 __u32 verb; /* HDA_VERB() */
28 __u32 res; /* response */
30 #define HDA_IOCTL_PVERSION _IOR('H', 0x10, int)
31 #define HDA_IOCTL_VERB_WRITE _IOWR('H', 0x11, struct hda_verb_ioctl)
32 #define HDA_IOCTL_GET_WCAP _IOWR('H', 0x12, struct hda_verb_ioctl)
34 static const struct ioctl sound_ioctls[] = {
35 IOCTL(SNDRV_SEQ_IOCTL_PVERSION),
36 IOCTL(SNDRV_SEQ_IOCTL_CLIENT_ID),
37 IOCTL(SNDRV_SEQ_IOCTL_SYSTEM_INFO),
38 IOCTL(SNDRV_SEQ_IOCTL_RUNNING_MODE),
39 IOCTL(SNDRV_SEQ_IOCTL_GET_CLIENT_INFO),
40 IOCTL(SNDRV_SEQ_IOCTL_SET_CLIENT_INFO),
41 IOCTL(SNDRV_SEQ_IOCTL_CREATE_PORT),
42 IOCTL(SNDRV_SEQ_IOCTL_DELETE_PORT),
43 IOCTL(SNDRV_SEQ_IOCTL_GET_PORT_INFO),
44 IOCTL(SNDRV_SEQ_IOCTL_SET_PORT_INFO),
45 IOCTL(SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT),
46 IOCTL(SNDRV_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V_DM_FM_IOCTL_PLAY_NOTE),
73 IOCTL(SNDRV_DM_FM_IOCTL_SET_VOICE),
74 IOCTL(SNDRV_DM_FM_IOCTL_SET_PARAMS),
75 IOCTL(SNDRV_DM_FM_IOCTL_SET_MODE),
76 IOCTL(SNDRV_DM_FM_IOCTL_SET_CONNECTION),
77 IOCTL(SNDRV_DM_FM_IOCTL_CLEAR_PATCHES),
78 IOCTL(SNDRV_HWDEP_IOCTL_PVERSION),
79 IOCTL(SNDRV_HWDEP_IOCTL_INFO),
80 IOCTL(SNDRV_HWDEP_IOCTL_DSP_STATUS),
81 IOCTL(SNDRV_HWDEP_IOCTL_DSP_LOAD),
82 IOCTL(SNDRV_PCM_IOCTL_PVERSION),
83 IOCTL(SNDRV_PCM_IOCTL_INFO),
84 IOCTL(SNDRV_PCM_IOCTL_TSTAMP),
85 IOCTL(SNDRV_PCM_IOCTL_TTSTAMP),
86 IOCTL(SNDRV_PCM_IOCTL_HW_REFINE),
87 IOCTL(SNDRV_PCM_IOCTL_HW_PARAMS),
88 IOCTL(SNDRV_PCM_IOCTL_HW_FREE),
89 IOCTL(SNDRV_PCM_IOCTL_SW_PARAMS),
90 IOCTL(SNDRV_PCM_IOCTL_STATUS),
91 IOCTL(SNDRV_PCM_IOCTL_DELAY),
92 IOCTL(SNDRV_PCM_IOCTL_HWSYNC),
93 IOCTL(SNDRV_PCM_IOCTL_SYNC_PTR),
94 IOCTL(SNDRV_PCM_IOCTL_CHANNEL_INFO),
95 IOCTL(SNDRV_PCM_IOCTL_PREPARE),
96 IOCTL(SNDRV_PCM_IOCTL_RESET),
97 IOCTL(SNDRV_PCM_IOCTL_START),
98 IOCTL(SNDRV_PCM_IOCTL_DROP),
99 IOCTL(SNDRV_PCM_IOCTL_DRAIN),
100 IOCTL(SNDRV_PCM_IOCTL_PAUSE),
101 IOCTL(SNDRV_PCM_IOCTL_REWIND),
102 IOCTL(SNDRV_PCM_IOCTL_RESUME),
103 IOCTL(SNDRV_PCM_IOCTL_XRUN),
104 IOCTL(SNDRV_PCM_IOCTL_FORWARD),
105 IOCTL(SNDRV_PCM_IOCTL_WRITEI_FRAMES),
106 IOCTL(SNDRV_PCM_IOCTL_READI_FRAMES),
107 IOCTL(SNDRV_PCM_IOCTL_WRITEN_FRAMES),
108 IOCTL(SNDRV_PCM_IOCTL_READN_FRAMES),
109 IOCTL(SNDRV_PCM_IOCTL_LINK),
110 IOCTL(SNDRV_PCM_IOCTL_UNLINK),
111 IOCTL(SNDRV_RAWMIDI_IOCTL_PVERSION),
112 IOCTL(SNDRV_RAWMIDI_IOCTL_INFO),
113 IOCTL(SNDRV_RAWMIDI_IOCTL_PARAMS),
114 IOCTL(SNDRV_RAWMIDI_IOCTL_STATUS),
115 IOCTL(SNDRV_RAWMIDI_IOCTL_DROP),
116 IOCTL(SNDRV_RAWMIDI_IOCTL_DRAIN),
117 IOCTL(SNDRV_TIMER_IOCTL_PVERSION),
118 IOCTL(SNDRV_TIMER_IOCTL_NEXT_DEVICE),
119 IOCTL(SNDRV_TIMER_IOCTL_TREAD),
120 IOCTL(SNDRV_TIMER_IOCTL_GINFO),
121 IOCTL(SNDRV_TIMER_IOCTL_GPARAMS),
122 IOCTL(SNDRV_TIMER_IOCTL_GSTATUS),
123 IOCTL(SNDRV_TIMER_IOCTL_SELECT),
124 IOCTL(SNDRV_TIMER_IOCTL_INFO),
125 IOCTL(SNDRV_TIMER_IOCTL_PARAMS),
126 IOCTL(SNDRV_TIMER_IOCTL_STATUS),
127 IOCTL(SNDRV_TIMER_IOCTL_START),
128 IOCTL(SNDRV_TIMER_IOCTL_STOP),
129 IOCTL(SNDRV_TIMER_IOCTL_CONTINUE),
130 IOCTL(SNDRV_TIMER_IOCTL_PAUSE),
131 IOCTL(SNDRV_CTL_IOCTL_PVERSION),
132 IOCTL(SNDRV_CTL_IOCTL_CARD_INFO),
133 IOCTL(SNDRV_CTL_IOCTL_ELEM_LIST),
134 IOCTL(SNDRV_CTL_IOCTL_ELEM_INFO),
135 IOCTL(SNDRV_CTL_IOCTL_ELEM_READ),
136 IOCTL(SNDRV_CTL_IOCTL_ELEM_WRITE),
137 IOCTL(SNDRV_CTL_IOCTL_ELEM_LOCK),
138 IOCTL(SNDRV_CTL_IOCTL_ELEM_UNLOCK),
139 IOCTL(SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS),
140 IOCTL(SNDRV_CTL_IOCTL_ELEM_ADD),
141 IOCTL(SNDRV_CTL_IOCTL_ELEM_REPLACE),
142 IOCTL(SNDRV_CTL_IOCTL_ELEM_REMOVE),
143 IOCTL(SNDRV_CTL_IOCTL_TLV_READ),
144 IOCTL(SNDRV_CTL_IOCTL_TLV_WRITE),
145 IOCTL(SNDRV_CTL_IOCTL_TLV_COMMAND),
146 IOCTL(SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE),
147 IOCTL(SNDRV_CTL_IOCTL_HWDEP_INFO),
148 IOCTL(SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE),
149 IOCTL(SNDRV_CTL_IOCTL_PCM_INFO),
150 IOCTL(SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE),
151 IOCTL(SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE),
152 IOCTL(SNDRV_CTL_IOCTL_RAWMIDI_INFO),
153 IOCTL(SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE),
154 IOCTL(SNDRV_CTL_IOCTL_POWER),
155 IOCTL(SNDRV_CTL_IOCTL_POWER_STATE),
156 IOCTL(HDA_IOCTL_PVERSION),
157 IOCTL(HDA_IOCTL_VERB_WRITE),
158 IOCTL(HDA_IOCTL_GET_WCAP),
159 IOCTL(SNDRV_HDSP_IOCTL_GET_PEAK_RMS),
160 IOCTL(SNDRV_HDSP_IOCTL_GET_CONFIG_INFO),
161 IOCTL(SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE),
162 IOCTL(SNDRV_HDSP_IOCTL_GET_VERSION),
163 IOCTL(SNDRV_HDSP_IOCTL_GET_MIXER),
164 IOCTL(SNDRV_HDSP_IOCTL_GET_9632_AEB),
165 IOCTL(SNDRV_HDSPM_IOCTL_GET_VERSION),
166 IOCTL(SNDRV_HDSPM_IOCTL_GET_MIXER),
167 IOCTL(SNDRV_SB_CSP_IOCTL_INFO),
168 IOCTL(SNDRV_SB_CSP_IOCTL_LOAD_CODE),
169 IOCTL(SNDRV_SB_CSP_IOCTL_UNLOAD_CODE),
170 IOCTL(SNDRV_SB_CSP_IOCTL_START),
171 IOCTL(SNDRV_SB_CSP_IOCTL_STOP),
172 IOCTL(SNDRV_SB_CSP_IOCTL_PAUSE),
173 IOCTL(SNDRV_SB_CSP_IOCTL_RESTART),
174 IOCTL(SNDRV_EMUX_IOCTL_VERSION),
175 IOCTL(SNDRV_EMUX_IOCTL_LOAD_PATCH),
176 IOCTL(SNDRV_EMUX_IOCTL_RESET_SAMPLES),
177 IOCTL(SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES),
178 IOCTL(SNDRV_EMUX_IOCTL_MEM_AVAIL),
179 IOCTL(SNDRV_EMUX_IOCTL_MISC_MODE),
182 IOCTL(SNDRV_EMU10K1_IOCTL_INFO),
183 IOCTL(SNDRV_EMU10K1_IOCTL_CODE_POKE),
184 IOCTL(SNDRV_EMU10K1_IOCTL_CODE_PEEK),
185 IOCTL(SNDRV_EMU10K1_IOCTL_TRAM_SETUP),
186 IOCTL(SNDRV_EMU10K1_IOCTL_TRAM_POKE),
187 IOCTL(SNDRV_EMU10K1_IOCTL_TRAM_PEEK),
188 IOCTL(SNDRV_EMU10K1_IOCTL_PCM_POKE),
189 IOCTL(SNDRV_EMU10K1_IOCTL_PCM_PEEK),
190 IOCTL(SNDRV_EMU10K1_IOCTL_PVERSION),
191 IOCTL(SNDRV_EMU10K1_IOCTL_STOP),
192 IOCTL(SNDRV_EMU10K1_IOCTL_CONTINUE),
193 IOCTL(SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER),
194 IOCTL(SNDRV_EMU10K1_IOCTL_SINGLE_STEP),
195 IOCTL(SNDRV_EMU10K1_IOCTL_DBG_READ),
197 { .name = "SNDRV_EMU10K1_IOCTL_INFO", .request = _IOC(_IOC_NONE,'H',0x10,0), },
198 { .name = "SNDRV_EMU10K1_IOCTL_CODE_POKE", .request = _IOC(_IOC_NONE,'H',0x11,0), },
199 { .name = "SNDRV_EMU10K1_IOCTL_CODE_PEEK", .request = _IOC(_IOC_NONE,'H',0x12,0), },
200 { .name = "SNDRV_EMU10K1_IOCTL_TRAM_SETUP", .request = _IOC(_IOC_NONE,'H',0x20,0), },
201 { .name = "SNDRV_EMU10K1_IOCTL_TRAM_POKE", .request = _IOC(_IOC_NONE,'H',0x21,0), },
202 { .name = "SNDRV_EMU10K1_IOCTL_TRAM_PEEK", .request = _IOC(_IOC_NONE,'H',0x22,0), },
203 { .name = "SNDRV_EMU10K1_IOCTL_PCM_POKE", .request = _IOC(_IOC_NONE,'H',0x30,0), },
204 { .name = "SNDRV_EMU10K1_IOCTL_PCM_PEEK", .request = _IOC(_IOC_NONE,'H',0x31,0), },
205 { .name = "SNDRV_EMU10K1_IOCTL_PVERSION", .request = _IOC(_IOC_NONE,'H',0x40,0), },
206 { .name = "SNDRV_EMU10K1_IOCTL_STOP", .request = _IOC(_IOC_NONE,'H',0x80,0), },
207 { .name = "SNDRV_EMU10K1_IOCTL_CONTINUE", .request = _IOC(_IOC_NONE,'H',0x81,0), },
208 { .name = "SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER", .request = _IOC(_IOC_NONE,'H',0x82,0), },
209 { .name = "SNDRV_EMU10K1_IOCTL_SINGLE_STEP", .request = _IOC(_IOC_NONE,'H',0x83,0), },
210 { .name = "SNDRV_EMU10K1_IOCTL_DBG_READ", .request = _IOC(_IOC_NONE,'H',0x84,0), },
212 #ifdef USE_SNDDRV_COMPRESS_OFFLOAD
213 IOCTL(SNDRV_COMPRESS_IOCTL_VERSION),
214 IOCTL(SNDRV_COMPRESS_GET_CAPS),
215 IOCTL(SNDRV_COMPRESS_GET_CODEC_CAPS),
216 IOCTL(SNDRV_COMPRESS_SET_PARAMS),
217 IOCTL(SNDRV_COMPRESS_GET_PARAMS),
218 #ifdef SNDRV_COMPRESS_SET_METADATA
219 IOCTL(SNDRV_COMPRESS_SET_METADATA),
220 #endif
221 #ifdef SNDRV_COMPRESS_GET_METADATA
222 IOCTL(SNDRV_COMPRESS_GET_METADATA),
223 #endif
224 IOCTL(SNDRV_COMPRESS_TSTAMP),
225 IOCTL(SNDRV_COMPRESS_AVAIL),
226 IOCTL(SNDRV_COMPRESS_PAUSE),
227 IOCTL(SNDRV_COMPRESS_RESUME),
228 IOCTL(SNDRV_COMPRESS_START),
229 IOCTL(SNDRV_COMPRESS_STOP),
230 IOCTL(SNDRV_COMPRESS_DRAIN),
231 #ifdef SNDRV_COMPRESS_NEXT_TRACK
232 IOCTL(SNDRV_COMPRESS_NEXT_TRACK),
233 #endif
234 #ifdef SNDRV_COMPRESS_PARTIAL_DRAIN
235 IOCTL(SNDRV_COMPRESS_PARTIAL_DRAIN),
236 #endif
237 #endif /* USE_SNDDRV_COMPRESS_OFFLOAD */
240 static const char *const sound_devs[] = {
241 "sound",
242 "alsa",
245 static const struct ioctl_group sound_grp = {
246 .devtype = DEV_CHAR,
247 .devs = sound_devs,
248 .devs_cnt = ARRAY_SIZE(sound_devs),
249 .sanitise = pick_random_ioctl,
250 .ioctls = sound_ioctls,
251 .ioctls_cnt = ARRAY_SIZE(sound_ioctls),
254 REG_IOCTL_GROUP(sound_grp)