Commit Graph

9 Commits

Author SHA1 Message Date
Lephe 3a2a194693
usb: unaligned reading (release candidate on features)
The only thing left on the bucket list is performance.
2023-03-26 11:36:40 +02:00
Lephe 4983849510
usb: consolidate reading logic again, now beta-worthy
This looks like it could work in the long term. The only issue that
really hasn't been addressed is how to use packet counters to cut
transactions when there's no ZLP, but we can leave that for later.
2023-03-18 19:51:57 +01:00
Lephe fc1f510288
usb: consolidate reading mode (basic multi-segment reads now working) 2023-03-12 17:53:44 +01:00
Lephe c59b2f90fb
usb: prototype reading mode
Currently only tested with short messages using the fxlink interface.
There is much to be expanded upon, but this is a worthy start.
2023-03-04 18:06:38 +01:00
Lephe af5c16a3d3
usb: massively improve writing logic
* Move logic around tracking transfers to asyncio.c.

* Add a "short buffer" holding 0-3 bytes between writes, so that the
  driver performs only 4-byte writes in the FIFO and a short write in
  the commit, if needed.
  - This is partially due to me thinking at some point that degrading
    writing size was impossible, but it might actually be possible by
    writing to FIFO/FIFO+2 or FIFO/FIFO+1/FIFO+2/FIFO+3.
  - In any case I think this new approach wins on performance.

* Get rid of unit_size since we now always use 4 bytes.

* Add a waiting function which is used in usb_close() (and once tested
  should be used in world switches too).

* Eliminate some of the special cases for the DCP, though not all (in
  particular I can't get the commit to rely on the BEMP interrupt yet,
  nor can I properly clear PID to NAK when unbinding).
2023-02-09 23:00:44 +01:00
Lephe d3a2cf07a0
usb: add video capture through the fxlink protocol 2021-08-11 01:43:26 +02:00
Lephe 8e730c2f78
replace gint/std headers with standard ones 2021-06-08 11:01:27 +02:00
Lephe a547235f8f
usb: FIFO controllers and fxlink API
This changes fixes the way gint uses the FIFO controllers D0F and D1F
to access the FIFO. It previously used D0F in the main thread and D1F
during interrupt handling, but this is incorrect for several reasons,
mainly the possible change of controllers between a write and a commit,
and numerous instances of two FIFOs managing the same pipe caused by
the constant switching.

gint now treats FIFO controllers as resources allocated to pipes for
the duration of a commit-terminated sequence of writes. The same
controller is used for a single pipe in both normal and interrupt
modes, and released when the pipe is committed. If no controller is
available, asynchronous writes fail and synchronous ones wait.

The fxlink API is also added with a small amount of functions, namely
to transfer screenshots and raw text. Currently these are synchronous
and do not use the DMA, this will be improved later.

Finally:
* Removed pipe logic from src/usb/setup.c, instead letting pipes.c
  handle the special case of the DCP (which might be regularized later)
* Removed the usb_pipe_mode_{read,write} functions as they're actually
  about FIFo controllers and it's not clear yet how a pipe with both
  read and write should be handled. This is left for the future.
* Clarified end-of-sequence semantics after a successful commit.
2021-05-12 09:17:25 +02:00
Lephe 1315c26099
usb: USB 2.0 function driver (WIP)
* Add the power management functions (mostly stable even under
  overclock; requires some testing, but no known issue)

* Add a dynamic configuration system where interfaces can declare
  descriptors with arbitrary endpoint numbers and additional
  parameters, and the driver allocates USB resources (endpoints, pipes
  and FIFO memory) between interfaces at startup. This allows
  implementations of different classes to be independent from each
  other.

* Add responses to common SETUP requests.

* Add pipe logic that allows programs to write data synchronously or
  asynchronously to pipes, in a single or several fragments, regardless
  of the buffer size (still WIP with a few details to polish and the
  API is not public yet).

* Add a WIP bulk IN interface that allows sending data to the host.
  This will eventually support the fxlink protocol.
2021-04-11 19:04:54 +02:00