From bogstad@condor.cs.jhu.edu Tue Nov  8 17:47:12 EST 1994
Article: 21237 of comp.os.linux.development
Path: bigblue.oit.unc.edu!concert!gatech!europa.eng.gtefsd.com!darwin.sura.net!jhunix1.hcf.jhu.edu!blaze.cs.jhu.edu!condor.cs.jhu.edu!not-for-mail
From: bogstad@condor.cs.jhu.edu (Bill Bogstad)
Newsgroups: comp.os.linux.development
Subject: Patches for NEC CDR-35D-01 CD-ROM drive and kernel 1.1.64
Date: 21 Nov 1994 11:03:27 -0500
Organization: The Johns Hopkins University, Computer Science Department
Lines: 155
Message-ID: <3aqgcf$be6@condor.cs.jhu.edu>
NNTP-Posting-Host: condor.cs.jhu.edu

	The following patches allow a really old NEC CD-ROM drive
(CDR-35D-01) to be used with Linux.  In particular, when you use a boot time
option of 'sr=1'; they disable some of the mandatory features of real SCSI
CD-ROM drives.  The patches have only been tested with an Adaptec 1542B SCSI
controller and a Archive 2150S on the bus.  Anyone else who has one of these
in a closet somewhere might want to try these patches.  They do not solve
the following problems:

1. The drive is set to SCSI ID 1 and can not be changed.
2. The drive (apparently) uses non-standard commands for playing of audio
CDs.  Attempts to use program control to play audio CDs even with these
patches will probably lock up your machine.

Hopefully, this will allow at least one other person to use their old SCSI
CD-ROM drive for something.  The patches are against the current development
kernel (1.1.64).

				Bill Bogstad
				bogstad@cs.jhu.edu

*** linux/init/main.c.ORIG	Mon Nov 14 03:19:42 1994
--- linux/init/main.c	Mon Nov 21 02:00:40 1994
***************
*** 87,92 ****
--- 87,93 ----
  extern void xd_setup(char *str, int *ints);
  extern void mcd_setup(char *str, int *ints);
  extern void st_setup(char *str, int *ints);
+ extern void sr_setup(char *str, int *ints);
  extern void st0x_setup(char *str, int *ints);
  extern void tmc8xx_setup(char *str, int *ints);
  extern void t128_setup(char *str, int *ints);
***************
*** 192,197 ****
--- 193,201 ----
  #endif
  #ifdef CONFIG_CHR_DEV_ST
  	{ "st=", st_setup },
+ #endif
+ #ifdef CONFIG_BLK_DEV_SR
+ 	{ "sr=", sr_setup },
  #endif
  #ifdef CONFIG_BUSMOUSE
  	{ "bmouse=", bmouse_setup },
*** linux/drivers/scsi/scsi.c.ORIG	Mon Nov 14 01:42:48 1994
--- linux/drivers/scsi/scsi.c	Mon Nov 21 00:56:49 1994
***************
*** 145,150 ****
--- 145,151 ----
     {"MAXTOR","XT-4170S","B5A"},   /* Locks-up sometimes when LUN>0 polled. */
     {"MAXTOR","XT-8760S","B7B"},   /* guess what? */
     {"NEC","CD-ROM DRIVE:841","1.0"},  /* Locks-up when LUN>0 polled. */
+    {"NEC","CD-ROM2 DRIVE","000"},  /* Locks-up when LUN>0 polled. */
     {"RODIME","RO3000S","2.33"},  /* Locks up if polled for lun != 0 */
     {"SEAGATE", "ST157N", "\004|j"}, /* causes failed REQUEST SENSE on lun 1 for aha152x
  				     * controller, which causes SCSI code to reset bus.*/
*** linux/drivers/scsi/sr.c.ORIG	Wed Oct 12 08:57:30 1994
--- linux/drivers/scsi/sr.c	Mon Nov 21 02:01:48 1994
***************
*** 47,52 ****
--- 47,54 ----
  
  static int * sr_blocksizes;
  
+ static int sr_stupid = 0;
+ 
  static int sr_open(struct inode *, struct file *);
  static void get_sectorsize(int);
  
***************
*** 58,65 ****
  static void sr_release(struct inode * inode, struct file * file)
  {
  	sync_dev(inode->i_rdev);
! 	if(! --scsi_CDs[MINOR(inode->i_rdev)].device->access_count)
! 	  sr_ioctl(inode, NULL, SCSI_IOCTL_DOORUNLOCK, 0);
  }
  
  static struct file_operations sr_fops = 
--- 60,69 ----
  static void sr_release(struct inode * inode, struct file * file)
  {
  	sync_dev(inode->i_rdev);
! 
! 	if (!sr_stupid)
! 		if(! --scsi_CDs[MINOR(inode->i_rdev)].device->access_count)
! 			sr_ioctl(inode, NULL, SCSI_IOCTL_DOORUNLOCK, 0);
  }
  
  static struct file_operations sr_fops = 
***************
*** 271,276 ****
--- 275,290 ----
    }
  }
  
+ /* Set the boot options. Syntax: sr=n
+    where n = 0 for normal
+ 	 n = X for various levels of stupidity in CD-ROM
+ */
+ void sr_setup(char *str, int *ints)
+ {
+ 	if (ints[0] > 0 && ints[1] > 0)
+ 		sr_stupid = ints[1];
+ }
+ 
  static int sr_open(struct inode * inode, struct file * filp)
  {
  	if(MINOR(inode->i_rdev) >= sr_template.nr_dev || 
***************
*** 281,288 ****
  
          check_disk_change(inode->i_rdev);
  
! 	if(!scsi_CDs[MINOR(inode->i_rdev)].device->access_count++)
! 	  sr_ioctl(inode, NULL, SCSI_IOCTL_DOORLOCK, 0);
  
  	/* If this device did not have media in the drive at boot time, then
  	   we would have been unable to get the sector size.  Check to see if
--- 295,303 ----
  
          check_disk_change(inode->i_rdev);
  
! 	if (!sr_stupid)
! 		if(!scsi_CDs[MINOR(inode->i_rdev)].device->access_count++)
! 			sr_ioctl(inode, NULL, SCSI_IOCTL_DOORLOCK, 0);
  
  	/* If this device did not have media in the drive at boot time, then
  	   we would have been unable to get the sector size.  Check to see if
***************
*** 702,708 ****
    unsigned char buffer[513];
    int the_result, retries;
    Scsi_Cmnd * SCpnt;
!   
    SCpnt = allocate_device(NULL, scsi_CDs[i].device, 1);
  
    retries = 3;
--- 717,731 ----
    unsigned char buffer[513];
    int the_result, retries;
    Scsi_Cmnd * SCpnt;
! 
!   /* do some reasonable guesses */
!   if (sr_stupid) {
!     scsi_CDs[i].capacity = 0x1fffff;
!     scsi_CDs[i].sector_size = 2048;  /* A guess, just in case */
!     scsi_CDs[i].needs_sector_size = 0;
!     return;
!   }
! 
    SCpnt = allocate_device(NULL, scsi_CDs[i].device, 1);
  
    retries = 3;



