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