DVD RAM patch.

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Wed, 22 Sep 1999 12:19:08 +0200 (MEST)


Hi Alan,

I see that a stupid patch for the Panasonic DVD RAM drive has slipped
into the 2.2.x kernels.

It is stupid because it drops "CD" support (i.e. play audio) for that
drive. It is also stupid because it clutters the code with another
inline check for another specific device. It is furthermore stupid
because it doesn't work for any of the other DVD RAM drives out there.

How about the attached one? It also cleans up the other inline check
for another device: the very old Toshiba CD.

It patches cleanly into 2.2.13pre8, so don't worry it was generated
against 2.2.12 .

(Should mail manage to munge on this: Try
http://www.bitwizard.nl/dvd/scsi_dvdram_patch_v4
)

Best regards,

Roger.

--------------------------------------------------------------------

diff -ur linux-2.2.12.clean/drivers/scsi/scsi.c linux/drivers/scsi/scsi.c
--- linux-2.2.12.clean/drivers/scsi/scsi.c Mon Aug 9 21:04:40 1999
+++ linux/drivers/scsi/scsi.c Wed Sep 22 11:51:03 1999
@@ -104,14 +104,17 @@
* lock up.
*/

-#define BLIST_NOLUN 0x01
-#define BLIST_FORCELUN 0x02
-#define BLIST_BORKEN 0x04
-#define BLIST_KEY 0x08
-#define BLIST_SINGLELUN 0x10
-#define BLIST_NOTQ 0x20
-#define BLIST_SPARSELUN 0x40
-#define BLIST_MAX5LUN 0x80
+#define BLIST_NOLUN 0x001
+#define BLIST_FORCELUN 0x002
+#define BLIST_BORKEN 0x004
+#define BLIST_KEY 0x008
+#define BLIST_SINGLELUN 0x010
+#define BLIST_NOTQ 0x020
+#define BLIST_SPARSELUN 0x040
+#define BLIST_MAX5LUN 0x080
+#define BLIST_ISDISK 0x100
+#define BLIST_ISROM 0x200
+#define BLIST_GHOST 0x400

/*
* Data declarations.
@@ -288,10 +291,14 @@
{"CANON","IPUBJD","*", BLIST_SPARSELUN},
{"nCipher","Fastness Crypto","*", BLIST_FORCELUN},
{"NEC","PD-1 ODX654P","*", BLIST_FORCELUN | BLIST_SINGLELUN},
-{"MATSHITA","PD","*", BLIST_FORCELUN | BLIST_SINGLELUN},
+{"MATSHITA","PD-1","*", BLIST_FORCELUN | BLIST_SINGLELUN},
{"YAMAHA","CDR100","1.00", BLIST_NOLUN}, /* Locks up if polled for lun != 0 */
{"YAMAHA","CDR102","1.00", BLIST_NOLUN}, /* Locks up if polled for lun != 0 */
{"iomega","jaz 1GB","J.86", BLIST_NOTQ | BLIST_NOLUN},
+{"CREATIVE","DVD-RAM RAM","*", BLIST_GHOST},
+{"MATSHITA","PD-2 LF-D100","*", BLIST_GHOST},
+{"YAMAHA","CRW4416S","*", BLIST_GHOST},
+{"TOSHIBA","CDROM","*", BLIST_ISROM},
/*
* Must be at end of list...
*/
@@ -654,6 +661,8 @@
struct Scsi_Device_Template *sdtpnt;
Scsi_Device * SDtail, *SDpnt=*SDpnt2;
int bflags, type=-1;
+ static int ghost_channel=-1, ghost_dev=-1;
+ int org_lun = lun;

SDpnt->host = shpnt;
SDpnt->id = dev;
@@ -661,6 +670,12 @@
SDpnt->channel = channel;
SDpnt->online = TRUE;

+ if ((channel == ghost_channel) && (dev == ghost_dev) && (lun == 1)) {
+ SDpnt->lun = 0;
+ } else {
+ ghost_channel = ghost_dev = -1;
+ }
+
/* Some low level driver could use device->type (DB) */
SDpnt->type = -1;

@@ -753,26 +768,37 @@
}

/*
- * It would seem some TOSHIBA CDROM gets things wrong
+ * Get any flags for this device.
*/
- if (!strncmp (scsi_result + 8, "TOSHIBA", 7) &&
- !strncmp (scsi_result + 16, "CD-ROM", 6) &&
- scsi_result[0] == TYPE_DISK) {
- scsi_result[0] = TYPE_ROM;
+ bflags = get_device_flags (scsi_result);
+
+ /* The Toshiba ROM was "gender-changed" here as an inline hack.
+ This is now much more generic.
+ This is a mess: What we really want is to leave the scsi_result
+ alone, and just change the SDpnt structure. And the SDpnt is what
+ we want print_inquiry to print. -- REW
+ */
+ if (bflags & BLIST_ISDISK) {
+ scsi_result[0] = TYPE_DISK;
scsi_result[1] |= 0x80; /* removable */
}

- /*
- * It would seem the Panasonic DVD-RAM is backwards too
- * If DVD-RAM or PD media used, it seems to function
- * as Direct-Access
- */
- if (!strncmp (scsi_result + 8, "MATSHITA", 7) &&
- !strncmp (scsi_result + 16, "PD-2 LF-D100", 12)) {
- scsi_result[0] = TYPE_DISK;
+ if (bflags & BLIST_ISROM) {
+ scsi_result[0] = TYPE_ROM;
scsi_result[1] |= 0x80; /* removable */
}

+ if (bflags & BLIST_GHOST) {
+ if ((ghost_channel == channel) && (ghost_dev == dev) && (org_lun == 1)) {
+ lun=1;
+ } else {
+ ghost_channel = channel;
+ ghost_dev = dev;
+ scsi_result[0] = TYPE_MOD;
+ scsi_result[1] |= 0x80; /* removable */
+ }
+ }
+
memcpy (SDpnt->vendor, scsi_result + 8, 8);
memcpy (SDpnt->model, scsi_result + 16, 16);
memcpy (SDpnt->rev, scsi_result + 32, 4);
@@ -835,10 +861,6 @@
*/
SDpnt->disconnect = 0;

- /*
- * Get any flags for this device.
- */
- bflags = get_device_flags (scsi_result);

/*
* Set the tagged_queue flag for SCSI-II devices that purport to support
@@ -961,6 +983,15 @@
*/
if (bflags & BLIST_FORCELUN) {
*max_dev_lun = 8;
+ return 1;
+ }
+
+ /*
+ * If this device is Ghosted, scan upto two luns. (It physically only
+ * has one). -- REW
+ */
+ if (bflags & BLIST_GHOST) {
+ *max_dev_lun = 2;
return 1;
}

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------

- 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.tux.org/lkml/