cdrom.h 28 KB

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