All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Bluetooth: Add new HCI commands to the init sequence
@ 2013-09-13  8:40 johan.hedberg
  2013-09-13  8:40 ` [PATCH 1/2] Bluetooth: Add synchronization train parameters reading support johan.hedberg
  2013-09-13  8:40 ` [PATCH 2/2] Bluetooth: Add event mask page 2 setting support johan.hedberg
  0 siblings, 2 replies; 7+ messages in thread
From: johan.hedberg @ 2013-09-13  8:40 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

These two patches add a couple of new(ish) HCI commands to the init
sequence. Event mask page 2 has been available already since core spec
4.0 whereas the sync train parameters were introduced in CSA4.

Johan

----------------------------------------------------------------
Johan Hedberg (2):
      Bluetooth: Add synchronization train parameters reading support
      Bluetooth: Add event mask page 2 setting support

 include/net/bluetooth/hci.h |  4 ++++
 net/bluetooth/hci_core.c    | 47 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] Bluetooth: Add synchronization train parameters reading support
  2013-09-13  8:40 [PATCH 0/2] Bluetooth: Add new HCI commands to the init sequence johan.hedberg
@ 2013-09-13  8:40 ` johan.hedberg
  2013-09-14  1:36   ` Marcel Holtmann
  2013-09-13  8:40 ` [PATCH 2/2] Bluetooth: Add event mask page 2 setting support johan.hedberg
  1 sibling, 1 reply; 7+ messages in thread
From: johan.hedberg @ 2013-09-13  8:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

This patch adds support for reading the synchronization train parameters
for controllers that support the feature. Since the feature is
detectable through the local features page 2, which is retreived only in
stage 3 of the HCI init sequence, there is no other option than to add a
fourth stage to the init sequence.

For now the patch doesn't yet add storing of the parameters, but it is
nevertheless convenient to have around to see what kind of parameters
various controllers use by default (analyzable e.g. with the btmon user
space tool).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 include/net/bluetooth/hci.h |  2 ++
 net/bluetooth/hci_core.c    | 15 ++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ba008d5..63cce97 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -839,6 +839,8 @@ struct hci_cp_write_le_host_supported {
 	__u8	simul;
 } __packed;
 
+#define HCI_OP_READ_SYNC_TRAIN_PARAMS	0x0c77
+
 #define HCI_OP_READ_LOCAL_VERSION	0x1001
 struct hci_rp_read_local_version {
 	__u8     status;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 12b017d..8f73b1f 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -645,6 +645,15 @@ static void hci_init3_req(struct hci_request *req, unsigned long opt)
 	}
 }
 
+static void hci_init4_req(struct hci_request *req, unsigned long opt)
+{
+	struct hci_dev *hdev = req->hdev;
+
+	/* Check for Synchronization Train support */
+	if (hdev->features[2][0] & 0x04)
+		hci_req_add(req, HCI_OP_READ_SYNC_TRAIN_PARAMS, 0, NULL);
+}
+
 static int __hci_init(struct hci_dev *hdev)
 {
 	int err;
@@ -664,7 +673,11 @@ static int __hci_init(struct hci_dev *hdev)
 	if (err < 0)
 		return err;
 
-	return __hci_req_sync(hdev, hci_init3_req, 0, HCI_INIT_TIMEOUT);
+	err = __hci_req_sync(hdev, hci_init3_req, 0, HCI_INIT_TIMEOUT);
+	if (err < 0)
+		return err;
+
+	return __hci_req_sync(hdev, hci_init4_req, 0, HCI_INIT_TIMEOUT);
 }
 
 static void hci_scan_req(struct hci_request *req, unsigned long opt)
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] Bluetooth: Add event mask page 2 setting support
  2013-09-13  8:40 [PATCH 0/2] Bluetooth: Add new HCI commands to the init sequence johan.hedberg
  2013-09-13  8:40 ` [PATCH 1/2] Bluetooth: Add synchronization train parameters reading support johan.hedberg
