Sharvil Nanavati | f3b23f2 | 2014-06-15 13:36:45 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame] | 3 | * Copyright 2014 Google, Inc. |
Sharvil Nanavati | f3b23f2 | 2014-06-15 13:36:45 -0700 | [diff] [blame] | 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 | #pragma once |
| 20 | |
| 21 | #include <stdbool.h> |
| 22 | #include <stdint.h> |
| 23 | |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 24 | #include "bt_types.h" |
Sharvil Nanavati | f3b23f2 | 2014-06-15 13:36:45 -0700 | [diff] [blame] | 25 | #include "bt_vendor_lib.h" |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 26 | #include "hci_internals.h" |
Zach Johnson | 218f375 | 2014-09-03 14:36:44 -0700 | [diff] [blame] | 27 | #include "hci_layer.h" |
Sharvil Nanavati | f3b23f2 | 2014-06-15 13:36:45 -0700 | [diff] [blame] | 28 | |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 29 | typedef enum { |
Myles Watson | 5ff20a2 | 2016-10-31 10:53:52 -0700 | [diff] [blame] | 30 | 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 Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 33 | VENDOR_GET_LPM_IDLE_TIMEOUT = BT_VND_OP_GET_LPM_IDLE_TIMEOUT, |
Myles Watson | 5ff20a2 | 2016-10-31 10:53:52 -0700 | [diff] [blame] | 34 | VENDOR_SET_LPM_WAKE_STATE = BT_VND_OP_LPM_WAKE_SET_STATE, |
| 35 | VENDOR_SET_AUDIO_STATE = BT_VND_OP_SET_AUDIO_STATE |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 36 | } vendor_opcode_t; |
Sharvil Nanavati | f3b23f2 | 2014-06-15 13:36:45 -0700 | [diff] [blame] | 37 | |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 38 | typedef enum { |
Myles Watson | 5ff20a2 | 2016-10-31 10:53:52 -0700 | [diff] [blame] | 39 | 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 Adsule | 47b4310 | 2015-05-19 02:44:26 -0500 | [diff] [blame] | 45 | VENDOR_LAST_OP |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 46 | } vendor_async_opcode_t; |
Sharvil Nanavati | f3b23f2 | 2014-06-15 13:36:45 -0700 | [diff] [blame] | 47 | |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 48 | typedef void (*vendor_cb)(bool success); |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 49 | |
Myles Watson | 5ff20a2 | 2016-10-31 10:53:52 -0700 | [diff] [blame] | 50 | typedef struct vendor_t { |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 51 | // Opens the vendor-specific library and sets the Bluetooth |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 52 | // address of the adapter to |local_bdaddr|. |hci_interface| is |
Zach Johnson | 218f375 | 2014-09-03 14:36:44 -0700 | [diff] [blame] | 53 | // used to send commands on behalf of the vendor library. |
Myles Watson | 5ff20a2 | 2016-10-31 10:53:52 -0700 | [diff] [blame] | 54 | bool (*open)(const uint8_t* local_bdaddr, const hci_t* hci_interface); |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 55 | |
| 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 Watson | 5ff20a2 | 2016-10-31 10:53:52 -0700 | [diff] [blame] | 61 | int (*send_command)(vendor_opcode_t opcode, void* param); |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 62 | |
| 63 | // Sends an asynchronous vendor-specific command to the library. |
Myles Watson | 5ff20a2 | 2016-10-31 10:53:52 -0700 | [diff] [blame] | 64 | int (*send_async_command)(vendor_async_opcode_t opcode, void* param); |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 65 | |
| 66 | // Registers a callback for an asynchronous vendor-specific command. |
| 67 | void (*set_callback)(vendor_async_opcode_t opcode, vendor_cb callback); |
Zach Johnson | bf8193b | 2014-09-08 09:56:35 -0700 | [diff] [blame] | 68 | } vendor_t; |
Zach Johnson | fbbd42b | 2014-08-15 17:00:17 -0700 | [diff] [blame] | 69 | |
Myles Watson | 5ff20a2 | 2016-10-31 10:53:52 -0700 | [diff] [blame] | 70 | const vendor_t* vendor_get_interface(); |