CDROM update [PATCH]

Erik Andersen (andersen@inconnect.com)
Fri, 17 Jul 1998 02:32:10 -0600


Here are a set of cdrom updates. These updates include:

o Various spelling fixes for the cdrom code.

Changes to cdrom:
o Fixed a bug in CDROM_SELECT_SPEED where you couldn't lower the speed
of the drive.
o Fixed the procfs-unload-module bug (the one Alan Cox listed on his
bug page) with the fill_inode procfs callback.
o Fixed it so that the /proc entry now also can show up when cdrom is
compiled into the kernel. Before it only worked when loaded as a module.
o Added in some MODULE_PARMs (so you can now set debug=1 in the module
options). These greatly facilitate debugging.

Changes to cdu31a:
o I now have a drive (thanks to John Kodis), so I began to hack at making
this driver actually _work_ under 2.1.x.
o Fixed an ugly hack in scd_open to handle spinup gracefully (instead of
faking that the door is open to force a spinup -- ugh)
o Added in a magic printk to slow it down enough to succeed -- a temporary
fix to the interrupt problems in do_sony_cd_cmd. I just got the drive
today, so I havn't yet found the real bug. At least mount shouldn't
hang now.

Changes to cdu31a:
o Updated link to ATAPI spec
o Updated TODO list

-Erik

--
Erik B. Andersen   Web:    http://www.inconnect.com/~andersen/ 
                   email:  andersee@debian.org
--This message was written using 73% post-consumer electrons--

