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