# Vanilla upstream kernel plus the Surface Pro 12" (Snapdragon X1P-42-100) # patch set from the miasvanklei Gentoo overlay, packaged for Fedora. # # Build inputs are produced by make-sources.sh in this directory; see README.md. # Upstream tarball version. For a release candidate this is the git.kernel.org # snapshot name (linux-7.3-rc1); for a stable release it is the tarball name # from cdn.kernel.org (linux-7.2.3). # # Both versions here are defaults, for a build driven straight off a checkout. # The release pipeline reads them out of the git tag it was triggered by and # passes them in with --define, which takes precedence -- so keep the plain # `%%global ` shape, which make-sources.sh reads with awk. %if %{undefined upstream_ver} %global upstream_ver 7.2.4 %endif # Bumped whenever the patch tarball changes without the upstream version moving. %if %{undefined patchset_ver} %global patchset_ver 1 %endif # rpm gives - to the version-release separator, so it cannot appear in Version # itself. A release candidate's own Makefile reports the version it leads up to # anyway -- 7.3-rc1 builds 7.3.0 -- and %%prep drops the EXTRAVERSION that would # otherwise carry the -rcN into uname -r. A stable version passes through. %global kversion %(echo %{upstream_ver} | sed -e 's/-rc[0-9]*$/.0/') # The kernel's own release string: what uname -r reports and what names # /usr/lib/modules/<...>. Matches Fedora's -. convention. %global kverrel %{version}-%{release}.%{_target_cpu} # No -debuginfo: modules are stripped at install time via INSTALL_MOD_STRIP. %global debug_package %{nil} %global _missing_build_ids_terminate_build 0 # rpm's kernel module file attribute would decorate every .ko with # kernel() provides and requires, which only Fedora's own split kernel # packaging can satisfy. Keep the module tree out of the dependency generator # entirely; the dependencies this package really has are declared by hand below. %global __provides_exclude_from ^/usr/lib/(modules|surface-dtb)/.*$ %global __requires_exclude_from ^/usr/lib/(modules|surface-dtb)/.*$ Name: kernel-surface Version: %{kversion} Release: %{patchset_ver}%{?dist} Summary: Linux kernel for the Microsoft Surface Pro 12-inch (Snapdragon X1P-42-100) License: GPL-2.0-only URL: https://github.com/miasvanklei/Gentoo-overlay ExclusiveArch: aarch64 Source0: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/snapshot/linux-%{upstream_ver}.tar.gz Source1: kernel-surface-patches-%{upstream_ver}-%{patchset_ver}.tar.gz Source2: base-aarch64.config Source3: surface.config Source4: live-image.config Source5: no-debug-info.config Source6: foreign-socs.config BuildRequires: bc BuildRequires: binutils BuildRequires: bison BuildRequires: bzip2 BuildRequires: diffutils BuildRequires: elfutils-devel BuildRequires: elfutils-libelf-devel BuildRequires: findutils BuildRequires: flex BuildRequires: gcc BuildRequires: gzip BuildRequires: hostname BuildRequires: kmod BuildRequires: make BuildRequires: openssl BuildRequires: openssl-devel BuildRequires: patch BuildRequires: perl-interpreter BuildRequires: python3 BuildRequires: rsync BuildRequires: tar BuildRequires: xz BuildRequires: zstd Requires: dracut Requires: kmod Requires: linux-firmware Requires: systemd >= 254 # This package stands in for the whole of Fedora's split kernel packaging, so # anything with a plain `Requires: kernel-core` (anaconda, dracut config, # desktop groups) resolves against it. It deliberately does not Obsolete the # Fedora packages: the KIWI description picks this one by name and s # the Fedora ones, which keeps the repo safe to enable on a normal system. Provides: kernel = %{version}-%{release} Provides: kernel-core = %{version}-%{release} Provides: kernel-modules = %{version}-%{release} Provides: kernel-modules-core = %{version}-%{release} Provides: kernel-modules-extra = %{version}-%{release} Provides: kernel-uname-r = %{kverrel} Provides: kernel-core-uname-r = %{kverrel} Provides: kernel-modules-uname-r = %{kverrel} Provides: kernel-modules-core-uname-r = %{kverrel} Provides: kernel-modules-extra-uname-r = %{kverrel} Provides: installonlypkg(kernel) # Fedora's kernel-uki-dtbloader carries ~3000 boards' device trees and conflicts # with a plain kernel image package; this board is not in its database anyway. Conflicts: kernel-uki-dtbloader %description The Linux kernel built from vanilla upstream sources with the Microsoft Surface Pro 12-inch (Snapdragon X1P-42-100) patch set from the miasvanklei Gentoo overlay applied. Beyond the device tree for the board, the patch set adds a Surface Aggregator Module RTC driver, a suspend workaround for the aggregator controller, CAMSS and CSI-2 D-PHY support for the tablet's cameras, remoteproc attach support for the already-running DSPs, and assorted clock, PCI and interrupt controller fixes for the platform. This package provides kernel, kernel-core, kernel-modules and kernel-modules-extra, so it can be installed in place of Fedora's kernel packages. %prep %setup -q -n linux-%{upstream_ver} -a 1 # Apply every patch directory in the order given by patch-order.txt, which # make-sources.sh encoded into the tarball's directory names. # # The patch flags are Portage's eapply flags (patch -p1 -f -g0 # --no-backup-if-mismatch), which is what the overlay's patches are maintained # against: they carry stale context lines from before upstream refactors and # only apply at GNU patch's default fuzz of 2. Forcing --fuzz=0 here rejects # roughly a fifth of the set. What guards against a silently mis-applied patch # is not the fuzz level but the .config and kernelrelease assertions below. for patchdir in patches/*/; do for patchfile in "${patchdir}"*.patch; do [ -e "${patchfile}" ] || continue echo "Applying ${patchfile}" patch -p1 -f -g0 --no-backup-if-mismatch -i "${patchfile}" done done rm -rf patches # The camera series calls devm_phy_get_by_of_node(), which only the phy series # adds -- and the overlay's own 7.2.3 ebuild left phy out of its loop while # shipping the camera patch that needs it. Applying one without the other # compiles for twenty-odd minutes before failing in camss-csiphy.c, so assert # the declaration is here while it is still cheap to say so. grep -q 'devm_phy_get_by_of_node' include/linux/phy/phy.h || { echo "ERROR: include/linux/phy/phy.h does not declare devm_phy_get_by_of_node." echo "The camera patches need the phy ones; check phy is in patch-order.txt" echo "and that it exists at the pinned overlay commit." exit 1 } # Fold the -rcN suffix into the package release instead of carrying it in # uname -r, so the module directory is named the way Fedora names it. sed -i 's/^EXTRAVERSION[[:space:]]*=.*/EXTRAVERSION =/' Makefile cp -f %{SOURCE2} .config # The base config still carries Fedora's own build salt, which feeds the # kernel's build ID; reset it so this kernel does not share one with the # Fedora build it was seeded from. cat > .release.config < from CONFIG_LOCALVERSION. A mismatch # here means it would not be the directory %%files and the scriptlets name, # which otherwise only shows up as a broken package. kernelrelease=$(make -s ARCH=arm64 kernelrelease | tail -n1) test "${kernelrelease}" = "%{kverrel}" || { echo "ERROR: kernelrelease is ${kernelrelease}, expected %{kverrel}" exit 1 } %build %make_build ARCH=arm64 Image modules dtbs %install %make_build ARCH=arm64 \ INSTALL_MOD_PATH=%{buildroot}/usr INSTALL_MOD_STRIP=1 \ modules_install %make_build ARCH=arm64 \ INSTALL_DTBS_PATH=%{buildroot}/usr/lib/modules/%{kverrel}/dtb \ dtbs_install # modules_install leaves symlinks into the build tree, which does not exist on # the installed system. rm -f %{buildroot}/usr/lib/modules/%{kverrel}/build rm -f %{buildroot}/usr/lib/modules/%{kverrel}/source # GRUB loads the aarch64 kernel as an EFI application, so this is the # uncompressed Image, not Image.gz. kernel-install copies it into /boot. install -Dm644 arch/arm64/boot/Image \ %{buildroot}/usr/lib/modules/%{kverrel}/vmlinuz install -Dm644 System.map \ %{buildroot}/usr/lib/modules/%{kverrel}/System.map install -Dm644 .config \ %{buildroot}/usr/lib/modules/%{kverrel}/config install -Dm644 arch/arm64/boot/dts/qcom/x1p42100-microsoft-sp12in.dtb \ %{buildroot}/usr/lib/surface-dtb/%{kverrel}/x1p42100-microsoft-sp12in.dtb %post /usr/sbin/depmod -a %{kverrel} || : %posttrans # Same as Fedora's kernel-core: hand the kernel to kernel-install, which # generates the initramfs, copies vmlinuz into /boot and writes the BLS loader # entry. if [ -x /usr/bin/kernel-install ]; then /usr/bin/kernel-install add %{kverrel} \ /usr/lib/modules/%{kverrel}/vmlinuz || : fi %preun if [ -x /usr/bin/kernel-install ]; then /usr/bin/kernel-install remove %{kverrel} || : fi %files %license COPYING /usr/lib/modules/%{kverrel}/ /usr/lib/surface-dtb/%{kverrel}/ %ghost %attr(0644,root,root) /boot/config-%{kverrel} %ghost %attr(0644,root,root) /boot/initramfs-%{kverrel}.img %ghost %attr(0600,root,root) /boot/System.map-%{kverrel} %ghost %attr(0644,root,root) /boot/vmlinuz-%{kverrel} %changelog * Tue Sep 08 2026 Saya Andy 7.2.4-1 - Update Linux kernel from 7.2.3 to 7.2.4 * Mon Sep 07 2026 Saya Andy 7.2.3-4 - Turn off all the ARM64 platform kernel modules besides qcom and vexpress (used in qemu) - Fix Bayer order in rear camera resulting in color space shift * Mon Sep 07 2026 Saya Andy 7.2.3-3 - Key the /usr/lib/surface-dtb copy of the device tree by kernel version. This package is installonly, so an unqualified path there conflicts between two installed releases as soon as the device tree they build differs. * Sun Sep 06 2026 Saya Andy 7.2.3-2 - Local camera patch: report the right bayer order when mirrored (fixes the black-green monochrome output issue) - Local surface patch: point iris at the OEM video firmware (fixes error -22 for video encoding/decoding) * Sun Sep 06 2026 Saya Andy 7.2.3-1 - Initial package: vanilla 7.2.3 with the overlay's Surface Pro 12" patch set