Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v5 0/5] L2CAP updates for FCS, valid PSMs, and stream recv
From: Mat Martineau @ 2010-08-24 22:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, rshaffer, linux-arm-msm

These patches incorporate requested fixes from the 'v4' submission.


[PATCH 1/5] Bluetooth: Only enable for L2CAP FCS for ERTM or streaming

This got an "applied" response on the mailing list, but it looks like
the commit got dropped during a rebase.


[PATCH 2/5] Bluetooth: Validate PSM values in calls to connect() and bind()

Fixed comments.


[PATCH 3/5] Bluetooth: Add common code for stream-oriented recvmsg()
[PATCH 4/5] Bluetooth: Use common SOCK_STREAM receive code in RFCOMM
[PATCH 5/5] Bluetooth: Use a stream-oriented recvmsg with SOCK_STREAM L2CAP sockets.

No changes were requested in these patches.


--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply

* Re: [PATCH 0/4] Fix error reporting for SDP Requests
From: Marcel Holtmann @ 2010-08-24 22:21 UTC (permalink / raw)
  To: Angela Bartholomaus; +Cc: linux-bluetooth, rshaffer, johan.hedberg
In-Reply-To: <1282688060-10727-1-git-send-email-angelab@codeaurora.org>

Hi Angela,

> Fixed the following issues revealed while performing bluez qualification: 
> - Incorrect error code was being reported for requests with invalid PDU size;
> - No error was being reported if a request less than 0x07 was received.

I never needed any of these fixes when doing qualification. So why do
you? Please mention the test case numbers.

Regards

Marcel



^ permalink raw reply

* [PATCH 4/4] Send Invalid Syntax Error if Resp Size Less Than 0x07
From: Angela Bartholomaus @ 2010-08-24 22:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, marcel, johan.hedberg, Angela Bartholomaus
In-Reply-To: <1282688060-10727-1-git-send-email-angelab@codeaurora.org>

Added in error catching, when a badly formed request comes in
---
 src/sdpd-request.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index 8547939..205b27b 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -684,6 +684,15 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf)
 	SDPDBG("max_rsp_size : %d", max_rsp_size);
 
 	/*
+	 * Check that max_rsp_size is within valid range
+	 * a minimum size of 0x0007 has to be used for data field
+	 */
+	if (max_rsp_size < 0x0007) {
+		status = SDP_INVALID_SYNTAX;
+		goto done;
+	}
+
+	/*
 	 * Calculate Attribute size acording to MTU
 	 * We can send only (MTU - sizeof(sdp_pdu_hdr_t) - sizeof(sdp_cont_state_t))
 	 */
-- 
1.7.0.2
--
Angela Bartholomaus
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 3/4] Send an Invalid PDU Size Error Resp for Service Attr Search Req
From: Angela Bartholomaus @ 2010-08-24 22:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, marcel, johan.hedberg, Angela Bartholomaus
In-Reply-To: <1282688060-10727-1-git-send-email-angelab@codeaurora.org>

Send error code for an SDP request received with an invalid PDU size
---
 src/sdpd-request.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index ccbd920..8547939 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -818,7 +818,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
 
 	plen = ntohs(((sdp_pdu_hdr_t *)(req->buf))->plen);
 	if (plen < totscanned || plen != totscanned + *(uint8_t *)pdata) {
-		status = SDP_INVALID_SYNTAX;
+		status = SDP_INVALID_PDU_SIZE;
 		goto done;
 	}
 
-- 
1.7.0.2
--
Angela Bartholomaus
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 2/4] Send an Invalid PDU Size Error Response for Service Attr Req
From: Angela Bartholomaus @ 2010-08-24 22:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, marcel, johan.hedberg, Angela Bartholomaus
In-Reply-To: <1282688060-10727-1-git-send-email-angelab@codeaurora.org>

Send error code for an SDP request received with an invalid PDU size
---
 src/sdpd-request.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index cc9fe82..ccbd920 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -667,7 +667,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf)
 	mlen = scanned + sizeof(uint32_t) + sizeof(uint16_t) + 1;
 	// ensure we don't read past buffer
 	if (plen < mlen || plen != mlen + *(uint8_t *)pdata) {
-		status = SDP_INVALID_SYNTAX;
+		status = SDP_INVALID_PDU_SIZE;
 		goto done;
 	}
 
-- 
1.7.0.2
--
Angela Bartholomaus
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 1/4] Send an Invalid PDU Size Error Response for Service Search Req
From: Angela Bartholomaus @ 2010-08-24 22:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, marcel, johan.hedberg, Angela Bartholomaus
In-Reply-To: <1282688060-10727-1-git-send-email-angelab@codeaurora.org>

Send error code for an SDP request received with an invalid PDU Size
---
 src/sdpd-request.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index d56ffc2..cc9fe82 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -367,7 +367,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
 	mlen = scanned + sizeof(uint16_t) + 1;
 	// ensure we don't read past buffer
 	if (plen < mlen || plen != mlen + *(uint8_t *)(pdata+sizeof(uint16_t))) {
-		status = SDP_INVALID_SYNTAX;
+		status = SDP_INVALID_PDU_SIZE;
 		goto done;
 	}
 
-- 
1.7.0.2
--
Angela Bartholomaus
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related

* [PATCH 0/4] Fix error reporting for SDP Requests
From: Angela Bartholomaus @ 2010-08-24 22:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: rshaffer, marcel, johan.hedberg

Fixed the following issues revealed while performing bluez qualification: 
- Incorrect error code was being reported for requests with invalid PDU size;
- No error was being reported if a request less than 0x07 was received.


Angela Bartholomaus
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply

* Re: [PATCH 0/3] Parsing of AMP related HCI commands and events
From: Johan Hedberg @ 2010-08-24  8:44 UTC (permalink / raw)
  To: Inga Stotland; +Cc: linux-bluetooth, rshaffer, marcel
In-Reply-To: <1282174734-1314-1-git-send-email-ingas@codeaurora.org>

Hi Inga,

On Wed, Aug 18, 2010, Inga Stotland wrote:
> Added support for interpreting of the following HCI commands:
> 
> Create Physical Link,
> Accept Physical Link,
> Disconnect Physical Link,
> Create Logical Link,
> Accept Logical Link,
> Disconnect Logical Link,
> Logical Link Cancel,
> Flow Spec Modify,
> Read Encryption Key Size,
> Read Local AMP Info,
> Read Local AMP ASSOC,
> Write Remote AMP ASSOC
> 
> and HCI events:
> 
> Physical Link Complete,
> Disconnect Physical Link Complete,
> Physical Link Loss Early Warning,
> Physical Link Recovery,
> Logical Link Complete,
> Disconnect Logical Link Complete,
> Flow Spec Modify Complete

Thanks. All three patches have been pushed upstream.

Johan

^ permalink raw reply

* ping slowness over bluetooth PAN
From: Han @ 2010-08-24  6:06 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

I noticed that ping is much more slow over bluetooth PAN connection
than a typical WiFI LAN:

especially the first packet:  (Ubuntu 9.10)

PAN:

64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=365 ms

WLAN:

64 bytes from Amelie (192.168.1.71): icmp_seq=1 ttl=128 time=3.53 ms

