Commit graph

42 commits

Author SHA1 Message Date
Hector Martin
ea4a8e9d35 main: Work around visense kernel channel swap bug
This is ugly and we really should figure out why the kernel admac stuff
borks, but it'll do for now...

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-12-17 17:14:36 +09:00
Hector Martin
38bc94fa77 blackbox: Fix metadata dump iteration
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-12-07 17:56:27 +09:00
Hector Martin
1773c6425b main: Handle SIGQUIT even if we got samples
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-12-07 17:11:07 +09:00
Hector Martin
d42f4817e0 cargo fmt
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-12-04 18:41:02 +09:00
Hector Martin
c3307388aa uclamp: Add support for sched utilization clamping
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-12-04 18:40:46 +09:00
Hector Martin
60752494cd main: Trap SIGQUIT to trigger a blackbox
The signal_hook crate makes this easy, but unfortunately insists on
hardcoding SA_RESTART. So we have to then use libc directly to patch
that out...

Still worth using signal_hook for the atomic flag helper though.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-12-04 18:40:46 +09:00
Hector Martin
4fb7fe7b41 main, rules: Rename Jxxx to AppleJxxx
This makes it more clear that we're matching against Apple machines. The
kernel driver will be updated to use this naming scheme. For backwards
compatibility, we add a rule to rename J313 at runtime (the only enabled
model at this time).

This update must be released together with a matching asahi-audio update
(but the kernel can come later).

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-12-04 17:24:31 +09:00
Hector Martin
7a82648d59 types: Display rounded-to-0 gain
So the display goes directly to 0.00 instead of flickering -0.00.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:35:39 +09:00
Hector Martin
ac120b7be1 types: Test for negative powers
Disallow nontrivial negative power, but clamp down rounding error to
avoid flickering signs in debug logs.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:35:39 +09:00
Hector Martin
21023ec426 Change temperature handling
Headroom goes *above* the limit, not below. Replace the max safe temp
thing with a window delta below the limit where attenuation begins.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:35:39 +09:00
Hector Martin
b12c8b69da main: Handle partial reads
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:30:35 +09:00
Hector Martin
e2b3a3ba7f main: Verbosely log suspend/resume handling
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:30:35 +09:00
Hector Martin
f8d9c55cbb types: Always set amp gain to max on startup
The kernel should clamp this to the correct value. We still read it back
later, to make sure our amp output calculations are correct.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:29:23 +09:00
Hector Martin
91e7c14b8e types: Do not prefix speaker name "Mono"
For single-speaker devices, there is no control prefix. So treat the
special name "Mono" as a null prefix in that case.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:29:23 +09:00
Hector Martin
83a53ba99f blackbox: Change file extensions
I guess I'm watching too much Mentour Pilot these days :-)

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:29:23 +09:00
Hector Martin
315255a7e0 main: Log blackbox speaker groups in integer order
For consistency.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:29:23 +09:00
Hector Martin
368be9d7df blackbox: Store state for all blocks
This lets us validate the model from blackbox dumps.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:29:22 +09:00
Hector Martin
7fbb53df51 blackbox: Add black-box debug functionality
On any panic, we dump out the last ~30 seconds of IVSENSE data along
with the starting state and panic reason.

Also add a feature to panic if the gain reduces too much. This can be
used to try to catch badness.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-29 00:28:08 +09:00
Hector Martin
a476f7daf1 helpers, types: Switch to panic for errors
We're not doing explicit error handling, since the kernel is in charge
of safety if we crash. Just panic on anything.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-23 02:20:19 +09:00
Hector Martin
157ddc4e41 Add suspend handling
ALSA needs special handling to correctly resume after the system is
suspended with a PCM active. Do the required dance.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-22 09:03:12 +09:00
Hector Martin
8fb7c31f88 Make mixer element names configurable
Doesn't really matter for us since all machines we plan to use so far
have the same chip, but might matter in the future.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-14 10:15:55 +09:00
Hector Martin
a250a73dd6 Clean up warnings
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-13 13:39:34 +09:00
Hector Martin
f33417573f Move config files under apple/
Take the vendor from the DT compatible, since in principle other
manufacturers could use this code too.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-13 13:36:20 +09:00
Hector Martin
c43b8b752b fixup! Implement flag file for optimistic cold boot state 2023-10-13 13:35:31 +09:00
Hector Martin
f382ce7a5c Verbosely report all gain changes
Just reporting the first nonzero change isn't really useful. Be spammy,
we can always reduce this later.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-13 13:34:46 +09:00
Hector Martin
ffa5af391d Implement flag file for optimistic cold boot state
If this is the first time the daemon runs, we assume 99C (just under the
limit, which means no reduction). Otherwise, we assume the max
temperature, and therefore max limit.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-13 13:34:41 +09:00
Hector Martin
fa4f763d05 Implement catchup/skipping the model forward
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 17:18:31 +09:00
Hector Martin
7ab0fed6d3 main: Report when gains go back to nominal
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 16:53:35 +09:00
Hector Martin
64e6710dac main: Be less spammy about sample rates
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 16:53:27 +09:00
Hector Martin
5c1fd2b60b main: Reset gains to 0dB on startup
This is mostly to avoid a sudden jump up in volume on the common case where the
first sound happens after enough catchup has occurred (once we implement
catchup...)

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 16:52:37 +09:00
Hector Martin
3660fd85d8 main: Implement main magic unlock control
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 16:52:12 +09:00
Hector Martin
6cb6c45083 types: Fix worst case initial magnet temp calculation
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 16:51:37 +09:00
Hector Martin
14c3ef0b7e types: Add write_int() helper
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 16:51:29 +09:00
Hector Martin
e19970b5e0 types: Lock all elements we interact with
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 16:51:15 +09:00
Hector Martin
7dc04ccb1d helpers: Add lock_el helper
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 16:51:00 +09:00
Hector Martin
b07584e1fd Grab current sample rate from mixer control 2023-05-09 19:12:43 +09:00
Hector Martin
5c47bc3e94 Automatically select the sample rate if zero
This allows the sense PCM to be opened at the correct current rate if
playback is active, or otherwise arbitrarily picks the lowest rate.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-05-09 19:12:02 +09:00
Hector Martin
21b3e49456 Wheee it works
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-02-24 01:17:41 +09:00
James Calligeros
1bb490871f
block on empty buffer
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2023-02-14 22:37:47 +10:00
James Calligeros
bc49ea2887
some fixes
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2023-02-14 22:02:30 +10:00
James Calligeros
a7ca735707
implement skeleton temp model
wip, probably horrible

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2023-02-14 20:30:57 +10:00
James Calligeros
e8a37a847b initial commit
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2022-12-02 13:54:41 +10:00