xref: /illumos-gate/usr/src/uts/common/sys/cdio.h (revision 2d6eb4a5)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_CDIO_H
28 #define	_SYS_CDIO_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * CDROM io controls type definitions
36  */
37 struct cdrom_msf {
38 	unsigned char	cdmsf_min0;	/* starting minute */
39 	unsigned char	cdmsf_sec0;	/* starting second */
40 	unsigned char	cdmsf_frame0;	/* starting frame  */
41 	unsigned char	cdmsf_min1;	/* ending minute   */
42 	unsigned char	cdmsf_sec1;	/* ending second   */
43 	unsigned char	cdmsf_frame1;	/* ending frame	   */
44 };
45 
46 struct cdrom_ti {
47 	unsigned char	cdti_trk0;	/* starting track */
48 	unsigned char	cdti_ind0;	/* starting index */
49 	unsigned char	cdti_trk1;	/* ending track */
50 	unsigned char	cdti_ind1;	/* ending index */
51 };
52 
53 struct cdrom_tochdr {
54 	unsigned char	cdth_trk0;	/* starting track */
55 	unsigned char	cdth_trk1;	/* ending track */
56 };
57 
58 struct cdrom_tocentry {
59 	unsigned char	cdte_track;
60 	unsigned	cdte_adr	:4;
61 	unsigned	cdte_ctrl	:4;
62 	unsigned char	cdte_format;
63 	union {
64 		struct {
65 			unsigned char	minute;
66 			unsigned char	second;
67 			unsigned char	frame;
68 		} msf;
69 		int	lba;
70 	} cdte_addr;
71 	unsigned char	cdte_datamode;
72 };
73 
74 /*
75  * CDROM address format definition, for use with struct cdrom_tocentry
76  */
77 #define	CDROM_LBA	0x01
78 #define	CDROM_MSF	0x02
79 
80 /*
81  * Bitmask for CD-ROM data track in the cdte_ctrl field
82  * A track is either data or audio.
83  */
84 #define	CDROM_DATA_TRACK	0x04
85 
86 /*
87  * For CDROMREADTOCENTRY, set the cdte_track to CDROM_LEADOUT to get
88  * the information for the leadout track.
89  */
90 #define	CDROM_LEADOUT	0xAA
91 
92 struct cdrom_subchnl {
93 	unsigned char	cdsc_format;
94 	unsigned char	cdsc_audiostatus;
95 	unsigned	cdsc_adr:	4;
96 	unsigned	cdsc_ctrl:	4;
97 	unsigned char	cdsc_trk;
98 	unsigned char	cdsc_ind;
99 	union {
100 		struct {
101 			unsigned char	minute;
102 			unsigned char	second;
103 			unsigned char	frame;
104 		} msf;
105 		int	lba;
106 	} cdsc_absaddr;
107 	union {
108 		struct {
109 			unsigned char	minute;
110 			unsigned char	second;
111 			unsigned char	frame;
112 		} msf;
113 		int	lba;
114 	} cdsc_reladdr;
115 };
116 
117 /*
118  * Definition for audio status returned from Read Sub-channel
119  */
120 #define	CDROM_AUDIO_INVALID	0x00	/* audio status not supported */
121 #define	CDROM_AUDIO_PLAY	0x11	/* audio play operation in progress */
122 #define	CDROM_AUDIO_PAUSED	0x12	/* audio play operation paused */
123 #define	CDROM_AUDIO_COMPLETED	0x13	/* audio play successfully completed */
124 #define	CDROM_AUDIO_ERROR	0x14	/* audio play stopped due to error */
125 #define	CDROM_AUDIO_NO_STATUS	0x15	/* no current audio status to return */
126 
127 /*
128  * definition of audio volume control structure
129  */
130 struct cdrom_volctrl {
131 	unsigned char	channel0;
132 	unsigned char	channel1;
133 	unsigned char	channel2;
134 	unsigned char	channel3;
135 };
136 
137 struct cdrom_read {
138 	int		cdread_lba;
139 	caddr_t		cdread_bufaddr;
140 	int		cdread_buflen;
141 };
142 
143 #if defined(_SYSCALL32)
144 
145 struct cdrom_read32 {
146 	int		cdread_lba;
147 	caddr32_t	cdread_bufaddr;
148 	int		cdread_buflen;
149 };
150 
151 #define	cdrom_read32tocdrom_read(cdrd32, cdrd)				\
152 	cdrd->cdread_lba	= cdrd32->cdread_lba;			\
153 	cdrd->cdread_bufaddr	= (caddr_t)(uintptr_t)cdrd32->cdread_bufaddr; \
154 	cdrd->cdread_buflen	= cdrd32->cdread_buflen
155 
156 #define	cdrom_readtocdrom_read32(cdrd, cdrd32)				\
157 	cdrd32->cdread_lba	= cdrd->cdread_lba;			\
158 	cdrd32->cdread_bufaddr	= (caddr32_t)(uintptr_t)cdrd->cdread_bufaddr; \
159 	cdrd32->cdread_buflen	= cdrd->cdread_buflen
160 
161 #endif	/* _SYSCALL32 */
162 
163 /*
164  * Definition of CD/DA structure
165  */
166 struct cdrom_cdda {
167 	unsigned int	cdda_addr;
168 	unsigned int	cdda_length;
169 	caddr_t		cdda_data;
170 	unsigned char	cdda_subcode;
171 };
172 
173 #if defined(_SYSCALL32)
174 struct cdrom_cdda32 {
175 	unsigned int	cdda_addr;
176 	unsigned int	cdda_length;
177 	caddr32_t	cdda_data;
178 	unsigned char	cdda_subcode;
179 };
180 
181 #define	cdrom_cdda32tocdrom_cdda(cdda32, cdda)			\
182 	cdda->cdda_addr		= cdda32->cdda_addr;		\
183 	cdda->cdda_length	= cdda32->cdda_length;		\
184 	cdda->cdda_data		= (caddr_t)(uintptr_t)cdda32->cdda_data; \
185 	cdda->cdda_subcode	= cdda32->cdda_subcode
186 
187 #define	cdrom_cddatocdrom_cdda32(cdda, cdda32)			\
188 	cdda32->cdda_addr	= cdda->cdda_addr;		\
189 	cdda32->cdda_length	= cdda->cdda_length;		\
190 	cdda32->cdda_data	= (caddr32_t)(uintptr_t)cdda->cdda_data; \
191 	cdda32->cdda_subcode	= cdda->cdda_subcode
192 
193 #endif	/* _SYSCALL32 */
194 
195 /*
196  * Definitions for cdda_subcode field
197  */
198 #define	CDROM_DA_NO_SUBCODE	0x00	/* CD/DA data with no subcode */
199 #define	CDROM_DA_SUBQ		0x01	/* CD/DA data with sub Q code */
200 #define	CDROM_DA_ALL_SUBCODE	0x02	/* CD/DA data with all subcode */
201 #define	CDROM_DA_SUBCODE_ONLY	0x03	/* All subcode only */
202 
203 /*
204  * Definition of CD/XA structure
205  */
206 struct cdrom_cdxa {
207 	unsigned int	cdxa_addr;
208 	unsigned int	cdxa_length;
209 	caddr_t		cdxa_data;
210 	unsigned char	cdxa_format;
211 };
212 
213 #if defined(_SYSCALL32)
214 
215 struct cdrom_cdxa32 {
216 	unsigned int	cdxa_addr;
217 	unsigned int	cdxa_length;
218 	caddr32_t	cdxa_data;
219 	unsigned char	cdxa_format;
220 };
221 
222 #define	cdrom_cdxa32tocdrom_cdxa(cdxa32, cdxa)				\
223 	cdxa->cdxa_addr		= cdxa32->cdxa_addr;			\
224 	cdxa->cdxa_length	= cdxa32->cdxa_length;			\
225 	cdxa->cdxa_data		= (caddr_t)(uintptr_t)cdxa32->cdxa_data; \
226 	cdxa->cdxa_format	= cdxa32->cdxa_format
227 
228 #define	cdrom_cdxatocdrom_cdxa32(cdxa, cdxa32)				\
229 	cdxa32->cdxa_addr	= cdxa->cdxa_addr;			\
230 	cdxa32->cdxa_length	= cdxa->cdxa_length;			\
231 	cdxa32->cdxa_data	= (caddr32_t)(uintptr_t)cdxa->cdxa_data; \
232 	cdxa32->cdxa_format	= cdxa->cdxa_format
233 
234 #endif	/* _SYSCALL32 */
235 
236 /*
237  * Definitions for cdxa_format field
238  */
239 #define	CDROM_XA_DATA		0x00	/* CD/XA data only */
240 #define	CDROM_XA_SECTOR_DATA	0x01	/* CD/XA all sector data */
241 #define	CDROM_XA_DATA_W_ERROR	0x02	/* CD/XA data with error flags data */
242 
243 /*
244  * Definition of subcode structure
245  */
246 struct cdrom_subcode {
247 	unsigned int	cdsc_length;
248 	caddr_t		cdsc_addr;
249 };
250 
251 #if defined(_SYSCALL32)
252 
253 struct cdrom_subcode32 {
254 	unsigned int	cdsc_length;
255 	caddr32_t	cdsc_addr;
256 };
257 
258 #define	cdrom_subcode32tocdrom_subcode(cdsc32, cdsc)			\
259 	cdsc->cdsc_length	= cdsc32->cdsc_length;			\
260 	cdsc->cdsc_addr		= (caddr_t)(uintptr_t)cdsc32->cdsc_addr
261 
262 #define	cdrom_subcodetocdrom_subcode32(cdsc, cdsc32)			\
263 	cdsc32->cdsc_length	= cdsc->cdsc_length;			\
264 	cdsc32->cdsc_addr	= (caddr32_t)(uintptr_t)cdsc->cdsc_addr
265 
266 #endif	/* _SYSCALL32 */
267 
268 /*
269  * Definitions for block size supported
270  */
271 #define	CDROM_BLK_512		512
272 #define	CDROM_BLK_1024		1024
273 #define	CDROM_BLK_2048		2048
274 #define	CDROM_BLK_2056		2056
275 #define	CDROM_BLK_2324		2324
276 #define	CDROM_BLK_2336		2336
277 #define	CDROM_BLK_2340		2340
278 #define	CDROM_BLK_2352		2352
279 #define	CDROM_BLK_2368		2368
280 #define	CDROM_BLK_2448		2448
281 #define	CDROM_BLK_2646		2646
282 #define	CDROM_BLK_2647		2647
283 #define	CDROM_BLK_SUBCODE	96
284 
285 /*
286  * Definitions for drive speed supported
287  */
288 #define	CDROM_NORMAL_SPEED	0x00
289 #define	CDROM_DOUBLE_SPEED	0x01
290 #define	CDROM_QUAD_SPEED	0x03
291 #define	CDROM_TWELVE_SPEED	0x0C
292 #define	CDROM_MAXIMUM_SPEED	0xff
293 
294 /*
295  * CDROM io control commands
296  */
297 #define	CDIOC			(0x04 << 8)
298 #define	CDROMPAUSE		(CDIOC|151)	/* Pause Audio Operation */
299 #define	CDROMRESUME		(CDIOC|152) /* Resume paused Audio Operation */
300 #define	CDROMPLAYMSF		(CDIOC|153)	/* Play Audio MSF */
301 #define	CDROMPLAYTRKIND		(CDIOC|154)	/* Play Audio Track/index */
302 #define	CDROMREADTOCHDR		(CDIOC|155)	/* Read TOC header */
303 #define	CDROMREADTOCENTRY	(CDIOC|156)	/* Read a TOC entry */
304 #define	CDROMSTOP		(CDIOC|157)	/* Stop the cdrom drive */
305 #define	CDROMSTART		(CDIOC|158)	/* Start the cdrom drive */
306 #define	CDROMEJECT		(CDIOC|159)	/* Ejects the cdrom caddy */
307 #define	CDROMVOLCTRL		(CDIOC|160)	/* control output volume */
308 #define	CDROMSUBCHNL		(CDIOC|161)	/* read the subchannel data */
309 #define	CDROMREADMODE2		(CDIOC|162)	/* read CDROM mode 2 data */
310 #define	CDROMREADMODE1		(CDIOC|163)	/* read CDROM mode 1 data */
311 
312 #define	CDROMREADOFFSET		(CDIOC|164)	/* read multi-session offset */
313 
314 #define	CDROMGBLKMODE		(CDIOC|165)	/* get current block mode */
315 #define	CDROMSBLKMODE		(CDIOC|166)	/* set current block mode */
316 #define	CDROMCDDA		(CDIOC|167)	/* read CD/DA data */
317 #define	CDROMCDXA		(CDIOC|168)	/* read CD/XA data */
318 #define	CDROMSUBCODE		(CDIOC|169)	/* read subcode */
319 #define	CDROMGDRVSPEED		(CDIOC|170)	/* get current drive speed */
320 #define	CDROMSDRVSPEED		(CDIOC|171)	/* set current drive speed */
321 
322 #define	CDROMCLOSETRAY		(CDIOC|172)	/* close cd tray,load media */
323 
324 /*
325  * Additional commands for CD-ROM
326  */
327 /*
328  *
329  *	Group 2 Commands
330  *
331  */
332 #define	SCMD_READ_SUBCHANNEL	0x42		/* optional SCSI command */
333 #define	SCMD_READ_TOC		0x43		/* optional SCSI command */
334 #define	SCMD_READ_HEADER	0x44		/* optional SCSI command */
335 #define	SCMD_PLAYAUDIO10	0x45		/* optional SCSI command */
336 #define	SCMD_PLAYAUDIO_MSF	0x47		/* optional SCSI command */
337 #define	SCMD_PLAYAUDIO_TI	0x48		/* optional SCSI command */
338 #define	SCMD_PLAYTRACK_REL10	0x49		/* optional SCSI command */
339 #define	SCMD_PAUSE_RESUME	0x4B		/* optional SCSI command */
340 
341 /*
342  *
343  *	Group 5 Commands
344  *
345  */
346 #define	SCMD_PLAYAUDIO12	0xA5		/* optional SCSI command */
347 #define	SCMD_PLAYTRACK_REL12	0xA9		/* optional SCSI command */
348 #define	SCMD_SET_CDROM_SPEED	0xBB		/* optional SCSI command */
349 #define	SCMD_READ_CD		0xBE	/* Universal way of accessing CD data */
350 
351 /*
352  * These defines are for SCMD_READ_CD command.
353  * See Expected Sector Type Field Definition (SCSI MMC-2 Spec section 6.1.15)
354  * This information is used to figure out which block size to use.
355  */
356 #define	READ_CD_EST_ALLTYPE	0x0	/* All Types */
357 #define	READ_CD_EST_CDDA	0x1	/* Only CD-DA */
358 #define	READ_CD_EST_MODE1	0x2	/* Only Yellow Book 2048 bytes */
359 #define	READ_CD_EST_MODE2	0x3	/* Only Yellow Book 2336 byte sectors */
360 #define	READ_CD_EST_MODE2FORM1	0x4	/* Only sectors with 2048 bytes */
361 #define	READ_CD_EST_MODE2FORM2	0x5	/* Only sectors with 2324 bytes */
362 #define	READ_CD_EST_RSVD1	0x6	/* reserved */
363 #define	READ_CD_EST_RSVD2	0x7	/* reserved */
364 
365 
366 /*
367  *
368  *	Group 6 Commands
369  *
370  */
371 #define	SCMD_CD_PLAYBACK_CONTROL 0xC9	/* SONY unique SCSI command */
372 #define	SCMD_CD_PLAYBACK_STATUS	0xC4	/* SONY unique SCSI command */
373 #define	SCMD_READ_CDDA		0xD8	/* Vendor unique SCSI command */
374 #define	SCMD_READ_CDXA		0xDB	/* Vendor unique SCSI command */
375 #define	SCMD_READ_ALL_SUBCODES	0xDF	/* Vendor unique SCSI command */
376 
377 #define	CDROM_MODE2_SIZE	2336
378 
379 /*
380  * scsi_key_strings for CDROM cdio SCMD_ definitions
381  */
382 #define	SCSI_CMDS_KEY_STRINGS_CDIO				\
383 /* 0x42 */ SCMD_READ_SUBCHANNEL,	"read_subchannel",		\
384 /* 0x43 */ SCMD_READ_TOC,		"read_toc",			\
385 /* 0x44 */ SCMD_REPORT_DENSITIES |					\
386 		SCMD_READ_HEADER,	"report_densities/read_header",	\
387 /* 0x45 */ SCMD_PLAYAUDIO10,		"playaudio",			\
388 /* 0x46 */ SCMD_GET_CONFIGURATION,	"get_configuration",		\
389 /* 0x47 */ SCMD_PLAYAUDIO_MSF,		"playaudio_msf",		\
390 /* 0x48 */ SCMD_PLAYAUDIO_TI,		"playaudio_ti",			\
391 /* 0x49 */ SCMD_PLAYTRACK_REL10,	"playaudio_rel",		\
392 /* 0x4b */ SCMD_PAUSE_RESUME,		"pause_resume",			\
393 									\
394 /* 0xa5 */ SCMD_PLAYAUDIO12,		"playaudio(12)",		\
395 /* 0xa9 */ SCMD_PLAYTRACK_REL12,	"playtrack_rel",		\
396 /* 0xbb */ SCMD_SET_CDROM_SPEED,	"set_cd_speed",			\
397 /* 0xbe */ SCMD_READ_CD,		"read_cd",			\
398 									\
399 /* 0xc4 */ SCMD_CD_PLAYBACK_STATUS,	"cd_playback_status",		\
400 /* 0xc9 */ SCMD_CD_PLAYBACK_CONTROL,	"cd_playback_control",		\
401 /* 0xd8 */ SCMD_READ_CDDA,		"read_cdda",			\
402 /* 0xdb */ SCMD_READ_CDXA,		"read_cdxa",			\
403 /* 0xdf */ SCMD_READ_ALL_SUBCODES,	"read_all_subcodes"
404 
405 #ifdef	__cplusplus
406 }
407 #endif
408 
409 #endif	/* _SYS_CDIO_H */
410