The WLAN case is 100 times faster on the first ping!  Is this
expected?  (I don't think this is due to the absolute bandwidth).  Any
insight is appreciated.

Han

^ permalink raw reply

* Re: [PATCHv2 2/2] Bluetooth: timer check sk is not owned before freeing
From: Gustavo F. Padovan @ 2010-08-23 22:45 UTC (permalink / raw)
  To: Emeltchenko Andrei; +Cc: linux-bluetooth
In-Reply-To: <1281619537-30096-3-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

* Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2010-08-12 16:25:37 +0300]:

> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
> 
> In timer context we might delete l2cap channel used by krfcommd.
> The check makes sure that sk is not owned.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
> ---
>  net/bluetooth/l2cap.c |   32 ++++++++++++++++++++------------
>  1 files changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
> index 0221d05..2f8ac5d 100644
> --- a/net/bluetooth/l2cap.c
> +++ b/net/bluetooth/l2cap.c
> @@ -73,6 +73,18 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
>  				u8 code, u8 ident, u16 dlen, void *data);
>  
>  /* ---- L2CAP timers ---- */
> +static void l2cap_sock_set_timer(struct sock *sk, long timeout)
> +{
> +	BT_DBG("sk %p state %d timeout %ld", sk, sk->sk_state, timeout);
> +	sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout);
> +}
> +
> +static void l2cap_sock_clear_timer(struct sock *sk)
> +{
> +	BT_DBG("sock %p state %d", sk, sk->sk_state);
> +	sk_stop_timer(sk, &sk->sk_timer);
> +}
> +
>  static void l2cap_sock_timeout(unsigned long arg)
>  {
>  	struct sock *sk = (struct sock *) arg;
> @@ -82,6 +94,14 @@ static void l2cap_sock_timeout(unsigned long arg)
>  
>  	bh_lock_sock(sk);
>  
> +	if (sock_owned_by_user(sk)) {
> +		/* sk is owned by user. Try again later */
> +		l2cap_sock_set_timer(sk, HZ * 2);
> +		bh_unlock_sock(sk);
> +		sock_put(sk);
> +		return;
> +	}

I'm not sure if I like this defer through timers. OTOH could be too much
overhead to do this defer through a work queue.
Also I think that 2 seconds is too much for this timer. 200 miliseconds
should be enough, what do you think?

-- 
Gustavo F. Padovan
http://padovan.org

^ permalink raw reply

* Re: [PATCH] Fix issues with emails category
From: Johan Hedberg @ 2010-08-23 20:50 UTC (permalink / raw)
  To: Lukasz Pawlik; +Cc: linux-bluetooth
In-Reply-To: <AANLkTi=KpD_dtVVe7tSBT-+Kv11QsXf-WbtanAe3ur9-@mail.gmail.com>

Hi Lukasz,

On Mon, Aug 23, 2010, Lukasz Pawlik wrote:
> From: Lukasz Pawlik <lucas.pawlik@gmail.com>
> Date: Mon, 23 Aug 2010 15:25:20 +0200
> Subject: [PATCH] Fix issues with emails category
> 
> Previously all emails sent during phonebook pull had the same
> category INTERNET. Now email are sent with valid category name
> (INTERNET;HOME or INTERNET;WORK)
> ---
>  plugins/phonebook-tracker.c |   31 +++++++++++++++++--------
>  plugins/vcard.c             |   53 ++++++++++++++++++++++++++++++++++---------
>  plugins/vcard.h             |   11 +++++++++
>  3 files changed, 74 insertions(+), 21 deletions(-)

Thanks. The patch is now pushed upstream, but I had to make a few coding
style fixes before that:

> +static struct phonebook_email *find_email(GSList *emails, const char *address,
> +										int type)

Over 80 column line.

> +	for (l = emails; l; l = l->next) {
> +		struct phonebook_email *email;
> +		email = l->data;

You don't really need the variable definition and assignment on
different lines here.

> +static void add_email(struct phonebook_contact *contact, const char *address,
> +						int type)

The continuation line should be indented as much as possible as long as
you don't go beyond 80 columns. (not sure if this is a kernel coding
style thingie but at least Marcel wants it that way).

> +static void vcard_printf_email(GString *vcards, uint8_t format,
> +								const char *address,
> +								enum phonebook_email_type category)

Way over 80 column lines. Are you using some other tab-width than 8?

Johan

^ permalink raw reply

* Re: [PATCH v4] Firmware download for Qualcomm Bluetooth devices
From: Johan Hedberg @ 2010-08-23 20:41 UTC (permalink / raw)
  To: Matthew Wilson; +Cc: linux-bluetooth, marcel, rshaffer
In-Reply-To: <1282580267-2146-1-git-send-email-mtwilson@codeaurora.org>

Hi Matt,

On Mon, Aug 23, 2010, Matthew Wilson wrote:
> Configures device address from hciattach parameter.
> UART speed limited to 115200.
> Requires separate device specific firmware.
> ---
>  Makefile.tools             |    3 +-
>  tools/hciattach.c          |   10 ++
>  tools/hciattach.h          |    1 +
>  tools/hciattach_qualcomm.c |  279 ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 292 insertions(+), 1 deletions(-)
>  create mode 100644 tools/hciattach_qualcomm.c

Thanks. The patch is now pushed upstream with a few more cosmetic
(coding style) changes. Take a look at the upstream tree if you're
interested in the details.

Johan

^ permalink raw reply

* [PATCH 2/2] Bluetooth: Implement LE Set Scan Enable cmd
From: Anderson Briglia @ 2010-08-23 19:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Briglia
In-Reply-To: <1282591815-26934-1-git-send-email-anderson.briglia@openbossa.org>

This patch implements LE Set Scan Enable command for dual
mode and Low Energy hci controllers. It also adds new HCI flags
in order to indicate the LE Scanning state for userland applications
and kernel itself.

Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
---
 include/net/bluetooth/hci.h |    5 +++++
 net/bluetooth/hci_event.c   |   25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index cae1816..268aa94 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -77,6 +77,7 @@ enum {
 
 	HCI_RAW,
 	HCI_LE_ADV,
+	HCI_LE_SCAN,
 };
 
 /* HCI ioctl defines */
@@ -599,6 +600,10 @@ struct hci_rp_read_bd_addr {
 	#define ADVERTISE_ENABLED	0x01
 	#define ADVERTISE_DISABLED	0x00
 
+#define HCI_OP_LE_SET_SCAN_ENABLE	0x200c
+	#define LESCAN_ENABLED		0x01
+	#define LESCAN_DISABLED		0x00
+
 /* ---- HCI Events ---- */
 #define HCI_EV_INQUIRY_COMPLETE		0x01
 
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c86c655..f483801 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -845,6 +845,27 @@ static void hci_cc_le_set_advertise(struct hci_dev *hdev, struct sk_buff *skb)
 	hci_req_complete(hdev, status);
 }
 
+static void hci_cc_le_set_scan(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	__u8 status = *((__u8 *) skb->data);
+	void *sent;
+
+	BT_DBG("%s status 0x%x", hdev->name, status);
+
+	sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE);
+	if (!sent)
+		return;
+
+	clear_bit(HCI_LE_SCAN, &hdev->flags);
+	if (!status) {
+		__u8 param = *((__u8 *) sent);
+		if (param & LESCAN_ENABLED)
+			set_bit(HCI_LE_SCAN, &hdev->flags);
+	}
+
+	hci_req_complete(hdev, status);
+}
+
 static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
