| ReStranger | 1b85f70 | 2025-09-30 04:05:06 +0300 | [diff] [blame] | 1 | #! /vendor/bin/sh |
| 2 | |
| 3 | # Copyright (c) 2009-2010, 2012, The Linux Foundation. All rights reserved. |
| 4 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are met: |
| 7 | # * Redistributions of source code must retain the above copyright |
| 8 | # notice, this list of conditions and the following disclaimer. |
| 9 | # * Redistributions in binary form must reproduce the above copyright |
| 10 | # notice, this list of conditions and the following disclaimer in the |
| 11 | # documentation and/or other materials provided with the distribution. |
| 12 | # * Neither the name of The Linux Foundation nor |
| 13 | # the names of its contributors may be used to endorse or promote |
| 14 | # products derived from this software without specific prior written |
| 15 | # permission. |
| 16 | # |
| 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 21 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 22 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 24 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 26 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 27 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | |
| 29 | LOG_TAG="qcom-bt-wlan-coex" |
| 30 | LOG_NAME="${0}:" |
| 31 | |
| 32 | coex_pid="" |
| 33 | ath_wlan_supported=`getprop wlan.driver.ath` |
| 34 | |
| 35 | loge () |
| 36 | { |
| 37 | /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@" |
| 38 | } |
| 39 | |
| 40 | logi () |
| 41 | { |
| 42 | /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@" |
| 43 | } |
| 44 | |
| 45 | failed () |
| 46 | { |
| 47 | loge "$1: exit code $2" |
| 48 | exit $2 |
| 49 | } |
| 50 | |
| 51 | start_coex () |
| 52 | { |
| 53 | case "$ath_wlan_supported" in |
| 54 | "2") |
| 55 | echo "ATH WLAN Chip ID AR6004 is enabled" |
| 56 | /system/bin/abtfilt -d -z -n -m -a -w wlan0 & |
| 57 | ;; |
| 58 | "1") |
| 59 | echo "ATH WLAN Chip ID is enabled" |
| 60 | # Must have -d -z -n -v -s -w wlan0 parameters for atheros btfilter. |
| 61 | /system/bin/abtfilt -d -z -n -v -q -s -w wlan0 & |
| 62 | ;; |
| 63 | "0") |
| 64 | echo "WCN WLAN Chip ID is enabled" |
| 65 | # Must have -o turned on to avoid daemon (otherwise we cannot get pid) |
| 66 | /system/bin/btwlancoex -o $opt_flags & |
| 67 | ;; |
| 68 | *) |
| 69 | echo "NO WLAN Chip ID is enabled, so enabling ATH as default" |
| 70 | # Must have -d -z -n -v -s -w wlan0 parameters for atheros btfilter. |
| 71 | /system/bin/abtfilt -d -z -n -v -q -s -w wlan0 & |
| 72 | ;; |
| 73 | esac |
| 74 | coex_pid=$! |
| 75 | logi "start_coex: pid = $coex_pid" |
| 76 | } |
| 77 | |
| 78 | kill_coex () |
| 79 | { |
| 80 | logi "kill_coex: pid = $coex_pid" |
| 81 | kill -TERM $coex_pid |
| 82 | # this shell doesn't exit now -- wait returns for normal exit |
| 83 | } |
| 84 | |
| 85 | # mimic coex options parsing -- maybe a waste of effort |
| 86 | USAGE="${0} [-o] [-c] [-r] [-i] [-h]" |
| 87 | |
| 88 | while getopts "ocrih" f |
| 89 | do |
| 90 | case $f in |
| 91 | o | c | r | i | h) opt_flags="$opt_flags -$f" ;; |
| 92 | \?) echo $USAGE; exit 1;; |
| 93 | esac |
| 94 | done |
| 95 | |
| 96 | # init does SIGTERM on ctl.stop for service |
| 97 | trap "kill_coex" TERM INT |
| 98 | |
| 99 | #Selectively start coex module |
| 100 | target=`getprop ro.board.platform` |
| 101 | |
| 102 | if [ "$target" == "msm8960" ] && [ "$ath_wlan_supported" != "2" ]; then |
| 103 | logi "btwlancoex/abtfilt is not needed" |
| 104 | else |
| 105 | # Build settings may not produce the coex executable |
| 106 | if ls /system/bin/btwlancoex || ls /system/bin/abtfilt |
| 107 | then |
| 108 | start_coex |
| 109 | wait $coex_pid |
| 110 | logi "Coex stopped" |
| 111 | else |
| 112 | logi "btwlancoex/abtfilt not available" |
| 113 | fi |
| 114 | fi |
| 115 | exit 0 |