Implement headphone autodetection, earpiece routing, and linear volume controls
- Fix msm8916-wcd ALSA UCM2 configs (Earpiece.conf, Speaker.conf, Headphones.conf, PrimaryMic.conf, HeadsetMic.conf) so Speaker, Earpiece, and Headphones outputs and Mic1/Headset inputs are always available and mutually exclusive without invalid mixer controls - Add event-driven wired headphone/headset jack detection and automatic audio routing in sxmo_soundmonitor.sh via evtest on the msm8916 Headset Jack input device - Make Earpiece, Speaker, and Headphones first-class routable output devices across sxmo_audio.sh, sxmo_modemaudio.sh, xdrawer, dmenu, and callscreen - Make volume controls strictly linear across all channels by keeping PipeWire software gain at unity (100%) when unmuted and linearly mapping 0-100% to hardware digital volume registers (RX3 for Speaker, RX1 for Earpiece, RX1+RX2 for Headphones, TX1+ADC for Microphone)
This commit is contained in:
1 parent
e42eb573ed
commit
370f8b085c
33 files changed
+1351
-488
No files matched your search
@@ -327,6 +327,7 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
::kill(previewPid, SIGTERM);
|
||||
::waitpid(previewPid, nullptr, WNOHANG);
|
||||
previewPid = -1;
|
||||
runAsyncCmd("sxmo_audio.sh device apply >/dev/null 2>&1");
|
||||
}
|
||||
previewPath.clear();
|
||||
};
|
||||
@@ -354,9 +355,8 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
stopPreview();
|
||||
settings = loadRingSettings();
|
||||
int rvol = std::clamp(settings.ringVol, 0, 100);
|
||||
int rx3 = (rvol <= 0) ? 0 : (60 + rvol * 24 / 100);
|
||||
int mpvVol = rvol;
|
||||
std::string volArg = "--volume=" + std::to_string(mpvVol);
|
||||
int rx3 = (rvol <= 0) ? 0 : (56 + (rvol * 32 + 50) / 100);
|
||||
std::string volArg = "--volume=100";
|
||||
runAsyncCmd("amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; "
|
||||
"amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 0 >/dev/null 2>&1; "
|
||||
"amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; "
|
||||
@@ -365,12 +365,10 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
"amixer -c 0 cset \"name='RX3 Digital Volume'\" " +
|
||||
std::to_string(rx3) + " >/dev/null 2>&1; "
|
||||
"wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; "
|
||||
"wpctl set-volume @DEFAULT_AUDIO_SINK@ " +
|
||||
std::to_string(rvol) + "% >/dev/null 2>&1; "
|
||||
"wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1; "
|
||||
"(sleep 0.25; amixer -c 0 cset \"name='RX3 Digital Volume'\" " +
|
||||
std::to_string(rx3) + " >/dev/null 2>&1; "
|
||||
"wpctl set-volume @DEFAULT_AUDIO_SINK@ " +
|
||||
std::to_string(rvol) + "% >/dev/null 2>&1) &");
|
||||
"wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1) &");
|
||||
pid_t pid = ::fork();
|
||||
if (pid == 0) {
|
||||
std::string runtimeDir = "/run/user/" + std::to_string(::getuid());
|
||||
@@ -623,11 +621,10 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
settings.ringVol = std::clamp(settings.ringVol + delta * 5, 0, 100);
|
||||
saveRingSettings(settings);
|
||||
if (previewPid > 0) {
|
||||
int rx3 = (settings.ringVol <= 0) ? 0 : (60 + settings.ringVol * 34 / 100);
|
||||
int rx3 = (settings.ringVol <= 0) ? 0 : (56 + (settings.ringVol * 32 + 50) / 100);
|
||||
runAsyncCmd("amixer -c 0 cset \"name='RX3 Digital Volume'\" " +
|
||||
std::to_string(rx3) + " >/dev/null 2>&1; "
|
||||
"wpctl set-volume @DEFAULT_AUDIO_SINK@ " +
|
||||
std::to_string(settings.ringVol) + "% >/dev/null 2>&1");
|
||||
"wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1");
|
||||
}
|
||||
setBanner("Ring volume: " + std::to_string(settings.ringVol) + "%");
|
||||
} else if (settingsRow == 2) {
|
||||
|
||||
Reference in new issue
Block a user