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