Subject: [PATCH] coolpi-genbook: select the internal ES8316 microphone input

The saved mixer state selected lin2-rin2 (MIC2), which is normally used by
an external/headset microphone.  The GenBook internal microphone is connected
to the MIC1 differential input, so select lin1-rin1 instead.

This keeps the existing ADC gain, mic boost and playback settings unchanged.
---
Index: config/bootscripts/boot-rk35xx.cmd
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/config/bootscripts/boot-rk35xx.cmd b/config/bootscripts/boot-rk35xx.cmd
--- a/config/bootscripts/boot-rk35xx.cmd	(revision c0a5915562ca65ac4e68fd7c9e6bf1c579afd55f)
+++ b/config/bootscripts/boot-rk35xx.cmd	(date 1785267288334)
@@ -3,7 +3,7 @@
 # Please edit /boot/armbianEnv.txt to set supported parameters
 #
 
-setenv load_addr "0x9000000"
+setenv load_addr "0x200000"
 setenv overlay_error "false"
 # default values
 setenv rootdev "/dev/mmcblk0p1"
Index: patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-data-role.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-data-role.patch b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-data-role.patch
new file mode 100644
--- /dev/null	(date 1785360584186)
+++ b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-data-role.patch	(date 1785360584186)
@@ -0,0 +1,120 @@
+From 5ccbe8f671734ad9d3d816d87c9a215d37b5aaf2 Mon Sep 17 00:00:00 2001
+From: OpenAI <noreply@openai.com>
+Date: Thu, 30 Jul 2026 00:35:00 +0300
+Subject: [PATCH] arm64: dts: rockchip: add GenBook HUSB311 Type-C data role
+
+The vendor GenBook device tree uses an HUSB311 TCPC at I2C4 address 0x4e
+with an active-low interrupt on GPIO0_D5. The second FUSB302 node in the
+vendor tree cannot probe because it requests the same interrupt pin, so
+do not instantiate it.
+
+Connect the HUSB311 connector to the DWC3 role switch and USBDP PHY
+orientation switch. Let TCPM control the GPIO0_A0 VBUS regulator.
+
+Keep all DWC3 properties before its port subnode, as required by the
+Device Tree source grammar.
+
+DisplayPort Alt Mode remains intentionally out of scope until USB data
+works reliably in both cable orientations.
+
+---
+diff --git a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+index 95a0678..8bb1874 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+@@ -371,8 +371,92 @@
+ 	status = "okay";
+ };
+ 
++&{/i2c@feac0000} {
++	usbc0: typec-portc@4e {
++		compatible = "hynetek,husb311", "richtek,rt1711h";
++		reg = <0x4e>;
++		interrupt-parent = <&gpio0>;
++		interrupts = <RK_PD5 IRQ_TYPE_LEVEL_LOW>;
++		pinctrl-names = "default";
++		pinctrl-0 = <&usbc0_int>;
++		vbus-supply = <&vcc5v0_otg>;
++		wakeup-source;
++
++		connector {
++			compatible = "usb-c-connector";
++			label = "USB-C";
++			data-role = "dual";
++			power-role = "dual";
++			try-power-role = "sink";
++
++			source-pdos = <0x0401912c>;
++			sink-pdos = <0x0401912c 0x0402d12c
++				     0x0403c12c 0x0404b12c>;
++			op-sink-microwatt = <1000000>;
++
++			ports {
++				#address-cells = <1>;
++				#size-cells = <0>;
++
++				port@0 {
++					reg = <0>;
++
++					usbc0_orien_sw: endpoint {
++						remote-endpoint =
++							<&usbdp_phy0_orientation_switch>;
++					};
++				};
++
++				port@1 {
++					reg = <1>;
++
++					usbc0_role_sw: endpoint {
++						remote-endpoint =
++							<&dwc3_0_role_switch>;
++					};
++				};
++			};
++		};
++	};
++};
++
++&pinctrl {
++	usb-typec {
++		usbc0_int: usbc0-int {
++			rockchip,pins =
++				<0 RK_PD5 RK_FUNC_GPIO &pcfg_pull_up>;
++		};
++	};
++};
++
++&u2phy0_otg {
++	/delete-property/ phy-supply;
++};
++
++&usbdp_phy0 {
++	orientation-switch;
++
++	port {
++		usbdp_phy0_orientation_switch: endpoint {
++			remote-endpoint = <&usbc0_orien_sw>;
++		};
++	};
++};
++
++&vcc5v0_otg {
++	/delete-property/ regulator-always-on;
++	/delete-property/ regulator-boot-on;
++};
++
+ /* Type C port */
+ &usb_host0_xhci {
+-	dr_mode = "host";
++	dr_mode = "otg";
++	usb-role-switch;
+ 	status = "okay";
++
++	port {
++		dwc3_0_role_switch: endpoint {
++			remote-endpoint = <&usbc0_role_sw>;
++		};
++	};
+ };
+-- 
+2.50.1
Index: config/bootscripts/boot-rockchip64-ttyS0.cmd
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/config/bootscripts/boot-rockchip64-ttyS0.cmd b/config/bootscripts/boot-rockchip64-ttyS0.cmd
--- a/config/bootscripts/boot-rockchip64-ttyS0.cmd	(revision c0a5915562ca65ac4e68fd7c9e6bf1c579afd55f)
+++ b/config/bootscripts/boot-rockchip64-ttyS0.cmd	(date 1785267288379)
@@ -3,7 +3,7 @@
 # Please edit /boot/armbianEnv.txt to set supported parameters
 #
 
-setenv load_addr "0x9000000"
+setenv load_addr "0x200000"
 setenv overlay_error "false"
 # default values
 setenv rootdev "/dev/mmcblk0p1"
