Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / dev / disk / wcd / wd_cd.h
1 /*-
2  * Copyright (c) 1998, 1999 Søren Schmidt
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer,
10  *    without modification, immediately at the beginning of the file.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD: src/sys/i386/isa/wd_cd.h,v 1.6 1999/10/03 04:12:07 bde Exp $
29  * $DragonFly: src/sys/dev/disk/wcd/Attic/wd_cd.h,v 1.2 2003/06/17 04:28:37 dillon Exp $
30  */
31
32 /*
33  * CDROM Table Of Contents
34  */
35 #define MAXTRK 99
36 struct toc {
37         struct ioc_toc_header hdr;
38         struct cd_toc_entry tab[MAXTRK + 1];
39 };
40
41 /*
42  * CDROM Audio Control Parameters Page
43  */
44 struct audiopage {
45         /* Mode Page data header */
46         u_short data_length;
47         u_char medium_type;
48         u_char dev_spec;
49         u_char unused[2];
50         u_short blk_desc_len;
51
52         /* Audio control page */
53         u_char page_code;
54 #define CDROM_AUDIO_PAGE      0x0e
55 #define CDROM_AUDIO_PAGE_MASK 0x4e
56
57         u_char param_len;
58         u_char flags;
59 #define CD_PA_SOTC      0x02
60 #define CD_PA_IMMED     0x04
61
62         u_char reserved3;
63         u_char reserved4;
64         u_char reserved5;
65         u_short lb_per_sec;
66         struct port_control {
67                 u_char channels:4;
68 #define CHANNEL_0       1
69 #define CHANNEL_1       2
70 #define CHANNEL_2       4
71 #define CHANNEL_3       8
72                 u_char volume;
73         }            port[4];
74 };
75
76 /*
77  * CDROM Capabilities and Mechanical Status Page
78  */
79 struct cappage {
80         /* Mode data header */
81         u_short data_length;
82         u_char medium_type;             /* Present media type */
83 #define MST_TYPE_MASK_LOW       0x0f
84 #define MST_FMT_NONE            0x00
85 #define MST_DATA_120            0x01
86 #define MST_AUDIO_120           0x02
87 #define MST_COMB_120            0x03
88 #define MST_PHOTO_120           0x04
89 #define MST_DATA_80             0x05
90 #define MST_AUDIO_80            0x06
91 #define MST_COMB_80             0x07
92 #define MST_PHOTO_80            0x08
93
94 #define MST_TYPE_MASK_HIGH      0x70
95 #define MST_CDROM               0x00
96 #define MST_CDR                 0x10
97 #define MST_CDRW                0x20
98
99 #define MST_NO_DISC             0x70
100 #define MST_DOOR_OPEN           0x71
101 #define MST_FMT_ERROR           0x72
102
103         u_char dev_spec;
104         u_char unused[2];
105         u_short blk_desc_len;
106
107         /* Capabilities page */
108         u_char page_code;
109 #define ATAPI_CDROM_CAP_PAGE        0x2a
110
111         u_char param_len;
112         u_char read_cdr:1;              /* Supports CD-R read */
113         u_char read_cdrw:1;             /* Supports CD-RW read */
114         u_char method2:1;               /* Supports reading packet tracks */
115         u_char byte2_37:5;
116         u_char write_cdr:1;             /* Supports CD-R write */
117         u_char write_cdrw:1;            /* Supports CD-RW write */
118         u_char test_write:1;            /* Supports test writing */
119         u_char byte3_37:5;
120         u_char audio_play:1;            /* Audio play supported */
121         u_char composite:1;             /* Composite audio/video supported */
122         u_char dport1:1;                /* Digital audio on port 1 */
123         u_char dport2:1;                /* Digital audio on port 2 */
124         u_char mode2_form1:1;           /* Mode 2 form 1 (XA) read */
125         u_char mode2_form2:1;           /* Mode 2 form 2 format */
126         u_char multisession:1;          /* Multi-session photo-CD */
127         u_char:1;
128         u_char cd_da:1;                 /* Audio-CD read supported */
129         u_char cd_da_stream:1;          /* CD-DA streaming */
130         u_char rw:1;                    /* Combined R-W subchannels */
131         u_char rw_corr:1;               /* R-W subchannel data corrected */
132         u_char c2:1;                    /* C2 error pointers supported */
133         u_char isrc:1;                  /* Can return the ISRC info */
134         u_char upc:1;                   /* Can return the catalog number UPC */
135         u_char:1;
136         u_char lock:1;                  /* Can be locked */
137         u_char locked:1;                /* Current lock state */
138         u_char prevent:1;               /* Prevent jumper installed */
139         u_char eject:1;                 /* Can eject */
140         u_char:1;
141         u_char mech:3;                  /* Loading mechanism type */
142 #define MST_MECH_CADDY      0
143 #define MST_MECH_TRAY       1
144 #define MST_MECH_POPUP      2
145 #define MST_MECH_CHANGER    4
146 #define MST_MECH_CARTRIDGE  5
147
148         u_char sep_vol:1;               /* Independent volume of channels */
149         u_char sep_mute:1;              /* Independent mute of channels */
150         u_char:6;
151
152         u_short max_speed;              /* Max raw data rate in bytes/1000 */
153         u_short max_vol_levels;         /* Number of discrete volume levels */
154         u_short buf_size;               /* Internal buffer size in bytes/1024 */
155         u_short cur_speed;              /* Current data rate in bytes/1000  */
156
157         u_char reserved3;
158         u_char bckf:1;                  /* Data valid on failing edge of BCK */
159         u_char rch:1;                   /* High LRCK indicates left channel */
160         u_char lsbf:1;                  /* Set if LSB first */
161         u_char dlen:2;
162 #define MST_DLEN_32         0
163 #define MST_DLEN_16         1
164 #define MST_DLEN_24         2
165 #define MST_DLEN_24_I2S     3
166
167         u_char:3;
168         u_char reserved4[2];
169 };
170
171 /*
172  * CDROM Changer mechanism status structure
173  */
174 struct changer {
175         u_char current_slot:5;          /* Active changer slot */
176         u_char mech_state:2;            /* Current changer state */
177 #define CH_READY        0
178 #define CH_LOADING      1
179 #define CH_UNLOADING    2
180 #define CH_INITIALIZING 3
181
182         u_char fault:1;                 /* Fault in last operation */
183         u_char reserved0:5;
184         u_char cd_state:3;              /* Current mechanism state */
185 #define CD_IDLE         0
186 #define CD_AUDIO_ACTIVE 1
187 #define CD_AUDIO_SCAN   2
188 #define CD_HOST_ACTIVE  3
189 #define CD_NO_STATE     7
190
191         u_char current_lba[3];          /* Current LBA */
192         u_char slots;                   /* Number of available slots */
193         u_short table_length;           /* Slot table length */
194         struct {
195                 u_char changed:1;       /* Media has changed in this slot */
196                 u_char unused:6;
197                 u_char present:1;       /* Slot has a CD present */
198                 u_char reserved0;
199                 u_char reserved1;
200                 u_char reserved2;
201         }      slot[32];
202 };
203
204 /*
205  * CDROM Write Parameters Mode Page (Burners ONLY)
206  */
207 struct write_param {
208         /* Mode Page data header */
209         u_short data_length;
210         u_char medium_type;
211         u_char dev_spec;
212         u_char unused[2];
213         u_short blk_desc_len;
214
215         /* Write Parameters mode page */
216         u_char page_code;               /* 0x05 */
217         u_char page_length;             /* 0x32 */
218         u_char write_type:4;            /* Write stream type */
219 #define CDR_WTYPE_PACKET        0x00
220 #define CDR_WTYPE_TRACK         0x01
221 #define CDR_WTYPE_SESSION       0x02
222 #define CDR_WTYPE_RAW           0x03
223
224         u_char test_write:1;            /* Test write enable */
225         u_char reserved2_567:3;
226         u_char track_mode:4;            /* Track mode */
227 #define CDR_TMODE_AUDIO         0x01
228 #define CDR_TMODE_INCR_DATA     0x01
229 #define CDR_TMODE_ALLOW_COPY    0x02
230 #define CDR_TMODE_DATA          0x04
231 #define CDR_TMODE_QUAD_AUDIO    0x08
232
233         u_char copy:1;                  /* Generation stamp */
234         u_char fp:1;                    /* Fixed packet type */
235         u_char multi_session:2;         /* Multi-session type */
236 #define CDR_MSES_NONE           0x00
237 #define CDR_MSES_FINAL          0x01
238 #define CDR_MSES_RESERVED       0x02
239 #define CDR_MSES_NULTI          0x03
240
241         u_char data_block_type:4;       /* Data block type code */
242 #define CDR_DB_RAW              0x0     /* 2352 bytes of raw data */
243 #define CDR_DB_RAW_PQ           0x1     /* 2368 bytes raw data + P/Q subchan */
244 #define CDR_DB_RAW_PW           0x2     /* 2448 bytes raw data + P-W subchan */
245 #define CDR_DB_RAW_PW_R         0x3     /* 2448 bytes raw data + P-W raw sub */
246 #define CDR_DB_RES_4            0x4     /* Reserved */
247 #define CDR_DB_RES_5            0x5     /* Reserved */
248 #define CDR_DB_RES_6            0x6     /* Reserved */
249 #define CDR_DB_VS_7             0x7     /* Vendor specific */
250 #define CDR_DB_ROM_MODE1        0x8     /* 2048 bytes Mode 1 (ISO/IEC 10149) */
251 #define CDR_DB_ROM_MODE2        0x9     /* 2336 bytes Mode 2 (ISO/IEC 10149) */
252 #define CDR_DB_XA_MODE1         0x10    /* 2048 bytes Mode 1 (CD-ROM XA 1) */
253 #define CDR_DB_XA_MODE2_F1      0x11    /* 2056 bytes Mode 2 (CD-ROM XA 1) */
254 #define CDR_DB_XA_MODE2_F2      0x12    /* 2324 bytes Mode 2 (CD-ROM XA 2) */
255 #define CDR_DB_XA_MODE2_MIX     0x13    /* 2332 bytes Mode 2 (CD-ROM XA 1/2) */
256 #define CDR_DB_RES_14           0x14    /* Reserved */
257 #define CDR_DB_VS_15            0x15    /* Vendor specific */
258
259         u_char reserved4_4567:4;
260         u_char reserved5;
261         u_char reserved6;
262         u_char host_app_code:6;         /* Host application code */
263         u_char reserved7_67:2;
264         u_char session_format;          /* Session format */
265 #define CDR_SESS_CDROM          0x00
266 #define CDR_SESS_CDI            0x10
267 #define CDR_SESS_CDROM_XA       0x20
268
269         u_char reserved9;
270         u_int packet_size;              /* Packet size in bytes */
271         u_short audio_pause_length;     /* Audio pause length in secs */
272         u_char media_catalog_number[16];
273         u_char isr_code[16];
274         u_char sub_hdr_byte0;
275         u_char sub_hdr_byte1;
276         u_char sub_hdr_byte2;
277         u_char sub_hdr_byte3;
278 /*
279         u_char  vendor_specific_byte0;
280         u_char  vendor_specific_byte1;
281         u_char  vendor_specific_byte2;
282         u_char  vendor_specific_byte3;
283 */
284
285 } __attribute__((packed));
286 /*
287  * CDROM Read Track Information structure
288  */
289 struct acd_track_info {
290         u_short data_length;
291         u_char  track_number;           /* Current track number */
292         u_char  session_number;         /* Current session number */
293         u_char  reserved4;
294         u_char  track_mode:4;           /* Mode of this track */
295         u_char  copy:1;                 /* Generation stamp */
296         u_char  damage:1;               /* Damaged track */
297         u_char  reserved5_67:2;
298         u_char  data_mode:4;            /* Data mode of this disc */
299         u_char  fp:1;                   /* Fixed packet */
300         u_char  packet:1;               /* Packet track */
301         u_char  blank:1;                /* Blank (empty) track */
302         u_char  rt:1;                   /* Reserved track */
303         u_char  nwa_valid:1;            /* next_writeable_addr field valid */
304         u_char  reserved7_17:7;
305         u_int   track_start_addr;       /* Start of this track */
306         u_int   next_writeable_addr;    /* Next writeable addr on this disc */
307         u_int   free_blocks;            /* Free block on this disc */
308         u_int   fixed_packet_size;      /* Size of packets on this track */
309         u_int   track_length;           /* Length of this track */
310 };
311
312 /*
313  * Structure describing an ATAPI CDROM device
314  */
315 struct acd {
316         int unit;                       /* IDE bus drive unit */
317         int lun;                        /* Logical device unit */
318         int flags;                      /* Device state flags */
319         int refcnt;                     /* The number of raw opens */
320         struct atapi *ata;              /* Controller structure */
321         struct buf_queue_head buf_queue;        /* Queue of i/o requests */
322         struct atapi_params *param;     /* Drive parameters table */
323         struct toc toc;                 /* Table of disc contents */
324         struct {
325                 u_long volsize;         /* Volume size in blocks */
326                 u_long blksize;         /* Block size in bytes */
327         }      info;
328         struct audiopage au;            /* Audio page info */
329         struct cappage cap;             /* Capabilities page info */
330         struct audiopage aumask;        /* Audio page mask */
331         struct {                        /* Subchannel info */
332                 u_char void0;
333                 u_char audio_status;
334                 u_short data_length;
335                 u_char data_format;
336                 u_char control;
337                 u_char track;
338                 u_char indx;
339                 u_long abslba;
340                 u_long rellba;
341         } subchan;
342         struct changer *changer_info;   /* Changer info */
343         int slot;                       /* This lun's slot number */
344         struct devstat *device_stats;   /* Devstat parameters */
345         u_int block_size;               /* Blocksize currently used */
346         u_char dummy;                   /* Use dummy writes */
347         u_char speed;                   /* Select drive speed */
348         u_int next_writeable_lba;       /* Next writable position */
349         struct wormio_prepare_track preptrack;  /* Scratch region */
350 };