Optimize battery life across DTB pinctrl, schedutil, SDHCI, and background daemons
This commit is contained in:
1 parent
9c28fa1e4c
commit
0a24bf8aff
20 files changed
+57
-27
No files matched your search
Binary file not shown.
@@ -957,7 +957,7 @@
|
|||||||
pins = "gpio38";
|
pins = "gpio38";
|
||||||
function = "gpio";
|
function = "gpio";
|
||||||
drive-strength = <0x02>;
|
drive-strength = <0x02>;
|
||||||
bias-disable;
|
bias-pull-up;
|
||||||
phandle = <0x91>;
|
phandle = <0x91>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -957,7 +957,7 @@
|
|||||||
pins = "gpio38";
|
pins = "gpio38";
|
||||||
function = "gpio";
|
function = "gpio";
|
||||||
drive-strength = <0x02>;
|
drive-strength = <0x02>;
|
||||||
bias-disable;
|
bias-pull-up;
|
||||||
phandle = <0x91>;
|
phandle = <0x91>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -961,7 +961,7 @@
|
|||||||
pins = "gpio38";
|
pins = "gpio38";
|
||||||
function = "gpio";
|
function = "gpio";
|
||||||
drive-strength = <0x02>;
|
drive-strength = <0x02>;
|
||||||
bias-disable;
|
bias-pull-up;
|
||||||
phandle = <0x91>;
|
phandle = <0x91>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -961,7 +961,7 @@
|
|||||||
pins = "gpio38";
|
pins = "gpio38";
|
||||||
function = "gpio";
|
function = "gpio";
|
||||||
drive-strength = <0x02>;
|
drive-strength = <0x02>;
|
||||||
bias-disable;
|
bias-pull-up;
|
||||||
phandle = <0x91>;
|
phandle = <0x91>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -957,7 +957,7 @@
|
|||||||
pins = "gpio38";
|
pins = "gpio38";
|
||||||
function = "gpio";
|
function = "gpio";
|
||||||
drive-strength = <0x02>;
|
drive-strength = <0x02>;
|
||||||
bias-disable;
|
bias-pull-up;
|
||||||
phandle = <0x91>;
|
phandle = <0x91>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,29 @@ if [ -w /sys/class/graphics/fbcon/cursor_blink ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Reduce periodic VM stat shepherd and dirty writeback timer wakeups
|
# Reduce periodic VM stat shepherd and dirty writeback timer wakeups
|
||||||
{ echo 10 > /proc/sys/vm/stat_interval; } 2>/dev/null || true
|
{ echo 30 > /proc/sys/vm/stat_interval; } 2>/dev/null || true
|
||||||
{ echo 1500 > /proc/sys/vm/dirty_writeback_centisecs; } 2>/dev/null || true
|
{ echo 6000 > /proc/sys/vm/dirty_writeback_centisecs; } 2>/dev/null || true
|
||||||
{ echo 3000 > /proc/sys/vm/dirty_expire_centisecs; } 2>/dev/null || true
|
{ echo 6000 > /proc/sys/vm/dirty_expire_centisecs; } 2>/dev/null || true
|
||||||
|
{ echo 0 > /proc/sys/kernel/nmi_watchdog; } 2>/dev/null || true
|
||||||
{ echo "1 4 1 4" > /proc/sys/kernel/printk; } 2>/dev/null || true
|
{ echo "1 4 1 4" > /proc/sys/kernel/printk; } 2>/dev/null || true
|
||||||
|
|
||||||
# Automount microSD card if present at boot
|
# Tune CPUFreq schedutil governor for rapid downclocking to 200 MHz at idle
|
||||||
|
# (qcom-cpufreq reports transition_latency=UINT_MAX, causing schedutil rate_limit_us
|
||||||
|
# to default to 6442450 us = 6.44s without this override)
|
||||||
|
for gov_dir in /sys/devices/system/cpu/cpufreq/schedutil /sys/devices/system/cpu/cpufreq/policy*/schedutil /sys/devices/system/cpu/cpu*/cpufreq/schedutil; do
|
||||||
|
if [ -d "$gov_dir" ]; then
|
||||||
|
{ echo 2000 > "$gov_dir/rate_limit_us"; } 2>/dev/null || true
|
||||||
|
{ echo 20000 > "$gov_dir/up_rate_limit_us"; } 2>/dev/null || true
|
||||||
|
{ echo 1000 > "$gov_dir/down_rate_limit_us"; } 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Enable IEEE 802.11 power save on WCN3620 wlan0
|
||||||
|
if command -v iw >/dev/null 2>&1; then
|
||||||
|
iw dev wlan0 set power_save on 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Automount microSD card if present at boot (unbinds 7864900.sdhci when slot is empty)
|
||||||
if [ -x /usr/bin/sxmo_sdcard.sh ]; then
|
if [ -x /usr/bin/sxmo_sdcard.sh ]; then
|
||||||
/usr/bin/sxmo_sdcard.sh automount boot >/dev/null 2>&1 &
|
/usr/bin/sxmo_sdcard.sh automount boot >/dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -64,17 +64,20 @@ mainloop() {
|
|||||||
|
|
||||||
# Monitor Secondary GW SIM calls and SMS in Dual-SIM Dual Standby (DSDS)
|
# Monitor Secondary GW SIM calls and SMS in Dual-SIM Dual Standby (DSDS)
|
||||||
(
|
(
|
||||||
|
sleep 4
|
||||||
|
if [ ! -f /tmp/sxmo_dsds_active ]; then
|
||||||
|
doas -n /usr/libexec/msm-modem-uim-selection status >/dev/null 2>&1 || /usr/libexec/msm-modem-uim-selection status >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
while : ; do
|
while : ; do
|
||||||
uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)"
|
if [ "$(cat /tmp/sxmo_dsds_active 2>/dev/null || echo 0)" = "1" ]; then
|
||||||
if printf "%s\n" "$uim_st" | grep -q "^DUAL_SIM_ACTIVE=1$"; then
|
if doas -n true 2>/dev/null; then
|
||||||
if doas -n /usr/libexec/msm-modem-uim-selection status >/dev/null 2>&1; then
|
|
||||||
doas -n /usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
doas -n /usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
||||||
else
|
else
|
||||||
/usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
/usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
sleep 5
|
sleep 10
|
||||||
else
|
else
|
||||||
sleep 30
|
sleep 120
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
) &
|
) &
|
||||||
|
|||||||
@@ -594,10 +594,12 @@ provision_slot() {
|
|||||||
echo "Slot $other_slot already bound to secondary-gw-provisioning ($other_app_state)."
|
echo "Slot $other_slot already bound to secondary-gw-provisioning ($other_app_state)."
|
||||||
fi
|
fi
|
||||||
ensure_dsds_nas_registration
|
ensure_dsds_nas_registration
|
||||||
|
printf '1\n' > /tmp/sxmo_dsds_active 2>/dev/null || true
|
||||||
else
|
else
|
||||||
if [ "${SECONDARY_GW_SLOT:-0}" != "0" ]; then
|
if [ "${SECONDARY_GW_SLOT:-0}" != "0" ]; then
|
||||||
$QMICLI_MODEM --uim-change-provisioning-session='activate=no,session-type=secondary-gw-provisioning' >/dev/null 2>&1 || true
|
$QMICLI_MODEM --uim-change-provisioning-session='activate=no,session-type=secondary-gw-provisioning' >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
|
printf '0\n' > /tmp/sxmo_dsds_active 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -788,6 +790,11 @@ s2_state = sys.argv[4] if len(sys.argv) > 4 else "absent"
|
|||||||
|
|
||||||
dual_active = 1 if (s1_state == "present" and s2_state == "present" and prim_slot in (1, 2) and sec_slot in (1, 2)) else 0
|
dual_active = 1 if (s1_state == "present" and s2_state == "present" and prim_slot in (1, 2) and sec_slot in (1, 2)) else 0
|
||||||
print(f"DUAL_SIM_ACTIVE={dual_active}")
|
print(f"DUAL_SIM_ACTIVE={dual_active}")
|
||||||
|
try:
|
||||||
|
with open("/tmp/sxmo_dsds_active", "w") as df:
|
||||||
|
df.write(f"{dual_active}\n")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
AF_QIPCRTR = 42
|
AF_QIPCRTR = 42
|
||||||
QRTR_PORT_CTRL = 0xfffffffe
|
QRTR_PORT_CTRL = 0xfffffffe
|
||||||
@@ -1116,6 +1123,10 @@ PY
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
imei)
|
imei)
|
||||||
|
if [ -f /tmp/bananarchy_duress_mode ] && [ -s /tmp/bananarchy_duress_imei ]; then
|
||||||
|
cat /tmp/bananarchy_duress_imei
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
imei1=""
|
imei1=""
|
||||||
imei2=""
|
imei2=""
|
||||||
imei_sv=""
|
imei_sv=""
|
||||||
@@ -2785,7 +2796,7 @@ while True:
|
|||||||
elif multipart_buf:
|
elif multipart_buf:
|
||||||
poll_timeout = 2.0
|
poll_timeout = 2.0
|
||||||
else:
|
else:
|
||||||
poll_timeout = 60.0
|
poll_timeout = 300.0
|
||||||
r, _, _ = select.select([ws, vs], [], [], poll_timeout)
|
r, _, _ = select.select([ws, vs], [], [], poll_timeout)
|
||||||
got_voice_ind = False
|
got_voice_ind = False
|
||||||
events = []
|
events = []
|
||||||
@@ -2846,7 +2857,7 @@ while True:
|
|||||||
v_txn = (v_txn % 60000) + 1
|
v_txn = (v_txn % 60000) + 1
|
||||||
sync_sub1_calls(parse_call_info(full_tlvs), sec_slot)
|
sync_sub1_calls(parse_call_info(full_tlvs), sec_slot)
|
||||||
|
|
||||||
if time.time() - last_poll >= 120.0:
|
if not os.path.exists("/tmp/bananarchy_screen_locked") and time.time() - last_poll >= 600.0:
|
||||||
w_txn = poll_stored_sms(ws, wms_addr, w_txn, sec_slot)
|
w_txn = poll_stored_sms(ws, wms_addr, w_txn, sec_slot)
|
||||||
last_poll = time.time()
|
last_poll = time.time()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -534,7 +534,8 @@ case "$1" in
|
|||||||
periodics) # 60 s loop
|
periodics) # 60 s loop
|
||||||
cur_st=""
|
cur_st=""
|
||||||
[ -r "$SXMO_STATE" ] && { read -r cur_st < "$SXMO_STATE" 2>/dev/null || true; }
|
[ -r "$SXMO_STATE" ] && { read -r cur_st < "$SXMO_STATE" 2>/dev/null || true; }
|
||||||
if [ "$cur_st" = "screenoff" ]; then
|
cur_bl="$(cat /sys/class/backlight/backlight/brightness 2>/dev/null || echo 1)"
|
||||||
|
if [ "$cur_st" = "screenoff" ] || [ "${cur_bl:-1}" -le 0 ] 2>/dev/null || [ -f /tmp/bananarchy_screen_locked ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
set_time
|
set_time
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <condition_variable>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -249,7 +250,7 @@ std::string getWaypointsPath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string getOsmTileCacheDir() {
|
std::string getOsmTileCacheDir() {
|
||||||
if (::access("/media/sdcard", W_OK) == 0) {
|
if (!isDuressMode() && ::access("/media/sdcard", W_OK) == 0) {
|
||||||
std::string sdDir = "/media/sdcard/osm_tiles";
|
std::string sdDir = "/media/sdcard/osm_tiles";
|
||||||
::mkdir(sdDir.c_str(), 0755);
|
::mkdir(sdDir.c_str(), 0755);
|
||||||
return sdDir;
|
return sdDir;
|
||||||
@@ -442,6 +443,7 @@ class OsmTileCache {
|
|||||||
|
|
||||||
~OsmTileCache() {
|
~OsmTileCache() {
|
||||||
stopWorker_.store(true);
|
stopWorker_.store(true);
|
||||||
|
cv_.notify_all();
|
||||||
if (worker_.joinable()) worker_.join();
|
if (worker_.joinable()) worker_.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,6 +487,7 @@ class OsmTileCache {
|
|||||||
cache_[key] = std::move(pending);
|
cache_[key] = std::move(pending);
|
||||||
if (queue_.size() < 16) {
|
if (queue_.size() < 16) {
|
||||||
queue_.push_back({z, x, y, key, diskPath});
|
queue_.push_back({z, x, y, key, diskPath});
|
||||||
|
cv_.notify_one();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -505,18 +508,12 @@ class OsmTileCache {
|
|||||||
void workerLoop() {
|
void workerLoop() {
|
||||||
while (!stopWorker_.load()) {
|
while (!stopWorker_.load()) {
|
||||||
TileReq req;
|
TileReq req;
|
||||||
bool hasReq = false;
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(mtx_);
|
std::unique_lock<std::mutex> lk(mtx_);
|
||||||
if (!queue_.empty()) {
|
cv_.wait(lk, [this]() { return stopWorker_.load() || !queue_.empty(); });
|
||||||
|
if (stopWorker_.load()) break;
|
||||||
req = queue_.back();
|
req = queue_.back();
|
||||||
queue_.pop_back();
|
queue_.pop_back();
|
||||||
hasReq = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hasReq) {
|
|
||||||
::usleep(120000);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string url = "https://tile.openstreetmap.org/" + std::to_string(req.z) +
|
std::string url = "https://tile.openstreetmap.org/" + std::to_string(req.z) +
|
||||||
@@ -544,6 +541,7 @@ class OsmTileCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::mutex mtx_;
|
std::mutex mtx_;
|
||||||
|
std::condition_variable cv_;
|
||||||
std::unordered_map<std::string, TilePixels> cache_;
|
std::unordered_map<std::string, TilePixels> cache_;
|
||||||
std::vector<TileReq> queue_;
|
std::vector<TileReq> queue_;
|
||||||
std::atomic<bool> stopWorker_{false};
|
std::atomic<bool> stopWorker_{false};
|
||||||
|
|||||||
Reference in new issue
Block a user