# Maintainer: Andrew Clunis <andrew@orospakr.ca>
# Patched i2c-piix4 (ASF SMBus Host Notify on AMD FCH / ACPI SMB0001), rmi_smbus
# and psmouse, built by DKMS from pristine kernel sources plus the patches in
# patches/. Lets the Synaptics touchpad on the ThinkPad T14 / P14s Gen 1 and
# Gen 2 AMD run over RMI4/SMBus instead of the PS/2 fallback.
_name=thinkpad-t14-amd-touchpad
pkgname=$_name-dkms
pkgver=0.2.3
pkgrel=1
pkgdesc="Synaptics RMI4/SMBus touchpad on ThinkPad T14/P14s Gen 1 and Gen 2 AMD: patched i2c-piix4, rmi_smbus, psmouse (DKMS)"
arch=('x86_64')
url="https://github.com/orospakr/$_name"
license=('GPL-2.0-only')
depends=('dkms')
conflicts=('i2c-piix4-asf-dkms')
replaces=('i2c-piix4-asf-dkms')
install=$pkgname.install
source=("$_name-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz"
        "$_name.conf"
        "$pkgname.install")
sha256sums=('2943b98cf2b7e8ad2c74462b3ff696f70c4c1fe728bb781022e52480f2f09c81'
            '6830eebbc8f0b7758a8da744a7b36fdc56270734e287ccdb642506c13c36f5a7'
            'e848ed6b1cd83ac1e62918001f4e6c31c95b8d43a6bf238445f07567b6879ba5')

package() {
  local s="$srcdir/$_name-$pkgver"
  local d="$pkgdir/usr/src/$_name-$pkgver"
  install -d "$d"
  cp -r "$s/drivers" "$s/patches" "$s/tools" "$d/"
  install -Dm644 "$s/dkms.conf" "$s/Makefile" "$s/KERNEL_SOURCE" -t "$d"
  rm -rf "$d/tools/check" "$d/tools/ci"
  install -Dm755 "$s/tools/check" "$pkgdir/usr/bin/$_name-check"
  install -Dm644 "$srcdir/$_name.conf" "$pkgdir/usr/lib/modprobe.d/$_name.conf"
  install -Dm644 "$s/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 "$s/README.md" "$pkgdir/usr/share/doc/$pkgname/README.md"
}
