cdrom-standard.rst 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  1. =======================
  2. A Linux CD-ROM standard
  3. =======================
  4. :Author: David van Leeuwen <david@ElseWare.cistron.nl>
  5. :Date: 12 March 1999
  6. :Updated by: Erik Andersen (andersee@debian.org)
  7. :Updated by: Jens Axboe (axboe@image.dk)
  8. Introduction
  9. ============
  10. Linux is probably the Unix-like operating system that supports
  11. the widest variety of hardware devices. The reasons for this are
  12. presumably
  13. - The large list of hardware devices available for the many platforms
  14. that Linux now supports (i.e., i386-PCs, Sparc Suns, etc.)
  15. - The open design of the operating system, such that anybody can write a
  16. driver for Linux.
  17. - There is plenty of source code around as examples of how to write a driver.
  18. The openness of Linux, and the many different types of available
  19. hardware has allowed Linux to support many different hardware devices.
  20. Unfortunately, the very openness that has allowed Linux to support
  21. all these different devices has also allowed the behavior of each
  22. device driver to differ significantly from one device to another.
  23. This divergence of behavior has been very significant for CD-ROM
  24. devices; the way a particular drive reacts to a `standard` *ioctl()*
  25. call varies greatly from one device driver to another. To avoid making
  26. their drivers totally inconsistent, the writers of Linux CD-ROM
  27. drivers generally created new device drivers by understanding, copying,
  28. and then changing an existing one. Unfortunately, this practice did not
  29. maintain uniform behavior across all the Linux CD-ROM drivers.
  30. This document describes an effort to establish Uniform behavior across
  31. all the different CD-ROM device drivers for Linux. This document also
  32. defines the various *ioctl()'s*, and how the low-level CD-ROM device
  33. drivers should implement them. Currently (as of the Linux 2.1.\ *x*
  34. development kernels) several low-level CD-ROM device drivers, including
  35. both IDE/ATAPI and SCSI, now use this Uniform interface.
  36. When the CD-ROM was developed, the interface between the CD-ROM drive
  37. and the computer was not specified in the standards. As a result, many
  38. different CD-ROM interfaces were developed. Some of them had their
  39. own proprietary design (Sony, Mitsumi, Panasonic, Philips), other
  40. manufacturers adopted an existing electrical interface and changed
  41. the functionality (CreativeLabs/SoundBlaster, Teac, Funai) or simply
  42. adapted their drives to one or more of the already existing electrical
  43. interfaces (Aztech, Sanyo, Funai, Vertos, Longshine, Optics Storage and
  44. most of the `NoName` manufacturers). In cases where a new drive really
  45. brought its own interface or used its own command set and flow control
  46. scheme, either a separate driver had to be written, or an existing
  47. driver had to be enhanced. History has delivered us CD-ROM support for
  48. many of these different interfaces. Nowadays, almost all new CD-ROM
  49. drives are either IDE/ATAPI or SCSI, and it is very unlikely that any
  50. manufacturer will create a new interface. Even finding drives for the
  51. old proprietary interfaces is getting difficult.
  52. When (in the 1.3.70's) I looked at the existing software interface,
  53. which was expressed through `cdrom.h`, it appeared to be a rather wild
  54. set of commands and data formats [#f1]_. It seemed that many
  55. features of the software interface had been added to accommodate the
  56. capabilities of a particular drive, in an *ad hoc* manner. More
  57. importantly, it appeared that the behavior of the `standard` commands
  58. was different for most of the different drivers: e. g., some drivers
  59. close the tray if an *open()* call occurs when the tray is open, while
  60. others do not. Some drivers lock the door upon opening the device, to
  61. prevent an incoherent file system, but others don't, to allow software
  62. ejection. Undoubtedly, the capabilities of the different drives vary,
  63. but even when two drives have the same capability their drivers'
  64. behavior was usually different.
  65. .. [#f1]
  66. I cannot recollect what kernel version I looked at, then,
  67. presumably 1.2.13 and 1.3.34 --- the latest kernel that I was
  68. indirectly involved in.
  69. I decided to start a discussion on how to make all the Linux CD-ROM
  70. drivers behave more uniformly. I began by contacting the developers of
  71. the many CD-ROM drivers found in the Linux kernel. Their reactions
  72. encouraged me to write the Uniform CD-ROM Driver which this document is
  73. intended to describe. The implementation of the Uniform CD-ROM Driver is
  74. in the file `cdrom.c`. This driver is intended to be an additional software
  75. layer that sits on top of the low-level device drivers for each CD-ROM drive.
  76. By adding this additional layer, it is possible to have all the different
  77. CD-ROM devices behave **exactly** the same (insofar as the underlying
  78. hardware will allow).
  79. The goal of the Uniform CD-ROM Driver is **not** to alienate driver developers
  80. whohave not yet taken steps to support this effort. The goal of Uniform CD-ROM
  81. Driver is simply to give people writing application programs for CD-ROM drives
  82. **one** Linux CD-ROM interface with consistent behavior for all
  83. CD-ROM devices. In addition, this also provides a consistent interface
  84. between the low-level device driver code and the Linux kernel. Care
  85. is taken that 100% compatibility exists with the data structures and
  86. programmer's interface defined in `cdrom.h`. This guide was written to
  87. help CD-ROM driver developers adapt their code to use the Uniform CD-ROM
  88. Driver code defined in `cdrom.c`.
  89. Personally, I think that the most important hardware interfaces are
  90. the IDE/ATAPI drives and, of course, the SCSI drives, but as prices
  91. of hardware drop continuously, it is also likely that people may have
  92. more than one CD-ROM drive, possibly of mixed types. It is important
  93. that these drives behave in the same way. In December 1994, one of the
  94. cheapest CD-ROM drives was a Philips cm206, a double-speed proprietary
  95. drive. In the months that I was busy writing a Linux driver for it,
  96. proprietary drives became obsolete and IDE/ATAPI drives became the
  97. standard. At the time of the last update to this document (November
  98. 1997) it is becoming difficult to even **find** anything less than a
  99. 16 speed CD-ROM drive, and 24 speed drives are common.
  100. .. _cdrom_api:
  101. Standardizing through another software level
  102. ============================================
  103. At the time this document was conceived, all drivers directly
  104. implemented the CD-ROM *ioctl()* calls through their own routines. This
  105. led to the danger of different drivers forgetting to do important things
  106. like checking that the user was giving the driver valid data. More
  107. importantly, this led to the divergence of behavior, which has already
  108. been discussed.
  109. For this reason, the Uniform CD-ROM Driver was created to enforce consistent
  110. CD-ROM drive behavior, and to provide a common set of services to the various
  111. low-level CD-ROM device drivers. The Uniform CD-ROM Driver now provides another
  112. software-level, that separates the *ioctl()* and *open()* implementation
  113. from the actual hardware implementation. Note that this effort has
  114. made few changes which will affect a user's application programs. The
  115. greatest change involved moving the contents of the various low-level
  116. CD-ROM drivers\' header files to the kernel's cdrom directory. This was
  117. done to help ensure that the user is only presented with only one cdrom
  118. interface, the interface defined in `cdrom.h`.
  119. CD-ROM drives are specific enough (i. e., different from other
  120. block-devices such as floppy or hard disc drives), to define a set
  121. of common **CD-ROM device operations**, *<cdrom-device>_dops*.
  122. These operations are different from the classical block-device file
  123. operations, *<block-device>_fops*.
  124. The routines for the Uniform CD-ROM Driver interface level are implemented
  125. in the file `cdrom.c`. In this file, the Uniform CD-ROM Driver interfaces
  126. with the kernel as a block device by registering the following general
  127. *struct file_operations*::
  128. struct file_operations cdrom_fops = {
  129. NULL, /∗ lseek ∗/
  130. block _read , /∗ read—general block-dev read ∗/
  131. block _write, /∗ write—general block-dev write ∗/
  132. NULL, /∗ readdir ∗/
  133. NULL, /∗ select ∗/
  134. cdrom_ioctl, /∗ ioctl ∗/
  135. NULL, /∗ mmap ∗/
  136. cdrom_open, /∗ open ∗/
  137. cdrom_release, /∗ release ∗/
  138. NULL, /∗ fsync ∗/
  139. NULL, /∗ fasync ∗/
  140. NULL /∗ revalidate ∗/
  141. };
  142. Every active CD-ROM device shares this *struct*. The routines
  143. declared above are all implemented in `cdrom.c`, since this file is the
  144. place where the behavior of all CD-ROM-devices is defined and
  145. standardized. The actual interface to the various types of CD-ROM
  146. hardware is still performed by various low-level CD-ROM-device
  147. drivers. These routines simply implement certain **capabilities**
  148. that are common to all CD-ROM (and really, all removable-media
  149. devices).
  150. Registration of a low-level CD-ROM device driver is now done through
  151. the general routines in `cdrom.c`, not through the Virtual File System
  152. (VFS) any more. The interface implemented in `cdrom.c` is carried out
  153. through two general structures that contain information about the
  154. capabilities of the driver, and the specific drives on which the
  155. driver operates. The structures are:
  156. cdrom_device_ops
  157. This structure contains information about the low-level driver for a
  158. CD-ROM device. This structure is conceptually connected to the major
  159. number of the device (although some drivers may have different
  160. major numbers, as is the case for the IDE driver).
  161. cdrom_device_info
  162. This structure contains information about a particular CD-ROM drive,
  163. such as its device name, speed, etc. This structure is conceptually
  164. connected to the minor number of the device.
  165. Registering a particular CD-ROM drive with the Uniform CD-ROM Driver
  166. is done by the low-level device driver though a call to::
  167. register_cdrom(struct cdrom_device_info * <device>_info)
  168. The device information structure, *<device>_info*, contains all the
  169. information needed for the kernel to interface with the low-level
  170. CD-ROM device driver. One of the most important entries in this
  171. structure is a pointer to the *cdrom_device_ops* structure of the
  172. low-level driver.
  173. The device operations structure, *cdrom_device_ops*, contains a list
  174. of pointers to the functions which are implemented in the low-level
  175. device driver. When `cdrom.c` accesses a CD-ROM device, it does it
  176. through the functions in this structure. It is impossible to know all
  177. the capabilities of future CD-ROM drives, so it is expected that this
  178. list may need to be expanded from time to time as new technologies are
  179. developed. For example, CD-R and CD-R/W drives are beginning to become
  180. popular, and support will soon need to be added for them. For now, the
  181. current *struct* is::
  182. struct cdrom_device_ops {
  183. int (*open)(struct cdrom_device_info *, int)
  184. void (*release)(struct cdrom_device_info *);
  185. int (*drive_status)(struct cdrom_device_info *, int);
  186. unsigned int (*check_events)(struct cdrom_device_info *,
  187. unsigned int, int);
  188. int (*media_changed)(struct cdrom_device_info *, int);
  189. int (*tray_move)(struct cdrom_device_info *, int);
  190. int (*lock_door)(struct cdrom_device_info *, int);
  191. int (*select_speed)(struct cdrom_device_info *, int);
  192. int (*select_disc)(struct cdrom_device_info *, int);
  193. int (*get_last_session) (struct cdrom_device_info *,
  194. struct cdrom_multisession *);
  195. int (*get_mcn)(struct cdrom_device_info *, struct cdrom_mcn *);
  196. int (*reset)(struct cdrom_device_info *);
  197. int (*audio_ioctl)(struct cdrom_device_info *,
  198. unsigned int, void *);
  199. const int capability; /* capability flags */
  200. int (*generic_packet)(struct cdrom_device_info *,
  201. struct packet_command *);
  202. };
  203. When a low-level device driver implements one of these capabilities,
  204. it should add a function pointer to this *struct*. When a particular
  205. function is not implemented, however, this *struct* should contain a
  206. NULL instead. The *capability* flags specify the capabilities of the
  207. CD-ROM hardware and/or low-level CD-ROM driver when a CD-ROM drive
  208. is registered with the Uniform CD-ROM Driver.
  209. Note that most functions have fewer parameters than their
  210. *blkdev_fops* counterparts. This is because very little of the
  211. information in the structures *inode* and *file* is used. For most
  212. drivers, the main parameter is the *struct* *cdrom_device_info*, from
  213. which the major and minor number can be extracted. (Most low-level
  214. CD-ROM drivers don't even look at the major and minor number though,
  215. since many of them only support one device.) This will be available
  216. through *dev* in *cdrom_device_info* described below.
  217. The drive-specific, minor-like information that is registered with
  218. `cdrom.c`, currently contains the following fields::
  219. struct cdrom_device_info {
  220. const struct cdrom_device_ops * ops; /* device operations for this major */
  221. struct list_head list; /* linked list of all device_info */
  222. struct gendisk * disk; /* matching block layer disk */
  223. void * handle; /* driver-dependent data */
  224. int mask; /* mask of capability: disables them */
  225. int speed; /* maximum speed for reading data */
  226. int capacity; /* number of discs in a jukebox */
  227. unsigned int options:30; /* options flags */
  228. unsigned mc_flags:2; /* media-change buffer flags */
  229. unsigned int vfs_events; /* cached events for vfs path */
  230. unsigned int ioctl_events; /* cached events for ioctl path */
  231. int use_count; /* number of times device is opened */
  232. char name[20]; /* name of the device type */
  233. __u8 sanyo_slot : 2; /* Sanyo 3-CD changer support */
  234. __u8 keeplocked : 1; /* CDROM_LOCKDOOR status */
  235. __u8 reserved : 5; /* not used yet */
  236. int cdda_method; /* see CDDA_* flags */
  237. __u8 last_sense; /* saves last sense key */
  238. __u8 media_written; /* dirty flag, DVD+RW bookkeeping */
  239. unsigned short mmc3_profile; /* current MMC3 profile */
  240. int for_data; /* unknown:TBD */
  241. int (*exit)(struct cdrom_device_info *);/* unknown:TBD */
  242. int mrw_mode_page; /* which MRW mode page is in use */
  243. };
  244. Using this *struct*, a linked list of the registered minor devices is
  245. built, using the *next* field. The device number, the device operations
  246. struct and specifications of properties of the drive are stored in this
  247. structure.
  248. The *mask* flags can be used to mask out some of the capabilities listed
  249. in *ops->capability*, if a specific drive doesn't support a feature
  250. of the driver. The value *speed* specifies the maximum head-rate of the
  251. drive, measured in units of normal audio speed (176kB/sec raw data or
  252. 150kB/sec file system data). The parameters are declared *const*
  253. because they describe properties of the drive, which don't change after
  254. registration.
  255. A few registers contain variables local to the CD-ROM drive. The
  256. flags *options* are used to specify how the general CD-ROM routines
  257. should behave. These various flags registers should provide enough
  258. flexibility to adapt to the different users' wishes (and **not** the
  259. `arbitrary` wishes of the author of the low-level device driver, as is
  260. the case in the old scheme). The register *mc_flags* is used to buffer
  261. the information from *media_changed()* to two separate queues. Other
  262. data that is specific to a minor drive, can be accessed through *handle*,
  263. which can point to a data structure specific to the low-level driver.
  264. The fields *use_count*, *next*, *options* and *mc_flags* need not be
  265. initialized.
  266. The intermediate software layer that `cdrom.c` forms will perform some
  267. additional bookkeeping. The use count of the device (the number of
  268. processes that have the device opened) is registered in *use_count*. The
  269. function *cdrom_ioctl()* will verify the appropriate user-memory regions
  270. for read and write, and in case a location on the CD is transferred,
  271. it will `sanitize` the format by making requests to the low-level
  272. drivers in a standard format, and translating all formats between the
  273. user-software and low level drivers. This relieves much of the drivers'
  274. memory checking and format checking and translation. Also, the necessary
  275. structures will be declared on the program stack.
  276. The implementation of the functions should be as defined in the
  277. following sections. Two functions **must** be implemented, namely
  278. *open()* and *release()*. Other functions may be omitted, their
  279. corresponding capability flags will be cleared upon registration.
  280. Generally, a function returns zero on success and negative on error. A
  281. function call should return only after the command has completed, but of
  282. course waiting for the device should not use processor time.
  283. ::
  284. int open(struct cdrom_device_info *cdi, int purpose)
  285. *Open()* should try to open the device for a specific *purpose*, which
  286. can be either:
  287. - Open for reading data, as done by `mount()` (2), or the
  288. user commands `dd` or `cat`.
  289. - Open for *ioctl* commands, as done by audio-CD playing programs.
  290. Notice that any strategic code (closing tray upon *open()*, etc.) is
  291. done by the calling routine in `cdrom.c`, so the low-level routine
  292. should only be concerned with proper initialization, such as spinning
  293. up the disc, etc.
  294. ::
  295. void release(struct cdrom_device_info *cdi)
  296. Device-specific actions should be taken such as spinning down the device.
  297. However, strategic actions such as ejection of the tray, or unlocking
  298. the door, should be left over to the general routine *cdrom_release()*.
  299. This is the only function returning type *void*.
  300. .. _cdrom_drive_status:
  301. ::
  302. int drive_status(struct cdrom_device_info *cdi, int slot_nr)
  303. The function *drive_status*, if implemented, should provide
  304. information on the status of the drive (not the status of the disc,
  305. which may or may not be in the drive). If the drive is not a changer,
  306. *slot_nr* should be ignored. In `cdrom.h` the possibilities are listed::
  307. CDS_NO_INFO /* no information available */
  308. CDS_NO_DISC /* no disc is inserted, tray is closed */
  309. CDS_TRAY_OPEN /* tray is opened */
  310. CDS_DRIVE_NOT_READY /* something is wrong, tray is moving? */
  311. CDS_DISC_OK /* a disc is loaded and everything is fine */
  312. ::
  313. int tray_move(struct cdrom_device_info *cdi, int position)
  314. This function, if implemented, should control the tray movement. (No
  315. other function should control this.) The parameter *position* controls
  316. the desired direction of movement:
  317. - 0 Close tray
  318. - 1 Open tray
  319. This function returns 0 upon success, and a non-zero value upon
  320. error. Note that if the tray is already in the desired position, no
  321. action need be taken, and the return value should be 0.
  322. ::
  323. int lock_door(struct cdrom_device_info *cdi, int lock)
  324. This function (and no other code) controls locking of the door, if the
  325. drive allows this. The value of *lock* controls the desired locking
  326. state:
  327. - 0 Unlock door, manual opening is allowed
  328. - 1 Lock door, tray cannot be ejected manually
  329. This function returns 0 upon success, and a non-zero value upon
  330. error. Note that if the door is already in the requested state, no
  331. action need be taken, and the return value should be 0.
  332. ::
  333. int select_speed(struct cdrom_device_info *cdi, int speed)
  334. Some CD-ROM drives are capable of changing their head-speed. There
  335. are several reasons for changing the speed of a CD-ROM drive. Badly
  336. pressed CD-ROM s may benefit from less-than-maximum head rate. Modern
  337. CD-ROM drives can obtain very high head rates (up to *24x* is
  338. common). It has been reported that these drives can make reading
  339. errors at these high speeds, reducing the speed can prevent data loss
  340. in these circumstances. Finally, some of these drives can
  341. make an annoyingly loud noise, which a lower speed may reduce.
  342. This function specifies the speed at which data is read or audio is
  343. played back. The value of *speed* specifies the head-speed of the
  344. drive, measured in units of standard cdrom speed (176kB/sec raw data
  345. or 150kB/sec file system data). So to request that a CD-ROM drive
  346. operate at 300kB/sec you would call the CDROM_SELECT_SPEED *ioctl*
  347. with *speed=2*. The special value `0` means `auto-selection`, i. e.,
  348. maximum data-rate or real-time audio rate. If the drive doesn't have
  349. this `auto-selection` capability, the decision should be made on the
  350. current disc loaded and the return value should be positive. A negative
  351. return value indicates an error.
  352. ::
  353. int select_disc(struct cdrom_device_info *cdi, int number)
  354. If the drive can store multiple discs (a juke-box) this function
  355. will perform disc selection. It should return the number of the
  356. selected disc on success, a negative value on error. Currently, only
  357. the ide-cd driver supports this functionality.
  358. ::
  359. int get_last_session(struct cdrom_device_info *cdi,
  360. struct cdrom_multisession *ms_info)
  361. This function should implement the old corresponding *ioctl()*. For
  362. device *cdi->dev*, the start of the last session of the current disc
  363. should be returned in the pointer argument *ms_info*. Note that
  364. routines in `cdrom.c` have sanitized this argument: its requested
  365. format will **always** be of the type *CDROM_LBA* (linear block
  366. addressing mode), whatever the calling software requested. But
  367. sanitization goes even further: the low-level implementation may
  368. return the requested information in *CDROM_MSF* format if it wishes so
  369. (setting the *ms_info->addr_format* field appropriately, of
  370. course) and the routines in `cdrom.c` will make the transformation if
  371. necessary. The return value is 0 upon success.
  372. ::
  373. int get_mcn(struct cdrom_device_info *cdi,
  374. struct cdrom_mcn *mcn)
  375. Some discs carry a `Media Catalog Number` (MCN), also called
  376. `Universal Product Code` (UPC). This number should reflect the number
  377. that is generally found in the bar-code on the product. Unfortunately,
  378. the few discs that carry such a number on the disc don't even use the
  379. same format. The return argument to this function is a pointer to a
  380. pre-declared memory region of type *struct cdrom_mcn*. The MCN is
  381. expected as a 13-character string, terminated by a null-character.
  382. ::
  383. int reset(struct cdrom_device_info *cdi)
  384. This call should perform a hard-reset on the drive (although in
  385. circumstances that a hard-reset is necessary, a drive may very well not
  386. listen to commands anymore). Preferably, control is returned to the
  387. caller only after the drive has finished resetting. If the drive is no
  388. longer listening, it may be wise for the underlying low-level cdrom
  389. driver to time out.
  390. ::
  391. int audio_ioctl(struct cdrom_device_info *cdi,
  392. unsigned int cmd, void *arg)
  393. Some of the CD-ROM-\ *ioctl()*\ 's defined in `cdrom.h` can be
  394. implemented by the routines described above, and hence the function
  395. *cdrom_ioctl* will use those. However, most *ioctl()*\ 's deal with
  396. audio-control. We have decided to leave these to be accessed through a
  397. single function, repeating the arguments *cmd* and *arg*. Note that
  398. the latter is of type *void*, rather than *unsigned long int*.
  399. The routine *cdrom_ioctl()* does do some useful things,
  400. though. It sanitizes the address format type to *CDROM_MSF* (Minutes,
  401. Seconds, Frames) for all audio calls. It also verifies the memory
  402. location of *arg*, and reserves stack-memory for the argument. This
  403. makes implementation of the *audio_ioctl()* much simpler than in the
  404. old driver scheme. For example, you may look up the function
  405. *cm206_audio_ioctl()* `cm206.c` that should be updated with
  406. this documentation.
  407. An unimplemented ioctl should return *-ENOSYS*, but a harmless request
  408. (e. g., *CDROMSTART*) may be ignored by returning 0 (success). Other
  409. errors should be according to the standards, whatever they are. When
  410. an error is returned by the low-level driver, the Uniform CD-ROM Driver
  411. tries whenever possible to return the error code to the calling program.
  412. (We may decide to sanitize the return value in *cdrom_ioctl()* though, in
  413. order to guarantee a uniform interface to the audio-player software.)
  414. ::
  415. int dev_ioctl(struct cdrom_device_info *cdi,
  416. unsigned int cmd, unsigned long arg)
  417. Some *ioctl()'s* seem to be specific to certain CD-ROM drives. That is,
  418. they are introduced to service some capabilities of certain drives. In
  419. fact, there are 6 different *ioctl()'s* for reading data, either in some
  420. particular kind of format, or audio data. Not many drives support
  421. reading audio tracks as data, I believe this is because of protection
  422. of copyrights of artists. Moreover, I think that if audio-tracks are
  423. supported, it should be done through the VFS and not via *ioctl()'s*. A
  424. problem here could be the fact that audio-frames are 2352 bytes long,
  425. so either the audio-file-system should ask for 75264 bytes at once
  426. (the least common multiple of 512 and 2352), or the drivers should
  427. bend their backs to cope with this incoherence (to which I would be
  428. opposed). Furthermore, it is very difficult for the hardware to find
  429. the exact frame boundaries, since there are no synchronization headers
  430. in audio frames. Once these issues are resolved, this code should be
  431. standardized in `cdrom.c`.
  432. Because there are so many *ioctl()'s* that seem to be introduced to
  433. satisfy certain drivers [#f2]_, any non-standard *ioctl()*\ s
  434. are routed through the call *dev_ioctl()*. In principle, `private`
  435. *ioctl()*\ 's should be numbered after the device's major number, and not
  436. the general CD-ROM *ioctl* number, `0x53`. Currently the
  437. non-supported *ioctl()'s* are:
  438. CDROMREADMODE1, CDROMREADMODE2, CDROMREADAUDIO, CDROMREADRAW,
  439. CDROMREADCOOKED, CDROMSEEK, CDROMPLAY-BLK and CDROM-READALL
  440. .. [#f2]
  441. Is there software around that actually uses these? I'd be interested!
  442. .. _cdrom_capabilities:
  443. CD-ROM capabilities
  444. -------------------
  445. Instead of just implementing some *ioctl* calls, the interface in
  446. `cdrom.c` supplies the possibility to indicate the **capabilities**
  447. of a CD-ROM drive. This can be done by ORing any number of
  448. capability-constants that are defined in `cdrom.h` at the registration
  449. phase. Currently, the capabilities are any of::
  450. CDC_CLOSE_TRAY /* can close tray by software control */
  451. CDC_OPEN_TRAY /* can open tray */
  452. CDC_LOCK /* can lock and unlock the door */
  453. CDC_SELECT_SPEED /* can select speed, in units of * sim*150 ,kB/s */
  454. CDC_SELECT_DISC /* drive is juke-box */
  455. CDC_MULTI_SESSION /* can read sessions *> rm1* */
  456. CDC_MCN /* can read Media Catalog Number */
  457. CDC_MEDIA_CHANGED /* can report if disc has changed */
  458. CDC_PLAY_AUDIO /* can perform audio-functions (play, pause, etc) */
  459. CDC_RESET /* hard reset device */
  460. CDC_IOCTLS /* driver has non-standard ioctls */
  461. CDC_DRIVE_STATUS /* driver implements drive status */
  462. The capability flag is declared *const*, to prevent drivers from
  463. accidentally tampering with the contents. The capability flags actually
  464. inform `cdrom.c` of what the driver can do. If the drive found
  465. by the driver does not have the capability, is can be masked out by
  466. the *cdrom_device_info* variable *mask*. For instance, the SCSI CD-ROM
  467. driver has implemented the code for loading and ejecting CD-ROM's, and
  468. hence its corresponding flags in *capability* will be set. But a SCSI
  469. CD-ROM drive might be a caddy system, which can't load the tray, and
  470. hence for this drive the *cdrom_device_info* struct will have set
  471. the *CDC_CLOSE_TRAY* bit in *mask*.
  472. In the file `cdrom.c` you will encounter many constructions of the type::
  473. if (cdo->capability & ∼cdi->mask & CDC _⟨capability⟩) ...
  474. There is no *ioctl* to set the mask... The reason is that
  475. I think it is better to control the **behavior** rather than the
  476. **capabilities**.
  477. Options
  478. -------
  479. A final flag register controls the **behavior** of the CD-ROM
  480. drives, in order to satisfy different users' wishes, hopefully
  481. independently of the ideas of the respective author who happened to
  482. have made the drive's support available to the Linux community. The
  483. current behavior options are::
  484. CDO_AUTO_CLOSE /* try to close tray upon device open() */
  485. CDO_AUTO_EJECT /* try to open tray on last device close() */
  486. CDO_USE_FFLAGS /* use file_pointer->f_flags to indicate purpose for open() */
  487. CDO_LOCK /* try to lock door if device is opened */
  488. CDO_CHECK_TYPE /* ensure disc type is data if opened for data */
  489. The initial value of this register is
  490. `CDO_AUTO_CLOSE | CDO_USE_FFLAGS | CDO_LOCK`, reflecting my own view on user
  491. interface and software standards. Before you protest, there are two
  492. new *ioctl()'s* implemented in `cdrom.c`, that allow you to control the
  493. behavior by software. These are::
  494. CDROM_SET_OPTIONS /* set options specified in (int)arg */
  495. CDROM_CLEAR_OPTIONS /* clear options specified in (int)arg */
  496. One option needs some more explanation: *CDO_USE_FFLAGS*. In the next
  497. newsection we explain what the need for this option is.
  498. A software package `setcd`, available from the Debian distribution
  499. and `sunsite.unc.edu`, allows user level control of these flags.
  500. The need to know the purpose of opening the CD-ROM device
  501. =========================================================
  502. Traditionally, Unix devices can be used in two different `modes`,
  503. either by reading/writing to the device file, or by issuing
  504. controlling commands to the device, by the device's *ioctl()*
  505. call. The problem with CD-ROM drives, is that they can be used for
  506. two entirely different purposes. One is to mount removable
  507. file systems, CD-ROM's, the other is to play audio CD's. Audio commands
  508. are implemented entirely through *ioctl()\'s*, presumably because the
  509. first implementation (SUN?) has been such. In principle there is
  510. nothing wrong with this, but a good control of the `CD player` demands
  511. that the device can **always** be opened in order to give the
  512. *ioctl* commands, regardless of the state the drive is in.
  513. On the other hand, when used as a removable-media disc drive (what the
  514. original purpose of CD-ROM s is) we would like to make sure that the
  515. disc drive is ready for operation upon opening the device. In the old
  516. scheme, some CD-ROM drivers don't do any integrity checking, resulting
  517. in a number of i/o errors reported by the VFS to the kernel when an
  518. attempt for mounting a CD-ROM on an empty drive occurs. This is not a
  519. particularly elegant way to find out that there is no CD-ROM inserted;
  520. it more-or-less looks like the old IBM-PC trying to read an empty floppy
  521. drive for a couple of seconds, after which the system complains it
  522. can't read from it. Nowadays we can **sense** the existence of a
  523. removable medium in a drive, and we believe we should exploit that
  524. fact. An integrity check on opening of the device, that verifies the
  525. availability of a CD-ROM and its correct type (data), would be
  526. desirable.
  527. These two ways of using a CD-ROM drive, principally for data and
  528. secondarily for playing audio discs, have different demands for the
  529. behavior of the *open()* call. Audio use simply wants to open the
  530. device in order to get a file handle which is needed for issuing
  531. *ioctl* commands, while data use wants to open for correct and
  532. reliable data transfer. The only way user programs can indicate what
  533. their *purpose* of opening the device is, is through the *flags*
  534. parameter (see `open(2)`). For CD-ROM devices, these flags aren't
  535. implemented (some drivers implement checking for write-related flags,
  536. but this is not strictly necessary if the device file has correct
  537. permission flags). Most option flags simply don't make sense to
  538. CD-ROM devices: *O_CREAT*, *O_NOCTTY*, *O_TRUNC*, *O_APPEND*, and
  539. *O_SYNC* have no meaning to a CD-ROM.
  540. We therefore propose to use the flag *O_NONBLOCK* to indicate
  541. that the device is opened just for issuing *ioctl*
  542. commands. Strictly, the meaning of *O_NONBLOCK* is that opening and
  543. subsequent calls to the device don't cause the calling process to
  544. wait. We could interpret this as don't wait until someone has
  545. inserted some valid data-CD-ROM. Thus, our proposal of the
  546. implementation for the *open()* call for CD-ROM s is:
  547. - If no other flags are set than *O_RDONLY*, the device is opened
  548. for data transfer, and the return value will be 0 only upon successful
  549. initialization of the transfer. The call may even induce some actions
  550. on the CD-ROM, such as closing the tray.
  551. - If the option flag *O_NONBLOCK* is set, opening will always be
  552. successful, unless the whole device doesn't exist. The drive will take
  553. no actions whatsoever.
  554. And what about standards?
  555. -------------------------
  556. You might hesitate to accept this proposal as it comes from the
  557. Linux community, and not from some standardizing institute. What
  558. about SUN, SGI, HP and all those other Unix and hardware vendors?
  559. Well, these companies are in the lucky position that they generally
  560. control both the hardware and software of their supported products,
  561. and are large enough to set their own standard. They do not have to
  562. deal with a dozen or more different, competing hardware
  563. configurations\ [#f3]_.
  564. .. [#f3]
  565. Incidentally, I think that SUN's approach to mounting CD-ROM s is very
  566. good in origin: under Solaris a volume-daemon automatically mounts a
  567. newly inserted CD-ROM under `/cdrom/*<volume-name>*`.
  568. In my opinion they should have pushed this
  569. further and have **every** CD-ROM on the local area network be
  570. mounted at the similar location, i. e., no matter in which particular
  571. machine you insert a CD-ROM, it will always appear at the same
  572. position in the directory tree, on every system. When I wanted to
  573. implement such a user-program for Linux, I came across the
  574. differences in behavior of the various drivers, and the need for an
  575. *ioctl* informing about media changes.
  576. We believe that using *O_NONBLOCK* to indicate that a device is being opened
  577. for *ioctl* commands only can be easily introduced in the Linux
  578. community. All the CD-player authors will have to be informed, we can
  579. even send in our own patches to the programs. The use of *O_NONBLOCK*
  580. has most likely no influence on the behavior of the CD-players on
  581. other operating systems than Linux. Finally, a user can always revert
  582. to old behavior by a call to
  583. *ioctl(file_descriptor, CDROM_CLEAR_OPTIONS, CDO_USE_FFLAGS)*.
  584. The preferred strategy of *open()*
  585. ----------------------------------
  586. The routines in `cdrom.c` are designed in such a way that run-time
  587. configuration of the behavior of CD-ROM devices (of **any** type)
  588. can be carried out, by the *CDROM_SET/CLEAR_OPTIONS* *ioctls*. Thus, various
  589. modes of operation can be set:
  590. `CDO_AUTO_CLOSE | CDO_USE_FFLAGS | CDO_LOCK`
  591. This is the default setting. (With *CDO_CHECK_TYPE* it will be better, in
  592. the future.) If the device is not yet opened by any other process, and if
  593. the device is being opened for data (*O_NONBLOCK* is not set) and the
  594. tray is found to be open, an attempt to close the tray is made. Then,
  595. it is verified that a disc is in the drive and, if *CDO_CHECK_TYPE* is
  596. set, that it contains tracks of type `data mode 1`. Only if all tests
  597. are passed is the return value zero. The door is locked to prevent file
  598. system corruption. If the drive is opened for audio (*O_NONBLOCK* is
  599. set), no actions are taken and a value of 0 will be returned.
  600. `CDO_AUTO_CLOSE | CDO_AUTO_EJECT | CDO_LOCK`
  601. This mimics the behavior of the current sbpcd-driver. The option flags are
  602. ignored, the tray is closed on the first open, if necessary. Similarly,
  603. the tray is opened on the last release, i. e., if a CD-ROM is unmounted,
  604. it is automatically ejected, such that the user can replace it.
  605. We hope that these option can convince everybody (both driver
  606. maintainers and user program developers) to adopt the new CD-ROM
  607. driver scheme and option flag interpretation.
  608. Description of routines in `cdrom.c`
  609. ====================================
  610. Only a few routines in `cdrom.c` are exported to the drivers. In this
  611. new section we will discuss these, as well as the functions that `take
  612. over` the CD-ROM interface to the kernel. The header file belonging
  613. to `cdrom.c` is called `cdrom.h`. Formerly, some of the contents of this
  614. file were placed in the file `ucdrom.h`, but this file has now been
  615. merged back into `cdrom.h`.
  616. ::
  617. struct file_operations cdrom_fops
  618. The contents of this structure were described in cdrom_api_.
  619. A pointer to this structure is assigned to the *fops* field
  620. of the *struct gendisk*.
  621. ::
  622. int register_cdrom(struct cdrom_device_info *cdi)
  623. This function is used in about the same way one registers *cdrom_fops*
  624. with the kernel, the device operations and information structures,
  625. as described in cdrom_api_, should be registered with the
  626. Uniform CD-ROM Driver::
  627. register_cdrom(&<device>_info);
  628. This function returns zero upon success, and non-zero upon
  629. failure. The structure *<device>_info* should have a pointer to the
  630. driver's *<device>_dops*, as in::
  631. struct cdrom_device_info <device>_info = {
  632. <device>_dops;
  633. ...
  634. }
  635. Note that a driver must have one static structure, *<device>_dops*, while
  636. it may have as many structures *<device>_info* as there are minor devices
  637. active. *Register_cdrom()* builds a linked list from these.
  638. ::
  639. void unregister_cdrom(struct cdrom_device_info *cdi)
  640. Unregistering device *cdi* with minor number *MINOR(cdi->dev)* removes
  641. the minor device from the list. If it was the last registered minor for
  642. the low-level driver, this disconnects the registered device-operation
  643. routines from the CD-ROM interface. This function returns zero upon
  644. success, and non-zero upon failure.
  645. ::
  646. int cdrom_open(struct inode * ip, struct file * fp)
  647. This function is not called directly by the low-level drivers, it is
  648. listed in the standard *cdrom_fops*. If the VFS opens a file, this
  649. function becomes active. A strategy is implemented in this routine,
  650. taking care of all capabilities and options that are set in the
  651. *cdrom_device_ops* connected to the device. Then, the program flow is
  652. transferred to the device_dependent *open()* call.
  653. ::
  654. void cdrom_release(struct inode *ip, struct file *fp)
  655. This function implements the reverse-logic of *cdrom_open()*, and then
  656. calls the device-dependent *release()* routine. When the use-count has
  657. reached 0, the allocated buffers are flushed by calls to *sync_dev(dev)*
  658. and *invalidate_buffers(dev)*.
  659. .. _cdrom_ioctl:
  660. ::
  661. int cdrom_ioctl(struct inode *ip, struct file *fp,
  662. unsigned int cmd, unsigned long arg)
  663. This function handles all the standard *ioctl* requests for CD-ROM
  664. devices in a uniform way. The different calls fall into three
  665. categories: *ioctl()'s* that can be directly implemented by device
  666. operations, ones that are routed through the call *audio_ioctl()*, and
  667. the remaining ones, that are presumable device-dependent. Generally, a
  668. negative return value indicates an error.
  669. Directly implemented *ioctl()'s*
  670. --------------------------------
  671. The following `old` CD-ROM *ioctl()*\ 's are implemented by directly
  672. calling device-operations in *cdrom_device_ops*, if implemented and
  673. not masked:
  674. `CDROMMULTISESSION`
  675. Requests the last session on a CD-ROM.
  676. `CDROMEJECT`
  677. Open tray.
  678. `CDROMCLOSETRAY`
  679. Close tray.
  680. `CDROMEJECT_SW`
  681. If *arg\not=0*, set behavior to auto-close (close
  682. tray on first open) and auto-eject (eject on last release), otherwise
  683. set behavior to non-moving on *open()* and *release()* calls.
  684. `CDROM_GET_MCN`
  685. Get the Media Catalog Number from a CD.
  686. *Ioctl*s routed through *audio_ioctl()*
  687. ---------------------------------------
  688. The following set of *ioctl()'s* are all implemented through a call to
  689. the *cdrom_fops* function *audio_ioctl()*. Memory checks and
  690. allocation are performed in *cdrom_ioctl()*, and also sanitization of
  691. address format (*CDROM_LBA*/*CDROM_MSF*) is done.
  692. `CDROMSUBCHNL`
  693. Get sub-channel data in argument *arg* of type
  694. `struct cdrom_subchnl *`.
  695. `CDROMREADTOCHDR`
  696. Read Table of Contents header, in *arg* of type
  697. `struct cdrom_tochdr *`.
  698. `CDROMREADTOCENTRY`
  699. Read a Table of Contents entry in *arg* and specified by *arg*
  700. of type `struct cdrom_tocentry *`.
  701. `CDROMPLAYMSF`
  702. Play audio fragment specified in Minute, Second, Frame format,
  703. delimited by *arg* of type `struct cdrom_msf *`.
  704. `CDROMPLAYTRKIND`
  705. Play audio fragment in track-index format delimited by *arg*
  706. of type `struct cdrom_ti *`.
  707. `CDROMVOLCTRL`
  708. Set volume specified by *arg* of type `struct cdrom_volctrl *`.
  709. `CDROMVOLREAD`
  710. Read volume into by *arg* of type `struct cdrom_volctrl *`.
  711. `CDROMSTART`
  712. Spin up disc.
  713. `CDROMSTOP`
  714. Stop playback of audio fragment.
  715. `CDROMPAUSE`
  716. Pause playback of audio fragment.
  717. `CDROMRESUME`
  718. Resume playing.
  719. New *ioctl()'s* in `cdrom.c`
  720. ----------------------------
  721. The following *ioctl()'s* have been introduced to allow user programs to
  722. control the behavior of individual CD-ROM devices. New *ioctl*
  723. commands can be identified by the underscores in their names.
  724. `CDROM_SET_OPTIONS`
  725. Set options specified by *arg*. Returns the option flag register
  726. after modification. Use *arg = \rm0* for reading the current flags.
  727. `CDROM_CLEAR_OPTIONS`
  728. Clear options specified by *arg*. Returns the option flag register
  729. after modification.
  730. `CDROM_SELECT_SPEED`
  731. Select head-rate speed of disc specified as by *arg* in units
  732. of standard cdrom speed (176\,kB/sec raw data or
  733. 150kB/sec file system data). The value 0 means `auto-select`,
  734. i. e., play audio discs at real time and data discs at maximum speed.
  735. The value *arg* is checked against the maximum head rate of the
  736. drive found in the *cdrom_dops*.
  737. `CDROM_SELECT_DISC`
  738. Select disc numbered *arg* from a juke-box.
  739. First disc is numbered 0. The number *arg* is checked against the
  740. maximum number of discs in the juke-box found in the *cdrom_dops*.
  741. `CDROM_MEDIA_CHANGED`
  742. Returns 1 if a disc has been changed since the last call.
  743. For juke-boxes, an extra argument *arg*
  744. specifies the slot for which the information is given. The special
  745. value *CDSL_CURRENT* requests that information about the currently
  746. selected slot be returned.
  747. `CDROM_DRIVE_STATUS`
  748. Returns the status of the drive by a call to
  749. *drive_status()*. Return values are defined in cdrom_drive_status_.
  750. Note that this call doesn't return information on the
  751. current playing activity of the drive; this can be polled through
  752. an *ioctl* call to *CDROMSUBCHNL*. For juke-boxes, an extra argument
  753. *arg* specifies the slot for which (possibly limited) information is
  754. given. The special value *CDSL_CURRENT* requests that information
  755. about the currently selected slot be returned.
  756. `CDROM_DISC_STATUS`
  757. Returns the type of the disc currently in the drive.
  758. It should be viewed as a complement to *CDROM_DRIVE_STATUS*.
  759. This *ioctl* can provide *some* information about the current
  760. disc that is inserted in the drive. This functionality used to be
  761. implemented in the low level drivers, but is now carried out
  762. entirely in Uniform CD-ROM Driver.
  763. The history of development of the CD's use as a carrier medium for
  764. various digital information has lead to many different disc types.
  765. This *ioctl* is useful only in the case that CDs have \emph {only
  766. one} type of data on them. While this is often the case, it is
  767. also very common for CDs to have some tracks with data, and some
  768. tracks with audio. Because this is an existing interface, rather
  769. than fixing this interface by changing the assumptions it was made
  770. under, thereby breaking all user applications that use this
  771. function, the Uniform CD-ROM Driver implements this *ioctl* as
  772. follows: If the CD in question has audio tracks on it, and it has
  773. absolutely no CD-I, XA, or data tracks on it, it will be reported
  774. as *CDS_AUDIO*. If it has both audio and data tracks, it will
  775. return *CDS_MIXED*. If there are no audio tracks on the disc, and
  776. if the CD in question has any CD-I tracks on it, it will be
  777. reported as *CDS_XA_2_2*. Failing that, if the CD in question
  778. has any XA tracks on it, it will be reported as *CDS_XA_2_1*.
  779. Finally, if the CD in question has any data tracks on it,
  780. it will be reported as a data CD (*CDS_DATA_1*).
  781. This *ioctl* can return::
  782. CDS_NO_INFO /* no information available */
  783. CDS_NO_DISC /* no disc is inserted, or tray is opened */
  784. CDS_AUDIO /* Audio disc (2352 audio bytes/frame) */
  785. CDS_DATA_1 /* data disc, mode 1 (2048 user bytes/frame) */
  786. CDS_XA_2_1 /* mixed data (XA), mode 2, form 1 (2048 user bytes) */
  787. CDS_XA_2_2 /* mixed data (XA), mode 2, form 1 (2324 user bytes) */
  788. CDS_MIXED /* mixed audio/data disc */
  789. For some information concerning frame layout of the various disc
  790. types, see a recent version of `cdrom.h`.
  791. `CDROM_CHANGER_NSLOTS`
  792. Returns the number of slots in a juke-box.
  793. `CDROMRESET`
  794. Reset the drive.
  795. `CDROM_GET_CAPABILITY`
  796. Returns the *capability* flags for the drive. Refer to section
  797. cdrom_capabilities_ for more information on these flags.
  798. `CDROM_LOCKDOOR`
  799. Locks the door of the drive. `arg == 0` unlocks the door,
  800. any other value locks it.
  801. `CDROM_DEBUG`
  802. Turns on debugging info. Only root is allowed to do this.
  803. Same semantics as CDROM_LOCKDOOR.
  804. Device dependent *ioctl()'s*
  805. ----------------------------
  806. Finally, all other *ioctl()'s* are passed to the function *dev_ioctl()*,
  807. if implemented. No memory allocation or verification is carried out.
  808. How to update your driver
  809. =========================
  810. - Make a backup of your current driver.
  811. - Get hold of the files `cdrom.c` and `cdrom.h`, they should be in
  812. the directory tree that came with this documentation.
  813. - Make sure you include `cdrom.h`.
  814. - Change the 3rd argument of *register_blkdev* from `&<your-drive>_fops`
  815. to `&cdrom_fops`.
  816. - Just after that line, add the following to register with the Uniform
  817. CD-ROM Driver::
  818. register_cdrom(&<your-drive>_info);*
  819. Similarly, add a call to *unregister_cdrom()* at the appropriate place.
  820. - Copy an example of the device-operations *struct* to your
  821. source, e. g., from `cm206.c` *cm206_dops*, and change all
  822. entries to names corresponding to your driver, or names you just
  823. happen to like. If your driver doesn't support a certain function,
  824. make the entry *NULL*. At the entry *capability* you should list all
  825. capabilities your driver currently supports. If your driver
  826. has a capability that is not listed, please send me a message.
  827. - Copy the *cdrom_device_info* declaration from the same example
  828. driver, and modify the entries according to your needs. If your
  829. driver dynamically determines the capabilities of the hardware, this
  830. structure should also be declared dynamically.
  831. - Implement all functions in your `<device>_dops` structure,
  832. according to prototypes listed in `cdrom.h`, and specifications given
  833. in cdrom_api_. Most likely you have already implemented
  834. the code in a large part, and you will almost certainly need to adapt the
  835. prototype and return values.
  836. - Rename your `<device>_ioctl()` function to *audio_ioctl* and
  837. change the prototype a little. Remove entries listed in the first
  838. part in cdrom_ioctl_, if your code was OK, these are
  839. just calls to the routines you adapted in the previous step.
  840. - You may remove all remaining memory checking code in the
  841. *audio_ioctl()* function that deals with audio commands (these are
  842. listed in the second part of cdrom_ioctl_. There is no
  843. need for memory allocation either, so most *case*s in the *switch*
  844. statement look similar to::
  845. case CDROMREADTOCENTRY:
  846. get_toc_entry\bigl((struct cdrom_tocentry *) arg);
  847. - All remaining *ioctl* cases must be moved to a separate
  848. function, *<device>_ioctl*, the device-dependent *ioctl()'s*. Note that
  849. memory checking and allocation must be kept in this code!
  850. - Change the prototypes of *<device>_open()* and
  851. *<device>_release()*, and remove any strategic code (i. e., tray
  852. movement, door locking, etc.).
  853. - Try to recompile the drivers. We advise you to use modules, both
  854. for `cdrom.o` and your driver, as debugging is much easier this
  855. way.
  856. Thanks
  857. ======
  858. Thanks to all the people involved. First, Erik Andersen, who has
  859. taken over the torch in maintaining `cdrom.c` and integrating much
  860. CD-ROM-related code in the 2.1-kernel. Thanks to Scott Snyder and
  861. Gerd Knorr, who were the first to implement this interface for SCSI
  862. and IDE-CD drivers and added many ideas for extension of the data
  863. structures relative to kernel~2.0. Further thanks to Heiko Eißfeldt,
  864. Thomas Quinot, Jon Tombs, Ken Pizzini, Eberhard Mönkeberg and Andrew Kroll,
  865. the Linux CD-ROM device driver developers who were kind
  866. enough to give suggestions and criticisms during the writing. Finally
  867. of course, I want to thank Linus Torvalds for making this possible in
  868. the first place.