bt_hci_bdroid.h revision 5738f83aeb59361a0a2eda2460113f6dc9194271
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
90/* Message event mask across Host/Controller lib and stack */
91#define MSG_EVT_MASK                    0xFF00 /* eq. BT_EVT_MASK */
92#define MSG_SUB_EVT_MASK                0x00FF /* eq. BT_SUB_EVT_MASK */
93
94/* Message event ID passed from Host/Controller lib to stack */
95#define MSG_HC_TO_STACK_HCI_ERR        0x1300 /* eq. BT_EVT_TO_BTU_HCIT_ERR */
96#define MSG_HC_TO_STACK_HCI_ACL        0x1100 /* eq. BT_EVT_TO_BTU_HCI_ACL */
97#define MSG_HC_TO_STACK_HCI_SCO        0x1200 /* eq. BT_EVT_TO_BTU_HCI_SCO */
98#define MSG_HC_TO_STACK_HCI_EVT        0x1000 /* eq. BT_EVT_TO_BTU_HCI_EVT */
99#define MSG_HC_TO_STACK_L2C_SEG_XMIT   0x1900 /* eq. BT_EVT_TO_BTU_L2C_SEG_XMIT */
100
101/* Message event ID passed from stack to vendor lib */
102#define MSG_STACK_TO_HC_HCI_ACL        0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */
103#define MSG_STACK_TO_HC_HCI_SCO        0x2200 /* eq. BT_EVT_TO_LM_HCI_SCO */
104#define MSG_STACK_TO_HC_HCI_CMD        0x2000 /* eq. BT_EVT_TO_LM_HCI_CMD */
105
106/* Local Bluetooth Controller ID for BR/EDR */
107#define LOCAL_BR_EDR_CONTROLLER_ID      0
108
109/******************************************************************************
110**  Type definitions and return values
111******************************************************************************/
112
113typedef struct
114{
115    uint16_t          event;
116    uint16_t          len;
117    uint16_t          offset;
118    uint16_t          layer_specific;
119} HC_BT_HDR;
120
121#define BT_HC_HDR_SIZE (sizeof(HC_BT_HDR))
122
123
124typedef struct _hc_buffer_hdr
125{
126    struct _hc_buffer_hdr *p_next;   /* next buffer in the queue */
127    uint8_t   reserved1;
128    uint8_t   reserved2;
129    uint8_t   reserved3;
130    uint8_t   reserved4;
131} HC_BUFFER_HDR_T;
132
133#define BT_HC_BUFFER_HDR_SIZE (sizeof(HC_BUFFER_HDR_T))
134
135/******************************************************************************
136**  Extern variables and functions
137******************************************************************************/
138
139extern bt_hc_callbacks_t *bt_hc_cbacks;
140
141/******************************************************************************
142**  Functions
143******************************************************************************/
144
145/*******************************************************************************
146**
147** Function        bthc_signal_event
148**
149** Description     Perform context switch to bt_hc main thread
150**
151** Returns         None
152**
153*******************************************************************************/
154extern void bthc_signal_event(uint16_t event);
155
156#endif /* BT_HCI_BDROID_H */
157