1/*
2 * 16 Feb 93	Julian Elischer	(julian@dialix.oz.au)
3 *
4 * $FreeBSD$
5 */
6
7/*
8<1>	Fixed a conflict with ioctl usage.  There were two different
9	functions using code #25.  Made file formatting consistent.
10	Added two new ioctl codes: door closing and audio pitch playback.
11	Added a STEREO union called STEREO.
12	5-Mar-95  Frank Durda IV	bsdmail@nemesis.lonestar.org
13
14<2>	Added a new ioctl that allows you to find out what capabilities
15	a drive has and what commands it will accept.  This allows a
16	user application to only offer controls (buttons, sliders, etc)
17	for functions that drive can actually do.   Things it can't do
18	can disappear or be greyed-out (like some other system).
19	If the driver doesn't respond to this call, well, handle it the
20	way you used to do it.
21	2-Apr-95  Frank Durda IV	bsdmail@nemesis.lonestar.org
22*/
23
24/* Shared between kernel & process */
25
26#ifndef	_SYS_CDIO_H_
27#define	_SYS_CDIO_H_
28
29#ifndef _KERNEL
30#include <sys/types.h>
31#endif
32#include <sys/ioccom.h>
33
34union msf_lba {
35	struct {
36		unsigned char   unused;
37		unsigned char   minute;
38		unsigned char   second;
39		unsigned char   frame;
40	} msf;
41	int     lba;    /* network byte order */
42	u_char	addr[4];
43};
44
45struct cd_toc_entry {
46#if BYTE_ORDER == LITTLE_ENDIAN
47	u_int	:8;
48	u_int	control:4;
49	u_int	addr_type:4;
50#else
51	u_int	:8;
52	u_int	addr_type:4;
53	u_int	control:4;
54#endif
55	u_char  track;
56	u_int	:8;
57	union msf_lba  addr;
58};
59
60struct cd_sub_channel_header {
61	u_int	:8;
62	u_char	audio_status;
63#define CD_AS_AUDIO_INVALID        0x00
64#define CD_AS_PLAY_IN_PROGRESS     0x11
65#define CD_AS_PLAY_PAUSED          0x12
66#define CD_AS_PLAY_COMPLETED       0x13
67#define CD_AS_PLAY_ERROR           0x14
68#define CD_AS_NO_STATUS            0x15
69	u_char	data_len[2];
70};
71
72struct cd_sub_channel_position_data {
73	u_char	data_format;
74	u_int	control:4;
75	u_int	addr_type:4;
76	u_char	track_number;
77	u_char	index_number;
78	union msf_lba  absaddr;
79	union msf_lba  reladdr;
80};
81
82struct cd_sub_channel_media_catalog {
83        u_char  data_format;
84        u_int   :8;
85        u_int   :8;
86        u_int   :8;
87        u_int   :7;
88        u_int   mc_valid:1;
89        u_char  mc_number[15];
90};
91
92struct cd_sub_channel_track_info {
93        u_char  data_format;
94        u_int   :8;
95        u_char  track_number;
96        u_int   :8;
97        u_int   :7;
98        u_int   ti_valid:1;
99        u_char  ti_number[15];
100};
101
102struct cd_sub_channel_info {
103	struct cd_sub_channel_header header;
104	union {
105		struct cd_sub_channel_position_data position;
106		struct cd_sub_channel_media_catalog media_catalog;
107		struct cd_sub_channel_track_info track_info;
108	} what;
109};
110
111
112/***************************************************************\
113* Ioctls for the CD drive					*
114\***************************************************************/
115
116struct ioc_play_track {
117	u_char	start_track;
118	u_char	start_index;
119	u_char	end_track;
120	u_char	end_index;
121};
122#define	CDIOCPLAYTRACKS	_IOW('c',1,struct ioc_play_track)
123
124
125struct ioc_play_blocks {
126	int	blk;
127	int	len;
128};
129#define	CDIOCPLAYBLOCKS	_IOW('c',2,struct ioc_play_blocks)
130
131
132struct ioc_read_subchannel {
133	u_char address_format;
134#define CD_LBA_FORMAT	1
135#define CD_MSF_FORMAT	2
136	u_char data_format;
137#define CD_SUBQ_DATA		0
138#define CD_CURRENT_POSITION	1
139#define CD_MEDIA_CATALOG	2
140#define CD_TRACK_INFO		3
141	u_char track;
142	int	data_len;
143	struct  cd_sub_channel_info *data;
144};
145#define CDIOCREADSUBCHANNEL _IOWR('c', 3 , struct ioc_read_subchannel )
146
147
148struct ioc_toc_header {
149	u_short len;
150	u_char  starting_track;
151	u_char  ending_track;
152};
153#define CDIOREADTOCHEADER _IOR('c',4,struct ioc_toc_header)
154
155
156struct ioc_read_toc_entry {
157	u_char	address_format;
158	u_char	starting_track;
159	u_short	data_len;
160	struct  cd_toc_entry *data;
161};
162#define CDIOREADTOCENTRYS _IOWR('c',5,struct ioc_read_toc_entry)
163
164
165struct ioc_read_toc_single_entry {
166	u_char	address_format;
167	u_char	track;
168	struct  cd_toc_entry entry;
169};
170#define CDIOREADTOCENTRY _IOWR('c',6,struct ioc_read_toc_single_entry)
171
172
173struct ioc_patch {
174	u_char	patch[4];	/* one for each channel */
175};
176#define	CDIOCSETPATCH	_IOW('c',9,struct ioc_patch)
177
178
179struct ioc_vol {
180	u_char	vol[4];	/* one for each channel */
181};
182#define	CDIOCGETVOL	_IOR('c',10,struct ioc_vol)
183
184#define	CDIOCSETVOL	_IOW('c',11,struct ioc_vol)
185
186#define	CDIOCSETMONO	_IO('c',12)
187
188#define	CDIOCSETSTERIO	_IO('c',13)
189#define	CDIOCSETSTEREO	_IO('c',13)
190
191#define	CDIOCSETMUTE	_IO('c',14)
192
193#define	CDIOCSETLEFT	_IO('c',15)
194
195#define	CDIOCSETRIGHT	_IO('c',16)
196
197#define	CDIOCSETDEBUG	_IO('c',17)
198
199#define	CDIOCCLRDEBUG	_IO('c',18)
200
201#define	CDIOCPAUSE	_IO('c',19)
202
203#define	CDIOCRESUME	_IO('c',20)
204
205#define	CDIOCRESET	_IO('c',21)
206
207#define	CDIOCSTART	_IO('c',22)
208
209#define	CDIOCSTOP	_IO('c',23)
210
211#define	CDIOCEJECT	_IO('c',24)
212
213
214struct ioc_play_msf {
215	u_char	start_m;
216	u_char	start_s;
217	u_char	start_f;
218	u_char	end_m;
219	u_char	end_s;
220	u_char	end_f;
221};
222#define	CDIOCPLAYMSF	_IOW('c',25,struct ioc_play_msf)
223
224#define	CDIOCALLOW	_IO('c',26)
225
226#define	CDIOCPREVENT	_IO('c',27)
227
228				/*<1>For drives that support it, this*/
229				/*<1>causes the drive to close its door*/
230				/*<1>and make the media (if any) ready*/
231#define CDIOCCLOSE	_IO('c',28)	/*<1>*/
232
233
234struct ioc_pitch {		/*<1>For drives that support it, this*/
235				/*<1>call instructs the drive to play the*/
236	short	speed;		/*<1>audio at a faster or slower-than-normal*/
237};				/*<1>rate. -32767 to -1 is slower, 0==normal,*/
238				/*<1>and 1 to 32767 is faster.  LSB bits are*/
239				/*<1>discarded first by drives with less res.*/
240#define	CDIOCPITCH	_IOW('c',29,struct ioc_pitch)	/*<1>*/
241
242struct ioc_capability {			/*<2>*/
243	u_long	play_function;		/*<2>*/
244#define CDDOPLAYTRK	0x00000001	/*<2>Can Play tracks/index*/
245#define	CDDOPLAYMSF	0x00000002	/*<2>Can Play msf to msf*/
246#define	CDDOPLAYBLOCKS	0x00000004	/*<2>Can Play range of blocks*/
247#define	CDDOPAUSE	0x00000100	/*<2>Output can be paused*/
248#define	CDDORESUME	0x00000200	/*<2>Output can be resumed*/
249#define	CDDORESET	0x00000400	/*<2>Drive can be completely reset*/
250#define	CDDOSTART	0x00000800	/*<2>Audio can be started*/
251#define CDDOSTOP	0x00001000	/*<2>Audio can be stopped*/
252#define CDDOPITCH	0x00002000	/*<2>Audio pitch */
253
254	u_long	routing_function;	/*<2>*/
255#define CDREADVOLUME	0x00000001	/*<2>Volume settings can be read*/
256#define CDSETVOLUME	0x00000002	/*<2>Volume settings can be set*/
257#define	CDSETMONO	0x00000100	/*<2>Output can be set to mono*/
258#define CDSETSTEREO	0x00000200	/*<2>Output can be set to stereo (def)*/
259#define	CDSETLEFT	0x00000400	/*<2>Output can be set to left only*/
260#define	CDSETRIGHT	0x00000800	/*<2>Output can be set to right only*/
261#define	CDSETMUTE	0x00001000	/*<2>Output can be muted*/
262#define CDSETPATCH	0x00008000	/*<2>Direct routing control allowed*/
263
264	u_long	special_function;	/*<2>*/
265#define	CDDOEJECT	0x00000001	/*<2>The tray can be opened*/
266#define	CDDOCLOSE	0x00000002	/*<2>The tray can be closed*/
267#define	CDDOLOCK	0x00000004	/*<2>The tray can be locked*/
268#define CDREADHEADER	0x00000100	/*<2>Can read Table of Contents*/
269#define	CDREADENTRIES	0x00000200	/*<2>Can read TOC Entries*/
270#define	CDREADSUBQ	0x00000200	/*<2>Can read Subchannel info*/
271#define CDREADRW	0x00000400	/*<2>Can read subcodes R-W*/
272#define	CDHASDEBUG	0x00004000	/*<2>The tray has dynamic debugging*/
273};					/*<2>*/
274
275#define	CDIOCCAPABILITY	_IOR('c',30,struct ioc_capability)	/*<2>*/
276
277/*
278 * Special version of CDIOCREADSUBCHANNEL which assumes that
279 * ioc_read_subchannel->data points to the kernel memory. For
280 * use in compatibility layers.
281 */
282#define CDIOCREADSUBCHANNEL_SYSSPACE _IOWR('c', 31, struct ioc_read_subchannel)
283
284#endif /* !_SYS_CDIO_H_ */
285