From owner-freebsd-hackers Fri Jan 2 02:20:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.7/8.8.7) id CAA23118 for hackers-outgoing; Fri, 2 Jan 1998 02:20:34 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id CAA23110 for ; Fri, 2 Jan 1998 02:20:28 -0800 (PST) (envelope-from luigi@labinfo.iet.unipi.it) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id JAA15463 for hackers@freebsd.org; Fri, 2 Jan 1998 09:56:58 +0100 From: Luigi Rizzo Message-Id: <199801020856.JAA15463@labinfo.iet.unipi.it> Subject: ATAPI again To: hackers@FreeBSD.ORG Date: Fri, 2 Jan 1998 09:56:58 +0100 (MET) X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk 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,