Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] Modified patch (Dynamic Alternate Setting)
Date: Fri, 27 Apr 2007 21:40:19 +0200	[thread overview]
Message-ID: <1177702819.14980.136.camel@aeonflux.holtmann.net> (raw)
In-Reply-To: <1177538646.14980.26.camel@aeonflux.holtmann.net>

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

Hi,

> > I have made the changes u suggested.
> > Take a look and let me know.
> 
> please fix the coding style of your additions. This patch is unreadable
> in this state. No forward declarations and no heavy nesting.

the following patch follows more my understanding how this should look
like. However the attached patch doesn't contain the code for stopping
and resubmitting the ISOC URBs.

Regards

Marcel


[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 2529 bytes --]

diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 406af57..b668476 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -839,7 +839,41 @@ static void hci_usb_destruct(struct hci_dev *hdev)
 
 static void hci_usb_notify(struct hci_dev *hdev, unsigned int evt)
 {
+	struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
+	unsigned long flags;
+	int new_alts;
+
 	BT_DBG("%s evt %d", hdev->name, evt);
+
+	new_alts = hdev->conn_hash.sco_num;
+
+	if (hdev->voice_setting & 0x0020) {
+		new_alts *= 2;
+		if (new_alts > 5)
+			new_alts = 5;
+	}
+
+	write_lock_irqsave(&husb->completion_lock, flags);
+
+	if (new_alts != husb->isoc_alts) {
+		husb->pend_alts = new_alts;
+		schedule_work(&husb->work);
+	}
+
+	write_unlock_irqrestore(&husb->completion_lock, flags);
+}
+
+static void set_isoc_alternate(struct work_struct *work)
+{
+	struct hci_usb *husb = container_of(work, struct hci_usb, work);
+
+	write_lock(&husb->completion_lock);
+
+	usb_set_interface(husb->udev, husb->isoc_ifnum, husb->pend_alts);
+
+	husb->isoc_alts = husb->pend_alts;
+
+	write_unlock(&husb->completion_lock);
 }
 
 static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
@@ -974,6 +1008,11 @@ static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id
 				husb->isoc_out_ep = isoc_out_ep;
 			}
 		}
+
+		husb->isoc_ifnum = isoc_ifnum;
+		husb->isoc_alts  = 0;
+
+		usb_set_interface(udev, isoc_ifnum, husb->isoc_alts);
 	}
 #endif
 
@@ -994,6 +1033,8 @@ static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id
 
 	husb->hdev = hdev;
 
+	INIT_WORK(&husb->work, set_isoc_alternate);
+
 	hdev->type = HCI_USB;
 	hdev->driver_data = husb;
 	SET_HCIDEV_DEV(hdev, &intf->dev);
diff --git a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h
index 963fc55..f1a7934 100644
--- a/drivers/bluetooth/hci_usb.h
+++ b/drivers/bluetooth/hci_usb.h
@@ -102,9 +102,9 @@ struct hci_usb {
 	struct hci_dev		*hdev;
 
 	unsigned long		state;
-	
+
 	struct usb_device	*udev;
-	
+
 	struct usb_host_endpoint	*bulk_in_ep;
 	struct usb_host_endpoint	*bulk_out_ep;
 	struct usb_host_endpoint	*intr_in_ep;
@@ -113,8 +113,14 @@ struct hci_usb {
 	struct usb_host_endpoint	*isoc_out_ep;
 	struct usb_host_endpoint	*isoc_in_ep;
 
+	int				isoc_ifnum;
+	int				isoc_alts;
+	int				pend_alts;
+
 	__u8			ctrl_req;
 
+	struct work_struct	work;
+
 	struct sk_buff_head	transmit_q[4];
 	struct sk_buff		*reassembly[4];		/* Reassembly buffers */
 

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

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

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

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

  reply	other threads:[~2007-04-27 19:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-25 21:24 [Bluez-devel] Modified patch (Dynamic Alternate Setting) list subscribe
2007-04-25 22:04 ` Marcel Holtmann
2007-04-27 19:40   ` Marcel Holtmann [this message]
2007-04-27 20:10     ` Marcel Holtmann
2007-05-03 21:17       ` list subscribe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1177702819.14980.136.camel@aeonflux.holtmann.net \
    --to=marcel@holtmann.org \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox