root/include/linux/cdrom.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * -- <linux/cdrom.h>
   3  * general (not only SCSI) header library for linux CDROM drivers
   4  * (C) 1992         David Giller rafetmad@oxy.edu
   5  *     1994, 1995   Eberhard Moenkeberg emoenke@gwdg.de
   6  *
   7  */
   8 
   9 #ifndef _LINUX_CDROM_H
  10 #define _LINUX_CDROM_H
  11 
  12 /*
  13  * some fix numbers
  14  */
  15 #define CD_MINS             74 /* max. minutes per CD, not really a limit */
  16 #define CD_SECS             60 /* seconds per minute */
  17 #define CD_FRAMES           75 /* frames per second */
  18 
  19 #define CD_SYNC_SIZE        12 /* 12 sync bytes per raw data frame, not transfered by the drive */
  20 #define CD_HEAD_SIZE         4 /* header (address) bytes per raw data frame */
  21 #define CD_SUBHEAD_SIZE      8 /* subheader bytes per raw XA data frame */
  22 #define CD_XA_HEAD        (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
  23 #define CD_XA_SYNC_HEAD   (CD_XA_HEAD+12)/* sync bytes + header of XA frame */
  24 
  25 #define CD_FRAMESIZE      2048 /* bytes per frame, "cooked" mode */
  26 #define CD_FRAMESIZE_RAW  2352 /* bytes per frame, "raw" mode */
  27 /* most drives don't deliver everything: */
  28 #define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /* 2340 */
  29 #define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /* 2336 */
  30 
  31 #define CD_EDC_SIZE         4 /* bytes EDC per most raw data frame types */
  32 #define CD_ZERO_SIZE        8 /* bytes zero per yellow book mode 1 frame */
  33 #define CD_ECC_SIZE       276 /* bytes ECC per most raw data frame types */
  34 #define CD_XA_TAIL        (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
  35 
  36 #define CD_FRAMESIZE_SUB    96 /* subchannel data "frame" size */
  37 #define CD_MSF_OFFSET      150 /* MSF numbering offset of first frame */
  38 
  39 #define CD_CHUNK_SIZE       24 /* lowest-level "data bytes piece" */
  40 #define CD_NUM_OF_CHUNKS    98 /* chunks per frame */
  41 
  42 #define CD_FRAMESIZE_XA CD_FRAMESIZE_RAW1 /* obsolete name */
  43 #define CD_BLOCK_OFFSET    CD_MSF_OFFSET /* obsolete name */
  44 
  45 /*
  46  * the raw frame layout:
  47  *
  48  * - audio (red):                  | audio_sample_bytes |
  49  *                                 |        2352        |
  50  *
  51  * - data (yellow, mode1):         | sync - head - data - EDC - zero - ECC |
  52  *                                 |  12  -   4  - 2048 -  4  -   8  - 276 |
  53  *
  54  * - data (yellow, mode2):         | sync - head - data |
  55  *                                 |  12  -   4  - 2336 |
  56  *
  57  * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
  58  *                                 |  12  -   4  -  8  - 2048 -  4  - 276 |
  59  *
  60  * - XA data (green, mode2 form2): | sync - head - sub - data - EDC |
  61  *                                 |  12  -   4  -  8  - 2324 -  4  |
  62  */
  63 
  64 /*
  65  * CDROM IOCTL structures
  66  */
  67 
  68 struct cdrom_msf 
  69 {
  70         u_char  cdmsf_min0;     /* start minute */
  71         u_char  cdmsf_sec0;     /* start second */
  72         u_char  cdmsf_frame0;   /* start frame */
  73         u_char  cdmsf_min1;     /* end minute */
  74         u_char  cdmsf_sec1;     /* end second */
  75         u_char  cdmsf_frame1;   /* end frame */
  76 };
  77 
  78 struct cdrom_ti 
  79 {
  80         u_char  cdti_trk0;      /* start track */
  81         u_char  cdti_ind0;      /* start index */
  82         u_char  cdti_trk1;      /* end track */
  83         u_char  cdti_ind1;      /* end index */
  84 };
  85 
  86 struct cdrom_tochdr     
  87 {
  88         u_char  cdth_trk0;      /* start track */
  89         u_char  cdth_trk1;      /* end track */
  90 };
  91 
  92 struct cdrom_tocentry 
  93 {
  94         u_char  cdte_track;
  95         u_char  cdte_adr        :4;
  96         u_char  cdte_ctrl       :4;
  97         u_char  cdte_format;
  98         union
  99         {
 100                 struct
 101                 {
 102                         u_char  minute;
 103                         u_char  second;
 104                         u_char  frame;
 105                 } msf;
 106                 int     lba;
 107         } cdte_addr;
 108         u_char  cdte_datamode;
 109 };
 110 
 111 /*
 112  * CD-ROM address types (cdrom_tocentry.cdte_format)
 113  */
 114 #define CDROM_LBA 0x01 /* "logical block": first frame is #0 */
 115 #define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
 116 
 117 /*
 118  * bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl)
 119  */
 120 #define CDROM_DATA_TRACK        0x04
 121 
 122 /*
 123  * The leadout track is always 0xAA, regardless of # of tracks on disc
 124  */
 125 #define CDROM_LEADOUT   0xAA
 126 
 127 struct cdrom_subchnl 
 128 {
 129         u_char  cdsc_format;
 130         u_char  cdsc_audiostatus;
 131         u_char  cdsc_adr:       4;
 132         u_char  cdsc_ctrl:      4;
 133         u_char  cdsc_trk;
 134         u_char  cdsc_ind;
 135         union
 136         {
 137                 struct                  
 138                 {
 139                         u_char  minute;
 140                         u_char  second;
 141                         u_char  frame;
 142                 } msf;
 143                 int     lba;
 144         } cdsc_absaddr;
 145         union 
 146         {
 147                 struct 
 148                 {
 149                         u_char  minute;
 150                         u_char  second;
 151                         u_char  frame;
 152                 } msf;
 153                 int     lba;
 154         } cdsc_reladdr;
 155 };
 156 
 157 /*
 158  * audio states (from SCSI-2, but seen with other drives, too)
 159  */
 160 #define CDROM_AUDIO_INVALID     0x00    /* audio status not supported */
 161 #define CDROM_AUDIO_PLAY        0x11    /* audio play operation in progress */
 162 #define CDROM_AUDIO_PAUSED      0x12    /* audio play operation paused */
 163 #define CDROM_AUDIO_COMPLETED   0x13    /* audio play successfully completed */
 164 #define CDROM_AUDIO_ERROR       0x14    /* audio play stopped due to error */
 165 #define CDROM_AUDIO_NO_STATUS   0x15    /* no current audio status to return */
 166 
 167 struct cdrom_volctrl
 168 {
 169         u_char  channel0;
 170         u_char  channel1;
 171         u_char  channel2;
 172         u_char  channel3;
 173 };
 174 
 175 struct cdrom_read      
 176 {
 177         int     cdread_lba;
 178         caddr_t cdread_bufaddr;
 179         int     cdread_buflen;
 180 };
 181 
 182 /*
 183  * extensions for transfering audio frames
 184  * currently used by sbpcd.c, cdu31a.c, ide-cd.c
 185  */
 186 struct cdrom_read_audio
 187 {
 188         union
 189         {
 190                 struct                  
 191                 {
 192                         u_char minute;
 193                         u_char second;
 194                         u_char frame;
 195                 } msf;
 196                 int     lba;
 197         } addr; /* frame address */
 198         u_char addr_format; /* CDROM_LBA or CDROM_MSF */
 199         int nframes; /* number of 2352-byte-frames to read at once, limited by the drivers */
 200         u_char *buf; /* frame buffer (size: nframes*2352 bytes) */
 201 };
 202 
 203 /*
 204  * this has to be the "arg" of the CDROMMULTISESSION ioctl
 205  * for obtaining multi session info.
 206  * The returned "addr" is valid only if "xa_flag" is true.
 207  */
 208 struct cdrom_multisession
 209 {
 210         union
 211         {
 212                 struct                  
 213                 {
 214                         u_char minute;
 215                         u_char second;
 216                         u_char frame;
 217                 } msf;
 218                 int lba;
 219         } addr; /* frame address: start-of-last-session (not the new "frame 16"!)*/
 220         u_char xa_flag; /* 1: "is XA disk" */
 221         u_char addr_format; /* CDROM_LBA or CDROM_MSF */
 222 };
 223 
 224 #ifdef FIVETWELVE
 225 #define CDROM_MODE1_SIZE        512
 226 #else
 227 #define CDROM_MODE1_SIZE        2048
 228 #endif FIVETWELVE
 229 #define CDROM_MODE2_SIZE        2336
 230 
 231 /*
 232  * CD-ROM IOCTL commands
 233  * For IOCTL calls, we will commandeer byte 0x53, or 'S'.
 234  */
 235 
 236 #define CDROMPAUSE              0x5301
 237 #define CDROMRESUME             0x5302
 238 #define CDROMPLAYMSF            0x5303  /* (struct cdrom_msf) */
 239 #define CDROMPLAYTRKIND         0x5304  /* (struct cdrom_ti) */
 240 
 241 #define CDROMREADTOCHDR         0x5305  /* (struct cdrom_tochdr) */
 242 #define CDROMREADTOCENTRY       0x5306  /* (struct cdrom_tocentry) */
 243 
 244 #define CDROMSTOP               0x5307  /* stop the drive motor */
 245 #define CDROMSTART              0x5308  /* turn the motor on */
 246 
 247 #define CDROMEJECT              0x5309  /* eject CD-ROM media */
 248 
 249 #define CDROMVOLCTRL            0x530a  /* (struct cdrom_volctrl) */
 250 
 251 #define CDROMSUBCHNL            0x530b  /* (struct cdrom_subchnl) */
 252 
 253 #define CDROMREADMODE2          0x530c  /* (struct cdrom_read) */
 254                                           /* read type-2 data (not suppt) */
 255 
 256 #define CDROMREADMODE1          0x530d  /* (struct cdrom_read) */
 257                                           /* read type-1 data */
 258 
 259 #define CDROMREADAUDIO          0x530e  /* (struct cdrom_read_audio) */
 260 
 261 /*
 262  * enable (1) / disable (0) auto-ejecting
 263  */
 264 #define CDROMEJECT_SW           0x530f  /* arg: 0 or 1 */
 265  
 266 /*
 267  * obtain the start-of-last-session address of multi session disks
 268  */
 269 #define CDROMMULTISESSION       0x5310  /* (struct cdrom_multisession) */
 270 
 271 /*
 272  * obtain the "universal product code" number
 273  * (only some data disks have it coded)
 274  */
 275 #define CDROM_GET_UPC           0x5311  /* 8 bytes returned */
 276 
 277 #define CDROMRESET              0x5312  /* hard-reset the drive */
 278 #define CDROMVOLREAD            0x5313  /* let the drive tell its volume setting */
 279                                         /* (struct cdrom_volctrl) */
 280 
 281 /* 
 282  * these ioctls are used in aztcd.c
 283  */
 284 #define CDROMREADRAW            0x5314  /* read data in raw mode */
 285 #define CDROMREADCOOKED         0x5315  /* read data in cooked mode */
 286 #define CDROMSEEK               0x5316  /*seek msf address*/
 287   
 288 
 289 
 290 /*
 291  * CD-ROM-specific SCSI command opcodes
 292  */
 293 
 294 /*
 295  * Group 2 (10-byte).  All of these are called 'optional' by SCSI-II.
 296  */
 297 #define SCMD_READ_TOC           0x43    /* read table of contents */
 298 #define SCMD_PLAYAUDIO_MSF      0x47    /* play data at time offset */
 299 #define SCMD_PLAYAUDIO_TI       0x48    /* play data at track/index */
 300 #define SCMD_PAUSE_RESUME       0x4B    /* pause/resume audio */
 301 #define SCMD_READ_SUBCHANNEL    0x42    /* read SC info on playing disc */
 302 #define SCMD_PLAYAUDIO10        0x45    /* play data at logical block */
 303 #define SCMD_READ_HEADER        0x44    /* read TOC header */
 304 
 305 /*
 306  * Group 5
 307  */
 308 #define SCMD_PLAYAUDIO12        0xA5    /* play data at logical block */
 309 #define SCMD_PLAYTRACK_REL12    0xA9    /* play track at relative offset */
 310 
 311 /*
 312  * Group 6 Commands
 313  */
 314 #define SCMD_CD_PLAYBACK_CONTROL 0xC9   /* Sony vendor-specific audio */
 315 #define SCMD_CD_PLAYBACK_STATUS 0xC4    /* control opcodes */
 316 
 317 /*
 318  * CD-ROM capacity structure.
 319  */
 320 struct scsi_capacity 
 321 {
 322         u_long  capacity;
 323         u_long  lbasize;
 324 };
 325 
 326 /*
 327  * CD-ROM MODE_SENSE/MODE_SELECT parameters
 328  */
 329 #define ERR_RECOVERY_PARMS      0x01
 330 #define DISCO_RECO_PARMS        0x02
 331 #define FORMAT_PARMS            0x03
 332 #define GEOMETRY_PARMS          0x04
 333 #define CERTIFICATION_PARMS     0x06
 334 #define CACHE_PARMS             0x38
 335 
 336 /*
 337  * standard mode-select header prepended to all mode-select commands
 338  */
 339 struct ccs_modesel_head 
 340 {
 341         u_char  _r1;    /* reserved */
 342         u_char  medium; /* device-specific medium type */
 343         u_char  _r2;    /* reserved */
 344         u_char  block_desc_length; /* block descriptor length */
 345         u_char  density; /* device-specific density code */
 346         u_char  number_blocks_hi; /* number of blocks in this block desc */
 347         u_char  number_blocks_med;
 348         u_char  number_blocks_lo;
 349         u_char  _r3;
 350         u_char  block_length_hi; /* block length for blocks in this desc */
 351         u_short block_length;
 352 };
 353 
 354 /*
 355  * error recovery parameters
 356  */
 357 struct ccs_err_recovery 
 358 {
 359         u_char  _r1 : 2;        /* reserved */
 360         u_char  page_code : 6;  /* page code */
 361         u_char  page_length;    /* page length */
 362         u_char  awre    : 1;    /* auto write realloc enabled */
 363         u_char  arre    : 1;    /* auto read realloc enabled */
 364         u_char  tb      : 1;    /* transfer block */
 365         u_char  rc      : 1;    /* read continuous */
 366         u_char  eec     : 1;    /* enable early correction */
 367         u_char  per     : 1;    /* post error */
 368         u_char  dte     : 1;    /* disable transfer on error */
 369         u_char  dcr     : 1;    /* disable correction */
 370         u_char  retry_count;    /* error retry count */
 371         u_char  correction_span; /* largest recov. to be attempted, bits */
 372         u_char  head_offset_count; /* head offset (2's C) for each retry */
 373         u_char  strobe_offset_count; /* data strobe */
 374         u_char  recovery_time_limit; /* time limit on recovery attempts */
 375 };
 376 
 377 /*
 378  * disco/reco parameters
 379  */
 380 struct ccs_disco_reco 
 381 {
 382         u_char  _r1     : 2;    /* reserved */
 383         u_char  page_code : 6;  /* page code */
 384         u_char  page_length;    /* page length */
 385         u_char  buffer_full_ratio; /* write buffer reconnect threshold */
 386         u_char  buffer_empty_ratio; /* read */
 387         u_short bus_inactivity_limit; /* limit on bus inactivity time */
 388         u_short disconnect_time_limit; /* minimum disconnect time */
 389         u_short connect_time_limit; /* minimum connect time */
 390         u_short _r2;            /* reserved */
 391 };
 392 
 393 /*
 394  * drive geometry parameters
 395  */
 396 struct ccs_geometry 
 397 {
 398         u_char  _r1     : 2;    /* reserved */
 399         u_char  page_code : 6;  /* page code */
 400         u_char  page_length;    /* page length */
 401         u_char  cyl_ub;         /* #cyls */
 402         u_char  cyl_mb;
 403         u_char  cyl_lb;
 404         u_char  heads;          /* #heads */
 405         u_char  precomp_cyl_ub; /* precomp start */
 406         u_char  precomp_cyl_mb;
 407         u_char  precomp_cyl_lb;
 408         u_char  current_cyl_ub; /* reduced current start */
 409         u_char  current_cyl_mb;
 410         u_char  current_cyl_lb;
 411         u_short step_rate;      /* stepping motor rate */
 412         u_char  landing_cyl_ub; /* landing zone */
 413         u_char  landing_cyl_mb;
 414         u_char  landing_cyl_lb;
 415         u_char  _r2;
 416         u_char  _r3;
 417         u_char  _r4;
 418 };
 419 
 420 /*
 421  * cache parameters
 422  */
 423 struct ccs_cache 
 424 {
 425         u_char  _r1     : 2;    /* reserved */
 426         u_char  page_code : 6;  /* page code */
 427         u_char  page_length;    /* page length */
 428         u_char  mode;           /* cache control byte */
 429         u_char  threshold;      /* prefetch threshold */
 430         u_char  max_prefetch;   /* maximum prefetch size */
 431         u_char  max_multiplier; /* maximum prefetch multiplier */
 432         u_char  min_prefetch;   /* minimum prefetch size */
 433         u_char  min_multiplier; /* minimum prefetch multiplier */
 434         u_char  _r2[8];
 435 };
 436 
 437 #endif  _LINUX_CDROM_H
 438 /*==========================================================================*/
 439 /*
 440  * Overrides for Emacs so that we follow Linus's tabbing style.
 441  * Emacs will notice this stuff at the end of the file and automatically
 442  * adjust the settings for this buffer only.  This must remain at the end
 443  * of the file. 
 444  * ---------------------------------------------------------------------------
 445  * Local variables:
 446  * c-indent-level: 8
 447  * c-brace-imaginary-offset: 0
 448  * c-brace-offset: -8
 449  * c-argdecl-indent: 8
 450  * c-label-offset: -8
 451  * c-continued-statement-offset: 8
 452  * c-continued-brace-offset: 0
 453  * End:
 454  */

/* [previous][next][first][last][top][bottom][index][help] */