public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] CDROMPLAYTRKIND translation in sr_ioctl.c for idescsi
@ 2000-11-12  2:55 Daniel R Risacher
  2000-11-12  6:16 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel R Risacher @ 2000-11-12  2:55 UTC (permalink / raw)
  To: linux-kernel


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. It is essentially the same thing as the
patch I posted for 2.2.12 on 19 Oct 1999, but updated for 2.4.0-test9.
This probably isn't the most elegant solution, but maybe it'll help
some people out until Jens figures out something better.

Daniel Risacher


--- linux/Documentation/Configure.help.old	Fri Sep 22 20:11:37 2000
+++ linux/Documentation/Configure.help	Sat Nov 11 19:02:05 2000
@@ -588,6 +588,20 @@
 
   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/ide/Config.in.old	Sat Nov 11 21:35:01 2000
+++ linux/drivers/ide/Config.in	Sat Nov 11 19:56:31 2000
@@ -31,6 +31,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 $CONFIG_SCSI
+  if [ "$CONFIG_BLK_DEV_IDESCSI" != "n" ]; then
+    bool '     Enable IDE-SCSI workaround in SCSI CDROM driver' CONFIG_SCSI_IDESCSI_WORKAROUND
+  fi
 
    comment 'IDE chipset support/bugfixes'
    if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
--- linux/drivers/scsi/sr_ioctl.c.old	Sat Nov 11 19:48:17 2000
+++ linux/drivers/scsi/sr_ioctl.c	Sat Nov 11 21:25:46 2000
@@ -1,3 +1,4 @@
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -30,6 +31,53 @@
 /* In fact, it is very slow if it has to spin up first */
 #define IOCTL_TIMEOUT 30*HZ
 
+#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;
+    u_char sr_cmd[10];
+    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);
+
+    sr_cmd[0] = GPCMD_PLAY_AUDIO_MSF;
+    sr_cmd[3] = trk0_te.cdte_addr.msf.minute;
+    sr_cmd[4] = trk0_te.cdte_addr.msf.second;
+    sr_cmd[5] = trk0_te.cdte_addr.msf.frame;
+    sr_cmd[6] = trk1_te.cdte_addr.msf.minute;
+    sr_cmd[7] = trk1_te.cdte_addr.msf.second;
+    sr_cmd[8] = trk1_te.cdte_addr.msf.frame;
+    printk ("Playing MSF %d %d %d to %d %d %d\n",
+            sr_cmd[3],
+            sr_cmd[4],
+            sr_cmd[5],
+            sr_cmd[6],
+            sr_cmd[7],
+            sr_cmd[8]);
+    return sr_do_ioctl(MINOR(cdi->dev), sr_cmd, NULL, 0, 0, SCSI_DATA_NONE);
+}
+#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 */
@@ -332,6 +380,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] = GPCMD_PLAYAUDIO_TI;
@@ -342,9 +393,9 @@
 		sr_cmd[8] = ti->cdti_ind1;
 
 		result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0, SCSI_DATA_NONE);
+#endif
 		break;
 	}
 	default:
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] CDROMPLAYTRKIND translation in sr_ioctl.c for idescsi
  2000-11-12  2:55 [PATCH] CDROMPLAYTRKIND translation in sr_ioctl.c for idescsi Daniel R Risacher
@ 2000-11-12  6:16 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2000-11-12  6:16 UTC (permalink / raw)
  To: Daniel R Risacher; +Cc: linux-kernel

On Sat, Nov 11 2000, Daniel R Risacher wrote:
> 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.

Yup

> 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. It is essentially the same thing as the
> patch I posted for 2.2.12 on 19 Oct 1999, but updated for 2.4.0-test9.
> This probably isn't the most elegant solution, but maybe it'll help
> some people out until Jens figures out something better.

I would take this patch, if you made it a fall back path when
PLAYAUDIO_TI fails with 05/20/00 sense. That makes a lot more sense
to me (pun intended) than a config option. What do you think, will
you do that?

For 2.5 the CD-ROM setup will be feature based. This is all supported
by newer drives, but it should be possible to make pseudo feature
profiles for older drives. This has the advantage that we always
'know' what is supported and what is not -- no more trial and error.

-- 
* Jens Axboe <axboe@suse.de>
* SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-11-12  6:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-12  2:55 [PATCH] CDROMPLAYTRKIND translation in sr_ioctl.c for idescsi Daniel R Risacher
2000-11-12  6:16 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox