Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
/*
2
 * -- <linux/cdrom.h>
3
 * General header file for linux CD-ROM drivers
4
 * Copyright (C) 1992         David Giller, rafetmad@oxy.edu
5
 *               1994, 1995   Eberhard Moenkeberg, emoenke@gwdg.de
6
 *               1996         David van Leeuwen, david@tm.tno.nl
7
 *               1997, 1998   Erik Andersen, andersee@debian.org
8
 *               1998-2000    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) */
79
#define CDROM_GET_UPC           CDROM_GET_MCN  /* This one is depricated, 
80
                                          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 */
153
struct cdrom_msf0              
154
{
155
        __u8    minute;
156
        __u8    second;
157
        __u8    frame;
158
};
159
 
160
/* Address in either MSF or logical format */
161
union cdrom_addr               
162
{
163
        struct cdrom_msf0       msf;
164
        int                     lba;
165
};
166
 
167
/* This struct is used by the CDROMPLAYMSF ioctl */
168
struct 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 */
179
struct 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 */
188
struct 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 */
195
struct 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 */
204
struct 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 */
218
struct 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 */
229
struct 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 */
237
struct 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 *buf;           /* frame buffer (size: nframes*2352 bytes) */
243
};
244
 
245
/* This struct is used with the CDROMMULTISESSION ioctl */
246
struct 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
 */  
260
struct cdrom_mcn
261
{
262
  __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
263
};
264
 
265
/* This is used by the CDROMPLAYBLK ioctl */
266
struct 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 */
280
struct cdrom_generic_command
281
{
282
        unsigned char           cmd[CDROM_PACKET_SIZE];
283
        unsigned char           *buffer;
284
        unsigned int            buflen;
285
        int                     stat;
286
        struct request_sense    *sense;
287
        unsigned char           data_direction;
288
        int                     quiet;
289
        int                     timeout;
290
        void                    *reserved[1];
291
};
292
 
293
 
294
/*
295
 * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336,
296
 * 2340, or 2352 bytes long.  
297
 
298
*         Sector types of the standard CD-ROM data formats:
299
 *
300
 * format   sector type               user data size (bytes)
301
 * -----------------------------------------------------------------------------
302
 *   1     (Red Book)    CD-DA          2352    (CD_FRAMESIZE_RAW)
303
 *   2     (Yellow Book) Mode1 Form1    2048    (CD_FRAMESIZE)
304
 *   3     (Yellow Book) Mode1 Form2    2336    (CD_FRAMESIZE_RAW0)
305
 *   4     (Green Book)  Mode2 Form1    2048    (CD_FRAMESIZE)
306
 *   5     (Green Book)  Mode2 Form2    2328    (2324+4 spare bytes)
307
 *
308
 *
309
 *       The layout of the standard CD-ROM data formats:
310
 * -----------------------------------------------------------------------------
311
 * - audio (red):                  | audio_sample_bytes |
312
 *                                 |        2352        |
313
 *
314
 * - data (yellow, mode1):         | sync - head - data - EDC - zero - ECC |
315
 *                                 |  12  -   4  - 2048 -  4  -   8  - 276 |
316
 *
317
 * - data (yellow, mode2):         | sync - head - data |
318
 *                                 |  12  -   4  - 2336 |
319
 *
320
 * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
321
 *                                 |  12  -   4  -  8  - 2048 -  4  - 276 |
322
 *
323
 * - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
324
 *                                 |  12  -   4  -  8  - 2324 -  4    |
325
 *
326
 */
327
 
328
/* Some generally useful CD-ROM information -- mostly based on the above */
329
#define CD_MINS              74 /* max. minutes per CD, not really a limit */
330
#define CD_SECS              60 /* seconds per minute */
331
#define CD_FRAMES            75 /* frames per second */
332
#define CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
333
#define CD_MSF_OFFSET       150 /* MSF numbering offset of first frame */
334
#define CD_CHUNK_SIZE        24 /* lowest-level "data bytes piece" */
335
#define CD_NUM_OF_CHUNKS     98 /* chunks per frame */
336
#define CD_FRAMESIZE_SUB     96 /* subchannel data "frame" size */
337
#define CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
338
#define CD_SUBHEAD_SIZE       8 /* subheader bytes per raw XA data frame */
339
#define CD_EDC_SIZE           4 /* bytes EDC per most raw data frame types */
340
#define CD_ZERO_SIZE          8 /* bytes zero per yellow book mode 1 frame */
341
#define CD_ECC_SIZE         276 /* bytes ECC per most raw data frame types */
342
#define CD_FRAMESIZE       2048 /* bytes per frame, "cooked" mode */
343
#define CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
344
#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ 
345
/* most drives don't deliver everything: */
346
#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
347
#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
348
 
