2 * Copyright (c) 1998,1999,2000,2001,2002 Søren Schmidt <sos@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
28 * $FreeBSD: src/sys/dev/ata/atapi-cd.h,v 1.15.2.9 2002/03/18 08:37:34 sos Exp $
29 * $DragonFly: src/sys/dev/disk/ata/atapi-cd.h,v 1.2 2003/06/17 04:28:22 dillon Exp $
32 /* CDROM Table Of Contents */
35 struct ioc_toc_header hdr;
36 struct cd_toc_entry tab[MAXTRK + 1];
39 /* DVD CSS authentication */
46 /* CDROM Audio Control Parameters Page */
48 /* mode page data header */
49 u_int16_t data_length;
53 u_int16_t blk_desc_len;
55 /* audio control page */
57 #define ATAPI_CDROM_AUDIO_PAGE 0x0e
58 #define ATAPI_CDROM_AUDIO_PAGE_MASK 0x4e
62 #define CD_PA_SOTC 0x02
63 #define CD_PA_IMMED 0x04
80 /* CDROM Capabilities and Mechanical Status Page */
82 /* mode page data header */
83 u_int16_t data_length;
85 #define MST_TYPE_MASK_LOW 0x0f
86 #define MST_FMT_NONE 0x00
87 #define MST_DATA_120 0x01
88 #define MST_AUDIO_120 0x02
89 #define MST_COMB_120 0x03
90 #define MST_PHOTO_120 0x04
91 #define MST_DATA_80 0x05
92 #define MST_AUDIO_80 0x06
93 #define MST_COMB_80 0x07
94 #define MST_PHOTO_80 0x08
96 #define MST_TYPE_MASK_HIGH 0x70
97 #define MST_CDROM 0x00
101 #define MST_NO_DISC 0x70
102 #define MST_DOOR_OPEN 0x71
103 #define MST_FMT_ERROR 0x72
107 u_int16_t blk_desc_len;
109 /* capabilities page */
111 #define ATAPI_CDROM_CAP_PAGE 0x2a
114 u_int8_t read_cdr :1; /* supports CD-R read */
115 u_int8_t read_cdrw :1; /* supports CD-RW read */
116 u_int8_t read_packet :1; /* supports reading packet tracks */
117 u_int8_t read_dvdrom :1; /* supports DVD-ROM read */
118 u_int8_t read_dvdr :1; /* supports DVD-R read */
119 u_int8_t read_dvdram :1; /* supports DVD-RAM read */
120 u_int8_t reserved2_67 :2;
121 u_int8_t write_cdr :1; /* supports CD-R write */
122 u_int8_t write_cdrw :1; /* supports CD-RW write */
123 u_int8_t test_write :1; /* supports test writing */
124 u_int8_t reserved3_3 :1;
125 u_int8_t write_dvdr :1; /* supports DVD-R write */
126 u_int8_t write_dvdram :1; /* supports DVD-RAM write */
127 u_int8_t reserved3_67 :2;
128 u_int8_t audio_play :1; /* audio play supported */
129 u_int8_t composite :1; /* composite audio/video supported */
130 u_int8_t dport1 :1; /* digital audio on port 1 */
131 u_int8_t dport2 :1; /* digital audio on port 2 */
132 u_int8_t mode2_form1 :1; /* mode 2 form 1 (XA) read */
133 u_int8_t mode2_form2 :1; /* mode 2 form 2 format */
134 u_int8_t multisession :1; /* multi-session photo-CD */
135 u_int8_t burnproof :1; /* supports burnproof */
136 u_int8_t cd_da :1; /* audio-CD read supported */
137 u_int8_t cd_da_stream :1; /* CD-DA streaming */
138 u_int8_t rw :1; /* combined R-W subchannels */
139 u_int8_t rw_corr :1; /* R-W subchannel data corrected */
140 u_int8_t c2 :1; /* C2 error pointers supported */
141 u_int8_t isrc :1; /* can return the ISRC info */
142 u_int8_t upc :1; /* can return the catalog number UPC */
144 u_int8_t lock :1; /* can be locked */
145 u_int8_t locked :1; /* current lock state */
146 u_int8_t prevent :1; /* prevent jumper installed */
147 u_int8_t eject :1; /* can eject */
149 u_int8_t mech :3; /* loading mechanism type */
150 #define MST_MECH_CADDY 0
151 #define MST_MECH_TRAY 1
152 #define MST_MECH_POPUP 2
153 #define MST_MECH_CHANGER 4
154 #define MST_MECH_CARTRIDGE 5
156 u_int8_t sep_vol :1; /* independent volume of channels */
157 u_int8_t sep_mute :1; /* independent mute of channels */
160 u_int16_t max_read_speed; /* max raw data rate in bytes/1000 */
161 u_int16_t max_vol_levels; /* number of discrete volume levels */
162 u_int16_t buf_size; /* internal buffer size in bytes/1024 */
163 u_int16_t cur_read_speed; /* current data rate in bytes/1000 */
166 u_int8_t bckf :1; /* data valid on failing edge of BCK */
167 u_int8_t rch :1; /* high LRCK indicates left channel */
168 u_int8_t lsbf :1; /* set if LSB first */
170 #define MST_DLEN_32 0
171 #define MST_DLEN_16 1
172 #define MST_DLEN_24 2
173 #define MST_DLEN_24_I2S 3
176 u_int16_t max_write_speed; /* max raw data rate in bytes/1000 */
177 u_int16_t cur_write_speed; /* current data rate in bytes/1000 */
178 u_int16_t copy_protect_rev;
182 /* CDROM Changer mechanism status structure */
184 u_int8_t current_slot :5; /* active changer slot */
185 u_int8_t mech_state :2; /* current changer state */
188 #define CH_UNLOADING 2
189 #define CH_INITIALIZING 3
191 u_int8_t fault :1; /* fault in last operation */
192 u_int8_t reserved0 :5;
193 u_int8_t cd_state :3; /* current mechanism state */
195 #define CD_AUDIO_ACTIVE 1
196 #define CD_AUDIO_SCAN 2
197 #define CD_HOST_ACTIVE 3
198 #define CD_NO_STATE 7
200 u_int8_t current_lba[3]; /* current LBA */
201 u_int8_t slots; /* number of available slots */
202 u_int16_t table_length; /* slot table length */
204 u_int8_t changed :1; /* media has changed in this slot */
206 u_int8_t present :1; /* slot has a CD present */
213 /* CDROM Write Parameters Mode Page (Burners ONLY) */
215 /* mode page data header */
216 u_int16_t data_length;
217 u_int8_t medium_type;
220 u_int16_t blk_desc_len;
222 /* write parameters page */
224 #define ATAPI_CDROM_WRITE_PARAMETERS_PAGE 0x05
226 u_int8_t page_length; /* 0x32 */
227 u_int8_t write_type :4; /* write stream type */
228 #define CDR_WTYPE_PACKET 0x00
229 #define CDR_WTYPE_TRACK 0x01
230 #define CDR_WTYPE_SESSION 0x02
231 #define CDR_WTYPE_RAW 0x03
233 u_int8_t test_write :1; /* test write enable */
234 u_int8_t reserved2_5 :1;
235 u_int8_t burnproof :1; /* BurnProof enable */
236 u_int8_t reserved2_7 :1;
237 u_int8_t track_mode :4; /* track mode */
238 #define CDR_TMODE_AUDIO 0x00
239 #define CDR_TMODE_AUDIO_PREEMP 0x01
240 #define CDR_TMODE_ALLOW_COPY 0x02
241 #define CDR_TMODE_DATA 0x04
242 #define CDR_TMODE_QUAD_AUDIO 0x08
244 u_int8_t copy :1; /* generation stamp */
245 u_int8_t fp :1; /* fixed packet type */
246 u_int8_t session_type :2; /* session type */
247 #define CDR_SESS_NONE 0x00
248 #define CDR_SESS_FINAL 0x01
249 #define CDR_SESS_RESERVED 0x02
250 #define CDR_SESS_MULTI 0x03
252 u_int8_t datablock_type :4; /* data type code (see cdrio.h) */
253 u_int8_t reserved4_4567 :4;
256 u_int8_t host_app_code :6; /* host application code */
257 u_int8_t reserved7_67 :2;
258 u_int8_t session_format; /* session format */
259 #define CDR_SESS_CDROM 0x00
260 #define CDR_SESS_CDI 0x10
261 #define CDR_SESS_CDROM_XA 0x20
264 u_int32_t packet_size; /* packet size in bytes */
265 u_int16_t audio_pause_length; /* audio pause length in secs */
266 u_int8_t media_catalog_number[16];
267 u_int8_t isr_code[16];
268 u_int8_t sub_hdr_byte0;
269 u_int8_t sub_hdr_byte1;
270 u_int8_t sub_hdr_byte2;
271 u_int8_t sub_hdr_byte3;
272 u_int8_t vendor_specific_byte0;
273 u_int8_t vendor_specific_byte1;
274 u_int8_t vendor_specific_byte2;
275 u_int8_t vendor_specific_byte3;
276 } __attribute__((packed));
278 /* CDROM Read Track Information structure */
279 struct acd_track_info {
280 u_int16_t data_length;
281 u_int8_t track_number; /* current track number */
282 u_int8_t session_number; /* current session number */
284 u_int8_t track_mode :4; /* mode of this track */
285 u_int8_t copy :1; /* generation stamp */
286 u_int8_t damage :1; /* damaged track */
287 u_int8_t reserved5_67 :2;
288 u_int8_t data_mode :4; /* data mode of this disc */
289 u_int8_t fp :1; /* fixed packet */
290 u_int8_t packet :1; /* packet track */
291 u_int8_t blank :1; /* blank (empty) track */
292 u_int8_t rt :1; /* reserved track */
293 u_int8_t nwa_valid :1; /* next_writeable_addr field valid */
294 u_int8_t reserved7_17 :7;
295 u_int track_start_addr; /* start of this track */
296 u_int next_writeable_addr; /* next writeable addr on this disc */
297 u_int free_blocks; /* free block on this disc */
298 u_int fixed_packet_size; /* size of packets on this track */
299 u_int track_length; /* length of this track */
304 TAILQ_ENTRY(acd_devlist) chain; /* list management */
307 /* Structure describing an ATAPI CDROM device */
309 struct ata_device *device; /* device softc */
310 int lun; /* logical device unit */
311 int flags; /* device state flags */
312 #define F_LOCKED 0x0001 /* this unit is locked */
314 struct buf_queue_head queue; /* queue of i/o requests */
315 TAILQ_HEAD(, acd_devlist) dev_list; /* list of "track" devices */
316 struct toc toc; /* table of disc contents */
317 struct audiopage au; /* audio page info */
318 struct audiopage aumask; /* audio page mask */
319 struct cappage cap; /* capabilities page info */
320 struct cd_sub_channel_info subchan; /* subchannel info */
321 struct changer *changer_info; /* changer info */
322 struct acd_softc **driver; /* softc's of changer slots */
323 int slot; /* this instance slot number */
324 time_t timestamp; /* this instance timestamp */
325 int disk_size; /* size of current media */
326 int block_size; /* blocksize currently used */
327 struct disklabel disklabel; /* fake disk label */
328 struct devstat *stats; /* devstat entry */
329 dev_t dev; /* device place holders */