From 34f62dee246d39da0f83d746550fdab4df67392c Mon Sep 17 00:00:00 2001
From: Niklas Cathor <niklas.cathor@gmx.de>
Date: Sun, 5 Apr 2020 16:29:46 +0200
Subject: [PATCH] firmware-samsung-kminilte: Samsung Galaxy S5 Mini firmware

post-install actions:
- enable "deferred-initcalls" in sysinit for wlan0 to be available
- force wpa_supplicant to use wlan0 instead of p2p0
(both based on script from device-samsung-klte package)
---
 firmware/firmware-samsung-kminilte/APKBUILD   | 37 +++++++++++++++++++
 .../firmware-samsung-kminilte.post-install    | 10 +++++
 2 files changed, 47 insertions(+)
 create mode 100644 firmware/firmware-samsung-kminilte/APKBUILD
 create mode 100644 firmware/firmware-samsung-kminilte/firmware-samsung-kminilte.post-install

diff --git a/firmware/firmware-samsung-kminilte/APKBUILD b/firmware/firmware-samsung-kminilte/APKBUILD
new file mode 100644
index 00000000000..0796820704c
--- /dev/null
+++ b/firmware/firmware-samsung-kminilte/APKBUILD
@@ -0,0 +1,37 @@
+# Contributor: nilclass
+pkgname="firmware-samsung-kminilte"
+pkgver=1
+pkgrel=0
+pkgdesc="Samsung Galaxy S5 Mini firmware"
+url="https://github.com/cm-3470/android_vendor_samsung_kminilte"
+arch="armhf"
+license="proprietary"
+options="!check !strip !archcheck !spdx"
+install="$pkgname.post-install"
+
+_repository="android_vendor_samsung_kminilte"
+_commit="996b9e165baf687c1dcc0b95e83f3208ee711f89"
+
+source="
+	$pkgname-$_commit.tar.gz::https://github.com/cm-3470/$_repository/archive/$_commit.tar.gz
+"
+
+# The installed location of these files must match CONFIG_BCMDHD_FW_PATH
+# and CONFIG_BCMDHD_NVRAM_PATH respectively.
+# Note that "_b2" is appended to the firmware path (in drivers/net/wireless/bcmdhd/dhd_sdio.c),
+# so CONFIG_BCMDHD_FW_PATH must end in `.bin`, not `.bin_b2`
+_files="
+	proprietary/etc/wifi/bcmdhd_sta.bin_b2
+	proprietary/etc/wifi/nvram_net.txt
+"
+
+package() {
+	mkdir -p "$pkgdir"
+	cd "$srcdir/$_repository-$_commit"
+	for _f in $_files; do
+		_filename=$(basename $_f)
+		install -Dm644 $_f "$pkgdir"/lib/firmware/postmarketos/$_filename
+	done
+}
+
+sha512sums="84732c5470f917395bdb291a82b0dce613ea0559e2a869d245ef367be8ec7d2dcc8c7db1f63a4ddd7e4e46d7e24105bd3f3104c0603d2f742567c0df205d7672  firmware-samsung-kminilte-996b9e165baf687c1dcc0b95e83f3208ee711f89.tar.gz"
diff --git a/firmware/firmware-samsung-kminilte/firmware-samsung-kminilte.post-install b/firmware/firmware-samsung-kminilte/firmware-samsung-kminilte.post-install
new file mode 100644
index 00000000000..7b758e41ff2
--- /dev/null
+++ b/firmware/firmware-samsung-kminilte/firmware-samsung-kminilte.post-install
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Enable autostart of deferred initcalls (needed to bring Wi-Fi online)
+rc-update -q add deferred-initcalls sysinit
+
+# Explicitly specify wlan device. Without this, p2p0 will be
+# selected automatically instead of wlan0, and Wi-Fi will not work.
+if ! grep -q "i wlan0" /etc/conf.d/wpa_supplicant ; then
+	sed -i 's/-Dnl80211,wext/-Dnl80211,wext -i wlan0/' /etc/conf.d/wpa_supplicant
+fi
-- 
GitLab