7#ifndef _PSP2KERN_USBD_H_
8#define _PSP2KERN_USBD_H_
18#define SCE_USBD_PROBE_SUCCEEDED (0)
19#define SCE_USBD_PROBE_FAILED (-1)
20#define SCE_USBD_ATTACH_SUCCEEDED (0)
21#define SCE_USBD_ATTACH_FAILED (-1)
22#define SCE_USBD_DETACH_SUCCEEDED (0)
23#define SCE_USBD_DETACH_FAILED (-1)
25#define SCE_USBD_MAX_LS_CONTROL_PACKET_SIZE 8
26#define SCE_USBD_MAX_FS_CONTROL_PACKET_SIZE 64
27#define SCE_USBD_MAX_ISOCHRONOUS_PACKET_SIZE 1023
28#define SCE_USBD_MAX_LS_INTERRUPT_PACKET_SIZE 8
29#define SCE_USBD_MAX_FS_INTERRUPT_PACKET_SIZE 64
30#define SCE_USBD_MAX_BULK_PACKET_SIZE 64
32#define SCE_USBD_FEATURE_ENDPOINT_HALT 0x00
33#define SCE_USBD_FEATURE_DEVICE_REMOTE_WAKEUP 0x01
301#define SCE_USBD_DEVICE_SPEED_LS (0)
302#define SCE_USBD_DEVICE_SPEED_FS (1)
303#define SCE_USBD_DEVICE_SPEED_HS (2)
306#define ksceUsbdSetConfiguration(pid, config, cb, arg) ({ \
307 SceUsbdDeviceRequest _dr; \
308 _dr.bmRequestType = 0x00; \
309 _dr.bRequest = SCE_USBD_REQUEST_SET_CONFIGURATION; \
310 _dr.wValue = (config); \
313 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
316#define ksceUsbdClearDeviceFeature(pid, fs, cb, arg) ({ \
317 SceUsbdDeviceRequest _dr; \
318 _dr.bmRequestType = 0x00; \
319 _dr.bRequest = SCE_USBD_REQUEST_CLEAR_FEATURE; \
323 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
325#define ksceUsbdClearInterfaceFeature(pid, fs, interface, cb, arg) ({ \
326 SceUsbdDeviceRequest _dr; \
327 _dr.bmRequestType = 0x01; \
328 _dr.bRequest = SCE_USBD_REQUEST_CLEAR_FEATURE; \
330 _dr.wIndex = (interface); \
332 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
334#define ksceUsbdClearEndpointFeature(pid, fs, endpoint, cb, arg) ({ \
335 SceUsbdDeviceRequest _dr; \
336 _dr.bmRequestType = 0x02; \
337 _dr.bRequest = SCE_USBD_REQUEST_CLEAR_FEATURE; \
339 _dr.wIndex = (endpoint); \
341 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
343#define ksceUsbdGetConfiguration(pid, ptr, cb, arg) ({ \
344 SceUsbdDeviceRequest _dr; \
345 _dr.bmRequestType = 0x80; \
346 _dr.bRequest = SCE_USBD_REQUEST_GET_CONFIGURATION; \
350 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
352#define ksceUsbdGetDescriptor(pid, type, index, lang_id, ptr, len, cb, arg) ({ \
353 SceUsbdDeviceRequest _dr; \
354 _dr.bmRequestType = 0x80; \
355 _dr.bRequest = SCE_USBD_REQUEST_GET_DESCRIPTOR; \
356 _dr.wValue = ((type) << 8) | (index); \
357 _dr.wIndex = (lang_id); \
358 _dr.wLength = (len); \
359 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
361#define ksceUsbdGetInterface(pid, interface, ptr, cb, arg) ({ \
362 SceUsbdDeviceRequest _dr; \
363 _dr.bmRequestType = 0x81; \
364 _dr.bRequest = SCE_USBD_REQUEST_GET_INTERFACE; \
366 _dr.wIndex = (interface); \
368 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
370#define ksceUsbdGetDeviceStatus(pid, ptr, cb, arg) ({ \
371 SceUsbdDeviceRequest _dr; \
372 _dr.bmRequestType = 0x80; \
373 _dr.bRequest = SCE_USBD_REQUEST_GET_STATUS; \
377 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
379#define ksceUsbdGetInterfaceStatus(pid, interface, ptr, cb, arg) ({ \
380 SceUsbdDeviceRequest _dr; \
381 _dr.bmRequestType = 0x81; \
382 _dr.bRequest = SCE_USBD_REQUEST_GET_STATUS; \
384 _dr.wIndex = (interface); \
386 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
388#define ksceUsbdGetEndpointStatus(pid, endpoint, ptr, cb, arg) ({ \
389 SceUsbdDeviceRequest _dr; \
390 _dr.bmRequestType = 0x82; \
391 _dr.bRequest = SCE_USBD_REQUEST_GET_STATUS; \
393 _dr.wIndex = (endpoint); \
395 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
397#define ksceUsbdSetAddress(pid, address, cb, arg) ({ \
398 SceUsbdDeviceRequest _dr; \
399 _dr.bmRequestType = 0x00; \
400 _dr.bRequest = SCE_USBD_REQUEST_SET_ADDRESS; \
401 _dr.wValue = (address); \
404 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
406#define ksceUsbdSetConfiguration(pid, config, cb, arg) ({ \
407 SceUsbdDeviceRequest _dr; \
408 _dr.bmRequestType = 0x00; \
409 _dr.bRequest = SCE_USBD_REQUEST_SET_CONFIGURATION; \
410 _dr.wValue = (config); \
413 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
415#define ksceUsbdSetDeviceDescriptor(pid, type, index, lang_id, ptr, len, \
417 SceUsbdDeviceRequest _dr; \
418 _dr.bmRequestType = 0x00; \
419 _dr.bRequest = SCE_USBD_REQUEST_SET_DESCRIPTOR; \
420 _dr.wValue = ((type) << 8) | (index); \
421 _dr.wIndex = (lang_id); \
422 _dr.wLength = (len); \
423 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
425#define ksceUsbdSetInterfaceDescriptor(pid, type, index, lang_id, ptr, len, \
427 SceUsbdDeviceRequest _dr; \
428 _dr.bmRequestType = 0x01; \
429 _dr.bRequest = SCE_USBD_REQUEST_SET_DESCRIPTOR; \
430 _dr.wValue = ((type) << 8) | (index); \
431 _dr.wIndex = (lang_id); \
432 _dr.wLength = (len); \
433 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
435#define ksceUsbdSetEndpointDescriptor(pid, type, index, lang_id, ptr, len, \
437 SceUsbdDeviceRequest _dr; \
438 _dr.bmRequestType = 0x02; \
439 _dr.bRequest = SCE_USBD_REQUEST_SET_DESCRIPTOR; \
440 _dr.wValue = ((type) << 8) | (index); \
441 _dr.wIndex = (lang_id); \
442 _dr.wLength = (len); \
443 ksceUsbdControlTransfer((pid), (&_dr), (ptr), (cb), (arg)); })
445#define ksceUsbdSetDeviceFeature(pid, fs, cb, arg) ({ \
446 SceUsbdDeviceRequest _dr; \
447 _dr.bmRequestType = 0x00; \
448 _dr.bRequest = SCE_USBD_REQUEST_SET_FEATURE; \
452 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
454#define ksceUsbdSetInterfaceFeature(pid, fs, interface, cb, arg) ({ \
455 SceUsbdDeviceRequest _dr; \
456 _dr.bmRequestType = 0x01; \
457 _dr.bRequest = SCE_USBD_REQUEST_SET_FEATURE; \
459 _dr.wIndex = (interface); \
461 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
463#define ksceUsbdSetEndpointFeature(pid, fs, endpoint, cb, arg) ({ \
464 SceUsbdDeviceRequest _dr; \
465 _dr.bmRequestType = 0x02; \
466 _dr.bRequest = SCE_USBD_REQUEST_SET_FEATURE; \
468 _dr.wIndex = (endpoint); \
470 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
472#define ksceUsbdSetInterface(pid, interface, alt_setting, cb, arg) ({ \
473 SceUsbdDeviceRequest _dr; \
474 _dr.bmRequestType = 0x01; \
475 _dr.bRequest = SCE_USBD_REQUEST_SET_INTERFACE; \
476 _dr.wValue = (alt_setting); \
477 _dr.wIndex = (interface); \
479 ksceUsbdControlTransfer((pid), (&_dr), NULL, (cb), (arg)); })
481#define ksceUsbdSynchFrame(pid, endpoint, pfn, cb, arg) ({ \
482 SceUsbdDeviceRequest _dr; \
483 _dr.bmRequestType = 0x82; \
484 _dr.bRequest = SCE_USBD_REQUEST_SYNCH_FRAME; \
486 _dr.wIndex = (endpoint); \
488 ksceUsbdControlTransfer((pid), (&_dr), pfn, (cb), (arg)); })
491#define OHCI_CC_NO_ERROR 0x0
492#define OHCI_CC_CRC 0x1
493#define OHCI_CC_BIT_STUFFING 0x2
494#define OHCI_CC_DATA_TOGGLE_MISMATCH 0x3
495#define OHCI_CC_STALL 0x4
496#define OHCI_CC_DEVICE_NOT_RESPONDING 0x5
497#define OHCI_CC_PID_CHECK_FAILURE 0x6
498#define OHCI_CC_UNEXPECTED_PID 0x7
499#define OHCI_CC_DATA_OVERRUN 0x8
500#define OHCI_CC_DATA_UNDERRUN 0x9
501#define OHCI_CC_BUFFER_OVERRUN 0xc
502#define OHCI_CC_BUFFER_UNDERRUN 0xd
503#define OHCI_CC_NOT_ACCESSED1 0xe
504#define OHCI_CC_NOT_ACCESSED2 0xf
505#define EHCI_CC_MISSED_MICRO_FRAME 0x10
506#define EHCI_CC_XACT 0x20
507#define EHCI_CC_BABBLE 0x30
508#define EHCI_CC_DATABUF 0x40
509#define EHCI_CC_HALTED 0x50
512#define USBD_CC_NOERR 0x0
513#define USBD_CC_MISSED_MICRO_FRAME 0x1
514#define USBD_CC_XACTERR 0x2
515#define USBD_CC_BABBLE 0x4
516#define USBD_CC_DATABUF 0x8
#define VITASDK_BUILD_ASSERT_EQ(__size__, __name__)
Definition build_utils.h:13
uint8_t type
0 = read?, 1 = write?, 2 = feature?, 3 = ?
Definition bt.h:2
void * buffer
Definition bt.h:6
uint32_t length
Definition bt.h:7
unsigned int SceSize
Definition types.h:56
int SceUID
UIDs are used to describe many different kernel objects.
Definition types.h:90
uint8_t bRequest
Definition usbd.h:54
SceUsbdDescriptorType
Definition usbd.h:46
int ksceUsbdBulkTransfer2(int pipe_id, unsigned char *buffer, unsigned int length, ksceUsbdDoneCallback cb, void *user_data)
Transfer data to/from endpoint.
int(* probe)(int device_id)
Definition usbd.h:38
int ksceUsbdControlTransfer(SceUID pipe_id, const SceUsbdDeviceRequest *req, unsigned char *buffer, ksceUsbdDoneCallback cb, void *user_data)
Transfer data to/from endpoint.
int ksceUsbdSuspendPhase2(int port, int flag)
const char * name
Definition usbd.h:45
int(* attach)(int device_id)
Definition usbd.h:47
int ksceUsbdHostStart(int port)
void(* ksceUsbdDoneCallback)(int32_t result, int32_t count, void *arg)
Definition usbd.h:179
uint16_t wValue
Definition usbd.h:55
int32_t relative_start_frame
Definition usbd.h:99
int ksceUsbdRegisterCompositeLdd(const SceUsbdCompositeDriver *driver)
Register USB driver for composite devices.
void(* ksceUsbdIsochDoneCallback)(int32_t result, ksceUsbdIsochTransfer *req, void *arg)
Definition usbd.h:180
const char * name
Definition usbd.h:37
uint16_t wIndex
Definition usbd.h:56
int(* attach)(int device_id)
Definition usbd.h:39
int ksceUsbdIsochronousTransfer(SceUID pipe_id, ksceUsbdIsochTransfer *transfer, ksceUsbdIsochDoneCallback cb, void *user_data)
Transfer isochronous data to/from endpoint.
int(* detach)(int device_id)
Definition usbd.h:48
int ksceUsbdResume(int port)
uint16_t PSW
Definition usbd.h:93
void * ksceUsbdScanStaticDescriptor(SceUID device_id, void *start, SceUsbdDescriptorType type)
Return usb descriptor.
int ksceUsbdClosePipe(SceUID pipe_id)
Close communication pipe to endpoint.
SceUID ksceUsbdOpenPipe(int device_id, SceUsbdEndpointDescriptor *endpoint)
Open communication pipe to endpoint.
uint16_t wLength
Definition usbd.h:57
int ksceUsbdBulkTransfer(SceUID pipe_id, unsigned char *buffer, unsigned int length, ksceUsbdDoneCallback cb, void *user_data)
Transfer data to/from endpoint.
int ksceUsbdInterruptTransfer(SceUID pipe_id, unsigned char *buffer, SceSize length, ksceUsbdDoneCallback cb, void *user_data)
Transfer data to/from interrupt endpoint.
int(* detach)(int device_id)
Definition usbd.h:40
int ksceUsbdGetDeviceSpeed(int device_id, uint8_t *speed)
Get device speed.
int ksceUsbdHostStop(int port)
uint8_t bmRequestType
Definition usbd.h:53
int ksceUsbdUnregisterCompositeLdd(const SceUsbdCompositeDriver *driver)
De-register USB driver for composite devices.
uint16_t len
Definition usbd.h:92
int(* probe)(int device_id, SceUsbdEndpointDescriptor *desc)
Definition usbd.h:46
int ksceUsbdRegisterDriver(const SceUsbdDriver *driver)
Register USB driver.
int ksceUsbd_05073925(SceUID device_id, int *unk1, int *unk2)
int ksceUsbdSuspend(int port)
unsigned short unk1
Definition usbd.h:1
void * buffer_base
Definition usbd.h:98
int ksceUsbdGetDeviceLocation(SceUID device_id, uint8_t *location)
Get device location.
int ksceUsbd_7938DAC7(SceUID pipe_id)
int32_t num_packets
Definition usbd.h:100
SceUsbdReqtype
Definition usbd.h:61
ksceUsbdIsochPswLen packets[8]
Definition usbd.h:101
SceUsbdRequest
Definition usbd.h:77
int ksceUsbdUnregisterDriver(const SceUsbdDriver *driver)
De-register USB driver.
@ SCE_USBD_REQTYPE_DIR_TO_HOST
Definition usbd.h:64
@ SCE_USBD_REQTYPE_TYPE_CLASS
Definition usbd.h:67
@ SCE_USBD_REQTYPE_RECIP_BITS
Definition usbd.h:70
@ SCE_USBD_REQTYPE_TYPE_STANDARD
Definition usbd.h:66
@ SCE_USBD_REQTYPE_TYPE_RESERVED
Definition usbd.h:69
@ SCE_USBD_REQTYPE_RECIP_INTERFACE
Definition usbd.h:72
@ SCE_USBD_REQTYPE_TYPE_BITS
Definition usbd.h:65
@ SCE_USBD_REQTYPE_RECIP_DEVICE
Definition usbd.h:71
@ SCE_USBD_REQTYPE_RECIP_ENDPOINT
Definition usbd.h:73
@ SCE_USBD_REQTYPE_TYPE_VENDOR
Definition usbd.h:68
@ SCE_USBD_REQTYPE_DIR_TO_DEVICE
Definition usbd.h:63
@ SCE_USBD_REQTYPE_RECIP_OTHER
Definition usbd.h:74
@ SCE_USBD_REQTYPE_DIR_BITS
Definition usbd.h:62
@ SCE_USBD_REQUEST_SET_FEATURE
Definition usbd.h:80
@ SCE_USBD_REQUEST_GET_STATUS
Definition usbd.h:78
@ SCE_USBD_REQUEST_SYNCH_FRAME
Definition usbd.h:88
@ SCE_USBD_REQUEST_SET_DESCRIPTOR
Definition usbd.h:83
@ SCE_USBD_REQUEST_SET_ADDRESS
Definition usbd.h:81
@ SCE_USBD_REQUEST_GET_DESCRIPTOR
Definition usbd.h:82
@ SCE_USBD_REQUEST_GET_CONFIGURATION
Definition usbd.h:84
@ SCE_USBD_REQUEST_GET_INTERFACE
Definition usbd.h:86
@ SCE_USBD_REQUEST_SET_INTERFACE
Definition usbd.h:87
@ SCE_USBD_REQUEST_CLEAR_FEATURE
Definition usbd.h:79
@ SCE_USBD_REQUEST_SET_CONFIGURATION
Definition usbd.h:85