Home | History | Annotate | Download | only in hardware
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ANDROID_INCLUDE_BT_HD_H
     18 #define ANDROID_INCLUDE_BT_HD_H
     19 
     20 #include <stdint.h>
     21 
     22 __BEGIN_DECLS
     23 
     24 typedef enum
     25 {
     26     BTHD_REPORT_TYPE_OTHER = 0,
     27     BTHD_REPORT_TYPE_INPUT,
     28     BTHD_REPORT_TYPE_OUTPUT,
     29     BTHD_REPORT_TYPE_FEATURE,
     30     BTHD_REPORT_TYPE_INTRDATA // special value for reports to be sent on INTR (INPUT is assumed)
     31 } bthd_report_type_t;
     32 
     33 typedef enum
     34 {
     35     BTHD_APP_STATE_NOT_REGISTERED,
     36     BTHD_APP_STATE_REGISTERED
     37 } bthd_application_state_t;
     38 
     39 typedef enum
     40 {
     41     BTHD_CONN_STATE_CONNECTED,
     42     BTHD_CONN_STATE_CONNECTING,
     43     BTHD_CONN_STATE_DISCONNECTED,
     44     BTHD_CONN_STATE_DISCONNECTING,
     45     BTHD_CONN_STATE_UNKNOWN
     46 } bthd_connection_state_t;
     47 
     48 typedef struct
     49 {
     50     const char      *name;
     51     const char      *description;
     52     const char      *provider;
     53     uint8_t         subclass;
     54     uint8_t         *desc_list;
     55     int             desc_list_len;
     56 } bthd_app_param_t;
     57 
     58 typedef struct
     59 {
     60     uint8_t  service_type;
     61     uint32_t token_rate;
     62     uint32_t token_bucket_size;
     63     uint32_t peak_bandwidth;
     64     uint32_t access_latency;
     65     uint32_t delay_variation;
     66 } bthd_qos_param_t;
     67 
     68 typedef void (* bthd_application_state_callback)(bt_bdaddr_t *bd_addr, bthd_application_state_t state);
     69 typedef void (* bthd_connection_state_callback)(bt_bdaddr_t *bd_addr, bthd_connection_state_t state);
     70 typedef void (* bthd_get_report_callback)(uint8_t type, uint8_t id, uint16_t buffer_size);
     71 typedef void (* bthd_set_report_callback)(uint8_t type, uint8_t id, uint16_t len, uint8_t *p_data);
     72 typedef void (* bthd_set_protocol_callback)(uint8_t protocol);
     73 typedef void (* bthd_intr_data_callback)(uint8_t report_id, uint16_t len, uint8_t *p_data);
     74 typedef void (* bthd_vc_unplug_callback)(void);
     75 
     76 /** BT-HD callbacks */
     77 typedef struct {
     78     size_t      size;
     79 
     80     bthd_application_state_callback application_state_cb;
     81     bthd_connection_state_callback  connection_state_cb;
     82     bthd_get_report_callback        get_report_cb;
     83     bthd_set_report_callback        set_report_cb;
     84     bthd_set_protocol_callback      set_protocol_cb;
     85     bthd_intr_data_callback         intr_data_cb;
     86     bthd_vc_unplug_callback         vc_unplug_cb;
     87 } bthd_callbacks_t;
     88 
     89 /** BT-HD interface */
     90 typedef struct {
     91 
     92     size_t          size;
     93 
     94     /** init interface and register callbacks */
     95     bt_status_t (*init)(bthd_callbacks_t* callbacks);
     96 
     97     /** close interface */
     98     void  (*cleanup)(void);
     99 
    100     /** register application */
    101     bt_status_t (*register_app)(bthd_app_param_t *app_param, bthd_qos_param_t *in_qos,
    102                                             bthd_qos_param_t *out_qos);
    103 
    104     /** unregister application */
    105     bt_status_t (*unregister_app)(void);
    106 
    107     /** connects to host with virtual cable */
    108     bt_status_t (*connect)(bt_bdaddr_t *bd_addr);
    109 
    110     /** disconnects from currently connected host */
    111     bt_status_t (*disconnect)(void);
    112 
    113     /** send report */
    114     bt_status_t (*send_report)(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data);
    115 
    116     /** notifies error for invalid SET_REPORT */
    117     bt_status_t (*report_error)(uint8_t error);
    118 
    119     /** send Virtual Cable Unplug  */
    120     bt_status_t (*virtual_cable_unplug)(void);
    121 
    122 } bthd_interface_t;
    123 
    124 __END_DECLS
    125 
    126 #endif /* ANDROID_INCLUDE_BT_HD_H */
    127 
    128