init.qcom.coex.sh 3.6 KB

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