1 /****************************************************************************** 2 * 3 * Copyright (C) 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 BTA_AV_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 #if (AVRC_METADATA_INCLUDED == TRUE) 78 #define BTA_AV_RC_SUPF_TG \ 79 (AVRC_SUPF_TG_CAT1 | AVRC_SUPF_TG_MULTI_PLAYER | \ 80 AVRC_SUPF_TG_BROWSE) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */ 81 #else 82 #define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1) 83 #endif 84 #endif 85 86 /* 87 * If the number of event IDs is changed in this array, BTA_AV_ NUM_RC_EVT_IDS 88 * also needs to be changed. 89 */ 90 const uint8_t bta_av_meta_caps_evt_ids[] = { 91 AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE, 92 AVRC_EVT_PLAY_POS_CHANGED, AVRC_EVT_AVAL_PLAYERS_CHANGE, 93 AVRC_EVT_ADDR_PLAYER_CHANGE, AVRC_EVT_UIDS_CHANGE, 94 AVRC_EVT_NOW_PLAYING_CHANGE, 95 /* TODO: Add support for these events 96 AVRC_EVT_APP_SETTING_CHANGE, 97 */ 98 }; 99 #ifndef BTA_AV_NUM_RC_EVT_IDS 100 #define BTA_AV_NUM_RC_EVT_IDS \ 101 (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0])) 102 #endif /* BTA_AV_NUM_RC_EVT_IDS */ 103 104 const uint8_t bta_avk_meta_caps_evt_ids[] = { 105 #if (AVRC_ADV_CTRL_INCLUDED == TRUE) 106 AVRC_EVT_VOLUME_CHANGE, 107 #endif 108 }; 109 #ifndef BTA_AVK_NUM_RC_EVT_IDS 110 #define BTA_AVK_NUM_RC_EVT_IDS \ 111 (sizeof(bta_avk_meta_caps_evt_ids) / sizeof(bta_avk_meta_caps_evt_ids[0])) 112 #endif /* BTA_AVK_NUM_RC_EVT_IDS */ 113 114 // These are the only events used with AVRCP1.3 115 const uint8_t bta_av_meta_caps_evt_ids_avrcp13[] = { 116 AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE, 117 AVRC_EVT_PLAY_POS_CHANGED, 118 }; 119 120 #ifndef BTA_AV_NUM_RC_EVT_IDS_AVRCP13 121 #define BTA_AV_NUM_RC_EVT_IDS_AVRCP13 \ 122 (sizeof(bta_av_meta_caps_evt_ids_avrcp13) / \ 123 sizeof(bta_av_meta_caps_evt_ids_avrcp13[0])) 124 #endif /* BTA_AVK_NUM_RC_EVT_IDS_AVRCP13 */ 125 126 /* the MTU for the AVRCP browsing channel */ 127 #ifndef BTA_AV_MAX_RC_BR_MTU 128 #define BTA_AV_MAX_RC_BR_MTU 1008 129 #endif 130 131 /* This configuration to be used when we are Src + TG + CT( only for abs vol) */ 132 const tBTA_AV_CFG bta_av_cfg = { 133 BTA_AV_RC_COMP_ID, /* AVRCP Company ID */ 134 #if (AVRC_METADATA_INCLUDED == TRUE) 135 512, /* AVRCP MTU at L2CAP for control channel */ 136 BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */ 137 #else 138 48, /* AVRCP MTU at L2CAP for control channel */ 139 BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */ 140 #endif 141 BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */ 142 BTA_AV_RC_SUPF_TG, /* AVRCP target categories */ 143 672, /* AVDTP signaling channel MTU at L2CAP */ 144 BTA_AV_MAX_A2DP_MTU, /* AVDTP audio transport channel MTU at L2CAP 145 */ 146 bta_av_audio_flush_to, /* AVDTP audio transport channel flush 147 timeout */ 148 6, /* AVDTP audio channel max data queue size */ 149 BTA_AV_MAX_VDP_MTU, /* AVDTP video transport channel MTU at L2CAP */ 150 600, /* AVDTP video transport channel flush timeout */ 151 false, /* true, to accept AVRC 1.3 group nevigation command */ 152 2, /* company id count in p_meta_co_ids */ 153 BTA_AV_NUM_RC_EVT_IDS, /* event id count in p_meta_evt_ids */ 154 BTA_AV_RC_PASS_RSP_CODE, /* the default response code for pass 155 through commands */ 156 bta_av_meta_caps_co_ids, /* the metadata Get Capabilities response 157 for company id */ 158 bta_av_meta_caps_evt_ids, /* the the metadata Get Capabilities 159 response for event id */ 160 NULL, /* the action function table for VDP stream */ 161 NULL, /* action function to register VDP */ 162 BTA_AV_RC_CT_NAME, /* Default AVRCP controller name */ 163 BTA_AV_RC_TG_NAME /* Default AVRCP target name */ 164 }; 165 166 /* This configuration to be used when we are Sink + CT + TG( only for abs vol) 167 */ 168 const tBTA_AV_CFG bta_avk_cfg = { 169 AVRC_CO_METADATA, /* AVRCP Company ID */ 170 #if (AVRC_METADATA_INCLUDED == TRUE) 171 512, /* AVRCP MTU at L2CAP for control channel */ 172 #else 173 48, /* AVRCP MTU at L2CAP for control channel */ 174 #endif 175 BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */ 176 BTA_AVK_RC_SUPF_CT, /* AVRCP controller categories */ 177 BTA_AVK_RC_SUPF_TG, /* AVRCP target categories */ 178 672, /* AVDTP signaling channel MTU at L2CAP */ 179 BTA_AV_MAX_A2DP_MTU, /* AVDTP audio transport channel MTU at L2CAP 180 */ 181 bta_av_audio_flush_to, /* AVDTP audio transport channel flush 182 timeout */ 183 6, /* AVDTP audio channel max data queue size */ 184 BTA_AV_MAX_VDP_MTU, /* AVDTP video transport channel MTU at L2CAP */ 185 600, /* AVDTP video transport channel flush timeout */ 186 false, /* true, to accept AVRC 1.3 group nevigation command */ 187 2, /* company id count in p_meta_co_ids */ 188 BTA_AVK_NUM_RC_EVT_IDS, /* event id count in p_meta_evt_ids */ 189 BTA_AV_RC_PASS_RSP_CODE, /* the default response code for pass 190 through commands */ 191 bta_av_meta_caps_co_ids, /* the metadata Get Capabilities response 192 for company id */ 193 bta_avk_meta_caps_evt_ids, /* the the metadata Get Capabilities 194 response for event id */ 195 NULL, /* the action function table for VDP stream */ 196 NULL, /* action function to register VDP */ 197 {0}, /* Default AVRCP controller name */ 198 {0}, /* Default AVRCP target name */ 199 }; 200 201 /* This configuration to be used when we are using AVRCP1.3 */ 202 const tBTA_AV_CFG bta_av_cfg_compatibility = { 203 BTA_AV_RC_COMP_ID, /* AVRCP Company ID */ 204 #if (AVRC_METADATA_INCLUDED == TRUE) 205 512, /* AVRCP MTU at L2CAP for control channel */ 206 BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */ 207 #else 208 48, /* AVRCP MTU at L2CAP for control channel */ 209 BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */ 210 #endif 211 BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */ 212 AVRC_SUPF_TG_CAT1, /* Only support CAT1 for AVRCP1.3 */ 213 672, /* AVDTP signaling channel MTU at L2CAP */ 214 BTA_AV_MAX_A2DP_MTU, /* AVDTP audio transport channel MTU at L2CAP 215 */ 216 bta_av_audio_flush_to, /* AVDTP audio transport channel flush 217 timeout */ 218 6, /* AVDTP audio channel max data queue size */ 219 BTA_AV_MAX_VDP_MTU, /* AVDTP video transport channel MTU at L2CAP */ 220 600, /* AVDTP video transport channel flush timeout */ 221 false, /* true, to accept AVRC 1.3 group nevigation command */ 222 2, /* company id count in p_meta_co_ids */ 223 BTA_AV_NUM_RC_EVT_IDS_AVRCP13, /* event id count for AVRCP1.3*/ 224 BTA_AV_RC_PASS_RSP_CODE, /* the default response code for pass 225 through commands */ 226 bta_av_meta_caps_co_ids, /* the metadata Get Capabilities response 227 for company id */ 228 bta_av_meta_caps_evt_ids_avrcp13, /* the the metadata Get Capabilities 229 response for event id, compatible 230 with AVRCP1.3*/ 231 NULL, /* the action function table for VDP stream */ 232 NULL, /* action function to register VDP */ 233 BTA_AV_RC_CT_NAME, /* Default AVRCP controller name */ 234 BTA_AV_RC_TG_NAME /* Default AVRCP target name */ 235 }; 236 237 tBTA_AV_CFG* p_bta_av_cfg = NULL; 238 239 const uint16_t bta_av_rc_id[] = { 240 0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT, 241 4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP, 242 8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU, 243 12=FAV_MENU, 13=EXIT */ 244 245 0, /* not used */ 246 247 0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3, 248 4=4, 5=5, 6=6, 7=7, 249 8=8, 9=9, 10=DOT, 11=ENTER, 250 12=CLEAR */ 251 252 0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 3=SOUND_SEL, 253 4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 7=PAGE_UP, 254 8=PAGE_DOWN */ 255 256 /* btui_app provides an example of how to leave the decision of rejecting a 257 command or not 258 * based on which media player is currently addressed (this is only applicable 259 for AVRCP 1.4 or later) 260 * If the decision is per player for a particular rc_id, the related bit is 261 clear (not set) 262 * bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE, 4=PLAY, 5=STOP, 263 6=PAUSE, 7=RECORD, 8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD, 264 12=BACKWARD */ 265 #if (BTA_AV_RC_PASS_RSP_CODE == BTA_AV_RSP_INTERIM) 266 0x0070, /* PLAY | STOP | PAUSE */ 267 #else /* BTA_AV_RC_PASS_RSP_CODE != BTA_AV_RSP_INTERIM */ 268 #if (BTA_AVRCP_FF_RW_SUPPORT == TRUE) 269 0x1b7E, /* PLAY | STOP | PAUSE | FF | RW | VOL_UP | VOL_DOWN | MUTE | FW | 270 BACK */ 271 #else /* BTA_AVRCP_FF_RW_SUPPORT == FALSE */ 272 0x187E, /* PLAY | STOP | PAUSE | VOL_UP | VOL_DOWN | MUTE | FW | BACK */ 273 #endif /* BTA_AVRCP_FF_RW_SUPPORT */ 274 #endif /* BTA_AV_RC_PASS_RSP_CODE */ 275 276 0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */ 277 278 0, /* not used */ 279 280 0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3, 281 4=F4, 5=F5 */ 282 }; 283 284 #if (BTA_AV_RC_PASS_RSP_CODE == BTA_AV_RSP_INTERIM) 285 const uint16_t bta_av_rc_id_ac[] = { 286 0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT, 287 4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 288 7=LEFT_UP, 289 8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 290 11=CONT_MENU, 291 12=FAV_MENU, 13=EXIT */ 292 293 0, /* not used */ 294 295 0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3, 296 4=4, 5=5, 6=6, 7=7, 297 8=8, 9=9, 10=DOT, 11=ENTER, 298 12=CLEAR */ 299 300 0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 301 3=SOUND_SEL, 302 4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 303 7=PAGE_UP, 304 8=PAGE_DOWN */ 305 306 /* btui_app provides an example of how to leave the decision of 307 * rejecting a command or not 308 * based on which media player is currently addressed (this is 309 * only applicable for AVRCP 1.4 or later) 310 * If the decision is per player for a particular rc_id, the 311 * related bit is set */ 312 0x1800, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE, 313 4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD, 314 8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD, 315 12=BACKWARD */ 316 317 0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */ 318 319 0, /* not used */ 320 321 0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3, 322 4=F4, 5=F5 */ 323 }; 324 uint16_t* p_bta_av_rc_id_ac = (uint16_t*)bta_av_rc_id_ac; 325 #else 326 uint16_t* p_bta_av_rc_id_ac = NULL; 327 #endif 328 329 uint16_t* p_bta_av_rc_id = (uint16_t*)bta_av_rc_id; 330