summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2005-10-31 00:26:08 +0000
committerJoris Vink <joris@cvs.openbsd.org>2005-10-31 00:26:08 +0000
commit51e3e528880937879a7b1ddf9442fc95c4a6c515 (patch)
tree4c97bf8fefc5272f557d8f1de5a14082101c5380 /sys
parent770fd31c8a2eaf51899ea7f025cc7fe17a35b594 (diff)
- add needed bass & treble glue in i2s;
- add support for bass & treble in snapper; ok drahn@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/macppc/dev/i2s.c39
-rw-r--r--sys/arch/macppc/dev/i2svar.h8
-rw-r--r--sys/arch/macppc/dev/snapper.c112
3 files changed, 155 insertions, 4 deletions
diff --git a/sys/arch/macppc/dev/i2s.c b/sys/arch/macppc/dev/i2s.c
index 879bb3cfe75..125596c5d51 100644
--- a/sys/arch/macppc/dev/i2s.c
+++ b/sys/arch/macppc/dev/i2s.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i2s.c,v 1.1 2005/10/26 17:57:20 joris Exp $ */
+/* $OpenBSD: i2s.c,v 1.2 2005/10/31 00:26:07 joris Exp $ */
/* $NetBSD: i2s.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */
/*-
@@ -502,6 +502,8 @@ enum {
I2S_VOL_OUTPUT,
I2S_INPUT_SELECT,
I2S_VOL_INPUT,
+ I2S_BASS,
+ I2S_TREBLE,
I2S_ENUM_LAST
};
@@ -538,6 +540,16 @@ i2s_set_port(h, mc)
(*sc->sc_setvolume)(sc, l, r);
return 0;
+ case I2S_BASS:
+ if (sc->sc_setbass != NULL)
+ (*sc->sc_setbass)(sc, l);
+ return (0);
+
+ case I2S_TREBLE:
+ if (sc->sc_settreble != NULL)
+ (*sc->sc_settreble)(sc, l);
+ return (0);
+
case I2S_INPUT_SELECT:
/* no change necessary? */
if (mc->un.mask == sc->sc_record_source)
@@ -585,6 +597,14 @@ i2s_get_port(h, mc)
mc->un.mask = sc->sc_record_source;
return 0;
+ case I2S_BASS:
+ mc->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_bass;
+ return (0);
+
+ case I2S_TREBLE:
+ mc->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_treble;
+ return (0);
+
case I2S_VOL_INPUT:
/* XXX TO BE DONE */
mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = 0;
@@ -677,6 +697,23 @@ i2s_query_devinfo(h, dip)
dip->type = AUDIO_MIXER_CLASS;
dip->next = dip->prev = AUDIO_MIXER_LAST;
return 0;
+
+ case I2S_BASS:
+ dip->mixer_class = I2S_MONITOR_CLASS;
+ strlcpy(dip->label.name, AudioNbass, sizeof(dip->label.name));
+ dip->type = AUDIO_MIXER_VALUE;
+ dip->prev = dip->next = AUDIO_MIXER_LAST;
+ dip->un.v.num_channels = 1;
+ return (0);
+
+ case I2S_TREBLE:
+ dip->mixer_class = I2S_MONITOR_CLASS;
+ strlcpy(dip->label.name, AudioNtreble, sizeof(dip->label.name));
+ dip->type = AUDIO_MIXER_VALUE;
+ dip->prev = dip->next = AUDIO_MIXER_LAST;
+ dip->un.v.num_channels = 1;
+ return (0);
+
}
return ENXIO;
diff --git a/sys/arch/macppc/dev/i2svar.h b/sys/arch/macppc/dev/i2svar.h
index a9b494e3fa7..0242e87bc7a 100644
--- a/sys/arch/macppc/dev/i2svar.h
+++ b/sys/arch/macppc/dev/i2svar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: i2svar.h,v 1.1 2005/10/26 17:57:20 joris Exp $ */
-/* $Id: i2svar.h,v 1.1 2005/10/26 17:57:20 joris Exp $ */
+/* $OpenBSD: i2svar.h,v 1.2 2005/10/31 00:26:07 joris Exp $ */
+/* $Id: i2svar.h,v 1.2 2005/10/31 00:26:07 joris Exp $ */
/*-
* Copyright (c) 2001,2003 Tsubai Masanari. All rights reserved.
@@ -58,6 +58,8 @@ struct i2s_softc {
u_int sc_output_mask; /* output source mask */
void (*sc_setvolume)(struct i2s_softc *, int, int);
+ void (*sc_setbass)(struct i2s_softc *, int);
+ void (*sc_settreble)(struct i2s_softc *, int);
u_char *sc_reg;
void *sc_i2c;
@@ -65,6 +67,8 @@ struct i2s_softc {
u_int sc_rate;
u_int sc_vol_l;
u_int sc_vol_r;
+ u_int sc_bass;
+ u_int sc_treble;
bus_dma_tag_t sc_dmat;
dbdma_regmap_t *sc_odma;
diff --git a/sys/arch/macppc/dev/snapper.c b/sys/arch/macppc/dev/snapper.c
index 54163a60434..10e4995c183 100644
--- a/sys/arch/macppc/dev/snapper.c
+++ b/sys/arch/macppc/dev/snapper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snapper.c,v 1.22 2005/10/31 00:04:54 joris Exp $ */
+/* $OpenBSD: snapper.c,v 1.23 2005/10/31 00:26:07 joris Exp $ */
/* $NetBSD: snapper.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */
/*-
@@ -70,6 +70,8 @@ int snapper_match(struct device *, void *, void *);
void snapper_attach(struct device *, struct device *, void *);
void snapper_defer(struct device *);
void snapper_set_volume(struct snapper_softc *, int, int);
+void snapper_set_bass(struct snapper_softc *, int);
+void snapper_set_treble(struct snapper_softc *, int);
int tas3004_write(struct snapper_softc *, u_int, const void *);
int tas3004_init(struct snapper_softc *);
@@ -116,6 +118,86 @@ struct audio_device snapper_device = {
"snapper"
};
+const uint8_t snapper_trebletab[] = {
+ 0x96, /* -18dB */
+ 0x94, /* -17dB */
+ 0x92, /* -16dB */
+ 0x90, /* -15dB */
+ 0x8e, /* -14dB */
+ 0x8c, /* -13dB */
+ 0x8a, /* -12dB */
+ 0x88, /* -11dB */
+ 0x86, /* -10dB */
+ 0x84, /* -9dB */
+ 0x82, /* -8dB */
+ 0x80, /* -7dB */
+ 0x7e, /* -6dB */
+ 0x7c, /* -5dB */
+ 0x7a, /* -4dB */
+ 0x78, /* -3dB */
+ 0x76, /* -2dB */
+ 0x74, /* -1dB */
+ 0x72, /* 0dB */
+ 0x70, /* 1dB */
+ 0x6d, /* 2dB */
+ 0x6b, /* 3dB */
+ 0x68, /* 4dB */
+ 0x65, /* 5dB */
+ 0x62, /* 6dB */
+ 0x5d, /* 7dB */
+ 0x59, /* 8dB */
+ 0x53, /* 9dB */
+ 0x4d, /* 10dB */
+ 0x47, /* 11dB */
+ 0x3f, /* 12dB */
+ 0x36, /* 13dB */
+ 0x2c, /* 14dB */
+ 0x20, /* 15dB */
+ 0x13, /* 16dB */
+ 0x04, /* 17dB */
+ 0x01, /* 18dB */
+};
+
+const uint8_t snapper_basstab[] = {
+ 0x96, /* -18dB */
+ 0x94, /* -17dB */
+ 0x92, /* -16dB */
+ 0x90, /* -15dB */
+ 0x8e, /* -14dB */
+ 0x8c, /* -13dB */
+ 0x8a, /* -12dB */
+ 0x88, /* -11dB */
+ 0x86, /* -10dB */
+ 0x84, /* -9dB */
+ 0x82, /* -8dB */
+ 0x80, /* -7dB */
+ 0x7e, /* -6dB */
+ 0x7c, /* -5dB */
+ 0x7a, /* -4dB */
+ 0x78, /* -3dB */
+ 0x76, /* -2dB */
+ 0x74, /* -1dB */
+ 0x72, /* 0dB */
+ 0x6f, /* 1dB */
+ 0x6d, /* 2dB */
+ 0x6a, /* 3dB */
+ 0x67, /* 4dB */
+ 0x65, /* 5dB */
+ 0x62, /* 6dB */
+ 0x5f, /* 7dB */
+ 0x5b, /* 8dB */
+ 0x55, /* 9dB */
+ 0x4f, /* 10dB */
+ 0x49, /* 11dB */
+ 0x43, /* 12dB */
+ 0x3b, /* 13dB */
+ 0x33, /* 14dB */
+ 0x29, /* 15dB */
+ 0x1e, /* 16dB */
+ 0x11, /* 17dB */
+ 0x01, /* 18dB */
+};
+
/* TAS3004 registers */
#define DEQ_MCR1 0x01 /* Main control register 1 (1byte) */
#define DEQ_DRC 0x02 /* Dynamic range compression (6bytes?) */
@@ -237,6 +319,8 @@ snapper_attach(parent, self, aux)
struct snapper_softc *sc = (struct snapper_softc *)self;
sc->sc_setvolume = snapper_set_volume;
+ sc->sc_setbass = snapper_set_bass;
+ sc->sc_settreble = snapper_set_treble;
i2s_attach(parent, sc, aux);
config_defer(self, snapper_defer);
@@ -288,6 +372,32 @@ snapper_set_volume(sc, left, right)
tas3004_write(sc, DEQ_VOLUME, vol);
}
+void
+snapper_set_treble(struct snapper_softc *sc, int value)
+{
+ uint8_t reg;
+
+ if ((value >= 0) && (value <= 255) && (value != sc->sc_treble)) {
+ reg = snapper_trebletab[(value >> 3) + 2];
+ if (tas3004_write(sc, DEQ_TREBLE, &reg) < 0)
+ return;
+ sc->sc_treble = value;
+ }
+}
+
+void
+snapper_set_bass(struct snapper_softc *sc, int value)
+{
+ uint8_t reg;
+
+ if ((value >= 0) && (value <= 255) && (value != sc->sc_bass)) {
+ reg = snapper_basstab[(value >> 3) + 2];
+ if (tas3004_write(sc, DEQ_BASS, &reg) < 0)
+ return;
+ sc->sc_bass = value;
+ }
+}
+
const struct tas3004_reg tas3004_initdata = {
{ DEQ_MCR1_SC_64 | DEQ_MCR1_SM_I2S | DEQ_MCR1_W_20 }, /* MCR1 */
{ 1, 0, 0, 0, 0, 0 }, /* DRC */