From ba7b266f5af3fd8798ed1c4362cb0b4970c4d4a2 Mon Sep 17 00:00:00 2001 From: Vachounet Date: Wed, 21 Jun 2017 11:09:59 +0200 Subject: [PATCH] potter: import stock FM and BT scripts --- device.mk | 2 + rootdir/Android.mk | 7 + rootdir/etc/init.qcom.bt.sh | 269 +++++++++++++++++++++++++++++++++++- rootdir/etc/init.qcom.fm.sh | 90 ++++++++++++ system.prop | 1 - 5 files changed, 364 insertions(+), 5 deletions(-) create mode 100644 rootdir/etc/init.qcom.fm.sh diff --git a/device.mk b/device.mk index 5a18292..e14e538 100644 --- a/device.mk +++ b/device.mk @@ -233,6 +233,8 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ init.mmi.touch.sh \ init.qcom.ril.sh \ + init.qcom.bt.sh \ + init.qcom.fm.sh \ wlan_carrier_bin.sh PRODUCT_PACKAGES += \ diff --git a/rootdir/Android.mk b/rootdir/Android.mk index 43f9fd1..a874f49 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -49,6 +49,13 @@ LOCAL_MODULE_CLASS := ETC LOCAL_SRC_FILES := etc/init.qcom.bt.sh include $(BUILD_PREBUILT) +include $(CLEAR_VARS) +LOCAL_MODULE := init.qcom.fm.sh +LOCAL_MODULE_TAGS := optional eng +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.qcom.fm.sh +include $(BUILD_PREBUILT) + include $(CLEAR_VARS) LOCAL_MODULE := init.qcom.ril.sh LOCAL_MODULE_TAGS := optional eng diff --git a/rootdir/etc/init.qcom.bt.sh b/rootdir/etc/init.qcom.bt.sh index 0e1ec31..f17b2fb 100644 --- a/rootdir/etc/init.qcom.bt.sh +++ b/rootdir/etc/init.qcom.bt.sh @@ -26,9 +26,15 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +#Read the arguments passed to the script +config="$1" + +BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto LOG_TAG="qcom-bluetooth" LOG_NAME="${0}:" +hciattach_pid="" + loge () { /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@" @@ -45,10 +51,226 @@ failed () exit $2 } +program_bdaddr () +{ + /system/bin/btnvtool -O + logi "Bluetooth Address programmed successfully" +} + +# +# enable bluetooth profiles dynamically +# +config_bt () +{ + baseband=`getprop ro.baseband` + target=`getprop ro.board.platform` + if [ -f /sys/devices/soc0/soc_id ]; then + soc_hwid=`cat /sys/devices/soc0/soc_id` + else + soc_hwid=`cat /sys/devices/system/soc/soc0/id` + fi + btsoc=`getprop qcom.bluetooth.soc` + + case $baseband in + "apq") + setprop ro.qualcomm.bluetooth.opp true + setprop ro.qualcomm.bluetooth.ftp true + setprop ro.qualcomm.bluetooth.nap false + setprop ro.bluetooth.sap false + setprop ro.bluetooth.dun false + # For MPQ as baseband is same for both + case $soc_hwid in + "130") + setprop ro.qualcomm.bluetooth.hsp true + setprop ro.qualcomm.bluetooth.hfp true + setprop ro.qualcomm.bluetooth.pbap false + setprop ro.qualcomm.bluetooth.map false + ;; + *) + setprop ro.qualcomm.bluetooth.hsp false + setprop ro.qualcomm.bluetooth.hfp false + setprop ro.qualcomm.bluetooth.pbap true + setprop ro.qualcomm.bluetooth.map true + ;; + esac + ;; + "mdm" | "svlte2a" | "svlte1" | "csfb") + setprop ro.qualcomm.bluetooth.opp true + setprop ro.qualcomm.bluetooth.hfp true + setprop ro.qualcomm.bluetooth.hsp true + setprop ro.qualcomm.bluetooth.pbap true + setprop ro.qualcomm.bluetooth.ftp true + setprop ro.qualcomm.bluetooth.map true + setprop ro.qualcomm.bluetooth.nap true + setprop ro.bluetooth.sap true + case $target in + "apq8084") + setprop ro.bluetooth.dun true + logi "Enabling BT-DUN for APQ8084" + ;; + *) + setprop ro.bluetooth.dun false + ;; + esac + ;; + "msm") + setprop ro.qualcomm.bluetooth.opp true + setprop ro.qualcomm.bluetooth.hfp true + setprop ro.qualcomm.bluetooth.hsp true + setprop ro.qualcomm.bluetooth.pbap true + setprop ro.qualcomm.bluetooth.ftp true + setprop ro.qualcomm.bluetooth.nap true + setprop ro.bluetooth.sap true + setprop ro.bluetooth.dun true + case $btsoc in + "ath3k") + setprop ro.qualcomm.bluetooth.map false + ;; + *) + setprop ro.qualcomm.bluetooth.map true + ;; + esac + ;; + *) + setprop ro.qualcomm.bluetooth.opp true + setprop ro.qualcomm.bluetooth.hfp true + setprop ro.qualcomm.bluetooth.hsp true + setprop ro.qualcomm.bluetooth.pbap true + setprop ro.qualcomm.bluetooth.ftp true + setprop ro.qualcomm.bluetooth.map true + setprop ro.qualcomm.bluetooth.nap true + setprop ro.bluetooth.sap true + setprop ro.bluetooth.dun true + ;; + esac + + #Enable Bluetooth Profiles specific to target Dynamically + case $target in + "msm8960") + if [ "$btsoc" != "ath3k" ] && [ "$soc_hwid" != "130" ] + then + setprop ro.bluetooth.hfp.ver 1.6 + setprop ro.qualcomm.bt.hci_transport smd + fi + ;; + "msm8974" | "msm8226" | "msm8610" | "msm8916" | "msm8909" | "msm8952" | "msm8937" | "msm8953" ) + if [ "$btsoc" != "ath3k" ] + then + setprop ro.bluetooth.hfp.ver 1.7 + setprop ro.qualcomm.bt.hci_transport smd + fi + ;; + "apq8084" | "mpq8092" | "msm8994" | "msm8992" ) + if [ "$btsoc" != "rome" ] + then + setprop ro.qualcomm.bt.hci_transport smd + elif [ "$btsoc" = "rome" ] + then + setprop ro.bluetooth.hfp.ver 1.6 + fi + ;; + "msm8996" ) + if [ "$btsoc" != "rome" ] + then + setprop ro.qualcomm.bt.hci_transport smd + elif [ "$btsoc" = "rome" ] + then + setprop ro.bluetooth.hfp.ver 1.7 + fi + ;; + "msmcobalt") + setprop ro.bluetooth.hfp.ver 1.6 + ;; + *) + ;; + esac + +if [ -f /system/etc/bluetooth/stack.conf ]; then +stack=`cat /system/etc/bluetooth/stack.conf` +fi + +case "$stack" in + "bluez") + logi "Bluetooth stack is $stack" + setprop ro.qc.bluetooth.stack $stack + reason=`getprop vold.decrypt` + case "$reason" in + "trigger_restart_framework") + start dbus + ;; + esac + ;; + *) + logi "Bluetooth stack is Bluedroid" + ;; +esac + +} + +start_hciattach () +{ + /system/bin/hciattach -n $BTS_DEVICE $BTS_TYPE $BTS_BAUD & + hciattach_pid=$! + logi "start_hciattach: pid = $hciattach_pid" + echo 1 > $BLUETOOTH_SLEEP_PATH +} + +kill_hciattach () +{ + echo 0 > $BLUETOOTH_SLEEP_PATH + logi "kill_hciattach: pid = $hciattach_pid" + ## careful not to kill zero or null! + kill -TERM $hciattach_pid + # this shell doesn't exit now -- wait returns for normal exit +} + +logi "init.qcom.bt.sh config = $config" +case "$config" in + "onboot") + exit 0 + ;; + *) + ;; +esac + +# mimic hciattach options parsing -- maybe a waste of effort +USAGE="hciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] [speed] [flow|noflow] [bdaddr]" + +while getopts "blnpt:s:" f +do + case $f in + b | l | n | p) opt_flags="$opt_flags -$f" ;; + t) timeout=$OPTARG;; + s) initial_speed=$OPTARG;; + \?) echo $USAGE; exit 1;; + esac +done +shift $(($OPTIND-1)) + +# Note that "hci_qcomm_init -e" prints expressions to set the shell variables +# BTS_DEVICE, BTS_TYPE, BTS_BAUD, and BTS_ADDRESS. + +#Selectively Disable sleep +BOARD=`getprop ro.board.platform` +STACK=`getprop ro.qc.bluetooth.stack` + +# BR/EDR & LE power class configurations POWER_CLASS=`getprop qcom.bt.dev_power_class` LE_POWER_CLASS=`getprop qcom.bt.le_dev_pwr_class` -setprop bluetooth.status off +#find the transport type +TRANSPORT=`getprop ro.qualcomm.bt.hci_transport` +logi "Transport : $TRANSPORT" +case $STACK in + "bluez") + logi "** Bluez stack **" + ;; + *) + logi "** Bluedroid stack **" + setprop bluetooth.status off + ;; +esac + case $POWER_CLASS in 1) PWR_CLASS="-p 0" ; @@ -79,12 +301,51 @@ eval $(/system/bin/hci_qcomm_init -e $PWR_CLASS $LE_PWR_CLASS && echo "exit_code case $exit_code_hci_qcomm_init in 0) logi "Bluetooth QSoC firmware download succeeded, $BTS_DEVICE $BTS_TYPE $BTS_BAUD $BTS_ADDRESS";; *) failed "Bluetooth QSoC firmware download failed" $exit_code_hci_qcomm_init; - - setprop bluetooth.status off + case $STACK in + "bluez") + logi "** Bluez stack **" + ;; + *) + logi "** Bluedroid stack **" + setprop bluetooth.status off + ;; + esac exit $exit_code_hci_qcomm_init;; esac -setprop bluetooth.status on +# init does SIGTERM on ctl.stop for service +trap "kill_hciattach" TERM INT + +case $TRANSPORT in + "smd") + case $STACK in + "bluez") + logi "** Bluez stack **" + echo 1 > /sys/module/hci_smd/parameters/hcismd_set + ;; + *) + logi "** Bluedroid stack **" + setprop bluetooth.status on + ;; + esac + ;; + *) + logi "start hciattach" + start_hciattach + case $STACK in + "bluez") + logi "Bluetooth is turning On with Bluez stack " + ;; + *) + logi "** Bluedroid stack **" + setprop bluetooth.status on + ;; + esac + + wait $hciattach_pid + logi "Bluetooth stopped" + ;; +esac exit 0 diff --git a/rootdir/etc/init.qcom.fm.sh b/rootdir/etc/init.qcom.fm.sh new file mode 100644 index 0000000..a3b1631 --- /dev/null +++ b/rootdir/etc/init.qcom.fm.sh @@ -0,0 +1,90 @@ +#!/system/bin/sh +# Copyright (c) 2009-2011, 2015, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +setprop hw.fm.init 0 + +mode=`getprop hw.fm.mode` +version=199217 + +LOG_TAG="qcom-fm" +LOG_NAME="${0}:" + +loge () +{ + /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@" +} + +logi () +{ + /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@" +} + +failed () +{ + loge "$1: exit code $2" + exit $2 +} + +logi "In FM shell Script" +logi "mode: $mode" +logi "Version : $version" + +#$fm_qsoc_patches +# +case $mode in + "normal") + logi "inserting the radio transport module" + echo 1 > /sys/module/radio_iris_transport/parameters/fmsmd_set + /system/bin/fm_qsoc_patches $version 0 + ;; + "wa_enable") + /system/bin/fm_qsoc_patches $version 1 + ;; + "wa_disable") + /system/bin/fm_qsoc_patches $version 2 + ;; + *) + logi "Shell: Default case" + /system/bin/fm_qsoc_patches $version 0 + ;; +esac + +exit_code_fm_qsoc_patches=$? + +case $exit_code_fm_qsoc_patches in + 0) + logi "FM QSoC calibration and firmware download succeeded" + ;; + *) + failed "FM QSoC firmware download and/or calibration failed" $exit_code_fm_qsoc_patches + ;; +esac + +setprop hw.fm.init 1 + +exit 0 diff --git a/system.prop b/system.prop index 9a86587..e22efe4 100644 --- a/system.prop +++ b/system.prop @@ -45,7 +45,6 @@ use.voice.path.for.pcm.voip=false bluetooth.hfp.client=1 qcom.bluetooth.soc=smd qcom.bt.le_dev_pwr_class=1 -ro.bluetooth.hfp.ver=1.7 ro.cutoff_voltage_mv=3400 # Camera