summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2022-08-20 17:05:20 +0000
committerSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2022-08-20 17:05:20 +0000
commit3e58068cc5f07ae3306630aaa1448fa87643c170 (patch)
tree3bb6a3f5ea7e4bb43bdb7f614aa0f30f51563f7e
parentf05b00e7be50dfbcf698a0d9c3b1f2fdbea98adc (diff)
aux/wm8960: relative volume adjustment through the fs interface
-rw-r--r--sys/man/8/wm896013
-rw-r--r--sys/src/cmd/aux/wm8960.c16
2 files changed, 25 insertions, 4 deletions
diff --git a/sys/man/8/wm8960 b/sys/man/8/wm8960
index 4c46604a6..76e9eaf24 100644
--- a/sys/man/8/wm8960
+++ b/sys/man/8/wm8960
@@ -17,6 +17,11 @@ wm8960 \- audio controls for MNT Reform 2
.B -s
.I service
]
+.nf
+.sp 0.3v
+.B /mnt/wm8960/audioctl
+.B /mnt/wm8960/volume
+.fi
.SH DESCRIPTION
.I Aux/imx8pm
presents at
@@ -28,7 +33,7 @@ MNT Reform 2. If a
.I service
is specified, the interface will be posted at
.BI /srv/ service
-as well. In order to only initialize the DAC and immediately exit without
+as well. In order to initialize the DAC and immediately exit, without
running a file system, option
.I -1
can be used.
@@ -57,7 +62,11 @@ DAC can be reinitialized by writing a single
.BR reset .
.TP
.B volume
-Provides an interface for volume control (see \fIaudio\fR(3)). Only
+Provides an interface for volume control (see \fIaudio\fR(3)). For ease of use,
+.B volume
+supports relative adjustments by prefixing a number with a sign.
+.IP
+Only
44100Hz (default) and 48000Hz sample rates are supported.
.IP
Enhanced stereo separation can be enabled by writing
diff --git a/sys/src/cmd/aux/wm8960.c b/sys/src/cmd/aux/wm8960.c
index adb554d47..0250d05bf 100644
--- a/sys/src/cmd/aux/wm8960.c
+++ b/sys/src/cmd/aux/wm8960.c
@@ -240,6 +240,18 @@ fsread(Req *r)
respond(r, nil);
}
+static int
+setoradd(int x, char *s)
+{
+ int d;
+
+ d = atoi(s);
+ if(*s == '+' || *s == '-')
+ return x + d;
+
+ return d;
+}
+
static void
fswrite(Req *r)
{
@@ -287,8 +299,8 @@ Emsg:
goto Emsg;
toggle(o, on);
}else if(r->fid->file->aux == (void*)Vol){
- vl = atoi(f[1]);
- vr = nf < 3 ? vl : atoi(f[2]);
+ vl = setoradd(o->vol[0], f[1]);
+ vr = setoradd(o->vol[1], nf < 3 ? f[1] : f[2]);
setvol(o, vl, vr);
}