Skip to content

Commit 50a8ae9

Browse files
committed
libbt: call hw_reset() in upio_set_bluetooth_power()
Workaround for bt_hci timeout. Information from following links : raspberrypi/linux#2832 https://github.com/raspberrypi/userland/blob/master/host_applications/linux/apps/vcmailbox/vcmailbox.c libbt changes are suggested by Lidong Zhou <[email protected]> Change-Id: Ic67eed2d60d9bea23323bbe82f824ea3afc4e674
1 parent 46099c2 commit 50a8ae9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/bt_vendor_brcm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ static int op(bt_vendor_opcode_t opcode, void *param)
152152
if (*state == BT_VND_PWR_ON)
153153
{
154154
ALOGW("NOTE: BT_VND_PWR_ON now forces power-off first");
155+
usleep(200000);
155156
upio_set_bluetooth_power(UPIO_BT_POWER_ON);
157+
usleep(200000);
156158
} else {
157159
/* Make sure wakelock is released */
158160
hw_lpm_set_wake_state(false);

src/upio.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <stdio.h>
4040
#include <unistd.h>
4141
#include <time.h>
42+
#include <sys/ioctl.h>
4243

4344
/******************************************************************************
4445
** Constants & Macros
@@ -275,6 +276,16 @@ void upio_cleanup(void)
275276
#endif
276277
}
277278

279+
static void hw_reset(bool reset) {
280+
unsigned buf[8] = { 8 * 4, 0, 0x38041, 8, 8, 128, 0, 0};
281+
buf[6] = reset ? 0 : 1;
282+
int fd = open("/dev/vcio", 0);
283+
if (fd >= 0) {
284+
ioctl(fd, _IOWR(100, 0, char *), buf);
285+
close(fd);
286+
}
287+
}
288+
278289
/*******************************************************************************
279290
**
280291
** Function upio_set_bluetooth_power
@@ -297,10 +308,12 @@ int upio_set_bluetooth_power(int on)
297308
{
298309
case UPIO_BT_POWER_OFF:
299310
buffer = '0';
311+
hw_reset(true);
300312
break;
301313

302314
case UPIO_BT_POWER_ON:
303315
buffer = '1';
316+
hw_reset(false);
304317
break;
305318
}
306319

0 commit comments

Comments
 (0)