Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 1 | /* |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 3 | * Not a Contribution |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 4 | * 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 Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 19 | #ifndef ANDROID_INCLUDE_BT_HD_H |
| 20 | #define ANDROID_INCLUDE_BT_HD_H |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 21 | |
| 22 | #include <stdint.h> |
| 23 | |
| 24 | __BEGIN_DECLS |
| 25 | |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 26 | typedef enum |
| 27 | { |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 28 | 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 Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 34 | |
| 35 | typedef enum |
| 36 | { |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 37 | BTHD_APP_STATE_NOT_REGISTERED, |
| 38 | BTHD_APP_STATE_REGISTERED |
| 39 | } bthd_application_state_t; |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 40 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 41 | typedef 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 Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 49 | |
| 50 | typedef struct |
| 51 | { |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 52 | 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 Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 59 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 60 | typedef 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 Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 69 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 70 | typedef void (* bthd_application_state_callback)(bt_bdaddr_t *bd_addr, bthd_application_state_t state); |
| 71 | typedef void (* bthd_connection_state_callback)(bt_bdaddr_t *bd_addr, bthd_connection_state_t state); |
| 72 | typedef void (* bthd_get_report_callback)(uint8_t type, uint8_t id, uint16_t buffer_size); |
| 73 | typedef void (* bthd_set_report_callback)(uint8_t type, uint8_t id, uint16_t len, uint8_t *p_data); |
| 74 | typedef void (* bthd_set_protocol_callback)(uint8_t protocol); |
| 75 | typedef void (* bthd_intr_data_callback)(uint8_t report_id, uint16_t len, uint8_t *p_data); |
| 76 | typedef void (* bthd_vc_unplug_callback)(void); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 77 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 78 | /** BT-HD callbacks */ |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 79 | typedef struct { |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 80 | size_t size; |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 81 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 82 | 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 Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 90 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 91 | /** BT-HD interface */ |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 92 | typedef struct { |
| 93 | |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 94 | size_t size; |
| 95 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 96 | /** init interface and register callbacks */ |
| 97 | bt_status_t (*init)(bthd_callbacks_t* callbacks); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 98 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 99 | /** close interface */ |
| 100 | void (*cleanup)(void); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 101 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 102 | /** 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 Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 105 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 106 | /** unregister application */ |
| 107 | bt_status_t (*unregister_app)(void); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 108 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 109 | /** connects to host with virtual cable */ |
| 110 | bt_status_t (*connect)(void); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 111 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 112 | /** disconnects from currently connected host */ |
| 113 | bt_status_t (*disconnect)(void); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 114 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 115 | /** send report */ |
| 116 | bt_status_t (*send_report)(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 117 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 118 | /** notifies error for invalid SET_REPORT */ |
| 119 | bt_status_t (*report_error)(uint8_t error); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 120 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 121 | /** send Virtual Cable Unplug */ |
| 122 | bt_status_t (*virtual_cable_unplug)(void); |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 123 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 124 | } bthd_interface_t; |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 125 | |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 126 | __END_DECLS |
| 127 | |
Hemant Gupta | 2d7d33b | 2013-11-11 11:53:48 +0530 | [diff] [blame] | 128 | #endif /* ANDROID_INCLUDE_BT_HD_H */ |
Hemant Gupta | b295f16 | 2014-04-18 12:18:16 +0530 | [diff] [blame] | 129 | |