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