Index: add-coolpi-genbook-ucm-v3.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/add-coolpi-genbook-ucm-v3.patch b/add-coolpi-genbook-ucm-v3.patch
new file mode 100644
--- /dev/null	(date 1785357807458)
+++ b/add-coolpi-genbook-ucm-v3.patch	(date 1785357807458)
@@ -0,0 +1,79 @@
+diff --git a/userpatches/customize-image.sh b/userpatches/customize-image.sh
+new file mode 100755
+--- /dev/null
++++ b/userpatches/customize-image.sh
+@@ -0,0 +1,74 @@
++#!/usr/bin/env bash
++set -Eeuo pipefail
++
++install -d -m 0755 /usr/share/alsa/ucm2/Rockchip/rk3588-es8316
++
++cat > /usr/share/alsa/ucm2/Rockchip/rk3588-es8316/HiFi.conf <<'__COOLPI_GENBOOK_UCM_V3_EOF__'
++SectionDevice."Speaker" {
++	Comment "Internal Speakers"
++
++	ConflictingDevice [
++		"Headphones"
++	]
++
++	EnableSequence [
++		cset "name='Speaker Switch' on"
++	]
++
++	DisableSequence [
++		cset "name='Speaker Switch' off"
++	]
++
++	Value {
++		PlaybackPriority 100
++		PlaybackPCM "hw:${CardId}"
++		PlaybackMixerElem "Headphone Mixer"
++		PlaybackMasterElem "DAC"
++	}
++}
++
++SectionDevice."Headphones" {
++	Comment "Headphones"
++
++	ConflictingDevice [
++		"Speaker"
++	]
++
++	EnableSequence [
++		cset "name='Speaker Switch' off"
++	]
++
++	Value {
++		PlaybackPriority 200
++		PlaybackPCM "hw:${CardId}"
++		PlaybackMixerElem "Headphone Mixer"
++		PlaybackMasterElem "DAC"
++		JackControl "Headphones Jack"
++	}
++}
++
++SectionDevice."Headset" {
++	Comment "Headset Microphone on IN2"
++
++	EnableSequence [
++		cset "name='Differential Mux' lin2-rin2"
++		cset "name='Left Headphone Mux' lin2-rin2"
++		cset "name='Right Headphone Mux' lin2-rin2"
++	]
++
++	DisableSequence [
++		cset "name='Differential Mux' lin1-rin1"
++		cset "name='Left Headphone Mux' lin1-rin1"
++		cset "name='Right Headphone Mux' lin1-rin1"
++	]
++
++	Value {
++		CapturePriority 200
++		CapturePCM "hw:${CardId}"
++		CaptureMixerElem "ADC PGA Gain"
++		CaptureMasterElem "ADC"
++	}
++}
++__COOLPI_GENBOOK_UCM_V3_EOF__
++
++chmod 0644 /usr/share/alsa/ucm2/Rockchip/rk3588-es8316/HiFi.conf
Index: patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-dp-altmode.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-dp-altmode.patch b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-dp-altmode.patch
new file mode 100644
--- /dev/null	(date 1785366185263)
+++ b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-dp-altmode.patch	(date 1785366185263)
@@ -0,0 +1,107 @@
+From e5c9ee061784750cf8a77309543fbf68cd639a32 Mon Sep 17 00:00:00 2001
+From: OpenAI <noreply@openai.com>
+Date: Thu, 30 Jul 2026 01:20:00 +0300
+Subject: [PATCH] arm64: dts: rockchip: add GenBook USB-C DisplayPort Alt
+ Mode via VP2
+
+USB data, VBUS, role switching and cable orientation are already working
+through the HUSB311/RT1711H TCPC.
+
+Add the DisplayPort Alt Mode endpoint between the USB-C connector and the
+RK3588 USBDP PHY. Enable the PHY mode switch and the board SBU DC-control
+GPIOs copied from the working vendor device tree.
+
+Enable DP0 and route VOP video port 2 to it, matching the working vendor
+device tree. VP0 drives the internal eDP panel and VP1 drives HDMI0. HDMI
+output on the tested dock is implemented by converting this DisplayPort
+Alt Mode signal inside the dock.
+
+---
+diff --git a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+index 8100e09..4e8cf88 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+@@ -405,11 +405,41 @@
+ 							<&dwc3_0_role_switch>;
+ 					};
+ 				};
++
++				port@2 {
++					reg = <2>;
++
++					dp_altmode_mux: endpoint {
++						remote-endpoint =
++							<&usbdp_phy0_dp_altmode_mux>;
++					};
++				};
++			};
++
++			altmodes {
++				#address-cells = <1>;
++				#size-cells = <0>;
++
++				altmode@0 {
++					reg = <0>;
++					svid = <0xff01>;
++					vdo = <0xffffffff>;
++				};
+ 			};
+ 		};
+ 	};
+ };
+ 
++&dp0 {
++	status = "okay";
++};
++
++&dp0_in {
++	dp0_in_vp2: endpoint {
++		remote-endpoint = <&vp2_out_dp0>;
++	};
++};
++
+ &pinctrl {
+ 	usb-typec {
+ 		usbc0_int: usbc0-int {
+@@ -424,12 +454,24 @@
+ };
+ 
+ &usbdp_phy0 {
++	mode-switch;
+ 	orientation-switch;
++	sbu1-dc-gpios = <&gpio4 RK_PA4 GPIO_ACTIVE_HIGH>;
++	sbu2-dc-gpios = <&gpio4 RK_PA5 GPIO_ACTIVE_HIGH>;
+ 
+ 	port {
+-		usbdp_phy0_orientation_switch: endpoint {
++		#address-cells = <1>;
++		#size-cells = <0>;
++
++		usbdp_phy0_orientation_switch: endpoint@0 {
++			reg = <0>;
+ 			remote-endpoint = <&usbc0_orien_sw>;
+ 		};
++
++		usbdp_phy0_dp_altmode_mux: endpoint@1 {
++			reg = <1>;
++			remote-endpoint = <&dp_altmode_mux>;
++		};
+ 	};
+ };
+ 
+@@ -438,6 +480,13 @@
+ 	/delete-property/ regulator-boot-on;
+ };
+ 
++&vp2 {
++	vp2_out_dp0: endpoint@ROCKCHIP_VOP2_EP_DP0 {
++		reg = <ROCKCHIP_VOP2_EP_DP0>;
++		remote-endpoint = <&dp0_in_vp2>;
++	};
++};
++
+ /* Type C port */
+ &usb_host0_xhci {
+ 	dr_mode = "otg";
+-- 
+2.50.1
Index: patch/kernel/archive/rockchip64-7.1/general-audio-graph-card-parse-pin-switches.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/patch/kernel/archive/rockchip64-7.1/general-audio-graph-card-parse-pin-switches.patch b/patch/kernel/archive/rockchip64-7.1/general-audio-graph-card-parse-pin-switches.patch
new file mode 100644
--- /dev/null	(date 1785354664184)
+++ b/patch/kernel/archive/rockchip64-7.1/general-audio-graph-card-parse-pin-switches.patch	(date 1785354664184)
@@ -0,0 +1,33 @@
+From f1abc1380487260ec1c9d01ef606acd48f2e4391 Mon Sep 17 00:00:00 2001
+From: OpenAI <noreply@openai.com>
+Date: Wed, 29 Jul 2026 22:50:00 +0300
+Subject: [PATCH] ASoC: audio-graph-card: parse pin-switches
+
+simple-card parses the pin-switches property, but audio-graph-card only
+parses widgets and routing. As a result a valid pin-switches property on
+an audio-graph-card node is silently ignored and no DAPM pin controls are
+created.
+
+Parse pin-switches after routing, matching simple-card. Boards without
+the property are unaffected.
+
+---
+ sound/soc/generic/audio-graph-card.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
+--- a/sound/soc/generic/audio-graph-card.c
++++ b/sound/soc/generic/audio-graph-card.c
+@@ -581,6 +581,10 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev)
+ 	if (ret < 0)
+ 		goto end;
+
++	ret = simple_util_parse_pin_switches(card, NULL);
++	if (ret < 0)
++		goto end;
++
+ 	memset(li, 0, sizeof(*li));
+ 	ret = graph_for_each_link(priv, li,
+ 				  graph_dai_link_of,
+-- 
+2.50.1
Index: config/bootscripts/boot-rockchip64.cmd
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/config/bootscripts/boot-rockchip64.cmd b/config/bootscripts/boot-rockchip64.cmd
--- a/config/bootscripts/boot-rockchip64.cmd	(revision c0a5915562ca65ac4e68fd7c9e6bf1c579afd55f)
+++ b/config/bootscripts/boot-rockchip64.cmd	(date 1785267288351)
@@ -3,7 +3,7 @@
 # Please edit /boot/armbianEnv.txt to set supported parameters
 #
 
-setenv load_addr "0x9000000"
+setenv load_addr "0x200000"
 setenv overlay_error "false"
 # default values
 setenv rootdev "/dev/mmcblk0p1"
Index: patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-internal-mic-v4.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-internal-mic-v4.patch b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-internal-mic-v4.patch
new file mode 100644
--- /dev/null	(date 1785364923762)
+++ b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-internal-mic-v4.patch	(date 1785364923762)
@@ -0,0 +1,40 @@
+From e9ae51fd259d5b6e545f82834f53bb9786340fb2 Mon Sep 17 00:00:00 2001
+From: OpenAI <noreply@openai.com>
+Date: Thu, 30 Jul 2026 01:40:00 +0300
+Subject: [PATCH] arm64: dts: rockchip: restore GenBook internal microphone
+
+The working vendor device tree routes the built-in analogue microphone to
+ES8316 MIC1 and the headset microphone to MIC2.
+
+The edge audio-graph-card override only describes MIC2, so selecting
+lin1-rin1 in ALSA cannot activate a complete DAPM path and capture
+contains only a nearly constant noise floor.
+
+Restore both vendor microphone routes and give userspace distinct Main
+Mic and Headset Mic widgets.
+
+---
+diff --git a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+index 3fd7efc..afd033e 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+@@ -161,13 +161,15 @@
+ 	hp-det-gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>;
+ 	pa-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
+ 	pin-switches = "Speaker";
+-	routing = "MIC2", "Mic Jack",
++	routing = "MIC1", "Main Mic",
++		  "MIC2", "Headset Mic",
+ 		  "Headphones", "HPOL",
+ 		  "Headphones", "HPOR",
+ 		  "Amplifier", "HPOL",
+ 		  "Amplifier", "HPOR",
+ 		  "Speaker", "Amplifier";
+-	widgets = "Microphone", "Mic Jack",
++	widgets = "Microphone", "Main Mic",
++		  "Microphone", "Headset Mic",
+ 		  "Headphone", "Headphones",
+ 		  "Speaker", "Speaker";
+ };
+-- 
+2.50.1
Index: config/kernel/linux-rockchip64-edge.config
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/config/kernel/linux-rockchip64-edge.config b/config/kernel/linux-rockchip64-edge.config
--- a/config/kernel/linux-rockchip64-edge.config	(revision c0a5915562ca65ac4e68fd7c9e6bf1c579afd55f)
+++ b/config/kernel/linux-rockchip64-edge.config	(date 1785363547477)
@@ -2603,7 +2603,7 @@
 CONFIG_TYPEC=y
 CONFIG_TYPEC_TCPM=y
 CONFIG_TYPEC_TCPCI=y
-CONFIG_TYPEC_RT1711H=m
+CONFIG_TYPEC_RT1711H=y
 CONFIG_TYPEC_FUSB302=y
 CONFIG_TYPEC_UCSI=m
 CONFIG_UCSI_CCG=m
@@ -2612,7 +2612,7 @@
 CONFIG_TYPEC_EXTCON=m
 CONFIG_TYPEC_MUX_FSA4480=m
 CONFIG_TYPEC_MUX_PI3USB30532=m
-CONFIG_TYPEC_DP_ALTMODE=m
+CONFIG_TYPEC_DP_ALTMODE=y
 CONFIG_MMC=y
 CONFIG_PWRSEQ_SD8787=m
 CONFIG_MMC_BLOCK_MINORS=32
@@ -3436,3 +3436,6 @@
 CONFIG_MEMCPY_KUNIT_TEST=m
 CONFIG_TEST_MEMCAT_P=m
 CONFIG_MEMTEST=y
+
+# CoolPi GenBook USB-C
+CONFIG_USB_ROLE_SWITCH=y
Index: packages/blobs/asound.state/asound.state.coolpi-genbook
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/blobs/asound.state/asound.state.coolpi-genbook b/packages/blobs/asound.state/asound.state.coolpi-genbook
new file mode 100644
--- /dev/null	(date 1785267288436)
+++ b/packages/blobs/asound.state/asound.state.coolpi-genbook	(date 1785267288436)
@@ -0,0 +1,849 @@
+state.rockchiphdmi0 {
+	control.1 {
+		iface MIXER
+		name 'Receive PATH3 Source Select'
+		value 'From SDI3'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From SDI0'
+			item.1 'From SDI1'
+			item.2 'From SDI2'
+			item.3 'From SDI3'
+		}
+	}
+	control.2 {
+		iface MIXER
+		name 'Receive PATH2 Source Select'
+		value 'From SDI2'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From SDI0'
+			item.1 'From SDI1'
+			item.2 'From SDI2'
+			item.3 'From SDI3'
+		}
+	}
+	control.3 {
+		iface MIXER
+		name 'Receive PATH1 Source Select'
+		value 'From SDI1'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From SDI0'
+			item.1 'From SDI1'
+			item.2 'From SDI2'
+			item.3 'From SDI3'
+		}
+	}
+	control.4 {
+		iface MIXER
+		name 'Receive PATH0 Source Select'
+		value 'From SDI0'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From SDI0'
+			item.1 'From SDI1'
+			item.2 'From SDI2'
+			item.3 'From SDI3'
+		}
+	}
+	control.5 {
+		iface MIXER
+		name 'Transmit SDO3 Source Select'
+		value 'From PATH3'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From PATH0'
+			item.1 'From PATH1'
+			item.2 'From PATH2'
+			item.3 'From PATH3'
+		}
+	}
+	control.6 {
+		iface MIXER
+		name 'Transmit SDO2 Source Select'
+		value 'From PATH2'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From PATH0'
+			item.1 'From PATH1'
+			item.2 'From PATH2'
+			item.3 'From PATH3'
+		}
+	}
+	control.7 {
+		iface MIXER
+		name 'Transmit SDO1 Source Select'
+		value 'From PATH1'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From PATH0'
+			item.1 'From PATH1'
+			item.2 'From PATH2'
+			item.3 'From PATH3'
+		}
+	}
+	control.8 {
+		iface MIXER
+		name 'Transmit SDO0 Source Select'
+		value 'From PATH0'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From PATH0'
+			item.1 'From PATH1'
+			item.2 'From PATH2'
+			item.3 'From PATH3'
+		}
+	}
+	control.9 {
+		iface MIXER
+		name 'I2STDM Digital Loopback Mode'
+		value Disabled
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 Disabled
+			item.1 Mode1
+			item.2 Mode2
+			item.3 'Mode2 Swap'
+		}
+	}
+	control.10 {
+		iface PCM
+		name 'PCM Read Wait Time MS'
+		value 0
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 10000 (step 1)'
+		}
+	}
+	control.11 {
+		iface PCM
+		name 'PCM Write Wait Time MS'
+		value 0
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 10000 (step 1)'
+		}
+	}
+	control.12 {
+		iface CARD
+		name 'rockchip-hdmi0 Jack'
+		value false
+		comment {
+			access read
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.13 {
+		iface PCM
+		name 'Playback Channel Map'
+		value.0 0
+		value.1 0
+		value.2 0
+		value.3 0
+		value.4 0
+		value.5 0
+		value.6 0
+		value.7 0
+		comment {
+			access read
+			type INTEGER
+			count 8
+			range '0 - 36'
+		}
+	}
+	control.14 {
+		iface PCM
+		name 'IEC958 Playback Mask'
+		value ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+		comment {
+			access read
+			type IEC958
+			count 1
+		}
+	}
+	control.15 {
+		iface PCM
+		name 'IEC958 Playback Default'
+		value '0400000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
+		comment {
+			access 'read write'
+			type IEC958
+			count 1
+		}
+	}
+	control.16 {
+		iface PCM
+		name ELD
+		value '100006006510000100000000000000000469e123565832333909070700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
+		comment {
+			access 'read volatile'
+			type BYTES
+			count 128
+		}
+	}
+	control.17 {
+		iface MIXER
+		name 'ELD Bypass Switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+}
+state.rockchipes8316 {
+	control.1 {
+		iface MIXER
+		name 'Receive PATH3 Source Select'
+		value 'From SDI3'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From SDI0'
+			item.1 'From SDI1'
+			item.2 'From SDI2'
+			item.3 'From SDI3'
+		}
+	}
+	control.2 {
+		iface MIXER
+		name 'Receive PATH2 Source Select'
+		value 'From SDI2'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From SDI0'
+			item.1 'From SDI1'
+			item.2 'From SDI2'
+			item.3 'From SDI3'
+		}
+	}
+	control.3 {
+		iface MIXER
+		name 'Receive PATH1 Source Select'
+		value 'From SDI1'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From SDI0'
+			item.1 'From SDI1'
+			item.2 'From SDI2'
+			item.3 'From SDI3'
+		}
+	}
+	control.4 {
+		iface MIXER
+		name 'Receive PATH0 Source Select'
+		value 'From SDI0'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From SDI0'
+			item.1 'From SDI1'
+			item.2 'From SDI2'
+			item.3 'From SDI3'
+		}
+	}
+	control.5 {
+		iface MIXER
+		name 'Transmit SDO3 Source Select'
+		value 'From PATH3'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From PATH0'
+			item.1 'From PATH1'
+			item.2 'From PATH2'
+			item.3 'From PATH3'
+		}
+	}
+	control.6 {
+		iface MIXER
+		name 'Transmit SDO2 Source Select'
+		value 'From PATH2'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From PATH0'
+			item.1 'From PATH1'
+			item.2 'From PATH2'
+			item.3 'From PATH3'
+		}
+	}
+	control.7 {
+		iface MIXER
+		name 'Transmit SDO1 Source Select'
+		value 'From PATH1'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From PATH0'
+			item.1 'From PATH1'
+			item.2 'From PATH2'
+			item.3 'From PATH3'
+		}
+	}
+	control.8 {
+		iface MIXER
+		name 'Transmit SDO0 Source Select'
+		value 'From PATH0'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'From PATH0'
+			item.1 'From PATH1'
+			item.2 'From PATH2'
+			item.3 'From PATH3'
+		}
+	}
+	control.9 {
+		iface MIXER
+		name 'I2STDM Digital Loopback Mode'
+		value Disabled
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 Disabled
+			item.1 Mode1
+			item.2 Mode2
+			item.3 'Mode2 Swap'
+		}
+	}
+	control.10 {
+		iface PCM
+		name 'PCM Read Wait Time MS'
+		value 0
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 10000 (step 1)'
+		}
+	}
+	control.11 {
+		iface PCM
+		name 'PCM Write Wait Time MS'
+		value 0
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 10000 (step 1)'
+		}
+	}
+	control.12 {
+		iface MIXER
+		name 'Headphone Playback Volume'
+		value.0 3
+		value.1 3
+		comment {
+			access 'read write'
+			type INTEGER
+			count 2
+			range '0 - 3'
+			dbmin -4800
+			dbmax 0
+			dbvalue.0 0
+			dbvalue.1 0
+		}
+	}
+	control.13 {
+		iface MIXER
+		name 'Headphone Mixer Volume'
+		value.0 11
+		value.1 11
+		comment {
+			access 'read write'
+			type INTEGER
+			count 2
+			range '0 - 11'
+			dbmin -1200
+			dbmax 0
+			dbvalue.0 0
+			dbvalue.1 0
+		}
+	}
+	control.14 {
+		iface MIXER
+		name 'Playback Polarity'
+		value Normal
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 Normal
+			item.1 'R Invert'
+			item.2 'L Invert'
+			item.3 'L + R Invert'
+		}
+	}
+	control.15 {
+		iface MIXER
+		name 'DAC Playback Volume'
+		value.0 192
+		value.1 192
+		comment {
+			access 'read write'
+			type INTEGER
+			count 2
+			range '0 - 192'
+			dbmin -9999999
+			dbmax 0
+			dbvalue.0 0
+			dbvalue.1 0
+		}
+	}
+	control.16 {
+		iface MIXER
+		name 'DAC Soft Ramp Switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.17 {
+		iface MIXER
+		name 'DAC Soft Ramp Rate'
+		value 4
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 4'
+		}
+	}
+	control.18 {
+		iface MIXER
+		name 'DAC Notch Filter Switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.19 {
+		iface MIXER
+		name 'DAC Double Fs Switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.20 {
+		iface MIXER
+		name 'DAC Stereo Enhancement'
+		value 0
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 7'
+		}
+	}
+	control.21 {
+		iface MIXER
+		name 'DAC Mono Mix Switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.22 {
+		iface MIXER
+		name 'Capture Polarity'
+		value Normal
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 Normal
+			item.1 Invert
+		}
+	}
+	control.23 {
+		iface MIXER
+		name 'Mic Boost Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.24 {
+		iface MIXER
+		name 'ADC Capture Volume'
+		value 192
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 192'
+			dbmin -9999999
+			dbmax 0
+			dbvalue.0 0
+		}
+	}
+	control.25 {
+		iface MIXER
+		name 'ADC PGA Gain Volume'
+		value 10
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 10'
+			dbmin -350
+			dbmax 2400
+			dbvalue.0 2400
+		}
+	}
+	control.26 {
+		iface MIXER
+		name 'ADC Soft Ramp Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.27 {
+		iface MIXER
+		name 'ADC Double Fs Switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.28 {
+		iface MIXER
+		name 'ALC Capture Switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.29 {
+		iface MIXER
+		name 'ALC Capture Max Volume'
+		value 28
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 28'
+			dbmin -650
+			dbmax 3550
+			dbvalue.0 3550
+		}
+	}
+	control.30 {
+		iface MIXER
+		name 'ALC Capture Min Volume'
+		value 0
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 28'
+			dbmin -1200
+			dbmax 3000
+			dbvalue.0 -1200
+		}
+	}
+	control.31 {
+		iface MIXER
+		name 'ALC Capture Target Volume'
+		value 11
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 11'
+			dbmin -1650
+			dbmax -150
+			dbvalue.0 -150
+		}
+	}
+	control.32 {
+		iface MIXER
+		name 'ALC Capture Hold Time'
+		value 0
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 10'
+		}
+	}
+	control.33 {
+		iface MIXER
+		name 'ALC Capture Decay Time'
+		value 3
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 10'
+		}
+	}
+	control.34 {
+		iface MIXER
+		name 'ALC Capture Attack Time'
+		value 2
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 10'
+		}
+	}
+	control.35 {
+		iface MIXER
+		name 'ALC Capture Noise Gate Switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.36 {
+		iface MIXER
+		name 'ALC Capture Noise Gate Threshold'
+		value 0
+		comment {
+			access 'read write'
+			type INTEGER
+			count 1
+			range '0 - 31'
+		}
+	}
+	control.37 {
+		iface MIXER
+		name 'ALC Capture Noise Gate Type'
+		value 'Constant PGA Gain'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'Constant PGA Gain'
+			item.1 'Mute ADC Output'
+		}
+	}
+	control.38 {
+		iface MIXER
+		name 'spk switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.39 {
+		iface MIXER
+		name 'hp switch'
+		value false
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.40 {
+		iface MIXER
+		name 'Headphone Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.41 {
+		iface MIXER
+		name 'Speaker Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.42 {
+		iface MIXER
+		name 'Main Mic Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.43 {
+		iface MIXER
+		name 'Headset Mic Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.44 {
+		iface MIXER
+		name 'Differential Mux'
+		value 'lin1-rin1 with 20db Boost'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 lin1-rin1
+			item.1 lin2-rin2
+			item.2 'lin1-rin1 with 20db Boost'
+			item.3 'lin2-rin2 with 20db Boost'
+		}
+	}
+	control.45 {
+		iface MIXER
+		name 'Digital Mic Mux'
+		value 'dmic disable'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'dmic disable'
+			item.1 'dmic data at high level'
+			item.2 'dmic data at low level'
+		}
+	}
+	control.46 {
+		iface MIXER
+		name 'DAC Source Mux'
+		value 'LDATA TO LDAC, RDATA TO RDAC'
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 'LDATA TO LDAC, RDATA TO RDAC'
+			item.1 'LDATA TO LDAC, LDATA TO RDAC'
+			item.2 'RDATA TO LDAC, RDATA TO RDAC'
+			item.3 'RDATA TO LDAC, LDATA TO RDAC'
+		}
+	}
+	control.47 {
+		iface MIXER
+		name 'Left Headphone Mux'
+		value lin2-rin2
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 lin1-rin1
+			item.1 lin2-rin2
+			item.2 'lin-rin with Boost'
+			item.3 'lin-rin with Boost and PGA'
+		}
+	}
+	control.48 {
+		iface MIXER
+		name 'Right Headphone Mux'
+		value lin2-rin2
+		comment {
+			access 'read write'
+			type ENUMERATED
+			count 1
+			item.0 lin1-rin1
+			item.1 lin2-rin2
+			item.2 'lin-rin with Boost'
+			item.3 'lin-rin with Boost and PGA'
+		}
+	}
+	control.49 {
+		iface MIXER
+		name 'Left Headphone Mixer LLIN Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.50 {
+		iface MIXER
+		name 'Left Headphone Mixer Left DAC Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.51 {
+		iface MIXER
+		name 'Right Headphone Mixer RLIN Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+	control.52 {
+		iface MIXER
+		name 'Right Headphone Mixer Right DAC Switch'
+		value true
+		comment {
+			access 'read write'
+			type BOOLEAN
+			count 1
+		}
+	}
+}
Index: patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-headphone-auto-switch.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-headphone-auto-switch.patch b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-headphone-auto-switch.patch
new file mode 100644
--- /dev/null	(date 1785280622803)
+++ b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-headphone-auto-switch.patch	(date 1785280622803)
@@ -0,0 +1,36 @@
+From 0b8b0f2ec96ca78840edca736b976f4fc05f15f4 Mon Sep 17 00:00:00 2001
+From: OpenAI <noreply@openai.com>
+Date: Wed, 29 Jul 2026 00:00:00 +0200
+Subject: [PATCH] arm64: dts: rockchip: add GenBook headphone detect and
+ speaker pin switch
+
+The vendor GenBook device tree uses GPIO1_B5 as the analogue jack detect
+input. The mainline audio-graph-card has no jack-detect GPIO, so no ALSA
+jack control is created and userspace cannot select headphones when the
+plug is inserted.
+
+Describe the same active-high detect GPIO using audio-graph-card's
+hp-det-gpios property. Also expose a DAPM Speaker Switch. The matching
+UCM profile disables this switch for the headphone route, which powers
+down the external speaker amplifier controlled by pa-gpios.
+
+---
+ .../dts/rockchip/rk3588-coolpi-cm5-genbook.dts       | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+index 0c4e013..2d5f37c 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+@@ -161,7 +161,9 @@
+ };
+
+ &{/analog-sound} {
++	hp-det-gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>;
+ 	pa-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
++	pin-switches = "Speaker";
+ 	routing = "MIC2", "Mic Jack",
+ 		  "Headphones", "HPOL",
+ 		  "Headphones", "HPOR",
+-- 
+2.50.1
Index: userpatches/customize-image.sh
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/userpatches/customize-image.sh b/userpatches/customize-image.sh
new file mode 100755
--- /dev/null	(date 1785364923796)
+++ b/userpatches/customize-image.sh	(date 1785364923796)
@@ -0,0 +1,211 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+install -d -m 0755 /usr/share/alsa/ucm2/Rockchip/rk3588-es8316
+
+cat > /usr/share/alsa/ucm2/Rockchip/rk3588-es8316/HiFi.conf <<'__COOLPI_GENBOOK_UCM_V3_EOF__'
+SectionDevice."Speaker" {
+	Comment "Internal Speakers"
+
+	ConflictingDevice [
+		"Headphones"
+	]
+
+	EnableSequence [
+		cset "name='Speaker Switch' on"
+	]
+
+	DisableSequence [
+		cset "name='Speaker Switch' off"
+	]
+
+	Value {
+		PlaybackPriority 100
+		PlaybackPCM "hw:${CardId}"
+		PlaybackMixerElem "Headphone Mixer"
+		PlaybackMasterElem "DAC"
+	}
+}
+
+SectionDevice."Headphones" {
+	Comment "Headphones"
+
+	ConflictingDevice [
+		"Speaker"
+	]
+
+	EnableSequence [
+		cset "name='Speaker Switch' off"
+	]
+
+	Value {
+		PlaybackPriority 200
+		PlaybackPCM "hw:${CardId}"
+		PlaybackMixerElem "Headphone Mixer"
+		PlaybackMasterElem "DAC"
+		JackControl "Headphones Jack"
+	}
+}
+
+SectionDevice."Headset" {
+	Comment "Headset Microphone on IN2"
+
+	EnableSequence [
+		cset "name='Differential Mux' lin2-rin2"
+		cset "name='Left Headphone Mux' lin2-rin2"
+		cset "name='Right Headphone Mux' lin2-rin2"
+	]
+
+	DisableSequence [
+		cset "name='Differential Mux' lin1-rin1"
+		cset "name='Left Headphone Mux' lin1-rin1"
+		cset "name='Right Headphone Mux' lin1-rin1"
+	]
+
+	Value {
+		CapturePriority 200
+		CapturePCM "hw:${CardId}"
+		CaptureMixerElem "ADC PGA Gain"
+		CaptureMasterElem "ADC"
+	}
+}
+__COOLPI_GENBOOK_UCM_V3_EOF__
+
+chmod 0644 /usr/share/alsa/ucm2/Rockchip/rk3588-es8316/HiFi.conf
+
+# BEGIN COOLPI_GENBOOK_AUDIO_UCM_V4
+UCM_CARD=/usr/share/alsa/ucm2/conf.d/rk3588-es8316/rk3588-es8316.conf
+UCM_HIFI=/usr/share/alsa/ucm2/Rockchip/rk3588-es8316/HiFi.conf
+
+install -d -m 0755 "$(dirname "$UCM_CARD")" "$(dirname "$UCM_HIFI")"
+
+# Keep our board-specific profiles across future alsa-ucm-conf updates.
+for target in "$UCM_CARD" "$UCM_HIFI"; do
+	if ! dpkg-divert --list "$target" | grep -q .; then
+		dpkg-divert --local --rename --add "$target"
+	fi
+done
+
+cat > "$UCM_CARD" <<'__COOLPI_GENBOOK_UCM_CARD_V4_EOF__'
+Syntax 3
+
+SectionUseCase."HiFi" {
+	File "/Rockchip/rk3588-es8316/HiFi.conf"
+	Comment "CoolPi GenBook HiFi"
+}
+
+BootSequence [
+	# Playback defaults
+	cset "name='Headphone Playback Volume' 3"
+	cset "name='Headphone Mixer Volume' 11"
+	cset "name='DAC Playback Volume' 192"
+	cset "name='Left Headphone Mixer Left DAC Switch' on"
+	cset "name='Right Headphone Mixer Right DAC Switch' on"
+
+	# Internal analogue microphone defaults
+	cset "name='ALC Capture Switch' off"
+	cset "name='ADC Capture Volume' 192"
+	cset "name='ADC PGA Gain Volume' 9"
+	cset "name='Digital Mic Mux' 'dmic disable'"
+	cset "name='Differential Mux' lin1-rin1"
+	cset "name='Main Mic Switch' on"
+	cset "name='Mic Boost Switch' on"
+]
+__COOLPI_GENBOOK_UCM_CARD_V4_EOF__
+
+cat > "$UCM_HIFI" <<'__COOLPI_GENBOOK_UCM_HIFI_V4_EOF__'
+SectionDevice."Speaker" {
+	Comment "Internal Speakers"
+
+	ConflictingDevice [
+		"Headphones"
+	]
+
+	EnableSequence [
+		cset "name='Speaker Switch' on"
+	]
+
+	DisableSequence [
+		cset "name='Speaker Switch' off"
+	]
+
+	Value {
+		PlaybackPriority 100
+		PlaybackPCM "hw:${CardId}"
+		PlaybackMixerElem "Headphone Mixer"
+		PlaybackMasterElem "DAC"
+	}
+}
+
+SectionDevice."Headphones" {
+	Comment "Headphones"
+
+	ConflictingDevice [
+		"Speaker"
+	]
+
+	EnableSequence [
+		cset "name='Speaker Switch' off"
+	]
+
+	Value {
+		PlaybackPriority 200
+		PlaybackPCM "hw:${CardId}"
+		PlaybackMixerElem "Headphone Mixer"
+		PlaybackMasterElem "DAC"
+		JackControl "Headphones Jack"
+	}
+}
+
+SectionDevice."Mic" {
+	Comment "Internal Microphone"
+
+	ConflictingDevice [
+		"Headset"
+	]
+
+	EnableSequence [
+		cset "name='Digital Mic Mux' 'dmic disable'"
+		cset "name='Differential Mux' lin1-rin1"
+		cset "name='Main Mic Switch' on"
+		cset "name='Mic Boost Switch' on"
+	]
+
+	Value {
+		CapturePriority 300
+		CapturePCM "hw:${CardId}"
+		CaptureMixerElem "ADC PGA Gain"
+		CaptureMasterElem "ADC"
+	}
+}
+
+SectionDevice."Headset" {
+	Comment "Headset Microphone"
+
+	ConflictingDevice [
+		"Mic"
+	]
+
+	EnableSequence [
+		cset "name='Digital Mic Mux' 'dmic disable'"
+		cset "name='Differential Mux' lin2-rin2"
+		cset "name='Main Mic Switch' on"
+		cset "name='Mic Boost Switch' on"
+	]
+
+	DisableSequence [
+		cset "name='Differential Mux' lin1-rin1"
+	]
+
+	Value {
+		CapturePriority 200
+		CapturePCM "hw:${CardId}"
+		CaptureMixerElem "ADC PGA Gain"
+		CaptureMasterElem "ADC"
+		JackControl "Headphones Jack"
+	}
+}
+__COOLPI_GENBOOK_UCM_HIFI_V4_EOF__
+
+chmod 0644 "$UCM_CARD" "$UCM_HIFI"
+# END COOLPI_GENBOOK_AUDIO_UCM_V4
Index: patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-led-behavior.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-led-behavior.patch b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-led-behavior.patch
new file mode 100644
--- /dev/null	(date 1785278641232)
+++ b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-led-behavior.patch	(date 1785278641232)
@@ -0,0 +1,41 @@
+From 2d07a9a1839802db7f43b641848a9a831bf2bd59 Mon Sep 17 00:00:00 2001
+From: OpenAI <noreply@openai.com>
+Date: Wed, 29 Jul 2026 00:00:00 +0200
+Subject: [PATCH] arm64: dts: rockchip: fix GenBook front LED functions
+
+The first green LED is physically used as the power indicator, so keep it
+solid instead of using the heartbeat trigger.
+
+Use the second green LED for block-device activity instead of leaving the
+mainline WLAN LED without a trigger.
+
+Leave the red charging LED unchanged until charging-state integration is
+implemented.
+
+---
+ .../dts/rockchip/rk3588-coolpi-cm5-genbook.dts | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+index 0c4e013..4d39e1b 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+@@ -136,6 +136,16 @@
+ 	};
+ };
+
++&heartbeat_led {
++	function = LED_FUNCTION_POWER;
++	linux,default-trigger = "default-on";
++};
++
++&wlan_led {
++	function = LED_FUNCTION_DISK_ACTIVITY;
++	linux,default-trigger = "disk-activity";
++};
++
+ &edp1 {
+ 	force-hpd;
+ 	status = "okay";
+-- 
+2.50.1
Index: config/boards/coolpi-genbook.csc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/config/boards/coolpi-genbook.csc b/config/boards/coolpi-genbook.csc
--- a/config/boards/coolpi-genbook.csc	(revision c0a5915562ca65ac4e68fd7c9e6bf1c579afd55f)
+++ b/config/boards/coolpi-genbook.csc	(date 1785267288309)
@@ -15,6 +15,7 @@
 BOOT_SUPPORT_SPI="yes"
 BOOT_SPI_RKSPI_LOADER="yes"
 IMAGE_PARTITION_TABLE="gpt"
+ASOUND_STATE="asound.state.coolpi-genbook"
 
 # Mainline U-Boot
 function post_family_config__coolpi-genbook_use_mainline_uboot() {
Index: patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-edge-platform-fixes-v2.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-edge-platform-fixes-v2.patch b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-edge-platform-fixes-v2.patch
new file mode 100644
--- /dev/null	(date 1785275795987)
+++ b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-edge-platform-fixes-v2.patch	(date 1785275795987)
@@ -0,0 +1,97 @@
+From 5fd46c6084934080bbd2b4e4e5d0aef901ce9850 Mon Sep 17 00:00:00 2001
+From: OpenAI <noreply@openai.com>
+Date: Tue, 28 Jul 2026 00:00:00 +0200
+Subject: [PATCH] arm64: dts: rockchip: fix GenBook speakers, USB-C host and
+ poweroff
+
+The GenBook uses an external speaker amplifier controlled by GPIO1_A6,
+but the mainline audio-graph-card only describes the headphone path.
+Describe the speaker endpoint and use audio-graph-card's pa-gpios support
+to sequence the amplifier. No separate pinctrl state is required because
+the Rockchip GPIO controller requests the pin in GPIO mode.
+
+The Type-C DWC3 controller is currently forced to peripheral USB 2.0 mode
+and has no VBUS supply. Configure the port as a fixed host, add the
+board's GPIO0_A0 controlled 5 V OTG rail, and remove the high-speed cap.
+
+The RK806 is the board's system PMIC. Mark it as the system power
+controller so poweroff reaches the PMIC instead of stopping with the
+machine still powered.
+
+This intentionally does not add the vendor HUSB311/FUSB302 Type-C/PD and
+DisplayPort Alt Mode graph. USB host devices should work, while USB-C
+display output may still need a separate controller/connector port.
+
+---
+ .../dts/rockchip/rk3588-coolpi-cm5-genbook.dts | 43 +++++++++++++++++-
+ 1 file changed, 41 insertions(+), 2 deletions(-)
+
+diff --git a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+index e1ed29e..0c4e013 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+@@ -133,6 +133,45 @@
+ 		pinctrl-0 = <&usb_host_pwren>;
+ 		vin-supply = <&vcc5v0_usb>;
+ 	};
++
++	/*
++	 * The vendor GenBook DT calls this rail vcc5v0_otg and controls it
++	 * with GPIO0_A0. The mainline DT already provides the matching
++	 * usb_otg_pwren pin group, but did not instantiate the regulator.
++	 *
++	 * Keep it on because the mainline board description below uses a
++	 * fixed host role until the Type-C/PD controller graph is ported.
++	 */
++	vcc5v0_otg: regulator-vcc5v0-otg {
++		compatible = "regulator-fixed";
++		regulator-name = "vcc5v0_otg";
++		regulator-boot-on;
++		regulator-always-on;
++		enable-active-high;
++		regulator-min-microvolt = <5000000>;
++		regulator-max-microvolt = <5000000>;
++		gpio = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>;
++		pinctrl-names = "default";
++		pinctrl-0 = <&usb_otg_pwren>;
++		vin-supply = <&vcc5v0_sys>;
++	};
++};
++
++&{/analog-sound} {
++	pa-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
++	routing = "MIC2", "Mic Jack",
++		  "Headphones", "HPOL",
++		  "Headphones", "HPOR",
++		  "Amplifier", "HPOL",
++		  "Amplifier", "HPOR",
++		  "Speaker", "Amplifier";
++	widgets = "Microphone", "Mic Jack",
++		  "Headphone", "Headphones",
++		  "Speaker", "Speaker";
++};
++
++&{/spi@feb20000/pmic@0} {
++	system-power-controller;
+ };
+
+ &edp1 {
+@@ -302,6 +341,7 @@
+ };
+
+ &u2phy0_otg {
++	phy-supply = <&vcc5v0_otg>;
+ 	status = "okay";
+ };
+
+@@ -338,7 +378,6 @@
+
+ /* Type C port */
+ &usb_host0_xhci {
+-	dr_mode = "peripheral";
+-	maximum-speed = "high-speed";
++	dr_mode = "host";
+ 	status = "okay";
+ };
+-- 
+2.50.1
Index: config/kernel/linux-rk35xx-vendor.config
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/config/kernel/linux-rk35xx-vendor.config b/config/kernel/linux-rk35xx-vendor.config
--- a/config/kernel/linux-rk35xx-vendor.config	(revision c0a5915562ca65ac4e68fd7c9e6bf1c579afd55f)
+++ b/config/kernel/linux-rk35xx-vendor.config	(date 1785267288408)
@@ -1286,6 +1286,7 @@
 CONFIG_POWER_RESET_GPIO=y
 CONFIG_POWER_RESET_GPIO_RESTART=y
 CONFIG_SYSCON_REBOOT_MODE=y
