Implement 0014 keypad debouncer, Sparkler LRA filter, standby fixes, and stage a1125 (ampere)
- Extend 0012 standby optimizations with removable-SD-only MMC_CAP_AGGRESSIVE_PM | MMC_CAP2_FULL_PWR_CYCLE in sdhci-msm, proxy mem clock and BIMC XO re-parenting + 0x45000 BIT(2) early-vote clear in qcom_q6v5_mss / gcc-msm8909, 100 MHz opp-99999975 floor across qcom-msm8909.dtsi and all 6 device DTS/DTBs, disabled-by-default Bluetooth with bt_enabled persistence, NM ipv6.method=ignore + standby wlan0/disable_ipv6 muting, and post-park DSDS signal hysteresis - Add ABI-preserving system-core keypad debouncer patch 0014 (drivers/input/input.c key_debounce_ms + pm8941-pwrkey press/release chatter holdoff), replace ignored col-scan-delay-ms with col-scan-delay-us = <0x32> and raise DT debounce intervals across all 6 DTS/DTBs, configure per-target key_debounce_ms at boot and xset r rate 300 25, and add C/DTS verification in scripts/test-keypad-debouncer.py - Isolate Nokia 8000 4G (nokia-sparkler / nokia-leo) media playback from the shared 157 Hz SPK_DRV vibrator channel via dynamic Speaker-only filtering in music.so, files.so, and ringtones.so, explicit RX3/SPK mixer zeroing on Earpiece/Headphones/Bluetooth routes in sxmo_audio.sh and preview plugins, and Sparkler/Leo-only /etc/mpv/mpv.conf provisioning - Register upcoming build a1125 (ampere) in scripts/version.sh, scripts/check-rebuild.sh, AGENTS.md, and CHANGELOG.md, fix --for-rebuild pre-rebuild stale output checks in check-rebuild.sh/test-cover-dt.py, rebuild vmlinuz/DTBs/plugins and all 4 --mkinitfs target images stamped a1125 (ampere), and pin their verified SHA-256 checksums
This commit is contained in:
1 parent
c529463ae3
commit
5d427e39ab
55 files changed
+78935
-77569
No files matched your search
@@ -7,15 +7,90 @@
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <pango/pangoxft.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <clocale>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace bananarchy;
|
||||
|
||||
constexpr const char* kSparklerSpeakerAf =
|
||||
"lavfi=[highpass=f=260:poles=2,highpass=f=260:poles=2,"
|
||||
"bandreject=f=157:width_type=h:w=80]";
|
||||
|
||||
bool isHapticAudioSpeakerDevice() {
|
||||
const char* env = std::getenv("BANANARCHY_HAPTIC_AUDIO_GUARD");
|
||||
if (env && *env == '1') return true;
|
||||
if (env && *env == '0') return false;
|
||||
|
||||
static int cached = -1;
|
||||
if (cached >= 0) return cached == 1;
|
||||
|
||||
int fd = ::open("/sys/firmware/devicetree/base/compatible",
|
||||
O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
char buf[256];
|
||||
ssize_t n = ::read(fd, buf, sizeof(buf) - 1);
|
||||
::close(fd);
|
||||
if (n <= 0) {
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
buf[n] = '\0';
|
||||
const char* p = buf;
|
||||
const char* end = buf + n;
|
||||
while (p < end && *p) {
|
||||
if (std::strcmp(p, "nokia,sparkler") == 0 ||
|
||||
std::strcmp(p, "nokia,leo") == 0) {
|
||||
cached = 1;
|
||||
return true;
|
||||
}
|
||||
p += std::strlen(p) + 1;
|
||||
}
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string normalizeAudioRoute(const std::string& raw) {
|
||||
std::string low = toLowerStr(raw);
|
||||
if (low.find("bluetooth") != std::string::npos ||
|
||||
low.find("bluez") != std::string::npos) {
|
||||
return "Bluetooth";
|
||||
}
|
||||
if (low.find("headphone") != std::string::npos ||
|
||||
low.find("headset") != std::string::npos) {
|
||||
return "Headphones";
|
||||
}
|
||||
if (low.find("earpiece") != std::string::npos) {
|
||||
return "Earpiece";
|
||||
}
|
||||
return "Speaker";
|
||||
}
|
||||
|
||||
std::string readActiveAudioRoute(const std::string& cfgDir) {
|
||||
std::string outDev;
|
||||
{
|
||||
std::ifstream ifs("/tmp/sxmo_audio_out_device");
|
||||
if (ifs && std::getline(ifs, outDev) && !outDev.empty()) {
|
||||
return normalizeAudioRoute(outDev);
|
||||
}
|
||||
}
|
||||
{
|
||||
std::ifstream ifs(cfgDir + "/audio_out_device");
|
||||
if (ifs && std::getline(ifs, outDev) && !outDev.empty()) {
|
||||
return normalizeAudioRoute(outDev);
|
||||
}
|
||||
}
|
||||
return "Speaker";
|
||||
}
|
||||
|
||||
volatile sig_atomic_t gRunning = 1;
|
||||
|
||||
void handleSignal(int) {
|
||||
@@ -829,25 +904,62 @@ int runFilesApp(int argc, char** argv) {
|
||||
int rvol = std::clamp(readRingVolumePct(), 0, 100);
|
||||
int rx3 = (rvol <= 0) ? 0 : (56 + (rvol * 32 + 50) / 100);
|
||||
int hp = (rvol <= 0) ? 0 : (52 + (rvol * 32 + 50) / 100);
|
||||
int ear = (rvol <= 0) ? 0 : (60 + (rvol * 32 + 50) / 100);
|
||||
std::string cfgDir = homeDir + "/.config/sxmo";
|
||||
const char* xdgCfg = std::getenv("XDG_CONFIG_HOME");
|
||||
if (xdgCfg && *xdgCfg) cfgDir = std::string(xdgCfg) + "/sxmo";
|
||||
bool useSparklerAf = isHapticAudioSpeakerDevice() &&
|
||||
readActiveAudioRoute(cfgDir) == "Speaker";
|
||||
std::string afOpt =
|
||||
useSparklerAf ? (std::string("--af=") + kSparklerSpeakerAf) : "";
|
||||
runAsyncCmd("outdev=$(cat /tmp/sxmo_audio_out_device 2>/dev/null); "
|
||||
"if [ \"$outdev\" = \"Bluetooth\" ]; then "
|
||||
" amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-volume @DEFAULT_SINK@ " + std::to_string(rvol) + "% >/dev/null 2>&1; "
|
||||
"elif [ \"$outdev\" = \"Headphones\" ]; then "
|
||||
" amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='EAR_S'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RDAC2 MUX'\" 'RX2' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 'RX1' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 MIX1 INP1'\" 'RX2' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHL'\" 'Switch' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHR'\" 'Switch' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; "
|
||||
" pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; "
|
||||
"elif [ \"$outdev\" = \"Earpiece\" ]; then "
|
||||
" amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHL'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHR'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RDAC2 MUX'\" 'RX1' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 'RX1' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='EAR_S'\" 'Switch' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 Digital Volume'\" " + std::to_string(ear) + " >/dev/null 2>&1; "
|
||||
" pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; "
|
||||
"else "
|
||||
" 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='EAR_S'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHL'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHR'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='SPK DAC Switch'\" 1 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 3 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 'RX1' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 Digital Volume'\" " + std::to_string(rx3) + " >/dev/null 2>&1; "
|
||||
" pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; "
|
||||
@@ -868,13 +980,23 @@ int runFilesApp(int argc, char** argv) {
|
||||
::dup2(devNull, STDERR_FILENO);
|
||||
if (devNull > 2) ::close(devNull);
|
||||
}
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", "--volume=100",
|
||||
"--loop=2", playTarget.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
if (!afOpt.empty()) {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", "--volume=100", afOpt.c_str(),
|
||||
"--loop=2", playTarget.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
} else {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", "--volume=100",
|
||||
"--loop=2", playTarget.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
}
|
||||
::_exit(127);
|
||||
} else if (pid > 0) {
|
||||
ringPreviewPid = pid;
|
||||
|
||||
@@ -77,6 +77,45 @@ struct BrowserItem {
|
||||
};
|
||||
|
||||
constexpr const char* kMpvSockPath = "/tmp/xmusic_mpv.sock";
|
||||
constexpr const char* kSparklerSpeakerAf =
|
||||
"lavfi=[highpass=f=260:poles=2,highpass=f=260:poles=2,"
|
||||
"bandreject=f=157:width_type=h:w=80]";
|
||||
|
||||
bool isHapticAudioSpeakerDevice() {
|
||||
const char* env = std::getenv("BANANARCHY_HAPTIC_AUDIO_GUARD");
|
||||
if (env && *env == '1') return true;
|
||||
if (env && *env == '0') return false;
|
||||
|
||||
static int cached = -1;
|
||||
if (cached >= 0) return cached == 1;
|
||||
|
||||
int fd = ::open("/sys/firmware/devicetree/base/compatible",
|
||||
O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
char buf[256];
|
||||
ssize_t n = ::read(fd, buf, sizeof(buf) - 1);
|
||||
::close(fd);
|
||||
if (n <= 0) {
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
buf[n] = '\0';
|
||||
const char* p = buf;
|
||||
const char* end = buf + n;
|
||||
while (p < end && *p) {
|
||||
if (std::strcmp(p, "nokia,sparkler") == 0 ||
|
||||
std::strcmp(p, "nokia,leo") == 0) {
|
||||
cached = 1;
|
||||
return true;
|
||||
}
|
||||
p += std::strlen(p) + 1;
|
||||
}
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string getExtLower(const std::string& name) {
|
||||
size_t dot = name.rfind('.');
|
||||
@@ -258,6 +297,39 @@ std::string getConfigDirPath() {
|
||||
return getHomePath() + "/.config/sxmo";
|
||||
}
|
||||
|
||||
std::string normalizeAudioRoute(const std::string& raw) {
|
||||
std::string low = toLowerStr(raw);
|
||||
if (low.find("bluetooth") != std::string::npos ||
|
||||
low.find("bluez") != std::string::npos) {
|
||||
return "Bluetooth";
|
||||
}
|
||||
if (low.find("headphone") != std::string::npos ||
|
||||
low.find("headset") != std::string::npos) {
|
||||
return "Headphones";
|
||||
}
|
||||
if (low.find("earpiece") != std::string::npos) {
|
||||
return "Earpiece";
|
||||
}
|
||||
return "Speaker";
|
||||
}
|
||||
|
||||
std::string readActiveAudioRoute() {
|
||||
std::string outDev;
|
||||
{
|
||||
std::ifstream ifs("/tmp/sxmo_audio_out_device");
|
||||
if (ifs && std::getline(ifs, outDev) && !outDev.empty()) {
|
||||
return normalizeAudioRoute(outDev);
|
||||
}
|
||||
}
|
||||
{
|
||||
std::ifstream ifs(getConfigDirPath() + "/audio_out_device");
|
||||
if (ifs && std::getline(ifs, outDev) && !outDev.empty()) {
|
||||
return normalizeAudioRoute(outDev);
|
||||
}
|
||||
}
|
||||
return "Speaker";
|
||||
}
|
||||
|
||||
int readSavedSpeakerVol() {
|
||||
std::string outDev = "Speaker";
|
||||
{
|
||||
@@ -371,6 +443,7 @@ int runMusicApp(int argc, char** argv) {
|
||||
int ipcFd = -1;
|
||||
std::string ipcReadBuf;
|
||||
std::string pendingLoadPath;
|
||||
std::string appliedMpvAf;
|
||||
bool isPlaying = false;
|
||||
bool isPaused = false;
|
||||
double timePosSec = 0.0;
|
||||
@@ -401,12 +474,24 @@ int runMusicApp(int argc, char** argv) {
|
||||
return w == static_cast<ssize_t>(msg.size());
|
||||
};
|
||||
|
||||
auto syncSparklerMpvFilter = [&](bool force = false) {
|
||||
if (!isHapticAudioSpeakerDevice() || ipcFd < 0) return;
|
||||
std::string wantAf =
|
||||
(readActiveAudioRoute() == "Speaker") ? kSparklerSpeakerAf : "";
|
||||
if (!force && wantAf == appliedMpvAf) return;
|
||||
if (sendIpcRaw("{\"command\":[\"set_property\",\"af\",\"" +
|
||||
jsonEscape(wantAf) + "\"]}")) {
|
||||
appliedMpvAf = wantAf;
|
||||
}
|
||||
};
|
||||
|
||||
auto stopMpvDaemon = [&]() {
|
||||
if (ipcFd >= 0) {
|
||||
::close(ipcFd);
|
||||
ipcFd = -1;
|
||||
}
|
||||
ipcReadBuf.clear();
|
||||
appliedMpvAf.clear();
|
||||
if (mpvPid > 0) {
|
||||
::kill(mpvPid, SIGTERM);
|
||||
for (int i = 0; i < 15; ++i) {
|
||||
@@ -430,9 +515,16 @@ int runMusicApp(int argc, char** argv) {
|
||||
::close(ipcFd);
|
||||
ipcFd = -1;
|
||||
}
|
||||
appliedMpvAf.clear();
|
||||
}
|
||||
}
|
||||
if (mpvPid <= 0) {
|
||||
bool wantSpeakerFilter =
|
||||
isHapticAudioSpeakerDevice() && readActiveAudioRoute() == "Speaker";
|
||||
std::string afOpt = wantSpeakerFilter
|
||||
? (std::string("--af=") + kSparklerSpeakerAf)
|
||||
: "";
|
||||
appliedMpvAf = wantSpeakerFilter ? kSparklerSpeakerAf : "";
|
||||
::unlink(kMpvSockPath);
|
||||
pid_t pid = ::fork();
|
||||
if (pid == 0) {
|
||||
@@ -452,11 +544,21 @@ int runMusicApp(int argc, char** argv) {
|
||||
}
|
||||
std::string ipcArg =
|
||||
std::string("--input-ipc-server=") + kMpvSockPath;
|
||||
::execlp("mpv", "mpv", "--no-video", "--no-terminal", "--quiet",
|
||||
"--ao=pipewire,pulse,alsa", "--audio-channels=stereo",
|
||||
"--audio-samplerate=48000", "--idle=yes", "--keep-open=no",
|
||||
"--volume-max=150", "--volume=100", ipcArg.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
if (!afOpt.empty()) {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-video", "--no-terminal",
|
||||
"--quiet", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--idle=yes", "--keep-open=no", "--volume-max=150",
|
||||
"--volume=100", afOpt.c_str(), ipcArg.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
} else {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-video", "--no-terminal",
|
||||
"--quiet", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--idle=yes", "--keep-open=no", "--volume-max=150",
|
||||
"--volume=100", ipcArg.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
}
|
||||
::_exit(127);
|
||||
} else if (pid > 0) {
|
||||
mpvPid = pid;
|
||||
@@ -482,6 +584,7 @@ int runMusicApp(int argc, char** argv) {
|
||||
sendIpcRaw("{\"command\":[\"observe_property\",2,\"duration\"]}");
|
||||
sendIpcRaw("{\"command\":[\"observe_property\",3,\"pause\"]}");
|
||||
sendIpcRaw("{\"command\":[\"observe_property\",4,\"media-title\"]}");
|
||||
syncSparklerMpvFilter(true);
|
||||
if (!pendingLoadPath.empty()) {
|
||||
std::string p = pendingLoadPath;
|
||||
pendingLoadPath.clear();
|
||||
@@ -532,6 +635,7 @@ int runMusicApp(int argc, char** argv) {
|
||||
|
||||
ensureMpvRunning();
|
||||
if (tryConnectIpc()) {
|
||||
syncSparklerMpvFilter(false);
|
||||
sendIpcRaw("{\"command\":[\"loadfile\",\"" + jsonEscape(loadTarget) +
|
||||
"\",\"replace\"]}");
|
||||
sendIpcRaw("{\"command\":[\"set_property\",\"pause\",false]}");
|
||||
@@ -1481,6 +1585,9 @@ int runMusicApp(int argc, char** argv) {
|
||||
if (mpvPid > 0 && ipcFd < 0) {
|
||||
tryConnectIpc();
|
||||
}
|
||||
if (isPlaying && !isPaused && ipcFd >= 0) {
|
||||
syncSparklerMpvFilter(false);
|
||||
}
|
||||
if (drainIpcSocket() && visible) {
|
||||
render();
|
||||
}
|
||||
@@ -1559,6 +1666,8 @@ int runMusicApp(int argc, char** argv) {
|
||||
for (const auto& cmd : readFifoLines(fifoFd)) {
|
||||
if (cmd == "CLOSE") {
|
||||
hideWindow();
|
||||
} else if (cmd == "AUDIO_ROUTE") {
|
||||
syncSparklerMpvFilter(false);
|
||||
} else if (cmd == "RELOAD_THEME") {
|
||||
pt.reload();
|
||||
if (visible) render();
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <pango/pangoxft.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <clocale>
|
||||
|
||||
#ifdef None
|
||||
@@ -23,6 +25,79 @@ namespace {
|
||||
|
||||
using namespace bananarchy;
|
||||
|
||||
constexpr const char* kSparklerSpeakerAf =
|
||||
"lavfi=[highpass=f=260:poles=2,highpass=f=260:poles=2,"
|
||||
"bandreject=f=157:width_type=h:w=80]";
|
||||
|
||||
bool isHapticAudioSpeakerDevice() {
|
||||
const char* env = std::getenv("BANANARCHY_HAPTIC_AUDIO_GUARD");
|
||||
if (env && *env == '1') return true;
|
||||
if (env && *env == '0') return false;
|
||||
|
||||
static int cached = -1;
|
||||
if (cached >= 0) return cached == 1;
|
||||
|
||||
int fd = ::open("/sys/firmware/devicetree/base/compatible",
|
||||
O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
char buf[256];
|
||||
ssize_t n = ::read(fd, buf, sizeof(buf) - 1);
|
||||
::close(fd);
|
||||
if (n <= 0) {
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
buf[n] = '\0';
|
||||
const char* p = buf;
|
||||
const char* end = buf + n;
|
||||
while (p < end && *p) {
|
||||
if (std::strcmp(p, "nokia,sparkler") == 0 ||
|
||||
std::strcmp(p, "nokia,leo") == 0) {
|
||||
cached = 1;
|
||||
return true;
|
||||
}
|
||||
p += std::strlen(p) + 1;
|
||||
}
|
||||
cached = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string normalizeAudioRoute(const std::string& raw) {
|
||||
std::string low = toLowerStr(raw);
|
||||
if (low.find("bluetooth") != std::string::npos ||
|
||||
low.find("bluez") != std::string::npos) {
|
||||
return "Bluetooth";
|
||||
}
|
||||
if (low.find("headphone") != std::string::npos ||
|
||||
low.find("headset") != std::string::npos) {
|
||||
return "Headphones";
|
||||
}
|
||||
if (low.find("earpiece") != std::string::npos) {
|
||||
return "Earpiece";
|
||||
}
|
||||
return "Speaker";
|
||||
}
|
||||
|
||||
std::string readActiveAudioRoute(const std::string& cfgDir) {
|
||||
std::string outDev;
|
||||
{
|
||||
std::ifstream ifs("/tmp/sxmo_audio_out_device");
|
||||
if (ifs && std::getline(ifs, outDev) && !outDev.empty()) {
|
||||
return normalizeAudioRoute(outDev);
|
||||
}
|
||||
}
|
||||
{
|
||||
std::ifstream ifs(cfgDir + "/audio_out_device");
|
||||
if (ifs && std::getline(ifs, outDev) && !outDev.empty()) {
|
||||
return normalizeAudioRoute(outDev);
|
||||
}
|
||||
}
|
||||
return "Speaker";
|
||||
}
|
||||
|
||||
volatile sig_atomic_t gRunning = 1;
|
||||
|
||||
void handleSignal(int) {
|
||||
@@ -501,27 +576,61 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
int rvol = std::clamp(settings.ringVol, 0, 100);
|
||||
int rx3 = (rvol <= 0) ? 0 : (56 + (rvol * 32 + 50) / 100);
|
||||
int hp = (rvol <= 0) ? 0 : (52 + (rvol * 32 + 50) / 100);
|
||||
int ear = (rvol <= 0) ? 0 : (60 + (rvol * 32 + 50) / 100);
|
||||
std::string volArg = "--volume=100";
|
||||
std::string loopArg = singleShot ? "--loop=no" : "--loop=2";
|
||||
bool useSparklerAf = isHapticAudioSpeakerDevice() &&
|
||||
readActiveAudioRoute(getConfigDir()) == "Speaker";
|
||||
std::string afOpt =
|
||||
useSparklerAf ? (std::string("--af=") + kSparklerSpeakerAf) : "";
|
||||
runAsyncCmd("outdev=$(cat /tmp/sxmo_audio_out_device 2>/dev/null); "
|
||||
"if [ \"$outdev\" = \"Bluetooth\" ]; then "
|
||||
" amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-volume @DEFAULT_SINK@ " + std::to_string(rvol) + "% >/dev/null 2>&1; "
|
||||
"elif [ \"$outdev\" = \"Headphones\" ]; then "
|
||||
" amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='EAR_S'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RDAC2 MUX'\" 'RX2' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 'RX1' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 MIX1 INP1'\" 'RX2' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHL'\" 'Switch' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHR'\" 'Switch' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 Digital Volume'\" " + std::to_string(hp) + " >/dev/null 2>&1; "
|
||||
" pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; "
|
||||
"elif [ \"$outdev\" = \"Earpiece\" ]; then "
|
||||
" amixer -c 0 cset \"name='SPK DAC Switch'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHL'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHR'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RDAC2 MUX'\" 'RX1' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 'RX1' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='EAR_S'\" 'Switch' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 Digital Volume'\" " + std::to_string(ear) + " >/dev/null 2>&1; "
|
||||
" pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; "
|
||||
"else "
|
||||
" 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='EAR_S'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHL'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='HPHR'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 MIX1 INP1'\" 'ZERO' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX1 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX2 Digital Volume'\" 0 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='SPK DAC Switch'\" 1 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 3 >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 'RX1' >/dev/null 2>&1; "
|
||||
" amixer -c 0 cset \"name='RX3 Digital Volume'\" " + std::to_string(rx3) + " >/dev/null 2>&1; "
|
||||
" pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1; "
|
||||
" pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1; "
|
||||
@@ -545,19 +654,37 @@ int runRingtonesApp(int argc, char** argv) {
|
||||
if (devNull > 2) ::close(devNull);
|
||||
}
|
||||
if (singleShot) {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", volArg.c_str(),
|
||||
"--end=6", loopArg.c_str(), playTarget.c_str(), nullptr);
|
||||
if (!afOpt.empty()) {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", volArg.c_str(), afOpt.c_str(),
|
||||
"--end=6", loopArg.c_str(), playTarget.c_str(), nullptr);
|
||||
} else {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", volArg.c_str(),
|
||||
"--end=6", loopArg.c_str(), playTarget.c_str(), nullptr);
|
||||
}
|
||||
} else {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", volArg.c_str(),
|
||||
loopArg.c_str(), playTarget.c_str(), nullptr);
|
||||
if (!afOpt.empty()) {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", volArg.c_str(), afOpt.c_str(),
|
||||
loopArg.c_str(), playTarget.c_str(), nullptr);
|
||||
} else {
|
||||
::execlp("mpv", "mpv", "--no-config", "--no-terminal",
|
||||
"--no-resume-playback", "--quiet", "--vo=null",
|
||||
"--no-video", "--ao=pipewire,pulse,alsa",
|
||||
"--audio-channels=stereo", "--audio-samplerate=48000",
|
||||
"--volume-max=150", volArg.c_str(),
|
||||
loopArg.c_str(), playTarget.c_str(), nullptr);
|
||||
}
|
||||
}
|
||||
::_exit(127);
|
||||
} else if (pid > 0) {
|
||||
|
||||
Reference in new issue
Block a user