# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=linux-valve-jupiter
pkgver=6.10_rc5
pkgrel=0
pkgdesc="Valve Steam Deck kernel fork"
arch="x86_64"
_flavor="valve-jupiter"
_carch="x86"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
	pmb:kconfigcheck-uefi
	"
makedepends="
	bash
	bison
	elfutils-dev
	findutils
	flex
	linux-headers
	openssl-dev
	perl
	postmarketos-installkernel
"

# Source
_config="config-$_flavor.$arch"
case $pkgver in
	*.*.*)	_kernver=${pkgver%.0};;
	*.*)	_kernver=$pkgver;;
esac

source="
	https://git.kernel.org/torvalds/t/linux-${_kernver//_/-}.tar.gz
	$_config

	0001-ACPICA-Limit-error-message-flood-caused-by-firmware-.patch
	0002-drivers-video-backlight-Disable-backlight-notificati.patch
	0003-iio-light-ltrf216a-Return-floating-point-values.patch
	0004-mfd-Add-MFD-core-driver-for-Steam-Deck.patch
	0005-hwmon-Add-driver-for-Steam-Deck-s-EC-sensors.patch
	0006-leds-steamdeck-Add-support-for-Steam-Deck-LED.patch
	0007-extcon-Add-driver-for-Steam-Deck.patch
	0008-hwmon-steamdeck-hwmon-Add-support-for-max-battery-le.patch
	0009-mfd-steamdeck-Expose-controller-board-power-in-sysfs.patch
	0010-x86-implement-tsc-directsync-for-systems-without-IA3.patch
	0011-x86-touch-clocksource-watchdog-after-syncing-TSCs.patch
	0012-x86-save-restore-TSC-counter-value-during-sleep-wake.patch
	0013-x86-only-restore-TSC-if-we-have-IA32_TSC_ADJUST-or-d.patch
	0014-x86-don-t-check-for-random-warps-if-using-direct-syn.patch
	0015-x86-revert-extra-time-added-to-check-for-tsc-wraps.patch
	0016-usb-dwc3-Hardcode-jupiter-ACPI-device-as-extcon-name.patch
	0017-usb-dwc3-Bump-USB-gadget-wakeup-timeout.patch
	0018-usb-dwc3-Drop-usb-role-swtich-from-dwc3_pci_mr_prope.patch
	0019-usb-dwc3-Fix-linux-extcon-name.patch
	0020-pinctrl-amd-Add-quirk-to-timeout-irq-pin-reconfigura.patch
	0021-mmc-core-add-safe_trim_quirk-attribute.patch
"
builddir="$srcdir/linux-${_kernver//_/-}"

