pkgname=firmware-qcom-adreno
pkgver=20220509
pkgrel=0
pkgdesc="Qualcomm Adreno GPU firmware from linux-firmware"
url="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/"
arch="aarch64 armv7"
license="custom"
subpackages="$pkgname-doc"
source="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-$pkgver.tar.gz"
options="!check !strip !archcheck !tracedeps pmb:cross-native"
builddir="$srcdir/linux-firmware-$pkgver"

# This package is a replacement for linux-firmware-qcom (packaging all GPU firmware
# in separate subpackages), so it's packaged in /qcom, not /postmarketos.
replaces="linux-firmware-qcom"
_fwdir="/lib/firmware/qcom"

_gpus="a300 a330 a420 a530 a630 a650 a660"
for gpu in $_gpus; do
	subpackages="$subpackages $pkgname-$gpu:_gpu"
done

package() {
	install -Dm644 LICENSE.qcom "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	install -Dm644 qcom/NOTICE.txt "$pkgdir"/usr/share/licenses/$pkgname/NOTICE
}

_gpu() {
	local gpu=${subpkgname##$pkgname-}
	pkgdesc="$pkgdesc ($gpu)"

	install -Dm644 "$builddir"/qcom/$gpu* -t "$subpkgdir/$_fwdir"/

	# Drop _zap shader firmware because that is typically signed
	# and therefore device-specific.
	rm -f "$subpkgdir/$_fwdir/$gpu"_zap*
}

sha512sums="
0591a35a14a6994ac60571a8e47c00ec013afbfedd4b3326cfe1971b9bd9a07ca7622b17177b3fb57a6c244d2caae12318fcbfac5da5f78a2c085285c9d85cf6  linux-firmware-20220509.tar.gz
"