@ 2013-09-13  8:40 ` johan.hedberg
  2013-09-14  1:35   ` Marcel Holtmann
  2013-09-19 15:22   ` Gustavo Padovan
  1 sibling, 2 replies; 7+ messages in thread
From: johan.hedberg @ 2013-09-13  8:40 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

For those controller that support the HCI_Set_Event_Mask_Page_2 command
we should include it in the init sequence. This patch implements sending
of the command and enables the events in it based on supported features
(currently only CSB is checked).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 include/net/bluetooth/hci.h |  2 ++
 net/bluetooth/hci_core.c    | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63cce97..57aa408 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -827,6 +827,8 @@ struct hci_rp_read_inq_rsp_tx_power {
 	__s8     tx_power;
 } __packed;
 
+#define HCI_OP_SET_EVENT_MASK_PAGE_2	0x0c63
+
 #define HCI_OP_READ_FLOW_CONTROL_MODE	0x0c66
 struct hci_rp_read_flow_control_mode {
 	__u8     status;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8f73b1f..35550d3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -604,6 +604,34 @@ static void hci_set_le_support(struct hci_request *req)
 			    &cp);
 }
 
+static void hci_set_event_mask_page_2(struct hci_request *req)
+{
+	struct hci_dev *hdev = req->hdev;
+	u8 events[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+	/* If Connectionless Slave Broadcast master role is supported
+	 * enable all necessary events for it.
+	 */
+	if (hdev->features[2][0] & 0x01) {
+		events[1] |= 0x40;	/* Triggered Clock Capture */
+		events[1] |= 0x80;	/* Synchronization Train Complete */
+		events[2] |= 0x10;	/* Slave Page Response Timeout */
+		events[2] |= 0x20;	/* CSB Channel Map Change */
+	}
+
+	/* If Connectionless Slave Broadcast slave role is supported
+	 * enable all necessary events for it.
+	 */
+	if (hdev->features[2][0] & 0x02) {
+		events[2] |= 0x01;	/* Synchronization Train Received */
+		events[2] |= 0x02;	/* CSB Receive */
+		events[2] |= 0x04;	/* CSB Timeout */
+		events[2] |= 0x08;	/* Truncated Page Complete */
+	}
+
+	hci_req_add(req, HCI_OP_SET_EVENT_MASK_PAGE_2, sizeof(events), events);
+}
+
 static void hci_init3_req(struct hci_request *req, unsigned long opt)
 {
 	struct hci_dev *hdev = req->hdev;
@@ -649,6 +677,10 @@ static void hci_init4_req(struct hci_request *req, unsigned long opt)
 {
 	struct hci_dev *hdev = req->hdev;
 
+	/* Set event mask page 2 if the HCI command for it is supported */
+	if (hdev->commands[22] & 0x04)
+		hci_set_event_mask_page_2(req);
+
 	/* Check for Synchronization Train support */
 	if (hdev->features[2][0] & 0x04)
 		hci_req_add(req, HCI_OP_READ_SYNC_TRAIN_PARAMS, 0, NULL);
-- 
1.8.4.rc3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] Bluetooth: Add event mask page 2 setting support
  2013-09-13  8:40 ` [PATCH 2/2] Bluetooth: Add event mask page 2 setting support johan.hedberg
@ 2013-09-14  1:35   ` Marcel Holtmann
  2013-09-14 15:58     ` Johan Hedberg
  2013-09-19 15:22   ` Gustavo Padovan
  1 sibling, 1 reply; 7+ messages in thread
From: Marcel Holtmann @ 2013-09-14  1:35 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

> For those controller that support the HCI_Set_Event_Mask_Page_2 command
> we should include it in the init sequence. This patch implements sending
> of the command and enables the events in it based on supported features
> (currently only CSB is checked).
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci.h |  2 ++
> net/bluetooth/hci_core.c    | 32 ++++++++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 63cce97..57aa408 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -827,6 +827,8 @@ struct hci_rp_read_inq_rsp_tx_power {
> 	__s8     tx_power;
> } __packed;
> 
> +#define HCI_OP_SET_EVENT_MASK_PAGE_2	0x0c63
> +

I am a little bit torn here. We define the struct for event mask, but never use it. Now we only define the opcode. So either we add the struct here for completeness sake or you add a cleanup patch that removes the event mask struct.

Otherwise, the patch is fine.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Bluetooth: Add synchronization train parameters reading support
  2013-09-13  8:40 ` [PATCH 1/2] Bluetooth: Add synchronization train parameters reading support johan.hedberg
