OSDN Git Service

Bluetooth: Add AVRCP 1.3 as a developer option for AVRCP version (2/2)
authorAjay Panicker <apanicke@google.com>
Fri, 1 Sep 2017 19:07:42 +0000 (12:07 -0700)
committerMyles Watson <mylesgw@google.com>
Fri, 22 Sep 2017 16:37:16 +0000 (16:37 +0000)
This is requied for the 2012 Mazda 3 carkit as the carkit refuses to send
AVRCP commands other than passthrough commands when the version is anything
else. AVRCP 1.3 is compatible with most carkits on the market and can be
used to get most carkits working at the cost of losing many features.

Bug: 37943083
Test: Set AVRCP 1.3 in developer options and see that SDP and the AVRCP
      capabilites have updated to reflect this.
      TestTracker: 105915/3975

Change-Id: Iffc7ed1dd91eecb699153125b25451de5826f202
(cherry picked from commit 2369a95e6ed0c16f61237fe9c1fc5a90d97129c1)

bta/av/bta_av_cfg.cc
bta/av/bta_av_int.h
bta/av/bta_av_main.cc

index 5fc75ba..688af45 100644 (file)
@@ -84,7 +84,7 @@ const uint16_t bta_av_audio_flush_to[] = {
 #endif
 
 /*
- * If the number of event IDs is changed in this array, BTA_AV_ NUM_RC_EVT_IDS
+ * If the number of event IDs is changed in this array, BTA_AV_NUM_RC_EVT_IDS
  * also needs to be changed.
  */
 const uint8_t bta_av_meta_caps_evt_ids[] = {
@@ -96,6 +96,7 @@ const uint8_t bta_av_meta_caps_evt_ids[] = {
     AVRC_EVT_APP_SETTING_CHANGE,
     */
 };
+
 #ifndef BTA_AV_NUM_RC_EVT_IDS
 #define BTA_AV_NUM_RC_EVT_IDS \
   (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0]))
@@ -106,11 +107,24 @@ const uint8_t bta_avk_meta_caps_evt_ids[] = {
     AVRC_EVT_VOLUME_CHANGE,
 #endif
 };
+
 #ifndef BTA_AVK_NUM_RC_EVT_IDS
 #define BTA_AVK_NUM_RC_EVT_IDS \
   (sizeof(bta_avk_meta_caps_evt_ids) / sizeof(bta_avk_meta_caps_evt_ids[0]))
 #endif /* BTA_AVK_NUM_RC_EVT_IDS */
 
+// These are the only events used with AVRCP1.3
+const uint8_t bta_av_meta_caps_evt_ids_avrcp13[] = {
+    AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE,
+    AVRC_EVT_PLAY_POS_CHANGED,
+};
+
+#ifndef BTA_AV_NUM_RC_EVT_IDS_AVRCP13
+#define BTA_AV_NUM_RC_EVT_IDS_AVRCP13         \
+  (sizeof(bta_av_meta_caps_evt_ids_avrcp13) / \
+   sizeof(bta_av_meta_caps_evt_ids_avrcp13[0]))
+#endif /* BTA_AVK_NUM_RC_EVT_IDS_AVRCP13 */
+
 /* the MTU for the AVRCP browsing channel */
 #ifndef BTA_AV_MAX_RC_BR_MTU
 #define BTA_AV_MAX_RC_BR_MTU 1008
@@ -186,6 +200,42 @@ const tBTA_AV_CFG bta_avk_cfg = {
     {0},                       /* Default AVRCP target name */
 };
 
