dmasound split

10 messages, 4 authors, 2000-03-20 · open the first message on its own page

dmasound split

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2000-03-07 20:50:43

This is my first test release for splitting the DMA sound driver in different
parts:

  - dmasound_core: machine independent code
  - dmasound_atari: Atari TT and Falcon code (does it make sense to split this
		    further?)
  - dmasound_awacs: PowerMac `Awacs' code
  - dmasound_paula: Amiga `Paula' code

I also cleant up the code a lot, and made the following changes (let's hope I
don't forget to mention some):

  - Add more machine specific function pointers to the MACHINE struct.
  - Merge the duplicated code for write_sq and read_sq as much as possible.
  - I use lots of #defines to `do {} while (0)' to avoid having too many
    occurrencies of #ifdef HAS_READ_SOUND (for recording).
  - Generate the copy-and-convert routines for Amiga using #defines. As a
    result we now have different routines for ulaw and alaw, which expands the
    object code a bit, but it's less error-prone.
  - Use resource management on Amiga.

The total source code did grow a bit, though. Mainly due to duplicated comments
and include statements in the modules.

Note that this is meant for 2.3.x. I haven't done 2.2.x since a long time.


Tested parts:

  - I only tested the driver for Amiga, as a loadable module. It worked even
    better than the old driver, since it plays all frames now (don't ask me
    why). `cat file > /dev/audio' still hangs at the end, though (killable by
    CTRL-C). (cfr. my previous mail to the linux-m68k list).


Known problems:

  - You can still rmmod the dmasound_{atari,awacs,paula} module while sound is
    playing, causing a crash.


To do:

  - Test it on other platforms.
  - Test recording on PowerMac.
  - Fix the locking issues.
  - Use module_{init,exit}(), conforming to the latest fashion.
  - Clean up, inline more small functions.
  - Disable heartbeat when playing sound on Amiga (heartbeat influences the
    low-pass filter and thus causes distortion).
  - Provide a small module to play with htotal when amifb is not used on Amiga
    (The DMA controller assigns DMA slots to the audio controller per video
    scanline, hence increasing the horizontal sync rate allows higher playback
    rates. Yes, that's what we call `integrated multimedia' :-).


Download:

    http://home.tvd.be/cr26864/Patches/dmasound.readme
    http://home.tvd.be/cr26864/Patches/dmasound.tar.gz


Instructions:

  - Extract dmasound.tar.gz

  - Delete obsolete files:

      rm drivers/sound/dmasound.[ch]

  - Copy new files:

      cp dmasound.h dmasound_* drivers/sound

  - Apply the patch:

      patch -p1 < dmasound.diff

  - Remove all lines containing `DMASOUND' from .config

  - Run `make oldconfig' and compile and install the modules

  - Make sure to remove the old dmasound.o from /lib/modules/<version>/misc/
    if you intend to use `modprobe' instead of `insmod', since `modprobe' may
    decide to load the old module also!

Good luck!! Thanks for your comments and test results!

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2000-03-07 21:49:34

On Tue, 7 Mar 2000, Geert Uytterhoeven wrote:
This is my first test release for splitting the DMA sound driver in different
parts:
And here's a first patch:

  - Fix the locking problem by adding open()/release() functions to the machine
    specific modules
  - Fix the incorrect size of the requested memory region for the Amiga driver
  - Rename HAS_READ_SOUND to HAS_RECORD
--- dmasound.h	Tue Mar  7 20:54:03 2000
+++ dmasound.h	Tue Mar  7 22:13:33 2000
@@ -74,14 +74,14 @@
 #undef HAS_8BIT_TABLES
 #undef HAS_14BIT_TABLES
 #undef HAS_16BIT_TABLES
-#undef HAS_READ_SOUND
+#undef HAS_RECORD

 #if defined(CONFIG_AMIGA) || defined(CONFIG_ATARI)
 #define HAS_8BIT_TABLES
 #endif
 #if defined(CONFIG_PPC)
 #define HAS_16BIT_TABLES
-#define HAS_READ_SOUND
+#define HAS_RECORD
 #endif

@@ -95,6 +95,8 @@
 typedef struct {
     const char *name;
     const char *name2;
+    void (*open)(void);
+    void (*release)(void);
     void *(*dma_alloc)(unsigned int, int);
     void (*dma_free)(void *, unsigned int);
     int (*irqinit)(void);
@@ -148,7 +150,7 @@
     SETTINGS soft;	/* software settings */
     SETTINGS dsp;	/* /dev/dsp default settings */
     TRANS *trans_write;	/* supported translations */
-#ifdef HAS_READ_SOUND
+#ifdef HAS_RECORD
     TRANS *trans_read;	/* supported translations */
 #endif
     int volume_left;	/* volume (range is machine dependent) */
--- dmasound_atari.c	Tue Mar  7 20:54:09 2000
+++ dmasound_atari.c	Tue Mar  7 22:14:31 2000
@@ -119,6 +119,8 @@
 /*** Low level stuff *********************************************************/


+static void AtaOpen(void);
+static void AtaRelease(void);
 static void *AtaAlloc(unsigned int size, int flags);
 static void AtaFree(void *, unsigned int size);
 static int AtaIrqInit(void);
@@ -815,6 +817,16 @@
  * Atari (TT/Falcon)
  */

+static void AtaOpen(void)
+{
+	MOD_INC_USE_COUNT;
+}
+
+static void AtaRelease(void)
+{
+	MOD_DEC_USE_COUNT;
+}
+
 static void *AtaAlloc(unsigned int size, int flags)
 {
 	return atari_stram_alloc( size, NULL, "dmasound" );
@@ -1480,6 +1492,8 @@
 static MACHINE machTT = {
 	name:		"Atari",
 	name2:		"TT",
+	open:		AtaOpen,
+	release:	AtaRelease,
 	dma_alloc:	AtaAlloc,
 	dma_free:	AtaFree,
 	irqinit:	AtaIrqInit,
--- dmasound_awacs.c	Tue Mar  7 20:54:09 2000
+++ dmasound_awacs.c	Tue Mar  7 22:14:37 2000
@@ -220,6 +220,8 @@
 /*** Low level stuff *********************************************************/


+static void PMacOpen(void);
+static void PMacRelease(void);
 static void *PMacAlloc(unsigned int size, int flags);
 static void PMacFree(void *ptr, unsigned int size);
 static int PMacIrqInit(void);
@@ -805,6 +807,16 @@
  * PCI PowerMac, with AWACS and DBDMA.
  */

+static void PMacOpen(void)
+{
+	MOD_INC_USE_COUNT;
+}
+
+static void PMacRelease(void)
+{
+	MOD_DEC_USE_COUNT;
+}
+
 static void *PMacAlloc(unsigned int size, int flags)
 {
 	return kmalloc(size, flags);
@@ -1899,6 +1911,8 @@
 static MACHINE machPMac = {
 	name:		awacs_name,
 	name2:		"AWACS",
+	open:		PMacOpen,
+	release:	PMacRelease,
 	dma_alloc:	PMacAlloc,
 	dma_free:	PMacFree,
 	irqinit:	PMacIrqInit,
--- dmasound_core.c	Tue Mar  7 20:54:09 2000
+++ dmasound_core.c	Tue Mar  7 22:23:50 2000
@@ -138,7 +138,7 @@

 int dmasound_catchRadius = 0;
 static int numWriteBufs = 4, writeBufSize = 32;
-#ifdef HAS_READ_SOUND
+#ifdef HAS_RECORD
 static int numReadBufs = 4, readBufSize = 32;
 #endif
@@ -415,7 +415,7 @@
  */

 struct sound_queue dmasound_write_sq;
-#ifdef HAS_READ_SOUND
+#ifdef HAS_RECORD
 struct sound_queue dmasound_read_sq;
 #endif
@@ -531,6 +531,7 @@
 static int mixer_open(struct inode *inode, struct file *file)
 {
 	MOD_INC_USE_COUNT;
+	dmasound.mach.open();
 	mixer.busy = 1;
 	return 0;
 }
@@ -538,6 +539,7 @@
 static int mixer_release(struct inode *inode, struct file *file)
 {
 	mixer.busy = 0;
+	dmasound.mach.release();
 	MOD_DEC_USE_COUNT;
 	return 0;
 }
@@ -742,7 +744,7 @@
 }


-#ifdef HAS_READ_SOUND
+#ifdef HAS_RECORD

 /* Here is how the values are used for reading.
  * The value 'active' simply indicates the DMA is running.  This is
@@ -807,7 +809,7 @@
 	}
 	return uRead;
 }
-#endif /* HAS_READ_SOUND */
+#endif /* HAS_RECORD */


 static inline void sq_init_waitqueue(struct sound_queue *sq)
@@ -864,18 +866,18 @@
 #define write_sq_open(file)	\
 	sq_open2(&write_sq, file, FMODE_WRITE, numWriteBufs, writeBufSize, 0)

-#ifdef HAS_READ_SOUND
+#ifdef HAS_RECORD
 #define read_sq_init_waitqueue()	sq_init_waitqueue(&read_sq)
 #define read_sq_wake_up(file)		sq_wake_up(&read_sq, file, FMODE_READ)
 #define read_sq_release_buffers()	sq_release_buffers(&read_sq, 1)
 #define read_sq_open(file)	\
 	sq_open2(&read_sq, file, FMODE_READ, numReadBufs, readBufSize, 1)
-#else /* !HAS_READ_SOUND */
+#else /* !HAS_RECORD */
 #define read_sq_init_waitqueue()	do {} while (0)
 #define read_sq_wake_up(file)		do {} while (0)
 #define read_sq_release_buffers()	do {} while (0)
 #define read_sq_open(file)		(0)
-#endif /* !HAS_READ_SOUND */
+#endif /* !HAS_RECORD */


 static int sq_open(struct inode *inode, struct file *file)
@@ -883,7 +885,9 @@
 	int rc;

 	MOD_INC_USE_COUNT;
+	dmasound.mach.open();
 	if ((rc = write_sq_open(file)) || (rc = read_sq_open(file))) {
+		dmasound.mach.release();
 		MOD_DEC_USE_COUNT;
 		return rc;
 	}
@@ -955,6 +959,7 @@

 	read_sq_release_buffers();
 	write_sq_release_buffers();
+	dmasound.mach.release();
 	MOD_DEC_USE_COUNT;

 	/* There is probably a DOS atack here. They change the mode flag. */
@@ -1075,7 +1080,7 @@
 	ioctl:		sq_ioctl,
 	open:		sq_open,
 	release:	sq_release,
-#ifdef HAS_READ_SOUND
+#ifdef HAS_RECORD
 	read:		sq_read,
 #endif
 };
@@ -1125,6 +1130,7 @@
 		return -EBUSY;

 	MOD_INC_USE_COUNT;
+	dmasound.mach.open();
 	state.ptr = 0;
 	state.busy = 1;
@@ -1181,6 +1187,7 @@
 static int state_release(struct inode *inode, struct file *file)
 {
 	state.busy = 0;
+	dmasound.mach.release();
 	MOD_DEC_USE_COUNT;
 	return 0;
 }
@@ -1276,7 +1283,6 @@
 	printk(KERN_INFO "DMA sound driver installed, using %d buffers of %dk.\n",
 	       numWriteBufs, writeBufSize);

-	MOD_INC_USE_COUNT;
 	return 0;
 }
@@ -1302,7 +1308,6 @@
 	if (sq_unit >= 0)
 		unregister_sound_dsp(sq_unit);

-	MOD_DEC_USE_COUNT;
 	dmasound_active = 0;
 }
@@ -1354,7 +1359,7 @@
 EXPORT_SYMBOL(dmasound_init);
 EXPORT_SYMBOL(dmasound_deinit);
 EXPORT_SYMBOL(dmasound_write_sq);
-#ifdef HAS_READ_SOUND
+#ifdef HAS_RECORD
 EXPORT_SYMBOL(dmasound_read_sq);
 #endif
 EXPORT_SYMBOL(dmasound_catchRadius);
--- dmasound_paula.c	Tue Mar  7 20:54:09 2000
+++ dmasound_paula.c	Tue Mar  7 22:45:09 2000
@@ -72,6 +72,8 @@
 /*** Low level stuff *********************************************************/


+static void AmiOpen(void);
+static void AmiRelease(void);
 static void *AmiAlloc(unsigned int size, int flags);
 static void AmiFree(void *obj, unsigned int size);
 static int AmiIrqInit(void);
@@ -281,6 +283,16 @@
 /*** Low level stuff *********************************************************/


+static void AmiOpen(void)
+{
+	MOD_INC_USE_COUNT;
+}
+
+static void AmiRelease(void)
+{
+	MOD_DEC_USE_COUNT;
+}
+
 static inline void StopDMA(void)
 {
 	custom.aud[0].audvol = custom.aud[1].audvol = 0;
@@ -639,6 +651,8 @@
 static MACHINE machAmiga = {
 	name:		"Amiga",
 	name2:		"AMIGA",
+	open:		AmiOpen,
+	release:	AmiRelease,
 	dma_alloc:	AmiAlloc,
 	dma_free:	AmiFree,
 	irqinit:	AmiIrqInit,
@@ -665,7 +679,7 @@
 int __init paula_dmasound_init(void)
 {
 	if (MACH_IS_AMIGA && AMIGAHW_PRESENT(AMI_AUDIO)) {
-	    if (!request_mem_region(CUSTOM_PHYSADDR+0xa0, 0x20,
+	    if (!request_mem_region(CUSTOM_PHYSADDR+0xa0, 0x40,
 				    "dmasound [Paula]"))
 		return -EBUSY;
 	    dmasound.mach = machAmiga;
@@ -685,7 +699,7 @@
 void cleanup_module(void)
 {
 	dmasound_deinit();
-	release_mem_region(CUSTOM_PHYSADDR+0xa0, 0x20);
+	release_mem_region(CUSTOM_PHYSADDR+0xa0, 0x40);
 }

 #endif /* MODULE */
Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2000-03-14 08:14:23

On Tue, 7 Mar 2000, Geert Uytterhoeven wrote:
On Tue, 7 Mar 2000, Geert Uytterhoeven wrote:
quoted
This is my first test release for splitting the DMA sound driver in different
parts:
And here's a first patch:
No comments whether it works on PowerMac and Atari?
I'd like to let this go in 2.4.0, since a driver for the Q40 is soon to be
added.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Michael Schmitz <hidden>
Date: 2000-03-14 09:55:34

quoted
And here's a first patch:
No comments whether it works on PowerMac and Atari?
No. I haven't done 2.3.x in a long time on m68k. I can try PowerMac
though. Would 2.3.48-linuxcare be a good code base?
I'd like to let this go in 2.4.0, since a driver for the Q40 is soon to be
added.
I figure Atari will have more serious problems with 2.4 :-(

	Michael


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Geert Uytterhoeven <hidden>
Date: 2000-03-14 10:10:53

On Tue, 14 Mar 2000, Michael Schmitz wrote:
quoted
quoted
And here's a first patch:
No comments whether it works on PowerMac and Atari?
No. I haven't done 2.3.x in a long time on m68k. I can try PowerMac
though. Would 2.3.48-linuxcare be a good code base?
Yes. Any recent 2.3.x tree will do.
quoted
I'd like to let this go in 2.4.0, since a driver for the Q40 is soon to be
added.
I figure Atari will have more serious problems with 2.4 :-(
Yep. Time to ship Andreas' TT to SuSE...

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven ------------- Sony Software Development Center Europe (SDCE)
Geert.Uytterhoeven@sonycom.com ------------------- Sint-Stevens-Woluwestraat 55
Voice +32-2-7248638 Fax +32-2-7262686 ---------------- B-1130 Brussels, Belgium


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Michael Schmitz <hidden>
Date: 2000-03-14 10:17:29

quoted
quoted
No comments whether it works on PowerMac and Atari?
No. I haven't done 2.3.x in a long time on m68k. I can try PowerMac
though. Would 2.3.48-linuxcare be a good code base?
Yes. Any recent 2.3.x tree will do.
Ok, I'll give it a look. I'm just backing up my LinuxPPC installation to
tape after XFree 4.0 trashed my partitions a bit yesterday.
quoted
quoted
I'd like to let this go in 2.4.0, since a driver for the Q40 is soon to be
added.
I figure Atari will have more serious problems with 2.4 :-(
Yep. Time to ship Andreas' TT to SuSE...
Looks like it. I never really understood what Jes wanted to change about
the serial layer, and I don't have much time for that recently.

	Michael


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Michel Lanners <hidden>
Date: 2000-03-19 09:46:24

Hi Geert,

On  14 Mar, this message from Geert Uytterhoeven echoed through cyberspace:
No comments whether it works on PowerMac and Atari?
I'd like to let this go in 2.4.0, since a driver for the Q40 is soon to be
added.
With all the latest patches applied:

1. compiled-in doesn't work; it seems the low-level parts are not
initialised:

Mar 19 08:54:33 piglet kernel: kmod: failed to exec  -s -k sound-slot-0, errno = 2
Mar 19 08:54:33 piglet kernel: kmod: failed to exec  -s -k sound-service-0-6, errno = 2

2. generic sound support compiled-in, PowerMac dmasound as a module:
kernel doesn't boot (hangs somewhere very early, drops me back onto
OF's screen)

3. sound & dmasound as modules: seems to work ok AFAICT. I don't have
any real sound apps to test, except system beep and using the mixer ;-)

Sorry I've not looked in more detail what's wrong, but I'm on other
subjects at the moment...

Michel

-------------------------------------------------------------------------
Michel Lanners                 |  " Read Philosophy.  Study Art.
23, Rue Paul Henkes            |    Ask Questions.  Make Mistakes.
L-1710 Luxembourg              |
email   mlan@cpu.lu            |
http://www.cpu.lu/~mlan        |                     Learn Always. "


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Michael Schmitz <hidden>
Date: 2000-03-20 09:47:18

quoted
No comments whether it works on PowerMac and Atari?
I'd like to let this go in 2.4.0, since a driver for the Q40 is soon to be
added.
With all the latest patches applied:

1. compiled-in doesn't work; it seems the low-level parts are not
initialised:

Mar 19 08:54:33 piglet kernel: kmod: failed to exec  -s -k sound-slot-0, errno = 2
Mar 19 08:54:33 piglet kernel: kmod: failed to exec  -s -k sound-service-0-6, errno = 2
Funny enough, this is solved on my Lombard by modprobe dmasound_core &&
modprobe dmasound_awacs. The modules are still around from an eariler
build with modularized dmasound, and still load OK. I'd say the kernel
never tries to initialize the compiled in dmasound so the module can still
register its hooks.

The Makefile seems OK, and the following dmasound symbols appear in the
symtab:

c018788c ? __kstrtab_dmasound
c0187898 ? __kstrtab_dmasound_init
c01878a8 ? __kstrtab_dmasound_write_sq
c01878bc ? __kstrtab_dmasound_read_sq
c01878d0 ? __kstrtab_dmasound_catchRadius
c01878e8 ? __kstrtab_dmasound_ulaw2dma16
c01878fc ? __kstrtab_dmasound_alaw2dma16
c018a664 ? __ksymtab_dmasound
c018a66c ? __ksymtab_dmasound_init
c018a674 ? __ksymtab_dmasound_write_sq
c018a67c ? __ksymtab_dmasound_read_sq
c018a684 ? __ksymtab_dmasound_catchRadius
c018a68c ? __ksymtab_dmasound_ulaw2dma16
c018a694 ? __ksymtab_dmasound_alaw2dma16
c019fd24 D dmasound_ulaw2dma16
c019ff24 D dmasound_alaw2dma16
c01a9f00 D dmasound_catchRadius
c01bfabc T dmasound_init
c01bfb3c t dmasound_setup
c01bfcd8 T awacs_dmasound_init
c01c7bec d __setup_str_dmasound_setup
c01e24c8 ? __setup_dmasound_setup
c025f348 B dmasound
c025f40c B dmasound_read_sq
c025f480 B dmasound_write_sq

Anything missing, Geert?

	Michael


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Geert Uytterhoeven <hidden>
Date: 2000-03-20 10:09:03

On Mon, 20 Mar 2000, Michael Schmitz wrote:
quoted
quoted
No comments whether it works on PowerMac and Atari?
I'd like to let this go in 2.4.0, since a driver for the Q40 is soon to be
added.
With all the latest patches applied:

1. compiled-in doesn't work; it seems the low-level parts are not
initialised:

Mar 19 08:54:33 piglet kernel: kmod: failed to exec  -s -k sound-slot-0, errno = 2
Mar 19 08:54:33 piglet kernel: kmod: failed to exec  -s -k sound-service-0-6, errno = 2
Funny enough, this is solved on my Lombard by modprobe dmasound_core &&
modprobe dmasound_awacs. The modules are still around from an eariler
build with modularized dmasound, and still load OK. I'd say the kernel
never tries to initialize the compiled in dmasound so the module can still
register its hooks.

The Makefile seems OK, and the following dmasound symbols appear in the
symtab:

c01bfabc T dmasound_init

Anything missing, Geert?
Isn't this the problem where dmasound_init() is no longer called? I forgot to
update the #ifdef CONFIG_DMASOUND since I never tried it builtin.

I received a patch to call it on #ifdef CONFIG_DMASOUND_*.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven ------------- Sony Software Development Center Europe (SDCE)
Geert.Uytterhoeven@sonycom.com ------------------- Sint-Stevens-Woluwestraat 55
Voice +32-2-7248638 Fax +32-2-7262686 ---------------- B-1130 Brussels, Belgium


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

Re: dmasound split

From: Michael Schmitz <hidden>
Date: 2000-03-20 10:16:09

quoted
Anything missing, Geert?
Isn't this the problem where dmasound_init() is no longer called? I forgot to
update the #ifdef CONFIG_DMASOUND since I never tried it builtin.
Sounds possible.
I received a patch to call it on #ifdef CONFIG_DMASOUND_*.
Meaning #if defined(CONFIG_DMASOUND_AWACS) || defined(CONFIG_DMASOUND_ATARI) .. ?

I'll try that, could you forward that patch if it's something else ??

	Michael


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help