diff --git a/src/bt_vendor_brcm.c b/src/bt_vendor_brcm.c index 01e89a2..9927ad8 100644 --- a/src/bt_vendor_brcm.c +++ b/src/bt_vendor_brcm.c @@ -152,7 +152,9 @@ static int op(bt_vendor_opcode_t opcode, void *param) if (*state == BT_VND_PWR_ON) { ALOGW("NOTE: BT_VND_PWR_ON now forces power-off first"); + usleep(200000); upio_set_bluetooth_power(UPIO_BT_POWER_ON); + usleep(200000); } else { /* Make sure wakelock is released */ hw_lpm_set_wake_state(false); diff --git a/src/upio.c b/src/upio.c index 5050393..388600d 100644 --- a/src/upio.c +++ b/src/upio.c @@ -39,6 +39,7 @@ #include #include #include +#include /****************************************************************************** ** Constants & Macros @@ -275,6 +276,16 @@ void upio_cleanup(void) #endif } +static void hw_reset(bool reset) { + unsigned buf[8] = { 8 * 4, 0, 0x38041, 8, 8, 128, 0, 0}; + buf[6] = reset ? 0 : 1; + int fd = open("/dev/vcio", 0); + if (fd >= 0) { + ioctl(fd, _IOWR(100, 0, char *), buf); + close(fd); + } +} + /******************************************************************************* ** ** Function upio_set_bluetooth_power @@ -297,10 +308,12 @@ int upio_set_bluetooth_power(int on) { case UPIO_BT_POWER_OFF: buffer = '0'; + hw_reset(true); break; case UPIO_BT_POWER_ON: buffer = '1'; + hw_reset(false); break; }