diff options
author | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2022-08-21 01:30:03 +0000 |
---|---|---|
committer | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2022-08-21 01:30:03 +0000 |
commit | a78b71b143240fa1dad019f5c655a03c2d2400d9 (patch) | |
tree | e89536e837fbd4a921542d81e73d7315b4da3ac4 | |
parent | 5e15db8fa31dd68fee22f260ae797a38ccaa4070 (diff) |
move and rename MNT Reform 2 support utilies, cat manpages into one
Aux/imx8pm and aux/wm8960 had pretty cryptic names and it made
more sense to use a reform/pm and reform/audio naming, accordingly.
Instead of having special mount points /mnt/pm and /mnt/wm8960,
/dev is used directly, removing the need to do any manual work -
stats(1) will continue showing the CPU temperature, and zuke(1)
will still be able to control the volume, etc.
Brightness controls were changed to a better interface -
/dev/light, where each line contains a "a_thing its_light_value".
This way more parts can be controlled. Right now it's only "lcd",
but later it might be "kbd" and "trackball" as well.
Example of lib/profile:
reform/audio
echo master 80 > /dev/volume
reform/pm
echo lcd 100 > /dev/light
-rw-r--r-- | sys/man/1/reform | 115 | ||||
-rw-r--r-- | sys/man/8/imx8pm | 58 | ||||
-rw-r--r-- | sys/man/8/wm8960 | 83 | ||||
-rw-r--r-- | sys/src/cmd/aux/mkfile | 2 | ||||
-rw-r--r-- | sys/src/cmd/reform/audio.c (renamed from sys/src/cmd/aux/wm8960.c) | 10 | ||||
-rw-r--r-- | sys/src/cmd/reform/mkfile | 13 | ||||
-rw-r--r-- | sys/src/cmd/reform/pm.c (renamed from sys/src/cmd/aux/imx8pm.c) | 42 |
7 files changed, 152 insertions, 171 deletions
diff --git a/sys/man/1/reform b/sys/man/1/reform new file mode 100644 index 000000000..4d95ebe48 --- /dev/null +++ b/sys/man/1/reform @@ -0,0 +1,115 @@ +.TH REFORM 1 +.SH NAME +audio, +pm +- MNT Reform 2 support utilities +.SH SYNOPSIS +.B reform/audio +[ +.B -1 +] +[ +.B -D +] +[ +.B -m +.I mountpoint +] +[ +.B -s +.I service +] +.PP +.B reform/pm +[ +.B -D +] +[ +.B -m +.I mountpoint +] +[ +.B -s +.I service +] +.SH DESCRIPTION +These programs provide support for certain functions of MNT Reform 2 +computing device make controlling file systems available under +.BR /dev . +.PP +.SS Audio +.I audio +initializes the DAC (Digital-to-Analog Converter) on the platform and +provides a standard \fIaudio\fR(3) interface to control volume and +other parameters. +With +.I -1 +only the initialization is performed and the program exits +immediately. +.PP +The following files are provided by the program: +.TP +.B audioctl +Shows the current status +.I (on +or +.I off ) +of the three "outputs" - +.BR master , +.BR hp +and +.BR spk . +Each can be enabled, disabled or toggled, by writing a single line to +the same file, consisting of the output name and the desired action - +.I on , +.I off +or +.I toggle , +accordingly. +.IP +DAC can be reinitialized by writing a single +.BR reset . +.TP +.B volume +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 +.IP +Enhanced stereo separation can be enabled by writing +.BR 3d , +followed by desired percentage of the effect. +.SS Power and monitoring +.I pm +presents a file system consisting of the following files: +.TP +.B light +Provides a way to control the backlight of the built-in LCD by +writing \fIlcd [-+]N\fR, +where +.I N +is expressed in percentage, either as an absolute value (0-100) or +relative to the current brightness - by prefixing with a sign. +Reading +.B light +returns the current brightness. +.TP +.B cputemp +Exposes the current temperature reading of the CPU. +.SH SOURCE +.B /sys/src/cmd/reform +.SH SEE ALSO +.IR audio (3) +.SH HISTORY +MNT Reform 2 support first appeared in 9front (August, 2022). +.SH BUGS +Only 44100Hz (default) and 48000Hz sample rates are supported with +.IR audio , +recording is not implemented. +.PP +.I Light +was chosen as a shorter alternative to +.IR brightness . +In the future it might support controlling keyboard and trackball +light levels. diff --git a/sys/man/8/imx8pm b/sys/man/8/imx8pm deleted file mode 100644 index 1c7630658..000000000 --- a/sys/man/8/imx8pm +++ /dev/null @@ -1,58 +0,0 @@ -.TH IMX8PM 8 -.SH NAME -imx8pm \- power management for MNT Reform 2 -.SH SYNOPSIS -.B aux/imx8pm -[ -.B -D -] -[ -.B -m -.I mountpoint -] -[ -.B -s -.I service -] -.nf -.sp 0.3v -.B /mnt/pm/cputemp -.B /mnt/pm/ctl -.fi -.SH DESCRIPTION -.I Aux/imx8pm -presents at -.I mountpoint -(default -.BR /mnt/pm ) -an interface to miscellaneous functions of IMX8MQ. If a -.I service -is specified, the interface will be posted at -.BI /srv/ service -as well. -.PP -.B cputemp -Exposes the current temperature reading of the CPU. -.PP -.B ctl -Provides a way to control the brightness of the built-in LCD by -writing -.IP -.I brightness [-+]N -.PP -.B N -is expressed in percentage, either as an absolute value (0-100) or -relative to the current brightness - by prefixing with a sign. -.PP -Reading -.B ctl -returns the current brightness. -.SH SOURCE -.B /sys/src/cmd/aux/imx8pm.c -.SH SEE ALSO -.IR wm8960 (8) -.SH BUGS -Absolutely yes. -.SH HISTORY -.I Acpi -first appeared in 9front (August, 2022). diff --git a/sys/man/8/wm8960 b/sys/man/8/wm8960 deleted file mode 100644 index 76e9eaf24..000000000 --- a/sys/man/8/wm8960 +++ /dev/null @@ -1,83 +0,0 @@ -.TH WM8960 8 -.SH NAME -wm8960 \- audio controls for MNT Reform 2 -.SH SYNOPSIS -.B aux/wm8960 -[ -.B -D -] -[ -.B -1 -] -[ -.B -m -.I mountpoint -] -[ -.B -s -.I service -] -.nf -.sp 0.3v -.B /mnt/wm8960/audioctl -.B /mnt/wm8960/volume -.fi -.SH DESCRIPTION -.I Aux/imx8pm -presents at -.I mountpoint -(default -.BR /mnt/wm8960 ) -an interface to control the DAC (Digital-to-Analog Converter) found on -MNT Reform 2. If a -.I service -is specified, the interface will be posted at -.BI /srv/ service -as well. In order to initialize the DAC and immediately exit, without -running a file system, option -.I -1 -can be used. -.PP -The directory contains the following files. -.TP -.B audioctl -Shows the current status -.I (on -or -.I off ) -of the three "outputs" - -.BR master , -.BR hp -and -.BR spk . -Each can be enabled, disabled or toggled, by writing a single line -to the same file, consisting of the output name and the desired action - -.I on , -.I off -or -.I toggle , -accordingly. -.IP -DAC can be reinitialized by writing a single -.BR reset . -.TP -.B volume -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 -.BR 3d , -followed by desired percentage of the effect. -.SH SOURCE -.B /sys/src/cmd/aux/wm8960.c -.SH SEE ALSO -.IR imx8pm (8) -.SH BUGS -Absolutely yes. -.SH HISTORY -.I Wm8960 -first appeared in 9front (August, 2022). diff --git a/sys/src/cmd/aux/mkfile b/sys/src/cmd/aux/mkfile index 76ef6a082..1ef302c45 100644 --- a/sys/src/cmd/aux/mkfile +++ b/sys/src/cmd/aux/mkfile @@ -22,7 +22,6 @@ TARG=\ getflags\ icanhasmsi\ icanhasvmx\ - imx8pm\ lines\ listen\ listen1\ @@ -50,7 +49,6 @@ TARG=\ write\ wacom\ wikifmt\ - wm8960\ wpa\ zerotrunc\ diff --git a/sys/src/cmd/aux/wm8960.c b/sys/src/cmd/reform/audio.c index 0250d05bf..9c73505b6 100644 --- a/sys/src/cmd/aux/wm8960.c +++ b/sys/src/cmd/reform/audio.c @@ -233,8 +233,8 @@ fsread(Req *r) for(i = 0, o = out; i < Nout; i++, o++) s = seprint(s, e, "%s %d %d\n", o->name, o->vol[0], o->vol[1]); s = seprint(s, e, "speed %d\n", rate); + seprint(s, e, "3d %d\n", ⅓d); } - seprint(s, e, "3d %d\n", ⅓d); readstr(r, msg); respond(r, nil); @@ -317,7 +317,7 @@ static Srv fs = { static void usage(void) { - fprint(2, "usage: aux/wm8960 [-1] [-D] [-m /mnt/pm] [-s service]\n"); + fprint(2, "usage: %s [-1] [-D] [-m /dev] [-s service]\n", argv0); exits("usage"); } @@ -327,7 +327,7 @@ main(int argc, char **argv) char *mtpt, *srv; int ctl, oneshot; - mtpt = "/mnt/wm8960"; + mtpt = "/dev"; srv = nil; oneshot = 0; ARGBEGIN{ @@ -363,8 +363,8 @@ main(int argc, char **argv) fs.tree = alloctree(uid, uid, DMDIR|0555, nil); createfile(fs.tree->root, "audioctl", uid, 0666, (void*)Ctl); createfile(fs.tree->root, "volume", uid, 0666, (void*)Vol); - - postmountsrv(&fs, srv, mtpt, MREPL); + /* have to mount -b to shadow sai's useless files */ + postmountsrv(&fs, srv, mtpt, MBEFORE); exits(nil); } diff --git a/sys/src/cmd/reform/mkfile b/sys/src/cmd/reform/mkfile new file mode 100644 index 000000000..a5a74483e --- /dev/null +++ b/sys/src/cmd/reform/mkfile @@ -0,0 +1,13 @@ +</$objtype/mkfile + +BIN=/$objtype/bin/reform +TARG=\ + audio\ + pm\ + +</sys/src/cmd/mkmany + +install:V: $BIN + +$BIN: + mkdir -p $BIN diff --git a/sys/src/cmd/aux/imx8pm.c b/sys/src/cmd/reform/pm.c index edcd81bb7..6e0f3c161 100644 --- a/sys/src/cmd/aux/imx8pm.c +++ b/sys/src/cmd/reform/pm.c @@ -9,7 +9,7 @@ enum Mhz = 1000*1000, Pwmsrcclk = 25*Mhz, - Ctl = 1, + Light = 1, Temp, PWMSAR = 0x0c/4, @@ -43,7 +43,7 @@ enum }; static u32int *pwm2, *tmu; -static char *uid = "mntpm"; +static char *uid = "pm"; static void wr(u32int *base, int reg, u32int v) @@ -60,7 +60,7 @@ rd(u32int *base, int reg) } static void -setbrightness(int p) +setlight(int p) { u32int v; @@ -74,7 +74,7 @@ setbrightness(int p) } static int -getbrightness(void) +getlight(void) { u32int m, v; @@ -156,8 +156,8 @@ fsread(Req *r) msg[0] = 0; if(r->ifcall.offset == 0){ - if(r->fid->file->aux == (void*)Ctl) - snprint(msg, sizeof(msg), "brightness %d\n", getbrightness()); + if(r->fid->file->aux == (void*)Light) + snprint(msg, sizeof(msg), "lcd %d\n", getlight()); else if(r->fid->file->aux == (void*)Temp){ if(getcputemp(c) == 0) snprint(msg, sizeof(msg), "%d.0\n", c[0]); @@ -176,7 +176,7 @@ fswrite(Req *r) char msg[256], *f[4]; int nf, v; - if(r->fid->file->aux == (void*)Ctl){ + if(r->fid->file->aux == (void*)Light){ snprint(msg, sizeof(msg), "%.*s", utfnlen((char*)r->ifcall.data, r->ifcall.count), (char*)r->ifcall.data); nf = tokenize(msg, f, nelem(f)); @@ -184,11 +184,11 @@ fswrite(Req *r) respond(r, "invalid ctl message"); return; } - if(strcmp(f[0], "brightness") == 0){ + if(strcmp(f[0], "lcd") == 0){ v = atoi(f[1]); if(*f[1] == '+' || *f[1] == '-') - v += getbrightness(); - setbrightness(v); + v += getlight(); + setlight(v); } } @@ -204,7 +204,7 @@ static Srv fs = { static void usage(void) { - fprint(2, "usage: aux/imx8pm [-D] [-m /mnt/pm] [-s service]\n"); + fprint(2, "usage: %s [-D] [-m /dev] [-s service]\n", argv0); exits("usage"); } @@ -213,7 +213,7 @@ main(int argc, char **argv) { char *mtpt, *srv; - mtpt = "/mnt/pm"; + mtpt = "/dev"; srv = nil; ARGBEGIN{ case 'D': @@ -229,19 +229,15 @@ main(int argc, char **argv) usage(); }ARGEND - fs.tree = alloctree(uid, uid, DMDIR|0555, nil); - createfile(fs.tree->root, "ctl", uid, 0666, (void*)Ctl); - if((tmu = segattach(0, "tmu", 0, 0xf20)) == (void*)-1) - tmu = nil; - else{ - createfile(fs.tree->root, "cputemp", uid, 0444, (void*)Temp); - tmuinit(); - } + sysfatal("no tmu"); if((pwm2 = segattach(0, "pwm2", 0, 0x18)) == (void*)-1) - pwm2 = nil; - - postmountsrv(&fs, srv, mtpt, MREPL); + sysfatal("no pwm2"); + tmuinit(); + fs.tree = alloctree(uid, uid, DMDIR|0555, nil); + createfile(fs.tree->root, "cputemp", uid, 0444, (void*)Temp); + createfile(fs.tree->root, "light", uid, 0666, (void*)Light); + postmountsrv(&fs, srv, mtpt, MAFTER); exits(nil); } |