xref: /openbsd-src/share/man/man4/cd.4 (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1.\"	$OpenBSD: cd.4,v 1.9 2001/06/22 12:15:44 mpech 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 January 16, 1996
30.Dt CD 4
31.Os
32.Sh NAME
33.Nm cd
34.Nd SCSI CD-ROM driver
35.Sh SYNOPSIS
36.Cd cd* at scsibus? target ? lun ?
37.Cd cd1 at scsibus0 target 4 lun 0
38.Sh DESCRIPTION
39The
40.Nm
41driver provides support for a SCSI CD-ROM (Compact Disc-Read Only Memory)
42drive.
43In an attempt to look like a regular disk, the
44.Nm
45driver synthesizes a partition table, with one partition covering the entire
46CD-ROM.
47It is possible to modify this partition table using
48.Xr disklabel 8 ,
49but it will only last until the CD-ROM is unmounted.
50In general the interfaces are similar to those described by
51.Xr wd 4
52and
53.Xr sd 4 .
54.Pp
55As the SCSI adapter is probed during boot, the SCSI bus is scanned for devices.
56Any devices found which answer as
57.Dq Read-only
58type devices will be
59.Dq attached
60to the
61.Nm
62driver.
63.Pp
64The system utility
65.Xr disklabel 8
66may be used to read the synthesized
67disk label
68structure, which will contain correct figures for the size of the
69CD-ROM should that information be required.
70.Sh KERNEL CONFIGURATION
71Any number of CD-ROM devices may be attached to the system regardless of system
72configuration as all resources are dynamically allocated.
73.Sh IOCTLS
74The following
75.Xr ioctl 2
76calls which apply to SCSI CD-ROM drives are defined in the header files
77.Aq Pa sys/cdio.h
78and
79.Aq Pa sys/disklabel.h .
80.Pp
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 CDIOSETVOL
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.It Dv FIBMAP
299Return the physical block number (in 512-byte sectors) given the
300logical block number.
301The argument is a pointer to an integer.
302On invocation, it should contain the logical block.
303On return, it contains the physical block number.
304.El
305.Pp
306In addition the general
307.Xr scsi 4
308ioctls may be used with the
309.Nm
310driver, if used against the `whole disk' partition (i.e.,
311.Pa /dev/rcd0c ) .
312.Sh NOTES
313When a CD-ROM is changed in a drive controlled by the
314.Nm
315driver, then the act of changing the media will invalidate the
316disklabel and information held within the kernel.
317To stop corruption, all accesses to the device will be discarded until
318there are no more open file descriptors referencing the device.
319During this period, all new open attempts will be rejected.
320When no more open file descriptors reference the device, the first next open
321will load a new set of parameters (including disklabel) for the drive.
322.Pp
323The audio code in the
324.Nm
325driver only supports SCSI-2 standard audio commands.
326Because many CD-ROM manufacturers have not followed the standard, there are
327many CD-ROM drives for which audio will not work.
328Some work is planned to support some of the more common
329.Dq broken
330CD-ROM drives; however, this is not yet under way.
331.Sh FILES
332.Bl -tag -width /dev/rcd[0-9][a-h] -compact
333.It Pa /dev/cd[0-9][a-h]
334block mode CD-ROM devices
335.It Pa /dev/rcd[0-9][a-h]
336raw mode CD-ROM devices
337.El
338.Sh DIAGNOSTICS
339None.
340.Sh SEE ALSO
341.Xr scsi 4 ,
342.Xr sd 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