summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2011-09-04 20:08:38 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2011-09-04 20:08:38 +0000
commit2bb12e1fbc90abd983354710fd09081596ff89e7 (patch)
tree908a70262a1d42d7070e89ff2bdde8c82548a7ff /sys/dev/ic
parent8ef67fc597df6b154f323003f51f7aaf2727fc87 (diff)
Add the possibility for a MD attachment to stack a stream filter (sw_code)
if it needs to rewrite the audio stream; adapted from NetBSD
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/am7930.c30
-rw-r--r--sys/dev/ic/am7930var.h9
2 files changed, 31 insertions, 8 deletions
diff --git a/sys/dev/ic/am7930.c b/sys/dev/ic/am7930.c
index a96ed78aa45..f510711e6ce 100644
--- a/sys/dev/ic/am7930.c
+++ b/sys/dev/ic/am7930.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: am7930.c,v 1.2 2011/09/04 08:03:32 miod Exp $ */
+/* $OpenBSD: am7930.c,v 1.3 2011/09/04 20:08:37 miod Exp $ */
/* $NetBSD: am7930.c,v 1.44 2001/11/13 13:14:34 lukem Exp $ */
/*
@@ -206,18 +206,13 @@ am7930_close(void *addr)
DPRINTF(("sa_close: closed.\n"));
}
-/*
- * 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 *play, struct audio_params *rec)
{
+ struct am7930_softc *sc = addr;
struct audio_params *p;
int mode;
-#if 0
- struct am7930_softc *sc = addr;
-#endif
for (mode = AUMODE_RECORD; mode != -1;
mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
@@ -263,6 +258,27 @@ am7930_set_params(void *addr, int setmode, int usemode,
p->channels = 1;
/* no other rates supported by amd chip */
p->sample_rate = 8000;
+
+ if (sc->sc_glue->factor > 1) {
+ p->factor = sc->sc_glue->factor;
+ /*
+ * Remember which converter routine had been
+ * selected, if any, since there is no way
+ * to stack filters yet.
+ *
+ * Note that we rely upon the converters working
+ * in place (i.e. with factor == 1), which is
+ * correct as long as we don't try to emulate
+ * 16-bit encodings.
+ */
+ if (mode == AUMODE_PLAY) {
+ sc->play_sw_code = p->sw_code;
+ p->sw_code = sc->sc_glue->output_conv;
+ } else {
+ sc->rec_sw_code = p->sw_code;
+ p->sw_code = sc->sc_glue->input_conv;
+ }
+ }
}
return 0;
diff --git a/sys/dev/ic/am7930var.h b/sys/dev/ic/am7930var.h
index e7242cc2bb3..e8861c0fac1 100644
--- a/sys/dev/ic/am7930var.h
+++ b/sys/dev/ic/am7930var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: am7930var.h,v 1.1 2011/09/03 20:03:29 miod Exp $ */
+/* $OpenBSD: am7930var.h,v 1.2 2011/09/04 20:08:37 miod Exp $ */
/* $NetBSD: am7930var.h,v 1.10 2005/01/15 15:19:52 kent Exp $ */
/*
@@ -50,6 +50,9 @@ struct am7930_glue {
void (*codec_iwrite16)(struct am7930_softc *sc, int, uint16_t);
void (*onopen)(struct am7930_softc *sc);
void (*onclose)(struct am7930_softc *sc);
+ int factor;
+ void (*input_conv)(void *, u_char *, int);
+ void (*output_conv)(void *, u_char *, int);
};
struct am7930_softc {
@@ -64,6 +67,10 @@ struct am7930_softc {
uint8_t sc_mic_mute;
struct am7930_glue *sc_glue;
+
+ /* saved audio_params sw_code if overwritten with the glue pointers */
+ void (*play_sw_code)(void *, u_char *, int);
+ void (*rec_sw_code)(void *, u_char *, int);
};
extern int am7930debug;