-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:
parent
383a9ac435
commit
d04eb939af
@ -13,11 +13,11 @@
|
||||
#include <net_buffer.h>
|
||||
#include <Drivers.h>
|
||||
|
||||
typedef enum { ANCILLYANT = 1,
|
||||
RUNNING,
|
||||
LEAVING,
|
||||
SENDING,
|
||||
PROCESSING
|
||||
typedef enum { ANCILLYANT = (1<<0),
|
||||
RUNNING = (1<<1),
|
||||
LEAVING = (1<<2),
|
||||
SENDING = (1<<3),
|
||||
PROCESSING = (1<<4)
|
||||
} bt_transport_status_t;
|
||||
|
||||
typedef uint8 bt_stat_t;
|
||||
@ -84,6 +84,7 @@ typedef struct bt_hci_device {
|
||||
|
||||
enum {
|
||||
ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET ,
|
||||
BT_UP,
|
||||
GET_STATICS,
|
||||
GET_NOTIFICATION_PORT,
|
||||
GET_HCI_ID
|
||||
|
@ -429,8 +429,8 @@ device_open(const char *name, uint32 flags, void **cookie)
|
||||
}
|
||||
|
||||
acquire_sem(bdev->lock);
|
||||
// Set HCI_RUNNING
|
||||
if ( TEST_AND_SET(&bdev->state, RUNNING) ) {
|
||||
// Set RUNNING
|
||||
if ( TEST_AND_SET(&bdev->state, ANCILLYANT) ) {
|
||||
flowf("dev already running! - reOpened device!\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
@ -451,7 +451,7 @@ device_open(const char *name, uint32 flags, void **cookie)
|
||||
// dumping the USB frames
|
||||
init_room(&bdev->eventRoom);
|
||||
init_room(&bdev->aclRoom);
|
||||
//Init_room(new_bt_dev->scoRoom);
|
||||
//init_room(new_bt_dev->scoRoom);
|
||||
|
||||
list_init(&bdev->snetBufferRecycleTrash);
|
||||
|
||||
@ -470,37 +470,15 @@ device_open(const char *name, uint32 flags, void **cookie)
|
||||
hdev = bdev->num;
|
||||
}
|
||||
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;
|
||||
release_sem(bdev->lock);
|
||||
|
||||
flowf(" successful\n");
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
case GET_STATICS:
|
||||
memcpy(params, &bdev->stat, sizeof(bt_hci_statistics));
|
||||
err = B_OK;
|
||||
break;
|
||||
break;
|
||||
|
||||
case GET_HCI_ID:
|
||||
*(hci_id*)params = bdev->hdev;
|
||||
|
@ -62,12 +62,14 @@ fail:
|
||||
void
|
||||
nb_destroy(net_buffer* nbuf)
|
||||
{
|
||||
if (nbuf == NULL)
|
||||
return;
|
||||
|
||||
/* Free possible allocated */
|
||||
if (nbuf->COOKIEFIELD != NULL)
|
||||
free((void*)nbuf->COOKIEFIELD);
|
||||
|
||||
// TODO check for survivers...
|
||||
// TODO check for survivers...
|
||||
if (nb != NULL)
|
||||
nb->free(nbuf);
|
||||
|
||||
|
@ -135,6 +135,9 @@ void BluetoothServer::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
status = B_WOULD_BLOCK;
|
||||
|
||||
/* TODO: This should be by user request only! */
|
||||
ldi->Launch();
|
||||
}
|
||||
|
||||
case BT_MSG_COUNT_LOCAL_DEVICES:
|
||||
|
@ -38,6 +38,7 @@ printf("### \n");
|
||||
status_t
|
||||
HCITransportAccessor::Launch() {
|
||||
|
||||
return B_OK;
|
||||
uint32 dummy;
|
||||
return ioctl(fFD, BT_UP, &dummy, sizeof(uint32));
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,12 @@ LocalDeviceHandler::GetID()
|
||||
return fHCIDelegate->GetID();
|
||||
}
|
||||
|
||||
status_t
|
||||
LocalDeviceHandler::Launch(void)
|
||||
{
|
||||
return fHCIDelegate->Launch();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LocalDeviceHandler::Available() {
|
||||
|
@ -20,10 +20,11 @@ class LocalDeviceHandler {
|
||||
|
||||
public:
|
||||
|
||||
virtual hci_id GetID();
|
||||
hci_id GetID();
|
||||
|
||||
virtual bool Available();
|
||||
bool Available();
|
||||
void Acquire(void);
|
||||
status_t Launch(void);
|
||||
|
||||
BMessage* GetPropertiesMessage(void) { return fProperties; }
|
||||
bool IsPropertyAvailable(const BString& property);
|
||||
|
Loading…
Reference in New Issue
Block a user