Added a test for MUIA_Listview_SelectChange.
[AROS.git] / workbench / devs / USB / include / usb.h
blobfe3115e425602dd2fba1b978f890b965038086ad
1 #ifndef USB_USB_H
2 #define USB_USB_H
4 /*
5 Copyright (C) 2006 by Michal Schulz
6 $Id$
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Library General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with this program; if not, write to the
20 Free Software Foundation, Inc.,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <stdint.h>
26 #include <exec/ports.h>
27 #include <exec/interrupts.h>
28 #include <hidd/hidd.h>
29 #include <oop/oop.h>
30 #include <utility/utility.h>
31 #include <utility/tagitem.h>
32 #include <usb/usb_core.h>
34 enum USB_PipeType {
35 PIPE_Isochronous,
36 PIPE_Control,
37 PIPE_Bulk,
38 PIPE_Interrupt
42 * Base USB class
45 #define CLID_Hidd_USB "Bus::USB"
46 #define IID_Hidd_USB "IBus::USB"
48 #define HiddUSBAttrBase __IHidd_USB
50 #ifndef __OOP_NOATTRBASES__
51 extern OOP_AttrBase HiddUSBAttrBase;
52 #endif
54 enum {
55 moHidd_USB_AttachDriver,
56 moHidd_USB_DetachDriver,
57 moHidd_USB_AddClass,
58 moHidd_USB_AllocAddress,
59 moHidd_USB_FreeAddress,
60 moHidd_USB_NewDevice, // Internal call used to attach new USB devices to the system
62 NUM_HIDD_USB_METHODS
65 enum {
66 aoHidd_USB_Bus,
68 num_Hidd_USB_Attrs
71 #define aHidd_USB_Bus (HiddUSBAttrBase + aoHidd_USB_Bus)
73 #define IS_USB_ATTR(attr, idx) \
74 (((idx) = (attr) - HiddUSBAttrBase) < num_Hidd_USB_Attrs)
76 /// The Method arguments for USB::AttachDriver call
77 struct pHidd_USB_AttachDriver {
78 OOP_MethodID mID;
79 OOP_Object *driverObject;
82 struct pHidd_USB_DetachDriver {
83 OOP_MethodID mID;
84 OOP_Object *driverObject;
87 struct pHidd_USB_AddClass {
88 OOP_MethodID mID;
89 const char *className;
92 struct pHidd_USB_AllocAddress {
93 OOP_MethodID mID;
94 OOP_Object *driverObject;
97 struct pHidd_USB_FreeAddress {
98 OOP_MethodID mID;
99 OOP_Object *driverObject;
100 uint8_t address;
103 struct pHidd_USB_NewDevice {
104 OOP_MethodID mID;
105 OOP_Object *hub; // New device attached to this hub
106 usb_device_descriptor_t *descriptor;
107 uint8_t fast;
111 * USB Device Class
114 #define CLID_Hidd_USBDevice "Hidd::USBDevice"
115 #define IID_Hidd_USBDevice "IHidd::USBDevice"
117 #define HiddUSBDeviceAttrBase __IHidd_USBDevice
119 #ifndef __OOP_NOATTRBASES__
120 extern OOP_AttrBase HiddUSBDeviceAttrBase;
121 #endif
123 enum {
124 moHidd_USBDevice_GetString,
125 moHidd_USBDevice_CreatePipe,
126 moHidd_USBDevice_DeletePipe,
127 moHidd_USBDevice_ControlMessage,
128 moHidd_USBDevice_GetDescriptor,
129 moHidd_USBDevice_GetConfigDescriptor,
130 moHidd_USBDevice_GetDeviceDescriptor,
131 moHidd_USBDevice_GetStatus,
132 moHidd_USBDevice_Configure,
133 moHidd_USBDevice_GetInterface,
134 moHidd_USBDevice_GetEndpoint,
135 moHidd_USBDevice_BulkTransfer,
136 moHidd_USBDevice_SetTimeout,
138 NUM_HIDD_USBDEVICE_METHODS
141 enum {
142 aoHidd_USBDevice_Address,
143 aoHidd_USBDevice_Bus,
144 aoHidd_USBDevice_Hub,
145 aoHidd_USBDevice_ProductID,
146 aoHidd_USBDevice_VendorID,
147 aoHidd_USBDevice_Interface,
148 aoHidd_USBDevice_InterfaceNumber,
150 aoHidd_USBDevice_ProductName,
151 aoHidd_USBDevice_ManufacturerName,
152 aoHidd_USBDevice_SerialNumber,
154 aoHidd_USBDevice_Fast,
155 aoHidd_USBDevice_MaxPacketSize,
157 aoHidd_USBDevice_Next,
159 num_Hidd_USBDevice_Attrs
162 #define aHidd_USBDevice_Address (HiddUSBDeviceAttrBase + aoHidd_USBDevice_Address)
163 #define aHidd_USBDevice_Bus (HiddUSBDeviceAttrBase + aoHidd_USBDevice_Bus)
164 #define aHidd_USBDevice_Hub (HiddUSBDeviceAttrBase + aoHidd_USBDevice_Hub)
165 #define aHidd_USBDevice_ProductID (HiddUSBDeviceAttrBase + aoHidd_USBDevice_ProductID)
166 #define aHidd_USBDevice_VendorID (HiddUSBDeviceAttrBase + aoHidd_USBDevice_VendorID)
167 #define aHidd_USBDevice_Interface (HiddUSBDeviceAttrBase + aoHidd_USBDevice_Interface)
168 #define aHidd_USBDevice_InterfaceNumber (HiddUSBDeviceAttrBase + aoHidd_USBDevice_InterfaceNumber)
169 #define aHidd_USBDevice_ProductName (HiddUSBDeviceAttrBase + aoHidd_USBDevice_ProductName)
170 #define aHidd_USBDevice_ManufacturerName (HiddUSBDeviceAttrBase + aoHidd_USBDevice_ManufacturerName)
171 #define aHidd_USBDevice_SerialNumber (HiddUSBDeviceAttrBase + aoHidd_USBDevice_SerialNumber)
173 #define aHidd_USBDevice_Fast (HiddUSBDeviceAttrBase + aoHidd_USBDevice_Fast)
174 #define aHidd_USBDevice_MaxPacketSize (HiddUSBDeviceAttrBase + aoHidd_USBDevice_MaxPacketSize)
176 #define aHidd_USBDevice_Next (HiddUSBDeviceAttrBase + aoHidd_USBDevice_Next)
178 #define IS_USBDEVICE_ATTR(attr, idx) \
179 (((idx) = (attr) - HiddUSBDeviceAttrBase) < num_Hidd_USBDevice_Attrs)
181 struct pHidd_USBDevice_GetDescriptor {
182 OOP_MethodID mID;
183 uint8_t type;
184 uint8_t index;
185 uint16_t length;
186 APTR descriptor;
189 struct pHidd_USBDevice_GetConfigDescriptor {
190 OOP_MethodID mID;
191 uint8_t index;
192 usb_config_descriptor_t *descriptor;
195 struct pHidd_USBDevice_GetDeviceDescriptor {
196 OOP_MethodID mID;
197 usb_device_descriptor_t *descriptor;
200 struct pHidd_USBDevice_GetStatus {
201 OOP_MethodID mID;
202 usb_status_t *status;
205 struct pHidd_USBDevice_GetString {
206 OOP_MethodID mID;
207 int8_t id;
208 uint16_t language;
209 usb_string_descriptor_t *string;
212 struct pHidd_USBDevice_ControlMessage {
213 OOP_MethodID mID;
214 APTR pipe;
215 USBDevice_Request *request;
216 APTR buffer;
217 uint32_t length;
220 struct pHidd_USBDevice_CreatePipe {
221 OOP_MethodID mID;
222 enum USB_PipeType type;
223 uint8_t endpoint;
224 uint8_t period;
225 uint16_t maxpacket;
226 uint32_t timeout;
229 struct pHidd_USBDevice_DeletePipe {
230 OOP_MethodID mID;
231 APTR pipe;
234 struct pHidd_USBDevice_Configure {
235 OOP_MethodID mID;
236 uint8_t configNr;
239 struct pHidd_USBDevice_GetInterface {
240 OOP_MethodID mID;
241 uint8_t interface;
244 struct pHidd_USBDevice_GetEndpoint {
245 OOP_MethodID mID;
246 uint8_t interface;
247 uint8_t endpoint;
250 struct pHidd_USBDevice_BulkTransfer {
251 OOP_MethodID mID;
252 APTR pipe;
253 APTR buffer;
254 uint32_t length;
257 struct pHidd_USBDevice_SetTimeout {
258 OOP_MethodID mID;
259 APTR pipe;
260 uint32_t timeout;
265 * USB Hub Class
268 #define CLID_Hidd_USBHub "Hidd::USBHub"
269 #define IID_Hidd_USBHub "IHidd::USBHub"
271 #define HiddUSBHubAttrBase __IHidd_USBHub
273 #ifndef __OOP_NOATTRBASES__
274 extern OOP_AttrBase HiddUSBHubAttrBase;
275 #endif
277 enum {
278 moHidd_USBHub_OnOff,
279 moHidd_USBHub_PortEnable,
280 moHidd_USBHub_PortReset,
281 moHidd_USBHub_GetPortStatus,
282 moHidd_USBHub_GetHubStatus,
283 moHidd_USBHub_ClearHubFeature,
284 moHidd_USBHub_SetHubFeature,
285 moHidd_USBHub_ClearPortFeature,
286 moHidd_USBHub_SetPortFeature,
287 moHidd_USBHub_GetChild,
288 moHidd_USBHub_GetHubDescriptor,
290 NUM_HIDD_USBHUB_METHODS
293 struct pHidd_USBHub_OnOff {
294 OOP_MethodID mID;
295 BOOL on;
298 struct pHidd_USBHub_PortEnable {
299 OOP_MethodID mID;
300 uint8_t portNummer;
301 BOOL enable;
304 struct pHidd_USBHub_PortReset {
305 OOP_MethodID mID;
306 uint8_t portNummer;
309 struct pHidd_USBHub_GetPortStatus {
310 OOP_MethodID mID;
311 uint8_t port;
312 usb_port_status_t *status;
315 struct pHidd_USBHub_GetHubStatus {
316 OOP_MethodID mID;
317 usb_hub_status_t *status;
320 struct pHidd_USBHub_ClearHubFeature {
321 OOP_MethodID mID;
322 int feature;
325 struct pHidd_USBHub_SetHubFeature {
326 OOP_MethodID mID;
327 int feature;
330 struct pHidd_USBHub_ClearPortFeature {
331 OOP_MethodID mID;
332 uint8_t port;
333 int feature;
336 struct pHidd_USBHub_SetPortFeature {
337 OOP_MethodID mID;
338 uint8_t port;
339 int feature;
342 struct pHidd_USBHub_GetChild {
343 OOP_MethodID mID;
344 int8_t port;
347 struct pHidd_USBHub_GetHubDescriptor {
348 OOP_MethodID mID;
349 usb_hub_descriptor_t *descriptor;
352 enum {
353 aoHidd_USBHub_IsRoot,
354 aoHidd_USBHub_IsCompound,
355 aoHidd_USBHub_HubCurrent,
356 aoHidd_USBHub_NumPorts,
358 num_Hidd_USBHub_Attrs
361 #define aHidd_USBHub_IsRoot (HiddUSBHubAttrBase + aoHidd_USBHub_IsRoot)
362 #define aHidd_USBHub_IsCompound (HiddUSBHubAttrBase + aoHidd_USBHub_IsCompound)
363 #define aHidd_USBHub_HubCurrent (HiddUSBHubAttrBase + aoHidd_USBHub_HubCurrent)
364 #define aHidd_USBHub_NumPorts (HiddUSBHubAttrBase + aoHidd_USBHub_NumPorts)
366 #define IS_USBHUB_ATTR(attr, idx) \
367 (((idx) = (attr) - HiddUSBHubAttrBase) < num_Hidd_USBHub_Attrs)
370 #define CLID_Hidd_USBDrv "Hidd::USBDriver"
371 #define IID_Hidd_USBDrv "IHidd::USBDriver"
373 #define HiddUSBDrvAttrBase __IHidd_USBDrv
375 #ifndef __OOP_NOATTRBASES__
376 extern OOP_AttrBase HiddUSBDrvAttrBase;
377 #endif
379 enum {
380 moHidd_USBDrv_CreatePipe,
381 moHidd_USBDrv_DeletePipe,
382 moHidd_USBDrv_ControlTransfer,
383 moHidd_USBDrv_AddInterrupt,
384 moHidd_USBDrv_RemInterrupt,
385 moHidd_USBDrv_BulkTransfer,
386 moHidd_USBDrv_SetTimeout,
388 NUM_HIDD_USBDRV_METHODS
391 enum {
392 num_Hidd_USBDrv_Attrs
395 #define IS_USBDRV_ATTR(attr, idx) \
396 (((idx) = (attr) - HiddUSBDrvAttrBase) < num_Hidd_USBDrv_Attrs)
398 struct pHidd_USBDrv_CreatePipe {
399 OOP_MethodID mID;
400 enum USB_PipeType type;
401 BOOL fullspeed;
402 uint8_t address;
403 uint8_t endpoint;
404 uint8_t period;
405 uint32_t maxpacket;
406 uint32_t timeout;
409 struct pHidd_USBDrv_DeletePipe {
410 OOP_MethodID mID;
411 void *pipe;
414 struct pHidd_USBDrv_ControlTransfer {
415 OOP_MethodID mID;
416 APTR pipe;
417 USBDevice_Request *request;
418 APTR buffer;
419 uint32_t length;
422 struct pHidd_USBDrv_BulkTransfer {
423 OOP_MethodID mID;
424 APTR pipe;
425 APTR buffer;
426 uint32_t length;
429 struct pHidd_USBDrv_AddInterrupt {
430 OOP_MethodID mID;
431 void *pipe;
432 void *buffer;
433 uint8_t length;
434 struct Interrupt *interrupt;
437 struct pHidd_USBDrv_RemInterrupt {
438 OOP_MethodID mID;
439 void *pipe;
440 struct Interrupt *interrupt;
443 struct pHidd_USBDrv_SetTimeout {
444 OOP_MethodID mID;
445 void *pipe;
446 uint32_t timeout;
450 /* USB stubs */
451 BOOL HIDD_USB_AttachDriver(OOP_Object *obj, OOP_Object *driver);
452 BOOL HIDD_USB_DetachDriver(OOP_Object *obj, OOP_Object *driver);
453 void HIDD_USB_AddClass(OOP_Object *obj, const char *className);
454 uint8_t HIDD_USB_AllocAddress(OOP_Object *obj, OOP_Object *driver);
455 void HIDD_USB_FreeAddress(OOP_Object *obj, OOP_Object *driver, uint8_t address);
456 OOP_Object *HIDD_USB_NewDevice(OOP_Object *obj, OOP_Object *hub, BOOL fast);
458 BOOL HIDD_USBDevice_GetDescriptor(OOP_Object *obj, uint8_t type, uint8_t index, uint16_t length, APTR descriptor);
459 BOOL HIDD_USBDevice_GetConfigDescriptor(OOP_Object *obj, uint8_t index, usb_config_descriptor_t *descriptor);
460 BOOL HIDD_USBDevice_GetDeviceDescriptor(OOP_Object *obj, usb_device_descriptor_t *descriptor);
461 BOOL HIDD_USBDevice_GetStatus(OOP_Object *obj, usb_status_t *status);
462 APTR HIDD_USBDevice_CreatePipe(OOP_Object *obj, enum USB_PipeType type, uint8_t endpoint, uint8_t period, uint16_t maxpacket, uint32_t timeout);
463 void HIDD_USBDevice_DeletePipe(OOP_Object *obj, APTR pipe);
464 BOOL HIDD_USBDevice_GetString(OOP_Object *obj, int8_t id, uint16_t language, usb_string_descriptor_t *string);
465 BOOL HIDD_USBDevice_ControlMessage(OOP_Object *obj, APTR pipe, USBDevice_Request *request, APTR buffer, uint32_t length);
466 BOOL HIDD_USBDevice_Configure(OOP_Object *obj, uint8_t configNr);
467 usb_interface_descriptor_t *HIDD_USBDevice_GetInterface(OOP_Object *obj, uint8_t interface);
468 usb_endpoint_descriptor_t *HIDD_USBDevice_GetEndpoint(OOP_Object *obj, uint8_t interface, uint8_t endpoint);
469 BOOL HIDD_USBDevice_BulkTransfer(OOP_Object *obj, APTR pipe, APTR buffer, uint32_t length);
470 void HIDD_USBDevice_SetTimeout(OOP_Object *obj, APTR pipe, uint32_t timeout);
472 BOOL HIDD_USBHub_OnOff(OOP_Object *obj, BOOL on);
473 OOP_Object *HIDD_USBHub_GetChild(OOP_Object *obj, uint8_t port);
474 BOOL HIDD_USBHub_PortEnable(OOP_Object *obj, uint8_t port, BOOL enable);
475 BOOL HIDD_USBHub_PortReset(OOP_Object *obj, uint8_t port);
476 BOOL HIDD_USBHub_GetPortStatus(OOP_Object *obj, uint8_t port, usb_port_status_t *status);
477 BOOL HIDD_USBHub_GetHubStatus(OOP_Object *obj, usb_hub_status_t *status);
478 BOOL HIDD_USBHub_ClearHubFeature(OOP_Object *obj, int feature);
479 BOOL HIDD_USBHub_SetHubFeature(OOP_Object *obj, int feature);
480 BOOL HIDD_USBHub_ClearPortFeature(OOP_Object *obj, uint8_t port, int feature);
481 BOOL HIDD_USBHub_SetPortFeature(OOP_Object *obj, uint8_t port, int feature);
482 BOOL HIDD_USBHub_GetHubDescriptor(OOP_Object *obj, usb_hub_descriptor_t *descriptor);
484 APTR HIDD_USBDrv_CreatePipe(OOP_Object *obj, enum USB_PipeType type, BOOL fullspeed, uint8_t address, uint8_t endpoint, uint8_t period, uint32_t maxpacket, uint32_t timeout);
485 void HIDD_USBDrv_DeletePipe(OOP_Object *obj, APTR pipe);
486 BOOL HIDD_USBDrv_ControlTransfer(OOP_Object *obj, APTR pipe, USBDevice_Request *request, APTR buffer, uint32_t length);
487 BOOL HIDD_USBDrv_AddInterrupt(OOP_Object *obj, void *pipe, void *buffer, uint8_t length, struct Interrupt *interrupt);
488 BOOL HIDD_USBDrv_RemInterrupt(OOP_Object *obj, void *pipe, struct Interrupt *interrupt);
489 BOOL HIDD_USBDrv_BulkTransfer(OOP_Object *obj, APTR pipe, APTR buffer, uint32_t length);
490 void HIDD_USBDrv_SetTimeout(OOP_Object *obj, APTR pipe, uint32_t timeout);
492 #endif /*USB_USB_H*/