Let it B, let it B...

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19904 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol
2007-01-22 16:55:37 +00:00
parent 72abc68c9f
commit 2781a652ae
+48 -48
View File
@@ -14,20 +14,20 @@
#include <List.h>
class USBDevice;
class USBEndpoint;
class USBInterface;
class USBConfiguration;
class USBRosterLooper;
class BUSBDevice;
class BUSBEndpoint;
class BUSBInterface;
class BUSBConfiguration;
class BUSBRosterLooper;
class USBEndpoint
class BUSBEndpoint
{
public:
// Connectivity functions (this endpoint belongs to an Interface that
// belongs to a Configuration that belongs to a Device)
const USBInterface *Interface(void) const;
const USBConfiguration *Configuration(void) const;
const USBDevice *Device(void) const;
const BUSBInterface *Interface(void) const;
const BUSBConfiguration *Configuration(void) const;
const BUSBDevice *Device(void) const;
// Raw descriptor data
const usb_endpoint_descriptor *Descriptor(void) const;
@@ -46,27 +46,27 @@ public:
status_t BulkTransfer(void *data, size_t length) const;
private:
friend USBDevice; // Only created by a USBDevice
friend USBInterface; // Only destroyed by a containing USBInterface
USBEndpoint(uint32 n, USBInterface *ifc);
~USBEndpoint();
friend BUSBDevice; // Only created by a USBDevice
friend BUSBInterface; // Only destroyed by a containing USBInterface
BUSBEndpoint(uint32 n, BUSBInterface *ifc);
~BUSBEndpoint();
USBInterface *interface;
BUSBInterface *interface;
usb_endpoint_descriptor descriptor;
uint32 endpoint_num;
};
class USBInterface
class BUSBInterface
{
public:
// Connectivity functions (this Interface belongs to a Configuration which
// belongs to a Device)
const USBConfiguration *Configuration(void) const;
const USBDevice *Device(void) const;
const BUSBConfiguration *Configuration(void) const;
const BUSBDevice *Device(void) const;
// Iterate over the Endpoints defined by this Interface
uint32 CountEndpoints(void) const;
const USBEndpoint *EndpointAt(uint32 n) const;
const BUSBEndpoint *EndpointAt(uint32 n) const;
// Access the raw descriptor
const usb_interface_descriptor *Descriptor(void) const;
@@ -78,46 +78,46 @@ public:
const char *InterfaceString(void) const;
private:
friend USBDevice; // only created by USBDevice
friend USBConfiguration; // only destroyed by the containing Configuration
USBInterface(uint32 n, USBConfiguration *cfc);
~USBInterface();
friend BUSBDevice; // only created by USBDevice
friend BUSBConfiguration; // only destroyed by the containing Configuration
BUSBInterface(uint32 n, BUSBConfiguration *cfc);
~BUSBInterface();
USBConfiguration *configuration;
BUSBConfiguration *configuration;
usb_interface_descriptor descriptor;
uint32 interface_num;
BList endpoints;
};
class USBConfiguration
class BUSBConfiguration
{
public:
// Connectivity functions (this Configuration belongs to a Device)
const USBDevice *Device(void) const;
const BUSBDevice *Device(void) const;
// Iterators for the Interfaces provided by this Configuration
uint32 CountInterfaces(void) const;
const USBInterface *InterfaceAt(uint32 n) const;
const BUSBInterface *InterfaceAt(uint32 n) const;
// Access the raw descriptor
const usb_configuration_descriptor *Descriptor(void) const;
private:
friend USBDevice;
USBConfiguration(uint n, USBDevice *dev);
~USBConfiguration();
friend BUSBDevice;
BUSBConfiguration(uint n, BUSBDevice *dev);
~BUSBConfiguration();
USBDevice *device;
BUSBDevice *device;
uint configuration_num;
usb_configuration_descriptor descriptor;
BList interfaces;
};
class USBDevice
class BUSBDevice
{
public:
USBDevice(const char *path = NULL);
virtual ~USBDevice();
BUSBDevice(const char *path = NULL);
virtual ~BUSBDevice();
virtual status_t InitCheck(void);
status_t SetTo(const char *path);
@@ -153,23 +153,23 @@ public:
// Iterate over the possible configurations
uint32 CountConfigurations(void) const;
const USBConfiguration *ConfigurationAt(uint32 n) const;
const BUSBConfiguration *ConfigurationAt(uint32 n) const;
// View and select the active configuration
const USBConfiguration *ActiveConfiguration(void) const;
status_t SetConfiguration(const USBConfiguration *conf);
const BUSBConfiguration *ActiveConfiguration(void) const;
status_t SetConfiguration(const BUSBConfiguration *conf);
// Initiate a Control (endpoint 0) transaction
status_t ControlTransfer(uint8 request_type, uint8 request, uint16 value,
uint16 index, uint16 length, void *data) const;
private:
status_t InterruptTransfer(const USBEndpoint *e, void *data, size_t length) const;
status_t BulkTransfer(const USBEndpoint *e, void *data, size_t length) const;
status_t InterruptTransfer(const BUSBEndpoint *e, void *data, size_t length) const;
status_t BulkTransfer(const BUSBEndpoint *e, void *data, size_t length) const;
void Release(void);
void PopulateInterface(USBInterface *ifc, usb_interface_descriptor *descr);
void PopulateConfig(USBConfiguration *conf, usb_configuration_descriptor *descr);
void PopulateInterface(BUSBInterface *ifc, usb_interface_descriptor *descr);
void PopulateConfig(BUSBConfiguration *conf, usb_configuration_descriptor *descr);
void PopulateDevice(void);
mutable char *serial_string; // Cache the string descriptors
@@ -179,27 +179,27 @@ private:
bool ishub;
int fd; // Connection to /dev/bus/usb/...
usb_device_descriptor descriptor; // Cache the descriptor
USBConfiguration *active; // Current active configuration
BUSBConfiguration *active; // Current active configuration
BList configurations; // All possible configurations
friend USBEndpoint; // USBEndpoint uses the XxxTransfer() methods
friend BUSBEndpoint; // USBEndpoint uses the XxxTransfer() methods
};
class USBRoster
class BUSBRoster
{
public:
USBRoster(void);
virtual ~USBRoster();
BUSBRoster(void);
virtual ~BUSBRoster();
// DeviceAdded() is called when a new device appears on the Bus.
// If the result is not B_OK, the USBDevice instance is deleted and
// there will be no DeviceRemoved notification.
virtual status_t DeviceAdded(USBDevice *dev) = 0;
virtual status_t DeviceAdded(BUSBDevice *dev) = 0;
// DeviceRemoved() is called when a device is disconnected from the Bus.
// The USBDevice WILL BE deleted after this method returns.
virtual void DeviceRemoved(USBDevice *dev) = 0;
virtual void DeviceRemoved(BUSBDevice *dev) = 0;
void Start(void);
void Stop(void);
@@ -208,4 +208,4 @@ private:
};
#endif
#endif