diff --git a/kernel/configs/geminux-mt6797x.config b/kernel/configs/geminux-mt6797x.config
index 3a0d4f0..125554a 100644
--- a/kernel/configs/geminux-mt6797x.config
+++ b/kernel/configs/geminux-mt6797x.config
@@ -238,7 +238,8 @@ CONFIG_TYPEC=m
# CONFIG_PCS_XPCS is not set
# CONFIG_PTP_1588_CLOCK is not set
CONFIG_CRYPTO_USER_API=y
-# CONFIG_CRYPTO_USER_API_RNG is not set
+CONFIG_CRYPTO_USER_API_RNG=m
+CONFIG_CRYPTO_USER_API_AEAD=m
# CONFIG_CRYPTO_USER is not set
# CONFIG_IP_PNP is not set
# CONFIG_IP_MULTICAST is not set
@@ -715,7 +716,14 @@ CONFIG_BT_MT6797=m
# CONFIG_BT_BNEP is not set
# CONFIG_BT_HIDP is not set
CONFIG_BT_LEDS=y
-# CONFIG_BT_HCIBTUSB is not set
+CONFIG_BT_INTEL=m
+CONFIG_BT_BCM=m
+CONFIG_BT_RTL=m
+CONFIG_BT_MTK=m
+CONFIG_BT_HCIBTUSB=m
+CONFIG_BT_HCIBTUSB_BCM=y
+CONFIG_BT_HCIBTUSB_MTK=y
+CONFIG_BT_HCIBTUSB_RTL=y
# CONFIG_BT_HCIBTSDIO is not set
# CONFIG_BT_HCIUART is not set
# CONFIG_BT_HCIVHCI is not set
@@ -886,6 +894,13 @@ CONFIG_I2C_CHARDEV=m
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=m
CONFIG_BT_HIDP=m
+CONFIG_INPUT_UINPUT=m
+CONFIG_HIDRAW=y
+CONFIG_UHID=m
+CONFIG_HID_APPLE=m
+CONFIG_HID_LOGITECH=m
+CONFIG_HID_LOGITECH_HIDPP=m
+CONFIG_HID_MICROSOFT=m
# Namespaces, cgroups, seccomp, watchdog
CONFIG_NAMESPACES=y
diff --git a/overlay/rootfs/etc/NetworkManager/conf.d/20-geminux-wifi.conf b/overlay/rootfs/etc/NetworkManager/conf.d/20-geminux-wifi.conf
new file mode 100644
index 0000000..043d7d8
--- /dev/null
+++ b/overlay/rootfs/etc/NetworkManager/conf.d/20-geminux-wifi.conf
@@ -0,0 +1,8 @@
+[device]
+# mt6797 mac80211 requires vif->addr == perm_addr when adding/opening wlan0.
+wifi.scan-rand-mac-address = no
+
+[connection]
+wifi.cloned-mac-address = permanent
+# mt6797 mac80211 requires RSN capabilities without MFPC/MFPR (802.11w disabled).
+wifi-sec.pmf = 1
diff --git a/overlay/rootfs/etc/bluetooth/input.conf b/overlay/rootfs/etc/bluetooth/input.conf
new file mode 100644
index 0000000..35121f7
--- /dev/null
+++ b/overlay/rootfs/etc/bluetooth/input.conf
@@ -0,0 +1,5 @@
+[General]
+UserspaceHID = true
+ClassicBondedOnly = false
+LEAutoSecurity = true
+IdleTimeout = 0
diff --git a/overlay/rootfs/etc/bluetooth/main.conf b/overlay/rootfs/etc/bluetooth/main.conf
index bed42db..594f71d 100644
--- a/overlay/rootfs/etc/bluetooth/main.conf
+++ b/overlay/rootfs/etc/bluetooth/main.conf
@@ -1,6 +1,11 @@
[General]
Name = Geminux-GeminiPDA
-FastConnectable = false
+ControllerMode = dual
+FastConnectable = true
+Experimental = true
+KernelExperimental = true
+JustWorksRepairing = always
[Policy]
-AutoEnable = false
+AutoEnable = true
+ReconnectAttempts = 7
diff --git a/overlay/rootfs/etc/conf.d/networkmanager b/overlay/rootfs/etc/conf.d/networkmanager
new file mode 100644
index 0000000..1476aad
--- /dev/null
+++ b/overlay/rootfs/etc/conf.d/networkmanager
@@ -0,0 +1 @@
+rc_need="polkit"
diff --git a/overlay/rootfs/etc/dbus-1/system.d/20-geminux-bluetooth.conf b/overlay/rootfs/etc/dbus-1/system.d/20-geminux-bluetooth.conf
new file mode 100644
index 0000000..428689d
--- /dev/null
+++ b/overlay/rootfs/etc/dbus-1/system.d/20-geminux-bluetooth.conf
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/overlay/rootfs/etc/default/useradd b/overlay/rootfs/etc/default/useradd
new file mode 100644
index 0000000..835e1dc
--- /dev/null
+++ b/overlay/rootfs/etc/default/useradd
@@ -0,0 +1 @@
+SHELL=/bin/bash
diff --git a/overlay/rootfs/etc/init.d/geminux-hwinit b/overlay/rootfs/etc/init.d/geminux-hwinit
index 02d67ba..1a0af23 100755
--- a/overlay/rootfs/etc/init.d/geminux-hwinit
+++ b/overlay/rootfs/etc/init.d/geminux-hwinit
@@ -7,7 +7,7 @@ LOG_FILE="/var/log/geminux-hwinit.log"
depend() {
need localmount udev
after geminux-usb-gadget sshd dbus elogind
- before tinydm networkmanager wpa_supplicant modemmanager geminux-leds geminux-powerd geminux-ccci
+ before tinydm networkmanager wpa_supplicant modemmanager bluetooth geminux-leds geminux-powerd geminux-ccci
}
log_msg() {
@@ -57,7 +57,28 @@ start() {
fi
if [ "${GEMINUX_ENABLE_CONSYS:-yes}" = "yes" ]; then
- load_group consys mt6797-consys mt6797-wlan-core mac btmt6797
+ if command -v iw >/dev/null 2>&1; then
+ iw reg reload >> "$LOG_FILE" 2>&1 || true
+ fi
+ if [ -x /usr/sbin/geminux-wifi-nvram ]; then
+ if /usr/sbin/geminux-wifi-nvram >> "$LOG_FILE" 2>&1; then
+ log_msg " geminux-wifi-nvram: OK"
+ else
+ log_msg " geminux-wifi-nvram: non-fatal"
+ fi
+ fi
+ load_group consys mt6797-consys mt6797-wlan-core mac
+ w_i=0
+ while [ "$w_i" -lt 60 ] && [ ! -d /sys/class/net/wlan0 ]; do
+ usleep 100000 2>/dev/null || break
+ w_i=$((w_i + 1))
+ done
+ if [ -d /sys/class/net/wlan0 ]; then
+ log_msg " consys wlan0: ready"
+ else
+ log_msg " consys wlan0: not present after wait"
+ fi
+ load_group consys_bt algif_rng algif_aead uhid uinput rfcomm bnep hidp btmt6797
fi
if [ "${GEMINUX_ENABLE_CCCI:-yes}" = "yes" ]; then
diff --git a/overlay/rootfs/etc/pipewire/pipewire.conf.d/10-geminux-power.conf b/overlay/rootfs/etc/pipewire/pipewire.conf.d/10-geminux-power.conf
index 182f59b..8a20943 100644
--- a/overlay/rootfs/etc/pipewire/pipewire.conf.d/10-geminux-power.conf
+++ b/overlay/rootfs/etc/pipewire/pipewire.conf.d/10-geminux-power.conf
@@ -1,7 +1,7 @@
# Larger PipeWire quantum buffers reduce audio DSP/CPU wakeups for battery life.
context.properties = {
default.clock.rate = 48000
- default.clock.min-quantum = 1024
+ default.clock.min-quantum = 128
default.clock.quantum = 2048
default.clock.max-quantum = 4096
}
diff --git a/overlay/rootfs/etc/polkit-1/rules.d/10-geminux.rules b/overlay/rootfs/etc/polkit-1/rules.d/10-geminux.rules
new file mode 100644
index 0000000..a0243f1
--- /dev/null
+++ b/overlay/rootfs/etc/polkit-1/rules.d/10-geminux.rules
@@ -0,0 +1,10 @@
+// Allow local Geminux desktop users (wheel/netdev/plugdev/lp) to control NetworkManager, ModemManager, and BlueZ without a Polkit agent.
+polkit.addRule(function(action, subject) {
+ if ((action.id.indexOf("org.freedesktop.NetworkManager.") === 0 ||
+ action.id.indexOf("org.freedesktop.ModemManager1.") === 0 ||
+ action.id.indexOf("org.bluez.") === 0) &&
+ (subject.isInGroup("wheel") || subject.isInGroup("netdev") ||
+ subject.isInGroup("plugdev") || subject.isInGroup("lp"))) {
+ return polkit.Result.YES;
+ }
+});
diff --git a/overlay/rootfs/etc/profile.d/10-geminux-env.sh b/overlay/rootfs/etc/profile.d/10-geminux-env.sh
index 023244f..85630ee 100644
--- a/overlay/rootfs/etc/profile.d/10-geminux-env.sh
+++ b/overlay/rootfs/etc/profile.d/10-geminux-env.sh
@@ -2,6 +2,7 @@
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
+export SHELL=/bin/bash
export TERMINAL=st
export EDITOR=nano
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
diff --git a/overlay/rootfs/etc/shells b/overlay/rootfs/etc/shells
new file mode 100644
index 0000000..9144403
--- /dev/null
+++ b/overlay/rootfs/etc/shells
@@ -0,0 +1,5 @@
+# valid login shells
+/bin/sh
+/bin/ash
+/bin/bash
+/usr/bin/bash
diff --git a/overlay/rootfs/etc/skel/.bash_profile b/overlay/rootfs/etc/skel/.bash_profile
new file mode 100644
index 0000000..aad5406
--- /dev/null
+++ b/overlay/rootfs/etc/skel/.bash_profile
@@ -0,0 +1,7 @@
+# Geminux bash login shell profile
+if [ -r "$HOME/.profile" ]; then
+ . "$HOME/.profile"
+fi
+if [ -r "$HOME/.bashrc" ]; then
+ . "$HOME/.bashrc"
+fi
diff --git a/overlay/rootfs/etc/udev/rules.d/90-geminux-hardware.rules b/overlay/rootfs/etc/udev/rules.d/90-geminux-hardware.rules
index 0ee7605..7364e26 100644
--- a/overlay/rootfs/etc/udev/rules.d/90-geminux-hardware.rules
+++ b/overlay/rootfs/etc/udev/rules.d/90-geminux-hardware.rules
@@ -4,6 +4,10 @@ SUBSYSTEM=="leds", RUN+="/bin/chgrp wheel /sys%p/brightness", RUN+="/bin/chmod 0
KERNEL=="ccci_*", GROUP="dialout", MODE="0660"
KERNEL=="ccci_monitor", SYMLINK+="ccci_md_ctl"
SUBSYSTEM=="video4linux", GROUP="video", MODE="0660"
+KERNEL=="rfkill", GROUP="plugdev", MODE="0664"
+KERNEL=="uhid", GROUP="input", MODE="0660"
+KERNEL=="uinput", GROUP="input", MODE="0660"
+SUBSYSTEM=="hidraw", GROUP="input", MODE="0660"
# Enable USB autosuspend on non-HID peripherals
ACTION=="add", SUBSYSTEM=="usb", ENV{ID_INPUT}=="", TEST=="power/control", ATTR{power/control}="auto"
diff --git a/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-geminux-suspend.conf b/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-geminux-suspend.conf
index 0a95560..1385858 100644
--- a/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-geminux-suspend.conf
+++ b/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-geminux-suspend.conf
@@ -1,5 +1,22 @@
-# Suspend idle ALSA and BlueZ audio nodes after 3 seconds to gate audio clocks.
+# Suspend idle ALSA and BlueZ audio nodes after 3 seconds and prioritize MT6351 HiFi audio.
monitor.alsa.rules = [
+ {
+ matches = [ { device.name = "alsa_card.platform-sound" } ]
+ actions = {
+ update-props = {
+ device.description = "Gemini Built-in Audio"
+ }
+ }
+ }
+ {
+ matches = [ { device.name = "alsa_card.platform-bluetooth-voice-sound" } ]
+ actions = {
+ update-props = {
+ device.description = "MT6797 BT-CVSD Voice Bridge"
+ device.profile = "off"
+ }
+ }
+ }
{
matches = [ { node.name = "~alsa_.*" } ]
actions = {
diff --git a/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/51-geminux-bluetooth.conf b/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/51-geminux-bluetooth.conf
new file mode 100644
index 0000000..467cf6e
--- /dev/null
+++ b/overlay/rootfs/etc/wireplumber/wireplumber.conf.d/51-geminux-bluetooth.conf
@@ -0,0 +1,9 @@
+# Enable BlueZ 5 high-quality codecs (SBC-XQ, AAC, LDAC, aptX), HSP/HFP mSBC duplex headset,
+# BLE Audio (LC3 BAP), and hardware volume control in WirePlumber.
+monitor.bluez.properties = {
+ bluez5.enable-sbc-xq = true
+ bluez5.enable-msbc = true
+ bluez5.enable-hw-volume = true
+ bluez5.hfphsp-backend = "native"
+ bluez5.roles = [ a2dp_sink a2dp_source bap_sink bap_source hsp_hs hsp_ag hfp_hf hfp_ag ]
+}
diff --git a/overlay/rootfs/usr/bin/geminux-launcher b/overlay/rootfs/usr/bin/geminux-launcher
index b93b57f..4e1f2e8 100755
--- a/overlay/rootfs/usr/bin/geminux-launcher
+++ b/overlay/rootfs/usr/bin/geminux-launcher
@@ -24,6 +24,7 @@ LAUNCHER_LIST="
SMS Messages|geminux-sms
Contacts|geminux-contacts
Network & Radios|geminux-net
+ Sound & Mixer|geminux-audio
Camera|geminux-camera
Control Center|geminux-control
Themes|geminux-themes
diff --git a/overlay/rootfs/usr/share/alsa/ucm2/MediaTek/mt6797-gemini/HiFi.conf b/overlay/rootfs/usr/share/alsa/ucm2/MediaTek/mt6797-gemini/HiFi.conf
index 4c1ad5c..aca5428 100644
--- a/overlay/rootfs/usr/share/alsa/ucm2/MediaTek/mt6797-gemini/HiFi.conf
+++ b/overlay/rootfs/usr/share/alsa/ucm2/MediaTek/mt6797-gemini/HiFi.conf
@@ -2,76 +2,129 @@ Syntax 4
SectionVerb {
EnableSequence [
- cset "name='Audio_Amp_R_Switch' On"
- cset "name='Audio_Amp_L_Switch' On"
- cset "name='Speaker_Amp_Switch' On"
- cset "name='Audio_ADC_1_Switch' On"
- cset "name='Audio_ADC_2_Switch' On"
+ cset "name='ADDA_DL_CH1 DL1_CH1' on"
+ cset "name='ADDA_DL_CH2 DL1_CH2' on"
+ cset "name='DAC In Mux' 'Normal Path'"
+ cset "name='HPL Mux' 'Audio Playback'"
+ cset "name='HPR Mux' 'Audio Playback'"
+ cset "name='Headphone Volume' 14,14"
+ cset "name='UL1_CH1 ADDA_UL_CH1' on"
+ cset "name='UL1_CH2 ADDA_UL_CH2' on"
+ cset "name='AIF Out Mux' 'Normal Path'"
+ cset "name='ADC L Mux' 'Left Preamplifier'"
+ cset "name='ADC R Mux' 'Right Preamplifier'"
+ cset "name='PGA Volume' 3,3"
]
DisableSequence [
- cset "name='Speaker_Amp_Switch' Off"
+ cset "name='Speaker Switch' off"
+ cset "name='Headphone Switch' off"
+ cset "name='Main Mic Switch' off"
+ cset "name='Back Mic Switch' off"
+ cset "name='Headset Mic Switch' off"
+ cset "name='HPL Mux' 'Open'"
+ cset "name='HPR Mux' 'Open'"
+ cset "name='ADC L Mux' 'Idle'"
+ cset "name='ADC R Mux' 'Idle'"
+ cset "name='ADDA_DL_CH1 DL1_CH1' off"
+ cset "name='ADDA_DL_CH2 DL1_CH2' off"
+ cset "name='UL1_CH1 ADDA_UL_CH1' off"
+ cset "name='UL1_CH2 ADDA_UL_CH2' off"
]
}
SectionDevice."Speaker" {
- Comment "Gemini PDA AW8738 Stereo Speakers"
+ Comment "Gemini Stereo Speakers"
+
+ ConflictingDevices [
+ "Headphones"
+ ]
EnableSequence [
- cset "name='Speaker_Amp_Switch' On"
+ cset "name='Speaker Switch' on"
]
DisableSequence [
- cset "name='Speaker_Amp_Switch' Off"
+ cset "name='Speaker Switch' off"
]
Value {
- PlaybackPriority 100
+ PlaybackPriority 200
PlaybackPCM "hw:${CardId},0"
+ PlaybackChannels 2
}
}
SectionDevice."Headphones" {
Comment "3.5mm Stereo Headphones"
+ ConflictingDevices [
+ "Speaker"
+ ]
+
EnableSequence [
- cset "name='Speaker_Amp_Switch' Off"
- cset "name='Headset_PGAL_GAIN' 8"
- cset "name='Headset_PGAR_GAIN' 8"
+ cset "name='Headphone Switch' on"
+ ]
+
+ DisableSequence [
+ cset "name='Headphone Switch' off"
]
Value {
- PlaybackPriority 200
+ PlaybackPriority 300
PlaybackPCM "hw:${CardId},0"
+ PlaybackChannels 2
JackControl "Headphone Jack"
}
}
SectionDevice."Mic" {
- Comment "Internal Microphone"
+ Comment "Internal Dual Microphones"
+
+ ConflictingDevices [
+ "Headset"
+ ]
EnableSequence [
- cset "name='Audio_MicSource1_Setting' ADC1"
- cset "name='Audio_ADC_1_Switch' On"
+ cset "name='PGA L Mux' 'AIN0'"
+ cset "name='PGA R Mux' 'AIN2'"
+ cset "name='Main Mic Switch' on"
+ cset "name='Back Mic Switch' on"
+ ]
+
+ DisableSequence [
+ cset "name='Main Mic Switch' off"
+ cset "name='Back Mic Switch' off"
]
Value {
- CapturePriority 100
- CapturePCM "hw:${CardId},0"
+ CapturePriority 200
+ CapturePCM "hw:${CardId},3"
+ CaptureChannels 2
}
}
SectionDevice."Headset" {
Comment "3.5mm Headset Microphone"
+ ConflictingDevices [
+ "Mic"
+ ]
+
EnableSequence [
- cset "name='Audio_MicSource1_Setting' ADC2"
- cset "name='Audio_ADC_2_Switch' On"
+ cset "name='PGA L Mux' 'AIN1'"
+ cset "name='PGA R Mux' 'AIN1'"
+ cset "name='Headset Mic Switch' on"
+ ]
+
+ DisableSequence [
+ cset "name='Headset Mic Switch' off"
]
Value {
- CapturePriority 200
- CapturePCM "hw:${CardId},0"
- JackControl "Mic Jack"
+ CapturePriority 300
+ CapturePCM "hw:${CardId},3"
+ CaptureChannels 2
+ JackControl "Headphone Jack"
}
}
diff --git a/overlay/rootfs/usr/share/alsa/ucm2/MediaTek/mt6797-gemini/VoiceCall.conf b/overlay/rootfs/usr/share/alsa/ucm2/MediaTek/mt6797-gemini/VoiceCall.conf
index 81bf44d..0736fa0 100644
--- a/overlay/rootfs/usr/share/alsa/ucm2/MediaTek/mt6797-gemini/VoiceCall.conf
+++ b/overlay/rootfs/usr/share/alsa/ucm2/MediaTek/mt6797-gemini/VoiceCall.conf
@@ -2,48 +2,104 @@ Syntax 4
SectionVerb {
EnableSequence [
- cset "name='MD1_Voice_Switch' On"
- cset "name='Voice_UL_Switch' On"
- cset "name='Voice_DL_Switch' On"
+ cset "name='ADDA_DL_CH1 DL2_CH1' on"
+ cset "name='ADDA_DL_CH2 DL2_CH2' on"
+ cset "name='ADDA_DL_CH1 PCM_2_CAP_CH1' on"
+ cset "name='ADDA_DL_CH2 PCM_2_CAP_CH2' on"
+ cset "name='PCM_2_PB_CH1 ADDA_UL_CH1' on"
+ cset "name='PCM_2_PB_CH2 ADDA_UL_CH2' on"
+ cset "name='UL2_CH1 ADDA_UL_CH1' on"
+ cset "name='UL2_CH2 ADDA_UL_CH2' on"
+ cset "name='DAC In Mux' 'Normal Path'"
+ cset "name='AIF Out Mux' 'Normal Path'"
+ cset "name='ADC L Mux' 'Left Preamplifier'"
+ cset "name='ADC R Mux' 'Right Preamplifier'"
+ cset "name='PGA Volume' 3,3"
]
DisableSequence [
- cset "name='MD1_Voice_Switch' Off"
+ cset "name='Speaker Switch' off"
+ cset "name='RCV Mux' 'Open'"
+ cset "name='HPL Mux' 'Open'"
+ cset "name='HPR Mux' 'Open'"
+ cset "name='Main Mic Switch' off"
+ cset "name='ADDA_DL_CH1 DL2_CH1' off"
+ cset "name='ADDA_DL_CH2 DL2_CH2' off"
+ cset "name='ADDA_DL_CH1 PCM_2_CAP_CH1' off"
+ cset "name='ADDA_DL_CH2 PCM_2_CAP_CH2' off"
+ cset "name='PCM_2_PB_CH1 ADDA_UL_CH1' off"
+ cset "name='PCM_2_PB_CH2 ADDA_UL_CH2' off"
+ cset "name='UL2_CH1 ADDA_UL_CH1' off"
+ cset "name='UL2_CH2 ADDA_UL_CH2' off"
]
}
SectionDevice."Earpiece" {
Comment "Handset Earpiece"
+ ConflictingDevices [
+ "Speaker"
+ ]
+
EnableSequence [
- cset "name='Speaker_Amp_Switch' Off"
- cset "name='Handset_PGA_GAIN' 8"
+ cset "name='RCV Mux' 'Voice Playback'"
+ cset "name='Handset Volume' 14"
+ ]
+
+ DisableSequence [
+ cset "name='RCV Mux' 'Open'"
]
Value {
PlaybackPriority 300
- PlaybackPCM "hw:${CardId},2"
+ PlaybackPCM "hw:${CardId},1"
+ PlaybackChannels 2
}
}
SectionDevice."Speaker" {
- Comment "Speakerphone (AW8738 Amp)"
+ Comment "Speakerphone"
+
+ ConflictingDevices [
+ "Earpiece"
+ ]
EnableSequence [
- cset "name='Speaker_Amp_Switch' On"
+ cset "name='HPL Mux' 'Audio Playback'"
+ cset "name='HPR Mux' 'Audio Playback'"
+ cset "name='Headphone Volume' 14,14"
+ cset "name='Speaker Switch' on"
+ ]
+
+ DisableSequence [
+ cset "name='Speaker Switch' off"
+ cset "name='HPL Mux' 'Open'"
+ cset "name='HPR Mux' 'Open'"
]
Value {
- PlaybackPriority 100
- PlaybackPCM "hw:${CardId},2"
+ PlaybackPriority 200
+ PlaybackPCM "hw:${CardId},1"
+ PlaybackChannels 2
}
}
SectionDevice."Mic" {
Comment "Cellular Voice Uplink Microphone"
+ EnableSequence [
+ cset "name='PGA L Mux' 'AIN0'"
+ cset "name='PGA R Mux' 'AIN2'"
+ cset "name='Main Mic Switch' on"
+ ]
+
+ DisableSequence [
+ cset "name='Main Mic Switch' off"
+ ]
+
Value {
- CapturePriority 100
- CapturePCM "hw:${CardId},2"
+ CapturePriority 200
+ CapturePCM "hw:${CardId},4"
+ CaptureChannels 2
}
}
diff --git a/overlay/rootfs/usr/share/alsa/ucm2/conf.d/mt6797-mt6351/mt6797-mt6351.conf b/overlay/rootfs/usr/share/alsa/ucm2/conf.d/mt6797-mt6351/mt6797-mt6351.conf
new file mode 120000
index 0000000..b34a3e7
--- /dev/null
+++ b/overlay/rootfs/usr/share/alsa/ucm2/conf.d/mt6797-mt6351/mt6797-mt6351.conf
@@ -0,0 +1 @@
+../../MediaTek/mt6797-gemini/mt6797-gemini.conf
\ No newline at end of file
diff --git a/patches/kernel/0005-mt6797-consys-wifi-factory-firmware.patch b/patches/kernel/0005-mt6797-consys-wifi-factory-firmware.patch
new file mode 100644
index 0000000..99689fe
--- /dev/null
+++ b/patches/kernel/0005-mt6797-consys-wifi-factory-firmware.patch
@@ -0,0 +1,1806 @@
+--- a/drivers/bluetooth/btmt6797-h4.h
++++ b/drivers/bluetooth/btmt6797-h4.h
+@@ -10,6 +10,7 @@
+ #define BT_H4_EVENT 0x04
+ #define BT_H4_ACL 0x02
+ #define BT_H4_SCO 0x03
++#define BT_H4_ISO 0x05
+ #define BT_H4_MAX 2048U
+
+ struct bt_h4 {
+@@ -55,6 +56,9 @@
+ case BT_H4_SCO:
+ h->header = 4;
+ break;
++ case BT_H4_ISO:
++ h->header = 5;
++ break;
+ default:
+ h->failed = 1;
+ return -1;
+@@ -66,6 +70,8 @@
+ body = h->packet[2];
+ else if (h->packet[0] == BT_H4_SCO)
+ body = h->packet[3];
++ else if (h->packet[0] == BT_H4_ISO)
++ body = h->packet[3] | ((h->packet[4] & 0x3f) << 8);
+ else
+ body = h->packet[3] | (h->packet[4] << 8);
+ if (h->header + body > BT_H4_MAX) {
+--- a/drivers/bluetooth/btmt6797.c
++++ b/drivers/bluetooth/btmt6797.c
+@@ -12,6 +12,7 @@
+ * starts no inquiry, page or scan.
+ */
+
++#include
+ #include
+ #include
+ #include
+@@ -24,8 +25,12 @@
+ #include "btmt6797-h4.h"
+
+ #define BTMT6797_OP_SET_BDADDR 0xfc1a
++#define BTMT6797_OP_SET_LE 0xfc6b
++#define BTMT6797_OP_SET_PCM 0xfc72
+ #define BTMT6797_OP_SET_RADIO 0xfc79
++#define BTMT6797_OP_SET_BTFTR 0xfc7d
+ #define BTMT6797_OP_SET_TX_OFFSET 0xfc93
++#define BTMT6797_NVRAM_FILE "mediatek/mt6797/BT.storage"
+
+ /* The parameters Gemian's in-kernel driver sends on this chip. */
+ static const u8 btmt6797_radio[] = { 0x06, 0x80, 0x00, 0x06, 0x03, 0x06 };
+@@ -40,18 +45,45 @@
+ struct bt_h4 h4;
+ struct sk_buff_head rx;
+ struct work_struct rx_work, error_work;
++ bool le_supported;
++ u8 le_feat0_mask;
++ u8 cmd25_or, cmd26_or, cmd27_or, cmd28_or;
+ };
+
+ /*
+- * The controller sets the LE bit, but lists no basic LE command and refuses LE Set
+- * Event Mask, which fails the core's init. Only classic Bluetooth is offered.
++ * Hide LMP_LE when the probe refuses LE, or mask controller LE feature/command
++ * bits that trigger unsupported LE init / event-mask opcodes on MT6797 CONSYS.
+ */
+-static void btmt6797_hide_le(struct sk_buff *skb, unsigned char type)
++static void btmt6797_filter_rx(struct btmt6797 *bt, struct sk_buff *skb, unsigned char type)
+ {
+- /* Event, length, credits, opcode, status, then the eight feature bytes. */
+- if (type == HCI_EVENT_PKT && skb->len == 14 && skb->data[0] == HCI_EV_CMD_COMPLETE &&
+- get_unaligned_le16(skb->data + 3) == HCI_OP_READ_LOCAL_FEATURES)
+- skb->data[6 + 4] &= ~LMP_LE;
++ u16 op;
++
++ if (type != HCI_EVENT_PKT || skb->len < 6 || skb->data[0] != HCI_EV_CMD_COMPLETE)
++ return;
++ op = get_unaligned_le16(skb->data + 3);
++ if (op == HCI_OP_READ_LOCAL_FEATURES && skb->len >= 14) {
++ if (!bt->le_supported)
++ skb->data[6 + 4] &= ~LMP_LE;
++ return;
++ }
++ if (!bt->le_supported || skb->data[5])
++ return;
++ if (op == HCI_OP_LE_READ_LOCAL_FEATURES && skb->len >= 14) {
++ skb->data[6] &= bt->le_feat0_mask;
++ memset(skb->data + 7, 0, 7);
++ } else if (op == HCI_OP_READ_LOCAL_COMMANDS && skb->len >= 70) {
++ if (!(bt->cmd25_or & 0x40))
++ skb->data[6 + 25] &= ~0x40;
++ if (!(bt->cmd26_or & 0x40))
++ skb->data[6 + 26] &= ~0x40;
++ if (!(bt->cmd26_or & 0x80))
++ skb->data[6 + 26] &= ~0x80;
++ memset(skb->data + 6 + 34, 0, 15);
++ skb->data[6 + 25] |= bt->cmd25_or;
++ skb->data[6 + 26] |= bt->cmd26_or;
++ skb->data[6 + 27] |= bt->cmd27_or;
++ skb->data[6 + 28] |= bt->cmd28_or;
++ }
+ }
+
+ static int btmt6797_emit(void *context, unsigned char type, const unsigned char *data,
+@@ -65,7 +97,7 @@
+ return -ENOMEM;
+ hci_skb_pkt_type(skb) = type;
+ skb_put_data(skb, data, length);
+- btmt6797_hide_le(skb, type);
++ btmt6797_filter_rx(bt, skb, type);
+ skb_queue_tail(&bt->rx, skb);
+ return 0;
+ }
+@@ -113,6 +145,12 @@
+ struct btmt6797 *bt = hci_get_drvdata(hdev);
+ int ret;
+
++ bt->le_supported = false;
++ bt->le_feat0_mask = 0;
++ bt->cmd25_or = 0;
++ bt->cmd26_or = 0;
++ bt->cmd27_or = 0;
++ bt->cmd28_or = 0;
+ bt_h4_reset(&bt->h4);
+ ret = mt6797_consys_stp_attach(MT6797_STP_TASK_BT, btmt6797_receive, bt);
+ if (ret)
+@@ -165,19 +203,91 @@
+ return 0;
+ }
+
+-/* Every open: the function-on before it returned the controller to its defaults. */
+-static int btmt6797_setup(struct hci_dev *hdev)
++static int btmt6797_cmd_read(struct hci_dev *hdev, u16 opcode, const void *data,
++ u32 length, void *resp, size_t resp_len)
+ {
+- int ret;
++ struct sk_buff *skb;
+
+- if (!gemian_radio)
+- return 0;
+- ret = btmt6797_vendor(hdev, BTMT6797_OP_SET_RADIO, btmt6797_radio,
+- sizeof(btmt6797_radio));
+- if (ret)
+- return ret;
+- return btmt6797_vendor(hdev, BTMT6797_OP_SET_TX_OFFSET, btmt6797_tx_offset,
+- sizeof(btmt6797_tx_offset));
++ skb = __hci_cmd_sync(hdev, opcode, length, data, HCI_INIT_TIMEOUT);
++ if (IS_ERR(skb))
++ return PTR_ERR(skb);
++ if (!skb->len || skb->data[0]) {
++ kfree_skb(skb);
++ return -EIO;
++ }
++ if (resp && resp_len) {
++ size_t cp = min_t(size_t, resp_len, skb->len - 1);
++
++ memset(resp, 0, resp_len);
++ memcpy(resp, skb->data + 1, cp);
++ }
++ kfree_skb(skb);
++ return 0;
++}
++
++static int btmt6797_cmd_try(struct hci_dev *hdev, u16 opcode, const void *data, u32 length)
++{
++ return btmt6797_cmd_read(hdev, opcode, data, length, NULL, 0);
++}
++
++static bool btmt6797_probe_le(struct btmt6797 *bt, struct hci_dev *hdev)
++{
++ static const u8 le_on_a[2] = { 0x01, 0x01 };
++ static const u8 le_on_b[2] = { 0x01, 0x00 };
++ static const u8 scan_p[7] = { 0x01, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00 };
++ static const u8 host_le[2] = { 0x01, 0x00 };
++ u8 ev[8] = { 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
++ u8 le_feat[8], le_buf[3], le_states[8], cmds[64];
++ u8 mask = HCI_LE_ENCRYPTION | HCI_LE_PERIPHERAL_FEATURES | HCI_LE_PING;
++
++ if (btmt6797_cmd_try(hdev, BTMT6797_OP_SET_LE, le_on_a, sizeof(le_on_a)))
++ btmt6797_cmd_try(hdev, BTMT6797_OP_SET_LE, le_on_b, sizeof(le_on_b));
++
++ if (btmt6797_cmd_read(hdev, HCI_OP_READ_LOCAL_COMMANDS, NULL, 0, cmds, sizeof(cmds)) ||
++ btmt6797_cmd_read(hdev, HCI_OP_LE_READ_LOCAL_FEATURES, NULL, 0, le_feat, sizeof(le_feat)) ||
++ btmt6797_cmd_read(hdev, HCI_OP_LE_READ_BUFFER_SIZE, NULL, 0, le_buf, sizeof(le_buf)) ||
++ btmt6797_cmd_read(hdev, HCI_OP_LE_READ_SUPPORTED_STATES, NULL, 0, le_states, sizeof(le_states)) ||
++ btmt6797_cmd_try(hdev, HCI_OP_LE_SET_EVENT_MASK, ev, sizeof(ev)) ||
++ btmt6797_cmd_try(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, host_le, sizeof(host_le)))
++ return false;
++
++ bt_dev_info(hdev, "CONSYS raw le_feat=%*ph cmds25_28=%*ph",
++ 8, le_feat, 4, cmds + 25);
++
++ if (le_feat[0] & HCI_LE_CONN_PARAM_REQ_PROC) {
++ ev[0] |= 0x20;
++ if (!btmt6797_cmd_try(hdev, HCI_OP_LE_SET_EVENT_MASK, ev, sizeof(ev)))
++ mask |= HCI_LE_CONN_PARAM_REQ_PROC;
++ else
++ ev[0] &= ~0x20;
++ }
++ if (le_feat[0] & HCI_LE_DATA_LEN_EXT) {
++ ev[0] |= 0x40;
++ if (!btmt6797_cmd_try(hdev, HCI_OP_LE_SET_EVENT_MASK, ev, sizeof(ev)) &&
++ !btmt6797_cmd_try(hdev, HCI_OP_LE_READ_MAX_DATA_LEN, NULL, 0) &&
++ !btmt6797_cmd_try(hdev, HCI_OP_LE_READ_DEF_DATA_LEN, NULL, 0))
++ mask |= HCI_LE_DATA_LEN_EXT;
++ }
++
++ ev[0] = 0x1f;
++ btmt6797_cmd_try(hdev, HCI_OP_LE_SET_EVENT_MASK, ev, sizeof(ev));
++
++ bt->le_feat0_mask = mask;
++ bt->cmd25_or = 0x07; /* Set Event Mask, Read Buffer Size, Read Local Features */
++ bt->cmd28_or = 0x08; /* LE Read Supported States */
++
++ if (!btmt6797_cmd_try(hdev, HCI_OP_LE_READ_ADV_TX_POWER, NULL, 0))
++ bt->cmd25_or |= 0x40;
++ if (!btmt6797_cmd_try(hdev, HCI_OP_LE_READ_ACCEPT_LIST_SIZE, NULL, 0) &&
++ !btmt6797_cmd_try(hdev, HCI_OP_LE_CLEAR_ACCEPT_LIST, NULL, 0))
++ bt->cmd26_or |= 0xc0;
++ if (!btmt6797_cmd_try(hdev, HCI_OP_LE_SET_SCAN_PARAM, scan_p, sizeof(scan_p))) {
++ bt->cmd25_or |= 0xb0; /* Rand Addr, Adv Params, Adv Data */
++ bt->cmd26_or |= 0x3f; /* Scan Rsp, Adv En, Scan Param, Scan En, Conn, Cancel */
++ bt->cmd27_or |= 0xfc; /* Conn Update, Host Ch, Ch Map, Rem Feat, Encrypt, Rand */
++ bt->cmd28_or |= 0x0f; /* Start Enc, LTK Reply/Neg, Supported States */
++ }
++ return true;
+ }
+
+ static int btmt6797_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
+@@ -185,6 +295,60 @@
+ return btmt6797_vendor(hdev, BTMT6797_OP_SET_BDADDR, bdaddr, sizeof(*bdaddr));
+ }
+
++/* Every open: the function-on before it returned the controller to its defaults. */
++static int btmt6797_setup(struct hci_dev *hdev)
++{
++ struct btmt6797 *bt = hci_get_drvdata(hdev);
++ const struct firmware *fw = NULL;
++ static const u8 default_btftr[2] = { 0x80, 0x00 };
++ int ret = 0;
++
++ if (!firmware_request_nowarn(&fw, BTMT6797_NVRAM_FILE, &hdev->dev)) {
++ if (fw->size >= 30) {
++ bool non_zero = false, all_ff = true;
++ int i;
++
++ for (i = 0; i < 6; i++) {
++ if (fw->data[i])
++ non_zero = true;
++ if (fw->data[i] != 0xff)
++ all_ff = false;
++ }
++ if (non_zero && !all_ff && !(fw->data[0] & 0x01)) {
++ bdaddr_t bd;
++
++ for (i = 0; i < 6; i++)
++ bd.b[i] = fw->data[5 - i];
++ btmt6797_set_bdaddr(hdev, &bd);
++ memzero_explicit(&bd, sizeof(bd));
++ }
++ btmt6797_cmd_try(hdev, BTMT6797_OP_SET_PCM, fw->data + 8, 4);
++ btmt6797_cmd_try(hdev, BTMT6797_OP_SET_RADIO, fw->data + 12, 6);
++ btmt6797_cmd_try(hdev, BTMT6797_OP_SET_BTFTR, fw->data + 25, 2);
++ btmt6797_cmd_try(hdev, BTMT6797_OP_SET_TX_OFFSET, fw->data + 27, 3);
++ }
++ release_firmware(fw);
++ } else {
++ btmt6797_cmd_try(hdev, BTMT6797_OP_SET_BTFTR,
++ default_btftr, sizeof(default_btftr));
++ if (gemian_radio) {
++ ret = btmt6797_vendor(hdev, BTMT6797_OP_SET_RADIO, btmt6797_radio,
++ sizeof(btmt6797_radio));
++ if (ret)
++ return ret;
++ ret = btmt6797_vendor(hdev, BTMT6797_OP_SET_TX_OFFSET, btmt6797_tx_offset,
++ sizeof(btmt6797_tx_offset));
++ if (ret)
++ return ret;
++ }
++ }
++
++ bt->le_supported = btmt6797_probe_le(bt, hdev);
++ bt_dev_info(hdev, "CONSYS Bluetooth setup complete (LE=%s mask=0x%02x)",
++ bt->le_supported ? "enabled" : "masked", bt->le_feat0_mask);
++ return 0;
++}
++
+ static int btmt6797_probe(struct platform_device *pdev)
+ {
+ struct btmt6797 *bt;
+@@ -242,3 +406,4 @@
+ MODULE_DESCRIPTION("MediaTek MT6797 CONSYS Bluetooth");
+ MODULE_LICENSE("GPL");
+ MODULE_ALIAS("platform:btmt6797");
++MODULE_FIRMWARE(BTMT6797_NVRAM_FILE);
+--- a/drivers/net/wireless/mediatek/mt6797/data.c
++++ b/drivers/net/wireless/mediatek/mt6797/data.c
+@@ -528,7 +528,8 @@
+ (mt6797_join_le16(packet + 2) >> 13) != 2 ||
+ packet[5] != channel || (packet[6] & 0x80) == 0 ||
+ (packet[6] & 63) != 14 || packet[7] != 0x04 ||
+- (packet[9] >> 4) != 4 || mt6797_join_le16(packet + 10) != 0xc200)
++ ((packet[9] >> 4) != 4 && (packet[9] >> 4) != 2) ||
++ mt6797_join_le16(packet + 10) != 0xc200)
+ return false;
+ match = packet[4];
+ if (((match & 0x3f) != 0x08 && (match & 0x3f) != 0x04) ||
+@@ -713,11 +714,12 @@
+ * acknowledgment, no A-MSDU, no EOSP) and agrees with byte 9; a non-QoS
+ * frame, and every frame without WMM, keeps TID 0 and QoS control 0 (0289).
+ */
+-static inline bool mt6797_ccmp_rx_tid_ok(const unsigned char *packet, unsigned int fc)
++static inline bool mt6797_ccmp_rx_tid_ok(const unsigned char *packet, unsigned int fc,
++ unsigned char expected_cipher)
+ {
+ unsigned int qos = mt6797_join_le16(packet + 26);
+
+- if ((packet[9] & 0xf0) != 0x40)
++ if ((packet[9] & 0xf0) != expected_cipher)
+ return false;
+ if (fc & MT6797_CCMP_RX_QOS_BIT)
+ return !(qos & ~0x000fU) && (qos & 15) == (packet[9] & 15U) &&
+@@ -795,7 +797,8 @@
+ fc = mt6797_join_le16(packet + 16);
+ if ((fc & ~(0x2800U | MT6797_CCMP_RX_QOS_BIT)) != 0x4208 ||
+ (mt6797_join_le16(packet + 24) & 15) ||
+- !mt6797_ccmp_rx_tid_ok(packet, fc) || mt6797_join_le32(packet + 28))
++ !mt6797_ccmp_rx_tid_ok(packet, fc, 0x40) ||
++ mt6797_join_le32(packet + 28))
+ return false;
+ ethernet = packet + offset;
+ for (i = 0; i < 6; i++) {
+@@ -984,16 +987,20 @@
+ size_t offset = 48; /* base16, mandatory Group4 at16, Group1 at32 */
+ unsigned int groups, fc, i, tid;
+ unsigned char *last;
++ unsigned char expected_sec;
+ bool greater = false, own_any = false, ap_any = false, source_any = false;
+ const unsigned char *ethernet;
+
+ if (!packet || !context || !out || bytes < 16 || bytes > 2352 ||
+ !context->authorized || !context->active || !context->seeded ||
+- context->pairwise || context->cipher != 0x000fac04U ||
+- context->key_bytes != 16 || context->key_id > 3 ||
++ context->pairwise ||
++ !((context->cipher == 0x000fac04U && context->key_bytes == 16) ||
++ (context->cipher == 0x000fac02U && context->key_bytes == 32)) ||
++ context->key_id > 3 ||
+ context->wlan_index != 2 || context->rxd_bssid > 63 || !context->channel ||
+ (context->own[0] & 1) || (context->ap[0] & 1))
+ return false;
++ expected_sec = context->cipher == 0x000fac02U ? 0x20 : 0x40;
+ for (i = 0; i < 6; i++) {
+ own_any |= context->own[i] != 0;
+ ap_any |= context->ap[i] != 0;
+@@ -1004,7 +1011,7 @@
+ (packet[4] >> 6) != context->key_id || packet[5] != context->channel ||
+ (packet[6] & 0xbf) != 0x8e ||
+ packet[7] != (unsigned int)context->rxd_bssid << 2 ||
+- packet[8] != context->wlan_index || (packet[9] & 0xf0) != 0x40 ||
++ packet[8] != context->wlan_index || (packet[9] & 0xf0) != expected_sec ||
+ mt6797_join_le16(packet + 10) != 0xc000)
+ return false;
+ groups = (mt6797_join_le16(packet + 2) >> 9) & 15;
+@@ -1022,7 +1029,8 @@
+ fc = mt6797_join_le16(packet + 16);
+ if ((fc & ~(0x2800U | MT6797_CCMP_RX_QOS_BIT)) != 0x4208 ||
+ (mt6797_join_le16(packet + 24) & 15) ||
+- !mt6797_ccmp_rx_tid_ok(packet, fc) || mt6797_join_le32(packet + 28))
++ !mt6797_ccmp_rx_tid_ok(packet, fc, expected_sec) ||
++ mt6797_join_le32(packet + 28))
+ return false;
+ ethernet = packet + offset;
+ for (i = 0; i < 6; i++) {
+@@ -1263,7 +1271,7 @@
+ field = (mt6797_join_le16(p + 2) >> 13) != 2 ? "packet-type" :
+ (p[6] & 0xbf) != 0x8e ? "layout" :
+ p[8] != 1 && p[8] != 2 ? "wlan-index" :
+- (p[9] & 0xf0) != 0x40 ? "cipher" :
++ ((p[9] & 0xf0) != 0x40 && !(p[8] == 2 && (p[9] & 0xf0) == 0x20)) ? "cipher" :
+ !mt6797_ccmp_rx_status_ok(mt6797_join_le16(p + 10)) ? "prefix" :
+ (groups & 9) != 9 ? "groups" :
+ (fc & ~(0x2800U | MT6797_CCMP_RX_QOS_BIT)) != 0x4208 ? "frame-control" :
+--- a/drivers/net/wireless/mediatek/mt6797/hif.c
++++ b/drivers/net/wireless/mediatek/mt6797/hif.c
+@@ -114,6 +114,33 @@
+ output, capacity, command);
+ }
+
++static inline int
++mt6797_join_prepare_eapol_native(struct mt6797_normal_transaction *t,
++ const unsigned char *frame, size_t bytes,
++ unsigned char wlan, unsigned char pid,
++ unsigned int lifetime_ms,
++ unsigned int attempt_count,
++ unsigned char *output, size_t capacity,
++ struct mt6797_hif_command *command)
++{
++ unsigned char descriptor[MT6797_JOIN_TX_DESC_BYTES];
++ unsigned int pages;
++
++ if (command)
++ *command = (struct mt6797_hif_command){0};
++ if (!t || !output || !command)
++ return -EINVAL;
++ if (t->phase != MT6797_NORMAL_NVRAM_SUBMITTED || !t->used_sequences ||
++ !t->tc4_limit || t->tc4_limit > 0xffffU || t->tc4_free > t->tc4_limit)
++ return mt6797_normal_abort(t);
++ if (!mt6797_join_tx_eapol_native_descriptor(frame, bytes, wlan, pid,
++ lifetime_ms, attempt_count,
++ descriptor, &pages))
++ return -EINVAL;
++ return mt6797_join_prepare_frame(t, descriptor, frame, bytes, pages,
++ output, capacity, command);
++}
++
+ /* Prepare one protected Ethernet II data frame on the TC1 data pool: the
+ * same framing as the TC4 frames, the pages debited from the pool admitted
+ * by mt6797_normal_admit_tc1, one frame in flight (the pool must be whole),
+@@ -1733,20 +1760,31 @@
+ }
+ EXPORT_SYMBOL_GPL(mt6797_hif_join_station_qos);
+
+-int mt6797_hif_join_key(struct mt6797_hif *hif, unsigned int sequence,
+- bool add, bool pairwise, const u8 *peer,
+- unsigned int key_id, const u8 *material, u64 deadline_ns)
++int mt6797_hif_join_key_cipher(struct mt6797_hif *hif, unsigned int sequence,
++ bool add, bool pairwise, bool tkip,
++ const u8 *peer, unsigned int key_id,
++ const u8 *material, u64 deadline_ns)
+ {
+ u8 payload[MT6797_JOIN_KEY_BYTES];
+ int error;
+
+- if (!mt6797_join_key_payload(add, pairwise, peer, key_id, material, payload))
++ if (!mt6797_join_key_payload_cipher(add, pairwise, tkip, peer, key_id,
++ material, payload))
+ return -EINVAL;
+ error = mt6797_hif_send_join_command(hif, 0x07, sequence, payload,
+ sizeof(payload), true, deadline_ns);
+ memzero_explicit(payload, sizeof(payload));
+ return error;
+ }
++EXPORT_SYMBOL_GPL(mt6797_hif_join_key_cipher);
++
++int mt6797_hif_join_key(struct mt6797_hif *hif, unsigned int sequence,
++ bool add, bool pairwise, const u8 *peer,
++ unsigned int key_id, const u8 *material, u64 deadline_ns)
++{
++ return mt6797_hif_join_key_cipher(hif, sequence, add, pairwise, false,
++ peer, key_id, material, deadline_ns);
++}
+ EXPORT_SYMBOL_GPL(mt6797_hif_join_key);
+ int mt6797_hif_join_remove_station(struct mt6797_hif *hif,
+ unsigned int sequence, u64 deadline_ns)
+@@ -2051,6 +2089,50 @@
+ }
+ EXPORT_SYMBOL_GPL(mt6797_hif_send_security);
+
++int mt6797_hif_send_eapol_native(struct mt6797_hif *hif, const u8 *frame,
++ size_t frame_bytes, u8 wlan, u8 pid,
++ unsigned int lifetime_ms,
++ unsigned int attempt_count, u64 deadline_ns)
++{
++ struct mt6797_hif_pio_result transfer;
++ struct mt6797_hif_command command;
++ int error;
++
++ if (!hif || !frame)
++ return -EINVAL;
++ if (!mutex_trylock(&hif->mutex))
++ return -EBUSY;
++ if (!hif->firmware_ready || !hif->capability_complete ||
++ hif->transaction->phase != MT6797_INIT_IDLE ||
++ hif->normal.phase != MT6797_NORMAL_NVRAM_SUBMITTED) {
++ error = -EIO;
++ goto unlock;
++ }
++ error = mt6797_join_prepare_eapol_native(&hif->normal, frame, frame_bytes,
++ wlan, pid, lifetime_ms,
++ attempt_count, hif->scratch,
++ sizeof(hif->scratch), &command);
++ if (error)
++ goto unlock;
++ error = mt6797_hif_enter(hif, deadline_ns);
++ if (error)
++ goto fail;
++ error = mt6797_hif_pio_transfer(&hif->io, 0x34, MT6797_HIF_WRITE,
++ hif->scratch,
++ MT6797_JOIN_TX_DESC_BYTES + frame_bytes,
++ sizeof(hif->scratch), &transfer);
++ error = mt6797_normal_submitted(&hif->normal, error);
++ if (!error)
++ error = mt6797_hif_guard(hif);
++fail:
++ if (error)
++ error = mt6797_hif_fail(hif, error);
++unlock:
++ mutex_unlock(&hif->mutex);
++ return error;
++}
++EXPORT_SYMBOL_GPL(mt6797_hif_send_eapol_native);
++
+ int mt6797_hif_send_data_report(struct mt6797_hif *hif, const u8 *frame,
+ size_t frame_bytes, u8 wlan, u8 pid,
+ bool status_report,
+--- a/drivers/net/wireless/mediatek/mt6797/hif.h
++++ b/drivers/net/wireless/mediatek/mt6797/hif.h
+@@ -223,6 +223,10 @@
+ int mt6797_hif_join_key(struct mt6797_hif *hif, unsigned int sequence,
+ bool add, bool pairwise, const u8 *peer,
+ unsigned int key_id, const u8 *material, u64 deadline_ns);
++int mt6797_hif_join_key_cipher(struct mt6797_hif *hif, unsigned int sequence,
++ bool add, bool pairwise, bool tkip,
++ const u8 *peer, unsigned int key_id,
++ const u8 *material, u64 deadline_ns);
+ /* The firmware's 802.11 power-save profile for BSS 0 (command 0x05):
+ * 0 constantly awake, 1 maximum power save, 2 fast power save.
+ */
+@@ -302,6 +306,10 @@
+ size_t frame_bytes, u8 wlan, u8 pid,
+ unsigned int lifetime_ms, unsigned int attempt_count,
+ u64 deadline_ns);
++int mt6797_hif_send_eapol_native(struct mt6797_hif *hif, const u8 *frame,
++ size_t frame_bytes, u8 wlan, u8 pid,
++ unsigned int lifetime_ms,
++ unsigned int attempt_count, u64 deadline_ns);
+
+ int mt6797_hif_send_config(struct mt6797_hif *hif,
+ enum mt6797_normal_config_kind kind,
+--- a/drivers/net/wireless/mediatek/mt6797/join.c
++++ b/drivers/net/wireless/mediatek/mt6797/join.c
+@@ -410,11 +410,19 @@
+ 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02,
+ };
+
++static const u8 mt6797_join_rsn_tkip_group_body[18] = {
++ 0x01, 0x00,
++ 0x00, 0x0f, 0xac, 0x02,
++ 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04,
++ 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02,
++};
++
+ static bool mt6797_join_rsn_capabilities(const u8 *capabilities)
+ {
+ unsigned int value = mt6797_join_le16(capabilities);
+
+- return value == 0 || value == 0x000c;
++ /* Allow PTKSA/GTKSA replay-counter counts (bits 2..5); reject MFP/pre-auth. */
++ return (value & ~0x003cU) == 0;
+ }
+
+ /* Called with join_queue.lock held. */
+@@ -493,8 +501,10 @@
+ if (f[ie] == WLAN_EID_RSN) {
+ if (++rsn_count != 1 ||
+ f[ie + 1] != sizeof(mt6797_join_rsn_body) + 2 ||
+- memcmp(f + ie + 2, mt6797_join_rsn_body,
+- sizeof(mt6797_join_rsn_body)) ||
++ (memcmp(f + ie + 2, mt6797_join_rsn_body,
++ sizeof(mt6797_join_rsn_body)) &&
++ memcmp(f + ie + 2, mt6797_join_rsn_tkip_group_body,
++ sizeof(mt6797_join_rsn_tkip_group_body))) ||
+ !mt6797_join_rsn_capabilities(f + ie + 2 +
+ sizeof(mt6797_join_rsn_body))) {
+ dev_info(wiphy_dev(mac->hw->wiphy),
+@@ -648,7 +658,6 @@
+ mac->scan_channels = 0;
+ mac->scan_total = 0;
+ mac->scan_next = 0;
+- mac->scan_sequence = 0;
+ mac->scan_packets = 0;
+ mac->scan_beacon = false;
+ mac->scan_credit = false;
+@@ -686,6 +695,7 @@
+ mac->join_deauth_status = 0;
+ mac->join_cleanup_stage = 0;
+ mac->join_rsn = false;
++ mac->reg_pending = false;
+ mac->join_key_pairwise = 0;
+ mac->join_key_group = 0;
+ mac->join_key_pairwise_submitted = false;
+@@ -1004,7 +1014,7 @@
+ * state is reset; the wire identities, keys and epoch were never consumed.
+ * The lifetime counted at this scan's submission is handed back.
+ */
+-static void mt6797_mac_join_reopen_scan(struct mt6797_mac *mac)
++void mt6797_mac_join_reopen_scan(struct mt6797_mac *mac)
+ {
+ unsigned long flags;
+
+@@ -1020,7 +1030,6 @@
+ mac->scan_channels = 0;
+ mac->scan_total = 0;
+ mac->scan_next = 0;
+- mac->scan_sequence = 0;
+ mac->scan_packets = 0;
+ mac->scan_beacon = false;
+ mac->scan_credit = false;
+@@ -1774,9 +1783,16 @@
+
+ if (!mac->ccmp_pm_connected || !mac->ccmp_pm_credit_ns)
+ return -EOPNOTSUPP;
+- /* The regulatory change did not settle during the join. */
+- if (mac->reg_pending)
+- return -ECANCELED;
++ {
++ int slot = mac->join_channel_valid ?
++ mt6797_channel_slot(mac->join_chan_number) : -1;
++
++ if (slot < 0 ||
++ (mac->channels[slot].flags &
++ (IEEE80211_CHAN_DISABLED | IEEE80211_CHAN_NO_20MHZ |
++ IEEE80211_CHAN_RADAR)))
++ return -ECANCELED;
++ }
+ if (!mac->join_channel_granted || mac->join_channel_released ||
+ mac->join_data_phase || mac->join_page_debt || mac->join_credit_pending)
+ return -EBUSY;
+@@ -2340,17 +2356,18 @@
+ ret = -EINVAL;
+ goto failed;
+ }
+- memcpy(mac->join_eth, skb->data + 16, ETH_ALEN);
+- memcpy(mac->join_eth + 6, skb->data + 10, ETH_ALEN);
+- memcpy(mac->join_eth + 12, skb->data + hl + 6, 2);
+- memcpy(mac->join_eth + 14, skb->data + hl + 8, skb->len - (hl + 8));
+ ret = mt6797_ccmp_assign_pid(mac, false, !port);
+ if (ret)
+ goto failed;
+ mac->join_last_acked = false;
+ reinit_completion(&mac->join_frame_done);
+- pages = (MT6797_JOIN_TX_DESC_BYTES + eth_bytes + 127) / 128;
+ if (!port) {
++ memcpy(mac->join_eth, skb->data + 16, ETH_ALEN);
++ memcpy(mac->join_eth + 6, skb->data + 10, ETH_ALEN);
++ memcpy(mac->join_eth + 12, skb->data + hl + 6, 2);
++ memcpy(mac->join_eth + 14, skb->data + hl + 8,
++ skb->len - (hl + 8));
++ pages = (MT6797_JOIN_TX_DESC_BYTES + eth_bytes + 127) / 128;
+ per_frame = mt6797_mac_tx_rate(mac, skb, &rate);
+ /* Retired on credit arrival: no PID in the descriptor
+ * and no status report; the host PID keys the slot.
+@@ -2388,9 +2405,10 @@
+ mac->join_frame_deadline = ktime_get_ns() + 750 * NSEC_PER_MSEC;
+ goto submitted;
+ }
+- ret = mt6797_hif_send_security(mac->hif, mac->join_eth, eth_bytes,
+- 1, mac->join_pid, 500,
+- MT6797_TX_ATTEMPTS, deadline);
++ pages = (MT6797_JOIN_TX_DESC_BYTES + skb->len + 127) / 128;
++ ret = mt6797_hif_send_eapol_native(mac->hif, skb->data, skb->len, 1,
++ mac->join_pid, 500,
++ MT6797_TX_ATTEMPTS, deadline);
+ if (ret)
+ goto failed;
+ mac->join_page_debt = pages;
+@@ -3403,6 +3421,52 @@
+ return ret;
+ }
+
++static void mt6797_mac_join_ht_elems(const struct mt6797_mac *mac,
++ u8 ht_op40[22], const u8 **ht_cap,
++ const u8 **ht_op)
++{
++ *ht_cap = NULL;
++ *ht_op = NULL;
++ if (!mac->join_wmm_accepted || !mac->join_ht_accepted ||
++ !mac->join_ht_op_seen || !mac->join_ht_peer_cap_seen)
++ return;
++ *ht_cap = mac->join_ht_peer_cap;
++ memcpy(ht_op40, mac->join_ht_op, 22);
++ /* As rlm.c does when 40 MHz is not allowed: without an HT40
++ * join, info 1 drops its secondary offset and channel width.
++ */
++ if (!mac->join_sco)
++ ht_op40[1] &= ~0x07;
++ *ht_op = ht_op40;
++}
++
++static int mt6797_mac_join_send_bss(struct mt6797_mac *mac, bool wpa2,
++ const u8 *ht_op)
++{
++ int ret;
++
++ if (mac->sequence > 253)
++ return -ENOSPC;
++ mac->join_credit_deadline = min_t(u64, mac->join_deadline,
++ ktime_get_ns() + 100 * NSEC_PER_MSEC);
++ reinit_completion(&mac->join_credit_done);
++ mac->join_credit_pending = true;
++ mac->join_page_debt = 1;
++ ret = mt6797_hif_join_bss_qos(mac->hif, mac->sequence++, mac->join_ap,
++ mac->join_chan_number,
++ mac->join_ssid, mac->join_ssid_bytes,
++ mac->join_desired_rates,
++ mac->join_peer_basic_rates,
++ mac->join_short_preamble,
++ mac->join_short_slot, wpa2,
++ mac->join_wmm_accepted,
++ ht_op, mac->join_credit_deadline);
++ mt6797_mac_join_refused(mac, ret);
++ if (!ret)
++ ret = mt6797_mac_join_wait_credit(mac);
++ return ret;
++}
++
+ int mt6797_mac_join_associate(struct mt6797_mac *mac, unsigned int aid)
+ {
+ u64 deadline, now;
+@@ -3422,39 +3486,11 @@
+ mac->ccmp_dtim_period = 0;
+ mac->ccmp_dtim_status = -ENODATA;
+ reinit_completion(&mac->ccmp_dtim_done);
+- /* Pinned vendor AIS applies BSS/RLM before the associated STA record. */
+- mac->join_credit_deadline = min_t(u64, mac->join_deadline,
+- ktime_get_ns() + 100 * NSEC_PER_MSEC);
+- reinit_completion(&mac->join_credit_done);
+- mac->join_credit_pending = true;
+- mac->join_page_debt = 1;
+ /* Both records declare HT only with WMM records and the access point's
+ * accepted HT; the element bodies are named once, as sent (0295).
+ */
+- if (mac->join_wmm_accepted && mac->join_ht_accepted &&
+- mac->join_ht_op_seen && mac->join_ht_peer_cap_seen) {
+- ht_cap = mac->join_ht_peer_cap;
+- ht_op = mac->join_ht_op;
+- /* As rlm.c does when 40 MHz is not allowed: without an HT40
+- * join, info 1 drops its secondary offset and channel width.
+- */
+- memcpy(ht_op40, mac->join_ht_op, sizeof(ht_op40));
+- if (!mac->join_sco)
+- ht_op40[1] &= ~0x07;
+- ht_op = ht_op40;
+- }
+- ret = mt6797_hif_join_bss_qos(mac->hif, mac->sequence++, mac->join_ap,
+- mac->join_chan_number,
+- mac->join_ssid, mac->join_ssid_bytes,
+- mac->join_desired_rates, mac->join_peer_basic_rates,
+- mac->join_short_preamble, mac->join_short_slot,
+- mac->join_rsn,
+- mac->join_wmm_accepted &&
+- 1,
+- ht_op, mac->join_credit_deadline);
+- mt6797_mac_join_refused(mac, ret);
+- if (!ret)
+- ret = mt6797_mac_join_wait_credit(mac);
++ mt6797_mac_join_ht_elems(mac, ht_op40, &ht_cap, &ht_op);
++ ret = mt6797_mac_join_send_bss(mac, mac->join_rsn, ht_op);
+ if (ret)
+ return ret;
+ mac->join_bss_configured = true;
+--- a/drivers/net/wireless/mediatek/mt6797/mac-priv.h
++++ b/drivers/net/wireless/mediatek/mt6797/mac-priv.h
+@@ -838,6 +838,7 @@
+ void mt6797_mac_join_await(struct mt6797_mac *mac, bool teardown);
+ void mt6797_mac_join_send_ps(struct mt6797_mac *mac);
+ bool mt6797_mac_join_ps_ready(const struct mt6797_mac *mac);
++void mt6797_mac_join_reopen_scan(struct mt6797_mac *mac);
+ bool mt6797_mac_join_retire_idle_scan(struct mt6797_mac *mac);
+ int mt6797_mac_send(struct mt6797_mac *mac,
+ enum mt6797_normal_config_kind kind,
+@@ -899,6 +900,8 @@
+
+ int mt6797_mac_join_associate(struct mt6797_mac *mac, unsigned int aid);
+
++int mt6797_channel_slot(unsigned int channel);
++
+ int mt6797_mac_join_request_cleanup(struct mt6797_mac *mac);
+
+ #endif /* MT6797_MAC_PRIV_H */
+--- a/drivers/net/wireless/mediatek/mt6797/main.c
++++ b/drivers/net/wireless/mediatek/mt6797/main.c
+@@ -66,7 +66,7 @@
+ return 0;
+ }
+
+-static inline int mt6797_channel_slot(unsigned int channel)
++int mt6797_channel_slot(unsigned int channel)
+ {
+ unsigned int i;
+
+@@ -130,6 +130,60 @@
+ return 0;
+ }
+
++/* When per-channel cfg80211 beacon hints punch NO_IR holes inside UNII bands,
++ * exact passive runs can exceed the firmware's six-subband CMD_SET_DOMAIN_INFO
++ * table. Coalesce [first_noir..last_noir] within each contiguous enabled
++ * operating-class run while keeping host channel->flags untouched.
++ */
++static inline int
++mt6797_regulatory_passive_coalesced(const struct mt6797_channel_limit *channels,
++ unsigned char *output)
++{
++ unsigned int i = 0, slot = 0, run_start, run_end, j, number;
++ int first_noir, last_noir;
++ unsigned char *band;
++
++ memset(output + 4, 0, 48);
++ while (i < MT6797_CHANNELS) {
++ if (!channels[i].enabled) {
++ i++;
++ continue;
++ }
++ run_start = i++;
++ number = mt6797_channel_number(run_start);
++ while (i < MT6797_CHANNELS &&
++ channels[i].enabled &&
++ mt6797_channel_class(mt6797_channel_number(i)) ==
++ mt6797_channel_class(number) &&
++ mt6797_channel_number(i) ==
++ mt6797_channel_number(i - 1) +
++ (run_start < MT6797_2G_CHANNELS ? 1 : 4))
++ i++;
++ run_end = i;
++ first_noir = -1;
++ last_noir = -1;
++ for (j = run_start; j < run_end; j++) {
++ if (channels[j].no_ir) {
++ if (first_noir < 0)
++ first_noir = j;
++ last_noir = j;
++ }
++ }
++ if (first_noir < 0)
++ continue;
++ if (slot == 6)
++ return -E2BIG;
++ number = mt6797_channel_number(first_noir);
++ band = output + 4 + 8 * slot++;
++ band[0] = mt6797_channel_class(number);
++ band[1] = first_noir < MT6797_2G_CHANNELS ? 1 : 2;
++ band[2] = first_noir < MT6797_2G_CHANNELS ? 1 : 4;
++ band[3] = number;
++ band[4] = last_noir - first_noir + 1;
++ }
++ return 0;
++}
++
+ /* Source wire layouts: two 56-byte domains and CID 0x38's 32-byte control.
+ * Disabled channels are absent from both domain lists; their minimum power
+ * byte is not an RF-disable mechanism. NO_IR channels appear in the passive
+@@ -189,6 +243,8 @@
+ built.power[26 + group] = (unsigned char)unii_power[group];
+
+ error = mt6797_regulatory_ranges(channels, true, built.passive);
++ if (error == -E2BIG)
++ error = mt6797_regulatory_passive_coalesced(channels, built.passive);
+ if (!error)
+ error = mt6797_regulatory_ranges(channels, false, built.domain);
+ if (error)
+@@ -342,7 +398,10 @@
+ return 0;
+ }
+
+-static const u32 mt6797_ccmp_ciphers[] = { WLAN_CIPHER_SUITE_CCMP };
++static const u32 mt6797_ccmp_ciphers[] = {
++ WLAN_CIPHER_SUITE_CCMP,
++ WLAN_CIPHER_SUITE_TKIP,
++};
+
+ int mt6797_mac_send(struct mt6797_mac *mac,
+ enum mt6797_normal_config_kind kind,
+@@ -472,6 +531,8 @@
+ memcpy(mac->alpha2, "00", 2);
+ }
+
++static int mt6797_mac_await_idle(struct mt6797_mac *mac, u64 end);
++
+ static void mt6797_mac_regulatory(struct wiphy *wiphy,
+ struct regulatory_request *request)
+ {
+@@ -505,30 +566,43 @@
+ goto out;
+ }
+ memcpy(mac->alpha2, saved, 2);
+- /* A disconnect makes cfg80211 pass through the world domain and
+- * back to the country. For a roam that lands just after the
+- * join starts, so let the join run while it settles; the
+- * firmware keeps its domain. A change still unsettled when the
+- * data phase starts ends the lifetime there.
++ /* A disconnect or association Country IE transitions cfg80211
++ * between world ("00") and the AP's country while a join or
++ * connected data phase is active. Keep the session alive as
++ * long as our operating channel remains permitted; a change
++ * that disables or marks radar on our channel stops below.
+ */
+- if (mac->join_running && !mac->join_retired && !mac->join_cleanup_done &&
+- !mac->join_data_phase && mac->join_scan_ready) {
+- mac->reg_pending = true;
+- goto out;
++ if (mac->join_running && !mac->join_retired && !mac->join_cleanup_done) {
++ int slot = mac->join_channel_valid ?
++ mt6797_channel_slot(mac->join_chan_number) : -1;
++ bool chan_ok = !mac->join_channel_valid ||
++ (slot >= 0 &&
++ !(mac->channels[slot].flags &
++ (IEEE80211_CHAN_DISABLED | IEEE80211_CHAN_NO_20MHZ |
++ IEEE80211_CHAN_RADAR)));
++
++ if (chan_ok) {
++ mac->reg_pending = true;
++ goto out;
++ }
+ }
+ }
+ if (mt6797_mac_join_regulatory_stop(mac, &discard, &internal))
+ goto out;
+ /* Regulatory changes retire an accepted scan before submitting updates.
+- * Host completion does not claim firmware cancellation or queue drain.
+ */
+ if (mac->scan_active) {
+- struct cfg80211_scan_info info = {.aborted = true};
+ int cancelled = -ECANCELED;
+
+- mt6797_mac_finish_scan(mac, &cancelled, true);
+- ieee80211_scan_completed(mac->hw, &info);
+- goto out;
++ if (mt6797_mac_finish_scan(mac, &cancelled, true)) {
++ mutex_unlock(&mac->mutex);
++ cancel_delayed_work_sync(&mac->scan_work);
++ ieee80211_scan_completed(mac->hw,
++ &(struct cfg80211_scan_info){.aborted = true});
++ mutex_lock(&mac->mutex);
++ }
++ if (mac->closing || mac->first_error)
++ goto out;
+ }
+ mt6797_mac_set_alpha2(mac, request->alpha2);
+ /* Before configuration, save the tag only. The initial transaction
+@@ -536,7 +610,15 @@
+ */
+ if (!mac->configured)
+ goto out;
+- ret = mt6797_mac_send_regulatory(mac);
++ ret = mt6797_mac_await_idle(mac, ktime_get_ns() + 500 * NSEC_PER_MSEC);
++ if (!ret && mac->sequence > 200 && mac->sequence_base &&
++ !mac->join_page_debt && !mac->join_data_page_debt &&
++ !mt6797_hif_recycle_sequences(mac->hif, mac->sequence_base))
++ mac->sequence = mac->sequence_base;
++ if (!ret)
++ ret = mt6797_mac_send_regulatory(mac);
++ if (!ret)
++ mac->reg_pending = false;
+ if (ret) {
+ mac->first_error = ret;
+ dev_err(wiphy_dev(wiphy), "regulatory submission stopped (%d)\n", ret);
+@@ -572,16 +654,50 @@
+ return ret;
+ }
+
+-/* Stop exactly one accepted host request. The scan/BSS slots remain retired
+- * even after normal completion: no unproved cancellation/reuse fence is used.
++static int mt6797_mac_await_idle(struct mt6797_mac *mac, u64 end);
++
++static int mt6797_mac_drain_cancelled_scan(struct mt6797_mac *mac)
++{
++ struct mt6797_hif_rx_result rx;
++ unsigned int n, port;
++ u64 deadline;
++ int ret;
++
++ ret = mt6797_mac_await_idle(mac, ktime_get_ns() + 500 * NSEC_PER_MSEC);
++ if (ret)
++ return ret;
++ mt6797_hif_rx_batch_pass(mac->hif);
++ for (n = 0; n < 32; n++) {
++ bool got = false;
++
++ deadline = ktime_get_ns() + 50 * NSEC_PER_MSEC;
++ for (port = 0; port < 2; port++) {
++ ret = mt6797_hif_receive_runtime_packet(mac->hif, port, deadline,
++ mac->scan_packet,
++ sizeof(mac->scan_packet), &rx);
++ if (ret == -EAGAIN)
++ continue;
++ if (ret)
++ return ret;
++ got = true;
++ }
++ if (!got)
++ break;
++ }
++ return 0;
++}
++
++/* Stop exactly one accepted host request. A live host cancellation (-ECANCELED)
++ * that cleanly cancels and disables the scan BSS reopens the scan slot; only
++ * actual hardware/protocol faults poison first_error.
+ * Never submit cleanup after a transport, ownership or protocol failure.
+ */
+ static bool mt6797_mac_finish_scan(struct mt6797_mac *mac, int *status,
+ bool cancel)
+ {
+ u8 bss[12], abort[4] = {mac->scan_sequence, 0, 0, 0};
+- bool retain = false;
+- int ret;
++ bool retain = false, cancelled;
++ int ret, hw_err = 0;
+
+ if (!mac->scan_active)
+ return false;
+@@ -612,23 +728,37 @@
+ ret = mt6797_mac_send(mac, MT6797_NORMAL_SCAN_CANCEL,
+ abort, sizeof(abort));
+ if (ret)
+- *status = ret;
++ hw_err = ret;
+ }
+- if (!retain && mac->bss_active && !mac->first_error) {
++ if (!retain && mac->bss_active && !mac->first_error && !hw_err) {
+ mt6797_scan_bss(mac->hw->wiphy->perm_addr, false, bss);
+ ret = mt6797_mac_send(mac, MT6797_NORMAL_BSS_ACTIVE,
+ bss, sizeof(bss));
+ if (ret)
+- *status = ret;
++ hw_err = ret;
+ else
+ mac->bss_active = false;
+ }
+- if (*status && !mac->first_error)
++ cancelled = cancel && *status == -ECANCELED && !hw_err && !mac->first_error &&
++ !mac->closing && !mac->join_closed && !mac->join_peer_used &&
++ !mac->join_retired;
++ if (cancelled) {
++ hw_err = mt6797_mac_drain_cancelled_scan(mac);
++ if (!hw_err)
++ mt6797_mac_join_reopen_scan(mac);
++ }
++ if (hw_err) {
++ *status = hw_err;
++ if (!mac->first_error)
++ mac->first_error = hw_err;
++ } else if (*status && *status != -ECANCELED && !mac->first_error) {
+ mac->first_error = *status;
++ }
+ memzero_explicit(mac->scan_packet, sizeof(mac->scan_packet));
+ dev_info(wiphy_dev(mac->hw->wiphy),
+- "one-shot passive WLAN scan: status=%d complete=%u frame=%u beacon=%u credit=%u retired=1\n",
+- *status, !*status, mac->scan_frame_seen, mac->scan_beacon, mac->scan_credit);
++ "one-shot passive WLAN scan: status=%d complete=%u frame=%u beacon=%u credit=%u retired=%u\n",
++ *status, !*status, mac->scan_frame_seen, mac->scan_beacon,
++ mac->scan_credit, !cancelled || !!hw_err);
+ return true;
+ }
+
+@@ -725,14 +855,18 @@
+ {
+ u8 payload[MT6797_PASSIVE_SCAN_BYTES];
+ bool probing = mac->scan_next < mac->scan_probing;
+- unsigned int count;
++ unsigned int count, next_seq;
+ int ret;
+
+ /* A request is all probing or all passive. */
+ count = min((probing ? mac->scan_probing : mac->scan_total) - mac->scan_next,
+ MT6797_SCAN_REQUEST_CHANNELS);
++ /* Keep scan_sequence monotonic within a session so stale 0x0d events
++ * emitted after a cancelled scan never match a later scan request.
++ */
++ next_seq = mac->scan_sequence >= 255 ? 1 : mac->scan_sequence + 1;
+ /* The firmware's default dwell for probing, as the vendor asks. */
+- ret = mt6797_scan_request(mac->scan_sequence + 1,
++ ret = mt6797_scan_request(next_seq,
+ mac->scan_list + mac->scan_next, count,
+ probing ? 0 : mac->scan_dwell_ms, probing,
+ mac->scan_ssids, mac->scan_n_ssids, payload);
+@@ -741,7 +875,7 @@
+ sizeof(payload));
+ if (ret)
+ return ret;
+- mac->scan_sequence++;
++ mac->scan_sequence = next_seq;
+ mac->scan_next += count;
+ mac->scan_count = count;
+ mac->scan_deadline = ktime_get_ns() + 5 * NSEC_PER_SEC +
+@@ -785,7 +919,7 @@
+ return mt6797_mac_send(mac, MT6797_NORMAL_SCAN_CANCEL, abort, sizeof(abort));
+ }
+ if (mac->join_data_ended || ktime_get_ns() >= mac->scan_deadline) {
+- mac->scan_online_cancel = !!mac->scan_sequence;
++ mac->scan_online_cancel = mac->scan_next > 0;
+ mt6797_mac_online_scan_end(mac, true);
+ return 0;
+ }
+@@ -967,6 +1101,14 @@
+ mac->first_error = ret;
+ return ret;
+ }
++ if (mac->sequence > 200 && mac->sequence_base &&
++ !mac->join_page_debt && !mac->join_data_page_debt &&
++ !mt6797_hif_recycle_sequences(mac->hif, mac->sequence_base)) {
++ dev_info(wiphy_dev(mac->hw->wiphy),
++ "one-shot WLAN idle scan sequence recycle: from=%u to=%u\n",
++ mac->sequence, mac->sequence_base);
++ mac->sequence = mac->sequence_base;
++ }
+ if (mac->monitor_left_on) {
+ ret = mt6797_hif_diag_mask(mac->hif, mac->sequence++, false,
+ ktime_get_ns() + NSEC_PER_SEC);
+@@ -1146,7 +1288,6 @@
+ }
+ mac->scan_total = request->req.n_channels;
+ mac->scan_next = 0;
+- mac->scan_sequence = 0;
+ /* The firmware's default dwell: it keeps returning to the channel. */
+ mac->scan_dwell_ms = 0;
+ mac->scan_channels = mask;
+@@ -1164,7 +1305,6 @@
+ goto out;
+ mac->scan_total = request->req.n_channels;
+ mac->scan_next = 0;
+- mac->scan_sequence = 0;
+ mac->scan_dwell_ms = mac->scan_total == 1 ? MT6797_PASSIVE_SCAN_DWELL_MS :
+ MT6797_PASSIVE_SWEEP_DWELL_MS;
+ ret = mt6797_mac_scan_submit(mac);
+@@ -1189,7 +1329,7 @@
+ {
+ struct mt6797_mac *mac = hw->priv;
+ struct cfg80211_scan_info info = {.aborted = true};
+- bool notify;
++ bool notify, teardown;
+ int ret = -ECANCELED;
+ bool close_join;
+ unsigned long flags;
+@@ -1197,11 +1337,21 @@
+ mutex_lock(&mac->mutex);
+ if (mac->scan_online) {
+ /* The connection stays; the worker sends the firmware's cancel. */
+- mac->scan_online_cancel = !!mac->scan_sequence;
++ mac->scan_online_cancel = mac->scan_next > 0;
+ mt6797_mac_online_scan_end(mac, true);
+ mutex_unlock(&mac->mutex);
+ return;
+ }
++ teardown = !vif || mac->join_closed || mac->closing ||
++ mac->first_error || mac->join_peer_used;
++ if (!teardown) {
++ notify = mac->scan_active ? mt6797_mac_finish_scan(mac, &ret, true) : false;
++ mutex_unlock(&mac->mutex);
++ cancel_delayed_work_sync(&mac->scan_work);
++ if (notify)
++ ieee80211_scan_completed(hw, &info);
++ return;
++ }
+ /* Cancellation can race the queued host completion after scan_active clears. */
+ mac->join_retired = true;
+ close_join = mac->join_scan_ready || mac->join_running || mac->join_peer_used;
+@@ -1300,6 +1450,8 @@
+ /* mac80211 passes radio_idx -1 for a wiphy without per-radio
+ * configuration; only a radio-specific request is unsupported here.
+ */
++ if (mac->vif && (mac->closing || mac->first_error || mac->join_closed))
++ mt6797_consys_wlan_request_restart();
+ if (!mac->scan_ready || mac->first_error || mac->closing || radio_idx != -1 ||
+ (hw->conf.flags & IEEE80211_CONF_MONITOR) ||
+ ((hw->conf.flags & IEEE80211_CONF_PS) && !mac->ps_profile))
+@@ -1321,8 +1473,7 @@
+ def->center_freq1 == channel->center_freq - 10))) &&
+ !def->center_freq2 &&
+ !(channel->flags & (IEEE80211_CHAN_DISABLED |
+- IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_20MHZ |
+- IEEE80211_CHAN_RADAR));
++ IEEE80211_CHAN_NO_20MHZ | IEEE80211_CHAN_RADAR));
+ /* Diagnostic only: name the first rejected operating channel
+ * so a refused join can be attributed offline.
+ */
+@@ -1660,6 +1811,21 @@
+ "one-shot WLAN power save: profile=%u status=%d\n", profile, ret);
+ }
+
++static void mt6797_copy_key_seq(u32 cipher, const struct ieee80211_key_seq *seq,
++ u8 pn[6])
++{
++ if (cipher == WLAN_CIPHER_SUITE_TKIP) {
++ pn[0] = (seq->tkip.iv32 >> 24) & 0xff;
++ pn[1] = (seq->tkip.iv32 >> 16) & 0xff;
++ pn[2] = (seq->tkip.iv32 >> 8) & 0xff;
++ pn[3] = seq->tkip.iv32 & 0xff;
++ pn[4] = (seq->tkip.iv16 >> 8) & 0xff;
++ pn[5] = seq->tkip.iv16 & 0xff;
++ } else {
++ memcpy(pn, seq->ccmp.pn, 6);
++ }
++}
++
+ static int mt6797_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
+ struct ieee80211_vif *vif, struct ieee80211_sta *sta,
+ struct ieee80211_key_conf *key)
+@@ -1708,7 +1874,10 @@
+ !mac->join_sta_active || !mac->join_bss_configured ||
+ mac->join_retired || mac->closing || mac->first_error ||
+ mac->join_credit_pending ||
+- key->cipher != WLAN_CIPHER_SUITE_CCMP || key->keylen != 16 ||
++ !((pairwise && key->cipher == WLAN_CIPHER_SUITE_CCMP && key->keylen == 16) ||
++ (!pairwise &&
++ ((key->cipher == WLAN_CIPHER_SUITE_CCMP && key->keylen == 16) ||
++ (key->cipher == WLAN_CIPHER_SUITE_TKIP && key->keylen == 32)))) ||
+ key->keyidx < 0 || key->keyidx > 3 || mac->sequence > 253 ||
+ (pairwise && (!sta || !ether_addr_equal(sta->addr, mac->join_ap) ||
+ key->keyidx || mac->join_key_pairwise)) ||
+@@ -1766,9 +1935,10 @@
+ reinit_completion(&mac->join_credit_done);
+ mac->join_credit_pending = true;
+ mac->join_page_debt = 1;
+- ret = mt6797_hif_join_key(mac->hif, mac->sequence++, true, pairwise,
+- mac->join_ap, key->keyidx, key->key,
+- mac->join_credit_deadline);
++ ret = mt6797_hif_join_key_cipher(mac->hif, mac->sequence++, true, pairwise,
++ key->cipher == WLAN_CIPHER_SUITE_TKIP,
++ mac->join_ap, key->keyidx, key->key,
++ mac->join_credit_deadline);
+ mt6797_mac_join_refused(mac, ret);
+ if (!ret && pairwise)
+ mac->join_key_pairwise_submitted = true;
+@@ -1794,9 +1964,10 @@
+ ret = mac->first_error ? mac->first_error : -ETIMEDOUT;
+ goto failed;
+ }
+- memcpy(mac->ccmp_rx.pn, seed.ccmp.pn, 6);
++ mt6797_copy_key_seq(key->cipher, &seed, mac->ccmp_rx.pn);
+ for (tid = 1; tid < MT6797_CCMP_RX_TIDS; tid++)
+- memcpy(mac->ccmp_rx.tid_pn[tid - 1], tid_seed[tid - 1].ccmp.pn, 6);
++ mt6797_copy_key_seq(key->cipher, &tid_seed[tid - 1],
++ mac->ccmp_rx.tid_pn[tid - 1]);
+ memcpy(mac->ccmp_rx.own, hw->wiphy->perm_addr, 6);
+ memcpy(mac->ccmp_rx.ap, mac->join_ap, 6);
+ mac->ccmp_rx.cipher = key->cipher;
+@@ -1823,9 +1994,10 @@
+ ret = mac->first_error ? mac->first_error : -EOPNOTSUPP;
+ goto failed;
+ }
+- memcpy(mac->ccmp_gtk_rx.pn, seed.ccmp.pn, 6);
++ mt6797_copy_key_seq(key->cipher, &seed, mac->ccmp_gtk_rx.pn);
+ for (tid = 1; tid < MT6797_CCMP_RX_TIDS; tid++)
+- memcpy(mac->ccmp_gtk_rx.tid_pn[tid - 1], tid_seed[tid - 1].ccmp.pn, 6);
++ mt6797_copy_key_seq(key->cipher, &tid_seed[tid - 1],
++ mac->ccmp_gtk_rx.tid_pn[tid - 1]);
+ memcpy(mac->ccmp_gtk_rx.own, hw->wiphy->perm_addr, 6);
+ memcpy(mac->ccmp_gtk_rx.ap, mac->join_ap, 6);
+ mac->ccmp_gtk_rx.cipher = key->cipher;
+@@ -2439,7 +2611,7 @@
+ *out = NULL;
+ if (!dev || !hif || !capability || !record)
+ return -EINVAL;
+- if (capability->product != 0x6797 || capability->firmware_own != 0x0403 ||
++ if (capability->product != 0x6797 || !capability->firmware_own ||
+ capability->firmware_peer || capability->rf_cal_fail ||
+ capability->bb_cal_fail || !mt6797_wifi_record_commands(record))
+ return -EOPNOTSUPP;
+@@ -2566,6 +2738,8 @@
+ mac->band_5g.ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
+ hw->wiphy->bands[NL80211_BAND_5GHZ] = &mac->band_5g;
+ }
++ /* This driver handles Open System + PSK auth only; do not advertise SAE. */
++ hw->wiphy->features &= ~NL80211_FEATURE_SAE;
+ ret = ieee80211_register_hw(hw);
+ if (ret)
+ goto free_hw;
+--- a/drivers/net/wireless/mediatek/mt6797/mcu.h
++++ b/drivers/net/wireless/mediatek/mt6797/mcu.h
+@@ -773,6 +773,66 @@
+ return true;
+ }
+
++/* Native 802.11 unprotected EAPOL TX descriptor on TC4: avoids firmware header
++ * translation/encryption quirks during pre-key 4-way handshake while preserving
++ * exact sequence, AID/QoS control, and LLC/SNAP framing from mac80211.
++ */
++static inline bool
++mt6797_join_tx_eapol_native_descriptor(const unsigned char *frame, size_t bytes,
++ unsigned char wlan, unsigned char pid,
++ unsigned int lifetime_ms,
++ unsigned int attempt_count,
++ unsigned char output[MT6797_JOIN_TX_DESC_BYTES],
++ unsigned int *pages)
++{
++ unsigned char d[MT6797_JOIN_TX_DESC_BYTES] = {0};
++ unsigned int fc, hl, subtype, sequence, lifetime, total, count, i;
++
++ if (!frame || !output || !pages || bytes < 36 || bytes > 2304 ||
++ wlan > 30 || !pid || pid > 127 || !lifetime_ms ||
++ lifetime_ms > 10000 || !attempt_count || attempt_count > 30)
++ return false;
++ fc = mt6797_join_le16(frame);
++ if ((fc & 0xff7fU) != 0x0108U)
++ return false; /* Unprotected To-DS Data or QoS Data only. */
++ hl = (fc & 0x0080U) ? 26U : 24U;
++ if (bytes < hl + 12 || (frame[22] & 15) ||
++ (hl == 26U && (frame[24] & 0x80U)))
++ return false;
++ if ((frame[4] & 1) || (frame[10] & 1) ||
++ frame[hl] != 0xaa || frame[hl + 1] != 0xaa || frame[hl + 2] != 3 ||
++ frame[hl + 3] || frame[hl + 4] || frame[hl + 5] ||
++ frame[hl + 6] != 0x88 || frame[hl + 7] != 0x8e)
++ return false;
++ subtype = (fc >> 4) & 15U;
++ sequence = mt6797_join_le16(frame + 22) >> 4;
++ lifetime = (lifetime_ms * 1000U / 1024U) >> 5;
++ if (!lifetime)
++ lifetime = 1;
++ if (lifetime > 255)
++ lifetime = 255;
++ total = MT6797_JOIN_TX_DESC_BYTES + bytes;
++ count = attempt_count << 11;
++ d[0] = total; d[1] = total >> 8;
++ d[2] = (MT6797_JOIN_TX_DESC_BYTES + hl) / 2;
++ d[3] = 0x88; /* TC4: MCU port, queue 1. */
++ d[4] = wlan;
++ d[5] = 0xc0U | (unsigned char)(hl / 2U); /* Long descriptor, native 802.11 */
++ d[6] = (hl == 26U) ? (unsigned char)((frame[24] & 7U) << 4) : 0; /* PF=0 */
++ d[7] = 1U << 2; /* Own-MAC 1 */
++ d[8] = (2U << 4) | (unsigned char)subtype; /* Type 2 (Data) | subtype */
++ d[10] = lifetime;
++ d[11] = 0x80; /* Fixed rate enabled, zero power offset. */
++ d[12] = count; d[13] = count >> 8;
++ d[14] = sequence; d[15] = (sequence >> 8) | 0x80;
++ d[20] = pid; d[21] = 2; /* TX status to MCU. */
++ d[26] = (0x4bU << 2) & 255; d[27] = (0x4bU << 2) >> 8;
++ for (i = 0; i < MT6797_JOIN_TX_DESC_BYTES; i++)
++ output[i] = d[i];
++ *pages = (total + 127U) / 128U;
++ return true;
++}
++
+ /* Original encoder from the pinned public gen3 nicTxComposeDesc path for one
+ * protected Ethernet II data frame of a legacy station: TC1 (PORT_INDEX_LMAC
+ * 0, MAC_TXQ_AC1_INDEX 1, the pinned arTcResourceControl row), long format,
+@@ -1089,16 +1149,18 @@
+ * payload and the transfer buffer after submission; nothing is retained.
+ */
+ static inline bool
+-mt6797_join_key_payload(bool add, bool pairwise, const unsigned char *peer,
+- unsigned int key_id, const unsigned char *material,
+- unsigned char output[MT6797_JOIN_KEY_BYTES])
++mt6797_join_key_payload_cipher(bool add, bool pairwise, bool tkip,
++ const unsigned char *peer,
++ unsigned int key_id, const unsigned char *material,
++ unsigned char output[MT6797_JOIN_KEY_BYTES])
+ {
+ unsigned char p[MT6797_JOIN_KEY_BYTES] = {0};
+ unsigned int i, any = 0;
+
+ bool group_removal = !add && !pairwise;
+
+- if (!output || key_id > 3 || (pairwise && key_id) || (add && !material))
++ if (!output || key_id > 3 || (pairwise && (key_id || tkip)) ||
++ (add && !material))
+ return false;
+ if (group_removal) {
+ if (peer)
+@@ -1117,20 +1179,37 @@
+ if (!group_removal)
+ for (i = 0; i < 6; i++)
+ p[4 + i] = peer[i];
+- p[11] = add ? 4 : 0;
++ p[11] = add ? (tkip ? 2 : 4) : 0;
+ p[12] = key_id;
+- p[13] = add ? 16 : 0;
++ p[13] = add ? (tkip ? 32 : 16) : 0;
+ p[14] = pairwise ? 1 : group_removal ? MT6797_JOIN_RESERVED_WLAN_INDEX :
+ MT6797_JOIN_BMC_WLAN_INDEX;
+- if (add)
++ if (add) {
+ for (i = 0; i < 16; i++)
+ p[16 + i] = material[i];
++ if (tkip) {
++ /* Swap Linux NL80211 TX/RX MIC (16..23 / 24..31) to MediaTek Gen3 order. */
++ for (i = 0; i < 8; i++) {
++ p[32 + i] = material[24 + i];
++ p[40 + i] = material[16 + i];
++ }
++ }
++ }
+ for (i = 0; i < MT6797_JOIN_KEY_BYTES; i++)
+ output[i] = p[i];
+ mt6797_join_clear(p, MT6797_JOIN_KEY_BYTES);
+ return true;
+ }
+
++static inline bool
++mt6797_join_key_payload(bool add, bool pairwise, const unsigned char *peer,
++ unsigned int key_id, const unsigned char *material,
++ unsigned char output[MT6797_JOIN_KEY_BYTES])
++{
++ return mt6797_join_key_payload_cipher(add, pairwise, false, peer,
++ key_id, material, output);
++}
++
+ /* The monitor control the proven data path uses: the stock SET_MONITOR
+ * callback's complete Boolean-mask store, written directly as one word at
+ * its fixed address through the register-access command. Only this address
+--- a/drivers/soc/mediatek/mt6797-consys.c
++++ b/drivers/soc/mediatek/mt6797-consys.c
+@@ -27,11 +27,11 @@
+ #include
+ #include
+ #include
+-#include
+ #include
+ #include
+ #include
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -151,7 +151,7 @@
+ unsigned char command[WMT_FULL_MAX_PAYLOAD];
+ unsigned char calibration[8];
+ struct wmt_init_step step;
+- unsigned int completed, antenna_mode, calibration_bytes;
++ unsigned int completed, total_steps, antenna_mode, calibration_bytes;
+ int result;
+ bool bt_rail, wifi_rail;
+ } common_init;
+@@ -193,7 +193,7 @@
+ #if IS_ENABLED(CONFIG_MT6797_MAC80211)
+ static DEFINE_MUTEX(mt6797_consys_wlan_lock);
+
+-#define MT6797_CONSYS_RESTART_SPACING_NS (30ULL * NSEC_PER_SEC)
++#define MT6797_CONSYS_RESTART_SPACING_NS (3ULL * NSEC_PER_SEC)
+ #endif
+
+ static int mt6797_consys_check_supplies(struct device_node *node)
+@@ -487,6 +487,15 @@
+ remap_after = remap_before;
+ goto clear;
+ }
++ if (region1 == 0x44604460 &&
++ range19 == expected_range && policy19 == MT6797_EMI_COPY_POLICY &&
++ !range18 && !policy18 && !range23 && !policy23 &&
++ remap_before == (MT6797_REMAP_OFF_VALUE | requested)) {
++ dev_info(dev, "WMT setup kept from an earlier partial start: region 19 and remap as set\n");
++ owner->wmt_init_attempted = true;
++ remap_after = remap_before;
++ goto clear;
++ }
+ if (remap_before != MT6797_REMAP_OFF_VALUE ||
+ region1 != 0x44604460 || range18 || policy18 || range19 ||
+ policy19 || range23 || policy23) {
+@@ -1091,11 +1100,14 @@
+ }
+
+ static void mt6797_consys_wlan_restart_work(struct work_struct *work);
+-static DECLARE_WORK(mt6797_consys_wlan_restart, mt6797_consys_wlan_restart_work);
++static DECLARE_DELAYED_WORK(mt6797_consys_wlan_restart,
++ mt6797_consys_wlan_restart_work);
++static DEFINE_SPINLOCK(mt6797_consys_restart_lock);
++static u64 mt6797_consys_last_restart_ns;
+
+ void mt6797_consys_wlan_detach(const struct mt6797_mac_ops *ops)
+ {
+- cancel_work_sync(&mt6797_consys_wlan_restart);
++ cancel_delayed_work_sync(&mt6797_consys_wlan_restart);
+ mt6797_consys_wlan_detach_now(ops);
+ }
+ EXPORT_SYMBOL_GPL(mt6797_consys_wlan_detach);
+@@ -1110,6 +1122,7 @@
+ struct mt6797_consys *owner = &mt6797_consys;
+ const struct mt6797_mac_ops *ops;
+ struct device *dev;
++ unsigned long flags;
+ int ret;
+
+ mutex_lock(&mt6797_consys_wlan_lock);
+@@ -1120,28 +1133,39 @@
+ put_device(dev);
+ return;
+ }
++ spin_lock_irqsave(&mt6797_consys_restart_lock, flags);
++ mt6797_consys_last_restart_ns = ktime_get_ns();
++ spin_unlock_irqrestore(&mt6797_consys_restart_lock, flags);
+ dev_info(dev, "WLAN restart: begin\n");
+ mt6797_consys_wlan_detach_now(ops);
+ ret = device_reprobe(dev);
+ if (!ret)
+ ret = mt6797_consys_wlan_attach(ops);
++ spin_lock_irqsave(&mt6797_consys_restart_lock, flags);
++ mt6797_consys_last_restart_ns = ktime_get_ns();
++ spin_unlock_irqrestore(&mt6797_consys_restart_lock, flags);
+ dev_info(dev, "WLAN restart: status=%d\n", ret);
+ put_device(dev);
+ }
+
+ void mt6797_consys_wlan_request_restart(void)
+ {
+- static u64 last;
+- u64 now = ktime_get_ns();
++ u64 now = ktime_get_ns(), delay_ns = 0;
++ unsigned long flags;
+
+- /* Built in, CONSYS has no remove path to restart through. A fault that
+- * repeats at once stays down between tries.
++ /* Built in, CONSYS has no remove path to restart through. Space
++ * repeated restarts cleanly without dropping recovery requests.
+ */
+- if (!IS_MODULE(CONFIG_MTK_MT6797_CONSYS) ||
+- (last && now - last < MT6797_CONSYS_RESTART_SPACING_NS))
++ if (!IS_MODULE(CONFIG_MTK_MT6797_CONSYS))
+ return;
+- last = now;
+- schedule_work(&mt6797_consys_wlan_restart);
++ spin_lock_irqsave(&mt6797_consys_restart_lock, flags);
++ if (mt6797_consys_last_restart_ns &&
++ now - mt6797_consys_last_restart_ns < MT6797_CONSYS_RESTART_SPACING_NS)
++ delay_ns = MT6797_CONSYS_RESTART_SPACING_NS -
++ (now - mt6797_consys_last_restart_ns);
++ spin_unlock_irqrestore(&mt6797_consys_restart_lock, flags);
++ schedule_delayed_work(&mt6797_consys_wlan_restart,
++ nsecs_to_jiffies(delay_ns));
+ }
+ EXPORT_SYMBOL_GPL(mt6797_consys_wlan_request_restart);
+
+@@ -1222,6 +1246,7 @@
+ static const u8 start[16] = {
+ 16, 0, 0, 0x80, 2, 0xa0, 0, 3,
+ };
++ struct mt6797_wlan_firmware_summary summary = {};
+ struct mt6797_wlan_ordinary_result ordinary = {};
+ struct mt6797_normal_capability capability;
+ struct mt6797_capability_trace cap_trace;
+@@ -1314,12 +1339,14 @@
+ 1,
+ 1);
+ }
++ (void)mt6797_wlan_firmware_summary(owner->wlan_image, &summary);
+ ret = mt6797_wlan_firmware_submit_ordinary(owner->wlan_image,
+ owner->fw_hif, &ordinary);
+ dev_info(dev,
+- "one-shot WLAN ordinary transfer: status=%d completed=%u/2 bytes=%zu/14832 failed_index=%u firmware_status=%u partial=%zu\n",
+- ret, ordinary.sections, ordinary.bytes, ordinary.failed_index,
+- ordinary.firmware_status, ordinary.partial_submitted);
++ "one-shot WLAN ordinary transfer: status=%d completed=%u/2 bytes=%zu/%zu failed_index=%u firmware_status=%u partial=%zu\n",
++ ret, ordinary.sections, ordinary.bytes, summary.ordinary_bytes,
++ ordinary.failed_index, ordinary.firmware_status,
++ ordinary.partial_submitted);
+ if (ret)
+ goto stopped;
+ ret = mt6797_hif_read32(owner->fw_hif, 0,
+@@ -1488,9 +1515,11 @@
+ ret = mt6797_wlan_firmware_summary(owner->wlan_image, &summary);
+ if (ret || summary.sections != 4 ||
+ summary.ordinary_sections != 2 ||
+- summary.ordinary_bytes != 14832 ||
++ !summary.ordinary_bytes ||
++ summary.ordinary_bytes > SZ_1M ||
+ summary.emi_sections != 2 ||
+- summary.emi_bytes != 396688) {
++ !summary.emi_bytes ||
++ summary.emi_bytes > SZ_512K) {
+ ret = ret ?: -EINVAL;
+ goto stopped;
+ }
+@@ -1589,19 +1618,10 @@
+ /* Vendor WMT_LIB_RX_TIMEOUT, used for every WMT event including calibration. */
+ #define MT6797_WMT_INIT_EXCHANGE_MS 2000U
+
+-/* Retained Gemian pair, in download order; contents stay outside the kernel. */
+-static const struct {
+- const char *name;
+- u8 sha256[SHA256_DIGEST_SIZE];
+-} mt6797_rom_patches[2] = {
+- { "mediatek/mt6797/ROMv3_patch_1_1_hdr.bin", {
+- 0x57, 0x32, 0xc0, 0x73, 0x03, 0x80, 0xe9, 0x37, 0xb4, 0x8a, 0xd1, 0x69,
+- 0xf2, 0x80, 0x5b, 0x65, 0xe8, 0xd4, 0xa1, 0x78, 0x26, 0x55, 0x66, 0xc5,
+- 0x08, 0x3c, 0xb2, 0xcc, 0x2d, 0x24, 0x9f, 0x1e } },
+- { "mediatek/mt6797/ROMv3_patch_1_0_hdr.bin", {
+- 0x45, 0x0c, 0x2b, 0x09, 0x49, 0xcf, 0x87, 0x92, 0x17, 0xac, 0x9a, 0xef,
+- 0x81, 0xb1, 0x8b, 0x86, 0x09, 0x82, 0xf0, 0xe6, 0x93, 0x40, 0x78, 0x4b,
+- 0x44, 0x8b, 0x54, 0x36, 0x5d, 0x8c, 0xf6, 0x30 } },
++/* ROM patch filenames in download order; verified via container metadata. */
++static const char * const mt6797_rom_patches[2] = {
++ "mediatek/mt6797/ROMv3_patch_1_1_hdr.bin",
++ "mediatek/mt6797/ROMv3_patch_1_0_hdr.bin",
+ };
+
+ static int mt6797_consys_init_rail(struct regulator *rail, bool on, bool *state)
+@@ -1640,25 +1660,25 @@
+ typeof(owner->common_init) *ci = &owner->common_init;
+ const struct firmware *fw[2] = {};
+ struct wmt_rom_patch pair[2];
+- u8 digest[SHA256_DIGEST_SIZE];
+ unsigned long budget, wait;
+- unsigned int i;
++ unsigned int i, total_steps = 0, cal_step = 0;
+ int ret;
+
+ for (i = 0; i < 2; i++) {
+- ret = request_firmware(&fw[i], mt6797_rom_patches[i].name, dev);
++ ret = request_firmware(&fw[i], mt6797_rom_patches[i], dev);
+ if (ret)
+ goto out;
+- sha256(fw[i]->data, fw[i]->size, digest);
+- if (memcmp(digest, mt6797_rom_patches[i].sha256, sizeof(digest)) ||
+- wmt_rom_patch_parse(fw[i]->data, fw[i]->size, i + 1, &pair[i])) {
++ if (wmt_rom_patch_parse(fw[i]->data, fw[i]->size, i + 1, &pair[i])) {
+ ret = -EINVAL;
+ goto out;
+ }
+ }
++ total_steps = mt6797_wmt_init_steps(pair);
++ cal_step = mt6797_wmt_calibration_step(pair);
++ ci->total_steps = total_steps;
+ budget = jiffies + msecs_to_jiffies(MT6797_WMT_INIT_BUDGET_MS);
+ wait = msecs_to_jiffies(MT6797_WMT_INIT_EXCHANGE_MS);
+- for (i = 0; i < WMT_INIT_STEPS; i++) {
++ for (i = 0; i < total_steps; i++) {
+ if (time_after_eq(jiffies, budget)) {
+ ret = -ETIMEDOUT;
+ goto out;
+@@ -1689,7 +1709,7 @@
+ jiffies + wait);
+ if (!ret)
+ ret = mt6797_wmt_full_exchange(&ci->io);
+- if (!ret && i == WMT_INIT_CALIBRATION) {
++ if (!ret && i == cal_step) {
+ ci->calibration_bytes = min_t(unsigned int, ci->io.rx_count,
+ sizeof(ci->calibration));
+ memcpy(ci->calibration, ci->io.received,
+@@ -1706,10 +1726,10 @@
+ release_firmware(fw[i]);
+ dev_info(dev,
+ "one-shot WMT common init: result=%d completed=%u/%u bt-rail=%d wifi-rail=%d link=%u/%u/%u/%u\n",
+- ret, ci->completed, WMT_INIT_STEPS, ci->bt_rail, ci->wifi_rail,
++ ret, ci->completed, total_steps, ci->bt_rail, ci->wifi_rail,
+ n->link.transport.tx_next, n->link.transport.rx_next,
+ n->link.transport.peer_ack, n->link.transport.local_ack);
+- if (ret && ci->completed < WMT_INIT_STEPS && ci->io.prepared) {
++ if (ret && ci->completed < total_steps && ci->io.prepared) {
+ dev_info(dev,
+ "WMT common init failed step %u: tx=%u rx=%u services=%u frames=%u iir=0x%08x no-source=%u\n",
+ ci->completed, ci->io.tx_count, ci->io.rx_count,
+@@ -2087,7 +2107,8 @@
+ goto out;
+ }
+ if (owner->common_init.result ||
+- owner->common_init.completed != WMT_INIT_STEPS) {
++ !owner->common_init.total_steps ||
++ owner->common_init.completed != owner->common_init.total_steps) {
+ ret = -EAGAIN;
+ goto out;
+ }
+--- a/drivers/soc/mediatek/mt6797-wmt.h
++++ b/drivers/soc/mediatek/mt6797-wmt.h
+@@ -1463,21 +1463,24 @@
+ unsigned char address[4];
+ };
+
+-/* Selected retained pair only. Caller verifies exact full-file digest and
+- * applicability separately; metadata alone is not firmware authentication.
+- * Result aliases immutable input. Refusal leaves output unchanged.
++#define WMT_ROM_PATCH_MAX_BYTES (512U * 1024U)
++
++/* Parse one retained MT6797 WMT ROM patch header and alias its immutable body.
++ * Refusal leaves output unchanged.
+ */
+ static inline int wmt_rom_patch_parse(const unsigned char *file, unsigned int bytes,
+ unsigned int sequence, struct wmt_rom_patch *result)
+ {
+- static const unsigned int lengths[] = { 46444, 210876 };
+ static const unsigned char addresses[][4] = {
+ { 0, 0, 0x0a, 0xf0 }, { 0, 0, 9, 0 }
+ };
+ unsigned int i;
+
+ if (!file || !result || sequence < 1 || sequence > 2 ||
+- bytes != lengths[sequence - 1] + 28 || file[24] != (0x20 | sequence))
++ bytes <= 28 || bytes > 28 + WMT_ROM_PATCH_MAX_BYTES ||
++ file[16] != 'A' || file[17] != 'L' ||
++ file[18] != 'P' || file[19] != 'S' ||
++ file[24] != (0x20 | sequence))
+ return -1;
+ for (i = 1; i < 4; i++)
+ if (file[24 + i] != addresses[sequence - 1][i])
+@@ -1499,7 +1502,8 @@
+ {
+ unsigned int count, offset, length, i;
+
+- if (!patch || !patch->body || !patch->length || patch->length > 210876 || !out)
++ if (!patch || !patch->body || !patch->length ||
++ patch->length > WMT_ROM_PATCH_MAX_BYTES || !out)
+ return -1;
+ count = (patch->length + 999) / 1000;
+ if (index >= count)
+@@ -1520,6 +1524,17 @@
+ return length + 5;
+ }
+
++static inline unsigned int mt6797_wmt_rom_single_steps(unsigned int length)
++{
++ return (length + 999U) / 1000U + 3U;
++}
++
++static inline unsigned int mt6797_wmt_rom_steps(const struct wmt_rom_patch pair[2])
++{
++ return mt6797_wmt_rom_single_steps(pair[0].length) +
++ mt6797_wmt_rom_single_steps(pair[1].length);
++}
++
+ /* MT6797 selected pair: two addresses, body fragments, ordinary WMT reset,
+ * then the second patch. Constructor only; ordinal advances after a complete
+ * checked transport exchange, never on construction or partial submission.
+@@ -1530,25 +1545,28 @@
+ unsigned int capacity, unsigned char expected[8],
+ unsigned int *expected_length)
+ {
+- static const unsigned int lengths[2] = { 46444, 210876 };
+ static const unsigned char addresses[2][4] = {
+ { 0, 0, 10, 240 }, { 0, 0, 9, 0 }
+ };
+- unsigned int i, j, sequence, step, count, bytes, event_bytes;
++ unsigned int i, j, steps0, steps1, sequence, step, count, bytes, event_bytes;
+
+- if (!pair || !out || !expected || !expected_length || ordinal >= 264)
++ if (!pair || !out || !expected || !expected_length)
+ return -1;
+ for (i = 0; i < 2; i++) {
+ if (!pair[i].body || pair[i].sequence != i + 1 ||
+- pair[i].length != lengths[i])
++ !pair[i].length || pair[i].length > WMT_ROM_PATCH_MAX_BYTES)
+ return -1;
+ for (j = 0; j < 4; j++)
+ if (pair[i].address[j] != addresses[i][j])
+ return -1;
+ }
+- sequence = ordinal < 50 ? 0 : 1;
+- step = sequence ? ordinal - 50 : ordinal;
+- count = (lengths[sequence] + 999) / 1000;
++ steps0 = mt6797_wmt_rom_single_steps(pair[0].length);
++ steps1 = mt6797_wmt_rom_single_steps(pair[1].length);
++ if (ordinal >= steps0 + steps1)
++ return -1;
++ sequence = ordinal < steps0 ? 0 : 1;
++ step = sequence ? ordinal - steps0 : ordinal;
++ count = (pair[sequence].length + 999U) / 1000U;
+ if (step < 2) {
+ if (capacity < 20)
+ return -1;
+@@ -1617,10 +1635,17 @@
+ };
+
+ #define WMT_INIT_PRE 7U
+-#define WMT_INIT_PATCH 264U
+ #define WMT_INIT_POST 8U
+-#define WMT_INIT_STEPS (WMT_INIT_PRE + WMT_INIT_PATCH + WMT_INIT_POST + 6U)
+-#define WMT_INIT_CALIBRATION (WMT_INIT_PRE + WMT_INIT_PATCH + WMT_INIT_POST + 2U)
++
++static inline unsigned int mt6797_wmt_init_steps(const struct wmt_rom_patch pair[2])
++{
++ return WMT_INIT_PRE + mt6797_wmt_rom_steps(pair) + WMT_INIT_POST + 6U;
++}
++
++static inline unsigned int mt6797_wmt_calibration_step(const struct wmt_rom_patch pair[2])
++{
++ return WMT_INIT_PRE + mt6797_wmt_rom_steps(pair) + WMT_INIT_POST + 2U;
++}
+
+ struct wmt_init_step {
+ enum wmt_init_kind kind;
+@@ -1727,16 +1752,20 @@
+ sizeof(wmt_init_lte_l),
+ };
+ struct wmt_init_step next = { .kind = WMT_INIT_EXCHANGE };
+- unsigned int i, base, reg, expected_length;
++ unsigned int i, base, reg, expected_length, patch_steps, total_steps;
+ int bytes;
+
+- if (!pair || !out || !step || antenna_mode > 255 || index >= WMT_INIT_STEPS)
++ if (!pair || !out || !step || antenna_mode > 255)
++ return -1;
++ patch_steps = mt6797_wmt_rom_steps(pair);
++ total_steps = mt6797_wmt_init_steps(pair);
++ if (index >= total_steps)
+ return -1;
+ if (index < WMT_INIT_PRE ||
+- (index >= WMT_INIT_PRE + WMT_INIT_PATCH &&
+- index < WMT_INIT_PRE + WMT_INIT_PATCH + 3)) {
++ (index >= WMT_INIT_PRE + patch_steps &&
++ index < WMT_INIT_PRE + patch_steps + 3)) {
+ reg = index < WMT_INIT_PRE ? index :
+- WMT_INIT_PRE + index - (WMT_INIT_PRE + WMT_INIT_PATCH);
++ WMT_INIT_PRE + index - (WMT_INIT_PRE + patch_steps);
+ if (capacity < 20)
+ return -1;
+ out[0] = 0x01;
+@@ -1751,7 +1780,7 @@
+ out[8 + i] = wmt_init_reg[reg][i];
+ bytes = 20;
+ wmt_init_expect(&next, wmt_init_reg_event, 8, 8);
+- } else if (index < WMT_INIT_PRE + WMT_INIT_PATCH) {
++ } else if (index < WMT_INIT_PRE + patch_steps) {
+ bytes = mt6797_wmt_rom_step(pair, index - WMT_INIT_PRE, out, capacity,
+ next.expected, &expected_length);
+ if (bytes < 0)
+@@ -1759,7 +1788,7 @@
+ next.prefix = expected_length;
+ next.expected_length = expected_length;
+ } else {
+- base = index - (WMT_INIT_PRE + WMT_INIT_PATCH + 3);
++ base = index - (WMT_INIT_PRE + patch_steps + 3);
+ if (base < 5) {
+ bytes = wmt_init_copy(out, capacity, lte[base], lte_length[base]);
+ wmt_init_expect(&next, wmt_init_coex_event, 5, 5);
diff --git a/patches/kernel/series b/patches/kernel/series
index 9642dd7..5d599a1 100644
--- a/patches/kernel/series
+++ b/patches/kernel/series
@@ -2,3 +2,4 @@
0002-mt6797-ccci-cldma-and-md1-domain.patch
0003-arm64-dts-mediatek-geminux-gemini-pda.patch
0004-gemini-ssd2092-display-and-touch.patch
+0005-mt6797-consys-wifi-factory-firmware.patch
diff --git a/prebuilt/geminux/usr/bin/geminux-audio b/prebuilt/geminux/usr/bin/geminux-audio
new file mode 100755
index 0000000..b31f43b
Binary files /dev/null and b/prebuilt/geminux/usr/bin/geminux-audio differ
diff --git a/prebuilt/geminux/usr/bin/geminux-bt-obex b/prebuilt/geminux/usr/bin/geminux-bt-obex
index 48ccf23..b3bb4e7 100755
Binary files a/prebuilt/geminux/usr/bin/geminux-bt-obex and b/prebuilt/geminux/usr/bin/geminux-bt-obex differ
diff --git a/prebuilt/geminux/usr/bin/geminux-control b/prebuilt/geminux/usr/bin/geminux-control
index 2d23a2c..bebb4ac 100755
Binary files a/prebuilt/geminux/usr/bin/geminux-control and b/prebuilt/geminux/usr/bin/geminux-control differ
diff --git a/prebuilt/geminux/usr/bin/geminux-net b/prebuilt/geminux/usr/bin/geminux-net
index f0b2456..b08a0a9 100755
Binary files a/prebuilt/geminux/usr/bin/geminux-net and b/prebuilt/geminux/usr/bin/geminux-net differ
diff --git a/prebuilt/geminux/usr/include/gemui.h b/prebuilt/geminux/usr/include/gemui.h
index c09b460..5fd95dd 100644
--- a/prebuilt/geminux/usr/include/gemui.h
+++ b/prebuilt/geminux/usr/include/gemui.h
@@ -121,6 +121,7 @@ int gemui_add_fd(gemui_app_t *app, int fd, gemui_fd_cb cb, void *userdata);
void gemui_del_fd(gemui_app_t *app, int fd);
void gemui_set_timer_ms(gemui_app_t *app, int interval_ms, gemui_timer_cb cb, void *userdata);
void gemui_request_redraw(gemui_app_t *app);
+void gemui_flush_draw(gemui_app_t *app);
void gemui_show_toast(gemui_app_t *app, const char *msg, int duration_ms);
int gemui_run(gemui_app_t *app);
void gemui_quit(gemui_app_t *app, int code);
@@ -157,6 +158,7 @@ void gemui_draw_toast(gemui_app_t *app, cairo_t *cr);
int gemui_unix_cmd(const char *sock_path, const char *cmd, char *resp, size_t resp_sz);
int gemui_read_file_line(const char *path, char *buf, size_t sz);
+int gemui_run_cmd_timeout(const char *const argv[], char *out, size_t out_sz, int timeout_ms);
int gemui_run_cmd_capture(const char *const argv[], char *out, size_t out_sz);
int gemui_spawn_detached(const char *const argv[]);
void gemui_utf8_pop_char(char *buf);
diff --git a/prebuilt/geminux/usr/lib/libgemui.so b/prebuilt/geminux/usr/lib/libgemui.so
index 3dc2b92..d95c050 100755
Binary files a/prebuilt/geminux/usr/lib/libgemui.so and b/prebuilt/geminux/usr/lib/libgemui.so differ
diff --git a/prebuilt/geminux/usr/sbin/geminux-wifi-nvram b/prebuilt/geminux/usr/sbin/geminux-wifi-nvram
new file mode 100755
index 0000000..00553a2
Binary files /dev/null and b/prebuilt/geminux/usr/sbin/geminux-wifi-nvram differ
diff --git a/prebuilt/kernel/boot/Image.gz b/prebuilt/kernel/boot/Image.gz
index 3e25782..f089f68 100644
Binary files a/prebuilt/kernel/boot/Image.gz and b/prebuilt/kernel/boot/Image.gz differ
diff --git a/prebuilt/kernel/boot/config-7.3.5-geminux b/prebuilt/kernel/boot/config-7.3.5-geminux
index 6c585d9..53738e8 100644
--- a/prebuilt/kernel/boot/config-7.3.5-geminux
+++ b/prebuilt/kernel/boot/config-7.3.5-geminux
@@ -1436,13 +1436,23 @@ CONFIG_BT_LEDS=y
#
# Bluetooth device drivers
#
-# CONFIG_BT_HCIBTUSB is not set
+CONFIG_BT_INTEL=m
+CONFIG_BT_BCM=m
+CONFIG_BT_RTL=m
+CONFIG_BT_MTK=m
+CONFIG_BT_HCIBTUSB=m
+# CONFIG_BT_HCIBTUSB_AUTOSUSPEND is not set
+CONFIG_BT_HCIBTUSB_POLL_SYNC=y
+CONFIG_BT_HCIBTUSB_BCM=y
+CONFIG_BT_HCIBTUSB_MTK=y
+CONFIG_BT_HCIBTUSB_RTL=y
# CONFIG_BT_HCIBTSDIO is not set
# CONFIG_BT_HCIUART is not set
# CONFIG_BT_HCIBCM203X is not set
# CONFIG_BT_HCIBFUSB is not set
# CONFIG_BT_HCIVHCI is not set
# CONFIG_BT_MRVL is not set
+# CONFIG_BT_ATH3K is not set
# CONFIG_BT_MTKSDIO is not set
CONFIG_BT_MT6797=m
# CONFIG_BT_VIRTIO is not set
@@ -2179,7 +2189,7 @@ CONFIG_INPUT_GEMINI_LID=m
# CONFIG_INPUT_YEALINK is not set
# CONFIG_INPUT_CM109 is not set
CONFIG_INPUT_REGULATOR_HAPTIC=m
-# CONFIG_INPUT_UINPUT is not set
+CONFIG_INPUT_UINPUT=m
# CONFIG_INPUT_PCF8574 is not set
CONFIG_INPUT_PWM_BEEPER=y
CONFIG_INPUT_PWM_VIBRA=y
@@ -4405,8 +4415,8 @@ CONFIG_SND_AUDIO_GRAPH_CARD2=m
CONFIG_HID_SUPPORT=y
CONFIG_HID=y
# CONFIG_HID_BATTERY_STRENGTH is not set
-# CONFIG_HIDRAW is not set
-# CONFIG_UHID is not set
+CONFIG_HIDRAW=y
+CONFIG_UHID=m
CONFIG_HID_GENERIC=y
# CONFIG_HID_HAPTIC is not set
@@ -4416,7 +4426,7 @@ CONFIG_HID_GENERIC=y
# CONFIG_HID_A4TECH is not set
# CONFIG_HID_ACCUTOUCH is not set
# CONFIG_HID_ACRUX is not set
-# CONFIG_HID_APPLE is not set
+CONFIG_HID_APPLE=m
# CONFIG_HID_APPLEIR is not set
# CONFIG_HID_ASUS is not set
# CONFIG_HID_AUREAL is not set
@@ -4430,6 +4440,7 @@ CONFIG_HID_GENERIC=y
# CONFIG_HID_MACALLY is not set
# CONFIG_HID_PRODIKEYS is not set
# CONFIG_HID_CMEDIA is not set
+# CONFIG_HID_CP2112 is not set
# CONFIG_HID_CREATIVE_SB0540 is not set
# CONFIG_HID_CYPRESS is not set
# CONFIG_HID_DRAGONRISE is not set
@@ -4439,6 +4450,7 @@ CONFIG_HID_GENERIC=y
# CONFIG_HID_ELO is not set
# CONFIG_HID_EVISION is not set
# CONFIG_HID_EZKEY is not set
+# CONFIG_HID_FT260 is not set
# CONFIG_HID_GEMBIRD is not set
# CONFIG_HID_GFRM is not set
# CONFIG_HID_GLORIOUS is not set
@@ -4469,14 +4481,20 @@ CONFIG_HID_GENERIC=y
# CONFIG_HID_LENOVO_GO is not set
# CONFIG_HID_LENOVO_GO_S is not set
# CONFIG_HID_LETSKETCH is not set
-# CONFIG_HID_LOGITECH is not set
+CONFIG_HID_LOGITECH=m
+# CONFIG_HID_LOGITECH_DJ is not set
+CONFIG_HID_LOGITECH_HIDPP=m
+# CONFIG_LOGITECH_FF is not set
+# CONFIG_LOGIRUMBLEPAD2_FF is not set
+# CONFIG_LOGIG940_FF is not set
+# CONFIG_LOGIWHEELS_FF is not set
# CONFIG_HID_MAGICMOUSE is not set
# CONFIG_HID_MALTRON is not set
# CONFIG_HID_MAYFLASH is not set
# CONFIG_HID_MEGAWORLD_FF is not set
# CONFIG_HID_RAKK is not set
# CONFIG_HID_REDRAGON is not set
-# CONFIG_HID_MICROSOFT is not set
+CONFIG_HID_MICROSOFT=m
# CONFIG_HID_MONTEREY is not set
CONFIG_HID_MULTITOUCH=y
# CONFIG_HID_NINTENDO is not set
@@ -6536,6 +6554,8 @@ CONFIG_CRYPTO_SKCIPHER=y
CONFIG_CRYPTO_SKCIPHER2=y
CONFIG_CRYPTO_HASH=y
CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=m
CONFIG_CRYPTO_AKCIPHER2=y
CONFIG_CRYPTO_AKCIPHER=y
CONFIG_CRYPTO_KPP2=y
@@ -6666,8 +6686,8 @@ CONFIG_CRYPTO_KDF800108_CTR=y
CONFIG_CRYPTO_USER_API=y
CONFIG_CRYPTO_USER_API_HASH=y
CONFIG_CRYPTO_USER_API_SKCIPHER=y
-# CONFIG_CRYPTO_USER_API_RNG is not set
-# CONFIG_CRYPTO_USER_API_AEAD is not set
+CONFIG_CRYPTO_USER_API_RNG=m
+CONFIG_CRYPTO_USER_API_AEAD=m
CONFIG_CRYPTO_USER_API_ENABLE_OBSOLETE=y
# end of Userspace interface (deprecated)
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/algif_aead.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/algif_aead.ko.zst
new file mode 100644
index 0000000..72ef0f1
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/algif_aead.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/algif_rng.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/algif_rng.ko.zst
new file mode 100644
index 0000000..4bc74e8
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/algif_rng.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/rng.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/rng.ko.zst
new file mode 100644
index 0000000..f2f7261
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/crypto/rng.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btbcm.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btbcm.ko.zst
new file mode 100644
index 0000000..04106c3
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btbcm.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btintel.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btintel.ko.zst
new file mode 100644
index 0000000..ef280a0
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btintel.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btmt6797.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btmt6797.ko.zst
index 26c543f..3fdb8b1 100644
Binary files a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btmt6797.ko.zst and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btmt6797.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btmtk.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btmtk.ko.zst
new file mode 100644
index 0000000..b978a02
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btmtk.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btrtl.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btrtl.ko.zst
new file mode 100644
index 0000000..84d37d0
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btrtl.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btusb.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btusb.ko.zst
new file mode 100644
index 0000000..b94b711
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/bluetooth/btusb.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-apple.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-apple.ko.zst
new file mode 100644
index 0000000..6fab64d
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-apple.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-lg-g15.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-lg-g15.ko.zst
new file mode 100644
index 0000000..95846b1
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-lg-g15.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-logitech-hidpp.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-logitech-hidpp.ko.zst
new file mode 100644
index 0000000..b76511c
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-logitech-hidpp.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-logitech.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-logitech.ko.zst
new file mode 100644
index 0000000..a83a015
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-logitech.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-microsoft.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-microsoft.ko.zst
new file mode 100644
index 0000000..05eb18b
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/hid-microsoft.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/uhid.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/uhid.ko.zst
new file mode 100644
index 0000000..77005dd
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/hid/uhid.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/input/misc/uinput.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/input/misc/uinput.ko.zst
new file mode 100644
index 0000000..6f224c8
Binary files /dev/null and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/input/misc/uinput.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/net/wireless/mediatek/mt6797/mac.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/net/wireless/mediatek/mt6797/mac.ko.zst
index a4170bf..bd65878 100644
Binary files a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/net/wireless/mediatek/mt6797/mac.ko.zst and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/net/wireless/mediatek/mt6797/mac.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/net/wireless/mediatek/mt6797/mt6797-wlan-core.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/net/wireless/mediatek/mt6797/mt6797-wlan-core.ko.zst
index 2bbfd41..458c456 100644
Binary files a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/net/wireless/mediatek/mt6797/mt6797-wlan-core.ko.zst and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/net/wireless/mediatek/mt6797/mt6797-wlan-core.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/soc/mediatek/mt6797-consys.ko.zst b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/soc/mediatek/mt6797-consys.ko.zst
index f1de2f3..961d85c 100644
Binary files a/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/soc/mediatek/mt6797-consys.ko.zst and b/prebuilt/kernel/lib/modules/7.3.5-geminux/kernel/drivers/soc/mediatek/mt6797-consys.ko.zst differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.alias b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.alias
index a3e9acd..6ff2ff7 100644
--- a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.alias
+++ b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.alias
@@ -4751,6 +4751,8 @@ alias of:N*T*Cnovatek,nt36772-ts novatek_nt36xxx
alias i2c:nt36772-ts novatek_nt36xxx
alias of:N*T*Cregulator-hapticC* regulator_haptic
alias of:N*T*Cregulator-haptic regulator_haptic
+alias devname:uinput uinput
+alias char-major-10-223 uinput
alias i2c:bq32000 rtc_bq32k
alias of:N*T*Cti,bq32000C* rtc_bq32k
alias of:N*T*Cti,bq32000 rtc_bq32k
@@ -5031,6 +5033,243 @@ alias of:N*T*Cmediatek,mt8196-cpufreq-hwC* mediatek_cpufreq_hw
alias of:N*T*Cmediatek,mt8196-cpufreq-hw mediatek_cpufreq_hw
alias of:N*T*Cmediatek,cpufreq-hwC* mediatek_cpufreq_hw
alias of:N*T*Cmediatek,cpufreq-hw mediatek_cpufreq_hw
+alias devname:uhid uhid
+alias char-major-10-239 uhid
+alias hid:b0003g*v000005ACp00008102 hid_apple
+alias hid:b0005g*v0000004Cp00000322 hid_apple
+alias hid:b0003g*v000005ACp00000322 hid_apple
+alias hid:b0005g*v0000004Cp00000321 hid_apple
+alias hid:b0003g*v000005ACp00000321 hid_apple
+alias hid:b0005g*v0000004Cp00000320 hid_apple
+alias hid:b0003g*v000005ACp00000320 hid_apple
+alias hid:b0005g*v0000004Cp0000029F hid_apple
+alias hid:b0003g*v000005ACp0000029F hid_apple
+alias hid:b0005g*v0000004Cp0000029A hid_apple
+alias hid:b0003g*v000005ACp0000029A hid_apple
+alias hid:b0005g*v0000004Cp0000029C hid_apple
+alias hid:b0003g*v000005ACp0000029C hid_apple
+alias hid:b0003g*v000005ACp0000030B hid_apple
+alias hid:b0003g*v000005ACp0000030A hid_apple
+alias hid:b0005g*v000005ACp0000023B hid_apple
+alias hid:b0005g*v000005ACp0000023A hid_apple
+alias hid:b0005g*v000005ACp00000239 hid_apple
+alias hid:b0003g*v000005ACp00000340 hid_apple
+alias hid:b0003g*v000005ACp00000280 hid_apple
+alias hid:b0003g*v000005ACp0000027F hid_apple
+alias hid:b0003g*v000005ACp0000027E hid_apple
+alias hid:b0003g*v000005ACp0000027D hid_apple
+alias hid:b0003g*v000005ACp00000278 hid_apple
+alias hid:b0003g*v000005ACp0000027C hid_apple
+alias hid:b0003g*v000005ACp0000027B hid_apple
+alias hid:b0003g*v000005ACp0000027A hid_apple
+alias hid:b0003g*v000005ACp00000274 hid_apple
+alias hid:b0003g*v000005ACp00000273 hid_apple
+alias hid:b0003g*v000005ACp00000272 hid_apple
+alias hid:b0003g*v000005ACp00000292 hid_apple
+alias hid:b0003g*v000005ACp00000291 hid_apple
+alias hid:b0003g*v000005ACp00000290 hid_apple
+alias hid:b0003g*v000005ACp0000025B hid_apple
+alias hid:b0003g*v000005ACp0000025A hid_apple
+alias hid:b0003g*v000005ACp00000259 hid_apple
+alias hid:b0003g*v000005ACp00000264 hid_apple
+alias hid:b0003g*v000005ACp00000263 hid_apple
+alias hid:b0003g*v000005ACp00000262 hid_apple
+alias hid:b0003g*v000005ACp00000254 hid_apple
+alias hid:b0003g*v000005ACp00000253 hid_apple
+alias hid:b0003g*v000005ACp00000252 hid_apple
+alias hid:b0003g*v000005ACp0000024B hid_apple
+alias hid:b0003g*v000005ACp0000024A hid_apple
+alias hid:b0003g*v000005ACp00000249 hid_apple
+alias hid:b0003g*v000005ACp0000024E hid_apple
+alias hid:b0003g*v000005ACp0000024D hid_apple
+alias hid:b0003g*v000005ACp0000024C hid_apple
+alias hid:b0003g*v000005ACp00000247 hid_apple
+alias hid:b0003g*v000005ACp00000246 hid_apple
+alias hid:b0003g*v000005ACp00000245 hid_apple
+alias hid:b0003g*v000005ACp00000244 hid_apple
+alias hid:b0003g*v000005ACp00000243 hid_apple
+alias hid:b0003g*v000005ACp00000242 hid_apple
+alias hid:b0003g*v000005ACp00000241 hid_apple
+alias hid:b0003g*v000005ACp00000240 hid_apple
+alias hid:b0003g*v000005ACp0000023F hid_apple
+alias hid:b0003g*v000005ACp00000238 hid_apple
+alias hid:b0003g*v000005ACp00000237 hid_apple
+alias hid:b0003g*v000005ACp00000236 hid_apple
+alias hid:b0003g*v000005ACp00000232 hid_apple
+alias hid:b0003g*v000005ACp00000231 hid_apple
+alias hid:b0003g*v000005ACp00000230 hid_apple
+alias hid:b0003g*v000005ACp00000225 hid_apple
+alias hid:b0003g*v000005ACp00000224 hid_apple
+alias hid:b0003g*v000005ACp00000223 hid_apple
+alias hid:b0005g*v0000004Cp0000026C hid_apple
+alias hid:b0003g*v000005ACp0000026C hid_apple
+alias hid:b0005g*v0000004Cp00000267 hid_apple
+alias hid:b0003g*v000005ACp00000267 hid_apple
+alias hid:b0005g*v000005ACp0000022E hid_apple
+alias hid:b0005g*v000005ACp00000257 hid_apple
+alias hid:b0005g*v000005ACp00000255 hid_apple
+alias hid:b0005g*v000005ACp00000256 hid_apple
+alias hid:b0005g*v000005ACp0000022D hid_apple
+alias hid:b0005g*v000005ACp0000022C hid_apple
+alias hid:b0003g*v000005ACp00000251 hid_apple
+alias hid:b0005g*v000005ACp00000250 hid_apple
+alias hid:b0003g*v000005ACp00000250 hid_apple
+alias hid:b0005g*v000005ACp0000024F hid_apple
+alias hid:b0003g*v000005ACp0000024F hid_apple
+alias hid:b0003g*v000005ACp0000022B hid_apple
+alias hid:b0003g*v000005ACp0000022A hid_apple
+alias hid:b0003g*v000005ACp00000229 hid_apple
+alias hid:b0003g*v000005ACp00000222 hid_apple
+alias hid:b0003g*v000005ACp00000221 hid_apple
+alias hid:b0003g*v000005ACp00000220 hid_apple
+alias hid:b0003g*v000005ACp0000021F hid_apple
+alias hid:b0003g*v000005ACp0000021E hid_apple
+alias hid:b0003g*v000005ACp0000021D hid_apple
+alias hid:b0003g*v000005ACp0000021C hid_apple
+alias hid:b0003g*v000005ACp0000021B hid_apple
+alias hid:b0003g*v000005ACp0000021A hid_apple
+alias hid:b0003g*v000005ACp00000219 hid_apple
+alias hid:b0003g*v000005ACp00000218 hid_apple
+alias hid:b0003g*v000005ACp00000217 hid_apple
+alias hid:b0003g*v000005ACp00000216 hid_apple
+alias hid:b0003g*v000005ACp00000215 hid_apple
+alias hid:b0003g*v000005ACp00000214 hid_apple
+alias hid:b0003g*v000005ACp0000020F hid_apple
+alias hid:b0003g*v000005ACp0000020E hid_apple
+alias hid:b0003g*v000005ACp00000304 hid_apple
+alias hid:b0003g*v0000046Dp0000C623 hid_logitech
+alias hid:b0003g*v0000046Dp0000C626 hid_logitech
+alias hid:b0003g*v0000046Dp0000C287 hid_logitech
+alias hid:b0003g*v0000046Dp0000C218 hid_logitech
+alias hid:b0003g*v0000046Dp0000C293 hid_logitech
+alias hid:b0003g*v0000046Dp0000C20E hid_logitech
+alias hid:b0003g*v0000046Dp0000C29C hid_logitech
+alias hid:b0003g*v0000046Dp0000C298 hid_logitech
+alias hid:b0003g*v0000046Dp0000C29B hid_logitech
+alias hid:b0003g*v0000046Dp0000C29A hid_logitech
+alias hid:b0003g*v0000046Dp0000C299 hid_logitech
+alias hid:b0003g*v0000046Dp0000CA04 hid_logitech
+alias hid:b0003g*v0000046Dp0000CA03 hid_logitech
+alias hid:b0003g*v0000046Dp0000C295 hid_logitech
+alias hid:b0003g*v0000046Dp0000C286 hid_logitech
+alias hid:b0003g*v0000046Dp0000C283 hid_logitech
+alias hid:b0003g*v0000046Dp0000C24F hid_logitech
+alias hid:b0003g*v0000046Dp0000C219 hid_logitech
+alias hid:b0003g*v0000046Dp0000C211 hid_logitech
+alias hid:b0003g*v0000046Dp0000C20A hid_logitech
+alias hid:b0003g*v0000046Dp0000C294 hid_logitech
+alias hid:b0003g*v0000046Dp0000C216 hid_logitech
+alias hid:b0003g*v0000046Dp0000C215 hid_logitech
+alias hid:b0003g*v0000046Dp0000C512 hid_logitech
+alias hid:b0003g*v0000046Dp0000C30A hid_logitech
+alias hid:b0003g*v0000046Dp0000C704 hid_logitech
+alias hid:b0003g*v0000046Dp0000C101 hid_logitech
+alias hid:b0003g*v0000046Dp0000C50C hid_logitech
+alias hid:b0003g*v0000046Dp00000A07 hid_lg_g15
+alias hid:b0003g*v0000046Dp0000C22E hid_lg_g15
+alias hid:b0003g*v0000046Dp0000C22D hid_lg_g15
+alias hid:b0003g*v0000046Dp0000C227 hid_lg_g15
+alias hid:b0003g*v0000046Dp0000C222 hid_lg_g15
+alias hid:b0003g*v0000046Dp0000C225 hid_lg_g15
+alias hid:b0003g*v0000046Dp0000C21C hid_lg_g15
+alias hid:b0005g*v0000046Dp0000B39D hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B39C hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B397 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B394 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B36E hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B369 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B38F hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B38C hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B380 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B378 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B388 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B386 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B384 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B383 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B374 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B371 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B377 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B370 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B36F hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B042 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B391 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B038 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B037 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B034 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B025 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B023 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B02A hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B020 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B01E hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B01D hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B019 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B015 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B012 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B008 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B35F hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B30B hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B309 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B305 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp00000A87 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C09A hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C09B hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C094 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C26E hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C262 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C343 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C091 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C08A hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C088 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C086 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C081 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C090 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C087 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C098 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C095 hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C08D hid_logitech_hidpp
+alias hid:b0003g*v0000046Dp0000C082 hid_logitech_hidpp
+alias hid:b0003g0104v0000046Dp* hid_logitech_hidpp
+alias hid:b0003g0104v0000046Dp000000FE hid_logitech_hidpp
+alias hid:b0003g0104v0000046Dp0000005C hid_logitech_hidpp
+alias hid:b0003g0104v0000046Dp00000057 hid_logitech_hidpp
+alias hid:b0003g0104v0000046Dp00000049 hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp* hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp0000407F hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp0000B30B hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp0000B309 hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp0000B305 hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp00004002 hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp00004024 hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp0000101A hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp0000101B hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp0000402D hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp00001017 hid_logitech_hidpp
+alias hid:b0005g*v0000046Dp0000B00C hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp00004101 hid_logitech_hidpp
+alias hid:b0003g0102v0000046Dp00004011 hid_logitech_hidpp
+alias hid:b0005g*v0000045Ep000002E0 hid_microsoft
+alias hid:b0005g*v0000045Ep00000B22 hid_microsoft
+alias hid:b0005g*v0000045Ep00000B05 hid_microsoft
+alias hid:b0005g*v0000045Ep00000B13 hid_microsoft
+alias hid:b0005g*v0000045Ep00000B20 hid_microsoft
+alias hid:b0005g*v0000045Ep000002FD hid_microsoft
+alias hid:b0005g*v0000045Ep0000091B hid_microsoft
+alias hid:b0005g*v0000045Ep00000701 hid_microsoft
+alias hid:b0003g*v0000045Ep000000E3 hid_microsoft
+alias hid:b0003g*v0000045Ep000007DA hid_microsoft
+alias hid:b0003g*v0000045Ep0000076C hid_microsoft
+alias hid:b0003g*v0000045Ep0000009D hid_microsoft
+alias hid:b0003g*v0000045Ep00000732 hid_microsoft
+alias hid:b0003g*v0000045Ep00000750 hid_microsoft
+alias hid:b0003g*v0000045Ep000000B4 hid_microsoft
+alias hid:b0003g*v0000045Ep00000730 hid_microsoft
+alias hid:b0003g*v0000045Ep00000713 hid_microsoft
+alias hid:b0003g*v0000045Ep000000F9 hid_microsoft
+alias hid:b0003g*v0000045Ep0000071D hid_microsoft
+alias hid:b0003g*v0000045Ep000000DC hid_microsoft
+alias hid:b0003g*v0000045Ep000000DB hid_microsoft
+alias hid:b0003g*v0000045Ep00000048 hid_microsoft
+alias hid:b0003g*v0000045Ep0000003B hid_microsoft
alias usb:v*p*d*dc*dsc*dp*ic03isc*ip*in* usbhid
alias of:N*T*Cgoogle,cros-ec-typecC* cros_ec_typec
alias of:N*T*Cgoogle,cros-ec-typec cros_ec_typec
@@ -5284,6 +5523,44 @@ alias of:N*T*Cqcom,spmi-sdam nvmem_qcom_spmi_sdam
alias of:N*T*Cgpio-muxC* mux_gpio
alias of:N*T*Cgpio-mux mux_gpio
alias platform:mt6797-gnss gnss_mt6797
+alias usb:v8087p0A5Ad*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v0930p*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v413Cp*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v13D3p*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v050Dp*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v0B05p*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v0A5Cp*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v04CAp*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v0489p*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v0BB4p*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v105Bp*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v19FFp0239d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v0C10p0000d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v0BDBp1002d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v044Ep3002d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v044Ep3001d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v04BFp030Ad*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v057Cp3800d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v05ACp8281d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v05ACp821Ad*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v05ACp821Fd*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v05ACp821Bd*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v05ACp8218d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v05ACp8215d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v05ACp8213d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v0A5Cp21E1d*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v0E8Dp763Fd*dc*dsc*dp*ic*isc*ip*in* btusb
+alias usb:v05ACp*d*dc*dsc*dp*icFFisc01ip01in* btusb
+alias usb:v*p*d*dc*dsc*dp*icE0isc01ip01in* btusb
+alias usb:v*p*d*dcE0dsc01dp04ic*isc*ip*in* btusb
+alias usb:v*p*d*dcE0dsc01dp01ic*isc*ip*in* btusb
+alias usb:v0471p0215d*dc*dsc*dp*icFFiscFFipFFin* btusb
+alias of:N*T*Cusb4ca,301aC* btusb
+alias of:N*T*Cusb4ca,301a btusb
+alias of:N*T*Cusbcf3,e300C* btusb
+alias of:N*T*Cusbcf3,e300 btusb
+alias of:N*T*Cusb1286,204eC* btusb
+alias of:N*T*Cusb1286,204e btusb
alias platform:btmt6797 btmt6797
alias of:N*T*Cqcom,soundwire-v3.1.0C* soundwire_qcom
alias of:N*T*Cqcom,soundwire-v3.1.0 soundwire_qcom
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.alias.bin b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.alias.bin
index be6e8f2..57a8687 100644
Binary files a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.alias.bin and b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.alias.bin differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.dep b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.dep
index fde918b..62e97e5 100644
--- a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.dep
+++ b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.dep
@@ -1,5 +1,8 @@
kernel/fs/exfat/exfat.ko.zst:
+kernel/crypto/rng.ko.zst:
kernel/crypto/tcrypt.ko.zst:
+kernel/crypto/algif_rng.ko.zst: kernel/crypto/rng.ko.zst
+kernel/crypto/algif_aead.ko.zst:
kernel/lib/crc/crc8.ko.zst:
kernel/lib/crc/crc-itu-t.ko.zst:
kernel/lib/crypto/libchacha20poly1305.ko.zst: kernel/lib/crypto/libpoly1305.ko.zst
@@ -160,6 +163,7 @@ kernel/drivers/input/keyboard/adc-keys.ko.zst:
kernel/drivers/input/touchscreen/novatek-nt36xxx.ko.zst:
kernel/drivers/input/misc/gemini-lid.ko.zst:
kernel/drivers/input/misc/regulator-haptic.ko.zst:
+kernel/drivers/input/misc/uinput.ko.zst:
kernel/drivers/rtc/rtc-bq32k.ko.zst:
kernel/drivers/rtc/rtc-ds1307.ko.zst:
kernel/drivers/rtc/rtc-hym8563.ko.zst:
@@ -213,6 +217,12 @@ kernel/drivers/cpufreq/cpufreq_conservative.ko.zst:
kernel/drivers/cpufreq/battery-headroom.ko.zst:
kernel/drivers/cpufreq/cpufreq-dt.ko.zst:
kernel/drivers/cpufreq/mediatek-cpufreq-hw.ko.zst:
+kernel/drivers/hid/uhid.ko.zst:
+kernel/drivers/hid/hid-apple.ko.zst:
+kernel/drivers/hid/hid-logitech.ko.zst: kernel/drivers/hid/usbhid/usbhid.ko.zst
+kernel/drivers/hid/hid-lg-g15.ko.zst:
+kernel/drivers/hid/hid-logitech-hidpp.ko.zst: kernel/drivers/hid/usbhid/usbhid.ko.zst
+kernel/drivers/hid/hid-microsoft.ko.zst:
kernel/drivers/hid/usbhid/usbhid.ko.zst:
kernel/drivers/platform/chrome/cros-ec-typec.ko.zst:
kernel/drivers/devfreq/mtk-cci-devfreq.ko.zst:
@@ -253,7 +263,12 @@ kernel/drivers/nvmem/nvmem-rmem.ko.zst:
kernel/drivers/nvmem/nvmem_qcom-spmi-sdam.ko.zst:
kernel/drivers/mux/mux-gpio.ko.zst:
kernel/drivers/gnss/gnss-mt6797.ko.zst: kernel/drivers/soc/mediatek/mt6797-consys.ko.zst kernel/drivers/net/wireless/mediatek/mt6797/mt6797-wlan-core.ko.zst
+kernel/drivers/bluetooth/btusb.ko.zst: kernel/drivers/bluetooth/btrtl.ko.zst kernel/drivers/bluetooth/btintel.ko.zst kernel/drivers/bluetooth/btbcm.ko.zst kernel/drivers/bluetooth/btmtk.ko.zst kernel/net/bluetooth/bluetooth.ko.zst
+kernel/drivers/bluetooth/btintel.ko.zst: kernel/net/bluetooth/bluetooth.ko.zst
kernel/drivers/bluetooth/btmt6797.ko.zst: kernel/net/bluetooth/bluetooth.ko.zst kernel/drivers/soc/mediatek/mt6797-consys.ko.zst kernel/drivers/net/wireless/mediatek/mt6797/mt6797-wlan-core.ko.zst
+kernel/drivers/bluetooth/btbcm.ko.zst: kernel/net/bluetooth/bluetooth.ko.zst
+kernel/drivers/bluetooth/btrtl.ko.zst: kernel/net/bluetooth/bluetooth.ko.zst
+kernel/drivers/bluetooth/btmtk.ko.zst: kernel/net/bluetooth/bluetooth.ko.zst
kernel/drivers/soundwire/soundwire-bus.ko.zst:
kernel/drivers/soundwire/soundwire-qcom.ko.zst: kernel/sound/soc/snd-soc-core.ko.zst kernel/sound/core/snd-pcm-dmaengine.ko.zst kernel/sound/core/snd-pcm.ko.zst kernel/sound/core/snd-timer.ko.zst kernel/sound/core/snd.ko.zst kernel/drivers/soundwire/soundwire-bus.ko.zst
kernel/sound/core/snd.ko.zst:
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.dep.bin b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.dep.bin
index 8f1d4b9..3db5833 100644
Binary files a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.dep.bin and b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.dep.bin differ
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.devname b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.devname
index 74d3852..9c2baef 100644
--- a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.devname
+++ b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.devname
@@ -1,4 +1,6 @@
# Device nodes to trigger on-demand module loading.
tun net/tun c10:200
ppp_generic ppp c108:0
+uinput uinput c10:223
+uhid uhid c10:239
snd_timer snd/timer c116:33
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.order b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.order
index 30022d3..fec14bb 100644
--- a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.order
+++ b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.order
@@ -1,5 +1,8 @@
kernel/fs/exfat/exfat.ko
+kernel/crypto/rng.ko
kernel/crypto/tcrypt.ko
+kernel/crypto/algif_rng.ko
+kernel/crypto/algif_aead.ko
kernel/lib/crc/crc8.ko
kernel/lib/crc/crc-itu-t.ko
kernel/lib/crypto/libchacha20poly1305.ko
@@ -160,6 +163,7 @@ kernel/drivers/input/keyboard/adc-keys.ko
kernel/drivers/input/touchscreen/novatek-nt36xxx.ko
kernel/drivers/input/misc/gemini-lid.ko
kernel/drivers/input/misc/regulator-haptic.ko
+kernel/drivers/input/misc/uinput.ko
kernel/drivers/rtc/rtc-bq32k.ko
kernel/drivers/rtc/rtc-ds1307.ko
kernel/drivers/rtc/rtc-hym8563.ko
@@ -213,6 +217,12 @@ kernel/drivers/cpufreq/cpufreq_conservative.ko
kernel/drivers/cpufreq/battery-headroom.ko
kernel/drivers/cpufreq/cpufreq-dt.ko
kernel/drivers/cpufreq/mediatek-cpufreq-hw.ko
+kernel/drivers/hid/uhid.ko
+kernel/drivers/hid/hid-apple.ko
+kernel/drivers/hid/hid-logitech.ko
+kernel/drivers/hid/hid-lg-g15.ko
+kernel/drivers/hid/hid-logitech-hidpp.ko
+kernel/drivers/hid/hid-microsoft.ko
kernel/drivers/hid/usbhid/usbhid.ko
kernel/drivers/platform/chrome/cros-ec-typec.ko
kernel/drivers/devfreq/mtk-cci-devfreq.ko
@@ -253,7 +263,12 @@ kernel/drivers/nvmem/nvmem-rmem.ko
kernel/drivers/nvmem/nvmem_qcom-spmi-sdam.ko
kernel/drivers/mux/mux-gpio.ko
kernel/drivers/gnss/gnss-mt6797.ko
+kernel/drivers/bluetooth/btusb.ko
+kernel/drivers/bluetooth/btintel.ko
kernel/drivers/bluetooth/btmt6797.ko
+kernel/drivers/bluetooth/btbcm.ko
+kernel/drivers/bluetooth/btrtl.ko
+kernel/drivers/bluetooth/btmtk.ko
kernel/drivers/soundwire/soundwire-bus.ko
kernel/drivers/soundwire/soundwire-qcom.ko
kernel/sound/core/snd.ko
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.symbols b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.symbols
index 9fd2e74..de88db7 100644
--- a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.symbols
+++ b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.symbols
@@ -18,6 +18,8 @@ alias symbol:sdw_read_no_pm soundwire_bus
alias symbol:sdw_cols soundwire_bus
alias symbol:drm_dp_dsc_slice_count_to_mask drm_display_helper
alias symbol:copy_from_user_toio snd
+alias symbol:btintel_set_event_mask_mfg btintel
+alias symbol:btmtk_setup_firmware btmtk
alias symbol:__hci_cmd_sync_status bluetooth
alias symbol:v4l2_match_dv_timings v4l2_dv_timings
alias symbol:snd_soc_dai_action snd_soc_core
@@ -57,6 +59,7 @@ alias symbol:snd_soc_add_pcm_runtimes snd_soc_core
alias symbol:snd_rawmidi_free snd_rawmidi
alias symbol:snd_refcount_sync snd
alias symbol:cec_transmit_msg cec
+alias symbol:crypto_unregister_rngs rng
alias symbol:mt6797_hif_free mt6797_wlan_core
alias symbol:drm_dp_atomic_find_time_slots drm_display_helper
alias symbol:media_entity_enum_cleanup mc
@@ -94,12 +97,14 @@ alias symbol:drm_hdmi_avi_infoframe_content_type drm_display_helper
alias symbol:genphy_c45_plca_get_status libphy
alias symbol:phy_set_sym_pause libphy
alias symbol:udp_tunnel_dst_lookup udp_tunnel
+alias symbol:btintel_guid_dsm btintel
alias symbol:crc8_populate_msb crc8
alias symbol:snd_pcm_format_linear snd_pcm
alias symbol:v4l2_fh_init videodev
alias symbol:__phy_write_mmd libphy
alias symbol:graph_util_card_probe snd_soc_simple_card_utils
alias symbol:tcpci_register_port tcpci
+alias symbol:crypto_register_rng rng
alias symbol:snd_timer_pause snd_timer
alias symbol:media_graph_walk_init mc
alias symbol:snd_soc_find_dai_with_mutex snd_soc_core
@@ -132,9 +137,11 @@ alias symbol:copy_to_iter_fromio snd
alias symbol:snd_pcm_format_big_endian snd_pcm
alias symbol:v4l2_m2m_register_media_controller v4l2_mem2mem
alias symbol:drm_sched_job_has_dependency gpu_sched
+alias symbol:btmtk_usb_subsys_reset btmtk
alias symbol:drm_dp_mst_atomic_check_mgr drm_display_helper
alias symbol:v4l2_simplify_fraction videodev
alias symbol:drm_dp_vsc_sdp_log drm_display_helper
+alias symbol:btintel_print_fseq_info btintel
alias symbol:mdio_device_reset libphy
alias symbol:v4l2_src_change_event_subscribe videodev
alias symbol:drm_hdmi_avi_infoframe_bars drm_display_helper
@@ -176,6 +183,7 @@ alias symbol:snd_request_card snd
alias symbol:ip_vs_proto_name ip_vs
alias symbol:v4l2_m2m_ioctl_stateless_decoder_cmd v4l2_mem2mem
alias symbol:rt5682_reg snd_soc_rt5682
+alias symbol:btintel_acpi_reset_method btintel
alias symbol:snd_pcm_lib_ioctl snd_pcm
alias symbol:drm_dp_downstream_444_to_420_conversion drm_display_helper
alias symbol:mt6797_hif_join_bss_qos mt6797_wlan_core
@@ -268,6 +276,7 @@ alias symbol:snd_soc_dapm_ignore_suspend snd_soc_core
alias symbol:v4l2_valid_dv_timings v4l2_dv_timings
alias symbol:drm_dp_mst_port_downstream_of_parent drm_display_helper
alias symbol:bcm_config_lre_advert bcm_phy_lib
+alias symbol:btmtk_usb_shutdown btmtk
alias symbol:phy_start_cable_test_tdr libphy
alias symbol:drm_sched_job_init gpu_sched
alias symbol:snd_soc_component_update_bits_async snd_soc_core
@@ -282,6 +291,7 @@ alias symbol:snd_pcm_new_stream snd_pcm
alias symbol:snd_usb_find_format snd_usb_audio
alias symbol:snd_soc_unregister_card snd_soc_core
alias symbol:sdw_rows soundwire_bus
+alias symbol:btintel_regmap_init btintel
alias symbol:mdio_driver_register libphy
alias symbol:phy_get_pause libphy
alias symbol:snd_card_register snd
@@ -315,6 +325,7 @@ alias symbol:snd_dma_buffer_mmap snd_pcm
alias symbol:tcpm_unregister_port tcpm
alias symbol:media_create_pad_links mc
alias symbol:snd_soc_runtime_action snd_soc_core
+alias symbol:btintel_set_quality_report btintel
alias symbol:v4l2_fraction_to_interval videodev
alias symbol:slhc_uncompress slhc
alias symbol:bt_err_ratelimited bluetooth
@@ -324,6 +335,7 @@ alias symbol:bmi160_enable_irq bmi160_core
alias symbol:sdw_nwrite soundwire_bus
alias symbol:v4l2_i2c_subdev_set_name videodev
alias symbol:__mdiobus_modify_changed mdio_bus
+alias symbol:btrtl_set_driver_name btrtl
alias symbol:nf_ct_expect_hash nf_conntrack
alias symbol:usb_stor_disconnect usb_storage
alias symbol:phylink_ethtool_get_pauseparam phylink
@@ -347,6 +359,7 @@ alias symbol:phy_config_aneg libphy
alias symbol:v4l2_i2c_tuner_addrs videodev
alias symbol:genphy_c45_read_pma libphy
alias symbol:media_graph_walk_cleanup mc
+alias symbol:btintel_bootloader_setup_tlv btintel
alias symbol:snd_dmaengine_pcm_pointer snd_pcm_dmaengine
alias symbol:tap_free_minor tap
alias symbol:mt6359_set_mtkaif_calibration_phase snd_soc_mt6359
@@ -368,6 +381,7 @@ alias symbol:__phy_package_write_mmd phy_package
alias symbol:genphy_c45_eee_is_active libphy
alias symbol:hid_is_usb usbhid
alias symbol:snd_device_disconnect snd
+alias symbol:btintel_enter_mfg btintel
alias symbol:snd_soc_unregister_dai snd_soc_core
alias symbol:v4l2_mc_create_media_graph videodev
alias symbol:drm_dp_vsc_sdp_supported drm_display_helper
@@ -436,6 +450,7 @@ alias symbol:mt6797_hif_join_pm_abort_debt mt6797_wlan_core
alias symbol:drm_dp_remote_aux_init drm_display_helper
alias symbol:drm_dp_dual_mode_get_tmds_output drm_display_helper
alias symbol:mt6797_wifi_record_commands mt6797_wlan_core
+alias symbol:btbcm_patchram btbcm
alias symbol:phy_select_page libphy
alias symbol:snd_soc_usb_setup_offload_jack soc_usb
alias symbol:nft_meta_get_eval nf_tables
@@ -558,6 +573,7 @@ alias symbol:snd_soc_component_compr_get_codec_caps snd_soc_core
alias symbol:snd_soc_suspend snd_soc_core
alias symbol:st_sensors_allocate_trigger st_sensors
alias symbol:vb2_core_streamoff videobuf2_common
+alias symbol:btbcm_finalize btbcm
alias symbol:mt6797_hif_send_data_report mt6797_wlan_core
alias symbol:genphy_read_mmd_c45 libphy
alias symbol:simple_util_remove snd_soc_simple_card_utils
@@ -588,6 +604,7 @@ alias symbol:nf_ct_helper_expectfn_find_by_symbol nf_conntrack
alias symbol:sdw_stream_remove_master soundwire_bus
alias symbol:genphy_aneg_done libphy
alias symbol:__sdw_register_driver soundwire_bus
+alias symbol:crypto_unregister_rng rng
alias symbol:iio_triggered_buffer_cleanup industrialio_triggered_buffer
alias symbol:v4l2_m2m_dqbuf v4l2_mem2mem
alias symbol:v4l2_vp9_kf_partition_probs v4l2_vp9
@@ -598,6 +615,7 @@ alias symbol:drm_scdc_set_scrambling drm_display_helper
alias symbol:st_sensors_power_enable st_sensors
alias symbol:snd_sgbuf_get_chunk_size snd_pcm
alias symbol:snd_soc_component_get_kcontrol snd_soc_core
+alias symbol:btbcm_setup_patchram btbcm
alias symbol:media_device_unregister_entity mc
alias symbol:sdw_slave_read_lane_mapping soundwire_bus
alias symbol:__traceiter_vb2_v4l2_buf_queue videodev
@@ -663,6 +681,7 @@ alias symbol:cros_ec_sensors_core_write cros_ec_sensors_core
alias symbol:mtk_mmsys_mixer_in_channel_swap mtk_mmsys
alias symbol:snd_soc_bytes_info_ext snd_soc_core
alias symbol:mt8195_afe_enable_clk snd_soc_mt8195_afe
+alias symbol:btbcm_check_bdaddr btbcm
alias symbol:drm_hdmi_avi_infoframe_colorimetry drm_display_helper
alias symbol:snd_dma_free_pages snd_pcm
alias symbol:usb_serial_generic_chars_in_buffer usbserial
@@ -686,6 +705,7 @@ alias symbol:bt_warn_ratelimited bluetooth
alias symbol:cdc_ncm_change_mtu cdc_ncm
alias symbol:v4l2_event_subscribe videodev
alias symbol:vb2_buffer_in_use videobuf2_common
+alias symbol:btintel_set_diag btintel
alias symbol:mt6359_set_mtkaif_protocol snd_soc_mt6359
alias symbol:v4l2_fh_del videodev
alias symbol:usb_stor_bulk_transfer_buf usb_storage
@@ -702,6 +722,7 @@ alias symbol:v4l2_compat_ioctl32 videodev
alias symbol:drm_hdcp_check_ksvs_revoked drm_display_helper
alias symbol:nf_ct_bridge_register nf_conntrack
alias symbol:xt_register_targets x_tables
+alias symbol:btintel_recv_event btintel
alias symbol:mtk_afe_pcm_platform snd_soc_mtk_common
alias symbol:phylink_ethtool_set_pauseparam phylink
alias symbol:snd_card_rw_proc_new snd
@@ -745,6 +766,7 @@ alias symbol:snd_fasync_free snd
alias symbol:genphy_c45_check_and_restart_aneg libphy
alias symbol:hci_set_fw_info bluetooth
alias symbol:v4l2_m2m_ioctl_try_encoder_cmd v4l2_mem2mem
+alias symbol:btintel_set_bdaddr btintel
alias symbol:nf_conntrack_helper_unregister nf_conntrack
alias symbol:wcd_interrupt_callback snd_soc_wcd_common
alias symbol:xhci_stop xhci_hcd
@@ -813,6 +835,7 @@ alias symbol:v4l2_detect_cvt v4l2_dv_timings
alias symbol:phy_10gbit_features libphy
alias symbol:cec_allocate_adapter cec
alias symbol:drm_dp_dpcd_poll_act_handled drm_display_helper
+alias symbol:crypto_del_default_rng rng
alias symbol:tcpm_pd_receive tcpm
alias symbol:mt6797_hif_set_data_bw40 mt6797_wlan_core
alias symbol:snd_soc_component_alloc snd_soc_core
@@ -855,6 +878,7 @@ alias symbol:phy_restart_aneg libphy
alias symbol:snd_soc_dapm_get_volsw snd_soc_core
alias symbol:__hci_reset_dev bluetooth
alias symbol:xt_request_find_target x_tables
+alias symbol:btintel_configure_setup btintel
alias symbol:xhci_sideband_remove_interrupter xhci_hcd
alias symbol:nft_request_module nf_tables
alias symbol:usb_stor_resume usb_storage
@@ -900,6 +924,7 @@ alias symbol:v4l2_m2m_ioctl_create_bufs v4l2_mem2mem
alias symbol:mtk_memif_set_rate_substream snd_soc_mtk_common
alias symbol:phy_speed_up libphy
alias symbol:linedisp_unregister line_display
+alias symbol:btrtl_shutdown_realtek btrtl
alias symbol:snd_card_disconnect_sync snd
alias symbol:v4l2_fwnode_endpoint_parse v4l2_fwnode
alias symbol:v4l2_query_ext_ctrl videodev
@@ -951,6 +976,7 @@ alias symbol:bcm_phy_enable_jumbo bcm_phy_lib
alias symbol:es8328_probe snd_soc_es8328
alias symbol:usb_stor_reset_resume usb_storage
alias symbol:mt8192_afe_gpio_request snd_soc_mt8192_afe
+alias symbol:btrtl_set_quirks btrtl
alias symbol:snd_card_add_dev_attr snd
alias symbol:snd_devm_card_new snd
alias symbol:v4l2_g_ctrl videodev
@@ -1048,6 +1074,7 @@ alias symbol:st_sensors_debugfs_reg_access st_sensors
alias symbol:nf_ct_ext_add nf_conntrack
alias symbol:snd_pcm_lib_default_mmap snd_pcm
alias symbol:graph_util_parse_trigger_order snd_soc_simple_card_utils
+alias symbol:mt6797_hif_join_key_cipher mt6797_wlan_core
alias symbol:sdw_shutdown_stream soundwire_bus
alias symbol:wcd_mbhc_typec_report_unplug snd_soc_wcd_mbhc
alias symbol:xt_unregister_targets x_tables
@@ -1068,6 +1095,7 @@ alias symbol:l2cap_conn_hold_unless_zero bluetooth
alias symbol:snd_soc_link_compr_set_params snd_soc_core
alias symbol:nf_ct_get_tuplepr nf_conntrack
alias symbol:snd_soc_dlc_use_cpu_as_platform snd_soc_core
+alias symbol:btmtk_register_coredump btmtk
alias symbol:imx_audmux_v2_configure_port snd_soc_imx_audmux
alias symbol:v4l2_ctrl_radio_filter videodev
alias symbol:v4l2_fwnode_parse_link v4l2_fwnode
@@ -1093,6 +1121,7 @@ alias symbol:wcd_bus_config snd_soc_wcd_common
alias symbol:xt_hook_ops_alloc x_tables
alias symbol:drm_dp_dsc_branch_max_overall_throughput drm_display_helper
alias symbol:wcd938x_sdw_hw_params snd_soc_wcd938x_sdw
+alias symbol:btmtk_usb_suspend btmtk
alias symbol:nf_ct_unlink_expect_report nf_conntrack
alias symbol:drm_dp_max_dprx_data_rate drm_display_helper
alias symbol:mt6797_hif_cleanup_ready mt6797_wlan_core
@@ -1103,11 +1132,13 @@ alias symbol:nf_conntrack_lock nf_conntrack
alias symbol:v4l2_ctrl_subdev_log_status videodev
alias symbol:cros_ec_sensors_pm_ops cros_ec_sensors_core
alias symbol:mt6797_hif_query_capability mt6797_wlan_core
+alias symbol:mt6797_hif_send_eapol_native mt6797_wlan_core
alias symbol:snd_ctl_replace snd
alias symbol:vb2_mmap videobuf2_common
alias symbol:free_mdio_bitbang mdio_bitbang
alias symbol:phylink_fwnode_phy_connect phylink
alias symbol:bt_sock_stream_recvmsg bluetooth
+alias symbol:btmtk_usb_recv_acl btmtk
alias symbol:drm_dp_pcon_dsc_bpp_incr drm_display_helper
alias symbol:genphy_c45_read_lpa libphy
alias symbol:media_request_object_find mc
@@ -1186,6 +1217,7 @@ alias symbol:__media_remove_intf_link mc
alias symbol:hci_set_hw_info bluetooth
alias symbol:v4l2_subdev_call_wrappers videodev
alias symbol:usbnet_set_link_ksettings_mii usbnet
+alias symbol:btbcm_setup_apple btbcm
alias symbol:IIO_ST_SENSORS st_magn
alias symbol:phy_eee_rx_clock_stop libphy
alias symbol:nf_ct_delete nf_conntrack
@@ -1219,6 +1251,8 @@ alias symbol:ip_vs_proto_data_get ip_vs
alias symbol:phylink_replay_link_begin phylink
alias symbol:xhci_sideband_interrupter_id xhci_hcd
alias symbol:usbnet_unlink_rx_urbs usbnet
+alias symbol:btintel_read_boot_params btintel
+alias symbol:btmtk_fw_get_filename btmtk
alias symbol:v4l2_m2m_ioctl_try_decoder_cmd v4l2_mem2mem
alias symbol:xhci_shutdown xhci_hcd
alias symbol:snd_usb_hw_free snd_usb_audio
@@ -1335,6 +1369,7 @@ alias symbol:rt5682_volatile_register snd_soc_rt5682
alias symbol:phy_get_tx_amplitude_gain libphy
alias symbol:vb2_create_bufs videobuf2_v4l2
alias symbol:snd_device_free snd
+alias symbol:btintel_bootup btintel
alias symbol:nft_meta_inner_eval nf_tables
alias symbol:snd_soc_of_parse_audio_routing snd_soc_core
alias symbol:xhci_dbg_trace xhci_hcd
@@ -1439,12 +1474,14 @@ alias symbol:nf_ct_helper_ext_add nf_conntrack
alias symbol:drm_sched_entity_destroy gpu_sched
alias symbol:nf_conntrack_htable_size nf_conntrack
alias symbol:at803x_config_intr qcom_phy_lib
+alias symbol:btrtl_download_firmware btrtl
alias symbol:drm_scdc_read drm_display_helper
alias symbol:mdiobus_c45_write_nested mdio_bus
alias symbol:phylink_ethtool_ksettings_set phylink
alias symbol:usbnet_read_cmd usbnet
alias symbol:nf_ct_netns_get nf_conntrack
alias symbol:drm_dp_aux_register drm_display_helper
+alias symbol:btintel_download_firmware btintel
alias symbol:qcom_vadc_decimation_from_dt qcom_vadc_common
alias symbol:snd_soc_link_compr_startup snd_soc_core
alias symbol:__SCK__tp_func_vb2_v4l2_buf_done videodev
@@ -1500,6 +1537,7 @@ alias symbol:phy_device_register libphy
alias symbol:xt_unregister_target x_tables
alias symbol:v4l2_ctrl_auto_cluster videodev
alias symbol:v4l2_m2m_mmap v4l2_mem2mem
+alias symbol:btintel_secure_send_result btintel
alias symbol:snd_soc_bytes_put snd_soc_core
alias symbol:tcpm_port_is_toggling tcpm
alias symbol:__traceiter_vb2_v4l2_buf_done videodev
@@ -1511,6 +1549,7 @@ alias symbol:devm_drm_dp_hpd_bridge_alloc aux_hpd_bridge
alias symbol:phy_package_get_priv phy_package
alias symbol:v4l2_src_change_event_subdev_subscribe videodev
alias symbol:at803x_cdt_start qcom_phy_lib
+alias symbol:btintel_send_intel_reset btintel
alias symbol:sdw_write_no_pm soundwire_bus
alias symbol:crc_itu_t crc_itu_t
alias symbol:phy_save_page libphy
@@ -1555,6 +1594,7 @@ alias symbol:usbnet_device_suggests_idle usbnet
alias symbol:sdw_prepare_stream soundwire_bus
alias symbol:qcom_vadc_scale qcom_vadc_common
alias symbol:usb_wwan_dtr_rts usb_wwan
+alias symbol:btbcm_set_bdaddr btbcm
alias symbol:phy_init_eee libphy
alias symbol:usb_wwan_suspend usb_wwan
alias symbol:simple_util_is_convert_required snd_soc_simple_card_utils
@@ -1606,6 +1646,7 @@ alias symbol:drm_dp_set_phy_test_pattern drm_display_helper
alias symbol:phylink_start phylink
alias symbol:nf_reject_skb_v4_unreach nf_reject_ipv4
alias symbol:slhc_init slhc
+alias symbol:btintel_load_ddc_config btintel
alias symbol:mtk_memif_set_disable snd_soc_mtk_common
alias symbol:mt8183_dai_i2s_set_share snd_soc_mt8183_afe
alias symbol:v4l2_ctrl_get_menu videodev
@@ -1614,6 +1655,7 @@ alias symbol:nf_conntrack_unregister_notifier nf_conntrack
alias symbol:v4l2_event_queue videodev
alias symbol:snd_show_eld snd_pcm
alias symbol:media_device_unregister mc
+alias symbol:btmtk_set_bdaddr btmtk
alias symbol:drm_dp_dual_mode_read drm_display_helper
alias symbol:mcp23x08_regmap pinctrl_mcp23s08
alias symbol:swphy_validate_state libphy
@@ -1759,6 +1801,7 @@ alias symbol:mtk_afe_resume snd_soc_mtk_common
alias symbol:copy_to_user_fromio snd
alias symbol:snd_pcm_format_name snd_pcm
alias symbol:snd_soc_jack_add_gpiods snd_soc_core
+alias symbol:btmtk_reset_sync btmtk
alias symbol:snd_pcm_lib_preallocate_pages_for_all snd_pcm
alias symbol:vb2_streamoff videobuf2_v4l2
alias symbol:snd_ctl_add snd
@@ -1806,6 +1849,7 @@ alias symbol:xt_check_match x_tables
alias symbol:ip_tunnel_encap_add_ops ip_tunnel
alias symbol:phy_device_free libphy
alias symbol:tap_get_socket tap
+alias symbol:btbcm_write_pcm_int_params btbcm
alias symbol:phy_ethtool_get_eee libphy
alias symbol:snd_rawmidi_init snd_rawmidi
alias symbol:snd_usb_hw_params snd_usb_audio
@@ -1826,6 +1870,7 @@ alias symbol:nf_nat_exp_find_port nf_nat
alias symbol:v4l2_i2c_new_subdev videodev
alias symbol:fsl_asoc_get_xr_sx snd_soc_fsl_utils
alias symbol:nft_meta_set_dump nf_tables
+alias symbol:btbcm_initialize btbcm
alias symbol:rndis_tx_fixup rndis_host
alias symbol:hci_cmd_sync_cancel_sync bluetooth
alias symbol:v4l2_ctrl_find videodev
@@ -1833,6 +1878,7 @@ alias symbol:mdio_driver_unregister libphy
alias symbol:usb_stor_pre_reset usb_storage
alias symbol:bcm_phy_config_intr bcm_phy_lib
alias symbol:snd_soc_put_strobe snd_soc_core
+alias symbol:crypto_alloc_rng rng
alias symbol:drm_dp_psr_setup_time drm_display_helper
alias symbol:xt_register_target x_tables
alias symbol:nf_nat_masquerade_ipv4 nf_nat
@@ -1845,6 +1891,7 @@ alias symbol:phylink_limit_mac_speed phylink
alias symbol:snd_soc_dapm_force_enable_pin snd_soc_core
alias symbol:xhci_sideband_get_endpoint_buffer xhci_hcd
alias symbol:smsc_phy_config_init smsc
+alias symbol:btintel_set_msft_opcode btintel
alias symbol:mt6358_set_mtkaif_protocol snd_soc_mt6358
alias symbol:mt6797_hif_host_interrupt mt6797_wlan_core
alias symbol:net_selftest selftests
@@ -1901,6 +1948,7 @@ alias symbol:snd_soc_unregister_component_by_driver snd_soc_core
alias symbol:bcm_phy_downshift_set bcm_phy_lib
alias symbol:vb2_fop_read videobuf2_v4l2
alias symbol:usbnet_cdc_status cdc_ether
+alias symbol:btintel_check_bdaddr btintel
alias symbol:ucsi_register typec_ucsi
alias symbol:lpass_macro_set_codec_version snd_soc_lpass_macro_common
alias symbol:snd_card_disconnect snd
@@ -1912,6 +1960,7 @@ alias symbol:snd_soc_dai_digital_mute snd_soc_core
alias symbol:usb_stor_sense_invalidCDB usb_storage
alias symbol:v4l2_vp9_reset_frame_ctx v4l2_vp9
alias symbol:drm_fbdev_dma_driver_fbdev_probe drm_dma_helper
+alias symbol:btintel_parse_version_tlv btintel
alias symbol:phy_read_mmd libphy
alias symbol:snd_soc_jack_add_zones snd_soc_core
alias symbol:swphy_read_reg libphy
@@ -1953,6 +2002,7 @@ alias symbol:v4l2_calc_timeperframe v4l2_dv_timings
alias symbol:phylink_mii_c22_pcs_an_restart phylink
alias symbol:st_sensors_set_enable st_sensors
alias symbol:__traceiter_xhci_dbg_init xhci_hcd
+alias symbol:btrtl_free btrtl
alias symbol:xt_match_to_user x_tables
alias symbol:ip_tunnel_init_net ip_tunnel
alias symbol:snd_soc_component_compr_pointer snd_soc_core
@@ -1987,6 +2037,7 @@ alias symbol:mtk_hdmi_get_ncts mtk_hdmi_common
alias symbol:phy_config_inband libphy
alias symbol:fixed_phy_change_carrier fixed_phy
alias symbol:__tracepoint_xhci_dbg_init xhci_hcd
+alias symbol:btmtk_usb_setup btmtk
alias symbol:drm_dp_stop_crc drm_display_helper
alias symbol:snd_soc_dapm_enable_pin snd_soc_core
alias symbol:v4l2_i2c_subdev_init videodev
@@ -2001,8 +2052,10 @@ alias symbol:drm_dp_mst_get_edid drm_display_helper
alias symbol:rt5640_disable_micbias1_for_ovcd snd_soc_rt5640
alias symbol:phy_stop libphy
alias symbol:cdc_ncm_rx_verify_nth16 cdc_ncm
+alias symbol:crypto_rng_reset rng
alias symbol:lpass_macro_pds_init snd_soc_lpass_macro_common
alias symbol:at803x_handle_interrupt qcom_phy_lib
+alias symbol:btintel_version_info btintel
alias symbol:vb2_core_create_bufs videobuf2_common
alias symbol:video_unregister_device videodev
alias symbol:phy_print_status libphy
@@ -2034,9 +2087,11 @@ alias symbol:poly1305_final libpoly1305
alias symbol:snd_pcm_format_silence_64 snd_pcm
alias symbol:snd_usb_unlock_shutdown snd_usb_audio
alias symbol:v4l2_ctrl_new_std_menu videodev
+alias symbol:alloc_mtk_intr_urb btmtk
alias symbol:drm_hdmi_acr_get_n_cts drm_display_helper
alias symbol:of_sdw_find_device_by_node soundwire_bus
alias symbol:xchacha20poly1305_encrypt libchacha20poly1305
+alias symbol:btmtk_process_coredump btmtk
alias symbol:qcom_phy_get_stats qcom_phy_lib
alias symbol:snd_usbmidi_disconnect snd_usbmidi_lib
alias symbol:drm_fb_dma_get_gem_addr drm_dma_helper
@@ -2046,8 +2101,10 @@ alias symbol:v4l2_ctrl_merge videodev
alias symbol:v4l2_m2m_expbuf v4l2_mem2mem
alias symbol:ppp_output_wakeup ppp_generic
alias symbol:snd_pcm_stream_unlock_irqrestore snd_pcm
+alias symbol:btrtl_initialize btrtl
alias symbol:usb_stor_control_msg usb_storage
alias symbol:usb_wwan_write_room usb_wwan
+alias symbol:btintel_exit_mfg btintel
alias symbol:st_sensors_set_dataready_irq st_sensors
alias symbol:nf_nat_ipv4_register_fn nf_nat
alias symbol:nft_set_do_lookup nf_tables
@@ -2056,6 +2113,7 @@ alias symbol:microtune_attach mt20xx
alias symbol:tda18271_attach tda18271
alias symbol:usb_serial_generic_write_start usbserial
alias symbol:v4l2_subdev_notify_event videodev
+alias symbol:btintel_version_info_tlv btintel
alias symbol:__phy_modify_mmd libphy
alias symbol:v4l2_ctrl_replace videodev
alias symbol:phy_find_next libphy
@@ -2185,6 +2243,7 @@ alias symbol:st_sensors_init_sensor st_sensors
alias symbol:udp_tunnel_notify_del_rx_port udp_tunnel
alias symbol:snd_ctl_find_numid snd
alias symbol:chacha20poly1305_encrypt libchacha20poly1305
+alias symbol:crypto_register_rngs rng
alias symbol:qca808x_led_reg_hw_control_enable qcom_phy_lib
alias symbol:__devm_regmap_init_spmi_ext regmap_spmi
alias symbol:nft_hook_find_ops nf_tables
@@ -2240,6 +2299,7 @@ alias symbol:media_create_intf_link mc
alias symbol:mtk_hdmi_bridge_mode_fixup mtk_hdmi_common
alias symbol:bcm_phy_led_brightness_set bcm_phy_lib
alias symbol:nf_conntrack_eventmask_report nf_conntrack
+alias symbol:btintel_read_version btintel
alias symbol:phylink_mii_c22_pcs_encode_advertisement phylink
alias symbol:snd_soc_register_component_d snd_soc_core
alias symbol:__hci_cmd_send bluetooth
@@ -2254,6 +2314,7 @@ alias symbol:mt6797_hif_join_station mt6797_wlan_core
alias symbol:__regmap_init_sdw regmap_sdw
alias symbol:xhci_hub_control xhci_hcd
alias symbol:mt6797_wifi_record_data mt6797_wlan_core
+alias symbol:btrtl_get_uart_settings btrtl
alias symbol:phy_start libphy
alias symbol:simple_util_init_aux_jacks snd_soc_simple_card_utils
alias symbol:phylink_mii_ioctl phylink
@@ -2275,7 +2336,9 @@ alias symbol:usbnet_cdc_zte_rx_fixup cdc_ether
alias symbol:bt_sock_alloc bluetooth
alias symbol:snd_soc_card_jack_new snd_soc_core
alias symbol:st_magn_common_probe st_magn
+alias symbol:btrtl_setup_realtek btrtl
alias symbol:v4l2_m2m_ioctl_stateless_try_decoder_cmd v4l2_mem2mem
+alias symbol:btmtk_recv_event btmtk
alias symbol:at803x_read_status qcom_phy_lib
alias symbol:snd_soc_ret snd_soc_core
alias symbol:v4l2_fill_pixfmt_mp_aligned videodev
@@ -2284,6 +2347,7 @@ alias symbol:nf_ct_seqadj_init nf_conntrack
alias symbol:phy_connect_direct libphy
alias symbol:hci_cmd_sync_dequeue bluetooth
alias symbol:linkmode_resolve_pause libphy
+alias symbol:btmtk_setup_firmware_79xx btmtk
alias symbol:media_request_get_by_fd mc
alias symbol:vb2_core_reqbufs videobuf2_common
alias symbol:mtk_hdmi_audio_get_eld mtk_hdmi_common
@@ -2329,6 +2393,7 @@ alias symbol:macvlan_link_register macvlan
alias symbol:rl6231_calc_dmic_clk snd_soc_rl6231
alias symbol:snd_soc_card_set_topology_name snd_soc_core
alias symbol:tuners tuner_types
+alias symbol:__crypto_stdrng_get_bytes rng
alias symbol:video_ioctl2 videodev
alias symbol:fsl_asoc_get_enum_double snd_soc_fsl_utils
alias symbol:snd_pcm_lib_free_pages snd_pcm
@@ -2349,6 +2414,7 @@ alias symbol:mtk_mmsys_hdr_config mtk_mmsys
alias symbol:usbnet_suspend usbnet
alias symbol:sdw_find_col_index soundwire_bus
alias symbol:snd_ctl_enum_info snd
+alias symbol:btbcm_read_pcm_int_params btbcm
alias symbol:mdiobus_alloc_size libphy
alias symbol:v4l2_device_put videodev
alias symbol:vb2_queue_error videobuf2_common
@@ -2440,6 +2506,7 @@ alias symbol:drm_dp_mst_update_slots drm_display_helper
alias symbol:hci_devcd_register bluetooth
alias symbol:nf_nat_inet_fn nf_nat
alias symbol:snd_pcm_format_size snd_pcm
+alias symbol:btintel_shutdown_combined btintel
alias symbol:snd_soc_dai_set_sysclk snd_soc_core
alias symbol:curve25519 libcurve25519
alias symbol:hci_alloc_dev_priv bluetooth
@@ -2506,6 +2573,7 @@ alias symbol:phy_package_unlock phy_package
alias symbol:snd_pcm_stop snd_pcm
alias symbol:usb_serial_generic_write_bulk_callback usbserial
alias symbol:usbnet_start_xmit usbnet
+alias symbol:btintel_hw_error btintel
alias symbol:phy_port_destroy libphy
alias symbol:simple_util_be_hw_params_fixup snd_soc_simple_card_utils
alias symbol:phy_port_get_type libphy
@@ -2554,6 +2622,7 @@ alias symbol:drm_dp_send_real_edid_checksum drm_display_helper
alias symbol:tda829x_probe tda8290
alias symbol:ucsi_send_command typec_ucsi
alias symbol:cdc_ncm_rx_verify_ndp16 cdc_ncm
+alias symbol:btmtk_usb_resume btmtk
alias symbol:cec_s_phys_addr_from_edid cec
alias symbol:drm_connector_hdmi_audio_init drm_display_helper
alias symbol:drm_dp_vsc_sdp_pack drm_display_helper
diff --git a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.symbols.bin b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.symbols.bin
index 9c317ed..5d11afb 100644
Binary files a/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.symbols.bin and b/prebuilt/kernel/lib/modules/7.3.5-geminux/modules.symbols.bin differ
diff --git a/prebuilt/suckless/usr/bin/dmenu b/prebuilt/suckless/usr/bin/dmenu
index 5e97965..bd879ae 100755
Binary files a/prebuilt/suckless/usr/bin/dmenu and b/prebuilt/suckless/usr/bin/dmenu differ
diff --git a/prebuilt/suckless/usr/bin/dwm b/prebuilt/suckless/usr/bin/dwm
index c5d233a..11afef8 100755
Binary files a/prebuilt/suckless/usr/bin/dwm and b/prebuilt/suckless/usr/bin/dwm differ
diff --git a/prebuilt/suckless/usr/bin/st b/prebuilt/suckless/usr/bin/st
index f5c4356..5fa7169 100755
Binary files a/prebuilt/suckless/usr/bin/st and b/prebuilt/suckless/usr/bin/st differ
diff --git a/rebuild-image.sh b/rebuild-image.sh
index b29125c..b89a38b 100755
--- a/rebuild-image.sh
+++ b/rebuild-image.sh
@@ -141,6 +141,17 @@ PYEOF
chown 0:0 /rootfs/usr/bin/Xorg
chmod 04755 /rootfs/usr/bin/Xorg
fi
+ if [ -f /rootfs/usr/libexec/dbus-daemon-launch-helper ]; then
+ DBUS_GID="$(awk -F: "\$1 == \"messagebus\" { print \$3; exit }" /rootfs/etc/group)"
+ chown "0:${DBUS_GID:-103}" /rootfs/usr/libexec/dbus-daemon-launch-helper
+ chmod 04750 /rootfs/usr/libexec/dbus-daemon-launch-helper
+ fi
+ if [ -d /rootfs/etc/polkit-1/rules.d ]; then
+ POLKIT_GID="$(awk -F: "\$1 == \"polkitd\" { print \$3; exit }" /rootfs/etc/group)"
+ chown "0:${POLKIT_GID:-110}" /rootfs/etc/polkit-1/rules.d
+ chmod 0750 /rootfs/etc/polkit-1/rules.d
+ chmod 0644 /rootfs/etc/polkit-1/rules.d/*.rules 2>/dev/null || true
+ fi
USED_KB="$(du -sk /rootfs | awk "{print \$1}")"
# Allocate exact content + ~512 MiB headroom (1 MiB aligned)
diff --git a/scripts/apply-geminux-overlay.sh b/scripts/apply-geminux-overlay.sh
index f6448c1..34da9c2 100755
--- a/scripts/apply-geminux-overlay.sh
+++ b/scripts/apply-geminux-overlay.sh
@@ -135,6 +135,7 @@ if command -v glib-compile-schemas >/dev/null 2>&1 && \
fi
rm -f "$TARGET_ROOTFS/etc/runlevels/sysinit/hwdrivers"
+rm -f "$TARGET_ROOTFS/etc/runlevels/default/wpa_supplicant"
if [ -f "$TARGET_ROOTFS/etc/inittab" ]; then
sed -i 's/^tty1::respawn:/#tty1::respawn:/' "$TARGET_ROOTFS/etc/inittab"
fi
@@ -154,19 +155,36 @@ if [ -e "$TARGET_ROOTFS/etc/init.d/geminux-usb-gadget" ]; then
fi
rm -f "$TARGET_ROOTFS/etc/runlevels/default/geminux-usb-gadget"
-for svc in geminux-hwinit geminux-ccci geminux-powerd geminux-leds; do
+for svc in geminux-hwinit geminux-ccci geminux-powerd geminux-leds bluetooth polkit; do
if [ -e "$TARGET_ROOTFS/etc/init.d/$svc" ]; then
mkdir -p "$TARGET_ROOTFS/etc/runlevels/default"
ln -sf "/etc/init.d/$svc" "$TARGET_ROOTFS/etc/runlevels/default/$svc"
fi
done
-rm -f "$TARGET_ROOTFS/etc/runlevels/default/bluetooth"
if [ -x "$BASE_DIR/scripts/version.sh" ]; then
"$BASE_DIR/scripts/version.sh" "$TARGET_ROOTFS"
fi
"$BASE_DIR/scripts/set-geminux-hostname.sh" "$TARGET_ROOTFS" "$DEVICE"
+if [ -x "$TARGET_ROOTFS/bin/bash" ] && [ ! -e "$TARGET_ROOTFS/usr/bin/bash" ]; then
+ ln -sf /bin/bash "$TARGET_ROOTFS/usr/bin/bash"
+fi
+
+if [ -f "$TARGET_ROOTFS/etc/passwd" ]; then
+ sed -i -E \
+ -e 's#^(root:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*):.*#\1:/bin/bash#' \
+ -e 's#^(user:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*):.*#\1:/bin/bash#' \
+ "$TARGET_ROOTFS/etc/passwd"
+fi
+
+mkdir -p "$TARGET_ROOTFS/root"
+for f in .bashrc .profile .bash_profile; do
+ if [ -f "$TARGET_ROOTFS/etc/skel/$f" ]; then
+ cp -f "$TARGET_ROOTFS/etc/skel/$f" "$TARGET_ROOTFS/root/$f"
+ fi
+done
+
echo "[4/4] Populating /home/user skel and setting permissions..."
mkdir -p "$TARGET_ROOTFS/home/user/.config" "$TARGET_ROOTFS/home/user/.local/share/geminux" \
"$TARGET_ROOTFS/home/user/Pictures" "$TARGET_ROOTFS/home/user/Videos" \
diff --git a/scripts/bootstrap-rootfs-container.sh b/scripts/bootstrap-rootfs-container.sh
index f12a3b8..33052ed 100755
--- a/scripts/bootstrap-rootfs-container.sh
+++ b/scripts/bootstrap-rootfs-container.sh
@@ -93,12 +93,17 @@ system_users = [
"dnsmasq:x:103:104:dnsmasq:/dev/null:/sbin/nologin",
"polkitd:x:105:110:polkitd:/var/empty:/sbin/nologin",
"greetd:x:107:112:greetd:/var/lib/greetd:/sbin/nologin",
- "user:x:10000:10000::/home/user:/bin/ash",
+ "user:x:10000:10000::/home/user:/bin/bash",
]
for entry in system_users:
name = entry.split(":")[0]
if not any(row.startswith(name + ":") for row in passwd):
passwd.append(entry)
+for idx, row in enumerate(passwd):
+ fields = row.split(":")
+ if len(fields) >= 7 and fields[0] in ("root", "user"):
+ fields[6] = "/bin/bash"
+ passwd[idx] = ":".join(fields)
system_groups = [
"klogd:x:101:klogd",
@@ -119,7 +124,7 @@ for entry in system_groups:
member_groups = (
"wheel", "audio", "input", "netdev", "plugdev", "video", "seat",
- "dialout", "tty", "pipewire",
+ "dialout", "tty", "pipewire", "lp",
)
for index, row in enumerate(group):
fields = row.split(":")
@@ -200,8 +205,8 @@ done
for svc in bootmisc hostname loopback modules sysctl tmpfs zram-init; do
enable_service boot "$svc"
done
-for svc in cgroups chronyd dbus elogind local modemmanager networkmanager \
- sshd tinydm udev-postmount wpa_supplicant; do
+for svc in bluetooth cgroups chronyd dbus elogind local modemmanager networkmanager \
+ polkit sshd tinydm udev-postmount; do
enable_service default "$svc"
done
for svc in killprocs mount-ro savecache; do
diff --git a/scripts/build-kernel.sh b/scripts/build-kernel.sh
index aab094c..ea01d05 100755
--- a/scripts/build-kernel.sh
+++ b/scripts/build-kernel.sh
@@ -188,9 +188,10 @@ EOF
(cd "$stage_dir" && find . -print0 | cpio --null -ov --format=newc --quiet | gzip -9 > "$out_gz")
}
- # Also add e2fsprogs (e2fsck, resize2fs) + shared libs for initramfs filesystem safety
+ # Also add e2fsprogs (e2fsck, resize2fs) + shared libs for initramfs filesystem safety,
+ # and wireless-regdb so built-in cfg80211 loads regulatory.db at early boot.
apk --root "$SYSROOT_INIT" --arch aarch64 add --no-scripts \
- musl e2fsprogs e2fsprogs-extra util-linux-misc >/dev/null
+ musl e2fsprogs e2fsprogs-extra util-linux-misc wireless-regdb >/dev/null
build_cpio_with_fs() {
mode="$1"
@@ -201,6 +202,10 @@ EOF
cp -a "$SYSROOT_INIT/lib/"ld-musl-*.so* "$stage_dir/lib/" 2>/dev/null || true
cp -a "$SYSROOT_INIT/lib/lib"* "$stage_dir/lib/" 2>/dev/null || true
cp -a "$SYSROOT_INIT/usr/lib/lib"* "$stage_dir/usr/lib/" 2>/dev/null || true
+ if [ -f "$SYSROOT_INIT/lib/firmware/regulatory.db" ]; then
+ mkdir -p "$stage_dir/lib/firmware"
+ cp -a "$SYSROOT_INIT/lib/firmware/regulatory.db"* "$stage_dir/lib/firmware/"
+ fi
for tool in e2fsck fsck.ext4 resize2fs blkid; do
if [ -e "$SYSROOT_INIT/sbin/$tool" ]; then
cp -a "$SYSROOT_INIT/sbin/$tool" "$stage_dir/sbin/"
diff --git a/scripts/build-suckless.sh b/scripts/build-suckless.sh
index df5b163..1bceee3 100755
--- a/scripts/build-suckless.sh
+++ b/scripts/build-suckless.sh
@@ -46,6 +46,8 @@ EOF
musl-dev \
libx11-dev \
libxft-dev \
+ libxfixes-dev \
+ libxi-dev \
libxinerama-dev \
libxrender-dev \
fontconfig-dev \
diff --git a/scripts/check-rebuild.sh b/scripts/check-rebuild.sh
index 6ced45e..844099b 100755
--- a/scripts/check-rebuild.sh
+++ b/scripts/check-rebuild.sh
@@ -23,13 +23,12 @@ if grep -qi 'postmarketos' "$ROOTFS_DIR/etc/apk/repositories"; then
fi
echo "OK"
-echo "[2/8] Checking excluded Wayland/Rust/compiler/upstream packages..."
+echo "[2/8] Checking excluded Wayland/Rust/upstream packages..."
for bad_pkg in sway wayfire weston phosh cage xwayland grim slurp wofi \
sudo-rs postmarketos-base-sudo-rs rust cargo librsvg libglycin rav1e \
rav1e-libs libdovi mesa-rusticl gdk-pixbuf adwaita-icon-theme imv-x11 \
gst-libav gst-plugins-bad gst-plugins-good libnotify \
- linux-edge linux-lts xorg-server xf86-input-libinput xf86-video-fbdev \
- gcc g++ musl-dev make; do
+ linux-edge linux-lts xorg-server xf86-input-libinput xf86-video-fbdev; do
if grep -Fxq "P:$bad_pkg" "$ROOTFS_DIR/lib/apk/db/installed"; then
echo "FAIL: forbidden package '$bad_pkg' is installed in rootfs" >&2
exit 1
@@ -195,11 +194,15 @@ if "CONFIG_REGULATOR_FIXED_VOLTAGE=y" not in kcfg.splitlines():
rootfs = sys.argv[4]
for req_rel in ("etc/pam.d/autologin", "etc/init.d/geminux-hwinit",
"usr/lib/dri/simpledrm_dri.so", "etc/runlevels/boot/geminux-usb-gadget",
- "usr/share/X11/xkb/types/custom", "usr/sbin/dnsmasq"):
+ "usr/share/X11/xkb/types/custom", "usr/sbin/dnsmasq",
+ "etc/NetworkManager/conf.d/20-geminux-wifi.conf", "etc/shells",
+ "usr/sbin/geminux-wifi-nvram", "etc/polkit-1/rules.d/10-geminux.rules"):
if not os.path.lexists(os.path.join(rootfs, req_rel)):
raise SystemExit(f"FAIL: missing required path {os.path.join(rootfs, req_rel)}")
if os.path.lexists(os.path.join(rootfs, "etc/runlevels/sysinit/hwdrivers")):
raise SystemExit("FAIL: hwdrivers must not be enabled in sysinit")
+if os.path.lexists(os.path.join(rootfs, "etc/runlevels/default/wpa_supplicant")):
+ raise SystemExit("FAIL: wpa_supplicant must not be enabled in default runlevel")
with open(os.path.join(rootfs, "etc/inittab"), "r", encoding="utf-8") as f:
for line in f:
if line.startswith("tty1::respawn:"):
@@ -210,6 +213,9 @@ for rel, needle in (
("etc/X11/xorg.conf.d/30-geminux-keyboard.conf", "custom:types"),
("etc/X11/xorg.conf.d/20-geminux-touch.conf", "0 -1 1 1 0 0 0 0 1"),
("etc/conf.d/geminux-hwinit", 'GEMINUX_ENABLE_MEDIATEK_DRM="yes"'),
+ ("etc/NetworkManager/conf.d/20-geminux-wifi.conf", "wifi.scan-rand-mac-address = no"),
+ ("etc/NetworkManager/conf.d/20-geminux-wifi.conf", "wifi-sec.pmf = 1"),
+ ("etc/shells", "/bin/bash"),
):
p = os.path.join(rootfs, rel)
with open(p, "r", encoding="utf-8") as f:
@@ -253,6 +259,21 @@ docker run --rm -i -v "$IMAGES_DIR:/images:ro" -v "$BASE_DIR/prebuilt/kernel/boo
debugfs -R "stat /usr/bin/doas" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*04755\b" || {
echo "FAIL: geminux-rootfs.img /usr/bin/doas is not mode 04755" >&2; exit 1;
}
+ debugfs -R "stat /usr/libexec/dbus-daemon-launch-helper" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*04750\b" || {
+ echo "FAIL: geminux-rootfs.img /usr/libexec/dbus-daemon-launch-helper is not mode 04750" >&2; exit 1;
+ }
+ debugfs -R "stat /usr/libexec/dbus-daemon-launch-helper" /images/geminux-rootfs.img | grep -qE "User:[[:space:]]*0\b" || {
+ echo "FAIL: geminux-rootfs.img /usr/libexec/dbus-daemon-launch-helper is not UID 0" >&2; exit 1;
+ }
+ debugfs -R "stat /usr/libexec/dbus-daemon-launch-helper" /images/geminux-rootfs.img | grep -qE "Group:[[:space:]]*103\b" || {
+ echo "FAIL: geminux-rootfs.img /usr/libexec/dbus-daemon-launch-helper is not GID 103" >&2; exit 1;
+ }
+ debugfs -R "stat /etc/polkit-1/rules.d" /images/geminux-rootfs.img | grep -qE "Mode:[[:space:]]*0?4?0750\b" || {
+ echo "FAIL: geminux-rootfs.img /etc/polkit-1/rules.d is not mode 0750" >&2; exit 1;
+ }
+ debugfs -R "stat /etc/polkit-1/rules.d" /images/geminux-rootfs.img | grep -qE "Group:[[:space:]]*110\b" || {
+ echo "FAIL: geminux-rootfs.img /etc/polkit-1/rules.d is not GID 110" >&2; exit 1;
+ }
debugfs -R "stat /home/user" /images/geminux-rootfs.img | grep -qE "User:[[:space:]]*10000\b" || {
echo "FAIL: geminux-rootfs.img /home/user is not UID 10000" >&2; exit 1;
}
diff --git a/scripts/package-local-apks.sh b/scripts/package-local-apks.sh
index fa8b6d5..117cee3 100755
--- a/scripts/package-local-apks.sh
+++ b/scripts/package-local-apks.sh
@@ -222,7 +222,7 @@ ustage = os.path.join(work_dir, "geminux-ui")
copy_tree_dedup("/geminux/prebuilt/geminux", ustage)
make_pkg(
"geminux-ui", pkg_ver,
- "Geminux libgemui.so toolkit, 9 landscape HiDPI apps, and 7 zero-poll C11 daemons",
+ "Geminux libgemui.so toolkit, 10 landscape HiDPI apps, and 7 zero-poll C11 daemons",
ustage,
provides=["so:libgemui.so=0", f"cmd:geminux-power-ctl={pkg_ver}"],
depends=collect_needed_so(ustage),
diff --git a/scripts/rootfs-packages.txt b/scripts/rootfs-packages.txt
index 2d520cc..c948ceb 100644
--- a/scripts/rootfs-packages.txt
+++ b/scripts/rootfs-packages.txt
@@ -1,6 +1,6 @@
# Geminux aarch64 rootfs package set.
# Single source of truth for scripts/bootstrap-rootfs.sh and rebuild-image.sh.
-# Pure X11 (XLibre + Panfrost), zero Wayland components, zero Rust, zero on-device compiler.
+# Pure X11 (XLibre + Panfrost), zero Wayland components, zero Rust.
alpine-base
alsa-ucm-conf
alsa-utils
@@ -10,12 +10,14 @@ bluez
bluez-btmgmt
bluez-openrc
brightnessctl
+build-base
cairo
ca-certificates
chrony
chrony-openrc
coreutils
curl
+curl-dev
dbus
dbus-libs
dbus-openrc
@@ -24,11 +26,13 @@ doas
dosfstools
e2fsprogs
e2fsprogs-extra
+ed
elogind
eudev
eudev-openrc
evtest
exfatprogs
+fdk-aac
font-dejavu
font-dejavu-sans-mono-nerd
font-fira-code
@@ -48,14 +52,21 @@ ip6tables
iproute2
iptables
iw
+janet
+janet-dev
+jpm
+jq
kmod
lang
less
libcurl
libdrm
libepoxy
+libfreeaptx
libinput
libjpeg-turbo
+liblc3
+libldac
libpng
libva
libva-utils
@@ -67,6 +78,7 @@ libxrandr
libxscrnsaver
libxtst
mandoc
+mc
mesa-dri-gallium
mesa-egl
mesa-gbm
@@ -79,23 +91,36 @@ modemmanager-openrc
mtdev
musl-locales
nano
+nawk
networkmanager
networkmanager-cli
networkmanager-openrc
+networkmanager-tui
networkmanager-wifi
nsxiv
openrc
openssh
openssh-server-pam
pango
+perl
+perl-io-socket-ssl
+perl-libwww
+perl-lwp-protocol-https
+perl-mozilla-ca
+perl-net-ssleay
pipewire
pipewire-alsa
pipewire-pulse
pipewire-spa-bluez
+pipewire-tools
pixman
polkit
+pulseaudio-utils
+rlwrap
+sbc
scrot
setxkbmap
+spandsp3
sqlite-libs
sudo
tinydm
@@ -106,9 +131,9 @@ usbutils
util-linux
util-linux-misc
v4l-utils
+wireless-regdb
wireplumber
wpa_supplicant
-wpa_supplicant-openrc
xauth
xclip
xdotool
@@ -120,5 +145,6 @@ xrandr
xrdb
xset
xsetroot
+yabasic
zram-init
zram-init-openrc
diff --git a/scripts/rootfs-prune-packages.txt b/scripts/rootfs-prune-packages.txt
index 6a99b15..6128b85 100644
--- a/scripts/rootfs-prune-packages.txt
+++ b/scripts/rootfs-prune-packages.txt
@@ -1,4 +1,4 @@
-# Packages excluded from the final Geminux aarch64 image (Wayland, Rust, upstream overrides, compilers).
+# Packages excluded from the final Geminux aarch64 image (Wayland, Rust, upstream overrides).
grim
imv-wayland
libdecor
@@ -36,10 +36,7 @@ xorg-server
xorg-server-common
xf86-input-libinput
xf86-video-fbdev
-gcc
-g++
-musl-dev
-make
+wpa_supplicant-openrc
!imv-wayland
!grim
!slurp
@@ -77,7 +74,8 @@ make
!xorg-server-common
!xf86-input-libinput
!xf86-video-fbdev
-!gcc
-!g++
-!musl-dev
-!make
+!wpa_supplicant-openrc
+@!gcc
+@!g++
+@!musl-dev
+@!make
diff --git a/scripts/test-power-policy.py b/scripts/test-power-policy.py
index 4040371..20e929a 100755
--- a/scripts/test-power-policy.py
+++ b/scripts/test-power-policy.py
@@ -10,8 +10,10 @@ import tempfile
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DAEMON_DIR = os.path.join(BASE_DIR, "src", "geminux-daemons")
+APPS_DIR = os.path.join(BASE_DIR, "src", "geminux-apps")
POLICY_C = os.path.join(DAEMON_DIR, "geminux-power-policy.c")
GESTURE_C = os.path.join(DAEMON_DIR, "geminux-touch-gesture.c")
+WIFI_NVRAM_C = os.path.join(DAEMON_DIR, "geminux-wifi-nvram-core.c")
DAEMON_FILES = {
"geminux-powerd.c": "epoll_wait",
@@ -28,6 +30,10 @@ C_TEST = r"""
#include
#include "geminux-power-policy.h"
#include "geminux-touch-gesture.h"
+#include "geminux-wifi-nvram-core.h"
+#include "geminux-wifi-list.h"
+#include "geminux-bt-list.h"
+#include "geminux-audio-parse.h"
static int count_decision(const geminux_gesture_action_t *a, int mode) {
int c = 0;
@@ -165,6 +171,123 @@ int main(void) {
assert(perf.suspend_timeout_s == 0);
test_touch_gestures();
+
+ /* Wi-Fi NVRAM record validation, scan, and deterministic MAC fallback */
+ static unsigned char blob[1024];
+ unsigned char rec[GEMINUX_WIFI_STORAGE_BYTES];
+ unsigned char out_rec[GEMINUX_WIFI_STORAGE_BYTES];
+ bool have_mac = false;
+
+ memset(blob, 0xff, sizeof(blob));
+ memset(rec, 0, sizeof(rec));
+ rec[0] = 0x06;
+ rec[1] = 0x01;
+ rec[197] = 1;
+ rec[262] = 1;
+ rec[512] = 0xaa;
+ rec[513] = geminux_wifi_nvram_checksum(rec);
+ assert(geminux_wifi_nvram_valid_record(rec, sizeof(rec), false));
+ assert(!geminux_wifi_nvram_valid_record(rec, sizeof(rec), true));
+
+ memcpy(blob + 128, rec, sizeof(rec));
+ assert(geminux_wifi_nvram_scan_blob(blob, sizeof(blob), out_rec, &have_mac));
+ assert(!have_mac);
+
+ geminux_wifi_nvram_apply_fallback_mac(out_rec, "test-unit-seed");
+ assert(geminux_wifi_nvram_valid_record(out_rec, sizeof(out_rec), true));
+ assert((out_rec[4] & 0x03) == 0x02);
+ memcpy(blob + 256, out_rec, sizeof(out_rec));
+ assert(geminux_wifi_nvram_scan_blob(blob, sizeof(blob), out_rec, &have_mac));
+ assert(have_mac);
+
+ /* Wi-Fi mesh grouping, DFS avoidance, 5GHz tie-break, and escaped colons */
+ const char *scan =
+ " :11\\:22\\:33\\:44\\:55\\:01::6:100:WPA2\n"
+ " :11\\:22\\:33\\:44\\:55\\:02:My\\:Mesh\\\\Home:52:95:WPA2\n"
+ " :11\\:22\\:33\\:44\\:55\\:03:My\\:Mesh\\\\Home:2:80:WPA2\n"
+ " :11\\:22\\:33\\:44\\:55\\:04:My\\:Mesh\\\\Home:44:80:WPA2 WPA3\n"
+ " :11\\:22\\:33\\:44\\:55\\:05:My\\:Mesh\\\\Home:11:65:WPA2\n"
+ " :11\\:22\\:33\\:44\\:55\\:06:My\\:Mesh\\\\Home:9:50:WPA2\n"
+ " :11\\:22\\:33\\:44\\:55\\:07:My\\:Mesh\\\\Home:157:40:WPA2\n"
+ " :11\\:22\\:33\\:44\\:55\\:08:My\\:Mesh\\\\Home:1:30:WPA2\n"
+ " :11\\:22\\:33\\:44\\:55\\:09:My\\:Mesh\\\\Home:161:20:WPA2\n"
+ " :aa\\:bb\\:cc\\:dd\\:ee\\:01:CafeOpen:6:90:--\n"
+ "*:aa\\:bb\\:cc\\:dd\\:ee\\:02:CurrentNet:36:55:WPA2\n"
+ " :aa\\:bb\\:cc\\:dd\\:ee\\:03:StrongOther:1:92:\n";
+ geminux_wifi_group_t groups[GEMINUX_MAX_WIFI_GROUPS];
+ int ng = geminux_parse_wifi_scan(scan, groups, GEMINUX_MAX_WIFI_GROUPS);
+ assert(ng == 4);
+ assert(strcmp(groups[0].ssid, "CurrentNet") == 0);
+ assert(groups[0].in_use);
+ assert(strcmp(groups[1].ssid, "StrongOther") == 0);
+ assert(strcmp(groups[1].security, "Open") == 0);
+ assert(strcmp(groups[2].ssid, "CafeOpen") == 0);
+ assert(strcmp(groups[2].security, "Open") == 0);
+ assert(strcmp(groups[3].ssid, "My:Mesh\\Home") == 0);
+ assert(groups[3].ap_count == 8);
+ assert(groups[3].best_chan == 44);
+ assert(groups[3].best_signal == 80);
+ assert(groups[3].best_joinable);
+ assert(strcmp(groups[3].best_bssid, "11:22:33:44:55:04") == 0);
+
+ /* Bluetooth device list parsing & priority sort */
+ const char *bt_all =
+ "Waiting to connect to bluetoothd...\n"
+ "\x1b[0;93mDevice aa:bb:cc:dd:ee:03 Keychron K3\x1b[0m\n"
+ "Device aa:bb:cc:dd:ee:01 Sony WH-1000XM5\n"
+ "Device aa:bb:cc:dd:ee:02 Logitech MX Anywhere 3\n";
+ const char *bt_pair = "Device AA:BB:CC:DD:EE:02 Logitech MX Anywhere 3\n"
+ "Device AA:BB:CC:DD:EE:03 Keychron K3\n";
+ const char *bt_conn = "Device AA:BB:CC:DD:EE:03 Keychron K3\n";
+ geminux_bt_dev_t bt_devs[GEMINUX_MAX_BT_DEVS];
+ int nbt = geminux_parse_bt_devices(bt_all, bt_pair, bt_conn, bt_devs, GEMINUX_MAX_BT_DEVS);
+ assert(nbt == 3);
+ assert(bt_devs[0].connected && strcmp(bt_devs[0].name, "Keychron K3") == 0);
+ assert(bt_devs[1].paired && !bt_devs[1].connected && strcmp(bt_devs[1].mac, "AA:BB:CC:DD:EE:02") == 0);
+ assert(!bt_devs[2].paired && strcmp(bt_devs[2].name, "Sony WH-1000XM5") == 0);
+
+ /* PipeWire wpctl / pactl parsing */
+ int vpct = 0;
+ bool vmuted = false;
+ assert(geminux_parse_wpctl_volume("Volume: 0.65 [MUTED]\n", &vpct, &vmuted));
+ assert(vpct == 65 && vmuted);
+
+ char def_sink[128], def_src[128];
+ geminux_parse_pactl_defaults("Server Name: PulseAudio (on PipeWire 1.6.11)\n"
+ "Default Sink: alsa_output.platform-sound.stereo-fallback\n"
+ "Default Source: alsa_input.platform-sound.stereo-fallback\n",
+ def_sink, sizeof(def_sink), def_src, sizeof(def_src));
+ assert(strcmp(def_sink, "alsa_output.platform-sound.stereo-fallback") == 0);
+ assert(strcmp(def_src, "alsa_input.platform-sound.stereo-fallback") == 0);
+
+ const char *sinks_txt =
+ "Sink #50\n"
+ "\tState: SUSPENDED\n"
+ "\tName: alsa_output.platform-sound.stereo-fallback\n"
+ "\tDescription: Built-in Audio Stereo\n"
+ "\tMute: no\n"
+ "\tVolume: front-left: 26214 / 40% / -23.87 dB, front-right: 26214 / 40% / -23.87 dB\n"
+ "\tBase Volume: 65536 / 100% / 0.00 dB\n";
+ geminux_audio_node_t nodes[GEMINUX_MAX_AUDIO_NODES];
+ int ns = geminux_parse_pactl_nodes(sinks_txt, "Sink #", def_sink, false, nodes, GEMINUX_MAX_AUDIO_NODES);
+ assert(ns == 1 && nodes[0].index == 50 && nodes[0].is_default && nodes[0].vol_pct == 40 && !nodes[0].muted);
+
+ const char *cards_txt =
+ "Card #44\n"
+ "\tName: bluez_card.11_22_33_44_55_66\n"
+ "\tProperties:\n"
+ "\t\tdevice.description = \"WH-1000XM5\"\n"
+ "\tProfiles:\n"
+ "\t\toff: Off (sinks: 0, sources: 0, priority: 0, available: yes)\n"
+ "\t\ta2dp-sink-sbc: High Fidelity Playback (A2DP Sink, codec SBC-XQ) (sinks: 1, sources: 0, priority: 32, available: yes)\n"
+ "\t\theadset-head-unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 1, available: yes)\n"
+ "\tActive Profile: a2dp-sink-sbc\n";
+ geminux_audio_profile_t profs[GEMINUX_MAX_AUDIO_PROFILES];
+ int np = geminux_parse_pactl_cards(cards_txt, profs, GEMINUX_MAX_AUDIO_PROFILES);
+ assert(np == 3);
+ assert(strcmp(profs[1].card_label, "WH-1000XM5") == 0);
+ assert(profs[1].active && profs[1].available);
+ assert(!profs[2].active && strcmp(profs[2].profile_name, "headset-head-unit") == 0);
return 0;
}
"""
@@ -191,7 +314,7 @@ def main():
if gcc:
subprocess.run(
[gcc, "-std=c11", "-Wall", "-Wextra", "-Werror",
- "-I", DAEMON_DIR, src, POLICY_C, GESTURE_C, "-lm", "-o", bin_path],
+ "-I", DAEMON_DIR, "-I", APPS_DIR, src, POLICY_C, GESTURE_C, WIFI_NVRAM_C, "-lm", "-o", bin_path],
check=True,
)
subprocess.run([bin_path], check=True)
@@ -200,9 +323,10 @@ def main():
["docker", "run", "--rm", "-v", f"{BASE_DIR}:/geminux:ro",
"-v", f"{tmp}:/work", "alpine:3.24", "sh", "-eu", "-c",
"apk add --no-cache build-base >/dev/null && "
- "gcc -std=c11 -Wall -Wextra -Werror -I/geminux/src/geminux-daemons "
+ "gcc -std=c11 -Wall -Wextra -Werror -I/geminux/src/geminux-daemons -I/geminux/src/geminux-apps "
"/work/test_power.c /geminux/src/geminux-daemons/geminux-power-policy.c "
- "/geminux/src/geminux-daemons/geminux-touch-gesture.c -lm "
+ "/geminux/src/geminux-daemons/geminux-touch-gesture.c "
+ "/geminux/src/geminux-daemons/geminux-wifi-nvram-core.c -lm "
"-o /work/test_power && /work/test_power"],
check=True,
)
diff --git a/src/dmenu/config.mk b/src/dmenu/config.mk
index 134ee63..36224a2 100644
--- a/src/dmenu/config.mk
+++ b/src/dmenu/config.mk
@@ -6,8 +6,8 @@ MANPREFIX = $(PREFIX)/share/man
PKG_CONFIG ?= pkg-config
-INCS = $(shell $(PKG_CONFIG) --cflags fontconfig freetype2 xft pango pangoxft harfbuzz x11 xinerama)
-LIBS = -lm $(shell $(PKG_CONFIG) --libs fontconfig freetype2 xft pango pangoxft harfbuzz x11 xinerama)
+INCS = $(shell $(PKG_CONFIG) --cflags fontconfig freetype2 xft pango pangoxft harfbuzz x11 xfixes xi xinerama)
+LIBS = -lm $(shell $(PKG_CONFIG) --libs fontconfig freetype2 xft pango pangoxft harfbuzz x11 xfixes xi xinerama)
CPPFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" -DXINERAMA
CFLAGS = -std=gnu99 -pedantic -Wall -O2 $(INCS) $(CPPFLAGS)
diff --git a/src/dmenu/dmenu.c b/src/dmenu/dmenu.c
index ddf770e..2f0d86e 100644
--- a/src/dmenu/dmenu.c
+++ b/src/dmenu/dmenu.c
@@ -15,6 +15,9 @@
#include
#include
#include
+#include
+#include
+#include
#ifdef XINERAMA
#include
#endif
@@ -58,6 +61,8 @@ static Drw *drw;
static Clr *scheme[SchemeLast];
static char xres_font[256] = "";
static char *dyn_colors[SchemeLast][2] = { {NULL, NULL}, {NULL, NULL}, {NULL, NULL} };
+static Cursor vpointer = None, bpointer = None;
+static int pointer_hidden = 0, xi_opcode = -1, xfixes_ok = 0;
#include "config.h"
@@ -175,9 +180,53 @@ static int max_textw(void) {
return len;
}
+static void dmenu_xi_raw_select(int enable) {
+ unsigned char mask[XIMaskLen(XI_LASTEVENT)];
+ XIEventMask evmask;
+
+ if (xi_opcode < 0) return;
+ memset(mask, 0, sizeof(mask));
+ if (enable) {
+ XISetMask(mask, XI_RawMotion);
+ XISetMask(mask, XI_RawButtonPress);
+ XISetMask(mask, XI_RawTouchBegin);
+ }
+ evmask.deviceid = XIAllMasterDevices;
+ evmask.mask_len = (int)sizeof(mask);
+ evmask.mask = mask;
+ XISelectEvents(dpy, root, &evmask, 1);
+}
+
+static void hidecursor(void) {
+ if (pointer_hidden) return;
+ if (bpointer != None) XDefineCursor(dpy, win, bpointer);
+ if (xfixes_ok) XFixesHideCursor(dpy, root);
+ dmenu_xi_raw_select(1);
+ pointer_hidden = 1;
+ XFlush(dpy);
+}
+
+static void showcursor(void) {
+ if (!pointer_hidden) return;
+ pointer_hidden = 0;
+ dmenu_xi_raw_select(0);
+ if (xfixes_ok) XFixesShowCursor(dpy, root);
+ if (vpointer != None) XDefineCursor(dpy, win, vpointer);
+ XFlush(dpy);
+}
+
static void cleanup(void) {
size_t i;
+ showcursor();
XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ if (vpointer != None) {
+ XFreeCursor(dpy, vpointer);
+ vpointer = None;
+ }
+ if (bpointer != None) {
+ XFreeCursor(dpy, bpointer);
+ bpointer = None;
+ }
for (i = 0; i < SchemeLast; i++) {
free(scheme[i]);
free(dyn_colors[i][0]);
@@ -421,11 +470,13 @@ static void keypress(XKeyEvent *ev) {
default:
return;
case XLookupChars:
+ hidecursor();
goto insert_chars;
case XLookupKeySym:
case XLookupBoth:
break;
}
+ if (!IsModifierKey(ksym)) hidecursor();
if (ev->state & ControlMask) {
switch (ksym) {
@@ -605,6 +656,7 @@ static void buttonpress(XEvent *e) {
XButtonPressedEvent *ev = &e->xbutton;
int x = 0, y = 0, w;
+ showcursor();
if (ev->window != win) return;
if (ev->button == Button4) {
if (sel && sel->left) {
@@ -730,6 +782,17 @@ static void readstdin(void) {
static void run(void) {
XEvent ev;
while (!XNextEvent(dpy, &ev)) {
+ if (ev.type == GenericEvent) {
+ if (ev.xcookie.extension == xi_opcode &&
+ XGetEventData(dpy, &ev.xcookie)) {
+ if (ev.xcookie.evtype == XI_RawMotion ||
+ ev.xcookie.evtype == XI_RawButtonPress ||
+ ev.xcookie.evtype == XI_RawTouchBegin)
+ showcursor();
+ XFreeEventData(dpy, &ev.xcookie);
+ }
+ continue;
+ }
if (XFilterEvent(&ev, win)) continue;
switch (ev.type) {
case DestroyNotify:
@@ -749,6 +812,9 @@ static void run(void) {
case ButtonPress:
buttonpress(&ev);
break;
+ case MotionNotify:
+ showcursor();
+ break;
case SelectionNotify:
if (ev.xselection.property == utf8) pastesel();
break;
@@ -826,12 +892,33 @@ static void setup(void) {
swa.override_redirect = True;
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
- swa.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | VisibilityChangeMask;
+ swa.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | PointerMotionMask | VisibilityChangeMask;
win = XCreateWindow(dpy, parentwin, x, y, (unsigned int)mw, (unsigned int)mh, 0,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
XSetClassHint(dpy, win, &ch);
+ {
+ int ev_base = 0, err_base = 0;
+ char blank_bits[1] = {0};
+ Pixmap blank = XCreateBitmapFromData(dpy, win, blank_bits, 1, 1);
+ XColor black;
+ memset(&black, 0, sizeof(black));
+ xfixes_ok = XFixesQueryExtension(dpy, &ev_base, &err_base) ? 1 : 0;
+ xi_opcode = -1;
+ if (XQueryExtension(dpy, "XInputExtension", &xi_opcode, &ev_base, &err_base)) {
+ int maj = 2, min = 2;
+ if (XIQueryVersion(dpy, &maj, &min) != Success)
+ xi_opcode = -1;
+ } else {
+ xi_opcode = -1;
+ }
+ vpointer = XCreateFontCursor(dpy, XC_left_ptr);
+ bpointer = XCreatePixmapCursor(dpy, blank, blank, &black, &black, 0, 0);
+ XFreePixmap(dpy, blank);
+ if (vpointer != None) XDefineCursor(dpy, win, vpointer);
+ }
+
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
die("XOpenIM failed: could not open input device");
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
diff --git a/src/dwm/config.def.h b/src/dwm/config.def.h
index ed37b69..b9fd03d 100644
--- a/src/dwm/config.def.h
+++ b/src/dwm/config.def.h
@@ -33,6 +33,7 @@ static const Rule rules[] = {
{ "geminux-callscreen", NULL, NULL, ~0U, 0, -1 },
{ "geminux-lock", NULL, NULL, ~0U, 1, -1 },
{ "geminux-control", NULL, NULL, 0, 1, -1 },
+ { "geminux-audio", NULL, NULL, 0, 1, -1 },
{ "geminux-themes", NULL, NULL, 0, 1, -1 },
};
@@ -67,6 +68,7 @@ static const char *controlcmd[] = { "geminux-control", NULL };
static const char *dialercmd[] = { "geminux-dialer", NULL };
static const char *smscmd[] = { "geminux-sms", NULL };
static const char *netcmd[] = { "geminux-net", NULL };
+static const char *audiocmd[] = { "geminux-audio", NULL };
static const char *cameracmd[] = { "geminux-camera", NULL };
static const char *themescmd[] = { "geminux-themes", NULL };
static const char *lockcmd[] = { "geminux-lock", NULL };
@@ -98,6 +100,7 @@ static const Key keys[] = {
{ MODKEY, XK_d, spawn, {.v = dialercmd} },
{ MODKEY, XK_s, spawn, {.v = smscmd} },
{ MODKEY, XK_n, spawn, {.v = netcmd} },
+ { MODKEY, XK_a, spawn, {.v = audiocmd} },
{ MODKEY, XK_v, spawn, {.v = cameracmd} },
{ MODKEY, XK_t, spawn, {.v = themescmd} },
{ MODKEY|ShiftMask, XK_l, spawn, {.v = lockcmd} },
diff --git a/src/geminux-apps/Makefile b/src/geminux-apps/Makefile
index 158d9a9..195d213 100644
--- a/src/geminux-apps/Makefile
+++ b/src/geminux-apps/Makefile
@@ -13,6 +13,7 @@ APPS = \
geminux-sms \
geminux-contacts \
geminux-net \
+ geminux-audio \
geminux-camera \
geminux-control \
geminux-themes \
@@ -23,6 +24,12 @@ all: $(APPS)
geminux-camera: geminux-camera.c ../libgemui/gemui.h
$(CC) $(CFLAGS) -o $@ $< $(LIBS) -ljpeg
+geminux-net: geminux-net.c geminux-wifi-list.h geminux-bt-list.h ../libgemui/gemui.h
+ $(CC) $(CFLAGS) -o $@ $< $(LIBS)
+
+geminux-audio: geminux-audio.c geminux-audio-parse.h ../libgemui/gemui.h
+ $(CC) $(CFLAGS) -o $@ $< $(LIBS)
+
geminux-%: geminux-%.c ../libgemui/gemui.h
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
diff --git a/src/geminux-apps/geminux-audio-parse.h b/src/geminux-apps/geminux-audio-parse.h
new file mode 100644
index 0000000..e339530
--- /dev/null
+++ b/src/geminux-apps/geminux-audio-parse.h
@@ -0,0 +1,284 @@
+/*
+ * Header-only C11 parsers for PipeWire / wpctl / pactl audio endpoints, streams, and card profiles.
+ */
+#ifndef GEMINUX_AUDIO_PARSE_H
+#define GEMINUX_AUDIO_PARSE_H
+
+#include
+#include
+#include
+#include
+#include
+
+#define GEMINUX_MAX_AUDIO_NODES 24
+#define GEMINUX_MAX_AUDIO_PROFILES 32
+
+typedef struct {
+ int index;
+ char name[128];
+ char label[128];
+ char state[24];
+ char port[64];
+ int vol_pct;
+ bool muted;
+ bool is_default;
+ bool is_stream;
+} geminux_audio_node_t;
+
+typedef struct {
+ char card_name[128];
+ char card_label[128];
+ char profile_name[96];
+ char profile_desc[128];
+ bool active;
+ bool available;
+} geminux_audio_profile_t;
+
+static inline bool geminux_parse_wpctl_volume(const char *text, int *vol_pct_out, bool *muted_out) {
+ if (!text) return false;
+ const char *p = strstr(text, "Volume:");
+ if (!p) return false;
+ double v = atof(p + 7);
+ if (v < 0.0) v = 0.0;
+ if (v > 2.0) v = 2.0;
+ if (vol_pct_out) *vol_pct_out = (int)(v * 100.0 + 0.5);
+ if (muted_out) *muted_out = (strstr(text, "[MUTED]") != NULL);
+ return true;
+}
+
+static inline void geminux_parse_pactl_defaults(const char *info_txt,
+ char *def_sink, size_t sink_sz,
+ char *def_src, size_t src_sz) {
+ if (def_sink && sink_sz > 0) def_sink[0] = '\0';
+ if (def_src && src_sz > 0) def_src[0] = '\0';
+ if (!info_txt) return;
+ const char *cur = info_txt;
+ while (*cur) {
+ const char *nl = strchr(cur, '\n');
+ size_t raw_len = nl ? (size_t)(nl - cur) : strlen(cur);
+ char ln[256];
+ size_t cp = raw_len < sizeof(ln) - 1 ? raw_len : sizeof(ln) - 1;
+ memcpy(ln, cur, cp);
+ ln[cp] = '\0';
+ cur = nl ? nl + 1 : cur + raw_len;
+ while (cp > 0 && (ln[cp - 1] == '\r' || ln[cp - 1] == ' ')) ln[--cp] = '\0';
+ if (def_sink && strncmp(ln, "Default Sink:", 13) == 0) {
+ const char *v = ln + 13;
+ while (*v == ' ' || *v == '\t') v++;
+ snprintf(def_sink, sink_sz, "%s", v);
+ } else if (def_src && strncmp(ln, "Default Source:", 15) == 0) {
+ const char *v = ln + 15;
+ while (*v == ' ' || *v == '\t') v++;
+ snprintf(def_src, src_sz, "%s", v);
+ }
+ }
+}
+
+static inline int geminux_extract_first_pct(const char *s) {
+ if (!s) return 100;
+ for (const char *p = s; *p; p++) {
+ if (*p == '%' && p > s && isdigit((unsigned char)p[-1])) {
+ const char *q = p;
+ while (q > s && isdigit((unsigned char)q[-1])) q--;
+ int pct = atoi(q);
+ if (pct < 0) pct = 0;
+ if (pct > 200) pct = 200;
+ return pct;
+ }
+ }
+ return 100;
+}
+
+static inline bool geminux_extract_quoted_prop(const char *line, const char *key,
+ char *out, size_t out_sz) {
+ size_t klen = strlen(key);
+ if (strncmp(line, key, klen) != 0) return false;
+ const char *p = line + klen;
+ while (*p == ' ' || *p == '\t') p++;
+ if (*p != '=') return false;
+ p++;
+ while (*p == ' ' || *p == '\t') p++;
+ if (*p == '"') {
+ p++;
+ const char *end = strrchr(p, '"');
+ size_t len = end ? (size_t)(end - p) : strlen(p);
+ if (len >= out_sz) len = out_sz - 1;
+ memcpy(out, p, len);
+ out[len] = '\0';
+ } else {
+ snprintf(out, out_sz, "%s", p);
+ }
+ return out[0] != '\0';
+}
+
+static inline int geminux_parse_pactl_nodes(const char *txt, const char *header_prefix,
+ const char *default_name, bool is_stream,
+ geminux_audio_node_t *out, int max_out) {
+ if (!txt || !header_prefix || !out || max_out <= 0) return 0;
+ size_t hlen = strlen(header_prefix);
+ int count = 0;
+ geminux_audio_node_t *cur_node = NULL;
+ char app_name[64] = {0};
+ char media_name[64] = {0};
+ bool in_props = false;
+
+ const char *cur = txt;
+ while (*cur) {
+ const char *nl = strchr(cur, '\n');
+ size_t raw_len = nl ? (size_t)(nl - cur) : strlen(cur);
+ char ln[384];
+ size_t cp = raw_len < sizeof(ln) - 1 ? raw_len : sizeof(ln) - 1;
+ memcpy(ln, cur, cp);
+ ln[cp] = '\0';
+ cur = nl ? nl + 1 : cur + raw_len;
+ while (cp > 0 && (ln[cp - 1] == '\r' || ln[cp - 1] == ' ')) ln[--cp] = '\0';
+
+ if (strncmp(ln, header_prefix, hlen) == 0) {
+ if (count >= max_out) {
+ cur_node = NULL;
+ continue;
+ }
+ cur_node = &out[count++];
+ memset(cur_node, 0, sizeof(*cur_node));
+ cur_node->index = atoi(ln + hlen);
+ cur_node->vol_pct = 100;
+ cur_node->is_stream = is_stream;
+ app_name[0] = '\0';
+ media_name[0] = '\0';
+ in_props = false;
+ continue;
+ }
+ if (!cur_node) continue;
+
+ if (ln[0] == '\t' && ln[1] != '\t') {
+ in_props = false;
+ const char *k = ln + 1;
+ if (strcmp(k, "Properties:") == 0) {
+ in_props = true;
+ } else if (strncmp(k, "State: ", 7) == 0) {
+ snprintf(cur_node->state, sizeof(cur_node->state), "%s", k + 7);
+ } else if (strncmp(k, "Name: ", 6) == 0) {
+ snprintf(cur_node->name, sizeof(cur_node->name), "%s", k + 6);
+ if (default_name && default_name[0] && strcmp(cur_node->name, default_name) == 0) {
+ cur_node->is_default = true;
+ }
+ if (!cur_node->label[0]) {
+ snprintf(cur_node->label, sizeof(cur_node->label), "%s", cur_node->name);
+ }
+ } else if (strncmp(k, "Description: ", 13) == 0) {
+ snprintf(cur_node->label, sizeof(cur_node->label), "%s", k + 13);
+ } else if (strncmp(k, "Mute: ", 6) == 0) {
+ cur_node->muted = (strcmp(k + 6, "yes") == 0);
+ } else if (strncmp(k, "Volume: ", 8) == 0) {
+ cur_node->vol_pct = geminux_extract_first_pct(k + 8);
+ } else if (strncmp(k, "Active Port: ", 13) == 0) {
+ snprintf(cur_node->port, sizeof(cur_node->port), "%s", k + 13);
+ }
+ } else if (in_props && ln[0] == '\t' && ln[1] == '\t') {
+ const char *k = ln + 2;
+ if (!geminux_extract_quoted_prop(k, "application.name", app_name, sizeof(app_name))) {
+ geminux_extract_quoted_prop(k, "media.name", media_name, sizeof(media_name));
+ }
+ if (is_stream) {
+ if (app_name[0] && media_name[0] && strcmp(app_name, media_name) != 0) {
+ snprintf(cur_node->label, sizeof(cur_node->label), "%.56s: %.56s", app_name, media_name);
+ } else if (app_name[0]) {
+ snprintf(cur_node->label, sizeof(cur_node->label), "%s", app_name);
+ } else if (media_name[0]) {
+ snprintf(cur_node->label, sizeof(cur_node->label), "%s", media_name);
+ }
+ } else if (!cur_node->label[0]) {
+ geminux_extract_quoted_prop(k, "device.description", cur_node->label, sizeof(cur_node->label));
+ }
+ }
+ }
+ return count;
+}
+
+static inline int geminux_parse_pactl_cards(const char *cards_txt,
+ geminux_audio_profile_t *out, int max_out) {
+ if (!cards_txt || !out || max_out <= 0) return 0;
+ int total = 0;
+ int card_start = 0;
+ char card_name[128] = {0};
+ char card_label[128] = {0};
+ char active_prof[96] = {0};
+ int sec = 0; /* 1=Properties, 2=Profiles */
+
+ const char *cur = cards_txt;
+ while (*cur) {
+ const char *nl = strchr(cur, '\n');
+ size_t raw_len = nl ? (size_t)(nl - cur) : strlen(cur);
+ char ln[384];
+ size_t cp = raw_len < sizeof(ln) - 1 ? raw_len : sizeof(ln) - 1;
+ memcpy(ln, cur, cp);
+ ln[cp] = '\0';
+ cur = nl ? nl + 1 : cur + raw_len;
+ while (cp > 0 && (ln[cp - 1] == '\r' || ln[cp - 1] == ' ')) ln[--cp] = '\0';
+
+ if (strncmp(ln, "Card #", 6) == 0) {
+ card_start = total;
+ card_name[0] = '\0';
+ card_label[0] = '\0';
+ active_prof[0] = '\0';
+ sec = 0;
+ continue;
+ }
+
+ if (ln[0] == '\t' && ln[1] != '\t') {
+ const char *k = ln + 1;
+ sec = 0;
+ if (strcmp(k, "Properties:") == 0) {
+ sec = 1;
+ } else if (strcmp(k, "Profiles:") == 0) {
+ sec = 2;
+ } else if (strncmp(k, "Name: ", 6) == 0) {
+ snprintf(card_name, sizeof(card_name), "%s", k + 6);
+ if (!card_label[0]) snprintf(card_label, sizeof(card_label), "%s", card_name);
+ for (int i = card_start; i < total; i++) {
+ snprintf(out[i].card_name, sizeof(out[i].card_name), "%s", card_name);
+ }
+ } else if (strncmp(k, "Active Profile: ", 16) == 0) {
+ snprintf(active_prof, sizeof(active_prof), "%s", k + 16);
+ for (int i = card_start; i < total; i++) {
+ out[i].active = (strcmp(out[i].profile_name, active_prof) == 0);
+ }
+ }
+ } else if (sec == 1 && ln[0] == '\t' && ln[1] == '\t') {
+ const char *k = ln + 2;
+ if (geminux_extract_quoted_prop(k, "device.description", card_label, sizeof(card_label)) ||
+ (!card_label[0] && geminux_extract_quoted_prop(k, "alsa.card_name", card_label, sizeof(card_label)))) {
+ for (int i = card_start; i < total; i++) {
+ snprintf(out[i].card_label, sizeof(out[i].card_label), "%s", card_label);
+ }
+ }
+ } else if (sec == 2 && ln[0] == '\t' && ln[1] == '\t' && total < max_out) {
+ const char *k = ln + 2;
+ const char *sep = strstr(k, ": ");
+ if (!sep) continue;
+ geminux_audio_profile_t *p = &out[total++];
+ memset(p, 0, sizeof(*p));
+ snprintf(p->card_name, sizeof(p->card_name), "%s", card_name);
+ snprintf(p->card_label, sizeof(p->card_label), "%s", card_label[0] ? card_label : card_name);
+ size_t idlen = (size_t)(sep - k);
+ if (idlen >= sizeof(p->profile_name)) idlen = sizeof(p->profile_name) - 1;
+ memcpy(p->profile_name, k, idlen);
+ p->profile_name[idlen] = '\0';
+
+ const char *rhs = sep + 2;
+ p->available = (strstr(rhs, "available: no") == NULL);
+ const char *meta = strstr(rhs, " (sinks:");
+ if (!meta) meta = strstr(rhs, " (available:");
+ size_t dlen = meta ? (size_t)(meta - rhs) : strlen(rhs);
+ if (dlen >= sizeof(p->profile_desc)) dlen = sizeof(p->profile_desc) - 1;
+ memcpy(p->profile_desc, rhs, dlen);
+ p->profile_desc[dlen] = '\0';
+ if (active_prof[0] && strcmp(p->profile_name, active_prof) == 0) {
+ p->active = true;
+ }
+ }
+ }
+ return total;
+}
+
+#endif /* GEMINUX_AUDIO_PARSE_H */
diff --git a/src/geminux-apps/geminux-audio.c b/src/geminux-apps/geminux-audio.c
new file mode 100644
index 0000000..0e5be0a
--- /dev/null
+++ b/src/geminux-apps/geminux-audio.c
@@ -0,0 +1,604 @@
+#define _POSIX_C_SOURCE 200809L
+#include "gemui.h"
+#include "geminux-audio-parse.h"
+
+#include
+#include
+#include
+
+#define HIT_TAB 1
+#define HIT_SLIDER 2
+#define HIT_MUTE_DEF 3
+#define HIT_TEST 4
+#define HIT_ROUTE_A 5
+#define HIT_ROUTE_B 6
+#define HIT_GOTO_CARDS 7
+#define HIT_ROW 8
+#define HIT_ACT_DEF 9
+#define HIT_ACT_MUTE 10
+#define HIT_ACT_DOWN 11
+#define HIT_ACT_UP 12
+#define HIT_ACT_REF 13
+
+typedef struct {
+ bool is_stream;
+ int index;
+ int vol_pct;
+ bool muted;
+ bool is_default;
+ char name[128];
+ char label[128];
+ char col2[64];
+ char col3[48];
+} audio_row_t;
+
+typedef struct {
+ gemui_app_t *app;
+ int tab; /* 0=Playback, 1=Recording, 2=Cards & BT Profiles */
+ int out_vol_pct;
+ bool out_muted;
+ int in_vol_pct;
+ bool in_muted;
+ bool speaker_on;
+ bool headset_mic_on;
+
+ char def_sink[128];
+ char def_source[128];
+ audio_row_t rows[GEMINUX_MAX_AUDIO_NODES * 2];
+ geminux_audio_profile_t profiles[GEMINUX_MAX_AUDIO_PROFILES];
+ int num_rows;
+ int num_profiles;
+ int sel_row;
+ int scroll_off;
+ gemui_rect_t slider_rect;
+ bool dragging_slider;
+ char status_text[256];
+} audio_state_t;
+
+static int audio_visible_rows(const audio_state_t *st) {
+ int h = st->app ? gemui_height(st->app) : 940;
+ int list_y = (st->tab == 2) ? 260 : 366;
+ int box_h = h - list_y - 112;
+ int vis = (box_h - 12) / 72;
+ return vis > 0 ? vis : 1;
+}
+
+static void audio_clamp_scroll(audio_state_t *st) {
+ int vis = audio_visible_rows(st);
+ int count = (st->tab == 2) ? st->num_profiles : st->num_rows;
+ int max_off = count > vis ? count - vis : 0;
+ if (st->scroll_off < 0) st->scroll_off = 0;
+ if (st->scroll_off > max_off) st->scroll_off = max_off;
+ if (st->sel_row >= 0 && st->sel_row < count) {
+ if (st->sel_row < st->scroll_off) st->scroll_off = st->sel_row;
+ else if (st->sel_row >= st->scroll_off + vis) st->scroll_off = st->sel_row - vis + 1;
+ }
+}
+
+static void append_nodes_to_rows(audio_state_t *st, const geminux_audio_node_t *nodes,
+ int n, bool skip_monitors, const char *prev_name) {
+ for (int i = 0; i < n && st->num_rows < (int)(sizeof(st->rows) / sizeof(st->rows[0])); i++) {
+ const geminux_audio_node_t *nd = &nodes[i];
+ if (skip_monitors && !nd->is_stream && strstr(nd->name, ".monitor") != NULL) {
+ continue;
+ }
+ int ridx = st->num_rows++;
+ audio_row_t *r = &st->rows[ridx];
+ memset(r, 0, sizeof(*r));
+ r->is_stream = nd->is_stream;
+ r->index = nd->index;
+ r->vol_pct = nd->vol_pct;
+ r->muted = nd->muted;
+ r->is_default = nd->is_default;
+ snprintf(r->name, sizeof(r->name), "%s", nd->name);
+ snprintf(r->label, sizeof(r->label), "%s%s",
+ nd->is_stream ? "[APP] " : (nd->is_default ? "* " : " "),
+ nd->label[0] ? nd->label : nd->name);
+ snprintf(r->col2, sizeof(r->col2), "%s",
+ nd->is_stream ? "App Stream" : (nd->is_default ? "Default" : (nd->state[0] ? nd->state : "Ready")));
+ snprintf(r->col3, sizeof(r->col3), "%d%%%s", nd->vol_pct, nd->muted ? " MUTED" : "");
+ if (prev_name[0] && r->name[0] && strcmp(r->name, prev_name) == 0) {
+ st->sel_row = ridx;
+ }
+ }
+}
+
+static void refresh_alsa_hints(audio_state_t *st) {
+ char out[512] = {0};
+ const char *sp[] = {"amixer", "-c", "0", "cget", "name='Speaker Switch'", NULL};
+ if (gemui_run_cmd_timeout(sp, out, sizeof(out), 700) == 0) {
+ st->speaker_on = (strstr(out, ": values=on") != NULL || strstr(out, ": values=1") != NULL);
+ }
+ out[0] = '\0';
+ const char *mic[] = {"amixer", "-c", "0", "cget", "name='Headset Mic Switch'", NULL};
+ if (gemui_run_cmd_timeout(mic, out, sizeof(out), 700) == 0) {
+ st->headset_mic_on = (strstr(out, ": values=on") != NULL || strstr(out, ": values=1") != NULL);
+ }
+}
+
+static void refresh_audio(audio_state_t *st) {
+ char prev_name[128] = {0};
+ if (st->tab == 2 && st->sel_row >= 0 && st->sel_row < st->num_profiles) {
+ snprintf(prev_name, sizeof(prev_name), "%s", st->profiles[st->sel_row].profile_name);
+ } else if (st->tab != 2 && st->sel_row >= 0 && st->sel_row < st->num_rows) {
+ snprintf(prev_name, sizeof(prev_name), "%s", st->rows[st->sel_row].name);
+ }
+
+ char out[256] = {0};
+ const char *vo[] = {"wpctl", "get-volume", "@DEFAULT_AUDIO_SINK@", NULL};
+ if (gemui_run_cmd_timeout(vo, out, sizeof(out), 900) == 0) {
+ geminux_parse_wpctl_volume(out, &st->out_vol_pct, &st->out_muted);
+ }
+ out[0] = '\0';
+ const char *vi[] = {"wpctl", "get-volume", "@DEFAULT_AUDIO_SOURCE@", NULL};
+ if (gemui_run_cmd_timeout(vi, out, sizeof(out), 900) == 0) {
+ geminux_parse_wpctl_volume(out, &st->in_vol_pct, &st->in_muted);
+ }
+
+ refresh_alsa_hints(st);
+
+ static char big[32768];
+ big[0] = '\0';
+ const char *pi[] = {"pactl", "info", NULL};
+ if (gemui_run_cmd_timeout(pi, big, sizeof(big), 900) == 0) {
+ geminux_parse_pactl_defaults(big, st->def_sink, sizeof(st->def_sink),
+ st->def_source, sizeof(st->def_source));
+ }
+
+ st->num_rows = 0;
+ st->num_profiles = 0;
+ st->sel_row = -1;
+
+ if (st->tab == 0) {
+ geminux_audio_node_t sinks[GEMINUX_MAX_AUDIO_NODES];
+ geminux_audio_node_t inputs[GEMINUX_MAX_AUDIO_NODES];
+ big[0] = '\0';
+ const char *ps[] = {"pactl", "list", "sinks", NULL};
+ if (gemui_run_cmd_timeout(ps, big, sizeof(big), 1200) == 0) {
+ int ns = geminux_parse_pactl_nodes(big, "Sink #", st->def_sink, false,
+ sinks, GEMINUX_MAX_AUDIO_NODES);
+ append_nodes_to_rows(st, sinks, ns, false, prev_name);
+ }
+ big[0] = '\0';
+ const char *psi[] = {"pactl", "list", "sink-inputs", NULL};
+ if (gemui_run_cmd_timeout(psi, big, sizeof(big), 1200) == 0) {
+ int ni = geminux_parse_pactl_nodes(big, "Sink Input #", NULL, true,
+ inputs, GEMINUX_MAX_AUDIO_NODES);
+ append_nodes_to_rows(st, inputs, ni, false, prev_name);
+ }
+ snprintf(st->status_text, sizeof(st->status_text),
+ "PipeWire Output: %d%% %s | Route: %s",
+ st->out_vol_pct, st->out_muted ? "[MUTED]" : "",
+ st->speaker_on ? "Speakers" : "Headphones");
+ } else if (st->tab == 1) {
+ geminux_audio_node_t srcs[GEMINUX_MAX_AUDIO_NODES];
+ geminux_audio_node_t souts[GEMINUX_MAX_AUDIO_NODES];
+ big[0] = '\0';
+ const char *ps[] = {"pactl", "list", "sources", NULL};
+ if (gemui_run_cmd_timeout(ps, big, sizeof(big), 1200) == 0) {
+ int ns = geminux_parse_pactl_nodes(big, "Source #", st->def_source, false,
+ srcs, GEMINUX_MAX_AUDIO_NODES);
+ append_nodes_to_rows(st, srcs, ns, true, prev_name);
+ }
+ big[0] = '\0';
+ const char *pso[] = {"pactl", "list", "source-outputs", NULL};
+ if (gemui_run_cmd_timeout(pso, big, sizeof(big), 1200) == 0) {
+ int no = geminux_parse_pactl_nodes(big, "Source Output #", NULL, true,
+ souts, GEMINUX_MAX_AUDIO_NODES);
+ append_nodes_to_rows(st, souts, no, false, prev_name);
+ }
+ snprintf(st->status_text, sizeof(st->status_text),
+ "PipeWire Recording: %d%% %s | Mic: %s",
+ st->in_vol_pct, st->in_muted ? "[MUTED]" : "",
+ st->headset_mic_on ? "Headset Mic" : "Internal Mic");
+ } else {
+ big[0] = '\0';
+ const char *pc[] = {"pactl", "list", "cards", NULL};
+ if (gemui_run_cmd_timeout(pc, big, sizeof(big), 1200) == 0) {
+ st->num_profiles = geminux_parse_pactl_cards(big, st->profiles, GEMINUX_MAX_AUDIO_PROFILES);
+ for (int i = 0; i < st->num_profiles; i++) {
+ if (prev_name[0] && strcmp(st->profiles[i].profile_name, prev_name) == 0) {
+ st->sel_row = i;
+ break;
+ }
+ }
+ }
+ snprintf(st->status_text, sizeof(st->status_text),
+ "Audio Card & Bluetooth Profiles (A2DP / HSP / HFP / HiFi)");
+ }
+ audio_clamp_scroll(st);
+}
+
+static void apply_default_slider(audio_state_t *st, double norm) {
+ if (norm < 0.0) norm = 0.0;
+ if (norm > 1.0) norm = 1.0;
+ int max_pct = (st->tab == 1) ? 150 : 125;
+ int pct = (int)(norm * max_pct + 0.5);
+ char arg[32];
+ snprintf(arg, sizeof(arg), "%d%%", pct);
+ const char *target = (st->tab == 1) ? "@DEFAULT_AUDIO_SOURCE@" : "@DEFAULT_AUDIO_SINK@";
+ const char *limit = (st->tab == 1) ? "1.5" : "1.25";
+ const char *cmd[] = {"wpctl", "set-volume", "-l", limit, target, arg, NULL};
+ gemui_run_cmd_timeout(cmd, NULL, 0, 800);
+ if (st->tab == 1) {
+ st->in_vol_pct = pct;
+ } else {
+ st->out_vol_pct = pct;
+ const char *pk[] = {"pkill", "-USR1", "geminux-statusd", NULL};
+ gemui_run_cmd_timeout(pk, NULL, 0, 500);
+ }
+ gemui_request_redraw(st->app);
+}
+
+static void adjust_selected_node(audio_state_t *st, int action) {
+ if (st->sel_row < 0 || st->sel_row >= st->num_rows) {
+ gemui_show_toast(st->app, "Select a device or stream row first", 1600);
+ return;
+ }
+ const audio_row_t *r = &st->rows[st->sel_row];
+ char idx[24];
+ snprintf(idx, sizeof(idx), "%d", r->index);
+
+ if (action == HIT_ACT_DEF) {
+ if (r->is_stream || !r->name[0]) {
+ gemui_show_toast(st->app, "Select a hardware/Bluetooth device row", 1800);
+ return;
+ }
+ const char *cmd[] = {"pactl", st->tab == 1 ? "set-default-source" : "set-default-sink",
+ r->name, NULL};
+ int rc = gemui_run_cmd_timeout(cmd, NULL, 0, 1200);
+ gemui_show_toast(st->app, rc == 0 ? "Updated default audio device" : "Failed to switch default", 1800);
+ } else if (action == HIT_ACT_MUTE) {
+ const char *sub = (st->tab == 1)
+ ? (r->is_stream ? "set-source-output-mute" : "set-source-mute")
+ : (r->is_stream ? "set-sink-input-mute" : "set-sink-mute");
+ const char *target = (r->is_stream || !r->name[0]) ? idx : r->name;
+ const char *cmd[] = {"pactl", sub, target, "toggle", NULL};
+ gemui_run_cmd_timeout(cmd, NULL, 0, 1200);
+ } else if (action == HIT_ACT_DOWN || action == HIT_ACT_UP) {
+ const char *delta = (action == HIT_ACT_UP) ? "+5%" : "-5%";
+ const char *sub = (st->tab == 1)
+ ? (r->is_stream ? "set-source-output-volume" : "set-source-volume")
+ : (r->is_stream ? "set-sink-input-volume" : "set-sink-volume");
+ const char *target = (r->is_stream || !r->name[0]) ? idx : r->name;
+ const char *cmd[] = {"pactl", sub, target, delta, NULL};
+ gemui_run_cmd_timeout(cmd, NULL, 0, 1200);
+ }
+ const char *pk[] = {"pkill", "-USR1", "geminux-statusd", NULL};
+ gemui_run_cmd_timeout(pk, NULL, 0, 400);
+ refresh_audio(st);
+}
+
+static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
+ audio_state_t *st = ud;
+ const gemui_theme_t *t = gemui_theme(app);
+
+ gemui_draw_header(app, cr, "\xf3\xb0\x95\xbe", "Geminux Sound & Mixer (PipeWire)", st->status_text);
+
+ int pad = 20;
+ int top = 92;
+ int tab_w = (w - pad * 2 - 2 * 12) / 3;
+ static const char *tabs[3] = {"Playback (Output)", "Recording (Input)", "Cards & BT Profiles"};
+ for (int i = 0; i < 3; i++) {
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + i * (tab_w + 12), top, tab_w, 66},
+ tabs[i], HIT_TAB, i, false, st->tab == i, false);
+ }
+
+ int cw = w - pad * 2;
+ int cy = top + 82;
+ if (st->tab == 0 || st->tab == 1) {
+ int btn_w = 224;
+ int sl_w = cw - btn_w * 2 - 24;
+ int pct = (st->tab == 1) ? st->in_vol_pct : st->out_vol_pct;
+ bool muted = (st->tab == 1) ? st->in_muted : st->out_muted;
+ int max_pct = (st->tab == 1) ? 150 : 125;
+ double norm = (double)pct / (double)max_pct;
+ if (norm > 1.0) norm = 1.0;
+ char vtxt[40];
+ snprintf(vtxt, sizeof(vtxt), "%d%%%s", pct, muted ? " MUTED" : "");
+ st->slider_rect = (gemui_rect_t){pad, cy, sl_w, 96};
+ gemui_draw_slider(app, cr, st->slider_rect,
+ st->tab == 1 ? "Default Input Gain (Mic)" : "Default Output Volume",
+ norm, vtxt, HIT_SLIDER, 0, false);
+
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + sl_w + 12, cy, btn_w, 96},
+ muted ? "Unmute" : "Mute", HIT_MUTE_DEF, 0, false, muted, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + sl_w + 12 + btn_w + 12, cy, btn_w, 96},
+ st->tab == 1 ? "3s Mic Test" : "Test Tone", HIT_TEST, 0, true, false, false);
+
+ int ry = cy + 108;
+ int rw3 = (cw - 24) / 3;
+ if (st->tab == 0) {
+ gemui_draw_button(app, cr, (gemui_rect_t){pad, ry, rw3, 68},
+ "Internal Speakers", HIT_ROUTE_A, 0, false, st->speaker_on, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + rw3 + 12, ry, rw3, 68},
+ "3.5mm Headphones", HIT_ROUTE_B, 0, false, !st->speaker_on, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + 2 * (rw3 + 12), ry, rw3, 68},
+ "Bluetooth Audio Profiles", HIT_GOTO_CARDS, 0, false, false, false);
+ } else {
+ gemui_draw_button(app, cr, (gemui_rect_t){pad, ry, rw3, 68},
+ "Internal Dual Mic", HIT_ROUTE_A, 1, false, !st->headset_mic_on, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + rw3 + 12, ry, rw3, 68},
+ "3.5mm Headset Mic", HIT_ROUTE_B, 1, false, st->headset_mic_on, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + 2 * (rw3 + 12), ry, rw3, 68},
+ "Bluetooth HFP Headset", HIT_GOTO_CARDS, 0, false, false, false);
+ }
+ } else {
+ gemui_draw_button(app, cr, (gemui_rect_t){pad, cy, cw, 68},
+ "Select card profile below (e.g. Bluetooth A2DP Stereo vs HSP/HFP Headset Mic)",
+ HIT_ACT_REF, 0, false, false, false);
+ }
+
+ int list_y = (st->tab == 2) ? 260 : 366;
+ gemui_rect_t box = {pad, list_y, cw, h - list_y - 112};
+ gemui_fill_round(cr, box, 12, t->bg_bar);
+ gemui_stroke_round(cr, box, 12, 1.5, t->border);
+
+ int count = (st->tab == 2) ? st->num_profiles : st->num_rows;
+ if (count == 0) {
+ gemui_draw_text(cr, t, box, "No PipeWire audio endpoints found",
+ 0, false, GEMUI_ALIGN_CENTER, t->fg_muted);
+ } else {
+ int rh = 72;
+ for (int vis = 0; st->scroll_off + vis < count; vis++) {
+ int i = st->scroll_off + vis;
+ gemui_rect_t rr = {box.x + 10, box.y + 8 + vis * rh, box.w - 20, rh - 6};
+ if (rr.y + rr.h > box.y + box.h) break;
+ bool sel = (i == st->sel_row);
+ gemui_fill_round(cr, rr, 10, sel ? t->sel_bg : (i % 2 ? t->bg_alt_odd : t->bg_alt_even));
+ if (st->tab == 2) {
+ const geminux_audio_profile_t *p = &st->profiles[i];
+ char c1[280];
+ snprintf(c1, sizeof(c1), "%s%s — %s", p->active ? "* " : " ", p->card_label, p->profile_desc);
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 16, rr.y, rr.w - 460, rr.h},
+ c1, -2, p->active, GEMUI_ALIGN_LEFT,
+ sel ? t->sel_fg : t->fg_bright);
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 440, rr.y, 290, rr.h},
+ p->profile_name, -3, false, GEMUI_ALIGN_RIGHT,
+ sel ? t->sel_fg : t->accent_alt);
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 140, rr.y, 126, rr.h},
+ p->available ? (p->active ? "Active" : "Ready") : "Unavail", -3,
+ false, GEMUI_ALIGN_RIGHT, sel ? t->sel_fg : t->fg_muted);
+ } else {
+ const audio_row_t *r = &st->rows[i];
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 16, rr.y, rr.w - 410, rr.h},
+ r->label, -1, !r->is_stream, GEMUI_ALIGN_LEFT,
+ sel ? t->sel_fg : t->fg_bright);
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 390, rr.y, 200, rr.h},
+ r->col2, -2, false, GEMUI_ALIGN_RIGHT,
+ sel ? t->sel_fg : t->accent_alt);
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 180, rr.y, 166, rr.h},
+ r->col3, -2, false, GEMUI_ALIGN_RIGHT,
+ sel ? t->sel_fg : t->fg_muted);
+ }
+ gemui_hit_add(app, rr, HIT_ROW, i);
+ }
+ }
+
+ int fy = h - 92;
+ if (st->tab == 2) {
+ int fw = (cw - 24) / 3;
+ gemui_draw_button(app, cr, (gemui_rect_t){pad, fy, fw, 72},
+ "Activate Profile", HIT_ACT_DEF, 0, true, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + fw + 12, fy, fw, 72},
+ "Bluetooth Devices", HIT_GOTO_CARDS, 1, false, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + 2 * (fw + 12), fy, fw, 72},
+ "Refresh", HIT_ACT_REF, 0, false, false, false);
+ } else {
+ int fw = (cw - 48) / 5;
+ gemui_draw_button(app, cr, (gemui_rect_t){pad, fy, fw, 72},
+ st->tab == 1 ? "Set Default In" : "Set Default Out",
+ HIT_ACT_DEF, 0, true, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + (fw + 12), fy, fw, 72},
+ "Mute Item", HIT_ACT_MUTE, 0, false, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + 2 * (fw + 12), fy, fw, 72},
+ "Vol -5%", HIT_ACT_DOWN, 0, false, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + 3 * (fw + 12), fy, fw, 72},
+ "Vol +5%", HIT_ACT_UP, 0, false, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + 4 * (fw + 12), fy, fw, 72},
+ "Refresh", HIT_ACT_REF, 0, false, false, false);
+ }
+}
+
+static void on_key(gemui_app_t *app, KeySym ks, unsigned int state, const char *utf8, void *ud) {
+ (void)state; (void)utf8;
+ audio_state_t *st = ud;
+ int count = (st->tab == 2) ? st->num_profiles : st->num_rows;
+ if (ks == XK_Escape || ks == XK_q) {
+ gemui_quit(app, 0);
+ } else if (ks == XK_Tab) {
+ st->tab = (st->tab + 1) % 3;
+ refresh_audio(st);
+ gemui_request_redraw(app);
+ } else if (ks == XK_Up && count > 0) {
+ st->sel_row = (st->sel_row > 0) ? st->sel_row - 1 : 0;
+ audio_clamp_scroll(st);
+ gemui_request_redraw(app);
+ } else if (ks == XK_Down && count > 0) {
+ st->sel_row = (st->sel_row + 1 < count) ? st->sel_row + 1 : count - 1;
+ audio_clamp_scroll(st);
+ gemui_request_redraw(app);
+ } else if ((ks == XK_Left || ks == XK_minus) && st->tab < 2) {
+ int max_pct = (st->tab == 1) ? 150 : 125;
+ int cur = (st->tab == 1) ? st->in_vol_pct : st->out_vol_pct;
+ apply_default_slider(st, (double)(cur - 5) / (double)max_pct);
+ } else if ((ks == XK_Right || ks == XK_equal) && st->tab < 2) {
+ int max_pct = (st->tab == 1) ? 150 : 125;
+ int cur = (st->tab == 1) ? st->in_vol_pct : st->out_vol_pct;
+ apply_default_slider(st, (double)(cur + 5) / (double)max_pct);
+ } else if (ks == XK_Return || ks == XK_KP_Enter) {
+ if (st->tab == 2 && st->sel_row >= 0 && st->sel_row < st->num_profiles) {
+ const geminux_audio_profile_t *p = &st->profiles[st->sel_row];
+ const char *cmd[] = {"pactl", "set-card-profile", p->card_name, p->profile_name, NULL};
+ gemui_run_cmd_timeout(cmd, NULL, 0, 1200);
+ refresh_audio(st);
+ gemui_request_redraw(app);
+ } else if (st->tab < 2) {
+ adjust_selected_node(st, HIT_ACT_DEF);
+ gemui_request_redraw(app);
+ }
+ }
+}
+
+static void on_ptr(gemui_app_t *app, int type, int x, int y, unsigned int btn, void *ud) {
+ (void)btn;
+ audio_state_t *st = ud;
+ if (type == GEMUI_PTR_UP) {
+ if (st->dragging_slider) {
+ st->dragging_slider = false;
+ refresh_audio(st);
+ gemui_request_redraw(app);
+ }
+ return;
+ }
+ if (type == GEMUI_PTR_MOVE) {
+ if (st->dragging_slider && st->slider_rect.w > 32) {
+ apply_default_slider(st, (double)(x - st->slider_rect.x - 16) / (st->slider_rect.w - 32));
+ }
+ return;
+ }
+ if (type == GEMUI_PTR_SCROLL_UP) {
+ if (st->scroll_off > 0) {
+ st->scroll_off--;
+ gemui_request_redraw(app);
+ }
+ return;
+ }
+ if (type == GEMUI_PTR_SCROLL_DOWN) {
+ st->scroll_off++;
+ audio_clamp_scroll(st);
+ gemui_request_redraw(app);
+ return;
+ }
+ if (type != GEMUI_PTR_DOWN) return;
+
+ const gemui_hit_t *hit = gemui_hit_test(app, x, y);
+ if (!hit) return;
+
+ if (hit->id == HIT_TAB) {
+ st->tab = hit->val;
+ refresh_audio(st);
+ } else if (hit->id == HIT_SLIDER && st->slider_rect.w > 32) {
+ st->dragging_slider = true;
+ apply_default_slider(st, (double)(x - st->slider_rect.x - 16) / (st->slider_rect.w - 32));
+ return;
+ } else if (hit->id == HIT_MUTE_DEF) {
+ const char *tgt = (st->tab == 1) ? "@DEFAULT_AUDIO_SOURCE@" : "@DEFAULT_AUDIO_SINK@";
+ const char *cmd[] = {"wpctl", "set-mute", tgt, "toggle", NULL};
+ gemui_run_cmd_timeout(cmd, NULL, 0, 900);
+ const char *pk[] = {"pkill", "-USR1", "geminux-statusd", NULL};
+ gemui_run_cmd_timeout(pk, NULL, 0, 400);
+ refresh_audio(st);
+ } else if (hit->id == HIT_TEST) {
+ if (st->tab == 1) {
+ const char *cmd[] = {
+ "/bin/sh", "-c",
+ "f=/tmp/geminux-mic-$$.wav; timeout 3 pw-record \"$f\" >/dev/null 2>&1; pw-play \"$f\" >/dev/null 2>&1; rm -f \"$f\"",
+ NULL
+ };
+ gemui_spawn_detached(cmd);
+ gemui_show_toast(app, "Recording 3s mic loopback test...", 3200);
+ } else {
+ const char *cmd[] = {
+ "/bin/sh", "-c",
+ "timeout 2 speaker-test -D pulse -c 2 -t sine -f 660 -l 1 >/dev/null 2>&1 || true",
+ NULL
+ };
+ gemui_spawn_detached(cmd);
+ gemui_show_toast(app, "Playing stereo test tone", 1600);
+ }
+ } else if (hit->id == HIT_ROUTE_A) {
+ if (hit->val == 0) {
+ const char *p0[] = {"pactl", "set-sink-port", "alsa_output.platform-sound.HiFi__Speaker__sink", "[Out] Speaker", NULL};
+ const char *p1[] = {"pactl", "set-sink-port", "@DEFAULT_AUDIO_SINK@", "[Out] Speaker", NULL};
+ const char *c1[] = {"amixer", "-c", "0", "cset", "name='Headphone Switch'", "off", NULL};
+ const char *c2[] = {"amixer", "-c", "0", "cset", "name='Speaker Switch'", "on", NULL};
+ gemui_run_cmd_timeout(p0, NULL, 0, 700);
+ gemui_run_cmd_timeout(p1, NULL, 0, 700);
+ gemui_run_cmd_timeout(c1, NULL, 0, 700);
+ gemui_run_cmd_timeout(c2, NULL, 0, 700);
+ } else {
+ const char *p1[] = {"pactl", "set-source-port", "@DEFAULT_AUDIO_SOURCE@", "[In] Mic", NULL};
+ const char *c1[] = {"amixer", "-c", "0", "cset", "name='Headset Mic Switch'", "off", NULL};
+ const char *c2[] = {"amixer", "-c", "0", "cset", "name='PGA L Mux'", "AIN0", NULL};
+ const char *c3[] = {"amixer", "-c", "0", "cset", "name='PGA R Mux'", "AIN2", NULL};
+ const char *c4[] = {"amixer", "-c", "0", "cset", "name='Main Mic Switch'", "on", NULL};
+ const char *c5[] = {"amixer", "-c", "0", "cset", "name='Back Mic Switch'", "on", NULL};
+ gemui_run_cmd_timeout(p1, NULL, 0, 700);
+ gemui_run_cmd_timeout(c1, NULL, 0, 700);
+ gemui_run_cmd_timeout(c2, NULL, 0, 700);
+ gemui_run_cmd_timeout(c3, NULL, 0, 700);
+ gemui_run_cmd_timeout(c4, NULL, 0, 700);
+ gemui_run_cmd_timeout(c5, NULL, 0, 700);
+ }
+ refresh_audio(st);
+ } else if (hit->id == HIT_ROUTE_B) {
+ if (hit->val == 0) {
+ const char *p1[] = {"pactl", "set-sink-port", "@DEFAULT_AUDIO_SINK@", "[Out] Headphones", NULL};
+ const char *c1[] = {"amixer", "-c", "0", "cset", "name='Speaker Switch'", "off", NULL};
+ const char *c2[] = {"amixer", "-c", "0", "cset", "name='Headphone Switch'", "on", NULL};
+ gemui_run_cmd_timeout(p1, NULL, 0, 700);
+ gemui_run_cmd_timeout(c1, NULL, 0, 700);
+ gemui_run_cmd_timeout(c2, NULL, 0, 700);
+ } else {
+ const char *p1[] = {"pactl", "set-source-port", "@DEFAULT_AUDIO_SOURCE@", "[In] Headset", NULL};
+ const char *c1[] = {"amixer", "-c", "0", "cset", "name='Main Mic Switch'", "off", NULL};
+ const char *c2[] = {"amixer", "-c", "0", "cset", "name='Back Mic Switch'", "off", NULL};
+ const char *c3[] = {"amixer", "-c", "0", "cset", "name='PGA L Mux'", "AIN1", NULL};
+ const char *c4[] = {"amixer", "-c", "0", "cset", "name='PGA R Mux'", "AIN1", NULL};
+ const char *c5[] = {"amixer", "-c", "0", "cset", "name='Headset Mic Switch'", "on", NULL};
+ gemui_run_cmd_timeout(p1, NULL, 0, 700);
+ gemui_run_cmd_timeout(c1, NULL, 0, 700);
+ gemui_run_cmd_timeout(c2, NULL, 0, 700);
+ gemui_run_cmd_timeout(c3, NULL, 0, 700);
+ gemui_run_cmd_timeout(c4, NULL, 0, 700);
+ gemui_run_cmd_timeout(c5, NULL, 0, 700);
+ }
+ refresh_audio(st);
+ } else if (hit->id == HIT_GOTO_CARDS) {
+ if (hit->val == 1) {
+ const char *netcmd[] = {"geminux-net", NULL};
+ gemui_spawn_detached(netcmd);
+ } else {
+ st->tab = 2;
+ refresh_audio(st);
+ }
+ } else if (hit->id == HIT_ROW) {
+ st->sel_row = hit->val;
+ } else if (hit->id == HIT_ACT_DEF && st->tab == 2) {
+ if (st->sel_row >= 0 && st->sel_row < st->num_profiles) {
+ const geminux_audio_profile_t *p = &st->profiles[st->sel_row];
+ const char *cmd[] = {"pactl", "set-card-profile", p->card_name, p->profile_name, NULL};
+ int rc = gemui_run_cmd_timeout(cmd, NULL, 0, 1200);
+ gemui_show_toast(app, rc == 0 ? "Activated audio profile" : "Profile switch failed", 1800);
+ refresh_audio(st);
+ } else {
+ gemui_show_toast(app, "Select a profile first", 1600);
+ }
+ } else if (hit->id == HIT_ACT_DEF || hit->id == HIT_ACT_MUTE ||
+ hit->id == HIT_ACT_DOWN || hit->id == HIT_ACT_UP) {
+ adjust_selected_node(st, hit->id);
+ } else if (hit->id == HIT_ACT_REF) {
+ refresh_audio(st);
+ gemui_show_toast(app, "Refreshed audio state", 1200);
+ }
+ gemui_request_redraw(app);
+}
+
+int main(void) {
+ audio_state_t st;
+ memset(&st, 0, sizeof(st));
+ st.sel_row = -1;
+ st.out_vol_pct = 40;
+ st.in_vol_pct = 100;
+ refresh_audio(&st);
+
+ st.app = gemui_create("geminux-audio", "Geminux Sound & Mixer", 1920, 940, false);
+ if (!st.app) return 1;
+
+ gemui_handlers_t h = { .on_draw = on_draw, .on_key = on_key, .on_ptr = on_ptr };
+ gemui_set_handlers(st.app, &h, &st);
+ int rc = gemui_run(st.app);
+ gemui_destroy(st.app);
+ return rc;
+}
diff --git a/src/geminux-apps/geminux-bt-list.h b/src/geminux-apps/geminux-bt-list.h
new file mode 100644
index 0000000..6a7562e
--- /dev/null
+++ b/src/geminux-apps/geminux-bt-list.h
@@ -0,0 +1,133 @@
+/*
+ * Header-only C11 helpers for parsing bluetoothctl device listings into sorted entries.
+ */
+#ifndef GEMINUX_BT_LIST_H
+#define GEMINUX_BT_LIST_H
+
+#include
+#include
+#include
+#include
+#include
+
+#define GEMINUX_MAX_BT_DEVS 32
+
+typedef struct {
+ char mac[24];
+ char name[96];
+ bool paired;
+ bool connected;
+} geminux_bt_dev_t;
+
+static inline bool geminux_bt_is_mac(const char *s) {
+ if (!s || strlen(s) < 17) return false;
+ for (int i = 0; i < 17; i++) {
+ if (i % 3 == 2) {
+ if (s[i] != ':') return false;
+ } else if (!isxdigit((unsigned char)s[i])) {
+ return false;
+ }
+ }
+ return s[17] == '\0' || s[17] == ' ' || s[17] == '\t';
+}
+
+static inline void geminux_bt_strip_ansi(const char *in, char *out, size_t out_sz) {
+ size_t j = 0;
+ for (size_t i = 0; in[i] && j + 1 < out_sz; i++) {
+ if ((unsigned char)in[i] == 0x1b && in[i + 1] == '[') {
+ i += 2;
+ while (in[i] && !((in[i] >= 'A' && in[i] <= 'Z') || (in[i] >= 'a' && in[i] <= 'z'))) {
+ i++;
+ }
+ continue;
+ }
+ if ((unsigned char)in[i] >= 0x20 || in[i] == '\t') {
+ out[j++] = in[i];
+ }
+ }
+ out[j] = '\0';
+}
+
+static inline void geminux_bt_feed_list(const char *text, geminux_bt_dev_t *devs,
+ int *count, int max_devs,
+ bool mark_paired, bool mark_connected) {
+ if (!text || !devs || !count || max_devs <= 0) return;
+ const char *cur = text;
+ while (*cur) {
+ const char *nl = strchr(cur, '\n');
+ size_t raw_len = nl ? (size_t)(nl - cur) : strlen(cur);
+ char raw[256], ln[256];
+ size_t cp = raw_len < sizeof(raw) - 1 ? raw_len : sizeof(raw) - 1;
+ memcpy(raw, cur, cp);
+ raw[cp] = '\0';
+ cur = nl ? nl + 1 : cur + raw_len;
+
+ geminux_bt_strip_ansi(raw, ln, sizeof(ln));
+ char *p = ln;
+ while (*p == ' ' || *p == '\t') p++;
+ if (strncmp(p, "[NEW]", 5) == 0 || strncmp(p, "[CHG]", 5) == 0) p += 5;
+ while (*p == ' ' || *p == '\t') p++;
+ if (strncmp(p, "Device ", 7) != 0) continue;
+ p += 7;
+ if (!geminux_bt_is_mac(p)) continue;
+
+ char mac[24];
+ memcpy(mac, p, 17);
+ mac[17] = '\0';
+ for (int i = 0; i < 17; i++) mac[i] = (char)toupper((unsigned char)mac[i]);
+
+ const char *name = p + 17;
+ while (*name == ' ' || *name == '\t') name++;
+ size_t nlen = strlen(name);
+ while (nlen > 0 && (name[nlen - 1] == ' ' || name[nlen - 1] == '\r')) nlen--;
+
+ int idx = -1;
+ for (int i = 0; i < *count; i++) {
+ if (strcmp(devs[i].mac, mac) == 0) {
+ idx = i;
+ break;
+ }
+ }
+ if (idx < 0) {
+ if (*count >= max_devs) continue;
+ idx = (*count)++;
+ memset(&devs[idx], 0, sizeof(devs[idx]));
+ snprintf(devs[idx].mac, sizeof(devs[idx].mac), "%s", mac);
+ }
+ if (nlen > 0) {
+ size_t keep = nlen < sizeof(devs[idx].name) - 1 ? nlen : sizeof(devs[idx].name) - 1;
+ memcpy(devs[idx].name, name, keep);
+ devs[idx].name[keep] = '\0';
+ } else if (!devs[idx].name[0]) {
+ snprintf(devs[idx].name, sizeof(devs[idx].name), "%s", mac);
+ }
+ if (mark_paired) devs[idx].paired = true;
+ if (mark_connected) {
+ devs[idx].connected = true;
+ devs[idx].paired = true;
+ }
+ }
+}
+
+static inline int geminux_bt_dev_cmp(const void *pa, const void *pb) {
+ const geminux_bt_dev_t *a = (const geminux_bt_dev_t *)pa;
+ const geminux_bt_dev_t *b = (const geminux_bt_dev_t *)pb;
+ if (a->connected != b->connected) return b->connected ? 1 : -1;
+ if (a->paired != b->paired) return b->paired ? 1 : -1;
+ return strcmp(a->name, b->name);
+}
+
+static inline int geminux_parse_bt_devices(const char *all_txt,
+ const char *paired_txt,
+ const char *conn_txt,
+ geminux_bt_dev_t *devs,
+ int max_devs) {
+ int n = 0;
+ geminux_bt_feed_list(all_txt, devs, &n, max_devs, false, false);
+ geminux_bt_feed_list(paired_txt, devs, &n, max_devs, true, false);
+ geminux_bt_feed_list(conn_txt, devs, &n, max_devs, true, true);
+ if (n > 1) qsort(devs, (size_t)n, sizeof(devs[0]), geminux_bt_dev_cmp);
+ return n;
+}
+
+#endif /* GEMINUX_BT_LIST_H */
diff --git a/src/geminux-apps/geminux-control.c b/src/geminux-apps/geminux-control.c
index 3f78c4a..a645aba 100644
--- a/src/geminux-apps/geminux-control.c
+++ b/src/geminux-apps/geminux-control.c
@@ -14,6 +14,7 @@
#define HIT_SUSPEND 6
#define HIT_REBOOT 7
#define HIT_POWER 8
+#define HIT_MIXER 9
typedef struct {
gemui_app_t *app;
@@ -104,10 +105,12 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
snprintf(btxt, sizeof(btxt), "%d%%", (int)(bnorm * 100.0 + 0.5));
gemui_draw_slider(app, cr, st->bri_rect, "Display Backlight", bnorm, btxt, HIT_BRI, 0, false);
- st->vol_rect = (gemui_rect_t){pad, 210, cw, 104};
+ st->vol_rect = (gemui_rect_t){pad, 210, cw - 240, 104};
char vtxt[32];
snprintf(vtxt, sizeof(vtxt), "%d%%", st->vol_pct);
gemui_draw_slider(app, cr, st->vol_rect, "Master Audio Volume", st->vol_pct / 100.0, vtxt, HIT_VOL, 0, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + cw - 228, 210, 228, 104},
+ "Audio Mixer", HIT_MIXER, 0, true, false, false);
gemui_draw_text(cr, t, (gemui_rect_t){pad, 330, cw, 40},
"MT6797X Power Profile (A72 Big Cluster + Schedutil)",
@@ -175,6 +178,9 @@ static void on_ptr(gemui_app_t *app, int type, int x, int y, unsigned int btn, v
} else if (hit->id == HIT_VOL) {
st->active_drag = HIT_VOL;
set_volume_norm(st, (double)(x - st->vol_rect.x - 16) / (st->vol_rect.w - 32));
+ } else if (hit->id == HIT_MIXER) {
+ const char *cmd[] = {"geminux-audio", NULL};
+ gemui_spawn_detached(cmd);
} else if (hit->id == HIT_PROF) {
static const char *pnames[3] = {"eco", "balanced", "performance"};
st->profile = hit->val;
diff --git a/src/geminux-apps/geminux-net.c b/src/geminux-apps/geminux-net.c
index b6a2864..4f73295 100644
--- a/src/geminux-apps/geminux-net.c
+++ b/src/geminux-apps/geminux-net.c
@@ -1,9 +1,17 @@
#define _POSIX_C_SOURCE 200809L
#include "gemui.h"
+#include "geminux-wifi-list.h"
+#include "geminux-bt-list.h"
+#include
+#include
+#include
#include
#include
#include
+#include
+#include
+#include
#define HIT_TAB 1
#define HIT_TOGGLE 2
@@ -11,6 +19,22 @@
#define HIT_ROW 4
#define HIT_PSK 5
#define HIT_CONNECT 6
+#define HIT_SHOW_PSK 7
+#define HIT_BT_CONN 8
+#define HIT_BT_DISC 9
+#define HIT_BT_REM 10
+#define HIT_AUDIO 11
+
+enum {
+ WORK_NONE = 0,
+ WORK_WIFI_CONN,
+ WORK_WIFI_SCAN,
+ WORK_BT_PWR,
+ WORK_BT_SCAN,
+ WORK_BT_CONN,
+ WORK_BT_DISC,
+ WORK_BT_REM,
+};
typedef struct {
char col1[96];
@@ -24,50 +48,169 @@ typedef struct {
bool wifi_on;
bool cellular_on;
bool bt_on;
+ bool bt_svc_up;
bool hdmi_on;
net_row_t rows[32];
+ geminux_wifi_group_t wifi_groups[GEMINUX_MAX_WIFI_GROUPS];
+ geminux_bt_dev_t bt_devs[GEMINUX_MAX_BT_DEVS];
int num_rows;
int sel_row;
+ int scroll_off;
char status_text[256];
char psk[128];
bool focus_psk;
+ bool show_psk;
+
+ pid_t worker_pid;
+ int worker_fd;
+ int worker_kind;
+ int worker_tick;
+ uint64_t worker_deadline_ms;
+ char worker_label[96];
+ char worker_out[2048];
+ size_t worker_len;
} net_state_t;
-static void refresh_tab(net_state_t *st) {
- st->num_rows = 0;
- st->sel_row = -1;
- char out[4096] = {0};
+static uint64_t net_now_ms(void) {
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (uint64_t)ts.tv_sec * 1000ULL + (uint64_t)(ts.tv_nsec / 1000000L);
+}
+static int net_visible_rows(const net_state_t *st) {
+ int h = st->app ? gemui_height(st->app) : 940;
+ int foot_h = (st->tab == 0 || st->tab == 2) ? 94 : 0;
+ int box_h = h - (92 + 82 + 88) - 20 - foot_h;
+ int vis = (box_h - 8) / 72;
+ return vis > 0 ? vis : 1;
+}
+
+static void net_clamp_scroll(net_state_t *st) {
+ int vis = net_visible_rows(st);
+ int max_off = st->num_rows > vis ? st->num_rows - vis : 0;
+ if (st->scroll_off < 0) st->scroll_off = 0;
+ if (st->scroll_off > max_off) st->scroll_off = max_off;
+ if (st->sel_row >= 0 && st->sel_row < st->num_rows) {
+ if (st->sel_row < st->scroll_off) st->scroll_off = st->sel_row;
+ else if (st->sel_row >= st->scroll_off + vis) st->scroll_off = st->sel_row - vis + 1;
+ }
+}
+
+static void refresh_wifi(net_state_t *st, const char *prev_ssid) {
+ static char out[16384];
+ out[0] = '\0';
const char *wargv[] = {"nmcli", "-t", "-f", "WIFI", "general", NULL};
- if (gemui_run_cmd_capture(wargv, out, sizeof(out)) == 0) {
+ if (gemui_run_cmd_timeout(wargv, out, sizeof(out), 900) == 0) {
st->wifi_on = strstr(out, "enabled") != NULL;
}
- if (st->tab == 0) {
- const char *scan[] = {"nmcli", "-t", "-f", "IN-USE,SSID,SIGNAL,SECURITY", "dev", "wifi", "list", NULL};
- if (gemui_run_cmd_capture(scan, out, sizeof(out)) == 0) {
- char *save = NULL;
- for (char *ln = strtok_r(out, "\n", &save); ln && st->num_rows < 32; ln = strtok_r(NULL, "\n", &save)) {
- char *c1 = strchr(ln, ':');
- char *c2 = c1 ? strchr(c1 + 1, ':') : NULL;
- char *c3 = c2 ? strchr(c2 + 1, ':') : NULL;
- if (!c1 || !c2 || !c3) continue;
- *c1 = *c2 = *c3 = '\0';
- net_row_t *r = &st->rows[st->num_rows++];
- snprintf(r->col1, sizeof(r->col1), "%s%s", (ln[0] == '*') ? "* " : "", c1 + 1);
- snprintf(r->col2, sizeof(r->col2), "Signal %s%%", c2 + 1);
- snprintf(r->col3, sizeof(r->col3), "%s", (c3 + 1)[0] ? (c3 + 1) : "Open");
+ out[0] = '\0';
+ const char *scan[] = {"nmcli", "-t", "-f", "IN-USE,BSSID,SSID,CHAN,SIGNAL,SECURITY", "dev", "wifi", "list", NULL};
+ if (gemui_run_cmd_timeout(scan, out, sizeof(out), 1200) == 0) {
+ int ng = geminux_parse_wifi_scan(out, st->wifi_groups, GEMINUX_MAX_WIFI_GROUPS);
+ st->num_rows = ng;
+ for (int i = 0; i < ng; i++) {
+ const geminux_wifi_group_t *g = &st->wifi_groups[i];
+ net_row_t *r = &st->rows[i];
+ snprintf(r->col1, sizeof(r->col1), "%s%s", g->in_use ? "* " : "", g->ssid);
+ if (g->ap_count > 1) {
+ snprintf(r->col2, sizeof(r->col2), "Mesh (%d) %d%%", g->ap_count, g->best_signal);
+ } else {
+ snprintf(r->col2, sizeof(r->col2), "Signal %d%%", g->best_signal);
+ }
+ snprintf(r->col3, sizeof(r->col3), "%s", g->security);
+ if (prev_ssid[0] && strcmp(g->ssid, prev_ssid) == 0) {
+ st->sel_row = i;
}
}
- snprintf(st->status_text, sizeof(st->status_text), "Wi-Fi %s (powersave=3)",
- st->wifi_on ? "Enabled" : "Disabled");
+ }
+ net_clamp_scroll(st);
+ snprintf(st->status_text, sizeof(st->status_text), "Wi-Fi %s (powersave=3)",
+ st->wifi_on ? "Enabled" : "Disabled");
+}
+
+static void refresh_bt(net_state_t *st, const char *prev_mac) {
+ static char all_out[8192];
+ static char pair_out[4096];
+ static char conn_out[4096];
+ char show_out[1024] = {0};
+ char rf_out[256] = {0};
+
+ const char *rf[] = {"rfkill", "list", "bluetooth", NULL};
+ gemui_run_cmd_timeout(rf, rf_out, sizeof(rf_out), 500);
+ bool rf_unblocked = (strstr(rf_out, "Soft blocked: no") != NULL);
+
+ const char *sh[] = {"bluetoothctl", "--timeout", "1", "show", NULL};
+ int sh_rc = gemui_run_cmd_timeout(sh, show_out, sizeof(show_out), 900);
+ st->bt_svc_up = (sh_rc == 0 && strstr(show_out, "Controller ") != NULL);
+ if (st->bt_svc_up) {
+ st->bt_on = (strstr(show_out, "Powered: yes") != NULL) && rf_unblocked;
+ } else {
+ st->bt_on = false;
+ }
+
+ st->num_rows = 0;
+ st->sel_row = -1;
+ if (st->bt_svc_up) {
+ all_out[0] = '\0';
+ pair_out[0] = '\0';
+ conn_out[0] = '\0';
+ const char *b_all[] = {"bluetoothctl", "--timeout", "1", "devices", NULL};
+ const char *b_pair[] = {"bluetoothctl", "--timeout", "1", "devices", "Paired", NULL};
+ const char *b_conn[] = {"bluetoothctl", "--timeout", "1", "devices", "Connected", NULL};
+ gemui_run_cmd_timeout(b_all, all_out, sizeof(all_out), 900);
+ gemui_run_cmd_timeout(b_pair, pair_out, sizeof(pair_out), 800);
+ gemui_run_cmd_timeout(b_conn, conn_out, sizeof(conn_out), 800);
+
+ int nb = geminux_parse_bt_devices(all_out, pair_out, conn_out,
+ st->bt_devs, GEMINUX_MAX_BT_DEVS);
+ st->num_rows = nb;
+ for (int i = 0; i < nb; i++) {
+ const geminux_bt_dev_t *d = &st->bt_devs[i];
+ net_row_t *r = &st->rows[i];
+ snprintf(r->col1, sizeof(r->col1), "%s%s", d->connected ? "* " : "", d->name);
+ snprintf(r->col2, sizeof(r->col2), "%s",
+ d->connected ? "Connected" : (d->paired ? "Paired" : "Discovered"));
+ snprintf(r->col3, sizeof(r->col3), "%s", d->mac);
+ if (prev_mac[0] && strcmp(d->mac, prev_mac) == 0) {
+ st->sel_row = i;
+ }
+ }
+ }
+ net_clamp_scroll(st);
+ if (!st->bt_svc_up) {
+ snprintf(st->status_text, sizeof(st->status_text),
+ "Bluetooth service offline (toggle Radio ON to start)");
+ } else {
+ snprintf(st->status_text, sizeof(st->status_text),
+ "Bluetooth %s (Dual BR/EDR + BLE + HID + Audio)",
+ st->bt_on ? "Powered ON" : "Powered OFF");
+ }
+}
+
+static void refresh_tab(net_state_t *st) {
+ char prev_key[96] = {0};
+ if (st->tab == 0 && st->sel_row >= 0 && st->sel_row < st->num_rows) {
+ snprintf(prev_key, sizeof(prev_key), "%s", st->wifi_groups[st->sel_row].ssid);
+ } else if (st->tab == 2 && st->sel_row >= 0 && st->sel_row < st->num_rows) {
+ snprintf(prev_key, sizeof(prev_key), "%s", st->bt_devs[st->sel_row].mac);
+ }
+
+ st->num_rows = 0;
+ st->sel_row = -1;
+ static char out[16384];
+ out[0] = '\0';
+
+ if (st->tab == 0) {
+ refresh_wifi(st, prev_key);
} else if (st->tab == 1) {
+ st->scroll_off = 0;
gemui_unix_cmd("/run/geminux/ccci.sock", "status", out, sizeof(out));
st->cellular_on = strstr(out, "READY") != NULL;
snprintf(st->status_text, sizeof(st->status_text), "CCCI Modem: %s",
out[0] ? out : "Degraded / No MD1 firmware loaded");
const char *mm[] = {"mmcli", "-m", "0", NULL};
- if (gemui_run_cmd_capture(mm, out, sizeof(out)) == 0) {
+ if (gemui_run_cmd_timeout(mm, out, sizeof(out), 900) == 0) {
char *save = NULL;
for (char *ln = strtok_r(out, "\n", &save); ln && st->num_rows < 20; ln = strtok_r(NULL, "\n", &save)) {
while (*ln == ' ' || *ln == '|') ln++;
@@ -79,29 +222,19 @@ static void refresh_tab(net_state_t *st) {
}
}
} else if (st->tab == 2) {
- const char *bt[] = {"bluetoothctl", "devices", NULL};
- if (gemui_run_cmd_capture(bt, out, sizeof(out)) == 0) {
- char *save = NULL;
- for (char *ln = strtok_r(out, "\n", &save); ln && st->num_rows < 32; ln = strtok_r(NULL, "\n", &save)) {
- snprintf(st->rows[st->num_rows].col1, sizeof(st->rows[0].col1), "%s", ln);
- st->rows[st->num_rows].col2[0] = '\0';
- st->rows[st->num_rows].col3[0] = '\0';
- st->num_rows++;
- }
- }
- const char *rf[] = {"rfkill", "list", "bluetooth", NULL};
- gemui_run_cmd_capture(rf, out, sizeof(out));
- st->bt_on = strstr(out, "Soft blocked: no") != NULL;
- snprintf(st->status_text, sizeof(st->status_text),
- "Bluetooth %s (AutoEnable=false at boot)", st->bt_on ? "Powered ON" : "Powered OFF");
+ refresh_bt(st, prev_key);
} else {
+ st->scroll_off = 0;
+ st->hdmi_on = false;
const char *xr[] = {"xrandr", "--query", NULL};
- if (gemui_run_cmd_capture(xr, out, sizeof(out)) == 0) {
+ if (gemui_run_cmd_timeout(xr, out, sizeof(out), 900) == 0) {
char *save = NULL;
for (char *ln = strtok_r(out, "\n", &save); ln && st->num_rows < 24; ln = strtok_r(NULL, "\n", &save)) {
if (strstr(ln, "connected")) {
if (strstr(ln, "HDMI") && !strstr(ln, "disconnected")) st->hdmi_on = true;
snprintf(st->rows[st->num_rows].col1, sizeof(st->rows[0].col1), "%s", ln);
+ st->rows[st->num_rows].col2[0] = '\0';
+ st->rows[st->num_rows].col3[0] = '\0';
st->num_rows++;
}
}
@@ -111,11 +244,460 @@ static void refresh_tab(net_state_t *st) {
}
}
+static void on_worker_timer(gemui_app_t *app, void *ud);
+
+static void cancel_worker(net_state_t *st, const char *toast) {
+ if (st->worker_pid <= 0) return;
+ kill(-st->worker_pid, SIGTERM);
+ kill(st->worker_pid, SIGTERM);
+ if (st->worker_fd >= 0) {
+ gemui_del_fd(st->app, st->worker_fd);
+ close(st->worker_fd);
+ st->worker_fd = -1;
+ }
+ int status = 0;
+ waitpid(st->worker_pid, &status, 0);
+ st->worker_pid = 0;
+ st->worker_kind = WORK_NONE;
+ gemui_set_timer_ms(st->app, 0, NULL, NULL);
+ if (toast) gemui_show_toast(st->app, toast, 1600);
+ refresh_tab(st);
+ gemui_request_redraw(st->app);
+}
+
+static void extract_last_error(const char *raw, char *dst, size_t dst_sz) {
+ dst[0] = '\0';
+ if (!raw || !raw[0]) return;
+ char tmp[1024];
+ snprintf(tmp, sizeof(tmp), "%s", raw);
+ char *last = NULL;
+ char *save = NULL;
+ for (char *ln = strtok_r(tmp, "\r\n", &save); ln; ln = strtok_r(NULL, "\r\n", &save)) {
+ while (*ln == ' ' || *ln == '\t') ln++;
+ if (ln[0]) last = ln;
+ }
+ if (!last) return;
+ if (strncmp(last, "Error: ", 7) == 0) last += 7;
+ snprintf(dst, dst_sz, "%s", last);
+}
+
+static void on_worker_fd(gemui_app_t *app, int fd, void *ud) {
+ net_state_t *st = ud;
+ char buf[512];
+ bool eof = false;
+ while (1) {
+ ssize_t n = read(fd, buf, sizeof(buf));
+ if (n > 0) {
+ if (st->worker_len + 1 < sizeof(st->worker_out)) {
+ size_t cp = (size_t)n;
+ if (cp > sizeof(st->worker_out) - 1 - st->worker_len) {
+ cp = sizeof(st->worker_out) - 1 - st->worker_len;
+ }
+ memcpy(st->worker_out + st->worker_len, buf, cp);
+ st->worker_len += cp;
+ st->worker_out[st->worker_len] = '\0';
+ }
+ } else if (n == 0) {
+ eof = true;
+ break;
+ } else {
+ if (errno == EINTR) continue;
+ if (errno == EAGAIN || errno == EWOULDBLOCK) break;
+ eof = true;
+ break;
+ }
+ }
+ if (!eof) return;
+
+ gemui_del_fd(app, fd);
+ close(fd);
+ st->worker_fd = -1;
+
+ int status = 0;
+ if (st->worker_pid > 0) {
+ while (waitpid(st->worker_pid, &status, 0) < 0 && errno == EINTR) {}
+ }
+ int rc = WIFEXITED(status) ? WEXITSTATUS(status) : 1;
+ int kind = st->worker_kind;
+ st->worker_pid = 0;
+ st->worker_kind = WORK_NONE;
+ gemui_set_timer_ms(app, 0, NULL, NULL);
+
+ char err[192] = {0};
+ extract_last_error(st->worker_out, err, sizeof(err));
+ char toast[256];
+
+ if (kind == WORK_WIFI_CONN) {
+ if (rc == 0) {
+ memset(st->psk, 0, sizeof(st->psk));
+ st->show_psk = false;
+ gemui_show_toast(app, "Connected to Wi-Fi", 2200);
+ } else {
+ snprintf(toast, sizeof(toast), err[0] ? "Wi-Fi failed: %.180s" : "Wi-Fi connect failed", err);
+ gemui_show_toast(app, toast, 3500);
+ }
+ } else if (kind == WORK_WIFI_SCAN) {
+ gemui_show_toast(app, rc == 0 ? "Wi-Fi scan updated" : "Wi-Fi rescan failed", 1800);
+ } else if (kind == WORK_BT_PWR) {
+ if (rc == 0) gemui_show_toast(app, "Updated Bluetooth power", 1800);
+ else {
+ snprintf(toast, sizeof(toast), err[0] ? "Bluetooth power: %.180s" : "Bluetooth power failed", err);
+ gemui_show_toast(app, toast, 2600);
+ }
+ } else if (kind == WORK_BT_SCAN) {
+ gemui_show_toast(app, "Bluetooth scan finished", 1800);
+ } else if (kind == WORK_BT_CONN) {
+ if (rc == 0) gemui_show_toast(app, "Bluetooth device connected", 2200);
+ else {
+ snprintf(toast, sizeof(toast), err[0] ? "BT connect failed: %.170s" : "Bluetooth connect failed", err);
+ gemui_show_toast(app, toast, 3000);
+ }
+ } else if (kind == WORK_BT_DISC) {
+ gemui_show_toast(app, rc == 0 ? "Bluetooth device disconnected" : "Disconnect failed", 2000);
+ } else if (kind == WORK_BT_REM) {
+ gemui_show_toast(app, rc == 0 ? "Removed Bluetooth device" : "Remove failed", 2000);
+ }
+
+ refresh_tab(st);
+ gemui_request_redraw(app);
+}
+
+static void on_worker_timer(gemui_app_t *app, void *ud) {
+ net_state_t *st = ud;
+ if (st->worker_pid <= 0) {
+ gemui_set_timer_ms(app, 0, NULL, NULL);
+ return;
+ }
+ uint64_t now = net_now_ms();
+ if (st->worker_deadline_ms > 0 && now >= st->worker_deadline_ms) {
+ kill(-st->worker_pid, SIGKILL);
+ kill(st->worker_pid, SIGKILL);
+ return;
+ }
+ st->worker_tick++;
+ if (st->worker_kind == WORK_BT_SCAN && (st->worker_tick % 4) == 0 && st->tab == 2) {
+ char prev_mac[24] = {0};
+ if (st->sel_row >= 0 && st->sel_row < st->num_rows) {
+ snprintf(prev_mac, sizeof(prev_mac), "%s", st->bt_devs[st->sel_row].mac);
+ }
+ refresh_bt(st, prev_mac);
+ }
+ gemui_request_redraw(app);
+}
+
+typedef int (*net_child_fn)(void *ctx);
+
+static bool start_worker(net_state_t *st, int kind, const char *label,
+ int timeout_ms, net_child_fn fn, void *ctx) {
+ if (st->worker_pid > 0) {
+ gemui_show_toast(st->app, "Operation in progress (press Cancel to abort)", 2000);
+ return false;
+ }
+ int pfd[2];
+ if (pipe(pfd) < 0) return false;
+ pid_t pid = fork();
+ if (pid < 0) {
+ close(pfd[0]);
+ close(pfd[1]);
+ return false;
+ }
+ if (pid == 0) {
+ setpgid(0, 0);
+ int devnull = open("/dev/null", O_RDONLY);
+ if (devnull >= 0) {
+ dup2(devnull, STDIN_FILENO);
+ if (devnull > 2) close(devnull);
+ } else {
+ close(STDIN_FILENO);
+ }
+ close(pfd[0]);
+ dup2(pfd[1], STDOUT_FILENO);
+ dup2(pfd[1], STDERR_FILENO);
+ if (pfd[1] > 2) close(pfd[1]);
+ int rc = fn(ctx);
+ _exit(rc);
+ }
+ close(pfd[1]);
+ int fl = fcntl(pfd[0], F_GETFL, 0);
+ if (fl >= 0) fcntl(pfd[0], F_SETFL, fl | O_NONBLOCK);
+ int fdfl = fcntl(pfd[0], F_GETFD, 0);
+ if (fdfl >= 0) fcntl(pfd[0], F_SETFD, fdfl | FD_CLOEXEC);
+
+ st->worker_pid = pid;
+ st->worker_fd = pfd[0];
+ st->worker_kind = kind;
+ st->worker_tick = 0;
+ st->worker_len = 0;
+ st->worker_out[0] = '\0';
+ st->worker_deadline_ms = net_now_ms() + (uint64_t)(timeout_ms > 0 ? timeout_ms : 30000);
+ snprintf(st->worker_label, sizeof(st->worker_label), "%s", label);
+
+ gemui_add_fd(st->app, pfd[0], on_worker_fd, st);
+ gemui_set_timer_ms(st->app, 500, on_worker_timer, st);
+ gemui_show_toast(st->app, label, 2500);
+ gemui_request_redraw(st->app);
+ return true;
+}
+
+typedef struct {
+ char ssid[96];
+ char bssid[24];
+ char psk[128];
+ int ap_count;
+ bool is_open;
+ bool has_psk;
+} wifi_job_t;
+
+static void wifi_delete_ssid_profiles(const char *ssid) {
+ const char *del_id[] = {"nmcli", "connection", "delete", "id", ssid, NULL};
+ gemui_run_cmd_timeout(del_id, NULL, 0, 5000);
+
+ char list[4096] = {0};
+ const char *show[] = {"nmcli", "-t", "-f", "UUID,TYPE", "connection", "show", NULL};
+ if (gemui_run_cmd_timeout(show, list, sizeof(list), 2000) != 0) return;
+
+ char *save = NULL;
+ for (char *ln = strtok_r(list, "\n", &save); ln; ln = strtok_r(NULL, "\n", &save)) {
+ char *sep = strchr(ln, ':');
+ if (!sep) continue;
+ *sep = '\0';
+ const char *uuid = ln;
+ const char *type = sep + 1;
+ if (strcmp(type, "802-11-wireless") != 0 || !uuid[0]) continue;
+ char p_ssid[128] = {0};
+ const char *get_ssid[] = {"nmcli", "-g", "802-11-wireless.ssid", "connection", "show", "uuid", uuid, NULL};
+ if (gemui_run_cmd_timeout(get_ssid, p_ssid, sizeof(p_ssid), 1200) == 0) {
+ size_t n = strlen(p_ssid);
+ while (n > 0 && (p_ssid[n - 1] == '\n' || p_ssid[n - 1] == '\r')) p_ssid[--n] = '\0';
+ if (strcmp(p_ssid, ssid) == 0) {
+ const char *del_u[] = {"nmcli", "connection", "delete", "uuid", uuid, NULL};
+ gemui_run_cmd_timeout(del_u, NULL, 0, 5000);
+ }
+ }
+ }
+}
+
+static int child_wifi_connect(void *ctx) {
+ wifi_job_t *j = ctx;
+ char out[512] = {0};
+ int cfg_rc = 0;
+
+ if (j->is_open || j->has_psk) {
+ wifi_delete_ssid_profiles(j->ssid);
+
+ const char *add[20];
+ int n = 0;
+ add[n++] = "nmcli";
+ add[n++] = "connection";
+ add[n++] = "add";
+ add[n++] = "type";
+ add[n++] = "wifi";
+ add[n++] = "con-name";
+ add[n++] = j->ssid;
+ add[n++] = "ifname";
+ add[n++] = "wlan0";
+ add[n++] = "ssid";
+ add[n++] = j->ssid;
+ if (!j->is_open) {
+ add[n++] = "wifi-sec.key-mgmt";
+ add[n++] = "wpa-psk";
+ add[n++] = "wifi-sec.pmf";
+ add[n++] = "disable";
+ add[n++] = "wifi-sec.psk";
+ add[n++] = j->psk;
+ }
+ add[n] = NULL;
+ cfg_rc = gemui_run_cmd_timeout(add, out, sizeof(out), 8000);
+ } else {
+ const char *mod[] = {"nmcli", "connection", "modify", "id", j->ssid,
+ "802-11-wireless.bssid", "", "wifi-sec.pmf", "disable", NULL};
+ cfg_rc = gemui_run_cmd_timeout(mod, out, sizeof(out), 5000);
+ }
+ memset(j->psk, 0, sizeof(j->psk));
+
+ int rc = cfg_rc;
+ if (rc == 0) {
+ if (j->bssid[0]) {
+ const char *wait_sec = (j->ap_count > 1) ? "14" : "16";
+ const char *up_ap[] = {"nmcli", "--wait", wait_sec, "connection", "up",
+ "id", j->ssid, "ifname", "wlan0", "ap", j->bssid, NULL};
+ out[0] = '\0';
+ rc = gemui_run_cmd_timeout(up_ap, out, sizeof(out), 20000);
+ }
+ if (rc != 0 || !j->bssid[0]) {
+ const char *up[] = {"nmcli", "--wait", "18", "connection", "up",
+ "id", j->ssid, "ifname", "wlan0", NULL};
+ out[0] = '\0';
+ rc = gemui_run_cmd_timeout(up, out, sizeof(out), 22000);
+ }
+ }
+ if (rc != 0 && out[0]) {
+ fputs(out, stdout);
+ }
+ return rc;
+}
+
+static int child_wifi_rescan(void *ctx) {
+ (void)ctx;
+ char out[256] = {0};
+ const char *argv[] = {"nmcli", "dev", "wifi", "rescan", NULL};
+ int rc = gemui_run_cmd_timeout(argv, out, sizeof(out), 8000);
+ if (rc != 0 && out[0]) fputs(out, stdout);
+ return rc;
+}
+
+typedef struct {
+ char mac[24];
+ bool enable;
+ bool paired;
+} bt_job_t;
+
+static int child_bt_power(void *ctx) {
+ bt_job_t *j = ctx;
+ char out[512] = {0};
+ if (j->enable) {
+ const char *unb[] = {"rfkill", "unblock", "bluetooth", NULL};
+ gemui_run_cmd_timeout(unb, NULL, 0, 1500);
+ const char *sh[] = {"bluetoothctl", "--timeout", "1", "show", NULL};
+ if (gemui_run_cmd_timeout(sh, out, sizeof(out), 1500) != 0 ||
+ !strstr(out, "Controller ")) {
+ const char *start[] = {"doas", "/sbin/rc-service", "bluetooth", "start", NULL};
+ gemui_run_cmd_timeout(start, out, sizeof(out), 6000);
+ }
+ const char *pon[] = {"bluetoothctl", "--timeout", "4", "power", "on", NULL};
+ int rc = gemui_run_cmd_timeout(pon, out, sizeof(out), 5000);
+ if (rc != 0 && out[0]) fputs(out, stdout);
+ return rc;
+ } else {
+ const char *poff[] = {"bluetoothctl", "--timeout", "3", "power", "off", NULL};
+ gemui_run_cmd_timeout(poff, NULL, 0, 3500);
+ const char *blk[] = {"rfkill", "block", "bluetooth", NULL};
+ return gemui_run_cmd_timeout(blk, NULL, 0, 1500);
+ }
+}
+
+static int child_bt_scan(void *ctx) {
+ (void)ctx;
+ const char *unb[] = {"rfkill", "unblock", "bluetooth", NULL};
+ gemui_run_cmd_timeout(unb, NULL, 0, 1500);
+ const char *pon[] = {"bluetoothctl", "--timeout", "3", "power", "on", NULL};
+ gemui_run_cmd_timeout(pon, NULL, 0, 3500);
+ const char *sc[] = {"bluetoothctl", "--timeout", "12", "scan", "on", NULL};
+ return gemui_run_cmd_timeout(sc, NULL, 0, 13000);
+}
+
+static int child_bt_connect(void *ctx) {
+ bt_job_t *j = ctx;
+ char out[512] = {0};
+ const char *tr[] = {"bluetoothctl", "--timeout", "4", "trust", j->mac, NULL};
+ gemui_run_cmd_timeout(tr, NULL, 0, 4500);
+ int rc = 0;
+ if (!j->paired) {
+ const char *pr[] = {"bluetoothctl", "--timeout", "18", "pair", j->mac, NULL};
+ out[0] = '\0';
+ rc = gemui_run_cmd_timeout(pr, out, sizeof(out), 19000);
+ if (rc != 0 && !strstr(out, "Already Exists")) {
+ if (out[0]) fputs(out, stdout);
+ return rc;
+ }
+ }
+ const char *cn[] = {"bluetoothctl", "--timeout", "15", "connect", j->mac, NULL};
+ out[0] = '\0';
+ rc = gemui_run_cmd_timeout(cn, out, sizeof(out), 16000);
+ if (rc != 0 && out[0]) fputs(out, stdout);
+ return rc;
+}
+
+static int child_bt_disconnect(void *ctx) {
+ bt_job_t *j = ctx;
+ char out[256] = {0};
+ const char *dc[] = {"bluetoothctl", "--timeout", "8", "disconnect", j->mac, NULL};
+ int rc = gemui_run_cmd_timeout(dc, out, sizeof(out), 9000);
+ if (rc != 0 && out[0]) fputs(out, stdout);
+ return rc;
+}
+
+static int child_bt_remove(void *ctx) {
+ bt_job_t *j = ctx;
+ char out[256] = {0};
+ const char *rm[] = {"bluetoothctl", "--timeout", "8", "remove", j->mac, NULL};
+ int rc = gemui_run_cmd_timeout(rm, out, sizeof(out), 9000);
+ if (rc != 0 && out[0]) fputs(out, stdout);
+ return rc;
+}
+
+static bool wifi_profile_exists(const char *ssid) {
+ char out[128] = {0};
+ const char *argv[] = {"nmcli", "-g", "connection.uuid", "connection", "show", "id", ssid, NULL};
+ return gemui_run_cmd_timeout(argv, out, sizeof(out), 900) == 0 && out[0] != '\0';
+}
+
+static void connect_selected_wifi(net_state_t *st) {
+ if (st->sel_row < 0 || st->sel_row >= st->num_rows) {
+ gemui_show_toast(st->app, "Select an SSID row first", 1600);
+ return;
+ }
+ const geminux_wifi_group_t *grp = &st->wifi_groups[st->sel_row];
+ bool is_open = (strcmp(grp->security, "Open") == 0 || grp->security[0] == '\0');
+ bool has_psk = (st->psk[0] != '\0');
+
+ if (!is_open) {
+ if (!has_psk && !wifi_profile_exists(grp->ssid)) {
+ gemui_show_toast(st->app, "Enter Wi-Fi passphrase first", 2000);
+ st->focus_psk = true;
+ gemui_request_redraw(st->app);
+ return;
+ }
+ if (has_psk && strlen(st->psk) < 8) {
+ gemui_show_toast(st->app, "Passphrase must be at least 8 characters", 2200);
+ st->focus_psk = true;
+ gemui_request_redraw(st->app);
+ return;
+ }
+ }
+
+ wifi_job_t job;
+ memset(&job, 0, sizeof(job));
+ snprintf(job.ssid, sizeof(job.ssid), "%s", grp->ssid);
+ snprintf(job.bssid, sizeof(job.bssid), "%s", grp->best_bssid);
+ snprintf(job.psk, sizeof(job.psk), "%s", st->psk);
+ job.ap_count = grp->ap_count;
+ job.is_open = is_open;
+ job.has_psk = has_psk;
+ start_worker(st, WORK_WIFI_CONN, "Connecting to Wi-Fi...", 48000, child_wifi_connect, &job);
+ memset(&job, 0, sizeof(job));
+}
+
+static void start_bt_dev_action(net_state_t *st, int kind) {
+ if (st->sel_row < 0 || st->sel_row >= st->num_rows) {
+ gemui_show_toast(st->app, "Select a Bluetooth device first", 1600);
+ return;
+ }
+ bt_job_t job;
+ memset(&job, 0, sizeof(job));
+ snprintf(job.mac, sizeof(job.mac), "%s", st->bt_devs[st->sel_row].mac);
+ job.paired = st->bt_devs[st->sel_row].paired;
+ if (kind == WORK_BT_CONN) {
+ start_worker(st, WORK_BT_CONN, "Pairing & connecting Bluetooth...", 38000, child_bt_connect, &job);
+ } else if (kind == WORK_BT_DISC) {
+ start_worker(st, WORK_BT_DISC, "Disconnecting Bluetooth device...", 10000, child_bt_disconnect, &job);
+ } else {
+ start_worker(st, WORK_BT_REM, "Removing Bluetooth device...", 10000, child_bt_remove, &job);
+ }
+}
+
static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
net_state_t *st = ud;
const gemui_theme_t *t = gemui_theme(app);
- gemui_draw_header(app, cr, "\xef\x87\xab", "Geminux Network & Radios", st->status_text);
+ char badge[280];
+ if (st->worker_pid > 0) {
+ int sec = (st->worker_tick + 1) / 2;
+ snprintf(badge, sizeof(badge), "%s (%ds)", st->worker_label, sec);
+ } else {
+ snprintf(badge, sizeof(badge), "%s", st->status_text);
+ }
+ gemui_draw_header(app, cr, "\xef\x87\xab", "Geminux Network & Radios", badge);
int pad = 20;
int top = 92;
@@ -131,8 +713,9 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
if (st->tab == 0) {
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 72},
"Wi-Fi Radio", st->wifi_on, HIT_TOGGLE, 0, false);
+ const char *act_lbl = (st->worker_pid > 0) ? "Cancel Operation" : "Rescan Networks";
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 72},
- "Rescan Networks", HIT_ACTION, 0, true, false, false);
+ act_lbl, HIT_ACTION, 0, st->worker_pid == 0, st->worker_pid > 0, false);
} else if (st->tab == 1) {
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 72},
"MT6797 Modem Active", st->cellular_on, HIT_TOGGLE, 1, false);
@@ -141,8 +724,10 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
} else if (st->tab == 2) {
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 72},
"Bluetooth Radio", st->bt_on, HIT_TOGGLE, 2, false);
+ const char *bt_lbl = (st->worker_kind == WORK_BT_SCAN) ? "Stop Scan"
+ : (st->worker_pid > 0) ? "Cancel Operation" : "Scan 12s";
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 72},
- "Scan 10s", HIT_ACTION, 2, true, false, false);
+ bt_lbl, HIT_ACTION, 2, st->worker_pid == 0, st->worker_pid > 0, false);
} else {
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 72},
"SiI9024 HDMI Extend", st->hdmi_on, HIT_TOGGLE, 3, false);
@@ -150,29 +735,32 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
"Mirror Primary Display", HIT_ACTION, 3, true, false, false);
}
- int foot_h = (st->tab == 0) ? 94 : 0;
+ int foot_h = (st->tab == 0 || st->tab == 2) ? 94 : 0;
gemui_rect_t box = {pad, cy + 88, w - pad * 2, h - (cy + 88) - pad - foot_h};
gemui_fill_round(cr, box, 12, t->bg_bar);
gemui_stroke_round(cr, box, 12, 1.5, t->border);
if (st->num_rows == 0) {
- gemui_draw_text(cr, t, box, "No interfaces or scan results available", 0, false,
- GEMUI_ALIGN_CENTER, t->fg_muted);
+ const char *empty_msg = (st->tab == 2 && st->bt_svc_up)
+ ? "No Bluetooth devices found — press Scan 12s"
+ : "No interfaces or scan results available";
+ gemui_draw_text(cr, t, box, empty_msg, 0, false, GEMUI_ALIGN_CENTER, t->fg_muted);
} else {
int rh = 72;
- for (int i = 0; i < st->num_rows; i++) {
- gemui_rect_t rr = {box.x + 10, box.y + 8 + i * rh, box.w - 20, rh - 6};
+ for (int vis = 0; st->scroll_off + vis < st->num_rows; vis++) {
+ int i = st->scroll_off + vis;
+ gemui_rect_t rr = {box.x + 10, box.y + 8 + vis * rh, box.w - 20, rh - 6};
if (rr.y + rr.h > box.y + box.h) break;
bool sel = (i == st->sel_row);
gemui_fill_round(cr, rr, 10, sel ? t->sel_bg : (i % 2 ? t->bg_alt_odd : t->bg_alt_even));
- gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 16, rr.y, rr.w - 360, rr.h},
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 16, rr.y, rr.w - 460, rr.h},
st->rows[i].col1, -1, true, GEMUI_ALIGN_LEFT,
sel ? t->sel_fg : t->fg_bright);
- gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 340, rr.y, 190, rr.h},
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 440, rr.y, 210, rr.h},
st->rows[i].col2, -2, false, GEMUI_ALIGN_RIGHT,
sel ? t->sel_fg : t->accent_alt);
- gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 140, rr.y, 126, rr.h},
- st->rows[i].col3, -2, false, GEMUI_ALIGN_RIGHT,
+ gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 220, rr.y, 206, rr.h},
+ st->rows[i].col3, -3, false, GEMUI_ALIGN_RIGHT,
sel ? t->sel_fg : t->fg_muted);
gemui_hit_add(app, rr, HIT_ROW, i);
}
@@ -180,50 +768,59 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
if (st->tab == 0) {
int cw = 260;
- gemui_draw_input(app, cr, (gemui_rect_t){pad, h - 92, w - pad * 2 - cw - 12, 72},
+ int sw = 200;
+ int iw = w - pad * 2 - cw - sw - 24;
+ gemui_draw_input(app, cr, (gemui_rect_t){pad, h - 92, iw, 72},
"Wi-Fi passphrase (if connecting to secured SSID)...",
- st->psk, true, st->focus_psk, HIT_PSK, 0);
+ st->psk, !st->show_psk, st->focus_psk, HIT_PSK, 0);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + iw + 12, h - 92, sw, 72},
+ st->show_psk ? "Hide PW" : "Show PW", HIT_SHOW_PSK, 0,
+ false, st->show_psk, false);
gemui_draw_button(app, cr, (gemui_rect_t){w - pad - cw, h - 92, cw, 72},
"Connect Wi-Fi", HIT_CONNECT, 0, true, false, false);
+ } else if (st->tab == 2) {
+ int bw = (w - pad * 2 - 3 * 12) / 4;
+ gemui_draw_button(app, cr, (gemui_rect_t){pad, h - 92, bw, 72},
+ "Pair & Connect", HIT_BT_CONN, 0, true, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + bw + 12, h - 92, bw, 72},
+ "Disconnect", HIT_BT_DISC, 0, false, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + 2 * (bw + 12), h - 92, bw, 72},
+ "Forget Device", HIT_BT_REM, 0, false, false, false);
+ gemui_draw_button(app, cr, (gemui_rect_t){pad + 3 * (bw + 12), h - 92, bw, 72},
+ "Sound & Mixer", HIT_AUDIO, 0, false, false, false);
}
}
-static void connect_selected_wifi(net_state_t *st) {
- if (st->sel_row < 0 || st->sel_row >= st->num_rows) {
- gemui_show_toast(st->app, "Select an SSID row first", 1600);
- return;
- }
- const char *ssid = st->rows[st->sel_row].col1;
- if (ssid[0] == '*' && ssid[1] == ' ') ssid += 2;
- char out[256] = {0};
- int rc;
- if (st->psk[0]) {
- const char *argv[] = {"nmcli", "dev", "wifi", "connect", ssid, "password", st->psk, NULL};
- rc = gemui_run_cmd_capture(argv, out, sizeof(out));
- } else {
- const char *argv[] = {"nmcli", "dev", "wifi", "connect", ssid, NULL};
- rc = gemui_run_cmd_capture(argv, out, sizeof(out));
- }
- gemui_show_toast(st->app, rc == 0 ? "Connected to Wi-Fi" : "Wi-Fi connect failed", 2200);
- refresh_tab(st);
- gemui_request_redraw(st->app);
-}
-
static void on_key(gemui_app_t *app, KeySym ks, unsigned int state, const char *utf8, void *ud) {
- (void)state;
net_state_t *st = ud;
if (ks == XK_Escape) {
gemui_quit(app, 0);
} else if (ks == XK_Tab) {
st->tab = (st->tab + 1) % 4;
+ st->focus_psk = false;
refresh_tab(st);
gemui_request_redraw(app);
- } else if (ks == XK_Return && st->tab == 0) {
- connect_selected_wifi(st);
- } else if (ks == XK_BackSpace && st->focus_psk) {
+ } else if (ks == XK_Up && st->num_rows > 0) {
+ st->sel_row = (st->sel_row > 0) ? st->sel_row - 1 : 0;
+ net_clamp_scroll(st);
+ gemui_request_redraw(app);
+ } else if (ks == XK_Down && st->num_rows > 0) {
+ st->sel_row = (st->sel_row + 1 < st->num_rows) ? st->sel_row + 1 : st->num_rows - 1;
+ net_clamp_scroll(st);
+ gemui_request_redraw(app);
+ } else if (ks == XK_Return || ks == XK_KP_Enter) {
+ if (st->tab == 0) connect_selected_wifi(st);
+ else if (st->tab == 2) start_bt_dev_action(st, WORK_BT_CONN);
+ } else if ((ks == XK_BackSpace || ks == XK_Delete) && st->tab == 0 && (st->focus_psk || st->sel_row >= 0)) {
+ st->focus_psk = true;
gemui_utf8_pop_char(st->psk);
gemui_request_redraw(app);
- } else if (st->focus_psk && utf8 && utf8[0]) {
+ } else if ((state & ControlMask) && (ks == XK_u || ks == XK_U) && st->tab == 0) {
+ st->focus_psk = true;
+ memset(st->psk, 0, sizeof(st->psk));
+ gemui_request_redraw(app);
+ } else if (st->tab == 0 && (st->focus_psk || st->sel_row >= 0) && utf8 && utf8[0]) {
+ st->focus_psk = true;
size_t cur = strlen(st->psk), add = strlen(utf8);
if (cur + add < sizeof(st->psk)) {
memcpy(st->psk + cur, utf8, add + 1);
@@ -235,6 +832,19 @@ static void on_key(gemui_app_t *app, KeySym ks, unsigned int state, const char *
static void on_ptr(gemui_app_t *app, int type, int x, int y, unsigned int btn, void *ud) {
(void)btn;
net_state_t *st = ud;
+ if (type == GEMUI_PTR_SCROLL_UP) {
+ if (st->scroll_off > 0) {
+ st->scroll_off--;
+ gemui_request_redraw(app);
+ }
+ return;
+ }
+ if (type == GEMUI_PTR_SCROLL_DOWN) {
+ st->scroll_off++;
+ net_clamp_scroll(st);
+ gemui_request_redraw(app);
+ return;
+ }
if (type != GEMUI_PTR_DOWN) return;
const gemui_hit_t *hit = gemui_hit_test(app, x, y);
if (!hit) return;
@@ -245,44 +855,75 @@ static void on_ptr(gemui_app_t *app, int type, int x, int y, unsigned int btn, v
refresh_tab(st);
} else if (hit->id == HIT_ROW) {
st->sel_row = hit->val;
+ if (st->tab == 0) st->focus_psk = true;
} else if (hit->id == HIT_PSK) {
st->focus_psk = true;
+ } else if (hit->id == HIT_SHOW_PSK) {
+ st->show_psk = !st->show_psk;
+ st->focus_psk = true;
} else if (hit->id == HIT_CONNECT) {
connect_selected_wifi(st);
return;
+ } else if (hit->id == HIT_BT_CONN) {
+ start_bt_dev_action(st, WORK_BT_CONN);
+ return;
+ } else if (hit->id == HIT_BT_DISC) {
+ start_bt_dev_action(st, WORK_BT_DISC);
+ return;
+ } else if (hit->id == HIT_BT_REM) {
+ start_bt_dev_action(st, WORK_BT_REM);
+ return;
+ } else if (hit->id == HIT_AUDIO) {
+ const char *acmd[] = {"geminux-audio", NULL};
+ gemui_spawn_detached(acmd);
+ return;
} else if (hit->id == HIT_TOGGLE) {
if (hit->val == 0) {
const char *argv[] = {"nmcli", "radio", "wifi", st->wifi_on ? "off" : "on", NULL};
- gemui_run_cmd_capture(argv, NULL, 0);
+ gemui_run_cmd_timeout(argv, NULL, 0, 2000);
+ refresh_tab(st);
} else if (hit->val == 1) {
gemui_unix_cmd("/run/geminux/ccci.sock",
st->cellular_on ? "flight on" : "flight off", NULL, 0);
+ refresh_tab(st);
} else if (hit->val == 2) {
- const char *argv[] = {"rfkill", st->bt_on ? "block" : "unblock", "bluetooth", NULL};
- gemui_run_cmd_capture(argv, NULL, 0);
+ bt_job_t job;
+ memset(&job, 0, sizeof(job));
+ job.enable = !st->bt_on;
+ start_worker(st, WORK_BT_PWR,
+ job.enable ? "Enabling Bluetooth..." : "Disabling Bluetooth...",
+ 10000, child_bt_power, &job);
+ return;
} else if (hit->val == 3) {
const char *argv[] = {"xrandr", "--output", "HDMI-1", st->hdmi_on ? "--off" : "--auto", NULL};
- gemui_run_cmd_capture(argv, NULL, 0);
+ gemui_run_cmd_timeout(argv, NULL, 0, 2000);
st->hdmi_on = !st->hdmi_on;
+ refresh_tab(st);
}
- refresh_tab(st);
} else if (hit->id == HIT_ACTION) {
if (hit->val == 0) {
- const char *argv[] = {"nmcli", "dev", "wifi", "rescan", NULL};
- gemui_run_cmd_capture(argv, NULL, 0);
- gemui_show_toast(app, "Rescanning Wi-Fi...", 1400);
+ if (st->worker_pid > 0) {
+ cancel_worker(st, "Cancelled operation");
+ } else {
+ start_worker(st, WORK_WIFI_SCAN, "Rescanning Wi-Fi...", 10000, child_wifi_rescan, NULL);
+ }
+ return;
} else if (hit->val == 1) {
gemui_unix_cmd("/run/geminux/ccci.sock", "reset", NULL, 0);
gemui_show_toast(app, "Sent CCCI reset request", 1600);
+ refresh_tab(st);
} else if (hit->val == 2) {
- const char *argv[] = {"bluetoothctl", "--timeout", "10", "scan", "on", NULL};
- gemui_spawn_detached(argv);
- gemui_show_toast(app, "Bluetooth discovery active (10s)", 1800);
+ if (st->worker_pid > 0) {
+ cancel_worker(st, st->worker_kind == WORK_BT_SCAN ? "Bluetooth scan stopped" : "Cancelled");
+ } else {
+ start_worker(st, WORK_BT_SCAN, "Scanning Bluetooth (12s)...", 15000, child_bt_scan, NULL);
+ }
+ return;
} else if (hit->val == 3) {
const char *argv[] = {"xrandr", "--output", "HDMI-1", "--same-as", "DSI-1", NULL};
- gemui_run_cmd_capture(argv, NULL, 0);
+ gemui_run_cmd_timeout(argv, NULL, 0, 2000);
+ refresh_tab(st);
}
- refresh_tab(st);
}
gemui_request_redraw(app);
}
@@ -291,6 +932,7 @@ int main(void) {
net_state_t st;
memset(&st, 0, sizeof(st));
st.sel_row = -1;
+ st.worker_fd = -1;
refresh_tab(&st);
st.app = gemui_create("geminux-net", "Geminux Network & Radios", 1920, 940, false);
@@ -299,6 +941,13 @@ int main(void) {
gemui_handlers_t h = { .on_draw = on_draw, .on_key = on_key, .on_ptr = on_ptr };
gemui_set_handlers(st.app, &h, &st);
int rc = gemui_run(st.app);
+ if (st.worker_pid > 0) {
+ kill(-st.worker_pid, SIGTERM);
+ kill(st.worker_pid, SIGTERM);
+ waitpid(st.worker_pid, NULL, 0);
+ }
+ if (st.worker_fd >= 0) close(st.worker_fd);
+ memset(st.psk, 0, sizeof(st.psk));
gemui_destroy(st.app);
return rc;
}
diff --git a/src/geminux-apps/geminux-wifi-list.h b/src/geminux-apps/geminux-wifi-list.h
new file mode 100644
index 0000000..be59a5f
--- /dev/null
+++ b/src/geminux-apps/geminux-wifi-list.h
@@ -0,0 +1,144 @@
+/*
+ * Header-only C11 helpers for parsing and grouping nmcli terse Wi-Fi scans
+ * (deduplicating mesh BSSIDs per SSID and selecting the best joinable AP).
+ */
+#ifndef GEMINUX_WIFI_LIST_H
+#define GEMINUX_WIFI_LIST_H
+
+#include
+#include
+#include
+#include
+
+#define GEMINUX_MAX_WIFI_GROUPS 32
+
+typedef struct {
+ char ssid[96];
+ char best_bssid[24];
+ char security[48];
+ int best_signal;
+ int best_chan;
+ int ap_count;
+ bool best_joinable;
+ bool in_use;
+} geminux_wifi_group_t;
+
+static inline int geminux_split_nmcli_terse(char *line, char **fields, int max_fields) {
+ if (!line || !fields || max_fields <= 0) return 0;
+ int count = 0;
+ fields[count++] = line;
+ char *rd = line;
+ char *wr = line;
+ while (*rd) {
+ if (rd[0] == '\\' && (rd[1] == ':' || rd[1] == '\\')) {
+ *wr++ = rd[1];
+ rd += 2;
+ } else if (rd[0] == ':' && count < max_fields) {
+ *wr++ = '\0';
+ fields[count++] = wr;
+ rd++;
+ } else {
+ *wr++ = *rd++;
+ }
+ }
+ *wr = '\0';
+ return count;
+}
+
+static inline bool geminux_wifi_chan_joinable(int chan) {
+ return (chan >= 1 && chan <= 13) ||
+ (chan >= 36 && chan <= 48) ||
+ (chan >= 149 && chan <= 165);
+}
+
+static inline int geminux_wifi_group_cmp(const void *pa, const void *pb) {
+ const geminux_wifi_group_t *a = (const geminux_wifi_group_t *)pa;
+ const geminux_wifi_group_t *b = (const geminux_wifi_group_t *)pb;
+ if (a->in_use != b->in_use) return b->in_use ? 1 : -1;
+ if (a->best_signal != b->best_signal) return (b->best_signal > a->best_signal) ? 1 : -1;
+ return strcmp(a->ssid, b->ssid);
+}
+
+static inline int geminux_parse_wifi_scan(const char *nmcli_out,
+ geminux_wifi_group_t *groups,
+ int max_groups) {
+ if (!nmcli_out || !groups || max_groups <= 0) return 0;
+
+ int n = 0;
+ const char *cur = nmcli_out;
+ while (*cur) {
+ const char *nl = strchr(cur, '\n');
+ size_t raw_len = nl ? (size_t)(nl - cur) : strlen(cur);
+ char ln[512];
+ size_t l = raw_len < sizeof(ln) - 1 ? raw_len : sizeof(ln) - 1;
+ memcpy(ln, cur, l);
+ ln[l] = '\0';
+ cur = nl ? nl + 1 : cur + raw_len;
+
+ while (l > 0 && ln[l - 1] == '\r') ln[--l] = '\0';
+ if (!ln[0]) continue;
+
+ char *fields[6] = {0};
+ if (geminux_split_nmcli_terse(ln, fields, 6) < 6) continue;
+
+ const char *inuse = fields[0];
+ const char *bssid = fields[1];
+ const char *ssid = fields[2];
+ int chan = atoi(fields[3]);
+ int sig = atoi(fields[4]);
+ const char *sec = fields[5];
+ if (!ssid[0]) continue;
+ if (!sec[0] || strcmp(sec, "--") == 0) sec = "Open";
+
+ bool active = (inuse[0] == '*');
+ bool joinable = geminux_wifi_chan_joinable(chan);
+
+ int idx = -1;
+ for (int i = 0; i < n; i++) {
+ if (strcmp(groups[i].ssid, ssid) == 0) {
+ idx = i;
+ break;
+ }
+ }
+
+ if (idx < 0) {
+ if (n >= max_groups) continue;
+ geminux_wifi_group_t *g = &groups[n++];
+ memset(g, 0, sizeof(*g));
+ snprintf(g->ssid, sizeof(g->ssid), "%s", ssid);
+ snprintf(g->best_bssid, sizeof(g->best_bssid), "%s", bssid);
+ snprintf(g->security, sizeof(g->security), "%s", sec);
+ g->best_signal = sig;
+ g->best_chan = chan;
+ g->best_joinable = joinable;
+ g->ap_count = 1;
+ g->in_use = active;
+ } else {
+ geminux_wifi_group_t *g = &groups[idx];
+ g->ap_count++;
+ if (active) g->in_use = true;
+ if (strcmp(g->security, "Open") == 0 && strcmp(sec, "Open") != 0) {
+ snprintf(g->security, sizeof(g->security), "%s", sec);
+ }
+ bool better = false;
+ if (joinable && !g->best_joinable) {
+ better = true;
+ } else if (joinable == g->best_joinable) {
+ if (sig > g->best_signal) better = true;
+ else if (sig == g->best_signal && chan >= 36 && g->best_chan < 36) better = true;
+ }
+ if (better) {
+ snprintf(g->best_bssid, sizeof(g->best_bssid), "%s", bssid);
+ g->best_signal = sig;
+ g->best_chan = chan;
+ g->best_joinable = joinable;
+ snprintf(g->security, sizeof(g->security), "%s", sec);
+ }
+ }
+ }
+
+ if (n > 1) qsort(groups, (size_t)n, sizeof(groups[0]), geminux_wifi_group_cmp);
+ return n;
+}
+
+#endif /* GEMINUX_WIFI_LIST_H */
diff --git a/src/geminux-daemons/Makefile b/src/geminux-daemons/Makefile
index ed888c7..6f10d7e 100644
--- a/src/geminux-daemons/Makefile
+++ b/src/geminux-daemons/Makefile
@@ -22,7 +22,8 @@ BINS = \
geminux-bt-obex \
geminux-leds \
geminux-power-audit \
- geminux-checkpw
+ geminux-checkpw \
+ geminux-wifi-nvram
all: $(BINS)
@@ -56,12 +57,15 @@ geminux-power-audit: geminux-power-audit.c
geminux-checkpw: geminux-checkpw.c
$(CC) $(CFLAGS) -o $@ $<
+geminux-wifi-nvram: geminux-wifi-nvram.c geminux-wifi-nvram-core.c geminux-wifi-nvram-core.h
+ $(CC) $(CFLAGS) -o $@ geminux-wifi-nvram.c geminux-wifi-nvram-core.c
+
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/sbin
cp -f geminux-power-ctl geminux-statusd geminux-touchd geminux-modem-ctl \
geminux-bt-obex geminux-power-audit $(DESTDIR)$(PREFIX)/bin/
cp -f geminux-powerd geminux-ccci-daemon geminux-leds \
- geminux-checkpw $(DESTDIR)$(PREFIX)/sbin/
+ geminux-checkpw geminux-wifi-nvram $(DESTDIR)$(PREFIX)/sbin/
chmod 0755 $(DESTDIR)$(PREFIX)/bin/geminux-* $(DESTDIR)$(PREFIX)/sbin/geminux-*
clean:
diff --git a/src/geminux-daemons/geminux-bt-obex.c b/src/geminux-daemons/geminux-bt-obex.c
index 373e022..d981882 100644
--- a/src/geminux-daemons/geminux-bt-obex.c
+++ b/src/geminux-daemons/geminux-bt-obex.c
@@ -1,10 +1,53 @@
#define _POSIX_C_SOURCE 200809L
#include
+#include
#include
+#include
#include
#include
+#define GEMINUX_BT_AGENT_PATH "/org/geminux/bt_agent"
+
static GMainLoop *g_loop = NULL;
+static GDBusConnection *g_sys = NULL;
+static GDBusNodeInfo *g_agent_introspection = NULL;
+static guint g_agent_reg_id = 0;
+
+static const gchar g_agent_xml[] =
+ ""
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
+ "";
static void notify_event(const char *title, const char *body) {
const char *argv[] = {"notify-send", title, body, NULL};
@@ -12,6 +55,78 @@ static void notify_event(const char *title, const char *body) {
NULL, NULL, NULL, NULL);
}
+static void on_agent_call(GDBusConnection *conn, const gchar *sender,
+ const gchar *obj_path, const gchar *iface_name,
+ const gchar *method_name, GVariant *params,
+ GDBusMethodInvocation *inv, gpointer ud) {
+ (void)conn; (void)sender; (void)obj_path; (void)iface_name; (void)ud;
+ if (strcmp(method_name, "RequestPinCode") == 0) {
+ notify_event("Bluetooth Pairing", "Using PIN 0000 for device pairing");
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(s)", "0000"));
+ } else if (strcmp(method_name, "DisplayPinCode") == 0) {
+ const gchar *dev = NULL, *pin = NULL;
+ g_variant_get(params, "(&o&s)", &dev, &pin);
+ char msg[160];
+ snprintf(msg, sizeof(msg), "Type PIN %s + Enter on device", pin ? pin : "0000");
+ notify_event("Bluetooth Pairing PIN", msg);
+ g_dbus_method_invocation_return_value(inv, NULL);
+ } else if (strcmp(method_name, "RequestPasskey") == 0) {
+ g_dbus_method_invocation_return_value(inv, g_variant_new("(u)", (guint32)0));
+ } else if (strcmp(method_name, "DisplayPasskey") == 0) {
+ const gchar *dev = NULL;
+ guint32 passkey = 0;
+ guint16 entered = 0;
+ g_variant_get(params, "(&ouq)", &dev, &passkey, &entered);
+ if (entered == 0) {
+ char msg[160];
+ snprintf(msg, sizeof(msg), "Type passkey %06" PRIu32 " + Enter on device", passkey);
+ notify_event("Bluetooth Passkey", msg);
+ }
+ g_dbus_method_invocation_return_value(inv, NULL);
+ } else if (strcmp(method_name, "RequestConfirmation") == 0) {
+ const gchar *dev = NULL;
+ guint32 passkey = 0;
+ g_variant_get(params, "(&ou)", &dev, &passkey);
+ char msg[160];
+ snprintf(msg, sizeof(msg), "Confirmed pairing passkey %06" PRIu32, passkey);
+ notify_event("Bluetooth Pairing", msg);
+ g_dbus_method_invocation_return_value(inv, NULL);
+ } else {
+ if (strcmp(method_name, "Cancel") == 0) {
+ notify_event("Bluetooth Pairing", "Pairing cancelled");
+ }
+ g_dbus_method_invocation_return_value(inv, NULL);
+ }
+}
+
+static const GDBusInterfaceVTable g_agent_vtable = {
+ .method_call = on_agent_call,
+};
+
+static void on_agent_registered(GObject *src, GAsyncResult *res, gpointer ud) {
+ (void)ud;
+ GVariant *ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(src), res, NULL);
+ if (ret) {
+ g_variant_unref(ret);
+ g_dbus_connection_call(
+ G_DBUS_CONNECTION(src), "org.bluez", "/org/bluez",
+ "org.bluez.AgentManager1", "RequestDefaultAgent",
+ g_variant_new("(o)", GEMINUX_BT_AGENT_PATH), NULL,
+ G_DBUS_CALL_FLAGS_NONE, 3000, NULL, NULL, NULL);
+ }
+}
+
+static void on_bluez_appeared(GDBusConnection *conn, const gchar *name,
+ const gchar *owner, gpointer ud) {
+ (void)name; (void)owner; (void)ud;
+ if (!g_agent_reg_id) return;
+ g_dbus_connection_call(
+ conn, "org.bluez", "/org/bluez",
+ "org.bluez.AgentManager1", "RegisterAgent",
+ g_variant_new("(os)", GEMINUX_BT_AGENT_PATH, "KeyboardDisplay"), NULL,
+ G_DBUS_CALL_FLAGS_NONE, 3000, NULL, on_agent_registered, NULL);
+}
+
static void on_bluez_props(GDBusConnection *conn, const gchar *sender,
const gchar *obj_path, const gchar *iface_name,
const gchar *signal_name, GVariant *params,
@@ -55,10 +170,20 @@ int main(void) {
signal(SIGCHLD, SIG_IGN);
g_loop = g_main_loop_new(NULL, FALSE);
- GDBusConnection *sys = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
- if (sys) {
+ g_sys = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+ guint watch_id = 0;
+ if (g_sys) {
+ g_agent_introspection = g_dbus_node_info_new_for_xml(g_agent_xml, NULL);
+ if (g_agent_introspection) {
+ g_agent_reg_id = g_dbus_connection_register_object(
+ g_sys, GEMINUX_BT_AGENT_PATH, g_agent_introspection->interfaces[0],
+ &g_agent_vtable, NULL, NULL, NULL);
+ }
+ watch_id = g_bus_watch_name_on_connection(
+ g_sys, "org.bluez", G_BUS_NAME_WATCHER_FLAGS_NONE,
+ on_bluez_appeared, NULL, NULL, NULL);
g_dbus_connection_signal_subscribe(
- sys, "org.bluez", "org.freedesktop.DBus.Properties",
+ g_sys, "org.bluez", "org.freedesktop.DBus.Properties",
"PropertiesChanged", NULL, "org.bluez.Device1",
G_DBUS_SIGNAL_FLAGS_NONE, on_bluez_props, NULL, NULL);
}
@@ -71,7 +196,10 @@ int main(void) {
}
g_main_loop_run(g_loop);
- if (sys) g_object_unref(sys);
+ if (watch_id) g_bus_unwatch_name(watch_id);
+ if (g_sys && g_agent_reg_id) g_dbus_connection_unregister_object(g_sys, g_agent_reg_id);
+ if (g_agent_introspection) g_dbus_node_info_unref(g_agent_introspection);
+ if (g_sys) g_object_unref(g_sys);
if (ses) g_object_unref(ses);
g_main_loop_unref(g_loop);
return 0;
diff --git a/src/geminux-daemons/geminux-wifi-nvram-core.c b/src/geminux-daemons/geminux-wifi-nvram-core.c
new file mode 100644
index 0000000..62bb133
--- /dev/null
+++ b/src/geminux-daemons/geminux-wifi-nvram-core.c
@@ -0,0 +1,105 @@
+#include "geminux-wifi-nvram-core.h"
+
+#include
+
+static uint16_t read_le16(const uint8_t *p) {
+ return (uint16_t)p[0] | ((uint16_t)p[1] << 8);
+}
+
+uint8_t geminux_wifi_nvram_checksum(const uint8_t *rec512) {
+ uint8_t check = 0;
+ for (size_t i = 0; i < GEMINUX_WIFI_RECORD_BYTES; i++) {
+ check = (uint8_t)((i & 1U) ? (check ^ rec512[i]) : (check + rec512[i]));
+ }
+ return check;
+}
+
+bool geminux_wifi_nvram_has_valid_mac(const uint8_t *rec512) {
+ if (!rec512) return false;
+ /* Multicast bit must be clear (unicast address required by IEEE 802.11). */
+ if (rec512[4] & 0x01U) return false;
+ uint8_t or_acc = 0;
+ uint8_t and_acc = 0xffU;
+ for (size_t i = 4; i < 10; i++) {
+ or_acc |= rec512[i];
+ and_acc &= rec512[i];
+ }
+ return or_acc != 0 && and_acc != 0xffU;
+}
+
+bool geminux_wifi_nvram_valid_record(const uint8_t *buf, size_t len, bool require_mac) {
+ if (!buf || len != GEMINUX_WIFI_STORAGE_BYTES) return false;
+ if (buf[512] != 0xaaU) return false;
+ if (geminux_wifi_nvram_checksum(buf) != buf[513]) return false;
+ if (read_le16(buf + 2) > 0x0200U || read_le16(buf + 258) > 0x0200U) return false;
+ if (buf[83] || buf[104] || buf[155] || buf[266]) return false;
+ if (require_mac && !geminux_wifi_nvram_has_valid_mac(buf)) return false;
+ return true;
+}
+
+void geminux_wifi_nvram_apply_fallback_mac(uint8_t buf514[GEMINUX_WIFI_STORAGE_BYTES],
+ const char *seed_str) {
+ uint64_t h = 14695981039346656037ULL;
+ if (seed_str && seed_str[0]) {
+ for (const unsigned char *p = (const unsigned char *)seed_str; *p; p++) {
+ h ^= (uint64_t)(*p);
+ h *= 1099511628211ULL;
+ }
+ } else {
+ h ^= 0x6797a115ULL;
+ }
+ buf514[4] = 0x02U;
+ buf514[5] = (uint8_t)(h >> 8);
+ buf514[6] = (uint8_t)(h >> 16);
+ buf514[7] = (uint8_t)(h >> 24);
+ buf514[8] = (uint8_t)(h >> 32);
+ buf514[9] = (uint8_t)(h >> 40);
+ if ((buf514[5] | buf514[6] | buf514[7] | buf514[8] | buf514[9]) == 0) {
+ buf514[5] = 0x67U;
+ buf514[9] = 0x97U;
+ }
+ buf514[512] = 0xaaU;
+ buf514[513] = geminux_wifi_nvram_checksum(buf514);
+}
+
+bool geminux_wifi_nvram_scan_blob(const uint8_t *blob, size_t blob_len,
+ uint8_t out514[GEMINUX_WIFI_STORAGE_BYTES],
+ bool *has_valid_mac_out) {
+ if (has_valid_mac_out) *has_valid_mac_out = false;
+ if (!blob || !out514 || blob_len < GEMINUX_WIFI_STORAGE_BYTES) return false;
+
+ if (blob_len >= (size_t)GEMINUX_WIFI_NVRAM_FAST_OFFSET + GEMINUX_WIFI_STORAGE_BYTES) {
+ const uint8_t *fast = blob + GEMINUX_WIFI_NVRAM_FAST_OFFSET;
+ if (fast[0] == 0x06U && fast[1] == 0x01U &&
+ geminux_wifi_nvram_valid_record(fast, GEMINUX_WIFI_STORAGE_BYTES, true)) {
+ memcpy(out514, fast, GEMINUX_WIFI_STORAGE_BYTES);
+ if (has_valid_mac_out) *has_valid_mac_out = true;
+ return true;
+ }
+ }
+
+ bool have_backup = false;
+ uint8_t backup[GEMINUX_WIFI_STORAGE_BYTES];
+ size_t limit = blob_len - GEMINUX_WIFI_STORAGE_BYTES;
+ for (size_t off = 0; off <= limit; off++) {
+ const uint8_t *cand = blob + off;
+ if (cand[0] != 0x06U || cand[1] != 0x01U || cand[512] != 0xaaU) continue;
+ if (geminux_wifi_nvram_valid_record(cand, GEMINUX_WIFI_STORAGE_BYTES, true)) {
+ memcpy(out514, cand, GEMINUX_WIFI_STORAGE_BYTES);
+ if (has_valid_mac_out) *has_valid_mac_out = true;
+ return true;
+ }
+ if (!have_backup &&
+ geminux_wifi_nvram_valid_record(cand, GEMINUX_WIFI_STORAGE_BYTES, false)) {
+ memcpy(backup, cand, GEMINUX_WIFI_STORAGE_BYTES);
+ have_backup = true;
+ }
+ }
+
+ if (have_backup) {
+ memcpy(out514, backup, GEMINUX_WIFI_STORAGE_BYTES);
+ if (has_valid_mac_out) *has_valid_mac_out = false;
+ return true;
+ }
+ return false;
+}
diff --git a/src/geminux-daemons/geminux-wifi-nvram-core.h b/src/geminux-daemons/geminux-wifi-nvram-core.h
new file mode 100644
index 0000000..c7b0b23
--- /dev/null
+++ b/src/geminux-daemons/geminux-wifi-nvram-core.h
@@ -0,0 +1,21 @@
+#ifndef GEMINUX_WIFI_NVRAM_CORE_H
+#define GEMINUX_WIFI_NVRAM_CORE_H
+
+#include
+#include
+#include
+
+#define GEMINUX_WIFI_RECORD_BYTES 512U
+#define GEMINUX_WIFI_STORAGE_BYTES 514U
+#define GEMINUX_WIFI_NVRAM_FAST_OFFSET 0x40042U
+
+uint8_t geminux_wifi_nvram_checksum(const uint8_t *rec512);
+bool geminux_wifi_nvram_has_valid_mac(const uint8_t *rec512);
+bool geminux_wifi_nvram_valid_record(const uint8_t *buf, size_t len, bool require_mac);
+void geminux_wifi_nvram_apply_fallback_mac(uint8_t buf514[GEMINUX_WIFI_STORAGE_BYTES],
+ const char *seed_str);
+bool geminux_wifi_nvram_scan_blob(const uint8_t *blob, size_t blob_len,
+ uint8_t out514[GEMINUX_WIFI_STORAGE_BYTES],
+ bool *has_valid_mac_out);
+
+#endif
diff --git a/src/geminux-daemons/geminux-wifi-nvram.c b/src/geminux-daemons/geminux-wifi-nvram.c
new file mode 100644
index 0000000..e7332ac
--- /dev/null
+++ b/src/geminux-daemons/geminux-wifi-nvram.c
@@ -0,0 +1,311 @@
+#define _POSIX_C_SOURCE 200809L
+#include "geminux-wifi-nvram-core.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define MAX_NVRAM_READ_BYTES (8U * 1024U * 1024U)
+#define DEFAULT_OUTPUT_PATH "/lib/firmware/mediatek/mt6797/WIFI.storage"
+#define DEFAULT_BT_OUTPUT_PATH "/lib/firmware/mediatek/mt6797/BT.storage"
+#define GEMINUX_BT_STORAGE_BYTES 66U
+
+static int read_fd_exact_or_cap(int fd, uint8_t *buf, size_t cap, size_t *out_len) {
+ size_t total = 0;
+ while (total < cap) {
+ ssize_t r = read(fd, buf + total, cap - total);
+ if (r < 0) {
+ if (errno == EINTR) continue;
+ return -1;
+ }
+ if (r == 0) break;
+ total += (size_t)r;
+ }
+ *out_len = total;
+ return 0;
+}
+
+static bool read_file_exact(const char *path, uint8_t *buf, size_t cap, size_t *out_len) {
+ int fd = open(path, O_RDONLY);
+ if (fd < 0) return false;
+ int rc = read_fd_exact_or_cap(fd, buf, cap, out_len);
+ close(fd);
+ return rc == 0;
+}
+
+static bool find_partition_device(const char *partname, char *dev_out, size_t dev_sz) {
+ DIR *d = opendir("/sys/class/block");
+ if (!d) return false;
+
+ bool found = false;
+ struct dirent *de;
+ while ((de = readdir(d)) != NULL) {
+ if (de->d_name[0] == '.') continue;
+ char uevent_path[320];
+ snprintf(uevent_path, sizeof(uevent_path), "/sys/class/block/%s/uevent", de->d_name);
+ FILE *f = fopen(uevent_path, "r");
+ if (!f) continue;
+
+ char devname[128] = {0};
+ char pname[128] = {0};
+ char line[256];
+ while (fgets(line, sizeof(line), f)) {
+ size_t n = strlen(line);
+ while (n > 0 && (line[n - 1] == '\n' || line[n - 1] == '\r')) line[--n] = '\0';
+ if (strncmp(line, "DEVNAME=", 8) == 0) {
+ snprintf(devname, sizeof(devname), "%s", line + 8);
+ } else if (strncmp(line, "PARTNAME=", 9) == 0) {
+ snprintf(pname, sizeof(pname), "%s", line + 9);
+ }
+ }
+ fclose(f);
+
+ if (strcmp(pname, partname) == 0 && devname[0]) {
+ snprintf(dev_out, dev_sz, "/dev/%s", devname);
+ found = true;
+ break;
+ }
+ }
+ closedir(d);
+ return found;
+}
+
+static int mkdir_p(const char *dir) {
+ char tmp[512];
+ snprintf(tmp, sizeof(tmp), "%s", dir);
+ size_t len = strlen(tmp);
+ if (len == 0) return 0;
+ if (tmp[len - 1] == '/') tmp[len - 1] = '\0';
+ for (char *p = tmp + 1; *p; p++) {
+ if (*p == '/') {
+ *p = '\0';
+ if (mkdir(tmp, 0755) != 0 && errno != EEXIST) return -1;
+ *p = '/';
+ }
+ }
+ if (mkdir(tmp, 0755) != 0 && errno != EEXIST) return -1;
+ return 0;
+}
+
+static int write_atomic_bytes(const char *out_path, const uint8_t *rec, size_t len) {
+ char dir[512];
+ snprintf(dir, sizeof(dir), "%s", out_path);
+ char *slash = strrchr(dir, '/');
+ if (slash) {
+ *slash = '\0';
+ if (dir[0] && mkdir_p(dir) != 0) return -1;
+ }
+
+ char tmp_path[560];
+ snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", out_path);
+ int fd = open(tmp_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ if (fd < 0) return -1;
+
+ size_t off = 0;
+ while (off < len) {
+ ssize_t w = write(fd, rec + off, len - off);
+ if (w < 0) {
+ if (errno == EINTR) continue;
+ close(fd);
+ unlink(tmp_path);
+ return -1;
+ }
+ off += (size_t)w;
+ }
+ fchmod(fd, 0644);
+ fsync(fd);
+ close(fd);
+
+ if (rename(tmp_path, out_path) != 0) {
+ unlink(tmp_path);
+ return -1;
+ }
+ return 0;
+}
+
+static bool bt_addr_nonzero(const uint8_t *buf, size_t len) {
+ if (len < 6) return false;
+ bool all_zero = true, all_ff = true;
+ for (size_t i = 0; i < 6; i++) {
+ if (buf[i] != 0x00) all_zero = false;
+ if (buf[i] != 0xff) all_ff = false;
+ }
+ return !all_zero && !all_ff;
+}
+
+static int mount_nvdata_ro(char *mnt_out, size_t mnt_sz) {
+ char dev_path[256] = "/dev/mmcblk0p6";
+ find_partition_device("nvdata", dev_path, sizeof(dev_path));
+
+ const char *mnt = "/run/geminux-nvdata-mnt";
+ if (mkdir_p("/run") != 0 || (mkdir(mnt, 0700) != 0 && errno != EEXIST)) {
+ mnt = "/tmp/geminux-nvdata-mnt";
+ if (mkdir(mnt, 0700) != 0 && errno != EEXIST) return -1;
+ }
+ if (mount(dev_path, mnt, "ext4", MS_RDONLY, "noload") != 0) {
+ rmdir(mnt);
+ return -1;
+ }
+ snprintf(mnt_out, mnt_sz, "%s", mnt);
+ return 0;
+}
+
+static bool try_nvram_partition(uint8_t rec_out[GEMINUX_WIFI_STORAGE_BYTES],
+ bool *has_mac_out) {
+ char dev_path[256] = "/dev/mmcblk0p19";
+ find_partition_device("nvram", dev_path, sizeof(dev_path));
+
+ int fd = open(dev_path, O_RDONLY);
+ if (fd < 0) return false;
+
+ uint8_t *buf = malloc(MAX_NVRAM_READ_BYTES);
+ if (!buf) {
+ close(fd);
+ return false;
+ }
+
+ size_t got = 0;
+ int rc = read_fd_exact_or_cap(fd, buf, MAX_NVRAM_READ_BYTES, &got);
+ close(fd);
+
+ bool ok = (rc == 0) && geminux_wifi_nvram_scan_blob(buf, got, rec_out, has_mac_out);
+ memset(buf, 0, got);
+ free(buf);
+ return ok;
+}
+
+static bool try_nvdata_partition(uint8_t rec_out[GEMINUX_WIFI_STORAGE_BYTES],
+ bool *has_mac_out) {
+ char mnt[128];
+ if (mount_nvdata_ro(mnt, sizeof(mnt)) != 0) return false;
+
+ char rec_path[320];
+ snprintf(rec_path, sizeof(rec_path), "%s/APCFG/APRDEB/WIFI", mnt);
+ uint8_t cand[GEMINUX_WIFI_STORAGE_BYTES];
+ size_t len = 0;
+ bool ok = read_file_exact(rec_path, cand, sizeof(cand), &len) &&
+ geminux_wifi_nvram_valid_record(cand, len, false);
+ if (ok) {
+ memcpy(rec_out, cand, GEMINUX_WIFI_STORAGE_BYTES);
+ *has_mac_out = geminux_wifi_nvram_has_valid_mac(cand);
+ }
+ memset(cand, 0, sizeof(cand));
+ umount2(mnt, MNT_DETACH);
+ rmdir(mnt);
+ return ok;
+}
+
+static void provision_bt_storage(const char *out_path) {
+ uint8_t existing[GEMINUX_BT_STORAGE_BYTES];
+ size_t existing_len = 0;
+ if (read_file_exact(out_path, existing, sizeof(existing), &existing_len) &&
+ existing_len == GEMINUX_BT_STORAGE_BYTES && bt_addr_nonzero(existing, existing_len)) {
+ memset(existing, 0, sizeof(existing));
+ return;
+ }
+ memset(existing, 0, sizeof(existing));
+
+ char mnt[128];
+ if (mount_nvdata_ro(mnt, sizeof(mnt)) != 0) return;
+
+ char bt_path[320];
+ snprintf(bt_path, sizeof(bt_path), "%s/APCFG/APRDEB/BT_Addr", mnt);
+ uint8_t cand[GEMINUX_BT_STORAGE_BYTES];
+ size_t len = 0;
+ bool ok = read_file_exact(bt_path, cand, sizeof(cand), &len) &&
+ len == GEMINUX_BT_STORAGE_BYTES && bt_addr_nonzero(cand, len);
+ umount2(mnt, MNT_DETACH);
+ rmdir(mnt);
+
+ if (ok && write_atomic_bytes(out_path, cand, GEMINUX_BT_STORAGE_BYTES) == 0) {
+ printf("geminux-wifi-nvram: provisioned %s (%u bytes)\n",
+ out_path, GEMINUX_BT_STORAGE_BYTES);
+ }
+ memset(cand, 0, sizeof(cand));
+}
+
+static void read_seed_string(char *seed, size_t sz) {
+ memset(seed, 0, sz);
+ size_t n = 0;
+ uint8_t raw[128] = {0};
+ if (read_file_exact("/etc/machine-id", raw, sizeof(raw) - 1, &n) && n > 0) {
+ while (n > 0 && (raw[n - 1] == '\n' || raw[n - 1] == '\r')) raw[--n] = '\0';
+ snprintf(seed, sz, "%s", (const char *)raw);
+ return;
+ }
+ if (read_file_exact("/sys/block/mmcblk0/device/cid", raw, sizeof(raw) - 1, &n) && n > 0) {
+ while (n > 0 && (raw[n - 1] == '\n' || raw[n - 1] == '\r')) raw[--n] = '\0';
+ snprintf(seed, sz, "%s", (const char *)raw);
+ return;
+ }
+ snprintf(seed, sz, "geminux-mt6797");
+}
+
+int main(int argc, char **argv) {
+ const char *out_path = (argc > 1 && argv[1][0]) ? argv[1] : DEFAULT_OUTPUT_PATH;
+ if (argc <= 1) {
+ provision_bt_storage(DEFAULT_BT_OUTPUT_PATH);
+ }
+
+ uint8_t existing[GEMINUX_WIFI_STORAGE_BYTES];
+ size_t existing_len = 0;
+ if (read_file_exact(out_path, existing, sizeof(existing), &existing_len) &&
+ geminux_wifi_nvram_valid_record(existing, existing_len, true)) {
+ memset(existing, 0, sizeof(existing));
+ return 0;
+ }
+ memset(existing, 0, sizeof(existing));
+
+ uint8_t chosen[GEMINUX_WIFI_STORAGE_BYTES];
+ bool have_rec = false;
+ bool have_mac = false;
+
+ if (try_nvram_partition(chosen, &have_mac)) {
+ have_rec = true;
+ }
+
+ if (!have_rec || !have_mac) {
+ uint8_t nvdata_rec[GEMINUX_WIFI_STORAGE_BYTES];
+ bool nvdata_mac = false;
+ if (try_nvdata_partition(nvdata_rec, &nvdata_mac)) {
+ if (!have_rec || nvdata_mac) {
+ memcpy(chosen, nvdata_rec, sizeof(chosen));
+ have_rec = true;
+ have_mac = nvdata_mac;
+ }
+ memset(nvdata_rec, 0, sizeof(nvdata_rec));
+ }
+ }
+
+ if (!have_rec) {
+ fprintf(stderr, "geminux-wifi-nvram: no valid NVRAM/nvdata WIFI record found\n");
+ return 1;
+ }
+
+ if (!have_mac) {
+ char seed[128];
+ read_seed_string(seed, sizeof(seed));
+ geminux_wifi_nvram_apply_fallback_mac(chosen, seed);
+ memset(seed, 0, sizeof(seed));
+ }
+
+ int wrc = write_atomic_bytes(out_path, chosen, GEMINUX_WIFI_STORAGE_BYTES);
+ memset(chosen, 0, sizeof(chosen));
+ if (wrc != 0) {
+ fprintf(stderr, "geminux-wifi-nvram: failed to write %s (%s)\n",
+ out_path, strerror(errno));
+ return 1;
+ }
+
+ printf("geminux-wifi-nvram: provisioned %s (%u bytes)\n",
+ out_path, GEMINUX_WIFI_STORAGE_BYTES);
+ return 0;
+}
diff --git a/src/libgemui/gemui.c b/src/libgemui/gemui.c
index 89bfa53..600aa68 100644
--- a/src/libgemui/gemui.c
+++ b/src/libgemui/gemui.c
@@ -3,6 +3,7 @@
#include
#include
+#include
#include
#include
#include
@@ -303,6 +304,8 @@ static void gemui_ensure_backbuf(gemui_app_t *app) {
gemui_app_t *gemui_create(const char *res_name, const char *title,
int w, int h, bool fullscreen_override) {
+ setlocale(LC_CTYPE, "");
+ XSetLocaleModifiers("");
gemui_init_sigpipe();
Display *dpy = XOpenDisplay(NULL);
if (!dpy) {
@@ -550,6 +553,12 @@ static void gemui_render_frame(gemui_app_t *app) {
app->need_redraw = false;
}
+void gemui_flush_draw(gemui_app_t *app) {
+ if (!app) return;
+ app->need_redraw = true;
+ gemui_render_frame(app);
+}
+
static void gemui_handle_x_events(gemui_app_t *app) {
while (XPending(app->dpy) > 0 && app->running) {
XEvent ev;
@@ -925,6 +934,7 @@ void gemui_draw_input(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
size_t len = strlen(text);
if (len > 48) len = 48;
for (size_t i = 0; i < len; i++) display[i] = '*';
+ if (focused && len + 1 < sizeof(display)) display[len++] = '_';
display[len] = '\0';
} else {
snprintf(display, sizeof(display), "%s%s", text, focused ? "_" : "");
@@ -1005,7 +1015,7 @@ int gemui_read_file_line(const char *path, char *buf, size_t sz) {
return 0;
}
-int gemui_run_cmd_capture(const char *const argv[], char *out, size_t out_sz) {
+int gemui_run_cmd_timeout(const char *const argv[], char *out, size_t out_sz, int timeout_ms) {
if (!argv || !argv[0]) return -1;
int pfd[2];
if (pipe(pfd) < 0) return -1;
@@ -1016,33 +1026,90 @@ int gemui_run_cmd_capture(const char *const argv[], char *out, size_t out_sz) {
return -1;
}
if (pid == 0) {
+ setpgid(0, 0);
+ int devnull = open("/dev/null", O_RDONLY);
+ if (devnull >= 0) {
+ dup2(devnull, STDIN_FILENO);
+ if (devnull > 2) close(devnull);
+ } else {
+ close(STDIN_FILENO);
+ }
close(pfd[0]);
dup2(pfd[1], STDOUT_FILENO);
dup2(pfd[1], STDERR_FILENO);
- close(pfd[1]);
+ if (pfd[1] > 2) close(pfd[1]);
execvp(argv[0], (char *const *)argv);
_exit(127);
}
close(pfd[1]);
+ int fl = fcntl(pfd[0], F_GETFL, 0);
+ if (fl >= 0) fcntl(pfd[0], F_SETFL, fl | O_NONBLOCK);
+
size_t off = 0;
- char tmp[256];
- while (1) {
- ssize_t n = read(pfd[0], tmp, sizeof(tmp));
- if (n <= 0) break;
- if (out && off + 1 < out_sz) {
- size_t cp = (size_t)n;
- if (cp > out_sz - 1 - off) cp = out_sz - 1 - off;
- memcpy(out + off, tmp, cp);
- off += cp;
+ char tmp[512];
+ uint64_t deadline = (timeout_ms > 0) ? (gemui_now_ms() + (uint64_t)timeout_ms) : UINT64_MAX;
+ bool timed_out = false;
+ bool eof = false;
+
+ while (!eof) {
+ int wait_ms = -1;
+ if (timeout_ms > 0) {
+ uint64_t now = gemui_now_ms();
+ if (now >= deadline) {
+ timed_out = true;
+ break;
+ }
+ uint64_t rem = deadline - now;
+ wait_ms = rem > 60000ULL ? 60000 : (int)rem;
+ }
+ struct pollfd pf = { .fd = pfd[0], .events = POLLIN | POLLHUP };
+ int pr = poll(&pf, 1, wait_ms);
+ if (pr < 0) {
+ if (errno == EINTR) continue;
+ break;
+ }
+ if (pr == 0) {
+ timed_out = true;
+ break;
+ }
+ while (1) {
+ ssize_t n = read(pfd[0], tmp, sizeof(tmp));
+ if (n > 0) {
+ if (out && off + 1 < out_sz) {
+ size_t cp = (size_t)n;
+ if (cp > out_sz - 1 - off) cp = out_sz - 1 - off;
+ memcpy(out + off, tmp, cp);
+ off += cp;
+ }
+ } else if (n == 0) {
+ eof = true;
+ break;
+ } else {
+ if (errno == EINTR) continue;
+ if (errno == EAGAIN || errno == EWOULDBLOCK) break;
+ eof = true;
+ break;
+ }
}
}
if (out && out_sz > 0) out[off] = '\0';
close(pfd[0]);
+ if (timed_out) {
+ kill(-pid, SIGKILL);
+ kill(pid, SIGKILL);
+ }
int status = 0;
- if (waitpid(pid, &status, 0) < 0) return -1;
+ while (waitpid(pid, &status, 0) < 0) {
+ if (errno != EINTR) return timed_out ? 124 : -1;
+ }
+ if (timed_out) return 124;
return WIFEXITED(status) ? WEXITSTATUS(status) : 1;
}
+int gemui_run_cmd_capture(const char *const argv[], char *out, size_t out_sz) {
+ return gemui_run_cmd_timeout(argv, out, out_sz, 2500);
+}
+
int gemui_spawn_detached(const char *const argv[]) {
if (!argv || !argv[0]) return -1;
pid_t pid = fork();
diff --git a/src/libgemui/gemui.h b/src/libgemui/gemui.h
index c09b460..5fd95dd 100644
--- a/src/libgemui/gemui.h
+++ b/src/libgemui/gemui.h
@@ -121,6 +121,7 @@ int gemui_add_fd(gemui_app_t *app, int fd, gemui_fd_cb cb, void *userdata);
void gemui_del_fd(gemui_app_t *app, int fd);
void gemui_set_timer_ms(gemui_app_t *app, int interval_ms, gemui_timer_cb cb, void *userdata);
void gemui_request_redraw(gemui_app_t *app);
+void gemui_flush_draw(gemui_app_t *app);
void gemui_show_toast(gemui_app_t *app, const char *msg, int duration_ms);
int gemui_run(gemui_app_t *app);
void gemui_quit(gemui_app_t *app, int code);
@@ -157,6 +158,7 @@ void gemui_draw_toast(gemui_app_t *app, cairo_t *cr);
int gemui_unix_cmd(const char *sock_path, const char *cmd, char *resp, size_t resp_sz);
int gemui_read_file_line(const char *path, char *buf, size_t sz);
+int gemui_run_cmd_timeout(const char *const argv[], char *out, size_t out_sz, int timeout_ms);
int gemui_run_cmd_capture(const char *const argv[], char *out, size_t out_sz);
int gemui_spawn_detached(const char *const argv[]);
void gemui_utf8_pop_char(char *buf);
diff --git a/src/st/config.def.h b/src/st/config.def.h
index 8423d24..b432707 100644
--- a/src/st/config.def.h
+++ b/src/st/config.def.h
@@ -16,7 +16,7 @@ static int borderpx = 6;
* 4: value of shell in /etc/passwd
* 5: value of shell in config.h
*/
-static char *shell = "/bin/sh";
+static char *shell = "/bin/bash";
char *utmp = NULL;
/* scroll program: to enable use a string like "scroll" */
char *scroll = NULL;
diff --git a/src/st/config.h b/src/st/config.h
index 8423d24..b432707 100644
--- a/src/st/config.h
+++ b/src/st/config.h
@@ -16,7 +16,7 @@ static int borderpx = 6;
* 4: value of shell in /etc/passwd
* 5: value of shell in config.h
*/
-static char *shell = "/bin/sh";
+static char *shell = "/bin/bash";
char *utmp = NULL;
/* scroll program: to enable use a string like "scroll" */
char *scroll = NULL;
diff --git a/src/st/config.mk b/src/st/config.mk
index e23795b..c6e998f 100644
--- a/src/st/config.mk
+++ b/src/st/config.mk
@@ -6,8 +6,8 @@ MANPREFIX = $(PREFIX)/share/man
PKG_CONFIG ?= pkg-config
-INCS = $(shell $(PKG_CONFIG) --cflags fontconfig freetype2 harfbuzz xft x11)
-LIBS = -lm -lrt -lutil $(shell $(PKG_CONFIG) --libs fontconfig freetype2 harfbuzz xft x11)
+INCS = $(shell $(PKG_CONFIG) --cflags fontconfig freetype2 harfbuzz xft x11 xfixes xi)
+LIBS = -lm -lrt -lutil $(shell $(PKG_CONFIG) --libs fontconfig freetype2 harfbuzz xft x11 xfixes xi)
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS) -O2 -std=gnu99 -Wall
diff --git a/src/st/x.c b/src/st/x.c
index 2f14e88..c8a1b08 100644
--- a/src/st/x.c
+++ b/src/st/x.c
@@ -10,7 +10,10 @@
#include
#include
#include
+#include
#include
+#include
+#include
#include
#include
#include
@@ -126,6 +129,10 @@ typedef struct {
int isfixed; /* is fixed geometry? */
int l, t; /* left and top offset */
int gm; /* geometry mask */
+ Cursor vpointer, bpointer;
+ int pointerisvisible;
+ int xi_opcode;
+ int xfixes_ok;
} XWindow;
typedef struct {
@@ -205,6 +212,9 @@ static void mousereport(XEvent *);
static char *kmap(KeySym, uint);
static int match(uint, uint);
static void updateselectionmodeatom(void);
+static void st_xi_raw_select(int);
+static void xhidepointer(void);
+static void xshowpointer(void);
static void run(void);
static void usage(void);
@@ -529,6 +539,7 @@ bpress(XEvent *e)
struct timespec now;
int snap;
+ xshowpointer();
if (!selectionmodeenabled)
return;
@@ -768,6 +779,7 @@ brelease(XEvent *e)
void
bmotion(XEvent *e)
{
+ xshowpointer();
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) {
mousereport(e);
return;
@@ -1252,6 +1264,38 @@ xinit(int cols, int rows)
xw.selectionmode = XInternAtom(xw.dpy, "_ST_SELMODE", False);
updateselectionmodeatom();
+ /* pointer cursor setup and blank cursor for hide-while-typing */
+ {
+ int ev_base = 0, err_base = 0;
+ char blank_bits[1] = {0};
+ Pixmap blank = XCreateBitmapFromData(xw.dpy, xw.win, blank_bits, 1, 1);
+ XColor black = {0};
+ XColor xmousefg = {0}, xmousebg = {0};
+
+ xw.xfixes_ok = XFixesQueryExtension(xw.dpy, &ev_base, &err_base) ? 1 : 0;
+ xw.xi_opcode = -1;
+ if (XQueryExtension(xw.dpy, "XInputExtension", &xw.xi_opcode, &ev_base, &err_base)) {
+ int maj = 2, min = 2;
+ if (XIQueryVersion(xw.dpy, &maj, &min) != Success)
+ xw.xi_opcode = -1;
+ } else {
+ xw.xi_opcode = -1;
+ }
+
+ xw.vpointer = XCreateFontCursor(xw.dpy, mouseshape);
+ xmousefg.red = dc.col[mousefg].color.red;
+ xmousefg.green = dc.col[mousefg].color.green;
+ xmousefg.blue = dc.col[mousefg].color.blue;
+ xmousebg.red = dc.col[mousebg].color.red;
+ xmousebg.green = dc.col[mousebg].color.green;
+ xmousebg.blue = dc.col[mousebg].color.blue;
+ XRecolorCursor(xw.dpy, xw.vpointer, &xmousefg, &xmousebg);
+ xw.bpointer = XCreatePixmapCursor(xw.dpy, blank, blank, &black, &black, 0, 0);
+ XFreePixmap(xw.dpy, blank);
+ xw.pointerisvisible = 1;
+ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
+ }
+
win.mode = MODE_NUMLOCK;
resettitle();
xhints();
@@ -1744,12 +1788,64 @@ visibility(XEvent *ev)
void
unmap(XEvent *ev)
{
+ xshowpointer();
win.mode &= ~MODE_VISIBLE;
}
+void
+st_xi_raw_select(int enable)
+{
+ unsigned char mask[XIMaskLen(XI_LASTEVENT)];
+ XIEventMask evmask;
+
+ if (xw.xi_opcode < 0)
+ return;
+ memset(mask, 0, sizeof(mask));
+ if (enable) {
+ XISetMask(mask, XI_RawMotion);
+ XISetMask(mask, XI_RawButtonPress);
+ XISetMask(mask, XI_RawTouchBegin);
+ }
+ evmask.deviceid = XIAllMasterDevices;
+ evmask.mask_len = (int)sizeof(mask);
+ evmask.mask = mask;
+ XISelectEvents(xw.dpy, XRootWindow(xw.dpy, xw.scr), &evmask, 1);
+}
+
+void
+xhidepointer(void)
+{
+ if (!xw.pointerisvisible)
+ return;
+ XDefineCursor(xw.dpy, xw.win, xw.bpointer);
+ if (xw.xfixes_ok)
+ XFixesHideCursor(xw.dpy, XRootWindow(xw.dpy, xw.scr));
+ st_xi_raw_select(1);
+ xsetpointermotion(1);
+ xw.pointerisvisible = 0;
+ XFlush(xw.dpy);
+}
+
+void
+xshowpointer(void)
+{
+ if (xw.pointerisvisible)
+ return;
+ xw.pointerisvisible = 1;
+ st_xi_raw_select(0);
+ if (xw.xfixes_ok)
+ XFixesShowCursor(xw.dpy, XRootWindow(xw.dpy, xw.scr));
+ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
+ if (!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY))
+ xsetpointermotion(0);
+ XFlush(xw.dpy);
+}
+
void
xsetpointermotion(int set)
{
+ if (!set && !xw.pointerisvisible)
+ return;
MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
}
@@ -1806,6 +1902,7 @@ focus(XEvent *ev)
if (IS_SET(MODE_FOCUS))
ttywrite("\033[I", 3, 0);
} else {
+ xshowpointer();
if (xw.ime.xic)
XUnsetICFocus(xw.ime.xic);
if (e->mode == NotifyGrab)
@@ -1879,12 +1976,15 @@ kpress(XEvent *ev)
if (status == XLookupNone)
return;
if (status == XLookupChars) {
+ xhidepointer();
ttywrite(buf, len, 1);
return;
}
} else {
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
}
+ if (!IsModifierKey(ksym))
+ xhidepointer();
/* 1. shortcuts */
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
if (ksym == bp->keysym && match(bp->mod, e->state)) {
@@ -2036,6 +2136,17 @@ run(void)
while (XPending(xw.dpy)) {
xev = 1;
XNextEvent(xw.dpy, &ev);
+ if (ev.type == GenericEvent) {
+ if (ev.xcookie.extension == xw.xi_opcode &&
+ XGetEventData(xw.dpy, &ev.xcookie)) {
+ if (ev.xcookie.evtype == XI_RawMotion ||
+ ev.xcookie.evtype == XI_RawButtonPress ||
+ ev.xcookie.evtype == XI_RawTouchBegin)
+ xshowpointer();
+ XFreeEventData(xw.dpy, &ev.xcookie);
+ }
+ continue;
+ }
if (ev.type == ClientMessage &&
(Atom)ev.xclient.data.l[0] == xw.wmdeletewin) {
cmessage(&ev);