Skip to content

Commit

Permalink
libbt: call hw_reset() in upio_set_bluetooth_power()
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
peyo-hd committed Nov 18, 2022
1 parent bbeef79 commit ee8a363
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bt_vendor_brcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions src/upio.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/ioctl.h>

/******************************************************************************
** Constants & Macros
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down

0 comments on commit ee8a363

Please sign in to comment.