cdrom.h 29 KB

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