Android Hardware Abstraction Layer
bt_hci_lib.h
Go to the documentation of this file.
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 #ifndef BT_HCI_LIB_H
20 #define BT_HCI_LIB_H
21 
22 #include <stdint.h>
23 #include <sys/cdefs.h>
24 #include <sys/types.h>
25 
26 /** Struct types */
27 
28 
29 /** Typedefs and defines */
30 
31 /* Generic purpose transac returned upon request complete */
32 typedef void* TRANSAC;
33 
34 /** Bluetooth Power Control States */
35 typedef enum {
39 
40 /** Bluetooth Low Power Mode */
41 typedef enum {
47 
48 /** Receive flow control */
49 typedef enum {
50  BT_RXFLOW_OFF, /* add transport device fd to select set */
51  BT_RXFLOW_ON, /* remove transport device to from select set */
53 
54 /** HCI logging control */
55 typedef enum {
59 
60 /** Result of write request */
61 typedef enum {
62  BT_HC_TX_SUCCESS, /* a buffer is fully processed and can be released */
63  BT_HC_TX_FAIL, /* transmit fail */
64  BT_HC_TX_FRAGMENT, /* send split ACL pkt back to stack to reprocess */
66 
67 /** Result of preload initialization */
68 typedef enum {
72 
73 /** Result of postload initialization */
74 typedef enum {
78 
79 /** Result of low power enable/disable request */
80 typedef enum {
84 
85 /** Host/Controller Library Return Status */
86 typedef enum {
94 
95 
96 /* Section comment */
97 
98 /*
99  * Bluetooth Host/Controller callback structure.
100  */
101 
102 /* called upon bt host wake signal */
104 
105 /* preload initialization callback */
106 typedef void (*preload_result_cb)(TRANSAC transac, bt_hc_preload_result_t result);
107 
108 /* postload initialization callback */
109 typedef void (*postload_result_cb)(TRANSAC transac, bt_hc_postload_result_t result);
110 
111 /* lpm enable/disable callback */
113 
114 /* datapath buffer allocation callback (callout) */
115 typedef char* (*alloc_mem_cb)(int size);
116 
117 /* datapath buffer deallocation callback (callout) */
118 typedef int (*dealloc_mem_cb)(TRANSAC transac, char *p_buf);
119 
120 /* transmit result callback */
121 typedef int (*tx_result_cb)(TRANSAC transac, char *p_buf, bt_hc_transmit_result_t result);
122 
123 /* a previously setup buffer is read and available for processing
124  buffer is deallocated in stack when processed */
125 typedef int (*data_ind_cb)(TRANSAC transac, char *p_buf, int len);
126 
127 typedef struct {
128  /** set to sizeof(bt_hc_callbacks_t) */
129  size_t size;
130 
131  /* notifies caller result of preload request */
133 
134  /* notifies caller result of postload request */
136 
137  /* notifies caller result of lpm enable/disable */
139 
140  /* notifies hardware on host wake state */
142 
143  /* buffer allocation request */
145 
146  /* buffer deallocation request */
148 
149  /* notifies stack data is available */
151 
152  /* notifies caller when a buffer is transmitted (or failed) */
155 
156 /*
157  * Bluetooth Host/Controller Interface
158  */
159 typedef struct {
160  /** Set to sizeof(bt_hc_interface_t) */
161  size_t size;
162 
163  /**
164  * Opens the interface and provides the callback routines
165  * to the implemenation of this interface.
166  */
167  int (*init)(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr);
168 
169  /** Chip power control */
170  void (*set_power)(bt_hc_chip_power_state_t state);
171 
172  /** Set low power mode wake */
173  int (*lpm)(bt_hc_low_power_event_t event);
174 
175  /** Called prior to stack initialization */
176  void (*preload)(TRANSAC transac);
177 
178  /** Called post stack initialization */
179  void (*postload)(TRANSAC transac);
180 
181  /** Transmit buffer */
182  int (*transmit_buf)(TRANSAC transac, char *p_buf, int len);
183 
184  /** Controls receive flow */
185  int (*set_rxflow)(bt_rx_flow_state_t state);
186 
187  /** Controls HCI logging on/off */
188  int (*logging)(bt_hc_logging_state_t state, char *p_path);
189 
190  /** Closes the interface */
191  void (*cleanup)( void );
193 
194 
195 /*
196  * External shared lib functions
197  */
198 
199 extern const bt_hc_interface_t* bt_hc_get_interface(void);
200 
201 #endif /* BT_HCI_LIB_H */
202