• 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 #pragma once
31 
32 #include "bt_hci_lib.h"
33 
34 #ifdef HAS_BDROID_BUILDCFG
35 #include "bdroid_buildcfg.h"
36 #endif
37 
38 /******************************************************************************
39 **  Constants & Macros
40 ******************************************************************************/
41 
42 #if __STDC_VERSION__ < 199901L
43 #  ifndef FALSE
44 #    define FALSE 0
45 #  endif
46 #  ifndef TRUE
47 #    define TRUE (!FALSE)
48 #  endif
49 #else
50 #  include <stdbool.h>
51 #  ifndef FALSE
52 #    define FALSE  false
53 #  endif
54 #  ifndef TRUE
55 #    define TRUE   true
56 #  endif
57 #endif
58 
59 #define HCI_ACL_MAX_SIZE 1024
60 #define HCI_MAX_FRAME_SIZE (HCI_ACL_MAX_SIZE + 4)
61 
62 /* Host/Controller lib internal event ID */
63 typedef enum {
64   HC_EVENT_LPM_IDLE_TIMEOUT,
65 } bthc_event_t;
66 
67 #define MSG_CTRL_TO_HC_CMD             0x0100 /* evt mask used by HC_EVENT_TX_CMD */
68 
69 /* Message event mask across Host/Controller lib and stack */
70 #define MSG_EVT_MASK                    0xFF00 /* eq. BT_EVT_MASK */
71 #define MSG_SUB_EVT_MASK                0x00FF /* eq. BT_SUB_EVT_MASK */
72 
73 /* Message event ID passed from Host/Controller lib to stack */
74 #define MSG_HC_TO_STACK_HCI_ERR        0x1300 /* eq. BT_EVT_TO_BTU_HCIT_ERR */
75 #define MSG_HC_TO_STACK_HCI_ACL        0x1100 /* eq. BT_EVT_TO_BTU_HCI_ACL */
76 #define MSG_HC_TO_STACK_HCI_SCO        0x1200 /* eq. BT_EVT_TO_BTU_HCI_SCO */
77 #define MSG_HC_TO_STACK_HCI_EVT        0x1000 /* eq. BT_EVT_TO_BTU_HCI_EVT */
78 #define MSG_HC_TO_STACK_L2C_SEG_XMIT   0x1900 /* eq. BT_EVT_TO_BTU_L2C_SEG_XMIT */
79 
80 /* Message event ID passed from stack to vendor lib */
81 #define MSG_STACK_TO_HC_HCI_ACL        0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */
82 #define MSG_STACK_TO_HC_HCI_SCO        0x2200 /* eq. BT_EVT_TO_LM_HCI_SCO */
83 #define MSG_STACK_TO_HC_HCI_CMD        0x2000 /* eq. BT_EVT_TO_LM_HCI_CMD */
84 
85 /* Local Bluetooth Controller ID for BR/EDR */
86 #define LOCAL_BR_EDR_CONTROLLER_ID      0
87 
88 /* Definitions of audio codec type
89  *      inherited from AG callout function "codec" parameter
90  */
91 #define SCO_CODEC_NONE      0x0000 /* BTA_AG_CODEC_NONE/BTM_SCO_CODEC_NONE */
92 #define SCO_CODEC_CVSD      0x0001 /* BTA_AG_CODEC_CVSD/BTM_SCO_CODEC_CVSD */
93 #define SCO_CODEC_MSBC      0x0002 /* BTA_AG_CODEC_MSBC/BTM_SCO_CODEC_MSBC */
94 
95 /******************************************************************************
96 **  Type definitions and return values
97 ******************************************************************************/
98 
99 typedef struct
100 {
101     uint16_t          event;
102     uint16_t          len;
103     uint16_t          offset;
104     uint16_t          layer_specific;
105     uint8_t           data[];
106 } HC_BT_HDR;
107 
108 #define BT_HC_HDR_SIZE (sizeof(HC_BT_HDR))
109 
110 typedef struct _hc_buffer_hdr
111 {
112     struct _hc_buffer_hdr *p_next;   /* next buffer in the queue */
113     uint8_t   reserved1;
114     uint8_t   reserved2;
115     uint8_t   reserved3;
116     uint8_t   reserved4;
117 } HC_BUFFER_HDR_T;
118 
119 #define BT_HC_BUFFER_HDR_SIZE (sizeof(HC_BUFFER_HDR_T))
120 
121 /******************************************************************************
122 **  Extern variables and functions
123 ******************************************************************************/
124 
125 extern bt_hc_callbacks_t *bt_hc_cbacks;
126 
127 /******************************************************************************
128 **  Functions
129 ******************************************************************************/
130 
131 // Called when a buffer has been produced by the serial layer and should be
132 // processed by the HCI layer.
133 void bthc_rx_ready(void);
134 void bthc_tx(HC_BT_HDR *buf);
135 void bthc_idle_timeout(void);
136