From owner-freebsd-hackers Sat Jan 3 05:58:49 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.7/8.8.7) id FAA12381 for hackers-outgoing; Sat, 3 Jan 1998 05:58:49 -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 FAA12374 for ; Sat, 3 Jan 1998 05:58:43 -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 NAA16694; Sat, 3 Jan 1998 13:35:39 +0100 From: Luigi Rizzo Message-Id: <199801031235.NAA16694@labinfo.iet.unipi.it> Subject: read audio from atapi cd: success! To: hackers@FreeBSD.ORG Date: Sat, 3 Jan 1998 13:35:39 +0100 (MET) X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk Well, I managed to put together some code to read audio data from ATAPI CDs :) The code is very primitive and inefficient (e.g. it uses ioctl() and cannot currently read more than one block at a time, meaning it is far slower than real time at least on my 2x drive) but it is there as a hint to somebody with more knowledge than I have to make it work well. I DO NOT recommend to commit the as it is now, but I do hope that some committer with sufficient knowledge has the time to work on it and improve it according to the suggestion which follow. Diffs (more or less against 2.2.1R) are at ttp://www.iet.unipi.it/~luigi/cdda.diffs They include changes to 3 files: atapi.c, wcd.c and cdio.h, and a simple program to test the ioctl and read audio data. The patch also includes a more verbose attach to reveal the capabilities of the drive, and an attempt to make the initial MODE_SENSE not timeout. However the latter seems to be very unreliable on my drive (Sony CDU-55E), which often returns a CHECK code. BRIEF DESCRIPTION OF THE CODE My initial goal was to support reading audio data through the read() interface. However, I was having some trouble and unexpected behaviours in replacing the READ_BIG with READ_CD command (maybe due to interactions with other commands), so I decided to go along another way and introduce a new ioctl() to be able to play with the parameters in the atapi command. The way I have implemented it, the ioctl issues a wcd_request_wait for ATAPI_READ_CD, copying each block into a kernel buffer and from there into user space using copyout. This is highly inefficient since you cannot read more than 1 sector/revolution. It ought to be made more efficient by using a larger block of storage and allowing for more than one sector at a time. I am not sure of how much work is necessary to make the ioctl() copy directly into the user-supplied buffer, it is probably necessary to lock the buffer in memory and map it into the kernel space around the transfer -- more or less what is done in function physio() in file /sys/kern/kern_physio.c. There might be more efficient ways, and I'd hate duplicating lot of code which is already there... Cheers Luigi -----------------------------+-------------------------------------- Luigi Rizzo | Dip. di Ingegneria dell'Informazione email: luigi@iet.unipi.it | Universita' di Pisa tel: +39-50-568533 | via Diotisalvi 2, 56126 PISA (Italy) fax: +39-50-568522 | http://www.iet.unipi.it/~luigi/ _____________________________|______________________________________