summaryrefslogtreecommitdiff
path: root/include/uhd/iface.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/uhd/iface.h')
-rw-r--r--include/uhd/iface.h158
1 files changed, 83 insertions, 75 deletions
diff --git a/include/uhd/iface.h b/include/uhd/iface.h
index 72c5ca7..cc25361 100644
--- a/include/uhd/iface.h
+++ b/include/uhd/iface.h
@@ -72,8 +72,8 @@ extern bool uhd_iface_valid(const uhd_iface *iface);
/**
* Create a new interface.
*
- * @param handle Device handle.
- * @param number Interface number.
+ * @param handle Device handle.
+ * @param number Interface number.
* @param int_in_ep_addr Interrupt in endpoint address.
* @param int_in_ep_maxp Interrupt in endpoint maximum packet size.
*
@@ -92,143 +92,151 @@ extern uhd_iface *uhd_iface_new(libusb_device_handle *handle,
extern void uhd_iface_free(uhd_iface *iface);
/**
- * Check if an interface list is valid.
+ * Detach an interface from its kernel driver (if any).
*
- * @param list Interface list to check.
+ * @param iface The interface to detach.
*
- * @return True if the interface list is valid, false otherwise.
+ * @return Libusb error code.
*/
-extern bool uhd_iface_list_valid(const uhd_iface *list);
+extern enum libusb_error uhd_iface_detach(uhd_iface *iface);
/**
- * Check if an interface list is empty.
+ * Attach an interface to its kernel driver (if detached before).
*
- * @param list Interface list to check.
+ * @param iface The interface to attach.
*
- * @return True if the interface list is empty, false otherwise.
+ * @return Libusb error code.
*/
-static inline bool
-uhd_iface_list_empty(const uhd_iface *list)
-{
- return list == NULL;
-}
+extern enum libusb_error uhd_iface_attach(uhd_iface *iface);
/**
- * Calculate length of an interface list.
+ * Claim an interface.
*
- * @param list The list to calculate length of.
+ * @param iface The interface to claim.
*
- * @return The list length.
+ * @return Libusb error code.
*/
-extern size_t uhd_iface_list_len(const uhd_iface *list);
+extern enum libusb_error uhd_iface_claim(uhd_iface *iface);
/**
- * Free an interface list.
+ * Set idle duration on an interface; ignore errors indicating missing
+ * support.
*
- * @param list The interface list to free.
+ * @param iface The interface to set idle duration on.
+ * @param duration The duration in 4 ms steps starting from 4 ms.
+ * @param timeout The request timeout, ms.
+ *
+ * @return Libusb error code.
*/
-extern void uhd_iface_list_free(uhd_iface *list);
-
+extern enum libusb_error uhd_iface_set_idle(
+ const uhd_iface *iface,
+ uint8_t duration,
+ unsigned int timeout);
/**
- * Fetch a list of HID interfaces from a device.
+ * Set HID protocol on an interface; ignore errors indicating missing
+ * support.
*
- * @param handle The device handle to fetch interface list from.
- * @param plist Location for the resulting list head; could be NULL.
+ * @param iface The interface to set idle duration on.
+ * @param report True for "report" protocol, false for "boot" protocol.
+ * @param timeout The request timeout, ms.
*
* @return Libusb error code.
*/
-enum libusb_error
-uhd_iface_list_new_from_dev(libusb_device_handle *handle,
- uhd_iface **plist);
+extern enum libusb_error uhd_iface_set_protocol(
+ const uhd_iface *iface,
+ bool report,
+ unsigned int timeout);
/**
- * Filter an interface list by an optional interface number, resulting
- * either in an empty, a single-interface, or an unmodified list.
+ * Clear halt condition on the input interrupt endpoint of an interface.
*
- * @param plist The original list head.
- * @param number The interface number to match against, or a negative
- * integer meaning there is no restriction.
+ * @param iface The interface to clear halt condition on.
*
- * @return The resulting list head
+ * @return Libusb error code.
*/
-extern uhd_iface *uhd_iface_list_fltr_by_num(uhd_iface *list,
- int number);
+extern enum libusb_error uhd_iface_clear_halt(uhd_iface *iface);
/**
- * Detach all interfaces in a list from their kernel drivers (if any).
+ * Release an interface (if claimed before).
*
- * @param list The list of interfaces to detach.
+ * @param iface The interface to release.
*
* @return Libusb error code.
*/
-extern enum libusb_error uhd_iface_list_detach(uhd_iface *list);
+extern enum libusb_error uhd_iface_release(uhd_iface *iface);
/**
- * Attach all interfaces in a list to their kernel drivers (if were detached
- * before).
+ * Check if an interface list is valid.
*
- * @param list The list of interfaces to attach.
+ * @param list Interface list to check.
*
- * @return Libusb error code.
+ * @return True if the interface list is valid, false otherwise.
*/
-extern enum libusb_error uhd_iface_list_attach(uhd_iface *list);
+extern bool uhd_iface_list_valid(const uhd_iface *list);
/**
- * Claim all interfaces in a list.
+ * Check if an interface list is empty.
*
- * @param list The list of interfaces to claim.
+ * @param list Interface list to check.
*
- * @return Libusb error code.
+ * @return True if the interface list is empty, false otherwise.
*/
-extern enum libusb_error uhd_iface_list_claim(uhd_iface *list);
+static inline bool
+uhd_iface_list_empty(const uhd_iface *list)
+{
+ return list == NULL;
+}
/**
- * Set idle duration on all interfaces in a list; ignore errors indicating
- * missing support.
+ * Calculate length of an interface list.
*
- * @param list The list of interfaces to set idle duration on.
- * @param duration The duration in 4 ms steps starting from 4 ms.
- * @param timeout The request timeout, ms.
+ * @param list The list to calculate length of.
*
- * @return Libusb error code.
+ * @return The list length.
*/
-extern enum libusb_error uhd_iface_list_set_idle(
- const uhd_iface *list,
- uint8_t duration,
- unsigned int timeout);
+extern size_t uhd_iface_list_len(const uhd_iface *list);
/**
- * Set HID protocol on all interfaces in a list; ignore errors indicating
- * missing support.
+ * Free an interface list.
*
- * @param list The list of interfaces to set idle duration on.
- * @param report True for "report" protocol, false for "boot" protocol.
- * @param timeout The request timeout, ms.
+ * @param list The interface list to free.
+ */
+extern void uhd_iface_list_free(uhd_iface *list);
+
+/**
+ * Iterate over an interface list.
*
- * @return Libusb error code.
+ * @param _iface Loop interface variable.
+ * @param _list Interface list to iterate over.
*/
-extern enum libusb_error uhd_iface_list_set_protocol(
- const uhd_iface *list,
- bool report,
- unsigned int timeout);
+#define UHD_IFACE_LIST_FOR_EACH(_iface, _list) \
+ for (_iface = _list; _iface != NULL; _iface = _iface->next)
/**
- * Clear halt condition on input interrupt endpoints of all interfaces.
+ * Fetch a list of HID interfaces from a device.
*
- * @param list The list of interfaces to clear halt condition on.
+ * @param handle The device handle to fetch interface list from.
+ * @param plist Location for the resulting list head; could be NULL.
*
* @return Libusb error code.
*/
-extern enum libusb_error uhd_iface_list_clear_halt(uhd_iface *list);
+enum libusb_error
+uhd_iface_list_new_from_dev(libusb_device_handle *handle,
+ uhd_iface **plist);
+
/**
- * Release all interfaces in a list (if were claimed before).
+ * Filter an interface list by an optional interface number, resulting
+ * either in an empty, a single-interface, or an unmodified list.
*
- * @param list The list of interfaces to release.
+ * @param plist The original list head.
+ * @param number The interface number to match against, or a negative
+ * integer meaning there is no restriction.
*
- * @return Libusb error code.
+ * @return The resulting list head
*/
-extern enum libusb_error uhd_iface_list_release(uhd_iface *list);
+extern uhd_iface *uhd_iface_list_fltr_by_num(uhd_iface *list,
+ int number);
#ifdef __cplusplus
} /* extern "C" */