+/* This configuration to be used when we are using AVRCP1.3 */
+const tBTA_AV_CFG bta_av_cfg_compatibility = {
+    BTA_AV_RC_COMP_ID, /* AVRCP Company ID */
+#if (AVRC_METADATA_INCLUDED == TRUE)
+    512,                  /* AVRCP MTU at L2CAP for control channel */
+    BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
+#else
+    48,                   /* AVRCP MTU at L2CAP for control channel */
+    BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
+#endif
+    BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */
+    AVRC_SUPF_TG_CAT1, /* Only support CAT1 for AVRCP1.3 */
+    672,               /* AVDTP signaling channel MTU at L2CAP */
+    BTA_AV_MAX_A2DP_MTU, /* AVDTP audio transport channel MTU at L2CAP
+                          */
+    bta_av_audio_flush_to, /* AVDTP audio transport channel flush
+                              timeout */
+    6,                  /* AVDTP audio channel max data queue size */
+    BTA_AV_MAX_VDP_MTU, /* AVDTP video transport channel MTU at L2CAP */
+    600,                /* AVDTP video transport channel flush timeout */
+    false,              /* true, to accept AVRC 1.3 group nevigation command */
+    2,                  /* company id count in p_meta_co_ids */
+    BTA_AV_NUM_RC_EVT_IDS_AVRCP13,    /* event id count for AVRCP1.3*/
+    BTA_AV_RC_PASS_RSP_CODE,          /* the default response code for pass
+                                         through commands */
+    bta_av_meta_caps_co_ids,          /* the metadata Get Capabilities response
+                                         for company id */
+    bta_av_meta_caps_evt_ids_avrcp13, /* the the metadata Get Capabilities
+                                         response for event id, compatible
+                                         with AVRCP1.3*/
+    NULL,              /* the action function table for VDP stream */
+    NULL,              /* action function to register VDP */
+    BTA_AV_RC_CT_NAME, /* Default AVRCP controller name */
+    BTA_AV_RC_TG_NAME  /* Default AVRCP target name */
+};
+
 tBTA_AV_CFG* p_bta_av_cfg = NULL;
 
 const uint16_t bta_av_rc_id[] = {
index c145759..963a84a 100644 (file)
@@ -577,6 +577,7 @@ extern tBTA_AV_CB bta_av_cb;
 extern tBTA_AV_CFG* p_bta_av_cfg;
 extern const tBTA_AV_CFG bta_avk_cfg;
 extern const tBTA_AV_CFG bta_av_cfg;
+extern const tBTA_AV_CFG bta_av_cfg_compatibility;
 
 /* rc id config struct */
 extern uint16_t* p_bta_av_rc_id;
index c81ed8d..0d7c360 100644 (file)
 #define AVRCP_1_4_STRING "avrcp14"
 #endif
 
+#ifndef AVRCP_1_3_STRING
+#define AVRCP_1_3_STRING "avrcp13"
+#endif
+
 /* state machine states */
 enum { BTA_AV_INIT_ST, BTA_AV_OPEN_ST };
 
@@ -422,11 +426,20 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) {
   registr.app_id = p_data->api_reg.app_id;
   registr.chnl = (tBTA_AV_CHNL)p_data->hdr.layer_specific;
 
+  char avrcp_version[PROPERTY_VALUE_MAX] = {0};
+  osi_property_get(AVRCP_VERSION_PROPERTY, avrcp_version, AVRCP_1_4_STRING);
+  LOG_INFO(LOG_TAG, "AVRCP version used for sdp: \"%s\"", avrcp_version);
+
   uint16_t profile_initialized = p_data->api_reg.service_uuid;
   if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK) {
     p_bta_av_cfg = (tBTA_AV_CFG*)&bta_avk_cfg;
   } else if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE) {
     p_bta_av_cfg = (tBTA_AV_CFG*)&bta_av_cfg;
+
+    if (!strncmp(AVRCP_1_3_STRING, avrcp_version, sizeof(AVRCP_1_3_STRING))) {
+      LOG_INFO(LOG_TAG, "AVRCP 1.3 capabilites used");
+      p_bta_av_cfg = (tBTA_AV_CFG*)&bta_av_cfg_compatibility;
+    }
   }
 
   APPL_TRACE_DEBUG("%s: profile: 0x%x", __func__, profile_initialized);
@@ -479,19 +492,15 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) {
         uint16_t profile_version = AVRC_REV_1_0;
 
         if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE) {
-          // This check can override the AVRCP profile version with a property
-          char avrcp_version[PROPERTY_VALUE_MAX] = {0};
-          osi_property_get(AVRCP_VERSION_PROPERTY, avrcp_version,
-                           AVRCP_1_4_STRING);
-          LOG_INFO(LOG_TAG, "AVRCP version used for sdp: \"%s\"",
-                   avrcp_version);
-
           if (!strncmp(AVRCP_1_6_STRING, avrcp_version,
                        sizeof(AVRCP_1_6_STRING))) {
             profile_version = AVRC_REV_1_6;
           } else if (!strncmp(AVRCP_1_5_STRING, avrcp_version,
                               sizeof(AVRCP_1_5_STRING))) {
             profile_version = AVRC_REV_1_5;
+          } else if (!strncmp(AVRCP_1_3_STRING, avrcp_version,
+                              sizeof(AVRCP_1_3_STRING))) {
+            profile_version = AVRC_REV_1_3;
           } else {
             profile_version = AVRC_REV_1_4;
           }