# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: knuxify <knuxify@gmail.com>
pkgname=device-samsung-lt01
pkgdesc="Samsung Galaxy Tab 3 8.0"
pkgver=1
pkgrel=4
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="
	alsa-ucm-conf
	mkbootimg
	postmarketos-base
	postmarketos-initramfs-minimal
	"
_pmb_recommends="$pkgname-nonfree-firmware"
makedepends="devicepkg-dev"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-kernel-wifi:kernel_wifi
	$pkgname-kernel-3g:kernel_3g
	$pkgname-kernel-lte:kernel_lte
"
source="
	deviceinfo
	ucm/TAB3.conf
	ucm/HiFi.conf
	"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	_tab3_audio_dir="$pkgdir/usr/share/alsa/ucm2/conf.d/TAB3"

	# Alsa UCM configs
	install -Dm644 "$srcdir"/TAB3.conf \
		-t "$_tab3_audio_dir"
	install -Dm644 "$srcdir"/HiFi.conf \
		-t "$_tab3_audio_dir"
}

nonfree_firmware() {
	pkgdesc="WiFi, Bluetooth, MFC firmware"
	depends="
		firmware-samsung-lt01-bluetooth
		firmware-samsung-lt01-wifi
		linux-firmware-s5p-mfc
		"
	mkdir "$subpkgdir"
}

kernel_wifi() {
	pkgdesc="WiFi variant (SM-T310)"
	depends="linux-postmarketos-exynos4"
	devicepkg_subpackage_kernel "$startdir" "$pkgname" "$subpkgname"
}

kernel_3g() {
	pkgdesc="3G variant (SM-T311)"
	depends="linux-postmarketos-exynos4"
	devicepkg_subpackage_kernel "$startdir" "$pkgname" "$subpkgname"
}

kernel_lte() {
	pkgdesc="LTE variant (SM-T315)"
	depends="linux-postmarketos-exynos4"
	devicepkg_subpackage_kernel "$startdir" "$pkgname" "$subpkgname"
}

sha512sums="
0a1ff386ed7288858e10bb42ac5b63bccbe8e82503bfabfdfb42dbc39e2b80529e1f85ba92b0dd7dd5ff0f550792521d9aad2f5dc2309a711759be5fe94b2d98  deviceinfo
caa81e8ab6753c0ca24c22fb6742288765dfbf2469b8b8c35c5789edfcee546ef1c3b14ad6e540c417f434258399300f17d312b58157635eafab134587ef94cc  TAB3.conf
d08c35377c66681ac3b562888301cff8516024581180aa7d7cf6cfe89ed2d2d6b715f2a1164445678041d160775e945f99bf0605ffc12b6ee8d84c50ef57df9b  HiFi.conf
"