prepare() {
	default_prepare
	cp "$srcdir/$_config" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot
	make install modules_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

sha512sums="
9f807b4f9e084aec03819196af2303f72a4534116aea8f2f856ef5b26aa454f5f4acd79c3774584e0c68bb954a7e1717de81b39825557c0fb8ee19e9a5ab7a95  linux-6.10-rc5.tar.gz
e131297e748f5248593870dc025d7bcb24a205911cb35a9a1914e7f465c50552f72fe25fe53f1d743df285eb34a63dd0d13282b2c757babf16766390a77a8896  config-valve-jupiter.x86_64
f4ac1868a85337ad32cbc67f27e82a2fc464cefd71dde7b9c59335802f182d9030dc5e87f7a5950288ef7ef4d31f338c42add0a0de4419bb5d40c455ace11934  0001-ACPICA-Limit-error-message-flood-caused-by-firmware-.patch
e13fb749e7b87d38ac32a8fb7f01fafa1ac2c1f86ae7d92b0388bf2a4dac61bfc5ce210ef20bed39b73c14209320b0a480d88c2c8ce92780f332a1252f68c73b  0002-drivers-video-backlight-Disable-backlight-notificati.patch
e82a5cad57b01fda0c51e0b7844dcd2200361f59c38164d417b9a0b30dc4601cfe900e9fe075cf9c6be8e9b8d8ccd7ef0fe87ebca540265540b9b115224e231f  0003-iio-light-ltrf216a-Return-floating-point-values.patch
58ac734f35066f56feee8b6ee468ad59517c8a3c61262ed3bdfb9958d20296c4925439a43e7d025c88ddbcd9099dfd353d4eb3483359c3e257663b9601afc2d0  0004-mfd-Add-MFD-core-driver-for-Steam-Deck.patch
660b91144680af6388edee875606b76d19ca955dec91a6ed3df35802a2efbfe80da5384df4f462b74f4cfe7e99e193c7c77fd8b17d6e7d4a32fe1e40d13a9283  0005-hwmon-Add-driver-for-Steam-Deck-s-EC-sensors.patch
f9626ac2a3e22a384878de640a8eabb2aa0fde458e3db6cd6302f59f40f95b1b0160538ff25f0cc64dd1ffbf5e141da29bbb8d82d09e7ca09b57bc5e05fad369  0006-leds-steamdeck-Add-support-for-Steam-Deck-LED.patch
55f038281aa04e7389fcc24629a920e2b439b567d79bbde327966919ac4886205baa0cab16941b9d57b8cd82cf9640ab779965f19ec131d297c8d6a29bc2f09d  0007-extcon-Add-driver-for-Steam-Deck.patch
e21c5fe01b0b156d83eb356732ac15065ecccee96e3ccee448c46156f3eb49b99e74b98a32064f1094403d93fdda16b68981f74936fe2277f657becdd07359e6  0008-hwmon-steamdeck-hwmon-Add-support-for-max-battery-le.patch
a73c5c7383efdbc43808c5eaede95d445722a1a277783aac8f5a5f6618bfebd59335008dcc8dd3698cbeb13d463ca1127c666e5d92fc06aa860c8a8444f4b872  0009-mfd-steamdeck-Expose-controller-board-power-in-sysfs.patch
dec179fe18b3ba20dd67383f6f172f511694d8b9e7241227776c1bee93326343a8a6c1b94059a9cb7268eac383ebb4d263ee575a18d954e3d5665359146842f2  0010-x86-implement-tsc-directsync-for-systems-without-IA3.patch
f788fd3916eaef9d63f5808b7096f1efe70ad5d081b7fb84078221e6f9447e464c4cf476d684970432d6a23a4428dc4d62d9636b302b0b0da6863709d9694ff8  0011-x86-touch-clocksource-watchdog-after-syncing-TSCs.patch
7090440a009ad4254c2a6b3210616ad8ba66ff8a1283fa724eee90bb9fa1777a8e7d27bf6f5d0b9633138c02bea52711fb0fd6a8b29f7572f2d2df5abe4857b0  0012-x86-save-restore-TSC-counter-value-during-sleep-wake.patch
367ced397de8970e26e09f0f1feafbfa2e6ce3b99ed3f5b956c4750a2c447ad35cdddee5c352bec1d57f4b3ed50373a0369d494bd53bec20c9a56f9099389477  0013-x86-only-restore-TSC-if-we-have-IA32_TSC_ADJUST-or-d.patch
583c42558c971da5e6f0501b224ad5f7d0024116ba262a3b4fb0ca3368e4360a956e7837c4ad83effa0574f045f1b96d27dd300455ef305738497c5f94a83668  0014-x86-don-t-check-for-random-warps-if-using-direct-syn.patch
c0089ef5a4e61095b31e3cd97288310a165d0312a8cb270e1376928cd391d9a5a426f762725ac53f174363ab8a28a7a53f55509f056a03e02e5fbcbf9f622bb8  0015-x86-revert-extra-time-added-to-check-for-tsc-wraps.patch
205895e60dc5fb72815b2edea76ffbc7ecf932b16fc84cf92af45bc4aaba0ae01c9fc4ec03e538bceac7bb21ae83e58df4d10a4060eb25571bf766292cb0753d  0016-usb-dwc3-Hardcode-jupiter-ACPI-device-as-extcon-name.patch
189d5143f8462e15746f4737181b1ad7879a15fbe761c848b9da544b3ce4801ce32814992ebb08c4c384b601c6a1f097e490a317280176bd0db230534529c4f3  0017-usb-dwc3-Bump-USB-gadget-wakeup-timeout.patch
9d2e4c5193a1d5299120d417d9c408ef5e86cb779c2d8a2ca4f1ccc9b0ab1b1f636672e35b1035173dcac5bb5e0bdb7ccea359b02f780c3311fc131be66c8295  0018-usb-dwc3-Drop-usb-role-swtich-from-dwc3_pci_mr_prope.patch
d2847053c6e8c3f19e5ff743ee79e012aefd0ce80cfb23390bd3e9f9af03e3d81004d8ddac3401ef43d501bf3b2f84f0d8cffacb0e0f205bcb5003c143ab525c  0019-usb-dwc3-Fix-linux-extcon-name.patch
32438e7d940a5d593d3ae4915fe75f3f8d18286d16ffa0274588e72118cde654cb8630ca7e71edc4fab281b1179f253097c411d313243218648688366b8acae9  0020-pinctrl-amd-Add-quirk-to-timeout-irq-pin-reconfigura.patch
504134d216957c8308b88a1d3fe215e36dc099b7816c738644f419bc226aab93ba98f37bb9a0a4061e06e1fe6738fa31442904a8282fdbed992bd75c428b3f22  0021-mmc-core-add-safe_trim_quirk-attribute.patch
"
