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