+CONFIG_BATTERY_CW2015=y
 CONFIG_BATTERY_CW2017=y
 CONFIG_BATTERY_SBS=y
 CONFIG_BATTERY_MAX17042=y
@@ -2096,6 +2097,7 @@
 CONFIG_HID_STEAM=m
 CONFIG_HID_STEELSERIES=m
 CONFIG_HID_WIIMOTE=m
+CONFIG_I2C_HID_OF=m
 CONFIG_USB_HIDDEV=y
 CONFIG_USB_LED_TRIG=y
 CONFIG_USB_ULPI_BUS=m
Index: coolpi-genbook_7.1.5.patch
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/coolpi-genbook_7.1.5.patch b/coolpi-genbook_7.1.5.patch
new file mode 100644
--- /dev/null	(date 1785363613137)
+++ b/coolpi-genbook_7.1.5.patch	(date 1785363613137)
@@ -0,0 +1,124 @@
+Subject: [PATCH] coolpi-genbook: select the internal ES8316 microphone input
+
+The saved mixer state selected lin2-rin2 (MIC2), which is normally used by
+an external/headset microphone.  The GenBook internal microphone is connected
+to the MIC1 differential input, so select lin1-rin1 instead.
+
+This keeps the existing ADC gain, mic boost and playback settings unchanged.
+---
+Index: patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-dp-altmode.patch
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-dp-altmode.patch b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-dp-altmode.patch
+new file mode 100644
+--- /dev/null	(date 1785363547448)
++++ b/patch/kernel/archive/rockchip64-7.1/board-coolpi-genbook-usbc-dp-altmode.patch	(date 1785363547448)
+@@ -0,0 +1,106 @@
++From e5c9ee061784750cf8a77309543fbf68cd639a32 Mon Sep 17 00:00:00 2001
++From: OpenAI <noreply@openai.com>
++Date: Thu, 30 Jul 2026 01:20:00 +0300
++Subject: [PATCH] arm64: dts: rockchip: add GenBook USB-C DisplayPort Alt
++ Mode
++
++USB data, VBUS, role switching and cable orientation are already working
++through the HUSB311/RT1711H TCPC.
++
++Add the DisplayPort Alt Mode endpoint between the USB-C connector and the
++RK3588 USBDP PHY. Enable the PHY mode switch and the board SBU DC-control
++GPIOs copied from the working vendor device tree.
++
++Enable DP0 and route the otherwise unused VOP video port 1 to it. HDMI
++output on the tested dock is implemented by converting this DisplayPort
++Alt Mode signal inside the dock.
++
++---
++diff --git a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
++index 8100e09..4e8cf88 100644
++--- a/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
+++++ b/arch/arm64/boot/dts/rockchip/rk3588-coolpi-cm5-genbook.dts
++@@ -405,11 +405,41 @@
++ 							<&dwc3_0_role_switch>;
++ 					};
++ 				};
+++
+++				port@2 {
+++					reg = <2>;
+++
+++					dp_altmode_mux: endpoint {
+++						remote-endpoint =
+++							<&usbdp_phy0_dp_altmode_mux>;
+++					};
+++				};
+++			};
+++
+++			altmodes {
+++				#address-cells = <1>;
+++				#size-cells = <0>;
+++
+++				altmode@0 {
+++					reg = <0>;
+++					svid = <0xff01>;
+++					vdo = <0xffffffff>;
+++				};
++ 			};
++ 		};
++ 	};
++ };
++ 
+++&dp0 {
+++	status = "okay";
+++};
+++
+++&dp0_in {
+++	dp0_in_vp1: endpoint {
+++		remote-endpoint = <&vp1_out_dp0>;
+++	};
+++};
+++
++ &pinctrl {
++ 	usb-typec {
++ 		usbc0_int: usbc0-int {
++@@ -424,12 +454,24 @@
++ };
++ 
++ &usbdp_phy0 {
+++	mode-switch;
++ 	orientation-switch;
+++	sbu1-dc-gpios = <&gpio4 RK_PA4 GPIO_ACTIVE_HIGH>;
+++	sbu2-dc-gpios = <&gpio4 RK_PA5 GPIO_ACTIVE_HIGH>;
++ 
++ 	port {
++-		usbdp_phy0_orientation_switch: endpoint {
+++		#address-cells = <1>;
+++		#size-cells = <0>;
+++
+++		usbdp_phy0_orientation_switch: endpoint@0 {
+++			reg = <0>;
++ 			remote-endpoint = <&usbc0_orien_sw>;
++ 		};
+++
+++		usbdp_phy0_dp_altmode_mux: endpoint@1 {
+++			reg = <1>;
+++			remote-endpoint = <&dp_altmode_mux>;
+++		};
++ 	};
++ };
++ 
++@@ -438,6 +480,13 @@
++ 	/delete-property/ regulator-boot-on;
++ };
++ 
+++&vp1 {
+++	vp1_out_dp0: endpoint@ROCKCHIP_VOP2_EP_DP0 {
+++		reg = <ROCKCHIP_VOP2_EP_DP0>;
+++		remote-endpoint = <&dp0_in_vp1>;
+++	};
+++};
+++
++ /* Type C port */
++ &usb_host0_xhci {
++ 	dr_mode = "otg";
++-- 
++2.50.1
