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