blob: d3fc5f8adbc4adc3545f6f3b0053219274ee3516 [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`
jeonghoon.lim668b0cc2012-08-23 13:10:57 +090028DUTADDR=`getprop net.btdut.address`
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070029
30#find the transport type
31logi "Transport : $TRANSPORT"
jeonghoon.lim668b0cc2012-08-23 13:10:57 +090032logi "DUTADDR : $DUTADDR"
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070033
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090034#load bd addr
jeonghoon.lim668b0cc2012-08-23 13:10:57 +090035if [$DUTADDR == ""]
36then
37BDADDR=`/system/bin/bdAddrLoader -f /persist/bluetooth/.bdaddr -h -x`
38else
39BDADDR=`/system/bin/bdAddrLoader -p net.btdut.address -s -x`
40fi
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090041
Jeonghoon lim0a3bd802012-08-14 18:08:24 -070042setprop bluetooth.status off
43
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090044logi "BDADDR: $BDADDR"
45
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070046case $POWER_CLASS in
47 1) PWR_CLASS="-p 0" ;
48 logi "Power Class: 1";;
49 2) PWR_CLASS="-p 1" ;
50 logi "Power Class: 2";;
51 3) PWR_CLASS="-p 2" ;
52 logi "Power Class: CUSTOM";;
53 *) PWR_CLASS="";
54 logi "Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM)";
55 logi "Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3>";;
56esac
57
jeonghoon.lim668b0cc2012-08-23 13:10:57 +090058if [$BDADDR == ""]
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090059then
jeonghoon.lim668b0cc2012-08-23 13:10:57 +090060logwrapper /system/bin/hci_qcomm_init -e $PWR_CLASS -vv
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090061else
jeonghoon.lim668b0cc2012-08-23 13:10:57 +090062logwrapper /system/bin/hci_qcomm_init -b $BDADDR -e $PWR_CLASS -vv
jeonghoon.lim85ddb8c2012-07-20 11:35:54 +090063fi
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070064
65case $? in
jeonghoon.lim668b0cc2012-08-23 13:10:57 +090066 0) logi "Bluetooth QSoC firmware download succeeded, $PWR_CLASS $BDADDR $TRANSPORT";;
Devin Kim5f7b5e12013-02-01 08:42:14 -080067 *) failed "Bluetooth QSoC firmware download failed" $?;
Jeonghoon lim0a3bd802012-08-14 18:08:24 -070068 setprop bluetooth.status off;
Devin Kim5f7b5e12013-02-01 08:42:14 -080069 exit $?;;
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070070esac
71
Jeonghoon lim0a3bd802012-08-14 18:08:24 -070072setprop bluetooth.status on
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070073
Jeonghoon lim0a3bd802012-08-14 18:08:24 -070074logi "start bluetooth smd transport"
jeonghoon.lim6a2ca5a2012-07-13 13:00:37 -070075
76exit 0