summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-05-08 17:52:19 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-05-08 17:52:19 +0000
commitaefb840fc1791a810a96795359325f54934cd72f (patch)
treeec55373cfaddb6e5a0bbffa162982c3744d22be5 /sys/dev/pci
parent786d7b987c829d864e7037901e5d07af57eff75b (diff)
add support HT mixer knobs (ie routing control). Allow monitoring
analog inputs
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/envy.c42
-rw-r--r--sys/dev/pci/envyreg.h10
2 files changed, 46 insertions, 6 deletions
diff --git a/sys/dev/pci/envy.c b/sys/dev/pci/envy.c
index 56d4d234d37..42d333b7246 100644
--- a/sys/dev/pci/envy.c
+++ b/sys/dev/pci/envy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envy.c,v 1.26 2009/05/08 16:53:45 ratchov Exp $ */
+/* $OpenBSD: envy.c,v 1.27 2009/05/08 17:52:18 ratchov Exp $ */
/*
* Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
*
@@ -788,6 +788,19 @@ envy_lineout_getsrc(struct envy_softc *sc, int out)
{
int reg, shift, src;
+ if (sc->isht) {
+ reg = bus_space_read_4(sc->mt_iot, sc->mt_ioh, ENVY_MT_HTSRC);
+ DPRINTF("%s: outsrc=%x\n", DEVNAME(sc), reg);
+ shift = 3 * (out / 2) + ((out & 1) ? 20 : 8);
+ src = (reg >> shift) & ENVY_MT_HTSRC_MASK;
+ if (src == ENVY_MT_HTSRC_DMA) {
+ return ENVY_MIX_OUTSRC_DMA;
+ } else {
+ src -= ENVY_MT_HTSRC_LINE;
+ return ENVY_MIX_OUTSRC_LINEIN + src;
+ }
+ }
+
reg = bus_space_read_2(sc->mt_iot, sc->mt_ioh, ENVY_MT_OUTSRC);
DPRINTF("%s: outsrc=%x\n", DEVNAME(sc), reg);
shift = (out & 1) ? (out & ~1) + 8 : out;
@@ -811,6 +824,25 @@ envy_lineout_setsrc(struct envy_softc *sc, int out, int src)
{
int reg, shift, mask, sel;
+ if (sc->isht) {
+ if (src < ENVY_MIX_OUTSRC_SPDIN) {
+ sel = ENVY_MT_HTSRC_LINE;
+ sel += src;
+ } else if (src < ENVY_MIX_OUTSRC_DMA) {
+ sel = ENVY_MT_HTSRC_SPD;
+ sel += src - ENVY_MIX_OUTSRC_SPDIN;
+ } else {
+ sel = ENVY_MT_HTSRC_DMA;
+ }
+ shift = 3 * (out / 2) + ((out & 1) ? 20 : 8);
+ mask = ENVY_MT_HTSRC_MASK << shift;
+ reg = bus_space_read_4(sc->mt_iot, sc->mt_ioh, ENVY_MT_HTSRC);
+ reg = (reg & ~mask) | (sel << shift);
+ bus_space_write_4(sc->mt_iot, sc->mt_ioh, ENVY_MT_HTSRC, reg);
+ DPRINTF("%s: outsrc <- %x\n", DEVNAME(sc), reg);
+ return;
+ }
+
if (src < ENVY_MIX_OUTSRC_DMA) {
/*
* linein and spdin are used as output source so we
@@ -1344,7 +1376,7 @@ envy_query_devinfo(void *self, struct mixer_devinfo *dev)
/*
* output.lineX_source
*/
- ndev = sc->isht ? 0 : sc->card->noch;
+ ndev = sc->card->noch;
if (idx < ndev) {
n = 0;
dev->type = AUDIO_MIXER_ENUM;
@@ -1357,7 +1389,7 @@ envy_query_devinfo(void *self, struct mixer_devinfo *dev)
dev->un.e.member[n].ord = n;
snprintf(dev->un.e.member[n++].label.name,
MAX_AUDIO_DEV_LEN, "play%d", idx);
- if (idx < 2) {
+ if (!sc->isht && idx < 2) {
dev->un.e.member[n].ord = n;
snprintf(dev->un.e.member[n++].label.name,
MAX_AUDIO_DEV_LEN, "mon%d", idx);
@@ -1417,7 +1449,7 @@ envy_get_port(void *self, struct mixer_ctrl *ctl)
}
idx = ctl->dev - ENVY_MIX_NCLASS;
- ndev = sc->isht ? 0 : sc->card->noch;
+ ndev = sc->card->noch;
if (idx < ndev) {
ctl->un.ord = envy_lineout_getsrc(sc, idx);
if (ctl->un.ord >= ENVY_MIX_NOUTSRC)
@@ -1458,7 +1490,7 @@ envy_set_port(void *self, struct mixer_ctrl *ctl)
}
idx = ctl->dev - ENVY_MIX_NCLASS;
- ndev = sc->isht ? 0 : sc->card->noch;
+ ndev = sc->card->noch;
if (idx < ndev) {
maxsrc = sc->card->nich + 1;
if (idx < 2)
diff --git a/sys/dev/pci/envyreg.h b/sys/dev/pci/envyreg.h
index 81516f6682e..e70ff18603a 100644
--- a/sys/dev/pci/envyreg.h
+++ b/sys/dev/pci/envyreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: envyreg.h,v 1.8 2009/05/08 16:53:45 ratchov Exp $ */
+/* $OpenBSD: envyreg.h,v 1.9 2009/05/08 17:52:18 ratchov Exp $ */
/*
* Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
*
@@ -145,6 +145,14 @@
#define ENVY_MT_INSEL_MASK ((1 << ENVY_MT_INSEL_BITS) - 1)
/*
+ * HT routing control
+ */
+#define ENVY_MT_HTSRC 0x2c
+#define ENVY_MT_HTSRC_DMA 0x00
+#define ENVY_MT_HTSRC_LINE 0x02
+#define ENVY_MT_HTSRC_SPD 0x04
+#define ENVY_MT_HTSRC_MASK 0x07
+/*
* AK4524 control registers
*/
#define AK4524_PWR 0x00