xref: /haiku/headers/os/bluetooth/HCI/btHCI_transport.h (revision 6ac63f933fe2a8f83b555731e0ea8d1416f13097)
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 
23 	bt_stat_t	acceptedTX;
24 	bt_stat_t	rejectedTX;
25 	bt_stat_t	successfulTX;
26 	bt_stat_t	errorTX;
27 
28 	bt_stat_t	acceptedRX;
29 	bt_stat_t	rejectedRX;
30 	bt_stat_t	successfulRX;
31 	bt_stat_t	errorRX;
32 
33 	bt_stat_t	commandTX;
34 	bt_stat_t	eventRX;
35 	bt_stat_t	aclTX;
36 	bt_stat_t	aclRX;
37 	bt_stat_t	scoTX;
38 	bt_stat_t	scoRX;
39 	bt_stat_t	escoTX;
40 	bt_stat_t	escoRX;
41 
42 	bt_stat_t	bytesRX;
43 	bt_stat_t	bytesTX;
44 
45 
46 } bt_hci_statistics;
47 
48 /* TODO: Possible hooks which drivers will have to provide */
49 typedef struct bt_hci_transport {
50 
51 	status_t	(*SendCommand)(hci_id hci_dev, net_buffer *snbuf);
52 	status_t	(*SendPacket)(hci_id hci_dev, net_buffer *nbuf );
53 	status_t	(*SendSCO)(hci_id hci_dev, net_buffer *nbuf );
54 	status_t	(*DeliverStatistics)(bt_hci_statistics *statistics);
55 
56 	transport_type	kind;
57 	char			name[B_OS_NAME_LENGTH];
58 
59 } bt_hci_transport;
60 
61 typedef struct bt_hci_device {
62 
63 	transport_type	kind;
64 	char			realName[B_OS_NAME_LENGTH];
65 
66 } bt_hci_device;
67 
68 
69 /* Here the transport driver have some flags that */
70 /* can be used to inform the upper layer about some */
71 /* special behaouvior to perform */
72 
73 #define BT_IGNORE_THIS_DEVICE	(1<<0)
74 #define BT_SCO_NOT_WORKING		(1<<1)
75 #define BT_WILL_NEED_A_RESET	(1<<2)
76 #define BT_DIGIANSWER			(1<<4)
77 
78 /* Mandatory IOCTLS to be */
79 
80 #define BT_IOCTLS_OFFSET 3000
81 
82 enum {
83 	ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET,
84 	GET_STATS,
85 	GET_NOTIFICATION_PORT,
86 	GET_HCI_ID,
87 	BT_UP
88 };
89 
90 #define PACK_PORTCODE(type,hid,data)	((type&0xFF)<<24|(hid&0xFF)<<16|(data&0xFFFF))
91 #define GET_PORTCODE_TYPE(code)			((code&0xFF000000)>>24)
92 #define GET_PORTCODE_HID(code)			((code&0x00FF0000)>>16)
93 #define GET_PORTCODE_DATA(code)			((code&0x0000FFFF))
94 
95 /* Port drivers can use to send information (1 for all for
96    at moment refer to ioctl GET_NOTIFICATION_PORT)*/
97 #define BT_USERLAND_PORT_NAME "BT kernel-user Land"
98 
99 #endif // _BTHCI_TRANSPORT_H_
100