2 * Haiku Backend for libusb
3 * Copyright © 2014 Akshay Jaggi <akshay1994.leo@gmail.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "haiku_usb_raw.h"
31 class USBDeviceHandle;
36 USBDevice(const char *);
38 const char* Location() const;
39 uint8 CountConfigurations() const;
40 const usb_device_descriptor* Descriptor() const;
41 const usb_configuration_descriptor* ConfigurationDescriptor(uint32) const;
42 const usb_configuration_descriptor* ActiveConfiguration() const;
43 uint8 EndpointToIndex(uint8) const;
44 uint8 EndpointToInterface(uint8) const;
45 int ClaimInterface(int);
46 int ReleaseInterface(int);
47 int CheckInterfacesFree(int);
48 int SetActiveConfiguration(int);
49 int ActiveConfigurationIndex() const;
53 unsigned int fClaimedInterfaces; // Max Interfaces can be 32. Using a bitmask
54 usb_device_descriptor fDeviceDescriptor;
55 unsigned char** fConfigurationDescriptors;
56 int fActiveConfiguration;
58 map<uint8,uint8> fConfigToIndex;
59 map<uint8,uint8>* fEndpointToIndex;
60 map<uint8,uint8>* fEndpointToInterface;
64 class USBDeviceHandle {
66 USBDeviceHandle(USBDevice *dev);
67 virtual ~USBDeviceHandle();
68 int ClaimInterface(int);
69 int ReleaseInterface(int);
70 int SetConfiguration(int);
71 int SetAltSetting(int, int);
72 status_t SubmitTransfer(struct usbi_transfer *);
73 status_t CancelTransfer(USBTransfer *);
77 static status_t TransfersThread(void *);
78 void TransfersWorker();
79 USBDevice* fUSBDevice;
80 unsigned int fClaimedInterfaces;
82 BLocker fTransfersLock;
84 thread_id fTransfersThread;
90 USBTransfer(struct usbi_transfer *, USBDevice *);
91 virtual ~USBTransfer();
93 struct usbi_transfer* UsbiTransfer();
97 struct usbi_transfer* fUsbiTransfer;
98 struct libusb_transfer* fLibusbTransfer;
99 USBDevice* fUSBDevice;
107 virtual ~USBRoster();