cdrom.h 28 KB

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