#!/bin/sh
set -e

PREREQS=""
case $1 in
    prereqs) echo "${PREREQS}"; exit 0;;
esac

. /usr/share/initramfs-tools/hook-functions

# Fetch the device parameters
for x in $(cat /proc/cmdline); do
    case $x in
        mobile.qcomsoc=*) QCOMSOC="${x#mobile.qcomsoc=}" ;;
        mobile.model=*) MODEL="${x#mobile.model=}" ;;
    esac
done

if [ "${QCOMSOC}" ] && [ "${MODEL}" ]; then
    # Special case for the OnePlus 6 & 6T: both models use the same
    # firmware folder: sdm845/oneplus6
    if [ "${MODEL}" = "enchilada" ] || [ "${MODEL}" = "fajita" ]; then
        MODEL="oneplus6"
    fi

    add_firmware "${QCOMSOC}/${MODEL}/a630_zap.mbn"
    add_firmware "${QCOMSOC}/${MODEL}/ipa_fws.mbn"

    RADIOFW="ath10k/WCN3990/hw1.0/board-2.bin \
             qca/${MODEL}/crnv21.bin \
             qca/crbtfw21.tlv"
    for fwfile in ${RADIOFW}; do
        if [ -f "/lib/firmware/${fwfile}" ]; then
            add_firmware "${fwfile}"
        fi
    done
fi
