• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @file    wm_bt_av.h
18  *
19  * @brief   Bluetooth API
20  *
21  * @author  WinnerMicro
22  *
23  * Copyright (c) 2020 Winner Microelectronics Co., Ltd.
24  */
25 
26 #ifndef __WM_BT_A2DP_H__
27 #define __WM_BT_A2DP_H__
28 
29 #include "wm_bt.h"
30 
31 /**
32  * @defgroup BT_APIs Bluetooth APIs
33  * @brief Bluetooth related APIs
34  */
35 
36 /**
37  * @addtogroup BT_APIs
38  * @{
39  */
40 
41 /**
42  * @defgroup BT_AV_APIs
43  * @brief BT_AV APIs
44  */
45 
46 /**
47  * @addtogroup BT_AV_APIs
48  * @{
49  */
50 
51 /**sink realed api*/
52 /**
53  * @brief          Initializes the AV interface for sink mode
54  *
55  * @param[in]     callback      pointer on callback function
56  *
57  * @retval         @ref tls_bt_status_t
58  *
59  * @note           None
60  */
61 tls_bt_status_t tls_bt_av_sink_init(tls_bt_a2dp_sink_callback_t callback);
62 
63 /**
64  * @brief          Shuts down the AV sink interface and does the cleanup
65  *
66  * @param       None
67  *
68  * @retval         @ref tls_bt_status_t
69  *
70  * @note           None
71  */
72 tls_bt_status_t tls_bt_av_sink_deinit(void);
73 
74 /**
75  * @brief          Establishes the AV signalling channel with the source
76  *
77  * @param[in]      *bd_addr         remote device bluetooth device address
78  *
79  * @retval         @ref tls_bt_status_t
80  *
81  * @note           None
82  */
83 tls_bt_status_t tls_bt_av_sink_connect_src(tls_bt_addr_t *bd_addr);
84 
85 /**
86  * @brief          Tears down the AV signalling channel with the source side
87  *
88  * @param[in]      *bd_addr         remote device bluetooth device address
89  *
90  * @retval         @ref tls_bt_status_t
91  *
92  * @note           None
93  */
94 tls_bt_status_t tls_bt_av_sink_disconnect(tls_bt_addr_t *bd_addr);
95 
96 /**src realed api*/
97 
98 /**
99  * @brief          Initializes the AV interface for source mode
100  *
101  * @param[in]     callback      pointer on callback function
102  *
103  * @retval         @ref tls_bt_status_t
104  *
105  * @note           None
106  */
107 tls_bt_status_t tls_bt_av_src_init(tls_bt_a2dp_src_callback_t callback);
108 
109 /**
110  * @brief          Shuts down the AV source interface and does the cleanup
111  *
112  * @param       None
113  *
114  * @retval         @ref tls_bt_status_t
115  *
116  * @note           None
117  */
118 tls_bt_status_t tls_bt_av_src_deinit(void);
119 
120 /**
121  * @brief          Establishes the AV signalling channel with the sink
122  *
123  * @param[in]      *bd_addr         remote device bluetooth device address
124  *
125  * @retval         @ref tls_bt_status_t
126  *
127  * @note           None
128  */
129 tls_bt_status_t tls_bt_av_src_connect_sink(tls_bt_addr_t *bd_addr);
130 
131 /**
132  * @brief          Tears down the AV signalling channel with the sink side
133  *
134  * @param[in]      *bd_addr         remote device bluetooth device address
135  *
136  * @retval         @ref tls_bt_status_t
137  *
138  * @note           None
139  */
140 tls_bt_status_t tls_bt_av_src_disconnect(tls_bt_addr_t *bd_addr);
141 
142 /**btrc related api supported by now*/
143 
144 /**
145  * @brief          Initializes the AVRC interface
146  *
147  * @param[in]     callback      pointer on callback function
148  *
149  * @retval         @ref tls_bt_status_t
150  *
151  * @note           None
152  */
153 tls_bt_status_t tls_btrc_init(tls_btrc_callback_t callback);
154 
155 /**
156  * @brief          Closes the AVRC interface
157  *
158  * @param       None
159  *
160  * @retval         @ref tls_bt_status_t
161  *
162  * @note           None
163  */
164 tls_bt_status_t tls_btrc_deinit(void);
165 
166 /**
167  * @brief          Returns the current play status.
168  *
169  * @param[in]     tls_btrc_play_status_t      stopped, playing, paused...
170  * @param[in]     song_len     seconds of the song
171  * @param[in]     song_pos    played seconds of the song
172  *
173  * @retval         @ref tls_bt_status_t
174  *
175  * @note           This method is called in response to GetPlayStatus request.
176  */
177 tls_bt_status_t tls_btrc_get_play_status_rsp(tls_btrc_play_status_t play_status, uint32_t song_len,
178                                              uint32_t song_pos);
179 
180 /**
181  * @brief          Returns the current songs' element attributes in text
182  *
183  * @param[in]     num_attr     counter of song`s element attributes
184  * @param[in]     p_attrs     pointer of element attributes
185  *
186  * @retval         @ref tls_bt_status_t
187  *
188  * @note           None
189  */
190 tls_bt_status_t tls_btrc_get_element_attr_rsp(uint8_t num_attr, tls_btrc_element_attr_val_t *p_attrs);
191 
192 /**
193  * @brief          Response to the register notification request in text
194  *
195  * @param[in]     event_id      play_status, track or play_pos changed
196  * @param[in]     type     notification type
197  * @param[in]     p_param    pointer to details of notification structer
198  *
199  * @retval         @ref tls_bt_status_t
200  *
201  * @note           None
202  */
203 tls_bt_status_t tls_btrc_register_notification_rsp(tls_btrc_event_id_t event_id,
204     tls_btrc_notification_type_t type, tls_btrc_register_notification_t *p_param);
205 
206 /**
207  * @brief          Send current volume setting to remote side
208  *
209  * @param[in]    volue      Should be in the range 0-127. bit7 is reseved and cannot be set
210  *
211  * @retval         @ref tls_bt_status_t
212  *
213  * @note           Support limited to SetAbsoluteVolume
214  *              This can be enhanced to support Relative Volume (AVRCP 1.0).
215  *                   With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN
216  *                   as opposed to absolute volume level
217  */
218 tls_bt_status_t tls_btrc_set_volume(uint8_t volume);
219 
220 /**btrc ctrl related api supported by now*/
221 
222 /**
223  * @brief          Initializes the AVRC ctrl interface
224  *
225  * @param[in]     callback      pointer on callback function
226  *
227  * @retval         @ref tls_bt_status_t
228  *
229  * @note           None
230  */
231 tls_bt_status_t tls_btrc_ctrl_init(tls_btrc_ctrl_callback_t callback);
232 
233 /**
234  * @brief          Closes the AVRC ctrl interface
235  *
236  * @param       None
237  *
238  * @retval         @ref tls_bt_status_t
239  *
240  * @note           None
241  */
242 tls_bt_status_t tls_btrc_ctrl_deinit(void);
243 
244 /**
245  * @brief           Send Pass-Through command
246  *
247  * @param[in]     bd_addr      remote device bluetooth device address
248  * @param[in]     key_code    code definition of the key
249  * @param[in]     key_state    key stae
250  *
251  * @retval         @ref tls_bt_status_t
252  *
253  * @note           None
254  */
255 tls_bt_status_t tls_btrc_ctrl_send_passthrough_cmd(tls_bt_addr_t *bd_addr, uint8_t key_code, uint8_t key_state);
256 
257 /**
258  * @brief           Send group  navigation command
259  *
260  * @param[in]     bd_addr      remote device bluetooth device address
261  * @param[in]     key_code    code definition of the key
262  * @param[in]     key_state    key stae
263  *
264  * @retval         @ref tls_bt_status_t
265  *
266  * @note           None
267  */
268 tls_bt_status_t tls_btrc_ctrl_send_groupnavigation_cmd(tls_bt_addr_t *bd_addr, uint8_t key_code, uint8_t key_state);
269 
270 /**
271  * @brief           Set current values of Player Attributes
272  *
273  * @param[in]     bd_addr        remote device bluetooth device address
274  * @param[in]     num_attrib    couner of attributes
275  * @param[in]     attrib_ids     atrribute of index indicator
276   * @param[in]    attrib_vals    attribute of values
277  *
278  * @retval         @ref tls_bt_status_t
279  *
280  * @note           None
281  */
282 tls_bt_status_t tls_btrc_ctrl_change_player_app_setting(tls_bt_addr_t *bd_addr, uint8_t num_attrib,
283                                                         uint8_t *attrib_ids, uint8_t *attrib_vals);
284 
285 /**
286  * @brief          Rsp for SetAbsoluteVolume Command
287  *
288  * @param[in]     bd_addr        remote device bluetooth device address
289  * @param[in]     abs_vol       the absolute volume
290  * @param[in]     label           label indicator
291  *
292  * @retval         @ref tls_bt_status_t
293  *
294  * @note           None
295  */
296 tls_bt_status_t tls_btrc_ctrl_set_volume_rsp(tls_bt_addr_t *bd_addr, uint8_t abs_vol, uint8_t label);
297 
298 /**
299  * @brief          Rsp for Notification of Absolute Volume
300  *
301  * @param[in]     bd_addr        remote device bluetooth device address
302  * @param[in]     rsp_type       interim or changed
303   * @param[in]    abs_vol      the absolute volume value
304  * @param[in]     label           label indicator
305  *
306  * @retval         @ref tls_bt_status_t
307  *
308  * @note           None
309  */
310 tls_bt_status_t tls_btrc_ctrl_volume_change_notification_rsp(tls_bt_addr_t *bd_addr,
311                                                              tls_btrc_notification_type_t rsp_type,
312                                                              uint8_t abs_vol, uint8_t label);
313 
314 #endif