# Reference: <https://postmarketos.org/devicepkg>
maintainer="bluebunny <bluebunny@postmarketos.org>"
pkgname=device-xiaomi-pipa
pkgdesc="Xiaomi Pad 6"
pkgver=10
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
	alsa-ucm-conf
	firmware-xiaomi-pipa-adreno
	firmware-xiaomi-pipa-adsp
	firmware-xiaomi-pipa-awinic
	firmware-xiaomi-pipa-cdsp
	firmware-xiaomi-pipa-hexagonfs
	firmware-xiaomi-pipa-novatek
	firmware-xiaomi-pipa-nuvolta
	firmware-xiaomi-pipa-slpi
	firmware-xiaomi-pipa-venus
	hexagonrpcd
	linux-firmware-qca
	linux-firmware-qcom
	postmarketos-base
	soc-qcom
	soc-qcom-qbootctl
	systemd-boot
"
makedepends="devicepkg-dev"
subpackages="
	$pkgname-kernel-csot:kernel_csot
	$pkgname-kernel-tianma:kernel_tianma
"
source="
	81-libssc-xiaomi-pipa.rules
	HiFi.conf
	deviceinfo
	local-overrides.quirks
	modules-initfs
	pipa.conf
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	install -Dm644 "$srcdir"/81-libssc-xiaomi-pipa.rules -t \
		"$pkgdir/usr/lib/udev/rules.d/"

	install -Dm644 "$srcdir"/local-overrides.quirks -t \
		"$pkgdir/usr/share/libinput/"

	install -Dm644 "$srcdir"/pipa.conf -t \
		"$pkgdir/usr/share/alsa/ucm2/Xiaomi/pipa/"

	install -Dm644 "$srcdir"/HiFi.conf -t \
		"$pkgdir/usr/share/alsa/ucm2/Xiaomi/pipa/"

	mkdir -p "$pkgdir/usr/share/alsa/ucm2/conf.d/sm8250"
	ln -s ../../Xiaomi/pipa/pipa.conf \
		"$pkgdir/usr/share/alsa/ucm2/conf.d/sm8250/xiaomi-XiaomiPad6.conf"
}

kernel_csot() {
	pkgdesc="Stable kernel with CSOT panel"
	depends="linux-xiaomi-pipa"
	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

kernel_tianma() {
	pkgdesc="Stable kernel with Tianma panel"
	depends="linux-xiaomi-pipa"
	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

sha512sums="
d0e8f2e378130130ac72703aed957f7638e2dd75acf4aa421e1b4592c6cb6d296b652db0d9c242be4e56326760ce18d28c1e36ae553d0b7a7f91e12ab0353f22  81-libssc-xiaomi-pipa.rules
13c0c6639af2ac7103b2a30612f8a8b4bf1cfd875da527a2bccb786a846d948b3f30f79b01485402bdc9fa2db6c2ab2a449669199fb1e4b425c6604a7fe0eed5  HiFi.conf
9ce5336d2815de6dfe8477daa326abf8c79640d3fe519ef1978b18b49e489d70371215d3c0bbfb55068afde4b01b166b0a2a1a8d57b81355e465f542a43e361f  deviceinfo
bea1b1a792cb5d7d41b82551fb0da5a8380bf3fd4eb0e6392dac7c215a3661a4f6106444767a8c4e8609c6effb96228bb1d71f0d2f2ae9ad1e49553b83828e81  local-overrides.quirks
ec16967d268aa6dac891740b2302d7d850650b0d529e93df66292a7d6675bbe042d4a9dda173981e93ed04fa564d5a42398f627d6e98227bcc07771592a703d2  modules-initfs
007908c49db107dd8289a96049ed4d77a55c7846e21f76fa7f97306df953ccdec7d821cbc7732a3ff7c532285175ebf0d6a4e3f224740ac002b23f3608cbf76d  pipa.conf
"
