jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame^] | 1 | #!/system/bin/sh |
| 2 | |
| 3 | BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto |
| 4 | LOG_TAG="mako-bluetooth" |
| 5 | LOG_NAME="${0}:" |
| 6 | |
| 7 | hciattach_pid="" |
| 8 | |
| 9 | loge () |
| 10 | { |
| 11 | /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@" |
| 12 | } |
| 13 | |
| 14 | logi () |
| 15 | { |
| 16 | /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@" |
| 17 | } |
| 18 | |
| 19 | failed () |
| 20 | { |
| 21 | loge "$1: exit code $2" |
| 22 | exit $2 |
| 23 | } |
| 24 | |
| 25 | # Note that "hci_qcomm_init -e" prints expressions to set the shell variables |
| 26 | # BTS_DEVICE, BTS_TYPE, BTS_BAUD, and BTS_ADDRESS. |
| 27 | |
| 28 | POWER_CLASS=`getprop qcom.bt.dev_power_class` |
| 29 | TRANSPORT=`getprop ro.qualcomm.bt.hci_transport` |
| 30 | |
| 31 | #find the transport type |
| 32 | logi "Transport : $TRANSPORT" |
| 33 | |
| 34 | case $POWER_CLASS in |
| 35 | 1) PWR_CLASS="-p 0" ; |
| 36 | logi "Power Class: 1";; |
| 37 | 2) PWR_CLASS="-p 1" ; |
| 38 | logi "Power Class: 2";; |
| 39 | 3) PWR_CLASS="-p 2" ; |
| 40 | logi "Power Class: CUSTOM";; |
| 41 | *) PWR_CLASS=""; |
| 42 | logi "Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM)"; |
| 43 | logi "Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3>";; |
| 44 | esac |
| 45 | |
| 46 | logwrapper /system/bin/hci_qcomm_init -e $PWR_CLASS |
| 47 | |
| 48 | case $? in |
| 49 | 0) logi "Bluetooth QSoC firmware download succeeded, $BTS_DEVICE $BTS_TYPE $BTS_BAUD $BTS_ADDRESS";; |
| 50 | *) failed "Bluetooth QSoC firmware download failed" $exit_code_hci_qcomm_init; |
| 51 | exit $exit_code_hci_qcomm_init;; |
| 52 | esac |
| 53 | |
| 54 | logi "start bluetooth smd transport" |
| 55 | |
| 56 | echo 1 > /sys/module/hci_smd/parameters/hcismd_set |
| 57 | |
| 58 | exit 0 |