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