summaryrefslogtreecommitdiff
path: root/sys/src/cmd/reform
diff options
context:
space:
mode:
authorSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2022-09-08 22:57:08 +0000
committerSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2022-09-08 22:57:08 +0000
commita3a0a3268c2c7173b01c61131a6b43f0454dda72 (patch)
tree9b398f397863952ab5416683e0772261b5e9ae82 /sys/src/cmd/reform
parentc013393923b925557a8a7f23cd065a19fe87f48f (diff)
reform/audio: use soft-mute to toggle DAC
Disabling DAC caused an audible pop and would stop the clock, causing any program writing to /dev/audio to halt until DAC would be enabled again. Use "digital soft mute" instead - no clock stopping, nor pops.
Diffstat (limited to 'sys/src/cmd/reform')
-rw-r--r--sys/src/cmd/reform/audio.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/src/cmd/reform/audio.c b/sys/src/cmd/reform/audio.c
index fe88c8ed8..fa57e174d 100644
--- a/sys/src/cmd/reform/audio.c
+++ b/sys/src/cmd/reform/audio.c
@@ -50,6 +50,18 @@ wr(int a, int v)
}
static void
+dactoggle(Out *, int on)
+{
+ /*
+ * Jack detect becomes extremely unstable when playing on spk and the
+ * volume is very high - DAC start to switch back and forth between two
+ * outputs. Solve this by always attenuating by -6dB and somewhat limiting
+ * the volume on DAC ("master") - to 0xf9 instead of 0xff (max).
+ */
+ wr(0x05, 1<<7 | (!on)<<3);
+}
+
+static void
classdspk(Out *, int on)
{
wr(0x31, (on ? 3 : 0)<<6 | 0x37); /* class D SPK out */
@@ -70,7 +82,7 @@ toggle(Out *o, int on)
static Out out[Nout] =
{
- [Dac] = {"master", 0x0a, 0xf9, 3<<7, nil, 0},
+ [Dac] = {"master", 0x0a, 0xf9, 0, dactoggle, 0},
[Hp] = {"hp", 0x02, 0x7f, 3<<5, nil, 0},
[Spk] = {"spk", 0x28, 0x7f, 3<<3, classdspk, 0},
};
@@ -198,20 +210,16 @@ reset(void)
/* turn on all outputs */
toggle(out+Hp, 1);
toggle(out+Spk, 1);
+
+ /* enable/unmute DAC */
+ reg1a |= 3<<7;
+ wr(0x1a, reg1a);
toggle(out+Dac, 1);
/* sensible defaults */
setvol(out+Spk, 100, 100);
setvol(out+Hp, 75, 75);
setvol(out+Dac, 80, 80);
-
- /*
- * Jack detect becomes extremely unstable when playing on spk and the
- * volume is very high - DAC start to switch back and forth between two
- * outputs. Solve this by always attenuating by -6dB and somewhat limiting
- * the volume on DAC ("master") - to 0xf9 instead of 0xff (max).
- */
- wr(0x05, 1<<7 | 0<<3); /* unmute DAC */
}
static void