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