1 |
1626 |
jcastillo |
/*
|
2 |
|
|
* sbpcd.c CD-ROM device driver for the whole family of traditional,
|
3 |
|
|
* non-ATAPI IDE-style Matsushita/Panasonic CR-5xx drives.
|
4 |
|
|
* Works with SoundBlaster compatible cards and with "no-sound"
|
5 |
|
|
* interface cards like Lasermate, Panasonic CI-101P, Teac, ...
|
6 |
|
|
* Also for the Longshine LCS-7260 drive.
|
7 |
|
|
* Also for the IBM "External ISA CD-Rom" drive.
|
8 |
|
|
* Also for the CreativeLabs CD200 drive.
|
9 |
|
|
* Also for the TEAC CD-55A drive.
|
10 |
|
|
* Also for the ECS-AT "Vertos 100" drive.
|
11 |
|
|
* Not for Sanyo drives (but for the H94A, sjcd is there...).
|
12 |
|
|
* Not for any other Funai drives than the CD200 types (sometimes
|
13 |
|
|
* labelled E2550UA or MK4015 or 2800F).
|
14 |
|
|
*/
|
15 |
|
|
|
16 |
|
|
#define VERSION "v4.6 Eberhard Moenkeberg <emoenke@gwdg.de>"
|
17 |
|
|
|
18 |
|
|
/* Copyright (C) 1993, 1994, 1995 Eberhard Moenkeberg <emoenke@gwdg.de>
|
19 |
|
|
*
|
20 |
|
|
* This program is free software; you can redistribute it and/or modify
|
21 |
|
|
* it under the terms of the GNU General Public License as published by
|
22 |
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
23 |
|
|
* any later version.
|
24 |
|
|
*
|
25 |
|
|
* You should have received a copy of the GNU General Public License
|
26 |
|
|
* (for example /usr/src/linux/COPYING); if not, write to the Free
|
27 |
|
|
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
28 |
|
|
*
|
29 |
|
|
* If you change this software, you should mail a .diff file with some
|
30 |
|
|
* description lines to emoenke@gwdg.de. I want to know about it.
|
31 |
|
|
*
|
32 |
|
|
* If you are the editor of a Linux CD, you should enable sbpcd.c within
|
33 |
|
|
* your boot floppy kernel and send me one of your CDs for free.
|
34 |
|
|
*
|
35 |
|
|
* If you would like to port the driver to an other operating system (f.e.
|
36 |
|
|
* FreeBSD or NetBSD) or use it as an information source, you shall not be
|
37 |
|
|
* restricted by the GPL under the following conditions:
|
38 |
|
|
* a) the source code of your work is freely available
|
39 |
|
|
* b) my part of the work gets mentioned at all places where your
|
40 |
|
|
* authorship gets mentioned
|
41 |
|
|
* c) I receive a copy of your code together with a full installation
|
42 |
|
|
* package of your operating system for free.
|
43 |
|
|
*
|
44 |
|
|
*
|
45 |
|
|
* VERSION HISTORY
|
46 |
|
|
*
|
47 |
|
|
* 0.1 initial release, April/May 93, after mcd.c (Martin Harriss)
|
48 |
|
|
*
|
49 |
|
|
* 0.2 the "repeat:"-loop in do_sbpcd_request did not check for
|
50 |
|
|
* end-of-request_queue (resulting in kernel panic).
|
51 |
|
|
* Flow control seems stable, but throughput is not better.
|
52 |
|
|
*
|
53 |
|
|
* 0.3 interrupt locking totally eliminated (maybe "inb" and "outb"
|
54 |
|
|
* are still locking) - 0.2 made keyboard-type-ahead losses.
|
55 |
|
|
* check_sbpcd_media_change added (to use by isofs/inode.c)
|
56 |
|
|
* - but it detects almost nothing.
|
57 |
|
|
*
|
58 |
|
|
* 0.4 use MAJOR 25 definitely.
|
59 |
|
|
* Almost total re-design to support double-speed drives and
|
60 |
|
|
* "naked" (no sound) interface cards ("LaserMate" interface type).
|
61 |
|
|
* Flow control should be exact now.
|
62 |
|
|
* Don't occupy the SbPro IRQ line (not needed either); will
|
63 |
|
|
* live together with Hannu Savolainen's sndkit now.
|
64 |
|
|
* Speeded up data transfer to 150 kB/sec, with help from Kai
|
65 |
|
|
* Makisara, the "provider" of the "mt" tape utility.
|
66 |
|
|
* Give "SpinUp" command if necessary.
|
67 |
|
|
* First steps to support up to 4 drives (but currently only one).
|
68 |
|
|
* Implemented audio capabilities - workman should work, xcdplayer
|
69 |
|
|
* gives some problems.
|
70 |
|
|
* This version is still consuming too much CPU time, and
|
71 |
|
|
* sleeping still has to be worked on.
|
72 |
|
|
* During "long" implied seeks, it seems possible that a
|
73 |
|
|
* ReadStatus command gets ignored. That gives the message
|
74 |
|
|
* "ResponseStatus timed out" (happens about 6 times here during
|
75 |
|
|
* a "ls -alR" of the YGGDRASIL LGX-Beta CD). Such a case is
|
76 |
|
|
* handled without data error, but it should get done better.
|
77 |
|
|
*
|
78 |
|
|
* 0.5 Free CPU during waits (again with help from Kai Makisara).
|
79 |
|
|
* Made it work together with the LILO/kernel setup standard.
|
80 |
|
|
* Included auto-probing code, as suggested by YGGDRASIL.
|
81 |
|
|
* Formal redesign to add DDI debugging.
|
82 |
|
|
* There are still flaws in IOCTL (workman with double speed drive).
|
83 |
|
|
*
|
84 |
|
|
* 1.0 Added support for all drive IDs (0...3, no longer only 0)
|
85 |
|
|
* and up to 4 drives on one controller.
|
86 |
|
|
* Added "#define MANY_SESSION" for "old" multi session CDs.
|
87 |
|
|
*
|
88 |
|
|
* 1.1 Do SpinUp for new drives, too.
|
89 |
|
|
* Revised for clean compile under "old" kernels (0.99pl9).
|
90 |
|
|
*
|
91 |
|
|
* 1.2 Found the "workman with double-speed drive" bug: use the driver's
|
92 |
|
|
* audio_state, not what the drive is reporting with ReadSubQ.
|
93 |
|
|
*
|
94 |
|
|
* 1.3 Minor cleanups.
|
95 |
|
|
* Refinements regarding Workman.
|
96 |
|
|
*
|
97 |
|
|
* 1.4 Read XA disks (PhotoCDs) with "old" drives, too (but only the first
|
98 |
|
|
* session - no chance to fully access a "multi-session" CD).
|
99 |
|
|
* This currently still is too slow (50 kB/sec) - but possibly
|
100 |
|
|
* the old drives won't do it faster.
|
101 |
|
|
* Implemented "door (un)lock" for new drives (still does not work
|
102 |
|
|
* as wanted - no lock possible after an unlock).
|
103 |
|
|
* Added some debugging printout for the UPC/EAN code - but my drives
|
104 |
|
|
* return only zeroes. Is there no UPC/EAN code written?
|
105 |
|
|
*
|
106 |
|
|
* 1.5 Laborate with UPC/EAN code (not better yet).
|
107 |
|
|
* Adapt to kernel 1.1.8 change (have to explicitly include
|
108 |
|
|
* <linux/string.h> now).
|
109 |
|
|
*
|
110 |
|
|
* 1.6 Trying to read audio frames as data. Impossible with the current
|
111 |
|
|
* drive firmware levels, as it seems. Awaiting any hint. ;-)
|
112 |
|
|
* Changed "door unlock": repeat it until success.
|
113 |
|
|
* Changed CDROMSTOP routine (stop somewhat "softer" so that Workman
|
114 |
|
|
* won't get confused).
|
115 |
|
|
* Added a third interface type: Sequoia S-1000, as used with the SPEA
|
116 |
|
|
* Media FX sound card. This interface (usable for Sony and Mitsumi
|
117 |
|
|
* drives, too) needs a special configuration setup and behaves like a
|
118 |
|
|
* LaserMate type after that. Still experimental - I do not have such
|
119 |
|
|
* an interface.
|
120 |
|
|
* Use the "variable BLOCK_SIZE" feature (2048). But it does only work
|
121 |
|
|
* if you give the mount option "block=2048".
|
122 |
|
|
* The media_check routine is currently disabled; now that it gets
|
123 |
|
|
* called as it should I fear it must get synchronized for not to
|
124 |
|
|
* disturb the normal driver's activity.
|
125 |
|
|
*
|
126 |
|
|
* 2.0 Version number bumped - two reasons:
|
127 |
|
|
* - reading audio tracks as data works now with CR-562 and CR-563. We
|
128 |
|
|
* currently do it by an IOCTL (yet has to get standardized), one frame
|
129 |
|
|
* at a time; that is pretty slow. But it works.
|
130 |
|
|
* - we are maintaining now up to 4 interfaces (each up to 4 drives):
|
131 |
|
|
* did it the easy way - a different MAJOR (25, 26, ...) and a different
|
132 |
|
|
* copy of the driver (sbpcd.c, sbpcd2.c, sbpcd3.c, sbpcd4.c - only
|
133 |
|
|
* distinguished by the value of SBPCD_ISSUE and the driver's name),
|
134 |
|
|
* and a common sbpcd.h file.
|
135 |
|
|
* Bettered the "ReadCapacity error" problem with old CR-52x drives (the
|
136 |
|
|
* drives sometimes need a manual "eject/insert" before work): just
|
137 |
|
|
* reset the drive and do again. Needs lots of resets here and sometimes
|
138 |
|
|
* that does not cure, so this can't be the solution.
|
139 |
|
|
*
|
140 |
|
|
* 2.1 Found bug with multisession CDs (accessing frame 16).
|
141 |
|
|
* "read audio" works now with address type CDROM_MSF, too.
|
142 |
|
|
* Bigger audio frame buffer: allows reading max. 4 frames at time; this
|
143 |
|
|
* gives a significant speedup, but reading more than one frame at once
|
144 |
|
|
* gives missing chunks at each single frame boundary.
|
145 |
|
|
*
|
146 |
|
|
* 2.2 Kernel interface cleanups: timers, init, setup, media check.
|
147 |
|
|
*
|
148 |
|
|
* 2.3 Let "door lock" and "eject" live together.
|
149 |
|
|
* Implemented "close tray" (done automatically during open).
|
150 |
|
|
*
|
151 |
|
|
* 2.4 Use different names for device registering.
|
152 |
|
|
*
|
153 |
|
|
* 2.5 Added "#if EJECT" code (default: enabled) to automatically eject
|
154 |
|
|
* the tray during last call to "sbpcd_release".
|
155 |
|
|
* Added "#if JUKEBOX" code (default: disabled) to automatically eject
|
156 |
|
|
* the tray during call to "sbpcd_open" if no disk is in.
|
157 |
|
|
* Turn on the CD volume of "compatible" sound cards, too; just define
|
158 |
|
|
* SOUND_BASE (in sbpcd.h) accordingly (default: disabled).
|
159 |
|
|
*
|
160 |
|
|
* 2.6 Nothing new.
|
161 |
|
|
*
|
162 |
|
|
* 2.7 Added CDROMEJECT_SW ioctl to set the "EJECT" behavior on the fly:
|
163 |
|
|
* 0 disables, 1 enables auto-ejecting. Useful to keep the tray in
|
164 |
|
|
* during shutdown.
|
165 |
|
|
*
|
166 |
|
|
* 2.8 Added first support (still BETA, I need feedback or a drive) for
|
167 |
|
|
* the Longshine LCS-7260 drives. They appear as double-speed drives
|
168 |
|
|
* using the "old" command scheme, extended by tray control and door
|
169 |
|
|
* lock functions.
|
170 |
|
|
* Found (and fixed preliminary) a flaw with some multisession CDs: we
|
171 |
|
|
* have to re-direct not only the accesses to frame 16 (the isofs
|
172 |
|
|
* routines drive it up to max. 100), but also those to the continuation
|
173 |
|
|
* (repetition) frames (as far as they exist - currently set fix as
|
174 |
|
|
* 16..20).
|
175 |
|
|
* Changed default of the "JUKEBOX" define. If you use this default,
|
176 |
|
|
* your tray will eject if you try to mount without a disk in. Next
|
177 |
|
|
* mount command will insert the tray - so, just fill in a disk. ;-)
|
178 |
|
|
*
|
179 |
|
|
* 2.9 Fulfilled the Longshine LCS-7260 support; with great help and
|
180 |
|
|
* experiments by Serge Robyns.
|
181 |
|
|
* First attempts to support the TEAC CD-55A drives; but still not
|
182 |
|
|
* usable yet.
|
183 |
|
|
* Implemented the CDROMMULTISESSION ioctl; this is an attempt to handle
|
184 |
|
|
* multi session CDs more "transparent" (redirection handling has to be
|
185 |
|
|
* done within the isofs routines, and only for the special purpose of
|
186 |
|
|
* obtaining the "right" volume descriptor; accesses to the raw device
|
187 |
|
|
* should not get redirected).
|
188 |
|
|
*
|
189 |
|
|
* 3.0 Just a "normal" increment, with some provisions to do it better. ;-)
|
190 |
|
|
* Introduced "#define READ_AUDIO" to specify the maximum number of
|
191 |
|
|
* audio frames to grab with one request. This defines a buffer size
|
192 |
|
|
* within kernel space; a value of 0 will reserve no such space and
|
193 |
|
|
* disable the CDROMREADAUDIO ioctl. A value of 75 enables the reading
|
194 |
|
|
* of a whole second with one command, but will use a buffer of more
|
195 |
|
|
* than 172 kB.
|
196 |
|
|
* Started CD200 support. Drive detection should work, but nothing
|
197 |
|
|
* more.
|
198 |
|
|
*
|
199 |
|
|
* 3.1 Working to support the CD200 and the Teac CD-55A drives.
|
200 |
|
|
* AT-BUS style device numbering no longer used: use SCSI style now.
|
201 |
|
|
* So, the first "found" device has MINOR 0, regardless of the
|
202 |
|
|
* jumpered drive ID. This implies modifications to the /dev/sbpcd*
|
203 |
|
|
* entries for some people, but will help the DAU (german TLA, english:
|
204 |
|
|
* "newbie", maybe ;-) to install his "first" system from a CD.
|
205 |
|
|
*
|
206 |
|
|
* 3.2 Still testing with CD200 and CD-55A drives.
|
207 |
|
|
*
|
208 |
|
|
* 3.3 Working with CD200 support.
|
209 |
|
|
*
|
210 |
|
|
* 3.4 Auto-probing stops if an address of 0 is seen (to be entered with
|
211 |
|
|
* the kernel command line).
|
212 |
|
|
* Made the driver "loadable". If used as a module, "audio copy" is
|
213 |
|
|
* disabled, and the internal read ahead data buffer has a reduced size
|
214 |
|
|
* of 4 kB; so, throughput may be reduced a little bit with slow CPUs.
|
215 |
|
|
*
|
216 |
|
|
* 3.5 Provisions to handle weird photoCDs which have an interrupted
|
217 |
|
|
* "formatting" immediately after the last frames of some files: simply
|
218 |
|
|
* never "read ahead" with MultiSession CDs. By this, CPU usage may be
|
219 |
|
|
* increased with those CDs, and there may be a loss in speed.
|
220 |
|
|
* Re-structured the messaging system.
|
221 |
|
|
* The "loadable" version no longer has a limited READ_AUDIO buffer
|
222 |
|
|
* size.
|
223 |
|
|
* Removed "MANY_SESSION" handling for "old" multi session CDs.
|
224 |
|
|
* Added "private" IOCTLs CDROMRESET and CDROMVOLREAD.
|
225 |
|
|
* Started again to support the TEAC CD-55A drives, now that I found
|
226 |
|
|
* the money for "my own" drive. ;-)
|
227 |
|
|
* The TEAC CD-55A support is fairly working now.
|
228 |
|
|
* I have measured that the drive "delivers" at 600 kB/sec (even with
|
229 |
|
|
* bigger requests than the drive's 64 kB buffer can satisfy), but
|
230 |
|
|
* the "real" rate does not exceed 520 kB/sec at the moment.
|
231 |
|
|
* Caused by the various changes to build in TEAC support, the timed
|
232 |
|
|
* loops are de-optimized at the moment (less throughput with CR-52x
|
233 |
|
|
* drives, and the TEAC will give speed only with SBP_BUFFER_FRAMES 64).
|
234 |
|
|
*
|
235 |
|
|
* 3.6 Fixed TEAC data read problems with SbPro interfaces.
|
236 |
|
|
* Initial size of the READ_AUDIO buffer is 0. Can get set to any size
|
237 |
|
|
* during runtime.
|
238 |
|
|
*
|
239 |
|
|
* 3.7 Introduced MAX_DRIVES for some poor interface cards (seen with TEAC
|
240 |
|
|
* drives) which allow only one drive (ID 0); this avoids repetitive
|
241 |
|
|
* detection under IDs 1..3.
|
242 |
|
|
* Elongated cmd_out_T response waiting; necessary for photo CDs with
|
243 |
|
|
* a lot of sessions.
|
244 |
|
|
* Bettered the sbpcd_open() behavior with TEAC drives.
|
245 |
|
|
*
|
246 |
|
|
* 3.8 Elongated max_latency for CR-56x drives.
|
247 |
|
|
*
|
248 |
|
|
* 3.9 Finally fixed the long-known SoundScape/SPEA/Sequoia S-1000 interface
|
249 |
|
|
* configuration bug.
|
250 |
|
|
* Now Corey, Heiko, Ken, Leo, Vadim/Eric & Werner are invited to copy
|
251 |
|
|
* the config_spea() routine into their drivers. ;-)
|
252 |
|
|
*
|
253 |
|
|
* 4.0 No "big step" - normal version increment.
|
254 |
|
|
* Adapted the benefits from 1.3.33.
|
255 |
|
|
* Fiddled with CDROMREADAUDIO flaws.
|
256 |
|
|
* Avoid ReadCapacity command with CD200 drives (the MKE 1.01 version
|
257 |
|
|
* seems not to support it).
|
258 |
|
|
* Fulfilled "read audio" for CD200 drives, with help of Pete Heist
|
259 |
|
|
* (heistp@rpi.edu).
|
260 |
|
|
*
|
261 |
|
|
* 4.1 Use loglevel KERN_INFO with printk().
|
262 |
|
|
* Added support for "Vertos 100" drive ("ECS-AT") - it is very similar
|
263 |
|
|
* to the Longshine LCS-7260. Give feedback if you can - I never saw
|
264 |
|
|
* such a drive, and I have no specs.
|
265 |
|
|
*
|
266 |
|
|
* 4.2 Support for Teac 16-bit interface cards. Can't get auto-detected,
|
267 |
|
|
* so you have to jumper your card to 0x2C0. Still not 100% - come
|
268 |
|
|
* in contact if you can give qualified feedback.
|
269 |
|
|
* Use loglevel KERN_NOTICE with printk(). If you get annoyed by a
|
270 |
|
|
* flood of unwanted messages and the accompanied delay, try to read
|
271 |
|
|
* my documentation. Especially the Linux CDROM drivers have to do an
|
272 |
|
|
* important job for the newcomers, so the "distributed" version has
|
273 |
|
|
* to fit some special needs. Since generations, the flood of messages
|
274 |
|
|
* is user-configurable (even at runtime), but to get aware of this, one
|
275 |
|
|
* needs a special mental quality: the ability to read.
|
276 |
|
|
*
|
277 |
|
|
* 4.3 CD200F does not like to receive a command while the drive is
|
278 |
|
|
* reading the ToC; still trying to solve it.
|
279 |
|
|
* Removed some redundant verify_area calls (yes, Heiko Eissfeldt
|
280 |
|
|
* is visiting all the Linux CDROM drivers ;-).
|
281 |
|
|
*
|
282 |
|
|
* 4.4 Adapted one idea from tiensivu@pilot.msu.edu's "stripping-down"
|
283 |
|
|
* experiments: "KLOGD_PAUSE".
|
284 |
|
|
* Inhibited "play audio" attempts with data CDs. Provisions for a
|
285 |
|
|
* "data-safe" handling of "mixed" (data plus audio) Cds.
|
286 |
|
|
*
|
287 |
|
|
* 4.5 Meanwhile Gonzalo Tornaria <tornaria@cmat.edu.uy> (GTL) built a
|
288 |
|
|
* special end_request routine: we seem to have to take care for not
|
289 |
|
|
* to have two processes working at the request list. My understanding
|
290 |
|
|
* was and is that ll_rw_blk should not call do_sbpcd_request as long
|
291 |
|
|
* as there is still one call active (the first call will care for all
|
292 |
|
|
* outstanding I/Os, and if a second call happens, that is a bug in
|
293 |
|
|
* ll_rw_blk.c).
|
294 |
|
|
* "Check media change" without touching any drive.
|
295 |
|
|
*
|
296 |
|
|
* 4.6 Use a semaphore to synchronize multi-activity; elaborated by Rob
|
297 |
|
|
* Riggs <rriggs@tesser.com>. At the moment, we simply block "read"
|
298 |
|
|
* against "ioctl" and vice versa. This could be refined further, but
|
299 |
|
|
* I guess with almost no performance increase.
|
300 |
|
|
* Experiments to speed up the CD-55A; again with help of Rob Riggs
|
301 |
|
|
* (to be true, he gave both, idea & code. ;-)
|
302 |
|
|
*
|
303 |
|
|
*
|
304 |
|
|
* TODO
|
305 |
|
|
* implement "read all subchannel data" (96 bytes per frame)
|
306 |
|
|
*
|
307 |
|
|
* special thanks to Kai Makisara (kai.makisara@vtt.fi) for his fine
|
308 |
|
|
* elaborated speed-up experiments (and the fabulous results!), for
|
309 |
|
|
* the "push" towards load-free wait loops, and for the extensive mail
|
310 |
|
|
* thread which brought additional hints and bug fixes.
|
311 |
|
|
*
|
312 |
|
|
*/
|
313 |
|
|
|
314 |
|
|
#ifndef SBPCD_ISSUE
|
315 |
|
|
#define SBPCD_ISSUE 1
|
316 |
|
|
#endif SBPCD_ISSUE
|
317 |
|
|
|
318 |
|
|
#include <linux/module.h>
|
319 |
|
|
|
320 |
|
|
#include <linux/errno.h>
|
321 |
|
|
#include <linux/sched.h>
|
322 |
|
|
#include <linux/mm.h>
|
323 |
|
|
#include <linux/timer.h>
|
324 |
|
|
#include <linux/fs.h>
|
325 |
|
|
#include <linux/kernel.h>
|
326 |
|
|
#include <linux/cdrom.h>
|
327 |
|
|
#include <linux/ioport.h>
|
328 |
|
|
#include <linux/major.h>
|
329 |
|
|
#include <linux/string.h>
|
330 |
|
|
#include <asm/system.h>
|
331 |
|
|
#include <asm/io.h>
|
332 |
|
|
#include <asm/segment.h>
|
333 |
|
|
#include <stdarg.h>
|
334 |
|
|
#include <linux/sbpcd.h>
|
335 |
|
|
#include <linux/config.h>
|
336 |
|
|
|
337 |
|
|
#if !(SBPCD_ISSUE-1)
|
338 |
|
|
#define MAJOR_NR MATSUSHITA_CDROM_MAJOR
|
339 |
|
|
#endif
|
340 |
|
|
#if !(SBPCD_ISSUE-2)
|
341 |
|
|
#define MAJOR_NR MATSUSHITA_CDROM2_MAJOR /* second driver issue */
|
342 |
|
|
#endif
|
343 |
|
|
#if !(SBPCD_ISSUE-3)
|
344 |
|
|
#define MAJOR_NR MATSUSHITA_CDROM3_MAJOR /* third driver issue */
|
345 |
|
|
#endif
|
346 |
|
|
#if !(SBPCD_ISSUE-4)
|
347 |
|
|
#define MAJOR_NR MATSUSHITA_CDROM4_MAJOR /* fourth driver issue */
|
348 |
|
|
#endif
|
349 |
|
|
|
350 |
|
|
#include <linux/blk.h>
|
351 |
|
|
|
352 |
|
|
/*==========================================================================*/
|
353 |
|
|
/*
|
354 |
|
|
* provisions for more than 1 driver issues
|
355 |
|
|
* currently up to 4 drivers, expandable
|
356 |
|
|
*/
|
357 |
|
|
#if !(SBPCD_ISSUE-1)
|
358 |
|
|
#define DO_SBPCD_REQUEST(a) do_sbpcd_request(a)
|
359 |
|
|
#define SBPCD_INIT(a) sbpcd_init(a)
|
360 |
|
|
#endif
|
361 |
|
|
#if !(SBPCD_ISSUE-2)
|
362 |
|
|
#define DO_SBPCD_REQUEST(a) do_sbpcd2_request(a)
|
363 |
|
|
#define SBPCD_INIT(a) sbpcd2_init(a)
|
364 |
|
|
#endif
|
365 |
|
|
#if !(SBPCD_ISSUE-3)
|
366 |
|
|
#define DO_SBPCD_REQUEST(a) do_sbpcd3_request(a)
|
367 |
|
|
#define SBPCD_INIT(a) sbpcd3_init(a)
|
368 |
|
|
#endif
|
369 |
|
|
#if !(SBPCD_ISSUE-4)
|
370 |
|
|
#define DO_SBPCD_REQUEST(a) do_sbpcd4_request(a)
|
371 |
|
|
#define SBPCD_INIT(a) sbpcd4_init(a)
|
372 |
|
|
#endif
|
373 |
|
|
/*==========================================================================*/
|
374 |
|
|
#if SBPCD_DIS_IRQ
|
375 |
|
|
#define SBPCD_CLI cli()
|
376 |
|
|
#define SBPCD_STI sti()
|
377 |
|
|
#else
|
378 |
|
|
#define SBPCD_CLI
|
379 |
|
|
#define SBPCD_STI
|
380 |
|
|
#endif SBPCD_DIS_IRQ
|
381 |
|
|
/*==========================================================================*/
|
382 |
|
|
/*
|
383 |
|
|
* auto-probing address list
|
384 |
|
|
* inspired by Adam J. Richter from Yggdrasil
|
385 |
|
|
*
|
386 |
|
|
* still not good enough - can cause a hang.
|
387 |
|
|
* example: a NE 2000 ethernet card at 300 will cause a hang probing 310.
|
388 |
|
|
* if that happens, reboot and use the LILO (kernel) command line.
|
389 |
|
|
* The possibly conflicting ethernet card addresses get NOT probed
|
390 |
|
|
* by default - to minimize the hang possibilities.
|
391 |
|
|
*
|
392 |
|
|
* The SB Pro addresses get "mirrored" at 0x6xx and some more locations - to
|
393 |
|
|
* avoid a type error, the 0x2xx-addresses must get checked before 0x6xx.
|
394 |
|
|
*
|
395 |
|
|
* send mail to emoenke@gwdg.de if your interface card is not FULLY
|
396 |
|
|
* represented here.
|
397 |
|
|
*/
|
398 |
|
|
#if !(SBPCD_ISSUE-1)
|
399 |
|
|
static int sbpcd[] =
|
400 |
|
|
{
|
401 |
|
|
CDROM_PORT, SBPRO, /* probe with user's setup first */
|
402 |
|
|
#if DISTRIBUTION
|
403 |
|
|
0x230, 1, /* Soundblaster Pro and 16 (default) */
|
404 |
|
|
0x300, 0, /* CI-101P (default), WDH-7001C (default),
|
405 |
|
|
Galaxy (default), Reveal (one default) */
|
406 |
|
|
0x250, 1, /* OmniCD default, Soundblaster Pro and 16 */
|
407 |
|
|
0x2C0, 3, /* Teac 16-bit cards */
|
408 |
|
|
0x260, 1, /* OmniCD */
|
409 |
|
|
0x320, 0, /* Lasermate, CI-101P, WDH-7001C, Galaxy, Reveal (other default),
|
410 |
|
|
Longshine LCS-6853 (default) */
|
411 |
|
|
0x338, 0, /* Reveal Sound Wave 32 card model #SC600 */
|
412 |
|
|
0x340, 0, /* Mozart sound card (default), Lasermate, CI-101P */
|
413 |
|
|
0x360, 0, /* Lasermate, CI-101P */
|
414 |
|
|
0x270, 1, /* Soundblaster 16 */
|
415 |
|
|
0x670, 0, /* "sound card #9" */
|
416 |
|
|
0x690, 0, /* "sound card #9" */
|
417 |
|
|
0x338, 2, /* SPEA Media FX, Ensonic SoundScape (default) */
|
418 |
|
|
0x328, 2, /* SPEA Media FX */
|
419 |
|
|
0x348, 2, /* SPEA Media FX */
|
420 |
|
|
0x634, 0, /* some newer sound cards */
|
421 |
|
|
0x638, 0, /* some newer sound cards */
|
422 |
|
|
0x230, 1, /* some newer sound cards */
|
423 |
|
|
/* due to incomplete address decoding of the SbPro card, these must be last */
|
424 |
|
|
0x630, 0, /* "sound card #9" (default) */
|
425 |
|
|
0x650, 0, /* "sound card #9" */
|
426 |
|
|
#ifdef MODULE
|
427 |
|
|
/*
|
428 |
|
|
* some "hazardous" locations (no harm with the loadable version)
|
429 |
|
|
* (will stop the bus if a NE2000 ethernet card resides at offset -0x10)
|
430 |
|
|
*/
|
431 |
|
|
0x330, 0, /* Lasermate, CI-101P, WDH-7001C */
|
432 |
|
|
0x350, 0, /* Lasermate, CI-101P */
|
433 |
|
|
0x358, 2, /* SPEA Media FX */
|
434 |
|
|
0x370, 0, /* Lasermate, CI-101P */
|
435 |
|
|
0x290, 1, /* Soundblaster 16 */
|
436 |
|
|
0x310, 0, /* Lasermate, CI-101P, WDH-7001C */
|
437 |
|
|
#endif MODULE
|
438 |
|
|
#endif DISTRIBUTION
|
439 |
|
|
};
|
440 |
|
|
#else
|
441 |
|
|
static int sbpcd[] = {CDROM_PORT, SBPRO}; /* probe with user's setup only */
|
442 |
|
|
#endif
|
443 |
|
|
|
444 |
|
|
#define NUM_PROBE (sizeof(sbpcd) / sizeof(int))
|
445 |
|
|
|
446 |
|
|
/*==========================================================================*/
|
447 |
|
|
/*
|
448 |
|
|
* the external references:
|
449 |
|
|
*/
|
450 |
|
|
#if !(SBPCD_ISSUE-1)
|
451 |
|
|
#ifdef CONFIG_SBPCD2
|
452 |
|
|
extern int sbpcd2_init(void);
|
453 |
|
|
#endif
|
454 |
|
|
#ifdef CONFIG_SBPCD3
|
455 |
|
|
extern int sbpcd3_init(void);
|
456 |
|
|
#endif
|
457 |
|
|
#ifdef CONFIG_SBPCD4
|
458 |
|
|
extern int sbpcd4_init(void);
|
459 |
|
|
#endif
|
460 |
|
|
#endif
|
461 |
|
|
|
462 |
|
|
/*==========================================================================*/
|
463 |
|
|
|
464 |
|
|
#define INLINE inline
|
465 |
|
|
|
466 |
|
|
/*==========================================================================*/
|
467 |
|
|
/*
|
468 |
|
|
* the forward references:
|
469 |
|
|
*/
|
470 |
|
|
static void sbp_sleep(u_int);
|
471 |
|
|
static void mark_timeout_delay(u_long);
|
472 |
|
|
static void mark_timeout_data(u_long);
|
473 |
|
|
#if 0
|
474 |
|
|
static void mark_timeout_audio(u_long);
|
475 |
|
|
#endif
|
476 |
|
|
static void sbp_read_cmd(struct request *req);
|
477 |
|
|
static int sbp_data(struct request *req);
|
478 |
|
|
static int cmd_out(void);
|
479 |
|
|
static int DiskInfo(void);
|
480 |
|
|
static int sbpcd_chk_disk_change(kdev_t);
|
481 |
|
|
|
482 |
|
|
/*==========================================================================*/
|
483 |
|
|
|
484 |
|
|
/*
|
485 |
|
|
* pattern for printk selection:
|
486 |
|
|
*
|
487 |
|
|
* (1<<DBG_INF) necessary information
|
488 |
|
|
* (1<<DBG_BSZ) BLOCK_SIZE trace
|
489 |
|
|
* (1<<DBG_REA) "read" status trace
|
490 |
|
|
* (1<<DBG_CHK) "media check" trace
|
491 |
|
|
* (1<<DBG_TIM) datarate timer test
|
492 |
|
|
* (1<<DBG_INI) initialization trace
|
493 |
|
|
* (1<<DBG_TOC) tell TocEntry values
|
494 |
|
|
* (1<<DBG_IOC) ioctl trace
|
495 |
|
|
* (1<<DBG_STA) "ResponseStatus" trace
|
496 |
|
|
* (1<<DBG_ERR) "cc_ReadError" trace
|
497 |
|
|
* (1<<DBG_CMD) "cmd_out" trace
|
498 |
|
|
* (1<<DBG_WRN) give explanation before auto-probing
|
499 |
|
|
* (1<<DBG_MUL) multi session code test
|
500 |
|
|
* (1<<DBG_IDX) "drive_id != 0" test code
|
501 |
|
|
* (1<<DBG_IOX) some special information
|
502 |
|
|
* (1<<DBG_DID) drive ID test
|
503 |
|
|
* (1<<DBG_RES) drive reset info
|
504 |
|
|
* (1<<DBG_SPI) SpinUp test info
|
505 |
|
|
* (1<<DBG_IOS) ioctl trace: "subchannel"
|
506 |
|
|
* (1<<DBG_IO2) ioctl trace: general
|
507 |
|
|
* (1<<DBG_UPC) show UPC info
|
508 |
|
|
* (1<<DBG_XA1) XA mode debugging
|
509 |
|
|
* (1<<DBG_LCK) door (un)lock info
|
510 |
|
|
* (1<<DBG_SQ1) dump SubQ frame
|
511 |
|
|
* (1<<DBG_AUD) "read audio" debugging
|
512 |
|
|
* (1<<DBG_SEQ) Sequoia interface configuration trace
|
513 |
|
|
* (1<<DBG_LCS) Longshine LCS-7260 debugging trace
|
514 |
|
|
* (1<<DBG_CD2) MKE/Funai CD200 debugging trace
|
515 |
|
|
* (1<<DBG_TEA) TEAC CD-55A debugging trace
|
516 |
|
|
* (1<<DBG_ECS) ECS-AT (Vertos-100) debugging trace
|
517 |
|
|
* (1<<DBG_000) unnecessary information
|
518 |
|
|
*/
|
519 |
|
|
#if DISTRIBUTION
|
520 |
|
|
static int sbpcd_debug = (1<<DBG_INF);
|
521 |
|
|
#else
|
522 |
|
|
static int sbpcd_debug = ((1<<DBG_INF) |
|
523 |
|
|
(1<<DBG_TOC) |
|
524 |
|
|
(1<<DBG_MUL) |
|
525 |
|
|
(1<<DBG_UPC));
|
526 |
|
|
#endif DISTRIBUTION
|
527 |
|
|
|
528 |
|
|
static int sbpcd_ioaddr = CDROM_PORT; /* default I/O base address */
|
529 |
|
|
static int sbpro_type = SBPRO;
|
530 |
|
|
static unsigned char setup_done = 0;
|
531 |
|
|
static unsigned char f_16bit = 0;
|
532 |
|
|
static unsigned char do_16bit = 0;
|
533 |
|
|
static int CDo_command, CDo_reset;
|
534 |
|
|
static int CDo_sel_i_d, CDo_enable;
|
535 |
|
|
static int CDi_info, CDi_status, CDi_data;
|
536 |
|
|
static struct cdrom_msf msf;
|
537 |
|
|
static struct cdrom_ti ti;
|
538 |
|
|
static struct cdrom_tochdr tochdr;
|
539 |
|
|
static struct cdrom_tocentry tocentry;
|
540 |
|
|
static struct cdrom_subchnl SC;
|
541 |
|
|
static struct cdrom_volctrl volctrl;
|
542 |
|
|
static struct cdrom_read_audio read_audio;
|
543 |
|
|
static struct cdrom_multisession ms_info;
|
544 |
|
|
|
545 |
|
|
static unsigned char msgnum=0;
|
546 |
|
|
static char msgbuf[80];
|
547 |
|
|
|
548 |
|
|
static const char *str_sb = "SoundBlaster";
|
549 |
|
|
static const char *str_sb_l = "soundblaster";
|
550 |
|
|
static const char *str_lm = "LaserMate";
|
551 |
|
|
static const char *str_sp = "SPEA";
|
552 |
|
|
static const char *str_sp_l = "spea";
|
553 |
|
|
static const char *str_ss = "SoundScape";
|
554 |
|
|
static const char *str_ss_l = "soundscape";
|
555 |
|
|
static const char *str_t16 = "Teac16bit";
|
556 |
|
|
static const char *str_t16_l = "teac16bit";
|
557 |
|
|
const char *type;
|
558 |
|
|
|
559 |
|
|
#if !(SBPCD_ISSUE-1)
|
560 |
|
|
static const char *major_name="sbpcd";
|
561 |
|
|
#endif
|
562 |
|
|
#if !(SBPCD_ISSUE-2)
|
563 |
|
|
static const char *major_name="sbpcd2";
|
564 |
|
|
#endif
|
565 |
|
|
#if !(SBPCD_ISSUE-3)
|
566 |
|
|
static const char *major_name="sbpcd3";
|
567 |
|
|
#endif
|
568 |
|
|
#if !(SBPCD_ISSUE-4)
|
569 |
|
|
static const char *major_name="sbpcd4";
|
570 |
|
|
#endif
|
571 |
|
|
|
572 |
|
|
/*==========================================================================*/
|
573 |
|
|
|
574 |
|
|
#if FUTURE
|
575 |
|
|
static struct wait_queue *sbp_waitq = NULL;
|
576 |
|
|
#endif FUTURE
|
577 |
|
|
|
578 |
|
|
static int teac=SBP_TEAC_SPEED;
|
579 |
|
|
static int buffers=SBP_BUFFER_FRAMES;
|
580 |
|
|
|
581 |
|
|
static u_char family0[]="MATSHITA"; /* MKE CR-521, CR-522, CR-523 */
|
582 |
|
|
static u_char family1[]="CR-56"; /* MKE CR-562, CR-563 */
|
583 |
|
|
static u_char family2[]="CD200"; /* MKE CD200, Funai CD200F */
|
584 |
|
|
static u_char familyL[]="LCS-7260"; /* Longshine LCS-7260 */
|
585 |
|
|
static u_char familyT[]="CD-55"; /* TEAC CD-55A */
|
586 |
|
|
static u_char familyV[]="ECS-AT"; /* ECS Vertos 100 */
|
587 |
|
|
|
588 |
|
|
static u_int recursion=0; /* internal testing only */
|
589 |
|
|
static u_int fatal_err=0; /* internal testing only */
|
590 |
|
|
static u_int response_count=0;
|
591 |
|
|
static u_int flags_cmd_out;
|
592 |
|
|
static u_char cmd_type=0;
|
593 |
|
|
static u_char drvcmd[10];
|
594 |
|
|
static u_char infobuf[20];
|
595 |
|
|
static u_char xa_head_buf[CD_XA_HEAD];
|
596 |
|
|
static u_char xa_tail_buf[CD_XA_TAIL];
|
597 |
|
|
|
598 |
|
|
#if OLD_BUSY
|
599 |
|
|
static volatile u_char busy_data=0;
|
600 |
|
|
static volatile u_char busy_audio=0; /* true semaphores would be safer */
|
601 |
|
|
#endif OLD_BUSY
|
602 |
|
|
static struct semaphore ioctl_read_sem = MUTEX;
|
603 |
|
|
static u_long timeout;
|
604 |
|
|
static volatile u_char timed_out_delay=0;
|
605 |
|
|
static volatile u_char timed_out_data=0;
|
606 |
|
|
#if 0
|
607 |
|
|
static volatile u_char timed_out_audio=0;
|
608 |
|
|
#endif
|
609 |
|
|
static u_int datarate= 1000000;
|
610 |
|
|
static u_int maxtim16=16000000;
|
611 |
|
|
static u_int maxtim04= 4000000;
|
612 |
|
|
static u_int maxtim02= 2000000;
|
613 |
|
|
static u_int maxtim_8= 30000;
|
614 |
|
|
#if LONG_TIMING
|
615 |
|
|
static u_int maxtim_data= 9000;
|
616 |
|
|
#else
|
617 |
|
|
static u_int maxtim_data= 3000;
|
618 |
|
|
#endif LONG_TIMING
|
619 |
|
|
#if DISTRIBUTION
|
620 |
|
|
static int n_retries=3;
|
621 |
|
|
#else
|
622 |
|
|
static int n_retries=1;
|
623 |
|
|
#endif
|
624 |
|
|
/*==========================================================================*/
|
625 |
|
|
|
626 |
|
|
static int ndrives=0;
|
627 |
|
|
static u_char drv_pattern[NR_SBPCD]={speed_auto,speed_auto,speed_auto,speed_auto};
|
628 |
|
|
static int sbpcd_blocksizes[NR_SBPCD] = {0, };
|
629 |
|
|
|
630 |
|
|
/*==========================================================================*/
|
631 |
|
|
/*
|
632 |
|
|
* drive space begins here (needed separate for each unit)
|
633 |
|
|
*/
|
634 |
|
|
static int d=0; /* DriveStruct index: drive number */
|
635 |
|
|
|
636 |
|
|
static struct {
|
637 |
|
|
char drv_id; /* "jumpered" drive ID or -1 */
|
638 |
|
|
char drv_sel; /* drive select lines bits */
|
639 |
|
|
|
640 |
|
|
char drive_model[9];
|
641 |
|
|
u_char firmware_version[4];
|
642 |
|
|
char f_eject; /* auto-eject flag: 0 or 1 */
|
643 |
|
|
u_char *sbp_buf; /* Pointer to internal data buffer,
|
644 |
|
|
space allocated during sbpcd_init() */
|
645 |
|
|
u_int sbp_bufsiz; /* size of sbp_buf (# of frames) */
|
646 |
|
|
int sbp_first_frame; /* First frame in buffer */
|
647 |
|
|
int sbp_last_frame; /* Last frame in buffer */
|
648 |
|
|
int sbp_read_frames; /* Number of frames being read to buffer */
|
649 |
|
|
int sbp_current; /* Frame being currently read */
|
650 |
|
|
|
651 |
|
|
u_char mode; /* read_mode: READ_M1, READ_M2, READ_SC, READ_AU */
|
652 |
|
|
u_char *aud_buf; /* Pointer to audio data buffer,
|
653 |
|
|
space allocated during sbpcd_init() */
|
654 |
|
|
u_int sbp_audsiz; /* size of aud_buf (# of raw frames) */
|
655 |
|
|
u_int drv_type;
|
656 |
|
|
u_char drv_options;
|
657 |
|
|
int status_bits;
|
658 |
|
|
u_char diskstate_flags;
|
659 |
|
|
u_char sense_byte;
|
660 |
|
|
|
661 |
|
|
u_char CD_changed;
|
662 |
|
|
char open_count;
|
663 |
|
|
u_char error_byte;
|
664 |
|
|
|
665 |
|
|
u_char f_multisession;
|
666 |
|
|
u_int lba_multi;
|
667 |
|
|
int first_session;
|
668 |
|
|
int last_session;
|
669 |
|
|
int track_of_last_session;
|
670 |
|
|
|
671 |
|
|
u_char audio_state;
|
672 |
|
|
u_int pos_audio_start;
|
673 |
|
|
u_int pos_audio_end;
|
674 |
|
|
char vol_chan0;
|
675 |
|
|
u_char vol_ctrl0;
|
676 |
|
|
char vol_chan1;
|
677 |
|
|
u_char vol_ctrl1;
|
678 |
|
|
#if 000 /* no supported drive has it */
|
679 |
|
|
char vol_chan2;
|
680 |
|
|
u_char vol_ctrl2;
|
681 |
|
|
char vol_chan3;
|
682 |
|
|
u_char vol_ctrl3;
|
683 |
|
|
#endif 000
|
684 |
|
|
u_char volume_control; /* TEAC on/off bits */
|
685 |
|
|
|
686 |
|
|
u_char SubQ_ctl_adr;
|
687 |
|
|
u_char SubQ_trk;
|
688 |
|
|
u_char SubQ_pnt_idx;
|
689 |
|
|
u_int SubQ_run_tot;
|
690 |
|
|
u_int SubQ_run_trk;
|
691 |
|
|
u_char SubQ_whatisthis;
|
692 |
|
|
|
693 |
|
|
u_char UPC_ctl_adr;
|
694 |
|
|
u_char UPC_buf[7];
|
695 |
|
|
|
696 |
|
|
int frame_size;
|
697 |
|
|
int CDsize_frm;
|
698 |
|
|
|
699 |
|
|
u_char xa_byte; /* 0x20: XA capabilities */
|
700 |
|
|
u_char n_first_track; /* binary */
|
701 |
|
|
u_char n_last_track; /* binary (not bcd), 0x01...0x63 */
|
702 |
|
|
u_int size_msf; /* time of whole CD, position of LeadOut track */
|
703 |
|
|
u_int size_blk;
|
704 |
|
|
|
705 |
|
|
u_char TocEnt_nixbyte; /* em */
|
706 |
|
|
u_char TocEnt_ctl_adr;
|
707 |
|
|
u_char TocEnt_number;
|
708 |
|
|
u_char TocEnt_format; /* em */
|
709 |
|
|
u_int TocEnt_address;
|
710 |
|
|
#if SAFE_MIXED
|
711 |
|
|
char has_data;
|
712 |
|
|
#endif SAFE_MIXED
|
713 |
|
|
u_char ored_ctl_adr; /* to detect if CDROM contains data tracks */
|
714 |
|
|
|
715 |
|
|
struct {
|
716 |
|
|
u_char nixbyte; /* em */
|
717 |
|
|
u_char ctl_adr; /* 0x4x: data, 0x0x: audio */
|
718 |
|
|
u_char number;
|
719 |
|
|
u_char format; /* em */ /* 0x00: lba, 0x01: msf */
|
720 |
|
|
u_int address;
|
721 |
|
|
} TocBuffer[MAX_TRACKS+1]; /* last entry faked */
|
722 |
|
|
|
723 |
|
|
int in_SpinUp; /* CR-52x test flag */
|
724 |
|
|
int n_bytes; /* TEAC awaited response count */
|
725 |
|
|
u_char error_state, b3, b4; /* TEAC command error state */
|
726 |
|
|
u_char f_drv_error; /* TEAC command error flag */
|
727 |
|
|
u_char speed_byte;
|
728 |
|
|
int frmsiz;
|
729 |
|
|
u_char f_XA; /* 1: XA */
|
730 |
|
|
u_char type_byte; /* 0, 1, 3 */
|
731 |
|
|
u_char mode_xb_6;
|
732 |
|
|
u_char mode_yb_7;
|
733 |
|
|
u_char mode_xb_8;
|
734 |
|
|
u_char delay;
|
735 |
|
|
|
736 |
|
|
} D_S[NR_SBPCD];
|
737 |
|
|
|
738 |
|
|
/*
|
739 |
|
|
* drive space ends here (needed separate for each unit)
|
740 |
|
|
*/
|
741 |
|
|
/*==========================================================================*/
|
742 |
|
|
#if 0
|
743 |
|
|
unsigned long cli_sti; /* for saving the processor flags */
|
744 |
|
|
#endif
|
745 |
|
|
/*==========================================================================*/
|
746 |
|
|
static struct timer_list delay_timer = { NULL, NULL, 0, 0, mark_timeout_delay};
|
747 |
|
|
static struct timer_list data_timer = { NULL, NULL, 0, 0, mark_timeout_data};
|
748 |
|
|
#if 0
|
749 |
|
|
static struct timer_list audio_timer = { NULL, NULL, 0, 0, mark_timeout_audio};
|
750 |
|
|
#endif
|
751 |
|
|
/*==========================================================================*/
|
752 |
|
|
/*
|
753 |
|
|
* DDI interface
|
754 |
|
|
*/
|
755 |
|
|
static void msg(int level, const char *fmt, ...)
|
756 |
|
|
{
|
757 |
|
|
#if DISTRIBUTION
|
758 |
|
|
#define MSG_LEVEL KERN_NOTICE
|
759 |
|
|
#else
|
760 |
|
|
#define MSG_LEVEL KERN_INFO
|
761 |
|
|
#endif DISTRIBUTION
|
762 |
|
|
|
763 |
|
|
char buf[256];
|
764 |
|
|
va_list args;
|
765 |
|
|
|
766 |
|
|
if (!(sbpcd_debug&(1<<level))) return;
|
767 |
|
|
|
768 |
|
|
msgnum++;
|
769 |
|
|
if (msgnum>99) msgnum=0;
|
770 |
|
|
sprintf(buf, MSG_LEVEL "%s-%d [%02d]: ", major_name, d, msgnum);
|
771 |
|
|
va_start(args, fmt);
|
772 |
|
|
vsprintf(&buf[18], fmt, args);
|
773 |
|
|
va_end(args);
|
774 |
|
|
printk(buf);
|
775 |
|
|
#if KLOGD_PAUSE
|
776 |
|
|
sbp_sleep(KLOGD_PAUSE); /* else messages get lost */
|
777 |
|
|
#endif KLOGD_PAUSE
|
778 |
|
|
return;
|
779 |
|
|
}
|
780 |
|
|
/*==========================================================================*/
|
781 |
|
|
/*
|
782 |
|
|
* DDI interface: runtime trace bit pattern maintenance
|
783 |
|
|
*/
|
784 |
|
|
static int sbpcd_dbg_ioctl(unsigned long arg, int level)
|
785 |
|
|
{
|
786 |
|
|
switch(arg)
|
787 |
|
|
{
|
788 |
|
|
case 0: /* OFF */
|
789 |
|
|
sbpcd_debug = DBG_INF;
|
790 |
|
|
break;
|
791 |
|
|
|
792 |
|
|
default:
|
793 |
|
|
if (arg>=128) sbpcd_debug &= ~(1<<(arg-128));
|
794 |
|
|
else sbpcd_debug |= (1<<arg);
|
795 |
|
|
}
|
796 |
|
|
return (arg);
|
797 |
|
|
}
|
798 |
|
|
/*==========================================================================*/
|
799 |
|
|
static void mark_timeout_delay(u_long i)
|
800 |
|
|
{
|
801 |
|
|
timed_out_delay=1;
|
802 |
|
|
#if 0
|
803 |
|
|
msg(DBG_TIM,"delay timer expired.\n");
|
804 |
|
|
#endif
|
805 |
|
|
}
|
806 |
|
|
/*==========================================================================*/
|
807 |
|
|
static void mark_timeout_data(u_long i)
|
808 |
|
|
{
|
809 |
|
|
timed_out_data=1;
|
810 |
|
|
#if 0
|
811 |
|
|
msg(DBG_TIM,"data timer expired.\n");
|
812 |
|
|
#endif
|
813 |
|
|
}
|
814 |
|
|
/*==========================================================================*/
|
815 |
|
|
#if 0
|
816 |
|
|
static void mark_timeout_audio(u_long i)
|
817 |
|
|
{
|
818 |
|
|
timed_out_audio=1;
|
819 |
|
|
#if 0
|
820 |
|
|
msg(DBG_TIM,"audio timer expired.\n");
|
821 |
|
|
#endif
|
822 |
|
|
}
|
823 |
|
|
#endif
|
824 |
|
|
/*==========================================================================*/
|
825 |
|
|
/*
|
826 |
|
|
* Wait a little while (used for polling the drive).
|
827 |
|
|
*/
|
828 |
|
|
static void sbp_sleep(u_int time)
|
829 |
|
|
{
|
830 |
|
|
sti();
|
831 |
|
|
current->state = TASK_INTERRUPTIBLE;
|
832 |
|
|
current->timeout = jiffies + time;
|
833 |
|
|
schedule();
|
834 |
|
|
sti();
|
835 |
|
|
}
|
836 |
|
|
/*==========================================================================*/
|
837 |
|
|
#define RETURN_UP(rc) {up(&ioctl_read_sem); return(rc);}
|
838 |
|
|
/*==========================================================================*/
|
839 |
|
|
/*
|
840 |
|
|
* convert logical_block_address to m-s-f_number (3 bytes only)
|
841 |
|
|
*/
|
842 |
|
|
static INLINE void lba2msf(int lba, u_char *msf)
|
843 |
|
|
{
|
844 |
|
|
lba += CD_MSF_OFFSET;
|
845 |
|
|
msf[0] = lba / (CD_SECS*CD_FRAMES);
|
846 |
|
|
lba %= CD_SECS*CD_FRAMES;
|
847 |
|
|
msf[1] = lba / CD_FRAMES;
|
848 |
|
|
msf[2] = lba % CD_FRAMES;
|
849 |
|
|
}
|
850 |
|
|
/*==========================================================================*/
|
851 |
|
|
/*==========================================================================*/
|
852 |
|
|
/*
|
853 |
|
|
* convert msf-bin to msf-bcd
|
854 |
|
|
*/
|
855 |
|
|
static INLINE void bin2bcdx(u_char *p) /* must work only up to 75 or 99 */
|
856 |
|
|
{
|
857 |
|
|
*p=((*p/10)<<4)|(*p%10);
|
858 |
|
|
}
|
859 |
|
|
/*==========================================================================*/
|
860 |
|
|
static INLINE u_int blk2msf(u_int blk)
|
861 |
|
|
{
|
862 |
|
|
MSF msf;
|
863 |
|
|
u_int mm;
|
864 |
|
|
|
865 |
|
|
msf.c[3] = 0;
|
866 |
|
|
msf.c[2] = (blk + CD_MSF_OFFSET) / (CD_SECS * CD_FRAMES);
|
867 |
|
|
mm = (blk + CD_MSF_OFFSET) % (CD_SECS * CD_FRAMES);
|
868 |
|
|
msf.c[1] = mm / CD_FRAMES;
|
869 |
|
|
msf.c[0] = mm % CD_FRAMES;
|
870 |
|
|
return (msf.n);
|
871 |
|
|
}
|
872 |
|
|
/*==========================================================================*/
|
873 |
|
|
static INLINE u_int make16(u_char rh, u_char rl)
|
874 |
|
|
{
|
875 |
|
|
return ((rh<<8)|rl);
|
876 |
|
|
}
|
877 |
|
|
/*==========================================================================*/
|
878 |
|
|
static INLINE u_int make32(u_int rh, u_int rl)
|
879 |
|
|
{
|
880 |
|
|
return ((rh<<16)|rl);
|
881 |
|
|
}
|
882 |
|
|
/*==========================================================================*/
|
883 |
|
|
static INLINE u_char swap_nibbles(u_char i)
|
884 |
|
|
{
|
885 |
|
|
return ((i<<4)|(i>>4));
|
886 |
|
|
}
|
887 |
|
|
/*==========================================================================*/
|
888 |
|
|
static INLINE u_char byt2bcd(u_char i)
|
889 |
|
|
{
|
890 |
|
|
return (((i/10)<<4)+i%10);
|
891 |
|
|
}
|
892 |
|
|
/*==========================================================================*/
|
893 |
|
|
static INLINE u_char bcd2bin(u_char bcd)
|
894 |
|
|
{
|
895 |
|
|
return ((bcd>>4)*10+(bcd&0x0F));
|
896 |
|
|
}
|
897 |
|
|
/*==========================================================================*/
|
898 |
|
|
static INLINE int msf2blk(int msfx)
|
899 |
|
|
{
|
900 |
|
|
MSF msf;
|
901 |
|
|
int i;
|
902 |
|
|
|
903 |
|
|
msf.n=msfx;
|
904 |
|
|
i=(msf.c[2] * CD_SECS + msf.c[1]) * CD_FRAMES + msf.c[0] - CD_MSF_OFFSET;
|
905 |
|
|
if (i<0) return (0);
|
906 |
|
|
return (i);
|
907 |
|
|
}
|
908 |
|
|
/*==========================================================================*/
|
909 |
|
|
/*
|
910 |
|
|
* convert m-s-f_number (3 bytes only) to logical_block_address
|
911 |
|
|
*/
|
912 |
|
|
static INLINE int msf2lba(u_char *msf)
|
913 |
|
|
{
|
914 |
|
|
int i;
|
915 |
|
|
|
916 |
|
|
i=(msf[0] * CD_SECS + msf[1]) * CD_FRAMES + msf[2] - CD_MSF_OFFSET;
|
917 |
|
|
if (i<0) return (0);
|
918 |
|
|
return (i);
|
919 |
|
|
}
|
920 |
|
|
/*==========================================================================*/
|
921 |
|
|
/* evaluate cc_ReadError code */
|
922 |
|
|
static int sta2err(int sta)
|
923 |
|
|
{
|
924 |
|
|
if (famT_drive)
|
925 |
|
|
{
|
926 |
|
|
if (sta==0x00) return (0);
|
927 |
|
|
if (sta==0x01) return (-604); /* CRC error */
|
928 |
|
|
if (sta==0x02) return (-602); /* drive not ready */
|
929 |
|
|
if (sta==0x03) return (-607); /* unknown media */
|
930 |
|
|
if (sta==0x04) return (-612); /* general failure */
|
931 |
|
|
if (sta==0x05) return (0);
|
932 |
|
|
if (sta==0x06) return (-ERR_DISKCHANGE); /* disk change */
|
933 |
|
|
if (sta==0x0b) return (-612); /* general failure */
|
934 |
|
|
if (sta==0xff) return (-612); /* general failure */
|
935 |
|
|
return (0);
|
936 |
|
|
}
|
937 |
|
|
else
|
938 |
|
|
{
|
939 |
|
|
if (sta<=2) return (sta);
|
940 |
|
|
if (sta==0x05) return (-604); /* CRC error */
|
941 |
|
|
if (sta==0x06) return (-606); /* seek error */
|
942 |
|
|
if (sta==0x0d) return (-606); /* seek error */
|
943 |
|
|
if (sta==0x0e) return (-603); /* unknown command */
|
944 |
|
|
if (sta==0x14) return (-603); /* unknown command */
|
945 |
|
|
if (sta==0x0c) return (-611); /* read fault */
|
946 |
|
|
if (sta==0x0f) return (-611); /* read fault */
|
947 |
|
|
if (sta==0x10) return (-611); /* read fault */
|
948 |
|
|
if (sta>=0x16) return (-612); /* general failure */
|
949 |
|
|
if (sta==0x11) return (-ERR_DISKCHANGE); /* disk change (LCS: removed) */
|
950 |
|
|
if (famL_drive)
|
951 |
|
|
if (sta==0x12) return (-ERR_DISKCHANGE); /* disk change (inserted) */
|
952 |
|
|
return (-602); /* drive not ready */
|
953 |
|
|
}
|
954 |
|
|
}
|
955 |
|
|
/*==========================================================================*/
|
956 |
|
|
static INLINE void clr_cmdbuf(void)
|
957 |
|
|
{
|
958 |
|
|
int i;
|
959 |
|
|
|
960 |
|
|
for (i=0;i<10;i++) drvcmd[i]=0;
|
961 |
|
|
cmd_type=0;
|
962 |
|
|
}
|
963 |
|
|
/*==========================================================================*/
|
964 |
|
|
static void flush_status(void)
|
965 |
|
|
{
|
966 |
|
|
int i;
|
967 |
|
|
|
968 |
|
|
sbp_sleep(15*HZ/10);
|
969 |
|
|
for (i=maxtim_data;i!=0;i--) inb(CDi_status);
|
970 |
|
|
}
|
971 |
|
|
/*====================================================================*/
|
972 |
|
|
/*
|
973 |
|
|
* CDi status loop for Teac CD-55A (Rob Riggs)
|
974 |
|
|
*
|
975 |
|
|
* This is needed because for some strange reason
|
976 |
|
|
* the CD-55A can take a real long time to give a
|
977 |
|
|
* status response. This seems to happen after we
|
978 |
|
|
* issue a READ command where a long seek is involved.
|
979 |
|
|
*
|
980 |
|
|
* I tried to ensure that we get max throughput with
|
981 |
|
|
* minimal busy waiting. We busy wait at first, then
|
982 |
|
|
* "switch gears" and start sleeping. We sleep for
|
983 |
|
|
* longer periods of time the longer we wait.
|
984 |
|
|
*
|
985 |
|
|
*/
|
986 |
|
|
static int CDi_stat_loop_T(void)
|
987 |
|
|
{
|
988 |
|
|
int i, gear=1;
|
989 |
|
|
u_long timeout_1, timeout_2, timeout_3, timeout_4;
|
990 |
|
|
|
991 |
|
|
timeout_1 = jiffies + HZ / 50; /* sbp_sleep(0) for a short period */
|
992 |
|
|
timeout_2 = jiffies + HZ / 5; /* nap for no more than 200ms */
|
993 |
|
|
timeout_3 = jiffies + 5 * HZ; /* sleep for up to 5s */
|
994 |
|
|
timeout_4 = jiffies + 45 * HZ; /* long sleep for up to 45s. */
|
995 |
|
|
do
|
996 |
|
|
{
|
997 |
|
|
i = inb(CDi_status);
|
998 |
|
|
if (!(i&s_not_data_ready)) return (i);
|
999 |
|
|
if (!(i&s_not_result_ready)) return (i);
|
1000 |
|
|
switch(gear)
|
1001 |
|
|
{
|
1002 |
|
|
case 4:
|
1003 |
|
|
sbp_sleep(HZ);
|
1004 |
|
|
if (jiffies > timeout_4) gear++;
|
1005 |
|
|
msg(DBG_TEA, "CDi_stat_loop_T: long sleep active.\n");
|
1006 |
|
|
break;
|
1007 |
|
|
case 3:
|
1008 |
|
|
sbp_sleep(HZ/10);
|
1009 |
|
|
if (jiffies > timeout_3) gear++;
|
1010 |
|
|
break;
|
1011 |
|
|
case 2:
|
1012 |
|
|
sbp_sleep(HZ/100);
|
1013 |
|
|
if (jiffies > timeout_2) gear++;
|
1014 |
|
|
break;
|
1015 |
|
|
case 1:
|
1016 |
|
|
sbp_sleep(0);
|
1017 |
|
|
if (jiffies > timeout_1) gear++;
|
1018 |
|
|
}
|
1019 |
|
|
} while (gear < 5);
|
1020 |
|
|
return -1;
|
1021 |
|
|
}
|
1022 |
|
|
/*==========================================================================*/
|
1023 |
|
|
static int CDi_stat_loop(void)
|
1024 |
|
|
{
|
1025 |
|
|
int i,j;
|
1026 |
|
|
|
1027 |
|
|
for(timeout = jiffies + 10*HZ, i=maxtim_data; timeout > jiffies; )
|
1028 |
|
|
{
|
1029 |
|
|
for ( ;i!=0;i--)
|
1030 |
|
|
{
|
1031 |
|
|
j=inb(CDi_status);
|
1032 |
|
|
if (!(j&s_not_data_ready)) return (j);
|
1033 |
|
|
if (!(j&s_not_result_ready)) return (j);
|
1034 |
|
|
if (fam0L_drive) if (j&s_attention) return (j);
|
1035 |
|
|
}
|
1036 |
|
|
sbp_sleep(1);
|
1037 |
|
|
i = 1;
|
1038 |
|
|
}
|
1039 |
|
|
msg(DBG_LCS,"CDi_stat_loop failed\n");
|
1040 |
|
|
return (-1);
|
1041 |
|
|
}
|
1042 |
|
|
/*==========================================================================*/
|
1043 |
|
|
#if 00000
|
1044 |
|
|
/*==========================================================================*/
|
1045 |
|
|
static int tst_DataReady(void)
|
1046 |
|
|
{
|
1047 |
|
|
int i;
|
1048 |
|
|
|
1049 |
|
|
i=inb(CDi_status);
|
1050 |
|
|
if (i&s_not_data_ready) return (0);
|
1051 |
|
|
return (1);
|
1052 |
|
|
}
|
1053 |
|
|
/*==========================================================================*/
|
1054 |
|
|
static int tst_ResultReady(void)
|
1055 |
|
|
{
|
1056 |
|
|
int i;
|
1057 |
|
|
|
1058 |
|
|
i=inb(CDi_status);
|
1059 |
|
|
if (i&s_not_result_ready) return (0);
|
1060 |
|
|
return (1);
|
1061 |
|
|
}
|
1062 |
|
|
/*==========================================================================*/
|
1063 |
|
|
static int tst_Attention(void)
|
1064 |
|
|
{
|
1065 |
|
|
int i;
|
1066 |
|
|
|
1067 |
|
|
i=inb(CDi_status);
|
1068 |
|
|
if (i&s_attention) return (1);
|
1069 |
|
|
return (0);
|
1070 |
|
|
}
|
1071 |
|
|
/*==========================================================================*/
|
1072 |
|
|
#endif 00000
|
1073 |
|
|
/*==========================================================================*/
|
1074 |
|
|
static int ResponseInfo(void)
|
1075 |
|
|
{
|
1076 |
|
|
int i,j,st=0;
|
1077 |
|
|
u_long timeout;
|
1078 |
|
|
|
1079 |
|
|
for (i=0,timeout=jiffies+HZ;i<response_count;i++)
|
1080 |
|
|
{
|
1081 |
|
|
for (j=maxtim_data; ; )
|
1082 |
|
|
{
|
1083 |
|
|
for ( ;j!=0;j-- )
|
1084 |
|
|
{
|
1085 |
|
|
st=inb(CDi_status);
|
1086 |
|
|
if (!(st&s_not_result_ready)) break;
|
1087 |
|
|
}
|
1088 |
|
|
if ((j!=0)||(timeout<=jiffies)) break;
|
1089 |
|
|
sbp_sleep(1);
|
1090 |
|
|
j = 1;
|
1091 |
|
|
}
|
1092 |
|
|
if (timeout<=jiffies) break;
|
1093 |
|
|
infobuf[i]=inb(CDi_info);
|
1094 |
|
|
}
|
1095 |
|
|
#if 000
|
1096 |
|
|
while (!(inb(CDi_status)&s_not_result_ready))
|
1097 |
|
|
{
|
1098 |
|
|
infobuf[i++]=inb(CDi_info);
|
1099 |
|
|
}
|
1100 |
|
|
j=i-response_count;
|
1101 |
|
|
if (j>0) msg(DBG_INF,"ResponseInfo: got %d trailing bytes.\n",j);
|
1102 |
|
|
#endif 000
|
1103 |
|
|
for (j=0;j<i;j++)
|
1104 |
|
|
sprintf(&msgbuf[j*3]," %02X",infobuf[j]);
|
1105 |
|
|
msgbuf[j*3]=0;
|
1106 |
|
|
msg(DBG_CMD,"ResponseInfo:%s (%d,%d)\n",msgbuf,response_count,i);
|
1107 |
|
|
j=response_count-i;
|
1108 |
|
|
if (j>0) return (-j);
|
1109 |
|
|
else return (i);
|
1110 |
|
|
}
|
1111 |
|
|
/*==========================================================================*/
|
1112 |
|
|
static void EvaluateStatus(int st)
|
1113 |
|
|
{
|
1114 |
|
|
D_S[d].status_bits=0;
|
1115 |
|
|
if (fam1_drive) D_S[d].status_bits=st|p_success;
|
1116 |
|
|
else if (fam0_drive)
|
1117 |
|
|
{
|
1118 |
|
|
if (st&p_caddin_old) D_S[d].status_bits |= p_door_closed|p_caddy_in;
|
1119 |
|
|
if (st&p_spinning) D_S[d].status_bits |= p_spinning;
|
1120 |
|
|
if (st&p_check) D_S[d].status_bits |= p_check;
|
1121 |
|
|
if (st&p_success_old) D_S[d].status_bits |= p_success;
|
1122 |
|
|
if (st&p_busy_old) D_S[d].status_bits |= p_busy_new;
|
1123 |
|
|
if (st&p_disk_ok) D_S[d].status_bits |= p_disk_ok;
|
1124 |
|
|
}
|
1125 |
|
|
else if (famLV_drive)
|
1126 |
|
|
{
|
1127 |
|
|
D_S[d].status_bits |= p_success;
|
1128 |
|
|
if (st&p_caddin_old) D_S[d].status_bits |= p_disk_ok|p_caddy_in;
|
1129 |
|
|
if (st&p_spinning) D_S[d].status_bits |= p_spinning;
|
1130 |
|
|
if (st&p_check) D_S[d].status_bits |= p_check;
|
1131 |
|
|
if (st&p_busy_old) D_S[d].status_bits |= p_busy_new;
|
1132 |
|
|
if (st&p_lcs_door_closed) D_S[d].status_bits |= p_door_closed;
|
1133 |
|
|
if (st&p_lcs_door_locked) D_S[d].status_bits |= p_door_locked;
|
1134 |
|
|
}
|
1135 |
|
|
else if (fam2_drive)
|
1136 |
|
|
{
|
1137 |
|
|
D_S[d].status_bits |= p_success;
|
1138 |
|
|
if (st&p2_check) D_S[d].status_bits |= p1_check;
|
1139 |
|
|
if (st&p2_door_closed) D_S[d].status_bits |= p1_door_closed;
|
1140 |
|
|
if (st&p2_disk_in) D_S[d].status_bits |= p1_disk_in;
|
1141 |
|
|
if (st&p2_busy1) D_S[d].status_bits |= p1_busy;
|
1142 |
|
|
if (st&p2_busy2) D_S[d].status_bits |= p1_busy;
|
1143 |
|
|
if (st&p2_spinning) D_S[d].status_bits |= p1_spinning;
|
1144 |
|
|
if (st&p2_door_locked) D_S[d].status_bits |= p1_door_locked;
|
1145 |
|
|
if (st&p2_disk_ok) D_S[d].status_bits |= p1_disk_ok;
|
1146 |
|
|
}
|
1147 |
|
|
else if (famT_drive)
|
1148 |
|
|
{
|
1149 |
|
|
return; /* still needs to get coded */
|
1150 |
|
|
D_S[d].status_bits |= p_success;
|
1151 |
|
|
if (st&p2_check) D_S[d].status_bits |= p1_check;
|
1152 |
|
|
if (st&p2_door_closed) D_S[d].status_bits |= p1_door_closed;
|
1153 |
|
|
if (st&p2_disk_in) D_S[d].status_bits |= p1_disk_in;
|
1154 |
|
|
if (st&p2_busy1) D_S[d].status_bits |= p1_busy;
|
1155 |
|
|
if (st&p2_busy2) D_S[d].status_bits |= p1_busy;
|
1156 |
|
|
if (st&p2_spinning) D_S[d].status_bits |= p1_spinning;
|
1157 |
|
|
if (st&p2_door_locked) D_S[d].status_bits |= p1_door_locked;
|
1158 |
|
|
if (st&p2_disk_ok) D_S[d].status_bits |= p1_disk_ok;
|
1159 |
|
|
}
|
1160 |
|
|
return;
|
1161 |
|
|
}
|
1162 |
|
|
/*==========================================================================*/
|
1163 |
|
|
static int get_state_T(void)
|
1164 |
|
|
{
|
1165 |
|
|
int i;
|
1166 |
|
|
|
1167 |
|
|
static int cmd_out_T(void);
|
1168 |
|
|
|
1169 |
|
|
clr_cmdbuf();
|
1170 |
|
|
D_S[d].n_bytes=1;
|
1171 |
|
|
drvcmd[0]=CMDT_STATUS;
|
1172 |
|
|
i=cmd_out_T();
|
1173 |
|
|
if (i>=0) i=infobuf[0];
|
1174 |
|
|
else
|
1175 |
|
|
{
|
1176 |
|
|
msg(DBG_TEA,"get_state_T error %d\n", i);
|
1177 |
|
|
return (i);
|
1178 |
|
|
}
|
1179 |
|
|
if (i>=0)
|
1180 |
|
|
/* 2: closed, disk in */
|
1181 |
|
|
D_S[d].status_bits=p1_door_closed|p1_disk_in|p1_spinning|p1_disk_ok;
|
1182 |
|
|
else if (D_S[d].error_state==6)
|
1183 |
|
|
{
|
1184 |
|
|
/* 3: closed, disk in, changed ("06 xx xx") */
|
1185 |
|
|
D_S[d].status_bits=p1_door_closed|p1_disk_in;
|
1186 |
|
|
D_S[d].CD_changed=0xFF;
|
1187 |
|
|
D_S[d].diskstate_flags &= ~toc_bit;
|
1188 |
|
|
}
|
1189 |
|
|
else if ((D_S[d].error_state!=2)||(D_S[d].b3!=0x3A)||(D_S[d].b4==0x00))
|
1190 |
|
|
{
|
1191 |
|
|
/* 1: closed, no disk ("xx yy zz"or "02 3A 00") */
|
1192 |
|
|
D_S[d].status_bits=p1_door_closed;
|
1193 |
|
|
D_S[d].open_count=0;
|
1194 |
|
|
}
|
1195 |
|
|
else if (D_S[d].b4==0x01)
|
1196 |
|
|
{
|
1197 |
|
|
/* 0: open ("02 3A 01") */
|
1198 |
|
|
D_S[d].status_bits=0;
|
1199 |
|
|
D_S[d].open_count=0;
|
1200 |
|
|
}
|
1201 |
|
|
else
|
1202 |
|
|
{
|
1203 |
|
|
/* 1: closed, no disk ("02 3A xx") */
|
1204 |
|
|
D_S[d].status_bits=p1_door_closed;
|
1205 |
|
|
D_S[d].open_count=0;
|
1206 |
|
|
}
|
1207 |
|
|
return (D_S[d].status_bits);
|
1208 |
|
|
}
|
1209 |
|
|
/*==========================================================================*/
|
1210 |
|
|
static int ResponseStatus(void)
|
1211 |
|
|
{
|
1212 |
|
|
int i,j;
|
1213 |
|
|
u_long timeout;
|
1214 |
|
|
|
1215 |
|
|
msg(DBG_STA,"doing ResponseStatus...\n");
|
1216 |
|
|
if (famT_drive) return (get_state_T());
|
1217 |
|
|
if (flags_cmd_out & f_respo3) timeout = jiffies;
|
1218 |
|
|
else if (flags_cmd_out & f_respo2) timeout = jiffies + 16*HZ;
|
1219 |
|
|
else timeout = jiffies + 4*HZ;
|
1220 |
|
|
j=maxtim_8;
|
1221 |
|
|
do
|
1222 |
|
|
{
|
1223 |
|
|
for ( ;j!=0;j--)
|
1224 |
|
|
{
|
1225 |
|
|
i=inb(CDi_status);
|
1226 |
|
|
if (!(i&s_not_result_ready)) break;
|
1227 |
|
|
}
|
1228 |
|
|
if ((j!=0)||(timeout<jiffies)) break;
|
1229 |
|
|
sbp_sleep(1);
|
1230 |
|
|
j = 1;
|
1231 |
|
|
}
|
1232 |
|
|
while (1);
|
1233 |
|
|
if (j==0)
|
1234 |
|
|
{
|
1235 |
|
|
if ((flags_cmd_out & f_respo3) == 0)
|
1236 |
|
|
msg(DBG_STA,"ResponseStatus: timeout.\n");
|
1237 |
|
|
D_S[d].status_bits=0;
|
1238 |
|
|
return (-401);
|
1239 |
|
|
}
|
1240 |
|
|
i=inb(CDi_info);
|
1241 |
|
|
msg(DBG_STA,"ResponseStatus: response %02X.\n", i);
|
1242 |
|
|
EvaluateStatus(i);
|
1243 |
|
|
msg(DBG_STA,"status_bits=%02X, i=%02X\n",D_S[d].status_bits,i);
|
1244 |
|
|
return (D_S[d].status_bits);
|
1245 |
|
|
}
|
1246 |
|
|
/*==========================================================================*/
|
1247 |
|
|
static void cc_ReadStatus(void)
|
1248 |
|
|
{
|
1249 |
|
|
int i;
|
1250 |
|
|
|
1251 |
|
|
msg(DBG_STA,"giving cc_ReadStatus command\n");
|
1252 |
|
|
if (famT_drive) return;
|
1253 |
|
|
SBPCD_CLI;
|
1254 |
|
|
if (fam0LV_drive) OUT(CDo_command,CMD0_STATUS);
|
1255 |
|
|
else if (fam1_drive) OUT(CDo_command,CMD1_STATUS);
|
1256 |
|
|
else if (fam2_drive) OUT(CDo_command,CMD2_STATUS);
|
1257 |
|
|
if (!fam0LV_drive) for (i=0;i<6;i++) OUT(CDo_command,0);
|
1258 |
|
|
SBPCD_STI;
|
1259 |
|
|
}
|
1260 |
|
|
/*==========================================================================*/
|
1261 |
|
|
static int cc_ReadError(void)
|
1262 |
|
|
{
|
1263 |
|
|
int i;
|
1264 |
|
|
|
1265 |
|
|
clr_cmdbuf();
|
1266 |
|
|
msg(DBG_ERR,"giving cc_ReadError command.\n");
|
1267 |
|
|
if (fam1_drive)
|
1268 |
|
|
{
|
1269 |
|
|
drvcmd[0]=CMD1_READ_ERR;
|
1270 |
|
|
response_count=8;
|
1271 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus;
|
1272 |
|
|
}
|
1273 |
|
|
else if (fam0LV_drive)
|
1274 |
|
|
{
|
1275 |
|
|
drvcmd[0]=CMD0_READ_ERR;
|
1276 |
|
|
response_count=6;
|
1277 |
|
|
if (famLV_drive)
|
1278 |
|
|
flags_cmd_out=f_putcmd;
|
1279 |
|
|
else
|
1280 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus;
|
1281 |
|
|
}
|
1282 |
|
|
else if (fam2_drive)
|
1283 |
|
|
{
|
1284 |
|
|
drvcmd[0]=CMD2_READ_ERR;
|
1285 |
|
|
response_count=6;
|
1286 |
|
|
flags_cmd_out=f_putcmd;
|
1287 |
|
|
}
|
1288 |
|
|
else if (famT_drive)
|
1289 |
|
|
{
|
1290 |
|
|
response_count=5;
|
1291 |
|
|
drvcmd[0]=CMDT_READ_ERR;
|
1292 |
|
|
}
|
1293 |
|
|
i=cmd_out();
|
1294 |
|
|
D_S[d].error_byte=0;
|
1295 |
|
|
msg(DBG_ERR,"cc_ReadError: cmd_out(CMDx_READ_ERR) returns %d (%02X)\n",i,i);
|
1296 |
|
|
if (i<0) return (i);
|
1297 |
|
|
if (fam0V_drive) i=1;
|
1298 |
|
|
else i=2;
|
1299 |
|
|
D_S[d].error_byte=infobuf[i];
|
1300 |
|
|
msg(DBG_ERR,"cc_ReadError: infobuf[%d] is %d (%02X)\n",i,D_S[d].error_byte,D_S[d].error_byte);
|
1301 |
|
|
i=sta2err(infobuf[i]);
|
1302 |
|
|
if (i==-ERR_DISKCHANGE)
|
1303 |
|
|
{
|
1304 |
|
|
D_S[d].CD_changed=0xFF;
|
1305 |
|
|
D_S[d].diskstate_flags &= ~toc_bit;
|
1306 |
|
|
}
|
1307 |
|
|
return (i);
|
1308 |
|
|
}
|
1309 |
|
|
/*==========================================================================*/
|
1310 |
|
|
static int cmd_out_T(void)
|
1311 |
|
|
{
|
1312 |
|
|
#undef CMDT_TRIES
|
1313 |
|
|
#define CMDT_TRIES 1000
|
1314 |
|
|
#define TEST_FALSE_FF 1
|
1315 |
|
|
|
1316 |
|
|
static int cc_DriveReset(void);
|
1317 |
|
|
int i, j, l=0, m, ntries;
|
1318 |
|
|
long flags;
|
1319 |
|
|
|
1320 |
|
|
D_S[d].error_state=0;
|
1321 |
|
|
D_S[d].b3=0;
|
1322 |
|
|
D_S[d].b4=0;
|
1323 |
|
|
D_S[d].f_drv_error=0;
|
1324 |
|
|
for (i=0;i<10;i++) sprintf(&msgbuf[i*3]," %02X",drvcmd[i]);
|
1325 |
|
|
msgbuf[i*3]=0;
|
1326 |
|
|
msg(DBG_CMD,"cmd_out_T:%s\n",msgbuf);
|
1327 |
|
|
|
1328 |
|
|
OUT(CDo_sel_i_d,0);
|
1329 |
|
|
OUT(CDo_enable,D_S[d].drv_sel);
|
1330 |
|
|
i=inb(CDi_status);
|
1331 |
|
|
do_16bit=0;
|
1332 |
|
|
if ((f_16bit)&&(!(i&0x80)))
|
1333 |
|
|
{
|
1334 |
|
|
do_16bit=1;
|
1335 |
|
|
msg(DBG_TEA,"cmd_out_T: do_16bit set.\n");
|
1336 |
|
|
}
|
1337 |
|
|
if (!(i&s_not_result_ready))
|
1338 |
|
|
do
|
1339 |
|
|
{
|
1340 |
|
|
j=inb(CDi_info);
|
1341 |
|
|
i=inb(CDi_status);
|
1342 |
|
|
sbp_sleep(0);
|
1343 |
|
|
msg(DBG_TEA,"cmd_out_T: spurious !s_not_result_ready. (%02X)\n", j);
|
1344 |
|
|
}
|
1345 |
|
|
while (!(i&s_not_result_ready));
|
1346 |
|
|
save_flags(flags); cli();
|
1347 |
|
|
for (i=0;i<10;i++) OUT(CDo_command,drvcmd[i]);
|
1348 |
|
|
restore_flags(flags);
|
1349 |
|
|
for (ntries=CMDT_TRIES;ntries>0;ntries--)
|
1350 |
|
|
{
|
1351 |
|
|
if (drvcmd[0]==CMDT_READ_VER) sbp_sleep(HZ); /* fixme */
|
1352 |
|
|
#if 01
|
1353 |
|
|
OUT(CDo_sel_i_d,1);
|
1354 |
|
|
#endif 01
|
1355 |
|
|
if (teac==2)
|
1356 |
|
|
{
|
1357 |
|
|
if ((i=CDi_stat_loop_T()) == -1) break;
|
1358 |
|
|
}
|
1359 |
|
|
else
|
1360 |
|
|
{
|
1361 |
|
|
#if 0
|
1362 |
|
|
OUT(CDo_sel_i_d,1);
|
1363 |
|
|
#endif 0
|
1364 |
|
|
i=inb(CDi_status);
|
1365 |
|
|
}
|
1366 |
|
|
if (!(i&s_not_data_ready)) /* f.e. CMDT_DISKINFO */
|
1367 |
|
|
{
|
1368 |
|
|
OUT(CDo_sel_i_d,1);
|
1369 |
|
|
if (drvcmd[0]==CMDT_READ) return (0); /* handled elsewhere */
|
1370 |
|
|
if (drvcmd[0]==CMDT_DISKINFO)
|
1371 |
|
|
{
|
1372 |
|
|
l=0;
|
1373 |
|
|
do
|
1374 |
|
|
{
|
1375 |
|
|
if (do_16bit)
|
1376 |
|
|
{
|
1377 |
|
|
i=inw(CDi_data);
|
1378 |
|
|
infobuf[l++]=i&0x0ff;
|
1379 |
|
|
infobuf[l++]=i>>8;
|
1380 |
|
|
#if TEST_FALSE_FF
|
1381 |
|
|
if ((l==2)&&(infobuf[0]==0x0ff))
|
1382 |
|
|
{
|
1383 |
|
|
infobuf[0]=infobuf[1];
|
1384 |
|
|
l=1;
|
1385 |
|
|
msg(DBG_TEA,"cmd_out_T: do_16bit: false first byte!\n");
|
1386 |
|
|
}
|
1387 |
|
|
#endif TEST_FALSE_FF
|
1388 |
|
|
}
|
1389 |
|
|
else infobuf[l++]=inb(CDi_data);
|
1390 |
|
|
i=inb(CDi_status);
|
1391 |
|
|
}
|
1392 |
|
|
while (!(i&s_not_data_ready));
|
1393 |
|
|
for (j=0;j<l;j++) sprintf(&msgbuf[j*3]," %02X",infobuf[j]);
|
1394 |
|
|
msgbuf[j*3]=0;
|
1395 |
|
|
msg(DBG_CMD,"cmd_out_T data response:%s\n", msgbuf);
|
1396 |
|
|
}
|
1397 |
|
|
else
|
1398 |
|
|
{
|
1399 |
|
|
msg(DBG_TEA,"cmd_out_T: data response with cmd_%02X!\n",
|
1400 |
|
|
drvcmd[0]);
|
1401 |
|
|
j=0;
|
1402 |
|
|
do
|
1403 |
|
|
{
|
1404 |
|
|
if (do_16bit) i=inw(CDi_data);
|
1405 |
|
|
else i=inb(CDi_data);
|
1406 |
|
|
j++;
|
1407 |
|
|
i=inb(CDi_status);
|
1408 |
|
|
}
|
1409 |
|
|
while (!(i&s_not_data_ready));
|
1410 |
|
|
msg(DBG_TEA,"cmd_out_T: data response: discarded %d bytes/words.\n", j);
|
1411 |
|
|
fatal_err++;
|
1412 |
|
|
}
|
1413 |
|
|
}
|
1414 |
|
|
i=inb(CDi_status);
|
1415 |
|
|
if (!(i&s_not_result_ready))
|
1416 |
|
|
{
|
1417 |
|
|
OUT(CDo_sel_i_d,0);
|
1418 |
|
|
if (drvcmd[0]==CMDT_DISKINFO) m=l;
|
1419 |
|
|
else m=0;
|
1420 |
|
|
do
|
1421 |
|
|
{
|
1422 |
|
|
infobuf[m++]=inb(CDi_info);
|
1423 |
|
|
i=inb(CDi_status);
|
1424 |
|
|
}
|
1425 |
|
|
while (!(i&s_not_result_ready));
|
1426 |
|
|
for (j=0;j<m;j++) sprintf(&msgbuf[j*3]," %02X",infobuf[j]);
|
1427 |
|
|
msgbuf[j*3]=0;
|
1428 |
|
|
msg(DBG_CMD,"cmd_out_T info response:%s\n", msgbuf);
|
1429 |
|
|
if (drvcmd[0]==CMDT_DISKINFO)
|
1430 |
|
|
{
|
1431 |
|
|
infobuf[0]=infobuf[l];
|
1432 |
|
|
if (infobuf[0]!=0x02) return (l); /* data length */
|
1433 |
|
|
}
|
1434 |
|
|
else if (infobuf[0]!=0x02) return (m); /* info length */
|
1435 |
|
|
do
|
1436 |
|
|
{
|
1437 |
|
|
++recursion;
|
1438 |
|
|
if (recursion>1) msg(DBG_TEA,"cmd_out_T READ_ERR recursion (%02X): %d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", drvcmd[0], recursion);
|
1439 |
|
|
clr_cmdbuf();
|
1440 |
|
|
drvcmd[0]=CMDT_READ_ERR;
|
1441 |
|
|
j=cmd_out_T(); /* !!! recursive here !!! */
|
1442 |
|
|
--recursion;
|
1443 |
|
|
sbp_sleep(1);
|
1444 |
|
|
}
|
1445 |
|
|
while (j<0);
|
1446 |
|
|
D_S[d].error_state=infobuf[2];
|
1447 |
|
|
D_S[d].b3=infobuf[3];
|
1448 |
|
|
D_S[d].b4=infobuf[4];
|
1449 |
|
|
if (D_S[d].f_drv_error)
|
1450 |
|
|
{
|
1451 |
|
|
D_S[d].f_drv_error=0;
|
1452 |
|
|
cc_DriveReset();
|
1453 |
|
|
D_S[d].error_state=2;
|
1454 |
|
|
}
|
1455 |
|
|
return (-D_S[d].error_state-400);
|
1456 |
|
|
}
|
1457 |
|
|
if (drvcmd[0]==CMDT_READ) return (0); /* handled elsewhere */
|
1458 |
|
|
if ((teac==0)||(ntries<(CMDT_TRIES-5))) sbp_sleep(HZ/10);
|
1459 |
|
|
else sbp_sleep(HZ/100);
|
1460 |
|
|
if (ntries>(CMDT_TRIES-50)) continue;
|
1461 |
|
|
msg(DBG_TEA,"cmd_out_T: next CMDT_TRIES (%02X): %d.\n", drvcmd[0], ntries-1);
|
1462 |
|
|
}
|
1463 |
|
|
D_S[d].f_drv_error=1;
|
1464 |
|
|
cc_DriveReset();
|
1465 |
|
|
D_S[d].error_state=2;
|
1466 |
|
|
return (-99);
|
1467 |
|
|
}
|
1468 |
|
|
/*==========================================================================*/
|
1469 |
|
|
static int cmd_out(void)
|
1470 |
|
|
{
|
1471 |
|
|
int i=0;
|
1472 |
|
|
|
1473 |
|
|
if (famT_drive) return(cmd_out_T());
|
1474 |
|
|
|
1475 |
|
|
if (flags_cmd_out&f_putcmd)
|
1476 |
|
|
{
|
1477 |
|
|
for (i=0;i<7;i++)
|
1478 |
|
|
sprintf(&msgbuf[i*3], " %02X", drvcmd[i]);
|
1479 |
|
|
msgbuf[i*3]=0;
|
1480 |
|
|
msg(DBG_CMD,"cmd_out:%s\n", msgbuf);
|
1481 |
|
|
cli();
|
1482 |
|
|
for (i=0;i<7;i++) OUT(CDo_command,drvcmd[i]);
|
1483 |
|
|
sti();
|
1484 |
|
|
}
|
1485 |
|
|
if (response_count!=0)
|
1486 |
|
|
{
|
1487 |
|
|
if (cmd_type!=0)
|
1488 |
|
|
{
|
1489 |
|
|
if (sbpro_type==1) OUT(CDo_sel_i_d,1);
|
1490 |
|
|
msg(DBG_INF,"misleaded to try ResponseData.\n");
|
1491 |
|
|
if (sbpro_type==1) OUT(CDo_sel_i_d,0);
|
1492 |
|
|
return (-22);
|
1493 |
|
|
}
|
1494 |
|
|
else i=ResponseInfo();
|
1495 |
|
|
if (i<0) return (i);
|
1496 |
|
|
}
|
1497 |
|
|
if (D_S[d].in_SpinUp) msg(DBG_SPI,"in_SpinUp: to CDi_stat_loop.\n");
|
1498 |
|
|
if (flags_cmd_out&f_lopsta)
|
1499 |
|
|
{
|
1500 |
|
|
i=CDi_stat_loop();
|
1501 |
|
|
if ((i<0)||!(i&s_attention)) return (-8);
|
1502 |
|
|
}
|
1503 |
|
|
if (!(flags_cmd_out&f_getsta)) goto LOC_229;
|
1504 |
|
|
|
1505 |
|
|
LOC_228:
|
1506 |
|
|
if (D_S[d].in_SpinUp) msg(DBG_SPI,"in_SpinUp: to cc_ReadStatus.\n");
|
1507 |
|
|
cc_ReadStatus();
|
1508 |
|
|
|
1509 |
|
|
LOC_229:
|
1510 |
|
|
if (flags_cmd_out&f_ResponseStatus)
|
1511 |
|
|
{
|
1512 |
|
|
if (D_S[d].in_SpinUp) msg(DBG_SPI,"in_SpinUp: to ResponseStatus.\n");
|
1513 |
|
|
i=ResponseStatus();
|
1514 |
|
|
/* builds status_bits, returns orig. status or p_busy_new */
|
1515 |
|
|
if (i<0) return (i);
|
1516 |
|
|
if (flags_cmd_out&(f_bit1|f_wait_if_busy))
|
1517 |
|
|
{
|
1518 |
|
|
if (!st_check)
|
1519 |
|
|
{
|
1520 |
|
|
if ((flags_cmd_out&f_bit1)&&(i&p_success)) goto LOC_232;
|
1521 |
|
|
if ((!(flags_cmd_out&f_wait_if_busy))||(!st_busy)) goto LOC_228;
|
1522 |
|
|
}
|
1523 |
|
|
}
|
1524 |
|
|
}
|
1525 |
|
|
LOC_232:
|
1526 |
|
|
if (!(flags_cmd_out&f_obey_p_check)) return (0);
|
1527 |
|
|
if (!st_check) return (0);
|
1528 |
|
|
if (D_S[d].in_SpinUp) msg(DBG_SPI,"in_SpinUp: to cc_ReadError.\n");
|
1529 |
|
|
i=cc_ReadError();
|
1530 |
|
|
if (D_S[d].in_SpinUp) msg(DBG_SPI,"in_SpinUp: to cmd_out OK.\n");
|
1531 |
|
|
msg(DBG_000,"cmd_out: cc_ReadError=%d\n", i);
|
1532 |
|
|
return (i);
|
1533 |
|
|
}
|
1534 |
|
|
/*==========================================================================*/
|
1535 |
|
|
static int cc_Seek(u_int pos, char f_blk_msf)
|
1536 |
|
|
{
|
1537 |
|
|
int i;
|
1538 |
|
|
|
1539 |
|
|
clr_cmdbuf();
|
1540 |
|
|
if (f_blk_msf>1) return (-3);
|
1541 |
|
|
if (fam0V_drive)
|
1542 |
|
|
{
|
1543 |
|
|
drvcmd[0]=CMD0_SEEK;
|
1544 |
|
|
if (f_blk_msf==1) pos=msf2blk(pos);
|
1545 |
|
|
drvcmd[2]=(pos>>16)&0x00FF;
|
1546 |
|
|
drvcmd[3]=(pos>>8)&0x00FF;
|
1547 |
|
|
drvcmd[4]=pos&0x00FF;
|
1548 |
|
|
if (fam0_drive)
|
1549 |
|
|
flags_cmd_out = f_putcmd | f_respo2 | f_lopsta | f_getsta |
|
1550 |
|
|
f_ResponseStatus | f_obey_p_check | f_bit1;
|
1551 |
|
|
else
|
1552 |
|
|
flags_cmd_out = f_putcmd;
|
1553 |
|
|
}
|
1554 |
|
|
else if (fam1L_drive)
|
1555 |
|
|
{
|
1556 |
|
|
drvcmd[0]=CMD1_SEEK; /* same as CMD1_ and CMDL_ */
|
1557 |
|
|
if (f_blk_msf==0) pos=blk2msf(pos);
|
1558 |
|
|
drvcmd[1]=(pos>>16)&0x00FF;
|
1559 |
|
|
drvcmd[2]=(pos>>8)&0x00FF;
|
1560 |
|
|
drvcmd[3]=pos&0x00FF;
|
1561 |
|
|
if (famL_drive)
|
1562 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_lopsta|f_getsta|f_ResponseStatus|f_obey_p_check|f_bit1;
|
1563 |
|
|
else
|
1564 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_ResponseStatus|f_obey_p_check;
|
1565 |
|
|
}
|
1566 |
|
|
else if (fam2_drive)
|
1567 |
|
|
{
|
1568 |
|
|
drvcmd[0]=CMD2_SEEK;
|
1569 |
|
|
if (f_blk_msf==0) pos=blk2msf(pos);
|
1570 |
|
|
drvcmd[2]=(pos>>24)&0x00FF;
|
1571 |
|
|
drvcmd[3]=(pos>>16)&0x00FF;
|
1572 |
|
|
drvcmd[4]=(pos>>8)&0x00FF;
|
1573 |
|
|
drvcmd[5]=pos&0x00FF;
|
1574 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus;
|
1575 |
|
|
}
|
1576 |
|
|
else if (famT_drive)
|
1577 |
|
|
{
|
1578 |
|
|
drvcmd[0]=CMDT_SEEK;
|
1579 |
|
|
if (f_blk_msf==1) pos=msf2blk(pos);
|
1580 |
|
|
drvcmd[2]=(pos>>24)&0x00FF;
|
1581 |
|
|
drvcmd[3]=(pos>>16)&0x00FF;
|
1582 |
|
|
drvcmd[4]=(pos>>8)&0x00FF;
|
1583 |
|
|
drvcmd[5]=pos&0x00FF;
|
1584 |
|
|
D_S[d].n_bytes=1;
|
1585 |
|
|
}
|
1586 |
|
|
response_count=0;
|
1587 |
|
|
i=cmd_out();
|
1588 |
|
|
return (i);
|
1589 |
|
|
}
|
1590 |
|
|
/*==========================================================================*/
|
1591 |
|
|
static int cc_SpinUp(void)
|
1592 |
|
|
{
|
1593 |
|
|
int i;
|
1594 |
|
|
|
1595 |
|
|
msg(DBG_SPI,"SpinUp.\n");
|
1596 |
|
|
D_S[d].in_SpinUp = 1;
|
1597 |
|
|
clr_cmdbuf();
|
1598 |
|
|
if (fam0LV_drive)
|
1599 |
|
|
{
|
1600 |
|
|
drvcmd[0]=CMD0_SPINUP;
|
1601 |
|
|
if (fam0L_drive)
|
1602 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_lopsta|f_getsta|
|
1603 |
|
|
f_ResponseStatus|f_obey_p_check|f_bit1;
|
1604 |
|
|
else
|
1605 |
|
|
flags_cmd_out=f_putcmd;
|
1606 |
|
|
}
|
1607 |
|
|
else if (fam1_drive)
|
1608 |
|
|
{
|
1609 |
|
|
drvcmd[0]=CMD1_SPINUP;
|
1610 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_ResponseStatus|f_obey_p_check;
|
1611 |
|
|
}
|
1612 |
|
|
else if (fam2_drive)
|
1613 |
|
|
{
|
1614 |
|
|
drvcmd[0]=CMD2_TRAY_CTL;
|
1615 |
|
|
drvcmd[4]=0x01; /* "spinup" */
|
1616 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_ResponseStatus|f_obey_p_check;
|
1617 |
|
|
}
|
1618 |
|
|
else if (famT_drive)
|
1619 |
|
|
{
|
1620 |
|
|
drvcmd[0]=CMDT_TRAY_CTL;
|
1621 |
|
|
drvcmd[4]=0x03; /* "insert", it hopefully spins the drive up */
|
1622 |
|
|
}
|
1623 |
|
|
response_count=0;
|
1624 |
|
|
i=cmd_out();
|
1625 |
|
|
D_S[d].in_SpinUp = 0;
|
1626 |
|
|
return (i);
|
1627 |
|
|
}
|
1628 |
|
|
/*==========================================================================*/
|
1629 |
|
|
static int cc_SpinDown(void)
|
1630 |
|
|
{
|
1631 |
|
|
int i;
|
1632 |
|
|
|
1633 |
|
|
if (fam0_drive) return (0);
|
1634 |
|
|
clr_cmdbuf();
|
1635 |
|
|
response_count=0;
|
1636 |
|
|
if (fam1_drive)
|
1637 |
|
|
{
|
1638 |
|
|
drvcmd[0]=CMD1_SPINDOWN;
|
1639 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_ResponseStatus|f_obey_p_check;
|
1640 |
|
|
}
|
1641 |
|
|
else if (fam2_drive)
|
1642 |
|
|
{
|
1643 |
|
|
drvcmd[0]=CMD2_TRAY_CTL;
|
1644 |
|
|
drvcmd[4]=0x02; /* "eject" */
|
1645 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus;
|
1646 |
|
|
}
|
1647 |
|
|
else if (famL_drive)
|
1648 |
|
|
{
|
1649 |
|
|
drvcmd[0]=CMDL_SPINDOWN;
|
1650 |
|
|
drvcmd[1]=1;
|
1651 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_lopsta|f_getsta|f_ResponseStatus|f_obey_p_check|f_bit1;
|
1652 |
|
|
}
|
1653 |
|
|
else if (famV_drive)
|
1654 |
|
|
{
|
1655 |
|
|
drvcmd[0]=CMDV_SPINDOWN;
|
1656 |
|
|
flags_cmd_out=f_putcmd;
|
1657 |
|
|
}
|
1658 |
|
|
else if (famT_drive)
|
1659 |
|
|
{
|
1660 |
|
|
drvcmd[0]=CMDT_TRAY_CTL;
|
1661 |
|
|
drvcmd[4]=0x02; /* "eject" */
|
1662 |
|
|
}
|
1663 |
|
|
i=cmd_out();
|
1664 |
|
|
return (i);
|
1665 |
|
|
}
|
1666 |
|
|
/*==========================================================================*/
|
1667 |
|
|
static int cc_get_mode_T(void)
|
1668 |
|
|
{
|
1669 |
|
|
int i;
|
1670 |
|
|
|
1671 |
|
|
clr_cmdbuf();
|
1672 |
|
|
response_count=10;
|
1673 |
|
|
drvcmd[0]=CMDT_GETMODE;
|
1674 |
|
|
drvcmd[4]=response_count;
|
1675 |
|
|
i=cmd_out_T();
|
1676 |
|
|
return (i);
|
1677 |
|
|
}
|
1678 |
|
|
/*==========================================================================*/
|
1679 |
|
|
static int cc_set_mode_T(void)
|
1680 |
|
|
{
|
1681 |
|
|
int i;
|
1682 |
|
|
|
1683 |
|
|
clr_cmdbuf();
|
1684 |
|
|
response_count=1;
|
1685 |
|
|
drvcmd[0]=CMDT_SETMODE;
|
1686 |
|
|
drvcmd[1]=D_S[d].speed_byte;
|
1687 |
|
|
drvcmd[2]=D_S[d].frmsiz>>8;
|
1688 |
|
|
drvcmd[3]=D_S[d].frmsiz&0x0FF;
|
1689 |
|
|
drvcmd[4]=D_S[d].f_XA; /* 1: XA */
|
1690 |
|
|
drvcmd[5]=D_S[d].type_byte; /* 0, 1, 3 */
|
1691 |
|
|
drvcmd[6]=D_S[d].mode_xb_6;
|
1692 |
|
|
drvcmd[7]=D_S[d].mode_yb_7|D_S[d].volume_control;
|
1693 |
|
|
drvcmd[8]=D_S[d].mode_xb_8;
|
1694 |
|
|
drvcmd[9]=D_S[d].delay;
|
1695 |
|
|
i=cmd_out_T();
|
1696 |
|
|
return (i);
|
1697 |
|
|
}
|
1698 |
|
|
/*==========================================================================*/
|
1699 |
|
|
static int cc_prep_mode_T(void)
|
1700 |
|
|
{
|
1701 |
|
|
int i, j;
|
1702 |
|
|
|
1703 |
|
|
i=cc_get_mode_T();
|
1704 |
|
|
if (i<0) return (i);
|
1705 |
|
|
for (i=0;i<10;i++)
|
1706 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
1707 |
|
|
msgbuf[i*3]=0;
|
1708 |
|
|
msg(DBG_TEA,"CMDT_GETMODE:%s\n", msgbuf);
|
1709 |
|
|
D_S[d].speed_byte=0x02; /* 0x02: auto quad, 0x82: quad, 0x81: double, 0x80: single */
|
1710 |
|
|
D_S[d].frmsiz=make16(infobuf[2],infobuf[3]);
|
1711 |
|
|
D_S[d].f_XA=infobuf[4];
|
1712 |
|
|
if (D_S[d].f_XA==0) D_S[d].type_byte=0;
|
1713 |
|
|
else D_S[d].type_byte=1;
|
1714 |
|
|
D_S[d].mode_xb_6=infobuf[6];
|
1715 |
|
|
D_S[d].mode_yb_7=1;
|
1716 |
|
|
D_S[d].mode_xb_8=infobuf[8];
|
1717 |
|
|
D_S[d].delay=0; /* 0, 1, 2, 3 */
|
1718 |
|
|
j=cc_set_mode_T();
|
1719 |
|
|
i=cc_get_mode_T();
|
1720 |
|
|
for (i=0;i<10;i++)
|
1721 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
1722 |
|
|
msgbuf[i*3]=0;
|
1723 |
|
|
msg(DBG_TEA,"CMDT_GETMODE:%s\n", msgbuf);
|
1724 |
|
|
return (j);
|
1725 |
|
|
}
|
1726 |
|
|
/*==========================================================================*/
|
1727 |
|
|
static int cc_SetSpeed(u_char speed, u_char x1, u_char x2)
|
1728 |
|
|
{
|
1729 |
|
|
int i;
|
1730 |
|
|
|
1731 |
|
|
if (fam0LV_drive) return (0);
|
1732 |
|
|
clr_cmdbuf();
|
1733 |
|
|
response_count=0;
|
1734 |
|
|
if (fam1_drive)
|
1735 |
|
|
{
|
1736 |
|
|
drvcmd[0]=CMD1_SETMODE;
|
1737 |
|
|
drvcmd[1]=0x03;
|
1738 |
|
|
drvcmd[2]=speed;
|
1739 |
|
|
drvcmd[3]=x1;
|
1740 |
|
|
drvcmd[4]=x2;
|
1741 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
1742 |
|
|
}
|
1743 |
|
|
else if (fam2_drive)
|
1744 |
|
|
{
|
1745 |
|
|
drvcmd[0]=CMD2_SETSPEED;
|
1746 |
|
|
if (speed&speed_auto)
|
1747 |
|
|
{
|
1748 |
|
|
drvcmd[2]=0xFF;
|
1749 |
|
|
drvcmd[3]=0xFF;
|
1750 |
|
|
}
|
1751 |
|
|
else
|
1752 |
|
|
{
|
1753 |
|
|
drvcmd[2]=0;
|
1754 |
|
|
drvcmd[3]=150;
|
1755 |
|
|
}
|
1756 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
1757 |
|
|
}
|
1758 |
|
|
else if (famT_drive)
|
1759 |
|
|
{
|
1760 |
|
|
return (0);
|
1761 |
|
|
}
|
1762 |
|
|
i=cmd_out();
|
1763 |
|
|
return (i);
|
1764 |
|
|
}
|
1765 |
|
|
/*==========================================================================*/
|
1766 |
|
|
static int cc_SetVolume(void)
|
1767 |
|
|
{
|
1768 |
|
|
int i;
|
1769 |
|
|
u_char channel0,channel1,volume0,volume1;
|
1770 |
|
|
u_char control0,value0,control1,value1;
|
1771 |
|
|
|
1772 |
|
|
D_S[d].diskstate_flags &= ~volume_bit;
|
1773 |
|
|
clr_cmdbuf();
|
1774 |
|
|
channel0=D_S[d].vol_chan0;
|
1775 |
|
|
volume0=D_S[d].vol_ctrl0;
|
1776 |
|
|
channel1=control1=D_S[d].vol_chan1;
|
1777 |
|
|
volume1=value1=D_S[d].vol_ctrl1;
|
1778 |
|
|
control0=value0=0;
|
1779 |
|
|
|
1780 |
|
|
if (famV_drive) return (0);
|
1781 |
|
|
|
1782 |
|
|
if (((D_S[d].drv_options&audio_mono)!=0)&&(D_S[d].drv_type>=drv_211))
|
1783 |
|
|
{
|
1784 |
|
|
if ((volume0!=0)&&(volume1==0))
|
1785 |
|
|
{
|
1786 |
|
|
volume1=volume0;
|
1787 |
|
|
channel1=channel0;
|
1788 |
|
|
}
|
1789 |
|
|
else if ((volume0==0)&&(volume1!=0))
|
1790 |
|
|
{
|
1791 |
|
|
volume0=volume1;
|
1792 |
|
|
channel0=channel1;
|
1793 |
|
|
}
|
1794 |
|
|
}
|
1795 |
|
|
if (channel0>1)
|
1796 |
|
|
{
|
1797 |
|
|
channel0=0;
|
1798 |
|
|
volume0=0;
|
1799 |
|
|
}
|
1800 |
|
|
if (channel1>1)
|
1801 |
|
|
{
|
1802 |
|
|
channel1=1;
|
1803 |
|
|
volume1=0;
|
1804 |
|
|
}
|
1805 |
|
|
|
1806 |
|
|
if (fam1_drive)
|
1807 |
|
|
{
|
1808 |
|
|
control0=channel0+1;
|
1809 |
|
|
control1=channel1+1;
|
1810 |
|
|
value0=(volume0>volume1)?volume0:volume1;
|
1811 |
|
|
value1=value0;
|
1812 |
|
|
if (volume0==0) control0=0;
|
1813 |
|
|
if (volume1==0) control1=0;
|
1814 |
|
|
drvcmd[0]=CMD1_SETMODE;
|
1815 |
|
|
drvcmd[1]=0x05;
|
1816 |
|
|
drvcmd[3]=control0;
|
1817 |
|
|
drvcmd[4]=value0;
|
1818 |
|
|
drvcmd[5]=control1;
|
1819 |
|
|
drvcmd[6]=value1;
|
1820 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
1821 |
|
|
}
|
1822 |
|
|
else if (fam2_drive)
|
1823 |
|
|
{
|
1824 |
|
|
control0=channel0+1;
|
1825 |
|
|
control1=channel1+1;
|
1826 |
|
|
value0=(volume0>volume1)?volume0:volume1;
|
1827 |
|
|
value1=value0;
|
1828 |
|
|
if (volume0==0) control0=0;
|
1829 |
|
|
if (volume1==0) control1=0;
|
1830 |
|
|
drvcmd[0]=CMD2_SETMODE;
|
1831 |
|
|
drvcmd[1]=0x0E;
|
1832 |
|
|
drvcmd[3]=control0;
|
1833 |
|
|
drvcmd[4]=value0;
|
1834 |
|
|
drvcmd[5]=control1;
|
1835 |
|
|
drvcmd[6]=value1;
|
1836 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus;
|
1837 |
|
|
}
|
1838 |
|
|
else if (famL_drive)
|
1839 |
|
|
{
|
1840 |
|
|
if ((volume0==0)||(channel0!=0)) control0 |= 0x80;
|
1841 |
|
|
if ((volume1==0)||(channel1!=1)) control0 |= 0x40;
|
1842 |
|
|
if (volume0|volume1) value0=0x80;
|
1843 |
|
|
drvcmd[0]=CMDL_SETMODE;
|
1844 |
|
|
drvcmd[1]=0x03;
|
1845 |
|
|
drvcmd[4]=control0;
|
1846 |
|
|
drvcmd[5]=value0;
|
1847 |
|
|
flags_cmd_out=f_putcmd|f_lopsta|f_getsta|f_ResponseStatus|f_obey_p_check|f_bit1;
|
1848 |
|
|
}
|
1849 |
|
|
else if (fam0_drive) /* different firmware levels */
|
1850 |
|
|
{
|
1851 |
|
|
if (D_S[d].drv_type>=drv_300)
|
1852 |
|
|
{
|
1853 |
|
|
control0=volume0&0xFC;
|
1854 |
|
|
value0=volume1&0xFC;
|
1855 |
|
|
if ((volume0!=0)&&(volume0<4)) control0 |= 0x04;
|
1856 |
|
|
if ((volume1!=0)&&(volume1<4)) value0 |= 0x04;
|
1857 |
|
|
if (channel0!=0) control0 |= 0x01;
|
1858 |
|
|
if (channel1==1) value0 |= 0x01;
|
1859 |
|
|
}
|
1860 |
|
|
else
|
1861 |
|
|
{
|
1862 |
|
|
value0=(volume0>volume1)?volume0:volume1;
|
1863 |
|
|
if (D_S[d].drv_type<drv_211)
|
1864 |
|
|
{
|
1865 |
|
|
if (channel0!=0)
|
1866 |
|
|
{
|
1867 |
|
|
i=channel1;
|
1868 |
|
|
channel1=channel0;
|
1869 |
|
|
channel0=i;
|
1870 |
|
|
i=volume1;
|
1871 |
|
|
volume1=volume0;
|
1872 |
|
|
volume0=i;
|
1873 |
|
|
}
|
1874 |
|
|
if (channel0==channel1)
|
1875 |
|
|
{
|
1876 |
|
|
if (channel0==0)
|
1877 |
|
|
{
|
1878 |
|
|
channel1=1;
|
1879 |
|
|
volume1=0;
|
1880 |
|
|
volume0=value0;
|
1881 |
|
|
}
|
1882 |
|
|
else
|
1883 |
|
|
{
|
1884 |
|
|
channel0=0;
|
1885 |
|
|
volume0=0;
|
1886 |
|
|
volume1=value0;
|
1887 |
|
|
}
|
1888 |
|
|
}
|
1889 |
|
|
}
|
1890 |
|
|
|
1891 |
|
|
if ((volume0!=0)&&(volume1!=0))
|
1892 |
|
|
{
|
1893 |
|
|
if (volume0==0xFF) volume1=0xFF;
|
1894 |
|
|
else if (volume1==0xFF) volume0=0xFF;
|
1895 |
|
|
}
|
1896 |
|
|
else if (D_S[d].drv_type<drv_201) volume0=volume1=value0;
|
1897 |
|
|
|
1898 |
|
|
if (D_S[d].drv_type>=drv_201)
|
1899 |
|
|
{
|
1900 |
|
|
if (volume0==0) control0 |= 0x80;
|
1901 |
|
|
if (volume1==0) control0 |= 0x40;
|
1902 |
|
|
}
|
1903 |
|
|
if (D_S[d].drv_type>=drv_211)
|
1904 |
|
|
{
|
1905 |
|
|
if (channel0!=0) control0 |= 0x20;
|
1906 |
|
|
if (channel1!=1) control0 |= 0x10;
|
1907 |
|
|
}
|
1908 |
|
|
}
|
1909 |
|
|
drvcmd[0]=CMD0_SETMODE;
|
1910 |
|
|
drvcmd[1]=0x83;
|
1911 |
|
|
drvcmd[4]=control0;
|
1912 |
|
|
drvcmd[5]=value0;
|
1913 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
1914 |
|
|
}
|
1915 |
|
|
else if (famT_drive)
|
1916 |
|
|
{
|
1917 |
|
|
D_S[d].volume_control=0;
|
1918 |
|
|
if (!volume0) D_S[d].volume_control|=0x10;
|
1919 |
|
|
if (!volume1) D_S[d].volume_control|=0x20;
|
1920 |
|
|
i=cc_prep_mode_T();
|
1921 |
|
|
if (i<0) return (i);
|
1922 |
|
|
}
|
1923 |
|
|
if (!famT_drive)
|
1924 |
|
|
{
|
1925 |
|
|
response_count=0;
|
1926 |
|
|
i=cmd_out();
|
1927 |
|
|
if (i<0) return (i);
|
1928 |
|
|
}
|
1929 |
|
|
D_S[d].diskstate_flags |= volume_bit;
|
1930 |
|
|
return (0);
|
1931 |
|
|
}
|
1932 |
|
|
/*==========================================================================*/
|
1933 |
|
|
static int GetStatus(void)
|
1934 |
|
|
{
|
1935 |
|
|
int i;
|
1936 |
|
|
|
1937 |
|
|
if (famT_drive) return (0);
|
1938 |
|
|
flags_cmd_out=f_getsta|f_ResponseStatus|f_obey_p_check;
|
1939 |
|
|
response_count=0;
|
1940 |
|
|
cmd_type=0;
|
1941 |
|
|
i=cmd_out();
|
1942 |
|
|
return (i);
|
1943 |
|
|
}
|
1944 |
|
|
/*==========================================================================*/
|
1945 |
|
|
static int cc_DriveReset(void)
|
1946 |
|
|
{
|
1947 |
|
|
int i;
|
1948 |
|
|
|
1949 |
|
|
msg(DBG_RES,"cc_DriveReset called.\n");
|
1950 |
|
|
clr_cmdbuf();
|
1951 |
|
|
response_count=0;
|
1952 |
|
|
if (fam0LV_drive) OUT(CDo_reset,0x00);
|
1953 |
|
|
else if (fam1_drive)
|
1954 |
|
|
{
|
1955 |
|
|
drvcmd[0]=CMD1_RESET;
|
1956 |
|
|
flags_cmd_out=f_putcmd;
|
1957 |
|
|
i=cmd_out();
|
1958 |
|
|
}
|
1959 |
|
|
else if (fam2_drive)
|
1960 |
|
|
{
|
1961 |
|
|
drvcmd[0]=CMD2_RESET;
|
1962 |
|
|
flags_cmd_out=f_putcmd;
|
1963 |
|
|
i=cmd_out();
|
1964 |
|
|
OUT(CDo_reset,0x00);
|
1965 |
|
|
}
|
1966 |
|
|
else if (famT_drive)
|
1967 |
|
|
{
|
1968 |
|
|
OUT(CDo_sel_i_d,0);
|
1969 |
|
|
OUT(CDo_enable,D_S[d].drv_sel);
|
1970 |
|
|
OUT(CDo_command,CMDT_RESET);
|
1971 |
|
|
for (i=1;i<10;i++) OUT(CDo_command,0);
|
1972 |
|
|
}
|
1973 |
|
|
if (fam0LV_drive) sbp_sleep(5*HZ); /* wait 5 seconds */
|
1974 |
|
|
else sbp_sleep(1*HZ); /* wait a second */
|
1975 |
|
|
#if 1
|
1976 |
|
|
if (famT_drive)
|
1977 |
|
|
{
|
1978 |
|
|
msg(DBG_TEA, "================CMDT_RESET given=================.\n");
|
1979 |
|
|
sbp_sleep(3*HZ);
|
1980 |
|
|
}
|
1981 |
|
|
#endif 1
|
1982 |
|
|
flush_status();
|
1983 |
|
|
i=GetStatus();
|
1984 |
|
|
if (i<0) return i;
|
1985 |
|
|
if (!famT_drive)
|
1986 |
|
|
if (D_S[d].error_byte!=aud_12) return -501;
|
1987 |
|
|
return (0);
|
1988 |
|
|
}
|
1989 |
|
|
/*==========================================================================*/
|
1990 |
|
|
static int SetSpeed(void)
|
1991 |
|
|
{
|
1992 |
|
|
int i, speed;
|
1993 |
|
|
|
1994 |
|
|
if (!(D_S[d].drv_options&(speed_auto|speed_300|speed_150))) return (0);
|
1995 |
|
|
speed=speed_auto;
|
1996 |
|
|
if (!(D_S[d].drv_options&speed_auto))
|
1997 |
|
|
{
|
1998 |
|
|
speed |= speed_300;
|
1999 |
|
|
if (!(D_S[d].drv_options&speed_300)) speed=0;
|
2000 |
|
|
}
|
2001 |
|
|
i=cc_SetSpeed(speed,0,0);
|
2002 |
|
|
return (i);
|
2003 |
|
|
}
|
2004 |
|
|
/*==========================================================================*/
|
2005 |
|
|
static int DriveReset(void)
|
2006 |
|
|
{
|
2007 |
|
|
int i;
|
2008 |
|
|
|
2009 |
|
|
i=cc_DriveReset();
|
2010 |
|
|
if (i<0) return (-22);
|
2011 |
|
|
do
|
2012 |
|
|
{
|
2013 |
|
|
i=GetStatus();
|
2014 |
|
|
if ((i<0)&&(i!=-ERR_DISKCHANGE)) return (-2); /* from sta2err */
|
2015 |
|
|
if (!st_caddy_in) break;
|
2016 |
|
|
sbp_sleep(1);
|
2017 |
|
|
}
|
2018 |
|
|
while (!st_diskok);
|
2019 |
|
|
#if 000
|
2020 |
|
|
D_S[d].CD_changed=1;
|
2021 |
|
|
#endif
|
2022 |
|
|
if ((st_door_closed) && (st_caddy_in))
|
2023 |
|
|
{
|
2024 |
|
|
i=DiskInfo();
|
2025 |
|
|
if (i<0) return (-23);
|
2026 |
|
|
}
|
2027 |
|
|
return (0);
|
2028 |
|
|
}
|
2029 |
|
|
/*==========================================================================*/
|
2030 |
|
|
static int cc_PlayAudio(int pos_audio_start,int pos_audio_end)
|
2031 |
|
|
{
|
2032 |
|
|
int i, j, n;
|
2033 |
|
|
|
2034 |
|
|
if (D_S[d].audio_state==audio_playing) return (-EINVAL);
|
2035 |
|
|
clr_cmdbuf();
|
2036 |
|
|
response_count=0;
|
2037 |
|
|
if (famLV_drive)
|
2038 |
|
|
{
|
2039 |
|
|
drvcmd[0]=CMDL_PLAY;
|
2040 |
|
|
i=msf2blk(pos_audio_start);
|
2041 |
|
|
n=msf2blk(pos_audio_end)+1-i;
|
2042 |
|
|
drvcmd[1]=(i>>16)&0x00FF;
|
2043 |
|
|
drvcmd[2]=(i>>8)&0x00FF;
|
2044 |
|
|
drvcmd[3]=i&0x00FF;
|
2045 |
|
|
drvcmd[4]=(n>>16)&0x00FF;
|
2046 |
|
|
drvcmd[5]=(n>>8)&0x00FF;
|
2047 |
|
|
drvcmd[6]=n&0x00FF;
|
2048 |
|
|
if (famL_drive)
|
2049 |
|
|
flags_cmd_out = f_putcmd | f_respo2 | f_lopsta | f_getsta |
|
2050 |
|
|
f_ResponseStatus | f_obey_p_check | f_wait_if_busy;
|
2051 |
|
|
else
|
2052 |
|
|
flags_cmd_out = f_putcmd;
|
2053 |
|
|
}
|
2054 |
|
|
else
|
2055 |
|
|
{
|
2056 |
|
|
j=1;
|
2057 |
|
|
if (fam1_drive)
|
2058 |
|
|
{
|
2059 |
|
|
drvcmd[0]=CMD1_PLAY_MSF;
|
2060 |
|
|
flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus |
|
2061 |
|
|
f_obey_p_check | f_wait_if_busy;
|
2062 |
|
|
}
|
2063 |
|
|
else if (fam2_drive)
|
2064 |
|
|
{
|
2065 |
|
|
drvcmd[0]=CMD2_PLAY_MSF;
|
2066 |
|
|
flags_cmd_out = f_putcmd | f_ResponseStatus | f_obey_p_check;
|
2067 |
|
|
}
|
2068 |
|
|
else if (famT_drive)
|
2069 |
|
|
{
|
2070 |
|
|
drvcmd[0]=CMDT_PLAY_MSF;
|
2071 |
|
|
j=3;
|
2072 |
|
|
response_count=1;
|
2073 |
|
|
}
|
2074 |
|
|
else if (fam0_drive)
|
2075 |
|
|
{
|
2076 |
|
|
drvcmd[0]=CMD0_PLAY_MSF;
|
2077 |
|
|
flags_cmd_out = f_putcmd | f_respo2 | f_lopsta | f_getsta |
|
2078 |
|
|
f_ResponseStatus | f_obey_p_check | f_wait_if_busy;
|
2079 |
|
|
}
|
2080 |
|
|
drvcmd[j]=(pos_audio_start>>16)&0x00FF;
|
2081 |
|
|
drvcmd[j+1]=(pos_audio_start>>8)&0x00FF;
|
2082 |
|
|
drvcmd[j+2]=pos_audio_start&0x00FF;
|
2083 |
|
|
drvcmd[j+3]=(pos_audio_end>>16)&0x00FF;
|
2084 |
|
|
drvcmd[j+4]=(pos_audio_end>>8)&0x00FF;
|
2085 |
|
|
drvcmd[j+5]=pos_audio_end&0x00FF;
|
2086 |
|
|
}
|
2087 |
|
|
i=cmd_out();
|
2088 |
|
|
return (i);
|
2089 |
|
|
}
|
2090 |
|
|
/*==========================================================================*/
|
2091 |
|
|
static int cc_Pause_Resume(int pau_res)
|
2092 |
|
|
{
|
2093 |
|
|
int i;
|
2094 |
|
|
|
2095 |
|
|
clr_cmdbuf();
|
2096 |
|
|
response_count=0;
|
2097 |
|
|
if (fam1_drive)
|
2098 |
|
|
{
|
2099 |
|
|
drvcmd[0]=CMD1_PAU_RES;
|
2100 |
|
|
if (pau_res!=1) drvcmd[1]=0x80;
|
2101 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_ResponseStatus|f_obey_p_check;
|
2102 |
|
|
}
|
2103 |
|
|
else if (fam2_drive)
|
2104 |
|
|
{
|
2105 |
|
|
drvcmd[0]=CMD2_PAU_RES;
|
2106 |
|
|
if (pau_res!=1) drvcmd[2]=0x01;
|
2107 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus;
|
2108 |
|
|
}
|
2109 |
|
|
else if (fam0LV_drive)
|
2110 |
|
|
{
|
2111 |
|
|
drvcmd[0]=CMD0_PAU_RES;
|
2112 |
|
|
if (pau_res!=1) drvcmd[1]=0x80;
|
2113 |
|
|
if (famL_drive)
|
2114 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_lopsta|f_getsta|f_ResponseStatus|
|
2115 |
|
|
f_obey_p_check|f_bit1;
|
2116 |
|
|
else if (famV_drive)
|
2117 |
|
|
flags_cmd_out=f_putcmd;
|
2118 |
|
|
else
|
2119 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_lopsta|f_getsta|f_ResponseStatus|
|
2120 |
|
|
f_obey_p_check;
|
2121 |
|
|
}
|
2122 |
|
|
else if (famT_drive)
|
2123 |
|
|
{
|
2124 |
|
|
if (pau_res==3) return (cc_PlayAudio(D_S[d].pos_audio_start,D_S[d].pos_audio_end));
|
2125 |
|
|
else if (pau_res==1) drvcmd[0]=CMDT_PAUSE;
|
2126 |
|
|
else return (-56);
|
2127 |
|
|
}
|
2128 |
|
|
i=cmd_out();
|
2129 |
|
|
return (i);
|
2130 |
|
|
}
|
2131 |
|
|
/*==========================================================================*/
|
2132 |
|
|
static int cc_LockDoor(char lock)
|
2133 |
|
|
{
|
2134 |
|
|
int i;
|
2135 |
|
|
|
2136 |
|
|
if (fam0_drive) return (0);
|
2137 |
|
|
msg(DBG_LCK,"cc_LockDoor: %d (drive %d)\n", lock, d);
|
2138 |
|
|
msg(DBG_LCS,"p_door_locked bit %d before\n", st_door_locked);
|
2139 |
|
|
clr_cmdbuf();
|
2140 |
|
|
response_count=0;
|
2141 |
|
|
if (fam1_drive)
|
2142 |
|
|
{
|
2143 |
|
|
drvcmd[0]=CMD1_LOCK_CTL;
|
2144 |
|
|
if (lock==1) drvcmd[1]=0x01;
|
2145 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2146 |
|
|
}
|
2147 |
|
|
else if (fam2_drive)
|
2148 |
|
|
{
|
2149 |
|
|
drvcmd[0]=CMD2_LOCK_CTL;
|
2150 |
|
|
if (lock==1) drvcmd[4]=0x01;
|
2151 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus;
|
2152 |
|
|
}
|
2153 |
|
|
else if (famLV_drive)
|
2154 |
|
|
{
|
2155 |
|
|
drvcmd[0]=CMDL_LOCK_CTL;
|
2156 |
|
|
if (lock==1) drvcmd[1]=0x01;
|
2157 |
|
|
if (famL_drive)
|
2158 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_lopsta|f_getsta|f_ResponseStatus|f_obey_p_check|f_bit1;
|
2159 |
|
|
else
|
2160 |
|
|
flags_cmd_out=f_putcmd;
|
2161 |
|
|
}
|
2162 |
|
|
else if (famT_drive)
|
2163 |
|
|
{
|
2164 |
|
|
drvcmd[0]=CMDT_LOCK_CTL;
|
2165 |
|
|
if (lock==1) drvcmd[4]=0x01;
|
2166 |
|
|
}
|
2167 |
|
|
i=cmd_out();
|
2168 |
|
|
msg(DBG_LCS,"p_door_locked bit %d after\n", st_door_locked);
|
2169 |
|
|
return (i);
|
2170 |
|
|
}
|
2171 |
|
|
/*==========================================================================*/
|
2172 |
|
|
/*==========================================================================*/
|
2173 |
|
|
static int UnLockDoor(void)
|
2174 |
|
|
{
|
2175 |
|
|
int i,j;
|
2176 |
|
|
|
2177 |
|
|
j=20;
|
2178 |
|
|
do
|
2179 |
|
|
{
|
2180 |
|
|
i=cc_LockDoor(0);
|
2181 |
|
|
--j;
|
2182 |
|
|
sbp_sleep(1);
|
2183 |
|
|
}
|
2184 |
|
|
while ((i<0)&&(j));
|
2185 |
|
|
if (i<0)
|
2186 |
|
|
{
|
2187 |
|
|
cc_DriveReset();
|
2188 |
|
|
return -84;
|
2189 |
|
|
}
|
2190 |
|
|
return (0);
|
2191 |
|
|
}
|
2192 |
|
|
/*==========================================================================*/
|
2193 |
|
|
static int LockDoor(void)
|
2194 |
|
|
{
|
2195 |
|
|
int i,j;
|
2196 |
|
|
|
2197 |
|
|
j=20;
|
2198 |
|
|
do
|
2199 |
|
|
{
|
2200 |
|
|
i=cc_LockDoor(1);
|
2201 |
|
|
--j;
|
2202 |
|
|
sbp_sleep(1);
|
2203 |
|
|
}
|
2204 |
|
|
while ((i<0)&&(j));
|
2205 |
|
|
if (j==0)
|
2206 |
|
|
{
|
2207 |
|
|
cc_DriveReset();
|
2208 |
|
|
j=20;
|
2209 |
|
|
do
|
2210 |
|
|
{
|
2211 |
|
|
i=cc_LockDoor(1);
|
2212 |
|
|
--j;
|
2213 |
|
|
sbp_sleep(1);
|
2214 |
|
|
}
|
2215 |
|
|
while ((i<0)&&(j));
|
2216 |
|
|
}
|
2217 |
|
|
return (i);
|
2218 |
|
|
}
|
2219 |
|
|
/*==========================================================================*/
|
2220 |
|
|
static int cc_CloseTray(void)
|
2221 |
|
|
{
|
2222 |
|
|
int i;
|
2223 |
|
|
|
2224 |
|
|
if (fam0_drive) return (0);
|
2225 |
|
|
msg(DBG_LCK,"cc_CloseTray (drive %d)\n", d);
|
2226 |
|
|
msg(DBG_LCS,"p_door_closed bit %d before\n", st_door_closed);
|
2227 |
|
|
|
2228 |
|
|
clr_cmdbuf();
|
2229 |
|
|
response_count=0;
|
2230 |
|
|
if (fam1_drive)
|
2231 |
|
|
{
|
2232 |
|
|
drvcmd[0]=CMD1_TRAY_CTL;
|
2233 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_ResponseStatus|f_obey_p_check;
|
2234 |
|
|
}
|
2235 |
|
|
else if (fam2_drive)
|
2236 |
|
|
{
|
2237 |
|
|
drvcmd[0]=CMD2_TRAY_CTL;
|
2238 |
|
|
drvcmd[1]=0x01;
|
2239 |
|
|
drvcmd[4]=0x03; /* "insert" */
|
2240 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus;
|
2241 |
|
|
}
|
2242 |
|
|
else if (famLV_drive)
|
2243 |
|
|
{
|
2244 |
|
|
drvcmd[0]=CMDL_TRAY_CTL;
|
2245 |
|
|
if (famLV_drive)
|
2246 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_lopsta|f_getsta|
|
2247 |
|
|
f_ResponseStatus|f_obey_p_check|f_bit1;
|
2248 |
|
|
else
|
2249 |
|
|
flags_cmd_out=f_putcmd;
|
2250 |
|
|
}
|
2251 |
|
|
else if (famT_drive)
|
2252 |
|
|
{
|
2253 |
|
|
drvcmd[0]=CMDT_TRAY_CTL;
|
2254 |
|
|
drvcmd[4]=0x03; /* "insert" */
|
2255 |
|
|
}
|
2256 |
|
|
i=cmd_out();
|
2257 |
|
|
msg(DBG_LCS,"p_door_closed bit %d after\n", st_door_closed);
|
2258 |
|
|
return (i);
|
2259 |
|
|
}
|
2260 |
|
|
/*==========================================================================*/
|
2261 |
|
|
static int cc_ReadSubQ(void)
|
2262 |
|
|
{
|
2263 |
|
|
int i,j;
|
2264 |
|
|
|
2265 |
|
|
D_S[d].diskstate_flags &= ~subq_bit;
|
2266 |
|
|
for (j=255;j>0;j--)
|
2267 |
|
|
{
|
2268 |
|
|
clr_cmdbuf();
|
2269 |
|
|
if (fam1_drive)
|
2270 |
|
|
{
|
2271 |
|
|
drvcmd[0]=CMD1_READSUBQ;
|
2272 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2273 |
|
|
response_count=11;
|
2274 |
|
|
}
|
2275 |
|
|
else if (fam2_drive)
|
2276 |
|
|
{
|
2277 |
|
|
drvcmd[0]=CMD2_READSUBQ;
|
2278 |
|
|
drvcmd[1]=0x02;
|
2279 |
|
|
drvcmd[3]=0x01;
|
2280 |
|
|
flags_cmd_out=f_putcmd;
|
2281 |
|
|
response_count=10;
|
2282 |
|
|
}
|
2283 |
|
|
else if (fam0LV_drive)
|
2284 |
|
|
{
|
2285 |
|
|
drvcmd[0]=CMD0_READSUBQ;
|
2286 |
|
|
drvcmd[1]=0x02;
|
2287 |
|
|
if (famLV_drive)
|
2288 |
|
|
flags_cmd_out=f_putcmd;
|
2289 |
|
|
else
|
2290 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2291 |
|
|
response_count=13;
|
2292 |
|
|
}
|
2293 |
|
|
else if (famT_drive)
|
2294 |
|
|
{
|
2295 |
|
|
response_count=12;
|
2296 |
|
|
drvcmd[0]=CMDT_READSUBQ;
|
2297 |
|
|
drvcmd[1]=0x02;
|
2298 |
|
|
drvcmd[2]=0x40;
|
2299 |
|
|
drvcmd[3]=0x01;
|
2300 |
|
|
drvcmd[8]=response_count;
|
2301 |
|
|
}
|
2302 |
|
|
i=cmd_out();
|
2303 |
|
|
if (i<0) return (i);
|
2304 |
|
|
for (i=0;i<response_count;i++)
|
2305 |
|
|
{
|
2306 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
2307 |
|
|
msgbuf[i*3]=0;
|
2308 |
|
|
msg(DBG_SQ1,"cc_ReadSubQ:%s\n", msgbuf);
|
2309 |
|
|
}
|
2310 |
|
|
if (famT_drive) break;
|
2311 |
|
|
if (infobuf[0]!=0) break;
|
2312 |
|
|
if ((!st_spinning) || (j==1))
|
2313 |
|
|
{
|
2314 |
|
|
D_S[d].SubQ_ctl_adr=D_S[d].SubQ_trk=D_S[d].SubQ_pnt_idx=D_S[d].SubQ_whatisthis=0;
|
2315 |
|
|
D_S[d].SubQ_run_tot=D_S[d].SubQ_run_trk=0;
|
2316 |
|
|
return (0);
|
2317 |
|
|
}
|
2318 |
|
|
}
|
2319 |
|
|
if (famT_drive) D_S[d].SubQ_ctl_adr=infobuf[1];
|
2320 |
|
|
else D_S[d].SubQ_ctl_adr=swap_nibbles(infobuf[1]);
|
2321 |
|
|
D_S[d].SubQ_trk=byt2bcd(infobuf[2]);
|
2322 |
|
|
D_S[d].SubQ_pnt_idx=byt2bcd(infobuf[3]);
|
2323 |
|
|
if (fam0LV_drive) i=5;
|
2324 |
|
|
else if (fam12_drive) i=4;
|
2325 |
|
|
else if (famT_drive) i=8;
|
2326 |
|
|
D_S[d].SubQ_run_tot=make32(make16(0,infobuf[i]),make16(infobuf[i+1],infobuf[i+2])); /* msf-bin */
|
2327 |
|
|
i=7;
|
2328 |
|
|
if (fam0LV_drive) i=9;
|
2329 |
|
|
else if (fam12_drive) i=7;
|
2330 |
|
|
else if (famT_drive) i=4;
|
2331 |
|
|
D_S[d].SubQ_run_trk=make32(make16(0,infobuf[i]),make16(infobuf[i+1],infobuf[i+2])); /* msf-bin */
|
2332 |
|
|
D_S[d].SubQ_whatisthis=infobuf[i+3];
|
2333 |
|
|
D_S[d].diskstate_flags |= subq_bit;
|
2334 |
|
|
return (0);
|
2335 |
|
|
}
|
2336 |
|
|
/*==========================================================================*/
|
2337 |
|
|
static int cc_ModeSense(void)
|
2338 |
|
|
{
|
2339 |
|
|
int i;
|
2340 |
|
|
|
2341 |
|
|
if (fam2_drive) return (0);
|
2342 |
|
|
if (famV_drive) return (0);
|
2343 |
|
|
D_S[d].diskstate_flags &= ~frame_size_bit;
|
2344 |
|
|
clr_cmdbuf();
|
2345 |
|
|
if (fam1_drive)
|
2346 |
|
|
{
|
2347 |
|
|
response_count=5;
|
2348 |
|
|
drvcmd[0]=CMD1_GETMODE;
|
2349 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2350 |
|
|
}
|
2351 |
|
|
else if (fam0L_drive)
|
2352 |
|
|
{
|
2353 |
|
|
response_count=2;
|
2354 |
|
|
drvcmd[0]=CMD0_GETMODE;
|
2355 |
|
|
if (famL_drive) flags_cmd_out=f_putcmd;
|
2356 |
|
|
else flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2357 |
|
|
}
|
2358 |
|
|
else if (famT_drive)
|
2359 |
|
|
{
|
2360 |
|
|
response_count=10;
|
2361 |
|
|
drvcmd[0]=CMDT_GETMODE;
|
2362 |
|
|
drvcmd[4]=response_count;
|
2363 |
|
|
}
|
2364 |
|
|
i=cmd_out();
|
2365 |
|
|
if (i<0) return (i);
|
2366 |
|
|
i=0;
|
2367 |
|
|
D_S[d].sense_byte=0;
|
2368 |
|
|
if (fam1_drive) D_S[d].sense_byte=infobuf[i++];
|
2369 |
|
|
else if (famT_drive)
|
2370 |
|
|
{
|
2371 |
|
|
if (infobuf[4]==0x01) D_S[d].xa_byte=0x20;
|
2372 |
|
|
else D_S[d].xa_byte=0;
|
2373 |
|
|
i=2;
|
2374 |
|
|
}
|
2375 |
|
|
D_S[d].frame_size=make16(infobuf[i],infobuf[i+1]);
|
2376 |
|
|
for (i=0;i<response_count;i++)
|
2377 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
2378 |
|
|
msgbuf[i*3]=0;
|
2379 |
|
|
msg(DBG_XA1,"cc_ModeSense:%s\n", msgbuf);
|
2380 |
|
|
|
2381 |
|
|
D_S[d].diskstate_flags |= frame_size_bit;
|
2382 |
|
|
return (0);
|
2383 |
|
|
}
|
2384 |
|
|
/*==========================================================================*/
|
2385 |
|
|
/*==========================================================================*/
|
2386 |
|
|
static int cc_ModeSelect(int framesize)
|
2387 |
|
|
{
|
2388 |
|
|
int i;
|
2389 |
|
|
|
2390 |
|
|
if (fam2_drive) return (0);
|
2391 |
|
|
if (famV_drive) return (0);
|
2392 |
|
|
D_S[d].diskstate_flags &= ~frame_size_bit;
|
2393 |
|
|
clr_cmdbuf();
|
2394 |
|
|
D_S[d].frame_size=framesize;
|
2395 |
|
|
if (framesize==CD_FRAMESIZE_RAW) D_S[d].sense_byte=0x82;
|
2396 |
|
|
else D_S[d].sense_byte=0x00;
|
2397 |
|
|
|
2398 |
|
|
msg(DBG_XA1,"cc_ModeSelect: %02X %04X\n",
|
2399 |
|
|
D_S[d].sense_byte, D_S[d].frame_size);
|
2400 |
|
|
|
2401 |
|
|
if (fam1_drive)
|
2402 |
|
|
{
|
2403 |
|
|
drvcmd[0]=CMD1_SETMODE;
|
2404 |
|
|
drvcmd[1]=0x00;
|
2405 |
|
|
drvcmd[2]=D_S[d].sense_byte;
|
2406 |
|
|
drvcmd[3]=(D_S[d].frame_size>>8)&0xFF;
|
2407 |
|
|
drvcmd[4]=D_S[d].frame_size&0xFF;
|
2408 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2409 |
|
|
}
|
2410 |
|
|
else if (fam0L_drive)
|
2411 |
|
|
{
|
2412 |
|
|
drvcmd[0]=CMD0_SETMODE;
|
2413 |
|
|
drvcmd[1]=0x00;
|
2414 |
|
|
drvcmd[2]=(D_S[d].frame_size>>8)&0xFF;
|
2415 |
|
|
drvcmd[3]=D_S[d].frame_size&0xFF;
|
2416 |
|
|
drvcmd[4]=0x00;
|
2417 |
|
|
if(famL_drive)
|
2418 |
|
|
flags_cmd_out=f_putcmd|f_lopsta|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2419 |
|
|
else
|
2420 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2421 |
|
|
}
|
2422 |
|
|
else if (famT_drive)
|
2423 |
|
|
{
|
2424 |
|
|
return (-1);
|
2425 |
|
|
}
|
2426 |
|
|
response_count=0;
|
2427 |
|
|
i=cmd_out();
|
2428 |
|
|
if (i<0) return (i);
|
2429 |
|
|
D_S[d].diskstate_flags |= frame_size_bit;
|
2430 |
|
|
return (0);
|
2431 |
|
|
}
|
2432 |
|
|
/*==========================================================================*/
|
2433 |
|
|
static int cc_GetVolume(void)
|
2434 |
|
|
{
|
2435 |
|
|
int i;
|
2436 |
|
|
u_char switches;
|
2437 |
|
|
u_char chan0=0;
|
2438 |
|
|
u_char vol0=0;
|
2439 |
|
|
u_char chan1=1;
|
2440 |
|
|
u_char vol1=0;
|
2441 |
|
|
|
2442 |
|
|
if (famV_drive) return (0);
|
2443 |
|
|
D_S[d].diskstate_flags &= ~volume_bit;
|
2444 |
|
|
clr_cmdbuf();
|
2445 |
|
|
if (fam1_drive)
|
2446 |
|
|
{
|
2447 |
|
|
drvcmd[0]=CMD1_GETMODE;
|
2448 |
|
|
drvcmd[1]=0x05;
|
2449 |
|
|
response_count=5;
|
2450 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2451 |
|
|
}
|
2452 |
|
|
else if (fam2_drive)
|
2453 |
|
|
{
|
2454 |
|
|
drvcmd[0]=CMD2_GETMODE;
|
2455 |
|
|
drvcmd[1]=0x0E;
|
2456 |
|
|
response_count=5;
|
2457 |
|
|
flags_cmd_out=f_putcmd;
|
2458 |
|
|
}
|
2459 |
|
|
else if (fam0L_drive)
|
2460 |
|
|
{
|
2461 |
|
|
drvcmd[0]=CMD0_GETMODE;
|
2462 |
|
|
drvcmd[1]=0x03;
|
2463 |
|
|
response_count=2;
|
2464 |
|
|
if(famL_drive)
|
2465 |
|
|
flags_cmd_out=f_putcmd;
|
2466 |
|
|
else
|
2467 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2468 |
|
|
}
|
2469 |
|
|
else if (famT_drive)
|
2470 |
|
|
{
|
2471 |
|
|
i=cc_get_mode_T();
|
2472 |
|
|
if (i<0) return (i);
|
2473 |
|
|
}
|
2474 |
|
|
if (!famT_drive)
|
2475 |
|
|
{
|
2476 |
|
|
i=cmd_out();
|
2477 |
|
|
if (i<0) return (i);
|
2478 |
|
|
}
|
2479 |
|
|
if (fam1_drive)
|
2480 |
|
|
{
|
2481 |
|
|
chan0=infobuf[1]&0x0F;
|
2482 |
|
|
vol0=infobuf[2];
|
2483 |
|
|
chan1=infobuf[3]&0x0F;
|
2484 |
|
|
vol1=infobuf[4];
|
2485 |
|
|
if (chan0==0)
|
2486 |
|
|
{
|
2487 |
|
|
chan0=1;
|
2488 |
|
|
vol0=0;
|
2489 |
|
|
}
|
2490 |
|
|
if (chan1==0)
|
2491 |
|
|
{
|
2492 |
|
|
chan1=2;
|
2493 |
|
|
vol1=0;
|
2494 |
|
|
}
|
2495 |
|
|
chan0 >>= 1;
|
2496 |
|
|
chan1 >>= 1;
|
2497 |
|
|
}
|
2498 |
|
|
else if (fam2_drive)
|
2499 |
|
|
{
|
2500 |
|
|
chan0=infobuf[1];
|
2501 |
|
|
vol0=infobuf[2];
|
2502 |
|
|
chan1=infobuf[3];
|
2503 |
|
|
vol1=infobuf[4];
|
2504 |
|
|
}
|
2505 |
|
|
else if (famL_drive)
|
2506 |
|
|
{
|
2507 |
|
|
chan0=0;
|
2508 |
|
|
chan1=1;
|
2509 |
|
|
vol0=vol1=infobuf[1];
|
2510 |
|
|
switches=infobuf[0];
|
2511 |
|
|
if ((switches&0x80)!=0) chan0=1;
|
2512 |
|
|
if ((switches&0x40)!=0) chan1=0;
|
2513 |
|
|
}
|
2514 |
|
|
else if (fam0_drive) /* different firmware levels */
|
2515 |
|
|
{
|
2516 |
|
|
chan0=0;
|
2517 |
|
|
chan1=1;
|
2518 |
|
|
vol0=vol1=infobuf[1];
|
2519 |
|
|
if (D_S[d].drv_type>=drv_201)
|
2520 |
|
|
{
|
2521 |
|
|
if (D_S[d].drv_type<drv_300)
|
2522 |
|
|
{
|
2523 |
|
|
switches=infobuf[0];
|
2524 |
|
|
if ((switches&0x80)!=0) vol0=0;
|
2525 |
|
|
if ((switches&0x40)!=0) vol1=0;
|
2526 |
|
|
if (D_S[d].drv_type>=drv_211)
|
2527 |
|
|
{
|
2528 |
|
|
if ((switches&0x20)!=0) chan0=1;
|
2529 |
|
|
if ((switches&0x10)!=0) chan1=0;
|
2530 |
|
|
}
|
2531 |
|
|
}
|
2532 |
|
|
else
|
2533 |
|
|
{
|
2534 |
|
|
vol0=infobuf[0];
|
2535 |
|
|
if ((vol0&0x01)!=0) chan0=1;
|
2536 |
|
|
if ((vol1&0x01)==0) chan1=0;
|
2537 |
|
|
vol0 &= 0xFC;
|
2538 |
|
|
vol1 &= 0xFC;
|
2539 |
|
|
if (vol0!=0) vol0 += 3;
|
2540 |
|
|
if (vol1!=0) vol1 += 3;
|
2541 |
|
|
}
|
2542 |
|
|
}
|
2543 |
|
|
}
|
2544 |
|
|
else if (famT_drive)
|
2545 |
|
|
{
|
2546 |
|
|
D_S[d].volume_control=infobuf[7];
|
2547 |
|
|
chan0=0;
|
2548 |
|
|
chan1=1;
|
2549 |
|
|
if (D_S[d].volume_control&0x10) vol0=0;
|
2550 |
|
|
else vol0=0xff;
|
2551 |
|
|
if (D_S[d].volume_control&0x20) vol1=0;
|
2552 |
|
|
else vol1=0xff;
|
2553 |
|
|
}
|
2554 |
|
|
D_S[d].vol_chan0=chan0;
|
2555 |
|
|
D_S[d].vol_ctrl0=vol0;
|
2556 |
|
|
D_S[d].vol_chan1=chan1;
|
2557 |
|
|
D_S[d].vol_ctrl1=vol1;
|
2558 |
|
|
#if 000
|
2559 |
|
|
D_S[d].vol_chan2=2;
|
2560 |
|
|
D_S[d].vol_ctrl2=0xFF;
|
2561 |
|
|
D_S[d].vol_chan3=3;
|
2562 |
|
|
D_S[d].vol_ctrl3=0xFF;
|
2563 |
|
|
#endif 000
|
2564 |
|
|
D_S[d].diskstate_flags |= volume_bit;
|
2565 |
|
|
return (0);
|
2566 |
|
|
}
|
2567 |
|
|
/*==========================================================================*/
|
2568 |
|
|
static int cc_ReadCapacity(void)
|
2569 |
|
|
{
|
2570 |
|
|
int i, j;
|
2571 |
|
|
|
2572 |
|
|
if (fam2_drive) return (0); /* some firmware lacks this command */
|
2573 |
|
|
if (famLV_drive) return (0); /* some firmware lacks this command */
|
2574 |
|
|
if (famT_drive) return (0); /* done with cc_ReadTocDescr() */
|
2575 |
|
|
D_S[d].diskstate_flags &= ~cd_size_bit;
|
2576 |
|
|
for (j=3;j>0;j--)
|
2577 |
|
|
{
|
2578 |
|
|
clr_cmdbuf();
|
2579 |
|
|
if (fam1_drive)
|
2580 |
|
|
{
|
2581 |
|
|
drvcmd[0]=CMD1_CAPACITY;
|
2582 |
|
|
response_count=5;
|
2583 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2584 |
|
|
}
|
2585 |
|
|
#if 00
|
2586 |
|
|
else if (fam2_drive)
|
2587 |
|
|
{
|
2588 |
|
|
drvcmd[0]=CMD2_CAPACITY;
|
2589 |
|
|
response_count=8;
|
2590 |
|
|
flags_cmd_out=f_putcmd;
|
2591 |
|
|
}
|
2592 |
|
|
#endif
|
2593 |
|
|
else if (fam0_drive)
|
2594 |
|
|
{
|
2595 |
|
|
drvcmd[0]=CMD0_CAPACITY;
|
2596 |
|
|
response_count=5;
|
2597 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2598 |
|
|
}
|
2599 |
|
|
i=cmd_out();
|
2600 |
|
|
if (i>=0) break;
|
2601 |
|
|
msg(DBG_000,"cc_ReadCapacity: cmd_out: err %d\n", i);
|
2602 |
|
|
cc_ReadError();
|
2603 |
|
|
}
|
2604 |
|
|
if (j==0) return (i);
|
2605 |
|
|
if (fam1_drive) D_S[d].CDsize_frm=msf2blk(make32(make16(0,infobuf[0]),make16(infobuf[1],infobuf[2])))+CD_MSF_OFFSET;
|
2606 |
|
|
else if (fam0_drive) D_S[d].CDsize_frm=make32(make16(0,infobuf[0]),make16(infobuf[1],infobuf[2]));
|
2607 |
|
|
#if 00
|
2608 |
|
|
else if (fam2_drive) D_S[d].CDsize_frm=make32(make16(infobuf[0],infobuf[1]),make16(infobuf[2],infobuf[3]));
|
2609 |
|
|
#endif
|
2610 |
|
|
D_S[d].diskstate_flags |= cd_size_bit;
|
2611 |
|
|
msg(DBG_000,"cc_ReadCapacity: %d frames.\n", D_S[d].CDsize_frm);
|
2612 |
|
|
return (0);
|
2613 |
|
|
}
|
2614 |
|
|
/*==========================================================================*/
|
2615 |
|
|
static int cc_ReadTocDescr(void)
|
2616 |
|
|
{
|
2617 |
|
|
int i;
|
2618 |
|
|
|
2619 |
|
|
D_S[d].diskstate_flags &= ~toc_bit;
|
2620 |
|
|
clr_cmdbuf();
|
2621 |
|
|
if (fam1_drive)
|
2622 |
|
|
{
|
2623 |
|
|
drvcmd[0]=CMD1_DISKINFO;
|
2624 |
|
|
response_count=6;
|
2625 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2626 |
|
|
}
|
2627 |
|
|
else if (fam0LV_drive)
|
2628 |
|
|
{
|
2629 |
|
|
drvcmd[0]=CMD0_DISKINFO;
|
2630 |
|
|
response_count=6;
|
2631 |
|
|
if(famLV_drive)
|
2632 |
|
|
flags_cmd_out=f_putcmd;
|
2633 |
|
|
else
|
2634 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2635 |
|
|
}
|
2636 |
|
|
else if (fam2_drive)
|
2637 |
|
|
{
|
2638 |
|
|
/* possibly longer timeout periods necessary */
|
2639 |
|
|
D_S[d].f_multisession=0;
|
2640 |
|
|
drvcmd[0]=CMD2_DISKINFO;
|
2641 |
|
|
drvcmd[1]=0x02;
|
2642 |
|
|
drvcmd[2]=0xAB;
|
2643 |
|
|
drvcmd[3]=0xFF; /* session */
|
2644 |
|
|
response_count=8;
|
2645 |
|
|
flags_cmd_out=f_putcmd;
|
2646 |
|
|
}
|
2647 |
|
|
else if (famT_drive)
|
2648 |
|
|
{
|
2649 |
|
|
D_S[d].f_multisession=0;
|
2650 |
|
|
response_count=12;
|
2651 |
|
|
drvcmd[0]=CMDT_DISKINFO;
|
2652 |
|
|
drvcmd[1]=0x02;
|
2653 |
|
|
drvcmd[6]=CDROM_LEADOUT;
|
2654 |
|
|
drvcmd[8]=response_count;
|
2655 |
|
|
drvcmd[9]=0x00;
|
2656 |
|
|
}
|
2657 |
|
|
i=cmd_out();
|
2658 |
|
|
if (i<0) return (i);
|
2659 |
|
|
if ((famT_drive)&&(i<response_count)) return (-100-i);
|
2660 |
|
|
if ((fam1_drive)||(fam2_drive)||(fam0LV_drive))
|
2661 |
|
|
D_S[d].xa_byte=infobuf[0];
|
2662 |
|
|
if (fam2_drive)
|
2663 |
|
|
{
|
2664 |
|
|
D_S[d].first_session=infobuf[1];
|
2665 |
|
|
D_S[d].last_session=infobuf[2];
|
2666 |
|
|
D_S[d].n_first_track=infobuf[3];
|
2667 |
|
|
D_S[d].n_last_track=infobuf[4];
|
2668 |
|
|
if (D_S[d].first_session!=D_S[d].last_session)
|
2669 |
|
|
{
|
2670 |
|
|
D_S[d].f_multisession=1;
|
2671 |
|
|
D_S[d].lba_multi=msf2blk(make32(make16(0,infobuf[5]),make16(infobuf[6],infobuf[7])));
|
2672 |
|
|
}
|
2673 |
|
|
#if 0
|
2674 |
|
|
if (D_S[d].first_session!=D_S[d].last_session)
|
2675 |
|
|
{
|
2676 |
|
|
if (D_S[d].last_session<=20)
|
2677 |
|
|
zwanzig=D_S[d].last_session+1;
|
2678 |
|
|
else zwanzig=20;
|
2679 |
|
|
for (count=D_S[d].first_session;count<zwanzig;count++)
|
2680 |
|
|
{
|
2681 |
|
|
drvcmd[0]=CMD2_DISKINFO;
|
2682 |
|
|
drvcmd[1]=0x02;
|
2683 |
|
|
drvcmd[2]=0xAB;
|
2684 |
|
|
drvcmd[3]=count;
|
2685 |
|
|
response_count=8;
|
2686 |
|
|
flags_cmd_out=f_putcmd;
|
2687 |
|
|
i=cmd_out();
|
2688 |
|
|
if (i<0) return (i);
|
2689 |
|
|
D_S[d].msf_multi_n[count]=make32(make16(0,infobuf[5]),make16(infobuf[6],infobuf[7]));
|
2690 |
|
|
}
|
2691 |
|
|
D_S[d].diskstate_flags |= multisession_bit;
|
2692 |
|
|
}
|
2693 |
|
|
#endif
|
2694 |
|
|
drvcmd[0]=CMD2_DISKINFO;
|
2695 |
|
|
drvcmd[1]=0x02;
|
2696 |
|
|
drvcmd[2]=0xAA;
|
2697 |
|
|
drvcmd[3]=0xFF;
|
2698 |
|
|
response_count=5;
|
2699 |
|
|
flags_cmd_out=f_putcmd;
|
2700 |
|
|
i=cmd_out();
|
2701 |
|
|
if (i<0) return (i);
|
2702 |
|
|
D_S[d].size_msf=make32(make16(0,infobuf[2]),make16(infobuf[3],infobuf[4]));
|
2703 |
|
|
D_S[d].size_blk=msf2blk(D_S[d].size_msf);
|
2704 |
|
|
D_S[d].CDsize_frm=D_S[d].size_blk+1;
|
2705 |
|
|
}
|
2706 |
|
|
else if (famT_drive)
|
2707 |
|
|
{
|
2708 |
|
|
D_S[d].size_msf=make32(make16(infobuf[8],infobuf[9]),make16(infobuf[10],infobuf[11]));
|
2709 |
|
|
D_S[d].size_blk=msf2blk(D_S[d].size_msf);
|
2710 |
|
|
D_S[d].CDsize_frm=D_S[d].size_blk+1;
|
2711 |
|
|
D_S[d].n_first_track=infobuf[2];
|
2712 |
|
|
D_S[d].n_last_track=infobuf[3];
|
2713 |
|
|
}
|
2714 |
|
|
else
|
2715 |
|
|
{
|
2716 |
|
|
D_S[d].n_first_track=infobuf[1];
|
2717 |
|
|
D_S[d].n_last_track=infobuf[2];
|
2718 |
|
|
D_S[d].size_msf=make32(make16(0,infobuf[3]),make16(infobuf[4],infobuf[5]));
|
2719 |
|
|
D_S[d].size_blk=msf2blk(D_S[d].size_msf);
|
2720 |
|
|
if (famLV_drive) D_S[d].CDsize_frm=D_S[d].size_blk+1;
|
2721 |
|
|
}
|
2722 |
|
|
D_S[d].diskstate_flags |= toc_bit;
|
2723 |
|
|
msg(DBG_TOC,"TocDesc: %02X %02X %02X %08X\n",
|
2724 |
|
|
D_S[d].xa_byte,
|
2725 |
|
|
D_S[d].n_first_track,
|
2726 |
|
|
D_S[d].n_last_track,
|
2727 |
|
|
D_S[d].size_msf);
|
2728 |
|
|
return (0);
|
2729 |
|
|
}
|
2730 |
|
|
/*==========================================================================*/
|
2731 |
|
|
static int cc_ReadTocEntry(int num)
|
2732 |
|
|
{
|
2733 |
|
|
int i;
|
2734 |
|
|
|
2735 |
|
|
clr_cmdbuf();
|
2736 |
|
|
if (fam1_drive)
|
2737 |
|
|
{
|
2738 |
|
|
drvcmd[0]=CMD1_READTOC;
|
2739 |
|
|
drvcmd[2]=num;
|
2740 |
|
|
response_count=8;
|
2741 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2742 |
|
|
}
|
2743 |
|
|
else if (fam2_drive)
|
2744 |
|
|
{
|
2745 |
|
|
/* possibly longer timeout periods necessary */
|
2746 |
|
|
drvcmd[0]=CMD2_DISKINFO;
|
2747 |
|
|
drvcmd[1]=0x02;
|
2748 |
|
|
drvcmd[2]=num;
|
2749 |
|
|
response_count=5;
|
2750 |
|
|
flags_cmd_out=f_putcmd;
|
2751 |
|
|
}
|
2752 |
|
|
else if (fam0LV_drive)
|
2753 |
|
|
{
|
2754 |
|
|
drvcmd[0]=CMD0_READTOC;
|
2755 |
|
|
drvcmd[1]=0x02;
|
2756 |
|
|
drvcmd[2]=num;
|
2757 |
|
|
response_count=8;
|
2758 |
|
|
if (famLV_drive)
|
2759 |
|
|
flags_cmd_out=f_putcmd;
|
2760 |
|
|
else
|
2761 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2762 |
|
|
}
|
2763 |
|
|
else if (famT_drive)
|
2764 |
|
|
{
|
2765 |
|
|
response_count=12;
|
2766 |
|
|
drvcmd[0]=CMDT_DISKINFO;
|
2767 |
|
|
drvcmd[1]=0x02;
|
2768 |
|
|
drvcmd[6]=num;
|
2769 |
|
|
drvcmd[8]=response_count;
|
2770 |
|
|
drvcmd[9]=0x00;
|
2771 |
|
|
}
|
2772 |
|
|
i=cmd_out();
|
2773 |
|
|
if (i<0) return (i);
|
2774 |
|
|
if ((famT_drive)&&(i<response_count)) return (-100-i);
|
2775 |
|
|
if ((fam1_drive)||(fam0LV_drive))
|
2776 |
|
|
{
|
2777 |
|
|
D_S[d].TocEnt_nixbyte=infobuf[0];
|
2778 |
|
|
i=1;
|
2779 |
|
|
}
|
2780 |
|
|
else if (fam2_drive) i=0;
|
2781 |
|
|
else if (famT_drive) i=5;
|
2782 |
|
|
D_S[d].TocEnt_ctl_adr=swap_nibbles(infobuf[i++]);
|
2783 |
|
|
if ((fam1_drive)||(fam0L_drive))
|
2784 |
|
|
{
|
2785 |
|
|
D_S[d].TocEnt_number=infobuf[i++];
|
2786 |
|
|
D_S[d].TocEnt_format=infobuf[i];
|
2787 |
|
|
}
|
2788 |
|
|
else
|
2789 |
|
|
{
|
2790 |
|
|
D_S[d].TocEnt_number=num;
|
2791 |
|
|
D_S[d].TocEnt_format=0;
|
2792 |
|
|
}
|
2793 |
|
|
if (fam1_drive) i=4;
|
2794 |
|
|
else if (fam0LV_drive) i=5;
|
2795 |
|
|
else if (fam2_drive) i=2;
|
2796 |
|
|
else if (famT_drive) i=9;
|
2797 |
|
|
D_S[d].TocEnt_address=make32(make16(0,infobuf[i]),
|
2798 |
|
|
make16(infobuf[i+1],infobuf[i+2]));
|
2799 |
|
|
for (i=0;i<response_count;i++)
|
2800 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
2801 |
|
|
msgbuf[i*3]=0;
|
2802 |
|
|
msg(DBG_ECS,"TocEntry:%s\n", msgbuf);
|
2803 |
|
|
msg(DBG_TOC,"TocEntry: %02X %02X %02X %02X %08X\n",
|
2804 |
|
|
D_S[d].TocEnt_nixbyte, D_S[d].TocEnt_ctl_adr,
|
2805 |
|
|
D_S[d].TocEnt_number, D_S[d].TocEnt_format,
|
2806 |
|
|
D_S[d].TocEnt_address);
|
2807 |
|
|
return (0);
|
2808 |
|
|
}
|
2809 |
|
|
/*==========================================================================*/
|
2810 |
|
|
static int cc_ReadPacket(void)
|
2811 |
|
|
{
|
2812 |
|
|
int i;
|
2813 |
|
|
|
2814 |
|
|
clr_cmdbuf();
|
2815 |
|
|
drvcmd[0]=CMD0_PACKET;
|
2816 |
|
|
drvcmd[1]=response_count;
|
2817 |
|
|
if(famL_drive) flags_cmd_out=f_putcmd;
|
2818 |
|
|
else if (fam01_drive)
|
2819 |
|
|
flags_cmd_out=f_putcmd|f_getsta|f_ResponseStatus|f_obey_p_check;
|
2820 |
|
|
else if (fam2_drive) return (-1); /* not implemented yet */
|
2821 |
|
|
else if (famT_drive)
|
2822 |
|
|
{
|
2823 |
|
|
return (-1);
|
2824 |
|
|
}
|
2825 |
|
|
i=cmd_out();
|
2826 |
|
|
return (i);
|
2827 |
|
|
}
|
2828 |
|
|
/*==========================================================================*/
|
2829 |
|
|
static int convert_UPC(u_char *p)
|
2830 |
|
|
{
|
2831 |
|
|
int i;
|
2832 |
|
|
|
2833 |
|
|
p++;
|
2834 |
|
|
if (fam0L_drive) p[13]=0;
|
2835 |
|
|
for (i=0;i<7;i++)
|
2836 |
|
|
{
|
2837 |
|
|
if (fam1_drive) D_S[d].UPC_buf[i]=swap_nibbles(*p++);
|
2838 |
|
|
else if (fam0L_drive)
|
2839 |
|
|
{
|
2840 |
|
|
D_S[d].UPC_buf[i]=((*p++)<<4)&0xFF;
|
2841 |
|
|
D_S[d].UPC_buf[i] |= *p++;
|
2842 |
|
|
}
|
2843 |
|
|
else if (famT_drive)
|
2844 |
|
|
{
|
2845 |
|
|
return (-1);
|
2846 |
|
|
}
|
2847 |
|
|
else /* CD200 */
|
2848 |
|
|
{
|
2849 |
|
|
return (-1);
|
2850 |
|
|
}
|
2851 |
|
|
}
|
2852 |
|
|
D_S[d].UPC_buf[6] &= 0xF0;
|
2853 |
|
|
return (0);
|
2854 |
|
|
}
|
2855 |
|
|
/*==========================================================================*/
|
2856 |
|
|
static int cc_ReadUPC(void)
|
2857 |
|
|
{
|
2858 |
|
|
int i;
|
2859 |
|
|
#if TEST_UPC
|
2860 |
|
|
int block, checksum;
|
2861 |
|
|
#endif TEST_UPC
|
2862 |
|
|
|
2863 |
|
|
if (fam2_drive) return (0); /* not implemented yet */
|
2864 |
|
|
if (famT_drive) return (0); /* not implemented yet */
|
2865 |
|
|
if (famV_drive) return (0); /* not implemented yet */
|
2866 |
|
|
#if 1
|
2867 |
|
|
if (fam0_drive) return (0); /* but it should work */
|
2868 |
|
|
#endif 1
|
2869 |
|
|
|
2870 |
|
|
D_S[d].diskstate_flags &= ~upc_bit;
|
2871 |
|
|
#if TEST_UPC
|
2872 |
|
|
for (block=CD_MSF_OFFSET+1;block<CD_MSF_OFFSET+200;block++)
|
2873 |
|
|
{
|
2874 |
|
|
#endif TEST_UPC
|
2875 |
|
|
clr_cmdbuf();
|
2876 |
|
|
if (fam1_drive)
|
2877 |
|
|
{
|
2878 |
|
|
drvcmd[0]=CMD1_READ_UPC;
|
2879 |
|
|
#if TEST_UPC
|
2880 |
|
|
drvcmd[1]=(block>>16)&0xFF;
|
2881 |
|
|
drvcmd[2]=(block>>8)&0xFF;
|
2882 |
|
|
drvcmd[3]=block&0xFF;
|
2883 |
|
|
#endif TEST_UPC
|
2884 |
|
|
response_count=8;
|
2885 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2886 |
|
|
}
|
2887 |
|
|
else if (fam0L_drive)
|
2888 |
|
|
{
|
2889 |
|
|
drvcmd[0]=CMD0_READ_UPC;
|
2890 |
|
|
#if TEST_UPC
|
2891 |
|
|
drvcmd[2]=(block>>16)&0xFF;
|
2892 |
|
|
drvcmd[3]=(block>>8)&0xFF;
|
2893 |
|
|
drvcmd[4]=block&0xFF;
|
2894 |
|
|
#endif TEST_UPC
|
2895 |
|
|
response_count=0;
|
2896 |
|
|
flags_cmd_out=f_putcmd|f_lopsta|f_getsta|f_ResponseStatus|f_obey_p_check|f_bit1;
|
2897 |
|
|
}
|
2898 |
|
|
else if (fam2_drive)
|
2899 |
|
|
{
|
2900 |
|
|
return (-1);
|
2901 |
|
|
}
|
2902 |
|
|
else if (famT_drive)
|
2903 |
|
|
{
|
2904 |
|
|
return (-1);
|
2905 |
|
|
}
|
2906 |
|
|
i=cmd_out();
|
2907 |
|
|
if (i<0)
|
2908 |
|
|
{
|
2909 |
|
|
msg(DBG_000,"cc_ReadUPC cmd_out: err %d\n", i);
|
2910 |
|
|
return (i);
|
2911 |
|
|
}
|
2912 |
|
|
if (fam0L_drive)
|
2913 |
|
|
{
|
2914 |
|
|
response_count=16;
|
2915 |
|
|
if (famL_drive) flags_cmd_out=f_putcmd;
|
2916 |
|
|
i=cc_ReadPacket();
|
2917 |
|
|
if (i<0)
|
2918 |
|
|
{
|
2919 |
|
|
msg(DBG_000,"cc_ReadUPC ReadPacket: err %d\n", i);
|
2920 |
|
|
return (i);
|
2921 |
|
|
}
|
2922 |
|
|
}
|
2923 |
|
|
#if TEST_UPC
|
2924 |
|
|
checksum=0;
|
2925 |
|
|
#endif TEST_UPC
|
2926 |
|
|
for (i=0;i<(fam1_drive?8:16);i++)
|
2927 |
|
|
{
|
2928 |
|
|
#if TEST_UPC
|
2929 |
|
|
checksum |= infobuf[i];
|
2930 |
|
|
#endif TEST_UPC
|
2931 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
2932 |
|
|
}
|
2933 |
|
|
msgbuf[i*3]=0;
|
2934 |
|
|
msg(DBG_UPC,"UPC info:%s\n", msgbuf);
|
2935 |
|
|
#if TEST_UPC
|
2936 |
|
|
if ((checksum&0x7F)!=0) break;
|
2937 |
|
|
}
|
2938 |
|
|
#endif TEST_UPC
|
2939 |
|
|
D_S[d].UPC_ctl_adr=0;
|
2940 |
|
|
if (fam1_drive) i=0;
|
2941 |
|
|
else i=2;
|
2942 |
|
|
if ((infobuf[i]&0x80)!=0)
|
2943 |
|
|
{
|
2944 |
|
|
convert_UPC(&infobuf[i]);
|
2945 |
|
|
D_S[d].UPC_ctl_adr = (D_S[d].TocEnt_ctl_adr & 0xF0) | 0x02;
|
2946 |
|
|
}
|
2947 |
|
|
for (i=0;i<7;i++)
|
2948 |
|
|
sprintf(&msgbuf[i*3], " %02X", D_S[d].UPC_buf[i]);
|
2949 |
|
|
sprintf(&msgbuf[i*3], " (%02X)", D_S[d].UPC_ctl_adr);
|
2950 |
|
|
msgbuf[i*3+5]=0;
|
2951 |
|
|
msg(DBG_UPC,"UPC code:%s\n", msgbuf);
|
2952 |
|
|
D_S[d].diskstate_flags |= upc_bit;
|
2953 |
|
|
return (0);
|
2954 |
|
|
}
|
2955 |
|
|
/*==========================================================================*/
|
2956 |
|
|
static int cc_CheckMultiSession(void)
|
2957 |
|
|
{
|
2958 |
|
|
int i;
|
2959 |
|
|
|
2960 |
|
|
if (fam2_drive) return (0);
|
2961 |
|
|
D_S[d].f_multisession=0;
|
2962 |
|
|
D_S[d].lba_multi=0;
|
2963 |
|
|
if (fam0_drive) return (0);
|
2964 |
|
|
clr_cmdbuf();
|
2965 |
|
|
if (fam1_drive)
|
2966 |
|
|
{
|
2967 |
|
|
drvcmd[0]=CMD1_MULTISESS;
|
2968 |
|
|
response_count=6;
|
2969 |
|
|
flags_cmd_out=f_putcmd|f_ResponseStatus|f_obey_p_check;
|
2970 |
|
|
i=cmd_out();
|
2971 |
|
|
if (i<0) return (i);
|
2972 |
|
|
if ((infobuf[0]&0x80)!=0)
|
2973 |
|
|
{
|
2974 |
|
|
D_S[d].f_multisession=1;
|
2975 |
|
|
D_S[d].lba_multi=msf2blk(make32(make16(0,infobuf[1]),
|
2976 |
|
|
make16(infobuf[2],infobuf[3])));
|
2977 |
|
|
}
|
2978 |
|
|
}
|
2979 |
|
|
else if (famLV_drive)
|
2980 |
|
|
{
|
2981 |
|
|
drvcmd[0]=CMDL_MULTISESS;
|
2982 |
|
|
drvcmd[1]=3;
|
2983 |
|
|
drvcmd[2]=1;
|
2984 |
|
|
response_count=8;
|
2985 |
|
|
flags_cmd_out=f_putcmd;
|
2986 |
|
|
i=cmd_out();
|
2987 |
|
|
if (i<0) return (i);
|
2988 |
|
|
D_S[d].lba_multi=msf2blk(make32(make16(0,infobuf[5]),
|
2989 |
|
|
make16(infobuf[6],infobuf[7])));
|
2990 |
|
|
}
|
2991 |
|
|
else if (famT_drive)
|
2992 |
|
|
{
|
2993 |
|
|
response_count=12;
|
2994 |
|
|
drvcmd[0]=CMDT_DISKINFO;
|
2995 |
|
|
drvcmd[1]=0x02;
|
2996 |
|
|
drvcmd[6]=0;
|
2997 |
|
|
drvcmd[8]=response_count;
|
2998 |
|
|
drvcmd[9]=0x40;
|
2999 |
|
|
i=cmd_out();
|
3000 |
|
|
if (i<0) return (i);
|
3001 |
|
|
if (i<response_count) return (-100-i);
|
3002 |
|
|
D_S[d].first_session=infobuf[2];
|
3003 |
|
|
D_S[d].last_session=infobuf[3];
|
3004 |
|
|
D_S[d].track_of_last_session=infobuf[6];
|
3005 |
|
|
if (D_S[d].first_session!=D_S[d].last_session)
|
3006 |
|
|
{
|
3007 |
|
|
D_S[d].f_multisession=1;
|
3008 |
|
|
D_S[d].lba_multi=msf2blk(make32(make16(0,infobuf[9]),make16(infobuf[10],infobuf[11])));
|
3009 |
|
|
}
|
3010 |
|
|
}
|
3011 |
|
|
for (i=0;i<response_count;i++)
|
3012 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
3013 |
|
|
msgbuf[i*3]=0;
|
3014 |
|
|
msg(DBG_MUL,"MultiSession Info:%s (%d)\n", msgbuf, D_S[d].lba_multi);
|
3015 |
|
|
if (D_S[d].lba_multi>200)
|
3016 |
|
|
{
|
3017 |
|
|
D_S[d].f_multisession=1;
|
3018 |
|
|
msg(DBG_MUL,"MultiSession base: %06X\n", D_S[d].lba_multi);
|
3019 |
|
|
}
|
3020 |
|
|
return (0);
|
3021 |
|
|
}
|
3022 |
|
|
/*==========================================================================*/
|
3023 |
|
|
#if FUTURE
|
3024 |
|
|
static int cc_SubChanInfo(int frame, int count, u_char *buffer)
|
3025 |
|
|
/* "frame" is a RED BOOK (msf-bin) address */
|
3026 |
|
|
{
|
3027 |
|
|
int i;
|
3028 |
|
|
|
3029 |
|
|
if (fam0LV_drive) return (-ENOSYS); /* drive firmware lacks it */
|
3030 |
|
|
if (famT_drive)
|
3031 |
|
|
{
|
3032 |
|
|
return (-1);
|
3033 |
|
|
}
|
3034 |
|
|
#if 0
|
3035 |
|
|
if (D_S[d].audio_state!=audio_playing) return (-ENODATA);
|
3036 |
|
|
#endif
|
3037 |
|
|
clr_cmdbuf();
|
3038 |
|
|
drvcmd[0]=CMD1_SUBCHANINF;
|
3039 |
|
|
drvcmd[1]=(frame>>16)&0xFF;
|
3040 |
|
|
drvcmd[2]=(frame>>8)&0xFF;
|
3041 |
|
|
drvcmd[3]=frame&0xFF;
|
3042 |
|
|
drvcmd[5]=(count>>8)&0xFF;
|
3043 |
|
|
drvcmd[6]=count&0xFF;
|
3044 |
|
|
flags_cmd_out=f_putcmd|f_respo2|f_ResponseStatus|f_obey_p_check;
|
3045 |
|
|
cmd_type=READ_SC;
|
3046 |
|
|
D_S[d].frame_size=CD_FRAMESIZE_SUB;
|
3047 |
|
|
i=cmd_out(); /* which buffer to use? */
|
3048 |
|
|
return (i);
|
3049 |
|
|
}
|
3050 |
|
|
#endif FUTURE
|
3051 |
|
|
/*==========================================================================*/
|
3052 |
|
|
static void check_datarate(void)
|
3053 |
|
|
{
|
3054 |
|
|
int i=0;
|
3055 |
|
|
|
3056 |
|
|
msg(DBG_IOX,"check_datarate entered.\n");
|
3057 |
|
|
datarate=0;
|
3058 |
|
|
#if TEST_STI
|
3059 |
|
|
for (i=0;i<=1000;i++) printk(".");
|
3060 |
|
|
#endif
|
3061 |
|
|
/* set a timer to make (timed_out_delay!=0) after 1.1 seconds */
|
3062 |
|
|
#if 1
|
3063 |
|
|
del_timer(&delay_timer);
|
3064 |
|
|
#endif
|
3065 |
|
|
delay_timer.expires=jiffies+11*HZ/10;
|
3066 |
|
|
timed_out_delay=0;
|
3067 |
|
|
add_timer(&delay_timer);
|
3068 |
|
|
#if 0
|
3069 |
|
|
msg(DBG_TIM,"delay timer started (11*HZ/10).\n");
|
3070 |
|
|
#endif
|
3071 |
|
|
do
|
3072 |
|
|
{
|
3073 |
|
|
i=inb(CDi_status);
|
3074 |
|
|
datarate++;
|
3075 |
|
|
#if 1
|
3076 |
|
|
if (datarate>0x6FFFFFFF) break;
|
3077 |
|
|
#endif 00000
|
3078 |
|
|
}
|
3079 |
|
|
while (!timed_out_delay);
|
3080 |
|
|
del_timer(&delay_timer);
|
3081 |
|
|
#if 0
|
3082 |
|
|
msg(DBG_TIM,"datarate: %04X\n", datarate);
|
3083 |
|
|
#endif
|
3084 |
|
|
if (datarate<65536) datarate=65536;
|
3085 |
|
|
maxtim16=datarate*16;
|
3086 |
|
|
maxtim04=datarate*4;
|
3087 |
|
|
maxtim02=datarate*2;
|
3088 |
|
|
maxtim_8=datarate/32;
|
3089 |
|
|
#if LONG_TIMING
|
3090 |
|
|
maxtim_data=datarate/100;
|
3091 |
|
|
#else
|
3092 |
|
|
maxtim_data=datarate/300;
|
3093 |
|
|
#endif LONG_TIMING
|
3094 |
|
|
#if 0
|
3095 |
|
|
msg(DBG_TIM,"maxtim_8 %d, maxtim_data %d.\n", maxtim_8, maxtim_data);
|
3096 |
|
|
#endif
|
3097 |
|
|
}
|
3098 |
|
|
/*==========================================================================*/
|
3099 |
|
|
#if 0
|
3100 |
|
|
static int c2_ReadError(int fam)
|
3101 |
|
|
{
|
3102 |
|
|
int i;
|
3103 |
|
|
|
3104 |
|
|
clr_cmdbuf();
|
3105 |
|
|
response_count=9;
|
3106 |
|
|
clr_respo_buf(9);
|
3107 |
|
|
if (fam==1)
|
3108 |
|
|
{
|
3109 |
|
|
drvcmd[0]=CMD0_READ_ERR; /* same as CMD1_ and CMDL_ */
|
3110 |
|
|
i=do_cmd(f_putcmd|f_lopsta|f_getsta|f_ResponseStatus);
|
3111 |
|
|
}
|
3112 |
|
|
else if (fam==2)
|
3113 |
|
|
{
|
3114 |
|
|
drvcmd[0]=CMD2_READ_ERR;
|
3115 |
|
|
i=do_cmd(f_putcmd);
|
3116 |
|
|
}
|
3117 |
|
|
else return (-1);
|
3118 |
|
|
return (i);
|
3119 |
|
|
}
|
3120 |
|
|
#endif
|
3121 |
|
|
/*==========================================================================*/
|
3122 |
|
|
static void ask_mail(void)
|
3123 |
|
|
{
|
3124 |
|
|
int i;
|
3125 |
|
|
|
3126 |
|
|
msg(DBG_INF, "please mail the following lines to emoenke@gwdg.de\n");
|
3127 |
|
|
msg(DBG_INF, "(don't mail if you are not using the actual kernel):\n");
|
3128 |
|
|
msg(DBG_INF, "%s\n", VERSION);
|
3129 |
|
|
msg(DBG_INF, "address %03X, type %s, drive %s (ID %d)\n",
|
3130 |
|
|
CDo_command, type, D_S[d].drive_model, D_S[d].drv_id);
|
3131 |
|
|
for (i=0;i<12;i++)
|
3132 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
3133 |
|
|
msgbuf[i*3]=0;
|
3134 |
|
|
msg(DBG_INF,"infobuf =%s\n", msgbuf);
|
3135 |
|
|
for (i=0;i<12;i++)
|
3136 |
|
|
sprintf(&msgbuf[i*3], " %c ", infobuf[i]);
|
3137 |
|
|
msgbuf[i*3]=0;
|
3138 |
|
|
msg(DBG_INF,"infobuf =%s\n", msgbuf);
|
3139 |
|
|
}
|
3140 |
|
|
/*==========================================================================*/
|
3141 |
|
|
static int check_version(void)
|
3142 |
|
|
{
|
3143 |
|
|
int i, j, l;
|
3144 |
|
|
int teac_possible=0;
|
3145 |
|
|
|
3146 |
|
|
msg(DBG_INI,"check_version: id=%d, d=%d.\n", D_S[d].drv_id, d);
|
3147 |
|
|
D_S[d].drv_type=0;
|
3148 |
|
|
|
3149 |
|
|
/* check for CR-52x, CR-56x, LCS-7260 and ECS-AT */
|
3150 |
|
|
/* clear any pending error state */
|
3151 |
|
|
clr_cmdbuf();
|
3152 |
|
|
drvcmd[0]=CMD0_READ_ERR; /* same as CMD1_ and CMDL_ */
|
3153 |
|
|
response_count=9;
|
3154 |
|
|
flags_cmd_out=f_putcmd;
|
3155 |
|
|
i=cmd_out();
|
3156 |
|
|
if (i<0) msg(DBG_INI,"CMD0_READ_ERR returns %d (ok anyway).\n",i);
|
3157 |
|
|
/* read drive version */
|
3158 |
|
|
clr_cmdbuf();
|
3159 |
|
|
for (i=0;i<12;i++) infobuf[i]=0;
|
3160 |
|
|
drvcmd[0]=CMD0_READ_VER; /* same as CMD1_ and CMDL_ */
|
3161 |
|
|
response_count=12; /* fam1: only 11 */
|
3162 |
|
|
flags_cmd_out=f_putcmd;
|
3163 |
|
|
i=cmd_out();
|
3164 |
|
|
if (i<-1) msg(DBG_INI,"CMD0_READ_VER returns %d\n",i);
|
3165 |
|
|
if (i==-11) teac_possible++;
|
3166 |
|
|
j=0;
|
3167 |
|
|
for (i=0;i<12;i++) j+=infobuf[i];
|
3168 |
|
|
if (j)
|
3169 |
|
|
{
|
3170 |
|
|
for (i=0;i<12;i++)
|
3171 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
3172 |
|
|
msgbuf[i*3]=0;
|
3173 |
|
|
msg(DBG_ECS,"infobuf =%s\n", msgbuf);
|
3174 |
|
|
for (i=0;i<12;i++)
|
3175 |
|
|
sprintf(&msgbuf[i*3], " %c ", infobuf[i]);
|
3176 |
|
|
msgbuf[i*3]=0;
|
3177 |
|
|
msg(DBG_ECS,"infobuf =%s\n", msgbuf);
|
3178 |
|
|
}
|
3179 |
|
|
for (i=0;i<4;i++) if (infobuf[i]!=family1[i]) break;
|
3180 |
|
|
if (i==4)
|
3181 |
|
|
{
|
3182 |
|
|
D_S[d].drive_model[0]='C';
|
3183 |
|
|
D_S[d].drive_model[1]='R';
|
3184 |
|
|
D_S[d].drive_model[2]='-';
|
3185 |
|
|
D_S[d].drive_model[3]='5';
|
3186 |
|
|
D_S[d].drive_model[4]=infobuf[i++];
|
3187 |
|
|
D_S[d].drive_model[5]=infobuf[i++];
|
3188 |
|
|
D_S[d].drive_model[6]=0;
|
3189 |
|
|
D_S[d].drv_type=drv_fam1;
|
3190 |
|
|
}
|
3191 |
|
|
if (!D_S[d].drv_type)
|
3192 |
|
|
{
|
3193 |
|
|
for (i=0;i<8;i++) if (infobuf[i]!=family0[i]) break;
|
3194 |
|
|
if (i==8)
|
3195 |
|
|
{
|
3196 |
|
|
D_S[d].drive_model[0]='C';
|
3197 |
|
|
D_S[d].drive_model[1]='R';
|
3198 |
|
|
D_S[d].drive_model[2]='-';
|
3199 |
|
|
D_S[d].drive_model[3]='5';
|
3200 |
|
|
D_S[d].drive_model[4]='2';
|
3201 |
|
|
D_S[d].drive_model[5]='x';
|
3202 |
|
|
D_S[d].drive_model[6]=0;
|
3203 |
|
|
D_S[d].drv_type=drv_fam0;
|
3204 |
|
|
}
|
3205 |
|
|
}
|
3206 |
|
|
if (!D_S[d].drv_type)
|
3207 |
|
|
{
|
3208 |
|
|
for (i=0;i<8;i++) if (infobuf[i]!=familyL[i]) break;
|
3209 |
|
|
if (i==8)
|
3210 |
|
|
{
|
3211 |
|
|
for (j=0;j<8;j++)
|
3212 |
|
|
D_S[d].drive_model[j]=infobuf[j];
|
3213 |
|
|
D_S[d].drive_model[8]=0;
|
3214 |
|
|
D_S[d].drv_type=drv_famL;
|
3215 |
|
|
}
|
3216 |
|
|
}
|
3217 |
|
|
if (!D_S[d].drv_type)
|
3218 |
|
|
{
|
3219 |
|
|
for (i=0;i<6;i++) if (infobuf[i]!=familyV[i]) break;
|
3220 |
|
|
if (i==6)
|
3221 |
|
|
{
|
3222 |
|
|
for (j=0;j<6;j++)
|
3223 |
|
|
D_S[d].drive_model[j]=infobuf[j];
|
3224 |
|
|
D_S[d].drive_model[6]=0;
|
3225 |
|
|
D_S[d].drv_type=drv_famV;
|
3226 |
|
|
i+=2; /* 2 blanks before version */
|
3227 |
|
|
}
|
3228 |
|
|
}
|
3229 |
|
|
if (!D_S[d].drv_type)
|
3230 |
|
|
{
|
3231 |
|
|
/* check for CD200 */
|
3232 |
|
|
clr_cmdbuf();
|
3233 |
|
|
drvcmd[0]=CMD2_READ_ERR;
|
3234 |
|
|
response_count=9;
|
3235 |
|
|
flags_cmd_out=f_putcmd;
|
3236 |
|
|
i=cmd_out();
|
3237 |
|
|
if (i<0) msg(DBG_INI,"CMD2_READERR returns %d (ok anyway).\n",i);
|
3238 |
|
|
if (i<0) msg(DBG_000,"CMD2_READERR returns %d (ok anyway).\n",i);
|
3239 |
|
|
/* read drive version */
|
3240 |
|
|
clr_cmdbuf();
|
3241 |
|
|
for (i=0;i<12;i++) infobuf[i]=0;
|
3242 |
|
|
if (sbpro_type==1) OUT(CDo_sel_i_d,0);
|
3243 |
|
|
#if 0
|
3244 |
|
|
OUT(CDo_reset,0);
|
3245 |
|
|
sbp_sleep(6*HZ);
|
3246 |
|
|
OUT(CDo_enable,D_S[d].drv_sel);
|
3247 |
|
|
#endif 0
|
3248 |
|
|
drvcmd[0]=CMD2_READ_VER;
|
3249 |
|
|
response_count=12;
|
3250 |
|
|
flags_cmd_out=f_putcmd;
|
3251 |
|
|
i=cmd_out();
|
3252 |
|
|
if (i<0) msg(DBG_INI,"CMD2_READ_VER returns %d\n",i);
|
3253 |
|
|
if (i==-7) teac_possible++;
|
3254 |
|
|
j=0;
|
3255 |
|
|
for (i=0;i<12;i++) j+=infobuf[i];
|
3256 |
|
|
if (j)
|
3257 |
|
|
{
|
3258 |
|
|
for (i=0;i<12;i++)
|
3259 |
|
|
sprintf(&msgbuf[i*3], " %02X", infobuf[i]);
|
3260 |
|
|
msgbuf[i*3]=0;
|
3261 |
|
|
msg(DBG_IDX,"infobuf =%s\n", msgbuf);
|
3262 |
|
|
for (i=0;i<12;i++)
|
3263 |
|
|
sprintf(&msgbuf[i*3], " %c ", infobuf[i]);
|
3264 |
|
|
msgbuf[i*3]=0;
|
3265 |
|
|
msg(DBG_IDX,"infobuf =%s\n", msgbuf);
|
3266 |
|
|
}
|
3267 |
|
|
if (i>=0)
|
3268 |
|
|
{
|
3269 |
|
|
for (i=0;i<5;i++) if (infobuf[i]!=family2[i]) break;
|
3270 |
|
|
if (i==5)
|
3271 |
|
|
{
|
3272 |
|
|
D_S[d].drive_model[0]='C';
|
3273 |
|
|
D_S[d].drive_model[1]='D';
|
3274 |
|
|
D_S[d].drive_model[2]='2';
|
3275 |
|
|
D_S[d].drive_model[3]='0';
|
3276 |
|
|
D_S[d].drive_model[4]='0';
|
3277 |
|
|
D_S[d].drive_model[5]=infobuf[i++];
|
3278 |
|
|
D_S[d].drive_model[6]=infobuf[i++];
|
3279 |
|
|
D_S[d].drive_model[7]=0;
|
3280 |
|
|
D_S[d].drv_type=drv_fam2;
|
3281 |
|
|
}
|
3282 |
|
|
}
|
3283 |
|
|
}
|
3284 |
|
|
if (!D_S[d].drv_type)
|
3285 |
|
|
{
|
3286 |
|
|
/* check for TEAC CD-55A */
|
3287 |
|
|
msg(DBG_TEA,"teac_possible: %d\n",teac_possible);
|
3288 |
|
|
for (j=1;j<=((D_S[d].drv_id==0)?3:1);j++)
|
3289 |
|
|
{
|
3290 |
|
|
for (l=1;l<=((D_S[d].drv_id==0)?10:1);l++)
|
3291 |
|
|
{
|
3292 |
|
|
msg(DBG_TEA,"TEAC reset #%d-%d.\n", j, l);
|
3293 |
|
|
if (sbpro_type==1) OUT(CDo_reset,0);
|
3294 |
|
|
else
|
3295 |
|
|
{
|
3296 |
|
|
OUT(CDo_enable,D_S[d].drv_sel);
|
3297 |
|
|
OUT(CDo_sel_i_d,0);
|
3298 |
|
|
OUT(CDo_command,CMDT_RESET);
|
3299 |
|
|
for (i=0;i<9;i++) OUT(CDo_command,0);
|
3300 |
|
|
}
|
3301 |
|
|
sbp_sleep(5*HZ/10);
|
3302 |
|
|
OUT(CDo_enable,D_S[d].drv_sel);
|
3303 |
|
|
OUT(CDo_sel_i_d,0);
|
3304 |
|
|
i=inb(CDi_status);
|
3305 |
|
|
msg(DBG_TEA,"TEAC CDi_status: %02X.\n",i);
|
3306 |
|
|
#if 0
|
3307 |
|
|
if (i&s_not_result_ready) continue; /* drive not present or ready */
|
3308 |
|
|
#endif
|
3309 |
|
|
i=inb(CDi_info);
|
3310 |
|
|
msg(DBG_TEA,"TEAC CDi_info: %02X.\n",i);
|
3311 |
|
|
if (i==0x55) break; /* drive found */
|
3312 |
|
|
}
|
3313 |
|
|
if (i==0x55) break; /* drive found */
|
3314 |
|
|
}
|
3315 |
|
|
if (i==0x55) /* drive found */
|
3316 |
|
|
{
|
3317 |
|
|
msg(DBG_TEA,"TEAC drive found.\n");
|
3318 |
|
|
clr_cmdbuf();
|
3319 |
|
|
flags_cmd_out=f_putcmd;
|
3320 |
|
|
response_count=12;
|
3321 |
|
|
drvcmd[0]=CMDT_READ_VER;
|
3322 |
|
|
drvcmd[4]=response_count;
|
3323 |
|
|
for (i=0;i<12;i++) infobuf[i]=0;
|
3324 |
|
|
i=cmd_out_T();
|
3325 |
|
|
if (i!=0) msg(DBG_TEA,"cmd_out_T(CMDT_READ_VER) returns %d.\n",i);
|
3326 |
|
|
for (i=1;i<6;i++) if (infobuf[i]!=familyT[i-1]) break;
|
3327 |
|
|
if (i==6)
|
3328 |
|
|
{
|
3329 |
|
|
D_S[d].drive_model[0]='C';
|
3330 |
|
|
D_S[d].drive_model[1]='D';
|
3331 |
|
|
D_S[d].drive_model[2]='-';
|
3332 |
|
|
D_S[d].drive_model[3]='5';
|
3333 |
|
|
D_S[d].drive_model[4]='5';
|
3334 |
|
|
D_S[d].drive_model[5]=0;
|
3335 |
|
|
D_S[d].drv_type=drv_famT;
|
3336 |
|
|
}
|
3337 |
|
|
}
|
3338 |
|
|
}
|
3339 |
|
|
if (!D_S[d].drv_type)
|
3340 |
|
|
{
|
3341 |
|
|
msg(DBG_TEA,"no drive found at address %03X under ID %d.\n",CDo_command,D_S[d].drv_id);
|
3342 |
|
|
return (-522);
|
3343 |
|
|
}
|
3344 |
|
|
for (j=0;j<4;j++) D_S[d].firmware_version[j]=infobuf[i+j];
|
3345 |
|
|
if (famL_drive)
|
3346 |
|
|
{
|
3347 |
|
|
u_char lcs_firm_e1[]="A E1";
|
3348 |
|
|
u_char lcs_firm_f4[]="A4F4";
|
3349 |
|
|
|
3350 |
|
|
for (j=0;j<4;j++)
|
3351 |
|
|
if (D_S[d].firmware_version[j]!=lcs_firm_e1[j]) break;
|
3352 |
|
|
if (j==4) D_S[d].drv_type=drv_e1;
|
3353 |
|
|
|
3354 |
|
|
for (j=0;j<4;j++)
|
3355 |
|
|
if (D_S[d].firmware_version[j]!=lcs_firm_f4[j]) break;
|
3356 |
|
|
if (j==4) D_S[d].drv_type=drv_f4;
|
3357 |
|
|
|
3358 |
|
|
if (D_S[d].drv_type==drv_famL) ask_mail();
|
3359 |
|
|
}
|
3360 |
|
|
else if (famT_drive)
|
3361 |
|
|
{
|
3362 |
|
|
j=infobuf[4]; /* one-byte version??? - here: 0x15 */
|
3363 |
|
|
if (j=='5')
|
3364 |
|
|
{
|
3365 |
|
|
D_S[d].firmware_version[0]=infobuf[7];
|
3366 |
|
|
D_S[d].firmware_version[1]=infobuf[8];
|
3367 |
|
|
D_S[d].firmware_version[2]=infobuf[10];
|
3368 |
|
|
D_S[d].firmware_version[3]=infobuf[11];
|
3369 |
|
|
}
|
3370 |
|
|
else
|
3371 |
|
|
{
|
3372 |
|
|
if (j!=0x15) ask_mail();
|
3373 |
|
|
D_S[d].firmware_version[0]='0';
|
3374 |
|
|
D_S[d].firmware_version[1]='.';
|
3375 |
|
|
D_S[d].firmware_version[2]='0'+(j>>4);
|
3376 |
|
|
D_S[d].firmware_version[3]='0'+(j&0x0f);
|
3377 |
|
|
}
|
3378 |
|
|
}
|
3379 |
|
|
else /* CR-52x, CR-56x, CD200, ECS-AT */
|
3380 |
|
|
{
|
3381 |
|
|
j = (D_S[d].firmware_version[0] & 0x0F) * 100 +
|
3382 |
|
|
(D_S[d].firmware_version[2] & 0x0F) *10 +
|
3383 |
|
|
(D_S[d].firmware_version[3] & 0x0F);
|
3384 |
|
|
if (fam0_drive)
|
3385 |
|
|
{
|
3386 |
|
|
if (j<200) D_S[d].drv_type=drv_199;
|
3387 |
|
|
else if (j<201) D_S[d].drv_type=drv_200;
|
3388 |
|
|
else if (j<210) D_S[d].drv_type=drv_201;
|
3389 |
|
|
else if (j<211) D_S[d].drv_type=drv_210;
|
3390 |
|
|
else if (j<300) D_S[d].drv_type=drv_211;
|
3391 |
|
|
else if (j>=300) D_S[d].drv_type=drv_300;
|
3392 |
|
|
}
|
3393 |
|
|
else if (fam1_drive)
|
3394 |
|
|
{
|
3395 |
|
|
if (j<100) D_S[d].drv_type=drv_099;
|
3396 |
|
|
else
|
3397 |
|
|
{
|
3398 |
|
|
D_S[d].drv_type=drv_100;
|
3399 |
|
|
if ((j!=500)&&(j!=102)) ask_mail();
|
3400 |
|
|
}
|
3401 |
|
|
}
|
3402 |
|
|
else if (fam2_drive)
|
3403 |
|
|
{
|
3404 |
|
|
if (D_S[d].drive_model[5]=='F')
|
3405 |
|
|
{
|
3406 |
|
|
if ((j!=1)&&(j!=35)&&(j!=200)&&(j!=210))
|
3407 |
|
|
ask_mail(); /* unknown version at time */
|
3408 |
|
|
}
|
3409 |
|
|
else
|
3410 |
|
|
{
|
3411 |
|
|
msg(DBG_INF,"this CD200 drive is not fully supported yet - only audio will work.\n");
|
3412 |
|
|
if ((j!=101)&&(j!=35))
|
3413 |
|
|
ask_mail(); /* unknown version at time */
|
3414 |
|
|
}
|
3415 |
|
|
}
|
3416 |
|
|
else if (famV_drive)
|
3417 |
|
|
{
|
3418 |
|
|
if ((j==100)||(j==150)) D_S[d].drv_type=drv_at;
|
3419 |
|
|
ask_mail(); /* hopefully we get some feedback by this */
|
3420 |
|
|
}
|
3421 |
|
|
}
|
3422 |
|
|
msg(DBG_LCS,"drive type %02X\n",D_S[d].drv_type);
|
3423 |
|
|
msg(DBG_INI,"check_version done.\n");
|
3424 |
|
|
return (0);
|
3425 |
|
|
}
|
3426 |
|
|
/*==========================================================================*/
|
3427 |
|
|
static void switch_drive(int i)
|
3428 |
|
|
{
|
3429 |
|
|
d=i;
|
3430 |
|
|
OUT(CDo_enable,D_S[d].drv_sel);
|
3431 |
|
|
msg(DBG_DID,"drive %d (ID=%d) activated.\n", i, D_S[d].drv_id);
|
3432 |
|
|
return;
|
3433 |
|
|
}
|
3434 |
|
|
/*==========================================================================*/
|
3435 |
|
|
#ifdef PATH_CHECK
|
3436 |
|
|
/*
|
3437 |
|
|
* probe for the presence of an interface card
|
3438 |
|
|
*/
|
3439 |
|
|
static int check_card(int port)
|
3440 |
|
|
{
|
3441 |
|
|
#undef N_RESPO
|
3442 |
|
|
#define N_RESPO 20
|
3443 |
|
|
int i, j, k;
|
3444 |
|
|
u_char response[N_RESPO];
|
3445 |
|
|
u_char save_port0;
|
3446 |
|
|
u_char save_port3;
|
3447 |
|
|
|
3448 |
|
|
msg(DBG_INI,"check_card entered.\n");
|
3449 |
|
|
save_port0=inb(port+0);
|
3450 |
|
|
save_port3=inb(port+3);
|
3451 |
|
|
|
3452 |
|
|
for (j=0;j<NR_SBPCD;j++)
|
3453 |
|
|
{
|
3454 |
|
|
OUT(port+3,j) ; /* enable drive #j */
|
3455 |
|
|
OUT(port+0,CMD0_PATH_CHECK);
|
3456 |
|
|
for (i=10;i>0;i--) OUT(port+0,0);
|
3457 |
|
|
for (k=0;k<N_RESPO;k++) response[k]=0;
|
3458 |
|
|
for (k=0;k<N_RESPO;k++)
|
3459 |
|
|
{
|
3460 |
|
|
for (i=10000;i>0;i--)
|
3461 |
|
|
{
|
3462 |
|
|
if (inb(port+1)&s_not_result_ready) continue;
|
3463 |
|
|
response[k]=inb(port+0);
|
3464 |
|
|
break;
|
3465 |
|
|
}
|
3466 |
|
|
}
|
3467 |
|
|
for (i=0;i<N_RESPO;i++)
|
3468 |
|
|
sprintf(&msgbuf[i*3], " %02X", response[i]);
|
3469 |
|
|
msgbuf[i*3]=0;
|
3470 |
|
|
msg(DBG_TEA,"path check 00 (%d): %s\n", j, msgbuf);
|
3471 |
|
|
OUT(port+0,CMD0_PATH_CHECK);
|
3472 |
|
|
for (i=10;i>0;i--) OUT(port+0,0);
|
3473 |
|
|
for (k=0;k<N_RESPO;k++) response[k]=0xFF;
|
3474 |
|
|
for (k=0;k<N_RESPO;k++)
|
3475 |
|
|
{
|
3476 |
|
|
for (i=10000;i>0;i--)
|
3477 |
|
|
{
|
3478 |
|
|
if (inb(port+1)&s_not_result_ready) continue;
|
3479 |
|
|
response[k]=inb(port+0);
|
3480 |
|
|
break;
|
3481 |
|
|
}
|
3482 |
|
|
}
|
3483 |
|
|
for (i=0;i<N_RESPO;i++)
|
3484 |
|
|
sprintf(&msgbuf[i*3], " %02X", response[i]);
|
3485 |
|
|
msgbuf[i*3]=0;
|
3486 |
|
|
msg(DBG_TEA,"path check 00 (%d): %s\n", j, msgbuf);
|
3487 |
|
|
|
3488 |
|
|
if (response[0]==0xAA)
|
3489 |
|
|
if (response[1]==0x55)
|
3490 |
|
|
return (0);
|
3491 |
|
|
}
|
3492 |
|
|
for (j=0;j<NR_SBPCD;j++)
|
3493 |
|
|
{
|
3494 |
|
|
OUT(port+3,j) ; /* enable drive #j */
|
3495 |
|
|
OUT(port+0,CMD2_READ_VER);
|
3496 |
|
|
for (i=10;i>0;i--) OUT(port+0,0);
|
3497 |
|
|
for (k=0;k<N_RESPO;k++) response[k]=0;
|
3498 |
|
|
for (k=0;k<N_RESPO;k++)
|
3499 |
|
|
{
|
3500 |
|
|
for (i=1000000;i>0;i--)
|
3501 |
|
|
{
|
3502 |
|
|
if (inb(port+1)&s_not_result_ready) continue;
|
3503 |
|
|
response[k]=inb(port+0);
|
3504 |
|
|
break;
|
3505 |
|
|
}
|
3506 |
|
|
}
|
3507 |
|
|
for (i=0;i<N_RESPO;i++)
|
3508 |
|
|
sprintf(&msgbuf[i*3], " %02X", response[i]);
|
3509 |
|
|
msgbuf[i*3]=0;
|
3510 |
|
|
msg(DBG_TEA,"path check 12 (%d): %s\n", j, msgbuf);
|
3511 |
|
|
|
3512 |
|
|
OUT(port+0,CMD2_READ_VER);
|
3513 |
|
|
for (i=10;i>0;i--) OUT(port+0,0);
|
3514 |
|
|
for (k=0;k<N_RESPO;k++) response[k]=0xFF;
|
3515 |
|
|
for (k=0;k<N_RESPO;k++)
|
3516 |
|
|
{
|
3517 |
|
|
for (i=1000000;i>0;i--)
|
3518 |
|
|
{
|
3519 |
|
|
if (inb(port+1)&s_not_result_ready) continue;
|
3520 |
|
|
response[k]=inb(port+0);
|
3521 |
|
|
break;
|
3522 |
|
|
}
|
3523 |
|
|
}
|
3524 |
|
|
for (i=0;i<N_RESPO;i++)
|
3525 |
|
|
sprintf(&msgbuf[i*3], " %02X", response[i]);
|
3526 |
|
|
msgbuf[i*3]=0;
|
3527 |
|
|
msg(DBG_TEA,"path check 12 (%d): %s\n", j, msgbuf);
|
3528 |
|
|
|
3529 |
|
|
if (response[0]==0xAA)
|
3530 |
|
|
if (response[1]==0x55)
|
3531 |
|
|
return (0);
|
3532 |
|
|
}
|
3533 |
|
|
OUT(port+0,save_port0);
|
3534 |
|
|
OUT(port+3,save_port3);
|
3535 |
|
|
return (0); /* in any case - no real "function" at time */
|
3536 |
|
|
}
|
3537 |
|
|
#endif PATH_CHECK
|
3538 |
|
|
/*==========================================================================*/
|
3539 |
|
|
/*==========================================================================*/
|
3540 |
|
|
/*
|
3541 |
|
|
* probe for the presence of drives on the selected controller
|
3542 |
|
|
*/
|
3543 |
|
|
static int check_drives(void)
|
3544 |
|
|
{
|
3545 |
|
|
int i, j;
|
3546 |
|
|
|
3547 |
|
|
msg(DBG_INI,"check_drives entered.\n");
|
3548 |
|
|
ndrives=0;
|
3549 |
|
|
for (j=0;j<MAX_DRIVES;j++)
|
3550 |
|
|
{
|
3551 |
|
|
D_S[ndrives].drv_id=j;
|
3552 |
|
|
if (sbpro_type==1) D_S[ndrives].drv_sel=(j&0x01)<<1|(j&0x02)>>1;
|
3553 |
|
|
else D_S[ndrives].drv_sel=j;
|
3554 |
|
|
switch_drive(ndrives);
|
3555 |
|
|
msg(DBG_INI,"check_drives: drive %d (ID=%d) activated.\n",ndrives,j);
|
3556 |
|
|
msg(DBG_000,"check_drives: drive %d (ID=%d) activated.\n",ndrives,j);
|
3557 |
|
|
i=check_version();
|
3558 |
|
|
if (i<0) msg(DBG_INI,"check_version returns %d.\n",i);
|
3559 |
|
|
else
|
3560 |
|
|
{
|
3561 |
|
|
D_S[d].drv_options=drv_pattern[j];
|
3562 |
|
|
if (fam0L_drive) D_S[d].drv_options&=~(speed_auto|speed_300|speed_150);
|
3563 |
|
|
msg(DBG_INF, "Drive %d (ID=%d): %.9s (%.4s) at 0x%03X (type %d)\n",
|
3564 |
|
|
d,
|
3565 |
|
|
D_S[d].drv_id,
|
3566 |
|
|
D_S[d].drive_model,
|
3567 |
|
|
D_S[d].firmware_version,
|
3568 |
|
|
CDo_command,
|
3569 |
|
|
sbpro_type);
|
3570 |
|
|
ndrives++;
|
3571 |
|
|
}
|
3572 |
|
|
}
|
3573 |
|
|
for (j=ndrives;j<NR_SBPCD;j++) D_S[j].drv_id=-1;
|
3574 |
|
|
if (ndrives==0) return (-1);
|
3575 |
|
|
return (0);
|
3576 |
|
|
}
|
3577 |
|
|
/*==========================================================================*/
|
3578 |
|
|
#if FUTURE
|
3579 |
|
|
/*
|
3580 |
|
|
* obtain if requested service disturbs current audio state
|
3581 |
|
|
*/
|
3582 |
|
|
static int obey_audio_state(u_char audio_state, u_char func,u_char subfunc)
|
3583 |
|
|
{
|
3584 |
|
|
switch (audio_state) /* audio status from controller */
|
3585 |
|
|
{
|
3586 |
|
|
case aud_11: /* "audio play in progress" */
|
3587 |
|
|
case audx11:
|
3588 |
|
|
switch (func) /* DOS command code */
|
3589 |
|
|
{
|
3590 |
|
|
case cmd_07: /* input flush */
|
3591 |
|
|
case cmd_0d: /* open device */
|
3592 |
|
|
case cmd_0e: /* close device */
|
3593 |
|
|
case cmd_0c: /* ioctl output */
|
3594 |
|
|
return (1);
|
3595 |
|
|
case cmd_03: /* ioctl input */
|
3596 |
|
|
switch (subfunc)
|
3597 |
|
|
/* DOS ioctl input subfunction */
|
3598 |
|
|
{
|
3599 |
|
|
case cxi_00:
|
3600 |
|
|
case cxi_06:
|
3601 |
|
|
case cxi_09:
|
3602 |
|
|
return (1);
|
3603 |
|
|
default:
|
3604 |
|
|
return (ERROR15);
|
3605 |
|
|
}
|
3606 |
|
|
return (1);
|
3607 |
|
|
default:
|
3608 |
|
|
return (ERROR15);
|
3609 |
|
|
}
|
3610 |
|
|
return (1);
|
3611 |
|
|
case aud_12: /* "audio play paused" */
|
3612 |
|
|
case audx12:
|
3613 |
|
|
return (1);
|
3614 |
|
|
default:
|
3615 |
|
|
return (2);
|
3616 |
|
|
}
|
3617 |
|
|
}
|
3618 |
|
|
/*==========================================================================*/
|
3619 |
|
|
/* allowed is only
|
3620 |
|
|
* ioctl_o, flush_input, open_device, close_device,
|
3621 |
|
|
* tell_address, tell_volume, tell_capabiliti,
|
3622 |
|
|
* tell_framesize, tell_CD_changed, tell_audio_posi
|
3623 |
|
|
*/
|
3624 |
|
|
static int check_allowed1(u_char func1, u_char func2)
|
3625 |
|
|
{
|
3626 |
|
|
#if 000
|
3627 |
|
|
if (func1==ioctl_o) return (0);
|
3628 |
|
|
if (func1==read_long) return (-1);
|
3629 |
|
|
if (func1==read_long_prefetch) return (-1);
|
3630 |
|
|
if (func1==seek) return (-1);
|
3631 |
|
|
if (func1==audio_play) return (-1);
|
3632 |
|
|
if (func1==audio_pause) return (-1);
|
3633 |
|
|
if (func1==audio_resume) return (-1);
|
3634 |
|
|
if (func1!=ioctl_i) return (0);
|
3635 |
|
|
if (func2==tell_SubQ_run_tot) return (-1);
|
3636 |
|
|
if (func2==tell_cdsize) return (-1);
|
3637 |
|
|
if (func2==tell_TocDescrip) return (-1);
|
3638 |
|
|
if (func2==tell_TocEntry) return (-1);
|
3639 |
|
|
if (func2==tell_subQ_info) return (-1);
|
3640 |
|
|
if (fam1_drive) if (func2==tell_SubChanInfo) return (-1);
|
3641 |
|
|
if (func2==tell_UPC) return (-1);
|
3642 |
|
|
#else
|
3643 |
|
|
return (0);
|
3644 |
|
|
#endif 000
|
3645 |
|
|
}
|
3646 |
|
|
/*==========================================================================*/
|
3647 |
|
|
static int check_allowed2(u_char func1, u_char func2)
|
3648 |
|
|
{
|
3649 |
|
|
#if 000
|
3650 |
|
|
if (func1==read_long) return (-1);
|
3651 |
|
|
if (func1==read_long_prefetch) return (-1);
|
3652 |
|
|
if (func1==seek) return (-1);
|
3653 |
|
|
if (func1==audio_play) return (-1);
|
3654 |
|
|
if (func1!=ioctl_o) return (0);
|
3655 |
|
|
if (fam1_drive)
|
3656 |
|
|
{
|
3657 |
|
|
if (func2==EjectDisk) return (-1);
|
3658 |
|
|
if (func2==CloseTray) return (-1);
|
3659 |
|
|
}
|
3660 |
|
|
#else
|
3661 |
|
|
return (0);
|
3662 |
|
|
#endif 000
|
3663 |
|
|
}
|
3664 |
|
|
/*==========================================================================*/
|
3665 |
|
|
static int check_allowed3(u_char func1, u_char func2)
|
3666 |
|
|
{
|
3667 |
|
|
#if 000
|
3668 |
|
|
if (func1==ioctl_i)
|
3669 |
|
|
{
|
3670 |
|
|
if (func2==tell_address) return (0);
|
3671 |
|
|
if (func2==tell_capabiliti) return (0);
|
3672 |
|
|
if (func2==tell_CD_changed) return (0);
|
3673 |
|
|
if (fam0L_drive) if (func2==tell_SubChanInfo) return (0);
|
3674 |
|
|
return (-1);
|
3675 |
|
|
}
|
3676 |
|
|
if (func1==ioctl_o)
|
3677 |
|
|
{
|
3678 |
|
|
if (func2==DriveReset) return (0);
|
3679 |
|
|
if (fam0L_drive)
|
3680 |
|
|
{
|
3681 |
|
|
if (func2==EjectDisk) return (0);
|
3682 |
|
|
if (func2==LockDoor) return (0);
|
3683 |
|
|
if (func2==CloseTray) return (0);
|
3684 |
|
|
}
|
3685 |
|
|
return (-1);
|
3686 |
|
|
}
|
3687 |
|
|
if (func1==flush_input) return (-1);
|
3688 |
|
|
if (func1==read_long) return (-1);
|
3689 |
|
|
if (func1==read_long_prefetch) return (-1);
|
3690 |
|
|
if (func1==seek) return (-1);
|
3691 |
|
|
if (func1==audio_play) return (-1);
|
3692 |
|
|
if (func1==audio_pause) return (-1);
|
3693 |
|
|
if (func1==audio_resume) return (-1);
|
3694 |
|
|
#else
|
3695 |
|
|
return (0);
|
3696 |
|
|
#endif 000
|
3697 |
|
|
}
|
3698 |
|
|
/*==========================================================================*/
|
3699 |
|
|
static int seek_pos_audio_end(void)
|
3700 |
|
|
{
|
3701 |
|
|
int i;
|
3702 |
|
|
|
3703 |
|
|
i=msf2blk(D_S[d].pos_audio_end)-1;
|
3704 |
|
|
if (i<0) return (-1);
|
3705 |
|
|
i=cc_Seek(i,0);
|
3706 |
|
|
return (i);
|
3707 |
|
|
}
|
3708 |
|
|
#endif FUTURE
|
3709 |
|
|
/*==========================================================================*/
|
3710 |
|
|
static int ReadToC(void)
|
3711 |
|
|
{
|
3712 |
|
|
int i, j;
|
3713 |
|
|
D_S[d].diskstate_flags &= ~toc_bit;
|
3714 |
|
|
D_S[d].ored_ctl_adr=0;
|
3715 |
|
|
for (j=D_S[d].n_first_track;j<=D_S[d].n_last_track;j++)
|
3716 |
|
|
{
|
3717 |
|
|
i=cc_ReadTocEntry(j);
|
3718 |
|
|
if (i<0)
|
3719 |
|
|
{
|
3720 |
|
|
msg(DBG_INF,"cc_ReadTocEntry(%d) returns %d.\n",j,i);
|
3721 |
|
|
return (i);
|
3722 |
|
|
}
|
3723 |
|
|
D_S[d].TocBuffer[j].nixbyte=D_S[d].TocEnt_nixbyte;
|
3724 |
|
|
D_S[d].TocBuffer[j].ctl_adr=D_S[d].TocEnt_ctl_adr;
|
3725 |
|
|
D_S[d].TocBuffer[j].number=D_S[d].TocEnt_number;
|
3726 |
|
|
D_S[d].TocBuffer[j].format=D_S[d].TocEnt_format;
|
3727 |
|
|
D_S[d].TocBuffer[j].address=D_S[d].TocEnt_address;
|
3728 |
|
|
D_S[d].ored_ctl_adr |= D_S[d].TocEnt_ctl_adr;
|
3729 |
|
|
}
|
3730 |
|
|
/* fake entry for LeadOut Track */
|
3731 |
|
|
D_S[d].TocBuffer[j].nixbyte=0;
|
3732 |
|
|
D_S[d].TocBuffer[j].ctl_adr=0;
|
3733 |
|
|
D_S[d].TocBuffer[j].number=CDROM_LEADOUT;
|
3734 |
|
|
D_S[d].TocBuffer[j].format=0;
|
3735 |
|
|
D_S[d].TocBuffer[j].address=D_S[d].size_msf;
|
3736 |
|
|
|
3737 |
|
|
D_S[d].diskstate_flags |= toc_bit;
|
3738 |
|
|
return (0);
|
3739 |
|
|
}
|
3740 |
|
|
/*==========================================================================*/
|
3741 |
|
|
static int DiskInfo(void)
|
3742 |
|
|
{
|
3743 |
|
|
int i, j;
|
3744 |
|
|
|
3745 |
|
|
D_S[d].mode=READ_M1;
|
3746 |
|
|
|
3747 |
|
|
#undef LOOP_COUNT
|
3748 |
|
|
#define LOOP_COUNT 10 /* needed for some "old" drives */
|
3749 |
|
|
|
3750 |
|
|
msg(DBG_000,"DiskInfo entered.\n");
|
3751 |
|
|
for (j=1;j<LOOP_COUNT;j++)
|
3752 |
|
|
{
|
3753 |
|
|
i=SetSpeed();
|
3754 |
|
|
if (i<0)
|
3755 |
|
|
{
|
3756 |
|
|
msg(DBG_INF,"DiskInfo: SetSpeed returns %d\n", i);
|
3757 |
|
|
continue;
|
3758 |
|
|
}
|
3759 |
|
|
i=cc_ModeSense();
|
3760 |
|
|
if (i<0)
|
3761 |
|
|
{
|
3762 |
|
|
msg(DBG_INF,"DiskInfo: cc_ModeSense returns %d\n", i);
|
3763 |
|
|
continue;
|
3764 |
|
|
}
|
3765 |
|
|
i=cc_ReadCapacity();
|
3766 |
|
|
if (i>=0) break;
|
3767 |
|
|
msg(DBG_INF,"DiskInfo: ReadCapacity #%d returns %d\n", j, i);
|
3768 |
|
|
i=cc_DriveReset();
|
3769 |
|
|
}
|
3770 |
|
|
if (j==LOOP_COUNT) return (-33); /* give up */
|
3771 |
|
|
|
3772 |
|
|
i=cc_ReadTocDescr();
|
3773 |
|
|
if (i<0)
|
3774 |
|
|
{
|
3775 |
|
|
msg(DBG_INF,"DiskInfo: ReadTocDescr returns %d\n", i);
|
3776 |
|
|
return (i);
|
3777 |
|
|
}
|
3778 |
|
|
i=ReadToC();
|
3779 |
|
|
if (i<0)
|
3780 |
|
|
{
|
3781 |
|
|
msg(DBG_INF,"DiskInfo: ReadToC returns %d\n", i);
|
3782 |
|
|
return (i);
|
3783 |
|
|
}
|
3784 |
|
|
i=cc_CheckMultiSession();
|
3785 |
|
|
if (i<0)
|
3786 |
|
|
{
|
3787 |
|
|
msg(DBG_INF,"DiskInfo: cc_CheckMultiSession returns %d\n", i);
|
3788 |
|
|
return (i);
|
3789 |
|
|
}
|
3790 |
|
|
if (D_S[d].f_multisession) D_S[d].sbp_bufsiz=1; /* possibly a weird PhotoCD */
|
3791 |
|
|
else D_S[d].sbp_bufsiz=buffers;
|
3792 |
|
|
i=cc_ReadTocEntry(D_S[d].n_first_track);
|
3793 |
|
|
if (i<0)
|
3794 |
|
|
{
|
3795 |
|
|
msg(DBG_INF,"DiskInfo: cc_ReadTocEntry(1) returns %d\n", i);
|
3796 |
|
|
return (i);
|
3797 |
|
|
}
|
3798 |
|
|
i=cc_ReadUPC();
|
3799 |
|
|
if (i<0) msg(DBG_INF,"DiskInfo: cc_ReadUPC returns %d\n", i);
|
3800 |
|
|
if ((fam0L_drive) && (D_S[d].xa_byte==0x20))
|
3801 |
|
|
{
|
3802 |
|
|
/* XA disk with old drive */
|
3803 |
|
|
cc_ModeSelect(CD_FRAMESIZE_RAW1);
|
3804 |
|
|
cc_ModeSense();
|
3805 |
|
|
}
|
3806 |
|
|
if (famT_drive) cc_prep_mode_T();
|
3807 |
|
|
msg(DBG_000,"DiskInfo done.\n");
|
3808 |
|
|
return (0);
|
3809 |
|
|
}
|
3810 |
|
|
/*==========================================================================*/
|
3811 |
|
|
#if FUTURE
|
3812 |
|
|
/*
|
3813 |
|
|
* called always if driver gets entered
|
3814 |
|
|
* returns 0 or ERROR2 or ERROR15
|
3815 |
|
|
*/
|
3816 |
|
|
static int prepare(u_char func, u_char subfunc)
|
3817 |
|
|
{
|
3818 |
|
|
int i;
|
3819 |
|
|
|
3820 |
|
|
if (fam0L_drive)
|
3821 |
|
|
{
|
3822 |
|
|
i=inb(CDi_status);
|
3823 |
|
|
if (i&s_attention) GetStatus();
|
3824 |
|
|
}
|
3825 |
|
|
else if (fam1_drive) GetStatus();
|
3826 |
|
|
else if (fam2_drive) GetStatus();
|
3827 |
|
|
else if (famT_drive) GetStatus();
|
3828 |
|
|
if (D_S[d].CD_changed==0xFF)
|
3829 |
|
|
{
|
3830 |
|
|
D_S[d].diskstate_flags=0;
|
3831 |
|
|
D_S[d].audio_state=0;
|
3832 |
|
|
if (!st_diskok)
|
3833 |
|
|
{
|
3834 |
|
|
i=check_allowed1(func,subfunc);
|
3835 |
|
|
if (i<0) return (-2);
|
3836 |
|
|
}
|
3837 |
|
|
else
|
3838 |
|
|
{
|
3839 |
|
|
i=check_allowed3(func,subfunc);
|
3840 |
|
|
if (i<0)
|
3841 |
|
|
{
|
3842 |
|
|
D_S[d].CD_changed=1;
|
3843 |
|
|
return (-15);
|
3844 |
|
|
}
|
3845 |
|
|
}
|
3846 |
|
|
}
|
3847 |
|
|
else
|
3848 |
|
|
{
|
3849 |
|
|
if (!st_diskok)
|
3850 |
|
|
{
|
3851 |
|
|
D_S[d].diskstate_flags=0;
|
3852 |
|
|
D_S[d].audio_state=0;
|
3853 |
|
|
i=check_allowed1(func,subfunc);
|
3854 |
|
|
if (i<0) return (-2);
|
3855 |
|
|
}
|
3856 |
|
|
else
|
3857 |
|
|
{
|
3858 |
|
|
if (st_busy)
|
3859 |
|
|
{
|
3860 |
|
|
if (D_S[d].audio_state!=audio_pausing)
|
3861 |
|
|
{
|
3862 |
|
|
i=check_allowed2(func,subfunc);
|
3863 |
|
|
if (i<0) return (-2);
|
3864 |
|
|
}
|
3865 |
|
|
}
|
3866 |
|
|
else
|
3867 |
|
|
{
|
3868 |
|
|
if (D_S[d].audio_state==audio_playing) seek_pos_audio_end();
|
3869 |
|
|
D_S[d].audio_state=0;
|
3870 |
|
|
}
|
3871 |
|
|
if (!frame_size_valid)
|
3872 |
|
|
{
|
3873 |
|
|
i=DiskInfo();
|
3874 |
|
|
if (i<0)
|
3875 |
|
|
{
|
3876 |
|
|
D_S[d].diskstate_flags=0;
|
3877 |
|
|
D_S[d].audio_state=0;
|
3878 |
|
|
i=check_allowed1(func,subfunc);
|
3879 |
|
|
if (i<0) return (-2);
|
3880 |
|
|
}
|
3881 |
|
|
}
|
3882 |
|
|
}
|
3883 |
|
|
}
|
3884 |
|
|
return (0);
|
3885 |
|
|
}
|
3886 |
|
|
#endif FUTURE
|
3887 |
|
|
/*==========================================================================*/
|
3888 |
|
|
/*==========================================================================*/
|
3889 |
|
|
/*
|
3890 |
|
|
* Check the results of the "get status" command.
|
3891 |
|
|
*/
|
3892 |
|
|
static int sbp_status(void)
|
3893 |
|
|
{
|
3894 |
|
|
int st;
|
3895 |
|
|
|
3896 |
|
|
st=ResponseStatus();
|
3897 |
|
|
if (st<0)
|
3898 |
|
|
{
|
3899 |
|
|
msg(DBG_INF,"sbp_status: timeout.\n");
|
3900 |
|
|
return (0);
|
3901 |
|
|
}
|
3902 |
|
|
|
3903 |
|
|
if (!st_spinning) msg(DBG_SPI,"motor got off - ignoring.\n");
|
3904 |
|
|
|
3905 |
|
|
if (st_check)
|
3906 |
|
|
{
|
3907 |
|
|
msg(DBG_INF,"st_check detected - retrying.\n");
|
3908 |
|
|
return (0);
|
3909 |
|
|
}
|
3910 |
|
|
if (!st_door_closed)
|
3911 |
|
|
{
|
3912 |
|
|
msg(DBG_INF,"door is open - retrying.\n");
|
3913 |
|
|
return (0);
|
3914 |
|
|
}
|
3915 |
|
|
if (!st_caddy_in)
|
3916 |
|
|
{
|
3917 |
|
|
msg(DBG_INF,"disk removed - retrying.\n");
|
3918 |
|
|
return (0);
|
3919 |
|
|
}
|
3920 |
|
|
if (!st_diskok)
|
3921 |
|
|
{
|
3922 |
|
|
msg(DBG_INF,"!st_diskok detected - retrying.\n");
|
3923 |
|
|
return (0);
|
3924 |
|
|
}
|
3925 |
|
|
if (st_busy)
|
3926 |
|
|
{
|
3927 |
|
|
msg(DBG_INF,"st_busy detected - retrying.\n");
|
3928 |
|
|
return (0);
|
3929 |
|
|
}
|
3930 |
|
|
return (1);
|
3931 |
|
|
}
|
3932 |
|
|
/*==========================================================================*/
|
3933 |
|
|
|
3934 |
|
|
/*==========================================================================*/
|
3935 |
|
|
/*==========================================================================*/
|
3936 |
|
|
/*
|
3937 |
|
|
* ioctl support
|
3938 |
|
|
*/
|
3939 |
|
|
static int sbpcd_ioctl(struct inode *inode, struct file *file, u_int cmd,
|
3940 |
|
|
u_long arg)
|
3941 |
|
|
{
|
3942 |
|
|
int i, st;
|
3943 |
|
|
|
3944 |
|
|
msg(DBG_IO2,"ioctl(%d, 0x%08lX, 0x%08lX)\n",
|
3945 |
|
|
MINOR(inode->i_rdev), cmd, arg);
|
3946 |
|
|
if (!inode) return (-EINVAL);
|
3947 |
|
|
i=MINOR(inode->i_rdev);
|
3948 |
|
|
if ((i<0) || (i>=NR_SBPCD) || (D_S[i].drv_id==-1))
|
3949 |
|
|
{
|
3950 |
|
|
msg(DBG_INF, "ioctl: bad device: %04X\n", inode->i_rdev);
|
3951 |
|
|
return (-ENXIO); /* no such drive */
|
3952 |
|
|
}
|
3953 |
|
|
down(&ioctl_read_sem);
|
3954 |
|
|
if (d!=i) switch_drive(i);
|
3955 |
|
|
|
3956 |
|
|
#if 0
|
3957 |
|
|
st=GetStatus();
|
3958 |
|
|
if (st<0) RETURN_UP(-EIO);
|
3959 |
|
|
|
3960 |
|
|
if (!toc_valid)
|
3961 |
|
|
{
|
3962 |
|
|
i=DiskInfo();
|
3963 |
|
|
if (i<0) RETURN_UP(-EIO); /* error reading TOC */
|
3964 |
|
|
}
|
3965 |
|
|
#endif
|
3966 |
|
|
|
3967 |
|
|
msg(DBG_IO2,"ioctl: device %d, request %04X\n",i,cmd);
|
3968 |
|
|
switch (cmd) /* Sun-compatible */
|
3969 |
|
|
{
|
3970 |
|
|
case DDIOCSDBG: /* DDI Debug */
|
3971 |
|
|
if (!suser()) RETURN_UP(-EPERM);
|
3972 |
|
|
i=sbpcd_dbg_ioctl(arg,1);
|
3973 |
|
|
RETURN_UP(i);
|
3974 |
|
|
|
3975 |
|
|
case CDROMPAUSE: /* Pause the drive */
|
3976 |
|
|
msg(DBG_IOC,"ioctl: CDROMPAUSE entered.\n");
|
3977 |
|
|
/* pause the drive unit when it is currently in PLAY mode, */
|
3978 |
|
|
/* or reset the starting and ending locations when in PAUSED mode. */
|
3979 |
|
|
/* If applicable, at the next stopping point it reaches */
|
3980 |
|
|
/* the drive will discontinue playing. */
|
3981 |
|
|
switch (D_S[d].audio_state)
|
3982 |
|
|
{
|
3983 |
|
|
case audio_playing:
|
3984 |
|
|
if (famL_drive) i=cc_ReadSubQ();
|
3985 |
|
|
else i=cc_Pause_Resume(1);
|
3986 |
|
|
if (i<0) RETURN_UP(-EIO);
|
3987 |
|
|
if (famL_drive) i=cc_Pause_Resume(1);
|
3988 |
|
|
else i=cc_ReadSubQ();
|
3989 |
|
|
if (i<0) RETURN_UP(-EIO);
|
3990 |
|
|
D_S[d].pos_audio_start=D_S[d].SubQ_run_tot;
|
3991 |
|
|
D_S[d].audio_state=audio_pausing;
|
3992 |
|
|
RETURN_UP(0);
|
3993 |
|
|
case audio_pausing:
|
3994 |
|
|
i=cc_Seek(D_S[d].pos_audio_start,1);
|
3995 |
|
|
if (i<0) RETURN_UP(-EIO);
|
3996 |
|
|
RETURN_UP(0);
|
3997 |
|
|
default:
|
3998 |
|
|
RETURN_UP(-EINVAL);
|
3999 |
|
|
}
|
4000 |
|
|
|
4001 |
|
|
case CDROMRESUME: /* resume paused audio play */
|
4002 |
|
|
msg(DBG_IOC,"ioctl: CDROMRESUME entered.\n");
|
4003 |
|
|
/* resume playing audio tracks when a previous PLAY AUDIO call has */
|
4004 |
|
|
/* been paused with a PAUSE command. */
|
4005 |
|
|
/* It will resume playing from the location saved in SubQ_run_tot. */
|
4006 |
|
|
if (D_S[d].audio_state!=audio_pausing) return -EINVAL;
|
4007 |
|
|
if (famL_drive)
|
4008 |
|
|
i=cc_PlayAudio(D_S[d].pos_audio_start,
|
4009 |
|
|
D_S[d].pos_audio_end);
|
4010 |
|
|
else i=cc_Pause_Resume(3);
|
4011 |
|
|
if (i<0) RETURN_UP(-EIO);
|
4012 |
|
|
D_S[d].audio_state=audio_playing;
|
4013 |
|
|
RETURN_UP(0);
|
4014 |
|
|
|
4015 |
|
|
case CDROMPLAYMSF:
|
4016 |
|
|
msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n");
|
4017 |
|
|
#if SAFE_MIXED
|
4018 |
|
|
if (D_S[d].has_data>1) RETURN_UP(-EBUSY);
|
4019 |
|
|
#endif SAFE_MIXED
|
4020 |
|
|
if (D_S[d].audio_state==audio_playing)
|
4021 |
|
|
{
|
4022 |
|
|
i=cc_Pause_Resume(1);
|
4023 |
|
|
if (i<0) RETURN_UP(-EIO);
|
4024 |
|
|
i=cc_ReadSubQ();
|
4025 |
|
|
if (i<0) RETURN_UP(-EIO);
|
4026 |
|
|
D_S[d].pos_audio_start=D_S[d].SubQ_run_tot;
|
4027 |
|
|
i=cc_Seek(D_S[d].pos_audio_start,1);
|
4028 |
|
|
}
|
4029 |
|
|
st=verify_area(VERIFY_READ, (void *) arg, sizeof(struct cdrom_msf));
|
4030 |
|
|
if (st) RETURN_UP(st);
|
4031 |
|
|
memcpy_fromfs(&msf, (void *) arg, sizeof(struct cdrom_msf));
|
4032 |
|
|
/* values come as msf-bin */
|
4033 |
|
|
D_S[d].pos_audio_start = (msf.cdmsf_min0<<16) |
|
4034 |
|
|
(msf.cdmsf_sec0<<8) |
|
4035 |
|
|
msf.cdmsf_frame0;
|
4036 |
|
|
D_S[d].pos_audio_end = (msf.cdmsf_min1<<16) |
|
4037 |
|
|
(msf.cdmsf_sec1<<8) |
|
4038 |
|
|
msf.cdmsf_frame1;
|
4039 |
|
|
msg(DBG_IOX,"ioctl: CDROMPLAYMSF %08X %08X\n",
|
4040 |
|
|
D_S[d].pos_audio_start,D_S[d].pos_audio_end);
|
4041 |
|
|
i=cc_PlayAudio(D_S[d].pos_audio_start,D_S[d].pos_audio_end);
|
4042 |
|
|
if (i<0)
|
4043 |
|
|
{
|
4044 |
|
|
msg(DBG_INF,"ioctl: cc_PlayAudio returns %d\n",i);
|
4045 |
|
|
DriveReset();
|
4046 |
|
|
D_S[d].audio_state=0;
|
4047 |
|
|
RETURN_UP(-EIO);
|
4048 |
|
|
}
|
4049 |
|
|
D_S[d].audio_state=audio_playing;
|
4050 |
|
|
RETURN_UP(0);
|
4051 |
|
|
|
4052 |
|
|
case CDROMPLAYTRKIND: /* Play a track. This currently ignores index. */
|
4053 |
|
|
msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n");
|
4054 |
|
|
#if SAFE_MIXED
|
4055 |
|
|
if (D_S[d].has_data>1) RETURN_UP(-EBUSY);
|
4056 |
|
|
#endif SAFE_MIXED
|
4057 |
|
|
if (D_S[d].audio_state==audio_playing)
|
4058 |
|
|
{
|
4059 |
|
|
msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n");
|
4060 |
|
|
#if 1
|
4061 |
|
|
RETURN_UP(0); /* just let us play on */
|
4062 |
|
|
#else
|
4063 |
|
|
RETURN_UP(-EINVAL); /* play on, but say "error" */
|
4064 |
|
|
#endif
|
4065 |
|
|
}
|
4066 |
|
|
st=verify_area(VERIFY_READ,(void *) arg,sizeof(struct cdrom_ti));
|
4067 |
|
|
if (st<0)
|
4068 |
|
|
{
|
4069 |
|
|
msg(DBG_IOX,"CDROMPLAYTRKIND: verify_area error.\n");
|
4070 |
|
|
RETURN_UP(st);
|
4071 |
|
|
}
|
4072 |
|
|
memcpy_fromfs(&ti,(void *) arg,sizeof(struct cdrom_ti));
|
4073 |
|
|
msg(DBG_IOX,"ioctl: trk0: %d, ind0: %d, trk1:%d, ind1:%d\n",
|
4074 |
|
|
ti.cdti_trk0,ti.cdti_ind0,ti.cdti_trk1,ti.cdti_ind1);
|
4075 |
|
|
if (ti.cdti_trk0<D_S[d].n_first_track) RETURN_UP(-EINVAL);
|
4076 |
|
|
if (ti.cdti_trk0>D_S[d].n_last_track) RETURN_UP(-EINVAL);
|
4077 |
|
|
if (ti.cdti_trk1<ti.cdti_trk0) ti.cdti_trk1=ti.cdti_trk0;
|
4078 |
|
|
if (ti.cdti_trk1>D_S[d].n_last_track) ti.cdti_trk1=D_S[d].n_last_track;
|
4079 |
|
|
D_S[d].pos_audio_start=D_S[d].TocBuffer[ti.cdti_trk0].address;
|
4080 |
|
|
D_S[d].pos_audio_end=D_S[d].TocBuffer[ti.cdti_trk1+1].address;
|
4081 |
|
|
i=cc_PlayAudio(D_S[d].pos_audio_start,D_S[d].pos_audio_end);
|
4082 |
|
|
if (i<0)
|
4083 |
|
|
{
|
4084 |
|
|
msg(DBG_INF,"ioctl: cc_PlayAudio returns %d\n",i);
|
4085 |
|
|
DriveReset();
|
4086 |
|
|
D_S[d].audio_state=0;
|
4087 |
|
|
RETURN_UP(-EIO);
|
4088 |
|
|
}
|
4089 |
|
|
D_S[d].audio_state=audio_playing;
|
4090 |
|
|
RETURN_UP(0);
|
4091 |
|
|
|
4092 |
|
|
case CDROMREADTOCHDR: /* Read the table of contents header */
|
4093 |
|
|
msg(DBG_IOC,"ioctl: CDROMREADTOCHDR entered.\n");
|
4094 |
|
|
tochdr.cdth_trk0=D_S[d].n_first_track;
|
4095 |
|
|
tochdr.cdth_trk1=D_S[d].n_last_track;
|
4096 |
|
|
st=verify_area(VERIFY_WRITE, (void *) arg, sizeof(struct cdrom_tochdr));
|
4097 |
|
|
if (st) RETURN_UP(st);
|
4098 |
|
|
memcpy_tofs((void *) arg, &tochdr, sizeof(struct cdrom_tochdr));
|
4099 |
|
|
RETURN_UP(0);
|
4100 |
|
|
|
4101 |
|
|
case CDROMREADTOCENTRY: /* Read an entry in the table of contents */
|
4102 |
|
|
msg(DBG_IOC,"ioctl: CDROMREADTOCENTRY entered.\n");
|
4103 |
|
|
st=verify_area(VERIFY_WRITE,(void *) arg, sizeof(struct cdrom_tocentry));
|
4104 |
|
|
if (st) RETURN_UP(st);
|
4105 |
|
|
memcpy_fromfs(&tocentry, (void *) arg, sizeof(struct cdrom_tocentry));
|
4106 |
|
|
i=tocentry.cdte_track;
|
4107 |
|
|
if (i==CDROM_LEADOUT) i=D_S[d].n_last_track+1;
|
4108 |
|
|
else if (i<D_S[d].n_first_track||i>D_S[d].n_last_track)
|
4109 |
|
|
RETURN_UP(-EINVAL);
|
4110 |
|
|
tocentry.cdte_adr=D_S[d].TocBuffer[i].ctl_adr&0x0F;
|
4111 |
|
|
tocentry.cdte_ctrl=(D_S[d].TocBuffer[i].ctl_adr>>4)&0x0F;
|
4112 |
|
|
tocentry.cdte_datamode=D_S[d].TocBuffer[i].format;
|
4113 |
|
|
if (tocentry.cdte_format==CDROM_MSF) /* MSF-bin required */
|
4114 |
|
|
{
|
4115 |
|
|
tocentry.cdte_addr.msf.minute=(D_S[d].TocBuffer[i].address>>16)&0x00FF;
|
4116 |
|
|
tocentry.cdte_addr.msf.second=(D_S[d].TocBuffer[i].address>>8)&0x00FF;
|
4117 |
|
|
tocentry.cdte_addr.msf.frame=D_S[d].TocBuffer[i].address&0x00FF;
|
4118 |
|
|
}
|
4119 |
|
|
else if (tocentry.cdte_format==CDROM_LBA) /* blk required */
|
4120 |
|
|
tocentry.cdte_addr.lba=msf2blk(D_S[d].TocBuffer[i].address);
|
4121 |
|
|
else RETURN_UP(-EINVAL);
|
4122 |
|
|
memcpy_tofs((void *) arg, &tocentry, sizeof(struct cdrom_tocentry));
|
4123 |
|
|
RETURN_UP(0);
|
4124 |
|
|
|
4125 |
|
|
case CDROMRESET: /* hard reset the drive */
|
4126 |
|
|
msg(DBG_IOC,"ioctl: CDROMRESET entered.\n");
|
4127 |
|
|
i=DriveReset();
|
4128 |
|
|
D_S[d].audio_state=0;
|
4129 |
|
|
RETURN_UP(i);
|
4130 |
|
|
|
4131 |
|
|
case CDROMSTOP: /* Spin down the drive */
|
4132 |
|
|
msg(DBG_IOC,"ioctl: CDROMSTOP entered.\n");
|
4133 |
|
|
#if SAFE_MIXED
|
4134 |
|
|
if (D_S[d].has_data>1) RETURN_UP(-EBUSY);
|
4135 |
|
|
#endif SAFE_MIXED
|
4136 |
|
|
i=cc_Pause_Resume(1);
|
4137 |
|
|
D_S[d].audio_state=0;
|
4138 |
|
|
RETURN_UP(i);
|
4139 |
|
|
|
4140 |
|
|
case CDROMSTART: /* Spin up the drive */
|
4141 |
|
|
msg(DBG_IOC,"ioctl: CDROMSTART entered.\n");
|
4142 |
|
|
cc_SpinUp();
|
4143 |
|
|
D_S[d].audio_state=0;
|
4144 |
|
|
RETURN_UP(0);
|
4145 |
|
|
|
4146 |
|
|
case CDROMEJECT:
|
4147 |
|
|
msg(DBG_IOC,"ioctl: CDROMEJECT entered.\n");
|
4148 |
|
|
if (fam0_drive) return (0);
|
4149 |
|
|
if (D_S[d].open_count>1) RETURN_UP(-EBUSY);
|
4150 |
|
|
i=UnLockDoor();
|
4151 |
|
|
D_S[d].open_count=-9; /* to get it locked next time again */
|
4152 |
|
|
i=cc_SpinDown();
|
4153 |
|
|
msg(DBG_IOX,"ioctl: cc_SpinDown returned %d.\n", i);
|
4154 |
|
|
msg(DBG_TEA,"ioctl: cc_SpinDown returned %d.\n", i);
|
4155 |
|
|
if (i<0) RETURN_UP(-EIO);
|
4156 |
|
|
D_S[d].CD_changed=0xFF;
|
4157 |
|
|
D_S[d].diskstate_flags=0;
|
4158 |
|
|
D_S[d].audio_state=0;
|
4159 |
|
|
RETURN_UP(0);
|
4160 |
|
|
|
4161 |
|
|
case CDROMEJECT_SW:
|
4162 |
|
|
msg(DBG_IOC,"ioctl: CDROMEJECT_SW entered.\n");
|
4163 |
|
|
if (fam0_drive) RETURN_UP(0);
|
4164 |
|
|
D_S[d].f_eject=arg;
|
4165 |
|
|
RETURN_UP(0);
|
4166 |
|
|
|
4167 |
|
|
case CDROMVOLCTRL: /* Volume control */
|
4168 |
|
|
msg(DBG_IOC,"ioctl: CDROMVOLCTRL entered.\n");
|
4169 |
|
|
st=verify_area(VERIFY_READ,(void *) arg,sizeof(volctrl));
|
4170 |
|
|
if (st) RETURN_UP(st);
|
4171 |
|
|
memcpy_fromfs(&volctrl,(char *) arg,sizeof(volctrl));
|
4172 |
|
|
D_S[d].vol_chan0=0;
|
4173 |
|
|
D_S[d].vol_ctrl0=volctrl.channel0;
|
4174 |
|
|
D_S[d].vol_chan1=1;
|
4175 |
|
|
D_S[d].vol_ctrl1=volctrl.channel1;
|
4176 |
|
|
i=cc_SetVolume();
|
4177 |
|
|
RETURN_UP(0);
|
4178 |
|
|
|
4179 |
|
|
case CDROMVOLREAD: /* read Volume settings from drive */
|
4180 |
|
|
msg(DBG_IOC,"ioctl: CDROMVOLREAD entered.\n");
|
4181 |
|
|
st=verify_area(VERIFY_WRITE,(void *)arg,sizeof(volctrl));
|
4182 |
|
|
if (st) RETURN_UP(st);
|
4183 |
|
|
st=cc_GetVolume();
|
4184 |
|
|
if (st<0) return (st);
|
4185 |
|
|
volctrl.channel0=D_S[d].vol_ctrl0;
|
4186 |
|
|
volctrl.channel1=D_S[d].vol_ctrl1;
|
4187 |
|
|
volctrl.channel2=0;
|
4188 |
|
|
volctrl.channel2=0;
|
4189 |
|
|
memcpy_tofs((void *)arg,&volctrl,sizeof(volctrl));
|
4190 |
|
|
RETURN_UP(0);
|
4191 |
|
|
|
4192 |
|
|
case CDROMSUBCHNL: /* Get subchannel info */
|
4193 |
|
|
msg(DBG_IOS,"ioctl: CDROMSUBCHNL entered.\n");
|
4194 |
|
|
if ((st_spinning)||(!subq_valid)) {
|
4195 |
|
|
i=cc_ReadSubQ();
|
4196 |
|
|
if (i<0) RETURN_UP(-EIO);
|
4197 |
|
|
}
|
4198 |
|
|
st=verify_area(VERIFY_WRITE, (void *) arg, sizeof(struct cdrom_subchnl));
|
4199 |
|
|
if (st) RETURN_UP(st);
|
4200 |
|
|
memcpy_fromfs(&SC, (void *) arg, sizeof(struct cdrom_subchnl));
|
4201 |
|
|
switch (D_S[d].audio_state)
|
4202 |
|
|
{
|
4203 |
|
|
case audio_playing:
|
4204 |
|
|
SC.cdsc_audiostatus=CDROM_AUDIO_PLAY;
|
4205 |
|
|
break;
|
4206 |
|
|
case audio_pausing:
|
4207 |
|
|
SC.cdsc_audiostatus=CDROM_AUDIO_PAUSED;
|
4208 |
|
|
break;
|
4209 |
|
|
default:
|
4210 |
|
|
SC.cdsc_audiostatus=CDROM_AUDIO_NO_STATUS;
|
4211 |
|
|
break;
|
4212 |
|
|
}
|
4213 |
|
|
SC.cdsc_adr=D_S[d].SubQ_ctl_adr;
|
4214 |
|
|
SC.cdsc_ctrl=D_S[d].SubQ_ctl_adr>>4;
|
4215 |
|
|
SC.cdsc_trk=bcd2bin(D_S[d].SubQ_trk);
|
4216 |
|
|
SC.cdsc_ind=bcd2bin(D_S[d].SubQ_pnt_idx);
|
4217 |
|
|
if (SC.cdsc_format==CDROM_LBA)
|
4218 |
|
|
{
|
4219 |
|
|
SC.cdsc_absaddr.lba=msf2blk(D_S[d].SubQ_run_tot);
|
4220 |
|
|
SC.cdsc_reladdr.lba=msf2blk(D_S[d].SubQ_run_trk);
|
4221 |
|
|
}
|
4222 |
|
|
else /* not only if (SC.cdsc_format==CDROM_MSF) */
|
4223 |
|
|
{
|
4224 |
|
|
SC.cdsc_absaddr.msf.minute=(D_S[d].SubQ_run_tot>>16)&0x00FF;
|
4225 |
|
|
SC.cdsc_absaddr.msf.second=(D_S[d].SubQ_run_tot>>8)&0x00FF;
|
4226 |
|
|
SC.cdsc_absaddr.msf.frame=D_S[d].SubQ_run_tot&0x00FF;
|
4227 |
|
|
SC.cdsc_reladdr.msf.minute=(D_S[d].SubQ_run_trk>>16)&0x00FF;
|
4228 |
|
|
SC.cdsc_reladdr.msf.second=(D_S[d].SubQ_run_trk>>8)&0x00FF;
|
4229 |
|
|
SC.cdsc_reladdr.msf.frame=D_S[d].SubQ_run_trk&0x00FF;
|
4230 |
|
|
}
|
4231 |
|
|
memcpy_tofs((void *) arg, &SC, sizeof(struct cdrom_subchnl));
|
4232 |
|
|
msg(DBG_IOS,"CDROMSUBCHNL: %1X %02X %08X %08X %02X %02X %06X %06X\n",
|
4233 |
|
|
SC.cdsc_format,SC.cdsc_audiostatus,
|
4234 |
|
|
SC.cdsc_adr,SC.cdsc_ctrl,
|
4235 |
|
|
SC.cdsc_trk,SC.cdsc_ind,
|
4236 |
|
|
SC.cdsc_absaddr,SC.cdsc_reladdr);
|
4237 |
|
|
RETURN_UP(0);
|
4238 |
|
|
|
4239 |
|
|
case CDROMREADMODE1:
|
4240 |
|
|
msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n");
|
4241 |
|
|
#if SAFE_MIXED
|
4242 |
|
|
if (D_S[d].has_data>1) RETURN_UP(-EBUSY);
|
4243 |
|
|
#endif SAFE_MIXED
|
4244 |
|
|
cc_ModeSelect(CD_FRAMESIZE);
|
4245 |
|
|
cc_ModeSense();
|
4246 |
|
|
D_S[d].mode=READ_M1;
|
4247 |
|
|
RETURN_UP(0);
|
4248 |
|
|
|
4249 |
|
|
case CDROMREADMODE2: /* not usable at the moment */
|
4250 |
|
|
msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n");
|
4251 |
|
|
#if SAFE_MIXED
|
4252 |
|
|
if (D_S[d].has_data>1) RETURN_UP(-EBUSY);
|
4253 |
|
|
#endif SAFE_MIXED
|
4254 |
|
|
cc_ModeSelect(CD_FRAMESIZE_RAW1);
|
4255 |
|
|
cc_ModeSense();
|
4256 |
|
|
D_S[d].mode=READ_M2;
|
4257 |
|
|
RETURN_UP(0);
|
4258 |
|
|
|
4259 |
|
|
case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */
|
4260 |
|
|
msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n");
|
4261 |
|
|
if (D_S[d].sbp_audsiz>0) vfree(D_S[d].aud_buf);
|
4262 |
|
|
D_S[d].aud_buf=NULL;
|
4263 |
|
|
D_S[d].sbp_audsiz=arg;
|
4264 |
|
|
if (D_S[d].sbp_audsiz>0)
|
4265 |
|
|
{
|
4266 |
|
|
D_S[d].aud_buf=(u_char *) vmalloc(D_S[d].sbp_audsiz*CD_FRAMESIZE_RAW);
|
4267 |
|
|
if (D_S[d].aud_buf==NULL)
|
4268 |
|
|
{
|
4269 |
|
|
msg(DBG_INF,"audio buffer (%d frames) not available.\n",D_S[d].sbp_audsiz);
|
4270 |
|
|
D_S[d].sbp_audsiz=0;
|
4271 |
|
|
}
|
4272 |
|
|
else msg(DBG_INF,"audio buffer size: %d frames.\n",D_S[d].sbp_audsiz);
|
4273 |
|
|
}
|
4274 |
|
|
RETURN_UP(D_S[d].sbp_audsiz);
|
4275 |
|
|
|
4276 |
|
|
case CDROMREADAUDIO:
|
4277 |
|
|
{ /* start of CDROMREADAUDIO */
|
4278 |
|
|
int i=0, j=0, frame, block=0;
|
4279 |
|
|
u_int try=0;
|
4280 |
|
|
u_long timeout;
|
4281 |
|
|
u_char *p;
|
4282 |
|
|
u_int data_tries = 0;
|
4283 |
|
|
u_int data_waits = 0;
|
4284 |
|
|
u_int data_retrying = 0;
|
4285 |
|
|
int status_tries;
|
4286 |
|
|
int error_flag;
|
4287 |
|
|
|
4288 |
|
|
msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n");
|
4289 |
|
|
if (fam0_drive) RETURN_UP(-EINVAL);
|
4290 |
|
|
if (famL_drive) RETURN_UP(-EINVAL);
|
4291 |
|
|
if (famV_drive) RETURN_UP(-EINVAL);
|
4292 |
|
|
if (famT_drive) RETURN_UP(-EINVAL);
|
4293 |
|
|
#if SAFE_MIXED
|
4294 |
|
|
if (D_S[d].has_data>1) RETURN_UP(-EBUSY);
|
4295 |
|
|
#endif SAFE_MIXED
|
4296 |
|
|
if (D_S[d].aud_buf==NULL) RETURN_UP(-EINVAL);
|
4297 |
|
|
i=verify_area(VERIFY_READ, (void *) arg, sizeof(struct cdrom_read_audio));
|
4298 |
|
|
if (i) RETURN_UP(i);
|
4299 |
|
|
memcpy_fromfs(&read_audio, (void *) arg, sizeof(struct cdrom_read_audio));
|
4300 |
|
|
if (read_audio.nframes>D_S[d].sbp_audsiz) RETURN_UP(-EINVAL);
|
4301 |
|
|
i=verify_area(VERIFY_WRITE, read_audio.buf,
|
4302 |
|
|
read_audio.nframes*CD_FRAMESIZE_RAW);
|
4303 |
|
|
if (i) RETURN_UP(i);
|
4304 |
|
|
|
4305 |
|
|
if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */
|
4306 |
|
|
block=msf2lba(&read_audio.addr.msf.minute);
|
4307 |
|
|
else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */
|
4308 |
|
|
block=read_audio.addr.lba;
|
4309 |
|
|
else RETURN_UP(-EINVAL);
|
4310 |
|
|
#if 000
|
4311 |
|
|
i=cc_SetSpeed(speed_150,0,0);
|
4312 |
|
|
if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i);
|
4313 |
|
|
#endif
|
4314 |
|
|
msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n",
|
4315 |
|
|
block, blk2msf(block));
|
4316 |
|
|
msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n");
|
4317 |
|
|
#if OLD_BUSY
|
4318 |
|
|
while (busy_data) sbp_sleep(HZ/10); /* wait a bit */
|
4319 |
|
|
busy_audio=1;
|
4320 |
|
|
#endif OLD_BUSY
|
4321 |
|
|
error_flag=0;
|
4322 |
|
|
for (data_tries=5; data_tries>0; data_tries--)
|
4323 |
|
|
{
|
4324 |
|
|
msg(DBG_AUD,"data_tries=%d ...\n", data_tries);
|
4325 |
|
|
D_S[d].mode=READ_AU;
|
4326 |
|
|
cc_ModeSelect(CD_FRAMESIZE_RAW);
|
4327 |
|
|
cc_ModeSense();
|
4328 |
|
|
for (status_tries=3; status_tries > 0; status_tries--)
|
4329 |
|
|
{
|
4330 |
|
|
flags_cmd_out |= f_respo3;
|
4331 |
|
|
cc_ReadStatus();
|
4332 |
|
|
if (sbp_status() != 0) break;
|
4333 |
|
|
if (st_check) cc_ReadError();
|
4334 |
|
|
sbp_sleep(1); /* wait a bit, try again */
|
4335 |
|
|
}
|
4336 |
|
|
if (status_tries == 0)
|
4337 |
|
|
{
|
4338 |
|
|
msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries.\n");
|
4339 |
|
|
continue;
|
4340 |
|
|
}
|
4341 |
|
|
msg(DBG_AUD,"read_audio: sbp_status: ok.\n");
|
4342 |
|
|
|
4343 |
|
|
flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check;
|
4344 |
|
|
if (fam0L_drive)
|
4345 |
|
|
{
|
4346 |
|
|
flags_cmd_out |= f_lopsta | f_getsta | f_bit1;
|
4347 |
|
|
cmd_type=READ_M2;
|
4348 |
|
|
drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */
|
4349 |
|
|
drvcmd[1]=(block>>16)&0x000000ff;
|
4350 |
|
|
drvcmd[2]=(block>>8)&0x000000ff;
|
4351 |
|
|
drvcmd[3]=block&0x000000ff;
|
4352 |
|
|
drvcmd[4]=0;
|
4353 |
|
|
drvcmd[5]=read_audio.nframes; /* # of frames */
|
4354 |
|
|
drvcmd[6]=0;
|
4355 |
|
|
}
|
4356 |
|
|
else if (fam1_drive)
|
4357 |
|
|
{
|
4358 |
|
|
drvcmd[0]=CMD1_READ; /* "read frames", new drives */
|
4359 |
|
|
lba2msf(block,&drvcmd[1]); /* msf-bin format required */
|
4360 |
|
|
drvcmd[4]=0;
|
4361 |
|
|
drvcmd[5]=0;
|
4362 |
|
|
drvcmd[6]=read_audio.nframes; /* # of frames */
|
4363 |
|
|
}
|
4364 |
|
|
else if (fam2_drive)
|
4365 |
|
|
{
|
4366 |
|
|
drvcmd[0]=CMD2_READ_XA2;
|
4367 |
|
|
lba2msf(block,&drvcmd[1]); /* msf-bin format required */
|
4368 |
|
|
drvcmd[4]=0;
|
4369 |
|
|
drvcmd[5]=read_audio.nframes; /* # of frames */
|
4370 |
|
|
drvcmd[6]=0x11; /* raw mode */
|
4371 |
|
|
}
|
4372 |
|
|
else if (famT_drive) /* CD-55A: not tested yet */
|
4373 |
|
|
{
|
4374 |
|
|
}
|
4375 |
|
|
msg(DBG_AUD,"read_audio: before giving \"read\" command.\n");
|
4376 |
|
|
flags_cmd_out=f_putcmd;
|
4377 |
|
|
response_count=0;
|
4378 |
|
|
i=cmd_out();
|
4379 |
|
|
if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i);
|
4380 |
|
|
sbp_sleep(0);
|
4381 |
|
|
msg(DBG_AUD,"read_audio: after giving \"read\" command.\n");
|
4382 |
|
|
for (frame=1;frame<2 && !error_flag; frame++)
|
4383 |
|
|
{
|
4384 |
|
|
try=maxtim_data;
|
4385 |
|
|
for (timeout=jiffies+9*HZ; ; )
|
4386 |
|
|
{
|
4387 |
|
|
for ( ; try!=0;try--)
|
4388 |
|
|
{
|
4389 |
|
|
j=inb(CDi_status);
|
4390 |
|
|
if (!(j&s_not_data_ready)) break;
|
4391 |
|
|
if (!(j&s_not_result_ready)) break;
|
4392 |
|
|
if (fam0L_drive) if (j&s_attention) break;
|
4393 |
|
|
}
|
4394 |
|
|
if (try != 0 || timeout <= jiffies) break;
|
4395 |
|
|
if (data_retrying == 0) data_waits++;
|
4396 |
|
|
data_retrying = 1;
|
4397 |
|
|
sbp_sleep(1);
|
4398 |
|
|
try = 1;
|
4399 |
|
|
}
|
4400 |
|
|
if (try==0)
|
4401 |
|
|
{
|
4402 |
|
|
msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n");
|
4403 |
|
|
error_flag++;
|
4404 |
|
|
break;
|
4405 |
|
|
}
|
4406 |
|
|
msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n");
|
4407 |
|
|
if (j&s_not_data_ready)
|
4408 |
|
|
{
|
4409 |
|
|
msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n");
|
4410 |
|
|
error_flag++;
|
4411 |
|
|
break;
|
4412 |
|
|
}
|
4413 |
|
|
msg(DBG_AUD,"read_audio: before reading data.\n");
|
4414 |
|
|
error_flag=0;
|
4415 |
|
|
p = D_S[d].aud_buf;
|
4416 |
|
|
if (sbpro_type==1) OUT(CDo_sel_i_d,1);
|
4417 |
|
|
if (do_16bit) insw(CDi_data, p, read_audio.nframes*(CD_FRAMESIZE_RAW>>1));
|
4418 |
|
|
else insb(CDi_data, p, read_audio.nframes*CD_FRAMESIZE_RAW);
|
4419 |
|
|
if (sbpro_type==1) OUT(CDo_sel_i_d,0);
|
4420 |
|
|
data_retrying = 0;
|
4421 |
|
|
}
|
4422 |
|
|
msg(DBG_AUD,"read_audio: after reading data.\n");
|
4423 |
|
|
if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */
|
4424 |
|
|
{
|
4425 |
|
|
msg(DBG_AUD,"read_audio: read aborted by drive\n");
|
4426 |
|
|
#if 0000
|
4427 |
|
|
i=cc_DriveReset(); /* ugly fix to prevent a hang */
|
4428 |
|
|
#else
|
4429 |
|
|
i=cc_ReadError();
|
4430 |
|
|
#endif 0000
|
4431 |
|
|
continue;
|
4432 |
|
|
}
|
4433 |
|
|
if (fam0L_drive)
|
4434 |
|
|
{
|
4435 |
|
|
i=maxtim_data;
|
4436 |
|
|
for (timeout=jiffies+9*HZ; timeout > jiffies; timeout--)
|
4437 |
|
|
{
|
4438 |
|
|
for ( ;i!=0;i--)
|
4439 |
|
|
{
|
4440 |
|
|
j=inb(CDi_status);
|
4441 |
|
|
if (!(j&s_not_data_ready)) break;
|
4442 |
|
|
if (!(j&s_not_result_ready)) break;
|
4443 |
|
|
if (j&s_attention) break;
|
4444 |
|
|
}
|
4445 |
|
|
if (i != 0 || timeout <= jiffies) break;
|
4446 |
|
|
sbp_sleep(0);
|
4447 |
|
|
i = 1;
|
4448 |
|
|
}
|
4449 |
|
|
if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ");
|
4450 |
|
|
if (!(j&s_attention))
|
4451 |
|
|
{
|
4452 |
|
|
msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n");
|
4453 |
|
|
i=cc_DriveReset(); /* ugly fix to prevent a hang */
|
4454 |
|
|
continue;
|
4455 |
|
|
}
|
4456 |
|
|
}
|
4457 |
|
|
do
|
4458 |
|
|
{
|
4459 |
|
|
if (fam0L_drive) cc_ReadStatus();
|
4460 |
|
|
i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */
|
4461 |
|
|
if (i<0) { msg(DBG_AUD,
|
4462 |
|
|
"read_audio: cc_ReadStatus error after read: %02X\n",
|
4463 |
|
|
D_S[d].status_bits);
|
4464 |
|
|
continue; /* FIXME */
|
4465 |
|
|
}
|
4466 |
|
|
}
|
4467 |
|
|
while ((fam0L_drive)&&(!st_check)&&(!(i&p_success)));
|
4468 |
|
|
if (st_check)
|
4469 |
|
|
{
|
4470 |
|
|
i=cc_ReadError();
|
4471 |
|
|
msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i);
|
4472 |
|
|
continue;
|
4473 |
|
|
}
|
4474 |
|
|
memcpy_tofs((u_char *) read_audio.buf,
|
4475 |
|
|
(u_char *) D_S[d].aud_buf,
|
4476 |
|
|
read_audio.nframes*CD_FRAMESIZE_RAW);
|
4477 |
|
|
msg(DBG_AUD,"read_audio: memcpy_tofs done.\n");
|
4478 |
|
|
break;
|
4479 |
|
|
}
|
4480 |
|
|
cc_ModeSelect(CD_FRAMESIZE);
|
4481 |
|
|
cc_ModeSense();
|
4482 |
|
|
D_S[d].mode=READ_M1;
|
4483 |
|
|
#if OLD_BUSY
|
4484 |
|
|
busy_audio=0;
|
4485 |
|
|
#endif OLD_BUSY
|
4486 |
|
|
if (data_tries == 0)
|
4487 |
|
|
{
|
4488 |
|
|
msg(DBG_AUD,"read_audio: failed after 5 tries.\n");
|
4489 |
|
|
RETURN_UP(-EIO);
|
4490 |
|
|
}
|
4491 |
|
|
msg(DBG_AUD,"read_audio: successful return.\n");
|
4492 |
|
|
RETURN_UP(0);
|
4493 |
|
|
} /* end of CDROMREADAUDIO */
|
4494 |
|
|
|
4495 |
|
|
case CDROMMULTISESSION: /* tell start-of-last-session */
|
4496 |
|
|
msg(DBG_IOC,"ioctl: CDROMMULTISESSION entered.\n");
|
4497 |
|
|
st=verify_area(VERIFY_WRITE,(void *) arg, sizeof(struct cdrom_multisession));
|
4498 |
|
|
if (st) RETURN_UP(st);
|
4499 |
|
|
memcpy_fromfs(&ms_info, (void *) arg, sizeof(struct cdrom_multisession));
|
4500 |
|
|
if (ms_info.addr_format==CDROM_MSF) /* MSF-bin requested */
|
4501 |
|
|
lba2msf(D_S[d].lba_multi,&ms_info.addr.msf.minute);
|
4502 |
|
|
else if (ms_info.addr_format==CDROM_LBA) /* lba requested */
|
4503 |
|
|
ms_info.addr.lba=D_S[d].lba_multi;
|
4504 |
|
|
else RETURN_UP(-EINVAL);
|
4505 |
|
|
if (D_S[d].f_multisession) ms_info.xa_flag=1; /* valid redirection address */
|
4506 |
|
|
else ms_info.xa_flag=0; /* invalid redirection address */
|
4507 |
|
|
memcpy_tofs((void *) arg, &ms_info, sizeof(struct cdrom_multisession));
|
4508 |
|
|
msg(DBG_MUL,"ioctl: CDROMMULTISESSION done (%d, %08X).\n",
|
4509 |
|
|
ms_info.xa_flag, ms_info.addr.lba);
|
4510 |
|
|
RETURN_UP(0);
|
4511 |
|
|
|
4512 |
|
|
case BLKRASET:
|
4513 |
|
|
if(!suser()) RETURN_UP(-EACCES);
|
4514 |
|
|
if(!(inode->i_rdev)) RETURN_UP(-EINVAL);
|
4515 |
|
|
if(arg > 0xff) RETURN_UP(-EINVAL);
|
4516 |
|
|
read_ahead[MAJOR(inode->i_rdev)] = arg;
|
4517 |
|
|
RETURN_UP(0);
|
4518 |
|
|
|
4519 |
|
|
default:
|
4520 |
|
|
msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd);
|
4521 |
|
|
RETURN_UP(-EINVAL);
|
4522 |
|
|
} /* end switch(cmd) */
|
4523 |
|
|
}
|
4524 |
|
|
/*==========================================================================*/
|
4525 |
|
|
/*
|
4526 |
|
|
* Take care of the different block sizes between cdrom and Linux.
|
4527 |
|
|
*/
|
4528 |
|
|
static void sbp_transfer(struct request *req)
|
4529 |
|
|
{
|
4530 |
|
|
long offs;
|
4531 |
|
|
|
4532 |
|
|
while ( (req->nr_sectors > 0) &&
|
4533 |
|
|
(req->sector/4 >= D_S[d].sbp_first_frame) &&
|
4534 |
|
|
(req->sector/4 <= D_S[d].sbp_last_frame) )
|
4535 |
|
|
{
|
4536 |
|
|
offs = (req->sector - D_S[d].sbp_first_frame * 4) * 512;
|
4537 |
|
|
memcpy(req->buffer, D_S[d].sbp_buf + offs, 512);
|
4538 |
|
|
req->nr_sectors--;
|
4539 |
|
|
req->sector++;
|
4540 |
|
|
req->buffer += 512;
|
4541 |
|
|
}
|
4542 |
|
|
}
|
4543 |
|
|
/*==========================================================================*/
|
4544 |
|
|
/*
|
4545 |
|
|
* special end_request for sbpcd to solve CURRENT==NULL bug. (GTL)
|
4546 |
|
|
* GTL = Gonzalo Tornaria <tornaria@cmat.edu.uy>
|
4547 |
|
|
*
|
4548 |
|
|
* This is a kludge so we don't need to modify end_request.
|
4549 |
|
|
* We put the req we take out after INIT_REQUEST in the requests list,
|
4550 |
|
|
* so that end_request will discard it.
|
4551 |
|
|
*
|
4552 |
|
|
* The bug could be present in other block devices, perhaps we
|
4553 |
|
|
* should modify INIT_REQUEST and end_request instead, and
|
4554 |
|
|
* change every block device..
|
4555 |
|
|
*
|
4556 |
|
|
* Could be a race here?? Could e.g. a timer interrupt schedule() us?
|
4557 |
|
|
* If so, we should copy end_request here, and do it right.. (or
|
4558 |
|
|
* modify end_request and the block devices).
|
4559 |
|
|
*
|
4560 |
|
|
* In any case, the race here would be much small than it was, and
|
4561 |
|
|
* I couldn't reproduce..
|
4562 |
|
|
*
|
4563 |
|
|
* The race could be: suppose CURRENT==NULL. We put our req in the list,
|
4564 |
|
|
* and we are scheduled. Other process takes over, and gets into
|
4565 |
|
|
* do_sbpcd_request. It sees CURRENT!=NULL (it is == to our req), so
|
4566 |
|
|
* proceeds. It ends, so CURRENT is now NULL.. Now we awake somewhere in
|
4567 |
|
|
* end_request, but now CURRENT==NULL... oops!
|
4568 |
|
|
*
|
4569 |
|
|
*/
|
4570 |
|
|
#undef DEBUG_GTL
|
4571 |
|
|
static inline void sbpcd_end_request(struct request *req, int uptodate) {
|
4572 |
|
|
req->next=CURRENT;
|
4573 |
|
|
CURRENT=req;
|
4574 |
|
|
up(&ioctl_read_sem);
|
4575 |
|
|
end_request(uptodate);
|
4576 |
|
|
}
|
4577 |
|
|
/*==========================================================================*/
|
4578 |
|
|
/*
|
4579 |
|
|
* I/O request routine, called from Linux kernel.
|
4580 |
|
|
*/
|
4581 |
|
|
static void DO_SBPCD_REQUEST(void)
|
4582 |
|
|
{
|
4583 |
|
|
u_int block;
|
4584 |
|
|
u_int nsect;
|
4585 |
|
|
int i, status_tries, data_tries;
|
4586 |
|
|
struct request *req;
|
4587 |
|
|
#ifdef DEBUG_GTL
|
4588 |
|
|
static int xx_nr=0;
|
4589 |
|
|
int xnr;
|
4590 |
|
|
#endif
|
4591 |
|
|
|
4592 |
|
|
request_loop:
|
4593 |
|
|
#ifdef DEBUG_GTL
|
4594 |
|
|
xnr=++xx_nr;
|
4595 |
|
|
|
4596 |
|
|
if(!CURRENT)
|
4597 |
|
|
{
|
4598 |
|
|
printk( "do_sbpcd_request[%di](NULL), Pid:%d, Time:%li\n",
|
4599 |
|
|
xnr, current->pid, jiffies);
|
4600 |
|
|
printk( "do_sbpcd_request[%do](NULL) end 0 (null), Time:%li\n",
|
4601 |
|
|
xnr, jiffies);
|
4602 |
|
|
CLEAR_INTR;
|
4603 |
|
|
return;
|
4604 |
|
|
}
|
4605 |
|
|
|
4606 |
|
|
printk(" do_sbpcd_request[%di](%p:%ld+%ld), Pid:%d, Time:%li\n",
|
4607 |
|
|
xnr, CURRENT, CURRENT->sector, CURRENT->nr_sectors, current->pid, jiffies);
|
4608 |
|
|
#endif
|
4609 |
|
|
INIT_REQUEST;
|
4610 |
|
|
req=CURRENT; /* take out our request so no other */
|
4611 |
|
|
CURRENT=req->next; /* task can fuck it up GTL */
|
4612 |
|
|
sti();
|
4613 |
|
|
|
4614 |
|
|
down(&ioctl_read_sem);
|
4615 |
|
|
if (req->rq_status == RQ_INACTIVE)
|
4616 |
|
|
sbpcd_end_request(req, 0);
|
4617 |
|
|
if (req -> sector == -1)
|
4618 |
|
|
sbpcd_end_request(req, 0);
|
4619 |
|
|
|
4620 |
|
|
if (req->cmd != READ)
|
4621 |
|
|
{
|
4622 |
|
|
msg(DBG_INF, "bad cmd %d\n", req->cmd);
|
4623 |
|
|
goto err_done;
|
4624 |
|
|
}
|
4625 |
|
|
i = MINOR(req->rq_dev);
|
4626 |
|
|
if ( (i<0) || (i>=NR_SBPCD) || (D_S[i].drv_id==-1))
|
4627 |
|
|
{
|
4628 |
|
|
msg(DBG_INF, "do_request: bad device: %s\n",
|
4629 |
|
|
kdevname(req->rq_dev));
|
4630 |
|
|
goto err_done;
|
4631 |
|
|
}
|
4632 |
|
|
#if OLD_BUSY
|
4633 |
|
|
while (busy_audio) sbp_sleep(HZ); /* wait a bit */
|
4634 |
|
|
busy_data=1;
|
4635 |
|
|
#endif OLD_BUSY
|
4636 |
|
|
|
4637 |
|
|
if (D_S[i].audio_state==audio_playing) goto err_done;
|
4638 |
|
|
if (d!=i) switch_drive(i);
|
4639 |
|
|
|
4640 |
|
|
block = req->sector; /* always numbered as 512-byte-pieces */
|
4641 |
|
|
nsect = req->nr_sectors; /* always counted as 512-byte-pieces */
|
4642 |
|
|
|
4643 |
|
|
msg(DBG_BSZ,"read sector %d (%d sectors)\n", block, nsect);
|
4644 |
|
|
#if 0
|
4645 |
|
|
msg(DBG_MUL,"read LBA %d\n", block/4);
|
4646 |
|
|
#endif
|
4647 |
|
|
|
4648 |
|
|
sbp_transfer(req);
|
4649 |
|
|
/* if we satisfied the request from the buffer, we're done. */
|
4650 |
|
|
if (req->nr_sectors == 0)
|
4651 |
|
|
{
|
4652 |
|
|
#ifdef DEBUG_GTL
|
4653 |
|
|
printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 2, Time:%li\n",
|
4654 |
|
|
xnr, req, req->sector, req->nr_sectors, jiffies);
|
4655 |
|
|
#endif
|
4656 |
|
|
sbpcd_end_request(req, 1);
|
4657 |
|
|
goto request_loop;
|
4658 |
|
|
}
|
4659 |
|
|
|
4660 |
|
|
#if FUTURE
|
4661 |
|
|
i=prepare(0,0); /* at moment not really a hassle check, but ... */
|
4662 |
|
|
if (i!=0)
|
4663 |
|
|
msg(DBG_INF,"\"prepare\" tells error %d -- ignored\n", i);
|
4664 |
|
|
#endif FUTURE
|
4665 |
|
|
|
4666 |
|
|
if (!st_spinning) cc_SpinUp();
|
4667 |
|
|
|
4668 |
|
|
for (data_tries=n_retries; data_tries > 0; data_tries--)
|
4669 |
|
|
{
|
4670 |
|
|
for (status_tries=3; status_tries > 0; status_tries--)
|
4671 |
|
|
{
|
4672 |
|
|
flags_cmd_out |= f_respo3;
|
4673 |
|
|
cc_ReadStatus();
|
4674 |
|
|
if (sbp_status() != 0) break;
|
4675 |
|
|
if (st_check) cc_ReadError();
|
4676 |
|
|
sbp_sleep(1); /* wait a bit, try again */
|
4677 |
|
|
}
|
4678 |
|
|
if (status_tries == 0)
|
4679 |
|
|
{
|
4680 |
|
|
msg(DBG_INF,"sbp_status: failed after 3 tries\n");
|
4681 |
|
|
break;
|
4682 |
|
|
}
|
4683 |
|
|
|
4684 |
|
|
sbp_read_cmd(req);
|
4685 |
|
|
sbp_sleep(0);
|
4686 |
|
|
if (sbp_data(req) != 0)
|
4687 |
|
|
{
|
4688 |
|
|
#if SAFE_MIXED
|
4689 |
|
|
D_S[d].has_data=2; /* is really a data disk */
|
4690 |
|
|
#endif SAFE_MIXED
|
4691 |
|
|
#ifdef DEBUG_GTL
|
4692 |
|
|
printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 3, Time:%li\n",
|
4693 |
|
|
xnr, req, req->sector, req->nr_sectors, jiffies);
|
4694 |
|
|
#endif
|
4695 |
|
|
sbpcd_end_request(req, 1);
|
4696 |
|
|
goto request_loop;
|
4697 |
|
|
}
|
4698 |
|
|
}
|
4699 |
|
|
|
4700 |
|
|
err_done:
|
4701 |
|
|
#if OLD_BUSY
|
4702 |
|
|
busy_data=0;
|
4703 |
|
|
#endif OLD_BUSY
|
4704 |
|
|
#ifdef DEBUG_GTL
|
4705 |
|
|
printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 4 (error), Time:%li\n",
|
4706 |
|
|
xnr, req, req->sector, req->nr_sectors, jiffies);
|
4707 |
|
|
#endif
|
4708 |
|
|
sbpcd_end_request(req, 0);
|
4709 |
|
|
sbp_sleep(0); /* wait a bit, try again */
|
4710 |
|
|
goto request_loop;
|
4711 |
|
|
}
|
4712 |
|
|
/*==========================================================================*/
|
4713 |
|
|
/*
|
4714 |
|
|
* build and send the READ command.
|
4715 |
|
|
*/
|
4716 |
|
|
static void sbp_read_cmd(struct request *req)
|
4717 |
|
|
{
|
4718 |
|
|
#undef OLD
|
4719 |
|
|
|
4720 |
|
|
int i;
|
4721 |
|
|
int block;
|
4722 |
|
|
|
4723 |
|
|
D_S[d].sbp_first_frame=D_S[d].sbp_last_frame=-1; /* purge buffer */
|
4724 |
|
|
D_S[d].sbp_current = 0;
|
4725 |
|
|
block=req->sector/4;
|
4726 |
|
|
if (block+D_S[d].sbp_bufsiz <= D_S[d].CDsize_frm)
|
4727 |
|
|
D_S[d].sbp_read_frames = D_S[d].sbp_bufsiz;
|
4728 |
|
|
else
|
4729 |
|
|
{
|
4730 |
|
|
D_S[d].sbp_read_frames=D_S[d].CDsize_frm-block;
|
4731 |
|
|
/* avoid reading past end of data */
|
4732 |
|
|
if (D_S[d].sbp_read_frames < 1)
|
4733 |
|
|
{
|
4734 |
|
|
msg(DBG_INF,"requested frame %d, CD size %d ???\n",
|
4735 |
|
|
block, D_S[d].CDsize_frm);
|
4736 |
|
|
D_S[d].sbp_read_frames=1;
|
4737 |
|
|
}
|
4738 |
|
|
}
|
4739 |
|
|
|
4740 |
|
|
flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check;
|
4741 |
|
|
clr_cmdbuf();
|
4742 |
|
|
if (famV_drive)
|
4743 |
|
|
{
|
4744 |
|
|
drvcmd[0]=CMDV_READ;
|
4745 |
|
|
lba2msf(block,&drvcmd[1]); /* msf-bcd format required */
|
4746 |
|
|
bin2bcdx(&drvcmd[1]);
|
4747 |
|
|
bin2bcdx(&drvcmd[2]);
|
4748 |
|
|
bin2bcdx(&drvcmd[3]);
|
4749 |
|
|
drvcmd[4]=D_S[d].sbp_read_frames>>8;
|
4750 |
|
|
drvcmd[5]=D_S[d].sbp_read_frames&0xff;
|
4751 |
|
|
drvcmd[6]=0x02; /* flag "msf-bcd" */
|
4752 |
|
|
}
|
4753 |
|
|
else if (fam0L_drive)
|
4754 |
|
|
{
|
4755 |
|
|
flags_cmd_out |= f_lopsta | f_getsta | f_bit1;
|
4756 |
|
|
if (D_S[d].xa_byte==0x20)
|
4757 |
|
|
{
|
4758 |
|
|
cmd_type=READ_M2;
|
4759 |
|
|
drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */
|
4760 |
|
|
drvcmd[1]=(block>>16)&0x0ff;
|
4761 |
|
|
drvcmd[2]=(block>>8)&0x0ff;
|
4762 |
|
|
drvcmd[3]=block&0x0ff;
|
4763 |
|
|
drvcmd[4]=(D_S[d].sbp_read_frames>>8)&0x0ff;
|
4764 |
|
|
drvcmd[5]=D_S[d].sbp_read_frames&0x0ff;
|
4765 |
|
|
}
|
4766 |
|
|
else
|
4767 |
|
|
{
|
4768 |
|
|
drvcmd[0]=CMD0_READ; /* "read frames", old drives */
|
4769 |
|
|
if (D_S[d].drv_type>=drv_201)
|
4770 |
|
|
{
|
4771 |
|
|
lba2msf(block,&drvcmd[1]); /* msf-bcd format required */
|
4772 |
|
|
bin2bcdx(&drvcmd[1]);
|
4773 |
|
|
bin2bcdx(&drvcmd[2]);
|
4774 |
|
|
bin2bcdx(&drvcmd[3]);
|
4775 |
|
|
}
|
4776 |
|
|
else
|
4777 |
|
|
{
|
4778 |
|
|
drvcmd[1]=(block>>16)&0x0ff;
|
4779 |
|
|
drvcmd[2]=(block>>8)&0x0ff;
|
4780 |
|
|
drvcmd[3]=block&0x0ff;
|
4781 |
|
|
}
|
4782 |
|
|
drvcmd[4]=(D_S[d].sbp_read_frames>>8)&0x0ff;
|
4783 |
|
|
drvcmd[5]=D_S[d].sbp_read_frames&0x0ff;
|
4784 |
|
|
drvcmd[6]=(D_S[d].drv_type<drv_201)?0:2; /* flag "lba or msf-bcd format" */
|
4785 |
|
|
}
|
4786 |
|
|
}
|
4787 |
|
|
else if (fam1_drive)
|
4788 |
|
|
{
|
4789 |
|
|
drvcmd[0]=CMD1_READ;
|
4790 |
|
|
lba2msf(block,&drvcmd[1]); /* msf-bin format required */
|
4791 |
|
|
drvcmd[5]=(D_S[d].sbp_read_frames>>8)&0x0ff;
|
4792 |
|
|
drvcmd[6]=D_S[d].sbp_read_frames&0x0ff;
|
4793 |
|
|
}
|
4794 |
|
|
else if (fam2_drive)
|
4795 |
|
|
{
|
4796 |
|
|
drvcmd[0]=CMD2_READ;
|
4797 |
|
|
lba2msf(block,&drvcmd[1]); /* msf-bin format required */
|
4798 |
|
|
drvcmd[4]=(D_S[d].sbp_read_frames>>8)&0x0ff;
|
4799 |
|
|
drvcmd[5]=D_S[d].sbp_read_frames&0x0ff;
|
4800 |
|
|
drvcmd[6]=0x02;
|
4801 |
|
|
}
|
4802 |
|
|
else if (famT_drive)
|
4803 |
|
|
{
|
4804 |
|
|
drvcmd[0]=CMDT_READ;
|
4805 |
|
|
drvcmd[2]=(block>>24)&0x0ff;
|
4806 |
|
|
drvcmd[3]=(block>>16)&0x0ff;
|
4807 |
|
|
drvcmd[4]=(block>>8)&0x0ff;
|
4808 |
|
|
drvcmd[5]=block&0x0ff;
|
4809 |
|
|
drvcmd[7]=(D_S[d].sbp_read_frames>>8)&0x0ff;
|
4810 |
|
|
drvcmd[8]=D_S[d].sbp_read_frames&0x0ff;
|
4811 |
|
|
}
|
4812 |
|
|
flags_cmd_out=f_putcmd;
|
4813 |
|
|
response_count=0;
|
4814 |
|
|
i=cmd_out();
|
4815 |
|
|
if (i<0) msg(DBG_INF,"error giving READ command: %0d\n", i);
|
4816 |
|
|
return;
|
4817 |
|
|
}
|
4818 |
|
|
/*==========================================================================*/
|
4819 |
|
|
/*
|
4820 |
|
|
* Check the completion of the read-data command. On success, read
|
4821 |
|
|
* the D_S[d].sbp_bufsiz * 2048 bytes of data from the disk into buffer.
|
4822 |
|
|
*/
|
4823 |
|
|
static int sbp_data(struct request *req)
|
4824 |
|
|
{
|
4825 |
|
|
int i=0, j=0, l, frame;
|
4826 |
|
|
u_int try=0;
|
4827 |
|
|
u_long timeout;
|
4828 |
|
|
u_char *p;
|
4829 |
|
|
u_int data_tries = 0;
|
4830 |
|
|
u_int data_waits = 0;
|
4831 |
|
|
u_int data_retrying = 0;
|
4832 |
|
|
int error_flag;
|
4833 |
|
|
int xa_count;
|
4834 |
|
|
int max_latency;
|
4835 |
|
|
int success;
|
4836 |
|
|
int wait;
|
4837 |
|
|
int duration;
|
4838 |
|
|
|
4839 |
|
|
error_flag=0;
|
4840 |
|
|
success=0;
|
4841 |
|
|
#if LONG_TIMING
|
4842 |
|
|
max_latency=9*HZ;
|
4843 |
|
|
#else
|
4844 |
|
|
if (D_S[d].f_multisession) max_latency=15*HZ;
|
4845 |
|
|
else max_latency=5*HZ;
|
4846 |
|
|
#endif
|
4847 |
|
|
duration=jiffies;
|
4848 |
|
|
for (frame=0;frame<D_S[d].sbp_read_frames&&!error_flag; frame++)
|
4849 |
|
|
{
|
4850 |
|
|
SBPCD_CLI;
|
4851 |
|
|
|
4852 |
|
|
del_timer(&data_timer);
|
4853 |
|
|
data_timer.expires=jiffies+max_latency;
|
4854 |
|
|
timed_out_data=0;
|
4855 |
|
|
add_timer(&data_timer);
|
4856 |
|
|
while (!timed_out_data)
|
4857 |
|
|
{
|
4858 |
|
|
if (D_S[d].f_multisession) try=maxtim_data*4;
|
4859 |
|
|
else try=maxtim_data;
|
4860 |
|
|
msg(DBG_000,"sbp_data: CDi_status loop: try=%d.\n",try);
|
4861 |
|
|
for ( ; try!=0;try--)
|
4862 |
|
|
{
|
4863 |
|
|
j=inb(CDi_status);
|
4864 |
|
|
if (!(j&s_not_data_ready)) break;;
|
4865 |
|
|
if (!(j&s_not_result_ready)) break;
|
4866 |
|
|
if (fam0LV_drive) if (j&s_attention) break;
|
4867 |
|
|
}
|
4868 |
|
|
if (!(j&s_not_data_ready)) goto data_ready;
|
4869 |
|
|
if (try==0)
|
4870 |
|
|
{
|
4871 |
|
|
if (data_retrying == 0) data_waits++;
|
4872 |
|
|
data_retrying = 1;
|
4873 |
|
|
msg(DBG_000,"sbp_data: CDi_status loop: sleeping.\n");
|
4874 |
|
|
sbp_sleep(1);
|
4875 |
|
|
try = 1;
|
4876 |
|
|
}
|
4877 |
|
|
}
|
4878 |
|
|
msg(DBG_INF,"sbp_data: CDi_status loop expired.\n");
|
4879 |
|
|
data_ready:
|
4880 |
|
|
del_timer(&data_timer);
|
4881 |
|
|
|
4882 |
|
|
if (timed_out_data)
|
4883 |
|
|
{
|
4884 |
|
|
msg(DBG_INF,"sbp_data: CDi_status timeout (timed_out_data) (%02X).\n", j);
|
4885 |
|
|
error_flag++;
|
4886 |
|
|
break;
|
4887 |
|
|
}
|
4888 |
|
|
if (try==0)
|
4889 |
|
|
{
|
4890 |
|
|
msg(DBG_INF,"sbp_data: CDi_status timeout (try=0) (%02X).\n", j);
|
4891 |
|
|
error_flag++;
|
4892 |
|
|
break;
|
4893 |
|
|
}
|
4894 |
|
|
if (!(j&s_not_result_ready))
|
4895 |
|
|
{
|
4896 |
|
|
msg(DBG_INF, "sbp_data: RESULT_READY where DATA_READY awaited (%02X).\n", j);
|
4897 |
|
|
response_count=20;
|
4898 |
|
|
j=ResponseInfo();
|
4899 |
|
|
j=inb(CDi_status);
|
4900 |
|
|
}
|
4901 |
|
|
if (j&s_not_data_ready)
|
4902 |
|
|
{
|
4903 |
|
|
if ((D_S[d].ored_ctl_adr&0x40)==0)
|
4904 |
|
|
msg(DBG_INF, "CD contains no data tracks.\n");
|
4905 |
|
|
else msg(DBG_INF, "sbp_data: DATA_READY timeout (%02X).\n", j);
|
4906 |
|
|
error_flag++;
|
4907 |
|
|
break;
|
4908 |
|
|
}
|
4909 |
|
|
SBPCD_STI;
|
4910 |
|
|
error_flag=0;
|
4911 |
|
|
msg(DBG_000, "sbp_data: beginning to read.\n");
|
4912 |
|
|
p = D_S[d].sbp_buf + frame * CD_FRAMESIZE;
|
4913 |
|
|
if (sbpro_type==1) OUT(CDo_sel_i_d,1);
|
4914 |
|
|
if (cmd_type==READ_M2) {
|
4915 |
|
|
if (do_16bit) insw(CDi_data, xa_head_buf, CD_XA_HEAD>>1);
|
4916 |
|
|
else insb(CDi_data, xa_head_buf, CD_XA_HEAD);
|
4917 |
|
|
}
|
4918 |
|
|
if (do_16bit) insw(CDi_data, p, CD_FRAMESIZE>>1);
|
4919 |
|
|
else insb(CDi_data, p, CD_FRAMESIZE);
|
4920 |
|
|
if (cmd_type==READ_M2) {
|
4921 |
|
|
if (do_16bit) insw(CDi_data, xa_tail_buf, CD_XA_TAIL>>1);
|
4922 |
|
|
else insb(CDi_data, xa_tail_buf, CD_XA_TAIL);
|
4923 |
|
|
}
|
4924 |
|
|
D_S[d].sbp_current++;
|
4925 |
|
|
if (sbpro_type==1) OUT(CDo_sel_i_d,0);
|
4926 |
|
|
if (cmd_type==READ_M2)
|
4927 |
|
|
{
|
4928 |
|
|
for (xa_count=0;xa_count<CD_XA_HEAD;xa_count++)
|
4929 |
|
|
sprintf(&msgbuf[xa_count*3], " %02X", xa_head_buf[xa_count]);
|
4930 |
|
|
msgbuf[xa_count*3]=0;
|
4931 |
|
|
msg(DBG_XA1,"xa head:%s\n", msgbuf);
|
4932 |
|
|
}
|
4933 |
|
|
data_retrying = 0;
|
4934 |
|
|
data_tries++;
|
4935 |
|
|
if (data_tries >= 1000)
|
4936 |
|
|
{
|
4937 |
|
|
msg(DBG_INF,"sbp_data() statistics: %d waits in %d frames.\n", data_waits, data_tries);
|
4938 |
|
|
data_waits = data_tries = 0;
|
4939 |
|
|
}
|
4940 |
|
|
}
|
4941 |
|
|
duration=jiffies-duration;
|
4942 |
|
|
msg(DBG_TEA,"time to read %d frames: %d jiffies .\n",frame,duration);
|
4943 |
|
|
if (famT_drive)
|
4944 |
|
|
{
|
4945 |
|
|
wait=8;
|
4946 |
|
|
do
|
4947 |
|
|
{
|
4948 |
|
|
if (teac==2)
|
4949 |
|
|
{
|
4950 |
|
|
if ((i=CDi_stat_loop_T()) == -1) break;
|
4951 |
|
|
}
|
4952 |
|
|
else
|
4953 |
|
|
{
|
4954 |
|
|
sbp_sleep(1);
|
4955 |
|
|
OUT(CDo_sel_i_d,0);
|
4956 |
|
|
i=inb(CDi_status);
|
4957 |
|
|
}
|
4958 |
|
|
if (!(i&s_not_data_ready))
|
4959 |
|
|
{
|
4960 |
|
|
OUT(CDo_sel_i_d,1);
|
4961 |
|
|
j=0;
|
4962 |
|
|
do
|
4963 |
|
|
{
|
4964 |
|
|
if (do_16bit) i=inw(CDi_data);
|
4965 |
|
|
else i=inb(CDi_data);
|
4966 |
|
|
j++;
|
4967 |
|
|
i=inb(CDi_status);
|
4968 |
|
|
}
|
4969 |
|
|
while (!(i&s_not_data_ready));
|
4970 |
|
|
msg(DBG_TEA, "==========too much data (%d bytes/words)==============.\n", j);
|
4971 |
|
|
}
|
4972 |
|
|
if (!(i&s_not_result_ready))
|
4973 |
|
|
{
|
4974 |
|
|
OUT(CDo_sel_i_d,0);
|
4975 |
|
|
l=0;
|
4976 |
|
|
do
|
4977 |
|
|
{
|
4978 |
|
|
infobuf[l++]=inb(CDi_info);
|
4979 |
|
|
i=inb(CDi_status);
|
4980 |
|
|
}
|
4981 |
|
|
while (!(i&s_not_result_ready));
|
4982 |
|
|
if (infobuf[0]==0x00) success=1;
|
4983 |
|
|
#if 1
|
4984 |
|
|
for (j=0;j<l;j++) sprintf(&msgbuf[j*3], " %02X", infobuf[j]);
|
4985 |
|
|
msgbuf[j*3]=0;
|
4986 |
|
|
msg(DBG_TEA,"sbp_data info response:%s\n", msgbuf);
|
4987 |
|
|
#endif
|
4988 |
|
|
if (infobuf[0]==0x02)
|
4989 |
|
|
{
|
4990 |
|
|
error_flag++;
|
4991 |
|
|
do
|
4992 |
|
|
{
|
4993 |
|
|
++recursion;
|
4994 |
|
|
if (recursion>1) msg(DBG_TEA,"cmd_out_T READ_ERR recursion (sbp_data): %d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",recursion);
|
4995 |
|
|
else msg(DBG_TEA,"sbp_data: CMDT_READ_ERR necessary.\n");
|
4996 |
|
|
clr_cmdbuf();
|
4997 |
|
|
drvcmd[0]=CMDT_READ_ERR;
|
4998 |
|
|
j=cmd_out_T(); /* !!! recursive here !!! */
|
4999 |
|
|
--recursion;
|
5000 |
|
|
sbp_sleep(1);
|
5001 |
|
|
}
|
5002 |
|
|
while (j<0);
|
5003 |
|
|
D_S[d].error_state=infobuf[2];
|
5004 |
|
|
D_S[d].b3=infobuf[3];
|
5005 |
|
|
D_S[d].b4=infobuf[4];
|
5006 |
|
|
}
|
5007 |
|
|
break;
|
5008 |
|
|
}
|
5009 |
|
|
else
|
5010 |
|
|
{
|
5011 |
|
|
#if 0
|
5012 |
|
|
msg(DBG_TEA, "============= waiting for result=================.\n");
|
5013 |
|
|
sbp_sleep(1);
|
5014 |
|
|
#endif
|
5015 |
|
|
}
|
5016 |
|
|
}
|
5017 |
|
|
while (wait--);
|
5018 |
|
|
}
|
5019 |
|
|
|
5020 |
|
|
if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */
|
5021 |
|
|
{
|
5022 |
|
|
msg(DBG_TEA, "================error flag: %d=================.\n", error_flag);
|
5023 |
|
|
msg(DBG_INF,"sbp_data: read aborted by drive.\n");
|
5024 |
|
|
#if 1
|
5025 |
|
|
i=cc_DriveReset(); /* ugly fix to prevent a hang */
|
5026 |
|
|
#else
|
5027 |
|
|
i=cc_ReadError();
|
5028 |
|
|
#endif
|
5029 |
|
|
return (0);
|
5030 |
|
|
}
|
5031 |
|
|
|
5032 |
|
|
if (fam0LV_drive)
|
5033 |
|
|
{
|
5034 |
|
|
SBPCD_CLI;
|
5035 |
|
|
i=maxtim_data;
|
5036 |
|
|
for (timeout=jiffies+HZ; timeout > jiffies; timeout--)
|
5037 |
|
|
{
|
5038 |
|
|
for ( ;i!=0;i--)
|
5039 |
|
|
{
|
5040 |
|
|
j=inb(CDi_status);
|
5041 |
|
|
if (!(j&s_not_data_ready)) break;
|
5042 |
|
|
if (!(j&s_not_result_ready)) break;
|
5043 |
|
|
if (j&s_attention) break;
|
5044 |
|
|
}
|
5045 |
|
|
if (i != 0 || timeout <= jiffies) break;
|
5046 |
|
|
sbp_sleep(0);
|
5047 |
|
|
i = 1;
|
5048 |
|
|
}
|
5049 |
|
|
if (i==0) msg(DBG_INF,"status timeout after READ.\n");
|
5050 |
|
|
if (!(j&s_attention))
|
5051 |
|
|
{
|
5052 |
|
|
msg(DBG_INF,"sbp_data: timeout waiting DRV_ATTN - retrying.\n");
|
5053 |
|
|
i=cc_DriveReset(); /* ugly fix to prevent a hang */
|
5054 |
|
|
SBPCD_STI;
|
5055 |
|
|
return (0);
|
5056 |
|
|
}
|
5057 |
|
|
SBPCD_STI;
|
5058 |
|
|
}
|
5059 |
|
|
|
5060 |
|
|
#if 0
|
5061 |
|
|
if (!success)
|
5062 |
|
|
#endif 0
|
5063 |
|
|
do
|
5064 |
|
|
{
|
5065 |
|
|
if (fam0LV_drive) cc_ReadStatus();
|
5066 |
|
|
#if 1
|
5067 |
|
|
if (famT_drive) msg(DBG_TEA, "================before ResponseStatus=================.\n", i);
|
5068 |
|
|
#endif 1
|
5069 |
|
|
i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */
|
5070 |
|
|
#if 1
|
5071 |
|
|
if (famT_drive) msg(DBG_TEA, "================ResponseStatus: %d=================.\n", i);
|
5072 |
|
|
#endif 1
|
5073 |
|
|
if (i<0)
|
5074 |
|
|
{
|
5075 |
|
|
msg(DBG_INF,"bad cc_ReadStatus after read: %02X\n", D_S[d].status_bits);
|
5076 |
|
|
return (0);
|
5077 |
|
|
}
|
5078 |
|
|
}
|
5079 |
|
|
while ((fam0LV_drive)&&(!st_check)&&(!(i&p_success)));
|
5080 |
|
|
if (st_check)
|
5081 |
|
|
{
|
5082 |
|
|
i=cc_ReadError();
|
5083 |
|
|
msg(DBG_INF,"cc_ReadError was necessary after read: %d\n",i);
|
5084 |
|
|
return (0);
|
5085 |
|
|
}
|
5086 |
|
|
if (fatal_err)
|
5087 |
|
|
{
|
5088 |
|
|
fatal_err=0;
|
5089 |
|
|
D_S[d].sbp_first_frame=D_S[d].sbp_last_frame=-1; /* purge buffer */
|
5090 |
|
|
D_S[d].sbp_current = 0;
|
5091 |
|
|
msg(DBG_INF,"sbp_data: fatal_err - retrying.\n");
|
5092 |
|
|
return (0);
|
5093 |
|
|
}
|
5094 |
|
|
|
5095 |
|
|
D_S[d].sbp_first_frame = req -> sector / 4;
|
5096 |
|
|
D_S[d].sbp_last_frame = D_S[d].sbp_first_frame + D_S[d].sbp_read_frames - 1;
|
5097 |
|
|
sbp_transfer(req);
|
5098 |
|
|
return (1);
|
5099 |
|
|
}
|
5100 |
|
|
/*==========================================================================*/
|
5101 |
|
|
/*==========================================================================*/
|
5102 |
|
|
/*
|
5103 |
|
|
* Open the device special file. Check that a disk is in. Read TOC.
|
5104 |
|
|
*/
|
5105 |
|
|
static int sbpcd_open(struct inode *ip, struct file *fp)
|
5106 |
|
|
{
|
5107 |
|
|
int i;
|
5108 |
|
|
|
5109 |
|
|
i = MINOR(ip->i_rdev);
|
5110 |
|
|
if ((i<0) || (i>=NR_SBPCD) || (D_S[i].drv_id==-1))
|
5111 |
|
|
{
|
5112 |
|
|
msg(DBG_INF, "open: bad device: %04X\n", ip->i_rdev);
|
5113 |
|
|
return (-ENXIO); /* no such drive */
|
5114 |
|
|
}
|
5115 |
|
|
if (fp->f_mode & 2)
|
5116 |
|
|
return -EROFS;
|
5117 |
|
|
|
5118 |
|
|
down(&ioctl_read_sem);
|
5119 |
|
|
switch_drive(i);
|
5120 |
|
|
|
5121 |
|
|
i=cc_ReadError();
|
5122 |
|
|
flags_cmd_out |= f_respo2;
|
5123 |
|
|
cc_ReadStatus(); /* command: give 1-byte status */
|
5124 |
|
|
i=ResponseStatus();
|
5125 |
|
|
if (famT_drive&&(i<0))
|
5126 |
|
|
{
|
5127 |
|
|
cc_DriveReset();
|
5128 |
|
|
i=ResponseStatus();
|
5129 |
|
|
#if 0
|
5130 |
|
|
sbp_sleep(HZ);
|
5131 |
|
|
#endif 0
|
5132 |
|
|
i=ResponseStatus();
|
5133 |
|
|
}
|
5134 |
|
|
if (i<0)
|
5135 |
|
|
{
|
5136 |
|
|
msg(DBG_INF,"sbpcd_open: ResponseStatus timed out (%d).\n",i);
|
5137 |
|
|
RETURN_UP(-EIO); /* drive doesn't respond */
|
5138 |
|
|
}
|
5139 |
|
|
if (famT_drive) msg(DBG_TEA,"sbpcd_open: ResponseStatus=%02X\n", i);
|
5140 |
|
|
if (!st_door_closed)
|
5141 |
|
|
{
|
5142 |
|
|
if (famT_drive) msg(DBG_TEA,"sbpcd_open: !st_door_closed.\n");
|
5143 |
|
|
cc_CloseTray();
|
5144 |
|
|
flags_cmd_out |= f_respo2;
|
5145 |
|
|
cc_ReadStatus();
|
5146 |
|
|
i=ResponseStatus();
|
5147 |
|
|
}
|
5148 |
|
|
if (!(famT_drive))
|
5149 |
|
|
if (!st_spinning)
|
5150 |
|
|
{
|
5151 |
|
|
if (famT_drive) msg(DBG_TEA,"sbpcd_open: !st_spinning.\n");
|
5152 |
|
|
cc_SpinUp();
|
5153 |
|
|
flags_cmd_out |= f_respo2;
|
5154 |
|
|
cc_ReadStatus();
|
5155 |
|
|
i=ResponseStatus();
|
5156 |
|
|
}
|
5157 |
|
|
if (famT_drive) msg(DBG_TEA,"sbpcd_open: status %02X\n", D_S[d].status_bits);
|
5158 |
|
|
if (!st_door_closed||!st_caddy_in)
|
5159 |
|
|
{
|
5160 |
|
|
msg(DBG_INF, "sbpcd_open: no disk in drive.\n");
|
5161 |
|
|
D_S[d].open_count=0;
|
5162 |
|
|
#if JUKEBOX
|
5163 |
|
|
if (!fam0_drive)
|
5164 |
|
|
{
|
5165 |
|
|
i=UnLockDoor();
|
5166 |
|
|
cc_SpinDown(); /* eject tray */
|
5167 |
|
|
}
|
5168 |
|
|
#endif
|
5169 |
|
|
RETURN_UP(-ENXIO);
|
5170 |
|
|
}
|
5171 |
|
|
/*
|
5172 |
|
|
* try to keep an "open" counter here and lock the door if 0->1.
|
5173 |
|
|
*/
|
5174 |
|
|
MOD_INC_USE_COUNT;
|
5175 |
|
|
msg(DBG_LCK,"open_count: %d -> %d\n",
|
5176 |
|
|
D_S[d].open_count,D_S[d].open_count+1);
|
5177 |
|
|
if (++D_S[d].open_count<=1)
|
5178 |
|
|
{
|
5179 |
|
|
i=LockDoor();
|
5180 |
|
|
D_S[d].open_count=1;
|
5181 |
|
|
if (famT_drive) msg(DBG_TEA,"sbpcd_open: before i=DiskInfo();.\n");
|
5182 |
|
|
i=DiskInfo();
|
5183 |
|
|
if (famT_drive) msg(DBG_TEA,"sbpcd_open: after i=DiskInfo();.\n");
|
5184 |
|
|
if ((D_S[d].ored_ctl_adr&0x40)==0)
|
5185 |
|
|
{
|
5186 |
|
|
msg(DBG_INF,"CD contains no data tracks.\n");
|
5187 |
|
|
#if SAFE_MIXED
|
5188 |
|
|
D_S[d].has_data=0;
|
5189 |
|
|
#endif SAFE_MIXED
|
5190 |
|
|
}
|
5191 |
|
|
#if SAFE_MIXED
|
5192 |
|
|
else if (D_S[d].has_data<1) D_S[d].has_data=1;
|
5193 |
|
|
#endif SAFE_MIXED
|
5194 |
|
|
}
|
5195 |
|
|
if (!st_spinning) cc_SpinUp();
|
5196 |
|
|
RETURN_UP(0);
|
5197 |
|
|
}
|
5198 |
|
|
/*==========================================================================*/
|
5199 |
|
|
/*
|
5200 |
|
|
* On close, we flush all sbp blocks from the buffer cache.
|
5201 |
|
|
*/
|
5202 |
|
|
static void sbpcd_release(struct inode * ip, struct file * file)
|
5203 |
|
|
{
|
5204 |
|
|
int i;
|
5205 |
|
|
|
5206 |
|
|
i = MINOR(ip->i_rdev);
|
5207 |
|
|
if ((i<0) || (i>=NR_SBPCD) || (D_S[i].drv_id==-1))
|
5208 |
|
|
{
|
5209 |
|
|
msg(DBG_INF, "release: bad device: %04X\n", ip->i_rdev);
|
5210 |
|
|
return;
|
5211 |
|
|
}
|
5212 |
|
|
down(&ioctl_read_sem);
|
5213 |
|
|
switch_drive(i);
|
5214 |
|
|
/*
|
5215 |
|
|
* try to keep an "open" counter here and unlock the door if 1->0.
|
5216 |
|
|
*/
|
5217 |
|
|
MOD_DEC_USE_COUNT;
|
5218 |
|
|
msg(DBG_LCK,"open_count: %d -> %d\n",
|
5219 |
|
|
D_S[d].open_count,D_S[d].open_count-1);
|
5220 |
|
|
if (D_S[d].open_count>-2) /* CDROMEJECT may have been done */
|
5221 |
|
|
{
|
5222 |
|
|
if (--D_S[d].open_count<=0)
|
5223 |
|
|
{
|
5224 |
|
|
D_S[d].sbp_first_frame=D_S[d].sbp_last_frame=-1;
|
5225 |
|
|
sync_dev(ip->i_rdev); /* nonsense if read only device? */
|
5226 |
|
|
invalidate_buffers(ip->i_rdev);
|
5227 |
|
|
i=UnLockDoor();
|
5228 |
|
|
if (D_S[d].audio_state!=audio_playing)
|
5229 |
|
|
if (D_S[d].f_eject) cc_SpinDown();
|
5230 |
|
|
D_S[d].diskstate_flags &= ~cd_size_bit;
|
5231 |
|
|
D_S[d].open_count=0;
|
5232 |
|
|
#if SAFE_MIXED
|
5233 |
|
|
D_S[d].has_data=0;
|
5234 |
|
|
#endif SAFE_MIXED
|
5235 |
|
|
}
|
5236 |
|
|
}
|
5237 |
|
|
up(&ioctl_read_sem);
|
5238 |
|
|
}
|
5239 |
|
|
/*==========================================================================*/
|
5240 |
|
|
/*
|
5241 |
|
|
*
|
5242 |
|
|
*/
|
5243 |
|
|
static struct file_operations sbpcd_fops =
|
5244 |
|
|
{
|
5245 |
|
|
NULL, /* lseek - default */
|
5246 |
|
|
block_read, /* read - general block-dev read */
|
5247 |
|
|
block_write, /* write - general block-dev write */
|
5248 |
|
|
NULL, /* readdir - bad */
|
5249 |
|
|
NULL, /* select */
|
5250 |
|
|
sbpcd_ioctl, /* ioctl */
|
5251 |
|
|
NULL, /* mmap */
|
5252 |
|
|
sbpcd_open, /* open */
|
5253 |
|
|
sbpcd_release, /* release */
|
5254 |
|
|
NULL, /* fsync */
|
5255 |
|
|
NULL, /* fasync */
|
5256 |
|
|
sbpcd_chk_disk_change, /* media_change */
|
5257 |
|
|
NULL /* revalidate */
|
5258 |
|
|
};
|
5259 |
|
|
/*==========================================================================*/
|
5260 |
|
|
/*
|
5261 |
|
|
* accept "kernel command line" parameters
|
5262 |
|
|
* (suggested by Peter MacDonald with SLS 1.03)
|
5263 |
|
|
*
|
5264 |
|
|
* This is only implemented for the first controller. Should be enough to
|
5265 |
|
|
* allow installing with a "strange" distribution kernel.
|
5266 |
|
|
*
|
5267 |
|
|
* use: tell LILO:
|
5268 |
|
|
* sbpcd=0x230,SoundBlaster
|
5269 |
|
|
* or
|
5270 |
|
|
* sbpcd=0x300,LaserMate
|
5271 |
|
|
* or
|
5272 |
|
|
* sbpcd=0x338,SoundScape
|
5273 |
|
|
* or
|
5274 |
|
|
* sbpcd=0x2C0,Teac16bit
|
5275 |
|
|
*
|
5276 |
|
|
* (upper/lower case sensitive here - but all-lowercase is ok!!!).
|
5277 |
|
|
*
|
5278 |
|
|
* the address value has to be the CDROM PORT ADDRESS -
|
5279 |
|
|
* not the soundcard base address.
|
5280 |
|
|
* For the SPEA/SoundScape setup, DO NOT specify the "configuration port"
|
5281 |
|
|
* address, but the address which is really used for the CDROM (usually 8
|
5282 |
|
|
* bytes above).
|
5283 |
|
|
*
|
5284 |
|
|
*/
|
5285 |
|
|
#if (SBPCD_ISSUE-1)
|
5286 |
|
|
static
|
5287 |
|
|
#endif
|
5288 |
|
|
void sbpcd_setup(const char *s, int *p)
|
5289 |
|
|
{
|
5290 |
|
|
setup_done++;
|
5291 |
|
|
msg(DBG_INI,"sbpcd_setup called with %04X,%s\n",p[1], s);
|
5292 |
|
|
sbpro_type=0; /* default: "LaserMate" */
|
5293 |
|
|
if (p[0]>1) sbpro_type=p[2];
|
5294 |
|
|
else if (!strcmp(s,str_sb)) sbpro_type=1;
|
5295 |
|
|
else if (!strcmp(s,str_sb_l)) sbpro_type=1;
|
5296 |
|
|
else if (!strcmp(s,str_sp)) sbpro_type=2;
|
5297 |
|
|
else if (!strcmp(s,str_sp_l)) sbpro_type=2;
|
5298 |
|
|
else if (!strcmp(s,str_ss)) sbpro_type=2;
|
5299 |
|
|
else if (!strcmp(s,str_ss_l)) sbpro_type=2;
|
5300 |
|
|
else if (!strcmp(s,str_t16)) sbpro_type=3;
|
5301 |
|
|
else if (!strcmp(s,str_t16_l)) sbpro_type=3;
|
5302 |
|
|
if (p[0]>0) sbpcd_ioaddr=p[1];
|
5303 |
|
|
|
5304 |
|
|
CDo_command=sbpcd_ioaddr;
|
5305 |
|
|
CDi_info=sbpcd_ioaddr;
|
5306 |
|
|
CDi_status=sbpcd_ioaddr+1;
|
5307 |
|
|
CDo_sel_i_d=sbpcd_ioaddr+1;
|
5308 |
|
|
CDo_reset=sbpcd_ioaddr+2;
|
5309 |
|
|
CDo_enable=sbpcd_ioaddr+3;
|
5310 |
|
|
f_16bit=0;
|
5311 |
|
|
if ((sbpro_type==1)||(sbpro_type==3))
|
5312 |
|
|
{
|
5313 |
|
|
CDi_data=sbpcd_ioaddr;
|
5314 |
|
|
if (sbpro_type==3)
|
5315 |
|
|
{
|
5316 |
|
|
f_16bit=1;
|
5317 |
|
|
sbpro_type=1;
|
5318 |
|
|
}
|
5319 |
|
|
}
|
5320 |
|
|
else CDi_data=sbpcd_ioaddr+2;
|
5321 |
|
|
}
|
5322 |
|
|
/*==========================================================================*/
|
5323 |
|
|
/*
|
5324 |
|
|
* Sequoia S-1000 CD-ROM Interface Configuration
|
5325 |
|
|
* as used within SPEA Media FX, Ensonic SoundScape and some Reveal cards
|
5326 |
|
|
* The soundcard has to get jumpered for the interface type "Panasonic"
|
5327 |
|
|
* (not Sony or Mitsumi) and to get soft-configured for
|
5328 |
|
|
* -> configuration port address
|
5329 |
|
|
* -> CDROM port offset (num_ports): has to be 8 here. Possibly this
|
5330 |
|
|
* offset value determines the interface type (none, Panasonic,
|
5331 |
|
|
* Mitsumi, Sony).
|
5332 |
|
|
* The interface uses a configuration port (0x320, 0x330, 0x340, 0x350)
|
5333 |
|
|
* some bytes below the real CDROM address.
|
5334 |
|
|
*
|
5335 |
|
|
* For the Panasonic style (LaserMate) interface and the configuration
|
5336 |
|
|
* port 0x330, we have to use an offset of 8; so, the real CDROM port
|
5337 |
|
|
* address is 0x338.
|
5338 |
|
|
*/
|
5339 |
|
|
static int config_spea(void)
|
5340 |
|
|
{
|
5341 |
|
|
/*
|
5342 |
|
|
* base address offset between configuration port and CDROM port,
|
5343 |
|
|
* this probably defines the interface type
|
5344 |
|
|
* 2 (type=??): 0x00
|
5345 |
|
|
* 8 (type=LaserMate):0x10
|
5346 |
|
|
* 16 (type=??):0x20
|
5347 |
|
|
* 32 (type=??):0x30
|
5348 |
|
|
*/
|
5349 |
|
|
int n_ports=0x10;
|
5350 |
|
|
|
5351 |
|
|
int irq_number=0; /* off:0x00, 2/9:0x01, 7:0x03, 12:0x05, 15:0x07 */
|
5352 |
|
|
int dma_channel=0; /* off: 0x00, 0:0x08, 1:0x18, 3:0x38, 5:0x58, 6:0x68 */
|
5353 |
|
|
int dack_polarity=0; /* L:0x00, H:0x80 */
|
5354 |
|
|
int drq_polarity=0x40; /* L:0x00, H:0x40 */
|
5355 |
|
|
int i;
|
5356 |
|
|
|
5357 |
|
|
#define SPEA_REG_1 sbpcd_ioaddr-0x08+4
|
5358 |
|
|
#define SPEA_REG_2 sbpcd_ioaddr-0x08+5
|
5359 |
|
|
|
5360 |
|
|
OUT(SPEA_REG_1,0xFF);
|
5361 |
|
|
i=inb(SPEA_REG_1);
|
5362 |
|
|
if (i!=0x0F)
|
5363 |
|
|
{
|
5364 |
|
|
msg(DBG_SEQ,"no SPEA interface at %04X present.\n", sbpcd_ioaddr);
|
5365 |
|
|
return (-1); /* no interface found */
|
5366 |
|
|
}
|
5367 |
|
|
OUT(SPEA_REG_1,0x04);
|
5368 |
|
|
OUT(SPEA_REG_2,0xC0);
|
5369 |
|
|
|
5370 |
|
|
OUT(SPEA_REG_1,0x05);
|
5371 |
|
|
OUT(SPEA_REG_2,0x10|drq_polarity|dack_polarity);
|
5372 |
|
|
|
5373 |
|
|
#if 1
|
5374 |
|
|
#define SPEA_PATTERN 0x80
|
5375 |
|
|
#else
|
5376 |
|
|
#define SPEA_PATTERN 0x00
|
5377 |
|
|
#endif
|
5378 |
|
|
OUT(SPEA_REG_1,0x06);
|
5379 |
|
|
OUT(SPEA_REG_2,dma_channel|irq_number|SPEA_PATTERN);
|
5380 |
|
|
OUT(SPEA_REG_2,dma_channel|irq_number|SPEA_PATTERN);
|
5381 |
|
|
|
5382 |
|
|
OUT(SPEA_REG_1,0x09);
|
5383 |
|
|
i=(inb(SPEA_REG_2)&0xCF)|n_ports;
|
5384 |
|
|
OUT(SPEA_REG_2,i);
|
5385 |
|
|
|
5386 |
|
|
sbpro_type = 0; /* acts like a LaserMate interface now */
|
5387 |
|
|
msg(DBG_SEQ,"found SoundScape interface at %04X.\n", sbpcd_ioaddr);
|
5388 |
|
|
return (0);
|
5389 |
|
|
}
|
5390 |
|
|
/*==========================================================================*/
|
5391 |
|
|
/*
|
5392 |
|
|
* Test for presence of drive and initialize it.
|
5393 |
|
|
* Called once at boot or load time.
|
5394 |
|
|
*/
|
5395 |
|
|
#ifdef MODULE
|
5396 |
|
|
int init_module(void)
|
5397 |
|
|
#else
|
5398 |
|
|
int SBPCD_INIT(void)
|
5399 |
|
|
#endif MODULE
|
5400 |
|
|
{
|
5401 |
|
|
int i=0, j=0;
|
5402 |
|
|
int addr[2]={1, CDROM_PORT};
|
5403 |
|
|
int port_index;
|
5404 |
|
|
|
5405 |
|
|
sti();
|
5406 |
|
|
|
5407 |
|
|
msg(DBG_INF,"sbpcd.c %s\n", VERSION);
|
5408 |
|
|
#ifndef MODULE
|
5409 |
|
|
#if DISTRIBUTION
|
5410 |
|
|
if (!setup_done)
|
5411 |
|
|
{
|
5412 |
|
|
msg(DBG_INF,"Looking for Matsushita/Panasonic, CreativeLabs, Longshine, TEAC CD-ROM drives\n");
|
5413 |
|
|
msg(DBG_INF,"= = = = = = = = = = W A R N I N G = = = = = = = = = =\n");
|
5414 |
|
|
msg(DBG_INF,"Auto-Probing can cause a hang (f.e. touching an NE2000 card).\n");
|
5415 |
|
|
msg(DBG_INF,"If that happens, you have to reboot and use the\n");
|
5416 |
|
|
msg(DBG_INF,"LILO (kernel) command line feature like:\n");
|
5417 |
|
|
msg(DBG_INF," LILO boot: ... sbpcd=0x230,SoundBlaster\n");
|
5418 |
|
|
msg(DBG_INF,"or like:\n");
|
5419 |
|
|
msg(DBG_INF," LILO boot: ... sbpcd=0x300,LaserMate\n");
|
5420 |
|
|
msg(DBG_INF,"or like:\n");
|
5421 |
|
|
msg(DBG_INF," LILO boot: ... sbpcd=0x338,SoundScape\n");
|
5422 |
|
|
msg(DBG_INF,"with your REAL address.\n");
|
5423 |
|
|
msg(DBG_INF,"= = = = = = = = = = END of WARNING = = = = = == = = =\n");
|
5424 |
|
|
}
|
5425 |
|
|
#endif DISTRIBUTION
|
5426 |
|
|
sbpcd[0]=sbpcd_ioaddr; /* possibly changed by kernel command line */
|
5427 |
|
|
sbpcd[1]=sbpro_type; /* possibly changed by kernel command line */
|
5428 |
|
|
#endif MODULE
|
5429 |
|
|
|
5430 |
|
|
for (port_index=0;port_index<NUM_PROBE;port_index+=2)
|
5431 |
|
|
{
|
5432 |
|
|
addr[1]=sbpcd[port_index];
|
5433 |
|
|
if (addr[1]==0) break;
|
5434 |
|
|
if (check_region(addr[1],4))
|
5435 |
|
|
{
|
5436 |
|
|
msg(DBG_INF,"check_region: %03X is not free.\n",addr[1]);
|
5437 |
|
|
continue;
|
5438 |
|
|
}
|
5439 |
|
|
if (sbpcd[port_index+1]==2) type=str_sp;
|
5440 |
|
|
else if (sbpcd[port_index+1]==1) type=str_sb;
|
5441 |
|
|
else if (sbpcd[port_index+1]==3) type=str_t16;
|
5442 |
|
|
else type=str_lm;
|
5443 |
|
|
sbpcd_setup(type, addr);
|
5444 |
|
|
#if DISTRIBUTION
|
5445 |
|
|
msg(DBG_INF,"Scanning 0x%X (%s)...\n", CDo_command, type);
|
5446 |
|
|
#endif DISTRIBUTION
|
5447 |
|
|
if (sbpcd[port_index+1]==2)
|
5448 |
|
|
{
|
5449 |
|
|
i=config_spea();
|
5450 |
|
|
if (i<0) continue;
|
5451 |
|
|
}
|
5452 |
|
|
#ifdef PATH_CHECK
|
5453 |
|
|
if (check_card(addr[1])) continue;
|
5454 |
|
|
#endif PATH_CHECK
|
5455 |
|
|
i=check_drives();
|
5456 |
|
|
msg(DBG_INI,"check_drives done.\n");
|
5457 |
|
|
if (i>=0) break; /* drive found */
|
5458 |
|
|
} /* end of cycling through the set of possible I/O port addresses */
|
5459 |
|
|
|
5460 |
|
|
if (ndrives==0)
|
5461 |
|
|
{
|
5462 |
|
|
msg(DBG_INF, "No drive found.\n");
|
5463 |
|
|
#ifdef MODULE
|
5464 |
|
|
return -EIO;
|
5465 |
|
|
#else
|
5466 |
|
|
goto init_done;
|
5467 |
|
|
#endif MODULE
|
5468 |
|
|
}
|
5469 |
|
|
|
5470 |
|
|
if (port_index>0)
|
5471 |
|
|
{
|
5472 |
|
|
msg(DBG_INF, "You should read linux/Documentation/cdrom/sbpcd\n");
|
5473 |
|
|
msg(DBG_INF, "and then configure sbpcd.h for your hardware.\n");
|
5474 |
|
|
}
|
5475 |
|
|
check_datarate();
|
5476 |
|
|
msg(DBG_INI,"check_datarate done.\n");
|
5477 |
|
|
|
5478 |
|
|
#if 0
|
5479 |
|
|
if (!famL_drive)
|
5480 |
|
|
{
|
5481 |
|
|
OUT(CDo_reset,0);
|
5482 |
|
|
sbp_sleep(HZ);
|
5483 |
|
|
}
|
5484 |
|
|
#endif 0
|
5485 |
|
|
|
5486 |
|
|
for (j=0;j<NR_SBPCD;j++)
|
5487 |
|
|
{
|
5488 |
|
|
if (D_S[j].drv_id==-1) continue;
|
5489 |
|
|
switch_drive(j);
|
5490 |
|
|
#if 1
|
5491 |
|
|
if (!famL_drive) cc_DriveReset();
|
5492 |
|
|
#endif 0
|
5493 |
|
|
if (!st_spinning) cc_SpinUp();
|
5494 |
|
|
D_S[d].sbp_first_frame = -1; /* First frame in buffer */
|
5495 |
|
|
D_S[d].sbp_last_frame = -1; /* Last frame in buffer */
|
5496 |
|
|
D_S[d].sbp_read_frames = 0; /* Number of frames being read to buffer */
|
5497 |
|
|
D_S[d].sbp_current = 0; /* Frame being currently read */
|
5498 |
|
|
D_S[d].CD_changed=1;
|
5499 |
|
|
D_S[d].frame_size=CD_FRAMESIZE;
|
5500 |
|
|
D_S[d].f_eject=0;
|
5501 |
|
|
#if EJECT
|
5502 |
|
|
if (!fam0_drive) D_S[d].f_eject=1;
|
5503 |
|
|
#endif EJECT
|
5504 |
|
|
cc_ReadStatus();
|
5505 |
|
|
i=ResponseStatus(); /* returns orig. status or p_busy_new */
|
5506 |
|
|
if (famT_drive) i=ResponseStatus(); /* returns orig. status or p_busy_new */
|
5507 |
|
|
if (i<0) {
|
5508 |
|
|
if (i!=-402)
|
5509 |
|
|
msg(DBG_INF,"init: ResponseStatus returns %d.\n",i);
|
5510 |
|
|
}
|
5511 |
|
|
else
|
5512 |
|
|
{
|
5513 |
|
|
if (st_check)
|
5514 |
|
|
{
|
5515 |
|
|
i=cc_ReadError();
|
5516 |
|
|
msg(DBG_INI,"init: cc_ReadError returns %d\n",i);
|
5517 |
|
|
}
|
5518 |
|
|
}
|
5519 |
|
|
msg(DBG_INI,"init: first GetStatus: %d\n",i);
|
5520 |
|
|
msg(DBG_LCS,"init: first GetStatus: error_byte=%d\n",
|
5521 |
|
|
D_S[d].error_byte);
|
5522 |
|
|
if (D_S[d].error_byte==aud_12)
|
5523 |
|
|
{
|
5524 |
|
|
timeout=jiffies+2*HZ;
|
5525 |
|
|
do
|
5526 |
|
|
{
|
5527 |
|
|
i=GetStatus();
|
5528 |
|
|
msg(DBG_INI,"init: second GetStatus: %02X\n",i);
|
5529 |
|
|
msg(DBG_LCS,
|
5530 |
|
|
"init: second GetStatus: error_byte=%d\n",
|
5531 |
|
|
D_S[d].error_byte);
|
5532 |
|
|
if (i<0) break;
|
5533 |
|
|
if (!st_caddy_in) break;
|
5534 |
|
|
}
|
5535 |
|
|
while ((!st_diskok)||(timeout<jiffies));
|
5536 |
|
|
}
|
5537 |
|
|
i=SetSpeed();
|
5538 |
|
|
if (i>=0) D_S[d].CD_changed=1;
|
5539 |
|
|
}
|
5540 |
|
|
|
5541 |
|
|
/*
|
5542 |
|
|
* Turn on the CD audio channels.
|
5543 |
|
|
* The addresses are obtained from SOUND_BASE (see sbpcd.h).
|
5544 |
|
|
*/
|
5545 |
|
|
#if SOUND_BASE
|
5546 |
|
|
OUT(MIXER_addr,MIXER_CD_Volume); /* select SB Pro mixer register */
|
5547 |
|
|
OUT(MIXER_data,0xCC); /* one nibble per channel, max. value: 0xFF */
|
5548 |
|
|
#endif SOUND_BASE
|
5549 |
|
|
|
5550 |
|
|
if (register_blkdev(MAJOR_NR, major_name, &sbpcd_fops) != 0)
|
5551 |
|
|
{
|
5552 |
|
|
msg(DBG_INF, "Can't get MAJOR %d for Matsushita CDROM\n", MAJOR_NR);
|
5553 |
|
|
#ifdef MODULE
|
5554 |
|
|
return -EIO;
|
5555 |
|
|
#else
|
5556 |
|
|
goto init_done;
|
5557 |
|
|
#endif MODULE
|
5558 |
|
|
}
|
5559 |
|
|
blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;
|
5560 |
|
|
read_ahead[MAJOR_NR] = buffers * (CD_FRAMESIZE / 512);
|
5561 |
|
|
|
5562 |
|
|
request_region(CDo_command,4,major_name);
|
5563 |
|
|
|
5564 |
|
|
for (j=0;j<NR_SBPCD;j++)
|
5565 |
|
|
{
|
5566 |
|
|
if (D_S[j].drv_id==-1) continue;
|
5567 |
|
|
switch_drive(j);
|
5568 |
|
|
#if SAFE_MIXED
|
5569 |
|
|
D_S[j].has_data=0;
|
5570 |
|
|
#endif SAFE_MIXED
|
5571 |
|
|
/*
|
5572 |
|
|
* allocate memory for the frame buffers
|
5573 |
|
|
*/
|
5574 |
|
|
D_S[j].aud_buf=NULL;
|
5575 |
|
|
D_S[j].sbp_audsiz=0;
|
5576 |
|
|
D_S[j].sbp_bufsiz=buffers;
|
5577 |
|
|
if (D_S[j].drv_type&drv_fam1)
|
5578 |
|
|
if (READ_AUDIO>0) D_S[j].sbp_audsiz=READ_AUDIO;
|
5579 |
|
|
D_S[j].sbp_buf=(u_char *) vmalloc(D_S[j].sbp_bufsiz*CD_FRAMESIZE);
|
5580 |
|
|
if (D_S[j].sbp_buf==NULL)
|
5581 |
|
|
{
|
5582 |
|
|
msg(DBG_INF,"data buffer (%d frames) not available.\n",D_S[j].sbp_bufsiz);
|
5583 |
|
|
return -EIO;
|
5584 |
|
|
}
|
5585 |
|
|
#ifdef MODULE
|
5586 |
|
|
msg(DBG_INF,"data buffer size: %d frames.\n",buffers);
|
5587 |
|
|
#endif MODULE
|
5588 |
|
|
if (D_S[j].sbp_audsiz>0)
|
5589 |
|
|
{
|
5590 |
|
|
D_S[j].aud_buf=(u_char *) vmalloc(D_S[j].sbp_audsiz*CD_FRAMESIZE_RAW);
|
5591 |
|
|
if (D_S[j].aud_buf==NULL) msg(DBG_INF,"audio buffer (%d frames) not available.\n",D_S[j].sbp_audsiz);
|
5592 |
|
|
else msg(DBG_INF,"audio buffer size: %d frames.\n",D_S[j].sbp_audsiz);
|
5593 |
|
|
}
|
5594 |
|
|
/*
|
5595 |
|
|
* set the block size
|
5596 |
|
|
*/
|
5597 |
|
|
sbpcd_blocksizes[j]=CD_FRAMESIZE;
|
5598 |
|
|
}
|
5599 |
|
|
blksize_size[MAJOR_NR]=sbpcd_blocksizes;
|
5600 |
|
|
|
5601 |
|
|
#ifndef MODULE
|
5602 |
|
|
init_done:
|
5603 |
|
|
#if !(SBPCD_ISSUE-1)
|
5604 |
|
|
#ifdef CONFIG_SBPCD2
|
5605 |
|
|
sbpcd2_init();
|
5606 |
|
|
#endif CONFIG_SBPCD2
|
5607 |
|
|
#ifdef CONFIG_SBPCD3
|
5608 |
|
|
sbpcd3_init();
|
5609 |
|
|
#endif CONFIG_SBPCD3
|
5610 |
|
|
#ifdef CONFIG_SBPCD4
|
5611 |
|
|
sbpcd4_init();
|
5612 |
|
|
#endif CONFIG_SBPCD4
|
5613 |
|
|
#endif !(SBPCD_ISSUE-1)
|
5614 |
|
|
#endif MODULE
|
5615 |
|
|
return 0;
|
5616 |
|
|
}
|
5617 |
|
|
/*==========================================================================*/
|
5618 |
|
|
#ifdef MODULE
|
5619 |
|
|
void cleanup_module(void)
|
5620 |
|
|
{
|
5621 |
|
|
int j;
|
5622 |
|
|
|
5623 |
|
|
if ((unregister_blkdev(MAJOR_NR, major_name) == -EINVAL))
|
5624 |
|
|
{
|
5625 |
|
|
msg(DBG_INF, "What's that: can't unregister %s.\n", major_name);
|
5626 |
|
|
return;
|
5627 |
|
|
}
|
5628 |
|
|
release_region(CDo_command,4);
|
5629 |
|
|
|
5630 |
|
|
for (j=0;j<NR_SBPCD;j++)
|
5631 |
|
|
{
|
5632 |
|
|
if (D_S[j].drv_id==-1) continue;
|
5633 |
|
|
vfree(D_S[j].sbp_buf);
|
5634 |
|
|
if (D_S[j].sbp_audsiz>0) vfree(D_S[j].aud_buf);
|
5635 |
|
|
}
|
5636 |
|
|
msg(DBG_INF, "%s module released.\n", major_name);
|
5637 |
|
|
}
|
5638 |
|
|
#endif MODULE
|
5639 |
|
|
/*==========================================================================*/
|
5640 |
|
|
/*
|
5641 |
|
|
* Check if the media has changed in the CD-ROM drive.
|
5642 |
|
|
* used externally (isofs/inode.c, fs/buffer.c)
|
5643 |
|
|
*/
|
5644 |
|
|
static int sbpcd_chk_disk_change(kdev_t full_dev)
|
5645 |
|
|
{
|
5646 |
|
|
int i;
|
5647 |
|
|
|
5648 |
|
|
msg(DBG_CHK,"media_check (%d) called\n", MINOR(full_dev));
|
5649 |
|
|
i=MINOR(full_dev);
|
5650 |
|
|
if ( (i<0) || (i>=NR_SBPCD) || (D_S[i].drv_id==-1) )
|
5651 |
|
|
{
|
5652 |
|
|
msg(DBG_INF, "media_check: invalid device %04X.\n", full_dev);
|
5653 |
|
|
return (-1);
|
5654 |
|
|
}
|
5655 |
|
|
|
5656 |
|
|
if (D_S[i].CD_changed==0xFF)
|
5657 |
|
|
{
|
5658 |
|
|
D_S[i].CD_changed=0;
|
5659 |
|
|
msg(DBG_CHK,"medium changed (drive %d)\n", i);
|
5660 |
|
|
return (1);
|
5661 |
|
|
}
|
5662 |
|
|
else
|
5663 |
|
|
return (0);
|
5664 |
|
|
}
|
5665 |
|
|
/*==========================================================================*/
|
5666 |
|
|
/*
|
5667 |
|
|
* Overrides for Emacs so that we follow Linus's tabbing style.
|
5668 |
|
|
* Emacs will notice this stuff at the end of the file and automatically
|
5669 |
|
|
* adjust the settings for this buffer only. This must remain at the end
|
5670 |
|
|
* of the file.
|
5671 |
|
|
* ---------------------------------------------------------------------------
|
5672 |
|
|
* Local variables:
|
5673 |
|
|
* c-indent-level: 8
|
5674 |
|
|
* c-brace-imaginary-offset: 0
|
5675 |
|
|
* c-brace-offset: -8
|
5676 |
|
|
* c-argdecl-indent: 8
|
5677 |
|
|
* c-label-offset: -8
|
5678 |
|
|
* c-continued-statement-offset: 8
|
5679 |
|
|
* c-continued-brace-offset: 0
|
5680 |
|
|
* End:
|
5681 |
|
|
*/
|