Skip to content

Commit

Permalink
Support per-device Low Power Mode configuration
Browse files Browse the repository at this point in the history
Broadcom's Bluedroid's libbt-vendor implementation provides a set of
configurable values for the sleep_mode initialization. For example, some
devices have an active IRQ polarity set to 0 instead of the default 1.
In order to properly configure the BT chip, this patch exposes a set
of known LPM configurations choosable with LPM_DEVICE macro.
  • Loading branch information
FlorentRevest committed Feb 14, 2017
1 parent c8fbd5f commit 94fb127
Showing 1 changed file with 134 additions and 2 deletions.
136 changes: 134 additions & 2 deletions src/main.c
Expand Up @@ -179,9 +179,141 @@ uchar hci_update_baud_rate[] = { 0x01, 0x18, 0xfc, 0x06, 0x00, 0x00,
uchar hci_write_bd_addr[] = { 0x01, 0x01, 0xfc, 0x06,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

/* Custom Low Power Mode configuration.
* See android/hardware/broadcom/libbt/include/vnd_*.txt for more details. */
#ifdef LPM_ANGLER
#define LPM_IDLE_THRESHOLD 0x18
#define LPM_HC_IDLE_THRESHOLD 0x18
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_ANTHIAS
#define LPM_BT_WAKE_POLARITY 0x01
#define LPM_HOST_WAKE_POLARITY 0x01
#endif

#ifdef LPM_BASS
#define LPM_IDLE_THRESHOLD 0x0A
#define LPM_HC_IDLE_THRESHOLD 0x0A
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_CARP
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_DORY
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_HAMMERHEAD
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_LENOK
#define LPM_IDLE_THRESHOLD 0x0A
#define LPM_HC_IDLE_THRESHOLD 0x0A
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_NEMO
#define LPM_IDLE_THRESHOLD 0x0A
#define LPM_HC_IDLE_THRESHOLD 0x0A
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_PUFFER
#define LPM_IDLE_THRESHOLD 0x02
#define LPM_HC_IDLE_THRESHOLD 0x02
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_SAWSHARK
#define LPM_IDLE_THRESHOLD 0x18
#define LPM_HC_IDLE_THRESHOLD 0x18
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_SHAMU
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_SMELT
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_SPARROW
#define LPM_BT_WAKE_POLARITY 0x01
#define LPM_HOST_WAKE_POLARITY 0x01
#endif

#ifdef LPM_STURGEON
#define LPM_IDLE_THRESHOLD 0x18
#define LPM_HC_IDLE_THRESHOLD 0x18
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_TETRA
#define LPM_IDLE_THRESHOLD 0x01
#define LPM_HC_IDLE_THRESHOLD 0x01
#define LPM_BT_WAKE_POLARITY 0x00
#define LPM_HOST_WAKE_POLARITY 0x00
#endif

#ifdef LPM_WREN
#define LPM_BT_WAKE_POLARITY 0x01
#define LPM_HOST_WAKE_POLARITY 0x01
#endif

/* Default Low Power Mode configuration.
* See android/hardware/broadcom/libbt/include/bt_vendor_brcm.h for more details. */
#ifndef LPM_SLEEP_MODE
#define LPM_SLEEP_MODE 0x01
#endif
#ifndef LPM_IDLE_THRESHOLD
#define LPM_IDLE_THRESHOLD 0x01
#endif
#ifndef LPM_HC_IDLE_THRESHOLD
#define LPM_HC_IDLE_THRESHOLD 0x01
#endif
#ifndef LPM_BT_WAKE_POLARITY
#define LPM_BT_WAKE_POLARITY 0x01
#endif
#ifndef LPM_HOST_WAKE_POLARITY
#define LPM_HOST_WAKE_POLARITY 0x01
#endif
#ifndef LPM_ALLOW_HOST_SLEEP_DURING_SCO
#define LPM_ALLOW_HOST_SLEEP_DURING_SCO 0x01
#endif
#ifndef LPM_COMBINE_SLEEP_MODE_AND_LPM
#define LPM_COMBINE_SLEEP_MODE_AND_LPM 0x01
#endif
#ifndef LPM_ENABLE_UART_TXD_TRI_STATE
#define LPM_ENABLE_UART_TXD_TRI_STATE 0x00
#endif

uchar hci_write_sleep_mode[] = { 0x01, 0x27, 0xfc, 0x0c,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00 };
LPM_SLEEP_MODE,
LPM_IDLE_THRESHOLD,
LPM_HC_IDLE_THRESHOLD,
LPM_BT_WAKE_POLARITY,
LPM_HOST_WAKE_POLARITY,
LPM_ALLOW_HOST_SLEEP_DURING_SCO,
LPM_COMBINE_SLEEP_MODE_AND_LPM,
LPM_ENABLE_UART_TXD_TRI_STATE,
0x00, 0x00, 0x00, 0x00 };

uchar hci_write_sco_pcm_int[] =
{ 0x01, 0x1C, 0xFC, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 };
Expand Down

0 comments on commit 94fb127

Please sign in to comment.