/dev/random was almost always returning 0 bytes. This was due to several
[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.2 2003/06/17 04:28:58 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 _KERNEL
31 #include <sys/types.h>
32 #endif
33 #include <sys/ioccom.h>
34
35 union msf_lba {
36         struct {
37                 unsigned char   unused;
38                 unsigned char   minute;
39                 unsigned char   second;
40                 unsigned char   frame;
41         } msf;
42         int     lba;    /* network byte order */
43         u_char  addr[4];
44 };
45
46 struct cd_toc_entry {
47         u_int   :8;
48         u_int   control:4;
49         u_int   addr_type:4;
50         u_char  track;
51         u_int   :8;
52         union msf_lba  addr;
53 };
54
55 struct cd_sub_channel_header {
56         u_int   :8;
57         u_char  audio_status;
58 #define CD_AS_AUDIO_INVALID        0x00
59 #define CD_AS_PLAY_IN_PROGRESS     0x11
60 #define CD_AS_PLAY_PAUSED          0x12
61 #define CD_AS_PLAY_COMPLETED       0x13
62 #define CD_AS_PLAY_ERROR           0x14
63 #define CD_AS_NO_STATUS            0x15
64         u_char  data_len[2];
65 };
66
67 struct cd_sub_channel_position_data {
68         u_char  data_format;
69         u_int   control:4;
70         u_int   addr_type:4;
71         u_char  track_number;
72         u_char  index_number;
73         union msf_lba  absaddr;
74         union msf_lba  reladdr;
75 };
76
77 struct cd_sub_channel_media_catalog {
78         u_char  data_format;
79         u_int   :8;
80         u_int   :8;
81         u_int   :8;
82         u_int   :7;
83         u_int   mc_valid:1;
84         u_char  mc_number[15];
85 };
86
87 struct cd_sub_channel_track_info {
88         u_char  data_format;
89         u_int   :8;
90         u_char  track_number;
91         u_int   :8;
92         u_int   :7;
93         u_int   ti_valid:1;
94         u_char  ti_number[15];
95 };
96
97 struct cd_sub_channel_info {
98         struct cd_sub_channel_header header;
99         union {
100                 struct cd_sub_channel_position_data position;
101                 struct cd_sub_channel_media_catalog media_catalog;
102                 struct cd_sub_channel_track_info track_info;
103         } what;
104 };
105
106
107 /***************************************************************\
108 * Ioctls for the CD drive                                       *
109 \***************************************************************/
110
111 struct ioc_play_track
112 {
113         u_char  start_track;
114         u_char  start_index;
115         u_char  end_track;
116         u_char  end_index;
117 };
118 #define CDIOCPLAYTRACKS _IOW('c',1,struct ioc_play_track)
119
120
121 struct ioc_play_blocks
122 {
123         int     blk;
124         int     len;
125 };
126 #define CDIOCPLAYBLOCKS _IOW('c',2,struct ioc_play_blocks)
127
128
129 struct ioc_read_subchannel {
130         u_char address_format;
131 #define CD_LBA_FORMAT   1
132 #define CD_MSF_FORMAT   2
133         u_char data_format;
134 #define CD_SUBQ_DATA            0
135 #define CD_CURRENT_POSITION     1
136 #define CD_MEDIA_CATALOG        2
137 #define CD_TRACK_INFO           3
138         u_char track;
139         int     data_len;
140         struct  cd_sub_channel_info *data;
141 };
142 #define CDIOCREADSUBCHANNEL _IOWR('c', 3 , struct ioc_read_subchannel )
143
144
145 struct ioc_toc_header {
146         u_short len;
147         u_char  starting_track;
148         u_char  ending_track;
149 };
150 #define CDIOREADTOCHEADER _IOR('c',4,struct ioc_toc_header)
151
152
153 struct ioc_read_toc_entry {
154         u_char  address_format;
155         u_char  starting_track;
156         u_short data_len;
157         struct  cd_toc_entry *data;
158 };
159 #define CDIOREADTOCENTRYS _IOWR('c',5,struct ioc_read_toc_entry)
160
161
162 struct ioc_read_toc_single_entry {
163         u_char  address_format;
164         u_char  track;
165         struct  cd_toc_entry entry;
166 };
167 #define CDIOREADTOCENTRY _IOWR('c',6,struct ioc_read_toc_single_entry)
168
169
170 struct  ioc_patch
171 {
172         u_char  patch[4];       /* one for each channel */
173 };
174 #define CDIOCSETPATCH   _IOW('c',9,struct ioc_patch)
175
176
177 struct  ioc_vol
178 {
179         u_char  vol[4]; /* one for each channel */
180 };
181 #define CDIOCGETVOL     _IOR('c',10,struct ioc_vol)
182
183 #define CDIOCSETVOL     _IOW('c',11,struct ioc_vol)
184
185 #define CDIOCSETMONO    _IO('c',12)
186
187 #define CDIOCSETSTERIO  _IO('c',13)
188 #define CDIOCSETSTEREO  _IO('c',13)
189
190 #define CDIOCSETMUTE    _IO('c',14)
191
192 #define CDIOCSETLEFT    _IO('c',15)
193
194 #define CDIOCSETRIGHT   _IO('c',16)
195
196 #define CDIOCSETDEBUG   _IO('c',17)
197
198 #define CDIOCCLRDEBUG   _IO('c',18)
199
200 #define CDIOCPAUSE      _IO('c',19)
201
202 #define CDIOCRESUME     _IO('c',20)
203
204 #define CDIOCRESET      _IO('c',21)
205
206 #define CDIOCSTART      _IO('c',22)
207
208 #define CDIOCSTOP       _IO('c',23)
209
210 #define CDIOCEJECT      _IO('c',24)
211
212
213 struct ioc_play_msf
214 {
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
234 struct  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
242 struct 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 struct ioc_read_audio
278 {
279         u_char address_format;
280         union msf_lba address;
281         int nframes;
282         u_char* buffer;
283 };
284
285 #define CDIOCREADAUDIO _IOWR('c',31,struct ioc_read_audio)
286
287 #endif /* !_SYS_CDIO_H_ */