Re: sun4c audio in 4.5

Alexandre Ratchov <[email protected]>
Newsgroups gmane.os.openbsd.sparc
Message-ID <[email protected]>
On Sun, May 17, 2009 at 11:03:20AM -0400, Brandon Applegate wrote:
> On Sat, 16 May 2009, Alexandre Ratchov wrote:
>
>> here's the diff. I've no system to test/compile it
>> so i'm pretty sure it requires some tweaking, but the
>> approach should work. Anyone could tweak/test it ?
>
> I tried this both on stock 4.5 kernel source, as well as pulling  
> arch/sparc/dev/amd* down from CVSWEB (I noticed your patch is against 
> 1.32 of the driver file).  Both cases result in this:
>
> ../../../../arch/sparc/dev/amd7930.c: In function `amd7930attach':
> ../../../../arch/sparc/dev/amd7930.c:317: warning: implicit declaration 
> of function `softintr_establish'
> ../../../../arch/sparc/dev/amd7930.c:317: warning: assignment makes  
> pointer from integer without a cast
> ../../../../arch/sparc/dev/amd7930.c: In function `amd7930_set_params':
> ../../../../arch/sparc/dev/amd7930.c:393: `AUDIO_PLAY' undeclared (first  
> use in this function)
> ../../../../arch/sparc/dev/amd7930.c:393: (Each undeclared identifier is  
> reported only once
> ../../../../arch/sparc/dev/amd7930.c:393: for each function it appears  
> in.)
> ../../../../arch/sparc/dev/amd7930.c:400: `AUDIO_RECORD' undeclared 
> (first use in this function)
> ../../../../arch/sparc/dev/amd7930.c: In function `amd7930hwintr':
> ../../../../arch/sparc/dev/amd7930.c:806: warning: implicit declaration 
> of function `softintr_schedule'

you should apply it to the 4.5 file, because interrupts
handling changed the last few months:

cvs update -r OPENBSD_4_5_BASE -C  amd7930.c
patch <sun4u.diff

the patch should apply cleany since it touches other parts
of the code.

Below is another diff, with tweaks from jakemsr and fixed
typos.

-- Alexandre
Index: amd7930.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc/dev/amd7930.c,v
retrieving revision 1.32
diff -u -p -r1.32 amd7930.c
--- amd7930.c	10 Apr 2009 20:53:51 -0000	1.32
+++ amd7930.c	17 May 2009 16:19:10 -0000
@@ -43,6 +43,7 @@
 
 #include <sys/audioio.h>
 #include <dev/audio_if.h>
+#include <dev/mulaw.h>
 
 #include <dev/ic/am7930reg.h>
 #include <sparc/dev/amd7930var.h>
@@ -389,13 +390,22 @@ amd7930_set_params(addr, setmode, usemod
 	int setmode, usemode;
 	struct audio_params *p, *r;
 {
-	if (p->sample_rate < 7500 || p->sample_rate > 8500 ||
-	    p->encoding != AUDIO_ENCODING_ULAW ||
-	    p->precision != 8 ||
-	    p->channels != 1) 
-		return (EINVAL);
-	p->sample_rate = 8000;	/* no other rates supported by amd chip */     
-
+	if (setmode & AUMODE_PLAY) {
+		p->sample_rate = 8000;
+		p->encoding = AUDIO_ENCODING_ULINEAR;
+		p->precision = 8;
+		p->channels = 1;
+		p->sw_code = ulinear8_to_mulaw;
+		p->factor = 1;
+	}
+	if (setmode & AUMODE_RECORD) {
+		r->sample_rate = 8000;
+		r->encoding = AUDIO_ENCODING_ULINEAR;
+		r->precision = 8;
+		r->channels = 1;
+		r->sw_code = mulaw_to_ulinear8;
+		r->factor = 1;
+	}
 	return (0);
 }  
 
@@ -406,10 +416,10 @@ amd7930_query_encoding(addr, fp)
 {
 	switch (fp->index) {
 	case 0:
-		strlcpy(fp->name, AudioEmulaw, sizeof fp->name);
-		fp->encoding = AUDIO_ENCODING_ULAW;
+		strlcpy(fp->name, AudioEulinear, sizeof fp->name);
+		fp->encoding = AUDIO_ENCODING_ULINEAR;
 		fp->precision = 8;
-		fp->flags = 0;
+		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
 		break;
 	default:
 		return (EINVAL);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.