xref: /freebsd/sys/cam/scsi/scsi_cd.h (revision 2ff63af9b88c7413b7d71715b5532625752a248e)
188f25c08SKenneth D. Merry /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3bec9534dSPedro F. Giffuni  *
456eac725SKenneth D. Merry  * Copyright (c) 2000, 2002 Kenneth D. Merry
588f25c08SKenneth D. Merry  * All rights reserved.
688f25c08SKenneth D. Merry  *
788f25c08SKenneth D. Merry  * Redistribution and use in source and binary forms, with or without
888f25c08SKenneth D. Merry  * modification, are permitted provided that the following conditions
988f25c08SKenneth D. Merry  * are met:
1088f25c08SKenneth D. Merry  * 1. Redistributions of source code must retain the above copyright
1188f25c08SKenneth D. Merry  *    notice, this list of conditions, and the following disclaimer,
1288f25c08SKenneth D. Merry  *    without modification, immediately at the beginning of the file.
1388f25c08SKenneth D. Merry  * 2. The name of the author may not be used to endorse or promote products
1488f25c08SKenneth D. Merry  *    derived from this software without specific prior written permission.
1588f25c08SKenneth D. Merry  *
1688f25c08SKenneth D. Merry  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1788f25c08SKenneth D. Merry  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1888f25c08SKenneth D. Merry  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1988f25c08SKenneth D. Merry  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
2088f25c08SKenneth D. Merry  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2188f25c08SKenneth D. Merry  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2288f25c08SKenneth D. Merry  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2388f25c08SKenneth D. Merry  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2488f25c08SKenneth D. Merry  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2588f25c08SKenneth D. Merry  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2688f25c08SKenneth D. Merry  * SUCH DAMAGE.
2788f25c08SKenneth D. Merry  *
2888f25c08SKenneth D. Merry  */
2976babe50SJustin T. Gibbs /*
3076babe50SJustin T. Gibbs  * Written by Julian Elischer (julian@tfs.com)
3176babe50SJustin T. Gibbs  * for TRW Financial Systems.
3276babe50SJustin T. Gibbs  *
3376babe50SJustin T. Gibbs  * TRW Financial Systems, in accordance with their agreement with Carnegie
3476babe50SJustin T. Gibbs  * Mellon University, makes this software available to CMU to distribute
3576babe50SJustin T. Gibbs  * or use in any manner that they see fit as long as this message is kept with
3676babe50SJustin T. Gibbs  * the software. For this reason TFS also grants any other persons or
3776babe50SJustin T. Gibbs  * organisations permission to use or modify this software.
3876babe50SJustin T. Gibbs  *
3976babe50SJustin T. Gibbs  * TFS supplies this software to be publicly redistributed
4076babe50SJustin T. Gibbs  * on the understanding that TFS is not responsible for the correct
4176babe50SJustin T. Gibbs  * functioning of this software in any circumstances.
4276babe50SJustin T. Gibbs  *
4376babe50SJustin T. Gibbs  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
4476babe50SJustin T. Gibbs  *
4576babe50SJustin T. Gibbs  *	from: scsi_cd.h,v 1.10 1997/02/22 09:44:28 peter Exp $
4676babe50SJustin T. Gibbs  */
4776babe50SJustin T. Gibbs #ifndef	_SCSI_SCSI_CD_H
4876babe50SJustin T. Gibbs #define _SCSI_SCSI_CD_H 1
4976babe50SJustin T. Gibbs 
5076babe50SJustin T. Gibbs /*
5176babe50SJustin T. Gibbs  *	Define two bits always in the same place in byte 2 (flag byte)
5276babe50SJustin T. Gibbs  */
5376babe50SJustin T. Gibbs #define	CD_RELADDR	0x01
5476babe50SJustin T. Gibbs #define	CD_MSF		0x02
5576babe50SJustin T. Gibbs 
5676babe50SJustin T. Gibbs /*
5776babe50SJustin T. Gibbs  * SCSI command format
5876babe50SJustin T. Gibbs  */
5976babe50SJustin T. Gibbs 
6091be33dcSAlexander Motin struct scsi_get_config
6191be33dcSAlexander Motin {
6291be33dcSAlexander Motin 	uint8_t opcode;
6391be33dcSAlexander Motin 	uint8_t rt;
6491be33dcSAlexander Motin #define	SGC_RT_ALL		0x00
6591be33dcSAlexander Motin #define	SGC_RT_CURRENT		0x01
6691be33dcSAlexander Motin #define	SGC_RT_SPECIFIC		0x02
6791be33dcSAlexander Motin #define	SGC_RT_MASK		0x03
6891be33dcSAlexander Motin 	uint8_t starting_feature[2];
6991be33dcSAlexander Motin 	uint8_t reserved[3];
7091be33dcSAlexander Motin 	uint8_t length[2];
7191be33dcSAlexander Motin 	uint8_t control;
7291be33dcSAlexander Motin };
7391be33dcSAlexander Motin 
7491be33dcSAlexander Motin struct scsi_get_config_header
7591be33dcSAlexander Motin {
7691be33dcSAlexander Motin 	uint8_t data_length[4];
7791be33dcSAlexander Motin 	uint8_t reserved[2];
7891be33dcSAlexander Motin 	uint8_t current_profile[2];
7991be33dcSAlexander Motin };
8091be33dcSAlexander Motin 
8191be33dcSAlexander Motin struct scsi_get_config_feature
8291be33dcSAlexander Motin {
8391be33dcSAlexander Motin 	uint8_t feature_code[2];
8491be33dcSAlexander Motin 	uint8_t flags;
8591be33dcSAlexander Motin #define	SGC_F_CURRENT		0x01
8691be33dcSAlexander Motin #define	SGC_F_PERSISTENT	0x02
8791be33dcSAlexander Motin #define	SGC_F_VERSION_MASK	0x2C
8891be33dcSAlexander Motin #define	SGC_F_VERSION_SHIFT	2
8991be33dcSAlexander Motin 	uint8_t add_length;
9091be33dcSAlexander Motin 	uint8_t feature_data[];
9191be33dcSAlexander Motin };
9291be33dcSAlexander Motin 
9391be33dcSAlexander Motin struct scsi_get_event_status
9491be33dcSAlexander Motin {
9591be33dcSAlexander Motin 	uint8_t opcode;
9691be33dcSAlexander Motin 	uint8_t byte2;
9791be33dcSAlexander Motin #define	SGESN_POLLED		1
9891be33dcSAlexander Motin 	uint8_t reserved[2];
9991be33dcSAlexander Motin 	uint8_t notif_class;
10091be33dcSAlexander Motin 	uint8_t reserved2[2];
10191be33dcSAlexander Motin 	uint8_t length[2];
10291be33dcSAlexander Motin 	uint8_t control;
10391be33dcSAlexander Motin };
10491be33dcSAlexander Motin 
10591be33dcSAlexander Motin struct scsi_get_event_status_header
10691be33dcSAlexander Motin {
10791be33dcSAlexander Motin 	uint8_t descr_length[4];
10891be33dcSAlexander Motin 	uint8_t nea_class;
10991be33dcSAlexander Motin #define	SGESN_NEA		0x80
11091be33dcSAlexander Motin 	uint8_t supported_class;
11191be33dcSAlexander Motin };
11291be33dcSAlexander Motin 
11391be33dcSAlexander Motin struct scsi_get_event_status_descr
11491be33dcSAlexander Motin {
11591be33dcSAlexander Motin 	uint8_t event_code;
11691be33dcSAlexander Motin 	uint8_t event_info[];
11791be33dcSAlexander Motin };
11891be33dcSAlexander Motin 
11991be33dcSAlexander Motin struct scsi_mechanism_status
12091be33dcSAlexander Motin {
12191be33dcSAlexander Motin 	uint8_t opcode;
12291be33dcSAlexander Motin 	uint8_t reserved[7];
12391be33dcSAlexander Motin 	uint8_t length[2];
12491be33dcSAlexander Motin 	uint8_t reserved2;
12591be33dcSAlexander Motin 	uint8_t control;
12691be33dcSAlexander Motin };
12791be33dcSAlexander Motin 
12891be33dcSAlexander Motin struct scsi_mechanism_status_header
12991be33dcSAlexander Motin {
13091be33dcSAlexander Motin 	uint8_t state1;
13191be33dcSAlexander Motin 	uint8_t state2;
13291be33dcSAlexander Motin 	uint8_t lba[3];
13391be33dcSAlexander Motin 	uint8_t slots_num;
13491be33dcSAlexander Motin 	uint8_t slots_length[2];
13591be33dcSAlexander Motin };
13691be33dcSAlexander Motin 
13776babe50SJustin T. Gibbs struct scsi_pause
13876babe50SJustin T. Gibbs {
139*7c5d20a6SWarner Losh 	uint8_t op_code;
140*7c5d20a6SWarner Losh 	uint8_t byte2;
141*7c5d20a6SWarner Losh 	uint8_t unused[6];
142*7c5d20a6SWarner Losh 	uint8_t resume;
143*7c5d20a6SWarner Losh 	uint8_t control;
14476babe50SJustin T. Gibbs };
14576babe50SJustin T. Gibbs #define	PA_PAUSE	1
14676babe50SJustin T. Gibbs #define PA_RESUME	0
14776babe50SJustin T. Gibbs 
14876babe50SJustin T. Gibbs struct scsi_play_msf
14976babe50SJustin T. Gibbs {
150*7c5d20a6SWarner Losh 	uint8_t op_code;
151*7c5d20a6SWarner Losh 	uint8_t byte2;
152*7c5d20a6SWarner Losh 	uint8_t unused;
153*7c5d20a6SWarner Losh 	uint8_t start_m;
154*7c5d20a6SWarner Losh 	uint8_t start_s;
155*7c5d20a6SWarner Losh 	uint8_t start_f;
156*7c5d20a6SWarner Losh 	uint8_t end_m;
157*7c5d20a6SWarner Losh 	uint8_t end_s;
158*7c5d20a6SWarner Losh 	uint8_t end_f;
159*7c5d20a6SWarner Losh 	uint8_t control;
16076babe50SJustin T. Gibbs };
16176babe50SJustin T. Gibbs 
16276babe50SJustin T. Gibbs struct scsi_play_track
16376babe50SJustin T. Gibbs {
164*7c5d20a6SWarner Losh 	uint8_t op_code;
165*7c5d20a6SWarner Losh 	uint8_t byte2;
166*7c5d20a6SWarner Losh 	uint8_t unused[2];
167*7c5d20a6SWarner Losh 	uint8_t start_track;
168*7c5d20a6SWarner Losh 	uint8_t start_index;
169*7c5d20a6SWarner Losh 	uint8_t unused1;
170*7c5d20a6SWarner Losh 	uint8_t end_track;
171*7c5d20a6SWarner Losh 	uint8_t end_index;
172*7c5d20a6SWarner Losh 	uint8_t control;
17376babe50SJustin T. Gibbs };
17476babe50SJustin T. Gibbs 
175050279e5SKenneth D. Merry struct scsi_play_10
17676babe50SJustin T. Gibbs {
177*7c5d20a6SWarner Losh 	uint8_t op_code;
178*7c5d20a6SWarner Losh 	uint8_t byte2;
179*7c5d20a6SWarner Losh 	uint8_t blk_addr[4];
180*7c5d20a6SWarner Losh 	uint8_t unused;
181*7c5d20a6SWarner Losh 	uint8_t xfer_len[2];
182*7c5d20a6SWarner Losh 	uint8_t control;
18376babe50SJustin T. Gibbs };
18476babe50SJustin T. Gibbs 
185050279e5SKenneth D. Merry struct scsi_play_12
18676babe50SJustin T. Gibbs {
187*7c5d20a6SWarner Losh 	uint8_t op_code;
188*7c5d20a6SWarner Losh 	uint8_t byte2;	/* same as above */
189*7c5d20a6SWarner Losh 	uint8_t blk_addr[4];
190*7c5d20a6SWarner Losh 	uint8_t xfer_len[4];
191*7c5d20a6SWarner Losh 	uint8_t unused;
192*7c5d20a6SWarner Losh 	uint8_t control;
19376babe50SJustin T. Gibbs };
19476babe50SJustin T. Gibbs 
195050279e5SKenneth D. Merry struct scsi_play_rel_12
19676babe50SJustin T. Gibbs {
197*7c5d20a6SWarner Losh 	uint8_t op_code;
198*7c5d20a6SWarner Losh 	uint8_t byte2;	/* same as above */
199*7c5d20a6SWarner Losh 	uint8_t blk_addr[4];
200*7c5d20a6SWarner Losh 	uint8_t xfer_len[4];
201*7c5d20a6SWarner Losh 	uint8_t track;
202*7c5d20a6SWarner Losh 	uint8_t control;
20376babe50SJustin T. Gibbs };
20476babe50SJustin T. Gibbs 
20576babe50SJustin T. Gibbs struct scsi_read_header
20676babe50SJustin T. Gibbs {
207*7c5d20a6SWarner Losh 	uint8_t op_code;
208*7c5d20a6SWarner Losh 	uint8_t byte2;
209*7c5d20a6SWarner Losh 	uint8_t blk_addr[4];
210*7c5d20a6SWarner Losh 	uint8_t unused;
211*7c5d20a6SWarner Losh 	uint8_t data_len[2];
212*7c5d20a6SWarner Losh 	uint8_t control;
21376babe50SJustin T. Gibbs };
21476babe50SJustin T. Gibbs 
21576babe50SJustin T. Gibbs struct scsi_read_subchannel
21676babe50SJustin T. Gibbs {
217*7c5d20a6SWarner Losh 	uint8_t op_code;
218*7c5d20a6SWarner Losh 	uint8_t byte1;
219*7c5d20a6SWarner Losh 	uint8_t byte2;
22076babe50SJustin T. Gibbs #define	SRS_SUBQ	0x40
221*7c5d20a6SWarner Losh 	uint8_t subchan_format;
222*7c5d20a6SWarner Losh 	uint8_t unused[2];
223*7c5d20a6SWarner Losh 	uint8_t track;
224*7c5d20a6SWarner Losh 	uint8_t data_len[2];
225*7c5d20a6SWarner Losh 	uint8_t control;
22676babe50SJustin T. Gibbs };
22776babe50SJustin T. Gibbs 
22876babe50SJustin T. Gibbs struct scsi_read_toc
22976babe50SJustin T. Gibbs {
230*7c5d20a6SWarner Losh 	uint8_t op_code;
231*7c5d20a6SWarner Losh 	uint8_t byte2;
232*7c5d20a6SWarner Losh 	uint8_t format;
233dd78f432SAndriy Gapon #define	SRTOC_FORMAT_TOC	0x00
234dd78f432SAndriy Gapon #define	SRTOC_FORMAT_LAST_ADDR	0x01
235dd78f432SAndriy Gapon #define	SRTOC_FORMAT_QSUB_TOC	0x02
236dd78f432SAndriy Gapon #define	SRTOC_FORMAT_QSUB_PMA	0x03
237dd78f432SAndriy Gapon #define	SRTOC_FORMAT_ATIP	0x04
238dd78f432SAndriy Gapon #define	SRTOC_FORMAT_CD_TEXT	0x05
239*7c5d20a6SWarner Losh 	uint8_t unused[3];
240*7c5d20a6SWarner Losh 	uint8_t from_track;
241*7c5d20a6SWarner Losh 	uint8_t data_len[2];
242*7c5d20a6SWarner Losh 	uint8_t control;
24376babe50SJustin T. Gibbs };
24476babe50SJustin T. Gibbs 
24591be33dcSAlexander Motin struct scsi_read_toc_hdr
24691be33dcSAlexander Motin {
24791be33dcSAlexander Motin 	uint8_t data_length[2];
24891be33dcSAlexander Motin 	uint8_t first;
24991be33dcSAlexander Motin 	uint8_t last;
25091be33dcSAlexander Motin };
25191be33dcSAlexander Motin 
25291be33dcSAlexander Motin struct scsi_read_toc_type01_descr
25391be33dcSAlexander Motin {
25491be33dcSAlexander Motin 	uint8_t reserved;
25591be33dcSAlexander Motin 	uint8_t addr_ctl;
25691be33dcSAlexander Motin 	uint8_t track_number;
25791be33dcSAlexander Motin 	uint8_t reserved2;
25891be33dcSAlexander Motin 	uint8_t track_start[4];
25991be33dcSAlexander Motin };
26091be33dcSAlexander Motin 
26176babe50SJustin T. Gibbs struct scsi_read_cd_capacity
26276babe50SJustin T. Gibbs {
263*7c5d20a6SWarner Losh 	uint8_t op_code;
264*7c5d20a6SWarner Losh 	uint8_t byte2;
265*7c5d20a6SWarner Losh 	uint8_t addr_3;	/* Most Significant */
266*7c5d20a6SWarner Losh 	uint8_t addr_2;
267*7c5d20a6SWarner Losh 	uint8_t addr_1;
268*7c5d20a6SWarner Losh 	uint8_t addr_0;	/* Least Significant */
269*7c5d20a6SWarner Losh 	uint8_t unused[3];
270*7c5d20a6SWarner Losh 	uint8_t control;
27176babe50SJustin T. Gibbs };
27276babe50SJustin T. Gibbs 
27376ba4ecdSNate Lawson struct scsi_set_speed
27476ba4ecdSNate Lawson {
275*7c5d20a6SWarner Losh 	uint8_t opcode;
276*7c5d20a6SWarner Losh 	uint8_t byte2;
277*7c5d20a6SWarner Losh 	uint8_t readspeed[2];
278*7c5d20a6SWarner Losh 	uint8_t writespeed[2];
279*7c5d20a6SWarner Losh 	uint8_t reserved[5];
280*7c5d20a6SWarner Losh 	uint8_t control;
28176ba4ecdSNate Lawson };
28276ba4ecdSNate Lawson 
28388f25c08SKenneth D. Merry struct scsi_report_key
28488f25c08SKenneth D. Merry {
285*7c5d20a6SWarner Losh 	uint8_t opcode;
286*7c5d20a6SWarner Losh 	uint8_t reserved0;
287*7c5d20a6SWarner Losh 	uint8_t lba[4];
288*7c5d20a6SWarner Losh 	uint8_t reserved1[2];
289*7c5d20a6SWarner Losh 	uint8_t alloc_len[2];
290*7c5d20a6SWarner Losh 	uint8_t agid_keyformat;
29188f25c08SKenneth D. Merry #define RK_KF_AGID_MASK		0xc0
29288f25c08SKenneth D. Merry #define RK_KF_AGID_SHIFT	6
29388f25c08SKenneth D. Merry #define RK_KF_KEYFORMAT_MASK	0x3f
29488f25c08SKenneth D. Merry #define RK_KF_AGID		0x00
29588f25c08SKenneth D. Merry #define RK_KF_CHALLENGE		0x01
29688f25c08SKenneth D. Merry #define RF_KF_KEY1		0x02
29788f25c08SKenneth D. Merry #define RK_KF_KEY2		0x03
29888f25c08SKenneth D. Merry #define RF_KF_TITLE		0x04
29988f25c08SKenneth D. Merry #define RF_KF_ASF		0x05
30088f25c08SKenneth D. Merry #define RK_KF_RPC_SET		0x06
30188f25c08SKenneth D. Merry #define RF_KF_RPC_REPORT	0x08
30288f25c08SKenneth D. Merry #define RF_KF_INV_AGID		0x3f
303*7c5d20a6SWarner Losh 	uint8_t control;
30488f25c08SKenneth D. Merry };
30588f25c08SKenneth D. Merry 
30688f25c08SKenneth D. Merry /*
30788f25c08SKenneth D. Merry  * See the report key structure for key format and AGID definitions.
30888f25c08SKenneth D. Merry  */
30988f25c08SKenneth D. Merry struct scsi_send_key
31088f25c08SKenneth D. Merry {
311*7c5d20a6SWarner Losh 	uint8_t opcode;
312*7c5d20a6SWarner Losh 	uint8_t reserved[7];
313*7c5d20a6SWarner Losh 	uint8_t param_len[2];
314*7c5d20a6SWarner Losh 	uint8_t agid_keyformat;
315*7c5d20a6SWarner Losh 	uint8_t control;
31688f25c08SKenneth D. Merry };
31788f25c08SKenneth D. Merry 
31888f25c08SKenneth D. Merry struct scsi_read_dvd_structure
31988f25c08SKenneth D. Merry {
320*7c5d20a6SWarner Losh 	uint8_t opcode;
321*7c5d20a6SWarner Losh 	uint8_t reserved;
322*7c5d20a6SWarner Losh 	uint8_t address[4];
323*7c5d20a6SWarner Losh 	uint8_t layer_number;
324*7c5d20a6SWarner Losh 	uint8_t format;
32588f25c08SKenneth D. Merry #define RDS_FORMAT_PHYSICAL		0x00
32688f25c08SKenneth D. Merry #define RDS_FORMAT_COPYRIGHT		0x01
32788f25c08SKenneth D. Merry #define RDS_FORMAT_DISC_KEY		0x02
32888f25c08SKenneth D. Merry #define RDS_FORMAT_BCA			0x03
32988f25c08SKenneth D. Merry #define RDS_FORMAT_MANUFACTURER		0x04
33088f25c08SKenneth D. Merry #define RDS_FORMAT_CMGS_CPM		0x05
33188f25c08SKenneth D. Merry #define RDS_FORMAT_PROT_DISCID		0x06
33288f25c08SKenneth D. Merry #define RDS_FORMAT_DISC_KEY_BLOCK	0x07
33388f25c08SKenneth D. Merry #define RDS_FORMAT_DDS			0x08
33488f25c08SKenneth D. Merry #define RDS_FORMAT_DVDRAM_MEDIA_STAT	0x09
33588f25c08SKenneth D. Merry #define RDS_FORMAT_SPARE_AREA		0x0a
33688f25c08SKenneth D. Merry #define RDS_FORMAT_RMD_BORDEROUT	0x0c
33788f25c08SKenneth D. Merry #define RDS_FORMAT_RMD			0x0d
33888f25c08SKenneth D. Merry #define RDS_FORMAT_LEADIN		0x0e
33988f25c08SKenneth D. Merry #define RDS_FORMAT_DISC_ID		0x0f
34088f25c08SKenneth D. Merry #define RDS_FORMAT_DCB			0x30
34188f25c08SKenneth D. Merry #define RDS_FORMAT_WRITE_PROT		0xc0
34288f25c08SKenneth D. Merry #define RDS_FORMAT_STRUCTURE_LIST	0xff
343*7c5d20a6SWarner Losh 	uint8_t alloc_len[2];
344*7c5d20a6SWarner Losh 	uint8_t agid;
345*7c5d20a6SWarner Losh 	uint8_t control;
34688f25c08SKenneth D. Merry };
34788f25c08SKenneth D. Merry 
34876babe50SJustin T. Gibbs /*
34976babe50SJustin T. Gibbs  * Opcodes
35076babe50SJustin T. Gibbs  */
35176babe50SJustin T. Gibbs #define READ_CD_CAPACITY	0x25	/* slightly different from disk */
35276babe50SJustin T. Gibbs #define READ_SUBCHANNEL		0x42	/* cdrom read Subchannel */
35376babe50SJustin T. Gibbs #define READ_TOC		0x43	/* cdrom read TOC */
35476babe50SJustin T. Gibbs #define READ_HEADER		0x44	/* cdrom read header */
355050279e5SKenneth D. Merry #define PLAY_10			0x45	/* cdrom play  'play audio' mode */
35691be33dcSAlexander Motin #define GET_CONFIGURATION	0x46	/* Get device configuration */
35776babe50SJustin T. Gibbs #define PLAY_MSF		0x47	/* cdrom play Min,Sec,Frames mode */
35876babe50SJustin T. Gibbs #define PLAY_TRACK		0x48	/* cdrom play track/index mode */
35976babe50SJustin T. Gibbs #define PLAY_TRACK_REL		0x49	/* cdrom play track/index mode */
36091be33dcSAlexander Motin #define GET_EVENT_STATUS	0x4a	/* Get event status notification */
36176babe50SJustin T. Gibbs #define PAUSE			0x4b	/* cdrom pause in 'play audio' mode */
36288f25c08SKenneth D. Merry #define SEND_KEY		0xa3	/* dvd send key command */
36388f25c08SKenneth D. Merry #define REPORT_KEY		0xa4	/* dvd report key command */
364050279e5SKenneth D. Merry #define PLAY_12			0xa5	/* cdrom pause in 'play audio' mode */
36576babe50SJustin T. Gibbs #define PLAY_TRACK_REL_BIG	0xa9	/* cdrom play track/index mode */
36688f25c08SKenneth D. Merry #define READ_DVD_STRUCTURE	0xad	/* read dvd structure */
36776ba4ecdSNate Lawson #define SET_CD_SPEED		0xbb	/* set c/dvd speed */
36891be33dcSAlexander Motin #define MECHANISM_STATUS	0xbd	/* get status of c/dvd mechanics */
36976babe50SJustin T. Gibbs 
37088f25c08SKenneth D. Merry struct scsi_report_key_data_header
37188f25c08SKenneth D. Merry {
372*7c5d20a6SWarner Losh 	uint8_t data_len[2];
373*7c5d20a6SWarner Losh 	uint8_t reserved[2];
37488f25c08SKenneth D. Merry };
37576babe50SJustin T. Gibbs 
37688f25c08SKenneth D. Merry struct scsi_report_key_data_agid
37788f25c08SKenneth D. Merry {
378*7c5d20a6SWarner Losh 	uint8_t data_len[2];
379*7c5d20a6SWarner Losh 	uint8_t reserved[5];
380*7c5d20a6SWarner Losh 	uint8_t agid;
38188f25c08SKenneth D. Merry #define RKD_AGID_MASK	0xc0
38288f25c08SKenneth D. Merry #define RKD_AGID_SHIFT	6
38388f25c08SKenneth D. Merry };
38488f25c08SKenneth D. Merry 
38588f25c08SKenneth D. Merry struct scsi_report_key_data_challenge
38688f25c08SKenneth D. Merry {
387*7c5d20a6SWarner Losh 	uint8_t data_len[2];
388*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
389*7c5d20a6SWarner Losh 	uint8_t challenge_key[10];
390*7c5d20a6SWarner Losh 	uint8_t reserved1[2];
39188f25c08SKenneth D. Merry };
39288f25c08SKenneth D. Merry 
39388f25c08SKenneth D. Merry struct scsi_report_key_data_key1_key2
39488f25c08SKenneth D. Merry {
395*7c5d20a6SWarner Losh 	uint8_t data_len[2];
396*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
397*7c5d20a6SWarner Losh 	uint8_t key1[5];
398*7c5d20a6SWarner Losh 	uint8_t reserved1[3];
39988f25c08SKenneth D. Merry };
40088f25c08SKenneth D. Merry 
40188f25c08SKenneth D. Merry struct scsi_report_key_data_title
40288f25c08SKenneth D. Merry {
403*7c5d20a6SWarner Losh 	uint8_t data_len[2];
404*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
405*7c5d20a6SWarner Losh 	uint8_t byte0;
40688f25c08SKenneth D. Merry #define RKD_TITLE_CPM		0x80
40788f25c08SKenneth D. Merry #define RKD_TITLE_CPM_SHIFT	7
40888f25c08SKenneth D. Merry #define RKD_TITLE_CP_SEC	0x40
40988f25c08SKenneth D. Merry #define RKD_TITLE_CP_SEC_SHIFT	6
41088f25c08SKenneth D. Merry #define RKD_TITLE_CMGS_MASK	0x30
41188f25c08SKenneth D. Merry #define RKD_TITLE_CMGS_SHIFT	4
41288f25c08SKenneth D. Merry #define RKD_TITLE_CMGS_NO_RST	0x00
41388f25c08SKenneth D. Merry #define RKD_TITLE_CMGS_RSVD	0x10
41488f25c08SKenneth D. Merry #define RKD_TITLE_CMGS_1_GEN	0x20
41588f25c08SKenneth D. Merry #define RKD_TITLE_CMGS_NO_COPY	0x30
416*7c5d20a6SWarner Losh 	uint8_t title_key[5];
417*7c5d20a6SWarner Losh 	uint8_t reserved1[2];
41888f25c08SKenneth D. Merry };
41988f25c08SKenneth D. Merry 
42088f25c08SKenneth D. Merry struct scsi_report_key_data_asf
42188f25c08SKenneth D. Merry {
422*7c5d20a6SWarner Losh 	uint8_t data_len[2];
423*7c5d20a6SWarner Losh 	uint8_t reserved[5];
424*7c5d20a6SWarner Losh 	uint8_t success;
42588f25c08SKenneth D. Merry #define RKD_ASF_SUCCESS	0x01
42688f25c08SKenneth D. Merry };
42788f25c08SKenneth D. Merry 
42888f25c08SKenneth D. Merry struct scsi_report_key_data_rpc
42988f25c08SKenneth D. Merry {
430*7c5d20a6SWarner Losh 	uint8_t data_len[2];
431*7c5d20a6SWarner Losh 	uint8_t rpc_scheme0;
43288f25c08SKenneth D. Merry #define RKD_RPC_SCHEME_UNKNOWN		0x00
43388f25c08SKenneth D. Merry #define RKD_RPC_SCHEME_PHASE_II		0x01
434*7c5d20a6SWarner Losh 	uint8_t reserved0;
435*7c5d20a6SWarner Losh 	uint8_t byte4;
43688f25c08SKenneth D. Merry #define RKD_RPC_TYPE_MASK		0xC0
43788f25c08SKenneth D. Merry #define RKD_RPC_TYPE_SHIFT		6
43888f25c08SKenneth D. Merry #define RKD_RPC_TYPE_NONE		0x00
43988f25c08SKenneth D. Merry #define RKD_RPC_TYPE_SET		0x40
44088f25c08SKenneth D. Merry #define RKD_RPC_TYPE_LAST_CHANCE	0x80
44188f25c08SKenneth D. Merry #define RKD_RPC_TYPE_PERM		0xC0
44288f25c08SKenneth D. Merry #define RKD_RPC_VENDOR_RESET_MASK	0x38
44388f25c08SKenneth D. Merry #define RKD_RPC_VENDOR_RESET_SHIFT	3
44488f25c08SKenneth D. Merry #define RKD_RPC_USER_RESET_MASK		0x07
44588f25c08SKenneth D. Merry #define RKD_RPC_USER_RESET_SHIFT	0
446*7c5d20a6SWarner Losh 	uint8_t region_mask;
447*7c5d20a6SWarner Losh 	uint8_t rpc_scheme1;
448*7c5d20a6SWarner Losh 	uint8_t reserved1;
44988f25c08SKenneth D. Merry };
45088f25c08SKenneth D. Merry 
45188f25c08SKenneth D. Merry struct scsi_send_key_data_rpc
45288f25c08SKenneth D. Merry {
453*7c5d20a6SWarner Losh 	uint8_t data_len[2];
454*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
455*7c5d20a6SWarner Losh 	uint8_t region_code;
456*7c5d20a6SWarner Losh 	uint8_t reserved1[3];
45788f25c08SKenneth D. Merry };
45888f25c08SKenneth D. Merry 
45988f25c08SKenneth D. Merry /*
46088f25c08SKenneth D. Merry  * Common header for the return data from the READ DVD STRUCTURE command.
46188f25c08SKenneth D. Merry  */
46288f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_header
46388f25c08SKenneth D. Merry {
464*7c5d20a6SWarner Losh 	uint8_t data_len[2];
465*7c5d20a6SWarner Losh 	uint8_t reserved[2];
46688f25c08SKenneth D. Merry };
46788f25c08SKenneth D. Merry 
46888f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_layer_desc
46988f25c08SKenneth D. Merry {
470*7c5d20a6SWarner Losh 	uint8_t book_type_version;
47188f25c08SKenneth D. Merry #define RDSD_BOOK_TYPE_DVD_ROM	0x00
47288f25c08SKenneth D. Merry #define RDSD_BOOK_TYPE_DVD_RAM	0x10
47388f25c08SKenneth D. Merry #define RDSD_BOOK_TYPE_DVD_R	0x20
47488f25c08SKenneth D. Merry #define RDSD_BOOK_TYPE_DVD_RW	0x30
47588f25c08SKenneth D. Merry #define RDSD_BOOK_TYPE_DVD_PRW	0x90
47688f25c08SKenneth D. Merry #define RDSD_BOOK_TYPE_MASK	0xf0
47788f25c08SKenneth D. Merry #define RDSD_BOOK_TYPE_SHIFT	4
47888f25c08SKenneth D. Merry #define RDSD_BOOK_VERSION_MASK	0x0f
47988f25c08SKenneth D. Merry 	/*
48088f25c08SKenneth D. Merry 	 * The lower 4 bits of this field is referred to as the "minimum
48188f25c08SKenneth D. Merry 	 * rate" field in MMC2, and the "maximum rate" field in MMC3.  Ugh.
48288f25c08SKenneth D. Merry 	 */
483*7c5d20a6SWarner Losh 	uint8_t disc_size_max_rate;
48488f25c08SKenneth D. Merry #define RDSD_DISC_SIZE_120MM	0x00
48588f25c08SKenneth D. Merry #define RDSD_DISC_SIZE_80MM	0x10
48688f25c08SKenneth D. Merry #define RDSD_DISC_SIZE_MASK	0xf0
48788f25c08SKenneth D. Merry #define RDSD_DISC_SIZE_SHIFT	4
48888f25c08SKenneth D. Merry #define RDSD_MAX_RATE_0252	0x00
48988f25c08SKenneth D. Merry #define RDSD_MAX_RATE_0504	0x01
49088f25c08SKenneth D. Merry #define RDSD_MAX_RATE_1008	0x02
49188f25c08SKenneth D. Merry #define RDSD_MAX_RATE_NOT_SPEC	0x0f
49288f25c08SKenneth D. Merry #define RDSD_MAX_RATE_MASK	0x0f
493*7c5d20a6SWarner Losh 	uint8_t layer_info;
49488f25c08SKenneth D. Merry #define RDSD_NUM_LAYERS_MASK	0x60
49588f25c08SKenneth D. Merry #define RDSD_NUM_LAYERS_SHIFT	5
49688f25c08SKenneth D. Merry #define RDSD_NL_ONE_LAYER	0x00
49788f25c08SKenneth D. Merry #define RDSD_NL_TWO_LAYERS	0x20
49888f25c08SKenneth D. Merry #define RDSD_TRACK_PATH_MASK	0x10
49988f25c08SKenneth D. Merry #define RDSD_TRACK_PATH_SHIFT	4
50088f25c08SKenneth D. Merry #define RDSD_TP_PTP		0x00
50188f25c08SKenneth D. Merry #define RDSD_TP_OTP		0x10
50288f25c08SKenneth D. Merry #define RDSD_LAYER_TYPE_RO	0x01
50388f25c08SKenneth D. Merry #define RDSD_LAYER_TYPE_RECORD	0x02
50488f25c08SKenneth D. Merry #define RDSD_LAYER_TYPE_RW	0x04
50588f25c08SKenneth D. Merry #define RDSD_LAYER_TYPE_MASK	0x0f
506*7c5d20a6SWarner Losh 	uint8_t density;
50788f25c08SKenneth D. Merry #define RDSD_LIN_DENSITY_0267		0x00
50888f25c08SKenneth D. Merry #define RDSD_LIN_DENSITY_0293		0x10
50988f25c08SKenneth D. Merry #define RDSD_LIN_DENSITY_0409_0435	0x20
51088f25c08SKenneth D. Merry #define RDSD_LIN_DENSITY_0280_0291	0x40
51188f25c08SKenneth D. Merry /* XXX MMC2 uses 0.176um/bit instead of 0.353 as in MMC3 */
51288f25c08SKenneth D. Merry #define RDSD_LIN_DENSITY_0353		0x80
51388f25c08SKenneth D. Merry #define RDSD_LIN_DENSITY_MASK		0xf0
51488f25c08SKenneth D. Merry #define RDSD_LIN_DENSITY_SHIFT		4
51588f25c08SKenneth D. Merry #define RDSD_TRACK_DENSITY_074		0x00
51688f25c08SKenneth D. Merry #define RDSD_TRACK_DENSITY_080		0x01
51788f25c08SKenneth D. Merry #define RDSD_TRACK_DENSITY_0615		0x02
51888f25c08SKenneth D. Merry #define RDSD_TRACK_DENSITY_MASK		0x0f
519*7c5d20a6SWarner Losh 	uint8_t zeros0;
520*7c5d20a6SWarner Losh 	uint8_t main_data_start[3];
52188f25c08SKenneth D. Merry #define RDSD_MAIN_DATA_START_DVD_RO	0x30000
52288f25c08SKenneth D. Merry #define RDSD_MAIN_DATA_START_DVD_RW	0x31000
523*7c5d20a6SWarner Losh 	uint8_t zeros1;
524*7c5d20a6SWarner Losh 	uint8_t main_data_end[3];
525*7c5d20a6SWarner Losh 	uint8_t zeros2;
526*7c5d20a6SWarner Losh 	uint8_t end_sector_layer0[3];
527*7c5d20a6SWarner Losh 	uint8_t bca;
52888f25c08SKenneth D. Merry #define RDSD_BCA	0x80
52988f25c08SKenneth D. Merry #define RDSD_BCA_MASK	0x80
53088f25c08SKenneth D. Merry #define RDSD_BCA_SHIFT	7
531*7c5d20a6SWarner Losh 	uint8_t media_specific[2031];
53288f25c08SKenneth D. Merry };
53388f25c08SKenneth D. Merry 
53488f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_physical
53588f25c08SKenneth D. Merry {
536*7c5d20a6SWarner Losh 	uint8_t data_len[2];
537*7c5d20a6SWarner Losh 	uint8_t reserved[2];
53888f25c08SKenneth D. Merry 	struct scsi_read_dvd_struct_data_layer_desc layer_desc;
53988f25c08SKenneth D. Merry };
54088f25c08SKenneth D. Merry 
54188f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_copyright
54288f25c08SKenneth D. Merry {
543*7c5d20a6SWarner Losh 	uint8_t data_len[2];
544*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
545*7c5d20a6SWarner Losh 	uint8_t cps_type;
54688f25c08SKenneth D. Merry #define RDSD_CPS_NOT_PRESENT	0x00
54788f25c08SKenneth D. Merry #define RDSD_CPS_DATA_EXISTS	0x01
548*7c5d20a6SWarner Losh 	uint8_t region_info;
549*7c5d20a6SWarner Losh 	uint8_t reserved1[2];
55088f25c08SKenneth D. Merry };
55188f25c08SKenneth D. Merry 
55288f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_disc_key
55388f25c08SKenneth D. Merry {
554*7c5d20a6SWarner Losh 	uint8_t data_len[2];
555*7c5d20a6SWarner Losh 	uint8_t reserved[2];
556*7c5d20a6SWarner Losh 	uint8_t disc_key[2048];
55788f25c08SKenneth D. Merry };
55888f25c08SKenneth D. Merry 
55988f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_bca
56088f25c08SKenneth D. Merry {
561*7c5d20a6SWarner Losh 	uint8_t data_len[2];
562*7c5d20a6SWarner Losh 	uint8_t reserved[2];
563*7c5d20a6SWarner Losh 	uint8_t bca_info[188]; /* XXX 12-188 bytes */
56488f25c08SKenneth D. Merry };
56588f25c08SKenneth D. Merry 
56688f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_manufacturer
56788f25c08SKenneth D. Merry {
568*7c5d20a6SWarner Losh 	uint8_t data_len[2];
569*7c5d20a6SWarner Losh 	uint8_t reserved[2];
570*7c5d20a6SWarner Losh 	uint8_t manuf_info[2048];
57188f25c08SKenneth D. Merry };
57288f25c08SKenneth D. Merry 
57388f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_copy_manage
57488f25c08SKenneth D. Merry {
575*7c5d20a6SWarner Losh 	uint8_t data_len[2];
576*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
577*7c5d20a6SWarner Losh 	uint8_t byte4;
57888f25c08SKenneth D. Merry #define RDSD_CPM_NO_COPYRIGHT	0x00
57988f25c08SKenneth D. Merry #define RDSD_CPM_HAS_COPYRIGHT	0x80
58088f25c08SKenneth D. Merry #define RDSD_CPM_MASK		0x80
58188f25c08SKenneth D. Merry #define RDSD_CMGS_COPY_ALLOWED	0x00
58288f25c08SKenneth D. Merry #define RDSD_CMGS_ONE_COPY	0x20
58388f25c08SKenneth D. Merry #define RDSD_CMGS_NO_COPIES	0x30
58488f25c08SKenneth D. Merry #define RDSD_CMGS_MASK		0x30
585*7c5d20a6SWarner Losh 	uint8_t reserved1[3];
58688f25c08SKenneth D. Merry };
58788f25c08SKenneth D. Merry 
58888f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_prot_discid
58988f25c08SKenneth D. Merry {
590*7c5d20a6SWarner Losh 	uint8_t data_len[2];
591*7c5d20a6SWarner Losh 	uint8_t reserved[2];
592*7c5d20a6SWarner Losh 	uint8_t prot_discid_data[16];
59388f25c08SKenneth D. Merry };
59488f25c08SKenneth D. Merry 
59588f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_disc_key_blk
59688f25c08SKenneth D. Merry {
59788f25c08SKenneth D. Merry 	/*
59888f25c08SKenneth D. Merry 	 * Length is 0x6ffe == 28670 for CPRM, 0x3002 == 12990 for CSS2.
59988f25c08SKenneth D. Merry 	 */
600*7c5d20a6SWarner Losh 	uint8_t data_len[2];
601*7c5d20a6SWarner Losh 	uint8_t reserved;
602*7c5d20a6SWarner Losh 	uint8_t total_packs;
603*7c5d20a6SWarner Losh 	uint8_t disc_key_pack_data[28668];
60488f25c08SKenneth D. Merry };
60588f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_dds
60688f25c08SKenneth D. Merry {
607*7c5d20a6SWarner Losh 	uint8_t data_len[2];
608*7c5d20a6SWarner Losh 	uint8_t reserved[2];
609*7c5d20a6SWarner Losh 	uint8_t dds_info[2048];
61088f25c08SKenneth D. Merry };
61188f25c08SKenneth D. Merry 
61288f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_medium_status
61388f25c08SKenneth D. Merry {
614*7c5d20a6SWarner Losh 	uint8_t data_len[2];
615*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
616*7c5d20a6SWarner Losh 	uint8_t byte4;
61788f25c08SKenneth D. Merry #define RDSD_MS_CARTRIDGE	0x80
61888f25c08SKenneth D. Merry #define RDSD_MS_OUT		0x40
61988f25c08SKenneth D. Merry #define RDSD_MS_MSWI		0x08
62088f25c08SKenneth D. Merry #define RDSD_MS_CWP		0x04
62188f25c08SKenneth D. Merry #define RDSD_MS_PWP		0x02
622*7c5d20a6SWarner Losh 	uint8_t disc_type_id;
62388f25c08SKenneth D. Merry #define RDSD_DT_NEED_CARTRIDGE	0x00
62488f25c08SKenneth D. Merry #define RDSD_DT_NO_CART_NEEDED	0x01
625*7c5d20a6SWarner Losh 	uint8_t reserved1;
626*7c5d20a6SWarner Losh 	uint8_t ram_swi_info;
62788f25c08SKenneth D. Merry #define RDSD_SWI_NO_BARE	0x01
62888f25c08SKenneth D. Merry #define RDSD_SWI_UNSPEC		0xff
62988f25c08SKenneth D. Merry };
63088f25c08SKenneth D. Merry 
63188f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_spare_area
63288f25c08SKenneth D. Merry {
633*7c5d20a6SWarner Losh 	uint8_t data_len[2];
634*7c5d20a6SWarner Losh 	uint8_t reserved[2];
635*7c5d20a6SWarner Losh 	uint8_t unused_primary[4];
636*7c5d20a6SWarner Losh 	uint8_t unused_supl[4];
637*7c5d20a6SWarner Losh 	uint8_t allocated_supl[4];
63888f25c08SKenneth D. Merry };
63988f25c08SKenneth D. Merry 
64088f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_rmd_borderout
64188f25c08SKenneth D. Merry {
642*7c5d20a6SWarner Losh 	uint8_t data_len[2];
643*7c5d20a6SWarner Losh 	uint8_t reserved[2];
644*7c5d20a6SWarner Losh 	uint8_t rmd[30720]; 	/* maximum is 30720 bytes */
64588f25c08SKenneth D. Merry };
64688f25c08SKenneth D. Merry 
64788f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_rmd
64888f25c08SKenneth D. Merry {
649*7c5d20a6SWarner Losh 	uint8_t data_len[2];
650*7c5d20a6SWarner Losh 	uint8_t reserved[2];
651*7c5d20a6SWarner Losh 	uint8_t last_sector_num[4];
652*7c5d20a6SWarner Losh 	uint8_t rmd_bytes[32768];  /* This is the maximum */
65388f25c08SKenneth D. Merry };
65488f25c08SKenneth D. Merry 
65588f25c08SKenneth D. Merry /*
65688f25c08SKenneth D. Merry  * XXX KDM this is the MMC2 version of the structure.
65788f25c08SKenneth D. Merry  * The variable positions have changed (in a semi-conflicting way) in the
65888f25c08SKenneth D. Merry  * MMC3 spec, although the overall length of the structure is the same.
65988f25c08SKenneth D. Merry  */
66088f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_leadin
66188f25c08SKenneth D. Merry {
662*7c5d20a6SWarner Losh 	uint8_t data_len[2];
663*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
664*7c5d20a6SWarner Losh 	uint8_t field_id_1;
665*7c5d20a6SWarner Losh 	uint8_t app_code;
666*7c5d20a6SWarner Losh 	uint8_t disc_physical_data;
667*7c5d20a6SWarner Losh 	uint8_t last_addr[3];
668*7c5d20a6SWarner Losh 	uint8_t reserved1[2];
669*7c5d20a6SWarner Losh 	uint8_t field_id_2;
670*7c5d20a6SWarner Losh 	uint8_t rwp;
671*7c5d20a6SWarner Losh 	uint8_t rwp_wavelength;
672*7c5d20a6SWarner Losh 	uint8_t optimum_write_strategy;
673*7c5d20a6SWarner Losh 	uint8_t reserved2[4];
674*7c5d20a6SWarner Losh 	uint8_t field_id_3;
675*7c5d20a6SWarner Losh 	uint8_t manuf_id_17_12[6];
676*7c5d20a6SWarner Losh 	uint8_t reserved3;
677*7c5d20a6SWarner Losh 	uint8_t field_id_4;
678*7c5d20a6SWarner Losh 	uint8_t manuf_id_11_6[6];
679*7c5d20a6SWarner Losh 	uint8_t reserved4;
680*7c5d20a6SWarner Losh 	uint8_t field_id_5;
681*7c5d20a6SWarner Losh 	uint8_t manuf_id_5_0[6];
682*7c5d20a6SWarner Losh 	uint8_t reserved5[25];
68388f25c08SKenneth D. Merry };
68488f25c08SKenneth D. Merry 
68588f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_disc_id
68688f25c08SKenneth D. Merry {
687*7c5d20a6SWarner Losh 	uint8_t data_len[2];
688*7c5d20a6SWarner Losh 	uint8_t reserved[4];
689*7c5d20a6SWarner Losh 	uint8_t random_num[2];
690*7c5d20a6SWarner Losh 	uint8_t year[4];
691*7c5d20a6SWarner Losh 	uint8_t month[2];
692*7c5d20a6SWarner Losh 	uint8_t day[2];
693*7c5d20a6SWarner Losh 	uint8_t hour[2];
694*7c5d20a6SWarner Losh 	uint8_t minute[2];
695*7c5d20a6SWarner Losh 	uint8_t second[2];
69688f25c08SKenneth D. Merry };
69788f25c08SKenneth D. Merry 
69888f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_generic_dcb
69988f25c08SKenneth D. Merry {
700*7c5d20a6SWarner Losh 	uint8_t content_desc[4];
70188f25c08SKenneth D. Merry #define SCSI_RCB
702*7c5d20a6SWarner Losh 	uint8_t unknown_desc_actions[4];
70388f25c08SKenneth D. Merry #define RDSD_ACTION_RECORDING	0x0001
70488f25c08SKenneth D. Merry #define RDSD_ACTION_READING	0x0002
70588f25c08SKenneth D. Merry #define RDSD_ACTION_FORMAT	0x0004
70688f25c08SKenneth D. Merry #define RDSD_ACTION_MODIFY_DCB	0x0008
707*7c5d20a6SWarner Losh 	uint8_t vendor_id[32];
708*7c5d20a6SWarner Losh 	uint8_t dcb_data[32728];
70988f25c08SKenneth D. Merry };
71088f25c08SKenneth D. Merry 
71188f25c08SKenneth D. Merry struct scsi_read_dvd_struct_data_dcb
71288f25c08SKenneth D. Merry {
713*7c5d20a6SWarner Losh 	uint8_t data_len[2];
714*7c5d20a6SWarner Losh 	uint8_t reserved[2];
71588f25c08SKenneth D. Merry 	struct scsi_read_dvd_struct_data_generic_dcb dcb;
71688f25c08SKenneth D. Merry };
71788f25c08SKenneth D. Merry 
71888f25c08SKenneth D. Merry struct read_dvd_struct_write_prot
71988f25c08SKenneth D. Merry {
720*7c5d20a6SWarner Losh 	uint8_t data_len[2];
721*7c5d20a6SWarner Losh 	uint8_t reserved0[2];
722*7c5d20a6SWarner Losh 	uint8_t write_prot_status;
72388f25c08SKenneth D. Merry #define RDSD_WPS_MSWI		0x08
72488f25c08SKenneth D. Merry #define RDSD_WPS_CWP		0x04
72588f25c08SKenneth D. Merry #define RDSD_WPS_PWP		0x02
72688f25c08SKenneth D. Merry #define RDSD_WPS_SWPP		0x01
727*7c5d20a6SWarner Losh 	uint8_t reserved[3];
72888f25c08SKenneth D. Merry };
72988f25c08SKenneth D. Merry 
73088f25c08SKenneth D. Merry struct read_dvd_struct_list_entry
73188f25c08SKenneth D. Merry {
732*7c5d20a6SWarner Losh 	uint8_t format_code;
733*7c5d20a6SWarner Losh 	uint8_t sds_rds;
73488f25c08SKenneth D. Merry #define RDSD_SDS_NOT_WRITEABLE	0x00
73588f25c08SKenneth D. Merry #define RDSD_SDS_WRITEABLE	0x80
73688f25c08SKenneth D. Merry #define RDSD_SDS_MASK		0x80
73788f25c08SKenneth D. Merry #define RDSD_RDS_NOT_READABLE	0x00
73888f25c08SKenneth D. Merry #define RDSD_RDS_READABLE	0x40
73988f25c08SKenneth D. Merry #define RDSD_RDS_MASK		0x40
740*7c5d20a6SWarner Losh 	uint8_t struct_len[2];
74188f25c08SKenneth D. Merry };
74288f25c08SKenneth D. Merry 
74388f25c08SKenneth D. Merry struct read_dvd_struct_data_list
74488f25c08SKenneth D. Merry {
745*7c5d20a6SWarner Losh 	uint8_t data_len[2];
746*7c5d20a6SWarner Losh 	uint8_t reserved[2];
74788f25c08SKenneth D. Merry 	struct read_dvd_struct_list_entry entries[0];
74888f25c08SKenneth D. Merry };
74976babe50SJustin T. Gibbs 
75076babe50SJustin T. Gibbs struct scsi_read_cd_cap_data
75176babe50SJustin T. Gibbs {
752*7c5d20a6SWarner Losh 	uint8_t addr_3;	/* Most significant */
753*7c5d20a6SWarner Losh 	uint8_t addr_2;
754*7c5d20a6SWarner Losh 	uint8_t addr_1;
755*7c5d20a6SWarner Losh 	uint8_t addr_0;	/* Least significant */
756*7c5d20a6SWarner Losh 	uint8_t length_3;	/* Most significant */
757*7c5d20a6SWarner Losh 	uint8_t length_2;
758*7c5d20a6SWarner Losh 	uint8_t length_1;
759*7c5d20a6SWarner Losh 	uint8_t length_0;	/* Least significant */
76076babe50SJustin T. Gibbs };
76176babe50SJustin T. Gibbs 
76256eac725SKenneth D. Merry struct cd_audio_page
76376babe50SJustin T. Gibbs {
764*7c5d20a6SWarner Losh 	uint8_t page_code;
76576babe50SJustin T. Gibbs #define	CD_PAGE_CODE		0x3F
76676babe50SJustin T. Gibbs #define	AUDIO_PAGE		0x0e
76776babe50SJustin T. Gibbs #define	CD_PAGE_PS		0x80
768*7c5d20a6SWarner Losh 	uint8_t param_len;
769*7c5d20a6SWarner Losh 	uint8_t flags;
77076babe50SJustin T. Gibbs #define	CD_PA_SOTC		0x02
77176babe50SJustin T. Gibbs #define	CD_PA_IMMED		0x04
772*7c5d20a6SWarner Losh 	uint8_t unused[2];
773*7c5d20a6SWarner Losh 	uint8_t format_lba;
77476babe50SJustin T. Gibbs #define	CD_PA_FORMAT_LBA	0x0F
77576babe50SJustin T. Gibbs #define	CD_PA_APR_VALID		0x80
776*7c5d20a6SWarner Losh 	uint8_t lb_per_sec[2];
77776babe50SJustin T. Gibbs 	struct	port_control
77876babe50SJustin T. Gibbs 	{
779*7c5d20a6SWarner Losh 		uint8_t channels;
78076babe50SJustin T. Gibbs #define	CHANNEL			0x0F
78176babe50SJustin T. Gibbs #define	CHANNEL_0		1
78276babe50SJustin T. Gibbs #define	CHANNEL_1		2
78376babe50SJustin T. Gibbs #define	CHANNEL_2		4
78476babe50SJustin T. Gibbs #define	CHANNEL_3		8
78576babe50SJustin T. Gibbs #define	LEFT_CHANNEL		CHANNEL_0
78676babe50SJustin T. Gibbs #define	RIGHT_CHANNEL		CHANNEL_1
787*7c5d20a6SWarner Losh 		uint8_t volume;
78876babe50SJustin T. Gibbs 	} port[4];
78976babe50SJustin T. Gibbs #define	LEFT_PORT		0
79076babe50SJustin T. Gibbs #define	RIGHT_PORT		1
79156eac725SKenneth D. Merry };
79256eac725SKenneth D. Merry 
793d6e7f6e7SAlexander Motin struct scsi_cddvd_capabilities_page_sd {
794d6e7f6e7SAlexander Motin 	uint8_t reserved;
795d6e7f6e7SAlexander Motin 	uint8_t rotation_control;
796d6e7f6e7SAlexander Motin 	uint8_t write_speed_supported[2];
797d6e7f6e7SAlexander Motin };
798d6e7f6e7SAlexander Motin 
799d6e7f6e7SAlexander Motin struct scsi_cddvd_capabilities_page {
800d6e7f6e7SAlexander Motin 	uint8_t page_code;
801d6e7f6e7SAlexander Motin #define	SMS_CDDVD_CAPS_PAGE		0x2a
802d6e7f6e7SAlexander Motin 	uint8_t page_length;
803d6e7f6e7SAlexander Motin 	uint8_t caps1;
804d6e7f6e7SAlexander Motin 	uint8_t caps2;
805d6e7f6e7SAlexander Motin 	uint8_t caps3;
806d6e7f6e7SAlexander Motin 	uint8_t caps4;
807d6e7f6e7SAlexander Motin 	uint8_t caps5;
808d6e7f6e7SAlexander Motin 	uint8_t caps6;
809d6e7f6e7SAlexander Motin 	uint8_t obsolete[2];
810d6e7f6e7SAlexander Motin 	uint8_t nvol_levels[2];
811d6e7f6e7SAlexander Motin 	uint8_t buffer_size[2];
812d6e7f6e7SAlexander Motin 	uint8_t obsolete2[2];
813d6e7f6e7SAlexander Motin 	uint8_t reserved;
814d6e7f6e7SAlexander Motin 	uint8_t digital;
815d6e7f6e7SAlexander Motin 	uint8_t obsolete3;
816d6e7f6e7SAlexander Motin 	uint8_t copy_management;
817d6e7f6e7SAlexander Motin 	uint8_t reserved2;
818d6e7f6e7SAlexander Motin 	uint8_t rotation_control;
819d6e7f6e7SAlexander Motin 	uint8_t cur_write_speed;
820d6e7f6e7SAlexander Motin 	uint8_t num_speed_descr;
821d6e7f6e7SAlexander Motin 	struct scsi_cddvd_capabilities_page_sd speed_descr[];
822d6e7f6e7SAlexander Motin };
823d6e7f6e7SAlexander Motin 
82456eac725SKenneth D. Merry union cd_pages
82556eac725SKenneth D. Merry {
82656eac725SKenneth D. Merry 	struct cd_audio_page audio;
82756eac725SKenneth D. Merry };
82856eac725SKenneth D. Merry 
82956eac725SKenneth D. Merry struct cd_mode_data_10
83056eac725SKenneth D. Merry {
83156eac725SKenneth D. Merry 	struct scsi_mode_header_10 header;
83256eac725SKenneth D. Merry 	struct scsi_mode_blk_desc  blk_desc;
83356eac725SKenneth D. Merry 	union cd_pages page;
83476babe50SJustin T. Gibbs };
83576babe50SJustin T. Gibbs 
83676babe50SJustin T. Gibbs struct cd_mode_data
83776babe50SJustin T. Gibbs {
83876babe50SJustin T. Gibbs 	struct scsi_mode_header_6 header;
83976babe50SJustin T. Gibbs 	struct scsi_mode_blk_desc blk_desc;
84076babe50SJustin T. Gibbs 	union cd_pages page;
84176babe50SJustin T. Gibbs };
84288f25c08SKenneth D. Merry 
84356eac725SKenneth D. Merry union cd_mode_data_6_10
84456eac725SKenneth D. Merry {
84556eac725SKenneth D. Merry 	struct cd_mode_data mode_data_6;
84656eac725SKenneth D. Merry 	struct cd_mode_data_10 mode_data_10;
84756eac725SKenneth D. Merry };
84856eac725SKenneth D. Merry 
84956eac725SKenneth D. Merry struct cd_mode_params
85056eac725SKenneth D. Merry {
85156eac725SKenneth D. Merry 	STAILQ_ENTRY(cd_mode_params)	links;
85256eac725SKenneth D. Merry 	int				cdb_size;
85356eac725SKenneth D. Merry 	int				alloc_len;
854*7c5d20a6SWarner Losh 	uint8_t			*mode_buf;
85556eac725SKenneth D. Merry };
85656eac725SKenneth D. Merry 
85788f25c08SKenneth D. Merry __BEGIN_DECLS
858*7c5d20a6SWarner Losh void scsi_report_key(struct ccb_scsiio *csio, uint32_t retries,
85988f25c08SKenneth D. Merry 		     void (*cbfcnp)(struct cam_periph *, union ccb *),
860*7c5d20a6SWarner Losh 		     uint8_t tag_action, uint32_t lba, uint8_t agid,
861*7c5d20a6SWarner Losh 		     uint8_t key_format, uint8_t *data_ptr,
862*7c5d20a6SWarner Losh 		     uint32_t dxfer_len, uint8_t sense_len,
863*7c5d20a6SWarner Losh 		     uint32_t timeout);
86488f25c08SKenneth D. Merry 
865*7c5d20a6SWarner Losh void scsi_send_key(struct ccb_scsiio *csio, uint32_t retries,
86688f25c08SKenneth D. Merry 		   void (*cbfcnp)(struct cam_periph *, union ccb *),
867*7c5d20a6SWarner Losh 		   uint8_t tag_action, uint8_t agid, uint8_t key_format,
868*7c5d20a6SWarner Losh 		   uint8_t *data_ptr, uint32_t dxfer_len, uint8_t sense_len,
869*7c5d20a6SWarner Losh 		   uint32_t timeout);
87088f25c08SKenneth D. Merry 
871*7c5d20a6SWarner Losh void scsi_read_dvd_structure(struct ccb_scsiio *csio, uint32_t retries,
87288f25c08SKenneth D. Merry 			     void (*cbfcnp)(struct cam_periph *, union ccb *),
873*7c5d20a6SWarner Losh 			     uint8_t tag_action, uint32_t address,
874*7c5d20a6SWarner Losh 			     uint8_t layer_number, uint8_t format,
875*7c5d20a6SWarner Losh 			     uint8_t agid, uint8_t *data_ptr,
876*7c5d20a6SWarner Losh 			     uint32_t dxfer_len, uint8_t sense_len,
877*7c5d20a6SWarner Losh 			     uint32_t timeout);
87888f25c08SKenneth D. Merry 
879dd78f432SAndriy Gapon void scsi_read_toc(struct ccb_scsiio *csio, uint32_t retries,
880dd78f432SAndriy Gapon 		   void (*cbfcnp)(struct cam_periph *, union ccb *),
881dd78f432SAndriy Gapon 		   uint8_t tag_action, uint8_t byte1_flags, uint8_t format,
882dd78f432SAndriy Gapon 		   uint8_t track, uint8_t *data_ptr, uint32_t dxfer_len,
883dd78f432SAndriy Gapon 		   int sense_len, int timeout);
884dd78f432SAndriy Gapon 
88588f25c08SKenneth D. Merry __END_DECLS
88688f25c08SKenneth D. Merry 
88776babe50SJustin T. Gibbs #endif /*_SCSI_SCSI_CD_H*/
888