summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/pci/envy.c23
-rw-r--r--sys/dev/pci/envyreg.h4
2 files changed, 24 insertions, 3 deletions
diff --git a/sys/dev/pci/envy.c b/sys/dev/pci/envy.c
index aae043798c6..75e010a79e9 100644
--- a/sys/dev/pci/envy.c
+++ b/sys/dev/pci/envy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envy.c,v 1.73 2018/09/03 05:37:32 miko Exp $ */
+/* $OpenBSD: envy.c,v 1.74 2019/04/30 20:17:12 ratchov Exp $ */
/*
* Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
*
@@ -226,7 +226,9 @@ struct {
} envy_rates[] = {
{ 8000, 0x6}, { 9600, 0x3}, {11025, 0xa}, {12000, 2}, {16000, 5},
{22050, 0x9}, {24000, 0x1}, {32000, 0x4}, {44100, 8}, {48000, 0},
- {64000, 0xf}, {88200, 0xb}, {96000, 0x7}, {-1, -1}
+ {64000, 0xf}, {88200, 0xb}, {96000, 0x7},
+ {176400, 0xc}, {192000, 0xe},
+ {-1, -1}
};
/*
@@ -1849,7 +1851,13 @@ envy_set_params(void *self, int setmode, int usemode,
DPRINTF("%s: play/rec rates mismatch\n", DEVNAME(sc));
r->sample_rate = p->sample_rate;
}
+
rate = (setmode & AUMODE_PLAY) ? p->sample_rate : r->sample_rate;
+
+ /* only HT model supports rates above 96kHz */
+ if (!sc->isht && rate > 96000)
+ rate = 96000;
+
for (i = 0; envy_rates[i].rate < rate; i++) {
if (envy_rates[i].rate == -1) {
i--;
@@ -1857,10 +1865,21 @@ envy_set_params(void *self, int setmode, int usemode,
break;
}
}
+
+ if (sc->isht) {
+ reg = envy_mt_read_1(sc, ENVY_MT_FMT);
+ if (rate > 96000)
+ reg |= ENVY_MT_FMT_128X;
+ else
+ reg &= ~ENVY_MT_FMT_128X;
+ envy_mt_write_1(sc, ENVY_MT_FMT, reg);
+ }
+
reg = envy_mt_read_1(sc, ENVY_MT_RATE);
reg &= ~ENVY_MT_RATEMASK;
reg |= envy_rates[i].reg;
envy_mt_write_1(sc, ENVY_MT_RATE, reg);
+
if (setmode & AUMODE_PLAY) {
p->sample_rate = envy_rates[i].rate;
p->encoding = AUDIO_ENCODING_SLINEAR_LE;
diff --git a/sys/dev/pci/envyreg.h b/sys/dev/pci/envyreg.h
index be1a40760c2..a3af70e68c0 100644
--- a/sys/dev/pci/envyreg.h
+++ b/sys/dev/pci/envyreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: envyreg.h,v 1.17 2011/04/27 07:01:33 ratchov Exp $ */
+/* $OpenBSD: envyreg.h,v 1.18 2019/04/30 20:17:12 ratchov Exp $ */
/*
* Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
*
@@ -114,6 +114,8 @@
#define ENVY_MT_INTR_RMASK 0x80 /* !HT only */
#define ENVY_MT_RATE 1
#define ENVY_MT_RATEMASK 0x0f
+#define ENVY_MT_FMT 2
+#define ENVY_MT_FMT_128X 0x08 /* HT only */
#define ENVY_MT_IMASK 3 /* HT only */
#define ENVY_MT_IMASK_PDMA0 0x1
#define ENVY_MT_IMASK_RDMA0 0x2