From 18985be5fdc5b407f3ac4ace39af2623fd97f126 Mon Sep 17 00:00:00 2001 From: Kim Low Date: Wed, 20 Dec 2017 15:11:08 -0800 Subject: [PATCH] Add separate sniff mode settings for gamepads For gamepads, the sniff intervals need to be much shorter. The min is set to 14 slots (8.75ms) and max is set to 18 slots (11.25ms). Test: Load >=4.10 hid-sony driver, connect a DualShock4, check its responsiveness. Wait for 5 minutes, wake it up (if it went into PARK mode) and check that it's still as responsive. Furthermore, use a Bluetooth sniffer to confirm the sniff interval. Bug: 38511270 Change-Id: I27e2e0c8e88ab51800c4976e0971c92a3793f8d2 --- bta/dm/bta_dm_cfg.cc | 82 +++++++++++++++++++++++++++++++++---------------- bta/include/bta_api.h | 9 +++++- doc/power_management.md | 4 +-- 3 files changed, 66 insertions(+), 29 deletions(-) diff --git a/bta/dm/bta_dm_cfg.cc b/bta/dm/bta_dm_cfg.cc index 91053a19b..6af515140 100644 --- a/bta/dm/bta_dm_cfg.cc +++ b/bta/dm/bta_dm_cfg.cc @@ -28,6 +28,7 @@ #include "bt_target.h" #include "bta_api.h" #include "bta_dm_int.h" +#include "bta_hh_api.h" #include "bta_jv_api.h" #include "bta_sys.h" @@ -116,8 +117,8 @@ const tBTA_DM_CFG* p_bta_dm_cfg = &bta_dm_cfg; const tBTA_DM_RM* p_bta_dm_rm_cfg = &bta_dm_rm_cfg[0]; #define BTA_DM_NUM_PM_ENTRY \ - 23 /* number of entries in bta_dm_pm_cfg except the first */ -#define BTA_DM_NUM_PM_SPEC 15 /* number of entries in bta_dm_pm_spec */ + 25 /* number of entries in bta_dm_pm_cfg except the first */ +#define BTA_DM_NUM_PM_SPEC 16 /* number of entries in bta_dm_pm_spec */ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[BTA_DM_NUM_PM_ENTRY + 1] = { @@ -126,19 +127,23 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG {BTA_ID_AG, BTA_ALL_APP_ID, 0}, /* ag uses first spec table for app id 0 */ {BTA_ID_CT, 1, 1}, /* ct (BTA_ID_CT,APP ID=1) spec table */ - {BTA_ID_CG, BTA_ALL_APP_ID, 1}, /* cg resue ct spec table */ - {BTA_ID_DG, BTA_ALL_APP_ID, 2}, /* dg spec table */ - {BTA_ID_AV, BTA_ALL_APP_ID, 4}, /* av spec table */ - {BTA_ID_AVK, BTA_ALL_APP_ID, 12}, /* avk spec table */ - {BTA_ID_FTC, BTA_ALL_APP_ID, 6}, /* ftc spec table */ - {BTA_ID_FTS, BTA_ALL_APP_ID, 7}, /* fts spec table */ - {BTA_ID_HD, BTA_ALL_APP_ID, 3}, /* hd spec table */ - {BTA_ID_HH, BTA_ALL_APP_ID, 5}, /* hh spec table */ - {BTA_ID_PBC, BTA_ALL_APP_ID, 2}, /* reuse dg spec table */ - {BTA_ID_PBS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */ - {BTA_ID_OPC, BTA_ALL_APP_ID, 6}, /* reuse ftc spec table */ - {BTA_ID_OPS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */ - {BTA_ID_MSE, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */ + {BTA_ID_CG, BTA_ALL_APP_ID, 1}, /* cg resue ct spec table */ + {BTA_ID_DG, BTA_ALL_APP_ID, 2}, /* dg spec table */ + {BTA_ID_AV, BTA_ALL_APP_ID, 4}, /* av spec table */ + {BTA_ID_AVK, BTA_ALL_APP_ID, 12}, /* avk spec table */ + {BTA_ID_FTC, BTA_ALL_APP_ID, 6}, /* ftc spec table */ + {BTA_ID_FTS, BTA_ALL_APP_ID, 7}, /* fts spec table */ + {BTA_ID_HD, BTA_ALL_APP_ID, 3}, /* hd spec table */ + {BTA_ID_HH, BTA_HH_APP_ID_JOY, 5}, /* app BTA_HH_APP_ID_JOY, + similar to hh spec table */ + {BTA_ID_HH, BTA_HH_APP_ID_GPAD, 5}, /* app BTA_HH_APP_ID_GPAD, + similar to hh spec table */ + {BTA_ID_HH, BTA_ALL_APP_ID, 6}, /* hh spec table */ + {BTA_ID_PBC, BTA_ALL_APP_ID, 2}, /* reuse dg spec table */ + {BTA_ID_PBS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */ + {BTA_ID_OPC, BTA_ALL_APP_ID, 6}, /* reuse ftc spec table */ + {BTA_ID_OPS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */ + {BTA_ID_MSE, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */ {BTA_ID_JV, BTA_JV_PM_ID_1, 6}, /* app BTA_JV_PM_ID_1, reuse ftc spec table */ {BTA_ID_JV, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */ @@ -253,7 +258,29 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }}, - /* HH : 5 */ + /* HH for joysticks and gamepad : 5 */ + {(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */ +#if (BTM_SSR_INCLUDED == TRUE) + (BTA_DM_PM_SSR1), /* the SSR entry */ +#endif + { + {{BTA_DM_PM_SNIFF6, BTA_DM_PM_HH_OPEN_DELAY}, + {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */ + {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */ + {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */ + {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */ + {{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */ + {{BTA_DM_PM_NO_ACTION, 0}, + {BTA_DM_PM_NO_ACTION, 0}}, /* sco close, used for HH suspend */ + {{BTA_DM_PM_SNIFF6, BTA_DM_PM_HH_IDLE_DELAY}, + {BTA_DM_PM_NO_ACTION, 0}}, /* idle */ + {{BTA_DM_PM_SNIFF6, BTA_DM_PM_HH_ACTIVE_DELAY}, + {BTA_DM_PM_NO_ACTION, 0}}, /* busy */ + {{BTA_DM_PM_NO_ACTION, 0}, + {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ + }}, + + /* HH : 6 */ {(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */ #if (BTM_SSR_INCLUDED == TRUE) (BTA_DM_PM_SSR1), /* the SSR entry */ @@ -275,7 +302,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }}, - /* FTC, OPC, JV : 6 */ + /* FTC, OPC, JV : 7 */ {(BTA_DM_PM_SNIFF), /* allow sniff */ #if (BTM_SSR_INCLUDED == TRUE) (BTA_DM_PM_SSR2), /* the SSR entry */ @@ -295,7 +322,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }}, - /* FTS, PBS, OPS, MSE, BTA_JV_PM_ID_1 : 7 */ + /* FTS, PBS, OPS, MSE, BTA_JV_PM_ID_1 : 8 */ {(BTA_DM_PM_SNIFF), /* allow sniff */ #if (BTM_SSR_INCLUDED == TRUE) (BTA_DM_PM_SSR2), /* the SSR entry */ @@ -315,7 +342,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }}, - /* HL : 8 */ + /* HL : 9 */ {(BTA_DM_PM_SNIFF), /* allow sniff */ #if (BTM_SSR_INCLUDED == TRUE) (BTA_DM_PM_SSR2), /* the SSR entry */ @@ -336,7 +363,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }}, - /* PANU : 9 */ + /* PANU : 10 */ {(BTA_DM_PM_SNIFF), /* allow sniff */ #if (BTM_SSR_INCLUDED == TRUE) (BTA_DM_PM_SSR2), /* the SSR entry */ @@ -356,7 +383,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }}, - /* NAP : 10 */ + /* NAP : 11 */ {(BTA_DM_PM_SNIFF), /* allow sniff */ #if (BTM_SSR_INCLUDED == TRUE) (BTA_DM_PM_SSR2), /* the SSR entry */ @@ -377,7 +404,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }}, - /* HS : 11 */ + /* HS : 12 */ {(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */ #if (BTM_SSR_INCLUDED == TRUE) (BTA_DM_PM_SSR2), /* the SSR entry */ @@ -398,7 +425,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }}, - /* AVK : 12 */ + /* AVK : 13 */ {(BTA_DM_PM_SNIFF), /* allow sniff */ #if (BTM_SSR_INCLUDED == TRUE) (BTA_DM_PM_SSR2), /* the SSR entry */ @@ -417,7 +444,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }} - /* GATTC : 13 */ + /* GATTC : 14 */ , {(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */ #if (BTM_SSR_INCLUDED == TRUE) @@ -437,7 +464,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { {{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */ }} - /* GATTS : 14 */ + /* GATTS : 15 */ , {(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */ #if (BTM_SSR_INCLUDED == TRUE) @@ -474,7 +501,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = { /* Please refer to the SNIFF table definitions in bta_api.h. * * Adding to or Modifying the Table - * Additional sniff parameter entries can be added for BTA_DM_PM_SNIFF5 - + * Additional sniff parameter entries can be added for BTA_DM_PM_SNIFF6 - * BTA_DM_PM_SNIFF7. * Overrides of additional table entries can be specified in bdroid_buildcfg.h. * If additional @@ -521,6 +548,9 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTM_PM_PWR_MD bta_dm_pm_md[] = { {BTA_DM_PM_SNIFF5_MAX, BTA_DM_PM_SNIFF5_MIN, BTA_DM_PM_SNIFF5_ATTEMPT, BTA_DM_PM_SNIFF5_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF5- HD active */ + {BTA_DM_PM_SNIFF6_MAX, BTA_DM_PM_SNIFF6_MIN, BTA_DM_PM_SNIFF6_ATTEMPT, + BTA_DM_PM_SNIFF6_TIMEOUT, + BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF6- HD active */ {BTA_DM_PM_PARK_MAX, BTA_DM_PM_PARK_MIN, BTA_DM_PM_PARK_ATTEMPT, BTA_DM_PM_PARK_TIMEOUT, BTM_PM_MD_PARK} diff --git a/bta/include/bta_api.h b/bta/include/bta_api.h index 9d4693e0b..9f2ee2835 100644 --- a/bta/include/bta_api.h +++ b/bta/include/bta_api.h @@ -877,7 +877,7 @@ typedef uint8_t tBTA_DM_PM_ACTION; #ifndef BTA_DM_PM_PARK_IDX #define BTA_DM_PM_PARK_IDX \ - 5 /* the actual index to bta_dm_pm_md[] for PARK mode */ + 6 /* the actual index to bta_dm_pm_md[] for PARK mode */ #endif #ifndef BTA_DM_PM_SNIFF_A2DP_IDX @@ -968,6 +968,13 @@ typedef uint8_t tBTA_DM_PM_ACTION; #define BTA_DM_PM_SNIFF5_TIMEOUT 0 #endif +#ifndef BTA_DM_PM_SNIFF6_MAX +#define BTA_DM_PM_SNIFF6_MAX 18 +#define BTA_DM_PM_SNIFF6_MIN 14 +#define BTA_DM_PM_SNIFF6_ATTEMPT 1 +#define BTA_DM_PM_SNIFF6_TIMEOUT 0 +#endif + #ifndef BTA_DM_PM_PARK_MAX #define BTA_DM_PM_PARK_MAX 800 #define BTA_DM_PM_PARK_MIN 400 diff --git a/doc/power_management.md b/doc/power_management.md index 2b90130dd..68032571c 100644 --- a/doc/power_management.md +++ b/doc/power_management.md @@ -62,12 +62,12 @@ additional description: action that `bta_dm_pm_set_mode` will take, the connection will be removed from `bta_dm_conn_srvcs` and no longer be considered for power management decisions. - - `BTA_DM_PM_SNIFF` through `BTA_DM_PM_SNIFF4` are special, in that each + - `BTA_DM_PM_SNIFF` through `BTA_DM_PM_SNIFF6` are special, in that each level specifies a set of parameters for the SNIFF mode which relate to the min and max intervals, the number of attempts and the timeout. The overall action is still the same, however -- SNIFF mode is attempted. There are definitions available up to SNIFF7, but actual SSR values are only defined - up to SNIFF4. Params are defined in `bta_dm_ssr_spec`. + up to SNIFF6. Params are defined in `bta_dm_ssr_spec`. - `BTA_DM_PM_ACTIVE` is full-on power. - `BTA_DM_PM_RETRY` has the same effect as `BTA_DM_PM_NO_ACTION`, except a timeout is possible to be set, which effectively allows a power operation to -- 2.11.0