blob: 6ba5b097d039b735958c85f7ca35792be6b1538b [file] [log] [blame]
Hemant Gupta235998e2014-04-18 12:18:16 +05301/*
Hemant Guptae338c362013-11-11 11:53:48 +05302 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 * Not a Contribution
Hemant Gupta235998e2014-04-18 12:18:16 +05304 * Copyright (C) 2012 The Android Open Source Project
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
Hemant Guptae338c362013-11-11 11:53:48 +053019#ifndef ANDROID_INCLUDE_BT_HD_H
20#define ANDROID_INCLUDE_BT_HD_H
Hemant Gupta235998e2014-04-18 12:18:16 +053021
22#include <stdint.h>
23
24__BEGIN_DECLS
25
Hemant Gupta235998e2014-04-18 12:18:16 +053026typedef enum
27{
Hemant Guptae338c362013-11-11 11:53:48 +053028 BTHD_REPORT_TYPE_OTHER = 0,
29 BTHD_REPORT_TYPE_INPUT,
30 BTHD_REPORT_TYPE_OUTPUT,
31 BTHD_REPORT_TYPE_FEATURE,
32 BTHD_REPORT_TYPE_INTRDATA // special value for reports to be sent on INTR (INPUT is assumed)
33} bthd_report_type_t;
Hemant Gupta235998e2014-04-18 12:18:16 +053034
35typedef enum
36{
Hemant Guptae338c362013-11-11 11:53:48 +053037 BTHD_APP_STATE_NOT_REGISTERED,
38 BTHD_APP_STATE_REGISTERED
39} bthd_application_state_t;
Hemant Gupta235998e2014-04-18 12:18:16 +053040
Hemant Guptae338c362013-11-11 11:53:48 +053041typedef enum
42{
43 BTHD_CONN_STATE_CONNECTED,
44 BTHD_CONN_STATE_CONNECTING,
45 BTHD_CONN_STATE_DISCONNECTED,
46 BTHD_CONN_STATE_DISCONNECTING,
47 BTHD_CONN_STATE_UNKNOWN
48} bthd_connection_state_t;
Hemant Gupta235998e2014-04-18 12:18:16 +053049
50typedef struct
51{
Hemant Guptae338c362013-11-11 11:53:48 +053052 const char *name;
53 const char *description;
54 const char *provider;
55 uint8_t subclass;
56 uint8_t *desc_list;
57 int desc_list_len;
58} bthd_app_param_t;
Hemant Gupta235998e2014-04-18 12:18:16 +053059
Hemant Guptae338c362013-11-11 11:53:48 +053060typedef struct
61{
62 uint8_t service_type;
63 uint32_t token_rate;
64 uint32_t token_bucket_size;
65 uint32_t peak_bandwidth;
66 uint32_t access_latency;
67 uint32_t delay_variation;
68} bthd_qos_param_t;
Hemant Gupta235998e2014-04-18 12:18:16 +053069
Hemant Guptae338c362013-11-11 11:53:48 +053070typedef void (* bthd_application_state_callback)(bt_bdaddr_t *bd_addr, bthd_application_state_t state);
71typedef void (* bthd_connection_state_callback)(bt_bdaddr_t *bd_addr, bthd_connection_state_t state);
72typedef void (* bthd_get_report_callback)(uint8_t type, uint8_t id, uint16_t buffer_size);
73typedef void (* bthd_set_report_callback)(uint8_t type, uint8_t id, uint16_t len, uint8_t *p_data);
74typedef void (* bthd_set_protocol_callback)(uint8_t protocol);
75typedef void (* bthd_intr_data_callback)(uint8_t report_id, uint16_t len, uint8_t *p_data);
76typedef void (* bthd_vc_unplug_callback)(void);
Hemant Gupta235998e2014-04-18 12:18:16 +053077
Hemant Guptae338c362013-11-11 11:53:48 +053078/** BT-HD callbacks */
Hemant Gupta235998e2014-04-18 12:18:16 +053079typedef struct {
Hemant Gupta235998e2014-04-18 12:18:16 +053080 size_t size;
Hemant Gupta235998e2014-04-18 12:18:16 +053081
Hemant Guptae338c362013-11-11 11:53:48 +053082 bthd_application_state_callback application_state_cb;
83 bthd_connection_state_callback connection_state_cb;
84 bthd_get_report_callback get_report_cb;
85 bthd_set_report_callback set_report_cb;
86 bthd_set_protocol_callback set_protocol_cb;
87 bthd_intr_data_callback intr_data_cb;
88 bthd_vc_unplug_callback vc_unplug_cb;
89} bthd_callbacks_t;
Hemant Gupta235998e2014-04-18 12:18:16 +053090
Hemant Guptae338c362013-11-11 11:53:48 +053091/** BT-HD interface */
Hemant Gupta235998e2014-04-18 12:18:16 +053092typedef struct {
93
Hemant Gupta235998e2014-04-18 12:18:16 +053094 size_t size;
95
Hemant Guptae338c362013-11-11 11:53:48 +053096 /** init interface and register callbacks */
97 bt_status_t (*init)(bthd_callbacks_t* callbacks);
Hemant Gupta235998e2014-04-18 12:18:16 +053098
Hemant Guptae338c362013-11-11 11:53:48 +053099 /** close interface */
100 void (*cleanup)(void);
Hemant Gupta235998e2014-04-18 12:18:16 +0530101
Hemant Guptae338c362013-11-11 11:53:48 +0530102 /** register application */
103 bt_status_t (*register_app)(bthd_app_param_t *app_param, bthd_qos_param_t *in_qos,
104 bthd_qos_param_t *out_qos);
Hemant Gupta235998e2014-04-18 12:18:16 +0530105
Hemant Guptae338c362013-11-11 11:53:48 +0530106 /** unregister application */
107 bt_status_t (*unregister_app)(void);
Hemant Gupta235998e2014-04-18 12:18:16 +0530108
Hemant Guptae338c362013-11-11 11:53:48 +0530109 /** connects to host with virtual cable */
110 bt_status_t (*connect)(void);
Hemant Gupta235998e2014-04-18 12:18:16 +0530111
Hemant Guptae338c362013-11-11 11:53:48 +0530112 /** disconnects from currently connected host */
113 bt_status_t (*disconnect)(void);
Hemant Gupta235998e2014-04-18 12:18:16 +0530114
Hemant Guptae338c362013-11-11 11:53:48 +0530115 /** send report */
116 bt_status_t (*send_report)(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data);
Hemant Gupta235998e2014-04-18 12:18:16 +0530117
Hemant Guptae338c362013-11-11 11:53:48 +0530118 /** notifies error for invalid SET_REPORT */
119 bt_status_t (*report_error)(uint8_t error);
Hemant Gupta235998e2014-04-18 12:18:16 +0530120
Hemant Guptae338c362013-11-11 11:53:48 +0530121 /** send Virtual Cable Unplug */
122 bt_status_t (*virtual_cable_unplug)(void);
Hemant Gupta235998e2014-04-18 12:18:16 +0530123
Hemant Guptae338c362013-11-11 11:53:48 +0530124} bthd_interface_t;
Hemant Gupta235998e2014-04-18 12:18:16 +0530125
Hemant Gupta235998e2014-04-18 12:18:16 +0530126__END_DECLS
127
Hemant Guptae338c362013-11-11 11:53:48 +0530128#endif /* ANDROID_INCLUDE_BT_HD_H */
Hemant Gupta235998e2014-04-18 12:18:16 +0530129