cdrom.h 35 KB

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