diff --unified --new-file --recursive linux-2.1.108.virgin/Documentation/cdrom/ide-cd linux/Documentation/cdrom/ide-cd --- linux-2.1.108.virgin/Documentation/cdrom/ide-cd Fri May 1 14:59:50 1998 +++ linux/Documentation/cdrom/ide-cd Sat Jul 4 12:36:14 1998 @@ -6,11 +6,11 @@ --------------- The ide-cd driver should work with all ATAPI ver 1.2 to ATAPI 2.6 compliant -cdrom drives which attach to an IDE interface. Note that some cdrom vendors +CDROM drives which attach to an IDE interface. Note that some CDROM vendors (including Mitsumi, Sony, Creative, Aztech, and Goldstar) have made both ATAPI-compliant drives and drives which use a proprietary interface. If your drive uses one of those proprietary interfaces, -this driver will not work with it (but one of the other cdrom drivers +this driver will not work with it (but one of the other CDROM drivers probably will). This driver will not work with `ATAPI' drives which attach to the parallel port. In addition, there is at least one drive (CyCDROM CR520ie) which attaches to the IDE port but is not ATAPI; @@ -19,9 +19,9 @@ This driver provides the following features: - - Reading from data tracks, and mounting iso9660 filesystems. + - Reading from data tracks, and mounting ISO 9660 filesystems. - - Playing audio tracks. Most of the cdrom player programs floating + - Playing audio tracks. Most of the CDROM player programs floating around should work; I usually use Workman. - Multisession support. @@ -30,7 +30,7 @@ from audio tracks. The program cdda2wav can be used for this. Note, however, that only some drives actually support this. - - There is now support for cdrom changers which comply with the + - There is now support for CDROM changers which comply with the ATAPI 2.6 draft standard (such as the NEC CDR-251). This additional functionality includes a function call to query which slot is the currently selected slot, a function call to query which slots contain @@ -67,15 +67,15 @@ 2. You should also ensure that the iso9660 filesystem is either compiled into the kernel or available as a loadable module. You - can see if a filesystem is known to the kernel by cat'ing the file + can see if a filesystem is known to the kernel by catting /proc/filesystems. -3. The cdrom drive should be connected to the host on an IDE +3. The CDROM drive should be connected to the host on an IDE interface. Each interface on a system is defined by an I/O port address and an IRQ number, the standard assignments being 0x170 and 14 for the primary interface and 0x1f0 and 15 for the secondary interface. Each interface can control up to two devices, - where each device can be a hard drive, a cdrom drive, a floppy drive, + where each device can be a hard drive, a CDROM drive, a floppy drive, or a tape drive. The two devices on an interface are called `master' and `slave'; this is usually selectable via a jumper on the drive. @@ -85,10 +85,10 @@ `hdc' and `hdd'. (Interfaces at other locations get other letters in the third position; see Documentation/ide.txt.) - If you want your cdrom drive to be found automatically by the + If you want your CDROM drive to be found automatically by the driver, you should make sure your IDE interface uses either the primary or secondary addresses mentioned above. In addition, if - the cdrom drive is the only device on the IDE interface, it should + the CDROM drive is the only device on the IDE interface, it should be jumpered as `master'. (If for some reason you cannot configure your system in this manner, you can probably still use the driver. You may have to pass extra configuration information to the kernel @@ -117,33 +117,33 @@ 3. Basic usage -------------- -An iso9660 format cdrom can be mounted by putting the disc in the -drive and typing (as root) +An ISO 9660 CDROM can be mounted by putting the disc in the drive and +typing (as root) mount -t iso9660 /dev/cdrom /mnt/cdrom where it is assumed that /dev/cdrom is a link pointing to the actual device (as described in step 5 of the last section) and /mnt/cdrom is an empty directory. You should now be able to see the contents of the -cdrom under the /mnt/cdrom directory. If you want to eject the cdrom, +CDROM under the /mnt/cdrom directory. If you want to eject the CDROM, you must first dismount it with a command like umount /mnt/cdrom -Note that audio cds cannot be mounted. +Note that audio CDs cannot be mounted. -Some distributions set up /etc/fstab to always try to mount a cdrom -filesystem on bootup. It is not required to mount the cdrom in this -manner, though, and it may be a nuisance if you change cdroms often. +Some distributions set up /etc/fstab to always try to mount a CDROM +filesystem on bootup. It is not required to mount the CDROM in this +manner, though, and it may be a nuisance if you change CDROMs often. You should feel free to remove the cdrom line from /etc/fstab and -mount cdroms manually if that suits you better. +mount CDROMs manually if that suits you better. Multisession and photocd discs should work with no special handling. The hpcdtoppm package (ftp.gwdg.de:/pub/linux/hpcdtoppm/) may be useful for reading photocds. -To play an audio cd, you should first unmount and remove any data -cdrom. Any of the cdrom player programs should then work (workman, +To play an audio CD, you should first unmount and remove any data +CDROM. Any of the CDROM player programs should then work (workman, workbone, cdplayer, etc.). Lacking anything else, you could use the cdtester program in Documentation/cdrom/sbpcd. @@ -155,7 +155,7 @@ For supported changers, you can use the `cdchange' program (appended to the end of this file) to switch between changer slots. Note that the drive should be unmounted before attempting this. The program takes -two arguments: the cdrom device, and the slot number to which you wish +two arguments: the CDROM device, and the slot number to which you wish to change. If the slot number is -1, the drive is unloaded. @@ -263,7 +263,7 @@ means that the system did not see an interrupt from the drive when it was expecting one (on any feasible IRQ). If <n> is negative, that means the system saw interrupts on multiple IRQ lines, when - it was expecting to receive just one from the cdrom drive. + it was expecting to receive just one from the CDROM drive. - Double-check your hardware configuration to make sure that the IRQ number of your IDE interface matches what the driver expects. @@ -275,23 +275,23 @@ had one report of a system which was shipped with IRQ 15 disabled by default. - - Note that many MS-DOS cdrom drivers will still function even if + - Note that many MS-DOS CDROM drivers will still function even if there are hardware problems with the interrupt setup; they apparently don't use interrupts. - If you own a Pioneer DR-A24X, you _will_ get nasty error messages on boot such as "irq timeout: status=0x50 { DriveReady SeekComplete }" - The Pioneer DR-A24X cdrom drives are fairly popular these days. + The Pioneer DR-A24X CDROM drives are fairly popular these days. Unfortunately, these drives seem to become very confused when we perform the standard Linux ATA disk drive probe. If you own one of these drives, - you can bypass the ATA probing which confuses these cdrom drives, by + you can bypass the ATA probing which confuses these CDROM drives, by adding `append="hdX=noprobe hdX=cdrom"' to your lilo.conf file and runing lilo (again where X is the drive letter corresponding to where your drive is installed.) c. System hangups. - - If the system locks up when you try to access the cdrom, the most + - If the system locks up when you try to access the CDROM, the most likely cause is that you have a buggy IDE adapter which doesn't properly handle simultaneous transactions on multiple interfaces. The most notorious of these is the CMD640B chip. This problem can @@ -301,27 +301,27 @@ foolproof. See Documentation/ide.txt for more information about the `serialize' option and the CMD640B. - - Note that many MS-DOS cdrom drivers will work with such buggy - hardware, apparently because they never attempt to overlap cdrom + - Note that many MS-DOS CDROM drivers will work with such buggy + hardware, apparently because they never attempt to overlap CDROM operations with other disk activity. -d. Can't mount a cdrom. +d. Can't mount a CDROM. - If you get errors from mount, it may help to check `dmesg' to see if there are any more specific errors from the driver or from the filesystem. - - Make sure there's a cdrom loaded in the drive, and that's it's an - iso9660 format disc. You can't mount an audio cd. + - Make sure there's a CDROM loaded in the drive, and that's it's an + ISO 9660 disc. You can't mount an audio CD. - - With the cdrom in the drive and unmounted, try something like + - With the CDROM in the drive and unmounted, try something like cat /dev/cdrom | od | more If you see a dump, then the drive and driver are probably working - ok, and the problem is at the filesystem level (i.e., the cdrom is - not iso9660 format or has errors in the filesystem structure). + OK, and the problem is at the filesystem level (i.e., the CDROM is + not ISO 9660 or has errors in the filesystem structure). - If you see `not a block device' errors, check that the definitions of the device special files are correct. They should be as @@ -357,7 +357,7 @@ which could cause this. It was fixed in 1.3.0. If you can't upgrade, you can probably work around the problem by specifying a blocksize of 2048 when mounting. (Note that you won't be able to - directly execute binaries off the cdrom in that case.) + directly execute binaries off the CDROM in that case.) If you see this in kernels later than 1.3.0, please report it as a bug. @@ -366,7 +366,7 @@ f. Data corruption. - Random data corruption was occasionally observed with the Hitachi - CDR-7730 cdrom. If you experience data corruption, using "hdx=slow" + CDR-7730 CDROM. If you experience data corruption, using "hdx=slow" as a command line parameter may work around the problem, at the expense of low system performance. @@ -377,7 +377,7 @@ /* * cdchange.c [-v] <device> [<slot>] * - * This loads a cdrom from a specified slot in a changer, and displays + * This loads a CDROM from a specified slot in a changer, and displays * information about the changer status. The drive should be unmounted before * using this program. * @@ -385,8 +385,8 @@ * or no slot was specified. * * Based on code originally from Gerhard Zuber <zuber@berlin.snafu.de>. - * Changer status information, and rewrite for the new common cdrom driver - * interface by Erik Andersen <andersee@et.byu.edu>. + * Changer status information, and rewrite for the new Uniform CDROM driver + * interface by Erik Andersen <andersee@debian.org>. */ #include <stdio.h> diff --unified --new-file --recursive linux-2.1.108.virgin/drivers/block/ide-cd.c linux/drivers/block/ide-cd.c --- linux-2.1.108.virgin/drivers/block/ide-cd.c Sat May 16 08:59:34 1998 +++ linux/drivers/block/ide-cd.c Fri Jul 17 01:27:01 1998 @@ -13,22 +13,31 @@ * Suggestions are welcome. Patches that work are more welcome though. ;-) * For those wishing to work on this driver, please be sure you download * and comply with the latest ATAPI standard. This document can be - * obtained by anonymous ftp from fission.dt.wdc.com in directory: - * /pub/standards/SFF_atapi/spec/SFF8020-r2.6/PDF/8020r26.pdf + * obtained by anonymous ftp from: + * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps * * Drives that deviate from the ATAPI standard will be accomodated as much - * as possible via compile options. Since I only have a few drives, you you - * generally need to send me patches... + * as possable via compile time or command-line options. Since I only have + * a few drives, you generally need to send me patches... * * ---------------------------------- * TO DO LIST: - * -Avoid printing error messages for expected errors from the drive. - * (If you are using a cd changer, you may get errors in the kernel - * logs that are completly expected. Don't complain to me about this, - * unless you have a patch to fix it. I am working on it...) + * -Implement Microsoft Media Status Notification per the spec at + * http://www.microsoft.com/hwdev/respec/storspec.htm + * This will allow us to get automagically notified when the media changes + * on ATAPI drives (something the stock ATAPI spec is lacking). Looks + * very cool. I discovered its existance the other day at work... * -Fix ide_cdrom_reset so that it works (it does nothing right now) * -Query the drive to find what features are available before trying to * use them (like trying to close the tray in drives that can't). + * -Make it so that Pioneer CD DR-A24X and friends don't get screwed up on + * boot + * -Handle older drives that can't report their speed. (i.e. check if they + * support a version of ATAPI where they can report their speed before + * checking their speed and believing what they return). + * -It seems we do not always honor it when Uniform gets a request to change + * the cdi->options. We should _always_ check the options before doing stuff. + * This must be fixed. * * * ---------------------------------- @@ -205,10 +214,13 @@ * messages, since this is not an error. * -- Change error messages to be const * -- Remove a "\t" which looks ugly in the syslogs + * 4.14 July 17, 1998 -- Change to pointing to .ps version of ATAPI spec + * since the .pdf version doesn't seem to work... + * -- Updated the TODO list to something more current. * *************************************************************************/ -#define IDECD_VERSION "4.13" +#define IDECD_VERSION "4.14" #include <linux/module.h> #include <linux/types.h> @@ -1157,7 +1169,7 @@ if (pc->buflen == 0) cdrom_end_request (1, drive); else { - /* Comment this out, because this always happins + /* Comment this out, because this always happens right after a reset occurs, and it is annoying to always print expected stuff. */ /* diff --unified --new-file --recursive linux-2.1.108.virgin/drivers/block/ide-cd.h linux/drivers/block/ide-cd.h --- linux-2.1.108.virgin/drivers/block/ide-cd.h Sat May 16 08:59:34 1998 +++ linux/drivers/block/ide-cd.h Sat Jul 4 12:35:12 1998 @@ -105,9 +105,9 @@ #define ABORTED_COMMAND 0x0b #define MISCOMPARE 0x0e -/* We want some additional flags for cd-rom drives. +/* We want some additional flags for CDROM drives. To save space in the ide_drive_t struct, use some fields which - doesn't make sense for cd-roms -- `bios_cyl' and `bios_head'. */ + doesn't make sense for CDROMs -- `bios_cyl' and `bios_head'. */ /* Configuration flags. These describe the capabilities of the drive. They generally do not change after initialization, unless we learn diff --unified --new-file --recursive linux-2.1.108.virgin/drivers/block/paride/pcd.c linux/drivers/block/paride/pcd.c --- linux-2.1.108.virgin/drivers/block/paride/pcd.c Wed Jul 1 22:45:03 1998 +++ linux/drivers/block/paride/pcd.c Sat Jul 4 12:35:12 1998 @@ -2,11 +2,11 @@ pcd.c (c) 1997-8 Grant R. Guenther <grant@torque.net> Under the terms of the GNU public license. - This is high-level driver for parallel port ATAPI CDrom + This is a high-level driver for parallel port ATAPI CDROM drives based on chips supported by the paride module. By default, the driver will autoprobe for a single parallel - port ATAPI CDrom drive, but if their individual parameters are + port ATAPI CDROM drive, but if their individual parameters are specified, the driver can handle up to 4 drives. The behaviour of the pcd driver can be altered by setting @@ -38,7 +38,7 @@ of the mode numbers supported by the adapter. (-1 if not given) - <slv> ATAPI CDroms can be jumpered to master or slave. + <slv> ATAPI CDROMs can be jumpered to master or slave. Set this to 0 to choose the master drive, 1 to choose the slave, -1 (the default) to choose the first drive found. @@ -648,7 +648,7 @@ if (s) return -1; if ((pcd_buffer[0] & 0x1f) != 5) { - if (verbose) printk("%s: %s is not a CDrom\n", + if (verbose) printk("%s: %s is not a CDROM\n", PCD.name,PCD.drive?"Slave":"Master"); return -1; } @@ -709,7 +709,7 @@ if (k) return 0; - printk("%s: No CDrom drive found\n",name); + printk("%s: No CDROM drive found\n",name); return -1; } Binary files linux-2.1.108.virgin/drivers/cdrom/.cdrom.c.swp and linux/drivers/cdrom/.cdrom.c.swp differ diff --unified --new-file --recursive linux-2.1.108.virgin/drivers/cdrom/cdrom.c linux/drivers/cdrom/cdrom.c --- linux-2.1.108.virgin/drivers/cdrom/cdrom.c Mon Apr 6 22:21:49 1998 +++ linux/drivers/cdrom/cdrom.c Thu Jul 16 21:56:37 1998 @@ -71,10 +71,19 @@ of bytes not copied. I was returning whatever non-zero stuff came back from the copy_*_user functions directly, which would result in strange errors. +2.13 July 17, 1998 -- Erik Andersen <andersee@debian.org> + -- Fixed a bug in CDROM_SELECT_SPEED where you couldn't lower the speed + of the drive. Thanks to Tobias Ringstr|m <tori@prosolvia.se> for pointing + this out and providing a simple fix. + -- Fixed the procfs-unload-module bug with the fill_inode procfs callback. + thanks to Andrea Arcangeli <arcangeli@mbox.queen.it> + -- Fixed it so that the /proc entry now also shows up when cdrom is + compiled into the kernel. Before it only worked when loaded as a module. + -------------------------------------------------------------------------*/ -#define REVISION "Revision: 2.12" -#define VERSION "Id: cdrom.c 2.12 1998/01/24 22:15:45 erik Exp" +#define REVISION "Revision: 2.13" +#define VERSION "Id: cdrom.c 2.13 1998/07/17 erik" /* I use an error-log mask to give fine grain control over the type of messages dumped to the system logs. The available masks include: */ @@ -104,14 +113,28 @@ #include <linux/malloc.h> #include <linux/cdrom.h> #include <linux/sysctl.h> +#include <linux/proc_fs.h> #include <asm/fcntl.h> #include <asm/segment.h> #include <asm/uaccess.h> +/* used to tell the module to turn on full debugging messages */ +static int debug = 0; +/* default compatibility mode */ +static int autoclose=1; +static int autoeject=0; +static int lockdoor = 1; +static int check_media_type = 0; +MODULE_PARM(debug, "i"); +MODULE_PARM(autoclose, "i"); +MODULE_PARM(autoeject, "i"); +MODULE_PARM(lockdoor, "i"); +MODULE_PARM(check_media_type, "i"); #if (ERRLOGMASK!=CD_NOTHING) #define cdinfo(type, fmt, args...) \ - if (ERRLOGMASK & type) printk(KERN_INFO "cdrom: " fmt, ## args) + if ((ERRLOGMASK & type) || debug==1 ) \ + printk(KERN_INFO "cdrom: " fmt, ## args) #else #define cdinfo(type, fmt, args...) #endif @@ -139,6 +162,7 @@ struct cdrom_device_ops * cdo); static void sanitize_format(union cdrom_addr *addr, u_char * curr, u_char requested); +static void cdrom_sysctl_register(void); typedef struct { int data; int audio; @@ -176,6 +200,7 @@ int register_cdrom(struct cdrom_device_info *cdi) { + static char banner_printed = 0; int major = MAJOR (cdi->dev); struct cdrom_device_ops *cdo = cdi->ops; int *change_capability = (int *)&cdo->capability; /* hack */ @@ -184,6 +209,13 @@ return -1; if (cdo->open == NULL || cdo->release == NULL) return -2; + if ( !banner_printed ) { + printk(KERN_INFO "Uniform CDROM driver " REVISION "\n"); + banner_printed = 1; +#ifdef CONFIG_SYSCTL + cdrom_sysctl_register(); +#endif /* CONFIG_SYSCTL */ + } ENSURE(drive_status, CDC_DRIVE_STATUS ); ENSURE(media_changed, CDC_MEDIA_CHANGED); ENSURE(tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY); @@ -195,18 +227,17 @@ ENSURE(reset, CDC_RESET); ENSURE(audio_ioctl, CDC_PLAY_AUDIO); ENSURE(dev_ioctl, CDC_IOCTLS); - cdi->options = CDO_AUTO_CLOSE | CDO_USE_FFLAGS | CDO_LOCK; - /* default compatibility mode */ cdi->mc_flags = 0; cdo->n_minors = 0; - - { - static char banner_printed = 0; - if ( !banner_printed ) { - printk(KERN_INFO "Uniform CD-ROM driver " REVISION "\n"); - banner_printed = 1; - } - } + cdi->options = CDO_USE_FFLAGS; + if (autoclose==1) + cdi->options |= (int) CDO_AUTO_CLOSE; + if (autoeject==1) + cdi->options |= (int) CDO_AUTO_EJECT; + if (lockdoor==1) + cdi->options |= (int) CDO_LOCK; + if (check_media_type==1) + cdi->options |= (int) CDO_CHECK_TYPE; cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name); cdi->next = topCdromPtr; @@ -290,7 +321,7 @@ struct cdrom_device_ops *cdo = cdi->ops; tracktype tracks; cdinfo(CD_OPEN, "entering open_for_data\n"); - /* Check if the driver can report drive status. If it can we + /* Check if the driver can report drive status. If it can, we can do clever things. If it can't, well, we at least tried! */ if (cdo->drive_status != NULL) { ret = cdo->drive_status(cdi, CDSL_CURRENT); @@ -337,10 +368,15 @@ } /* CD-Players which don't use O_NONBLOCK, workman * for example, need bit CDO_CHECK_TYPE cleared! */ - if (cdi->options & CDO_CHECK_TYPE && tracks.data==0) { - cdinfo(CD_OPEN, "bummer. wrong media type.\n"); - ret=-EMEDIUMTYPE; - goto clean_up_and_return; + if (tracks.data==0) { + if (cdi->options & CDO_CHECK_TYPE) { + cdinfo(CD_OPEN, "bummer. wrong media type.\n"); + ret=-EMEDIUMTYPE; + goto clean_up_and_return; + } + else { + cdinfo(CD_OPEN, "wrong media type, but CDO_CHECK_TYPE not set.\n"); + } } cdinfo(CD_OPEN, "all seems well, opening the device.\n"); @@ -367,7 +403,7 @@ (notably ide-cd) lock the drive after every command. This produced a nasty bug where after mount failed, the drive would remain locked! This ensures that the drive gets unlocked after a mount fails. This - is a goto to avoid adding bloating the driver with redundant code. */ + is a goto to avoid bloating the driver with redundant code. */ clean_up_and_return: cdinfo(CD_WARNING, "open failed.\n"); if (cdo->capability & ~cdi->mask & CDC_LOCK && @@ -379,8 +415,7 @@ } /* This code is similar to that in open_for_data. The routine is called - in case a audio play operation is requested. It doesn't make much sense - to do this on a data disc. + whenever an audio play operation is requested. */ int check_for_audio_disc(struct cdrom_device_info * cdi, struct cdrom_device_ops * cdo) @@ -692,8 +727,6 @@ cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n"); if (!(cdo->capability & ~cdi->mask & CDC_SELECT_SPEED)) return -ENOSYS; - if ((int)arg > cdi->speed ) - return -EINVAL; return cdo->select_speed(cdi, arg); } @@ -1019,18 +1052,33 @@ {0} }; -#endif /* endif CONFIG_SYSCTL */ - - -#ifdef MODULE - -#ifdef CONFIG_SYSCTL - static struct ctl_table_header *cdrom_sysctl_header; +/* + * This is called as the fill_inode function when an inode + * is going into (fill = 1) or out of service (fill = 0). + * We use it here to manage the module use counts. + * + * Note: only the top-level directory needs to do this; if + * a lower level is referenced, the parent will be as well. + */ +static void cdrom_procfs_modcount(struct inode *inode, int fill) +{ + if (fill) + MOD_INC_USE_COUNT; + else + MOD_DEC_USE_COUNT; +} + static void cdrom_sysctl_register(void) { + static int initialized = 0; + + if ( initialized == 1 ) + return; cdrom_sysctl_header = register_sysctl_table(cdrom_root_table, 0); + cdrom_root_table->de->fill_inode = &cdrom_procfs_modcount; + initialized = 1; } static void cdrom_sysctl_unregister(void) @@ -1038,6 +1086,8 @@ unregister_sysctl_table(cdrom_sysctl_header); } #endif /* endif CONFIG_SYSCTL */ + +#ifdef MODULE int init_module(void) { diff --unified --new-file --recursive linux-2.1.108.virgin/drivers/cdrom/cdu31a.c linux/drivers/cdrom/cdu31a.c --- linux-2.1.108.virgin/drivers/cdrom/cdu31a.c Sat Feb 28 09:19:51 1998 +++ linux/drivers/cdrom/cdu31a.c Thu Jul 16 23:17:47 1998 @@ -5,6 +5,8 @@ * * Colossians 3:17 * +* See Documentation/cdrom/cdu31a for additional details about this driver. +* * The Sony interface device driver handles Sony interface CDROM * drives and provides a complete block-level interface as well as an * ioctl() interface compatible with the Sun (as specified in @@ -106,69 +108,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + * TODO: + * CDs with form1 and form2 sectors cause problems + * with current read-ahead strategy. * * Credits: * Heiko Eissfeldt <heiko@colossus.escape.de> * For finding abug in the return of the track numbers. - */ -/* conversion to Uniform cdrom layer. - TOC processing redone for proper multisession support. - - TODO: - CDs with form1 and form2 sectors cause problems - with current read-ahead strategy. - Heiko Eissfeldt Sep 97 */ - -/* + * TOC processing redone for proper multisession support. * - * Setting up the Sony CDU31A/CDU33A drive interface card. If - * You have another card, you are on your own. - * - * +----------+-----------------+----------------------+ - * | JP1 | 34 Pin Conn | | - * | JP2 +-----------------+ | - * | JP3 | - * | JP4 | - * | +--+ - * | | +-+ - * | | | | External - * | | | | Connector - * | | | | - * | | +-+ - * | +--+ - * | | - * | +--------+ - * | | - * +------------------------------------------+ - * - * JP1 sets the Base Address, using the following settings: - * - * Address Pin 1 Pin 2 - * ------- ----- ----- - * 0x320 Short Short - * 0x330 Short Open - * 0x340 Open Short - * 0x360 Open Open - * - * JP2 and JP3 configure the DMA channel; they must be set the same. - * - * DMA Pin 1 Pin 2 Pin 3 - * --- ----- ----- ----- - * 1 On Off On - * 2 Off On Off - * 3 Off Off On - * - * JP4 Configures the IRQ: - * - * IRQ Pin 1 Pin 2 Pin 3 Pin 4 - * --- ----- ----- ----- ----- - * 3 Off Off On Off - * 4 Off Off* Off On - * 5 On Off Off Off - * 6 Off On Off Off - * - * * The documentation states to set this for interrupt - * 4, but I think that is a mistake. * * It probably a little late to be adding a history, but I guess I * will start. @@ -190,6 +138,10 @@ * just dead code left over from the port. * Erik Andersen <andersee@debian.org> * + * 16 July 1998 -- Drive donated to Erik Andersen by John Kodis + * <kodis@jagunet.com>. Work begun on fixing driver to + * work under 2.1.X. Added temporary extra printks + * which seem to slow it down enough to work. */ #include <linux/major.h> @@ -257,6 +209,7 @@ static int handle_sony_cd_attention(void); static int read_subcode(void); static void sony_get_toc(void); +static int scd_spinup(void); /*static int scd_open(struct inode *inode, struct file *filp);*/ static int scd_open(struct cdrom_device_info *, int); static void do_sony_cd_cmd(unsigned char cmd, @@ -419,9 +372,10 @@ /* we have no changer support */ return -EINVAL; } - - /*return sony_spun_up ? CDS_DISC_OK : CDS_DRIVE_NOT_READY;*/ - return sony_spun_up ? CDS_DISC_OK : CDS_TRAY_OPEN; + if (scd_spinup() == 0) { + sony_spun_up = 1; + } + return sony_spun_up ? CDS_DISC_OK : CDS_DRIVE_NOT_READY; } static inline void @@ -1680,7 +1634,6 @@ #endif } -static int scd_spinup(void); /* * The OS calls this to perform a read or write operation to the drive. @@ -1984,8 +1937,11 @@ session = 1; while (1) { -#if DEBUG - printk("Trying session %d\n", session); +/* This seems to slow things down enough to make it work. This + * appears to be a problem in do_sony_cd_cmd. This printk seems + * to address the symptoms... -Erik */ +#if 1 + printk("cdu31a: Trying session %d\n", session); #endif parms[0] = session; do_sony_cd_cmd(SONY_READ_TOC_SPEC_CMD, @@ -2001,6 +1957,8 @@ if ((res_size < 2) || ((res_reg[0] & 0xf0) == 0x20)) { /* An error reading the TOC, this must be past the last session. */ + if (session == 1) + printk("Yikes! Couldn't read any sessions!"); break; } #if DEBUG

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html