- Schedule event interrupt transfer with the maximun possible event size, => reduces the number of callbacks for bigger packages
- Add debug options for dumping incoming usb buffers - Styling git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32721 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4c72b8cf43
commit
3f664b99dc
@ -269,10 +269,13 @@ device_added(usb_device* dev, void** cookie)
|
||||
/* Place to find out whats our concrete device and set up some special info to our driver */
|
||||
/* TODO: if this code increases too much reconsider this implementation*/
|
||||
desc = usb->get_device_descriptor(dev);
|
||||
if ( desc->vendor_id == 0x0a5c && (desc->product_id == 0x200a ||
|
||||
desc->product_id == 0x2009 ||
|
||||
desc->product_id == 0x2035 )) {
|
||||
if (desc->vendor_id == 0x0a5c
|
||||
&& (desc->product_id == 0x200a
|
||||
|| desc->product_id == 0x2009
|
||||
|| desc->product_id == 0x2035)) {
|
||||
|
||||
new_bt_dev->driver_info = BT_WILL_NEED_A_RESET | BT_SCO_NOT_WORKING;
|
||||
|
||||
}
|
||||
/*
|
||||
else if ( desc->vendor_id == YOUR_VENDOR_HERE && desc->product_id == YOUR_PRODUCT_HERE ) {
|
||||
@ -287,7 +290,8 @@ device_added(usb_device* dev, void** cookie)
|
||||
|
||||
// security check
|
||||
if (config->interface->active->descr->interface_number > 0){
|
||||
debugf("Strange condition happened %d\n", config->interface->active->descr->interface_number);
|
||||
debugf("Strange condition happened %d\n",
|
||||
config->interface->active->descr->interface_number);
|
||||
err = B_ERROR;
|
||||
goto bail;
|
||||
}
|
||||
@ -298,8 +302,7 @@ device_added(usb_device* dev, void** cookie)
|
||||
for (e = 0; e < uif->descr->num_endpoints; e++) {
|
||||
|
||||
ep = &uif->endpoint[e];
|
||||
switch (ep->descr->attributes & USB_ENDPOINT_ATTR_MASK)
|
||||
{
|
||||
switch (ep->descr->attributes & USB_ENDPOINT_ATTR_MASK) {
|
||||
case USB_ENDPOINT_ATTR_INTERRUPT:
|
||||
if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
|
||||
{
|
||||
@ -314,11 +317,11 @@ device_added(usb_device* dev, void** cookie)
|
||||
case USB_ENDPOINT_ATTR_BULK:
|
||||
if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) {
|
||||
new_bt_dev->bulk_in_ep = ep;
|
||||
new_bt_dev->max_packet_size_bulk_in = ep->descr->max_packet_size;;
|
||||
new_bt_dev->max_packet_size_bulk_in = ep->descr->max_packet_size;
|
||||
flowf("BULK int\n");
|
||||
} else {
|
||||
new_bt_dev->bulk_out_ep = ep;
|
||||
new_bt_dev->max_packet_size_bulk_out = ep->descr->max_packet_size;;
|
||||
new_bt_dev->max_packet_size_bulk_out = ep->descr->max_packet_size;
|
||||
flowf("BULK out\n");
|
||||
}
|
||||
break;
|
||||
@ -341,7 +344,7 @@ device_added(usb_device* dev, void** cookie)
|
||||
/* set the cookie that will be passed to other USB
|
||||
hook functions (currently device_removed() is the only other) */
|
||||
*cookie = new_bt_dev;
|
||||
debugf("Ok %p\n",bt_usb_devices[0]);
|
||||
debugf("Ok %p\n", new_bt_dev);
|
||||
return B_OK;
|
||||
|
||||
bail:
|
||||
@ -362,14 +365,12 @@ device_removed(void* cookie)
|
||||
debugf("device_removed(%p)\n", bdev);
|
||||
|
||||
if (bdev == NULL) {
|
||||
flowf(" not present in driver¿?\n");
|
||||
flowf(" not present in driver?\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (!TEST_AND_CLEAR(&bdev->state, RUNNING)) {
|
||||
flowf(" wasnt running¿?\n");
|
||||
}
|
||||
|
||||
if (!TEST_AND_CLEAR(&bdev->state, RUNNING))
|
||||
flowf("wasnt running?\n");
|
||||
|
||||
flowf("Cancelling queues...\n");
|
||||
if (bdev->intr_in_ep != NULL) {
|
||||
@ -388,7 +389,6 @@ device_removed(void* cookie)
|
||||
}
|
||||
|
||||
bdev->connected = false;
|
||||
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@ -412,10 +412,11 @@ submit_nbuffer(hci_id hid, net_buffer* nbuf)
|
||||
bdev = fetch_device(NULL, hid);
|
||||
|
||||
debugf("index=%lx nbuf=%p bdev=%p\n",hid, nbuf, bdev);
|
||||
|
||||
if (bdev != NULL) {
|
||||
switch (nbuf->protocol) {
|
||||
case BT_COMMAND:
|
||||
// not issed this way
|
||||
// not issued this way
|
||||
break;
|
||||
|
||||
case BT_ACL:
|
||||
@ -440,7 +441,7 @@ device_open(const char *name, uint32 flags, void **cookie)
|
||||
{
|
||||
status_t err = ENODEV;
|
||||
bt_usb_dev* bdev = NULL;
|
||||
hci_id hdev;
|
||||
hci_id hdev;
|
||||
int i;
|
||||
|
||||
flowf("device_open()\n");
|
||||
@ -496,12 +497,13 @@ device_open(const char *name, uint32 flags, void **cookie)
|
||||
bdev->hdev = hdev = ndev->index; // get the index
|
||||
bdev->ndev = ndev; // get the net_device
|
||||
|
||||
ndev->media = (uint32) submit_nbuffer; //XXX: interlayer-Hack
|
||||
ndev->media = (uint32)submit_nbuffer; //XXX: interlayer-Hack
|
||||
|
||||
} else
|
||||
hdev = bdev->num; /* XXX: Lets try to go on*/
|
||||
} else {
|
||||
hdev = bdev->num; /* XXX: Lets try to go on*/
|
||||
}
|
||||
} else {
|
||||
hdev = bdev->num; /* XXX: Lets try to go on*/
|
||||
hdev = bdev->num; /* XXX: Lets try to go on*/
|
||||
}
|
||||
|
||||
bdev->hdev = hdev;
|
||||
@ -576,7 +578,7 @@ device_close(void *cookie)
|
||||
|
||||
// unSet RUNNING
|
||||
if (TEST_AND_CLEAR(&bdev->state, RUNNING)) {
|
||||
debugf(" %s not running¿?\n",bdev->name);
|
||||
debugf(" %s not running?\n",bdev->name);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@ -850,7 +852,7 @@ uninit_driver(void)
|
||||
// if (connected_dev != NULL) {
|
||||
// debugf("Device %p still exists.\n", connected_dev);
|
||||
// }
|
||||
debugf("%s still present¿?\n",bt_usb_devices[j]->name);
|
||||
debugf("%s still present?\n",bt_usb_devices[j]->name);
|
||||
kill_device(bt_usb_devices[j]);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//#define DUMP_BUFFERS
|
||||
#define BT_DEBUG_THIS_MODULE
|
||||
#include <btDebug.h>
|
||||
|
||||
@ -44,7 +45,9 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
|
||||
|
||||
size_t currentPacketLen = 0;
|
||||
size_t expectedPacketLen = 0;
|
||||
|
||||
#ifdef DUMP_BUFFERS
|
||||
int16 index;
|
||||
#endif
|
||||
bdev->stat.bytesRX += count;
|
||||
|
||||
if (type == BT_EVENT)
|
||||
@ -62,11 +65,17 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
|
||||
/* new buffer incoming */
|
||||
switch (type) {
|
||||
case BT_EVENT:
|
||||
if (count >= HCI_EVENT_HDR_SIZE) {
|
||||
if (count >= HCI_EVENT_HDR_SIZE) {
|
||||
struct hci_event_header* headerPkt = data;
|
||||
expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen;
|
||||
snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash,
|
||||
expectedPacketLen);
|
||||
#ifdef DUMP_BUFFERS
|
||||
debugf("## Incoming EVENT frame %p len = %d ", snbuf, count);
|
||||
for (index = 0 ; index < count; index++)
|
||||
dprintf("%x:",((uint8*)data)[index]);
|
||||
dprintf(" ## \n");
|
||||
#endif
|
||||
} else {
|
||||
flowf("EVENT frame corrupted\n");
|
||||
return EILSEQ;
|
||||
@ -75,7 +84,6 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
|
||||
|
||||
case BT_ACL:
|
||||
if (count >= HCI_ACL_HDR_SIZE) {
|
||||
int16 index;
|
||||
struct hci_acl_header* headerPkt = data;
|
||||
|
||||
expectedPacketLen = HCI_ACL_HDR_SIZE
|
||||
@ -84,12 +92,12 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
|
||||
// Create the buffer -> TODO: this allocation can fail
|
||||
bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen);
|
||||
nbuf->protocol = type;
|
||||
|
||||
#ifdef DUMP_BUFFERS
|
||||
debugf("## Incoming ACL frame %p len = %d ", nbuf, count);
|
||||
for (index = 0 ; index < count; index++)
|
||||
dprintf("%x:",((uint8*)data)[index]);
|
||||
dprintf(" ## \n");
|
||||
|
||||
#endif
|
||||
} else {
|
||||
flowf("ACL frame corrupted\n");
|
||||
return EILSEQ;
|
||||
@ -141,7 +149,7 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
|
||||
|
||||
/* in case in the pipe there is info about the next buffer ... */
|
||||
count -= currentPacketLen;
|
||||
data += currentPacketLen;
|
||||
data += currentPacketLen;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
@ -162,7 +170,7 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len)
|
||||
{
|
||||
bt_usb_dev* bdev = cookie;
|
||||
//bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer/slower option
|
||||
status_t error;
|
||||
status_t error;
|
||||
|
||||
debugf("cookie@%p status=%s len=%ld\n", cookie, strerror(status), actual_len);
|
||||
|
||||
@ -184,7 +192,7 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len)
|
||||
resubmit:
|
||||
|
||||
error = usb->queue_interrupt(bdev->intr_in_ep->handle, data,
|
||||
bdev->max_packet_size_intr_in, event_complete, bdev);
|
||||
max(HCI_MAX_EVENT_SIZE, bdev->max_packet_size_intr_in), event_complete, bdev);
|
||||
|
||||
if (error != B_OK) {
|
||||
reuse_room(&bdev->eventRoom, data);
|
||||
@ -244,7 +252,7 @@ resubmit:
|
||||
status_t
|
||||
submit_rx_event(bt_usb_dev* bdev)
|
||||
{
|
||||
size_t size = bdev->max_packet_size_intr_in;
|
||||
size_t size = max(HCI_MAX_EVENT_SIZE, bdev->max_packet_size_intr_in);
|
||||
void* buf = alloc_room(&bdev->eventRoom, size);
|
||||
status_t status;
|
||||
|
||||
@ -293,7 +301,6 @@ submit_rx_acl(bt_usb_dev* bdev)
|
||||
status_t
|
||||
submit_rx_sco(bt_usb_dev* bdev)
|
||||
{
|
||||
|
||||
/* not yet implemented */
|
||||
return B_ERROR;
|
||||
}
|
||||
@ -341,7 +348,7 @@ acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len)
|
||||
net_buffer* nbuf = (net_buffer*)cookie;
|
||||
bt_usb_dev* bdev = GET_DEVICE(nbuf);
|
||||
|
||||
debugf("fetched=%p status=%ld nbuftype %lx B%p\n",bdev, status, nbuf->type, data);
|
||||
debugf("fetched=%p status=%ld nbuftype %lx B%p\n", bdev, status, nbuf->type, data);
|
||||
|
||||
if (status == B_OK) {
|
||||
bdev->stat.successfulTX++;
|
||||
@ -417,7 +424,7 @@ submit_tx_acl(bt_usb_dev* bdev, net_buffer* nbuf)
|
||||
flowf("### \n");
|
||||
|
||||
error = usb->queue_bulk(bdev->bulk_out_ep->handle, nb_get_whole_buffer(nbuf),
|
||||
nbuf->size, acl_tx_complete, (void*)nbuf);
|
||||
nbuf->size, acl_tx_complete, (void*)nbuf);
|
||||
|
||||
if (error != B_OK) {
|
||||
bdev->stat.rejectedTX++;
|
||||
|
Loading…
Reference in New Issue
Block a user