-Move the launching of the Local Device to an IOCTL from the open hook to be more compatible with the net_stack

-Implement Launch method in the accesors regarding previous comment
-Fix KDL at removing device



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26345 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2008-07-09 17:01:30 +00:00
parent 383a9ac435
commit d04eb939af
7 changed files with 59 additions and 38 deletions
+6 -5
View File
@@ -13,11 +13,11 @@
#include <net_buffer.h> #include <net_buffer.h>
#include <Drivers.h> #include <Drivers.h>
typedef enum { ANCILLYANT = 1, typedef enum { ANCILLYANT = (1<<0),
RUNNING, RUNNING = (1<<1),
LEAVING, LEAVING = (1<<2),
SENDING, SENDING = (1<<3),
PROCESSING PROCESSING = (1<<4)
} bt_transport_status_t; } bt_transport_status_t;
typedef uint8 bt_stat_t; typedef uint8 bt_stat_t;
@@ -84,6 +84,7 @@ typedef struct bt_hci_device {
enum { enum {
ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET , ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET ,
BT_UP,
GET_STATICS, GET_STATICS,
GET_NOTIFICATION_PORT, GET_NOTIFICATION_PORT,
GET_HCI_ID GET_HCI_ID
@@ -429,8 +429,8 @@ device_open(const char *name, uint32 flags, void **cookie)
} }
acquire_sem(bdev->lock); acquire_sem(bdev->lock);
// Set HCI_RUNNING // Set RUNNING
if ( TEST_AND_SET(&bdev->state, RUNNING) ) { if ( TEST_AND_SET(&bdev->state, ANCILLYANT) ) {
flowf("dev already running! - reOpened device!\n"); flowf("dev already running! - reOpened device!\n");
return B_ERROR; return B_ERROR;
} }
@@ -451,7 +451,7 @@ device_open(const char *name, uint32 flags, void **cookie)
// dumping the USB frames // dumping the USB frames
init_room(&bdev->eventRoom); init_room(&bdev->eventRoom);
init_room(&bdev->aclRoom); init_room(&bdev->aclRoom);
//Init_room(new_bt_dev->scoRoom); //init_room(new_bt_dev->scoRoom);
list_init(&bdev->snetBufferRecycleTrash); list_init(&bdev->snetBufferRecycleTrash);
@@ -470,37 +470,15 @@ device_open(const char *name, uint32 flags, void **cookie)
hdev = bdev->num; hdev = bdev->num;
} }
bdev->hdev = hdev; bdev->hdev = hdev;
// H: set the special flags
// EVENTS
err = submit_rx_event(bdev);
if (err != B_OK)
goto unrun;
#if BT_DRIVER_SUPPORTS_ACL
// ACL
for (i = 0; i < MAX_ACL_IN_WINDOW; i++) {
err = submit_rx_acl(bdev);
if (err != B_OK && i == 0 )
goto unrun;
}
#endif
#if BT_DRIVER_SUPPORTS_SCO
// TODO: SCO / eSCO
#endif
*cookie = bdev; *cookie = bdev;
release_sem(bdev->lock); release_sem(bdev->lock);
flowf(" successful\n"); flowf(" successful\n");
return B_OK; return B_OK;
unrun:
CLEAR_BIT(bdev->state, RUNNING); // Set the flaq in the HCI world
flowf("Queuing failed device stops running\n");
return err;
} }
@@ -617,13 +595,42 @@ device_control(void *cookie, uint32 msg, void *params, size_t size)
snb_put(snbuf, params, size); snb_put(snbuf, params, size);
err = submit_tx_command(bdev, snbuf); err = submit_tx_command(bdev, snbuf);
debugf("device launched %ld\n", err);
break;
case BT_UP:
// EVENTS
err = submit_rx_event(bdev);
if (err != B_OK) {
CLEAR_BIT(bdev->state, ANCILLYANT);
flowf("Queuing failed device stops running\n");
break;
}
#if BT_DRIVER_SUPPORTS_ACL // ACL
for (i = 0; i < MAX_ACL_IN_WINDOW; i++) {
err = submit_rx_acl(bdev);
if (err != B_OK && i == 0 ) {
CLEAR_BIT(bdev->state, ANCILLYANT); // Set the flaq in the HCI world
flowf("Queuing failed device stops running\n");
break;
}
}
#endif
SET_BIT(bdev->state, RUNNING);
#if BT_DRIVER_SUPPORTS_SCO
// TODO: SCO / eSCO
#endif
flowf("device launched\n");
break; break;
case GET_STATICS: case GET_STATICS:
memcpy(params, &bdev->stat, sizeof(bt_hci_statistics)); memcpy(params, &bdev->stat, sizeof(bt_hci_statistics));
err = B_OK; err = B_OK;
break; break;
case GET_HCI_ID: case GET_HCI_ID:
*(hci_id*)params = bdev->hdev; *(hci_id*)params = bdev->hdev;
@@ -62,12 +62,14 @@ fail:
void void
nb_destroy(net_buffer* nbuf) nb_destroy(net_buffer* nbuf)
{ {
if (nbuf == NULL)
return;
/* Free possible allocated */ /* Free possible allocated */
if (nbuf->COOKIEFIELD != NULL) if (nbuf->COOKIEFIELD != NULL)
free((void*)nbuf->COOKIEFIELD); free((void*)nbuf->COOKIEFIELD);
// TODO check for survivers... // TODO check for survivers...
if (nb != NULL) if (nb != NULL)
nb->free(nbuf); nb->free(nbuf);
@@ -135,6 +135,9 @@ void BluetoothServer::MessageReceived(BMessage *message)
} }
status = B_WOULD_BLOCK; status = B_WOULD_BLOCK;
/* TODO: This should be by user request only! */
ldi->Launch();
} }
case BT_MSG_COUNT_LOCAL_DEVICES: case BT_MSG_COUNT_LOCAL_DEVICES:
@@ -38,6 +38,7 @@ printf("### \n");
status_t status_t
HCITransportAccessor::Launch() { HCITransportAccessor::Launch() {
return B_OK; uint32 dummy;
return ioctl(fFD, BT_UP, &dummy, sizeof(uint32));
} }
@@ -29,6 +29,12 @@ LocalDeviceHandler::GetID()
return fHCIDelegate->GetID(); return fHCIDelegate->GetID();
} }
status_t
LocalDeviceHandler::Launch(void)
{
return fHCIDelegate->Launch();
}
bool bool
LocalDeviceHandler::Available() { LocalDeviceHandler::Available() {
+3 -2
View File
@@ -20,10 +20,11 @@ class LocalDeviceHandler {
public: public:
virtual hci_id GetID(); hci_id GetID();
virtual bool Available(); bool Available();
void Acquire(void); void Acquire(void);
status_t Launch(void);
BMessage* GetPropertiesMessage(void) { return fProperties; } BMessage* GetPropertiesMessage(void) { return fProperties; }
bool IsPropertyAvailable(const BString& property); bool IsPropertyAvailable(const BString& property);