aboutsummaryrefslogtreecommitdiff
path: root/TOOLS
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2023-11-19 03:36:24 +0100
committerJan200101 <sentrycraft123@gmail.com>2023-11-19 03:36:24 +0100
commitfd2abdd6bc1d035b90c0b5238bdc097461bc87ab (patch)
tree0fced873b61338b6f349ff1dcbe4db97ea294db3 /TOOLS
parentd258683ce35c01f79fa749fbc64dfdab53d0e69e (diff)
downloadkernel-fsync-fd2abdd6bc1d035b90c0b5238bdc097461bc87ab.tar.gz
kernel-fsync-fd2abdd6bc1d035b90c0b5238bdc097461bc87ab.zip
kernel 6.5.11 Steam Deck fixes
add patching scripts, update configs for the Steam Deck (Dual Role Device support is now required for USB interfacing)
Diffstat (limited to 'TOOLS')
-rwxr-xr-xTOOLS/bumpspec.sh25
-rwxr-xr-xTOOLS/patch_configs.py186
2 files changed, 211 insertions, 0 deletions
diff --git a/TOOLS/bumpspec.sh b/TOOLS/bumpspec.sh
new file mode 100755
index 0000000..00062b8
--- /dev/null
+++ b/TOOLS/bumpspec.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+set -eu
+
+if [[ $# != 2 ]]; then
+ >&2 echo "error: bumpspec requires 2 arguments"
+ exit 1
+fi
+
+COMMENT="${1}"
+SPEC="${2}"
+
+SPECRELEASE="$(grep "%define specrelease " ${SPEC})"
+# assumes the release number is 3 digits
+SPECRELEASE_NUMBER="$(echo ${SPECRELEASE} | cut -b 21-23)"
+
+NEW_SPECRELEASE_NUMBER="$(( ${SPECRELEASE_NUMBER} + 1))"
+NEW_SPECRELEASE="${SPECRELEASE/${SPECRELEASE_NUMBER}/${NEW_SPECRELEASE_NUMBER}}"
+
+echo ${NEW_SPECRELEASE}
+
+sed -i "s|${SPECRELEASE}|${NEW_SPECRELEASE}|g" ${SPEC}
+
+rpmdev-bumpspec --comment="${COMMENT}" ${SPEC}
+
+sed -i "s|%{pkg_release}.1|%{pkg_release}|g" ${SPEC}
diff --git a/TOOLS/patch_configs.py b/TOOLS/patch_configs.py
new file mode 100755
index 0000000..a1447e0
--- /dev/null
+++ b/TOOLS/patch_configs.py
@@ -0,0 +1,186 @@
+#!/usr/bin/env python3
+import sys
+import os
+
+CONFIG_FILE_EXT = ".config"
+
+UNSET = "unset"
+DISABLE = "n"
+ENABLE = "y"
+MODULE = "m"
+
+GENERIC_PATCHES = [
+ # kernel-fsync config
+ ["I2C_NCT6775", None, MODULE],
+ ["ZENIFY", None, ENABLE],
+ ["FB_SIMPLE", UNSET, ENABLE],
+ ["FB_EFI", UNSET, ENABLE],
+ ["FB_VESA", UNSET, ENABLE],
+ ["ACPI_EC_DEBUGFS", UNSET, MODULE],
+
+ # device specific config
+ # Microsoft Surface
+ ["HID_IPTS", None, MODULE],
+ ["HID_ITHC", None, MODULE],
+ ["SURFACE_BOOK1_DGPU_SWITCH", None, MODULE],
+ ["VIDEO_DW9719", None, MODULE],
+ ["IPC_CLASSES", None, ENABLE],
+ ["LEDS_TPS68470", None, MODULE],
+ # Lenovo Legion
+ ["LEGION_LAPTOP", None, MODULE],
+]
+
+ARCH_PATCHES = {
+ "x86_64": [
+ # Steam Deck
+ ["MFD_STEAMDECK", None, MODULE],
+ ["SENSORS_STEAMDECK", None, MODULE],
+ ["LEDS_STEAMDECK", None, MODULE],
+ ["EXTCON_STEAMDECK", None, MODULE],
+ # Required by the Steam Deck for DRD, otherwise USB is borked
+ ["USB_DWC3", None, MODULE],
+ ["USB_DWC3_ULPI", None, ENABLE],
+ ["USB_DWC3_DUAL_ROLE", None, ENABLE],
+ ["USB_DWC3_PCI", None, MODULE],
+ ["USB_DWC3_HAPS", None, MODULE],
+ ["USB_DWC2", None, MODULE],
+ ["USB_DWC2_DUAL_ROLE", None, ENABLE],
+ ["USB_DWC2_PCI", None, MODULE],
+ ["USB_DWC2_DEBUG", None, UNSET],
+ ["USB_DWC2_TRACK_MISSED_SOFS", None, UNSET],
+ ["USB_CHIPIDEA", None, MODULE],
+ ["USB_CHIPIDEA_UDC", None, ENABLE],
+ ["USB_CHIPIDEA_HOST", None, ENABLE],
+ ["USB_CHIPIDEA_PCI", None, MODULE],
+ ["USB_CHIPIDEA_MSM", None, MODULE],
+ ["USB_CHIPIDEA_GENERIC", None, MODULE],
+ ["USB_ISP1760", None, MODULE],
+ ["USB_ISP1760_HCD", None, ENABLE],
+ ["USB_ISP1761_UDC", None, ENABLE],
+ ["USB_ISP1760_DUAL_ROLE", None, ENABLE],
+ ["USB_GADGET", None, MODULE],
+ ["USB_GADGET_VBUS_DRAW", None, "2"],
+ ["USB_GADGET_STORAGE_NUM_BUFFERS", None, "2"],
+ ["USB_GADGET_DEBUG", None, UNSET],
+ ["USB_GADGET_DEBUG_FILES", None, UNSET],
+ ["USB_GADGET_DEBUG_FS", None, UNSET],
+ ["U_SERIAL_CONSOLE", None, UNSET],
+ ["USB_R8A66597", None, UNSET],
+ ["USB_PXA27X", None, UNSET],
+ ["USB_MV_UDC", None, UNSET],
+ ["USB_MV_U3D", None, UNSET],
+ ["USB_M66592", None, UNSET],
+ ["USB_BDC_UDC", None, UNSET],
+ ["USB_AMD5536UDC", None, UNSET],
+ ["USB_NET2272", None, UNSET],
+ ["USB_NET2280", None, UNSET],
+ ["USB_GOKU", None, UNSET],
+ ["USB_EG20T", None, UNSET],
+ ["USB_DUMMY_HCD", None, UNSET],
+ ["USB_CONFIGFS", None, UNSET],
+ ["PHY_SAMSUNG_USB2", None, UNSET],
+ ],
+}
+
+def generate_line(c, v) -> str:
+ if v == UNSET:
+ v = f"# {c} is not set"
+ else:
+ v = f"{c}={v}"
+ return v
+
+def apply_patches(data: str, patches, flags = None) -> str:
+ if flags is None:
+ flags = []
+
+ for name, *val in patches:
+ c = f"CONFIG_{name}"
+
+ s = f"{c}="
+ u = f"# {c} "
+
+ if len(val) == 3 and val[2] not in flags:
+ print(f" Skipping {name}")
+ continue
+
+ if any(x in data for x in [s, u]):
+ try:
+ i = data.index(s)
+ except ValueError:
+ i = data.index(u)
+
+ try:
+ line_start = data.rindex("\n", 0, i)+1
+ except ValueError:
+ # No newline before the config?
+ # Probably the first line in the file
+ line_start = 0
+
+ line_end = data.index("\n", line_start)
+
+ line = data[line_start:line_end]
+
+ if val[0] is not None:
+ # verify we found what we expect
+ l = generate_line(c, val[0])
+ if l != line:
+ #print(f" Could not apply {name}: could not find expected config")
+ continue
+ data = data[:line_start] + generate_line(c, val[1]) + data[line_end:]
+
+ elif val[0] is None:
+ # relevant entry does not exist yet and we don't want to replace anything specific
+ data += generate_line(c, val[1])
+ data += "\n"
+ else:
+ print(f" Couldn't find {name}")
+ exit(1)
+
+ return data
+
+CONFIG_FILES = sys.argv[1:]
+if not CONFIG_FILES:
+ print("No config files given")
+ exit(1)
+
+# Verify all given inputs first before working with them
+for file in CONFIG_FILES:
+ if not os.path.isfile(file):
+ print(f"{file} does not exist")
+ exit(1)
+
+ filename = os.path.basename(file)
+ if not filename.endswith(CONFIG_FILE_EXT):
+ print(f"{file} does not have the right file extension")
+ exit(1)
+
+ namesegs = filename[:-len(CONFIG_FILE_EXT)].split("-")
+ if len(namesegs) < 3:
+ print(f"{file} does not have the right number of segments")
+ exit(1)
+
+for file in CONFIG_FILES:
+ filename = os.path.basename(file)
+ print(f"Processing {filename}...")
+
+ namesegs = filename[:-len(CONFIG_FILE_EXT)].split("-")
+ namesegs.pop(0)
+
+ arch = namesegs.pop(0)
+ flavor = namesegs.pop(-1)
+ flags = namesegs
+ if "debug" not in flags:
+ flags.append("release")
+
+ with open(file, "r+") as fd:
+ data = fd.read()
+ fd.seek(0)
+
+ data = apply_patches(data, GENERIC_PATCHES, flags)
+ if arch in ARCH_PATCHES:
+ data = apply_patches(data, ARCH_PATCHES[arch], flags)
+
+ fd.write(data)
+ fd.truncate()
+
+ data = open(file, "r").read()