summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/sparc/conf/files.sparc4
-rw-r--r--sys/arch/vax/conf/files.vax4
-rw-r--r--sys/dev/ic/am7930.c82
3 files changed, 72 insertions, 18 deletions
diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc
index e67bc8641fa..2cc9c9385ea 100644
--- a/sys/arch/sparc/conf/files.sparc
+++ b/sys/arch/sparc/conf/files.sparc
@@ -1,4 +1,4 @@
-# $OpenBSD: files.sparc,v 1.90 2011/09/03 20:04:00 miod Exp $
+# $OpenBSD: files.sparc,v 1.91 2011/09/04 08:03:32 miod Exp $
# $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $
# @(#)files.sparc 8.1 (Berkeley) 7/19/93
@@ -144,7 +144,7 @@ file arch/sparc/dev/hme.c hme
attach esp at sbus, dma, obio
file arch/sparc/dev/esp.c esp
-device audioamd: audio, am7930
+device audioamd: audio, am7930, mulaw
attach audioamd at mainbus, obio, sbus
file arch/sparc/dev/audioamd.c audioamd
file arch/sparc/sparc/amd7930intr.s audioamd
diff --git a/sys/arch/vax/conf/files.vax b/sys/arch/vax/conf/files.vax
index d730b49676b..5b8b0fdcc6c 100644
--- a/sys/arch/vax/conf/files.vax
+++ b/sys/arch/vax/conf/files.vax
@@ -1,4 +1,4 @@
-# $OpenBSD: files.vax,v 1.55 2011/09/03 20:41:31 miod Exp $
+# $OpenBSD: files.vax,v 1.56 2011/09/04 08:03:32 miod Exp $
# $NetBSD: files.vax,v 1.60 1999/08/27 20:04:32 ragge Exp $
#
# new style config file for vax architecture
@@ -155,7 +155,7 @@ device led
attach led at mainbus
file arch/vax/vax/led.c led needs-flag
-device vsaudio: audio, am7930
+device vsaudio: audio, am7930, mulaw
attach vsaudio at vsbus
file arch/vax/vsa/vsaudio.c vsaudio
diff --git a/sys/dev/ic/am7930.c b/sys/dev/ic/am7930.c
index a18089f3817..a96ed78aa45 100644
--- a/sys/dev/ic/am7930.c
+++ b/sys/dev/ic/am7930.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: am7930.c,v 1.1 2011/09/03 20:03:29 miod Exp $ */
+/* $OpenBSD: am7930.c,v 1.2 2011/09/04 08:03:32 miod Exp $ */
/* $NetBSD: am7930.c,v 1.44 2001/11/13 13:14:34 lukem Exp $ */
/*
@@ -45,6 +45,7 @@
#include <sys/audioio.h>
#include <dev/audio_if.h>
+#include <dev/mulaw.h>
#include <dev/ic/am7930reg.h>
#include <dev/ic/am7930var.h>
@@ -209,15 +210,53 @@ am7930_close(void *addr)
* XXX should be extended to handle a few of the more common formats.
*/
int
-am7930_set_params(void *addr, int setmode, int usemode, struct audio_params *p,
- struct audio_params *r)
+am7930_set_params(void *addr, int setmode, int usemode,
+ struct audio_params *play, struct audio_params *rec)
{
+ struct audio_params *p;
+ int mode;
#if 0
struct am7930_softc *sc = addr;
#endif
- if ((usemode & AUMODE_PLAY) == AUMODE_PLAY) {
- p->encoding = AUDIO_ENCODING_ULAW;
+ for (mode = AUMODE_RECORD; mode != -1;
+ mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
+ if ((setmode & mode) == 0)
+ continue;
+
+ p = mode == AUMODE_PLAY ? play : rec;
+ if (p == NULL)
+ continue;
+
+ switch (p->encoding) {
+ case AUDIO_ENCODING_ULAW:
+ p->sw_code = NULL;
+ break;
+ case AUDIO_ENCODING_SLINEAR:
+ case AUDIO_ENCODING_SLINEAR_BE:
+ case AUDIO_ENCODING_SLINEAR_LE:
+ if (mode == AUMODE_PLAY)
+ p->sw_code = slinear8_to_mulaw;
+ else
+ p->sw_code = mulaw_to_slinear8;
+ break;
+ case AUDIO_ENCODING_ULINEAR:
+ case AUDIO_ENCODING_ULINEAR_BE:
+ case AUDIO_ENCODING_ULINEAR_LE:
+ if (mode == AUMODE_PLAY)
+ p->sw_code = ulinear8_to_mulaw;
+ else
+ p->sw_code = mulaw_to_ulinear8;
+ break;
+ case AUDIO_ENCODING_ALAW:
+ if (mode == AUMODE_PLAY)
+ p->sw_code = alaw_to_mulaw;
+ else
+ p->sw_code = mulaw_to_alaw;
+ break;
+ default:
+ return EINVAL;
+ }
p->precision = 8;
p->bps = 1;
p->msb = 1;
@@ -225,15 +264,6 @@ am7930_set_params(void *addr, int setmode, int usemode, struct audio_params *p,
/* no other rates supported by amd chip */
p->sample_rate = 8000;
}
- if ((usemode & AUMODE_RECORD) == AUMODE_RECORD) {
- r->encoding = AUDIO_ENCODING_ULAW;
- r->precision = 8;
- r->bps = 1;
- r->msb = 1;
- r->channels = 1;
- /* no other rates supported by amd chip */
- r->sample_rate = 8000;
- }
return 0;
}
@@ -250,6 +280,30 @@ am7930_query_encoding(void *addr, struct audio_encoding *fp)
fp->msb = 1;
fp->flags = 0;
break;
+ case 1:
+ strlcpy(fp->name, AudioEslinear, sizeof fp->name);
+ fp->encoding = AUDIO_ENCODING_SLINEAR;
+ fp->precision = 8;
+ fp->bps = 1;
+ fp->msb = 1;
+ fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ break;
+ case 2:
+ strlcpy(fp->name, AudioEulinear, sizeof fp->name);
+ fp->encoding = AUDIO_ENCODING_ULINEAR;
+ fp->precision = 8;
+ fp->bps = 1;
+ fp->msb = 1;
+ fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ break;
+ case 3:
+ strlcpy(fp->name, AudioEalaw, sizeof fp->name);
+ fp->encoding = AUDIO_ENCODING_ALAW;
+ fp->precision = 8;
+ fp->bps = 1;
+ fp->msb = 1;
+ fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
+ break;
default:
return EINVAL;
/*NOTREACHED*/