[PATCH] command translation for ide-scsi cdrom (pls test)

Daniel R Risacher (magnus@alum.mit.edu)
Tue, 19 Oct 1999 11:12:51 -0500


Summary:

Many audio-cdrom-playing programs don't work correctly with ATAPI
CDROM drives under ide-scsi translation, because ATAPI doesn't support
the PLAYAUDIO_TI command. The ide-cd driver handles this by
transforming CDROMPLAYTRKIND ioctls into something that the ATAPI
drive will understand, but this mechanism is bypassed when using
ide-scsi translation.

This patch creates a new kernel option,
CONFIG_SCSI_IDESCSI_WORKAROUND, that is available whenever ide-scsi
translation is enabled. Enabling this new option includes a
tranlation mechanism into the SCSI CDROM (sr) driver similar to the
mechanism in the ide-cd driver.

Hopefully this will make life much easier for those of us who use
ide-scsi for CDROM drives. The patch was made against 2.2.12,
although since it's a new feature, it probably should have been
against 2.3.xx. (sorry)

Daniel Risacher

--- linux/drivers/scsi/sr_ioctl.c.old Tue Oct 19 10:07:25 1999
+++ linux/drivers/scsi/sr_ioctl.c Tue Oct 19 10:14:46 1999
@@ -1,3 +1,4 @@
+#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
@@ -44,6 +45,46 @@
}
}

+#ifdef CONFIG_SCSI_IDESCSI_WORKAROUND
+/* ATAPI drives don't have a SCMD_PLAYAUDIO_TI command. When these drives
+ are emulating a SCSI device via the idescsi module, they need to have
+ CDROMPLAYTRKIND commands translated into CDROMPLAYMSF commands for them */
+
+static int
+sr_fake_playtrkind(struct cdrom_device_info *cdi, unsigned int cmd, void* arg)
+{
+ struct cdrom_ti* ti = (struct cdrom_ti*)arg;
+ struct cdrom_msf msf;
+ struct cdrom_tocentry trk0_te, trk1_te;
+ int ntracks;
+ struct cdrom_tochdr tochdr;
+ sr_audio_ioctl(cdi, CDROMREADTOCHDR, &tochdr);
+ ntracks = tochdr.cdth_trk1 - tochdr.cdth_trk0 + 1;
+
+ if (ti->cdti_trk1 == ntracks)
+ ti->cdti_trk1 = CDROM_LEADOUT;
+ else
+ ti->cdti_trk1 ++;
+
+ trk0_te.cdte_track = ti->cdti_trk0;
+ trk0_te.cdte_format = CDROM_MSF;
+ trk1_te.cdte_track = ti->cdti_trk1;
+ trk1_te.cdte_format = CDROM_MSF;
+
+ sr_audio_ioctl(cdi, CDROMREADTOCENTRY, &trk0_te);
+ sr_audio_ioctl(cdi, CDROMREADTOCENTRY, &trk1_te);
+
+ msf.cdmsf_min0 = trk0_te.cdte_addr.msf.minute;
+ msf.cdmsf_sec0 = trk0_te.cdte_addr.msf.second;
+ msf.cdmsf_frame0 = trk0_te.cdte_addr.msf.frame;
+ msf.cdmsf_min1 = trk1_te.cdte_addr.msf.minute;
+ msf.cdmsf_sec1 = trk1_te.cdte_addr.msf.second;
+ msf.cdmsf_frame1 = trk1_te.cdte_addr.msf.frame;
+
+ return sr_audio_ioctl(cdi, CDROMPLAYMSF, &msf);
+}
+#endif
+
/* We do our own retries because we want to know what the specific
error code is. Normally the UNIT_ATTENTION code will automatically
clear after one error */
@@ -374,6 +415,9 @@

case CDROMPLAYTRKIND:
{
+#ifdef CONFIG_SCSI_IDESCSI_WORKAROUND
+ result = sr_fake_playtrkind(cdi, cmd, arg);
+#else
struct cdrom_ti* ti = (struct cdrom_ti*)arg;

sr_cmd[0] = SCMD_PLAYAUDIO_TI;
@@ -388,6 +432,7 @@
sr_cmd[9] = 0;

result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0);
+#endif
break;
}

--- linux/Documentation/Configure.help.old Sat Aug 28 11:17:44 1999
+++ linux/Documentation/Configure.help Tue Oct 19 09:57:56 1999
@@ -455,6 +455,20 @@

People with SCSI-only systems can say N here. If unsure, say N.

+IDE-SCSI workaround
+CONFIG_SCSI_IDESCSI_WORKAROUND
+
+ This will enable the SCSI CDROM driver to work around a limitation of
+ the ATAPI specification. The ATAPI spec does not support the
+ play-track-index command, which means that many programs that play
+ audio CD's will not work correctly when using SCSI emulation.
+
+ With this option, the SCSI CDROM driver translates play-track-index
+ commands into play-minute-second-frame commands, in a way similar to
+ the IDE CDROM driver.
+
+ If unsure, say Y.
+
CMD640 chipset bugfix/support
CONFIG_BLK_DEV_CMD640
The CMD-Technologies CMD640 IDE chip is used on many common 486 and
--- linux/drivers/block/Config.in.old Tue Aug 10 20:01:43 1999
+++ linux/drivers/block/Config.in Tue Oct 19 09:58:03 1999
@@ -23,6 +23,9 @@
dep_tristate ' Include IDE/ATAPI TAPE support' CONFIG_BLK_DEV_IDETAPE $CONFIG_BLK_DEV_IDE
dep_tristate ' Include IDE/ATAPI FLOPPY support' CONFIG_BLK_DEV_IDEFLOPPY $CONFIG_BLK_DEV_IDE
dep_tristate ' SCSI emulation support' CONFIG_BLK_DEV_IDESCSI $CONFIG_BLK_DEV_IDE
+ if [ "$CONFIG_BLK_DEV_IDESCSI" != "n" ]; then
+ bool ' Enable IDE-SCSI workaround in SCSI CDROM driver' CONFIG_SCSI_IDESCSI_WORKAROUND
+ fi
if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
bool ' CMD640 chipset bugfix/support' CONFIG_BLK_DEV_CMD640
if [ "$CONFIG_BLK_DEV_CMD640" = "y" ]; then
--- linux/drivers/scsi/sr.c.old Fri Jan 15 16:41:04 1999
+++ linux/drivers/scsi/sr.c Tue Oct 19 10:11:18 1999
@@ -20,6 +20,8 @@
* Modified by Gerd Knorr <kraxel@cs.tu-berlin.de> to support the
* generic cdrom interface
*
+ * Modified by Daniel Risacher <magnus@alum.mit.edu> to include
+ * the workaround for scsi-emulated ATAPI drives
*/

#include <linux/module.h>

-
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/