@@ -1337,6 +1358,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
 		hci_cc_le_set_advertise(hdev, skb);
 		break;
 
+	case HCI_OP_LE_SET_SCAN_ENABLE:
+		hci_cc_le_set_scan(hdev, skb);
+		break;
+
 	default:
 		BT_DBG("%s opcode 0x%x", hdev->name, opcode);
 		break;
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 1/2] Bluetooth: Implement LE Set Advertise Enable cmd
From: Anderson Briglia @ 2010-08-23 19:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Briglia

This patch implements LE Set Advertise Enable command for dual mode and
Low Energy hci controllers. It also adds new HCI flags in order to
indicate the Advertising state for userland applications and kernel
itself.

Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
---
 include/net/bluetooth/hci.h |    6 ++++++
 net/bluetooth/hci_event.c   |   27 +++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index bcbdd6d..cae1816 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -76,6 +76,7 @@ enum {
 	HCI_INQUIRY,
 
 	HCI_RAW,
+	HCI_LE_ADV,
 };
 
 /* HCI ioctl defines */
@@ -593,6 +594,11 @@ struct hci_rp_read_bd_addr {
 	bdaddr_t bdaddr;
 } __packed;
 
+/* --- HCI LE Commands --- */
+#define HCI_OP_LE_SET_ADVERTISE_ENABLE	0x200a
+	#define ADVERTISE_ENABLED	0x01
+	#define ADVERTISE_DISABLED	0x00
+
 /* ---- HCI Events ---- */
 #define HCI_EV_INQUIRY_COMPLETE		0x01
 
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index bfef5ba..c86c655 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -822,6 +822,29 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)
 	hci_dev_unlock(hdev);
 }
 
+static void hci_cc_le_set_advertise(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	__u8 status = *((__u8 *) skb->data);
+	void *sent;
+
+	BT_DBG("%s status 0x%x", hdev->name, status);
+
+	sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADVERTISE_ENABLE);
+	if (!sent)
+		return;
+
+	if (!status) {
+		__u8 param = *((__u8 *) sent);
+
+		clear_bit(HCI_LE_ADV, &hdev->flags);
+
+		if (param & ADVERTISE_ENABLED)
+			set_bit(HCI_LE_ADV, &hdev->flags);
+	}
+
+	hci_req_complete(hdev, status);
+}
+
 static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
@@ -1310,6 +1333,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
 		hci_cc_read_bd_addr(hdev, skb);
 		break;
 
+	case HCI_OP_LE_SET_ADVERTISE_ENABLE:
+		hci_cc_le_set_advertise(hdev, skb);
+		break;
+
 	default:
 		BT_DBG("%s opcode 0x%x", hdev->name, opcode);
 		break;
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH v4] Firmware download for Qualcomm Bluetooth devices
From: Matthew Wilson @ 2010-08-23 16:17 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, johan.hedberg, rshaffer, Matthew Wilson
In-Reply-To: <20100820223757.GA23924@jh-x301>

Configures device address from hciattach parameter.
UART speed limited to 115200.
Requires separate device specific firmware.
---
 Makefile.tools             |    3 +-
 tools/hciattach.c          |   10 ++
 tools/hciattach.h          |    1 +
 tools/hciattach_qualcomm.c |  279 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 292 insertions(+), 1 deletions(-)
 create mode 100644 tools/hciattach_qualcomm.c

diff --git a/Makefile.tools b/Makefile.tools
index 8ee1972..1c46542 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -24,7 +24,8 @@ tools_hciattach_SOURCES = tools/hciattach.c tools/hciattach.h \
 						tools/hciattach_st.c \
 						tools/hciattach_ti.c \
 						tools/hciattach_tialt.c \
-						tools/hciattach_ath3k.c
+						tools/hciattach_ath3k.c \
+						tools/hciattach_qualcomm.c
 tools_hciattach_LDADD = lib/libbluetooth.la
 
 tools_hciconfig_SOURCES = tools/hciconfig.c tools/csr.h tools/csr.c \
diff --git a/tools/hciattach.c b/tools/hciattach.c
index 5662f57..fd53710 100644
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -312,6 +312,11 @@ static int ath3k_pm(int fd, struct uart_t *u, struct termios *ti)
 	return ath3k_post(fd, u->pm);
 }
 
