1 /******************************************************************************
2  *
3  *  Copyright (C) 2005-2012 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_target.h"
29 #include "bt_common.h"
30 #include "bta_api.h"
31 #include "bta_av_int.h"
32 
33 #ifndef BTA_AV_RC_PASS_RSP_CODE
34 #define BTA_AV_RC_PASS_RSP_CODE     BTA_AV_RSP_NOT_IMPL
35 #endif
36 
37 const UINT32  bta_av_meta_caps_co_ids[] = {
38     AVRC_CO_METADATA,
39     AVRC_CO_BROADCOM
40 };
41 
42 /* AVRCP cupported categories */
43 #if (AVRC_CTLR_INCLUDED == TRUE)
44 #define BTA_AV_RC_SUPF_CT       (AVRC_SUPF_CT_CAT2)
45 #endif
46 
47 #if (AVRC_CTLR_INCLUDED == TRUE)
48 #define BTA_AVK_RC_SUPF_CT       (AVRC_SUPF_CT_CAT1)
49 #define BTA_AVK_RC_SUPF_TG       (AVRC_SUPF_TG_CAT2)
50 #endif
51 
52 /* Added to modify
53 **	1. flush timeout
54 **	2. Remove Group navigation support in SupportedFeatures
55 **	3. GetCapabilities supported event_ids list
56 **	4. GetCapabilities supported event_ids count
57 */
58 /* Flushing partial avdtp packets can cause some headsets to disconnect the link
59    if receiving partial a2dp frames */
60 const UINT16  bta_av_audio_flush_to[] = {
61      0, /* 1 stream */
62      0, /* 2 streams */
63      0, /* 3 streams */
64      0, /* 4 streams */
65      0  /* 5 streams */
66 };     /* AVDTP audio transport channel flush timeout */
67 
68 /* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI  */
69 /* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be TRUE */
70 #if AVRC_METADATA_INCLUDED == TRUE
71 #define BTA_AV_RC_SUPF_TG       (AVRC_SUPF_TG_CAT1) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
72 #else
73 #define BTA_AV_RC_SUPF_TG       (AVRC_SUPF_TG_CAT1)
74 #endif
75 
76 /*
77  * If the number of event IDs is changed in this array, BTA_AV_ NUM_RC_EVT_IDS   also needs to be changed.
78  */
79 const UINT8  bta_av_meta_caps_evt_ids[] = {
80     AVRC_EVT_PLAY_STATUS_CHANGE,
81     AVRC_EVT_TRACK_CHANGE,
82     AVRC_EVT_PLAY_POS_CHANGED,
83     /* TODO: Add support for these events
84     AVRC_EVT_APP_SETTING_CHANGE,
85     */
86 };
87 #ifndef BTA_AV_NUM_RC_EVT_IDS
88 #define BTA_AV_NUM_RC_EVT_IDS   (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0]))
89 #endif /* BTA_AV_NUM_RC_EVT_IDS */
90 
91 const UINT8  bta_avk_meta_caps_evt_ids[] = {
92 #if AVRC_ADV_CTRL_INCLUDED == TRUE
93     AVRC_EVT_VOLUME_CHANGE,
94 #endif
95 };
96 #ifndef BTA_AVK_NUM_RC_EVT_IDS
97 #define BTA_AVK_NUM_RC_EVT_IDS   (sizeof(bta_avk_meta_caps_evt_ids) / sizeof(bta_avk_meta_caps_evt_ids[0]))
98 #endif /* BTA_AVK_NUM_RC_EVT_IDS */
99 
100 
101 /* the MTU for the AVRCP browsing channel */
102 #ifndef BTA_AV_MAX_RC_BR_MTU
103 #define BTA_AV_MAX_RC_BR_MTU      1008
104 #endif
105 
106 /* This configuration to be used when we are Src + TG + CT( only for abs vol) */
107 const tBTA_AV_CFG bta_av_cfg =
108 {
109     AVRC_CO_BROADCOM,       /* AVRCP Company ID */
110 #if AVRC_METADATA_INCLUDED == TRUE
111     512,                    /* AVRCP MTU at L2CAP for control channel */
112 #else
113     48,                     /* AVRCP MTU at L2CAP for control channel */
114 #endif
115     BTA_AV_MAX_RC_BR_MTU,   /* AVRCP MTU at L2CAP for browsing channel */
116     BTA_AV_RC_SUPF_CT,      /* AVRCP controller categories */
117     BTA_AV_RC_SUPF_TG,      /* AVRCP target categories */
118     672,                    /* AVDTP signaling channel MTU at L2CAP */
119     BTA_AV_MAX_A2DP_MTU,    /* AVDTP audio transport channel MTU at L2CAP */
120     bta_av_audio_flush_to,  /* AVDTP audio transport channel flush timeout */
121     6,                      /* AVDTP audio channel max data queue size */
122     BTA_AV_MAX_VDP_MTU,     /* AVDTP video transport channel MTU at L2CAP */
123     600,                    /* AVDTP video transport channel flush timeout */
124     FALSE,                   /* TRUE, to accept AVRC 1.3 group nevigation command */
125     2,                      /* company id count in p_meta_co_ids */
126     BTA_AV_NUM_RC_EVT_IDS, /* event id count in p_meta_evt_ids */
127     BTA_AV_RC_PASS_RSP_CODE,/* the default response code for pass through commands */
128     bta_av_meta_caps_co_ids,/* the metadata Get Capabilities response for company id */
129     bta_av_meta_caps_evt_ids,/* the the metadata Get Capabilities response for event id */
130     NULL,                   /* the action function table for VDP stream */
131     NULL,                   /* action function to register VDP */
132     {0},                    /* Default AVRCP controller name */
133     {0},                    /* Default AVRCP target name */
134 };
135 
136 /* This configuration to be used when we are Sink + CT + TG( only for abs vol) */
137 const tBTA_AV_CFG bta_avk_cfg =
138 {
139     AVRC_CO_METADATA,       /* AVRCP Company ID */
140 #if AVRC_METADATA_INCLUDED == TRUE
141     512,                    /* AVRCP MTU at L2CAP for control channel */
142 #else
143     48,                     /* AVRCP MTU at L2CAP for control channel */
144 #endif
145     BTA_AV_MAX_RC_BR_MTU,   /* AVRCP MTU at L2CAP for browsing channel */
146     BTA_AVK_RC_SUPF_CT,      /* AVRCP controller categories */
147     BTA_AVK_RC_SUPF_TG,      /* AVRCP target categories */
148     672,                    /* AVDTP signaling channel MTU at L2CAP */
149     BTA_AV_MAX_A2DP_MTU,    /* AVDTP audio transport channel MTU at L2CAP */
150     bta_av_audio_flush_to,  /* AVDTP audio transport channel flush timeout */
151     6,                      /* AVDTP audio channel max data queue size */
152     BTA_AV_MAX_VDP_MTU,     /* AVDTP video transport channel MTU at L2CAP */
153     600,                    /* AVDTP video transport channel flush timeout */
154     FALSE,                   /* TRUE, to accept AVRC 1.3 group nevigation command */
155     2,                      /* company id count in p_meta_co_ids */
156     BTA_AVK_NUM_RC_EVT_IDS, /* event id count in p_meta_evt_ids */
157     BTA_AV_RC_PASS_RSP_CODE,/* the default response code for pass through commands */
158     bta_av_meta_caps_co_ids,/* the metadata Get Capabilities response for company id */
159     bta_avk_meta_caps_evt_ids,/* the the metadata Get Capabilities response for event id */
160     NULL,                   /* the action function table for VDP stream */
161     NULL,                   /* action function to register VDP */
162     {0},                    /* Default AVRCP controller name */
163     {0},                    /* Default AVRCP target name */
164 };
165 
166 tBTA_AV_CFG *p_bta_av_cfg = NULL;
167 
168 const UINT16 bta_av_rc_id[] =
169 {
170     0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
171                          4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
172                          8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,
173                          12=FAV_MENU, 13=EXIT */
174 
175     0,      /* not used */
176 
177     0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
178                          4=4, 5=5, 6=6, 7=7,
179                          8=8, 9=9, 10=DOT, 11=ENTER,
180                          12=CLEAR */
181 
182     0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 3=SOUND_SEL,
183                          4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 7=PAGE_UP,
184                          8=PAGE_DOWN */
185 
186 #if (BTA_AV_RC_PASS_RSP_CODE == BTA_AV_RSP_INTERIM)
187     /* btui_app provides an example of how to leave the decision of rejecting a command or not
188      * based on which media player is currently addressed (this is only applicable for AVRCP 1.4 or later)
189      * If the decision is per player for a particular rc_id, the related bit is clear (not set) */
190     0x0070, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
191                          4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
192                          8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
193                          12=BACKWARD */
194 #else
195 #if (defined BTA_AVRCP_FF_RW_SUPPORT) && (BTA_AVRCP_FF_RW_SUPPORT == TRUE)
196     0x1b70, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
197                          4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
198                          8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
199                          12=BACKWARD */
200 #else
201     0x1870, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
202                          4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
203                          8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
204                          12=BACKWARD */
205 #endif
206 #endif
207 
208     0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
209 
210     0,      /* not used */
211 
212     0x0000  /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
213                          4=F4, 5=F5 */
214 };
215 
216 #if (BTA_AV_RC_PASS_RSP_CODE == BTA_AV_RSP_INTERIM)
217 const UINT16 bta_av_rc_id_ac[] =
218 {
219     0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
220                          4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
221                          8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,
222                          12=FAV_MENU, 13=EXIT */
223 
224     0,      /* not used */
225 
226     0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
227                          4=4, 5=5, 6=6, 7=7,
228                          8=8, 9=9, 10=DOT, 11=ENTER,
229                          12=CLEAR */
230 
231     0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 3=SOUND_SEL,
232                          4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 7=PAGE_UP,
233                          8=PAGE_DOWN */
234 
235     /* btui_app provides an example of how to leave the decision of rejecting a command or not
236      * based on which media player is currently addressed (this is only applicable for AVRCP 1.4 or later)
237      * If the decision is per player for a particular rc_id, the related bit is set */
238     0x1800, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
239                          4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
240                          8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
241                          12=BACKWARD */
242 
243     0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
244 
245     0,      /* not used */
246 
247     0x0000  /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
248                          4=F4, 5=F5 */
249 };
250 UINT16 *p_bta_av_rc_id_ac = (UINT16 *) bta_av_rc_id_ac;
251 #else
252 UINT16 *p_bta_av_rc_id_ac = NULL;
253 #endif
254 
255 UINT16 *p_bta_av_rc_id = (UINT16 *) bta_av_rc_id;
256