1# Copyright 2015 syzkaller project authors. All rights reserved.
2# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
3
4include <sound/asound.h>
5include <sound/asequencer.h>
6
7resource fd_sndseq[fd]
8
9syz_open_dev$sndseq(dev ptr[in, string["/dev/snd/seq"]], id const[0], flags flags[open_flags]) fd_sndseq
10write$sndseq(fd fd_sndseq, data ptr[in, array[snd_seq_event]], len bytesize[data])
11
12ioctl$SNDRV_SEQ_IOCTL_PVERSION(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_PVERSION], arg ptr[out, int32])
13ioctl$SNDRV_SEQ_IOCTL_CLIENT_ID(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_CLIENT_ID], arg ptr[out, int32])
14
15ioctl$SNDRV_SEQ_IOCTL_SYSTEM_INFO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SYSTEM_INFO], arg ptr[in, snd_seq_system_info])
16ioctl$SNDRV_SEQ_IOCTL_RUNNING_MODE(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_RUNNING_MODE], arg ptr[in, snd_seq_running_info])
17ioctl$SNDRV_SEQ_IOCTL_GET_CLIENT_INFO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_CLIENT_INFO], arg ptr[out, snd_seq_client_info])
18ioctl$SNDRV_SEQ_IOCTL_SET_CLIENT_INFO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SET_CLIENT_INFO], arg ptr[in, snd_seq_client_info])
19ioctl$SNDRV_SEQ_IOCTL_CREATE_PORT(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_CREATE_PORT], arg ptr[in, snd_seq_port_info])
20ioctl$SNDRV_SEQ_IOCTL_DELETE_PORT(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_DELETE_PORT], arg ptr[in, snd_seq_port_info])
21ioctl$SNDRV_SEQ_IOCTL_GET_PORT_INFO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_PORT_INFO], arg ptr[out, snd_seq_port_info])
22ioctl$SNDRV_SEQ_IOCTL_SET_PORT_INFO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SET_PORT_INFO], arg ptr[in, snd_seq_port_info])
23ioctl$SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT], arg ptr[in, snd_seq_port_subscribe])
24ioctl$SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT], arg ptr[in, snd_seq_port_subscribe])
25ioctl$SNDRV_SEQ_IOCTL_CREATE_QUEUE(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_CREATE_QUEUE], arg ptr[in, snd_seq_queue_info])
26ioctl$SNDRV_SEQ_IOCTL_DELETE_QUEUE(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_DELETE_QUEUE], arg ptr[in, snd_seq_queue_info])
27ioctl$SNDRV_SEQ_IOCTL_GET_QUEUE_INFO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_QUEUE_INFO], arg ptr[in, snd_seq_queue_info])
28ioctl$SNDRV_SEQ_IOCTL_SET_QUEUE_INFO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SET_QUEUE_INFO], arg ptr[in, snd_seq_queue_info])
29ioctl$SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE], arg ptr[in, snd_seq_queue_info])
30ioctl$SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS], arg ptr[in, snd_seq_queue_status])
31ioctl$SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO], arg ptr[out, snd_seq_queue_status])
32ioctl$SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO], arg ptr[in, snd_seq_queue_status])
33ioctl$SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER], arg ptr[in, snd_seq_queue_timer])
34ioctl$SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER], arg ptr[in, snd_seq_queue_timer])
35ioctl$SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT], arg ptr[in, snd_seq_queue_client])
36ioctl$SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT], arg ptr[in, snd_seq_queue_client])
37ioctl$SNDRV_SEQ_IOCTL_GET_CLIENT_POOL(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_CLIENT_POOL], arg ptr[in, snd_seq_client_pool])
38ioctl$SNDRV_SEQ_IOCTL_SET_CLIENT_POOL(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_SET_CLIENT_POOL], arg ptr[in, snd_seq_client_pool])
39ioctl$SNDRV_SEQ_IOCTL_REMOVE_EVENTS(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_REMOVE_EVENTS], arg ptr[in, snd_seq_remove_events])
40ioctl$SNDRV_SEQ_IOCTL_QUERY_SUBS(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_QUERY_SUBS], arg ptr[in, snd_seq_query_subs])
41ioctl$SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION], arg ptr[in, snd_seq_port_subscribe])
42ioctl$SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT], arg ptr[in, snd_seq_client_info])
43ioctl$SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT(fd fd_sndseq, cmd const[SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT], arg ptr[in, snd_seq_port_info])
44
45snd_seq_client_type = NO_CLIENT, USER_CLIENT, KERNEL_CLIENT
46snd_seq_filter = SNDRV_SEQ_FILTER_BROADCAST, SNDRV_SEQ_FILTER_MULTICAST, SNDRV_SEQ_FILTER_BOUNCE, SNDRV_SEQ_FILTER_USE_EVENT
47snd_seq_port_cap = SNDRV_SEQ_PORT_CAP_READ, SNDRV_SEQ_PORT_CAP_WRITE, SNDRV_SEQ_PORT_CAP_SYNC_READ, SNDRV_SEQ_PORT_CAP_SYNC_WRITE, SNDRV_SEQ_PORT_CAP_DUPLEX, SNDRV_SEQ_PORT_CAP_SUBS_READ, SNDRV_SEQ_PORT_CAP_SUBS_WRITE, SNDRV_SEQ_PORT_CAP_NO_EXPORT
48snd_seq_port_type = SNDRV_SEQ_PORT_TYPE_SPECIFIC, SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC, SNDRV_SEQ_PORT_TYPE_MIDI_GM, SNDRV_SEQ_PORT_TYPE_MIDI_GS, SNDRV_SEQ_PORT_TYPE_MIDI_XG, SNDRV_SEQ_PORT_TYPE_MIDI_MT32, SNDRV_SEQ_PORT_TYPE_MIDI_GM2, SNDRV_SEQ_PORT_TYPE_SYNTH, SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE, SNDRV_SEQ_PORT_TYPE_SAMPLE, SNDRV_SEQ_PORT_TYPE_HARDWARE, SNDRV_SEQ_PORT_TYPE_SOFTWARE, SNDRV_SEQ_PORT_TYPE_SYNTHESIZER, SNDRV_SEQ_PORT_TYPE_PORT, SNDRV_SEQ_PORT_TYPE_APPLICATION
49snd_seq_port_flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT, SNDRV_SEQ_PORT_FLG_TIMESTAMP, SNDRV_SEQ_PORT_FLG_TIME_REAL
50snd_seq_sub_flags = SNDRV_SEQ_PORT_SUBS_EXCLUSIVE, SNDRV_SEQ_PORT_SUBS_TIMESTAMP, SNDRV_SEQ_PORT_SUBS_TIME_REAL
51snd_seq_timer_type = SNDRV_SEQ_TIMER_ALSA, SNDRV_SEQ_TIMER_MIDI_CLOCK, SNDRV_SEQ_TIMER_MIDI_TICK
52snd_seq_remove_mode = SNDRV_SEQ_REMOVE_INPUT, SNDRV_SEQ_REMOVE_OUTPUT, SNDRV_SEQ_REMOVE_DEST, SNDRV_SEQ_REMOVE_DEST_CHANNEL, SNDRV_SEQ_REMOVE_TIME_BEFORE, SNDRV_SEQ_REMOVE_TIME_AFTER, SNDRV_SEQ_REMOVE_TIME_TICK, SNDRV_SEQ_REMOVE_EVENT_TYPE, SNDRV_SEQ_REMOVE_IGNORE_OFF, SNDRV_SEQ_REMOVE_TAG_MATCH
53snd_timer_class = SNDRV_TIMER_CLASS_NONE, SNDRV_TIMER_CLASS_SLAVE, SNDRV_TIMER_CLASS_GLOBAL, SNDRV_TIMER_CLASS_CARD, SNDRV_TIMER_CLASS_PCM
54snd_timer_sclass = SNDRV_TIMER_SCLASS_NONE, SNDRV_TIMER_SCLASS_APPLICATION, SNDRV_TIMER_SCLASS_SEQUENCER, SNDRV_TIMER_SCLASS_OSS_SEQUENCER
55snd_timer_dev = SNDRV_TIMER_GLOBAL_SYSTEM, SNDRV_TIMER_GLOBAL_RTC, SNDRV_TIMER_GLOBAL_HPET, SNDRV_TIMER_GLOBAL_HRTIMER
56snd_seq_subs_type = SNDRV_SEQ_QUERY_SUBS_READ, SNDRV_SEQ_QUERY_SUBS_WRITE
57
58snd_seq_client_name = "client0", "client1"
59snd_seq_port_name = "port0", "port1"
60snd_seq_queue_name = "queue0", "queue1"
61
62snd_seq_system_info {
63	queues	int32
64	clients	int32
65	ports	int32
66	channel	int32
67	nclient	int32
68	nqueue	int32
69	pad	array[const[0, int8], 24]
70}
71
72snd_seq_running_info {
73	client	int8
74	bigend	int8
75	cpumode	int8
76	pad1	const[0, int8]
77	pad2	array[const[0, int8], 12]
78}
79
80snd_seq_client_info {
81	client	int32
82	type	flags[snd_seq_client_type, int32]
83	name	string[snd_seq_client_name, 64]
84	filter	flags[snd_seq_filter, int32]
85	mfilt	array[int8, 8]
86	evfilt	array[int8, 32]
87	nports	int32
88	lost	int32
89	pad	array[const[0, int8], 64]
90}
91
92snd_seq_port_info {
93	addr	snd_seq_addr
94	name	string[snd_seq_port_name, 64]
95	cap	flags[snd_seq_port_cap, int32]
96	type	flags[snd_seq_port_type, int32]
97	chans	int32
98	voices	int32
99	svoices	int32
100	readuse	int32
101	wruse	int32
102	kernel	const[0, intptr]
103	flags	flags[snd_seq_port_flags, int32]
104	timeq	int32
105	pad	array[const[0, int8], 59]
106}
107
108snd_seq_port_subscribe {
109	sender	snd_seq_addr
110	dest	snd_seq_addr
111	voices	int32
112	flags	flags[snd_seq_sub_flags, int32]
113	queue	int8
114	pad1	array[const[0, int8], 3]
115	pad2	array[const[0, int8], 64]
116}
117
118snd_seq_queue_info {
119	queue	int32
120	owner	int32
121	locked	int32
122	name	string[snd_seq_queue_name, 64]
123	flags	int32
124	pad	array[const[0, int8], 60]
125}
126
127snd_seq_queue_status {
128	queue	int32
129	events	int32
130	tick	int32
131	time	timespec
132	runnint	int32
133	flags	int32
134	pad	array[const[0, int8], 64]
135}
136
137snd_seq_queue_timer {
138	queue	int32
139	type	flags[snd_seq_timer_type, int32]
140	id	snd_timer_id
141	pad	array[const[0, int8], 64]
142}
143
144snd_timer_id {
145	class	flags[snd_timer_class, int32]
146	sclass	flags[snd_timer_sclass, int32]
147	card	int32
148	dev	flags[snd_timer_dev, int32]
149	subdev	int32
150}
151
152snd_seq_queue_client {
153	queue	int32
154	client	int32
155	used	int32
156	pad	array[const[0, int8], 64]
157}
158
159snd_seq_client_pool {
160	client	int32
161	opool	int32
162	ipool	int32
163	oroom	int32
164	ofree	int32
165	ifree	int32
166	pad	array[const[0, int8], 64]
167}
168
169snd_seq_remove_events {
170	mode	flags[snd_seq_remove_mode, int32]
171	time	snd_seq_timestamp
172	queue	int8
173	dest	snd_seq_addr
174	chan	int8
175	type	flags[snd_seq_client_type, int32]
176	tag	int8
177	pad	array[const[0, int32], 10]
178}
179
180snd_seq_query_subs {
181	root	snd_seq_addr
182	type	flags[snd_seq_subs_type, int32]
183	index	int32
184	nsubs	int32
185	addr	snd_seq_addr
186	queue	int8
187	flags	int32
188	pad	array[const[0, int8], 64]
189}
190
191snd_seq_event {
192	type	int8
193	flags	int8
194	tag	int8
195	queue	int8
196	time	snd_seq_timestamp
197	src	snd_seq_addr
198	dst	snd_seq_addr
199	data	snd_seq_event_data
200}
201
202snd_seq_event_data [
203	note	snd_seq_ev_note
204	control	snd_seq_ev_ctrl
205	raw8	snd_seq_ev_raw8
206	raw32	snd_seq_ev_raw32
207	ext	snd_seq_ev_ext
208	queue	snd_seq_ev_queue_control
209	time	snd_seq_timestamp
210	addr	snd_seq_addr
211	connect	snd_seq_connect
212	result	snd_seq_result
213	quote	snd_seq_ev_quote
214]
215
216snd_seq_ev_note {
217	chan	int8
218	note	int8
219	veloc	int8
220	oveloc	int8
221	dur	int32
222}
223
224snd_seq_ev_ctrl {
225	chan	int8
226	param	int32
227	val	int32
228}
229
230snd_seq_ev_raw8 {
231	data	array[int8, 12]
232}
233
234snd_seq_ev_raw32 {
235	data	array[int32, 3]
236}
237
238snd_seq_ev_ext {
239	len	len[ptr, int32]
240	ptr	buffer[in]
241} [packed]
242
243snd_seq_ev_queue_control {
244	queue	int8
245	param	snd_seq_queue_skew
246}
247
248snd_seq_connect {
249	sender	snd_seq_addr
250	dest	snd_seq_addr
251}
252
253snd_seq_result {
254	event	int32
255	result	int32
256}
257
258snd_seq_ev_quote {
259	origin	snd_seq_addr
260	val	int16
261	event	ptr[in, snd_seq_event, opt]
262} [packed]
263
264snd_seq_queue_skew {
265	val	int32
266	base	int32
267}
268
269snd_seq_timestamp [
270	tick	int32
271	time	timespec
272]
273
274snd_seq_addr {
275	client	int8
276	port	int8
277}
278