blob: ca9f15311fb2c2b17d8db65355e1d48069f9f674 [file] [log] [blame]
Sharvil Nanavatif3b23f22014-06-15 13:36:45 -07001/******************************************************************************
2 *
Jakub Pawlowski5b790fe2017-09-18 09:00:20 -07003 * Copyright 2014 Google, Inc.
Sharvil Nanavatif3b23f22014-06-15 13:36:45 -07004 *
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#pragma once
20
21#include <stdbool.h>
22#include <stdint.h>
23
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070024#include "bt_types.h"
Sharvil Nanavatif3b23f22014-06-15 13:36:45 -070025#include "bt_vendor_lib.h"
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070026#include "hci_internals.h"
Zach Johnson218f3752014-09-03 14:36:44 -070027#include "hci_layer.h"
Sharvil Nanavatif3b23f22014-06-15 13:36:45 -070028
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070029typedef enum {
Myles Watson5ff20a22016-10-31 10:53:52 -070030 VENDOR_CHIP_POWER_CONTROL = BT_VND_OP_POWER_CTRL,
31 VENDOR_OPEN_USERIAL = BT_VND_OP_USERIAL_OPEN,
32 VENDOR_CLOSE_USERIAL = BT_VND_OP_USERIAL_CLOSE,
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070033 VENDOR_GET_LPM_IDLE_TIMEOUT = BT_VND_OP_GET_LPM_IDLE_TIMEOUT,
Myles Watson5ff20a22016-10-31 10:53:52 -070034 VENDOR_SET_LPM_WAKE_STATE = BT_VND_OP_LPM_WAKE_SET_STATE,
35 VENDOR_SET_AUDIO_STATE = BT_VND_OP_SET_AUDIO_STATE
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070036} vendor_opcode_t;
Sharvil Nanavatif3b23f22014-06-15 13:36:45 -070037
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070038typedef enum {
Myles Watson5ff20a22016-10-31 10:53:52 -070039 VENDOR_CONFIGURE_FIRMWARE = BT_VND_OP_FW_CFG,
40 VENDOR_CONFIGURE_SCO = BT_VND_OP_SCO_CFG,
41 VENDOR_SET_LPM_MODE = BT_VND_OP_LPM_SET_MODE,
42 VENDOR_DO_EPILOG = BT_VND_OP_EPILOG,
43 VENDOR_A2DP_OFFLOAD_START = BT_VND_OP_A2DP_OFFLOAD_START,
44 VENDOR_A2DP_OFFLOAD_STOP = BT_VND_OP_A2DP_OFFLOAD_STOP,
Abhijit Adsule47b43102015-05-19 02:44:26 -050045 VENDOR_LAST_OP
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070046} vendor_async_opcode_t;
Sharvil Nanavatif3b23f22014-06-15 13:36:45 -070047
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070048typedef void (*vendor_cb)(bool success);
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070049
Myles Watson5ff20a22016-10-31 10:53:52 -070050typedef struct vendor_t {
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070051 // Opens the vendor-specific library and sets the Bluetooth
Zach Johnsonbf8193b2014-09-08 09:56:35 -070052 // address of the adapter to |local_bdaddr|. |hci_interface| is
Zach Johnson218f3752014-09-03 14:36:44 -070053 // used to send commands on behalf of the vendor library.
Myles Watson5ff20a22016-10-31 10:53:52 -070054 bool (*open)(const uint8_t* local_bdaddr, const hci_t* hci_interface);
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070055
56 // Closes the vendor-specific library and frees all associated resources.
57 // Only |vendor_open| may be called after |vendor_close|.
58 void (*close)(void);
59
60 // Sends a vendor-specific command to the library.
Myles Watson5ff20a22016-10-31 10:53:52 -070061 int (*send_command)(vendor_opcode_t opcode, void* param);
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070062
63 // Sends an asynchronous vendor-specific command to the library.
Myles Watson5ff20a22016-10-31 10:53:52 -070064 int (*send_async_command)(vendor_async_opcode_t opcode, void* param);
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070065
66 // Registers a callback for an asynchronous vendor-specific command.
67 void (*set_callback)(vendor_async_opcode_t opcode, vendor_cb callback);
Zach Johnsonbf8193b2014-09-08 09:56:35 -070068} vendor_t;
Zach Johnsonfbbd42b2014-08-15 17:00:17 -070069
Myles Watson5ff20a22016-10-31 10:53:52 -070070const vendor_t* vendor_get_interface();