# Maintainer: Leandro Friedrich <email@leandrofriedrich.de>
pkgname=firmware-samsung-a52q
pkgver=20220820
pkgrel=0
pkgdesc="Firmware for Samsung Galaxy A52"
subpackages="
	$pkgname-adreno
	$pkgname-adsp
	$pkgname-cdsp
	$pkgname-ipa
	$pkgname-modem
	$pkgname-venus
	$pkgname-wlan
	$pkgname-bluetooth
	"
url="https://github.com/budderbrot/a52q-firmware"
arch="aarch64"
license="proprietary"
options="!check !strip !archcheck !tracedeps pmb:cross-native"
_commit="3ec32aecf7837a34240702955f5d01a336cf0c2c"
source="https://github.com/budderbrot/a52q-firmware/archive/$_commit/a52q-firmware-$_commit.tar.gz"
builddir="$srcdir/a52q-firmware-$_commit"

package() {
	# parent package is empty
	mkdir -p "$pkgdir"
}

adreno() {
	pkgdesc="Samsung Galaxy A52 adreno firmware"

	install -Dm644 "$builddir"/a6* -t \
		"$subpkgdir/lib/firmware/qcom/"
}

adsp() {
	pkgdesc="Samsung Galaxy A52 adsp firmware"

	install -Dm644 "$builddir"/adsp* -t \
		"$subpkgdir/lib/firmware/qcom/sm7125/a52q/"
}

cdsp() {
	pkgdesc="Samsung Galaxy A52 cdsp firmware"

	install -Dm644 "$builddir"/cdsp* -t \
		"$subpkgdir/lib/firmware/qcom/sm7125/a52q/"
}

ipa() {
	pkgdesc="Samsung Galaxy A52 ipa firmware"

	install -Dm644 "$builddir"/ipa_fws.* -t \
		"$subpkgdir/lib/firmware/qcom/sm7125/a52q/"
}

modem() {
	pkgdesc="Samsung Galaxy A52 modem firmware"

	# cp because of the modem_pr directory
	mkdir -p "$subpkgdir/lib/firmware/qcom/sm7125/a52q/"
	cp -r "$builddir"/modem* \
		"$subpkgdir/lib/firmware/qcom/sm7125/a52q/"
	find "$subpkgdir/lib/firmware/qcom/sm7125/a52q/" \
		-type f -exec chmod 0644 {} \;
}

venus() {
	pkgdesc="Samsung Galaxy A52 venus firmware"

	install -Dm644 "$builddir"/venus.* -t \
		"$subpkgdir/lib/firmware/qcom/sm7125/a52q/"
}

wlan() {
	pkgdesc="Samsung Galaxy A52 wlan firmware"

	install -Dm644 "$builddir"/board-2.bin -t \
		"$subpkgdir/lib/firmware/ath10k/WCN3990/hw1.0/"
	install -Dm644 "$builddir"/firmware-5.bin -t \
		"$subpkgdir/lib/firmware/ath10k/WCN3990/hw1.0/"
	install -Dm644 "$builddir"/wlanmdsp.mbn -t \
		"$subpkgdir/lib/firmware/qcom/sm7125/a52q/"
}

bluetooth() {
	pkgdesc="Samsung Galaxy A52 bluetooth firmware"

	install -Dm644 "$builddir"/crbtfw21.tlv -t \
		"$subpkgdir/lib/firmware/qca/"
	install -Dm644 "$builddir"/crnv21.* -t \
		"$subpkgdir/lib/firmware/qca/sm7125/a52q/"
}

sha512sums="
fbd93fc61903d16489f531c8431e8e1a4d5c21c0ada0c998c619c3b5193506c2fc6b6b56d6dd3002f834955e5d884dd80519eee260a04c96319b125ffad4b60a  a52q-firmware-3ec32aecf7837a34240702955f5d01a336cf0c2c.tar.gz
"
