]> git.sesse.net Git - vlc/blob - plugins/dvd/dvd_ioctl.h
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / plugins / dvd / dvd_ioctl.h
1 /*****************************************************************************
2  * dvd_ioctl.h: DVD ioctl replacement function
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id: dvd_ioctl.h,v 1.1 2001/02/20 07:49:12 sam Exp $
6  *
7  * Authors: David Giller <rafetmad@oxy.edu>
8  *          Eberhard Moenkeberg <emoenke@gwdg.de>
9  *          David van Leeuwen <david@tm.tno.nl>
10  *          Erik Andersen <andersee@debian.org>
11  *          Jens Axboe <axboe@suse.de>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
26  *****************************************************************************/
27
28 int dvd_ioctl( int i_fd, unsigned long i_op, void *p_arg );
29
30 /*****************************************************************************
31  * This is the Linux kernel's <linux/cdrom.h>, almost verbatim.
32  *****************************************************************************/
33
34 /*
35  * -- <linux/cdrom.h>
36  * General header file for linux CD-ROM drivers 
37  * Copyright (C) 1992         David Giller, rafetmad@oxy.edu
38  *               1994, 1995   Eberhard Moenkeberg, emoenke@gwdg.de
39  *               1996         David van Leeuwen, david@tm.tno.nl
40  *               1997, 1998   Erik Andersen, andersee@debian.org
41  *               1998-2000    Jens Axboe, axboe@suse.de
42  */
43
44 #ifndef _LINUX_CDROM_H
45 #define _LINUX_CDROM_H
46
47 #ifdef SYS_BEOS
48 #   include <be/support/byteorder.h>
49 #else
50 #   include <asm/byteorder.h>
51 #endif
52
53 /*******************************************************
54  * As of Linux 2.1.x, all Linux CD-ROM application programs will use this 
55  * (and only this) include file.  It is my hope to provide Linux with
56  * a uniform interface between software accessing CD-ROMs and the various 
57  * device drivers that actually talk to the drives.  There may still be
58  * 23 different kinds of strange CD-ROM drives, but at least there will 
59  * now be one, and only one, Linux CD-ROM interface.
60  *
61  * Additionally, as of Linux 2.1.x, all Linux application programs 
62  * should use the O_NONBLOCK option when opening a CD-ROM device 
63  * for subsequent ioctl commands.  This allows for neat system errors 
64  * like "No medium found" or "Wrong medium type" upon attempting to 
65  * mount or play an empty slot, mount an audio disc, or play a data disc.
66  * Generally, changing an application program to support O_NONBLOCK
67  * is as easy as the following:
68  *       -    drive = open("/dev/cdrom", O_RDONLY);
69  *       +    drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
70  * It is worth the small change.
71  *
72  *  Patches for many common CD programs (provided by David A. van Leeuwen)
73  *  can be found at:  ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/
74  * 
75  *******************************************************/
76
77 /* When a driver supports a certain function, but the cdrom drive we are 
78  * using doesn't, we will return the error EDRIVE_CANT_DO_THIS.  We will 
79  * borrow the "Operation not supported" error from the network folks to 
80  * accomplish this.  Maybe someday we will get a more targeted error code, 
81  * but this will do for now... */
82 #define EDRIVE_CANT_DO_THIS  EOPNOTSUPP
83
84 /*******************************************************
85  * The CD-ROM IOCTL commands  -- these should be supported by 
86  * all the various cdrom drivers.  For the CD-ROM ioctls, we 
87  * will commandeer byte 0x53, or 'S'.
88  *******************************************************/
89 #define CDROMPAUSE              0x5301 /* Pause Audio Operation */ 
90 #define CDROMRESUME             0x5302 /* Resume paused Audio Operation */
91 #define CDROMPLAYMSF            0x5303 /* Play Audio MSF (struct cdrom_msf) */
92 #define CDROMPLAYTRKIND         0x5304 /* Play Audio Track/index 
93                                            (struct cdrom_ti) */
94 #define CDROMREADTOCHDR         0x5305 /* Read TOC header 
95                                            (struct cdrom_tochdr) */
96 #define CDROMREADTOCENTRY       0x5306 /* Read TOC entry 
97                                            (struct cdrom_tocentry) */
98 #define CDROMSTOP               0x5307 /* Stop the cdrom drive */
99 #define CDROMSTART              0x5308 /* Start the cdrom drive */
100 #define CDROMEJECT              0x5309 /* Ejects the cdrom media */
101 #define CDROMVOLCTRL            0x530a /* Control output volume 
102                                            (struct cdrom_volctrl) */
103 #define CDROMSUBCHNL            0x530b /* Read subchannel data 
104                                            (struct cdrom_subchnl) */
105 #define CDROMREADMODE2          0x530c /* Read CDROM mode 2 data (2336 Bytes) 
106                                            (struct cdrom_read) */
107 #define CDROMREADMODE1          0x530d /* Read CDROM mode 1 data (2048 Bytes)
108                                            (struct cdrom_read) */
109 #define CDROMREADAUDIO          0x530e /* (struct cdrom_read_audio) */
110 #define CDROMEJECT_SW           0x530f /* enable(1)/disable(0) auto-ejecting */
111 #define CDROMMULTISESSION       0x5310 /* Obtain the start-of-last-session 
112                                            address of multi session disks 
113                                            (struct cdrom_multisession) */
114 #define CDROM_GET_MCN           0x5311 /* Obtain the "Universal Product Code" 
115                                            if available (struct cdrom_mcn) */
116 #define CDROM_GET_UPC           CDROM_GET_MCN  /* This one is depricated, 
117                                           but here anyway for compatability */
118 #define CDROMRESET              0x5312 /* hard-reset the drive */
119 #define CDROMVOLREAD            0x5313 /* Get the drive's volume setting 
120                                           (struct cdrom_volctrl) */
121 #define CDROMREADRAW            0x5314  /* read data in raw mode (2352 Bytes)
122                                            (struct cdrom_read) */
123 /* 
124  * These ioctls are used only used in aztcd.c and optcd.c
125  */
126 #define CDROMREADCOOKED         0x5315  /* read data in cooked mode */
127 #define CDROMSEEK               0x5316  /* seek msf address */
128   
129 /*
130  * This ioctl is only used by the scsi-cd driver.  
131    It is for playing audio in logical block addressing mode.
132  */
133 #define CDROMPLAYBLK            0x5317  /* (struct cdrom_blk) */
134
135 /* 
136  * These ioctls are only used in optcd.c
137  */
138 #define CDROMREADALL            0x5318  /* read all 2646 bytes */
139
140 /* 
141  * These ioctls are (now) only in ide-cd.c for controlling 
142  * drive spindown time.  They should be implemented in the
143  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
144  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
145  *  -Erik
146  */
147 #define CDROMGETSPINDOWN        0x531d
148 #define CDROMSETSPINDOWN        0x531e
149
150 /* 
151  * These ioctls are implemented through the uniform CD-ROM driver
152  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
153  * drivers are eventually ported to the uniform CD-ROM driver interface.
154  */
155 #define CDROMCLOSETRAY          0x5319  /* pendant of CDROMEJECT */
156 #define CDROM_SET_OPTIONS       0x5320  /* Set behavior options */
157 #define CDROM_CLEAR_OPTIONS     0x5321  /* Clear behavior options */
158 #define CDROM_SELECT_SPEED      0x5322  /* Set the CD-ROM speed */
159 #define CDROM_SELECT_DISC       0x5323  /* Select disc (for juke-boxes) */
160 #define CDROM_MEDIA_CHANGED     0x5325  /* Check is media changed  */
161 #define CDROM_DRIVE_STATUS      0x5326  /* Get tray position, etc. */
162 #define CDROM_DISC_STATUS       0x5327  /* Get disc type, etc. */
163 #define CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
164 #define CDROM_LOCKDOOR          0x5329  /* lock or unlock door */
165 #define CDROM_DEBUG             0x5330  /* Turn debug messages on/off */
166 #define CDROM_GET_CAPABILITY    0x5331  /* get capabilities */
167
168 /* This ioctl is only used by sbpcd at the moment */
169 #define CDROMAUDIOBUFSIZ        0x5382  /* set the audio buffer size */
170
171 /* DVD-ROM Specific ioctls */
172 #define DVD_READ_STRUCT         0x5390  /* Read structure */
173 #define DVD_WRITE_STRUCT        0x5391  /* Write structure */
174 #define DVD_AUTH                0x5392  /* Authentication */
175
176 #define CDROM_SEND_PACKET       0x5393  /* send a packet to the drive */
177 #define CDROM_NEXT_WRITABLE     0x5394  /* get next writable block */
178 #define CDROM_LAST_WRITTEN      0x5395  /* get last block written on disc */
179
180 /*******************************************************
181  * CDROM IOCTL structures
182  *******************************************************/
183
184 /* Address in MSF format */
185 struct cdrom_msf0               
186 {
187         unsigned char   minute;
188         unsigned char   second;
189         unsigned char   frame;
190 };
191
192 /* Address in either MSF or logical format */
193 union cdrom_addr                
194 {
195         struct cdrom_msf0       msf;
196         int                     lba;
197 };
198
199 /* This struct is used by the CDROMPLAYMSF ioctl */ 
200 struct cdrom_msf 
201 {
202         unsigned char   cdmsf_min0;     /* start minute */
203         unsigned char   cdmsf_sec0;     /* start second */
204         unsigned char   cdmsf_frame0;   /* start frame */
205         unsigned char   cdmsf_min1;     /* end minute */
206         unsigned char   cdmsf_sec1;     /* end second */
207         unsigned char   cdmsf_frame1;   /* end frame */
208 };
209
210 /* This struct is used by the CDROMPLAYTRKIND ioctl */
211 struct cdrom_ti 
212 {
213         unsigned char   cdti_trk0;      /* start track */
214         unsigned char   cdti_ind0;      /* start index */
215         unsigned char   cdti_trk1;      /* end track */
216         unsigned char   cdti_ind1;      /* end index */
217 };
218
219 /* This struct is used by the CDROMREADTOCHDR ioctl */
220 struct cdrom_tochdr     
221 {
222         unsigned char   cdth_trk0;      /* start track */
223         unsigned char   cdth_trk1;      /* end track */
224 };
225
226 /* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */
227 struct cdrom_volctrl
228 {
229         unsigned char   channel0;
230         unsigned char   channel1;
231         unsigned char   channel2;
232         unsigned char   channel3;
233 };
234
235 /* This struct is used by the CDROMSUBCHNL ioctl */
236 struct cdrom_subchnl 
237 {
238         unsigned char   cdsc_format;
239         unsigned char   cdsc_audiostatus;
240         unsigned char   cdsc_adr:       4;
241         unsigned char   cdsc_ctrl:      4;
242         unsigned char   cdsc_trk;
243         unsigned char   cdsc_ind;
244         union cdrom_addr cdsc_absaddr;
245         union cdrom_addr cdsc_reladdr;
246 };
247
248
249 /* This struct is used by the CDROMREADTOCENTRY ioctl */
250 struct cdrom_tocentry 
251 {
252         unsigned char   cdte_track;
253         unsigned char   cdte_adr        :4;
254         unsigned char   cdte_ctrl       :4;
255         unsigned char   cdte_format;
256         union cdrom_addr cdte_addr;
257         unsigned char   cdte_datamode;
258 };
259
260 /* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */
261 struct cdrom_read      
262 {
263         int     cdread_lba;
264         char    *cdread_bufaddr;
265         int     cdread_buflen;
266 };
267
268 /* This struct is used by the CDROMREADAUDIO ioctl */
269 struct cdrom_read_audio
270 {
271         union cdrom_addr addr; /* frame address */
272         unsigned char addr_format;    /* CDROM_LBA or CDROM_MSF */
273         int nframes;           /* number of 2352-byte-frames to read at once */
274         unsigned char *buf;           /* frame buffer (size: nframes*2352 bytes) */
275 };
276
277 /* This struct is used with the CDROMMULTISESSION ioctl */
278 struct cdrom_multisession
279 {
280         union cdrom_addr addr; /* frame address: start-of-last-session 
281                                    (not the new "frame 16"!).  Only valid
282                                    if the "xa_flag" is true. */
283         unsigned char xa_flag;        /* 1: "is XA disk" */
284         unsigned char addr_format;    /* CDROM_LBA or CDROM_MSF */
285 };
286
287 /* This struct is used with the CDROM_GET_MCN ioctl.  
288  * Very few audio discs actually have Universal Product Code information, 
289  * which should just be the Medium Catalog Number on the box.  Also note 
290  * that the way the codeis written on CD is _not_ uniform across all discs!
291  */  
292 struct cdrom_mcn 
293 {
294   unsigned char medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
295 };
296
297 /* This is used by the CDROMPLAYBLK ioctl */
298 struct cdrom_blk 
299 {
300         unsigned from;
301         unsigned short len;
302 };
303
304 #define CDROM_PACKET_SIZE       12
305
306 #define CGC_DATA_UNKNOWN        0
307 #define CGC_DATA_WRITE          1
308 #define CGC_DATA_READ           2
309 #define CGC_DATA_NONE           3
310
311 /* for CDROM_PACKET_COMMAND ioctl */
312 struct cdrom_generic_command
313 {
314         unsigned char           cmd[CDROM_PACKET_SIZE];
315         unsigned char           *buffer;
316         unsigned int            buflen;
317         int                     stat;
318         struct request_sense    *sense;
319         unsigned char           data_direction;
320         int                     quiet;
321         int                     timeout;
322         void                    *reserved[1];
323 };
324
325
326 /*
327  * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, 
328  * 2340, or 2352 bytes long.  
329
330 *         Sector types of the standard CD-ROM data formats:
331  *
332  * format   sector type               user data size (bytes)
333  * -----------------------------------------------------------------------------
334  *   1     (Red Book)    CD-DA          2352    (CD_FRAMESIZE_RAW)
335  *   2     (Yellow Book) Mode1 Form1    2048    (CD_FRAMESIZE)
336  *   3     (Yellow Book) Mode1 Form2    2336    (CD_FRAMESIZE_RAW0)
337  *   4     (Green Book)  Mode2 Form1    2048    (CD_FRAMESIZE)
338  *   5     (Green Book)  Mode2 Form2    2328    (2324+4 spare bytes)
339  *
340  *
341  *       The layout of the standard CD-ROM data formats:
342  * -----------------------------------------------------------------------------
343  * - audio (red):                  | audio_sample_bytes |
344  *                                 |        2352        |
345  *
346  * - data (yellow, mode1):         | sync - head - data - EDC - zero - ECC |
347  *                                 |  12  -   4  - 2048 -  4  -   8  - 276 |
348  *
349  * - data (yellow, mode2):         | sync - head - data |
350  *                                 |  12  -   4  - 2336 |
351  *
352  * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
353  *                                 |  12  -   4  -  8  - 2048 -  4  - 276 |
354  *
355  * - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
356  *                                 |  12  -   4  -  8  - 2324 -  4    |
357  *
358  */
359
360 /* Some generally useful CD-ROM information -- mostly based on the above */
361 #define CD_MINS              74 /* max. minutes per CD, not really a limit */
362 #define CD_SECS              60 /* seconds per minute */
363 #define CD_FRAMES            75 /* frames per second */
364 #define CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
365 #define CD_MSF_OFFSET       150 /* MSF numbering offset of first frame */
366 #define CD_CHUNK_SIZE        24 /* lowest-level "data bytes piece" */
367 #define CD_NUM_OF_CHUNKS     98 /* chunks per frame */
368 #define CD_FRAMESIZE_SUB     96 /* subchannel data "frame" size */
369 #define CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
370 #define CD_SUBHEAD_SIZE       8 /* subheader bytes per raw XA data frame */
371 #define CD_EDC_SIZE           4 /* bytes EDC per most raw data frame types */
372 #define CD_ZERO_SIZE          8 /* bytes zero per yellow book mode 1 frame */
373 #define CD_ECC_SIZE         276 /* bytes ECC per most raw data frame types */
374 #define CD_FRAMESIZE       2048 /* bytes per frame, "cooked" mode */
375 #define CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
376 #define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ 
377 /* most drives don't deliver everything: */
378 #define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
379 #define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
380
381 #define CD_XA_HEAD        (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
382 #define CD_XA_TAIL        (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
383 #define CD_XA_SYNC_HEAD   (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */
384
385 /* CD-ROM address types (cdrom_tocentry.cdte_format) */
386 #define CDROM_LBA 0x01 /* "logical block": first frame is #0 */
387 #define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
388
389 /* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */
390 #define CDROM_DATA_TRACK        0x04
391
392 /* The leadout track is always 0xAA, regardless of # of tracks on disc */
393 #define CDROM_LEADOUT           0xAA
394
395 /* audio states (from SCSI-2, but seen with other drives, too) */
396 #define CDROM_AUDIO_INVALID     0x00    /* audio status not supported */
397 #define CDROM_AUDIO_PLAY        0x11    /* audio play operation in progress */
398 #define CDROM_AUDIO_PAUSED      0x12    /* audio play operation paused */
399 #define CDROM_AUDIO_COMPLETED   0x13    /* audio play successfully completed */
400 #define CDROM_AUDIO_ERROR       0x14    /* audio play stopped due to error */
401 #define CDROM_AUDIO_NO_STATUS   0x15    /* no current audio status to return */
402
403 /* capability flags used with the uniform CD-ROM driver */ 
404 #define CDC_CLOSE_TRAY          0x1     /* caddy systems _can't_ close */
405 #define CDC_OPEN_TRAY           0x2     /* but _can_ eject.  */
406 #define CDC_LOCK                0x4     /* disable manual eject */
407 #define CDC_SELECT_SPEED        0x8     /* programmable speed */
408 #define CDC_SELECT_DISC         0x10    /* select disc from juke-box */
409 #define CDC_MULTI_SESSION       0x20    /* read sessions>1 */
410 #define CDC_MCN                 0x40    /* Medium Catalog Number */
411 #define CDC_MEDIA_CHANGED       0x80    /* media changed */
412 #define CDC_PLAY_AUDIO          0x100   /* audio functions */
413 #define CDC_RESET               0x200   /* hard reset device */
414 #define CDC_IOCTLS              0x400   /* driver has non-standard ioctls */
415 #define CDC_DRIVE_STATUS        0x800   /* driver implements drive status */
416 #define CDC_GENERIC_PACKET      0x1000  /* driver implements generic packets */
417 #define CDC_CD_R                0x2000  /* drive is a CD-R */
418 #define CDC_CD_RW               0x4000  /* drive is a CD-RW */
419 #define CDC_DVD                 0x8000  /* drive is a DVD */
420 #define CDC_DVD_R               0x10000 /* drive can write DVD-R */
421 #define CDC_DVD_RAM             0x20000 /* drive can write DVD-RAM */
422
423 /* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
424 #define CDS_NO_INFO             0       /* if not implemented */
425 #define CDS_NO_DISC             1
426 #define CDS_TRAY_OPEN           2
427 #define CDS_DRIVE_NOT_READY     3
428 #define CDS_DISC_OK             4
429
430 /* return values for the CDROM_DISC_STATUS ioctl */
431 /* can also return CDS_NO_[INFO|DISC], from above */
432 #define CDS_AUDIO               100
433 #define CDS_DATA_1              101
434 #define CDS_DATA_2              102
435 #define CDS_XA_2_1              103
436 #define CDS_XA_2_2              104
437 #define CDS_MIXED               105
438
439 /* User-configurable behavior options for the uniform CD-ROM driver */
440 #define CDO_AUTO_CLOSE          0x1     /* close tray on first open() */
441 #define CDO_AUTO_EJECT          0x2     /* open tray on last release() */
442 #define CDO_USE_FFLAGS          0x4     /* use O_NONBLOCK information on open */
443 #define CDO_LOCK                0x8     /* lock tray on open files */
444 #define CDO_CHECK_TYPE          0x10    /* check type on open for data */
445
446 /* Special codes used when specifying changer slots. */
447 #define CDSL_NONE               ((int) (~0U>>1)-1)
448 #define CDSL_CURRENT            ((int) (~0U>>1))
449
450 /* For partition based multisession access. IDE can handle 64 partitions
451  * per drive - SCSI CD-ROM's use minors to differentiate between the
452  * various drives, so we can't do multisessions the same way there.
453  * Use the -o session=x option to mount on them.
454  */
455 #define CD_PART_MAX             64
456 #define CD_PART_MASK            (CD_PART_MAX - 1)
457
458 /*********************************************************************
459  * Generic Packet commands, MMC commands, and such
460  *********************************************************************/
461
462  /* The generic packet command opcodes for CD/DVD Logical Units,
463  * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
464 #define GPCMD_BLANK                         0xa1
465 #define GPCMD_CLOSE_TRACK                   0x5b
466 #define GPCMD_FLUSH_CACHE                   0x35
467 #define GPCMD_FORMAT_UNIT                   0x04
468 #define GPCMD_GET_CONFIGURATION             0x46
469 #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
470 #define GPCMD_GET_PERFORMANCE               0xac
471 #define GPCMD_INQUIRY                       0x12
472 #define GPCMD_LOAD_UNLOAD                   0xa6
473 #define GPCMD_MECHANISM_STATUS              0xbd
474 #define GPCMD_MODE_SELECT_10                0x55
475 #define GPCMD_MODE_SENSE_10                 0x5a
476 #define GPCMD_PAUSE_RESUME                  0x4b
477 #define GPCMD_PLAY_AUDIO_10                 0x45
478 #define GPCMD_PLAY_AUDIO_MSF                0x47
479 #define GPCMD_PLAY_AUDIO_TI                 0x48
480 #define GPCMD_PLAY_CD                       0xbc
481 #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL  0x1e
482 #define GPCMD_READ_10                       0x28
483 #define GPCMD_READ_12                       0xa8
484 #define GPCMD_READ_CDVD_CAPACITY            0x25
485 #define GPCMD_READ_CD                       0xbe
486 #define GPCMD_READ_CD_MSF                   0xb9
487 #define GPCMD_READ_DISC_INFO                0x51
488 #define GPCMD_READ_DVD_STRUCTURE            0xad
489 #define GPCMD_READ_FORMAT_CAPACITIES        0x23
490 #define GPCMD_READ_HEADER                   0x44
491 #define GPCMD_READ_TRACK_RZONE_INFO         0x52
492 #define GPCMD_READ_SUBCHANNEL               0x42
493 #define GPCMD_READ_TOC_PMA_ATIP             0x43
494 #define GPCMD_REPAIR_RZONE_TRACK            0x58
495 #define GPCMD_REPORT_KEY                    0xa4
496 #define GPCMD_REQUEST_SENSE                 0x03
497 #define GPCMD_RESERVE_RZONE_TRACK           0x53
498 #define GPCMD_SCAN                          0xba
499 #define GPCMD_SEEK                          0x2b
500 #define GPCMD_SEND_DVD_STRUCTURE            0xad
501 #define GPCMD_SEND_EVENT                    0xa2
502 #define GPCMD_SEND_KEY                      0xa3
503 #define GPCMD_SEND_OPC                      0x54
504 #define GPCMD_SET_READ_AHEAD                0xa7
505 #define GPCMD_SET_STREAMING                 0xb6
506 #define GPCMD_START_STOP_UNIT               0x1b
507 #define GPCMD_STOP_PLAY_SCAN                0x4e
508 #define GPCMD_TEST_UNIT_READY               0x00
509 #define GPCMD_VERIFY_10                     0x2f
510 #define GPCMD_WRITE_10                      0x2a
511 #define GPCMD_WRITE_AND_VERIFY_10           0x2e
512 /* This is listed as optional in ATAPI 2.6, but is (curiously) 
513  * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
514  * Table 377 as an MMC command for SCSi devices though...  Most ATAPI
515  * drives support it. */
516 #define GPCMD_SET_SPEED                     0xbb
517 /* This seems to be a SCSI specific CD-ROM opcode 
518  * to play data at track/index */
519 #define GPCMD_PLAYAUDIO_TI                  0x48
520 /*
521  * From MS Media Status Notification Support Specification. For
522  * older drives only.
523  */
524 #define GPCMD_GET_MEDIA_STATUS              0xda
525
526 /* Mode page codes for mode sense/set */
527 #define GPMODE_R_W_ERROR_PAGE           0x01
528 #define GPMODE_WRITE_PARMS_PAGE         0x05
529 #define GPMODE_AUDIO_CTL_PAGE           0x0e
530 #define GPMODE_POWER_PAGE               0x1a
531 #define GPMODE_FAULT_FAIL_PAGE          0x1c
532 #define GPMODE_TO_PROTECT_PAGE          0x1d
533 #define GPMODE_CAPABILITIES_PAGE        0x2a
534 #define GPMODE_ALL_PAGES                0x3f
535 /* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
536  * of MODE_SENSE_POWER_PAGE */
537 #define GPMODE_CDROM_PAGE               0x0d
538
539
540
541 /* DVD struct types */
542 #define DVD_STRUCT_PHYSICAL     0x00
543 #define DVD_STRUCT_COPYRIGHT    0x01
544 #define DVD_STRUCT_DISCKEY      0x02
545 #define DVD_STRUCT_BCA          0x03
546 #define DVD_STRUCT_MANUFACT     0x04
547
548 struct dvd_layer {
549         unsigned char book_version      : 4;
550         unsigned char book_type         : 4;
551         unsigned char min_rate          : 4;
552         unsigned char disc_size         : 4;
553         unsigned char layer_type                : 4;
554         unsigned char track_path                : 1;
555         unsigned char nlayers           : 2;
556         unsigned char track_density     : 4;
557         unsigned char linear_density    : 4;
558         unsigned char bca               : 1;
559         uint32 start_sector;
560         uint32 end_sector;
561         uint32 end_sector_l0;
562 };
563
564 struct dvd_physical {
565         unsigned char type;
566         unsigned char layer_num;
567         struct dvd_layer layer[4];
568 };
569
570 struct dvd_copyright {
571         unsigned char type;
572
573         unsigned char layer_num;
574         unsigned char cpst;
575         unsigned char rmi;
576 };
577
578 struct dvd_disckey {
579         unsigned char type;
580
581         unsigned agid           : 2;
582         unsigned char value[2048];
583 };
584
585 struct dvd_bca {
586         unsigned char type;
587
588         int len;
589         unsigned char value[188];
590 };
591
592 struct dvd_manufact {
593         unsigned char type;
594
595         unsigned char layer_num;
596         int len;
597         unsigned char value[2048];
598 };
599
600 typedef union {
601         unsigned char type;
602
603         struct dvd_physical     physical;
604         struct dvd_copyright    copyright;
605         struct dvd_disckey      disckey;
606         struct dvd_bca          bca;
607         struct dvd_manufact     manufact;
608 } dvd_struct;
609
610 /*
611  * DVD authentication ioctl
612  */
613
614 /* Authentication states */
615 #define DVD_LU_SEND_AGID        0
616 #define DVD_HOST_SEND_CHALLENGE 1
617 #define DVD_LU_SEND_KEY1        2
618 #define DVD_LU_SEND_CHALLENGE   3
619 #define DVD_HOST_SEND_KEY2      4
620
621 /* Termination states */
622 #define DVD_AUTH_ESTABLISHED    5
623 #define DVD_AUTH_FAILURE        6
624
625 /* Other functions */
626 #define DVD_LU_SEND_TITLE_KEY   7
627 #define DVD_LU_SEND_ASF         8
628 #define DVD_INVALIDATE_AGID     9
629 #define DVD_LU_SEND_RPC_STATE   10
630 #define DVD_HOST_SEND_RPC_STATE 11
631
632 /* State data */
633 typedef unsigned char dvd_key[5];               /* 40-bit value, MSB is first elem. */
634 typedef unsigned char dvd_challenge[10];        /* 80-bit value, MSB is first elem. */
635
636 struct dvd_lu_send_agid {
637         unsigned char type;
638         unsigned agid           : 2;
639 };
640
641 struct dvd_host_send_challenge {
642         unsigned char type;
643         unsigned agid           : 2;
644
645         dvd_challenge chal;
646 };
647
648 struct dvd_send_key {
649         unsigned char type;
650         unsigned agid           : 2;
651
652         dvd_key key;
653 };
654
655 struct dvd_lu_send_challenge {
656         unsigned char type;
657         unsigned agid           : 2;
658
659         dvd_challenge chal;
660 };
661
662 #define DVD_CPM_NO_COPYRIGHT    0
663 #define DVD_CPM_COPYRIGHTED     1
664
665 #define DVD_CP_SEC_NONE         0
666 #define DVD_CP_SEC_EXIST        1
667
668 #define DVD_CGMS_UNRESTRICTED   0
669 #define DVD_CGMS_SINGLE         2
670 #define DVD_CGMS_RESTRICTED     3
671
672 struct dvd_lu_send_title_key {
673         unsigned char type;
674         unsigned agid           : 2;
675
676         dvd_key title_key;
677         int lba;
678         unsigned cpm            : 1;
679         unsigned cp_sec         : 1;
680         unsigned cgms           : 2;
681 };
682
683 struct dvd_lu_send_asf {
684         unsigned char type;
685         unsigned agid           : 2;
686
687         unsigned asf            : 1;
688 };
689
690 struct dvd_host_send_rpcstate {
691         unsigned char type;
692         unsigned char pdrc;
693 };
694
695 struct dvd_lu_send_rpcstate {
696         unsigned char type              : 2;
697         unsigned char vra               : 3;
698         unsigned char ucca              : 3;
699         unsigned char region_mask;
700         unsigned char rpc_scheme;
701 };
702
703 typedef union {
704         unsigned char type;
705
706         struct dvd_lu_send_agid         lsa;
707         struct dvd_host_send_challenge  hsc;
708         struct dvd_send_key             lsk;
709         struct dvd_lu_send_challenge    lsc;
710         struct dvd_send_key             hsk;
711         struct dvd_lu_send_title_key    lstk;
712         struct dvd_lu_send_asf          lsasf;
713         struct dvd_host_send_rpcstate   hrpcs;
714         struct dvd_lu_send_rpcstate     lrpcs;
715 } dvd_authinfo;
716
717 struct request_sense {
718 #if defined(__BIG_ENDIAN_BITFIELD)
719         unsigned char valid             : 1;
720         unsigned char error_code                : 7;
721 #elif defined(__LITTLE_ENDIAN_BITFIELD)
722         unsigned char error_code                : 7;
723         unsigned char valid             : 1;
724 #endif
725         unsigned char segment_number;
726 #if defined(__BIG_ENDIAN_BITFIELD)
727         unsigned char reserved1         : 2;
728         unsigned char ili               : 1;
729         unsigned char reserved2         : 1;
730         unsigned char sense_key         : 4;
731 #elif defined(__LITTLE_ENDIAN_BITFIELD)
732         unsigned char sense_key         : 4;
733         unsigned char reserved2         : 1;
734         unsigned char ili               : 1;
735         unsigned char reserved1         : 2;
736 #endif
737         unsigned char information[4];
738         unsigned char add_sense_len;
739         unsigned char command_info[4];
740         unsigned char asc;
741         unsigned char ascq;
742         unsigned char fruc;
743         unsigned char sks[3];
744         unsigned char asb[46];
745 };
746
747 typedef struct {
748         uint16 report_key_length;
749         unsigned char reserved1;
750         unsigned char reserved2;
751 #if defined(__BIG_ENDIAN_BITFIELD)
752         unsigned char type_code                 : 2;
753         unsigned char vra                       : 3;
754         unsigned char ucca                      : 3;
755 #elif defined(__LITTLE_ENDIAN_BITFIELD)
756         unsigned char ucca                      : 3;
757         unsigned char vra                       : 3;
758         unsigned char type_code                 : 2;
759 #endif
760         unsigned char region_mask;
761         unsigned char rpc_scheme;
762         unsigned char reserved3;
763 } rpc_state_t;
764
765 #endif  /* _LINUX_CDROM_H */
766