patch-pre2.0.13 linux/drivers/cdrom/sbpcd.c

Next file: linux/drivers/char/ChangeLog
Previous file: linux/drivers/cdrom/mcdx.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file pre2.0.12/linux/drivers/cdrom/sbpcd.c linux/drivers/cdrom/sbpcd.c
@@ -13,7 +13,7 @@
  *             labelled E2550UA or MK4015 or 2800F).
  */
 
-#define VERSION "v4.3 Eberhard Moenkeberg <emoenke@gwdg.de>"
+#define VERSION "v4.4 Eberhard Moenkeberg <emoenke@gwdg.de>"
 
 /*   Copyright (C) 1993, 1994, 1995  Eberhard Moenkeberg <emoenke@gwdg.de>
  *
@@ -278,6 +278,11 @@
  *       reading the ToC; still trying to solve it.
  *       Removed some redundant verify_area calls (yes, Heiko Eissfeldt
  *       is visiting all the Linux CDROM drivers ;-).
+ *       
+ *  4.4  Adapted one idea from tiensivu@pilot.msu.edu's "stripping-down"
+ *       experiments: "KLOGD_PAUSE".
+ *       Inhibited "play audio" attempts with data CDs. Provisions for a
+ *       "data-safe" handling of "mixed" (data plus audio) Cds.
  *
  *
  *  TODO
@@ -689,6 +694,9 @@
 	u_char TocEnt_number;
 	u_char TocEnt_format; /* em */
 	u_int TocEnt_address;
+#if SAFE_MIXED
+	char has_data;
+#endif SAFE_MIXED
 	u_char ored_ctl_adr; /* to detect if CDROM contains data tracks */
 	
 	struct {
@@ -751,7 +759,9 @@
 	vsprintf(&buf[18], fmt, args);
 	va_end(args);
 	printk(buf);
-	sbp_sleep(55); /* else messages get lost */
+#if KLOGD_PAUSE
+	sbp_sleep(KLOGD_PAUSE); /* else messages get lost */
+#endif KLOGD_PAUSE
 	return;
 }
 /*==========================================================================*/
