|
2 | 2 | How FunctionFS works
|
3 | 3 | ====================
|
4 | 4 |
|
| 5 | +Overview |
| 6 | +======== |
| 7 | + |
5 | 8 | From kernel point of view it is just a composite function with some
|
6 | 9 | unique behaviour. It may be added to an USB configuration only after
|
7 | 10 | the user space driver has registered by writing descriptors and
|
@@ -66,3 +69,36 @@ have been written to their ep0's.
|
66 | 69 |
|
67 | 70 | Conversely, the gadget is unregistered after the first USB function
|
68 | 71 | closes its endpoints.
|
| 72 | + |
| 73 | +DMABUF interface |
| 74 | +================ |
| 75 | + |
| 76 | +FunctionFS additionally supports a DMABUF based interface, where the |
| 77 | +userspace can attach DMABUF objects (externally created) to an endpoint, |
| 78 | +and subsequently use them for data transfers. |
| 79 | + |
| 80 | +A userspace application can then use this interface to share DMABUF |
| 81 | +objects between several interfaces, allowing it to transfer data in a |
| 82 | +zero-copy fashion, for instance between IIO and the USB stack. |
| 83 | + |
| 84 | +As part of this interface, three new IOCTLs have been added. These three |
| 85 | +IOCTLs have to be performed on a data endpoint (ie. not ep0). They are: |
| 86 | + |
| 87 | + ``FUNCTIONFS_DMABUF_ATTACH(int)`` |
| 88 | + Attach the DMABUF object, identified by its file descriptor, to the |
| 89 | + data endpoint. Returns zero on success, and a negative errno value |
| 90 | + on error. |
| 91 | + |
| 92 | + ``FUNCTIONFS_DMABUF_DETACH(int)`` |
| 93 | + Detach the given DMABUF object, identified by its file descriptor, |
| 94 | + from the data endpoint. Returns zero on success, and a negative |
| 95 | + errno value on error. Note that closing the endpoint's file |
| 96 | + descriptor will automatically detach all attached DMABUFs. |
| 97 | + |
| 98 | + ``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)`` |
| 99 | + Enqueue the previously attached DMABUF to the transfer queue. |
| 100 | + The argument is a structure that packs the DMABUF's file descriptor, |
| 101 | + the size in bytes to transfer (which should generally correspond to |
| 102 | + the size of the DMABUF), and a 'flags' field which is unused |
| 103 | + for now. Returns zero on success, and a negative errno value on |
| 104 | + error. |
0 commit comments