linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* dmasound audio patch
@ 2002-04-07 21:23 Bill Fink
  2002-04-08 10:30 ` Michel Dänzer
  2002-04-08 11:49 ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 13+ messages in thread
From: Bill Fink @ 2002-04-07 21:23 UTC (permalink / raw)
  To: LinuxPPC Developers; +Cc: YellowDog Linux General, Bill Fink

[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]

Hi,

A friend of mine, Rob Scott, worked up a patch to the dmasound driver
that fixes some of the PPC endianness issues by doing byte swapping
in the driver.  He uses it on a Titanium PowerBook, and I am using it
on a dual 500 MHz G4 with good results.  Before the patch, using xmms
with the AudioCD Reader plugin, I had to use the esound driver since
the OSS driver just gave static.  Now I can use the OSS driver directly,
so there's no need to run the esd daemon.

I know this patch probably isn't politically correct, since as I understand
it Linus doesn't believe that things such as byte swapping should be done
in the kernel.  But then he lives on a little endian machine and doesn't
need to mess with dozens of broken audio applications.  So if you're not
worried about kernel political correctness, you might want to give this
patch a try.  Of course I make no warranty of any kind, but I can attest
that it works fine on a couple of different PPC systems with BenH kernels
around 2.4.18.

						-Bill

[-- Attachment #2: dmasound.patch --]
[-- Type: application/octet-stream, Size: 2721 bytes --]

diff -ur .orig/dmasound_awacs.c .mod/dmasound_awacs.c
--- .orig/dmasound_awacs.c	Tue Feb 26 09:35:34 2002
+++ .mod/dmasound_awacs.c	Tue Feb 26 23:17:40 2002
@@ -753,6 +753,16 @@
 			dmasound.dsp.size = size;
 		}
 	}
+	else {
+		dmasound.soft.format = req_format;
+		dmasound.soft.size = size;
+		dmasound.hard.format = format;
+		if (dmasound.minDev == SND_DEV_DSP) {
+			dmasound.dsp.format = format;
+			dmasound.dsp.size = size;
+		}
+		format = req_format;
+	}
 
 	return format;
 }
@@ -2692,7 +2702,7 @@
 __init set_hw_byteswap(struct device_node *io)
 {
 	struct device_node *mio ;
-	unsigned int *p, kl = 0 ;
+	unsigned int kl = 0 ;
 
 	/* if seems that Keylargo can't byte-swap  */
 
diff -ur .orig/dmasound_core.c .mod/dmasound_core.c
--- .orig/dmasound_core.c	Tue Feb 26 09:35:34 2002
+++ .mod/dmasound_core.c	Tue Feb 26 23:17:40 2002
@@ -1263,7 +1263,7 @@
 			if (result < 0)
 				return result;
 			if (format != data)
-				return -EINVAL;
+				return -ENOSYS;
 			return 0;
 		} else
 			return -EINVAL ;
diff -ur .orig/trans_16.c .mod/trans_16.c
--- .orig/trans_16.c	Tue Feb 26 09:35:35 2002
+++ .mod/trans_16.c	Tue Feb 26 23:17:40 2002
@@ -163,23 +163,30 @@
 	ssize_t count, used;
 	int stereo = dmasound.soft.stereo;
 	short *fp = (short *) &frame[*frameUsed];
+	short *up = (short *) userPtr;
 
 	frameLeft >>= 2;
 	userCount >>= (stereo? 2: 1);
 	used = count = min_t(unsigned long, userCount, frameLeft);
-	if (!stereo) {
-		short *up = (short *) userPtr;
-		while (count > 0) {
-			short data;
+	while (count > 0) {
+		short data;
+		if (get_user(data, up++))
+			return -EFAULT;
+		if ((dmasound.hard.format == AFMT_S16_BE) && (dmasound.soft.format == AFMT_S16_LE)) {
+			*fp++ = swab16( data );
+		} else {
+			*fp++ = data;
+		}
+		if (stereo) {
 			if (get_user(data, up++))
 				return -EFAULT;
+		}
+		if ((dmasound.hard.format == AFMT_S16_BE) && (dmasound.soft.format == AFMT_S16_LE)) {
+			*fp++ = swab16( data );
+		} else {
 			*fp++ = data;
-			*fp++ = data;
-			count--;
 		}
-	} else {
-		if (copy_from_user(fp, userPtr, count * 4))
-			return -EFAULT;
+		count--;
 	}
 	*frameUsed += used * 4;
 	return stereo? used * 4: used * 2;
@@ -203,13 +210,21 @@
 		if (get_user(data, up++))
 			return -EFAULT;
 		data ^= mask;
-		*fp++ = data;
+		if ((dmasound.hard.format == AFMT_S16_BE) && (dmasound.soft.format == AFMT_S16_LE)) {
+			*fp++ = swab16(data);
+		} else {
+			*fp++ = data;
+		}
 		if (stereo) {
 			if (get_user(data, up++))
 				return -EFAULT;
 			data ^= mask;
 		}
-		*fp++ = data;
+		if ((dmasound.hard.format == AFMT_S16_BE) && (dmasound.soft.format == AFMT_S16_LE)) {
+			*fp++ = swab16(data);
+		} else {
+			*fp++ = data;
+		}
 		count--;
 	}
 	*frameUsed += used * 4;

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: dmasound audio patch
@ 2002-04-10  3:36 Bill Fink
  0 siblings, 0 replies; 13+ messages in thread
From: Bill Fink @ 2002-04-10  3:36 UTC (permalink / raw)
  To: LinuxPPC Developers; +Cc: Bill Fink


On Mon, 8 Apr 2002, Ethan Benson wrote:

> On Mon, Apr 08, 2002 at 09:52:00PM -0400, Bill Fink wrote:
> > I understand that ALSA is now available for PPC. I'll have to take a
> > closer look at it when I get a chance. When do you think ALSA will be
> > an integral part of the stable kernel?
>
> when 2.5 becomes the next stable kernel (2.6 or 3.0).

I was afraid that was what someone would say.  :-)

				-Bill

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-04-10  3:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-07 21:23 dmasound audio patch Bill Fink
2002-04-08 10:30 ` Michel Dänzer
2002-04-08 12:41   ` Bill Fink
2002-04-08 12:50     ` Michel Dänzer
2002-04-08 14:14       ` Bill Fink
2002-04-08 13:22     ` Bill Fink
2002-04-08 11:49 ` Benjamin Herrenschmidt
2002-04-08 19:23   ` Bill Fink
2002-04-08 18:45     ` Benjamin Herrenschmidt
2002-04-09  1:52       ` Bill Fink
2002-04-09  2:24         ` jeffk
2002-04-09  7:18         ` Ethan Benson
  -- strict thread matches above, loose matches on Subject: below --
2002-04-10  3:36 Bill Fink

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).