blob: 0111434f7371d0f0b5d1f2aab9c35a7fab0cd942 [file] [log] [blame]
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -07001#!/system/bin/sh
2
3BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto
4LOG_TAG="mako-bluetooth"
5LOG_NAME="${0}:"
6
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -07007loge ()
8{
9 /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
10}
11
12logi ()
13{
14 /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
15}
16
17failed ()
18{
19 loge "$1: exit code $2"
20 exit $2
21}
22
23# Note that "hci_qcomm_init -e" prints expressions to set the shell variables
24# BTS_DEVICE, BTS_TYPE, BTS_BAUD, and BTS_ADDRESS.
25
26POWER_CLASS=`getprop qcom.bt.dev_power_class`
27TRANSPORT=`getprop ro.qualcomm.bt.hci_transport`
28
29#find the transport type
30logi "Transport : $TRANSPORT"
31
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090032#load bd addr
33BDADDR=`/system/bin/bdAddrLoader -p`
34
Jeonghoon lim0a3bd802012-08-14 18:08:24 -070035setprop bluetooth.status off
36
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090037logi "BDADDR: $BDADDR"
38
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070039case $POWER_CLASS in
40 1) PWR_CLASS="-p 0" ;
41 logi "Power Class: 1";;
42 2) PWR_CLASS="-p 1" ;
43 logi "Power Class: 2";;
44 3) PWR_CLASS="-p 2" ;
45 logi "Power Class: CUSTOM";;
46 *) PWR_CLASS="";
47 logi "Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM)";
48 logi "Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3>";;
49esac
50
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090051if ["$BDADDR" == ""]
52then
53 logwrapper /system/bin/hci_qcomm_init -e $PWR_CLASS -vv
54else
55 logwrapper /system/bin/hci_qcomm_init -b $BDADDR -e $PWR_CLASS -vv
56fi
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070057
58case $? in
59 0) logi "Bluetooth QSoC firmware download succeeded, $BTS_DEVICE $BTS_TYPE $BTS_BAUD $BTS_ADDRESS";;
60 *) failed "Bluetooth QSoC firmware download failed" $exit_code_hci_qcomm_init;
Jeonghoon lim0a3bd802012-08-14 18:08:24 -070061 setprop bluetooth.status off;
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070062 exit $exit_code_hci_qcomm_init;;
63esac
64
Jeonghoon lim0a3bd802012-08-14 18:08:24 -070065setprop bluetooth.status on
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070066
Jeonghoon lim0a3bd802012-08-14 18:08:24 -070067logi "start bluetooth smd transport"
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070068
69exit 0