NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
bte_appl.h
1/******************************************************************************
2 *
3 * NOTICE OF CHANGES
4 * 2024/03/25:
5 * - Remove linux functionality for RVL target
6 *
7 * Compile with REVOLUTION defined to include these changes.
8 *
9 ******************************************************************************/
10
11
12
13/******************************************************************************
14 *
15 * Copyright (C) 2002-2012 Broadcom Corporation
16 *
17 * Licensed under the Apache License, Version 2.0 (the "License");
18 * you may not use this file except in compliance with the License.
19 * You may obtain a copy of the License at:
20 *
21 * http://www.apache.org/licenses/LICENSE-2.0
22 *
23 * Unless required by applicable law or agreed to in writing, software
24 * distributed under the License is distributed on an "AS IS" BASIS,
25 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 * See the License for the specific language governing permissions and
27 * limitations under the License.
28 *
29 ******************************************************************************/
30
31/******************************************************************************
32 *
33 * This is the interface file for the bte application task
34 *
35 ******************************************************************************/
36
37#ifndef BTE_APPL_H
38#define BTE_APPL_H
39
40#include "btm_int.h"
41#include "bta_api.h"
42#include "bta_sys.h"
43#include "bte.h"
44
45/* Maximum length for serial port device name */
46#ifndef BTE_APPL_MAX_USERIAL_DEV_NAME
47#define BTE_APPL_MAX_USERIAL_DEV_NAME (256)
48#endif
49#ifndef BTAPP_AHF_API_SUPPORT
50#define BTAPP_AHF_API_SUPPORT FALSE
51#endif
52
53/* BTA APP_IDs */
54#define UI_DM_ID 1
55#define UI_PRM_ID 20
56/* this defines the enabled BTA modules. client may not be defined as those are enabled at run time.
57 * they are defined for completeness. please check with bta_sys.h for new modules.
58 * BTA_ID_DM serves as flag for BTA_EnableBluetooth()
59 * BTA_ID_RES can be used to fs ID in bte_appl.
60 */
61
62#define BTAPP_NUM_ID_BLOCKS ((BTA_ID_MAX/32)+1) /* number of 32 bit required to store one bit per
63 btapp id */
64
65#define BTAPP_APPL_MAIL_EVENT(x) (x<<8) /* define bte_appl task mail box event. LSB contains
66 BTA_ID_xxx (see bta_sys.h) */
67#define BTAPP_APPL_MAIL_EVT 0xff00 /* high byte contains bitmap of application module event */
68
69/* helper macro to copy BTA callack data y into message buffer x, for event data structure z */
70#define MEMCPY_APPL_MSG(x, y, z) memcpy( (void *)(((UINT8 *)x)+sizeof(BT_HDR)), (void *)y, sizeof(z) )
71
72/* Event masks for BTE_APPL_TASK */
73#define BTE_APPL_STARTUP_EVT EVENT_MASK(APPL_EVT_0) /* Bluetooth has started */
74#define BTE_APPL_SHUTDOWN_EVT EVENT_MASK(APPL_EVT_1) /* Bluetooth is shutting down */
75#define BTE_APPL_SOCKET_RX_EVT EVENT_MASK(APPL_EVT_2) /* Socket data ready to be read */
76#define BTE_APPL_DBUS_RX_EVT EVENT_MASK(APPL_EVT_3) /* DBUS message ready to be read */
77#define BTE_APPL_BTA_ENABLE_EVT EVENT_MASK(APPL_EVT_4) /* BTA Enabled event */
78
79
80/* Application configuration */
81#define BTE_APPL_PATCHRAM_PATH_MAXLEN 128
82#define BTE_APPL_CONTACTS_DB_PATH 256
83
84typedef struct {
85 char patchram_path[BTE_APPL_PATCHRAM_PATH_MAXLEN+1];
86 UINT32 patchram_addr;
87 UINT32 reconfig_baud;
88 UINT32 clock_rate; /* clock rate (for uart baud calculation) */
89 BD_ADDR local_addr; /* local bd addr */
90 BD_ADDR rem_addr;
91 UINT8 lpm_enabled;
92 UINT8 bt_wake_polarity;
93 UINT8 host_wake_polarity;
94 BOOLEAN ag_enable_3way_conf;
95 UINT16 ag_voice_settings;
96 UINT8 ag_vsc_pcm_config[5];
97 UINT8 ag_vsc_sco_pcm[5];
98 /*tBTM_CMPL_CB*/ tBTM_DEV_STATUS_CB *p_reset_cplt_cb; /* Current reset_cplt_cb */
99 char contacts_db[BTE_APPL_CONTACTS_DB_PATH+1];
100 UINT32 bta_module_state[BTAPP_NUM_ID_BLOCKS]; /* state of enabled bta modules */
101#if (BTAPP_AHF_API_SUPPORT==TRUE)
102 UINT8 afh_first;
103 UINT8 afh_last;
104#endif
106
107extern tBTE_APPL_CFG bte_appl_cfg;
109#ifndef REVOLUTION
110typedef struct {
111 pthread_mutex_t mutex; /* mutex to protect below signal condition */
112 pthread_cond_t cond; /* signal event */
114
115/* helper functions to handle pthread conditions event from outside GKI */
116extern void bte_create_semaphore( tBTAPP_SEMAPHORE * p_sema );
117extern void bte_wait_semaphore( tBTAPP_SEMAPHORE * p_sema, unsigned msecs_to );
118extern void bte_signal_semaphore( tBTAPP_SEMAPHORE * p_sema );
119extern void bte_destroy_semaphore( tBTAPP_SEMAPHORE * p_sema );
121/* global application control block storing global application states and variables */
122typedef struct tBTE_APPL_CB_tag {
123 sigset_t signal_handler_set; /* signal handler set used by signal handler thread */
124#if ( TRUE == BTE_RESET_BAUD_ON_BT_DISABLE )
125 tBTAPP_SEMAPHORE shutdown_semaphore; /* used to sync with terminate handler initated ops */
126#endif
127 BOOLEAN amp_enabled; /* TRUE if AMP is in use */
128} tBTE_APPL_CB;
129
130extern tBTE_APPL_CB bte_appl_cb;
131#endif
132
133/* Exports the application task */
134extern void BTE_appl_task(UINT32 params);
135extern int BTAPP_enable_bta( const UINT32 bta_module_state[BTAPP_NUM_ID_BLOCKS], int includingFM );
136extern int BTAPP_disable_bta( const UINT32 bta_module_state[BTAPP_NUM_ID_BLOCKS], int includingFM );
137
138extern UINT8 appl_trace_level;
139#define BT_PCM_CLK_IDX 1
140#ifndef BT_PCM_DEF_CLK
141#define BT_PCM_DEF_CLK 4 /* defaults to 2048khz PCM clk */
142#endif
143#define BT_PCM_SYNC_MS_ROLE_IDX 3
144#define BT_PCM_CLK_MS_ROLE_IDX 4
145#ifndef BT_PCM_DEF_ROLE
146#define BT_PCM_DEF_ROLE 0x00 /* assume slave as default */
147#endif
148
149/* helper macros to set, clear and get current BTA module id in a 32bit ARRAY!! */
150/* set bit id to 1 in UINT32 a[] NO RANGE CHECK!*/
151#define BTAPP_SET_BTA_MOD(id, a) { a[id/32] |= (UINT32)(1<<(id % 32)); }
152
153/* set bit id to 0 (cleared) in UINT32 a[] NO RANGE CHECK */
154#define BTAPP_CLEAR_BTA_MOD(id, a) { a[id/32] &= (UINT32)!(1<<(id % 32)); }
155
156/* tests if bit id is 1 in UINT32 a[] NO RANGE CHECK */
157#define BTAPP_BTA_MOD_IS_SET(id, a) (a[id/32] & (UINT32)(1<<(id % 32)))
158
159/* update this list either via btld.txt or directly here by adding the new profiles as per bta_sys.h.
160 * each xxx_LISTx may only contain 32 bits */
161#ifndef BTAPP_BTA_MODULES_LIST0
162#define BTAPP_BTA_MODULES_LIST0 (\
163 ( 1<<BTA_ID_DM ) | \
164 ( 1<<BTA_ID_DG ) | \
165 ( 1<<BTA_ID_AG ) | \
166 ( 1<<BTA_ID_OPC )| \
167 ( 1<<BTA_ID_OPS )| \
168 ( 1<<BTA_ID_FTS )| \
169 ( 1<<BTA_ID_PAN )| \
170 ( 1<<BTA_ID_PR ) | \
171 ( 1<<BTA_ID_SC) | \
172 ( 1<<BTA_ID_AV ) | \
173 ( 1<<BTA_ID_HH ) | \
174 ( 1<<BTA_ID_PBS) | \
175 ( 1<<BTA_ID_FMTX)| \
176 ( 1<<BTA_ID_JV) | \
177 ( 1<<BTA_ID_MSE) \
178 )
179#endif
180
181#define BTAPP_LIST1_BLOCK 32 /* next 32 bit block */
182#ifndef BTAPP_BTA_MODULES_LIST1
183#define BTAPP_BTA_MODULES_LIST1 (\
184 ( 1<<(BTA_ID_MAX-BTAPP_LIST1_BLOCK) ) | \
185 ( 1<<(BTA_ID_MSE-BTAPP_LIST1_BLOCK) ) | \
186 0 \
187 )
188#endif
189/* for future GPS etc support. goes int LIST1 above */
190#if 0
191 ( 1<<(BTA_ID_SSR-BTAPP_LIST1_BLOCK) ) \
192 ( 1<<(BTA_ID_MSE-BTAPP_LIST1_BLOCK) ) \
193 ( 1<<(BTA_ID_MCE-BTAPP_LIST1_BLOCK) )
194#endif
195
196/* used application init default in bte_main.c, bte_appl_cfg */
197#ifndef BTAPP_DEFAULT_MODULES
198#if (1==BTAPP_NUM_ID_BLOCKS)
199#define BTAPP_DEFAULT_MODULES {BTAPP_BTA_MODULES_LIST0} /* max 32 modules IDs */
200#elif (2==BTAPP_NUM_ID_BLOCKS)
201#define BTAPP_DEFAULT_MODULES {BTAPP_BTA_MODULES_LIST0, BTAPP_BTA_MODULES_LIST1} /* 64 module IDs max */
202#else
203#error "Define more BTAPP_BTA_MODULES_LISTx"
204#endif
205#endif
206
207#endif /* BTE_APPL_H */