libnx
v4.2.0
|
USB (usb:hs) devices service IPC wrapper. More...
#include "../types.h"
#include "../sf/service.h"
#include "../services/usb.h"
#include "../kernel/event.h"
Go to the source code of this file.
Data Structures | |
struct | UsbHsInterfaceFilter |
Interface filtering struct. More... | |
struct | UsbHsInterfaceInfo |
Descriptors which are not available are set to all-zero. More... | |
struct | UsbHsInterface |
Interface struct. Note that devices have a seperate UsbHsInterface for each interface. More... | |
struct | UsbHsXferReport |
struct | UsbHsClientIfSession |
The interface service object. These Events have autoclear=false. More... | |
struct | UsbHsClientEpSession |
Enumerations | |
enum | UsbHsInterfaceFilterFlags { UsbHsInterfaceFilterFlags_idVendor = (1U<<( 0 )), UsbHsInterfaceFilterFlags_idProduct = (1U<<( 1 )), UsbHsInterfaceFilterFlags_bcdDevice_Min = (1U<<( 2 )), UsbHsInterfaceFilterFlags_bcdDevice_Max = (1U<<( 3 )), UsbHsInterfaceFilterFlags_bDeviceClass = (1U<<( 4 )), UsbHsInterfaceFilterFlags_bDeviceSubClass = (1U<<( 5 )), UsbHsInterfaceFilterFlags_bDeviceProtocol = (1U<<( 6 )), UsbHsInterfaceFilterFlags_bInterfaceClass = (1U<<( 7 )), UsbHsInterfaceFilterFlags_bInterfaceSubClass = (1U<<( 8 )), UsbHsInterfaceFilterFlags_bInterfaceProtocol = (1U<<( 9 )) } |
Functions | |
Result | usbHsInitialize (void) |
Initialize usb:hs. | |
void | usbHsExit (void) |
Exit usb:hs. | |
Service * | usbHsGetServiceSession (void) |
Gets the Service object for the actual usb:hs service session. | |
Event * | usbHsGetInterfaceStateChangeEvent (void) |
Returns the Event loaded during init with autoclear=false. More... | |
Result | usbHsQueryAllInterfaces (const UsbHsInterfaceFilter *filter, UsbHsInterface *interfaces, size_t interfaces_maxsize, s32 *total_entries) |
Returns an array of all UsbHsInterface. More... | |
Result | usbHsQueryAvailableInterfaces (const UsbHsInterfaceFilter *filter, UsbHsInterface *interfaces, size_t interfaces_maxsize, s32 *total_entries) |
Returns an array of UsbHsInterface which are available. More... | |
Result | usbHsQueryAcquiredInterfaces (UsbHsInterface *interfaces, size_t interfaces_maxsize, s32 *total_entries) |
Returns an array of UsbHsInterface which were previously acquired. More... | |
Result | usbHsCreateInterfaceAvailableEvent (Event *out_event, bool autoclear, u8 index, const UsbHsInterfaceFilter *filter) |
Creates an event which is signaled when an interface is available which passes the filtering checks. More... | |
Result | usbHsDestroyInterfaceAvailableEvent (Event *event, u8 index) |
Destroys an event setup by usbHsCreateInterfaceAvailableEvent. More... | |
Result | usbHsAcquireUsbIf (UsbHsClientIfSession *s, UsbHsInterface *interface) |
Acquires/opens the specified interface. More... | |
void | usbHsIfClose (UsbHsClientIfSession *s) |
UsbHsClientIfSession. More... | |
static bool | usbHsIfIsActive (UsbHsClientIfSession *s) |
Returns whether the specified interface session was initialized. | |
static s32 | usbHsIfGetID (UsbHsClientIfSession *s) |
Returns the ID which can be used for comparing with the ID in the output interfaces from usbHsQueryAcquiredInterfaces. | |
Result | usbHsIfSetInterface (UsbHsClientIfSession *s, UsbHsInterfaceInfo *inf, u8 id) |
Selects an interface. More... | |
Result | usbHsIfGetInterface (UsbHsClientIfSession *s, UsbHsInterfaceInfo *inf) |
Gets an interface. More... | |
Result | usbHsIfGetAlternateInterface (UsbHsClientIfSession *s, UsbHsInterfaceInfo *inf, u8 id) |
Gets an alternate interface. More... | |
Result | usbHsIfGetCurrentFrame (UsbHsClientIfSession *s, u32 *out) |
On [1.0.0] this is stubbed, just returns 0 with out=0. | |
Result | usbHsIfCtrlXfer (UsbHsClientIfSession *s, u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, void *buffer, u32 *transferredSize) |
Uses a control transfer, this will block until the transfer finishes. The buffer address and size should be aligned to 0x1000-bytes, where wLength is the original size. | |
Result | usbHsIfOpenUsbEp (UsbHsClientIfSession *s, UsbHsClientEpSession *ep, u16 maxUrbCount, u32 maxXferSize, struct usb_endpoint_descriptor *desc) |
Opens an endpoint. More... | |
Result | usbHsIfResetDevice (UsbHsClientIfSession *s) |
Resets the device: has the same affect as unplugging the device and plugging it back in. | |
void | usbHsEpClose (UsbHsClientEpSession *s) |
UsbHsClientEpSession. More... | |
Result | usbHsEpPostBuffer (UsbHsClientEpSession *s, void *buffer, u32 size, u32 *transferredSize) |
Uses a data transfer with the specified endpoint, this will block until the transfer finishes. The buffer address and size should be aligned to 0x1000-bytes, where the input size is the original size. | |
USB (usb:hs) devices service IPC wrapper.
Enumerator | |
---|---|
UsbHsInterfaceFilterFlags_idVendor | These use usb_device_descriptor. Bit2..6 require [6.0.0+], these are ignored on eariler versions. |
UsbHsInterfaceFilterFlags_bDeviceProtocol | These use usb_interface_descriptor. |
Result usbHsAcquireUsbIf | ( | UsbHsClientIfSession * | s, |
UsbHsInterface * | interface | ||
) |
Acquires/opens the specified interface.
This returns an error if the interface was already acquired by another process.
[in] | s | The service object. |
[in] | interface | Interface to use. |
Result usbHsCreateInterfaceAvailableEvent | ( | Event * | out_event, |
bool | autoclear, | ||
u8 | index, | ||
const UsbHsInterfaceFilter * | filter | ||
) |
Creates an event which is signaled when an interface is available which passes the filtering checks.
[out] | out_event | Event object. |
[in] | autoclear | Event autoclear. |
[in] | index | Event index, must be 0..2. |
[in] | filter | UsbHsInterfaceFilter. |
Destroys an event setup by usbHsCreateInterfaceAvailableEvent.
This must be used at some point during cleanup.
void usbHsEpClose | ( | UsbHsClientEpSession * | s | ) |
Closes the specified endpoint session.
Event* usbHsGetInterfaceStateChangeEvent | ( | void | ) |
Returns the Event loaded during init with autoclear=false.
Signaled when a device was removed. When signaled, the user should use usbHsQueryAcquiredInterfaces and cleanup state for all interfaces which are not listed in the output interfaces (none of the IDs match usbHsIfGetID output).
void usbHsIfClose | ( | UsbHsClientIfSession * | s | ) |
Closes the specified interface session.
Result usbHsIfGetAlternateInterface | ( | UsbHsClientIfSession * | s, |
UsbHsInterfaceInfo * | inf, | ||
u8 | id | ||
) |
Gets an alternate interface.
[in] | s | The service object. |
[out] | inf | The output interface info. If NULL, the output is stored within s instead. |
[in] | id | ID |
Result usbHsIfGetInterface | ( | UsbHsClientIfSession * | s, |
UsbHsInterfaceInfo * | inf | ||
) |
Gets an interface.
[in] | s | The service object. |
[out] | inf | The output interface info. If NULL, the output is stored within s instead. |
Result usbHsIfOpenUsbEp | ( | UsbHsClientIfSession * | s, |
UsbHsClientEpSession * | ep, | ||
u16 | maxUrbCount, | ||
u32 | maxXferSize, | ||
struct usb_endpoint_descriptor * | desc | ||
) |
Opens an endpoint.
maxUrbCount*maxXferSize must be non-zero.
[in] | s | The interface object. |
[out] | ep | The endpoint object. |
[in] | maxUrbCount | maxUrbCount, must be <0x11. |
[in] | maxXferSize | Max transfer size for a packet. This can be desc->wMaxPacketSize. Must be <=0xFF0000. |
[in] | desc | Endpoint descriptor. |
Result usbHsIfSetInterface | ( | UsbHsClientIfSession * | s, |
UsbHsInterfaceInfo * | inf, | ||
u8 | id | ||
) |
Selects an interface.
[in] | s | The service object. |
[out] | inf | The output interface info. If NULL, the output is stored within s instead. |
[in] | id | ID |
Result usbHsQueryAcquiredInterfaces | ( | UsbHsInterface * | interfaces, |
size_t | interfaces_maxsize, | ||
s32 * | total_entries | ||
) |
Returns an array of UsbHsInterface which were previously acquired.
[out] | interfaces | Array of output interfaces. |
[in] | interfaces_maxsize | Max byte-size of the interfaces buffer. |
[out] | total_entries | Total number of output interfaces. |
Result usbHsQueryAllInterfaces | ( | const UsbHsInterfaceFilter * | filter, |
UsbHsInterface * | interfaces, | ||
size_t | interfaces_maxsize, | ||
s32 * | total_entries | ||
) |
Returns an array of all UsbHsInterface.
Internally this loads the same interfaces as usbHsQueryAvailableInterfaces, followed by usbHsQueryAcquiredInterfaces. However, ID in UsbHsInterface is set to -1, hence the output from this should not be used with usbHsAcquireUsbIf.
[in] | filter | UsbHsInterfaceFilter. |
[out] | interfaces | Array of output interfaces. |
[in] | interfaces_maxsize | Max byte-size of the interfaces buffer. |
[out] | total_entries | Total number of output interfaces. |
Result usbHsQueryAvailableInterfaces | ( | const UsbHsInterfaceFilter * | filter, |
UsbHsInterface * | interfaces, | ||
size_t | interfaces_maxsize, | ||
s32 * | total_entries | ||
) |
Returns an array of UsbHsInterface which are available.
[in] | filter | UsbHsInterfaceFilter. |
[out] | interfaces | Array of output interfaces. |
[in] | interfaces_maxsize | Max byte-size of the interfaces buffer. |
[out] | total_entries | Total number of output interfaces. |