• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-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  *  Filename:      bt_hci_bdroid.h
22  *
23  *  Description:   A wrapper header file of bt_hci_lib.h
24  *
25  *                 Contains definitions specific for interfacing with Bluedroid
26  *                 Bluetooth stack
27  *
28  ******************************************************************************/
29 
30 #ifndef BT_HCI_BDROID_H
31 #define BT_HCI_BDROID_H
32 
33 #include "bt_hci_lib.h"
34 
35 /******************************************************************************
36 **  Constants & Macros
37 ******************************************************************************/
38 
39 #ifndef FALSE
40 #define FALSE  0
41 #endif
42 
43 #ifndef TRUE
44 #define TRUE   (!FALSE)
45 #endif
46 
47 #ifndef BTHC_LINUX_BASE_POLICY
48 #define BTHC_LINUX_BASE_POLICY SCHED_NORMAL
49 #endif
50 
51 #if (BTHC_LINUX_BASE_POLICY != SCHED_NORMAL)
52 #ifndef BTHC_LINUX_BASE_PRIORITY
53 #define BTHC_LINUX_BASE_PRIORITY 30
54 #endif
55 
56 #ifndef BTHC_USERIAL_READ_THREAD_PRIORITY
57 #define BTHC_USERIAL_READ_THREAD_PRIORITY (BTHC_LINUX_BASE_PRIORITY)
58 #endif
59 
60 #ifndef BTHC_MAIN_THREAD_PRIORITY
61 #define BTHC_MAIN_THREAD_PRIORITY (BTHC_LINUX_BASE_PRIORITY-1)
62 #endif
63 #endif  // (BTHC_LINUX_BASE_POLICY != SCHED_NORMAL)
64 
65 #ifndef BTHC_USERIAL_READ_MEM_SIZE
66 #define BTHC_USERIAL_READ_MEM_SIZE (1024)
67 #endif
68 
69 #ifndef BTSNOOPDISP_INCLUDED
70 #define BTSNOOPDISP_INCLUDED TRUE
71 #endif
72 
73 /* Disable external parser for production */
74 #ifndef BTSNOOP_EXT_PARSER_INCLUDED
75 #define BTSNOOP_EXT_PARSER_INCLUDED FALSE
76 #endif
77 
78 /* Host/Controller lib internal event ID */
79 #define HC_EVENT_PRELOAD               0x0001
80 #define HC_EVENT_POSTLOAD              0x0002
81 #define HC_EVENT_RX                    0x0004
82 #define HC_EVENT_TX                    0x0008
83 #define HC_EVENT_LPM_ENABLE            0x0010
84 #define HC_EVENT_LPM_DISABLE           0x0020
85 #define HC_EVENT_LPM_WAKE_DEVICE       0x0040
86 #define HC_EVENT_LPM_ALLOW_SLEEP       0x0080
87 #define HC_EVENT_LPM_IDLE_TIMEOUT      0x0100
88 #define HC_EVENT_EXIT                  0x0200
89 #define HC_EVENT_EPILOG                0x0400
90 
91 /* Message event mask across Host/Controller lib and stack */
92 #define MSG_EVT_MASK                    0xFF00 /* eq. BT_EVT_MASK */
93 #define MSG_SUB_EVT_MASK                0x00FF /* eq. BT_SUB_EVT_MASK */
94 
95 /* Message event ID passed from Host/Controller lib to stack */
96 #define MSG_HC_TO_STACK_HCI_ERR        0x1300 /* eq. BT_EVT_TO_BTU_HCIT_ERR */
97 #define MSG_HC_TO_STACK_HCI_ACL        0x1100 /* eq. BT_EVT_TO_BTU_HCI_ACL */
98 #define MSG_HC_TO_STACK_HCI_SCO        0x1200 /* eq. BT_EVT_TO_BTU_HCI_SCO */
99 #define MSG_HC_TO_STACK_HCI_EVT        0x1000 /* eq. BT_EVT_TO_BTU_HCI_EVT */
100 #define MSG_HC_TO_STACK_L2C_SEG_XMIT   0x1900 /* eq. BT_EVT_TO_BTU_L2C_SEG_XMIT */
101 
102 /* Message event ID passed from stack to vendor lib */
103 #define MSG_STACK_TO_HC_HCI_ACL        0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */
104 #define MSG_STACK_TO_HC_HCI_SCO        0x2200 /* eq. BT_EVT_TO_LM_HCI_SCO */
105 #define MSG_STACK_TO_HC_HCI_CMD        0x2000 /* eq. BT_EVT_TO_LM_HCI_CMD */
106 
107 /* Local Bluetooth Controller ID for BR/EDR */
108 #define LOCAL_BR_EDR_CONTROLLER_ID      0
109 
110 /******************************************************************************
111 **  Type definitions and return values
112 ******************************************************************************/
113 
114 typedef struct
115 {
116     uint16_t          event;
117     uint16_t          len;
118     uint16_t          offset;
119     uint16_t          layer_specific;
120 } HC_BT_HDR;
121 
122 #define BT_HC_HDR_SIZE (sizeof(HC_BT_HDR))
123 
124 
125 typedef struct _hc_buffer_hdr
126 {
127     struct _hc_buffer_hdr *p_next;   /* next buffer in the queue */
128     uint8_t   reserved1;
129     uint8_t   reserved2;
130     uint8_t   reserved3;
131     uint8_t   reserved4;
132 } HC_BUFFER_HDR_T;
133 
134 #define BT_HC_BUFFER_HDR_SIZE (sizeof(HC_BUFFER_HDR_T))
135 
136 /******************************************************************************
137 **  Extern variables and functions
138 ******************************************************************************/
139 
140 extern bt_hc_callbacks_t *bt_hc_cbacks;
141 
142 /******************************************************************************
143 **  Functions
144 ******************************************************************************/
145 
146 /*******************************************************************************
147 **
148 ** Function        bthc_signal_event
149 **
150 ** Description     Perform context switch to bt_hc main thread
151 **
152 ** Returns         None
153 **
154 *******************************************************************************/
155 extern void bthc_signal_event(uint16_t event);
156 
157 #endif /* BT_HCI_BDROID_H */
158