xref: /openbsd/share/man/man4/cd.4 (revision 09467b48)
1.\"	$OpenBSD: cd.4,v 1.25 2015/08/27 18:58:05 jmc 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: August 27 2015 $
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 CDIOREADTOCENTRIES Fa "struct ioc_read_toc_entry *"
216Return information from the table of contents entries mentioned.
217The argument structure is defined as follows:
218.Bd -literal -offset indent
219struct ioc_read_toc_entry {
220	u_char	address_format;
221	u_char	starting_track;
222	u_short	data_len;
223	struct  cd_toc_entry *data;
224};
225.Ed
226.Pp
227The requested data is written into an area of size
228.Li data_len
229and pointed to by
230.Li data .
231.It Dv CDIOCSETPATCH Fa "struct ioc_patch *"
232Attach various audio channels to various output channels.
233The argument structure is defined thusly:
234.Bd -literal -offset indent
235struct ioc_patch {
236	u_char	patch[4];
237	/* one for each channel */
238};
239.Ed
240.It Dv CDIOCGETVOL , CDIOCSETVOL Fa "struct ioc_vol *"
241Get (set) information about the volume settings of the output channels.
242The argument structure is as follows:
243.Bd -literal -offset indent
244struct	ioc_vol {
245	u_char	vol[4];
246	/* one for each channel */
247};
248.Ed
249.It Dv CDIOCSETMONO
250Patch all output channels to all source channels.
251.It Dv CDIOCSETSTEREO
252Patch left source channel to the left output channel and the right
253source channel to the right output channel.
254.It Dv CDIOCSETMUTE
255Mute output without changing the volume settings.
256.It Dv CDIOCSETLEFT , CDIOCSETRIGHT
257Attach both output channels to the left (right) source channel.
258.It Dv CDIOCSETDEBUG , CDIOCCLRDEBUG
259Turn on (off) debugging for the appropriate device.
260.It Dv CDIOCPAUSE , CDIOCRESUME
261Pause (resume) audio play, without resetting the location of the read-head.
262.It Dv CDIOCRESET
263Reset the drive.
264.It Dv CDIOCSTART , CDIOCSTOP
265Tell the drive to spin-up (-down) the CD-ROM.
266.It Dv CDIOCALLOW , CDIOCPREVENT
267Tell the drive to allow (prevent) manual ejection of the CD-ROM disc.
268Not all drives support this feature.
269.It Dv CDIOCEJECT
270Eject the CD-ROM.
271.\".It Dv CDIOCCLOSE
272.\"Tell the drive to close its door and load the media.  Not all drives
273.\"support this feature.
274.\"
275.\".It Dv CDIOCPITCH
276.\".Pq Li "struct ioc_pitch"
277.\"For drives that support it, this command instructs the drive to play
278.\"the audio at a faster or slower rate than normal.  Values of
279.\".Li speed
280.\"between -32767 and -1 result in slower playback; a zero value
281.\"indicates normal speed; and values from 1 to 32767 give faster
282.\"playback.  Drives with less than 16 bits of resolution will silently
283.\"ignore less-significant bits.  The structure is defined thusly:
284.\".Bd -literal -offset indent
285.\"struct	ioc_pitch {
286.\"	short	speed;
287.\"};
288.\".Ed
289.El
290.Pp
291In addition the general
292.Xr scsi 4
293ioctls may be used with the
294.Nm
295driver, if used against the `whole disk' partition (i.e.,
296.Pa /dev/rcd0c ) .
297.Sh NOTES
298When a CD-ROM is changed in a drive controlled by the
299.Nm
300driver, then the act of changing the media will invalidate the
301disklabel and information held within the kernel.
302To stop corruption, all accesses to the device will be discarded until
303there are no more open file descriptors referencing the device.
304During this period, all new open attempts will be rejected.
305When no more open file descriptors reference the device, the first next open
306will load a new set of parameters (including disklabel) for the drive.
307.Pp
308The audio code in the
309.Nm
310driver only supports SCSI-2 standard audio commands.
311Because many CD-ROM manufacturers have not followed the standard, there are
312many CD-ROM drives for which audio will not work.
313Some work is planned to support some of the more common
314.Dq broken
315CD-ROM drives; however, this is not yet under way.
316.Sh FILES
317.Bl -tag -width /dev/rcd[0-9][a-p] -compact
318.It Pa /dev/cd[0-9][a-p]
319block mode CD-ROM devices
320.It Pa /dev/rcd[0-9][a-p]
321raw mode CD-ROM devices
322.El
323.Sh DIAGNOSTICS
324None.
325.Sh SEE ALSO
326.Xr cdio 1 ,
327.Xr eject 1 ,
328.Xr ioctl 2 ,
329.Xr intro 4 ,
330.Xr scsi 4 ,
331.Xr scsibus 4 ,
332.Xr sd 4 ,
333.Xr wd 4 ,
334.Xr disklabel 5 ,
335.Xr disklabel 8
336.Sh HISTORY
337The
338.Nm
339driver appeared in 386BSD 0.1.
340.Sh BUGS
341The names of the structures used for the third argument to
342.Fn ioctl
343were poorly chosen, and a number of spelling errors have survived in
344the names of the
345.Fn ioctl
346commands.
347