From 85d56a8d38209c9d17a691c1cbefab22fb7bacc2 Mon Sep 17 00:00:00 2001 From: Andre Eisenbach Date: Thu, 13 Jun 2019 11:50:57 -0700 Subject: [PATCH] Limit sniff mode for Nintendo Pro Controller to 11.25ms Bug: 133410149 Test: manual Change-Id: I4bffb759323bedd36e754cf758ac1d61cffc886e (cherry picked from commit b62d0a17ec545fb477a5155790e9e96d1472659b) --- bta/hh/bta_hh_utils.cc | 6 ++++++ device/include/interop.h | 6 +++++- device/include/interop_database.h | 4 ++++ device/src/interop.cc | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bta/hh/bta_hh_utils.cc b/bta/hh/bta_hh_utils.cc index c4c60618f..e36978813 100644 --- a/bta/hh/bta_hh_utils.cc +++ b/bta/hh/bta_hh_utils.cc @@ -21,6 +21,7 @@ #if (BTA_HH_INCLUDED == TRUE) #include "bta_hh_int.h" +#include "device/include/interop.h" #include "osi/include/osi.h" /* if SSR max latency is not defined by remote device, set the default value @@ -393,6 +394,11 @@ tBTA_HH_STATUS bta_hh_read_ssr_param(const RawAddress& bd_addr, if (ssr_max_latency > BTA_HH_SSR_MAX_LATENCY_DEF) ssr_max_latency = BTA_HH_SSR_MAX_LATENCY_DEF; + if (interop_match_addr(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL, + &bd_addr)) { + if (ssr_max_latency > 18 /* slots * 0.625ms */) ssr_max_latency = 18; + } + *p_max_ssr_lat = ssr_max_latency; } else *p_max_ssr_lat = p_cb->kdev[i].dscp_info.ssr_max_latency; diff --git a/device/include/interop.h b/device/include/interop.h index b31efc36b..a9bf58603 100644 --- a/device/include/interop.h +++ b/device/include/interop.h @@ -89,7 +89,11 @@ typedef enum { // Disable role switch for headsets/car-kits. // Some car kits allow role switch but when the Phone initiates role switch, // the Remote device will go into bad state that will lead to LMP time out. - INTEROP_DISABLE_ROLE_SWITCH + INTEROP_DISABLE_ROLE_SWITCH, + + // Set a very low initial sniff subrating for HID devices that do not + // set their own sniff interval. + INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL, } interop_feature_t; // Check if a given |addr| matches a known interoperability workaround as diff --git a/device/include/interop_database.h b/device/include/interop_database.h index 1fa2a4dad..339e853dd 100644 --- a/device/include/interop_database.h +++ b/device/include/interop_database.h @@ -143,6 +143,10 @@ static const interop_addr_entry_t interop_addr_database[] = { // AirPods 2 - unacceptably loud volume {{{0x94, 0x16, 0x25, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, + + // Nintendo Switch Pro Controller - does not set sniff interval dynamically. + // Requires custom HID report command to change mode. + {{{0x98, 0xB6, 0xE9, 0, 0, 0}}, 3, INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL}, }; typedef struct { diff --git a/device/src/interop.cc b/device/src/interop.cc index c2ed2a8c9..e4bce56fe 100644 --- a/device/src/interop.cc +++ b/device/src/interop.cc @@ -128,6 +128,7 @@ static const char* interop_feature_string_(const interop_feature_t feature) { CASE_RETURN_STR(INTEROP_DISABLE_AVDTP_RECONFIGURE) CASE_RETURN_STR(INTEROP_DYNAMIC_ROLE_SWITCH) CASE_RETURN_STR(INTEROP_DISABLE_ROLE_SWITCH) + CASE_RETURN_STR(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL) } return "UNKNOWN"; -- 2.11.0