xref: /dragonfly/share/man/man4/cd.4 (revision f746689a)
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
41The
42.Nm
43driver provides support for a
44.Tn SCSI
45.Tn CD-ROM
46(Compact Disc-Read Only Memory) drive.
47In an attempt to look like a regular disk, the
48.Nm
49driver synthesizes a partition table, with one partition covering the entire
50.Tn CD-ROM .
51It is possible to modify this partition table using
52.Xr disklabel 8 ,
53but it will only last until the
54.Tn CD-ROM
55is unmounted.
56In general the interfaces are similar to those described by
57.Xr ad 4
58and
59.Xr da 4 .
60.Pp
61As the
62.Tn SCSI
63adapter is probed during boot, the
64.Tn SCSI
65bus is scanned for devices.
66Any devices found which answer as CDROM
67(type 5) or WORM (type 4) type devices will be `attached' to the
68.Nm
69driver.
70Prior to
71.Fx 2.1 ,
72the first device found will be attached as
73.Li cd0
74the next,
75.Li cd1 ,
76etc.
77Beginning in
78.Fx 2.1
79it is possible to specify what cd unit a device should
80come on line as; refer to
81.Xr scsi 4
82for details on kernel configuration.
83.Pp
84The
85.Cd target
86string is followed by the device's standard
87.Tn SCSI
88device ID number.
89The
90.Cd unit
91string is followed by the Logical Unit Number
92.Pq Tn LUN
93of the
94.Tn SCSI
95device's sub-device, if any, or zero.
96.Pp
97The system utility
98.Xr disklabel 8
99may be used to read the synthesized
100disk label
101structure, which will contain correct figures for the size of the
102.Tn CD-ROM
103should that information be required.
104.Sh KERNEL CONFIGURATION
105Any number of
106.Tn CD-ROM
107devices may be attached to the system regardless of system
108configuration as all resources are dynamically allocated.
109.Sh IOCTLS
110The following
111.Xr ioctl 2
112calls which apply to
113.Tn SCSI
114.Tn CD-ROM
115drives are defined
116in the header files
117.In sys/cdio.h
118and
119.In sys/disklabel.h .
120.Bl -tag -width ".Dv CDIOCREADSUBCHANNEL"
121.It Dv DIOCGDINFO
122.It Dv DIOCSDINFO
123.Pq Li "struct disklabel"
124Read or write the in-core copy of the disklabel for the
125drive.
126The disklabel is initialized with information
127read from the scsi inquiry commands, and should be the same as
128the information printed at boot.
129This structure is defined in
130.Xr disklabel 5 .
131.It Dv CDIOCCAPABILITY
132.Pq Li "struct ioc_capability"
133Retrieve information from the drive on what features it supports.
134The information is returned in the following structure:
135.Bd -literal -offset indent
136struct 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"
196Start audio playback given a track address and length.
197The structure is defined as follows:
198.Bd -literal -offset indent
199struct 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"
209Start audio playback given a block address and length.
210The structure is defined as follows:
211.Bd -literal -offset indent
212struct ioc_play_blocks
213{
214	int	blk;
215	int	len;
216};
217.Ed
218.It Dv CDIOCPLAYMSF
219.Pq Li "struct ioc_play_msf"
220Start audio playback given a `minutes-seconds-frames' address and
221length.
222The structure is defined as follows:
223.Bd -literal -offset indent
224struct 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"
236Read information from the subchannel at the location specified by this
237structure:
238.Bd -literal -offset indent
239struct 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"
255Return summary information about the table of contents for the mounted
256.Tn CD-ROM .
257The information is returned into the following structure:
258.Bd -literal -offset indent
259struct 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"
267Return information from the table of contents entries mentioned.
268.Pq Yes, this command name is misspelled.
269The argument structure is defined as follows:
270.Bd -literal -offset indent
271struct 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
278The requested data is written into an area of size
279.Li data_len
280and pointed to by
281.Li data .
282.It Dv CDIOCSETPATCH
283.Pq Li "struct ioc_patch"
284Attach various audio channels to various output channels.
285The argument structure is defined thusly:
286.Bd -literal -offset indent
287struct 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"
295Get (set) information about the volume settings of the output channels.
296The argument structure is as follows:
297.Bd -literal -offset indent
298struct	ioc_vol
299{
300	u_char	vol[4];
301	/* one for each channel */
302};
303.Ed
304.It Dv CDIOCSETMONO
305Patch all output channels to all source channels.
306.It Dv CDIOCSETSTEREO
307Patch left source channel to the left output channel and the right
308source channel to the right output channel.
309.It Dv CDIOCSETMUTE
310Mute output without changing the volume settings.
311.It Dv CDIOCSETLEFT
312.It Dv CDIOCSETRIGHT
313Attach both output channels to the left (right) source channel.
314.It Dv CDIOCSETDEBUG
315.It Dv CDIOCCLRDEBUG
316Turn on (off) debugging for the appropriate device.
317.It Dv CDIOCPAUSE
318.It Dv CDIOCRESUME
319Pause (resume) audio play, without resetting the location of the read-head.
320.It Dv CDIOCRESET
321Reset the drive.
322.It Dv CDIOCSTART
323.It Dv CDIOCSTOP
324Tell the drive to spin-up (-down) the
325.Tn CD-ROM .
326.It Dv CDIOCALLOW
327.It Dv CDIOCPREVENT
328Tell the drive to allow (prevent) manual ejection of the
329.Tn CD-ROM
330disc.  Not all drives support this feature.
331.It Dv CDIOCEJECT
332Eject the
333.Tn CD-ROM .
334.It Dv CDIOCCLOSE
335Tell the drive to close its door and load the media.
336Not all drives support this feature.
337.It Dv CDIOCPITCH
338.Pq Li "struct ioc_pitch"
339For drives that support it, this command instructs the drive to play
340the audio at a faster or slower rate than normal.
341Values of
342.Li speed
343between -32767 and -1 result in slower playback; a zero value
344indicates normal speed; and values from 1 to 32767 give faster
345playback.
346Drives with less than 16 bits of resolution will silently
347ignore less-significant bits.
348The structure is defined thusly:
349.Bd -literal -offset indent
350struct	ioc_pitch
351{
352	short	speed;
353};
354.Ed
355.El
356.Sh NOTES
357When a
358.Tn CD-ROM
359is changed in a drive controlled by the
360.Nm
361driver, then the act of changing the media will invalidate the
362disklabel and information held within the kernel.
363To stop corruption,
364all accesses to the device will be discarded until there are no more
365open file descriptors referencing the device.
366During this period, all
367new open attempts will be rejected.
368When no more open file descriptors
369reference the device, the first next open will load a new set of
370parameters (including disklabel) for the drive.
371.Pp
372The audio code in the
373.Nm
374driver only support
375.Tn SCSI-2
376standard audio commands.
377Because many
378.Tn CD-ROM
379manufacturers have not followed the standard, there are many
380.Tn CD-ROM
381drives for which audio will not work.
382Some work is planned to support
383some of the more common `broken'
384.Tn CD-ROM
385drives; however, this is not yet under way.
386.Sh CHANGER OPERATION
387This driver has built-in support for LUN-based CD changers.
388A LUN-based CD
389changer is a drive that can hold two or more CDs, but only has one CD
390player mechanism.
391Each CD in the drive shows up as a separate logical unit
392on the
393.Tn SCSI
394bus.  The
395.Nm
396driver automatically recognizes LUN-based changers, and routes commands for
397changers through an internal scheduler.
398The scheduler prevents changer
399"thrashing", which is caused by sending commands to different LUNs in the
400changer at the same time.
401.Pp
402The scheduler honors minimum and maximum time
403quanta that the driver will spend on a particular LUN.
404The minimum time
405is the guaranteed minimum amount of time that the driver will spend on a
406given LUN, even if there is no outstanding I/O for that LUN.
407The maximum
408time is the maximum amount of time the changer will spend on a LUN if there
409is outstanding I/O for another LUN.
410If there is no outstanding I/O for
411another LUN, the driver will allow indefinite access to a given LUN.
412.Pp
413The minimum and maximum time quanta are configurable via kernel options and
414also via sysctl variables.
415The 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
424The 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
433It is suggested that the user try experimenting with the minimum and
434maximum timeouts via the sysctl variables to arrive at the proper values
435for your changer.
436Once you have settled on the proper timeouts for your
437changer, you can then put them in your kernel config file.
438.Pp
439If your system does have a LUN-based changer, you may notice that the
440probe messages for the various LUNs of the changer will continue to appear
441while the boot process is going on.
442This is normal, and is caused by the
443changer 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]
447raw mode
448.Tn CD-ROM
449devices
450.El
451.Sh DIAGNOSTICS
452None.
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
460This
461.Nm
462driver is based upon the
463.Nm
464driver written by Julian Elischer, which appeared in
465.Bx 386 0.1 .
466The
467CAM version of the
468.Nm
469driver was written by Kenneth Merry and first appeared in
470.Fx 3.0 .
471.Sh BUGS
472The names of the structures used for the third argument to
473.Fn ioctl
474were poorly chosen, and a number of spelling errors have survived in
475the names of the
476.Fn ioctl
477commands.
478.Pp
479There is no mechanism currently to set different minimum and maximum
480timeouts for different CD changers; the timeout values set by the kernel
481options or the sysctl variables apply to all LUN-based CD changers in the
482system.
483It is possible to implement such support, but the sysctl
484implementation at least would be rather inelegant, because of the current
485inability of the sysctl code to handle the addition of nodes after compile
486time.
487Thus, it would take one dynamically sized sysctl variable and a
488userland utility to get/set the timeout values.
489Implementation of separate
490timeouts for different CD devices in the kernel config file would likely
491require modification of
492.Xr config 8
493to support the two timeouts when hardwiring
494.Nm
495devices.
496