|
From: Mats F. <ma...@us...> - 2001-05-15 15:00:55
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
hci.c 1.146 1.147=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Added functions for Park, Hold and Sniff mode
* Added two new functions for receiving data from BCSP
The diff of the modified file(s):
--- hci.c 2001/04/29 11:37:02 1.146
+++ hci.c 2001/05/15 15:00:55 1.147
@@ -140,6 +140,10 @@
#define USE_NCPTIMER=20
#define NCP_TIMEOUT (3*HZ)
=20
+#ifdef CONFIG_BLUETOOTH_USE_BCSP
+#define bt_write_lower_driver(data, len) bcsp_write_top(data, len)
+#endif
+
/****************** TYPE DEFINITION SECTION ******************************=
***/
=20
/* cmd_t and cmd_buf are structures used to handle the queue of commands
@@ -327,7 +331,7 @@
static s32 test_hci_hdl;
=20
/* temp solution to handle m/s switch */
-static s32 force_msswitch;
+static s32 force_msswitch =3D 0;
static s32 i_am_initiator =3D 0;
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
@@ -337,6 +341,7 @@
* parse_sco_packet or the parse_event_packet, depending on the packet type
*/
=20
+
void
hci_receive_data(u8* data, u32 count)
{
@@ -584,6 +589,99 @@
}
}
=20
+#ifdef CONFIG_BLUETOOTH_USE_BCSP
+void
+hci_receive_event(u8 *data, s32 count)
+{
+ u8 event_type, event_len;
+ u8 *tmp_buf;
+
+ tmp_buf =3D data;
+=09
+ while (count > 0) {
+ event_type =3D tmp_buf[0];
+ event_len =3D tmp_buf[1];
+ tmp_buf +=3D 2;
+ count -=3D 2;
+
+ D_REC(__FUNCTION__", Received event 0x%02x with len:%d\n", event_type, e=
vent_len);
+=09=09
+ process_event(tmp_buf, event_len, event_type);
+ tmp_buf +=3D event_len;
+ count -=3D event_len;
+ }
+}
+
+void
+hci_receive_acl(u8 *data, s32 count)
+{
+ u8 *tmp_buf;
+ u16 hci_hdl;
+ u8 pb_flag;
+ u8 bc_flag;
+ u16 data_len;
+ hci_in_buffer *in_buf;
+
+ tmp_buf =3D data;
+
+ while (count > 0) {
+ /* Parse the HCI header */
+ hci_hdl =3D CHAR2INT12(tmp_buf[1],tmp_buf[0]);
+ pb_flag =3D (((u32) tmp_buf[1]) & 0x30) >> 4;
+ bc_flag =3D (((u32) tmp_buf[1]) & 0xc0) >> 6;
+ data_len =3D CHAR2INT16(tmp_buf[3],tmp_buf[2]);
+ tmp_buf +=3D 4;
+ count -=3D 4;
+=09=09
+ /* Check the length to make sure we won't=20
+ overrun in_buf->buf_ptr in a memcpy later.
+ --gmcnutt
+ */
+ if (data_len > HCI_IN_SIZE) {
+ D_ERR(__FUNCTION__ ": %d is too big "\
+ "for our HCI input buffers -- "\
+ "discarding buffer\n",
+ data_len);
+ return;
+ }
+=09=09
+ if (pb_flag =3D=3D L2CAP_FRAME_START) {
+ D_REC(__FUNCTION__", new L2CAP frame\n");
+ in_buf =3D get_free_inbuffer();
+ if (in_buf) {
+ in_buf->nbr_of_hci_pkt =3D 1;
+ in_buf->hci_hdl =3D hci_hdl;
+ }=09
+ } else {
+ D_REC(__FUNCTION__", cont L2CAP frame\n");
+ in_buf =3D get_inbuffer(hci_hdl);
+ if (in_buf) {
+ in_buf->nbr_of_hci_pkt++;
+ }
+ }
+=09=09
+ if (in_buf) {
+ memcpy(in_buf->buf_ptr, tmp_buf, data_len);
+ D_REC(__FUNCTION__", Copied %d bytes into inbuffer\n",
+ data_len);
+ in_buf->buf_ptr +=3D data_len;
+ in_buf->count +=3D data_len;
+ D_REC(__FUNCTION__", in_buf->count:%d\n", in_buf->count);
+ } else {
+ D_ERR(__FUNCTION__", No inbuffer was found, "\
+ "discarding data\n");
+ return;
+ }
+=09=09
+ /* Decrease the amount of remaining data */
+ count -=3D data_len;
+=09=09
+ process_acl_data(in_buf, pb_flag);
+ tmp_buf +=3D data_len;
+ }
+}
+#endif
+
void
update_ncp(u8 nbr_of_hdl, u8 *pkt)
{
@@ -1746,6 +1844,8 @@
hci_force_msswitch(1);
#else /* CONFIG_BLUETOOTH_ENABLE_MSSWITCH */
DSYS("M/S switch disabled\n");
+
+ hci_force_msswitch(0);
#endif
}
=20
@@ -2698,6 +2798,7 @@
data portion of HCI ACL and SCO Data Packets sent from the Host to the =
Host=20
Controller. The function can be called from both the process currently =
in the
driver and the interrupt handler, therefore the option to block or not.=
*/
+
s32
hci_read_buffer_size(s32 block)
{
@@ -2713,6 +2814,7 @@
return send_cmd((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
}
=20
+
#if 0
s32
hci_read_local_version_info(s32 block)
@@ -2770,6 +2872,100 @@
=20
=20
s32
+hci_hold_mode(u16 hci_hdl, u16 max_int, u16 min_int)
+{=20=20
+ D_CMD(__FUNCTION__", for connnection handle 0x%x\n", hci_hdl);
+
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(HOLD_MODE, HCI_LP);
+=09
+ c_pkt.data[0] =3D hci_hdl & 0xff;
+ c_pkt.data[1] =3D (hci_hdl >> 8) & 0xff;
+ c_pkt.data[2] =3D max_int & 0xff;
+ c_pkt.data[3] =3D (max_int >> 8) & 0xff;
+ c_pkt.data[4] =3D min_int & 0xff;
+ c_pkt.data[5] =3D (min_int >> 8) & 0xff;
+ c_pkt.len =3D 6;
+
+ return send_cmd((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+}
+
+s32
+hci_sniff_mode(u16 hci_hdl, u16 max_int, u16 min_int, u16 attempt, u16 tim=
eout)
+{=20=20
+ D_CMD(__FUNCTION__", for connnection handle 0x%x\n", hci_hdl);
+
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(SNIFF_MODE, HCI_LP);
+=09
+ c_pkt.data[0] =3D hci_hdl & 0xff;
+ c_pkt.data[1] =3D (hci_hdl >> 8) & 0xff;
+ c_pkt.data[2] =3D max_int & 0xff;
+ c_pkt.data[3] =3D (max_int >> 8) & 0xff;
+ c_pkt.data[4] =3D min_int & 0xff;
+ c_pkt.data[5] =3D (min_int >> 8) & 0xff;
+ c_pkt.data[6] =3D attempt & 0xff;
+ c_pkt.data[7] =3D (attempt >> 8) & 0xff;
+ c_pkt.data[8] =3D timeout & 0xff;
+ c_pkt.data[9] =3D (timeout >> 8) & 0xff;
+=09
+ c_pkt.len =3D 10;
+
+ return send_cmd((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+}
+
+s32
+hci_exit_sniff_mode(u16 hci_hdl)
+{=20
+ D_CMD(__FUNCTION__", for connnection handle 0x%x\n", hci_hdl);
+
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(EXIT_SNIFF_MODE, HCI_LP);
+=09
+ c_pkt.data[0] =3D hci_hdl & 0xff;
+ c_pkt.data[1] =3D (hci_hdl >> 8) & 0xff;
+ c_pkt.len =3D 2;
+
+ return send_cmd((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+}
+
+s32
+hci_park_mode(u16 hci_hdl, u16 max_int, u16 min_int)
+{=20=20
+ D_CMD(__FUNCTION__", for connnection handle 0x%x\n", hci_hdl);
+
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(PARK_MODE, HCI_LP);
+=09
+ c_pkt.data[0] =3D hci_hdl & 0xff;
+ c_pkt.data[1] =3D (hci_hdl >> 8) & 0xff;
+ c_pkt.data[2] =3D max_int & 0xff;
+ c_pkt.data[3] =3D (max_int >> 8) & 0xff;
+ c_pkt.data[4] =3D min_int & 0xff;
+ c_pkt.data[5] =3D (min_int >> 8) & 0xff;
+ c_pkt.len =3D 6;
+
+ return send_cmd((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+}
+
+s32
+hci_exit_park_mode(u16 hci_hdl)
+{=20=20
+ D_CMD(__FUNCTION__", for connnection handle 0x%x\n", hci_hdl);
+
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(EXIT_PARK_MODE, HCI_LP);
+=09
+ c_pkt.data[0] =3D hci_hdl & 0xff;
+ c_pkt.data[1] =3D (hci_hdl >> 8) & 0xff;
+ c_pkt.len =3D 2;
+
+ return send_cmd((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+}
+
+
+
+s32
get_con_hdl(u8 *bd)
{
u32 i;
@@ -2885,24 +3081,7 @@
force_msswitch =3D enable;=20
}
=20
-
s32
-hci_hold_mode(u32 con_hdl, u32 max_interval, u32 min_interval)
-{
- c_pkt.type =3D CMD_PKT;
- c_pkt.opcode =3D hci_put_opcode(HOLD_MODE, HCI_LP) ;
- c_pkt.len =3D 6;
- c_pkt.data[0] =3D con_hdl & 0xff;
- c_pkt.data[1] =3D (con_hdl >> 8) & 0xff;
- c_pkt.data[2] =3D max_interval & 0xff;
- c_pkt.data[3] =3D (max_interval >> 8) & 0xff;
- c_pkt.data[4] =3D min_interval & 0xff;
- c_pkt.data[5] =3D (min_interval >> 8) & 0xff;
-
- return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE=
N);
-}
-
-s32
hci_write_page_to(u32 page_to)
{
c_pkt.type =3D CMD_PKT;
@@ -3172,7 +3351,6 @@
return c;
}
=20
-
void=20
set_acl_hdr(u8 *data, u32 len, u8 pb, u8 bc, u32 hci_hdl)
{
|