diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2014-09-18 17:44:48 +0200 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2014-10-23 09:49:41 +0200 |
commit | 40f12f3fc4bcd304c6fe14181b30f3e57aa86246 (patch) | |
tree | 690679ef27ee5148db238529595555b549f41642 /include | |
parent | a5af63144492273342f01f592a7d937b2556bccf (diff) | |
download | libusbg-40f12f3fc4bcd304c6fe14181b30f3e57aa86246.tar.gz libusbg-40f12f3fc4bcd304c6fe14181b30f3e57aa86246.tar.bz2 libusbg-40f12f3fc4bcd304c6fe14181b30f3e57aa86246.zip |
libusbg: Allow to set all gadget attrs using one function.
Having specialized functions for each attribute may be
sometime inconvenient to use. Provide also function
whihc allows to set attribute selected by parameter.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/usbg/usbg.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index 3f5d561..ffee155 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -88,6 +88,22 @@ typedef struct usbg_function usbg_function; typedef struct usbg_binding usbg_binding; /** + * @typedef usbg_gadget_attr + * @brief Gadget attributes which can be set using + * usbg_set_gadget_attr() function. + */ +typedef enum { + BCD_USB = 0, + B_DEVICE_CLASS, + B_DEVICE_SUB_CLASS, + B_DEVICE_PROTOCOL, + B_MAX_PACKET_SIZE_0, + ID_VENDOR, + ID_PRODUCT, + BCD_DEVICE, +} usbg_gadget_attr; + +/** * @typedef usbg_gadget_attrs * @brief USB gadget device attributes */ @@ -395,6 +411,43 @@ extern int usbg_create_gadget(usbg_state *s, const char *name, usbg_gadget **g); /** + * @brief Get string representing selected gadget attribute + * @param attr code of selected attrobute + * @return String suitable for given attribute or NULL if such + * string has not been found + */ +extern const char *usbg_get_gadget_attr_str(usbg_gadget_attr attr); + +/** + * @brief Lookup attr code based on its name + * @param name of attribute + * @return code of suitable attribute or usbg_error + */ +extern int usbg_lookup_gadget_attr(const char *name); + +/** + * @brief Set selected attribute to value + * @param g Pointer to gadget + * @param attr Code of selected attribute + * @param val value to be set + * @return 0 on success, usbg_error otherwise + * @note val is of type int but value provided to this function should + * be suitable to place it in type dedicated for selected attr (uint16 or uint8) + */ +extern int usbg_set_gadget_attr(usbg_gadget *g, usbg_gadget_attr attr, int val); + +/** + * @brief Get value of selected attribute + * @param g Pointer to gadget + * @param attr Code of selected attribute + * @return Value of selected attribute (always above zero) or + * usbg_error if error occurred. + * @note User should use only lowest one or two bytes as attribute value + * depending on attribute size (see usbg_gadget_attrs for details). + */ +extern int usbg_get_gadget_attr(usbg_gadget *g, usbg_gadget_attr attr); + +/** * @brief Set the USB gadget attributes * @param g Pointer to gadget * @param g_attrs Gadget attributes |