1 /*
2  * Copyright (C) 2018 Knowles Electronics
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _TUNNEL_H_
18 #define _TUNNEL_H_
19 
20 #if __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 struct ia_tunneling_hal;
26 
27 /**
28  * Opens up the tunnel port and sets it up to start the tunneling of data
29  *
30  * Input  - buffering size
31  *          If buffering size is non-zero, then set Non Buffering Flag
32  * Output - Handle to Tunneling HAL
33  *        - NULL on failure, non null on success
34  */
35 struct ia_tunneling_hal* ia_start_tunneling(int buffering_size);
36 
37 /**
38  * Enable the tunneling of the data for a particular tunnel id and a source id
39  *
40  * Input  - tun_hdl - Handle to the Tunneling HAL.
41  *          src_id - Source system ID for this tunnel
42  *          tunl_mode - tunnel out in sync or async mode.
43  *          tunl_encode -tunnel encoding format.
44  *
45  * Output - Zero on success, errno on failure.
46  */
47 int ia_enable_tunneling_source(struct ia_tunneling_hal *tun_hdl,
48                                unsigned int src_id,
49                                unsigned int tunl_mode,
50                                unsigned int tunl_encode);
51 
52 /**
53  * Disable the tunneling of the data for a particular tunnel id and a source id
54  *
55  * Input  - tun_hdl - Handle to the Tunneling HAL.
56  *          src_id - Source system ID for this tunnel
57  *          tunl_mode - tunnel out in sync or async mode.
58  *          tunl_encode -tunnel encoding format.
59  *
60  * Output - Zero on success, errno on failure.
61  */
62 int ia_disable_tunneling_source(struct ia_tunneling_hal *tun_hdl,
63                                unsigned int src_id,
64                                unsigned int tunl_mode,
65                                unsigned int tunl_encode);
66 
67 
68 /**
69  * Get the tunneled data. This data is an interleaved data from all the tunnels that were
70  * enabled.
71  *
72  * Input  - tun_hdl - Handle to the Tunneling HAL.
73  *          buf - buffer in which the data will be filled.
74  *          buf_size - Size of the buffer buf
75  * Output - Number of bytes filled into the buffer
76  */
77 int ia_read_tunnel_data(struct ia_tunneling_hal *tun_hdl, void *buf, int buf_size);
78 
79 /**
80  * Set the output buffer threshold for the event generation.
81  *
82  * Input  - threshold
83  *
84  * Output - Zero on success, errno on failure.
85  */
86 int ia_set_tunnel_out_buf_threshold(struct ia_tunneling_hal *thdl,
87                                     uint32_t threshold);
88 
89 /**
90  * Closes tunneling port
91  *
92  * Input  - tun_hdl - Handle to the Tunneling HAL.
93  * Output - Zero on success, errno on failure.
94  */
95 int ia_stop_tunneling(struct ia_tunneling_hal *tun_hdl);
96 
97 #if __cplusplus
98 } // extern "C"
99 #endif
100 
101 #endif
102