Home | History | Annotate | Download | only in av
      1 /******************************************************************************
      2  *
      3  *  Copyright 2005-2016 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 /******************************************************************************
     20  *
     21  *  This file contains compile-time configurable constants for advanced
     22  *  audio/video
     23  *
     24  ******************************************************************************/
     25 
     26 #include <stddef.h>
     27 
     28 #include "bt_common.h"
     29 #include "bt_target.h"
     30 #include "bta_api.h"
     31 #include "bta_av_int.h"
     32 
     33 #ifndef BTA_AV_RC_COMP_ID
     34 #define BTA_AV_RC_COMP_ID AVRC_CO_GOOGLE
     35 #endif
     36 
     37 #ifndef BTA_AV_RC_PASS_RSP_CODE
     38 #define BTA_AV_RC_PASS_RSP_CODE AVRC_RSP_NOT_IMPL
     39 #endif
     40 
     41 const uint32_t bta_av_meta_caps_co_ids[] = {AVRC_CO_METADATA, AVRC_CO_BROADCOM};
     42 
     43 /* AVRCP supported categories */
     44 #define BTA_AV_RC_SUPF_CT (AVRC_SUPF_CT_CAT2)
     45 #define BTA_AVK_RC_SUPF_CT (AVRC_SUPF_CT_CAT1 | AVRC_SUPF_CT_BROWSE)
     46 #define BTA_AVK_RC_SUPF_TG (AVRC_SUPF_TG_CAT2)
     47 
     48 /* AVRCP Controller and Targer default name */
     49 #ifndef BTA_AV_RC_CT_NAME
     50 #define BTA_AV_RC_CT_NAME "AVRC Controller"
     51 #endif
     52 
     53 #ifndef BTA_AV_RC_TG_NAME
     54 #define BTA_AV_RC_TG_NAME "AVRC Target"
     55 #endif
     56 
     57 /* Added to modify
     58  *	1. flush timeout
     59  *	2. Remove Group navigation support in SupportedFeatures
     60  *	3. GetCapabilities supported event_ids list
     61  *	4. GetCapabilities supported event_ids count
     62 */
     63 /* Flushing partial avdtp packets can cause some headsets to disconnect the link
     64    if receiving partial a2dp frames */
     65 const uint16_t bta_av_audio_flush_to[] = {
     66     0, /* 1 stream */
     67     0, /* 2 streams */
     68     0, /* 3 streams */
     69     0, /* 4 streams */
     70     0  /* 5 streams */
     71 };     /* AVDTP audio transport channel flush timeout */
     72 
     73 /* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI  */
     74 /* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be true
     75  */
     76 #ifndef BTA_AV_RC_SUPF_TG
     77 #define BTA_AV_RC_SUPF_TG                          \
     78   (AVRC_SUPF_TG_CAT1 | AVRC_SUPF_TG_MULTI_PLAYER | \
     79    AVRC_SUPF_TG_BROWSE) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
     80 #endif
     81 
     82 /*
     83  * If the number of event IDs is changed in this array, BTA_AV_NUM_RC_EVT_IDS
     84  * also needs to be changed.
     85  */
     86 const uint8_t bta_av_meta_caps_evt_ids[] = {
     87     AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE,
     88     AVRC_EVT_PLAY_POS_CHANGED,   AVRC_EVT_AVAL_PLAYERS_CHANGE,
     89     AVRC_EVT_ADDR_PLAYER_CHANGE, AVRC_EVT_UIDS_CHANGE,
     90     AVRC_EVT_NOW_PLAYING_CHANGE,
     91     /* TODO: Add support for these events
     92     AVRC_EVT_APP_SETTING_CHANGE,
     93     */
     94 };
     95 
     96 #ifndef BTA_AV_NUM_RC_EVT_IDS
     97 #define BTA_AV_NUM_RC_EVT_IDS \
     98   (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0]))
     99 #endif /* BTA_AV_NUM_RC_EVT_IDS */
    100 
    101 const uint8_t bta_avk_meta_caps_evt_ids[] = {
    102 #if (AVRC_ADV_CTRL_INCLUDED == TRUE)
    103     AVRC_EVT_VOLUME_CHANGE,
    104 #endif
    105 };
    106 
    107 #ifndef BTA_AVK_NUM_RC_EVT_IDS
    108 #define BTA_AVK_NUM_RC_EVT_IDS \
    109   (sizeof(bta_avk_meta_caps_evt_ids) / sizeof(bta_avk_meta_caps_evt_ids[0]))
    110 #endif /* BTA_AVK_NUM_RC_EVT_IDS */
    111 
    112 // These are the only events used with AVRCP1.3
    113 const uint8_t bta_av_meta_caps_evt_ids_avrcp13[] = {
    114     AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE,
    115     AVRC_EVT_PLAY_POS_CHANGED,
    116 };
    117 
    118 #ifndef BTA_AV_NUM_RC_EVT_IDS_AVRCP13
    119 #define BTA_AV_NUM_RC_EVT_IDS_AVRCP13         \
    120   (sizeof(bta_av_meta_caps_evt_ids_avrcp13) / \
    121    sizeof(bta_av_meta_caps_evt_ids_avrcp13[0]))
    122 #endif /* BTA_AVK_NUM_RC_EVT_IDS_AVRCP13 */
    123 
    124 /* the MTU for the AVRCP browsing channel */
    125 #ifndef BTA_AV_MAX_RC_BR_MTU
    126 #define BTA_AV_MAX_RC_BR_MTU 1008
    127 #endif
    128 
    129 /* This configuration to be used when we are Src + TG + CT( only for abs vol) */
    130 const tBTA_AV_CFG bta_av_cfg = {
    131     BTA_AV_RC_COMP_ID,     /* AVRCP Company ID */
    132     512,                   /* AVRCP MTU at L2CAP for control channel */
    133     BTA_AV_MAX_RC_BR_MTU,  /* AVRCP MTU at L2CAP for browsing channel */
    134     BTA_AV_RC_SUPF_CT,     /* AVRCP controller categories */
    135     BTA_AV_RC_SUPF_TG,     /* AVRCP target categories */
    136     672,                   /* AVDTP signaling channel MTU at L2CAP */
    137     BTA_AV_MAX_A2DP_MTU,   /* AVDTP audio transport channel MTU at L2CAP */
    138     bta_av_audio_flush_to, /* AVDTP audio transport channel flush
    139                               timeout */
    140     6,                     /* AVDTP audio channel max data queue size */
    141     false, /* true, to accept AVRC 1.3 group nevigation command */
    142     2,     /* company id count in p_meta_co_ids */
    143     BTA_AV_NUM_RC_EVT_IDS,    /* event id count in p_meta_evt_ids */
    144     BTA_AV_RC_PASS_RSP_CODE,  /* the default response code for pass
    145                                  through commands */
    146     bta_av_meta_caps_co_ids,  /* the metadata Get Capabilities response
    147                                  for company id */
    148     bta_av_meta_caps_evt_ids, /* the the metadata Get Capabilities
    149                                  response for event id */
    150     NULL,                     /* the action function table for audio stream */
    151     BTA_AV_RC_CT_NAME,        /* Default AVRCP controller name */
    152     BTA_AV_RC_TG_NAME         /* Default AVRCP target name */
    153 };
    154 
    155 /* This configuration to be used when we are Sink + CT + TG( only for abs vol)
    156  */
    157 const tBTA_AV_CFG bta_avk_cfg = {
    158     AVRC_CO_METADATA,      /* AVRCP Company ID */
    159     512,                   /* AVRCP MTU at L2CAP for control channel */
    160     BTA_AV_MAX_RC_BR_MTU,  /* AVRCP MTU at L2CAP for browsing channel */
    161     BTA_AVK_RC_SUPF_CT,    /* AVRCP controller categories */
    162     BTA_AVK_RC_SUPF_TG,    /* AVRCP target categories */
    163     672,                   /* AVDTP signaling channel MTU at L2CAP */
    164     BTA_AV_MAX_A2DP_MTU,   /* AVDTP audio transport channel MTU at L2CAP */
    165     bta_av_audio_flush_to, /* AVDTP audio transport channel flush timeout */
    166     6,                     /* AVDTP audio channel max data queue size */
    167     false, /* true, to accept AVRC 1.3 group nevigation command */
    168     2,     /* company id count in p_meta_co_ids */
    169     BTA_AVK_NUM_RC_EVT_IDS,    /* event id count in p_meta_evt_ids */
    170     BTA_AV_RC_PASS_RSP_CODE,   /* the default response code for pass
    171                                   through commands */
    172     bta_av_meta_caps_co_ids,   /* the metadata Get Capabilities response
    173                                   for company id */
    174     bta_avk_meta_caps_evt_ids, /* the the metadata Get Capabilities
    175                                   response for event id */
    176     NULL,                      /* the action function table for audio stream */
    177     {0},                       /* Default AVRCP controller name */
    178     {0},                       /* Default AVRCP target name */
    179 };
    180 
    181 /* This configuration to be used when we are using AVRCP1.3 */
    182 const tBTA_AV_CFG bta_av_cfg_compatibility = {
    183     BTA_AV_RC_COMP_ID,     /* AVRCP Company ID */
    184     512,                   /* AVRCP MTU at L2CAP for control channel */
    185     BTA_AV_MAX_RC_BR_MTU,  /* AVRCP MTU at L2CAP for browsing channel */
    186     BTA_AV_RC_SUPF_CT,     /* AVRCP controller categories */
    187     AVRC_SUPF_TG_CAT1,     /* Only support CAT1 for AVRCP1.3 */
    188     672,                   /* AVDTP signaling channel MTU at L2CAP */
    189     BTA_AV_MAX_A2DP_MTU,   /* AVDTP audio transport channel MTU at L2CAP */
    190     bta_av_audio_flush_to, /* AVDTP audio transport channel flush timeout */
    191     6,                     /* AVDTP audio channel max data queue size */
    192     false, /* true, to accept AVRC 1.3 group nevigation command */
    193     2,     /* company id count in p_meta_co_ids */
    194     BTA_AV_NUM_RC_EVT_IDS_AVRCP13,    /* event id count for AVRCP1.3 */
    195     BTA_AV_RC_PASS_RSP_CODE,          /* the default response code for pass
    196                                          through commands */
    197     bta_av_meta_caps_co_ids,          /* the metadata Get Capabilities response
    198                                          for company id */
    199     bta_av_meta_caps_evt_ids_avrcp13, /* the the metadata Get Capabilities
    200                                          response for event id, compatible
    201                                          with AVRCP1.3 */
    202     NULL,              /* the action function table for audio stream */
    203     BTA_AV_RC_CT_NAME, /* Default AVRCP controller name */
    204     BTA_AV_RC_TG_NAME  /* Default AVRCP target name */
    205 };
    206 
    207 const tBTA_AV_CFG* p_bta_av_cfg = NULL;
    208 
    209 const uint16_t bta_av_rc_id[] = {
    210     0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
    211                          4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
    212                          8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,
    213                          12=FAV_MENU, 13=EXIT */
    214 
    215     0, /* not used */
    216 
    217     0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
    218                          4=4, 5=5, 6=6, 7=7,
    219                          8=8, 9=9, 10=DOT, 11=ENTER,
    220                          12=CLEAR */
    221 
    222     0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 3=SOUND_SEL,
    223                          4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 7=PAGE_UP,
    224                          8=PAGE_DOWN */
    225 
    226 /* btui_app provides an example of how to leave the decision of rejecting a
    227  command or not
    228  * based on which media player is currently addressed (this is only applicable
    229  for AVRCP 1.4 or later)
    230  * If the decision is per player for a particular rc_id, the related bit is
    231  clear (not set)
    232  * bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE, 4=PLAY, 5=STOP,
    233              6=PAUSE, 7=RECORD, 8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
    234              12=BACKWARD */
    235 #if (BTA_AV_RC_PASS_RSP_CODE == AVRC_RSP_INTERIM)
    236     0x0070, /* PLAY | STOP | PAUSE */
    237 #else       /* BTA_AV_RC_PASS_RSP_CODE != AVRC_RSP_INTERIM */
    238     0x1b7E, /* PLAY | STOP | PAUSE | FF | RW | VOL_UP | VOL_DOWN | MUTE | FW |
    239                BACK */
    240 #endif /* BTA_AV_RC_PASS_RSP_CODE */
    241 
    242     0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
    243 
    244     0, /* not used */
    245 
    246     0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
    247                         4=F4, 5=F5 */
    248 };
    249 
    250 #if (BTA_AV_RC_PASS_RSP_CODE == AVRC_RSP_INTERIM)
    251 const uint16_t bta_av_rc_id_ac[] = {
    252     0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
    253                          4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN,
    254                7=LEFT_UP,
    255                          8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU,
    256                11=CONT_MENU,
    257                          12=FAV_MENU, 13=EXIT */
    258 
    259     0, /* not used */
    260 
    261     0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
    262                          4=4, 5=5, 6=6, 7=7,
    263                          8=8, 9=9, 10=DOT, 11=ENTER,
    264                          12=CLEAR */
    265 
    266     0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN,
    267                3=SOUND_SEL,
    268                          4=INPUT_SEL, 5=DISP_INFO, 6=HELP,
    269                7=PAGE_UP,
    270                          8=PAGE_DOWN */
    271 
    272     /* btui_app provides an example of how to leave the decision of
    273      * rejecting a command or not
    274      * based on which media player is currently addressed (this is
    275      * only applicable for AVRCP 1.4 or later)
    276      * If the decision is per player for a particular rc_id, the
    277      * related bit is set */
    278     0x1800, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
    279                          4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
    280                          8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
    281                          12=BACKWARD */
    282 
    283     0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
    284 
    285     0, /* not used */
    286 
    287     0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
    288                         4=F4, 5=F5 */
    289 };
    290 uint16_t* p_bta_av_rc_id_ac = (uint16_t*)bta_av_rc_id_ac;
    291 #else
    292 uint16_t* p_bta_av_rc_id_ac = NULL;
    293 #endif
    294 
    295 uint16_t* p_bta_av_rc_id = (uint16_t*)bta_av_rc_id;
    296