xref: /freebsd/sys/cam/scsi/scsi_cd.h (revision eacee0ff7ec955b32e09515246bd97b6edcd2b0f)
1 /*-
2  * Copyright (c) 2000 Kenneth D. Merry
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. The name of the author may not be used to endorse or promote products
12  *    derived from this software without specific prior written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  */
27 /*
28  * Written by Julian Elischer (julian@tfs.com)
29  * for TRW Financial Systems.
30  *
31  * TRW Financial Systems, in accordance with their agreement with Carnegie
32  * Mellon University, makes this software available to CMU to distribute
33  * or use in any manner that they see fit as long as this message is kept with
34  * the software. For this reason TFS also grants any other persons or
35  * organisations permission to use or modify this software.
36  *
37  * TFS supplies this software to be publicly redistributed
38  * on the understanding that TFS is not responsible for the correct
39  * functioning of this software in any circumstances.
40  *
41  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
42  *
43  *	from: scsi_cd.h,v 1.10 1997/02/22 09:44:28 peter Exp $
44  * $FreeBSD$
45  */
46 #ifndef	_SCSI_SCSI_CD_H
47 #define _SCSI_SCSI_CD_H 1
48 
49 /*
50  *	Define two bits always in the same place in byte 2 (flag byte)
51  */
52 #define	CD_RELADDR	0x01
53 #define	CD_MSF		0x02
54 
55 /*
56  * SCSI command format
57  */
58 
59 struct scsi_pause
60 {
61 	u_int8_t op_code;
62 	u_int8_t byte2;
63 	u_int8_t unused[6];
64 	u_int8_t resume;
65 	u_int8_t control;
66 };
67 #define	PA_PAUSE	1
68 #define PA_RESUME	0
69 
70 struct scsi_play_msf
71 {
72 	u_int8_t op_code;
73 	u_int8_t byte2;
74 	u_int8_t unused;
75 	u_int8_t start_m;
76 	u_int8_t start_s;
77 	u_int8_t start_f;
78 	u_int8_t end_m;
79 	u_int8_t end_s;
80 	u_int8_t end_f;
81 	u_int8_t control;
82 };
83 
84 struct scsi_play_track
85 {
86 	u_int8_t op_code;
87 	u_int8_t byte2;
88 	u_int8_t unused[2];
89 	u_int8_t start_track;
90 	u_int8_t start_index;
91 	u_int8_t unused1;
92 	u_int8_t end_track;
93 	u_int8_t end_index;
94 	u_int8_t control;
95 };
96 
97 struct scsi_play_10
98 {
99 	u_int8_t op_code;
100 	u_int8_t byte2;
101 	u_int8_t blk_addr[4];
102 	u_int8_t unused;
103 	u_int8_t xfer_len[2];
104 	u_int8_t control;
105 };
106 
107 struct scsi_play_12
108 {
109 	u_int8_t op_code;
110 	u_int8_t byte2;	/* same as above */
111 	u_int8_t blk_addr[4];
112 	u_int8_t xfer_len[4];
113 	u_int8_t unused;
114 	u_int8_t control;
115 };
116 
117 struct scsi_play_rel_12
118 {
119 	u_int8_t op_code;
120 	u_int8_t byte2;	/* same as above */
121 	u_int8_t blk_addr[4];
122 	u_int8_t xfer_len[4];
123 	u_int8_t track;
124 	u_int8_t control;
125 };
126 
127 struct scsi_read_header
128 {
129 	u_int8_t op_code;
130 	u_int8_t byte2;
131 	u_int8_t blk_addr[4];
132 	u_int8_t unused;
133 	u_int8_t data_len[2];
134 	u_int8_t control;
135 };
136 
137 struct scsi_read_subchannel
138 {
139 	u_int8_t op_code;
140 	u_int8_t byte1;
141 	u_int8_t byte2;
142 #define	SRS_SUBQ	0x40
143 	u_int8_t subchan_format;
144 	u_int8_t unused[2];
145 	u_int8_t track;
146 	u_int8_t data_len[2];
147 	u_int8_t control;
148 };
149 
150 struct scsi_read_toc
151 {
152 	u_int8_t op_code;
153 	u_int8_t byte2;
154 	u_int8_t unused[4];
155 	u_int8_t from_track;
156 	u_int8_t data_len[2];
157 	u_int8_t control;
158 };
159 
160 struct scsi_read_cd_capacity
161 {
162 	u_int8_t op_code;
163 	u_int8_t byte2;
164 	u_int8_t addr_3;	/* Most Significant */
165 	u_int8_t addr_2;
166 	u_int8_t addr_1;
167 	u_int8_t addr_0;	/* Least Significant */
168 	u_int8_t unused[3];
169 	u_int8_t control;
170 };
171 
172 struct scsi_report_key
173 {
174 	u_int8_t opcode;
175 	u_int8_t reserved0;
176 	u_int8_t lba[4];
177 	u_int8_t reserved1[2];
178 	u_int8_t alloc_len[2];
179 	u_int8_t agid_keyformat;
180 #define RK_KF_AGID_MASK		0xc0
181 #define RK_KF_AGID_SHIFT	6
182 #define RK_KF_KEYFORMAT_MASK	0x3f
183 #define RK_KF_AGID		0x00
184 #define RK_KF_CHALLENGE		0x01
185 #define RF_KF_KEY1		0x02
186 #define RK_KF_KEY2		0x03
187 #define RF_KF_TITLE		0x04
188 #define RF_KF_ASF		0x05
189 #define RK_KF_RPC_SET		0x06
190 #define RF_KF_RPC_REPORT	0x08
191 #define RF_KF_INV_AGID		0x3f
192 	u_int8_t control;
193 };
194 
195 /*
196  * See the report key structure for key format and AGID definitions.
197  */
198 struct scsi_send_key
199 {
200 	u_int8_t opcode;
201 	u_int8_t reserved[7];
202 	u_int8_t param_len[2];
203 	u_int8_t agid_keyformat;
204 	u_int8_t control;
205 };
206 
207 struct scsi_read_dvd_structure
208 {
209 	u_int8_t opcode;
210 	u_int8_t reserved;
211 	u_int8_t address[4];
212 	u_int8_t layer_number;
213 	u_int8_t format;
214 #define RDS_FORMAT_PHYSICAL		0x00
215 #define RDS_FORMAT_COPYRIGHT		0x01
216 #define RDS_FORMAT_DISC_KEY		0x02
217 #define RDS_FORMAT_BCA			0x03
218 #define RDS_FORMAT_MANUFACTURER		0x04
219 #define RDS_FORMAT_CMGS_CPM		0x05
220 #define RDS_FORMAT_PROT_DISCID		0x06
221 #define RDS_FORMAT_DISC_KEY_BLOCK	0x07
222 #define RDS_FORMAT_DDS			0x08
223 #define RDS_FORMAT_DVDRAM_MEDIA_STAT	0x09
224 #define RDS_FORMAT_SPARE_AREA		0x0a
225 #define RDS_FORMAT_RMD_BORDEROUT	0x0c
226 #define RDS_FORMAT_RMD			0x0d
227 #define RDS_FORMAT_LEADIN		0x0e
228 #define RDS_FORMAT_DISC_ID		0x0f
229 #define RDS_FORMAT_DCB			0x30
230 #define RDS_FORMAT_WRITE_PROT		0xc0
231 #define RDS_FORMAT_STRUCTURE_LIST	0xff
232 	u_int8_t alloc_len[2];
233 	u_int8_t agid;
234 	u_int8_t control;
235 };
236 
237 /*
238  * Opcodes
239  */
240 #define READ_CD_CAPACITY	0x25	/* slightly different from disk */
241 #define READ_SUBCHANNEL		0x42	/* cdrom read Subchannel */
242 #define READ_TOC		0x43	/* cdrom read TOC */
243 #define READ_HEADER		0x44	/* cdrom read header */
244 #define PLAY_10			0x45	/* cdrom play  'play audio' mode */
245 #define PLAY_MSF		0x47	/* cdrom play Min,Sec,Frames mode */
246 #define PLAY_TRACK		0x48	/* cdrom play track/index mode */
247 #define PLAY_TRACK_REL		0x49	/* cdrom play track/index mode */
248 #define PAUSE			0x4b	/* cdrom pause in 'play audio' mode */
249 #define SEND_KEY		0xa3	/* dvd send key command */
250 #define REPORT_KEY		0xa4	/* dvd report key command */
251 #define PLAY_12			0xa5	/* cdrom pause in 'play audio' mode */
252 #define PLAY_TRACK_REL_BIG	0xa9	/* cdrom play track/index mode */
253 #define READ_DVD_STRUCTURE	0xad	/* read dvd structure */
254 
255 struct scsi_report_key_data_header
256 {
257 	u_int8_t data_len[2];
258 	u_int8_t reserved[2];
259 };
260 
261 struct scsi_report_key_data_agid
262 {
263 	u_int8_t data_len[2];
264 	u_int8_t reserved[5];
265 	u_int8_t agid;
266 #define RKD_AGID_MASK	0xc0
267 #define RKD_AGID_SHIFT	6
268 };
269 
270 struct scsi_report_key_data_challenge
271 {
272 	u_int8_t data_len[2];
273 	u_int8_t reserved0[2];
274 	u_int8_t challenge_key[10];
275 	u_int8_t reserved1[2];
276 };
277 
278 struct scsi_report_key_data_key1_key2
279 {
280 	u_int8_t data_len[2];
281 	u_int8_t reserved0[2];
282 	u_int8_t key1[5];
283 	u_int8_t reserved1[3];
284 };
285 
286 struct scsi_report_key_data_title
287 {
288 	u_int8_t data_len[2];
289 	u_int8_t reserved0[2];
290 	u_int8_t byte0;
291 #define RKD_TITLE_CPM		0x80
292 #define RKD_TITLE_CPM_SHIFT	7
293 #define RKD_TITLE_CP_SEC	0x40
294 #define RKD_TITLE_CP_SEC_SHIFT	6
295 #define RKD_TITLE_CMGS_MASK	0x30
296 #define RKD_TITLE_CMGS_SHIFT	4
297 #define RKD_TITLE_CMGS_NO_RST	0x00
298 #define RKD_TITLE_CMGS_RSVD	0x10
299 #define RKD_TITLE_CMGS_1_GEN	0x20
300 #define RKD_TITLE_CMGS_NO_COPY	0x30
301 	u_int8_t title_key[5];
302 	u_int8_t reserved1[2];
303 };
304 
305 struct scsi_report_key_data_asf
306 {
307 	u_int8_t data_len[2];
308 	u_int8_t reserved[5];
309 	u_int8_t success;
310 #define RKD_ASF_SUCCESS	0x01
311 };
312 
313 struct scsi_report_key_data_rpc
314 {
315 	u_int8_t data_len[2];
316 	u_int8_t rpc_scheme0;
317 #define RKD_RPC_SCHEME_UNKNOWN		0x00
318 #define RKD_RPC_SCHEME_PHASE_II		0x01
319 	u_int8_t reserved0;
320 	u_int8_t byte4;
321 #define RKD_RPC_TYPE_MASK		0xC0
322 #define RKD_RPC_TYPE_SHIFT		6
323 #define RKD_RPC_TYPE_NONE		0x00
324 #define RKD_RPC_TYPE_SET		0x40
325 #define RKD_RPC_TYPE_LAST_CHANCE	0x80
326 #define RKD_RPC_TYPE_PERM		0xC0
327 #define RKD_RPC_VENDOR_RESET_MASK	0x38
328 #define RKD_RPC_VENDOR_RESET_SHIFT	3
329 #define RKD_RPC_USER_RESET_MASK		0x07
330 #define RKD_RPC_USER_RESET_SHIFT	0
331 	u_int8_t region_mask;
332 	u_int8_t rpc_scheme1;
333 	u_int8_t reserved1;
334 };
335 
336 struct scsi_send_key_data_rpc
337 {
338 	u_int8_t data_len[2];
339 	u_int8_t reserved0[2];
340 	u_int8_t region_code;
341 	u_int8_t reserved1[3];
342 };
343 
344 /*
345  * Common header for the return data from the READ DVD STRUCTURE command.
346  */
347 struct scsi_read_dvd_struct_data_header
348 {
349 	u_int8_t data_len[2];
350 	u_int8_t reserved[2];
351 };
352 
353 struct scsi_read_dvd_struct_data_layer_desc
354 {
355 	u_int8_t book_type_version;
356 #define RDSD_BOOK_TYPE_DVD_ROM	0x00
357 #define RDSD_BOOK_TYPE_DVD_RAM	0x10
358 #define RDSD_BOOK_TYPE_DVD_R	0x20
359 #define RDSD_BOOK_TYPE_DVD_RW	0x30
360 #define RDSD_BOOK_TYPE_DVD_PRW	0x90
361 #define RDSD_BOOK_TYPE_MASK	0xf0
362 #define RDSD_BOOK_TYPE_SHIFT	4
363 #define RDSD_BOOK_VERSION_MASK	0x0f
364 	/*
365 	 * The lower 4 bits of this field is referred to as the "minimum
366 	 * rate" field in MMC2, and the "maximum rate" field in MMC3.  Ugh.
367 	 */
368 	u_int8_t disc_size_max_rate;
369 #define RDSD_DISC_SIZE_120MM	0x00
370 #define RDSD_DISC_SIZE_80MM	0x10
371 #define RDSD_DISC_SIZE_MASK	0xf0
372 #define RDSD_DISC_SIZE_SHIFT	4
373 #define RDSD_MAX_RATE_0252	0x00
374 #define RDSD_MAX_RATE_0504	0x01
375 #define RDSD_MAX_RATE_1008	0x02
376 #define RDSD_MAX_RATE_NOT_SPEC	0x0f
377 #define RDSD_MAX_RATE_MASK	0x0f
378 	u_int8_t layer_info;
379 #define RDSD_NUM_LAYERS_MASK	0x60
380 #define RDSD_NUM_LAYERS_SHIFT	5
381 #define RDSD_NL_ONE_LAYER	0x00
382 #define RDSD_NL_TWO_LAYERS	0x20
383 #define RDSD_TRACK_PATH_MASK	0x10
384 #define RDSD_TRACK_PATH_SHIFT	4
385 #define RDSD_TP_PTP		0x00
386 #define RDSD_TP_OTP		0x10
387 #define RDSD_LAYER_TYPE_RO	0x01
388 #define RDSD_LAYER_TYPE_RECORD	0x02
389 #define RDSD_LAYER_TYPE_RW	0x04
390 #define RDSD_LAYER_TYPE_MASK	0x0f
391 	u_int8_t density;
392 #define RDSD_LIN_DENSITY_0267		0x00
393 #define RDSD_LIN_DENSITY_0293		0x10
394 #define RDSD_LIN_DENSITY_0409_0435	0x20
395 #define RDSD_LIN_DENSITY_0280_0291	0x40
396 /* XXX MMC2 uses 0.176um/bit instead of 0.353 as in MMC3 */
397 #define RDSD_LIN_DENSITY_0353		0x80
398 #define RDSD_LIN_DENSITY_MASK		0xf0
399 #define RDSD_LIN_DENSITY_SHIFT		4
400 #define RDSD_TRACK_DENSITY_074		0x00
401 #define RDSD_TRACK_DENSITY_080		0x01
402 #define RDSD_TRACK_DENSITY_0615		0x02
403 #define RDSD_TRACK_DENSITY_MASK		0x0f
404 	u_int8_t zeros0;
405 	u_int8_t main_data_start[3];
406 #define RDSD_MAIN_DATA_START_DVD_RO	0x30000
407 #define RDSD_MAIN_DATA_START_DVD_RW	0x31000
408 	u_int8_t zeros1;
409 	u_int8_t main_data_end[3];
410 	u_int8_t zeros2;
411 	u_int8_t end_sector_layer0[3];
412 	u_int8_t bca;
413 #define RDSD_BCA	0x80
414 #define RDSD_BCA_MASK	0x80
415 #define RDSD_BCA_SHIFT	7
416 	u_int8_t media_specific[2031];
417 };
418 
419 struct scsi_read_dvd_struct_data_physical
420 {
421 	u_int8_t data_len[2];
422 	u_int8_t reserved[2];
423 	struct scsi_read_dvd_struct_data_layer_desc layer_desc;
424 };
425 
426 struct scsi_read_dvd_struct_data_copyright
427 {
428 	u_int8_t data_len[2];
429 	u_int8_t reserved0[2];
430 	u_int8_t cps_type;
431 #define RDSD_CPS_NOT_PRESENT	0x00
432 #define RDSD_CPS_DATA_EXISTS	0x01
433 	u_int8_t region_info;
434 	u_int8_t reserved1[2];
435 };
436 
437 struct scsi_read_dvd_struct_data_disc_key
438 {
439 	u_int8_t data_len[2];
440 	u_int8_t reserved[2];
441 	u_int8_t disc_key[2048];
442 };
443 
444 struct scsi_read_dvd_struct_data_bca
445 {
446 	u_int8_t data_len[2];
447 	u_int8_t reserved[2];
448 	u_int8_t bca_info[188]; /* XXX 12-188 bytes */
449 };
450 
451 struct scsi_read_dvd_struct_data_manufacturer
452 {
453 	u_int8_t data_len[2];
454 	u_int8_t reserved[2];
455 	u_int8_t manuf_info[2048];
456 };
457 
458 struct scsi_read_dvd_struct_data_copy_manage
459 {
460 	u_int8_t data_len[2];
461 	u_int8_t reserved0[2];
462 	u_int8_t byte4;
463 #define RDSD_CPM_NO_COPYRIGHT	0x00
464 #define RDSD_CPM_HAS_COPYRIGHT	0x80
465 #define RDSD_CPM_MASK		0x80
466 #define RDSD_CMGS_COPY_ALLOWED	0x00
467 #define RDSD_CMGS_ONE_COPY	0x20
468 #define RDSD_CMGS_NO_COPIES	0x30
469 #define RDSD_CMGS_MASK		0x30
470 	u_int8_t reserved1[3];
471 };
472 
473 struct scsi_read_dvd_struct_data_prot_discid
474 {
475 	u_int8_t data_len[2];
476 	u_int8_t reserved[2];
477 	u_int8_t prot_discid_data[16];
478 };
479 
480 struct scsi_read_dvd_struct_data_disc_key_blk
481 {
482 	/*
483 	 * Length is 0x6ffe == 28670 for CPRM, 0x3002 == 12990 for CSS2.
484 	 */
485 	u_int8_t data_len[2];
486 	u_int8_t reserved;
487 	u_int8_t total_packs;
488 	u_int8_t disc_key_pack_data[28668];
489 };
490 struct scsi_read_dvd_struct_data_dds
491 {
492 	u_int8_t data_len[2];
493 	u_int8_t reserved[2];
494 	u_int8_t dds_info[2048];
495 };
496 
497 struct scsi_read_dvd_struct_data_medium_status
498 {
499 	u_int8_t data_len[2];
500 	u_int8_t reserved0[2];
501 	u_int8_t byte4;
502 #define RDSD_MS_CARTRIDGE	0x80
503 #define RDSD_MS_OUT		0x40
504 #define RDSD_MS_MSWI		0x08
505 #define RDSD_MS_CWP		0x04
506 #define RDSD_MS_PWP		0x02
507 	u_int8_t disc_type_id;
508 #define RDSD_DT_NEED_CARTRIDGE	0x00
509 #define RDSD_DT_NO_CART_NEEDED	0x01
510 	u_int8_t reserved1;
511 	u_int8_t ram_swi_info;
512 #define RDSD_SWI_NO_BARE	0x01
513 #define RDSD_SWI_UNSPEC		0xff
514 };
515 
516 struct scsi_read_dvd_struct_data_spare_area
517 {
518 	u_int8_t data_len[2];
519 	u_int8_t reserved[2];
520 	u_int8_t unused_primary[4];
521 	u_int8_t unused_supl[4];
522 	u_int8_t allocated_supl[4];
523 };
524 
525 struct scsi_read_dvd_struct_data_rmd_borderout
526 {
527 	u_int8_t data_len[2];
528 	u_int8_t reserved[2];
529 	u_int8_t rmd[30720]; 	/* maximum is 30720 bytes */
530 };
531 
532 struct scsi_read_dvd_struct_data_rmd
533 {
534 	u_int8_t data_len[2];
535 	u_int8_t reserved[2];
536 	u_int8_t last_sector_num[4];
537 	u_int8_t rmd_bytes[32768];  /* This is the maximum */
538 };
539 
540 /*
541  * XXX KDM this is the MMC2 version of the structure.
542  * The variable positions have changed (in a semi-conflicting way) in the
543  * MMC3 spec, although the overall length of the structure is the same.
544  */
545 struct scsi_read_dvd_struct_data_leadin
546 {
547 	u_int8_t data_len[2];
548 	u_int8_t reserved0[2];
549 	u_int8_t field_id_1;
550 	u_int8_t app_code;
551 	u_int8_t disc_physical_data;
552 	u_int8_t last_addr[3];
553 	u_int8_t reserved1[2];
554 	u_int8_t field_id_2;
555 	u_int8_t rwp;
556 	u_int8_t rwp_wavelength;
557 	u_int8_t optimum_write_strategy;
558 	u_int8_t reserved2[4];
559 	u_int8_t field_id_3;
560 	u_int8_t manuf_id_17_12[6];
561 	u_int8_t reserved3;
562 	u_int8_t field_id_4;
563 	u_int8_t manuf_id_11_6[6];
564 	u_int8_t reserved4;
565 	u_int8_t field_id_5;
566 	u_int8_t manuf_id_5_0[6];
567 	u_int8_t reserved5[25];
568 };
569 
570 struct scsi_read_dvd_struct_data_disc_id
571 {
572 	u_int8_t data_len[2];
573 	u_int8_t reserved[4];
574 	u_int8_t random_num[2];
575 	u_int8_t year[4];
576 	u_int8_t month[2];
577 	u_int8_t day[2];
578 	u_int8_t hour[2];
579 	u_int8_t minute[2];
580 	u_int8_t second[2];
581 };
582 
583 struct scsi_read_dvd_struct_data_generic_dcb
584 {
585 	u_int8_t content_desc[4];
586 #define SCSI_RCB
587 	u_int8_t unknown_desc_actions[4];
588 #define RDSD_ACTION_RECORDING	0x0001
589 #define RDSD_ACTION_READING	0x0002
590 #define RDSD_ACTION_FORMAT	0x0004
591 #define RDSD_ACTION_MODIFY_DCB	0x0008
592 	u_int8_t vendor_id[32];
593 	u_int8_t dcb_data[32728];
594 };
595 
596 struct scsi_read_dvd_struct_data_dcb
597 {
598 	u_int8_t data_len[2];
599 	u_int8_t reserved[2];
600 	struct scsi_read_dvd_struct_data_generic_dcb dcb;
601 };
602 
603 struct read_dvd_struct_write_prot
604 {
605 	u_int8_t data_len[2];
606 	u_int8_t reserved0[2];
607 	u_int8_t write_prot_status;
608 #define RDSD_WPS_MSWI		0x08
609 #define RDSD_WPS_CWP		0x04
610 #define RDSD_WPS_PWP		0x02
611 #define RDSD_WPS_SWPP		0x01
612 	u_int8_t reserved[3];
613 };
614 
615 struct read_dvd_struct_list_entry
616 {
617 	u_int8_t format_code;
618 	u_int8_t sds_rds;
619 #define RDSD_SDS_NOT_WRITEABLE	0x00
620 #define RDSD_SDS_WRITEABLE	0x80
621 #define RDSD_SDS_MASK		0x80
622 #define RDSD_RDS_NOT_READABLE	0x00
623 #define RDSD_RDS_READABLE	0x40
624 #define RDSD_RDS_MASK		0x40
625 	u_int8_t struct_len[2];
626 };
627 
628 struct read_dvd_struct_data_list
629 {
630 	u_int8_t data_len[2];
631 	u_int8_t reserved[2];
632 	struct read_dvd_struct_list_entry entries[0];
633 };
634 
635 struct scsi_read_cd_cap_data
636 {
637 	u_int8_t addr_3;	/* Most significant */
638 	u_int8_t addr_2;
639 	u_int8_t addr_1;
640 	u_int8_t addr_0;	/* Least significant */
641 	u_int8_t length_3;	/* Most significant */
642 	u_int8_t length_2;
643 	u_int8_t length_1;
644 	u_int8_t length_0;	/* Least significant */
645 };
646 
647 union	cd_pages
648 {
649 	struct	audio_page
650 	{
651 		u_int8_t page_code;
652 #define	CD_PAGE_CODE	0x3F
653 #define	AUDIO_PAGE	0x0e
654 #define	CD_PAGE_PS	0x80
655 		u_int8_t param_len;
656 		u_int8_t flags;
657 #define		CD_PA_SOTC	0x02
658 #define		CD_PA_IMMED	0x04
659 		u_int8_t unused[2];
660 		u_int8_t format_lba;
661 #define		CD_PA_FORMAT_LBA	0x0F
662 #define		CD_PA_APR_VALID	0x80
663 		u_int8_t lb_per_sec[2];
664 		struct	port_control
665 		{
666 			u_int8_t channels;
667 #define	CHANNEL 0x0F
668 #define	CHANNEL_0 1
669 #define	CHANNEL_1 2
670 #define	CHANNEL_2 4
671 #define	CHANNEL_3 8
672 #define	LEFT_CHANNEL	CHANNEL_0
673 #define	RIGHT_CHANNEL	CHANNEL_1
674 			u_int8_t volume;
675 		} port[4];
676 #define	LEFT_PORT	0
677 #define	RIGHT_PORT	1
678 	}audio;
679 };
680 
681 struct cd_mode_data
682 {
683 	struct scsi_mode_header_6 header;
684 	struct scsi_mode_blk_desc blk_desc;
685 	union cd_pages page;
686 };
687 
688 __BEGIN_DECLS
689 void scsi_report_key(struct ccb_scsiio *csio, u_int32_t retries,
690 		     void (*cbfcnp)(struct cam_periph *, union ccb *),
691 		     u_int8_t tag_action, u_int32_t lba, u_int8_t agid,
692 		     u_int8_t key_format, u_int8_t *data_ptr,
693 		     u_int32_t dxfer_len, u_int8_t sense_len,
694 		     u_int32_t timeout);
695 
696 void scsi_send_key(struct ccb_scsiio *csio, u_int32_t retries,
697 		   void (*cbfcnp)(struct cam_periph *, union ccb *),
698 		   u_int8_t tag_action, u_int8_t agid, u_int8_t key_format,
699 		   u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len,
700 		   u_int32_t timeout);
701 
702 void scsi_read_dvd_structure(struct ccb_scsiio *csio, u_int32_t retries,
703 			     void (*cbfcnp)(struct cam_periph *, union ccb *),
704 			     u_int8_t tag_action, u_int32_t address,
705 			     u_int8_t layer_number, u_int8_t format,
706 			     u_int8_t agid, u_int8_t *data_ptr,
707 			     u_int32_t dxfer_len, u_int8_t sense_len,
708 			     u_int32_t timeout);
709 
710 __END_DECLS
711 
712 #endif /*_SCSI_SCSI_CD_H*/
713 
714