@@ -1966,7 +1976,7 @@
 		else if (fam2_drive)
 		{
 			drvcmd[0]=CMD2_PLAY_MSF;
-			flags_cmd_out = f_putcmd | f_ResponseStatus;
+			flags_cmd_out = f_putcmd | f_ResponseStatus | f_obey_p_check;
 		}
 		else if (famT_drive)
 		{
@@ -3916,6 +3926,9 @@
 		
 	case CDROMPLAYMSF:
 		msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n");
+#if SAFE_MIXED
+		if (D_S[d].has_data>1) return (-EBUSY);
+#endif SAFE_MIXED
 		if (D_S[d].audio_state==audio_playing)
 		{
 			i=cc_Pause_Resume(1);
@@ -3938,15 +3951,21 @@
 		msg(DBG_IOX,"ioctl: CDROMPLAYMSF %08X %08X\n",
 		    D_S[d].pos_audio_start,D_S[d].pos_audio_end);
 		i=cc_PlayAudio(D_S[d].pos_audio_start,D_S[d].pos_audio_end);
-		msg(DBG_IOC,"ioctl: cc_PlayAudio returns %d\n",i);
-#if 0
-		if (i<0) return (-EIO);
-#endif 0
+		if (i<0)
+		{
+			msg(DBG_INF,"ioctl: cc_PlayAudio returns %d\n",i);
+			DriveReset();
+			D_S[d].audio_state=0;
+			return (-EIO);
+		}
 		D_S[d].audio_state=audio_playing;
 		return (0);
 		
 	case CDROMPLAYTRKIND: /* Play a track.  This currently ignores index. */
 		msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n");
+#if SAFE_MIXED
+		if (D_S[d].has_data>1) return (-EBUSY);
+#endif SAFE_MIXED
 		if (D_S[d].audio_state==audio_playing)
 		{
 			msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n");
@@ -3969,9 +3988,13 @@
 		D_S[d].pos_audio_start=D_S[d].TocBuffer[ti.cdti_trk0].address;
 		D_S[d].pos_audio_end=D_S[d].TocBuffer[ti.cdti_trk1+1].address;
 		i=cc_PlayAudio(D_S[d].pos_audio_start,D_S[d].pos_audio_end);
-#if 0
-		if (i<0) return (-EIO);
-#endif 0
+		if (i<0)
+		{
+			msg(DBG_INF,"ioctl: cc_PlayAudio returns %d\n",i);
+			DriveReset();
+			D_S[d].audio_state=0;
+			return (-EIO);
+		}
 		D_S[d].audio_state=audio_playing;
 		return (0);
 		
@@ -4015,6 +4038,9 @@
 		
 	case CDROMSTOP:      /* Spin down the drive */
 		msg(DBG_IOC,"ioctl: CDROMSTOP entered.\n");
+#if SAFE_MIXED
+		if (D_S[d].has_data>1) return (-EBUSY);
+#endif SAFE_MIXED
 		i=cc_Pause_Resume(1);
 		D_S[d].audio_state=0;
 		return (i);
@@ -4119,6 +4145,9 @@
 		
 	case CDROMREADMODE1:
 		msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n");
+#if SAFE_MIXED
+		if (D_S[d].has_data>1) return (-EBUSY);
+#endif SAFE_MIXED
 		cc_ModeSelect(CD_FRAMESIZE);
 		cc_ModeSense();
 		D_S[d].mode=READ_M1;
@@ -4126,6 +4155,9 @@
 		
 	case CDROMREADMODE2: /* not usable at the moment */
 		msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n");
+#if SAFE_MIXED
+		if (D_S[d].has_data>1) return (-EBUSY);
+#endif SAFE_MIXED
 		cc_ModeSelect(CD_FRAMESIZE_RAW1);
 		cc_ModeSense();
 		D_S[d].mode=READ_M2;
@@ -4165,6 +4197,9 @@
 		if (famL_drive) return (-EINVAL);
 		if (famV_drive) return (-EINVAL);
 		if (famT_drive) return (-EINVAL);
+#if SAFE_MIXED
+		if (D_S[d].has_data>1) return (-EBUSY);
+#endif SAFE_MIXED
 		if (D_S[d].aud_buf==NULL) return (-EINVAL);
 		i=verify_area(VERIFY_READ, (void *) arg, sizeof(struct cdrom_read_audio));
 		if (i) return (i);
@@ -4488,6 +4523,9 @@
 		sbp_sleep(0);
 		if (sbp_data() != 0)
 		{
+#if SAFE_MIXED
+			D_S[d].has_data=2; /* is really a data disk */
+#endif SAFE_MIXED
 			end_request(1);
 			goto request_loop;
 		}
@@ -4959,7 +4997,15 @@
 		i=DiskInfo();
 		if (famT_drive)	msg(DBG_TEA,"sbpcd_open: after i=DiskInfo();.\n");
 		if ((D_S[d].ored_ctl_adr&0x40)==0)
+		{		
 			msg(DBG_INF,"CD contains no data tracks.\n");
+#if SAFE_MIXED
+			D_S[d].has_data=0;
+#endif SAFE_MIXED
+		}
+#if SAFE_MIXED
+		else if (D_S[d].has_data<1) D_S[d].has_data=1;
+#endif SAFE_MIXED
 	}
 	if (!st_spinning) cc_SpinUp();
 	return (0);
@@ -4979,11 +5025,6 @@
 		return;
 	}
 	switch_drive(i);
-	
-	D_S[d].sbp_first_frame=D_S[d].sbp_last_frame=-1;
-	sync_dev(ip->i_rdev);                   /* nonsense if read only device? */
-	invalidate_buffers(ip->i_rdev);
-	
 	/*
 	 * try to keep an "open" counter here and unlock the door if 1->0.
 	 */
@@ -4994,11 +5035,17 @@
 	{
 		if (--D_S[d].open_count<=0) 
 		{
+			D_S[d].sbp_first_frame=D_S[d].sbp_last_frame=-1;
+			sync_dev(ip->i_rdev); /* nonsense if read only device? */
+			invalidate_buffers(ip->i_rdev);
 			i=UnLockDoor();
 			if (D_S[d].audio_state!=audio_playing)
 				if (D_S[d].f_eject) cc_SpinDown();
 			D_S[d].diskstate_flags &= ~cd_size_bit;
 			D_S[d].open_count=0; 
+#if SAFE_MIXED
+			D_S[d].has_data=0;
+#endif SAFE_MIXED
 		}
 	}
 }
@@ -5327,6 +5374,9 @@
 	{
 		if (D_S[j].drv_id==-1) continue;
 		switch_drive(j);
+#if SAFE_MIXED
+		D_S[j].has_data=0;
+#endif SAFE_MIXED
 		/*
 		 * allocate memory for the frame buffers
 		 */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this