18 Commits
Author SHA1 Message Date
Dean a98262ce94 Merge pull request #9339 from MaxLikesCode/feat/usbd-event-calls
feat(libSceUsbd): handle events with FreeBSD libusb's event lock and handler thread
2026-11-02 20:57:30 +13:00
MaxandClaude Opus 5.5 9f3799cfaa fix(libSceUsbd): wake event waiters after each pass of event handling
FreeBSD 11.4's libusb10_handle_events_sub ends every pass, a timed-out
one included, with pthread_cond_broadcast on the context's condition
variable, so a thread in libusb_wait_for_event wakes after each pass of
the handler. Here waiters woke only when the handler unlocked, so a
waiter could sleep through the handler's whole loop. Notify them when
the handler takes the event lock back after a pass.

The follower test that expected a timeout while the handler ran 20 ms
passes now races that wake-up, so guest_usbd checks three cases
instead: a follower with a long timeout returns 0 after a pass, a
follower times out during a longer pass, and a follower returns after
the handler held the event lock past its timeout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 15:27:07 +01:00
MaxandClaude Opus 5.5 c0d8f0a670 test(libSceUsbd): release the event lock while a timed-out waiter finishes
The timed-out follower case joined the follower while the main thread
held the event lock, so a follower whose timeout had expired but which
had not yet reacquired the lock could not return. Keep handling events
in slices, which release the lock, until the follower has returned, and
run the case a second time with the lock held past the follower's
timeout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 15:19:36 +01:00
MaxandClaude Opus 5.5 dbb27b9ef1 feat(libSceUsbd): handle events with FreeBSD libusb's event lock and handler thread
sceUsbdLockEvents, sceUsbdTryLockEvents, sceUsbdUnlockEvents,
sceUsbdLockEventWaiters, sceUsbdUnlockEventWaiters, sceUsbdWaitForEvent,
sceUsbdEventHandlerActive, sceUsbdHandleEvents and
sceUsbdHandleEventsLocked follow FreeBSD 11.4 libusb10_io.c: one lock
for events and their waiters, one handler thread that releases the lock
while the host libusb handles events, and waiters that are woken when
the handler unlocks and take over handling when there is none.
sceUsbdEventHandlingOk now reports whether the calling thread is the
handler, and sceUsbdHandleEventsTimeout takes the same path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 15:19:36 +01:00
simnJS 692cc3e025 test(libSceUsbd): race the cancel on an interrupt endpoint the host can read
The device test raced sceUsbdCancelTransfer on the first interrupt IN endpoint of the device. On Windows the first one can belong to a mouse or keyboard collection, which the system opens exclusively, so libusb's HID backend cannot read it and the submission failed, reported as a failed cancel race. The test now tries each interrupt IN endpoint, requires a refusal to be the host's I/O error with nothing in flight, and races on the first one the host accepts, with a buffer sized from that endpoint.
2026-10-28 14:51:59 +01:00
milescovielloandClaude Opus 5.5 646920d12a test(libSceUsbd): cover the bulk, iso and control transfer fillers and their accessors
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 21:05:09 +00:00
MaxandClaude Opus 5.5 64ae578dda feat(libSceUsbd): pass the device, packet size, alternate setting and halt calls through to libusb
sceUsbdGetDevice, sceUsbdGetDeviceSpeed, sceUsbdGetMaxPacketSize,
sceUsbdGetMaxIsoPacketSize, sceUsbdOpenDeviceWithVidPid,
sceUsbdSetInterfaceAltSetting, sceUsbdClearHalt and
sceUsbdDetachKernelDriver follow FreeBSD 11.4 libusb10.c over the host
libusb. The packet sizes and the alternate setting checks are done as
FreeBSD does them, so the library records which interfaces are claimed,
and a device stays known while a handle to it is open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 01:50:33 +02:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean d490ca219c Merge pull request #9190 from simnJS/feat/usbd-descriptor-queries
feat(libSceUsbd): pass configuration and descriptor queries through to libusb
2026-10-25 00:22:22 +13:00
simnJS 66f467e406 feat(libSceUsbd): pass configuration and descriptor queries through to libusb 2026-10-21 16:57:03 +02:00
al3w0f205 4895ab1a4c test(libSceUsbd): cover sceUsbdFillControlSetup buffer formatting 2026-10-21 07:37:15 -05:00
Semir Kabir 42cf82953c test(libSceUsbd): require a non-null active config interface array 2026-10-12 22:32:42 +02:00
Semir Kabir 6cab297837 test(libSceUsbd): skip null interface altsettings in the interrupt endpoint scan 2026-10-12 22:32:42 +02:00
Semir Kabir faff4a6453 fix(libSceUsbd): cancel transfers under the state lock 2026-10-12 22:32:42 +02:00
Semir Kabir 98d594c9c1 feat(libSceUsbd): pass USB devices and transfers through to the host with libusb 2026-10-12 22:32:42 +02:00
Semir Kabir 33c6e825ab feat(libSceUsbd): declare the device and handle calls for the no-device path 2026-10-11 10:06:27 -07:00
Semir Kabir cbd18363bd feat(libSceUsbd): implement transfer allocation and event handling for the no-device path 2026-10-11 09:40:14 +00:00
Gjon Gojcevic 6e5d70f0cd feat(libSceUsbd): report a USB stack with no devices attached
Init and exit succeed, the device list is empty, event handling waits for its timeout, and calls that need a device throw.
2026-10-08 13:34:39 +02:00