blob: a9a22f175123919ec3ba9f39f92e3481b003a1c3 [file] [log] [blame]
ReStranger1b85f702025-09-30 04:05:06 +03001#! /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
29LOG_TAG="qcom-bt-wlan-coex"
30LOG_NAME="${0}:"
31
32coex_pid=""
33ath_wlan_supported=`getprop wlan.driver.ath`
34
35loge ()
36{
37 /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
38}
39
40logi ()
41{
42 /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
43}
44
45failed ()
46{
47 loge "$1: exit code $2"
48 exit $2
49}
50
51start_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
78kill_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
86USAGE="${0} [-o] [-c] [-r] [-i] [-h]"
87
88while getopts "ocrih" f
89do
90 case $f in
91 o | c | r | i | h) opt_flags="$opt_flags -$f" ;;
92 \?) echo $USAGE; exit 1;;
93 esac
94done
95
96# init does SIGTERM on ctl.stop for service
97trap "kill_coex" TERM INT
98
99#Selectively start coex module
100target=`getprop ro.board.platform`
101
102if [ "$target" == "msm8960" ] && [ "$ath_wlan_supported" != "2" ]; then
103 logi "btwlancoex/abtfilt is not needed"
104else
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
114fi
115exit 0