1 /* $NetBSD: bluetooth.h,v 1.5 2004/01/04 05:47:43 dsainty Exp $ */
2
3 /*
4 * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) and
9 * David Sainty (David.Sainty@dtsp.co.nz).
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 struct btframe_buffer;
41
42 struct btframe_channel {
43 /*
44 * Allocate and transmit a buffer for transmission to
45 * Bluetooth device.
46 */
47
48 /*
49 * bt_alloc() allocates a buffer suitable for passing to
50 * bt_send() on this channel. The required buffer size should
51 * be passed in, and the method returns a pointer to the
52 * buffer space, and a handle for the buffer to be passed to
53 * bt_send(). Returns NULL on error (invalid size, or
54 * allocation error).
55 */
56 u_int8_t* (*bt_alloc)(void*, size_t, struct btframe_buffer **);
57
58 /*
59 * bt_send() sends the data stored in the given buffer with
60 * the given size. Returns zero on success, or a standard
61 * error number on failure.
62 */
63 int (*bt_send)(void*, struct btframe_buffer *, size_t);
64 };
65
66 struct btframe_methods {
67 int (*bt_open)(void *h, int flag, int mode, struct proc *p);
68 int (*bt_close)(void *h, int flag, int mode, struct proc *p);
69
70 /* HCI channels */
71 struct btframe_channel bt_control;
72 struct btframe_channel bt_acldata;
73 struct btframe_channel bt_scodata;
74
75 /* Raise SPL to a level that will prevent callbacks */
76 int (*bt_splraise)(void);
77 };
78
79 struct btframe_callback_methods {
80 /* Received data */
81 void (*bt_recveventdata)(void *, u_int8_t *, size_t);
82 void (*bt_recvacldata)(void *, u_int8_t *, size_t);
83 void (*bt_recvscodata)(void *, u_int8_t *, size_t);
84 };
85
86 struct bt_attach_args {
87 struct btframe_methods const *bt_methods;
88 struct btframe_callback_methods const **bt_cb;
89 void *bt_handle;
90 };
91
92 int bt_print(void *aux, const char *pnp);
93
94 #define BTGETW(x) (((u_int8_t const*)(x))[0] | ((u_int8_t const*)(x))[1] << 8)
95
96 /* HCI interface constants */
97
98 /* Maximum event packet length, including header */
99 #define BTHCI_EVENT_MIN_LEN 2
100 #define BTHCI_EVENT_MAX_LEN (0xff + BTHCI_EVENT_MIN_LEN)
101 #define BTHCI_EVENT_LEN_OFFT 1
102 #define BTHCI_EVENT_LEN_LENGTH 1
103
104 /* Maximum command packet length, including header */
105 #define BTHCI_COMMAND_MIN_LEN 3
106 #define BTHCI_COMMAND_MAX_LEN (0xff + BTHCI_COMMAND_MIN_LEN)
107 #define BTHCI_COMMAND_LEN_OFFT 2
108 #define BTHCI_COMMAND_LEN_LENGTH 1
109
110 /* Maximum ACL data packet length, including header */
111 #define BTHCI_ACL_DATA_MIN_LEN 4
112 #define BTHCI_ACL_DATA_MAX_LEN (0xffff + BTHCI_ACL_DATA_MIN_LEN)
113 #define BTHCI_ACL_DATA_LEN_OFFT 2
114 #define BTHCI_ACL_DATA_LEN_LENGTH 2
115
116 /* HCI consumer interface constants */
117 #define BTHCI_PKTID_COMMAND 1
118 #define BTHCI_PKTID_ACL_DATA 2
119 #define BTHCI_PKTID_SCO_DATA 3
120 #define BTHCI_PKTID_EVENT 4
Cache object: 8456fa7b064194617af1a8a7adb79951
|