Re: sun4c audio in 4.5
Alexandre Ratchov <[email protected]>
| Newsgroups | gmane.os.openbsd.sparc |
|---|---|
| Message-ID | <[email protected]> |
On Sat, May 16, 2009 at 08:23:10PM +0200, Alexandre Ratchov wrote:
> On Sat, May 16, 2009 at 01:19:18PM -0500, Todd T. Fries wrote:
> > Penned by Alexandre Ratchov on 20090516 20:14.16, we have:
> > | On Sat, May 16, 2009 at 01:57:40PM -0400, Brandon Applegate wrote:
> > | > On Sat, 16 May 2009, Todd T. Fries wrote:
> > | >
> > | >> For kicks, does anything change if you type this prior to running
> > | >> mpg123 with no special flags:
> > | >>
> > | >> aucat -l -m play
> > | >>
> > | >
> > | > Thanks for the quick reply. I should have included some more output in
> > | > my original post, so here is what I'm getting:
> > | >
> > | > # aucat -l -m play &
> > | > [1] 18912
> > | > # aucat: <default>: can't open device
> > | >
> > |
> > | i guess the device is ``amd7930'', which is mulaw only.
> > | Is it?
> > |
> > | (sndio doesn't expose non-linear encodings)
> > |
> > | -- Alexandre
> >
> > Could you perhaps explain how this helps make things work again?
> >
>
> i'm preparing a diff for this, it will be ready in few
> minutes ;)
>
> > Do you plan to change sndio or ?
> >
>
> it's the only device that is mulaw-only, so it's simpler
> to fix it in kernel to support linear encoding.
>
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 ?
-- 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 16 May 2009 18:31:46 -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,21 @@ 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 & AUDIO_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;
+ } else if (setmode & AUDIO_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,8 +415,8 @@ 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;
break;