xref: /openbsd-src/share/man/man4/cd.4 (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
1.\"	$OpenBSD: cd.4,v 1.20 2007/06/01 22:30:48 deraadt Exp $
2.\"	$NetBSD: cd.4,v 1.3 1996/10/20 23:15:21 explorer Exp $
3.\"
4.\" Copyright (c) 1996
5.\"     Julian Elischer <julian@freebsd.org>.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\"
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.Dd $Mdocdate: June 1 2007 $
30.Dt CD 4
31.Os
32.Sh NAME
33.Nm cd
34.Nd ATAPI and SCSI CD-ROM driver
35.Sh SYNOPSIS
36.Cd "cd* at scsibus?"
37.Cd "#cd0 at scsibus0 target 6 lun 0" Pq fixed-configuration example
38.Sh DESCRIPTION
39The
40.Nm
41driver provides support for ATAPI and SCSI CD-ROM
42.Pq Compact Disc Read-Only Memory
43drives, via
44.Xr scsibus 4 .
45In an attempt to look like a regular disk, the
46.Nm
47driver synthesizes a partition table, with one partition covering the entire
48CD-ROM.
49It is possible to modify this partition table using
50.Xr disklabel 8 ,
51but it will only last until the CD-ROM is unmounted.
52In general the interfaces are similar to those described by
53.Xr wd 4
54and
55.Xr sd 4 .
56.Pp
57As the SCSI adapter is probed during boot, the SCSI bus is scanned for devices.
58Any devices found which answer as
59.Dq Read-only
60and
61.Dq removable
62CD-ROM or WORM devices will be
63.Dq attached
64to the
65.Nm
66driver.
67.Pp
68The system utility
69.Xr disklabel 8
70may be used to read the synthesized
71disk label
72structure, which will contain correct figures for the size of the
73CD-ROM should that information be required.
74.Sh IOCTLS
75The following
76.Xr ioctl 2
77calls which apply to CD-ROM drives are defined in the header files
78.Aq Pa sys/cdio.h
79and
80.Aq Pa sys/disklabel.h .
81.Bl -tag -width Ds
82.It Dv DIOCGDINFO , Dv DIOCSDINFO
83.Pq Li "struct disklabel"
84Read or write the in-core copy of the disklabel for the drive.
85The disklabel is initialized with information read from the SCSI inquiry
86commands, and should be the same as the information printed at boot.
87This structure is defined in
88.Xr disklabel 5 .
89.\".It Dv CDIOCCAPABILITY
90.\".Pq Li "struct ioc_capability"
91.\"Retrieve information from the drive on what features it supports.  The
92.\"information is returned in the following structure:
93.\".Bd -literal -offset indent
94.\"struct ioc_capability {
95.\"	u_long	play_function;
96.\"#define CDDOPLAYTRK	0x00000001
97.\"	/* Can play tracks/index */
98.\"#define	CDDOPLAYMSF	0x00000002
99.\"	/* Can play msf to msf */
100.\"#define	CDDOPLAYBLOCKS	0x00000004
101.\"	/* Can play range of blocks */
102.\"#define	CDDOPAUSE	0x00000100
103.\"	/* Output can be paused */
104.\"#define	CDDORESUME	0x00000200
105.\"	/* Output can be resumed */
106.\"#define	CDDORESET	0x00000400
107.\"	/* Drive can be completely reset */
108.\"#define	CDDOSTART	0x00000800
109.\"	/* Audio can be started */
110.\"#define CDDOSTOP	0x00001000
111.\"	/* Audio can be stopped */
112.\"#define CDDOPITCH	0x00002000
113.\"	/* Audio pitch can be changed */
114.\"
115.\"	u_long	routing_function;
116.\"#define CDREADVOLUME	0x00000001
117.\"	/* Volume settings can be read */
118.\"#define CDSETVOLUME	0x00000002
119.\"	/* Volume settings can be set */
120.\"#define	CDSETMONO	0x00000100
121.\"	/* Output can be set to mono */
122.\"#define CDSETSTEREO	0x00000200
123.\"	/* Output can be set to stereo (def) */
124.\"#define	CDSETLEFT	0x00000400
125.\"	/* Output can be set to left only */
126.\"#define	CDSETRIGHT	0x00000800
127.\"	/* Output can be set to right only */
128.\"#define	CDSETMUTE	0x00001000
129.\"	/* Output can be muted */
130.\"#define CDSETPATCH	0x00008000
131.\"	/* Direct routing control allowed */
132.\"
133.\"	u_long	special_function;
134.\"#define	CDDOEJECT	0x00000001
135.\"	/* The tray can be opened */
136.\"#define	CDDOCLOSE	0x00000002
137.\"	/* The tray can be closed */
138.\"#define	CDDOLOCK	0x00000004
139.\"	/* The tray can be locked */
140.\"#define CDREADHEADER	0x00000100
141.\"	/* Can read Table of Contents */
142.\"#define	CDREADENTRIES	0x00000200
143.\"	/* Can read TOC Entries */
144.\"#define	CDREADSUBQ	0x00000200
145.\"	/* Can read Subchannel info */
146.\"#define CDREADRW	0x00000400
147.\"	/* Can read subcodes R-W */
148.\"#define	CDHASDEBUG	0x00004000
149.\"	/* The tray has dynamic debugging */
150.\"};
151.\".Ed
152.It Dv CDIOCPLAYTRACKS
153.Pq Li "struct ioc_play_track"
154Start audio playback given a track address and length.
155The structure is defined as follows:
156.Bd -literal -offset indent
157struct ioc_play_track {
158	u_char	start_track;
159	u_char	start_index;
160	u_char	end_track;
161	u_char	end_index;
162};
163.Ed
164.It Dv CDIOCPLAYBLOCKS
165.Pq Li "struct ioc_play_blocks"
166Start audio playback given a block address and length.
167The structure is defined as follows:
168.Bd -literal -offset indent
169struct ioc_play_blocks {
170	int	blk;
171	int	len;
172};
173.Ed
174.It Dv CDIOCPLAYMSF
175.Pq Li "struct ioc_play_msf"
176Start audio playback given a
177.Dq minutes-seconds-frames
178address and length.
179The structure is defined as follows:
180.Bd -literal -offset indent
181struct ioc_play_msf {
182	u_char	start_m;
183	u_char	start_s;
184	u_char	start_f;
185	u_char	end_m;
186	u_char	end_s;
187	u_char	end_f;
188};
189.Ed
190.It Dv CDIOCREADSUBCHANNEL
191.Pq Li "struct ioc_read_subchannel"
192Read information from the subchannel at the location specified by this
193structure:
194.Bd -literal -offset indent
195struct ioc_read_subchannel {
196	u_char address_format;
197#define CD_LBA_FORMAT	1
198#define CD_MSF_FORMAT	2
199	u_char data_format;
200#define CD_SUBQ_DATA		0
201#define CD_CURRENT_POSITION	1
202#define CD_MEDIA_CATALOG	2
203#define CD_TRACK_INFO		3
204	u_char track;
205	int	data_len;
206	struct  cd_sub_channel_info *data;
207};
208.Ed
209.It Dv CDIOREADTOCHEADER
210.Pq Li "struct ioc_toc_header"
211Return summary information about the table of contents for the
212mounted CD-ROM.
213The information is returned into the following structure:
214.Bd -literal -offset indent
215struct ioc_toc_header {
216	u_short len;
217	u_char  starting_track;
218	u_char  ending_track;
219};
220.Ed
221.It Dv CDIOREADTOCENTRYS
222.Pq Li "struct ioc_read_toc_entry"
223Return information from the table of contents entries mentioned.
224(Yes, this command name is misspelled.)
225The argument structure is defined as follows:
226.Bd -literal -offset indent
227struct ioc_read_toc_entry {
228	u_char	address_format;
229	u_char	starting_track;
230	u_short	data_len;
231	struct  cd_toc_entry *data;
232};
233.Ed
234The requested data is written into an area of size
235.Li data_len
236and pointed to by
237.Li data .
238.It Dv CDIOCSETPATCH
239.Pq Li "struct ioc_patch"
240Attach various audio channels to various output channels.
241The argument structure is defined thusly:
242.Bd -literal -offset indent
243struct ioc_patch {
244	u_char	patch[4];
245	/* one for each channel */
246};
247.Ed
248.It Dv CDIOCGETVOL , Dv CDIOCSETVOL
249.Pq Li "struct ioc_vol"
250Get (set) information about the volume settings of the output channels.
251The argument structure is as follows:
252.Bd -literal -offset indent
253struct	ioc_vol {
254	u_char	vol[4];
255	/* one for each channel */
256};
257.Ed
258.It Dv CDIOCSETMONO
259Patch all output channels to all source channels.
260.It Dv CDIOCSETSTEREO
261Patch left source channel to the left output channel and the right
262source channel to the right output channel.
263.It Dv CDIOCSETMUTE
264Mute output without changing the volume settings.
265.It Dv CDIOCSETLEFT , Dv CDIOCSETRIGHT
266Attach both output channels to the left (right) source channel.
267.It Dv CDIOCSETDEBUG , Dv CDIOCCLRDEBUG
268Turn on (off) debugging for the appropriate device.
269.It Dv CDIOCPAUSE , Dv CDIOCRESUME
270Pause (resume) audio play, without resetting the location of the read-head.
271.It Dv CDIOCRESET
272Reset the drive.
273.It Dv CDIOCSTART , Dv CDIOCSTOP
274Tell the drive to spin-up (-down) the CD-ROM.
275.It Dv CDIOCALLOW , Dv CDIOCPREVENT
276Tell the drive to allow (prevent) manual ejection of the CD-ROM disc.
277Not all drives support this feature.
278.It Dv CDIOCEJECT
279Eject the CD-ROM.
280.\".It Dv CDIOCCLOSE
281.\"Tell the drive to close its door and load the media.  Not all drives
282.\"support this feature.
283.\"
284.\".It Dv CDIOCPITCH
285.\".Pq Li "struct ioc_pitch"
286.\"For drives that support it, this command instructs the drive to play
287.\"the audio at a faster or slower rate than normal.  Values of
288.\".Li speed
289.\"between -32767 and -1 result in slower playback; a zero value
290.\"indicates normal speed; and values from 1 to 32767 give faster
291.\"playback.  Drives with less than 16 bits of resolution will silently
292.\"ignore less-significant bits.  The structure is defined thusly:
293.\".Bd -literal -offset indent
294.\"struct	ioc_pitch {
295.\"	short	speed;
296.\"};
297.\".Ed
298.El
299.Pp
300In addition the general
301.Xr scsi 4
302ioctls may be used with the
303.Nm
304driver, if used against the `whole disk' partition (i.e.,
305.Pa /dev/rcd0c ) .
306.Sh NOTES
307When a CD-ROM is changed in a drive controlled by the
308.Nm
309driver, then the act of changing the media will invalidate the
310disklabel and information held within the kernel.
311To stop corruption, all accesses to the device will be discarded until
312there are no more open file descriptors referencing the device.
313During this period, all new open attempts will be rejected.
314When no more open file descriptors reference the device, the first next open
315will load a new set of parameters (including disklabel) for the drive.
316.Pp
317The audio code in the
318.Nm
319driver only supports SCSI-2 standard audio commands.
320Because many CD-ROM manufacturers have not followed the standard, there are
321many CD-ROM drives for which audio will not work.
322Some work is planned to support some of the more common
323.Dq broken
324CD-ROM drives; however, this is not yet under way.
325.Sh FILES
326.Bl -tag -width /dev/rcd[0-9][a-p] -compact
327.It Pa /dev/cd[0-9][a-p]
328block mode CD-ROM devices
329.It Pa /dev/rcd[0-9][a-p]
330raw mode CD-ROM devices
331.El
332.Sh DIAGNOSTICS
333None.
334.Sh SEE ALSO
335.Xr cdio 1 ,
336.Xr eject 1 ,
337.Xr ioctl 2 ,
338.Xr intro 4 ,
339.Xr scsi 4 ,
340.Xr scsibus 4 ,
341.Xr sd 4 ,
342.Xr wd 4 ,
343.Xr disklabel 5 ,
344.Xr disklabel 8
345.Sh HISTORY
346The
347.Nm
348driver appeared in 386BSD 0.1.
349.Sh BUGS
350The names of the structures used for the third argument to
351.Fn ioctl
352were poorly chosen, and a number of spelling errors have survived in
353the names of the
354.Fn ioctl
355commands.
356