Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b44c2759 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Bluetooth: Add AVRCP 1.3 as a developer option for AVRCP version (2/2)" into oc-mr1-dev

parents 8879aa49 d881634d
Loading
Loading
Loading
Loading
+51 −1
Original line number Diff line number Diff line
@@ -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[] = {
+1 −0
Original line number Diff line number Diff line
@@ -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;
+16 −7
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@
#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 };

@@ -420,11 +424,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);
@@ -477,19 +490,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;
          }