mcdreg.h revision 1.7 1 /* $NetBSD: mcdreg.h,v 1.7 1995/07/10 01:27:27 cgd Exp $ */
2
3 /*
4 * Copyright 1993 by Holger Veit (data part)
5 * Copyright 1993 by Brian Moore (audio part)
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
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 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This software was developed by Holger Veit and Brian Moore
19 * for use with "386BSD" and similar operating systems.
20 * "Similar operating systems" includes mainly non-profit oriented
21 * systems for research and education, including but not restricted to
22 * "NetBSD", "FreeBSD", "Mach" (by CMU).
23 * 4. Neither the name of the developer(s) nor the name "386BSD"
24 * may be used to endorse or promote products derived from this
25 * software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
28 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
32 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
33 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
34 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 * This file contains definitions for some cdrom control commands
40 * and status codes. This info was "inherited" from the DOS MTMCDE.SYS
41 * driver, and is thus not complete (and may even be wrong). Some day
42 * the manufacturer or anyone else might provide better documentation,
43 * so this file (and the driver) will then have a better quality.
44 */
45
46 #if __GNUC__ >= 2
47 #pragma pack(1)
48 #endif
49
50 typedef unsigned char bcd_t;
51 #define M_msf(msf) msf[0]
52 #define S_msf(msf) msf[1]
53 #define F_msf(msf) msf[2]
54
55 #define MCD_COMMAND 0
56 #define MCD_STATUS 0
57 #define MCD_RDATA 0
58 #define MCD_RESET 1
59 #define MCD_XFER 1
60 #define MCD_CTL2 2 /* XXX Is this right? */
61 #define MCD_CONFIG 3
62
63 #define MCD_MASK_DMA 0x07 /* bits 2-0 = DMA channel */
64 #define MCD_MASK_IRQ 0x70 /* bits 6-4 = INT number */
65 /* 001 = int 2,9 */
66 /* 010 = int 3 */
67 /* 011 = int 5 */
68 /* 100 = int 10 */
69 /* 101 = int 11 */
70
71 /* Status bits */
72 #define MCD_ST_DOOROPEN 0x80
73 #define MCD_ST_DSKIN 0x40
74 #define MCD_ST_DSKCHNG 0x20
75 #define MCD_ST_SPINNING 0x10
76 #define MCD_ST_AUDIODISK 0x08 /* audio disk is in */
77 #define MCD_ST_READERR 0x04
78 #define MCD_ST_AUDIOBSY 0x02 /* audio disk is playing */
79 #define MCD_ST_CMDCHECK 0x01 /* command error */
80
81 /* Xfer bits */
82 #define MCD_XF_STATUSUNAVAIL 0x04
83 #define MCD_XF_DATAUNAVAIL 0x02
84
85 /* Modes */
86 #define MCD_MD_TESTMODE 0x80 /* 0 = DATALENGTH is valid */
87 #define MCD_MD_DATALENGTH 0x40 /* 1 = read ECC data also */
88 #define MCD_MD_ECCMODE 0x20 /* 1 = disable secondary ECC */
89 #define MCD_MD_SPINDOWN 0x08 /* 1 = spin down */
90 #define MCD_MD_READTOC 0x04 /* 1 = read TOC on GETQCHN */
91 #define MCD_MD_PLAYAUDIO 0x01 /* 1 = play audio through headphones */
92
93 #define MCD_MD_RAW (MCD_MD_PLAYAUDIO|MCD_MD_ECCMODE|MCD_MD_DATALENGTH)
94 #define MCD_MD_COOKED (MCD_MD_PLAYAUDIO)
95 #define MCD_MD_TOC (MCD_MD_PLAYAUDIO|MCD_MD_READTOC)
96 #define MCD_MD_SLEEP (MCD_MD_PLAYAUDIO|MCD_MD_SPINDOWN)
97
98 #define MCD_BLKSIZE_RAW sizeof(struct mcd_rawsector)
99 #define MCD_BLKSIZE_COOKED 2048
100
101 /* Lock states */
102 #define MCD_LK_UNLOCK 0x00
103 #define MCD_LK_LOCK 0x01
104 #define MCD_LK_TEST 0x02
105
106 /* Config commands */
107 #define MCD_CF_IRQENABLE 0x10
108 #define MCD_CF_DMATIMEOUT 0x08
109 #define MCD_CF_READUPC 0x04
110 #define MCD_CF_DMAENABLE 0x02
111 #define MCD_CF_BLOCKSIZE 0x01
112
113 /* UPC subcommands */
114 #define MCD_UPC_DISABLE 0x00
115 #define MCD_UPC_ENABLE 0x01
116
117 /* commands known by the controller */
118 #define MCD_CMDRESET 0x00
119 #define MCD_CMDGETVOLINFO 0x10 /* gets mcd_volinfo */
120 #define MCD_CMDGETDISKINFO 0x11 /* gets mcd_disk */
121 #define MCD_CMDGETQCHN 0x20 /* gets mcd_qchninfo */
122 #define MCD_CMDGETSENSE 0x30 /* gets sense info */
123 #define MCD_CMDGETSTAT 0x40 /* gets a byte of status */
124 #define MCD_CMDSETMODE 0x50 /* set transmission mode, needs byte */
125 #define MCD_CMDSTOPAUDIO 0x70
126 #define MCD_CMDSTOPAUDIOTIME 0x80
127 #define MCD_CMDGETVOLUME 0x8E /* gets mcd_volume */
128 #define MCD_CMDCONFIGDRIVE 0x90
129 #define MCD_CMDSETDRIVEMODE 0xa0 /* set drive mode */
130 #define MCD_CMDSETVOLUME 0xae /* sets mcd_volume */
131 #define MCD_CMDREAD1 0xb0 /* read n sectors */
132 #define MCD_CMDREADSINGLESPEED 0xc0 /* read (single speed) */
133 #define MCD_CMDREADDOUBLESPEED 0xc1 /* read (double speed) */
134 #define MCD_CMDGETDRIVEMODE 0xc2 /* get drive mode */
135 #define MCD_CMDREAD3 0xc3 /* ? */
136 #define MCD_CMDSETINTERLEAVE 0xc8 /* set interleave for read */
137 #define MCD_CMDCONTINFO 0xdc /* get controller info */
138 #define MCD_CMDSTOP 0xf0 /* stop everything */
139 #define MCD_CMDEJECTDISK 0xf6
140 #define MCD_CMDCLOSETRAY 0xf8
141 #define MCD_CMDSETLOCK 0xfe /* needs byte */
142
143 union mcd_qchninfo {
144 struct {
145 u_char control:4;
146 u_char addr_type:4;
147 u_char trk_no;
148 u_char idx_no;
149 bcd_t track_size[3];
150 u_char :8;
151 bcd_t absolute_pos[3];
152 } toc;
153 struct {
154 u_char control:4;
155 u_char addr_type:4;
156 u_char trk_no;
157 u_char idx_no;
158 bcd_t relative_pos[3];
159 u_char :8;
160 bcd_t absolute_pos[3];
161 } current;
162 struct {
163 u_char control:4;
164 u_char addr_type:4;
165 u_char upccode[7];
166 u_char junk[2];
167 } upc;
168 };
169
170 struct mcd_volinfo {
171 bcd_t trk_low;
172 bcd_t trk_high;
173 bcd_t vol_msf[3];
174 bcd_t trk1_msf[3];
175 };
176
177 struct mcd_result {
178 u_char length;
179 union {
180 struct {
181 u_char data[1];
182 } raw;
183 struct {
184 u_char code;
185 u_char version;
186 } continfo;
187 union mcd_qchninfo qchninfo;
188 struct mcd_volinfo volinfo;
189 } data;
190 };
191
192 struct mcd_command {
193 u_char opcode;
194 u_char length;
195 union {
196 struct {
197 u_char data[1];
198 } raw;
199 struct {
200 bcd_t start_msf[3];
201 bcd_t reserved[3];
202 } seek;
203 struct {
204 bcd_t start_msf[3];
205 bcd_t length[3];
206 } read;
207 struct {
208 bcd_t start_msf[3];
209 bcd_t end_msf[3];
210 } play;
211 struct {
212 u_char mode;
213 } datamode;
214 struct {
215 u_char time;
216 } hold;
217 struct {
218 u_char mode;
219 } drivemode;
220 struct {
221 u_char mode;
222 } lockmode;
223 struct {
224 u_char subcommand;
225 u_char data1, data2;
226 } config;
227 } data;
228 };
229
230 struct mcd_mbox {
231 struct mcd_command cmd;
232 struct mcd_result res;
233 };
234
235 struct mcd_volume {
236 u_char v0l;
237 u_char v0rs;
238 u_char v0r;
239 u_char v0ls;
240 };
241
242 struct mcd_rawsector {
243 u_char sync1[12];
244 u_char header[4];
245 u_char subheader1[4];
246 u_char subheader2[4];
247 u_char data[MCD_BLKSIZE_COOKED];
248 u_char ecc_bits[280];
249 };
250
251 #if __GNUC__ >= 2
252 #pragma pack(4)
253 #endif
254