349
#define CD_XA_HEAD        (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
350
#define CD_XA_TAIL        (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
351
#define CD_XA_SYNC_HEAD   (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */
352
 
353
/* CD-ROM address types (cdrom_tocentry.cdte_format) */
354
#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */
355
#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
356
 
357
/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */
358
#define CDROM_DATA_TRACK        0x04
359
 
360
/* The leadout track is always 0xAA, regardless of # of tracks on disc */
361
#define CDROM_LEADOUT           0xAA
362
 
363
/* audio states (from SCSI-2, but seen with other drives, too) */
364
#define CDROM_AUDIO_INVALID     0x00    /* audio status not supported */
365
#define CDROM_AUDIO_PLAY        0x11    /* audio play operation in progress */
366
#define CDROM_AUDIO_PAUSED      0x12    /* audio play operation paused */
367
#define CDROM_AUDIO_COMPLETED   0x13    /* audio play successfully completed */
368
#define CDROM_AUDIO_ERROR       0x14    /* audio play stopped due to error */
369
#define CDROM_AUDIO_NO_STATUS   0x15    /* no current audio status to return */
370
 
371
/* capability flags used with the uniform CD-ROM driver */
372
#define CDC_CLOSE_TRAY          0x1     /* caddy systems _can't_ close */
373
#define CDC_OPEN_TRAY           0x2     /* but _can_ eject.  */
374
#define CDC_LOCK                0x4     /* disable manual eject */
375
#define CDC_SELECT_SPEED        0x8     /* programmable speed */
376
#define CDC_SELECT_DISC         0x10    /* select disc from juke-box */
377
#define CDC_MULTI_SESSION       0x20    /* read sessions>1 */
378
#define CDC_MCN                 0x40    /* Medium Catalog Number */
379
#define CDC_MEDIA_CHANGED       0x80    /* media changed */
380
#define CDC_PLAY_AUDIO          0x100   /* audio functions */
381
#define CDC_RESET               0x200   /* hard reset device */
382
#define CDC_IOCTLS              0x400   /* driver has non-standard ioctls */
383
#define CDC_DRIVE_STATUS        0x800   /* driver implements drive status */
384
#define CDC_GENERIC_PACKET      0x1000  /* driver implements generic packets */
385
#define CDC_CD_R                0x2000  /* drive is a CD-R */
386
#define CDC_CD_RW               0x4000  /* drive is a CD-RW */
387
#define CDC_DVD                 0x8000  /* drive is a DVD */
388
#define CDC_DVD_R               0x10000 /* drive can write DVD-R */
389
#define CDC_DVD_RAM             0x20000 /* drive can write DVD-RAM */
390
#define CDC_MO_DRIVE            0x40000 /* drive is an MO device */
391
 
392
/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
393
#define CDS_NO_INFO             0       /* if not implemented */
394
#define CDS_NO_DISC             1
395
#define CDS_TRAY_OPEN           2
396
#define CDS_DRIVE_NOT_READY     3
397
#define CDS_DISC_OK             4
398
 
399
/* return values for the CDROM_DISC_STATUS ioctl */
400
/* can also return CDS_NO_[INFO|DISC], from above */
401
#define CDS_AUDIO               100
402
#define CDS_DATA_1              101
403
#define CDS_DATA_2              102
404
#define CDS_XA_2_1              103
405
#define CDS_XA_2_2              104
406
#define CDS_MIXED               105
407
 
408
/* User-configurable behavior options for the uniform CD-ROM driver */
409
#define CDO_AUTO_CLOSE          0x1     /* close tray on first open() */
410
#define CDO_AUTO_EJECT          0x2     /* open tray on last release() */
411
#define CDO_USE_FFLAGS          0x4     /* use O_NONBLOCK information on open */
412
#define CDO_LOCK                0x8     /* lock tray on open files */
413
#define CDO_CHECK_TYPE          0x10    /* check type on open for data */
414
 
