Date: Tue, 2 Jun 1998 16:48:24 -0700 (PDT) From: aswan@cs.berkeley.edu To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: kern/6843: patch to enable reading digital audio samples from an ide cdrom Message-ID: <199806022348.QAA00158@quimby.cs.berkeley.edu>
index | next in thread | raw e-mail
>Number: 6843
>Category: kern
>Synopsis: patch to enable reading digital audio samples from an ide cdrom
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Jun 2 16:50:00 PDT 1998
>Last-Modified:
>Originator: Andrew Swan
>Organization:
U.C. Berkeley
>Release: FreeBSD 2.2.6-RELEASE i386
>Environment:
Dell Dimenson XPS/H266, FreeBSD 2.2.6-RELEASE, NEC 286/3.05 CD-ROM
>Description:
I've included a patch here that adds an ioctl(), CDIOCREADAUDIO, to
the IDE cd-rom driver. This ioctl can be used to read the digital
audio samples directly off an audio cd. At this point, there isn't
a good program that uses this new interface to grab audio tracks,
but there is a linux program, cdda2wav, that does this which should
be easy to port. The patch works on my machine (see above) but I
haven't tested it on any different systems or different types of
drives.
>How-To-Repeat:
N/A
>Fix:
diff -rc sys-clean/i386/isa/atapi.h sys/i386/isa/atapi.h
*** sys-clean/i386/isa/atapi.h Tue Jun 2 16:05:34 1998
--- sys/i386/isa/atapi.h Tue Jun 2 16:09:53 1998
***************
*** 123,128 ****
--- 123,129 ----
*/
#define ATAPI_PLAY_MSF 0x47 /* play by MSF address */
#define ATAPI_PAUSE 0x4b /* stop/start audio operation */
+ #define ATAPI_READ_CD 0xbe /* read data */
/*
* Nonstandard packet commands
diff -rc sys-clean/i386/isa/wcd.c sys/i386/isa/wcd.c
*** sys-clean/i386/isa/wcd.c Tue Jun 2 16:05:47 1998
--- sys/i386/isa/wcd.c Tue Jun 2 16:26:04 1998
***************
*** 627,632 ****
--- 627,637 ----
*f = lba % 75;
}
+ static inline int msf2lba (u_char m, u_char s, u_char f)
+ {
+ return (m*60 + s)*75 + f - 150;
+ }
+
/*
* Perform special action on behalf of the user.
* Knows about the internals of this device
***************
*** 925,930 ****
--- 930,995 ----
case CDIOCSETRIGHT:
return wcd_setchan (t, CHANNEL_1, CHANNEL_1, 0, 0);
+
+ case CDIOCREADAUDIO: {
+ struct ioc_read_audio* args = (struct ioc_read_audio*) addr;
+ int lba, frames;
+ u_char* buffer, *ubuf;
+ int result = 0;
+
+ if (! t->toc.hdr.ending_track)
+ return (EIO);
+
+ frames = args->nframes;
+ if (frames < 0)
+ return (EINVAL);
+
+ ubuf = args->buffer;
+
+ if (args->address_format == CD_LBA_FORMAT)
+ lba = htonl(args->address.lba);
+ else if (args->address_format == CD_MSF_FORMAT)
+ lba = htonl(msf2lba(args->address.msf.minute,
+ args->address.msf.second,
+ args->address.msf.frame));
+ else
+ return (EINVAL);
+
+ #ifndef CD_BUFFER_BLOCKS
+ #define CD_BUFFER_BLOCKS 8
+ #endif
+ buffer = malloc(CD_BUFFER_BLOCKS * 2352, M_TEMP, M_NOWAIT);
+ if (!buffer)
+ return (ENOMEM);
+
+ while (frames > 0) {
+ u_char blocks;
+ int size;
+
+ blocks = (frames > CD_BUFFER_BLOCKS)
+ ? CD_BUFFER_BLOCKS : frames;
+ size = blocks * 2352;
+
+ result = wcd_request_wait(t, ATAPI_READ_CD, (1<<2),
+ lba>>24, ((lba>>16)&0xff),
+ ((lba>>8)&0xff), lba&0xff, 0, 0,
+ blocks, 0xf0, buffer, size);
+ if (result != 0)
+ break;
+
+ result = copyout(buffer, ubuf, size);
+ if (result != 0)
+ break;
+
+ ubuf += size;
+ frames -= blocks;
+ lba += blocks;
+ }
+
+ free(buffer, M_TEMP);
+ return (result);
+ }
+
}
return (error);
}
diff -rc sys-clean/sys/cdio.h sys/sys/cdio.h
*** sys-clean/sys/cdio.h Tue Jun 2 16:06:31 1998
--- sys/sys/cdio.h Tue Jun 2 16:27:09 1998
***************
*** 273,276 ****
--- 273,287 ----
#define CDIOCCAPABILITY _IOR('c',30,struct ioc_capability) /*<2>*/
+ struct ioc_read_audio
+ {
+ u_char address_format;
+ union msf_lba address;
+ int nframes;
+ u_char* buffer;
+ };
+
+ #define CDIOCREADAUDIO _IOWR('c',31,struct ioc_read_audio)
+
+
#endif /* !_SYS_CDIO_H_ */
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806022348.QAA00158>
