xref: /openbsd-src/share/man/man4/cd.4 (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1.\"	$OpenBSD: cd.4,v 1.24 2014/07/02 22:35:42 matthew 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: July 2 2014 $
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.In sys/cdio.h
79and
80.In sys/dkio.h .
81.Bl -tag -width Ds
82.It Dv DIOCGDINFO , DIOCSDINFO Fa "struct disklabel *"
83Read or write the in-core copy of the disklabel for the drive.
84The disklabel is initialized with information read from the SCSI inquiry
85commands, and should be the same as the information printed at boot.
86This structure is defined in
87.Xr disklabel 5 .
88.\".It Dv CDIOCCAPABILITY
89.\".Pq Li "struct ioc_capability"
90.\"Retrieve information from the drive on what features it supports.  The
91.\"information is returned in the following structure:
92.\".Bd -literal -offset indent
93.\"struct ioc_capability {
94.\"	u_long	play_function;
95.\"#define CDDOPLAYTRK	0x00000001
96.\"	/* Can play tracks/index */
97.\"#define	CDDOPLAYMSF	0x00000002
98.\"	/* Can play msf to msf */
99.\"#define	CDDOPLAYBLOCKS	0x00000004
100.\"	/* Can play range of blocks */
101.\"#define	CDDOPAUSE	0x00000100
102.\"	/* Output can be paused */
103.\"#define	CDDORESUME	0x00000200
104.\"	/* Output can be resumed */
105.\"#define	CDDORESET	0x00000400
106.\"	/* Drive can be completely reset */
107.\"#define	CDDOSTART	0x00000800
108.\"	/* Audio can be started */
109.\"#define CDDOSTOP	0x00001000
110.\"	/* Audio can be stopped */
111.\"#define CDDOPITCH	0x00002000
112.\"	/* Audio pitch can be changed */
113.\"
114.\"	u_long	routing_function;
115.\"#define CDREADVOLUME	0x00000001
116.\"	/* Volume settings can be read */
117.\"#define CDSETVOLUME	0x00000002
118.\"	/* Volume settings can be set */
119.\"#define	CDSETMONO	0x00000100
120.\"	/* Output can be set to mono */
121.\"#define CDSETSTEREO	0x00000200
122.\"	/* Output can be set to stereo (def) */
123.\"#define	CDSETLEFT	0x00000400
124.\"	/* Output can be set to left only */
125.\"#define	CDSETRIGHT	0x00000800
126.\"	/* Output can be set to right only */
127.\"#define	CDSETMUTE	0x00001000
128.\"	/* Output can be muted */
129.\"#define CDSETPATCH	0x00008000
130.\"	/* Direct routing control allowed */
131.\"
132.\"	u_long	special_function;
133.\"#define	CDDOEJECT	0x00000001
134.\"	/* The tray can be opened */
135.\"#define	CDDOCLOSE	0x00000002
136.\"	/* The tray can be closed */
137.\"#define	CDDOLOCK	0x00000004
138.\"	/* The tray can be locked */
139.\"#define CDREADHEADER	0x00000100
140.\"	/* Can read Table of Contents */
141.\"#define	CDREADENTRIES	0x00000200
142.\"	/* Can read TOC Entries */
143.\"#define	CDREADSUBQ	0x00000200
144.\"	/* Can read Subchannel info */
145.\"#define CDREADRW	0x00000400
146.\"	/* Can read subcodes R-W */
147.\"#define	CDHASDEBUG	0x00004000
148.\"	/* The tray has dynamic debugging */
149.\"};
150.\".Ed
151.It Dv CDIOCPLAYTRACKS Fa "struct ioc_play_track *"
152Start audio playback given a track address and length.
153The structure is defined as follows:
154.Bd -literal -offset indent
155struct ioc_play_track {
156	u_char	start_track;
157	u_char	start_index;
158	u_char	end_track;
159	u_char	end_index;
160};
161.Ed
162.It Dv CDIOCPLAYBLOCKS Fa "struct ioc_play_blocks *"
163Start audio playback given a block address and length.
164The structure is defined as follows:
165.Bd -literal -offset indent
166struct ioc_play_blocks {
167	int	blk;
168	int	len;
169};
170.Ed
171.It Dv CDIOCPLAYMSF Fa "struct ioc_play_msf *"
172Start audio playback given a
173.Dq minutes-seconds-frames
174address and length.
175The structure is defined as follows:
176.Bd -literal -offset indent
177struct ioc_play_msf {
178	u_char	start_m;
179	u_char	start_s;
180	u_char	start_f;
181	u_char	end_m;
182	u_char	end_s;
183	u_char	end_f;
184};
185.Ed
186.It Dv CDIOCREADSUBCHANNEL Fa "struct ioc_read_subchannel *"
187Read information from the subchannel at the location specified by this
188structure:
189.Bd -literal -offset indent
190struct ioc_read_subchannel {
191	u_char address_format;
192#define CD_LBA_FORMAT	1
193#define CD_MSF_FORMAT	2
194	u_char data_format;
195#define CD_SUBQ_DATA		0
196#define CD_CURRENT_POSITION	1
197#define CD_MEDIA_CATALOG	2
198#define CD_TRACK_INFO		3
199	u_char track;
200	int	data_len;
201	struct  cd_sub_channel_info *data;
202};
203.Ed
204.It Dv CDIOREADTOCHEADER Fa "struct ioc_toc_header *"
205Return summary information about the table of contents for the
206mounted CD-ROM.
207The information is returned into the following structure:
208.Bd -literal -offset indent
209struct ioc_toc_header {
210	u_short len;
211	u_char  starting_track;
212	u_char  ending_track;
213};
214.Ed
215.It Dv CDIOREADTOCENTRYS Fa "struct ioc_read_toc_entry *"
216Return information from the table of contents entries mentioned.
217(Yes, this command name is misspelled.)
218The argument structure is defined as follows:
219.Bd -literal -offset indent
220struct ioc_read_toc_entry {
221	u_char	address_format;
222	u_char	starting_track;
223	u_short	data_len;
224	struct  cd_toc_entry *data;
225};
226.Ed
227.Pp
228The requested data is written into an area of size
229.Li data_len
230and pointed to by
231.Li data .
232.It Dv CDIOCSETPATCH Fa "struct ioc_patch *"
233Attach various audio channels to various output channels.
234The argument structure is defined thusly:
235.Bd -literal -offset indent
236struct ioc_patch {
237	u_char	patch[4];
238	/* one for each channel */
239};
240.Ed
241.It Dv CDIOCGETVOL , CDIOCSETVOL Fa "struct ioc_vol *"
242Get (set) information about the volume settings of the output channels.
243The argument structure is as follows:
244.Bd -literal -offset indent
245struct	ioc_vol {
246	u_char	vol[4];
247	/* one for each channel */
248};
249.Ed
250.It Dv CDIOCSETMONO
251Patch all output channels to all source channels.
252.It Dv CDIOCSETSTEREO
253Patch left source channel to the left output channel and the right
254source channel to the right output channel.
255.It Dv CDIOCSETMUTE
256Mute output without changing the volume settings.
257.It Dv CDIOCSETLEFT , CDIOCSETRIGHT
258Attach both output channels to the left (right) source channel.
259.It Dv CDIOCSETDEBUG , CDIOCCLRDEBUG
260Turn on (off) debugging for the appropriate device.
261.It Dv CDIOCPAUSE , CDIOCRESUME
262Pause (resume) audio play, without resetting the location of the read-head.
263.It Dv CDIOCRESET
264Reset the drive.
265.It Dv CDIOCSTART , CDIOCSTOP
266Tell the drive to spin-up (-down) the CD-ROM.
267.It Dv CDIOCALLOW , CDIOCPREVENT
268Tell the drive to allow (prevent) manual ejection of the CD-ROM disc.
269Not all drives support this feature.
270.It Dv CDIOCEJECT
271Eject the CD-ROM.
272.\".It Dv CDIOCCLOSE
273.\"Tell the drive to close its door and load the media.  Not all drives
274.\"support this feature.
275.\"
276.\".It Dv CDIOCPITCH
277.\".Pq Li "struct ioc_pitch"
278.\"For drives that support it, this command instructs the drive to play
279.\"the audio at a faster or slower rate than normal.  Values of
280.\".Li speed
281.\"between -32767 and -1 result in slower playback; a zero value
282.\"indicates normal speed; and values from 1 to 32767 give faster
283.\"playback.  Drives with less than 16 bits of resolution will silently
284.\"ignore less-significant bits.  The structure is defined thusly:
285.\".Bd -literal -offset indent
286.\"struct	ioc_pitch {
287.\"	short	speed;
288.\"};
289.\".Ed
290.El
291.Pp
292In addition the general
293.Xr scsi 4
294ioctls may be used with the
295.Nm
296driver, if used against the `whole disk' partition (i.e.,
297.Pa /dev/rcd0c ) .
298.Sh NOTES
299When a CD-ROM is changed in a drive controlled by the
300.Nm
301driver, then the act of changing the media will invalidate the
302disklabel and information held within the kernel.
303To stop corruption, all accesses to the device will be discarded until
304there are no more open file descriptors referencing the device.
305During this period, all new open attempts will be rejected.
306When no more open file descriptors reference the device, the first next open
307will load a new set of parameters (including disklabel) for the drive.
308.Pp
309The audio code in the
310.Nm
311driver only supports SCSI-2 standard audio commands.
312Because many CD-ROM manufacturers have not followed the standard, there are
313many CD-ROM drives for which audio will not work.
314Some work is planned to support some of the more common
315.Dq broken
316CD-ROM drives; however, this is not yet under way.
317.Sh FILES
318.Bl -tag -width /dev/rcd[0-9][a-p] -compact
319.It Pa /dev/cd[0-9][a-p]
320block mode CD-ROM devices
321.It Pa /dev/rcd[0-9][a-p]
322raw mode CD-ROM devices
323.El
324.Sh DIAGNOSTICS
325None.
326.Sh SEE ALSO
327.Xr cdio 1 ,
328.Xr eject 1 ,
329.Xr ioctl 2 ,
330.Xr intro 4 ,
331.Xr scsi 4 ,
332.Xr scsibus 4 ,
333.Xr sd 4 ,
334.Xr wd 4 ,
335.Xr disklabel 5 ,
336.Xr disklabel 8
337.Sh HISTORY
338The
339.Nm
340driver appeared in 386BSD 0.1.
341.Sh BUGS
342The names of the structures used for the third argument to
343.Fn ioctl
344were poorly chosen, and a number of spelling errors have survived in
345the names of the
346.Fn ioctl
347commands.
348