# Co-Maintainer: Ingo Reitz <9l@9lo.re>
# Co-Maintainer: WeirdTreeThing <bradyn127@protonmail.com>
maintainer="Alicja Michalska <ellyqw@mainlining.org>"
pkgname=device-google-corsola
pkgdesc="Google Corsola Chromebooks"
pkgver=9
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
	alsa-ucm-conf
	depthcharge-tools
	linux-postmarketos-mediatek-mt81
	postmarketos-base
	postmarketos-cros-common
	soc-mediatek-mt8183
"
makedepends="devicepkg-dev"
_ucm_commit="b728563a07ebcd05545c60989412ae023b1dd06d"
source="deviceinfo
	kernel-cmdline.conf
	modules-initfs
	alsa-ucm-conf-$_ucm_commit.tar.gz::https://github.com/alsa-project/alsa-ucm-conf/archive/$_ucm_commit.tar.gz
"
subpackages="$pkgname-nonfree-firmware:nonfree_firmware"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

nonfree_firmware() {
	pkgdesc="WiFi/BT firmware"
		depends="linux-firmware-mediatek alsa-ucm-conf"

	# Symlink for SOF firmware
	_dir="$subpkgdir/lib/firmware/mediatek/sof-tplg"
	mkdir -p "$_dir"

	ln -s sof-mt8186.tplg.zst "$_dir"/sof-mt8186-google-steelix.tplg.zst

	# Alsa UCM configs
	_ucm_files="
		ucm2/MediaTek/mt8186-sof/init.conf
		ucm2/MediaTek/mt8186-sof/mt6366-rt1019-rt5682s/HiFi.conf
		ucm2/MediaTek/mt8186-sof/mt6366-rt1019-rt5682s/init.conf
		ucm2/MediaTek/mt8186-sof/mt6366-rt1019-rt5682s/sof-mt8186-mt6366-rt1019-rt5682s.conf
		ucm2/conf.d/sof-mt8186_rt10/sof-mt8186_rt1019_rt5682s.conf
	"
	for file in $_ucm_files
	do
		install -Dm644 "$srcdir/alsa-ucm-conf-$_ucm_commit/$file" \
			"$subpkgdir/usr/share/alsa/$file"
	done
}

sha512sums="
e32163709d30881bd87576556c9c659bba62acbe85be797919d87f41b18042d15d85710153606b85b4907930ba965572b4f8f52fbdabc2788f36343a2af5ac79  deviceinfo
97e88eaa9b8e7989a20d2572479fe5d1fe0284de862da11c91b1f347099d5704673837db01a6b0c289fee0a2d7236f64fba31fd6001475f957c23203e34fd6fb  kernel-cmdline.conf
56fdcaa7a610497ed1bddbbfc0850f895bcfd79173b2e7de4bcf196f69120e1b62680da2a0b74543f153cb3d2b84055e71e258e7df938913aff66dca47061d7a  modules-initfs
d33545d435755c2cca3b916d920464f3f711c6f09f48b68622f740f389c4faf95544467d9e3b418e562fadb8141ae37f2311166f228d5149434183736710567d  alsa-ucm-conf-b728563a07ebcd05545c60989412ae023b1dd06d.tar.gz
"