+static int qualcomm(int fd, struct uart_t *u, struct termios *ti)
+{
+	return qualcomm_init(fd, u->speed, ti, u->bdaddr);
+}
+
 static int read_check(int fd, void *buf, int count)
 {
 	int res;
@@ -1116,6 +1121,11 @@ struct uart_t uart[] = {
 
 	{ "ath3k",    0x0000, 0x0000, HCI_UART_ATH3K, 115200, 115200,
 			FLOW_CTL, DISABLE_PM, NULL, ath3k_ps, ath3k_pm  },
+
+	/* QUALCOMM BTS */
+	{ "qualcomm",   0x0000, 0x0000, HCI_UART_H4,   115200, 115200,
+			FLOW_CTL, DISABLE_PM, NULL, qualcomm, NULL },
+
 	{ NULL, 0 }
 };
 
diff --git a/tools/hciattach.h b/tools/hciattach.h
index c133321..2d26b77 100644
--- a/tools/hciattach.h
+++ b/tools/hciattach.h
@@ -52,3 +52,4 @@ int stlc2500_init(int fd, bdaddr_t *bdaddr);
 int bgb2xx_init(int dd, bdaddr_t *bdaddr);
 int ath3k_init(int fd, char *bdaddr, int speed);
 int ath3k_post(int fd, int pm);
+int qualcomm_init(int fd, int speed, struct termios *ti, const char *bdaddr);
diff --git a/tools/hciattach_qualcomm.c b/tools/hciattach_qualcomm.c
new file mode 100644
index 0000000..b0df4b2
--- /dev/null
+++ b/tools/hciattach_qualcomm.c
@@ -0,0 +1,279 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2005-2010  Marcel Holtmann <marcel@holtmann.org>
+ *  Copyright (c) 2010, Code Aurora Forum. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <syslog.h>
+#include <termios.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/poll.h>
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+#include <bluetooth/hci_lib.h>
+
+#include "hciattach.h"
+
+#define FAILIF(x, args...) do { \
+	if (x) { \
+		fprintf(stderr, ##args); \
+		return -1; \
+	} \
+} while (0)
+
+typedef struct {
+	uint8_t uart_prefix;
+	hci_event_hdr hci_hdr;
+	evt_cmd_complete cmd_complete;
+	uint8_t status;
+	uint8_t data[16];
+} __attribute__((packed)) command_complete_t;
+
+static int read_command_complete(int fd,
+					unsigned short opcode,
+					unsigned char len)
+{
+	command_complete_t resp;
+	unsigned char vsevent[512];
+	int n;
+
+	/* Read reply. */
+	n = read_hci_event(fd, vsevent, sizeof(vsevent));
+	FAILIF(n < 0, "Failed to read response");
+
+	FAILIF(vsevent[1] != 0xFF, "Failed to read response");
+
+	n = read_hci_event(fd, (unsigned char *)&resp, sizeof(resp));
+	FAILIF(n < 0, "Failed to read response");
+
+	/* event must be event-complete */
+	FAILIF(resp.hci_hdr.evt != EVT_CMD_COMPLETE,
+		"Error in response: not a cmd-complete event, "
+		"but 0x%02x!\n", resp.hci_hdr.evt);
+
+	FAILIF(resp.hci_hdr.plen < 4, /* plen >= 4 for EVT_CMD_COMPLETE */
+		"Error in response: plen is not >= 4, but 0x%02x!\n",
+		resp.hci_hdr.plen);
+
+	/* cmd-complete event: opcode */
+	FAILIF(resp.cmd_complete.opcode != 0,
+		"Error in response: opcode is 0x%04x, not 0!",
+		resp.cmd_complete.opcode);
+
+	return resp.status == 0 ? 0 : -1;
+}
+
+static int qualcomm_load_firmware(int fd,
+					const char *firmware,
+					const char *bdaddr_s)
+{
+
+	int fw = open(firmware, O_RDONLY);
+
+	fprintf(stdout, "Opening firmware file: %s\n", firmware);
+
+	FAILIF(fw < 0,
+		"Could not open firmware file %s: %s (%d).\n",
+		firmware, strerror(errno), errno);
+
+	fprintf(stdout, "Uploading firmware...\n");
+	do {
+		/* Read each command and wait for a response. */
+		unsigned char data[1024];
+		unsigned char cmdp[1 + sizeof(hci_command_hdr)];
+		hci_command_hdr *cmd = (hci_command_hdr *)(cmdp + 1);
+		int nr;
+		nr = read(fw, cmdp, sizeof(cmdp));
+		if (!nr)
+			break;
+		FAILIF(nr != sizeof(cmdp),
+			"Could not read H4 + HCI header!\n");
+		FAILIF(*cmdp != HCI_COMMAND_PKT,
+			"Command is not an H4 command packet!\n");
+
+		FAILIF(read(fw, data, cmd->plen) != cmd->plen,
+			"Could not read %d bytes of data \
+			for command with opcode %04x!\n",
+			cmd->plen,
+			cmd->opcode);
+
+		if ((data[0] == 1) && (data[1] == 2) && (data[2] == 6)) {
+			bdaddr_t bdaddr;
+			if (bdaddr_s != NULL) {
+				(void) str2ba(bdaddr_s, &bdaddr);
+				memcpy(&data[3], &bdaddr, sizeof(bdaddr_t));
+			}
+		}
+
+		{
+			int nw;
+			struct iovec iov_cmd[2];
+			iov_cmd[0].iov_base = cmdp;
+			iov_cmd[0].iov_len	= sizeof(cmdp);
+			iov_cmd[1].iov_base = data;
+			iov_cmd[1].iov_len	= cmd->plen;
+			nw = writev(fd, iov_cmd, 2);
+			FAILIF(nw != (int) sizeof(cmdp) + cmd->plen,
+				"Could not send entire command \
+				(sent only %d bytes)!\n",
+				nw);
+		}
+
+		/* Wait for response */
+		if (read_command_complete(fd, cmd->opcode, cmd->plen) < 0)
+		{
+			return -1;
+		}
+
+	} while (1);
+	fprintf(stdout, "Firmware upload successful.\n");
+
+	close(fw);
+	return 0;
+}
+
+int qualcomm_init(int fd, int speed, struct termios *ti, const char *bdaddr)
+{
+	struct timespec tm = {0, 50000};
+	char cmd[5];
+	unsigned char resp[100];		/* Response */
+	char fw[100];
+	int n;
+
+	memset(resp, '\0', 100);
+
+	/* Get Manufacturer and LMP version */
+	cmd[0] = HCI_COMMAND_PKT;
+	cmd[1] = 0x01;
+	cmd[2] = 0x10;
+	cmd[3] = 0x00;
+
+	do {
+		n = write(fd, cmd, 4);
+		if (n < 4) {
+			perror("Failed to write init command");
+			return -1;
+		}
+
+		/* Read reply. */
+		if (read_hci_event(fd, resp, 100) < 0) {
+			perror("Failed to read init response");
+			return -1;
+		}
+
+		/* Wait for command complete event for our Opcode */
+	} while (resp[4] != cmd[1] && resp[5] != cmd[2]);
+
+	/* Verify manufacturer */
+	if ((resp[11] & 0xFF) != 0x1d)
+		fprintf(stderr,
+			"WARNING : module's manufacturer is not Qualcomm\n");
+
+	/* Print LMP version */
+	fprintf(stderr,
+		"Qualcomm module LMP version : 0x%02x\n", resp[10] & 0xFF);
+
+	/* Print LMP subversion */
+	{
+		unsigned short lmp_subv = resp[13] | (resp[14] << 8);
+
+		fprintf(stderr,
+			"Qualcomm module LMP sub-version : 0x%04x\n", lmp_subv);
+
+	}
+
+	/* Get SoC type */
+	cmd[0] = HCI_COMMAND_PKT;
+	cmd[1] = 0x00;
+	cmd[2] = 0xFC;
+	cmd[3] = 0x01;
+	cmd[4] = 0x06;
+
+	do {
+		n = write(fd, cmd, 5);
+		if (n < 5) {
+			perror("Failed to write vendor init command");
+			return -1;
+		}
+
+		/* Read reply. */
+		if ((n = read_hci_event(fd, resp, 100)) < 0) {
+			perror("Failed to read vendor init response");
+			return -1;
+		}
+
+	} while (resp[3] != 0 && resp[4] != 2);
+
+	snprintf(fw, sizeof(fw),
+		"/etc/firmware/%c%c%c%c%c%c_%c%c%c%c.bin",
+		resp[18], resp[19], resp[20], resp[21],
+		resp[22], resp[23],
+		resp[32], resp[33], resp[34], resp[35]);
+
+	/* Wait for command complete event for our Opcode */
+	if (read_hci_event(fd, resp, 100) < 0) {
+		perror("Failed to read init response");
+		return -1;
+	}
+
+	qualcomm_load_firmware(fd, fw, bdaddr);
+
+	/* Reset */
+	cmd[0] = HCI_COMMAND_PKT;
+	cmd[1] = 0x03;
+	cmd[2] = 0x0C;
+	cmd[3] = 0x00;
+
+	do {
+		n = write(fd, cmd, 4);
+		if (n < 4) {
+			perror("Failed to write reset command");
+			return -1;
+		}
+
+		/* Read reply. */
+		if ((n = read_hci_event(fd, resp, 100)) < 0) {
+			perror("Failed to read reset response");
+			return -1;
+		}
+
+	} while (resp[4] != cmd[1] && resp[5] != cmd[2]);
+
+	nanosleep(&tm, NULL);
+	return 0;
+}
-- 
1.7.1.1

--
Matthew Wilson
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply related

* Re: [PATCH v3] Firmware download for Qualcomm Bluetooth devices
From: Matt Wilson @ 2010-08-23 14:38 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth, marcel, rshaffer
In-Reply-To: <20100820223757.GA23924@jh-x301>

On Sat, 2010-08-21 at 01:37 +0300, Johan Hedberg wrote:

> 
> And here. Why do you split it into three lines when it all fits within
> 80 columns?
> 
> Johan

Correction: prior style is actually from commit
13c0e26a0213f67f5bb9bd6915fddee9a7ca3b4 not
a8de99bdd963f0980877e066c7802c4247c1000c.

-Matt

--
Matthew Wilson
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
--

^ permalink raw reply

* Re: [PATCH v3] Firmware download for Qualcomm Bluetooth devices
From: Matt Wilson @ 2010-08-23 14:36 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth, marcel, rshaffer
In-Reply-To: <20100820223757.GA23924@jh-x301>

On Sat, 2010-08-21 at 01:37 +0300, Johan Hedberg wrote:
> Hi Matt,
> 
> On Fri, Aug 20, 2010, Matthew Wilson wrote:
> > Configures device address from hciattach parameter.
> > UART speed limited to 115200.
> > Requires separate device specific firmware.
> > ---
> >  Makefile.tools             |    3 +-
> >  tools/hciattach.c          |   10 ++
> >  tools/hciattach.h          |    1 +
> >  tools/hciattach_qualcomm.c |  279 ++++++++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 292 insertions(+), 1 deletions(-)
> >  create mode 100644 tools/hciattach_qualcomm.c
> 
> Thanks, the patch applies cleanly now. However, I spotted a couple of
> whitespace/coding style issues that would be good to get fixed before
> pushing this upstream:
> 
> > +#define FAILIF(x, args...) do {   \
> > +	if (x) {					  \
> > +		fprintf(stderr, ##args);  \
> > +		return -1;				  \
> > +	}							  \
> > +} while(0)
> 
> Before each \ at the end of the line you use a mix of tabs and spaces.
> Please just use tabs.
> 

See below for origin of style.

> > +typedef struct {
> > +	uint8_t uart_prefix;
> > +	hci_event_hdr hci_hdr;
> > +	evt_cmd_complete cmd_complete;
> > +	uint8_t status;
> > +	uint8_t data[16];
> > +} __attribute__((packed)) command_complete_t;
> > +
> > +
> 
> Why the two consecutive empty lines? Please remove one.

No reason. Will remove.

> 
> > +static int read_command_complete(int fd, unsigned short opcode, unsigned char len) {
> 
> This one looks like it goes beyond 80 columns. Please split it. Also,
> the coding style is to put the opening brace of a function on its own
> line.

See below for origin of style.

> > +	FAILIF(resp.hci_hdr.evt != EVT_CMD_COMPLETE, /* event must be event-complete */
> > +		   "Error in response: not a cmd-complete event, "
> > +		   "but 0x%02x!\n", resp.hci_hdr.evt);
> 
> Mixed tabs and spaces for indentation. Please just use tabs.
> 

See below for origin of style.

> > +	FAILIF(resp.hci_hdr.plen < 4, /* plen >= 4 for EVT_CMD_COMPLETE */
> > +		   "Error in response: plen is not >= 4, but 0x%02x!\n",
> > +		   resp.hci_hdr.plen);
> 
> Same here.
> 

See below for origin of style.

> > +
> > +	/* cmd-complete event: opcode */
> > +	FAILIF(resp.cmd_complete.opcode != 0,
> > +		   "Error in response: opcode is 0x%04x, not 0!",
> > +		   resp.cmd_complete.opcode);
> 
> And here.
> 

See below for origin of style.

> > +static int qualcomm_load_firmware(int fd, const char *firmware, const char *bdaddr_s) {
> 
> This one goes beyond 80 columns too and the opening brace should be on
> its own line.
> 
> > +	FAILIF(fw < 0,
> > +		   "Could not open firmware file %s: %s (%d).\n",
> > +		   firmware, strerror(errno), errno);
> 

See below for origin of style.

> Mixed tabs and spaces for indentation.
> 
> > +		FAILIF(read(fw, data, cmd->plen) != cmd->plen,
> > +			   "Could not read %d bytes of data for command with opcode %04x!\n",
> > +			   cmd->plen,
> > +			   cmd->opcode);
> 
> Same here.
> 

See below for origin of style.

> > +			FAILIF(nw != (int) sizeof(cmdp) + cmd->plen,
> > +				   "Could not send entire command (sent only %d bytes)!\n",
> > +				   nw);
> 
> And here.
> 

See below for origin of style.

> > +		if (read_command_complete(fd,
> > +					  cmd->opcode,
> > +					  cmd->plen) < 0) {
> 
> And here. Why do you split it into three lines when it all fits within
> 80 columns?
> 

The style is from prior commit a8de99bdd963f0980877e066c7802c4247c1000c
but I will fix anyway (just in this file; not in hciattach_tialt.c)

> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Many thanks for the comprehensive review. v4 coming shortly.

-Matt


^ permalink raw reply

* [PATCH] Fix issues with emails category
From: Lukasz Pawlik @ 2010-08-23 13:45 UTC (permalink / raw)
  To: linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-Fix-issues-with-emails-category.patch --]
[-- Type: text/x-patch, Size: 5783 bytes --]

From 35e6beaea7a20c42c3bd13af9b18e0883dd33f66 Mon Sep 17 00:00:00 2001
From: Lukasz Pawlik <lucas.pawlik@gmail.com>
Date: Mon, 23 Aug 2010 15:25:20 +0200
Subject: [PATCH] Fix issues with emails category

Previously all emails sent during phonebook pull had the same
category INTERNET. Now email are sent with valid category name
(INTERNET;HOME or INTERNET;WORK)
---
 plugins/phonebook-tracker.c |   31 +++++++++++++++++--------
 plugins/vcard.c             |   53 ++++++++++++++++++++++++++++++++++---------
 plugins/vcard.h             |   11 +++++++++
 3 files changed, 74 insertions(+), 21 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 3f63dcb..35742b6 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -687,27 +687,38 @@ static void add_phone_number(struct phonebook_contact *contact,
 	contact->numbers = g_slist_append(contact->numbers, number);
 }
 
-static gchar *find_email(GSList *emails, const char *email)
+static struct phonebook_email *find_email(GSList *emails, const char *address,
+										int type)
 {
 	GSList *l;
 
-	for (l = emails; l; l = l->next)
-		if (g_strcmp0(l->data, email) == 0)
-			return l->data;
+	for (l = emails; l; l = l->next) {
+		struct phonebook_email *email;
+		email = l->data;
+		if (g_strcmp0(email->address, address) == 0 &&
+					email->type == type)
+			return email;
+	}
 
 	return NULL;
 }
 
-static void add_email(struct phonebook_contact *contact, const char *email)
+static void add_email(struct phonebook_contact *contact, const char *address,
+						int type)
 {
-	if (email == NULL || strlen(email) == 0)
+	struct phonebook_email *email;
+	if (address == NULL || strlen(address) == 0)
 		return;
 
 	/* Not adding email if there is already added with the same value */
-	if (find_email(contact->emails, email))
+	if (find_email(contact->emails, address, type))
 		return;
 
-	contact->emails = g_slist_append(contact->emails, g_strdup(email));
+	email = g_new0(struct phonebook_email, 1);
+	email->address = g_strdup(address);
+	email->type = type;
+
+	contact->emails = g_slist_append(contact->emails, email);
 }
 
 static GString *gen_vcards(GSList *contacts,
@@ -817,8 +828,8 @@ add_numbers:
 	add_phone_number(contact, reply[COL_FAX_NUMBER], TEL_TYPE_FAX);
 
 	/* Adding emails */
-	add_email(contact, reply[COL_HOME_EMAIL]);
-	add_email(contact, reply[COL_WORK_EMAIL]);
+	add_email(contact, reply[COL_HOME_EMAIL], EMAIL_TYPE_HOME);
+	add_email(contact, reply[COL_WORK_EMAIL], EMAIL_TYPE_WORK);
 
 	DBG("contact %p", contact);
 
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 0eed8ae..3b67535 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -306,19 +306,39 @@ static void vcard_printf_slash_tag(GString *vcards, const char *tag,
 	vcard_printf(vcards, "%s:%s", buf, field);
 }
 
-static void vcard_printf_email(GString *vcards, const char *email)
+static void vcard_printf_email(GString *vcards, uint8_t format,
+								const char *address,
+								enum phonebook_email_type category)
 {
+	const char *category_string = "";
+	char field[LEN_MAX];
 	int len = 0;
 
-	if (email)
-		len = strlen(email);
+	if (!address || !(len = strlen(address)))
+		return;
 
-	if (len) {
-		char field[LEN_MAX];
-		add_slash(field, email, LEN_MAX, len);
-		vcard_printf(vcards,
-				"EMAIL;TYPE=INTERNET:%s", field);
+	switch (category){
+	case EMAIL_TYPE_HOME:
+		if (format == FORMAT_VCARD21)
+			category_string = "INTERNET;HOME";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=INTERNET;TYPE=HOME";
+		break;
+	case EMAIL_TYPE_WORK:
+		if (format == FORMAT_VCARD21)
+			category_string = "INTERNET;WORK";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=INTERNET;TYPE=WORK";
+		break;
+	default:
+		if (format == FORMAT_VCARD21)
+			category_string = "INTERNET";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=INTERNET";
 	}
+
+	add_slash(field, address, LEN_MAX, len);
+	vcard_printf(vcards,"EMAIL;%s:%s", category_string, field);
 }
 
 static gboolean org_fields_present(struct phonebook_contact *contact)
@@ -421,8 +441,11 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
 	if (filter & FILTER_EMAIL) {
 		GSList *l;
 
-		for (l = contact->emails; l; l = l->next)
-			vcard_printf_email(vcards, l->data);
+		for (l = contact->emails; l; l = l->next){
+			struct phonebook_email *email = l->data;
+
+			vcard_printf_email(vcards, format, email->address, email->type);
+		}
 	}
 
 	if (filter & FILTER_ADR)
@@ -459,6 +482,14 @@ static void number_free(gpointer data, gpointer user_data)
 	g_free(number);
 }
 
+static void email_free(gpointer data, gpointer user_data)
+{
+	struct phonebook_email *email = data;
+
+	g_free(email->address);
+	g_free(email);
+}
+
 void phonebook_contact_free(struct phonebook_contact *contact)
 {
 	if (contact == NULL)
@@ -467,7 +498,7 @@ void phonebook_contact_free(struct phonebook_contact *contact)
 	g_slist_foreach(contact->numbers, number_free, NULL);
 	g_slist_free(contact->numbers);
 
-	g_slist_foreach(contact->emails, (GFunc) g_free, NULL);
+	g_slist_foreach(contact->emails, email_free, NULL);
 	g_slist_free(contact->emails);
 
 	g_free(contact->fullname);
diff --git a/plugins/vcard.h b/plugins/vcard.h
index 0f52425..a22dfc1 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -27,6 +27,12 @@ enum phonebook_number_type {
 	TEL_TYPE_OTHER,
 };
 
+enum phonebook_email_type {
+	EMAIL_TYPE_HOME,
+	EMAIL_TYPE_WORK,
+	EMAIL_TYPE_OTHER,
+};
+
 enum phonebook_call_type {
 	CALL_TYPE_NOT_A_CALL,
 	CALL_TYPE_MISSED,
@@ -39,6 +45,11 @@ struct phonebook_number {
 	int type;
 };
 
+struct phonebook_email {
+	char *address;
+	int  type;
+};
+
 struct phonebook_contact {
 	char *fullname;
 	char *given;
-- 
1.7.0.4


^ permalink raw reply related

* Re: [PATCH v4 0/2] Get and Set Feature Reports on HIDRAW (USB and Bluetooth)
From: Jiri Kosina @ 2010-08-23 13:00 UTC (permalink / raw)
  To: Alan Ott
  Cc: Stefan Achatz, Antonio Ospite, Alexey Dobriyan, Tejun Heo,
	Alan Stern, Greg Kroah-Hartman, Marcel Holtmann, Stephane Chatty,
	Michael Poole, David S. Miller, Bastien Nocera, Eric Dumazet,
	linux-input, linux-kernel, linux-usb, linux-bluetooth, netdev
In-Reply-To: <1281990059-3562-1-git-send-email-alan@signal11.us>

On Mon, 16 Aug 2010, Alan Ott wrote:

> This is version 4. Built against 2.6.35+ revision 320b2b8de12698 .
> 
> Alan Ott (2):
>   HID: Add Support for Setting and Getting Feature Reports from hidraw
>   Bluetooth: hidp: Add support for hidraw  HIDIOCGFEATURE  and
>     HIDIOCSFEATURE
> 
>  drivers/hid/hidraw.c          |  105 ++++++++++++++++++++++++++++++++++++--
>  drivers/hid/usbhid/hid-core.c |   37 +++++++++++++-
>  include/linux/hid.h           |    3 +
>  include/linux/hidraw.h        |    3 +
>  net/bluetooth/hidp/core.c     |  114 +++++++++++++++++++++++++++++++++++++++--
>  net/bluetooth/hidp/hidp.h     |    8 +++
>  6 files changed, 260 insertions(+), 10 deletions(-)

Marcel, as per our previous discussion -- what is your word on this? I'd 
be glad taking it once you Ack the bluetooth bits (which, as far as I 
understood from your last mail, don't have strong objections against any 
more).

Thanks,

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

^ permalink raw reply

* Re: [PATCH] Fix issues with emails category
From: Uwe Kleine-König @ 2010-08-23 12:20 UTC (permalink / raw)
  To: Lukasz Pawlik; +Cc: linux-bluetooth
In-Reply-To: <AANLkTik_S1g==mJKEQHpKGbFiQALj2nE=UboDBiNfVYY@mail.gmail.com>

Hallo Lukasz,

On Mon, Aug 23, 2010 at 01:18:11PM +0200, Lukasz Pawlik wrote:
> From a537ade2e108a91552e0d9a6c4ff71ca35388e10 Mon Sep 17 00:00:00 2001
> From: Lukasz Pawlik <lucas.pawlik@gmail.com>
> Date: Mon, 23 Aug 2010 12:57:40 +0200
> Subject: [PATCH] Fix issues with emails category
> 
> Previously all emails sent during phonebook pull had the same
> category INTERNET. Now email are sent with valid category name
> (INTERNET;HOME or INTERNET;WORK)
> ---
>  plugins/phonebook-tracker.c |   30 +++++++++++++++++-------
>  plugins/vcard.c             |   53 ++++++++++++++++++++++++++++++++++---------
>  plugins/vcard.h             |   11 +++++++++
>  3 files changed, 74 insertions(+), 20 deletions(-)
> 
> diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
> index 3f63dcb..069e324 100644
> --- a/plugins/phonebook-tracker.c
> +++ b/plugins/phonebook-tracker.c
> @@ -687,27 +687,39 @@ static void add_phone_number(struct phonebook_contact *contact,
>  	contact->numbers = g_slist_append(contact->numbers, number);
>  }
>  
> -static gchar *find_email(GSList *emails, const char *email)
> +static struct phonebook_email *find_email(GSList *emails, const char *email,
> +										int type)
I assume your tabsize is < 8, because for me "int type" is after the
comma on the preceeding line.  I don't know for sure, but I assume bluez
uses the same convention as the kernel, so tabsize is 8.  (The functions
below need the same fix.)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply

* Re: [PATCH] Fix issues with emails category
From: Johan Hedberg @ 2010-08-23 11:42 UTC (permalink / raw)
  To: Lukasz Pawlik; +Cc: linux-bluetooth
In-Reply-To: <AANLkTik_S1g==mJKEQHpKGbFiQALj2nE=UboDBiNfVYY@mail.gmail.com>

Hi Lukasz,

On Mon, Aug 23, 2010, Lukasz Pawlik wrote:
> +	struct phonebook_email *email_addr;
> +
> +	for (l = emails; l; l = l->next) {
> +		email_addr = l->data;

Please always define variables in the smallest possible scope. In this
case email_addr can be defined in the beginning of the for-loop instead
of the beginning of the function.

> +		if (g_strcmp0(email_addr->email, email) == 0
> +			&& email_addr->type == type)
> +			return email_addr;

Continuation lines should be indented by at least two tabs more than the
original so that they stand out clearly from the actual code that's part
of the subsection. Also, the && goes on the preceeding line.


> -static void add_email(struct phonebook_contact *contact, const char *email)
> +static void add_email(struct phonebook_contact *contact, const char *email,
> +					int type)
>  {
> +	struct phonebook_email *email_addr;
>  	if (email == NULL || strlen(email) == 0)
>  		return;
>  
>  	/* Not adding email if there is already added with the same value */
> -	if (find_email(contact->emails, email))
> +	if (find_email(contact->emails, email, type))
>  		return;
>  
> -	contact->emails = g_slist_append(contact->emails, g_strdup(email));
> +	email_addr = g_new0(struct phonebook_email, 1);
> +	email_addr->email = g_strdup(email);
> +	email_addr->type = type;
> +
> +	contact->emails = g_slist_append(contact->emails, email_addr);

I'd do some renaming of variables here to make it more readable:

s/email/address/
s/email_address/email/
s/email->email/email->address/

> +struct phonebook_email {
> +	char *email;

As mentioned above I'd do a s/email/address/ here.

Johan

^ permalink raw reply

* [PATCH] Fix issues with emails category
From: Lukasz Pawlik @ 2010-08-23 11:18 UTC (permalink / raw)
  To: linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-Fix-issues-with-emails-category.patch --]
[-- Type: text/x-patch, Size: 5755 bytes --]

From a537ade2e108a91552e0d9a6c4ff71ca35388e10 Mon Sep 17 00:00:00 2001
From: Lukasz Pawlik <lucas.pawlik@gmail.com>
Date: Mon, 23 Aug 2010 12:57:40 +0200
Subject: [PATCH] Fix issues with emails category

Previously all emails sent during phonebook pull had the same
category INTERNET. Now email are sent with valid category name
(INTERNET;HOME or INTERNET;WORK)
---
 plugins/phonebook-tracker.c |   30 +++++++++++++++++-------
 plugins/vcard.c             |   53 ++++++++++++++++++++++++++++++++++---------
 plugins/vcard.h             |   11 +++++++++
 3 files changed, 74 insertions(+), 20 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 3f63dcb..069e324 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -687,27 +687,39 @@ static void add_phone_number(struct phonebook_contact *contact,
 	contact->numbers = g_slist_append(contact->numbers, number);
 }
 
-static gchar *find_email(GSList *emails, const char *email)
+static struct phonebook_email *find_email(GSList *emails, const char *email,
+										int type)
 {
 	GSList *l;
 
-	for (l = emails; l; l = l->next)
-		if (g_strcmp0(l->data, email) == 0)
-			return l->data;
+	struct phonebook_email *email_addr;
+
+	for (l = emails; l; l = l->next) {
+		email_addr = l->data;
+		if (g_strcmp0(email_addr->email, email) == 0
+			&& email_addr->type == type)
+			return email_addr;
+	}
 
 	return NULL;
 }
 
-static void add_email(struct phonebook_contact *contact, const char *email)
+static void add_email(struct phonebook_contact *contact, const char *email,
+					int type)
 {
+	struct phonebook_email *email_addr;
 	if (email == NULL || strlen(email) == 0)
 		return;
 
 	/* Not adding email if there is already added with the same value */
-	if (find_email(contact->emails, email))
+	if (find_email(contact->emails, email, type))
 		return;
 
-	contact->emails = g_slist_append(contact->emails, g_strdup(email));
+	email_addr = g_new0(struct phonebook_email, 1);
+	email_addr->email = g_strdup(email);
+	email_addr->type = type;
+
+	contact->emails = g_slist_append(contact->emails, email_addr);
 }
 
 static GString *gen_vcards(GSList *contacts,
@@ -817,8 +829,8 @@ add_numbers:
 	add_phone_number(contact, reply[COL_FAX_NUMBER], TEL_TYPE_FAX);
 
 	/* Adding emails */
-	add_email(contact, reply[COL_HOME_EMAIL]);
-	add_email(contact, reply[COL_WORK_EMAIL]);
+	add_email(contact, reply[COL_HOME_EMAIL], EMAIL_TYPE_HOME);
+	add_email(contact, reply[COL_WORK_EMAIL], EMAIL_TYPE_WORK);
 
 	DBG("contact %p", contact);
 
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 0eed8ae..425ac71 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -306,19 +306,39 @@ static void vcard_printf_slash_tag(GString *vcards, const char *tag,
 	vcard_printf(vcards, "%s:%s", buf, field);
 }
 
-static void vcard_printf_email(GString *vcards, const char *email)
+static void vcard_printf_email(GString *vcards, uint8_t format,
+								const char *email,
+								enum phonebook_email_type category)
 {
+	const char *category_string = "";
+	char field[LEN_MAX];
 	int len = 0;
 
-	if (email)
-		len = strlen(email);
+	if (!email || !(len = strlen(email)))
+		return;
 
-	if (len) {
-		char field[LEN_MAX];
-		add_slash(field, email, LEN_MAX, len);
-		vcard_printf(vcards,
-				"EMAIL;TYPE=INTERNET:%s", field);
+	switch (category){
+	case EMAIL_TYPE_HOME:
+		if (format == FORMAT_VCARD21)
+			category_string = "INTERNET;HOME";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=INTERNET;TYPE=HOME";
+		break;
+	case EMAIL_TYPE_WORK:
+		if (format == FORMAT_VCARD21)
+			category_string = "INTERNET;WORK";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=INTERNET;TYPE=WORK";
+		break;
+	default:
+		if (format == FORMAT_VCARD21)
+			category_string = "INTERNET";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=INTERNET";
 	}
+
+	add_slash(field, email, LEN_MAX, len);
+	vcard_printf(vcards,"EMAIL;%s:%s", category_string, field);
 }
 
 static gboolean org_fields_present(struct phonebook_contact *contact)
@@ -421,8 +441,11 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
 	if (filter & FILTER_EMAIL) {
 		GSList *l;
 
-		for (l = contact->emails; l; l = l->next)
-			vcard_printf_email(vcards, l->data);
+		for (l = contact->emails; l; l = l->next){
+			struct phonebook_email *email = l->data;
+
+			vcard_printf_email(vcards, format, email->email, email->type);
+		}
 	}
 
 	if (filter & FILTER_ADR)
@@ -459,6 +482,14 @@ static void number_free(gpointer data, gpointer user_data)
 	g_free(number);
 }
 
+static void email_free(gpointer data, gpointer user_data)
+{
+	struct phonebook_email *email = data;
+
+	g_free(email->email);
+	g_free(email);
+}
+
 void phonebook_contact_free(struct phonebook_contact *contact)
 {
 	if (contact == NULL)
@@ -467,7 +498,7 @@ void phonebook_contact_free(struct phonebook_contact *contact)
 	g_slist_foreach(contact->numbers, number_free, NULL);
 	g_slist_free(contact->numbers);
 
-	g_slist_foreach(contact->emails, (GFunc) g_free, NULL);
+	g_slist_foreach(contact->emails, email_free, NULL);
 	g_slist_free(contact->emails);
 
 	g_free(contact->fullname);
diff --git a/plugins/vcard.h b/plugins/vcard.h
index 0f52425..41423e0 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -27,6 +27,12 @@ enum phonebook_number_type {
 	TEL_TYPE_OTHER,
 };
 
+enum phonebook_email_type {
+	EMAIL_TYPE_HOME,
+	EMAIL_TYPE_WORK,
+	EMAIL_TYPE_OTHER,
+};
+
 enum phonebook_call_type {
 	CALL_TYPE_NOT_A_CALL,
 	CALL_TYPE_MISSED,
@@ -39,6 +45,11 @@ struct phonebook_number {
 	int type;
 };
 
+struct phonebook_email {
+	char *email;
+	int  type;
+};
+
 struct phonebook_contact {
 	char *fullname;
 	char *given;
-- 
1.7.0.4


^ permalink raw reply related

* data misalignment in l2cap_get_conf_opt
From: real mz @ 2010-08-23  9:42 UTC (permalink / raw)
  To: linux-bluetooth

 I met data misalignment exeception when using USB bt card. The fault
address is in l2cap_get_conf_opt() line 2296.
2290        switch (opt->len) {
2291        case 1:
2292                *val = *((u8 *) opt->val);
2293                break;
2294
2295        case 2:
2296                *val = __le16_to_cpu(*((__le16 *) opt->val));
2297                break;
2298
2299        case 4:
2300                *val = __le32_to_cpu(*((__le32 *) opt->val));
2301                break;

The address of opt->val is not 2-bytes aligned. actually this val is
read from conf_req[64] of struct l2cap_info, I think this opt->val can
not guarantee it is 2-bytes or 4-bytes aligned,
2296                *val = __le16_to_cpu(*((__le16 *) opt->val));
2300                *val = __le32_to_cpu(*((__le32 *) opt->val));
will cause misalignment fault in some processor that not support
unaligned access.

l2cap_pinfo struct:
 306struct l2cap_pinfo {
 307        struct bt_sock  bt;
 308        __le16          psm;
 309        __u16           dcid;
 310        __u16           scid;
 311
 312        __u16           imtu;
 313        __u16           omtu;
 314        __u16           flush_to;
 315        __u8            mode;
 316        __u8            num_conf_req;
 317        __u8            num_conf_rsp;
 318
 319        __u8            fcs;
 320        __u8            sec_level;
 321        __u8            role_switch;
 322        __u8            force_reliable;
 323
 324        __u8            conf_req[64];
...

Steven

^ permalink raw reply

* [RFCOMM] Cannot complete connections into Ubuntu
From: Shreesh Holla @ 2010-08-23  7:22 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

I'm running Ubuntu with 2.6.32.24 kernel.
I have a simple RFCOMM program running on Windows Mobile which would connect 
into the Ubuntu machine. Of course I have the corresponding service running on 
the Ubuntu machine. The RFCOMM port numbers do match up.

This was working a few days back and now with no changes(i.e. the same 
executable), it refuses to work anymore.

So is there some configuration needed  now?

I have the dongle running in Ubuntu as : hciconfig hci0 noauth noencrypt pscan

Thanks,
Shreesh


^ permalink raw reply

* RE: [PATCH 0/8] Clean up Obex btio.[ch] and make it self contained
From: Zhang, Zhenhua @ 2010-08-23  1:13 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <AANLkTi=B=GoXrymjfKAnXuRDiTe7Uxqdiqs831nsWRb-@mail.gmail.com>

Hi Luiz,

Luiz Augusto von Dentz wrote:
> Hi,
> 
> On Thu, Aug 19, 2010 at 5:21 PM, Zhenhua Zhang
> <zhenhua.zhang@intel.com> wrote: 
>> Hi,
>> 
>> This series of patches is to seperate btio.[ch] from src to btio
>> directory. To make btio.[ch] self contained for obexd, there're some
>> cleanup work:  
> 
> Sounds good, this should make it easier to maintain those in sync with
> other projects using it.
> 
>> 1. remove unused bt_io_set(). It is neither used by bluez or obexd.
>> 2. remove unused SCO/L2RAW related code for Obexd. Note: BlueZ code
>> requires SCO/L2RAW related functions. We may consider to add them
>> back later.  
> 
> Im not so sure if we want to have this code removed, obviously after
> that in case of changes/fixes they may not apply cleanly in all
> projects, so keeping them in sync won't be as easy anymore.

You're right. For such code used in BlueZ, I will keep them to make sync easier. So now I am cleaning up BlueZ's btio.[ch]. Before I complete that part, I just want to send out what I plan to change for btio.[ch] to collect review comments earlier. The patches for BlueZ will be send out later.

>> 3. replace void *userdata with gpointer userdata. To make it
>> consistent with bluez btio.c 
>> 4. refactor hci_devba into devid2ba. Remove dependence with hci*.h
>> 5. Remove libbluetooth dependence for obexd.
> 
> This is fine as long as the other copies have this changes too.

Regards,
Zhenhua

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox