1 /* 2 * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _BTHCI_TRANSPORT_H_ 6 #define _BTHCI_TRANSPORT_H_ 7 8 #include <bluetooth/HCI/btHCI.h> 9 10 #include <net_buffer.h> 11 #include <Drivers.h> 12 13 typedef enum { ANCILLYANT = (1<<0), 14 RUNNING = (1<<1), 15 LEAVING = (1<<2), 16 SENDING = (1<<3), 17 PROCESSING = (1<<4) 18 } bt_transport_status_t; 19 20 typedef uint8 bt_stat_t; 21 typedef struct bt_hci_statistics { 22 bt_stat_t acceptedTX; 23 bt_stat_t rejectedTX; 24 bt_stat_t successfulTX; 25 bt_stat_t errorTX; 26 27 bt_stat_t acceptedRX; 28 bt_stat_t rejectedRX; 29 bt_stat_t successfulRX; 30 bt_stat_t errorRX; 31 32 bt_stat_t commandTX; 33 bt_stat_t eventRX; 34 bt_stat_t aclTX; 35 bt_stat_t aclRX; 36 bt_stat_t scoTX; 37 bt_stat_t scoRX; 38 bt_stat_t escoTX; 39 bt_stat_t escoRX; 40 41 bt_stat_t bytesRX; 42 bt_stat_t bytesTX; 43 } bt_hci_statistics; 44 45 /* TODO: Possible hooks which drivers will have to provide */ 46 typedef struct bt_hci_transport { 47 48 status_t (*SendCommand)(hci_id hci_dev, net_buffer *snbuf); 49 status_t (*SendPacket)(hci_id hci_dev, net_buffer *nbuf ); 50 status_t (*SendSCO)(hci_id hci_dev, net_buffer *nbuf ); 51 status_t (*DeliverStatistics)(bt_hci_statistics *statistics); 52 53 transport_type kind; 54 char name[B_OS_NAME_LENGTH]; 55 56 } bt_hci_transport; 57 58 typedef struct bt_hci_device { 59 transport_type kind; 60 char realName[B_OS_NAME_LENGTH]; 61 } bt_hci_device; 62 63 64 /* Here the transport driver have some flags that */ 65 /* can be used to inform the upper layer about some */ 66 /* special behaouvior to perform */ 67 68 #define BT_IGNORE_THIS_DEVICE (1<<0) 69 #define BT_SCO_NOT_WORKING (1<<1) 70 #define BT_WILL_NEED_A_RESET (1<<2) 71 #define BT_DIGIANSWER (1<<4) 72 73 /* Mandatory IOCTLS to be */ 74 75 #define BT_IOCTLS_OFFSET 3000 76 77 enum { 78 ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, //12999 79 GET_STATS, 80 GET_NOTIFICATION_PORT, 81 GET_HCI_ID, 82 BT_UP 83 }; 84 85 #define PACK_PORTCODE(type,hid,data) ((type&0xFF)<<24|(hid&0xFF)<<16|(data&0xFFFF)) 86 #define GET_PORTCODE_TYPE(code) ((code&0xFF000000)>>24) 87 #define GET_PORTCODE_HID(code) ((code&0x00FF0000)>>16) 88 #define GET_PORTCODE_DATA(code) ((code&0x0000FFFF)) 89 90 /* Port drivers can use to send information (1 for all for 91 at moment refer to ioctl GET_NOTIFICATION_PORT)*/ 92 #define BT_USERLAND_PORT_NAME "Kernel-User Event" 93 #define BLUETOOTH_CONNECTION_PORT "bluetooth connection port" 94 #define BLUETOOTH_CONNECTION_SCHED_PORT "bluetooth con sched port" 95 96 #endif // _BTHCI_TRANSPORT_H_ 97