No description
Find a file
James Calligeros 8ff0db2e96
readme: fix typo
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2023-12-19 22:11:54 +10:00
conf/apple j314: Manually tweak model 2023-12-17 19:45:19 +09:00
docs speakers.txt: Correct gain for j375 2023-12-11 22:27:18 +09:00
src main: Work around visense kernel channel swap bug 2023-12-17 17:14:36 +09:00
testing analyze.py: Update gains for new kernel config 2023-12-17 17:14:36 +09:00
.gitignore Add testing scripts 2023-12-08 23:19:19 +09:00
95-speakersafetyd.rules rules: Enable all the devices expected to work soon 2023-12-08 23:20:24 +09:00
Cargo.lock Bump to 0.1.9 2023-12-17 19:45:19 +09:00
Cargo.toml Bump to 0.1.9 2023-12-17 19:45:19 +09:00
LICENSE LICENSE: Remove year from copyright line 2023-10-30 18:59:41 +09:00
Makefile Install tmpfiles.d snippet to create blackbox 2023-12-12 21:19:55 +10:00
README.md readme: fix typo 2023-12-19 22:11:54 +10:00
speakersafetyd.service speakersafetyd.service: Enable blackbox & conservative threshold 2023-10-29 00:29:23 +09:00
speakersafetyd.tmpfiles Install tmpfiles.d snippet to create blackbox 2023-12-12 21:19:55 +10:00

speakersafetyd - a software Smart Amp implementation

speakersafetyd is a userspace daemon written in Rust that implements an analogue of the Texas Instruments Smart Amp speaker protection model.

Apple Silicon Macs mostly use the Texas Instruments TAS2764 amp chip (codec in ALSA parlance), which provides sense lines for the voltage and current across the voice coil of the connected speaker. These codecs are designed to be used in embedded applications where device firmware takes this information and uses it to protect the speaker from damage. Apple instead implement this as machine-specific plugins to the userspace half of CoreAudio. An increasing number of other vendors in both the desktop and embedded/Android worlds are choosing to go down a similar route, folding this functionality into proprietary driver/userspace blobs that usually also bundle niceties like EQ (we have a solution for this too, see asahi-audio). This puts users at serious risk of permanently destroying their expensive devices if they choose to run custom software, such as Asahi Linux or an Open Source Android ROM.

speakersafetyd is the first (as far as we know) FOSS implementation of a speaker protection model. It solves the problem described above by allowing parties interested in compatible devices to quickly and easily implement a speaker protection model for those devices. Only Apple Silicon Macs under Linux are currently supported, however the model applies to all loudspeakers. The daemon itself should be easy enough to adapt for any device that provides V/ISENSE data in a manner similar to TAS2764.

Dependencies

  • Rust stable
  • alsa-lib
  • An Apple Silicon Mac running Asahi Linux

Some background on Smart Amps

The cheap component speaker elements used in modern devices like Bluetooth speakers, TVs, laptops, etc. are very fragile. In order to eke the highest possible sound quality out of them, they need to be driven hard. This leaves us with a dilemma - how do we drive these speakers hard enoguh to get a loud, high-quality output but not hard enough to destroy them?

A speaker's electromechanical characteristics can be modelled and boiled down to a set of parameters - the Thiele/Small Parameters. These can be used to predict what the speaker will do with certain inputs. When we add measured properties like the time constant of the speaker's voice coil's and magnet's temperature curve, we can accurately model a speaker's temperature for any given voltage/current across the coil. When the speaker is getting too hot, we just reduce the power going to it until it cools down.

This lets us fearlessly drive the speakers as hard as they physically can be without being permanently damaged. This is extremely useful, as without it the output level on these devices would have to be hard limited to a very low level that is known to be safe for the worst possible input. Instead, we can simply duck the output in those cases and allow the speakers to operate at full power where possible.

Many integrated amplifier chips implement this functionality in hardware, as well as additional advanced DSP features like compressors and limiters. Texas Instruments call their implementation "Smart Amp." Integrators need only communicate the parameter set to the chip for the speaker it is connected to, and it does the rest. Many do not however, and instead only provide facilities for measuring the voltage and current across the speaker's voice coil. It is up to the implementer to capture this data and do something with it.

speakersafetyd is (as far as we know) the first and only FOSS implementation of the Smart Amp protection model.