blob: fcdc11b9609b7c2efc4318811375a30574d7c586 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * -- <linux/cdrom.h>
3 * General header file for linux CD-ROM drivers
4 * Copyright (C) 1992 David Giller, rafetmad@oxy.edu
Jan Engelhardt96de0e22007-10-19 23:21:04 +02005 * 1994, 1995 Eberhard Mönkeberg, emoenke@gwdg.de
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * 1996 David van Leeuwen, david@tm.tno.nl
7 * 1997, 1998 Erik Andersen, andersee@debian.org
8 * 1998-2002 Jens Axboe, axboe@suse.de
9 */
10
11#ifndef _LINUX_CDROM_H
12#define _LINUX_CDROM_H
13
14#include <asm/byteorder.h>
15
16/*******************************************************
17 * As of Linux 2.1.x, all Linux CD-ROM application programs will use this
18 * (and only this) include file. It is my hope to provide Linux with
19 * a uniform interface between software accessing CD-ROMs and the various
20 * device drivers that actually talk to the drives. There may still be
21 * 23 different kinds of strange CD-ROM drives, but at least there will
22 * now be one, and only one, Linux CD-ROM interface.
23 *
24 * Additionally, as of Linux 2.1.x, all Linux application programs
25 * should use the O_NONBLOCK option when opening a CD-ROM device
26 * for subsequent ioctl commands. This allows for neat system errors
27 * like "No medium found" or "Wrong medium type" upon attempting to
28 * mount or play an empty slot, mount an audio disc, or play a data disc.
29 * Generally, changing an application program to support O_NONBLOCK
30 * is as easy as the following:
31 * - drive = open("/dev/cdrom", O_RDONLY);
32 * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
33 * It is worth the small change.
34 *
35 * Patches for many common CD programs (provided by David A. van Leeuwen)
36 * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/
37 *
38 *******************************************************/
39
40/* When a driver supports a certain function, but the cdrom drive we are
41 * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will
42 * borrow the "Operation not supported" error from the network folks to
43 * accomplish this. Maybe someday we will get a more targeted error code,
44 * but this will do for now... */
45#define EDRIVE_CANT_DO_THIS EOPNOTSUPP
46
47/*******************************************************
48 * The CD-ROM IOCTL commands -- these should be supported by
49 * all the various cdrom drivers. For the CD-ROM ioctls, we
50 * will commandeer byte 0x53, or 'S'.
51 *******************************************************/
52#define CDROMPAUSE 0x5301 /* Pause Audio Operation */
53#define CDROMRESUME 0x5302 /* Resume paused Audio Operation */
54#define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
55#define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
56 (struct cdrom_ti) */
57#define CDROMREADTOCHDR 0x5305 /* Read TOC header
58 (struct cdrom_tochdr) */
59#define CDROMREADTOCENTRY 0x5306 /* Read TOC entry
60 (struct cdrom_tocentry) */
61#define CDROMSTOP 0x5307 /* Stop the cdrom drive */
62#define CDROMSTART 0x5308 /* Start the cdrom drive */
63#define CDROMEJECT 0x5309 /* Ejects the cdrom media */
64#define CDROMVOLCTRL 0x530a /* Control output volume
65 (struct cdrom_volctrl) */
66#define CDROMSUBCHNL 0x530b /* Read subchannel data
67 (struct cdrom_subchnl) */
68#define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes)
69 (struct cdrom_read) */
70#define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes)
71 (struct cdrom_read) */
72#define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
73#define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
74#define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
75 address of multi session disks
76 (struct cdrom_multisession) */
77#define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
78 if available (struct cdrom_mcn) */
Rolf Eike Beer405bbe92007-10-20 03:10:57 +020079#define CDROM_GET_UPC CDROM_GET_MCN /* This one is deprecated,
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 but here anyway for compatibility */
81#define CDROMRESET 0x5312 /* hard-reset the drive */
82#define CDROMVOLREAD 0x5313 /* Get the drive's volume setting
83 (struct cdrom_volctrl) */
84#define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
85 (struct cdrom_read) */
86/*
87 * These ioctls are used only used in aztcd.c and optcd.c
88 */
89#define CDROMREADCOOKED 0x5315 /* read data in cooked mode */
90#define CDROMSEEK 0x5316 /* seek msf address */
91
92/*
93 * This ioctl is only used by the scsi-cd driver.
94 It is for playing audio in logical block addressing mode.
95 */
96#define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
97
98/*
99 * These ioctls are only used in optcd.c
100 */
101#define CDROMREADALL 0x5318 /* read all 2646 bytes */
102
103/*
104 * These ioctls are (now) only in ide-cd.c for controlling
105 * drive spindown time. They should be implemented in the
106 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
107 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
108 * -Erik
109 */
110#define CDROMGETSPINDOWN 0x531d
111#define CDROMSETSPINDOWN 0x531e
112
113/*
114 * These ioctls are implemented through the uniform CD-ROM driver
115 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
116 * drivers are eventually ported to the uniform CD-ROM driver interface.
117 */
118#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
119#define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
120#define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
121#define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
122#define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
123#define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
124#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
125#define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
126#define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
127#define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
128#define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
129#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
130
131/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
132 * Future CDROM ioctls should be kept below 0x537F
133 */
134
135/* This ioctl is only used by sbpcd at the moment */
136#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
137 /* conflict with SCSI_IOCTL_GET_IDLUN */
138
139/* DVD-ROM Specific ioctls */
140#define DVD_READ_STRUCT 0x5390 /* Read structure */
141#define DVD_WRITE_STRUCT 0x5391 /* Write structure */
142#define DVD_AUTH 0x5392 /* Authentication */
143
144#define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
145#define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
146#define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
147
148/*******************************************************
149 * CDROM IOCTL structures
150 *******************************************************/
151
152/* Address in MSF format */
153struct cdrom_msf0
154{
155 __u8 minute;
156 __u8 second;
157 __u8 frame;
158};
159
160/* Address in either MSF or logical format */
161union cdrom_addr
162{
163 struct cdrom_msf0 msf;
164 int lba;
165};
166
167/* This struct is used by the CDROMPLAYMSF ioctl */
168struct cdrom_msf
169{
170 __u8 cdmsf_min0; /* start minute */
171 __u8 cdmsf_sec0; /* start second */
172 __u8 cdmsf_frame0; /* start frame */
173 __u8 cdmsf_min1; /* end minute */
174 __u8 cdmsf_sec1; /* end second */
175 __u8 cdmsf_frame1; /* end frame */
176};
177
178/* This struct is used by the CDROMPLAYTRKIND ioctl */
179struct cdrom_ti
180{
181 __u8 cdti_trk0; /* start track */
182 __u8 cdti_ind0; /* start index */
183 __u8 cdti_trk1; /* end track */
184 __u8 cdti_ind1; /* end index */
185};
186
187/* This struct is used by the CDROMREADTOCHDR ioctl */
188struct cdrom_tochdr
189{
190 __u8 cdth_trk0; /* start track */
191 __u8 cdth_trk1; /* end track */
192};
193
194/* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */
195struct cdrom_volctrl
196{
197 __u8 channel0;
198 __u8 channel1;
199 __u8 channel2;
200 __u8 channel3;
201};
202
203/* This struct is used by the CDROMSUBCHNL ioctl */
204struct cdrom_subchnl
205{
206 __u8 cdsc_format;
207 __u8 cdsc_audiostatus;
208 __u8 cdsc_adr: 4;
209 __u8 cdsc_ctrl: 4;
210 __u8 cdsc_trk;
211 __u8 cdsc_ind;
212 union cdrom_addr cdsc_absaddr;
213 union cdrom_addr cdsc_reladdr;
214};
215
216
217/* This struct is used by the CDROMREADTOCENTRY ioctl */
218struct cdrom_tocentry
219{
220 __u8 cdte_track;
221 __u8 cdte_adr :4;
222 __u8 cdte_ctrl :4;
223 __u8 cdte_format;
224 union cdrom_addr cdte_addr;
225 __u8 cdte_datamode;
226};
227
228/* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */
229struct cdrom_read
230{
231 int cdread_lba;
232 char *cdread_bufaddr;
233 int cdread_buflen;
234};
235
236/* This struct is used by the CDROMREADAUDIO ioctl */
237struct cdrom_read_audio
238{
239 union cdrom_addr addr; /* frame address */
240 __u8 addr_format; /* CDROM_LBA or CDROM_MSF */
241 int nframes; /* number of 2352-byte-frames to read at once */
242 __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */
243};
244
245/* This struct is used with the CDROMMULTISESSION ioctl */
246struct cdrom_multisession
247{
248 union cdrom_addr addr; /* frame address: start-of-last-session
249 (not the new "frame 16"!). Only valid
250 if the "xa_flag" is true. */
251 __u8 xa_flag; /* 1: "is XA disk" */
252 __u8 addr_format; /* CDROM_LBA or CDROM_MSF */
253};
254
255/* This struct is used with the CDROM_GET_MCN ioctl.
256 * Very few audio discs actually have Universal Product Code information,
257 * which should just be the Medium Catalog Number on the box. Also note
258 * that the way the codeis written on CD is _not_ uniform across all discs!
259 */
260struct cdrom_mcn
261{
262 __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
263};
264
265/* This is used by the CDROMPLAYBLK ioctl */
266struct cdrom_blk
267{
268 unsigned from;
269 unsigned short len;
270};
271
272#define CDROM_PACKET_SIZE 12
273
274#define CGC_DATA_UNKNOWN 0
275#define CGC_DATA_WRITE 1
276#define CGC_DATA_READ 2
277#define CGC_DATA_NONE 3
278
279/* for CDROM_PACKET_COMMAND ioctl */
280struct cdrom_generic_command
281{
282 unsigned char cmd[CDROM_PACKET_SIZE];
283 unsigned char __user *buffer;
284 unsigned int buflen;
285 int stat;
286 struct request_sense __user *sense;
287 unsigned char data_direction;
288 int quiet;
289 int timeout;
290 void __user *reserved[1]; /* unused, actually */
291};
292
293/*
294 * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336,
295 * 2340, or 2352 bytes long.
296
297* Sector types of the standard CD-ROM data formats:
298 *
299 * format sector type user data size (bytes)
300 * -----------------------------------------------------------------------------
301 * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW)
302 * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE)
303 * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0)
304 * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE)
305 * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes)
306 *
307 *
308 * The layout of the standard CD-ROM data formats:
309 * -----------------------------------------------------------------------------
310 * - audio (red): | audio_sample_bytes |
311 * | 2352 |
312 *
313 * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC |
314 * | 12 - 4 - 2048 - 4 - 8 - 276 |
315 *
316 * - data (yellow, mode2): | sync - head - data |
317 * | 12 - 4 - 2336 |
318 *
319 * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
320 * | 12 - 4 - 8 - 2048 - 4 - 276 |
321 *
322 * - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
323 * | 12 - 4 - 8 - 2324 - 4 |
324 *
325 */
326
327/* Some generally useful CD-ROM information -- mostly based on the above */
328#define CD_MINS 74 /* max. minutes per CD, not really a limit */
329#define CD_SECS 60 /* seconds per minute */
330#define CD_FRAMES 75 /* frames per second */
331#define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */
332#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */
333#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */
334#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */
335#define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */
336#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */
337#define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */
338#define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */
339#define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */
340#define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */
341#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */
342#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */
343#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */
344/* most drives don't deliver everything: */
345#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
346#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
347
348#define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
349#define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
350#define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */
351
352/* CD-ROM address types (cdrom_tocentry.cdte_format) */
353#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */
354#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
355
356/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */
357#define CDROM_DATA_TRACK 0x04
358
359/* The leadout track is always 0xAA, regardless of # of tracks on disc */
360#define CDROM_LEADOUT 0xAA
361
362/* audio states (from SCSI-2, but seen with other drives, too) */
363#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */
364#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */
365#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */
366#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */
367#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */
368#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */
369
370/* capability flags used with the uniform CD-ROM driver */
371#define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */
372#define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */
373#define CDC_LOCK 0x4 /* disable manual eject */
374#define CDC_SELECT_SPEED 0x8 /* programmable speed */
375#define CDC_SELECT_DISC 0x10 /* select disc from juke-box */
376#define CDC_MULTI_SESSION 0x20 /* read sessions>1 */
377#define CDC_MCN 0x40 /* Medium Catalog Number */
378#define CDC_MEDIA_CHANGED 0x80 /* media changed */
379#define CDC_PLAY_AUDIO 0x100 /* audio functions */
380#define CDC_RESET 0x200 /* hard reset device */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */
382#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */
383#define CDC_CD_R 0x2000 /* drive is a CD-R */
384#define CDC_CD_RW 0x4000 /* drive is a CD-RW */
385#define CDC_DVD 0x8000 /* drive is a DVD */
386#define CDC_DVD_R 0x10000 /* drive can write DVD-R */
387#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */
388#define CDC_MO_DRIVE 0x40000 /* drive is an MO device */
389#define CDC_MRW 0x80000 /* drive can read MRW */
390#define CDC_MRW_W 0x100000 /* drive can write MRW */
391#define CDC_RAM 0x200000 /* ok to open for WRITE */
392
393/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
394#define CDS_NO_INFO 0 /* if not implemented */
395#define CDS_NO_DISC 1
396#define CDS_TRAY_OPEN 2
397#define CDS_DRIVE_NOT_READY 3
398#define CDS_DISC_OK 4
399
400/* return values for the CDROM_DISC_STATUS ioctl */
401/* can also return CDS_NO_[INFO|DISC], from above */
402#define CDS_AUDIO 100
403#define CDS_DATA_1 101
404#define CDS_DATA_2 102
405#define CDS_XA_2_1 103
406#define CDS_XA_2_2 104
407#define CDS_MIXED 105
408
409/* User-configurable behavior options for the uniform CD-ROM driver */
410#define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */
411#define CDO_AUTO_EJECT 0x2 /* open tray on last release() */
412#define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */
413#define CDO_LOCK 0x8 /* lock tray on open files */
414#define CDO_CHECK_TYPE 0x10 /* check type on open for data */
415
416/* Special codes used when specifying changer slots. */
Robert P. J. Day132e4b02007-07-15 23:41:19 -0700417#define CDSL_NONE (INT_MAX-1)
418#define CDSL_CURRENT INT_MAX
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
420/* For partition based multisession access. IDE can handle 64 partitions
421 * per drive - SCSI CD-ROM's use minors to differentiate between the
422 * various drives, so we can't do multisessions the same way there.
423 * Use the -o session=x option to mount on them.
424 */
425#define CD_PART_MAX 64
426#define CD_PART_MASK (CD_PART_MAX - 1)
427
428/*********************************************************************
429 * Generic Packet commands, MMC commands, and such
430 *********************************************************************/
431
432 /* The generic packet command opcodes for CD/DVD Logical Units,
433 * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
434#define GPCMD_BLANK 0xa1
435#define GPCMD_CLOSE_TRACK 0x5b
436#define GPCMD_FLUSH_CACHE 0x35
437#define GPCMD_FORMAT_UNIT 0x04
438#define GPCMD_GET_CONFIGURATION 0x46
439#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
440#define GPCMD_GET_PERFORMANCE 0xac
441#define GPCMD_INQUIRY 0x12
442#define GPCMD_LOAD_UNLOAD 0xa6
443#define GPCMD_MECHANISM_STATUS 0xbd
444#define GPCMD_MODE_SELECT_10 0x55
445#define GPCMD_MODE_SENSE_10 0x5a
446#define GPCMD_PAUSE_RESUME 0x4b
447#define GPCMD_PLAY_AUDIO_10 0x45
448#define GPCMD_PLAY_AUDIO_MSF 0x47
449#define GPCMD_PLAY_AUDIO_TI 0x48
450#define GPCMD_PLAY_CD 0xbc
451#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
452#define GPCMD_READ_10 0x28
453#define GPCMD_READ_12 0xa8
Tejun Heo537b53c2007-12-05 16:43:04 +0900454#define GPCMD_READ_BUFFER 0x3c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455#define GPCMD_READ_BUFFER_CAPACITY 0x5c
456#define GPCMD_READ_CDVD_CAPACITY 0x25
457#define GPCMD_READ_CD 0xbe
458#define GPCMD_READ_CD_MSF 0xb9
459#define GPCMD_READ_DISC_INFO 0x51
460#define GPCMD_READ_DVD_STRUCTURE 0xad
461#define GPCMD_READ_FORMAT_CAPACITIES 0x23
462#define GPCMD_READ_HEADER 0x44
463#define GPCMD_READ_TRACK_RZONE_INFO 0x52
464#define GPCMD_READ_SUBCHANNEL 0x42
465#define GPCMD_READ_TOC_PMA_ATIP 0x43
466#define GPCMD_REPAIR_RZONE_TRACK 0x58
467#define GPCMD_REPORT_KEY 0xa4
468#define GPCMD_REQUEST_SENSE 0x03
469#define GPCMD_RESERVE_RZONE_TRACK 0x53
470#define GPCMD_SEND_CUE_SHEET 0x5d
471#define GPCMD_SCAN 0xba
472#define GPCMD_SEEK 0x2b
473#define GPCMD_SEND_DVD_STRUCTURE 0xbf
474#define GPCMD_SEND_EVENT 0xa2
475#define GPCMD_SEND_KEY 0xa3
476#define GPCMD_SEND_OPC 0x54
477#define GPCMD_SET_READ_AHEAD 0xa7
478#define GPCMD_SET_STREAMING 0xb6
479#define GPCMD_START_STOP_UNIT 0x1b
480#define GPCMD_STOP_PLAY_SCAN 0x4e
481#define GPCMD_TEST_UNIT_READY 0x00
482#define GPCMD_VERIFY_10 0x2f
483#define GPCMD_WRITE_10 0x2a
Tejun Heo537b53c2007-12-05 16:43:04 +0900484#define GPCMD_WRITE_12 0xaa
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485#define GPCMD_WRITE_AND_VERIFY_10 0x2e
Tejun Heo537b53c2007-12-05 16:43:04 +0900486#define GPCMD_WRITE_BUFFER 0x3b
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487/* This is listed as optional in ATAPI 2.6, but is (curiously)
488 * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji
489 * Table 377 as an MMC command for SCSi devices though... Most ATAPI
490 * drives support it. */
491#define GPCMD_SET_SPEED 0xbb
492/* This seems to be a SCSI specific CD-ROM opcode
493 * to play data at track/index */
494#define GPCMD_PLAYAUDIO_TI 0x48
495/*
496 * From MS Media Status Notification Support Specification. For
497 * older drives only.
498 */
499#define GPCMD_GET_MEDIA_STATUS 0xda
500
501/* Mode page codes for mode sense/set */
502#define GPMODE_VENDOR_PAGE 0x00
503#define GPMODE_R_W_ERROR_PAGE 0x01
504#define GPMODE_WRITE_PARMS_PAGE 0x05
505#define GPMODE_WCACHING_PAGE 0x08
506#define GPMODE_AUDIO_CTL_PAGE 0x0e
507#define GPMODE_POWER_PAGE 0x1a
508#define GPMODE_FAULT_FAIL_PAGE 0x1c
509#define GPMODE_TO_PROTECT_PAGE 0x1d
510#define GPMODE_CAPABILITIES_PAGE 0x2a
511#define GPMODE_ALL_PAGES 0x3f
Rolf Eike Beer405bbe92007-10-20 03:10:57 +0200512/* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 * of MODE_SENSE_POWER_PAGE */
514#define GPMODE_CDROM_PAGE 0x0d
515
516
517
518/* DVD struct types */
519#define DVD_STRUCT_PHYSICAL 0x00
520#define DVD_STRUCT_COPYRIGHT 0x01
521#define DVD_STRUCT_DISCKEY 0x02
522#define DVD_STRUCT_BCA 0x03
523#define DVD_STRUCT_MANUFACT 0x04
524
525struct dvd_layer {
526 __u8 book_version : 4;
527 __u8 book_type : 4;
528 __u8 min_rate : 4;
529 __u8 disc_size : 4;
530 __u8 layer_type : 4;
531 __u8 track_path : 1;
532 __u8 nlayers : 2;
533 __u8 track_density : 4;
534 __u8 linear_density : 4;
535 __u8 bca : 1;
536 __u32 start_sector;
537 __u32 end_sector;
538 __u32 end_sector_l0;
539};
540
541#define DVD_LAYERS 4
542
543struct dvd_physical {
544 __u8 type;
545 __u8 layer_num;
546 struct dvd_layer layer[DVD_LAYERS];
547};
548
549struct dvd_copyright {
550 __u8 type;
551
552 __u8 layer_num;
553 __u8 cpst;
554 __u8 rmi;
555};
556
557struct dvd_disckey {
558 __u8 type;
559
560 unsigned agid : 2;
561 __u8 value[2048];
562};
563
564struct dvd_bca {
565 __u8 type;
566
567 int len;
568 __u8 value[188];
569};
570
571struct dvd_manufact {
572 __u8 type;
573
574 __u8 layer_num;
575 int len;
576 __u8 value[2048];
577};
578
579typedef union {
580 __u8 type;
581
582 struct dvd_physical physical;
583 struct dvd_copyright copyright;
584 struct dvd_disckey disckey;
585 struct dvd_bca bca;
586 struct dvd_manufact manufact;
587} dvd_struct;
588
589/*
590 * DVD authentication ioctl
591 */
592
593/* Authentication states */
594#define DVD_LU_SEND_AGID 0
595#define DVD_HOST_SEND_CHALLENGE 1
596#define DVD_LU_SEND_KEY1 2
597#define DVD_LU_SEND_CHALLENGE 3
598#define DVD_HOST_SEND_KEY2 4
599
600/* Termination states */
601#define DVD_AUTH_ESTABLISHED 5
602#define DVD_AUTH_FAILURE 6
603
604/* Other functions */
605#define DVD_LU_SEND_TITLE_KEY 7
606#define DVD_LU_SEND_ASF 8
607#define DVD_INVALIDATE_AGID 9
608#define DVD_LU_SEND_RPC_STATE 10
609#define DVD_HOST_SEND_RPC_STATE 11
610
611/* State data */
612typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */
613typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
614
615struct dvd_lu_send_agid {
616 __u8 type;
617 unsigned agid : 2;
618};
619
620struct dvd_host_send_challenge {
621 __u8 type;
622 unsigned agid : 2;
623
624 dvd_challenge chal;
625};
626
627struct dvd_send_key {
628 __u8 type;
629 unsigned agid : 2;
630
631 dvd_key key;
632};
633
634struct dvd_lu_send_challenge {
635 __u8 type;
636 unsigned agid : 2;
637
638 dvd_challenge chal;
639};
640
641#define DVD_CPM_NO_COPYRIGHT 0
642#define DVD_CPM_COPYRIGHTED 1
643
644#define DVD_CP_SEC_NONE 0
645#define DVD_CP_SEC_EXIST 1
646
647#define DVD_CGMS_UNRESTRICTED 0
648#define DVD_CGMS_SINGLE 2
649#define DVD_CGMS_RESTRICTED 3
650
651struct dvd_lu_send_title_key {
652 __u8 type;
653 unsigned agid : 2;
654
655 dvd_key title_key;
656 int lba;
657 unsigned cpm : 1;
658 unsigned cp_sec : 1;
659 unsigned cgms : 2;
660};
661
662struct dvd_lu_send_asf {
663 __u8 type;
664 unsigned agid : 2;
665
666 unsigned asf : 1;
667};
668
669struct dvd_host_send_rpcstate {
670 __u8 type;
671 __u8 pdrc;
672};
673
674struct dvd_lu_send_rpcstate {
675 __u8 type : 2;
676 __u8 vra : 3;
677 __u8 ucca : 3;
678 __u8 region_mask;
679 __u8 rpc_scheme;
680};
681
682typedef union {
683 __u8 type;
684
685 struct dvd_lu_send_agid lsa;
686 struct dvd_host_send_challenge hsc;
687 struct dvd_send_key lsk;
688 struct dvd_lu_send_challenge lsc;
689 struct dvd_send_key hsk;
690 struct dvd_lu_send_title_key lstk;
691 struct dvd_lu_send_asf lsasf;
692 struct dvd_host_send_rpcstate hrpcs;
693 struct dvd_lu_send_rpcstate lrpcs;
694} dvd_authinfo;
695
696struct request_sense {
697#if defined(__BIG_ENDIAN_BITFIELD)
698 __u8 valid : 1;
699 __u8 error_code : 7;
700#elif defined(__LITTLE_ENDIAN_BITFIELD)
701 __u8 error_code : 7;
702 __u8 valid : 1;
703#endif
704 __u8 segment_number;
705#if defined(__BIG_ENDIAN_BITFIELD)
706 __u8 reserved1 : 2;
707 __u8 ili : 1;
708 __u8 reserved2 : 1;
709 __u8 sense_key : 4;
710#elif defined(__LITTLE_ENDIAN_BITFIELD)
711 __u8 sense_key : 4;
712 __u8 reserved2 : 1;
713 __u8 ili : 1;
714 __u8 reserved1 : 2;
715#endif
716 __u8 information[4];
717 __u8 add_sense_len;
718 __u8 command_info[4];
719 __u8 asc;
720 __u8 ascq;
721 __u8 fruc;
722 __u8 sks[3];
723 __u8 asb[46];
724};
725
726/*
727 * feature profile
728 */
729#define CDF_RWRT 0x0020 /* "Random Writable" */
730#define CDF_HWDM 0x0024 /* "Hardware Defect Management" */
731#define CDF_MRW 0x0028
732
733/*
734 * media status bits
735 */
736#define CDM_MRW_NOTMRW 0
737#define CDM_MRW_BGFORMAT_INACTIVE 1
738#define CDM_MRW_BGFORMAT_ACTIVE 2
739#define CDM_MRW_BGFORMAT_COMPLETE 3
740
741/*
742 * mrw address spaces
743 */
744#define MRW_LBA_DMA 0
745#define MRW_LBA_GAA 1
746
747/*
748 * mrw mode pages (first is deprecated) -- probed at init time and
749 * cdi->mrw_mode_page is set
750 */
751#define MRW_MODE_PC_PRE1 0x2c
752#define MRW_MODE_PC 0x03
753
754struct mrw_feature_desc {
Alexey Dobriyan56052d52005-12-01 17:10:40 -0500755 __be16 feature_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756#if defined(__BIG_ENDIAN_BITFIELD)
757 __u8 reserved1 : 2;
758 __u8 feature_version : 4;
759 __u8 persistent : 1;
760 __u8 curr : 1;
761#elif defined(__LITTLE_ENDIAN_BITFIELD)
762 __u8 curr : 1;
763 __u8 persistent : 1;
764 __u8 feature_version : 4;
765 __u8 reserved1 : 2;
766#endif
767 __u8 add_len;
768#if defined(__BIG_ENDIAN_BITFIELD)
769 __u8 reserved2 : 7;
770 __u8 write : 1;
771#elif defined(__LITTLE_ENDIAN_BITFIELD)
772 __u8 write : 1;
773 __u8 reserved2 : 7;
774#endif
775 __u8 reserved3;
776 __u8 reserved4;
777 __u8 reserved5;
778};
779
780/* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */
781struct rwrt_feature_desc {
Alexey Dobriyan56052d52005-12-01 17:10:40 -0500782 __be16 feature_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783#if defined(__BIG_ENDIAN_BITFIELD)
784 __u8 reserved1 : 2;
785 __u8 feature_version : 4;
786 __u8 persistent : 1;
787 __u8 curr : 1;
788#elif defined(__LITTLE_ENDIAN_BITFIELD)
789 __u8 curr : 1;
790 __u8 persistent : 1;
791 __u8 feature_version : 4;
792 __u8 reserved1 : 2;
793#endif
794 __u8 add_len;
795 __u32 last_lba;
796 __u32 block_size;
797 __u16 blocking;
798#if defined(__BIG_ENDIAN_BITFIELD)
799 __u8 reserved2 : 7;
800 __u8 page_present : 1;
801#elif defined(__LITTLE_ENDIAN_BITFIELD)
802 __u8 page_present : 1;
803 __u8 reserved2 : 7;
804#endif
805 __u8 reserved3;
806};
807
808typedef struct {
Alexey Dobriyan56052d52005-12-01 17:10:40 -0500809 __be16 disc_information_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810#if defined(__BIG_ENDIAN_BITFIELD)
811 __u8 reserved1 : 3;
812 __u8 erasable : 1;
813 __u8 border_status : 2;
814 __u8 disc_status : 2;
815#elif defined(__LITTLE_ENDIAN_BITFIELD)
816 __u8 disc_status : 2;
817 __u8 border_status : 2;
818 __u8 erasable : 1;
819 __u8 reserved1 : 3;
820#else
821#error "Please fix <asm/byteorder.h>"
822#endif
823 __u8 n_first_track;
824 __u8 n_sessions_lsb;
825 __u8 first_track_lsb;
826 __u8 last_track_lsb;
827#if defined(__BIG_ENDIAN_BITFIELD)
828 __u8 did_v : 1;
829 __u8 dbc_v : 1;
830 __u8 uru : 1;
831 __u8 reserved2 : 2;
832 __u8 dbit : 1;
833 __u8 mrw_status : 2;
834#elif defined(__LITTLE_ENDIAN_BITFIELD)
835 __u8 mrw_status : 2;
836 __u8 dbit : 1;
837 __u8 reserved2 : 2;
838 __u8 uru : 1;
839 __u8 dbc_v : 1;
840 __u8 did_v : 1;
841#endif
842 __u8 disc_type;
843 __u8 n_sessions_msb;
844 __u8 first_track_msb;
845 __u8 last_track_msb;
846 __u32 disc_id;
847 __u32 lead_in;
848 __u32 lead_out;
849 __u8 disc_bar_code[8];
850 __u8 reserved3;
851 __u8 n_opc;
852} disc_information;
853
854typedef struct {
Alexey Dobriyan56052d52005-12-01 17:10:40 -0500855 __be16 track_information_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 __u8 track_lsb;
857 __u8 session_lsb;
858 __u8 reserved1;
859#if defined(__BIG_ENDIAN_BITFIELD)
860 __u8 reserved2 : 2;
861 __u8 damage : 1;
862 __u8 copy : 1;
863 __u8 track_mode : 4;
864 __u8 rt : 1;
865 __u8 blank : 1;
866 __u8 packet : 1;
867 __u8 fp : 1;
868 __u8 data_mode : 4;
869 __u8 reserved3 : 6;
870 __u8 lra_v : 1;
871 __u8 nwa_v : 1;
872#elif defined(__LITTLE_ENDIAN_BITFIELD)
873 __u8 track_mode : 4;
874 __u8 copy : 1;
875 __u8 damage : 1;
876 __u8 reserved2 : 2;
877 __u8 data_mode : 4;
878 __u8 fp : 1;
879 __u8 packet : 1;
880 __u8 blank : 1;
881 __u8 rt : 1;
882 __u8 nwa_v : 1;
883 __u8 lra_v : 1;
884 __u8 reserved3 : 6;
885#endif
Alexey Dobriyan56052d52005-12-01 17:10:40 -0500886 __be32 track_start;
887 __be32 next_writable;
888 __be32 free_blocks;
889 __be32 fixed_packet_size;
890 __be32 track_size;
891 __be32 last_rec_address;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892} track_information;
893
894struct feature_header {
895 __u32 data_len;
896 __u8 reserved1;
897 __u8 reserved2;
898 __u16 curr_profile;
899};
900
901struct mode_page_header {
Alexey Dobriyan56052d52005-12-01 17:10:40 -0500902 __be16 mode_data_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 __u8 medium_type;
904 __u8 reserved1;
905 __u8 reserved2;
906 __u8 reserved3;
Alexey Dobriyan56052d52005-12-01 17:10:40 -0500907 __be16 desc_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908};
909
910#ifdef __KERNEL__
911#include <linux/fs.h> /* not really needed, later.. */
912#include <linux/device.h>
913
914struct packet_command
915{
916 unsigned char cmd[CDROM_PACKET_SIZE];
917 unsigned char *buffer;
918 unsigned int buflen;
919 int stat;
920 struct request_sense *sense;
921 unsigned char data_direction;
922 int quiet;
923 int timeout;
924 void *reserved[1];
925};
926
927/*
928 * _OLD will use PIO transfer on atapi devices, _BPC_* will use DMA
929 */
930#define CDDA_OLD 0 /* old style */
931#define CDDA_BPC_SINGLE 1 /* single frame block pc */
932#define CDDA_BPC_FULL 2 /* multi frame block pc */
933
934/* Uniform cdrom data structures for cdrom.c */
935struct cdrom_device_info {
936 struct cdrom_device_ops *ops; /* link to device_ops */
937 struct cdrom_device_info *next; /* next device_info for this major */
938 struct gendisk *disk; /* matching block layer disk */
939 void *handle; /* driver-dependent data */
940/* specifications */
941 int mask; /* mask of capability: disables them */
942 int speed; /* maximum speed for reading data */
943 int capacity; /* number of discs in jukebox */
944/* device-related storage */
Randy Dunlap0cba01d2007-02-20 13:58:05 -0800945 unsigned int options : 30; /* options flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 unsigned mc_flags : 2; /* media change buffer flags */
947 int use_count; /* number of times device opened */
948 char name[20]; /* name of the device type */
949/* per-device flags */
950 __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */
951 __u8 reserved : 6; /* not used yet */
952 int cdda_method; /* see flags */
953 __u8 last_sense;
954 __u8 media_written; /* dirty flag, DVD+RW bookkeeping */
955 unsigned short mmc3_profile; /* current MMC3 profile */
956 int for_data;
957 int (*exit)(struct cdrom_device_info *);
958 int mrw_mode_page;
959};
960
961struct cdrom_device_ops {
962/* routines */
963 int (*open) (struct cdrom_device_info *, int);
964 void (*release) (struct cdrom_device_info *);
965 int (*drive_status) (struct cdrom_device_info *, int);
966 int (*media_changed) (struct cdrom_device_info *, int);
967 int (*tray_move) (struct cdrom_device_info *, int);
968 int (*lock_door) (struct cdrom_device_info *, int);
969 int (*select_speed) (struct cdrom_device_info *, int);
970 int (*select_disc) (struct cdrom_device_info *, int);
971 int (*get_last_session) (struct cdrom_device_info *,
972 struct cdrom_multisession *);
973 int (*get_mcn) (struct cdrom_device_info *,
974 struct cdrom_mcn *);
975 /* hard reset device */
976 int (*reset) (struct cdrom_device_info *);
977 /* play stuff */
978 int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
Christoph Hellwig6a2900b2006-03-23 03:00:15 -0800979
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980/* driver specifications */
981 const int capability; /* capability flags */
982 int n_minors; /* number of active minor devices */
983 /* handle uniform packets for scsi type devices (scsi,atapi) */
984 int (*generic_packet) (struct cdrom_device_info *,
985 struct packet_command *);
986};
987
988/* the general block_device operations structure: */
989extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip,
990 struct file *fp);
991extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp);
992extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi,
993 struct inode *ip, unsigned int cmd, unsigned long arg);
994extern int cdrom_media_changed(struct cdrom_device_info *);
995
996extern int register_cdrom(struct cdrom_device_info *cdi);
997extern int unregister_cdrom(struct cdrom_device_info *cdi);
998
999typedef struct {
1000 int data;
1001 int audio;
1002 int cdi;
1003 int xa;
1004 long error;
1005} tracktype;
1006
1007extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written);
1008extern int cdrom_number_of_slots(struct cdrom_device_info *cdi);
1009extern int cdrom_mode_select(struct cdrom_device_info *cdi,
1010 struct packet_command *cgc);
1011extern int cdrom_mode_sense(struct cdrom_device_info *cdi,
1012 struct packet_command *cgc,
1013 int page_code, int page_control);
1014extern void init_cdrom_command(struct packet_command *cgc,
1015 void *buffer, int len, int type);
1016
1017/* The SCSI spec says there could be 256 slots. */
1018#define CDROM_MAX_SLOTS 256
1019
1020struct cdrom_mechstat_header {
1021#if defined(__BIG_ENDIAN_BITFIELD)
1022 __u8 fault : 1;
1023 __u8 changer_state : 2;
1024 __u8 curslot : 5;
1025 __u8 mech_state : 3;
1026 __u8 door_open : 1;
1027 __u8 reserved1 : 4;
1028#elif defined(__LITTLE_ENDIAN_BITFIELD)
1029 __u8 curslot : 5;
1030 __u8 changer_state : 2;
1031 __u8 fault : 1;
1032 __u8 reserved1 : 4;
1033 __u8 door_open : 1;
1034 __u8 mech_state : 3;
1035#endif
1036 __u8 curlba[3];
1037 __u8 nslots;
1038 __u16 slot_tablelen;
1039};
1040
1041struct cdrom_slot {
1042#if defined(__BIG_ENDIAN_BITFIELD)
1043 __u8 disc_present : 1;
1044 __u8 reserved1 : 6;
1045 __u8 change : 1;
1046#elif defined(__LITTLE_ENDIAN_BITFIELD)
1047 __u8 change : 1;
1048 __u8 reserved1 : 6;
1049 __u8 disc_present : 1;
1050#endif
1051 __u8 reserved2[3];
1052};
1053
1054struct cdrom_changer_info {
1055 struct cdrom_mechstat_header hdr;
1056 struct cdrom_slot slots[CDROM_MAX_SLOTS];
1057};
1058
1059typedef enum {
1060 mechtype_caddy = 0,
1061 mechtype_tray = 1,
1062 mechtype_popup = 2,
1063 mechtype_individual_changer = 4,
1064 mechtype_cartridge_changer = 5
1065} mechtype_t;
1066
1067typedef struct {
1068#if defined(__BIG_ENDIAN_BITFIELD)
1069 __u8 ps : 1;
1070 __u8 reserved1 : 1;
1071 __u8 page_code : 6;
1072 __u8 page_length;
1073 __u8 reserved2 : 1;
1074 __u8 bufe : 1;
1075 __u8 ls_v : 1;
1076 __u8 test_write : 1;
1077 __u8 write_type : 4;
1078 __u8 multi_session : 2; /* or border, DVD */
1079 __u8 fp : 1;
1080 __u8 copy : 1;
1081 __u8 track_mode : 4;
1082 __u8 reserved3 : 4;
1083 __u8 data_block_type : 4;
1084#elif defined(__LITTLE_ENDIAN_BITFIELD)
1085 __u8 page_code : 6;
1086 __u8 reserved1 : 1;
1087 __u8 ps : 1;
1088 __u8 page_length;
1089 __u8 write_type : 4;
1090 __u8 test_write : 1;
1091 __u8 ls_v : 1;
1092 __u8 bufe : 1;
1093 __u8 reserved2 : 1;
1094 __u8 track_mode : 4;
1095 __u8 copy : 1;
1096 __u8 fp : 1;
1097 __u8 multi_session : 2; /* or border, DVD */
1098 __u8 data_block_type : 4;
1099 __u8 reserved3 : 4;
1100#endif
1101 __u8 link_size;
1102 __u8 reserved4;
1103#if defined(__BIG_ENDIAN_BITFIELD)
1104 __u8 reserved5 : 2;
1105 __u8 app_code : 6;
1106#elif defined(__LITTLE_ENDIAN_BITFIELD)
1107 __u8 app_code : 6;
1108 __u8 reserved5 : 2;
1109#endif
1110 __u8 session_format;
1111 __u8 reserved6;
Alexey Dobriyan56052d52005-12-01 17:10:40 -05001112 __be32 packet_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 __u16 audio_pause;
1114 __u8 mcn[16];
1115 __u8 isrc[16];
1116 __u8 subhdr0;
1117 __u8 subhdr1;
1118 __u8 subhdr2;
1119 __u8 subhdr3;
1120} __attribute__((packed)) write_param_page;
1121
1122struct modesel_head
1123{
1124 __u8 reserved1;
1125 __u8 medium;
1126 __u8 reserved2;
1127 __u8 block_desc_length;
1128 __u8 density;
1129 __u8 number_of_blocks_hi;
1130 __u8 number_of_blocks_med;
1131 __u8 number_of_blocks_lo;
1132 __u8 reserved3;
1133 __u8 block_length_hi;
1134 __u8 block_length_med;
1135 __u8 block_length_lo;
1136};
1137
1138typedef struct {
1139 __u16 report_key_length;
1140 __u8 reserved1;
1141 __u8 reserved2;
1142#if defined(__BIG_ENDIAN_BITFIELD)
1143 __u8 type_code : 2;
1144 __u8 vra : 3;
1145 __u8 ucca : 3;
1146#elif defined(__LITTLE_ENDIAN_BITFIELD)
1147 __u8 ucca : 3;
1148 __u8 vra : 3;
1149 __u8 type_code : 2;
1150#endif
1151 __u8 region_mask;
1152 __u8 rpc_scheme;
1153 __u8 reserved3;
1154} rpc_state_t;
1155
1156struct event_header {
Alexey Dobriyan56052d52005-12-01 17:10:40 -05001157 __be16 data_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158#if defined(__BIG_ENDIAN_BITFIELD)
1159 __u8 nea : 1;
1160 __u8 reserved1 : 4;
1161 __u8 notification_class : 3;
1162#elif defined(__LITTLE_ENDIAN_BITFIELD)
1163 __u8 notification_class : 3;
1164 __u8 reserved1 : 4;
1165 __u8 nea : 1;
1166#endif
1167 __u8 supp_event_class;
1168};
1169
1170struct media_event_desc {
1171#if defined(__BIG_ENDIAN_BITFIELD)
1172 __u8 reserved1 : 4;
1173 __u8 media_event_code : 4;
1174 __u8 reserved2 : 6;
1175 __u8 media_present : 1;
1176 __u8 door_open : 1;
1177#elif defined(__LITTLE_ENDIAN_BITFIELD)
1178 __u8 media_event_code : 4;
1179 __u8 reserved1 : 4;
1180 __u8 door_open : 1;
1181 __u8 media_present : 1;
1182 __u8 reserved2 : 6;
1183#endif
1184 __u8 start_slot;
1185 __u8 end_slot;
1186};
1187
1188extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med);
1189
1190#endif /* End of kernel only stuff */
1191
1192#endif /* _LINUX_CDROM_H */