# Co-Maintainer: Victor Pavlov (vipaoL) <vipaolmail@gmail.com>
maintainer="Barnabas Czeman <barnabas.czeman@postmarketos.org>"
pkgname=soc-qcom-msm8953
pkgdesc="Common package for Qualcomm MSM8953 devices"
pkgver=18
pkgrel=1
url="https://postmarketos.org"
license="BSD-3-Clause"
arch="aarch64"
options="!check !archcheck !tracedeps pmb:cross-native"
depends="$pkgname-ucm swclock-offset"
install="$pkgname-modem-openrc.post-install $pkgname-modem-openrc.post-upgrade"
subpackages="
	$pkgname-gpu
	$pkgname-modem
	$pkgname-modem-openrc:modem_openrc
	$pkgname-ucm
"

_ucm_commit="ed9334bda853fe032794751c34cea03ec0d7d4eb"
source="
	$pkgname-$_ucm_commit.tar.gz::https://github.com/msm8953-mainline/alsa-ucm-conf/archive/$_ucm_commit.tar.gz
	51-qcom.conf
	adreno-a506-quirks.sh
	moto-modem-rfs-setup.openrc
	q6voiced.conf
"

package() {
	mkdir -p "$pkgdir"
	install -Dm644 "$srcdir"/51-qcom.conf \
		-t "$pkgdir"/usr/share/wireplumber/wireplumber.conf.d
}

ucm() {
	provides="alsa-ucm-conf"
	provider_priority=1

	cd "$srcdir/alsa-ucm-conf-$_ucm_commit"
	mkdir -p "$subpkgdir"/usr/share/alsa
	cp -r ucm2 "$subpkgdir"/usr/share/alsa
}

modem() {
	depends="
		msm-modem-uim-selection
		q6voiced
		qrtr
		rmtfs
		tqftpserv
	"

	install -Dm644 "$srcdir"/q6voiced.conf "$subpkgdir"/etc/conf.d/q6voiced
}

modem_openrc() {
	install_if="$pkgname-modem=$pkgver-r$pkgrel openrc"
	depends="
		openrc
		q6voiced-openrc
		rmtfs-openrc
		tqftpserv-openrc
	"
	install -Dm755 $srcdir/moto-modem-rfs-setup.openrc "$subpkgdir"/etc/init.d/moto-modem-rfs-setup
}

gpu() {
	pkgdesc="Various GPU workarounds for Adreno a506"
	install_if="$pkgname=$pkgver-r$pkgrel mesa-dri-gallium"

	install -Dm644 "$srcdir"/adreno-a506-quirks.sh \
		"$subpkgdir"/etc/profile.d/adreno-a506-quirks.sh
}

sha512sums="
ade2ffb266adf502a7e3d0a9c9927c3bf153377093a903de1961ad6e4fdf04e813fab08c3077990c6ceb4e364809c5551174d19e4029e4374367444275325ca3  soc-qcom-msm8953-ed9334bda853fe032794751c34cea03ec0d7d4eb.tar.gz
28c14f47eaedec577d152001c51753537c98f267ac4a0acf78a304efebe5f6a1b4dc6d501497da9a0a925806a1d9c80b25e001cf9b1eb21efa22cd6a41ff753b  51-qcom.conf
4c71a37d3e9ef82b08b18928014f0cd8e33585199b8f12a5c124eb8c629f9d5ea1c76341769a2a5055f8a749e3ded3ae3baaf9678ea98bc9bae75337906d5e84  adreno-a506-quirks.sh
0d2539681c6a8e6f222ab378dc688a2b4a21dc61e393b4fe42420abb7ffd9ad1b8f69b10fbe18995f10b13cb870130f616b0b37a38f253e12041dd36391c613f  moto-modem-rfs-setup.openrc
3a4a9322839d4b3ef9d79668a37840a9f444954759ae3c512e694051d2f9a2573db42ad6c4c1a5c75eeb861232a27ba1a8cef9b503decd54ead25a96e3dd6f98  q6voiced.conf
"
