• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2018 Realtek 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:      userial_vendor.h
22  *
23  *  Description:   Contains vendor-specific definitions used in serial port
24  *                 controls
25  *
26  ******************************************************************************/
27 
28 #ifndef USERIAL_VENDOR_H
29 #define USERIAL_VENDOR_H
30 
31 #include "bt_vendor_rtk.h"
32 #include "userial.h"
33 #include "hci_h5_int.h"
34 #include <assert.h>
35 #include "rtk_parse.h"
36 #include "bt_skbuff.h"
37 #include "rtk_common.h"
38 
39 /******************************************************************************
40 **  Constants & Macros
41 ******************************************************************************/
42 #define RTK_NO_INTR(fn) \
43     do                  \
44     {                   \
45     } while ((fn) == -1 && errno == EINTR)
46 
47 /**** baud rates ****/
48 #define USERIAL_BAUD_300 0
49 #define USERIAL_BAUD_600 1
50 #define USERIAL_BAUD_1200 2
51 #define USERIAL_BAUD_2400 3
52 #define USERIAL_BAUD_9600 4
53 #define USERIAL_BAUD_19200 5
54 #define USERIAL_BAUD_57600 6
55 #define USERIAL_BAUD_115200 7
56 #define USERIAL_BAUD_230400 8
57 #define USERIAL_BAUD_460800 9
58 #define USERIAL_BAUD_921600 10
59 #define USERIAL_BAUD_1M 11
60 #define USERIAL_BAUD_1_5M 12
61 #define USERIAL_BAUD_2M 13
62 #define USERIAL_BAUD_3M 14
63 #define USERIAL_BAUD_4M 15
64 #define USERIAL_BAUD_AUTO 16
65 
66 /**** Data Format ****/
67 /* Stop Bits */
68 #define USERIAL_STOPBITS_1 1
69 #define USERIAL_STOPBITS_1_5 (1 << 1)
70 #define USERIAL_STOPBITS_2 (1 << 2)
71 
72 /* Parity Bits */
73 #define USERIAL_PARITY_NONE (1 << 3)
74 #define USERIAL_PARITY_EVEN (1 << 4)
75 #define USERIAL_PARITY_ODD (1 << 5)
76 
77 /* Data Bits */
78 #define USERIAL_DATABITS_5 (1 << 6)
79 #define USERIAL_DATABITS_6 (1 << 7)
80 #define USERIAL_DATABITS_7 (1 << 8)
81 #define USERIAL_DATABITS_8 (1 << 9)
82 
83 #define USERIAL_HW_FLOW_CTRL_OFF 0
84 #define USERIAL_HW_FLOW_CTRL_ON 1
85 
86 #if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
87 /* These are the ioctl values used for bt_wake ioctl via UART driver. you may
88  * need to redefine them on you platform!
89  * Logically they need to be unique and not colide with existing uart ioctl's.
90  */
91 #ifndef USERIAL_IOCTL_BT_WAKE_ASSERT
92 #define USERIAL_IOCTL_BT_WAKE_ASSERT 0x8003
93 #endif
94 #ifndef USERIAL_IOCTL_BT_WAKE_DEASSERT
95 #define USERIAL_IOCTL_BT_WAKE_DEASSERT 0x8004
96 #endif
97 #ifndef USERIAL_IOCTL_BT_WAKE_GET_ST
98 #define USERIAL_IOCTL_BT_WAKE_GET_ST 0x8005
99 #endif
100 #endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
101 
102 /******************************************************************************
103 **  Type definitions
104 ******************************************************************************/
105 /* Structure used to configure serial port during open */
106 typedef struct
107 {
108     uint16_t fmt;     /* Data format */
109     uint8_t baud;     /* Baud rate */
110     uint8_t hw_fctrl; /*hardware flowcontrol*/
111 } tUSERIAL_CFG;
112 
113 typedef enum
114 {
115 #if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
116     USERIAL_OP_ASSERT_BT_WAKE,
117     USERIAL_OP_DEASSERT_BT_WAKE,
118     USERIAL_OP_GET_BT_WAKE_STATE,
119 #endif
120     USERIAL_OP_NOP,
121 } userial_vendor_ioctl_op_t;
122 
123 enum
124 {
125     RTKBT_PACKET_IDLE,
126     RTKBT_PACKET_TYPE,
127     RTKBT_PACKET_HEADER,
128     RTKBT_PACKET_CONTENT,
129     RTKBT_PACKET_END
130 };
131 
132 /******************************************************************************
133 **  Extern variables and functions
134 ******************************************************************************/
135 
136 /******************************************************************************
137 **  Functions
138 ******************************************************************************/
139 
140 /*******************************************************************************
141 **
142 ** Function        userial_vendor_init
143 **
144 ** Description     Initialize userial vendor-specific control block
145 **
146 ** Returns         None
147 **
148 *******************************************************************************/
149 void userial_vendor_init(char *bt_device_node);
150 
151 /*******************************************************************************
152 **
153 ** Function        userial_vendor_open
154 **
155 ** Description     Open the serial port with the given configuration
156 **
157 ** Returns         device fd
158 **
159 *******************************************************************************/
160 int userial_vendor_open(tUSERIAL_CFG *p_cfg);
161 
162 /*******************************************************************************
163 **
164 ** Function        userial_vendor_close
165 **
166 ** Description     Conduct vendor-specific close work
167 **
168 ** Returns         None
169 **
170 *******************************************************************************/
171 void userial_vendor_close(void);
172 
173 /*******************************************************************************
174 **
175 ** Function        userial_vendor_set_baud
176 **
177 ** Description     Set new baud rate
178 **
179 ** Returns         None
180 **
181 *******************************************************************************/
182 void userial_vendor_set_baud(uint8_t userial_baud);
183 
184 /*******************************************************************************
185 **
186 ** Function        userial_vendor_ioctl
187 **
188 ** Description     ioctl interface
189 **
190 ** Returns         None
191 **
192 *******************************************************************************/
193 void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data);
194 
195 void userial_vendor_set_hw_fctrl(uint8_t hw_fctrl);
196 
197 int userial_socket_open(void);
198 
199 int userial_vendor_usb_ioctl(int operation, void *param);
200 
201 int userial_vendor_usb_open(void);
202 
203 void userial_recv_rawdata_hook(unsigned char *buffer, unsigned int total_length);
204 
205 #define RTK_HANDLE_EVENT
206 #define RTK_HANDLE_CMD
207 //#define CONFIG_SCO_OVER_HCI
208 #endif /* USERIAL_VENDOR_H */
209