]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - share/man/man4/cd.4
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / share / man / man4 / cd.4
1 .\" Copyright (c) 1996
2 .\"     Julian Elischer <julian@FreeBSD.org>.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\"
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd February 8, 2012
29 .Dt CD 4
30 .Os
31 .Sh NAME
32 .Nm cd
33 .Nd SCSI CD-ROM driver
34 .Sh SYNOPSIS
35 .Cd device cd
36 .Cd "options ""CHANGER_MIN_BUSY_SECONDS=3"""
37 .Cd "options ""CHANGER_MAX_BUSY_SECONDS=11""
38 .Sh DESCRIPTION
39 The
40 .Nm
41 driver provides support for a
42 .Tn SCSI
43 .Tn CD-ROM
44 (Compact Disc-Read Only Memory) drive.
45 In an attempt to look like a regular disk, the
46 .Nm
47 driver synthesizes a partition table, with one partition covering the entire
48 .Tn CD-ROM .
49 It is possible to modify this partition table using
50 .Xr disklabel 8 ,
51 but it will only last until the
52 .Tn CD-ROM
53 is unmounted.
54 In general the interfaces are similar to those described by
55 .Xr ada 4
56 and
57 .Xr da 4 .
58 .Pp
59 As the
60 .Tn SCSI
61 adapter is probed during boot, the
62 .Tn SCSI
63 bus is scanned for devices.
64 Any devices found which answer as CDROM
65 (type 5) or WORM (type 4) type devices will be `attached' to the
66 .Nm
67 driver.
68 Prior to
69 .Fx 2.1 ,
70 the first device found will be attached as
71 .Li cd0
72 the next,
73 .Li cd1 ,
74 etc.
75 Beginning in
76 .Fx 2.1
77 it is possible to specify what cd unit a device should
78 come on line as; refer to
79 .Xr scsi 4
80 for details on kernel configuration.
81 .Pp
82 The system utility
83 .Xr disklabel 8
84 may be used to read the synthesized
85 disk label
86 structure, which will contain correct figures for the size of the
87 .Tn CD-ROM
88 should that information be required.
89 .Sh KERNEL CONFIGURATION
90 Any number of
91 .Tn CD-ROM
92 devices may be attached to the system regardless of system
93 configuration as all resources are dynamically allocated.
94 .Sh IOCTLS
95 The following
96 .Xr ioctl 2
97 calls which apply to
98 .Tn SCSI
99 .Tn CD-ROM
100 drives are defined
101 in the header files
102 .In sys/cdio.h
103 and
104 .In sys/disklabel.h .
105 .Bl -tag -width CDIOCREADSUBCHANNEL
106 .It Dv DIOCGDINFO
107 .It Dv DIOCSDINFO
108 .Pq Li "struct disklabel"
109 Read or write the in-core copy of the disklabel for the
110 drive.
111 The disklabel is initialized with information
112 read from the scsi inquiry commands, and should be the same as
113 the information printed at boot.
114 This structure is defined in the header file
115 .In sys/disklabel.h .
116 .It Dv CDIOCCAPABILITY
117 .Pq Li "struct ioc_capability"
118 Retrieve information from the drive on what features it supports.
119 The information is returned in the following structure:
120 .Bd -literal -offset indent
121 struct ioc_capability {
122         u_long  play_function;
123 #define CDDOPLAYTRK     0x00000001
124         /* Can play tracks/index */
125 #define CDDOPLAYMSF     0x00000002
126         /* Can play msf to msf */
127 #define CDDOPLAYBLOCKS  0x00000004
128         /* Can play range of blocks */
129 #define CDDOPAUSE       0x00000100
130         /* Output can be paused */
131 #define CDDORESUME      0x00000200
132         /* Output can be resumed */
133 #define CDDORESET       0x00000400
134         /* Drive can be completely reset */
135 #define CDDOSTART       0x00000800
136         /* Audio can be started */
137 #define CDDOSTOP        0x00001000
138         /* Audio can be stopped */
139 #define CDDOPITCH       0x00002000
140         /* Audio pitch can be changed */
141
142         u_long  routing_function;
143 #define CDREADVOLUME    0x00000001
144         /* Volume settings can be read */
145 #define CDSETVOLUME     0x00000002
146         /* Volume settings can be set */
147 #define CDSETMONO       0x00000100
148         /* Output can be set to mono */
149 #define CDSETSTEREO     0x00000200
150         /* Output can be set to stereo (def) */
151 #define CDSETLEFT       0x00000400
152         /* Output can be set to left only */
153 #define CDSETRIGHT      0x00000800
154         /* Output can be set to right only */
155 #define CDSETMUTE       0x00001000
156         /* Output can be muted */
157 #define CDSETPATCH      0x00008000
158         /* Direct routing control allowed */
159
160         u_long  special_function;
161 #define CDDOEJECT       0x00000001
162         /* The tray can be opened */
163 #define CDDOCLOSE       0x00000002
164         /* The tray can be closed */
165 #define CDDOLOCK        0x00000004
166         /* The tray can be locked */
167 #define CDREADHEADER    0x00000100
168         /* Can read Table of Contents */
169 #define CDREADENTRIES   0x00000200
170         /* Can read TOC Entries */
171 #define CDREADSUBQ      0x00000200
172         /* Can read Subchannel info */
173 #define CDREADRW        0x00000400
174         /* Can read subcodes R-W */
175 #define CDHASDEBUG      0x00004000
176         /* The tray has dynamic debugging */
177 };
178 .Ed
179 .It Dv CDIOCPLAYTRACKS
180 .Pq Li "struct ioc_play_track"
181 Start audio playback given a track address and length.
182 The structure is defined as follows:
183 .Bd -literal -offset indent
184 struct ioc_play_track
185 {
186         u_char  start_track;
187         u_char  start_index;
188         u_char  end_track;
189         u_char  end_index;
190 };
191 .Ed
192 .It Dv CDIOCPLAYBLOCKS
193 .Pq Li "struct ioc_play_blocks"
194 Start audio playback given a block address and length.
195 The structure is defined as follows:
196 .Bd -literal -offset indent
197 struct ioc_play_blocks
198 {
199         int     blk;
200         int     len;
201 };
202 .Ed
203 .It Dv CDIOCPLAYMSF
204 .Pq Li "struct ioc_play_msf"
205 Start audio playback given a `minutes-seconds-frames' address and
206 length.
207 The structure is defined as follows:
208 .Bd -literal -offset indent
209 struct ioc_play_msf
210 {
211         u_char  start_m;
212         u_char  start_s;
213         u_char  start_f;
214         u_char  end_m;
215         u_char  end_s;
216         u_char  end_f;
217 };
218 .Ed
219 .It Dv CDIOCREADSUBCHANNEL
220 .Pq Li "struct ioc_read_subchannel"
221 Read information from the subchannel at the location specified by this
222 structure:
223 .Bd -literal -offset indent
224 struct ioc_read_subchannel {
225         u_char address_format;
226 #define CD_LBA_FORMAT   1
227 #define CD_MSF_FORMAT   2
228         u_char data_format;
229 #define CD_SUBQ_DATA            0
230 #define CD_CURRENT_POSITION     1
231 #define CD_MEDIA_CATALOG        2
232 #define CD_TRACK_INFO           3
233         u_char track;
234         int     data_len;
235         struct  cd_sub_channel_info *data;
236 };
237 .Ed
238 .It Dv CDIOREADTOCHEADER
239 .Pq Li "struct ioc_toc_header"
240 Return summary information about the table of contents for the mounted
241 .Tn CD-ROM .
242 The information is returned into the following structure:
243 .Bd -literal -offset indent
244 struct ioc_toc_header {
245         u_short len;
246         u_char  starting_track;
247         u_char  ending_track;
248 };
249 .Ed
250 .It Dv CDIOREADTOCENTRYS
251 .Pq Li "struct ioc_read_toc_entry"
252 Return information from the table of contents entries mentioned.
253 .Pq Yes, this command name is misspelled.
254 The argument structure is defined as follows:
255 .Bd -literal -offset indent
256 struct ioc_read_toc_entry {
257         u_char  address_format;
258         u_char  starting_track;
259         u_short data_len;
260         struct  cd_toc_entry *data;
261 };
262 .Ed
263 The requested data is written into an area of size
264 .Li data_len
265 and pointed to by
266 .Li data .
267 .It Dv CDIOCSETPATCH
268 .Pq Li "struct ioc_patch"
269 Attach various audio channels to various output channels.
270 The argument structure is defined thusly:
271 .Bd -literal -offset indent
272 struct ioc_patch {
273         u_char  patch[4];
274         /* one for each channel */
275 };
276 .Ed
277 .It Dv CDIOCGETVOL
278 .It Dv CDIOCSETVOL
279 .Pq Li "struct ioc_vol"
280 Get (set) information about the volume settings of the output channels.
281 The argument structure is as follows:
282 .Bd -literal -offset indent
283 struct  ioc_vol
284 {
285         u_char  vol[4];
286         /* one for each channel */
287 };
288 .Ed
289 .It Dv CDIOCSETMONO
290 Patch all output channels to all source channels.
291 .It Dv CDIOCSETSTEREO
292 Patch left source channel to the left output channel and the right
293 source channel to the right output channel.
294 .It Dv CDIOCSETMUTE
295 Mute output without changing the volume settings.
296 .It Dv CDIOCSETLEFT
297 .It Dv CDIOCSETRIGHT
298 Attach both output channels to the left (right) source channel.
299 .It Dv CDIOCSETDEBUG
300 .It Dv CDIOCCLRDEBUG
301 Turn on (off) debugging for the appropriate device.
302 .It Dv CDIOCPAUSE
303 .It Dv CDIOCRESUME
304 Pause (resume) audio play, without resetting the location of the read-head.
305 .It Dv CDIOCRESET
306 Reset the drive.
307 .It Dv CDIOCSTART
308 .It Dv CDIOCSTOP
309 Tell the drive to spin-up (-down) the
310 .Tn CD-ROM .
311 .It Dv CDIOCALLOW
312 .It Dv CDIOCPREVENT
313 Tell the drive to allow (prevent) manual ejection of the
314 .Tn CD-ROM
315 disc.
316 Not all drives support this feature.
317 .It Dv CDIOCEJECT
318 Eject the
319 .Tn CD-ROM .
320 .It Dv CDIOCCLOSE
321 Tell the drive to close its door and load the media.
322 Not all drives support this feature.
323 .It Dv CDIOCPITCH
324 .Pq Li "struct ioc_pitch"
325 For drives that support it, this command instructs the drive to play
326 the audio at a faster or slower rate than normal.
327 Values of
328 .Li speed
329 between -32767 and -1 result in slower playback; a zero value
330 indicates normal speed; and values from 1 to 32767 give faster
331 playback.
332 Drives with less than 16 bits of resolution will silently
333 ignore less-significant bits.
334 The structure is defined thusly:
335 .Bd -literal -offset indent
336 struct  ioc_pitch
337 {
338         short   speed;
339 };
340 .Ed
341 .El
342 .Sh NOTES
343 When a
344 .Tn CD-ROM
345 is changed in a drive controlled by the
346 .Nm
347 driver, then the act of changing the media will invalidate the
348 disklabel and information held within the kernel.
349 To stop corruption,
350 all accesses to the device will be discarded until there are no more
351 open file descriptors referencing the device.
352 During this period, all
353 new open attempts will be rejected.
354 When no more open file descriptors
355 reference the device, the first next open will load a new set of
356 parameters (including disklabel) for the drive.
357 .Pp
358 The audio code in the
359 .Nm
360 driver only support
361 .Tn SCSI-2
362 standard audio commands.
363 As many
364 .Tn CD-ROM
365 manufacturers have not followed the standard, there are many
366 .Tn CD-ROM
367 drives for which audio will not work.
368 Some work is planned to support
369 some of the more common `broken'
370 .Tn CD-ROM
371 drives; however, this is not yet under way.
372 .Sh CHANGER OPERATION
373 This driver has built-in support for LUN-based CD changers.
374 A LUN-based CD
375 changer is a drive that can hold two or more CDs, but only has one CD
376 player mechanism.
377 Each CD in the drive shows up as a separate logical unit
378 on the
379 .Tn SCSI
380 bus.
381 The
382 .Nm
383 driver automatically recognizes LUN-based changers, and routes commands for
384 changers through an internal scheduler.
385 The scheduler prevents changer
386 "thrashing", which is caused by sending commands to different LUNs in the
387 changer at the same time.
388 .Pp
389 The scheduler honors minimum and maximum time
390 quanta that the driver will spend on a particular LUN.
391 The minimum time
392 is the guaranteed minimum amount of time that the driver will spend on a
393 given LUN, even if there is no outstanding I/O for that LUN.
394 The maximum
395 time is the maximum amount of time the changer will spend on a LUN if there
396 is outstanding I/O for another LUN.
397 If there is no outstanding I/O for
398 another LUN, the driver will allow indefinite access to a given LUN.
399 .Pp
400 The minimum and maximum time quanta are configurable via kernel options and
401 also via sysctl and kernel tunable variables.
402 The kernel options are:
403 .Pp
404 .Bl -item -compact
405 .It
406 .Cd "options ""CHANGER_MIN_BUSY_SECONDS=3"""
407 .It
408 .Cd "options ""CHANGER_MAX_BUSY_SECONDS=11"""
409 .El
410 .Pp
411 The sysctl/kernel tunable variables are:
412 .Pp
413 .Bl -item -compact
414 .It
415 .Va kern.cam.cd.changer.min_busy_seconds
416 .It
417 .Va kern.cam.cd.changer.max_busy_seconds
418 .El
419 .Pp
420 It is suggested that the user try experimenting with the minimum and
421 maximum timeouts via the sysctl variables to arrive at the proper values
422 for your changer.
423 Once you have settled on the proper timeouts for your
424 changer, you can then put them in your kernel config file.
425 .Pp
426 If your system does have a LUN-based changer, you may notice that the
427 probe messages for the various LUNs of the changer will continue to appear
428 while the boot process is going on.
429 This is normal, and is caused by the
430 changer scheduling code.
431 .Sh SYSCTL VARIABLES
432 The following variables are available as both
433 .Xr sysctl 8
434 variables and
435 .Xr loader 8
436 tunables:
437 .Bl -tag -width 12
438 .It kern.cam.cd.retry_count
439 .Pp
440 This variable determines how many times the
441 .Nm
442 driver will retry a READ or WRITE command.
443 This does not affect the number of retries used during probe time or for
444 the
445 .Nm
446 driver dump routine.
447 This value currently defaults to 4.
448 .It kern.cam.cd.%d.minimum_cmd_size
449 .Pp
450 The
451 .Nm
452 driver attempts to automatically determine whether the drive it is talking
453 to supports 6 byte or 10 byte MODE SENSE/MODE SELECT operations.
454 Many
455 .Tn SCSI
456 drives only support 6 byte commands, and
457 .Tn ATAPI
458 drives only support 10 byte commands.
459 The
460 .Nm
461 driver first attempts to determine whether the protocol in use typically
462 supports 6 byte commands by issuing a CAM Path Inquiry CCB.
463 It will then default to 6 byte or 10 byte commands as appropriate.
464 After that, the
465 .Nm
466 driver defaults to using 6 byte commands (assuming the protocol the drive
467 speaks claims to support 6 byte commands), until one fails with a
468 .Tn SCSI
469 ILLEGAL REQUEST error.
470 Then it tries the 10 byte version of the command to
471 see if that works instead.
472 Users can change the default via per-drive
473 sysctl variables and loader tunables.
474 Where
475 .Dq %d
476 is the unit number of the drive in question.
477 Valid minimum command sizes
478 are 6 and 10.
479 Any value above 6 will be rounded to 10, and any value below
480 6 will be rounded to 6.
481 .It kern.cam.cd.changer.min_busy_seconds
482 .It kern.cam.cd.changer.max_busy_seconds
483 .Pp
484 Tune how long individual LUNs are 'locked' for I/O operations to
485 optimize changer operation.
486 See CHANGER OPERATION section for information on how to use these items.
487 .El
488 .Sh FILES
489 .Bl -tag -width /dev/cd[0-9][a-h] -compact
490 .It Pa /dev/cd[0-9][a-h]
491 raw mode
492 .Tn CD-ROM
493 devices
494 .El
495 .Sh DIAGNOSTICS
496 None.
497 .Sh SEE ALSO
498 .Xr cam 4 ,
499 .Xr da 4 ,
500 .Xr disklabel 8 ,
501 .Xr cd 9
502 .Sh HISTORY
503 This
504 .Nm
505 driver is based upon the
506 .Nm
507 driver written by Julian Elischer, which appeared in
508 .Bx 386 0.1 .
509 The
510 CAM version of the
511 .Nm
512 driver was written by Kenneth Merry and first appeared in
513 .Fx 3.0 .
514 .Sh BUGS
515 The names of the structures used for the third argument to
516 .Fn ioctl
517 were poorly chosen, and a number of spelling errors have survived in
518 the names of the
519 .Fn ioctl
520 commands.
521 .Pp
522 There is no mechanism currently to set different minimum and maximum
523 timeouts for different CD changers; the timeout values set by the kernel
524 options or the sysctl variables apply to all LUN-based CD changers in the
525 system.
526 It is possible to implement such support, but the sysctl
527 implementation at least would be rather inelegant, because of the current
528 inability of the sysctl code to handle the addition of nodes after compile
529 time.
530 Thus, it would take one dynamically sized sysctl variable and a
531 userland utility to get/set the timeout values.
532 Implementation of separate
533 timeouts for different CD devices in the kernel config file would likely
534 require modification of
535 .Xr config 8
536 to support the two timeouts when hardwiring
537 .Nm
538 devices.