|
From: Willy S. <sag...@us...> - 2002-04-08 16:44:09
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
hci.c 1.197 1.198=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added sniff, park and readnumbroadcast
The diff of the modified file(s):
--- hci.c 15 Mar 2002 14:45:34 -0000 1.197
+++ hci.c 8 Apr 2002 09:58:37 -0000 1.198
@@ -47,7 +47,7 @@
#ifdef __KERNEL__
#include <linux/config.h>
#include <linux/bluetooth/sysdep-2.1.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/bluetooth/hci.h>
#include <linux/bluetooth/hci_internal.h>
@@ -195,7 +195,6 @@
=20
/* Link Policy Commands */
static s32 role_discovery(u16 con_hdl);
-static s32 write_link_policy_settings(u16 con_hdl, u16 settings);
=20
/* Host Controller and Baseband Commands */
static s32 write_inquiryscan_activity(u32 interval, u32 wind);
@@ -300,22 +299,25 @@
static u8 hci_inq_aborted =3D 0;
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-struct wait_queue *hci_wq =3D NULL;
struct wait_queue *inq_wq =3D NULL;
struct wait_queue *set_baudrate_wq =3D NULL;
struct wait_queue *test_wq =3D NULL;
struct wait_queue *get_name_wq =3D NULL;
+struct wait_queue *read_clk_wq =3D NULL;
+struct wait_queue *hci_wq =3D NULL;
#else
wait_queue_head_t hci_wq;
wait_queue_head_t inq_wq;
wait_queue_head_t set_baudrate_wq;
wait_queue_head_t test_wq;
wait_queue_head_t get_name_wq;
+wait_queue_head_t read_clk_wq;
#endif /* LINUX_VERSION_CODE */
=20
static s32 test_wq_active =3D 0;
=20
static s32 result_param;
+static u32 result_param_offset;
=20
static struct inquiry_results *inq_res =3D NULL;
=20
@@ -888,7 +890,7 @@
remote_name_request(buf + 3, 0);
=20
/* enable m/s switch */=20
- write_link_policy_settings(hci_hdl, 0x01);
+ hci_write_link_policy_settings(hci_hdl, 0x01);
/* we demand role switch as server */
if (force_msswitch && !i_am_initiator) {
/* FIXME -- check return code */
@@ -948,7 +950,6 @@
hci_ctrl.acl_buf_count[hci_hdl], hci_hdl);
hci_ctrl.hc_buf.acl_num +=3D hci_ctrl.acl_buf_count[hci_hdl];
hci_ctrl.acl_buf_count[hci_hdl] =3D 0;
-
#ifdef __KERNEL__
/* Trigger the send task to start sending data. */
if (buf_count()) {=09=20=20=20=20=20
@@ -1180,6 +1181,20 @@
=20
case READ_CLOCK_OFFSET_COMPLETE:
D_CMD(__FUNCTION__ ": READ_CLOCK_OFFSET_COMPLETE\n");
+
+ if (buf[0]) {=20
+ D_ERR(__FUNCTION__ ": Read clock offset failed due to %s\n",
+ get_err_msg(buf[0]));
+ result_param_offset =3D 0x0ff<<16; //Insert -1 in the third byte, erro=
r to read clk offset
+ } else {
+ result_param_offset =3D (0x0ff&buf[3]) + (0x0ff00&(buf[4]<<8));
+ DSYS(__FUNCTION__ ": Read clock offset result_param_offset =3D 0x%X\n"=
,=20
+ result_param_offset);
+ }
+
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ wake_up_interruptible(&read_clk_wq);
+#endif /* LINUX_VERSION_CODE */
break;
=20
case CONNECTION_PACKET_TYPE_CHANGED:
@@ -1202,6 +1217,7 @@
process_vendor_event(buf, len, event_code);
break;
=20
+=09
default:
DSYS(__FUNCTION__ ": UNKNOWN EVENT CODE 0x%x\n", event_code);
break;
@@ -1247,7 +1263,6 @@
D_CMD(__FUNCTION__ ": LINK_KEY_REQUEST_REPLY Success\n");
result_param =3D 0;
}
-=09=09=09
wake_up_interruptible(&hci_wq);
break;
=20=09=09
@@ -1263,7 +1278,6 @@
D_CMD(__FUNCTION__ ": LINK_KEY_REQUEST_NEGATIVE_REPLY Success\n");
result_param =3D 0;
}
-=09=09=09
wake_up_interruptible(&hci_wq);
break;
=20=09=09
@@ -1279,7 +1293,6 @@
D_CMD(__FUNCTION__ ": PIN_CODE_REQUEST_REPLY Success\n");
result_param =3D 0;
}
-
wake_up_interruptible(&hci_wq);
break;
=20
@@ -1296,8 +1309,8 @@
D_CMD(__FUNCTION__ ": PIN_CODE_REQUEST_NEGATIVE_REPLY Success\n");
result_param =3D 0;
}
-
wake_up_interruptible(&hci_wq);
+=20
break;=09
=20
default:
@@ -1373,6 +1386,7 @@
break;
} else {
DSYS("READ_TRANSMIT_POWER_LEVEL: handle %d, %d dBm\n", hci_handle(&r_v=
al[1]), r_val[3]);
+ result_param =3D 0x0ff&r_val[3];
}
break;
=20
@@ -1514,15 +1528,35 @@
break;
=20=20=20=20=20=20=20=20=20=20=20=20=20
case SET_EVENT_FILTER:
+=20
D_CMD(__FUNCTION__ ": SET_EVENT_FILTER\n");
break;
=20=20=20=20=20=20=20=20=20=20=20=20=20
+ case READ_NUM_BROADCAST_RETRANSMISSIONS:
+ D_CMD(__FUNCTION__ ": READ_NUM_BROADCAST_RETRANSMISSIONS =
\n");
+=09=09=20=20=20=20=20=20=20=20
+ if (r_val[0]) {
+ D_ERR(__FUNCTION__ ": READ_NUM_BROADCAST_RETRANSMISSIONS: %s\n",
+ get_err_msg(r_val[0]));
+ } else {
+ result_param =3D r_val[1];
+ D_CMD(__FUNCTION__ ": READ_NUM_BROADCAST_RETRANSMISSIONS: num_b=
roadcast_retran =3D 0x%X\n",
+ result_param);
+ }
+ break;
+
+ case WRITE_NUM_BROADCAST_RETRANSMISSIONS:
+ D_CMD(__FUNCTION__ ": WRITE_NUM_BROADCAST_RETRANSMISSIONS \n ");
+ break;
+
+
default:
D_CMD(__FUNCTION__ ": HCI_HC, ocf %d not recognised!\n", ocf);
break;
}
/* FIX ME : Wake up from the correct queue */
wake_up_interruptible(&hci_wq);
+=20
break;
=20
case HCI_LP: /* Link policy commands */
@@ -1602,6 +1636,7 @@
#endif
#endif
wake_up_interruptible(&hci_wq);
+=20
break;
=20=20=20=20=20=20=20=20=20=20=20=20=20
case READ_BD_ADDR:
@@ -1622,6 +1657,31 @@
wake_up_interruptible(&hci_wq);
break;
=20=20=20=20=20=20=20=20=20=20=20
+ case HCI_SP:=09
+ release_cmd_timer();
+ switch (ocf) {=20=20
+ case READ_RSSI:
+ D_CMD(__FUNCTION__ ": READ_RSSI\n");
+ if (r_val[0]) {
+ D_ERR(__FUNCTION__ ": READ_RSSI: %s\n",
+ get_err_msg(r_val[0]));
+ result_param =3D 256;
+ break;
+ } else {
+ result_param =3D r_val[3];
+ D_CMD(__FUNCTION__ ": READ_RSSI : con_hdl=3D0x%X%X, RSSI_value=3D0x%X\=
n",
+ r_val[1], r_val[2], result_param);
+ }
+ break;
+ default:
+ D_ERR(__FUNCTION__ ": HCI_SP, ocf %d not recognised!\n", ocf);
+ break;
+ }
+ wake_up_interruptible(&hci_wq);
+=20
+ break;
+
+
case HCI_TC: /* Test Commands */
release_cmd_timer();
=20
@@ -1892,6 +1952,7 @@
init_waitqueue_head(&set_baudrate_wq);
init_waitqueue_head(&test_wq);
init_waitqueue_head(&get_name_wq);
+ init_waitqueue_head(&read_clk_wq);
sema_init(&hci_cmd_semaphore, 1);
sema_init(&hci_inq_semaphore, 1);
#endif /* LINUX_VERSION_CODE */
@@ -1905,6 +1966,32 @@
}
=20
s32
+hci_read_num_broadcast_restransmissions(void)
+{
+ s32 tmp;
+
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(READ_NUM_BROADCAST_RETRANSMISSIONS, HCI_H=
C);;
+ c_pkt.len =3D 0;
+=20=20
+ tmp =3D send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE=
N, DEFAULT_TIMEOUT);
+=09
+ return tmp < 0 ? (-1)<<8 : result_param|(1<<8);
+}
+
+s32
+hci_write_num_broadcast_restransmissions(u8 num_broadcast_retran)
+{
+
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(WRITE_NUM_BROADCAST_RETRANSMISSIONS, HCI_=
HC);;
+ c_pkt.len =3D 1;
+ c_pkt.data[0] =3D num_broadcast_retran;
+
+ return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+}
+
+s32
hci_init(void)
{
u32 i;
@@ -2426,7 +2513,7 @@
}
=20
s32
-write_link_policy_settings(u16 con_hdl, u16 settings)
+hci_write_link_policy_settings(u16 con_hdl, u16 settings)
{
D_CMD(__FUNCTION__ "\n");
=20
@@ -2855,6 +2942,7 @@
c_pkt.opcode =3D hci_put_opcode(SET_EVENT_FILTER, HCI_HC);
memcpy(c_pkt.data, data, len);
c_pkt.len =3D len;
+
return send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN=
, DEFAULT_TIMEOUT);
}
=20
@@ -2900,15 +2988,18 @@
s32
hci_read_power_transmit_level(u32 con_hdl, unsigned char type)
{
+ s32 tmp;
+
D_CMD(__FUNCTION__ "\n");
c_pkt.type =3D CMD_PKT;
- c_pkt.opcode =3D hci_put_opcode(READ_TRANSMIT_POWER_LEVEL, HCI_LP);
+ c_pkt.opcode =3D hci_put_opcode(READ_TRANSMIT_POWER_LEVEL, HCI_HC);
c_pkt.len =3D 3;
c_pkt.data[0] =3D con_hdl & 0xff;
c_pkt.data[1] =3D (con_hdl >> 8) & 0xff;
c_pkt.data[2] =3D type;
=20=09
- return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE=
N);
+ tmp =3D send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI=
_HDR_LEN, DEFAULT_TIMEOUT);
+ return tmp<0 ? 2<<8 : result_param|(1<<8);
}
=20
/* The hci_host_buffer_size function is used by the Host to notify the Host
@@ -3000,6 +3091,8 @@
return send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE=
N, DEFAULT_TIMEOUT);
else
return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+
+
}
=20
/* Defines of Informational Parameters function */
@@ -3116,13 +3209,14 @@
return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
}
=20
+
s32
-hci_sniff_mode(u16 hci_hdl, u16 max_int, u16 min_int, u16 attempt, u16 tim=
eout)
+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);
=20
c_pkt.type =3D CMD_PKT;
- c_pkt.opcode =3D hci_put_opcode(SNIFF_MODE, HCI_LP);
+ c_pkt.opcode =3D hci_put_opcode(PARK_MODE, HCI_LP);
=20=09
c_pkt.data[0] =3D hci_hdl & 0xff;
c_pkt.data[1] =3D (hci_hdl >> 8) & 0xff;
@@ -3130,46 +3224,45 @@
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;
+ c_pkt.len =3D 6;
=20
return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
}
=20
s32
-hci_exit_sniff_mode(u16 hci_hdl)
+hci_sniff_mode(u16 hci_hdl, u16 max_int, u16 min_int, u16 attempt, u16 tim=
eout)
{=20
D_CMD(__FUNCTION__ ": for connnection handle 0x%x\n", hci_hdl);
=20
c_pkt.type =3D CMD_PKT;
- c_pkt.opcode =3D hci_put_opcode(EXIT_SNIFF_MODE, HCI_LP);
+ c_pkt.opcode =3D hci_put_opcode(SNIFF_MODE, HCI_LP);
=20=09
c_pkt.data[0] =3D hci_hdl & 0xff;
c_pkt.data[1] =3D (hci_hdl >> 8) & 0xff;
- c_pkt.len =3D 2;
+ 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;
+ c_pkt.len =3D 10;
=20
return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
}
=20
s32
-hci_park_mode(u16 hci_hdl, u16 max_int, u16 min_int)
+hci_exit_sniff_mode(u16 hci_hdl)
{=20=20
D_CMD(__FUNCTION__ ": for connnection handle 0x%x\n", hci_hdl);
=20
c_pkt.type =3D CMD_PKT;
- c_pkt.opcode =3D hci_put_opcode(PARK_MODE, HCI_LP);
+ c_pkt.opcode =3D hci_put_opcode(EXIT_SNIFF_MODE, HCI_LP);
=20=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;
+ c_pkt.len =3D 2;
=20
return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
}
@@ -3340,22 +3433,29 @@
=20
s32 hci_read_clock_offset(u32 hdl)
{
+ s32 tmp;
+
c_pkt.type =3D CMD_PKT;
c_pkt.opcode =3D hci_put_opcode(READ_CLOCK_OFFSET, HCI_LC);
c_pkt.data[0] =3D (hdl & 0xff);
c_pkt.data[1] =3D ((hdl >> 8) & 0xff);
c_pkt.len =3D 2;
- return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE=
N);
+ tmp =3D send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI=
_HDR_LEN, DEFAULT_TIMEOUT*HZ);=20
+ return tmp < 0 ? 2<<16 : result_param_offset|(1<<16);
}
=20
s32 hci_read_rssi(u32 hdl)
{
+ s32 tmp;
+
c_pkt.type =3D CMD_PKT;
c_pkt.opcode =3D hci_put_opcode(READ_RSSI, HCI_SP);
c_pkt.data[0] =3D (hdl & 0xff);
c_pkt.data[1] =3D ((hdl >> 8) & 0xff);
c_pkt.len =3D 2;
- return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE=
N);
+ tmp =3D send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_L=
EN);
+=20=20=20=20=20=20=20=20
+ return (tmp<0)|(result_param=3D=3D256) ? 2<<8 : result_param|(1<<8=
);
}
=20
/* Sends a connect request to the BT unit with the address bd_addr */
@@ -4091,7 +4191,9 @@
=20=09
printk(__FUNCTION__ ": Timeout when waiting for command response\n");
hci_cmd_pending =3D 0;
+=20
wake_up_interruptible(&hci_wq);
+=20
}
#endif
=20
@@ -4149,25 +4251,18 @@
#else
DECLARE_WAITQUEUE(wait, current);
#endif
-
down(&hci_cmd_semaphore);
-=20
add_wait_queue(&hci_wq, &wait);
current->state =3D TASK_INTERRUPTIBLE;
-
#endif
hci_cmd_pending =3D 1;
-=20=20
start_cmd_timer(max_time);
-=09
tmp =3D send_cmd(cmd, len);
=20
#ifdef __KERNEL__
while (hci_cmd_pending)
schedule();
-
remove_wait_queue(&hci_wq, &wait);
-
up(&hci_cmd_semaphore);
#else
while (hci_cmd_pending)=09=09
|