Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Jan 1998 09:56:58 +0100 (MET)
From:      Luigi Rizzo <luigi@labinfo.iet.unipi.it>
To:        hackers@FreeBSD.ORG
Subject:   ATAPI again
Message-ID:  <199801020856.JAA15463@labinfo.iet.unipi.it>

next in thread | raw e-mail | index | archive | help
Hi,

I did some work on the atapi driver (atapi.c and wcd.c) aimed at
reading audio data from the disk. I am encountering a few problems
which I'll try to summarize.

1) timeout in MODE_SENSE at boot time.

First thing I tried was to make the boot message a bit more verbose
by dumping the various capability bits from the capability page.

I realized (at least on my SONY CDU-55E, but I have seen the same
behaviour on different drives in the last years) that frequently
(not sure about the exact cause, but more often after a warm boot or
when the tray is closed) the initial MODE_SENSE to get the capabilities
of the drive fails.  I thought it was a problem of the drive, but
now I think it is some problem in the driver.

In any case I managed to see that my drive (at least from the
capabilities) is able to extract audio data and other info via the
READ_CD command -- which is mandatory anyways for most formats
except CD-DA).

2) timeout in READ_CD

Second thing I tried was to replace the ATAPI_READ_BIG command with
ATAPI_READ_CD (with the proper changes in parameters). Unfortunately,
with this change, the first interrupt returns a length of 0 which
prevents the actual data transfer to complete. I tried to fake the
length to 2048 (for CDROM) but no success.

Maybe both things are related ?

The (minimal) diff for READ_CD is the following (wcd.c), plus you need
to add the following line to atapi.h

atapi.h:#define ATAPI_READ_CD           0xbe    /* universal read command */

	Cheers
	Luigi

--- wcd.c.orig	Sun Sep  8 12:28:23 1996
+++ wcd.c	Fri Jan  2 11:11:40 1998
@@ -323,6 +323,10 @@
 		if (t->flags & F_DEBUG)
 			wcd_dump (t->lun, "cap", &t->cap, sizeof t->cap);
 	}
+	else {
+	    printf("wcd: result code %d\n", result.code);
+	    wcd_describe (t);
+	}
 
 
 #ifdef DEVFS
@@ -402,6 +406,35 @@
 	if (t->cap.prevent)
 		printf (", lock protected");
 	printf ("\n");
+
+	printf ("wcd%d: ", t->lun);
+	if (t->cap.composite)
+		printf(", composite A/V");
+	if (t->cap.dport1)
+		printf(", dig.audio 1");
+	if (t->cap.dport2)
+		printf(", dig.audio 2");
+	if (t->cap.mode2_form1)
+		printf(", mode 2 form 1(XA)");
+	if (t->cap.mode2_form2)
+		printf(", mode 2 form 2");
+	if (t->cap.multisession)
+		printf(", multisession");
+	if (t->cap.cd_da)
+		printf(", CD-DA read");
+	if (t->cap.cd_da_stream)
+		printf(", CD-DA stream");
+	if (t->cap.rw)
+		printf(", combined rw");
+	if (t->cap.rw_corr)
+		printf(", rw correct.");
+	if (t->cap.c2)
+		printf(", C2 ptrs");
+	if (t->cap.isrc)
+		printf(", ISRC");
+	if (t->cap.upc)
+		printf(", UPC");
+	printf("\n");
 }
 
 static int 
@@ -547,11 +580,25 @@
 	 * What if something asks for 512 bytes not on a 2k boundary? */
 	blkno = bp->b_blkno / (SECSIZE / 512);
 	nblk = (bp->b_bcount + (SECSIZE - 1)) / SECSIZE;
-
+#if 1 /* XXX luigi */
+	/* byte 1 bit 4..2 indicate the expected sector type.
+	   0=any
+	   4=CDDA
+	   8=yellow book (2k, data)
+	   byte 9 should indicate the type of data to return.
+	   0x10 or 0x00 returns a LEN=0 to the DATAIN phase,
+	   thus causing a deadlock...
+	 */
+	atapi_request_callback (t->ata, t->unit, ATAPI_READ_CD, 0,
+		blkno>>24, blkno>>16, blkno>>8, blkno, 0, nblk>>8, nblk,0x10, 0,
+		0, 0, 0, 0, 0, (u_char*) bp->b_un.b_addr, bp->b_bcount,
+		wcd_done, t, bp);
+#else
 	atapi_request_callback (t->ata, t->unit, ATAPI_READ_BIG, 0,
 		blkno>>24, blkno>>16, blkno>>8, blkno, 0, nblk>>8, nblk, 0, 0,
 		0, 0, 0, 0, 0, (u_char*) bp->b_un.b_addr, bp->b_bcount,
 		wcd_done, t, bp);
+#endif
 }
 
 static void wcd_done (struct wcd *t, struct buf *bp, int resid,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801020856.JAA15463>