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