@ 2013-09-14  1:36   ` Marcel Holtmann
  0 siblings, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2013-09-14  1:36 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

> This patch adds support for reading the synchronization train parameters
> for controllers that support the feature. Since the feature is
> detectable through the local features page 2, which is retreived only in
> stage 3 of the HCI init sequence, there is no other option than to add a
> fourth stage to the init sequence.
> 
> For now the patch doesn't yet add storing of the parameters, but it is
> nevertheless convenient to have around to see what kind of parameters
> various controllers use by default (analyzable e.g. with the btmon user
> space tool).
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci.h |  2 ++
> net/bluetooth/hci_core.c    | 15 ++++++++++++++-
> 2 files changed, 16 insertions(+), 1 deletion(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] Bluetooth: Add event mask page 2 setting support
  2013-09-14  1:35   ` Marcel Holtmann
@ 2013-09-14 15:58     ` Johan Hedberg
  0 siblings, 0 replies; 7+ messages in thread
From: Johan Hedberg @ 2013-09-14 15:58 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Fri, Sep 13, 2013, Marcel Holtmann wrote:
> > For those controller that support the HCI_Set_Event_Mask_Page_2 command
> > we should include it in the init sequence. This patch implements sending
> > of the command and enables the events in it based on supported features
> > (currently only CSB is checked).
> > 
> > Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> > ---
> > include/net/bluetooth/hci.h |  2 ++
> > net/bluetooth/hci_core.c    | 32 ++++++++++++++++++++++++++++++++
> > 2 files changed, 34 insertions(+)
> > 
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 63cce97..57aa408 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -827,6 +827,8 @@ struct hci_rp_read_inq_rsp_tx_power {
> > 	__s8     tx_power;
> > } __packed;
> > 
> > +#define HCI_OP_SET_EVENT_MASK_PAGE_2	0x0c63
> > +
> 
> I am a little bit torn here. We define the struct for event mask, but
> never use it. Now we only define the opcode. So either we add the
> struct here for completeness sake or you add a cleanup patch that
> removes the event mask struct.

I'll create a separate cleanup patch to remove the unused struct.

Johan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] Bluetooth: Add event mask page 2 setting support
  2013-09-13  8:40 ` [PATCH 2/2] Bluetooth: Add event mask page 2 setting support johan.hedberg
  2013-09-14  1:35   ` Marcel Holtmann
@ 2013-09-19 15:22   ` Gustavo Padovan
  1 sibling, 0 replies; 7+ messages in thread
From: Gustavo Padovan @ 2013-09-19 15:22 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

2013-09-13 johan.hedberg@gmail.com <johan.hedberg@gmail.com>:

> From: Johan Hedberg <johan.hedberg@intel.com>
> 
> For those controller that support the HCI_Set_Event_Mask_Page_2 command
> we should include it in the init sequence. This patch implements sending
> of the command and enables the events in it based on supported features
> (currently only CSB is checked).
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
>  include/net/bluetooth/hci.h |  2 ++
>  net/bluetooth/hci_core.c    | 32 ++++++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+)

Patch has been applied to bluetooth-next. Thanks.

	Gustavo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-09-19 15:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-13  8:40 [PATCH 0/2] Bluetooth: Add new HCI commands to the init sequence johan.hedberg
2013-09-13  8:40 ` [PATCH 1/2] Bluetooth: Add synchronization train parameters reading support johan.hedberg
2013-09-14  1:36   ` Marcel Holtmann
2013-09-13  8:40 ` [PATCH 2/2] Bluetooth: Add event mask page 2 setting support johan.hedberg
2013-09-14  1:35   ` Marcel Holtmann
2013-09-14 15:58     ` Johan Hedberg
2013-09-19 15:22   ` Gustavo Padovan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.