415
/* Special codes used when specifying changer slots. */
416
#define CDSL_NONE               ((int) (~0U>>1)-1)
417
#define CDSL_CURRENT            ((int) (~0U>>1))
418
 
419
/* For partition based multisession access. IDE can handle 64 partitions
420
 * per drive - SCSI CD-ROM's use minors to differentiate between the
421
 * various drives, so we can't do multisessions the same way there.
422
 * Use the -o session=x option to mount on them.
423
 */
424
#define CD_PART_MAX             64
425
#define CD_PART_MASK            (CD_PART_MAX - 1)
426
 
427
/*********************************************************************
428
 * Generic Packet commands, MMC commands, and such
429
 *********************************************************************/
430
 
431
 /* The generic packet command opcodes for CD/DVD Logical Units,
432
 * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
433
#define GPCMD_BLANK                         0xa1
434
#define GPCMD_CLOSE_TRACK                   0x5b
435
#define GPCMD_FLUSH_CACHE                   0x35
436
#define GPCMD_FORMAT_UNIT                   0x04
437
#define GPCMD_GET_CONFIGURATION             0x46
438
#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
439
#define GPCMD_GET_PERFORMANCE               0xac
440
#define GPCMD_INQUIRY                       0x12
441
#define GPCMD_LOAD_UNLOAD                   0xa6
442
#define GPCMD_MECHANISM_STATUS              0xbd
443
#define GPCMD_MODE_SELECT_10                0x55
444
#define GPCMD_MODE_SENSE_10                 0x5a
445
#define GPCMD_PAUSE_RESUME                  0x4b
446
#define GPCMD_PLAY_AUDIO_10                 0x45
447
#define GPCMD_PLAY_AUDIO_MSF                0x47
448
#define GPCMD_PLAY_AUDIO_TI                 0x48
449
#define GPCMD_PLAY_CD                       0xbc
450
#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL  0x1e
451
#define GPCMD_READ_10                       0x28
452
#define GPCMD_READ_12                       0xa8
453
#define GPCMD_READ_CDVD_CAPACITY            0x25
454
#define GPCMD_READ_CD                       0xbe
455
#define GPCMD_READ_CD_MSF                   0xb9
456
#define GPCMD_READ_DISC_INFO                0x51
457
#define GPCMD_READ_DVD_STRUCTURE            0xad
458
#define GPCMD_READ_FORMAT_CAPACITIES        0x23
459
#define GPCMD_READ_HEADER                   0x44
460
#define GPCMD_READ_TRACK_RZONE_INFO         0x52
461
#define GPCMD_READ_SUBCHANNEL               0x42
462
#define GPCMD_READ_TOC_PMA_ATIP             0x43
463
#define GPCMD_REPAIR_RZONE_TRACK            0x58
464
#define GPCMD_REPORT_KEY                    0xa4
465
#define GPCMD_REQUEST_SENSE                 0x03
466
#define GPCMD_RESERVE_RZONE_TRACK           0x53
467
#define GPCMD_SCAN                          0xba
468
#define GPCMD_SEEK                          0x2b
469
#define GPCMD_SEND_DVD_STRUCTURE            0xad
470
#define GPCMD_SEND_EVENT                    0xa2
471
#define GPCMD_SEND_KEY                      0xa3
472
#define GPCMD_SEND_OPC                      0x54
473
#define GPCMD_SET_READ_AHEAD                0xa7
474
#define GPCMD_SET_STREAMING                 0xb6
475
#define GPCMD_START_STOP_UNIT               0x1b
476
#define GPCMD_STOP_PLAY_SCAN                0x4e
477
#define GPCMD_TEST_UNIT_READY               0x00
478
#define GPCMD_VERIFY_10                     0x2f
479
#define GPCMD_WRITE_10                      0x2a
480
#define GPCMD_WRITE_AND_VERIFY_10           0x2e
481
/* This is listed as optional in ATAPI 2.6, but is (curiously)
482
 * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
483
 * Table 377 as an MMC command for SCSi devices though...  Most ATAPI
484
 * drives support it. */
485
#define GPCMD_SET_SPEED                     0xbb
486
/* This seems to be a SCSI specific CD-ROM opcode
487
 * to play data at track/index */
488
#define GPCMD_PLAYAUDIO_TI                  0x48
489
/*
490
 * From MS Media Status Notification Support Specification. For
491
 * older drives only.
492
 */
493
#define GPCMD_GET_MEDIA_STATUS              0xda
494
 
495
/* Mode page codes for mode sense/set */
496
#define GPMODE_R_W_ERROR_PAGE           0x01
497
#define GPMODE_WRITE_PARMS_PAGE         0x05
498
#define GPMODE_AUDIO_CTL_PAGE           0x0e
499
#define GPMODE_POWER_PAGE               0x1a
500
#define GPMODE_FAULT_FAIL_PAGE          0x1c
501
#define GPMODE_TO_PROTECT_PAGE          0x1d
502
#define GPMODE_CAPABILITIES_PAGE        0x2a
503
#define GPMODE_ALL_PAGES                0x3f
504
/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
505
 * of MODE_SENSE_POWER_PAGE */
506
#define GPMODE_CDROM_PAGE               0x0d
507
 
508
 
509
 
510
/* DVD struct types */
511
#define DVD_STRUCT_PHYSICAL     0x00
512
#define DVD_STRUCT_COPYRIGHT    0x01
513
#define DVD_STRUCT_DISCKEY      0x02
514
#define DVD_STRUCT_BCA          0x03
515
#define DVD_STRUCT_MANUFACT     0x04
516
 
517
struct dvd_layer {
518
        __u8 book_version       : 4;
519
        __u8 book_type          : 4;
520
        __u8 min_rate           : 4;
521
        __u8 disc_size          : 4;
522
        __u8 layer_type         : 4;
523
        __u8 track_path         : 1;
524
        __u8 nlayers            : 2;
525
        __u8 track_density      : 4;
526
        __u8 linear_density     : 4;
527
        __u8 bca                : 1;
528
        __u32 start_sector;
529
        __u32 end_sector;
530
        __u32 end_sector_l0;
531
};
532
 
533
#define DVD_LAYERS      4
534
 
535
struct dvd_physical {
536
        __u8 type;
537
        __u8 layer_num;
538
        struct dvd_layer layer[DVD_LAYERS];
539
};
540
 
541
struct dvd_copyright {
542
        __u8 type;
543
 
544
        __u8 layer_num;
545
        __u8 cpst;
546
        __u8 rmi;
547
};
548
 
549
struct dvd_disckey {
550
        __u8 type;
551
 
552
        unsigned agid           : 2;
553
        __u8 value[2048];
554
};
555
 
556
struct dvd_bca {
557
        __u8 type;
558
 
559
        int len;
560
        __u8 value[188];
561
};
562
 
563
struct dvd_manufact {
564
        __u8 type;
565
 
566
        __u8 layer_num;
567
        int len;
568
        __u8 value[2048];
569
};
570
 
571
typedef union {
572
        __u8 type;
573
 
574
        struct dvd_physical     physical;
575
        struct dvd_copyright    copyright;
576
        struct dvd_disckey      disckey;
577
        struct dvd_bca          bca;
578
        struct dvd_manufact     manufact;
579
} dvd_struct;
580
 
581
/*
582
 * DVD authentication ioctl
583
 */
584
 
585
/* Authentication states */
586
#define DVD_LU_SEND_AGID        0
587
#define DVD_HOST_SEND_CHALLENGE 1
588
#define DVD_LU_SEND_KEY1        2
589
#define DVD_LU_SEND_CHALLENGE   3
590
#define DVD_HOST_SEND_KEY2      4
591
 
592
/* Termination states */
593
#define DVD_AUTH_ESTABLISHED    5
594
#define DVD_AUTH_FAILURE        6
595
 
596
/* Other functions */
597
#define DVD_LU_SEND_TITLE_KEY   7
598
#define DVD_LU_SEND_ASF         8
599
#define DVD_INVALIDATE_AGID     9
600
#define DVD_LU_SEND_RPC_STATE   10
601
#define DVD_HOST_SEND_RPC_STATE 11
602
 
603
/* State data */
604
typedef __u8 dvd_key[5];                /* 40-bit value, MSB is first elem. */
605
typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
606
 
607
struct dvd_lu_send_agid {
608
        __u8 type;
609
        unsigned agid           : 2;
610
};
611
 
612
struct dvd_host_send_challenge {
613
        __u8 type;
614
        unsigned agid           : 2;
615
 
616
        dvd_challenge chal;
617
};
618
 
619
struct dvd_send_key {
620
        __u8 type;
621
        unsigned agid           : 2;
622
 
623
        dvd_key key;
624
};
625
 
626
struct dvd_lu_send_challenge {
627
        __u8 type;
628
        unsigned agid           : 2;
629
 
630
        dvd_challenge chal;
631
};
632
 
633
#define DVD_CPM_NO_COPYRIGHT    0
634
#define DVD_CPM_COPYRIGHTED     1
635
 
636
#define DVD_CP_SEC_NONE         0
637
#define DVD_CP_SEC_EXIST        1
638
 
639
#define DVD_CGMS_UNRESTRICTED   0
640
#define DVD_CGMS_SINGLE         2
641
#define DVD_CGMS_RESTRICTED     3
642
 
643
struct dvd_lu_send_title_key {
644
        __u8 type;
645
        unsigned agid           : 2;
646
 
647
        dvd_key title_key;
648
        int lba;
649
        unsigned cpm            : 1;
650
        unsigned cp_sec         : 1;
651
        unsigned cgms           : 2;
652
};
653
 
654
struct dvd_lu_send_asf {
655
        __u8 type;
656
        unsigned agid           : 2;
657
 
658
        unsigned asf            : 1;
659
};
660
 
661
struct dvd_host_send_rpcstate {
662
        __u8 type;
663
        __u8 pdrc;
664
};
665
 
666
struct dvd_lu_send_rpcstate {
667
        __u8 type               : 2;
668
        __u8 vra                : 3;
669
        __u8 ucca               : 3;
670
        __u8 region_mask;
671
        __u8 rpc_scheme;
672
};
673
 
674
typedef union {
675
        __u8 type;
676
 
677
        struct dvd_lu_send_agid         lsa;
678
        struct dvd_host_send_challenge  hsc;
679
        struct dvd_send_key             lsk;
680
        struct dvd_lu_send_challenge    lsc;
681
        struct dvd_send_key             hsk;
682
        struct dvd_lu_send_title_key    lstk;
683
        struct dvd_lu_send_asf          lsasf;
684
        struct dvd_host_send_rpcstate   hrpcs;
685
        struct dvd_lu_send_rpcstate     lrpcs;
686
} dvd_authinfo;
687
 
688
struct request_sense {
689
#if defined(__BIG_ENDIAN_BITFIELD)
690
        __u8 valid              : 1;
691
        __u8 error_code         : 7;
692
#elif defined(__LITTLE_ENDIAN_BITFIELD)
693
        __u8 error_code         : 7;
694
        __u8 valid              : 1;
695
#endif
696
        __u8 segment_number;
697
#if defined(__BIG_ENDIAN_BITFIELD)
698
        __u8 reserved1          : 2;
699
        __u8 ili                : 1;
700
        __u8 reserved2          : 1;
701
        __u8 sense_key          : 4;
702
#elif defined(__LITTLE_ENDIAN_BITFIELD)
703
        __u8 sense_key          : 4;
704
        __u8 reserved2          : 1;
705
        __u8 ili                : 1;
706
        __u8 reserved1          : 2;
707
#endif
708
        __u8 information[4];
709
        __u8 add_sense_len;
710
        __u8 command_info[4];
711
        __u8 asc;
712
        __u8 ascq;
713
        __u8 fruc;
714
        __u8 sks[3];
715
        __u8 asb[46];
716
};
717
 
718
#ifdef __KERNEL__
719
#include <linux/fs.h>           /* not really needed, later.. */
720
#include <linux/device.h>
721
 
722
struct cdrom_write_settings {
723
        unsigned char fpacket;          /* fixed/variable packets */
724
        unsigned long packet_size;      /* write out this number of packets */
725
        unsigned long nwa;              /* next writeable address */
726
        unsigned char writeable;        /* cdrom is writeable */
727
};
728
 
729
/* Uniform cdrom data structures for cdrom.c */
730
struct cdrom_device_info {
731
        struct cdrom_device_ops  *ops;  /* link to device_ops */
732
        struct cdrom_device_info *next; /* next device_info for this major */
733
        void *handle;                   /* driver-dependent data */
734
/* specifications */
735
        int mask;                       /* mask of capability: disables them */
736
        int speed;                      /* maximum speed for reading data */
737
        int capacity;                   /* number of discs in jukebox */
738
/* device-related storage */
739
        int options             : 30;   /* options flags */
740
        unsigned mc_flags       : 2;    /* media change buffer flags */
741
        int use_count;                  /* number of times device opened */
742
        char name[20];                  /* name of the device type */
743
/* per-device flags */
744
        __u8 sanyo_slot         : 2;    /* Sanyo 3 CD changer support */
745
        __u8 reserved           : 6;    /* not used yet */
746
        struct cdrom_write_settings write;
747
};
748
 
749
struct cdrom_device_ops {
750
/* routines */
751
        int (*open) (struct cdrom_device_info *, int);
752
        void (*release) (struct cdrom_device_info *);
753
        int (*drive_status) (struct cdrom_device_info *, int);
754
        int (*media_changed) (struct cdrom_device_info *, int);
755
        int (*tray_move) (struct cdrom_device_info *, int);
756
        int (*lock_door) (struct cdrom_device_info *, int);
757
        int (*select_speed) (struct cdrom_device_info *, int);
758
        int (*select_disc) (struct cdrom_device_info *, int);
759
        int (*get_last_session) (struct cdrom_device_info *,
760
                                 struct cdrom_multisession *);
761
        int (*get_mcn) (struct cdrom_device_info *,
762
                        struct cdrom_mcn *);
763
        /* hard reset device */
764
        int (*reset) (struct cdrom_device_info *);
765
        /* play stuff */
766
        int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
767
        /* dev-specific */
768
        int (*dev_ioctl) (struct cdrom_device_info *,
769
                          unsigned int, unsigned long);
770
/* driver specifications */
771
        const int capability;   /* capability flags */
772
        int n_minors;           /* number of active minor devices */
773
        /* handle uniform packets for scsi type devices (scsi,atapi) */
774
        int (*generic_packet) (struct cdrom_device_info *,
775
                               struct cdrom_generic_command *);
776
};
777
 
778
/* the general block_device operations structure: */
779
extern int cdrom_open(struct cdrom_device_info *, struct inode *, struct file *);
780
extern int cdrom_release(struct cdrom_device_info *, struct file *);
781
extern int cdrom_ioctl(struct cdrom_device_info *, struct inode *, unsigned, unsigned long);
782
extern int cdrom_media_changed(struct cdrom_device_info *);
783
 
784
extern int register_cdrom(struct cdrom_device_info *cdi);
785
extern int unregister_cdrom(struct cdrom_device_info *cdi);
786
 
787
typedef struct {
788
    int data;
789
    int audio;
790
    int cdi;
791
    int xa;
792
    long error;
793
} tracktype;
794
 
795
extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written);
796
extern int cdrom_number_of_slots(struct cdrom_device_info *cdi);
797
extern int cdrom_mode_select(struct cdrom_device_info *cdi,
798
                             struct cdrom_generic_command *cgc);
799
extern int cdrom_mode_sense(struct cdrom_device_info *cdi,
800
                            struct cdrom_generic_command *cgc,
801
                            int page_code, int page_control);
802
extern void init_cdrom_command(struct cdrom_generic_command *cgc,
803
                               void *buffer, int len, int type);
804
 
805
typedef struct {
806
        __u16 disc_information_length;
807
#if defined(__BIG_ENDIAN_BITFIELD)
808
        __u8 reserved1                  : 3;
809
        __u8 erasable                   : 1;
810
        __u8 border_status              : 2;
811
        __u8 disc_status                : 2;
812
#elif defined(__LITTLE_ENDIAN_BITFIELD)
813
        __u8 disc_status                : 2;
814
        __u8 border_status              : 2;
815
        __u8 erasable                   : 1;
816
        __u8 reserved1                  : 3;
817
#else
818
#error "Please fix <asm/byteorder.h>"
819
#endif
820
        __u8 n_first_track;
821
        __u8 n_sessions_lsb;
822
        __u8 first_track_lsb;
823
        __u8 last_track_lsb;
824
#if defined(__BIG_ENDIAN_BITFIELD)
825
        __u8 did_v                      : 1;
826
        __u8 dbc_v                      : 1;
827
        __u8 uru                        : 1;
828
        __u8 reserved2                  : 5;
829
#elif defined(__LITTLE_ENDIAN_BITFIELD)
830
        __u8 reserved2                  : 5;
831
        __u8 uru                        : 1;
832
        __u8 dbc_v                      : 1;
833
        __u8 did_v                      : 1;
834
#endif
835
        __u8 disc_type;
836
        __u8 n_sessions_msb;
837
        __u8 first_track_msb;
838
        __u8 last_track_msb;
839
        __u32 disc_id;
840
        __u32 lead_in;
841
        __u32 lead_out;
842
        __u8 disc_bar_code[8];
843
        __u8 reserved3;
844
        __u8 n_opc;
845
} disc_information;
846
 
847
typedef struct {
848
        __u16 track_information_length;
849
        __u8 track_lsb;
850
        __u8 session_lsb;
851
        __u8 reserved1;
852
#if defined(__BIG_ENDIAN_BITFIELD)
853
        __u8 reserved2                  : 2;
854
        __u8 damage                     : 1;
855
        __u8 copy                       : 1;
856
        __u8 track_mode                 : 4;
857
        __u8 rt                         : 1;
858
        __u8 blank                      : 1;
859
        __u8 packet                     : 1;
860
        __u8 fp                         : 1;
861
        __u8 data_mode                  : 4;
862
        __u8 reserved3                  : 6;
863
        __u8 lra_v                      : 1;
864
        __u8 nwa_v                      : 1;
865
#elif defined(__LITTLE_ENDIAN_BITFIELD)
866
        __u8 track_mode                 : 4;
867
        __u8 copy                       : 1;
868
        __u8 damage                     : 1;
869
        __u8 reserved2                  : 2;
870
        __u8 data_mode                  : 4;
871
        __u8 fp                         : 1;
872
        __u8 packet                     : 1;
873
        __u8 blank                      : 1;
874
        __u8 rt                         : 1;
875
        __u8 nwa_v                      : 1;
876
        __u8 lra_v                      : 1;
877
        __u8 reserved3                  : 6;
878
#endif
879
        __u32 track_start;
880
        __u32 next_writable;
881
        __u32 free_blocks;
882
        __u32 fixed_packet_size;
883
        __u32 track_size;
884
        __u32 last_rec_address;
885
} track_information;
886
 
887
/* The SCSI spec says there could be 256 slots. */
888
#define CDROM_MAX_SLOTS 256
889
 
890
struct cdrom_mechstat_header {
891
#if defined(__BIG_ENDIAN_BITFIELD)
892
        __u8 fault         : 1;
893
        __u8 changer_state : 2;
894
        __u8 curslot       : 5;
895
        __u8 mech_state    : 3;
896
        __u8 door_open     : 1;
897
        __u8 reserved1     : 4;
898
#elif defined(__LITTLE_ENDIAN_BITFIELD)
899
        __u8 curslot       : 5;
900
        __u8 changer_state : 2;
901
        __u8 fault         : 1;
902
        __u8 reserved1     : 4;
903
        __u8 door_open     : 1;
904
        __u8 mech_state    : 3;
905
#endif
906
        __u8     curlba[3];
907
        __u8     nslots;
908
        __u16 slot_tablelen;
909
};
910
 
911
struct cdrom_slot {
912
#if defined(__BIG_ENDIAN_BITFIELD)
913
        __u8 disc_present : 1;
914
        __u8 reserved1    : 6;
915
        __u8 change       : 1;
916
#elif defined(__LITTLE_ENDIAN_BITFIELD)
917
        __u8 change       : 1;
918
        __u8 reserved1    : 6;
919
        __u8 disc_present : 1;
920
#endif
921
        __u8 reserved2[3];
922
};
923
 
924
struct cdrom_changer_info {
925
        struct cdrom_mechstat_header hdr;
926
        struct cdrom_slot slots[CDROM_MAX_SLOTS];
927
};
928
 
