| rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame] | 1 | 		Summary of CDROM ioctl calls. | 
 | 2 | 		============================ | 
 | 3 |  | 
 | 4 | 		Edward A. Falk <efalk@google.com> | 
 | 5 |  | 
 | 6 | 		November, 2004 | 
 | 7 |  | 
 | 8 | This document attempts to describe the ioctl(2) calls supported by | 
 | 9 | the CDROM layer.  These are by-and-large implemented (as of Linux 2.6) | 
 | 10 | in drivers/cdrom/cdrom.c and drivers/block/scsi_ioctl.c | 
 | 11 |  | 
 | 12 | ioctl values are listed in <linux/cdrom.h>.  As of this writing, they | 
 | 13 | are as follows: | 
 | 14 |  | 
 | 15 | 	CDROMPAUSE		Pause Audio Operation | 
 | 16 | 	CDROMRESUME		Resume paused Audio Operation | 
 | 17 | 	CDROMPLAYMSF		Play Audio MSF (struct cdrom_msf) | 
 | 18 | 	CDROMPLAYTRKIND		Play Audio Track/index (struct cdrom_ti) | 
 | 19 | 	CDROMREADTOCHDR		Read TOC header (struct cdrom_tochdr) | 
 | 20 | 	CDROMREADTOCENTRY	Read TOC entry (struct cdrom_tocentry) | 
 | 21 | 	CDROMSTOP		Stop the cdrom drive | 
 | 22 | 	CDROMSTART		Start the cdrom drive | 
 | 23 | 	CDROMEJECT		Ejects the cdrom media | 
 | 24 | 	CDROMVOLCTRL		Control output volume (struct cdrom_volctrl) | 
 | 25 | 	CDROMSUBCHNL		Read subchannel data (struct cdrom_subchnl) | 
 | 26 | 	CDROMREADMODE2		Read CDROM mode 2 data (2336 Bytes) | 
 | 27 | 					   (struct cdrom_read) | 
 | 28 | 	CDROMREADMODE1		Read CDROM mode 1 data (2048 Bytes) | 
 | 29 | 					   (struct cdrom_read) | 
 | 30 | 	CDROMREADAUDIO		(struct cdrom_read_audio) | 
 | 31 | 	CDROMEJECT_SW		enable(1)/disable(0) auto-ejecting | 
 | 32 | 	CDROMMULTISESSION	Obtain the start-of-last-session | 
 | 33 | 				  address of multi session disks | 
 | 34 | 				  (struct cdrom_multisession) | 
 | 35 | 	CDROM_GET_MCN		Obtain the "Universal Product Code" | 
 | 36 | 				   if available (struct cdrom_mcn) | 
 | 37 | 	CDROM_GET_UPC		Deprecated, use CDROM_GET_MCN instead. | 
 | 38 | 	CDROMRESET		hard-reset the drive | 
 | 39 | 	CDROMVOLREAD		Get the drive's volume setting | 
 | 40 | 					  (struct cdrom_volctrl) | 
 | 41 | 	CDROMREADRAW		read data in raw mode (2352 Bytes) | 
 | 42 | 					   (struct cdrom_read) | 
 | 43 | 	CDROMREADCOOKED		read data in cooked mode | 
 | 44 | 	CDROMSEEK		seek msf address | 
 | 45 | 	CDROMPLAYBLK		scsi-cd only, (struct cdrom_blk) | 
 | 46 | 	CDROMREADALL		read all 2646 bytes | 
 | 47 | 	CDROMGETSPINDOWN	return 4-bit spindown value | 
 | 48 | 	CDROMSETSPINDOWN	set 4-bit spindown value | 
 | 49 | 	CDROMCLOSETRAY		pendant of CDROMEJECT | 
 | 50 | 	CDROM_SET_OPTIONS	Set behavior options | 
 | 51 | 	CDROM_CLEAR_OPTIONS	Clear behavior options | 
 | 52 | 	CDROM_SELECT_SPEED	Set the CD-ROM speed | 
 | 53 | 	CDROM_SELECT_DISC	Select disc (for juke-boxes) | 
 | 54 | 	CDROM_MEDIA_CHANGED	Check is media changed | 
 | 55 | 	CDROM_DRIVE_STATUS	Get tray position, etc. | 
 | 56 | 	CDROM_DISC_STATUS	Get disc type, etc. | 
 | 57 | 	CDROM_CHANGER_NSLOTS	Get number of slots | 
 | 58 | 	CDROM_LOCKDOOR		lock or unlock door | 
 | 59 | 	CDROM_DEBUG		Turn debug messages on/off | 
 | 60 | 	CDROM_GET_CAPABILITY	get capabilities | 
 | 61 | 	CDROMAUDIOBUFSIZ	set the audio buffer size | 
 | 62 | 	DVD_READ_STRUCT		Read structure | 
 | 63 | 	DVD_WRITE_STRUCT	Write structure | 
 | 64 | 	DVD_AUTH		Authentication | 
 | 65 | 	CDROM_SEND_PACKET	send a packet to the drive | 
 | 66 | 	CDROM_NEXT_WRITABLE	get next writable block | 
 | 67 | 	CDROM_LAST_WRITTEN	get last block written on disc | 
 | 68 |  | 
 | 69 |  | 
 | 70 | The information that follows was determined from reading kernel source | 
 | 71 | code.  It is likely that some corrections will be made over time. | 
 | 72 |  | 
 | 73 |  | 
 | 74 |  | 
 | 75 |  | 
 | 76 |  | 
 | 77 |  | 
 | 78 |  | 
 | 79 | General: | 
 | 80 |  | 
 | 81 | 	Unless otherwise specified, all ioctl calls return 0 on success | 
 | 82 | 	and -1 with errno set to an appropriate value on error.  (Some | 
 | 83 | 	ioctls return non-negative data values.) | 
 | 84 |  | 
 | 85 | 	Unless otherwise specified, all ioctl calls return -1 and set | 
 | 86 | 	errno to EFAULT on a failed attempt to copy data to or from user | 
 | 87 | 	address space. | 
 | 88 |  | 
 | 89 | 	Individual drivers may return error codes not listed here. | 
 | 90 |  | 
 | 91 | 	Unless otherwise specified, all data structures and constants | 
 | 92 | 	are defined in <linux/cdrom.h> | 
 | 93 |  | 
 | 94 |  | 
 | 95 |  | 
 | 96 |  | 
 | 97 | CDROMPAUSE			Pause Audio Operation | 
 | 98 |  | 
 | 99 | 	usage: | 
 | 100 |  | 
 | 101 | 	  ioctl(fd, CDROMPAUSE, 0); | 
 | 102 |  | 
 | 103 | 	inputs:		none | 
 | 104 |  | 
 | 105 | 	outputs:	none | 
 | 106 |  | 
 | 107 | 	error return: | 
 | 108 | 	  ENOSYS	cd drive not audio-capable. | 
 | 109 |  | 
 | 110 |  | 
 | 111 | CDROMRESUME			Resume paused Audio Operation | 
 | 112 |  | 
 | 113 | 	usage: | 
 | 114 |  | 
 | 115 | 	  ioctl(fd, CDROMRESUME, 0); | 
 | 116 |  | 
 | 117 | 	inputs:		none | 
 | 118 |  | 
 | 119 | 	outputs:	none | 
 | 120 |  | 
 | 121 | 	error return: | 
 | 122 | 	  ENOSYS	cd drive not audio-capable. | 
 | 123 |  | 
 | 124 |  | 
 | 125 | CDROMPLAYMSF			Play Audio MSF (struct cdrom_msf) | 
 | 126 |  | 
 | 127 | 	usage: | 
 | 128 |  | 
 | 129 | 	  struct cdrom_msf msf; | 
 | 130 | 	  ioctl(fd, CDROMPLAYMSF, &msf); | 
 | 131 |  | 
 | 132 | 	inputs: | 
 | 133 | 	  cdrom_msf structure, describing a segment of music to play | 
 | 134 |  | 
 | 135 | 	outputs:	none | 
 | 136 |  | 
 | 137 | 	error return: | 
 | 138 | 	  ENOSYS	cd drive not audio-capable. | 
 | 139 |  | 
 | 140 | 	notes: | 
 | 141 | 	  MSF stands for minutes-seconds-frames | 
 | 142 | 	  LBA stands for logical block address | 
 | 143 |  | 
 | 144 | 	  Segment is described as start and end times, where each time | 
 | 145 | 	  is described as minutes:seconds:frames.  A frame is 1/75 of | 
 | 146 | 	  a second. | 
 | 147 |  | 
 | 148 |  | 
 | 149 | CDROMPLAYTRKIND			Play Audio Track/index (struct cdrom_ti) | 
 | 150 |  | 
 | 151 | 	usage: | 
 | 152 |  | 
 | 153 | 	  struct cdrom_ti ti; | 
 | 154 | 	  ioctl(fd, CDROMPLAYTRKIND, &ti); | 
 | 155 |  | 
 | 156 | 	inputs: | 
 | 157 | 	  cdrom_ti structure, describing a segment of music to play | 
 | 158 |  | 
 | 159 | 	outputs:	none | 
 | 160 |  | 
 | 161 | 	error return: | 
 | 162 | 	  ENOSYS	cd drive not audio-capable. | 
 | 163 |  | 
 | 164 | 	notes: | 
 | 165 | 	  Segment is described as start and end times, where each time | 
 | 166 | 	  is described as a track and an index. | 
 | 167 |  | 
 | 168 |  | 
 | 169 |  | 
 | 170 | CDROMREADTOCHDR			Read TOC header (struct cdrom_tochdr) | 
 | 171 |  | 
 | 172 | 	usage: | 
 | 173 |  | 
 | 174 | 	  cdrom_tochdr header; | 
 | 175 | 	  ioctl(fd, CDROMREADTOCHDR, &header); | 
 | 176 |  | 
 | 177 | 	inputs: | 
 | 178 | 	  cdrom_tochdr structure | 
 | 179 |  | 
 | 180 | 	outputs: | 
 | 181 | 	  cdrom_tochdr structure | 
 | 182 |  | 
 | 183 | 	error return: | 
 | 184 | 	  ENOSYS	cd drive not audio-capable. | 
 | 185 |  | 
 | 186 |  | 
 | 187 |  | 
 | 188 | CDROMREADTOCENTRY		Read TOC entry (struct cdrom_tocentry) | 
 | 189 |  | 
 | 190 | 	usage: | 
 | 191 |  | 
 | 192 | 	  struct cdrom_tocentry entry; | 
 | 193 | 	  ioctl(fd, CDROMREADTOCENTRY, &entry); | 
 | 194 |  | 
 | 195 | 	inputs: | 
 | 196 | 	  cdrom_tocentry structure | 
 | 197 |  | 
 | 198 | 	outputs: | 
 | 199 | 	  cdrom_tocentry structure | 
 | 200 |  | 
 | 201 | 	error return: | 
 | 202 | 	  ENOSYS	cd drive not audio-capable. | 
 | 203 | 	  EINVAL	entry.cdte_format not CDROM_MSF or CDROM_LBA | 
 | 204 | 	  EINVAL	requested track out of bounds | 
 | 205 | 	  EIO		I/O error reading TOC | 
 | 206 |  | 
 | 207 | 	notes: | 
 | 208 | 	  TOC stands for Table Of Contents | 
 | 209 | 	  MSF stands for minutes-seconds-frames | 
 | 210 | 	  LBA stands for logical block address | 
 | 211 |  | 
 | 212 |  | 
 | 213 |  | 
 | 214 | CDROMSTOP			Stop the cdrom drive | 
 | 215 |  | 
 | 216 | 	usage: | 
 | 217 |  | 
 | 218 | 	  ioctl(fd, CDROMSTOP, 0); | 
 | 219 |  | 
 | 220 | 	inputs:		none | 
 | 221 |  | 
 | 222 | 	outputs:	none | 
 | 223 |  | 
 | 224 | 	error return: | 
 | 225 | 	  ENOSYS	cd drive not audio-capable. | 
 | 226 |  | 
 | 227 | 	notes: | 
 | 228 | 	  Exact interpretation of this ioctl depends on the device, | 
 | 229 | 	  but most seem to spin the drive down. | 
 | 230 |  | 
 | 231 |  | 
 | 232 | CDROMSTART			Start the cdrom drive | 
 | 233 |  | 
 | 234 | 	usage: | 
 | 235 |  | 
 | 236 | 	  ioctl(fd, CDROMSTART, 0); | 
 | 237 |  | 
 | 238 | 	inputs:		none | 
 | 239 |  | 
 | 240 | 	outputs:	none | 
 | 241 |  | 
 | 242 | 	error return: | 
 | 243 | 	  ENOSYS	cd drive not audio-capable. | 
 | 244 |  | 
 | 245 | 	notes: | 
 | 246 | 	  Exact interpretation of this ioctl depends on the device, | 
 | 247 | 	  but most seem to spin the drive up and/or close the tray. | 
 | 248 | 	  Other devices ignore the ioctl completely. | 
 | 249 |  | 
 | 250 |  | 
 | 251 | CDROMEJECT			Ejects the cdrom media | 
 | 252 |  | 
 | 253 | 	usage: | 
 | 254 |  | 
 | 255 | 	  ioctl(fd, CDROMEJECT, 0); | 
 | 256 |  | 
 | 257 | 	inputs:		none | 
 | 258 |  | 
 | 259 | 	outputs:	none | 
 | 260 |  | 
 | 261 | 	error returns: | 
 | 262 | 	  ENOSYS	cd drive not capable of ejecting | 
 | 263 | 	  EBUSY		other processes are accessing drive, or door is locked | 
 | 264 |  | 
 | 265 | 	notes: | 
 | 266 | 	  See CDROM_LOCKDOOR, below. | 
 | 267 |  | 
 | 268 |  | 
 | 269 |  | 
 | 270 | CDROMCLOSETRAY			pendant of CDROMEJECT | 
 | 271 |  | 
 | 272 | 	usage: | 
 | 273 |  | 
 | 274 | 	  ioctl(fd, CDROMCLOSETRAY, 0); | 
 | 275 |  | 
 | 276 | 	inputs:		none | 
 | 277 |  | 
 | 278 | 	outputs:	none | 
 | 279 |  | 
 | 280 | 	error returns: | 
 | 281 | 	  ENOSYS	cd drive not capable of closing the tray | 
 | 282 | 	  EBUSY		other processes are accessing drive, or door is locked | 
 | 283 |  | 
 | 284 | 	notes: | 
 | 285 | 	  See CDROM_LOCKDOOR, below. | 
 | 286 |  | 
 | 287 |  | 
 | 288 |  | 
 | 289 | CDROMVOLCTRL			Control output volume (struct cdrom_volctrl) | 
 | 290 |  | 
 | 291 | 	usage: | 
 | 292 |  | 
 | 293 | 	  struct cdrom_volctrl volume; | 
 | 294 | 	  ioctl(fd, CDROMVOLCTRL, &volume); | 
 | 295 |  | 
 | 296 | 	inputs: | 
 | 297 | 	  cdrom_volctrl structure containing volumes for up to 4 | 
 | 298 | 	  channels. | 
 | 299 |  | 
 | 300 | 	outputs:	none | 
 | 301 |  | 
 | 302 | 	error return: | 
 | 303 | 	  ENOSYS	cd drive not audio-capable. | 
 | 304 |  | 
 | 305 |  | 
 | 306 |  | 
 | 307 | CDROMVOLREAD			Get the drive's volume setting | 
 | 308 | 					  (struct cdrom_volctrl) | 
 | 309 |  | 
 | 310 | 	usage: | 
 | 311 |  | 
 | 312 | 	  struct cdrom_volctrl volume; | 
 | 313 | 	  ioctl(fd, CDROMVOLREAD, &volume); | 
 | 314 |  | 
 | 315 | 	inputs:		none | 
 | 316 |  | 
 | 317 | 	outputs: | 
 | 318 | 	  The current volume settings. | 
 | 319 |  | 
 | 320 | 	error return: | 
 | 321 | 	  ENOSYS	cd drive not audio-capable. | 
 | 322 |  | 
 | 323 |  | 
 | 324 |  | 
 | 325 | CDROMSUBCHNL			Read subchannel data (struct cdrom_subchnl) | 
 | 326 |  | 
 | 327 | 	usage: | 
 | 328 |  | 
 | 329 | 	  struct cdrom_subchnl q; | 
 | 330 | 	  ioctl(fd, CDROMSUBCHNL, &q); | 
 | 331 |  | 
 | 332 | 	inputs: | 
 | 333 | 	  cdrom_subchnl structure | 
 | 334 |  | 
 | 335 | 	outputs: | 
 | 336 | 	  cdrom_subchnl structure | 
 | 337 |  | 
 | 338 | 	error return: | 
 | 339 | 	  ENOSYS	cd drive not audio-capable. | 
 | 340 | 	  EINVAL	format not CDROM_MSF or CDROM_LBA | 
 | 341 |  | 
 | 342 | 	notes: | 
 | 343 | 	  Format is converted to CDROM_MSF or CDROM_LBA | 
 | 344 | 	  as per user request on return | 
 | 345 |  | 
 | 346 |  | 
 | 347 |  | 
 | 348 | CDROMREADRAW			read data in raw mode (2352 Bytes) | 
 | 349 | 					   (struct cdrom_read) | 
 | 350 |  | 
 | 351 | 	usage: | 
 | 352 |  | 
 | 353 | 	  union { | 
 | 354 | 	    struct cdrom_msf msf;		/* input */ | 
 | 355 | 	    char buffer[CD_FRAMESIZE_RAW];	/* return */ | 
 | 356 | 	  } arg; | 
 | 357 | 	  ioctl(fd, CDROMREADRAW, &arg); | 
 | 358 |  | 
 | 359 | 	inputs: | 
 | 360 | 	  cdrom_msf structure indicating an address to read. | 
 | 361 | 	  Only the start values are significant. | 
 | 362 |  | 
 | 363 | 	outputs: | 
 | 364 | 	  Data written to address provided by user. | 
 | 365 |  | 
 | 366 | 	error return: | 
 | 367 | 	  EINVAL	address less than 0, or msf less than 0:2:0 | 
 | 368 | 	  ENOMEM	out of memory | 
 | 369 |  | 
 | 370 | 	notes: | 
 | 371 | 	  As of 2.6.8.1, comments in <linux/cdrom.h> indicate that this | 
 | 372 | 	  ioctl accepts a cdrom_read structure, but actual source code | 
 | 373 | 	  reads a cdrom_msf structure and writes a buffer of data to | 
 | 374 | 	  the same address. | 
 | 375 |  | 
 | 376 | 	  MSF values are converted to LBA values via this formula: | 
 | 377 |  | 
 | 378 | 	    lba = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; | 
 | 379 |  | 
 | 380 |  | 
 | 381 |  | 
 | 382 |  | 
 | 383 | CDROMREADMODE1			Read CDROM mode 1 data (2048 Bytes) | 
 | 384 | 					   (struct cdrom_read) | 
 | 385 |  | 
 | 386 | 	notes: | 
 | 387 | 	  Identical to CDROMREADRAW except that block size is | 
 | 388 | 	  CD_FRAMESIZE (2048) bytes | 
 | 389 |  | 
 | 390 |  | 
 | 391 |  | 
 | 392 | CDROMREADMODE2			Read CDROM mode 2 data (2336 Bytes) | 
 | 393 | 					   (struct cdrom_read) | 
 | 394 |  | 
 | 395 | 	notes: | 
 | 396 | 	  Identical to CDROMREADRAW except that block size is | 
 | 397 | 	  CD_FRAMESIZE_RAW0 (2336) bytes | 
 | 398 |  | 
 | 399 |  | 
 | 400 |  | 
 | 401 | CDROMREADAUDIO			(struct cdrom_read_audio) | 
 | 402 |  | 
 | 403 | 	usage: | 
 | 404 |  | 
 | 405 | 	  struct cdrom_read_audio ra; | 
 | 406 | 	  ioctl(fd, CDROMREADAUDIO, &ra); | 
 | 407 |  | 
 | 408 | 	inputs: | 
 | 409 | 	  cdrom_read_audio structure containing read start | 
 | 410 | 	  point and length | 
 | 411 |  | 
 | 412 | 	outputs: | 
 | 413 | 	  audio data, returned to buffer indicated by ra | 
 | 414 |  | 
 | 415 | 	error return: | 
 | 416 | 	  EINVAL	format not CDROM_MSF or CDROM_LBA | 
 | 417 | 	  EINVAL	nframes not in range [1 75] | 
 | 418 | 	  ENXIO		drive has no queue (probably means invalid fd) | 
 | 419 | 	  ENOMEM	out of memory | 
 | 420 |  | 
 | 421 |  | 
 | 422 | CDROMEJECT_SW			enable(1)/disable(0) auto-ejecting | 
 | 423 |  | 
 | 424 | 	usage: | 
 | 425 |  | 
 | 426 | 	  int val; | 
 | 427 | 	  ioctl(fd, CDROMEJECT_SW, val); | 
 | 428 |  | 
 | 429 | 	inputs: | 
 | 430 | 	  Flag specifying auto-eject flag. | 
 | 431 |  | 
 | 432 | 	outputs:	none | 
 | 433 |  | 
 | 434 | 	error return: | 
 | 435 | 	  ENOSYS	Drive is not capable of ejecting. | 
 | 436 | 	  EBUSY		Door is locked | 
 | 437 |  | 
 | 438 |  | 
 | 439 |  | 
 | 440 |  | 
 | 441 | CDROMMULTISESSION		Obtain the start-of-last-session | 
 | 442 | 				  address of multi session disks | 
 | 443 | 				  (struct cdrom_multisession) | 
 | 444 | 	usage: | 
 | 445 |  | 
 | 446 | 	  struct cdrom_multisession ms_info; | 
 | 447 | 	  ioctl(fd, CDROMMULTISESSION, &ms_info); | 
 | 448 |  | 
 | 449 | 	inputs: | 
 | 450 | 	  cdrom_multisession structure containing desired | 
 | 451 | 	  format. | 
 | 452 |  | 
 | 453 | 	outputs: | 
 | 454 | 	  cdrom_multisession structure is filled with last_session | 
 | 455 | 	  information. | 
 | 456 |  | 
 | 457 | 	error return: | 
 | 458 | 	  EINVAL	format not CDROM_MSF or CDROM_LBA | 
 | 459 |  | 
 | 460 |  | 
 | 461 | CDROM_GET_MCN			Obtain the "Universal Product Code" | 
 | 462 | 				   if available (struct cdrom_mcn) | 
 | 463 |  | 
 | 464 | 	usage: | 
 | 465 |  | 
 | 466 | 	  struct cdrom_mcn mcn; | 
 | 467 | 	  ioctl(fd, CDROM_GET_MCN, &mcn); | 
 | 468 |  | 
 | 469 | 	inputs:		none | 
 | 470 |  | 
 | 471 | 	outputs: | 
 | 472 | 	  Universal Product Code | 
 | 473 |  | 
 | 474 | 	error return: | 
 | 475 | 	  ENOSYS	Drive is not capable of reading MCN data. | 
 | 476 |  | 
 | 477 | 	notes: | 
 | 478 | 	  Source code comments state: | 
 | 479 |  | 
 | 480 | 	    The following function is implemented, although very few | 
 | 481 | 	    audio discs give Universal Product Code information, which | 
 | 482 | 	    should just be the Medium Catalog Number on the box.  Note, | 
 | 483 | 	    that the way the code is written on the CD is /not/ uniform | 
 | 484 | 	    across all discs! | 
 | 485 |  | 
 | 486 |  | 
 | 487 |  | 
 | 488 |  | 
 | 489 | CDROM_GET_UPC			CDROM_GET_MCN  (deprecated) | 
 | 490 |  | 
 | 491 | 	Not implemented, as of 2.6.8.1 | 
 | 492 |  | 
 | 493 |  | 
 | 494 |  | 
 | 495 | CDROMRESET			hard-reset the drive | 
 | 496 |  | 
 | 497 | 	usage: | 
 | 498 |  | 
 | 499 | 	  ioctl(fd, CDROMRESET, 0); | 
 | 500 |  | 
 | 501 | 	inputs:		none | 
 | 502 |  | 
 | 503 | 	outputs:	none | 
 | 504 |  | 
 | 505 | 	error return: | 
 | 506 | 	  EACCES	Access denied:  requires CAP_SYS_ADMIN | 
 | 507 | 	  ENOSYS	Drive is not capable of resetting. | 
 | 508 |  | 
 | 509 |  | 
 | 510 |  | 
 | 511 |  | 
 | 512 | CDROMREADCOOKED			read data in cooked mode | 
 | 513 |  | 
 | 514 | 	usage: | 
 | 515 |  | 
 | 516 | 	  u8 buffer[CD_FRAMESIZE] | 
 | 517 | 	  ioctl(fd, CDROMREADCOOKED, buffer); | 
 | 518 |  | 
 | 519 | 	inputs:		none | 
 | 520 |  | 
 | 521 | 	outputs: | 
 | 522 | 	  2048 bytes of data, "cooked" mode. | 
 | 523 |  | 
 | 524 | 	notes: | 
 | 525 | 	  Not implemented on all drives. | 
 | 526 |  | 
 | 527 |  | 
 | 528 |  | 
 | 529 |  | 
 | 530 | CDROMREADALL			read all 2646 bytes | 
 | 531 |  | 
 | 532 | 	Same as CDROMREADCOOKED, but reads 2646 bytes. | 
 | 533 |  | 
 | 534 |  | 
 | 535 |  | 
 | 536 | CDROMSEEK			seek msf address | 
 | 537 |  | 
 | 538 | 	usage: | 
 | 539 |  | 
 | 540 | 	  struct cdrom_msf msf; | 
 | 541 | 	  ioctl(fd, CDROMSEEK, &msf); | 
 | 542 |  | 
 | 543 | 	inputs: | 
 | 544 | 	  MSF address to seek to. | 
 | 545 |  | 
 | 546 | 	outputs:	none | 
 | 547 |  | 
 | 548 |  | 
 | 549 |  | 
 | 550 | CDROMPLAYBLK			scsi-cd only, (struct cdrom_blk) | 
 | 551 |  | 
 | 552 | 	usage: | 
 | 553 |  | 
 | 554 | 	  struct cdrom_blk blk; | 
 | 555 | 	  ioctl(fd, CDROMPLAYBLK, &blk); | 
 | 556 |  | 
 | 557 | 	inputs: | 
 | 558 | 	  Region to play | 
 | 559 |  | 
 | 560 | 	outputs:	none | 
 | 561 |  | 
 | 562 |  | 
 | 563 |  | 
 | 564 | CDROMGETSPINDOWN | 
 | 565 |  | 
 | 566 | 	usage: | 
 | 567 |  | 
 | 568 | 	  char spindown; | 
 | 569 | 	  ioctl(fd, CDROMGETSPINDOWN, &spindown); | 
 | 570 |  | 
 | 571 | 	inputs:		none | 
 | 572 |  | 
 | 573 | 	outputs: | 
 | 574 | 	  The value of the current 4-bit spindown value. | 
 | 575 |  | 
 | 576 |  | 
 | 577 |  | 
 | 578 |  | 
 | 579 | CDROMSETSPINDOWN | 
 | 580 |  | 
 | 581 | 	usage: | 
 | 582 |  | 
 | 583 | 	  char spindown | 
 | 584 | 	  ioctl(fd, CDROMSETSPINDOWN, &spindown); | 
 | 585 |  | 
 | 586 | 	inputs: | 
 | 587 | 	  4-bit value used to control spindown (TODO: more detail here) | 
 | 588 |  | 
 | 589 | 	outputs:	none | 
 | 590 |  | 
 | 591 |  | 
 | 592 |  | 
 | 593 |  | 
 | 594 |  | 
 | 595 | CDROM_SET_OPTIONS		Set behavior options | 
 | 596 |  | 
 | 597 | 	usage: | 
 | 598 |  | 
 | 599 | 	  int options; | 
 | 600 | 	  ioctl(fd, CDROM_SET_OPTIONS, options); | 
 | 601 |  | 
 | 602 | 	inputs: | 
 | 603 | 	  New values for drive options.  The logical 'or' of: | 
 | 604 | 	    CDO_AUTO_CLOSE	close tray on first open(2) | 
 | 605 | 	    CDO_AUTO_EJECT	open tray on last release | 
 | 606 | 	    CDO_USE_FFLAGS	use O_NONBLOCK information on open | 
 | 607 | 	    CDO_LOCK		lock tray on open files | 
 | 608 | 	    CDO_CHECK_TYPE	check type on open for data | 
 | 609 |  | 
 | 610 | 	outputs: | 
 | 611 | 	  Returns the resulting options settings in the | 
 | 612 | 	  ioctl return value.  Returns -1 on error. | 
 | 613 |  | 
 | 614 | 	error return: | 
 | 615 | 	  ENOSYS	selected option(s) not supported by drive. | 
 | 616 |  | 
 | 617 |  | 
 | 618 |  | 
 | 619 |  | 
 | 620 | CDROM_CLEAR_OPTIONS		Clear behavior options | 
 | 621 |  | 
 | 622 | 	Same as CDROM_SET_OPTIONS, except that selected options are | 
 | 623 | 	turned off. | 
 | 624 |  | 
 | 625 |  | 
 | 626 |  | 
 | 627 | CDROM_SELECT_SPEED		Set the CD-ROM speed | 
 | 628 |  | 
 | 629 | 	usage: | 
 | 630 |  | 
 | 631 | 	  int speed; | 
 | 632 | 	  ioctl(fd, CDROM_SELECT_SPEED, speed); | 
 | 633 |  | 
 | 634 | 	inputs: | 
 | 635 | 	  New drive speed. | 
 | 636 |  | 
 | 637 | 	outputs:	none | 
 | 638 |  | 
 | 639 | 	error return: | 
 | 640 | 	  ENOSYS	speed selection not supported by drive. | 
 | 641 |  | 
 | 642 |  | 
 | 643 |  | 
 | 644 | CDROM_SELECT_DISC		Select disc (for juke-boxes) | 
 | 645 |  | 
 | 646 | 	usage: | 
 | 647 |  | 
 | 648 | 	  int disk; | 
 | 649 | 	  ioctl(fd, CDROM_SELECT_DISC, disk); | 
 | 650 |  | 
 | 651 | 	inputs: | 
 | 652 | 	  Disk to load into drive. | 
 | 653 |  | 
 | 654 | 	outputs:	none | 
 | 655 |  | 
 | 656 | 	error return: | 
 | 657 | 	  EINVAL	Disk number beyond capacity of drive | 
 | 658 |  | 
 | 659 |  | 
 | 660 |  | 
 | 661 | CDROM_MEDIA_CHANGED		Check is media changed | 
 | 662 |  | 
 | 663 | 	usage: | 
 | 664 |  | 
 | 665 | 	  int slot; | 
 | 666 | 	  ioctl(fd, CDROM_MEDIA_CHANGED, slot); | 
 | 667 |  | 
 | 668 | 	inputs: | 
 | 669 | 	  Slot number to be tested, always zero except for jukeboxes. | 
 | 670 | 	  May also be special values CDSL_NONE or CDSL_CURRENT | 
 | 671 |  | 
 | 672 | 	outputs: | 
 | 673 | 	  Ioctl return value is 0 or 1 depending on whether the media | 
 | 674 | 	  has been changed, or -1 on error. | 
 | 675 |  | 
 | 676 | 	error returns: | 
 | 677 | 	  ENOSYS	Drive can't detect media change | 
 | 678 | 	  EINVAL	Slot number beyond capacity of drive | 
 | 679 | 	  ENOMEM	Out of memory | 
 | 680 |  | 
 | 681 |  | 
 | 682 |  | 
 | 683 | CDROM_DRIVE_STATUS		Get tray position, etc. | 
 | 684 |  | 
 | 685 | 	usage: | 
 | 686 |  | 
 | 687 | 	  int slot; | 
 | 688 | 	  ioctl(fd, CDROM_DRIVE_STATUS, slot); | 
 | 689 |  | 
 | 690 | 	inputs: | 
 | 691 | 	  Slot number to be tested, always zero except for jukeboxes. | 
 | 692 | 	  May also be special values CDSL_NONE or CDSL_CURRENT | 
 | 693 |  | 
 | 694 | 	outputs: | 
 | 695 | 	  Ioctl return value will be one of the following values | 
 | 696 | 	  from <linux/cdrom.h>: | 
 | 697 |  | 
 | 698 | 	    CDS_NO_INFO		Information not available. | 
 | 699 | 	    CDS_NO_DISC | 
 | 700 | 	    CDS_TRAY_OPEN | 
 | 701 | 	    CDS_DRIVE_NOT_READY | 
 | 702 | 	    CDS_DISC_OK | 
 | 703 | 	    -1			error | 
 | 704 |  | 
 | 705 | 	error returns: | 
 | 706 | 	  ENOSYS	Drive can't detect drive status | 
 | 707 | 	  EINVAL	Slot number beyond capacity of drive | 
 | 708 | 	  ENOMEM	Out of memory | 
 | 709 |  | 
 | 710 |  | 
 | 711 |  | 
 | 712 |  | 
 | 713 | CDROM_DISC_STATUS		Get disc type, etc. | 
 | 714 |  | 
 | 715 | 	usage: | 
 | 716 |  | 
 | 717 | 	  ioctl(fd, CDROM_DISC_STATUS, 0); | 
 | 718 |  | 
 | 719 | 	inputs:		none | 
 | 720 |  | 
 | 721 | 	outputs: | 
 | 722 | 	  Ioctl return value will be one of the following values | 
 | 723 | 	  from <linux/cdrom.h>: | 
 | 724 | 	    CDS_NO_INFO | 
 | 725 | 	    CDS_AUDIO | 
 | 726 | 	    CDS_MIXED | 
 | 727 | 	    CDS_XA_2_2 | 
 | 728 | 	    CDS_XA_2_1 | 
 | 729 | 	    CDS_DATA_1 | 
 | 730 |  | 
 | 731 | 	error returns:	none at present | 
 | 732 |  | 
 | 733 | 	notes: | 
 | 734 | 	  Source code comments state: | 
 | 735 |  | 
 | 736 | 	    Ok, this is where problems start.  The current interface for | 
 | 737 | 	    the CDROM_DISC_STATUS ioctl is flawed.  It makes the false | 
 | 738 | 	    assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. | 
 | 739 | 	    Unfortunately, while this is often the case, it is also | 
 | 740 | 	    very common for CDs to have some tracks with data, and some | 
 | 741 | 	    tracks with audio.	Just because I feel like it, I declare | 
 | 742 | 	    the following to be the best way to cope.  If the CD has | 
 | 743 | 	    ANY data tracks on it, it will be returned as a data CD. | 
 | 744 | 	    If it has any XA tracks, I will return it as that.	Now I | 
 | 745 | 	    could simplify this interface by combining these returns with | 
 | 746 | 	    the above, but this more clearly demonstrates the problem | 
 | 747 | 	    with the current interface.  Too bad this wasn't designed | 
 | 748 | 	    to use bitmasks...	       -Erik | 
 | 749 |  | 
 | 750 | 	    Well, now we have the option CDS_MIXED: a mixed-type CD. | 
 | 751 | 	    User level programmers might feel the ioctl is not very | 
 | 752 | 	    useful. | 
 | 753 | 			---david | 
 | 754 |  | 
 | 755 |  | 
 | 756 |  | 
 | 757 |  | 
 | 758 | CDROM_CHANGER_NSLOTS		Get number of slots | 
 | 759 |  | 
 | 760 | 	usage: | 
 | 761 |  | 
 | 762 | 	  ioctl(fd, CDROM_CHANGER_NSLOTS, 0); | 
 | 763 |  | 
 | 764 | 	inputs:		none | 
 | 765 |  | 
 | 766 | 	outputs: | 
 | 767 | 	  The ioctl return value will be the number of slots in a | 
 | 768 | 	  CD changer.  Typically 1 for non-multi-disk devices. | 
 | 769 |  | 
 | 770 | 	error returns:	none | 
 | 771 |  | 
 | 772 |  | 
 | 773 |  | 
 | 774 | CDROM_LOCKDOOR			lock or unlock door | 
 | 775 |  | 
 | 776 | 	usage: | 
 | 777 |  | 
 | 778 | 	  int lock; | 
 | 779 | 	  ioctl(fd, CDROM_LOCKDOOR, lock); | 
 | 780 |  | 
 | 781 | 	inputs: | 
 | 782 | 	  Door lock flag, 1=lock, 0=unlock | 
 | 783 |  | 
 | 784 | 	outputs:	none | 
 | 785 |  | 
 | 786 | 	error returns: | 
 | 787 | 	  EDRIVE_CANT_DO_THIS	Door lock function not supported. | 
 | 788 | 	  EBUSY			Attempt to unlock when multiple users | 
 | 789 | 	  			have the drive open and not CAP_SYS_ADMIN | 
 | 790 |  | 
 | 791 | 	notes: | 
 | 792 | 	  As of 2.6.8.1, the lock flag is a global lock, meaning that | 
 | 793 | 	  all CD drives will be locked or unlocked together.  This is | 
 | 794 | 	  probably a bug. | 
 | 795 |  | 
 | 796 | 	  The EDRIVE_CANT_DO_THIS value is defined in <linux/cdrom.h> | 
 | 797 | 	  and is currently (2.6.8.1) the same as EOPNOTSUPP | 
 | 798 |  | 
 | 799 |  | 
 | 800 |  | 
 | 801 | CDROM_DEBUG			Turn debug messages on/off | 
 | 802 |  | 
 | 803 | 	usage: | 
 | 804 |  | 
 | 805 | 	  int debug; | 
 | 806 | 	  ioctl(fd, CDROM_DEBUG, debug); | 
 | 807 |  | 
 | 808 | 	inputs: | 
 | 809 | 	  Cdrom debug flag, 0=disable, 1=enable | 
 | 810 |  | 
 | 811 | 	outputs: | 
 | 812 | 	  The ioctl return value will be the new debug flag. | 
 | 813 |  | 
 | 814 | 	error return: | 
 | 815 | 	  EACCES	Access denied:  requires CAP_SYS_ADMIN | 
 | 816 |  | 
 | 817 |  | 
 | 818 |  | 
 | 819 | CDROM_GET_CAPABILITY		get capabilities | 
 | 820 |  | 
 | 821 | 	usage: | 
 | 822 |  | 
 | 823 | 	  ioctl(fd, CDROM_GET_CAPABILITY, 0); | 
 | 824 |  | 
 | 825 | 	inputs:		none | 
 | 826 |  | 
 | 827 | 	outputs: | 
 | 828 | 	  The ioctl return value is the current device capability | 
 | 829 | 	  flags.  See CDC_CLOSE_TRAY, CDC_OPEN_TRAY, etc. | 
 | 830 |  | 
 | 831 |  | 
 | 832 |  | 
 | 833 | CDROMAUDIOBUFSIZ		set the audio buffer size | 
 | 834 |  | 
 | 835 | 	usage: | 
 | 836 |  | 
 | 837 | 	  int arg; | 
 | 838 | 	  ioctl(fd, CDROMAUDIOBUFSIZ, val); | 
 | 839 |  | 
 | 840 | 	inputs: | 
 | 841 | 	  New audio buffer size | 
 | 842 |  | 
 | 843 | 	outputs: | 
 | 844 | 	  The ioctl return value is the new audio buffer size, or -1 | 
 | 845 | 	  on error. | 
 | 846 |  | 
 | 847 | 	error return: | 
 | 848 | 	  ENOSYS	Not supported by this driver. | 
 | 849 |  | 
 | 850 | 	notes: | 
 | 851 | 	  Not supported by all drivers. | 
 | 852 |  | 
 | 853 |  | 
 | 854 |  | 
 | 855 | DVD_READ_STRUCT			Read structure | 
 | 856 |  | 
 | 857 | 	usage: | 
 | 858 |  | 
 | 859 | 	  dvd_struct s; | 
 | 860 | 	  ioctl(fd, DVD_READ_STRUCT, &s); | 
 | 861 |  | 
 | 862 | 	inputs: | 
 | 863 | 	  dvd_struct structure, containing: | 
 | 864 | 	    type		specifies the information desired, one of | 
 | 865 | 	    			DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT, | 
 | 866 | 				DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA, | 
 | 867 | 				DVD_STRUCT_MANUFACT | 
 | 868 | 	    physical.layer_num	desired layer, indexed from 0 | 
 | 869 | 	    copyright.layer_num	desired layer, indexed from 0 | 
 | 870 | 	    disckey.agid | 
 | 871 |  | 
 | 872 | 	outputs: | 
 | 873 | 	  dvd_struct structure, containing: | 
 | 874 | 	    physical		for type == DVD_STRUCT_PHYSICAL | 
 | 875 | 	    copyright		for type == DVD_STRUCT_COPYRIGHT | 
 | 876 | 	    disckey.value	for type == DVD_STRUCT_DISCKEY | 
 | 877 | 	    bca.{len,value}	for type == DVD_STRUCT_BCA | 
 | 878 | 	    manufact.{len,valu}	for type == DVD_STRUCT_MANUFACT | 
 | 879 |  | 
 | 880 | 	error returns: | 
 | 881 | 	  EINVAL	physical.layer_num exceeds number of layers | 
 | 882 | 	  EIO		Received invalid response from drive | 
 | 883 |  | 
 | 884 |  | 
 | 885 |  | 
 | 886 | DVD_WRITE_STRUCT		Write structure | 
 | 887 |  | 
 | 888 | 	Not implemented, as of 2.6.8.1 | 
 | 889 |  | 
 | 890 |  | 
 | 891 |  | 
 | 892 | DVD_AUTH			Authentication | 
 | 893 |  | 
 | 894 | 	usage: | 
 | 895 |  | 
 | 896 | 	  dvd_authinfo ai; | 
 | 897 | 	  ioctl(fd, DVD_AUTH, &ai); | 
 | 898 |  | 
 | 899 | 	inputs: | 
 | 900 | 	  dvd_authinfo structure.  See <linux/cdrom.h> | 
 | 901 |  | 
 | 902 | 	outputs: | 
 | 903 | 	  dvd_authinfo structure. | 
 | 904 |  | 
 | 905 | 	error return: | 
 | 906 | 	  ENOTTY	ai.type not recognized. | 
 | 907 |  | 
 | 908 |  | 
 | 909 |  | 
 | 910 | CDROM_SEND_PACKET		send a packet to the drive | 
 | 911 |  | 
 | 912 | 	usage: | 
 | 913 |  | 
 | 914 | 	  struct cdrom_generic_command cgc; | 
 | 915 | 	  ioctl(fd, CDROM_SEND_PACKET, &cgc); | 
 | 916 |  | 
 | 917 | 	inputs: | 
 | 918 | 	  cdrom_generic_command structure containing the packet to send. | 
 | 919 |  | 
 | 920 | 	outputs:	none | 
 | 921 | 	  cdrom_generic_command structure containing results. | 
 | 922 |  | 
 | 923 | 	error return: | 
 | 924 | 	  EIO		command failed. | 
 | 925 | 	  EPERM		Operation not permitted, either because a | 
 | 926 | 			write command was attempted on a drive which | 
 | 927 | 			is opened read-only, or because the command | 
 | 928 | 			requires CAP_SYS_RAWIO | 
 | 929 | 	  EINVAL	cgc.data_direction not set | 
 | 930 |  | 
 | 931 |  | 
 | 932 |  | 
 | 933 | CDROM_NEXT_WRITABLE		get next writable block | 
 | 934 |  | 
 | 935 | 	usage: | 
 | 936 |  | 
 | 937 | 	  long next; | 
 | 938 | 	  ioctl(fd, CDROM_NEXT_WRITABLE, &next); | 
 | 939 |  | 
 | 940 | 	inputs:		none | 
 | 941 |  | 
 | 942 | 	outputs: | 
 | 943 | 	  The next writable block. | 
 | 944 |  | 
 | 945 | 	notes: | 
 | 946 | 	  If the device does not support this ioctl directly, the | 
 | 947 | 	  ioctl will return CDROM_LAST_WRITTEN + 7. | 
 | 948 |  | 
 | 949 |  | 
 | 950 |  | 
 | 951 | CDROM_LAST_WRITTEN		get last block written on disc | 
 | 952 |  | 
 | 953 | 	usage: | 
 | 954 |  | 
 | 955 | 	  long last; | 
 | 956 | 	  ioctl(fd, CDROM_LAST_WRITTEN, &last); | 
 | 957 |  | 
 | 958 | 	inputs:		none | 
 | 959 |  | 
 | 960 | 	outputs: | 
 | 961 | 	  The last block written on disc | 
 | 962 |  | 
 | 963 | 	notes: | 
 | 964 | 	  If the device does not support this ioctl directly, the | 
 | 965 | 	  result is derived from the disc's table of contents.  If the | 
 | 966 | 	  table of contents can't be read, this ioctl returns an | 
 | 967 | 	  error. |