Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / staging / ath6kl / include / athbtfilter.h
1 //------------------------------------------------------------------------------
2 // <copyright file="athbtfilter.h" company="Atheros">
3 //    Copyright (c) 2007-2010 Atheros Corporation.  All rights reserved.
4 // 
5 //
6 // Permission to use, copy, modify, and/or distribute this software for any
7 // purpose with or without fee is hereby granted, provided that the above
8 // copyright notice and this permission notice appear in all copies.
9 //
10 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 //
18 //
19 //------------------------------------------------------------------------------
20 //==============================================================================
21 // Public Bluetooth filter APIs
22 // Author(s): ="Atheros"
23 //==============================================================================
24 #ifndef ATHBTFILTER_H_
25 #define ATHBTFILTER_H_
26
27 #define ATH_DEBUG_INFO  (1 << 2)
28 #define ATH_DEBUG_INF    ATH_DEBUG_INFO
29
30 typedef enum _ATHBT_HCI_CTRL_TYPE {
31     ATHBT_HCI_COMMAND     = 0,
32     ATHBT_HCI_EVENT       = 1,
33 } ATHBT_HCI_CTRL_TYPE;
34
35 typedef enum _ATHBT_STATE_INDICATION {
36     ATH_BT_NOOP        = 0,
37     ATH_BT_INQUIRY     = 1,
38     ATH_BT_CONNECT     = 2,
39     ATH_BT_SCO         = 3,
40     ATH_BT_ACL         = 4,
41     ATH_BT_A2DP        = 5,
42     ATH_BT_ESCO        = 6,
43     /* new states go here.. */
44
45     ATH_BT_MAX_STATE_INDICATION
46 } ATHBT_STATE_INDICATION;
47
48     /* filter function for OUTGOING commands and INCOMMING events */
49 typedef void   (*ATHBT_FILTER_CMD_EVENTS_FN)(void *pContext, ATHBT_HCI_CTRL_TYPE Type, unsigned char *pBuffer, int Length);
50
51     /* filter function for OUTGOING data HCI packets */
52 typedef void   (*ATHBT_FILTER_DATA_FN)(void *pContext, unsigned char *pBuffer, int Length);
53
54 typedef enum _ATHBT_STATE {
55     STATE_OFF  = 0,
56     STATE_ON   = 1,
57     STATE_MAX
58 } ATHBT_STATE;
59
60     /* BT state indication (when filter functions are not used) */
61
62 typedef void   (*ATHBT_INDICATE_STATE_FN)(void *pContext, ATHBT_STATE_INDICATION Indication, ATHBT_STATE State, unsigned char LMPVersion);
63
64 typedef struct _ATHBT_FILTER_INSTANCE {
65 #ifdef UNDER_CE
66     WCHAR                       *pWlanAdapterName;  /* filled in by user */
67 #else
68     char                        *pWlanAdapterName;  /* filled in by user */
69 #endif /* UNDER_CE */
70     int                         FilterEnabled;      /* filtering is enabled */
71     int                         Attached;           /* filter library is attached */
72     void                        *pContext;          /* private context for filter library */
73     ATHBT_FILTER_CMD_EVENTS_FN  pFilterCmdEvents;   /* function ptr to filter a command or event */
74     ATHBT_FILTER_DATA_FN        pFilterAclDataOut;  /* function ptr to filter ACL data out (to radio) */
75     ATHBT_FILTER_DATA_FN        pFilterAclDataIn;   /* function ptr to filter ACL data in (from radio) */
76     ATHBT_INDICATE_STATE_FN     pIndicateState;     /* function ptr to indicate a state */
77 } ATH_BT_FILTER_INSTANCE;
78
79
80 /* API MACROS */
81
82 #define AthBtFilterHciCommand(instance,packet,length)          \
83     if ((instance)->FilterEnabled) {                           \
84         (instance)->pFilterCmdEvents((instance)->pContext,     \
85                                    ATHBT_HCI_COMMAND,          \
86                                    (unsigned char *)(packet),  \
87                                    (length));                  \
88     }
89
90 #define AthBtFilterHciEvent(instance,packet,length)            \
91     if ((instance)->FilterEnabled) {                           \
92         (instance)->pFilterCmdEvents((instance)->pContext,     \
93                                    ATHBT_HCI_EVENT,            \
94                                    (unsigned char *)(packet),  \
95                                    (length));                  \
96     }
97
98 #define AthBtFilterHciAclDataOut(instance,packet,length)     \
99     if ((instance)->FilterEnabled) {                         \
100         (instance)->pFilterAclDataOut((instance)->pContext,  \
101                                  (unsigned char *)(packet),  \
102                                  (length));                  \
103     }
104
105 #define AthBtFilterHciAclDataIn(instance,packet,length)      \
106     if ((instance)->FilterEnabled) {                         \
107         (instance)->pFilterAclDataIn((instance)->pContext,   \
108                                  (unsigned char *)(packet),  \
109                                  (length));                  \
110     }
111         
112 /* if filtering is not desired, the application can indicate the state directly using this
113  * macro:
114  */
115 #define AthBtIndicateState(instance,indication,state)           \
116     if ((instance)->FilterEnabled) {                            \
117         (instance)->pIndicateState((instance)->pContext,        \
118                                    (indication),                \
119                                    (state),                     \
120                                    0);                          \
121     }
122
123 #ifdef __cplusplus
124 extern "C" {
125 #endif
126
127 /* API prototypes */
128 int     AthBtFilter_Attach(ATH_BT_FILTER_INSTANCE *pInstance, unsigned int flags);
129 void    AthBtFilter_Detach(ATH_BT_FILTER_INSTANCE *pInstance);
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /*ATHBTFILTER_H_*/