929
typedef enum {
930
        mechtype_caddy = 0,
931
        mechtype_tray  = 1,
932
        mechtype_popup = 2,
933
        mechtype_individual_changer = 4,
934
        mechtype_cartridge_changer  = 5
935
} mechtype_t;
936
 
937
struct mode_page_header {
938
        __u16 mode_data_length;
939
        __u8 medium_type;
940
        __u8 reserved1;
941
        __u8 reserved2;
942
        __u8 reserved3;
943
        __u16 desc_length;
944
};
945
 
946
typedef struct {
947
#if defined(__BIG_ENDIAN_BITFIELD)
948
        __u8 ps                 : 1;
949
        __u8 reserved1          : 1;
950
        __u8 page_code          : 6;
951
        __u8 page_length;
952
        __u8 reserved2          : 1;
953
        __u8 bufe               : 1;
954
        __u8 ls_v               : 1;
955
        __u8 test_write         : 1;
956
        __u8 write_type         : 4;
957
        __u8 multi_session      : 2; /* or border, DVD */
958
        __u8 fp                 : 1;
959
        __u8 copy               : 1;
960
        __u8 track_mode         : 4;
961
        __u8 reserved3          : 4;
962
        __u8 data_block_type    : 4;
963
#elif defined(__LITTLE_ENDIAN_BITFIELD)
964
        __u8 page_code          : 6;
965
        __u8 reserved1          : 1;
966
        __u8 ps                 : 1;
967
        __u8 page_length;
968
        __u8 write_type         : 4;
969
        __u8 test_write         : 1;
970
        __u8 ls_v               : 1;
971
        __u8 bufe               : 1;
972
        __u8 reserved2          : 1;
973
        __u8 track_mode         : 4;
974
        __u8 copy               : 1;
975
        __u8 fp                 : 1;
976
        __u8 multi_session      : 2; /* or border, DVD */
977
        __u8 data_block_type    : 4;
978
        __u8 reserved3          : 4;
979
#endif
980
        __u8 link_size;
981
        __u8 reserved4;
982
#if defined(__BIG_ENDIAN_BITFIELD)
983
        __u8 reserved5          : 2;
984
        __u8 app_code           : 6;
985
#elif defined(__LITTLE_ENDIAN_BITFIELD)
986
        __u8 app_code           : 6;
987
        __u8 reserved5          : 2;
988
#endif
989
        __u8 session_format;
990
        __u8 reserved6;
991
        __u32 packet_size;
992
        __u16 audio_pause;
993
        __u8 mcn[16];
994
        __u8 isrc[16];
995
        __u8 subhdr0;
996
        __u8 subhdr1;
997
        __u8 subhdr2;
998
        __u8 subhdr3;
999
} __attribute__((packed)) write_param_page;
1000
 
1001
struct modesel_head
1002
{
1003
        __u8    reserved1;
1004
        __u8    medium;
1005
        __u8    reserved2;
1006
        __u8    block_desc_length;
1007
        __u8    density;
1008
        __u8    number_of_blocks_hi;
1009
        __u8    number_of_blocks_med;
1010
        __u8    number_of_blocks_lo;
1011
        __u8    reserved3;
1012
        __u8    block_length_hi;
1013
        __u8    block_length_med;
1014
        __u8    block_length_lo;
1015
};
1016
 
1017
typedef struct {
1018
        __u16 report_key_length;
1019
        __u8 reserved1;
1020
        __u8 reserved2;
1021
#if defined(__BIG_ENDIAN_BITFIELD)
1022
        __u8 type_code                  : 2;
1023
        __u8 vra                        : 3;
1024
        __u8 ucca                       : 3;
1025
#elif defined(__LITTLE_ENDIAN_BITFIELD)
1026
        __u8 ucca                       : 3;
1027
        __u8 vra                        : 3;
1028
        __u8 type_code                  : 2;
1029
#endif
1030
        __u8 region_mask;
1031
        __u8 rpc_scheme;
1032
        __u8 reserved3;
1033
} rpc_state_t;
1034
 
1035
#endif  /* End of kernel only stuff */ 
1036
 
1037
#endif  /* _LINUX_CDROM_H */