|
From: Peter K. <pk...@us...> - 2001-10-10 16:22:11
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
Makefile 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20
bt_vendor.c 1.29 1.30=20=20=20=20=20=20=20=20=20=20=20=20
bt_vendor.h 1.10 1.11=20=20=20=20=20=20=20=20=20=20=20=20
btconfig.c 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Made it possible to specify the maximum transmit power to use
(only supported for CSR).
The diff of the modified file(s):
--- Makefile 2001/09/26 14:24:26 1.9
+++ Makefile 2001/10/10 16:22:10 1.10
@@ -30,7 +30,7 @@
BTDISCOBJS =3D btdisc.o bt_if.o bt_misc.o
BTINQOBJS =3D btinq.o bt_if.o bt_misc.o
BTTESTOBJS =3D bttest.o bt_misc.o bt_vendor.o bt_if.o
-BTCONFIGOBJS =3D btconfig.o bt_if.o bt_misc.o
+BTCONFIGOBJS =3D btconfig.o bt_vendor.o bt_if.o bt_misc.o
=20
ifdef HAVE_READLINE_READLINE
LDLIBS +=3D -lreadline -ltermcap
--- bt_vendor.c 2001/10/03 17:46:13 1.29
+++ bt_vendor.c 2001/10/10 16:22:10 1.30
@@ -49,6 +49,8 @@
#include <signal.h>
#include <string.h>
#include <stdlib.h>
+#include <limits.h>
+#include <errno.h>
=20
#include "bt_misc.h"
#include "bt_vendor.h"
@@ -74,6 +76,7 @@
static void unknown_init_hw(int bt_cfd, int phys_fd, const char *speedstr);
=20
static void csr_change_if(int bt_cfd, int phys_fd, const char *speedstr);
+static int csr_set_max_power(int bt_cfd, short max_power);
=20
void
init_phys(int fd)
@@ -155,7 +158,20 @@
}
}
=20
+int
+bt_set_max_power(int bt_cfd, short max_power)
+{
+ switch (hw_vendor())
+ {
+ case HW_CSR:
+ return csr_set_max_power(bt_cfd, max_power);
=20
+ default:
+ errno =3D EPERM;
+ return -1;
+ }
+}
+
/*=20
* This function tries to recover stack if init failed=20
* For now all other vendors but CSR is left to restart=20
@@ -235,13 +251,14 @@
/* CSR specific commands */
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
+#define PSKEY_LC_MAX_TX_POWER 0x0017
#define PSKEY_HOSTIO_UART_PS_BLOCK 0x0191
#define PSKEY_HOST_INTERFACE 0x01f9
#define PSKEY_UART_SLEEP_TIMEOUT 0x0222
+
#define CSR_PSKEY_GETREQ 0x0
#define CSR_PSKEY_SETREQ 0x2
=20
-
/* Set the phys device to CSR default, 115200 */=20
void
csr_init_phys(int fd)
@@ -505,6 +522,29 @@
syslog(LOG_INFO, "Did not set baudrate in CSR module as its firmware=
is too old (%d)", firmware);
}
}
+}
+
+int
+csr_set_max_power(int bt_cfd, short max_power)
+{
+ short old_max_power =3D SHRT_MAX;
+
+ /* We need to wait a little here for some reason, or the reading of the
+ current maximum power may fail and return 0 */
+ usleep(50000);
+
+ csr_pskey(bt_cfd, PSKEY_LC_MAX_TX_POWER, CSR_PSKEY_GETREQ, (unsigned sho=
rt *)&old_max_power, 1);
+
+ if (old_max_power !=3D max_power)
+ {
+ csr_pskey(bt_cfd, PSKEY_LC_MAX_TX_POWER, CSR_PSKEY_SETREQ, (unsigned s=
hort *)&max_power, 1);
+ if (restart_btd() < 0)
+ {
+ syslog(LOG_INFO, "Failed to restart btd");
+ }
+ }
+
+ return 0;
}
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
--- bt_vendor.h 2001/10/03 17:46:40 1.10
+++ bt_vendor.h 2001/10/10 16:22:10 1.11
@@ -68,6 +68,8 @@
void init_phys(int fd);
void init_failed(int bt_cfd, int phys_fd, const char *speedstr);
=20
+int bt_set_max_power(int bt_cfd, short max_power);
+
int hw_vendor(void);
=20
void csr_bcsp_to_h4(int bt_cfd, int phys_fd, const char *speedstr);
--- btconfig.c 2001/09/10 12:01:18 1.7
+++ btconfig.c 2001/10/10 16:22:10 1.8
@@ -61,6 +61,7 @@
#include "bt_if.h"
#include "bt_conf.h"
#include "bt_misc.h"
+#include "bt_vendor.h"
=20=20=20=20=20
/****************** CONSTANT AND MACRO SECTION ***************************=
***/
=20
@@ -107,6 +108,7 @@
static int var_force_ms_switch =3D -1; /* not yet set */
static int var_set_local_name =3D 0;
static int var_max_connections =3D -1; /* not yet set */
+static short var_max_power =3D SHRT_MAX; /* not yet set */
=20
/* long option list */
static struct option long_options[] =3D
@@ -204,7 +206,8 @@
if (var_set_local_name ||
var_write_scan_enable >=3D 0 ||
var_force_ms_switch >=3D 0 ||
- var_max_connections >=3D 0)
+ var_max_connections >=3D 0 ||
+ var_max_power !=3D SHRT_MAX)
{
/* Open BT ctrl device */=20=20
if ((bt_cfd =3D bt_openctrl()) < 0)
@@ -233,6 +236,9 @@
if (var_max_connections >=3D 0)
bt_set_max_conections(bt_cfd, var_max_connections);
=20
+ if (var_max_power !=3D SHRT_MAX)
+ bt_set_max_power(bt_cfd, var_max_power);
+=20=20=20=20
close(bt_cfd);
}
=20
@@ -452,6 +458,11 @@
{=20
var_max_connections =3D atoi(value);
D(syslog(LOG_INFO, __FUNCTION__ ": Maximum BT connections: %s", value)=
);
+ }
+ else if (!strcasecmp(field, "MaxPower"))
+ {=20
+ var_max_power =3D atoi(value);
+ D(syslog(LOG_INFO, __FUNCTION__ ": Maximum power: %s", value));
}
=20=20=20
return TRUE;
|