summaryrefslogtreecommitdiffstats
path: root/hci/include/vendor.h
blob: ec948fe6006e829be05c8449c252f1b87c244b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/******************************************************************************
 *
 *  Copyright (C) 2014 Google, Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#pragma once

#include <stdbool.h>
#include <stdint.h>

#include "bt_types.h"
#include "bt_vendor_lib.h"
#include "hci_internals.h"
#include "hci_layer.h"

typedef enum {
  VENDOR_CHIP_POWER_CONTROL   = BT_VND_OP_POWER_CTRL,
  VENDOR_OPEN_USERIAL         = BT_VND_OP_USERIAL_OPEN,
  VENDOR_CLOSE_USERIAL        = BT_VND_OP_USERIAL_CLOSE,
  VENDOR_GET_LPM_IDLE_TIMEOUT = BT_VND_OP_GET_LPM_IDLE_TIMEOUT,
  VENDOR_SET_LPM_WAKE_STATE   = BT_VND_OP_LPM_WAKE_SET_STATE,
  VENDOR_SET_AUDIO_STATE      = BT_VND_OP_SET_AUDIO_STATE
} vendor_opcode_t;

typedef enum {
  VENDOR_CONFIGURE_FIRMWARE   = BT_VND_OP_FW_CFG,
  VENDOR_CONFIGURE_SCO        = BT_VND_OP_SCO_CFG,
  VENDOR_SET_LPM_MODE         = BT_VND_OP_LPM_SET_MODE,
  VENDOR_DO_EPILOG            = BT_VND_OP_EPILOG
} vendor_async_opcode_t;

typedef void (*vendor_cb)(bool success);

typedef struct vendor_t{
  // Opens the vendor-specific library and sets the Bluetooth
  // address of the adapter to |local_bdaddr|. |hci_interface| is
  // used to send commands on behalf of the vendor library.
  bool (*open)(
    const uint8_t *local_bdaddr,
    const hci_t *hci_interface
  );

  // Closes the vendor-specific library and frees all associated resources.
  // Only |vendor_open| may be called after |vendor_close|.
  void (*close)(void);

  // Sends a vendor-specific command to the library.
  int (*send_command)(vendor_opcode_t opcode, void *param);

  // Sends an asynchronous vendor-specific command to the library.
  int (*send_async_command)(vendor_async_opcode_t opcode, void *param);

  // Registers a callback for an asynchronous vendor-specific command.
  void (*set_callback)(vendor_async_opcode_t opcode, vendor_cb callback);

  /** SSR cleanup is used in HW reset cases
  ** which would close all the client channels
  ** and turns off the chip*/
  void (*ssr_cleanup) (void);
} vendor_t;

const vendor_t *vendor_get_interface();