@@ -64,8 +64,10 @@ distribution.
6464#define USBV0_IOCTL_DEVREMOVALHOOK 26
6565#define USBV0_IOCTL_DEVINSERTHOOK 27
6666#define USBV0_IOCTL_DEVICECLASSCHANGE 28
67+ #define USBV0_IOCTL_RESETDEVICE 29
6768
6869#define USBV4_IOCTL_GETVERSION 6 // returns 0x40001
70+ #define USBV4_IOCTL_CANCELINTERRUPT 8
6971
7072#define USBV5_IOCTL_GETVERSION 0 // should return 0x50001
7173#define USBV5_IOCTL_GETDEVICECHANGE 1
@@ -1430,7 +1432,7 @@ s32 USB_SetAlternativeInterface(s32 fd, u8 interface, u8 alternateSetting)
14301432 return __usb_control_message (fd , (USB_CTRLTYPE_DIR_HOST2DEVICE | USB_CTRLTYPE_TYPE_STANDARD | USB_CTRLTYPE_REC_INTERFACE ), USB_REQ_SETINTERFACE , alternateSetting , interface , 0 , NULL , NULL , NULL );
14311433}
14321434
1433- static s32 USBV5_CancelEndpoint (s32 device_id , u8 endpoint )
1435+ static s32 USBV5_CancelEndpoint (s32 device_id )
14341436{
14351437 s32 ret ;
14361438 s32 fd ;
@@ -1446,17 +1448,34 @@ static s32 USBV5_CancelEndpoint(s32 device_id, u8 endpoint)
14461448 if (buf == NULL ) return IPC_ENOMEM ;
14471449
14481450 buf [0 ] = device_id ;
1449- buf [2 ] = endpoint ;
1451+
1452+ //Cancel all control messages
1453+ buf [2 ] = 0x00 ;
14501454 ret = IOS_Ioctl (fd , USBV5_IOCTL_CANCELENDPOINT , buf , 32 , NULL , 0 );
1455+ if (ret < 0 )
1456+ goto ret ;
1457+
1458+ //Cancel all incoming interrupts
1459+ buf [2 ] = 0x01 << 24 ;
1460+ ret = IOS_Ioctl (fd , USBV5_IOCTL_CANCELENDPOINT , buf , 32 , NULL , 0 );
1461+ if (ret < 0 )
1462+ goto ret ;
1463+
1464+ //Cancel all outgoing interrupts
1465+ buf [2 ] = 0x02 << 24 ;
1466+ ret = IOS_Ioctl (fd , USBV5_IOCTL_CANCELENDPOINT , buf , 32 , NULL , 0 );
1467+ if (ret < 0 )
1468+ goto ret ;
1469+
1470+ ret :
14511471 iosFree (hId , buf );
1452-
14531472 return ret ;
14541473}
14551474
14561475s32 USB_ClearHalt (s32 fd , u8 endpoint )
14571476{
14581477 if (fd >=0x20 || fd < -1 )
1459- return USBV5_CancelEndpoint (fd , endpoint );
1478+ return USBV5_CancelEndpoint (fd );
14601479 return __usb_control_message (fd , (USB_CTRLTYPE_DIR_HOST2DEVICE | USB_CTRLTYPE_TYPE_STANDARD | USB_CTRLTYPE_REC_ENDPOINT ), USB_REQ_CLEARFEATURE , USB_FEATURE_ENDPOINT_HALT , endpoint , 0 , NULL , NULL , NULL );
14611480}
14621481
0 commit comments