Merge branch 'vendor/DIFFUTILS'
[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  */
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 _SYS_TYPES_H_
30 #include <sys/types.h>
31 #endif
32 #ifndef _SYS_IOCCOM_H_
33 #include <sys/ioccom.h>
34 #endif
35
36 union msf_lba {
37         struct {
38                 unsigned char   unused;
39                 unsigned char   minute;
40                 unsigned char   second;
41                 unsigned char   frame;
42         } msf;
43         int     lba;    /* network byte order */
44         u_char  addr[4];
45 };
46
47 struct cd_toc_entry {
48         u_int   :8;
49         u_int   control:4;
50         u_int   addr_type:4;
51         u_char  track;
52         u_int   :8;
53         union msf_lba  addr;
54 };
55
56 struct cd_sub_channel_header {
57         u_int   :8;
58         u_char  audio_status;
59 #define CD_AS_AUDIO_INVALID        0x00
60 #define CD_AS_PLAY_IN_PROGRESS     0x11
61 #define CD_AS_PLAY_PAUSED          0x12
62 #define CD_AS_PLAY_COMPLETED       0x13
63 #define CD_AS_PLAY_ERROR           0x14
64 #define CD_AS_NO_STATUS            0x15
65         u_char  data_len[2];
66 };
67
68 struct cd_sub_channel_position_data {
69         u_char  data_format;
70         u_int   control:4;
71         u_int   addr_type:4;
72         u_char  track_number;
73         u_char  index_number;
74         union msf_lba  absaddr;
75         union msf_lba  reladdr;
76 };
77
78 struct cd_sub_channel_media_catalog {
79         u_char  data_format;
80         u_int   :8;
81         u_int   :8;
82         u_int   :8;
83         u_int   :7;
84         u_int   mc_valid:1;
85         u_char  mc_number[15];
86 };
87
88 struct cd_sub_channel_track_info {
89         u_char  data_format;
90         u_int   :8;
91         u_char  track_number;
92         u_int   :8;
93         u_int   :7;
94         u_int   ti_valid:1;
95         u_char  ti_number[15];
96 };
97
98 struct cd_sub_channel_info {
99         struct cd_sub_channel_header header;
100         union {
101                 struct cd_sub_channel_position_data position;
102                 struct cd_sub_channel_media_catalog media_catalog;
103                 struct cd_sub_channel_track_info track_info;
104         } what;
105 };
106
107
108 /***************************************************************\
109 * Ioctls for the CD drive                                       *
110 \***************************************************************/
111
112 struct ioc_play_track
113 {
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
121
122 struct ioc_play_blocks
123 {
124         int     blk;
125         int     len;
126 };
127 #define CDIOCPLAYBLOCKS _IOW('c',2,struct ioc_play_blocks)
128
129
130 struct ioc_read_subchannel {
131         u_char address_format;
132 #define CD_LBA_FORMAT   1
133 #define CD_MSF_FORMAT   2
134         u_char data_format;
135 #define CD_SUBQ_DATA            0
136 #define CD_CURRENT_POSITION     1
137 #define CD_MEDIA_CATALOG        2
138 #define CD_TRACK_INFO           3
139         u_char track;
140         int     data_len;
141         struct  cd_sub_channel_info *data;
142 };
143 #define CDIOCREADSUBCHANNEL _IOWR('c', 3 , struct ioc_read_subchannel )
144
145
146 struct ioc_toc_header {
147         u_short len;
148         u_char  starting_track;
149         u_char  ending_track;
150 };
151 #define CDIOREADTOCHEADER _IOR('c',4,struct ioc_toc_header)
152
153
154 struct ioc_read_toc_entry {
155         u_char  address_format;
156         u_char  starting_track;
157         u_short data_len;
158         struct  cd_toc_entry *data;
159 };
160 #define CDIOREADTOCENTRYS _IOWR('c',5,struct ioc_read_toc_entry)
161
162
163 struct ioc_read_toc_single_entry {
164         u_char  address_format;
165         u_char  track;
166         struct  cd_toc_entry entry;
167 };
168 #define CDIOREADTOCENTRY _IOWR('c',6,struct ioc_read_toc_single_entry)
169
170
171 struct  ioc_patch
172 {
173         u_char  patch[4];       /* one for each channel */
174 };
175 #define CDIOCSETPATCH   _IOW('c',9,struct ioc_patch)
176
177
178 struct  ioc_vol
179 {
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 CDIOCSETSTEREO  _IO('c',13)
189 #define CDIOCSETSTERIO  CDIOCSETSTEREO
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
214 struct ioc_play_msf
215 {
216         u_char  start_m;
217         u_char  start_s;
218         u_char  start_f;
219         u_char  end_m;
220         u_char  end_s;
221         u_char  end_f;
222 };
223 #define CDIOCPLAYMSF    _IOW('c',25,struct ioc_play_msf)
224
225 #define CDIOCALLOW      _IO('c',26)
226
227 #define CDIOCPREVENT    _IO('c',27)
228
229                                 /*<1>For drives that support it, this*/
230                                 /*<1>causes the drive to close its door*/
231                                 /*<1>and make the media (if any) ready*/
232 #define CDIOCCLOSE      _IO('c',28)     /*<1>*/
233
234
235 struct  ioc_pitch               /*<1>For drives that support it, this*/
236 {                               /*<1>call instructs the drive to play the*/
237         short   speed;          /*<1>audio at a faster or slower-than-normal*/
238 };                              /*<1>rate. -32767 to -1 is slower, 0==normal,*/
239                                 /*<1>and 1 to 32767 is faster.  LSB bits are*/
240                                 /*<1>discarded first by drives with less res.*/
241 #define CDIOCPITCH      _IOW('c',29,struct ioc_pitch)   /*<1>*/
242
243 struct ioc_capability {                 /*<2>*/
244         u_long  play_function;          /*<2>*/
245 #define CDDOPLAYTRK     0x00000001      /*<2>Can Play tracks/index*/
246 #define CDDOPLAYMSF     0x00000002      /*<2>Can Play msf to msf*/
247 #define CDDOPLAYBLOCKS  0x00000004      /*<2>Can Play range of blocks*/
248 #define CDDOPAUSE       0x00000100      /*<2>Output can be paused*/
249 #define CDDORESUME      0x00000200      /*<2>Output can be resumed*/
250 #define CDDORESET       0x00000400      /*<2>Drive can be completely reset*/
251 #define CDDOSTART       0x00000800      /*<2>Audio can be started*/
252 #define CDDOSTOP        0x00001000      /*<2>Audio can be stopped*/
253 #define CDDOPITCH       0x00002000      /*<2>Audio pitch */
254
255         u_long  routing_function;       /*<2>*/
256 #define CDREADVOLUME    0x00000001      /*<2>Volume settings can be read*/
257 #define CDSETVOLUME     0x00000002      /*<2>Volume settings can be set*/
258 #define CDSETMONO       0x00000100      /*<2>Output can be set to mono*/
259 #define CDSETSTEREO     0x00000200      /*<2>Output can be set to stereo (def)*/
260 #define CDSETLEFT       0x00000400      /*<2>Output can be set to left only*/
261 #define CDSETRIGHT      0x00000800      /*<2>Output can be set to right only*/
262 #define CDSETMUTE       0x00001000      /*<2>Output can be muted*/
263 #define CDSETPATCH      0x00008000      /*<2>Direct routing control allowed*/
264
265         u_long  special_function;       /*<2>*/
266 #define CDDOEJECT       0x00000001      /*<2>The tray can be opened*/
267 #define CDDOCLOSE       0x00000002      /*<2>The tray can be closed*/
268 #define CDDOLOCK        0x00000004      /*<2>The tray can be locked*/
269 #define CDREADHEADER    0x00000100      /*<2>Can read Table of Contents*/
270 #define CDREADENTRIES   0x00000200      /*<2>Can read TOC Entries*/
271 #define CDREADSUBQ      0x00000200      /*<2>Can read Subchannel info*/
272 #define CDREADRW        0x00000400      /*<2>Can read subcodes R-W*/
273 #define CDHASDEBUG      0x00004000      /*<2>The tray has dynamic debugging*/
274 };                                      /*<2>*/
275
276 #define CDIOCCAPABILITY _IOR('c',30,struct ioc_capability)      /*<2>*/
277
278 struct ioc_read_audio
279 {
280         u_char address_format;
281         union msf_lba address;
282         int nframes;
283         u_char* buffer;
284 };
285
286 #define CDIOCREADAUDIO _IOWR('c',31,struct ioc_read_audio)
287
288 #endif /* !_SYS_CDIO_H_ */