* Re: [PATCH 0/3] mgmt: read supported codecs
From: Kim Schulz @ 2012-11-23 10:10 UTC (permalink / raw)
To: Michael Knudsen; +Cc: linux-bluetooth, Michael Knudsen
In-Reply-To: <1353588468-28711-1-git-send-email-m.knudsen@samsung.com>
Den 2012-11-22 13:47, Michael Knudsen skrev:
> This implements the user space side of the read codecs command.
>
> Michael Knudsen (3):
> Bluetooth: Add HCI Coding Format definitions
> Bluetooth: Support the read codecs operation
> Doco: List the read codecs operation
>
> doc/mgmt-api.txt | 20 +++++++++++++++
> lib/hci.h | 9 +++++++
> lib/mgmt.h | 8 ++++++
> tools/btmgmt.c | 74
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 111 insertions(+)
Looks like the codein these patches have some indentation problems
(mixes tab and spaces).
--
Kim Schulz
^ permalink raw reply
* [PATCH 4/4] sdpd-request: Fix build errors due to unaligned memory access
From: Szymon Janc @ 2012-11-23 10:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353665354-32178-1-git-send-email-szymon.janc@tieto.com>
This fix following compilation errors on ARM.
CC src/bluetoothd-sdpd-request.o
src/sdpd-request.c: In function ‘extract_des’:
src/sdpd-request.c:186:17: error: cast increases required alignment of
target type [-Werror=cast-align]
src/sdpd-request.c:186:17: error: cast increases required alignment of
target type [-Werror=cast-align]
src/sdpd-request.c:210:17: error: cast increases required alignment of
target type [-Werror=cast-align]
src/sdpd-request.c:210:17: error: cast increases required alignment of
target type [-Werror=cast-align]
cc1: all warnings being treated as errors
make[1]: *** [src/bluetoothd-sdpd-request.o] Error 1
---
src/sdpd-request.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index 2af743e..a79efc7 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -182,8 +182,12 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
aid->uint16 = bt_get_be16(p);
pElem = (char *) aid;
} else {
+ uint16_t tmp;
+
+ memcpy(&tmp, p, sizeof(tmp));
+
pElem = malloc(sizeof(uint16_t));
- bt_put_be16(bt_get_unaligned((uint16_t *)p), pElem);
+ bt_put_be16(tmp, pElem);
}
p += sizeof(uint16_t);
seqlen += sizeof(uint16_t);
@@ -206,8 +210,12 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
pElem = (char *) aid;
} else {
+ uint32_t tmp;
+
+ memcpy(&tmp, p, sizeof(tmp));
+
pElem = malloc(sizeof(uint32_t));
- bt_put_be32(bt_get_unaligned((uint32_t *)p), pElem);
+ bt_put_be32(tmp, pElem);
}
p += sizeof(uint32_t);
seqlen += sizeof(uint32_t);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/4] monitor: Fix build errors due to unaligned memory access
From: Szymon Janc @ 2012-11-23 10:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353665354-32178-1-git-send-email-szymon.janc@tieto.com>
This fix following compilation errors on ARM.
CC monitor/hcidump.o
monitor/hcidump.c: In function ‘device_callback’:
monitor/hcidump.c:147:11: error: cast increases required alignment of
target type [-Werror=cast-align]
monitor/hcidump.c:150:10: error: cast increases required alignment of
target type [-Werror=cast-align]
monitor/hcidump.c: In function ‘stack_internal_callback’:
monitor/hcidump.c:348:9: error: cast increases required alignment of
target type [-Werror=cast-align]
cc1: all warnings being treated as errors
make[1]: *** [monitor/hcidump.o] Error 1
CC monitor/control.o
monitor/control.c: In function ‘data_callback’:
monitor/control.c:584:10: error: cast increases required alignment of
target type [-Werror=cast-align]
cc1: all warnings being treated as errors
make[1]: *** [monitor/control.o] Error 1
---
monitor/control.c | 7 +++++--
monitor/hcidump.c | 18 +++++++++++-------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/monitor/control.c b/monitor/control.c
index 3447b7a..9b76038 100644
--- a/monitor/control.c
+++ b/monitor/control.c
@@ -565,6 +565,7 @@ static void data_callback(int fd, uint32_t events, void *user_data)
while (1) {
struct cmsghdr *cmsg;
struct timeval *tv = NULL;
+ struct timeval ctv;
uint16_t opcode, index, pktlen;
ssize_t len;
@@ -580,8 +581,10 @@ static void data_callback(int fd, uint32_t events, void *user_data)
if (cmsg->cmsg_level != SOL_SOCKET)
continue;
- if (cmsg->cmsg_type == SCM_TIMESTAMP)
- tv = (struct timeval *) CMSG_DATA(cmsg);
+ if (cmsg->cmsg_type == SCM_TIMESTAMP) {
+ memcpy(&ctv, CMSG_DATA(cmsg), sizeof(ctv));
+ tv = &ctv;
+ }
}
opcode = btohs(hdr.opcode);
diff --git a/monitor/hcidump.c b/monitor/hcidump.c
index e69bcb1..9881bb3 100644
--- a/monitor/hcidump.c
+++ b/monitor/hcidump.c
@@ -130,7 +130,8 @@ static void device_callback(int fd, uint32_t events, void *user_data)
while (1) {
struct cmsghdr *cmsg;
struct timeval *tv = NULL;
- int *dir = NULL;
+ struct timeval ctv;
+ int dir = -1;
ssize_t len;
len = recvmsg(fd, &msg, MSG_DONTWAIT);
@@ -144,15 +145,16 @@ static void device_callback(int fd, uint32_t events, void *user_data)
switch (cmsg->cmsg_type) {
case HCI_DATA_DIR:
- dir = (int *) CMSG_DATA(cmsg);
+ memcpy(&dir, CMSG_DATA(cmsg), sizeof(dir));
break;
case HCI_CMSG_TSTAMP:
- tv = (struct timeval *) CMSG_DATA(cmsg);
+ memcpy(&ctv, CMSG_DATA(cmsg), sizeof(ctv));
+ tv = &ctv;
break;
}
}
- if (!dir || len < 1)
+ if (dir < 0 || len < 1)
continue;
switch (buf[0]) {
@@ -163,11 +165,11 @@ static void device_callback(int fd, uint32_t events, void *user_data)
packet_hci_event(tv, data->index, buf + 1, len - 1);
break;
case HCI_ACLDATA_PKT:
- packet_hci_acldata(tv, data->index, !!(*dir),
+ packet_hci_acldata(tv, data->index, !!dir,
buf + 1, len - 1);
break;
case HCI_SCODATA_PKT:
- packet_hci_scodata(tv, data->index, !!(*dir),
+ packet_hci_scodata(tv, data->index, !!dir,
buf + 1, len - 1);
break;
}
@@ -314,6 +316,7 @@ static void stack_internal_callback(int fd, uint32_t events, void *user_data)
evt_stack_internal *si;
evt_si_device *sd;
struct timeval *tv = NULL;
+ struct timeval ctv;
uint8_t type = 0xff, bus = 0xff;
char str[18], name[8] = "";
bdaddr_t bdaddr;
@@ -345,7 +348,8 @@ static void stack_internal_callback(int fd, uint32_t events, void *user_data)
switch (cmsg->cmsg_type) {
case HCI_CMSG_TSTAMP:
- tv = (struct timeval *) CMSG_DATA(cmsg);
+ memcpy(&ctv, CMSG_DATA(cmsg), sizeof(ctv));
+ tv = &ctv;
break;
}
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/4] sdp: Fix build errors due to unaligned memory access
From: Szymon Janc @ 2012-11-23 10:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1353665354-32178-1-git-send-email-szymon.janc@tieto.com>
This fix following compilation errors on ARM.
CC lib/sdp.lo
lib/sdp.c: In function 'sdp_device_record_unregister_binary':
lib/sdp.c:2984:11: error: cast increases required alignment of
target type [-Werror=cast-align]
lib/sdp.c:2984:11: error: cast increases required alignment of
target type [-Werror=cast-align]
lib/sdp.c: In function 'sdp_device_record_update':
lib/sdp.c:3089:11: error: cast increases required alignment of
target type [-Werror=cast-align]
lib/sdp.c:3089:11: error: cast increases required alignment of
target type [-Werror=cast-align]
lib/sdp.c: In function 'sdp_process':
lib/sdp.c:4139:22: error: cast increases required alignment of
target type [-Werror=cast-align]
lib/sdp.c:4146:14: error: cast increases required alignment of
target type [-Werror=cast-align]
lib/sdp.c:4146:14: error: cast increases required alignment of
target type [-Werror=cast-align]
cc1: all warnings being treated as errors
make[1]: *** [lib/sdp.lo] Error 1
---
lib/sdp.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/sdp.c b/lib/sdp.c
index ceb1192..4e070b5 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -2981,7 +2981,6 @@ int sdp_device_record_unregister_binary(sdp_session_t *session, bdaddr_t *device
rsphdr = (sdp_pdu_hdr_t *) rspbuf;
p = rspbuf + sizeof(sdp_pdu_hdr_t);
- status = bt_get_unaligned((uint16_t *) p);
if (rsphdr->pdu_id == SDP_ERROR_RSP) {
/* For this case the status always is invalid record handle */
@@ -2990,6 +2989,12 @@ int sdp_device_record_unregister_binary(sdp_session_t *session, bdaddr_t *device
} else if (rsphdr->pdu_id != SDP_SVC_REMOVE_RSP) {
errno = EPROTO;
status = -1;
+ } else {
+ uint16_t tmp;
+
+ memcpy(&tmp, p, sizeof(tmp));
+
+ status = tmp;
}
end:
free(reqbuf);
@@ -3086,7 +3091,6 @@ int sdp_device_record_update(sdp_session_t *session, bdaddr_t *device, const sdp
rsphdr = (sdp_pdu_hdr_t *) rspbuf;
p = rspbuf + sizeof(sdp_pdu_hdr_t);
- status = bt_get_unaligned((uint16_t *) p);
if (rsphdr->pdu_id == SDP_ERROR_RSP) {
/* The status can be invalid sintax or invalid record handle */
@@ -3095,6 +3099,12 @@ int sdp_device_record_update(sdp_session_t *session, bdaddr_t *device, const sdp
} else if (rsphdr->pdu_id != SDP_SVC_UPDATE_RSP) {
errno = EPROTO;
status = -1;
+ } else {
+ uint16_t tmp;
+
+ memcpy(&tmp, p, sizeof(tmp));
+
+ status = tmp;
}
end:
free(reqbuf);
@@ -4136,14 +4146,18 @@ int sdp_process(sdp_session_t *session)
rsp_count = sizeof(tsrc) + sizeof(csrc) + csrc * 4;
} else {
/* point to the first csrc */
- uint16_t *pcsrc = (uint16_t *) (t->rsp_concat_buf.data + 2);
+ uint8_t *pcsrc = t->rsp_concat_buf.data + 2;
+ uint16_t tcsrc, tcsrc2;
/* FIXME: update the interface later. csrc doesn't need be passed to clients */
pdata += sizeof(uint16_t); /* point to csrc */
/* the first csrc contains the sum of partial csrc responses */
- *pcsrc += bt_get_unaligned((uint16_t *) pdata);
+ memcpy(&tcsrc, pcsrc, sizeof(tcsrc));
+ memcpy(&tcsrc2, pdata, sizeof(tcsrc2));
+ tcsrc += tcsrc2;
+ memcpy(pcsrc, &tcsrc, sizeof(tcsrc));
pdata += sizeof(uint16_t); /* point to the first handle */
rsp_count = csrc * 4;
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/4] sap-u8500: Fix build errors due to unaligned memory access
From: Szymon Janc @ 2012-11-23 10:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This fix following compilation error on ARM.
CC profiles/sap/sap-u8500.o
profiles/sap/sap-u8500.c: In function recv_card_status:
profiles/sap/sap-u8500.c:323:16: error: cast increases required
alignment of target type [-Werror=cast-align]
profiles/sap/sap-u8500.c: In function recv_response:
profiles/sap/sap-u8500.c:423:12: error: cast increases required
alignment of target type [-Werror=cast-align]
cc1: all warnings being treated as errors
---
profiles/sap/sap-u8500.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/profiles/sap/sap-u8500.c b/profiles/sap/sap-u8500.c
index f07209d..b1aee57 100644
--- a/profiles/sap/sap-u8500.c
+++ b/profiles/sap/sap-u8500.c
@@ -313,16 +313,16 @@ static void recv_status(uint32_t status)
static void recv_card_status(uint32_t status, uint8_t *param)
{
- uint32_t *card_status;
+ uint32_t card_status;
uint8_t result;
uint8_t iccrs;
if (status != STE_STATUS_OK)
return;
- card_status = (uint32_t *)param;
+ memcpy(&card_status, param, sizeof(card_status));
- if (get_sap_reader_status(*card_status, &iccrs) < 0)
+ if (get_sap_reader_status(card_status, &iccrs) < 0)
result = SAP_RESULT_ERROR_NO_REASON;
else
result = get_sap_result(STE_GET_STATUS_MSG, status);
@@ -420,7 +420,7 @@ static void recv_response(struct ste_message *msg)
}
param = msg->payload;
- status = *(uint32_t *)param;
+ memcpy(&status, param, sizeof(status));
param += sizeof(status);
SAP_VDBG("status 0x%x", status);
--
1.7.9.5
^ permalink raw reply related
* Re: Query regarding device discovery
From: Luiz Augusto von Dentz @ 2012-11-23 9:54 UTC (permalink / raw)
To: Jaganath; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <2254742.168381353662862601.JavaMail.weblogic@epml01>
Hi,
On Fri, Nov 23, 2012 at 11:27 AM, JAGANATH KANAKKASSERY
<jaganath.k@samsung.com> wrote:
> Hello,
>
> I have a doubt with current discovery mechanism.
>
> Suppose application 1 calls "StartDiscovery". for which "Discovering = TRUE" comes
> and then deviceFound signals starts coming.
> In the mean time application 2 calls "StartDiscovery" which will be queued in BlueZ.
> Then "discovering = FALSE" comes for the discovery initiated from application 1.
> Then as per BlueZ design, it will restart discovery for application 1 since it has not
> called "StopDiscovery" yet. So "discovering = TRUE" comes again, which application 2
> thinks that it belongs to him.
> Then if application 1 calls "StopDiscovery" immediately, discovery will be stopped
> and "Discovering = FALSE" comes with which application 2 too thinks that discovery
> initiated by him is also done.
> So eventually application 2 will not get any devices.
> So I think with current design, applications that are interested only in one complete
> inquiry session will be in trouble.
>
> So can we disable the automatic reinitiating of device discovery?
> Or is there any way to handle this scenario?
StartDiscovery doesn't queue the sessions, it actually increase the
reference to the same discovery session which became shared between
the callers, it should not interfere with the ongoing discovery nor
change how we emit Discovering. That being said the concept of one
shot inquiry is flawed since it can miss devices, with addition of LE
this is even more visible because each inquiry is only 5.12 sec., you
can still detect when an inquiry is active just check when Discovering
is TRUE and nope it should not matter if there is 1 or 20 application
listening to it once Discovery switch to TRUE we are inquiring/scan
when it switch to FALSE it has stopped and is probably doing name
resolving.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Query regarding device discovery
From: JAGANATH KANAKKASSERY @ 2012-11-23 9:27 UTC (permalink / raw)
To: linux-bluetooth
SGVsbG8sIA0KIA0KSSBoYXZlIGEgZG91YnQgd2l0aCBjdXJyZW50IGRpc2NvdmVyeSBtZWNoYW5p
c20uIA0KIA0KU3VwcG9zZSBhcHBsaWNhdGlvbiAxIGNhbGxzICJTdGFydERpc2NvdmVyeSIuIGZv
ciB3aGljaCAiRGlzY292ZXJpbmcgPSBUUlVFIiBjb21lcw0KYW5kIHRoZW4gZGV2aWNlRm91bmQg
c2lnbmFscyBzdGFydHMgY29taW5nLg0KSW4gdGhlIG1lYW4gdGltZSBhcHBsaWNhdGlvbiAyIGNh
bGxzICJTdGFydERpc2NvdmVyeSIgd2hpY2ggd2lsbCBiZSBxdWV1ZWQgaW4gQmx1ZVouDQpUaGVu
ICJkaXNjb3ZlcmluZyA9IEZBTFNFIiBjb21lcyBmb3IgdGhlIGRpc2NvdmVyeSBpbml0aWF0ZWQg
ZnJvbSBhcHBsaWNhdGlvbiAxLg0KVGhlbiBhcyBwZXIgQmx1ZVogZGVzaWduLCBpdCB3aWxsIHJl
c3RhcnQgZGlzY292ZXJ5IGZvciBhcHBsaWNhdGlvbiAxIHNpbmNlIGl0IGhhcyBub3QNCmNhbGxl
ZCAiU3RvcERpc2NvdmVyeSIgeWV0LiBTbyAiZGlzY292ZXJpbmcgPSBUUlVFIiBjb21lcyBhZ2Fp
biwgd2hpY2ggYXBwbGljYXRpb24gMg0KdGhpbmtzIHRoYXQgaXQgYmVsb25ncyB0byBoaW0uIA0K
VGhlbiBpZiBhcHBsaWNhdGlvbiAxIGNhbGxzICJTdG9wRGlzY292ZXJ5IiBpbW1lZGlhdGVseSwg
ZGlzY292ZXJ5IHdpbGwgYmUgc3RvcHBlZA0KYW5kICJEaXNjb3ZlcmluZyA9IEZBTFNFIiBjb21l
cyB3aXRoIHdoaWNoIGFwcGxpY2F0aW9uIDIgdG9vIHRoaW5rcyB0aGF0IGRpc2NvdmVyeQ0KaW5p
dGlhdGVkIGJ5IGhpbSBpcyBhbHNvIGRvbmUuDQpTbyBldmVudHVhbGx5IGFwcGxpY2F0aW9uIDIg
d2lsbCBub3QgZ2V0IGFueSBkZXZpY2VzLg0KU28gSSB0aGluayB3aXRoIGN1cnJlbnQgZGVzaWdu
LCBhcHBsaWNhdGlvbnMgdGhhdCBhcmUgaW50ZXJlc3RlZCBvbmx5IGluIG9uZSBjb21wbGV0ZQ0K
aW5xdWlyeSBzZXNzaW9uIHdpbGwgYmUgaW4gdHJvdWJsZS4gDQogDQpTbyBjYW4gd2UgZGlzYWJs
ZSB0aGUgYXV0b21hdGljIHJlaW5pdGlhdGluZyBvZiBkZXZpY2UgZGlzY292ZXJ5Pw0KT3IgaXMg
dGhlcmUgYW55IHdheSB0byBoYW5kbGUgdGhpcyBzY2VuYXJpbz8gDQogDQpUaGFua3MsDQpKYWdh
bmF0aA==
^ permalink raw reply
* [PATCH 3/3] Doco: List the read codecs operation
From: Michael Knudsen @ 2012-11-22 12:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michael Knudsen
In-Reply-To: <1353588468-28711-1-git-send-email-m.knudsen@samsung.com>
---
doc/mgmt-api.txt | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 202c055..42af2d6 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -847,6 +847,26 @@ Set Device ID Command
a Command Status event on failure.
+Read Codecs Command
+====================
+
+ Command Code: 0x0029
+ Controller Index: <controller id>
+ Command Parameters:
+ Return Parameters:
+ Num_Of_Codecs (1 Octet)
+ Codec1 (1 Octet)
+ Codec2 (1 Octet)
+ ...
+
+ This command is used to read out the list of codecs that are
+ supported by the given controller.
+
+ This command generates a Command Complete event on success
+ or failure.
+
+
+
Command Complete Event
======================
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/3] Bluetooth: Support the read codecs operation
From: Michael Knudsen @ 2012-11-22 12:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michael Knudsen
In-Reply-To: <1353588468-28711-1-git-send-email-m.knudsen@samsung.com>
---
lib/mgmt.h | 8 ++++++
tools/btmgmt.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 6c7e44a..37b002c 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -318,6 +318,13 @@ struct mgmt_cp_set_device_id {
uint16_t version;
} __packed;
+#define MGMT_OP_READ_CODECS 0x0029
+struct mgmt_rp_read_codecs {
+ uint8_t count;
+ uint8_t codec[0];
+} __packed;
+
+
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
uint16_t opcode;
@@ -496,6 +503,7 @@ static const char *mgmt_op[] = {
"Block Device",
"Unblock Device",
"Set Device ID",
+ "Read Codecs",
};
static const char *mgmt_ev[] = {
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index ff6a46a..857c3a8 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -993,6 +993,79 @@ static void cmd_info(int mgmt_sk, uint16_t index, int argc, char **argv)
}
}
+struct codecs_map {
+ int codec;
+ char *name;
+} codecs_map[] = {
+ { HCI_FORMAT_ULAW, "uLAW" },
+ { HCI_FORMAT_ALAW, "aLAW" },
+ { HCI_FORMAT_CVSD, "CVSD" },
+ { HCI_FORMAT_TRANSPARENT, "transparent" },
+ { HCI_FORMAT_PCM, "PCM" },
+ { HCI_FORMAT_MSBC, "mSBC" },
+ { HCI_FORMAT_VENDOR, "vendor" },
+ { -1 },
+};
+
+static void codecs_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status,
+ void *rsp, uint16_t len, void *user_data)
+{
+ struct mgmt_rp_read_codecs *rp = rsp;
+ char addr[18];
+ int i, count;
+
+ if (status != 0) {
+ fprintf(stderr,
+ "Reading hci%u info failed with status 0x%02x (%s)\n",
+ id, status, mgmt_errstr(status));
+ exit(EXIT_FAILURE);
+ }
+
+ if (len < sizeof(*rp)) {
+ fprintf(stderr, "Too small codecs reply (%u bytes)\n", len);
+ exit(EXIT_FAILURE);
+ }
+
+ count = rp->count;
+
+ printf("hci%u:\tnumber of codecs: %u\n", id, count);
+
+ for (i = 0; i < count; i++) {
+ int entry;
+ struct codecs_map *p;
+
+ entry = rp->codec[i];
+
+ p = codecs_map;
+
+ while (p->codec != -1) {
+ if (entry == p->codec)
+ break;
+ else
+ p++;
+ }
+
+ if (p->codec != -1)
+ printf("\t%s (0x%x)\n", p->name, p->codec);
+ else
+ printf("\tunknown (0x%x)\n", p->codec);
+ }
+
+ exit(EXIT_SUCCESS);
+}
+
+static void cmd_codecs(int mgmt_sk, uint16_t index, int argc, char **argv)
+{
+ if (index == MGMT_INDEX_NONE)
+ index = 0;
+
+ if (mgmt_send_cmd(mgmt_sk, MGMT_OP_READ_CODECS, index, NULL,
+ 0, codecs_rsp, NULL) < 0) {
+ fprintf(stderr, "Unable to send read_info cmd\n");
+ exit(EXIT_FAILURE);
+ }
+}
+
static void setting_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status,
void *rsp, uint16_t len, void *user_data)
{
@@ -1824,6 +1897,7 @@ static struct {
{ "version", cmd_version, "Get the MGMT Version" },
{ "commands", cmd_commands, "List supported commands" },
{ "info", cmd_info, "Show controller info" },
+ { "codecs", cmd_codecs, "List supported codecs" },
{ "power", cmd_power, "Toggle powered state" },
{ "discov", cmd_discov, "Toggle discoverable state" },
{ "connectable",cmd_connectable,"Toggle connectable state" },
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/3] Bluetooth: Add HCI Coding Format definitions
From: Michael Knudsen @ 2012-11-22 12:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michael Knudsen
In-Reply-To: <1353588468-28711-1-git-send-email-m.knudsen@samsung.com>
---
lib/hci.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lib/hci.h b/lib/hci.h
index 2f18ec8..5e5f6b5 100644
--- a/lib/hci.h
+++ b/lib/hci.h
@@ -295,6 +295,15 @@ enum {
#define HCI_LM_RELIABLE 0x0010
#define HCI_LM_SECURE 0x0020
+/* Coding Format */
+#define HCI_FORMAT_ULAW 0x00
+#define HCI_FORMAT_ALAW 0x01
+#define HCI_FORMAT_CVSD 0x02
+#define HCI_FORMAT_TRANSPARENT 0x03
+#define HCI_FORMAT_PCM 0x04
+#define HCI_FORMAT_MSBC 0x05
+#define HCI_FORMAT_VENDOR 0xff
+
/* Link Key types */
#define HCI_LK_COMBINATION 0x00
#define HCI_LK_LOCAL_UNIT 0x01
--
1.7.9.5
^ permalink raw reply related
* [PATCH 0/3] mgmt: read supported codecs
From: Michael Knudsen @ 2012-11-22 12:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michael Knudsen
This implements the user space side of the read codecs command.
Michael Knudsen (3):
Bluetooth: Add HCI Coding Format definitions
Bluetooth: Support the read codecs operation
Doco: List the read codecs operation
doc/mgmt-api.txt | 20 +++++++++++++++
lib/hci.h | 9 +++++++
lib/mgmt.h | 8 ++++++
tools/btmgmt.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 111 insertions(+)
--
1.7.9.5
^ permalink raw reply
* [RFC 3/3] Bluetooth: Provide mgmt API for reading list of supported codecs
From: Michael Knudsen @ 2012-11-22 12:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michael Knudsen
In-Reply-To: <1353585909-28400-1-git-send-email-m.knudsen@samsung.com>
Provide an API for allowing user space to read the list of codecs
supported by a given controller. For now, hardwire PCM support,
but construct initial list of supported codecs by inspecting the
relevant bits of the local supported features bit mask. Later,
devices that support the appropriate HCI command will read out the
actual list during controller initialisation.
---
include/net/bluetooth/hci_core.h | 2 ++
include/net/bluetooth/mgmt.h | 7 +++++++
net/bluetooth/hci_core.c | 3 +++
net/bluetooth/hci_event.c | 21 +++++++++++++++++++++
net/bluetooth/mgmt.c | 36 ++++++++++++++++++++++++++++++++++++
5 files changed, 69 insertions(+)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ef5b85d..79fe128 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -153,6 +153,8 @@ struct hci_dev {
__u8 features[8];
__u8 host_features[8];
__u8 commands[64];
+ __u8 codecs;
+ __u8 codec[255];
__u8 hci_ver;
__u16 hci_rev;
__u8 lmp_ver;
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 22980a7..523dc58 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -350,6 +350,13 @@ struct mgmt_cp_set_device_id {
} __packed;
#define MGMT_SET_DEVICE_ID_SIZE 8
+#define MGMT_OP_READ_CODECS 0x0029
+#define MGMT_READ_CODECS_SIZE 0
+struct mgmt_rp_read_codecs {
+ __u8 count;
+ __u8 codec[0];
+} __packed;
+
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
__le16 opcode;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 81f4bac..9b0e974 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1708,6 +1708,9 @@ struct hci_dev *hci_alloc_dev(void)
hdev->sniff_max_interval = 800;
hdev->sniff_min_interval = 80;
+ hdev->codecs = 1;
+ hdev->codec[0] = HCI_FORMAT_PCM;
+
mutex_init(&hdev->lock);
mutex_init(&hdev->req_lock);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 9f5c5f2..b110aaf 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -779,6 +779,27 @@ static void hci_cc_read_local_features(struct hci_dev *hdev,
if (hdev->features[5] & LMP_EDR_3S_ESCO)
hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5);
+ /* Initialise codec list */
+ if (hdev->features[1] & LMP_ULAW) {
+ hdev->codec[hdev->codecs] = HCI_FORMAT_ULAW;
+ hdev->codecs++;
+ }
+
+ if (hdev->features[1] & LMP_ALAW) {
+ hdev->codec[hdev->codecs] = HCI_FORMAT_ALAW;
+ hdev->codecs++;
+ }
+
+ if (hdev->features[2] & LMP_CVSD) {
+ hdev->codec[hdev->codecs] = HCI_FORMAT_CVSD;
+ hdev->codecs++;
+ }
+
+ if (hdev->features[2] & LMP_TRSP_SCO) {
+ hdev->codec[hdev->codecs] = HCI_FORMAT_TRANSPARENT;
+ hdev->codecs++;
+ }
+
BT_DBG("%s features 0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", hdev->name,
hdev->features[0], hdev->features[1],
hdev->features[2], hdev->features[3],
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index dedbb1d..a47fda2 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -76,6 +76,7 @@ static const u16 mgmt_commands[] = {
MGMT_OP_BLOCK_DEVICE,
MGMT_OP_UNBLOCK_DEVICE,
MGMT_OP_SET_DEVICE_ID,
+ MGMT_OP_READ_CODECS,
};
static const u16 mgmt_events[] = {
@@ -319,6 +320,40 @@ static int read_commands(struct sock *sk, struct hci_dev *hdev, void *data,
return err;
}
+static int read_codecs(struct sock *sk, struct hci_dev *hdev, void *data,
+ u16 len)
+{
+ struct mgmt_rp_read_codecs *rp;
+ int err;
+ size_t rp_size;
+
+ BT_DBG("sock %p %s", sk, hdev->name);
+
+ hci_dev_lock(hdev);
+
+ rp_size = sizeof(*rp) + hdev->codecs;
+
+ rp = kmalloc(rp_size, GFP_KERNEL);
+ if (!rp) {
+ hci_dev_unlock(hdev);
+ return -ENOMEM;
+ }
+
+ memset(rp, 0, sizeof(rp));
+
+ rp->count = hdev->codecs;
+ memcpy(rp->codec, hdev->codec, hdev->codecs);
+
+ hci_dev_unlock(hdev);
+
+ err = cmd_complete(sk, hdev->id, MGMT_OP_READ_CODECS, 0, rp,
+ rp_size);
+
+ kfree(rp);
+
+ return err;
+}
+
static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
u16 data_len)
{
@@ -2748,6 +2783,7 @@ static const struct mgmt_handler {
{ block_device, false, MGMT_BLOCK_DEVICE_SIZE },
{ unblock_device, false, MGMT_UNBLOCK_DEVICE_SIZE },
{ set_device_id, false, MGMT_SET_DEVICE_ID_SIZE },
+ { read_codecs, true, MGMT_READ_CODECS_SIZE },
};
--
1.7.9.5
^ permalink raw reply related
* [RFC 2/3] Bluetooth: Add HCI Coding Format definitions
From: Michael Knudsen @ 2012-11-22 12:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michael Knudsen
In-Reply-To: <1353585909-28400-1-git-send-email-m.knudsen@samsung.com>
Add definitions for the codecs specified in CSA2.
---
include/net/bluetooth/hci.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 45ec1de..60505da 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -284,6 +284,15 @@ enum {
#define HCI_LM_RELIABLE 0x0010
#define HCI_LM_SECURE 0x0020
+/* Coding Format */
+#define HCI_FORMAT_ULAW 0x00
+#define HCI_FORMAT_ALAW 0x01
+#define HCI_FORMAT_CVSD 0x02
+#define HCI_FORMAT_TRANSPARENT 0x03
+#define HCI_FORMAT_PCM 0x04
+#define HCI_FORMAT_MSBC 0x05
+#define HCI_FORMAT_VENDOR 0xff
+
/* Authentication types */
#define HCI_AT_NO_BONDING 0x00
#define HCI_AT_NO_BONDING_MITM 0x01
--
1.7.9.5
^ permalink raw reply related
* [RFC 1/3] Bluetooth: Add HCI feature bit definition for transparent SCO
From: Michael Knudsen @ 2012-11-22 12:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michael Knudsen
In-Reply-To: <1353585909-28400-1-git-send-email-m.knudsen@samsung.com>
---
include/net/bluetooth/hci.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 45eee08..45ec1de 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -233,6 +233,7 @@ enum {
#define LMP_CVSD 0x01
#define LMP_PSCHEME 0x02
#define LMP_PCONTROL 0x04
+#define LMP_TRSP_SCO 0x08
#define LMP_RSSI_INQ 0x40
#define LMP_ESCO 0x80
--
1.7.9.5
^ permalink raw reply related
* [RFC 0/3] Bluetooth: mgmt API for reading supported codecs
From: Michael Knudsen @ 2012-11-22 12:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michael Knudsen
This adds a mgmt API for reading out the list of codecs supported by a
given controller. PCM is hardwired as it is always supported. Other
codecs are added once the supported features bits are read out from
the chip. Later, on devices with support for it, the appropriate HCI
command is used to read out the list of codecs for which there are no
HCI feature bits defined (e.g. mSBC).
Michael Knudsen (3):
Bluetooth: Add HCI feature bit definition for transparent SCO
Bluetooth: Add HCI Coding Format definitions
Bluetooth: Provide mgmt API for reading list of supported codecs
include/net/bluetooth/hci.h | 10 ++++++++++
include/net/bluetooth/hci_core.h | 2 ++
include/net/bluetooth/mgmt.h | 7 +++++++
net/bluetooth/hci_core.c | 3 +++
net/bluetooth/hci_event.c | 21 +++++++++++++++++++++
net/bluetooth/mgmt.c | 36 ++++++++++++++++++++++++++++++++++++
6 files changed, 79 insertions(+)
--
1.7.9.5
^ permalink raw reply
* Re: [PATCH BlueZ v2] hciconfig: Add an option to set which advertise type will be on
From: Johan Hedberg @ 2012-11-22 8:15 UTC (permalink / raw)
To: Jefferson Delfes; +Cc: linux-bluetooth
In-Reply-To: <1353528971-17861-1-git-send-email-jefferson.delfes@openbossa.org>
Hi Jefferson,
On Wed, Nov 21, 2012, Jefferson Delfes wrote:
> There are some advertise types that can be used, so we need a way to
> tell which one we want. The default one is ADV_IND.
> ---
> tools/hciconfig.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 69 insertions(+), 6 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* [PATCH BlueZ v2] hciconfig: Add an option to set which advertise type will be on
From: Jefferson Delfes @ 2012-11-21 20:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jefferson Delfes
In-Reply-To: <1353506992-3371-1-git-send-email-jefferson.delfes@openbossa.org>
There are some advertise types that can be used, so we need a way to
tell which one we want. The default one is ADV_IND.
---
tools/hciconfig.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 69 insertions(+), 6 deletions(-)
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 64f2650..99d15c2 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -242,6 +242,71 @@ static void cmd_le_adv(int ctl, int hdev, char *opt)
{
struct hci_request rq;
le_set_advertise_enable_cp advertise_cp;
+ le_set_advertising_parameters_cp adv_params_cp;
+ uint8_t status;
+ int dd, ret;
+
+ if (hdev < 0)
+ hdev = hci_get_route(NULL);
+
+ dd = hci_open_dev(hdev);
+ if (dd < 0) {
+ perror("Could not open device");
+ exit(1);
+ }
+
+ memset(&adv_params_cp, 0, sizeof(adv_params_cp));
+ adv_params_cp.min_interval = htobs(0x0800);
+ adv_params_cp.max_interval = htobs(0x0800);
+ if (opt)
+ adv_params_cp.advtype = atoi(opt);
+ adv_params_cp.chan_map = 7;
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_LE_CTL;
+ rq.ocf = OCF_LE_SET_ADVERTISING_PARAMETERS;
+ rq.cparam = &adv_params_cp;
+ rq.clen = LE_SET_ADVERTISING_PARAMETERS_CP_SIZE;
+ rq.rparam = &status;
+ rq.rlen = 1;
+
+ ret = hci_send_req(dd, &rq, 1000);
+ if (ret < 0)
+ goto done;
+
+ memset(&advertise_cp, 0, sizeof(advertise_cp));
+ advertise_cp.enable = 0x01;
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_LE_CTL;
+ rq.ocf = OCF_LE_SET_ADVERTISE_ENABLE;
+ rq.cparam = &advertise_cp;
+ rq.clen = LE_SET_ADVERTISE_ENABLE_CP_SIZE;
+ rq.rparam = &status;
+ rq.rlen = 1;
+
+ ret = hci_send_req(dd, &rq, 1000);
+
+done:
+ hci_close_dev(dd);
+
+ if (ret < 0) {
+ fprintf(stderr, "Can't set advertise mode on hci%d: %s (%d)\n",
+ hdev, strerror(errno), errno);
+ exit(1);
+ }
+
+ if (status) {
+ fprintf(stderr, "LE set advertise enable on hci%d returned status %d\n",
+ hdev, status);
+ exit(1);
+ }
+}
+
+static void cmd_no_le_adv(int ctl, int hdev, char *opt)
+{
+ struct hci_request rq;
+ le_set_advertise_enable_cp advertise_cp;
uint8_t status;
int dd, ret;
@@ -255,10 +320,6 @@ static void cmd_le_adv(int ctl, int hdev, char *opt)
}
memset(&advertise_cp, 0, sizeof(advertise_cp));
- if (strcmp(opt, "noleadv") == 0)
- advertise_cp.enable = 0x00;
- else
- advertise_cp.enable = 0x01;
memset(&rq, 0, sizeof(rq));
rq.ogf = OGF_LE_CTL;
@@ -1932,8 +1993,10 @@ static struct {
{ "block", cmd_block, "<bdaddr>", "Add a device to the blacklist" },
{ "unblock", cmd_unblock, "<bdaddr>", "Remove a device from the blacklist" },
{ "lerandaddr", cmd_le_addr, "<bdaddr>", "Set LE Random Address" },
- { "leadv", cmd_le_adv, 0, "Enable LE advertising" },
- { "noleadv", cmd_le_adv, 0, "Disable LE advertising" },
+ { "leadv", cmd_le_adv, "[type]", "Enable LE advertising"
+ "\n\t\t\t0 - Connectable undirected advertising (default)"
+ "\n\t\t\t3 - Non connectable undirected advertising"},
+ { "noleadv", cmd_no_le_adv, 0, "Disable LE advertising" },
{ "lestates", cmd_le_states, 0, "Display the supported LE states" },
{ NULL, NULL, 0 }
};
--
1.8.0
^ permalink raw reply related
* Re: [PATCH BlueZ] hciconfig: Add an option to set which advertise type will be on
From: Jefferson Delfes @ 2012-11-21 19:04 UTC (permalink / raw)
To: Jefferson Delfes, linux-bluetooth
In-Reply-To: <20121121185130.GB3074@x220.P-661HNU-F1>
Hi Johan.
I did compare with "noleadv" because if you have some param in
command.opt, main function drops one argument (command name) and it
will pass only the parameter of the command. So or it will be empty,
or it will have the argument for leadv.
I can split this function. Probably it will be more intuitive.
Thanks.
^ permalink raw reply
* Re: [RFC BlueZ] TODO: Add entry about built-in profiles connection management by core
From: Johan Hedberg @ 2012-11-21 18:53 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1353510762-28123-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Wed, Nov 21, 2012, Luiz Augusto von Dentz wrote:
> ---
> TODO | 9 +++++++++
> 1 file changed, 9 insertions(+)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH BlueZ] hciconfig: Add an option to set which advertise type will be on
From: Johan Hedberg @ 2012-11-21 18:51 UTC (permalink / raw)
To: Jefferson Delfes; +Cc: linux-bluetooth
In-Reply-To: <1353506992-3371-1-git-send-email-jefferson.delfes@openbossa.org>
Hi Jefferson,
On Wed, Nov 21, 2012, Jefferson Delfes wrote:
> + if (opt == NULL || strcmp(opt, "noleadv")) {
Wouldn't it be more intuitive to compare against "leadv" here instead of
"noleadv". Also whenever doing strcmp comparisons please use an explicit
== 0 or != 0. Also, if the logic (and length) of this function starts
growing too much you should really consider splitting it into one per
command.
Johan
^ permalink raw reply
* Re: [PATCH 1/5] doc: Update settings-storage.txt
From: Johan Hedberg @ 2012-11-21 18:46 UTC (permalink / raw)
To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1353505791-21134-1-git-send-email-frederic.danis@linux.intel.com>
Hi Frederic,
On Wed, Nov 21, 2012, Frédéric Danis wrote:
> Remote features are not available from user space,
> so replace Features entry by SupportedTechnologies.
>
> Device blocked should be saved in device info file.
> ---
> doc/settings-storage.txt | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
All five patches have been applied. Thanks.
Johan
^ permalink raw reply
* Re: net, bluetooth: object debug warning in bt_host_release()
From: Gustavo Padovan @ 2012-11-21 17:27 UTC (permalink / raw)
To: Sasha Levin
Cc: marcel, Johan Hedberg, David S. Miller, linux-bluetooth, netdev,
linux-kernel@vger.kernel.org, Dave Jones
In-Reply-To: <50A272E7.9080103@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 5585 bytes --]
* Sasha Levin <sasha.levin@oracle.com> [2012-11-13 11:18:47 -0500]:
> Hi all,
>
> While fuzzing with trinity on a KVM tools (lkvm) guest running latest -next kernel I've
> stumbled on the following:
>
> [ 1434.201149] ------------[ cut here ]------------
> [ 1434.204998] WARNING: at lib/debugobjects.c:261 debug_print_object+0x8e/0xb0()
> [ 1434.208324] ODEBUG: free active (active state 0) object type: work_struct hint: hci_power_on+0x0/0x90
> [ 1434.210386] Pid: 8564, comm: trinity-child25 Tainted: G W 3.7.0-rc5-next-20121112-sasha-00018-g2f4ce0e #127
> [ 1434.210760] Call Trace:
> [ 1434.210760] [<ffffffff819f3d6e>] ? debug_print_object+0x8e/0xb0
> [ 1434.210760] [<ffffffff8110b887>] warn_slowpath_common+0x87/0xb0
> [ 1434.210760] [<ffffffff8110b911>] warn_slowpath_fmt+0x41/0x50
> [ 1434.210760] [<ffffffff819f3d6e>] debug_print_object+0x8e/0xb0
> [ 1434.210760] [<ffffffff8376b750>] ? hci_dev_open+0x310/0x310
> [ 1434.210760] [<ffffffff83bf94e5>] ? _raw_spin_unlock_irqrestore+0x55/0xa0
> [ 1434.210760] [<ffffffff819f3ee5>] __debug_check_no_obj_freed+0xa5/0x230
> [ 1434.210760] [<ffffffff83785db0>] ? bt_host_release+0x10/0x20
> [ 1434.210760] [<ffffffff819f4d15>] debug_check_no_obj_freed+0x15/0x20
> [ 1434.210760] [<ffffffff8125eee7>] kfree+0x227/0x330
> [ 1434.210760] [<ffffffff83785db0>] bt_host_release+0x10/0x20
> [ 1434.210760] [<ffffffff81e539e5>] device_release+0x65/0xc0
> [ 1434.210760] [<ffffffff819d3975>] kobject_cleanup+0x145/0x190
> [ 1434.210760] [<ffffffff819d39cd>] kobject_release+0xd/0x10
> [ 1434.210760] [<ffffffff819d33cc>] kobject_put+0x4c/0x60
> [ 1434.210760] [<ffffffff81e548b2>] put_device+0x12/0x20
> [ 1434.210760] [<ffffffff8376a334>] hci_free_dev+0x24/0x30
> [ 1434.210760] [<ffffffff82fd8fe1>] vhci_release+0x31/0x60
> [ 1434.210760] [<ffffffff8127be12>] __fput+0x122/0x250
> [ 1434.210760] [<ffffffff811cab0d>] ? rcu_user_exit+0x9d/0xd0
> [ 1434.210760] [<ffffffff8127bf49>] ____fput+0x9/0x10
> [ 1434.210760] [<ffffffff81133402>] task_work_run+0xb2/0xf0
> [ 1434.210760] [<ffffffff8106cfa7>] do_notify_resume+0x77/0xa0
> [ 1434.210760] [<ffffffff83bfb0ea>] int_signal+0x12/0x17
> [ 1434.210760] ---[ end trace a6d57fefbc8a8cc7 ]---
>
> Not that the guest doesn't emulate anything that looks like a bluetooth device or
> has bluetooth capabilities.
You have a virtual bluetooth device (vhci). That is why you get a bluetooth
crash. I think the following patch will fix this issue.
Gustavo
---
Author: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Date: Wed Nov 21 00:50:21 2012 -0200
Bluetooth: cancel power_on work when unregistering the device
We need to cancel the hci_power_on work in order to avoid it run when we
try to free the hdev.
[ 1434.201149] ------------[ cut here ]------------
[ 1434.204998] WARNING: at lib/debugobjects.c:261 debug_print_object+0x8e/0xb0()
[ 1434.208324] ODEBUG: free active (active state 0) object type: work_struct hint:
_power_on+0x0/0x90
[ 1434.210386] Pid: 8564, comm: trinity-child25 Tainted: G W 3.7.0-rc5-n
20121112-sasha-00018-g2f4ce0e #127
[ 1434.210760] Call Trace:
[ 1434.210760] [<ffffffff819f3d6e>] ? debug_print_object+0x8e/0xb0
[ 1434.210760] [<ffffffff8110b887>] warn_slowpath_common+0x87/0xb0
[ 1434.210760] [<ffffffff8110b911>] warn_slowpath_fmt+0x41/0x50
[ 1434.210760] [<ffffffff819f3d6e>] debug_print_object+0x8e/0xb0
[ 1434.210760] [<ffffffff8376b750>] ? hci_dev_open+0x310/0x310
[ 1434.210760] [<ffffffff83bf94e5>] ? _raw_spin_unlock_irqrestore+0x55/0xa0
[ 1434.210760] [<ffffffff819f3ee5>] __debug_check_no_obj_freed+0xa5/0x230
[ 1434.210760] [<ffffffff83785db0>] ? bt_host_release+0x10/0x20
[ 1434.210760] [<ffffffff819f4d15>] debug_check_no_obj_freed+0x15/0x20
[ 1434.210760] [<ffffffff8125eee7>] kfree+0x227/0x330
[ 1434.210760] [<ffffffff83785db0>] bt_host_release+0x10/0x20
[ 1434.210760] [<ffffffff81e539e5>] device_release+0x65/0xc0
[ 1434.210760] [<ffffffff819d3975>] kobject_cleanup+0x145/0x190
[ 1434.210760] [<ffffffff819d39cd>] kobject_release+0xd/0x10
[ 1434.210760] [<ffffffff819d33cc>] kobject_put+0x4c/0x60
[ 1434.210760] [<ffffffff81e548b2>] put_device+0x12/0x20
[ 1434.210760] [<ffffffff8376a334>] hci_free_dev+0x24/0x30
[ 1434.210760] [<ffffffff82fd8fe1>] vhci_release+0x31/0x60
[ 1434.210760] [<ffffffff8127be12>] __fput+0x122/0x250
[ 1434.210760] [<ffffffff811cab0d>] ? rcu_user_exit+0x9d/0xd0
[ 1434.210760] [<ffffffff8127bf49>] ____fput+0x9/0x10
[ 1434.210760] [<ffffffff81133402>] task_work_run+0xb2/0xf0
[ 1434.210760] [<ffffffff8106cfa7>] do_notify_resume+0x77/0xa0
[ 1434.210760] [<ffffffff83bfb0ea>] int_signal+0x12/0x17
[ 1434.210760] ---[ end trace a6d57fefbc8a8cc7 ]---
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 81f4bac..69eb644 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1854,6 +1854,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
for (i = 0; i < NUM_REASSEMBLY; i++)
kfree_skb(hdev->reassembly[i]);
+ cancel_work_sync(&hdev->power_on);
+
if (!test_bit(HCI_INIT, &hdev->flags) &&
!test_bit(HCI_SETUP, &hdev->dev_flags)) {
hci_dev_lock(hdev);
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related
* [RFC BlueZ] TODO: Add entry about built-in profiles connection management by core
From: Luiz Augusto von Dentz @ 2012-11-21 15:12 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
TODO | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/TODO b/TODO
index 9f6655e..9c0b751 100644
--- a/TODO
+++ b/TODO
@@ -42,6 +42,15 @@ General
g_dbus_add_service_watch()). Idea first mentioned on
http://thread.gmane.org/gmane.linux.bluez.kernel/30175/focus=30190.
+- Reuse connection handling code of src/profile.c also for built-in profiles
+ so plugins would only need to register their btd_profile and the core takes
+ care of the rest including listen to the right channel and manages the sdp
+ record. Once btd_profile manages the connection it can also notify about
+ their state, this probably remove the need of having callbacks to
+ .connect/.disconnect since their state can be tracked, it also enables any
+ plugin to track any profile state change which can be useful for e.g.
+ a connection policy plugin in case one is needed.
+
Priority: Low
Complexity: C2
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ] hciconfig: Add an option to set which advertise type will be on
From: Jefferson Delfes @ 2012-11-21 14:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jefferson Delfes
There are some advertise types that can be used, so we need a way to
tell which one we want. The default one is ADV_IND.
---
tools/hciconfig.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 64f2650..e107bff 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -254,8 +254,31 @@ static void cmd_le_adv(int ctl, int hdev, char *opt)
exit(1);
}
+ if (opt == NULL || strcmp(opt, "noleadv")) {
+ le_set_advertising_parameters_cp adv_params_cp;
+
+ memset(&adv_params_cp, 0, sizeof(adv_params_cp));
+ adv_params_cp.min_interval = 0x0800;
+ adv_params_cp.max_interval = 0x0800;
+ if (opt)
+ adv_params_cp.advtype = atoi(opt);
+ adv_params_cp.chan_map = 7;
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_LE_CTL;
+ rq.ocf = OCF_LE_SET_ADVERTISING_PARAMETERS;
+ rq.cparam = &adv_params_cp;
+ rq.clen = LE_SET_ADVERTISING_PARAMETERS_CP_SIZE;
+ rq.rparam = &status;
+ rq.rlen = 1;
+
+ ret = hci_send_req(dd, &rq, 1000);
+ if (ret < 0)
+ goto done;
+ }
+
memset(&advertise_cp, 0, sizeof(advertise_cp));
- if (strcmp(opt, "noleadv") == 0)
+ if (opt && strcmp(opt, "noleadv") == 0)
advertise_cp.enable = 0x00;
else
advertise_cp.enable = 0x01;
@@ -270,6 +293,7 @@ static void cmd_le_adv(int ctl, int hdev, char *opt)
ret = hci_send_req(dd, &rq, 1000);
+done:
hci_close_dev(dd);
if (ret < 0) {
@@ -1932,7 +1956,9 @@ static struct {
{ "block", cmd_block, "<bdaddr>", "Add a device to the blacklist" },
{ "unblock", cmd_unblock, "<bdaddr>", "Remove a device from the blacklist" },
{ "lerandaddr", cmd_le_addr, "<bdaddr>", "Set LE Random Address" },
- { "leadv", cmd_le_adv, 0, "Enable LE advertising" },
+ { "leadv", cmd_le_adv, "[type]", "Enable LE advertising"
+ "\n\t\t\t0 - Connectable undirected advertising (default)"
+ "\n\t\t\t3 - Non connectable undirected advertising"},
{ "noleadv", cmd_le_adv, 0, "Disable LE advertising" },
{ "lestates", cmd_le_states, 0, "Display the supported LE states" },
{ NULL, NULL, 0 }
--
1.8.0
^ permalink raw reply related
* [PATCH 5/5] device: Retrieve device pnp ids from storage
From: Frédéric Danis @ 2012-11-21 13:49 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1353505791-21134-1-git-send-email-frederic.danis@linux.intel.com>
When device pnp ids are updated, save them and emit property
changed signals.
---
src/device.c | 51 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 17 deletions(-)
diff --git a/src/device.c b/src/device.c
index d4a553d..4559674 100644
--- a/src/device.c
+++ b/src/device.c
@@ -236,6 +236,17 @@ static gboolean store_device_info_cb(gpointer user_data)
g_key_file_set_boolean(key_file, "General", "Blocked",
device->blocked);
+ if (device->vendor_src) {
+ g_key_file_set_integer(key_file, "DeviceID", "Source",
+ device->vendor_src);
+ g_key_file_set_integer(key_file, "DeviceID", "Vendor",
+ device->vendor);
+ g_key_file_set_integer(key_file, "DeviceID", "Product",
+ device->product);
+ g_key_file_set_integer(key_file, "DeviceID", "Version",
+ device->version);
+ }
+
ba2str(adapter_get_address(device->adapter), adapter_addr);
ba2str(&device->bdaddr, device_addr);
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", adapter_addr,
@@ -1766,6 +1777,7 @@ static void load_info(struct btd_device *device, const gchar *local,
char *str;
gboolean store_needed = FALSE;
gboolean blocked;
+ int source, vendor, product, version;
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", local, peer);
filename[PATH_MAX] = '\0';
@@ -1811,6 +1823,24 @@ static void load_info(struct btd_device *device, const gchar *local,
if (blocked)
device_block(device, FALSE);
+ /* Load device id */
+ source = g_key_file_get_integer(key_file, "DeviceID", "Source", NULL);
+ if (source) {
+ device_set_vendor_src(device, source);
+
+ vendor = g_key_file_get_integer(key_file, "DeviceID",
+ "Vendor", NULL);
+ device_set_vendor(device, vendor);
+
+ product = g_key_file_get_integer(key_file, "DeviceID",
+ "Product", NULL);
+ device_set_product(device, product);
+
+ version = g_key_file_get_integer(key_file, "DeviceID",
+ "Version", NULL);
+ device_set_version(device, version);
+ }
+
if (store_needed)
store_device_info(device);
@@ -1825,7 +1855,6 @@ struct btd_device *device_create(struct btd_adapter *adapter,
const gchar *adapter_path = adapter_get_path(adapter);
const bdaddr_t *src;
char srcaddr[18];
- uint16_t vendor, product, version;
device = g_try_malloc0(sizeof(struct btd_device));
if (device == NULL)
@@ -1867,13 +1896,6 @@ struct btd_device *device_create(struct btd_adapter *adapter,
device_set_bonded(device, TRUE);
}
- if (read_device_id(srcaddr, address, bdaddr_type, NULL, &vendor,
- &product, &version) == 0) {
- device_set_vendor(device, vendor);
- device_set_product(device, product);
- device_set_version(device, version);
- }
-
return btd_device_ref(device);
}
@@ -2320,22 +2342,15 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
pdlist = sdp_data_get(rec, SDP_ATTR_VENDOR_ID);
vendor = pdlist ? pdlist->val.uint16 : 0x0000;
- device_set_vendor(device, vendor);
-
pdlist = sdp_data_get(rec, SDP_ATTR_PRODUCT_ID);
product = pdlist ? pdlist->val.uint16 : 0x0000;
- device_set_product(device, product);
-
pdlist = sdp_data_get(rec, SDP_ATTR_VERSION);
version = pdlist ? pdlist->val.uint16 : 0x0000;
- device_set_version(device, version);
-
if (source || vendor || product || version)
- store_device_id(srcaddr, dstaddr,
- device->bdaddr_type, source,
- vendor, product, version);
+ device_set_pnpid(device, source, vendor,
+ product, version);
}
/* Check for duplicates */
@@ -4094,4 +4109,6 @@ void device_set_pnpid(struct btd_device *device, uint8_t vendor_id_src,
device_set_vendor_src(device, vendor_id_src);
device_set_product(device, product_id);
device_set_version(device, product_ver);
+
+ store_device_info(device);
}
--
1.7.9.5
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox