1
0
Fork 0
mirror of https://github.com/linux-usb-gadgets/libusbgx.git synced 2025-07-23 10:15:06 +03:00
Commit graph

32 commits

Author SHA1 Message Date
Krzysztof Opasiak
98bd3bb016 libusbgx: examples: Use digital format for bMaxPacketSize0
bMaxPacketSize0 is maximal size of packet which can be
used for communication with ep0. As most people use digital
format for size, lets use digital format for both
initialization of this member in gadget atributes and for
printing it in show-gadgets.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Krzysztof Opasiak
5511d5b67c libusbgx: examples: Print bcdUSB and bcdDevice as BCD not HEX
bcdUSB and bcdDevice members should be interpreted as BCD.
So let's print them as BCD instea of HEX.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Krzysztof Opasiak
3f2fcde59c libusbgx: examples: Print gadget data in the same order as lsusb.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Dominic Sacré
184ef3b306 libusbgx: Update show-gadgets example to support MIDI gadgets
Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Dominic Sacré
e2bd9bb192 libusbgx: Format switch statements more consistently
Insert blank lines between all cases in switch statements that branch
on attribute types.

Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Krzysztof Opasiak
94561598ec libusbgx: Update example to show also mass storage function
Mass storage functions has been recently added to libusbgx
so update show-gadgets example to show also attributes of
mass storage function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
2015-12-22 21:45:35 +01:00
Krzysztof Opasiak
cee215c1df libusbgx: Introduce usbg_cleanup_function_attrs() function
We would like to eliminate static buffers from function
attributes. To achieve this we should ensure that there
is some function which free the memory allocated
in usbg_get_function_attrs()

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
2015-12-22 21:45:35 +01:00
Krzysztof Opasiak
752e9ee578 libusbgx: Make a use of usbg_f_attrs_type
This commit adds usbg_f_attrs_header which allows
to identify which union field is currently in use.
This allows to eliminate all switch() constructions
with list of all functions types for accessing
function attributes. Now, much more readable and
shorter enum with possible attribute types is used.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
2015-12-22 21:45:35 +01:00
Krzysztof Opasiak
0cd967b99b libusbgx: Rework API to use usbg_udc structure
Using string as udc identifier provides a lot
of troubles. To be more consistent with rest of
API rework it to start using usbg_udc structure
instead of using char *.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:41:57 +01:00
Krzysztof Opasiak
d3f3ca6081 libusbgx: Simplify getting names form library structures
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>

Changes since v1:
Fix show-gadgets example: get attributes before dereferencing them

Reported-by: Philippe De Swert <philippe.deswert@jollamobile.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:05:29 +01:00
Krzysztof Opasiak
ae40a83095 libusbgx: Update show gadget example support ffs functions.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:40:25 +01:00
Krzysztof Opasiak
bc1bf2e15a libusbgx: Use config ID and label instead of config name.
Naming convention of Config FS should not be exposed
to user of library. All API functions should use
configuration ID (configuration number) as unique
identificator and configuration label as human
readable description.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:38:48 +01:00
Krzysztof Opasiak
432ce82423 libusbgx: Replace usage of function name with type and instance.
User of library should not use directly function name but
only type of the function and name of instance. Using this
will separate user for naming convention on Config FS.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:38:42 +01:00
Krzysztof Opasiak
63f3bf5c57 libusbgx: Update examples to use returned error codes.
Examples provided with the library should use returned
error codes and provide information to user.

Remove todo baceuse it has been already done.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
97c6c58b87 libusbgx: Add error handling to usbg_init() and related functions.
Assumption that all malloc() and read()/write() finish correctly
is too bold. Errors should be handled and propagated to upper
layers of library and returned to user.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
ede62b9192 libusbgx: Refresh config strings while each get.
Config strings should not be cached in library.
Removing internal strings structure allowed to add
full support for multilingual strings.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
e2fd412088 libusbgx: Refresh gadget strings while each get.
Gadget strings should not be cached in library.
Removing internal strings structure allowed to add
full support for multilingual strings.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
2631010de5 libusbgx: Remove unused variables to make compiler happy.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
3bd78a504e libusbgx: Rename all public structures to usbg convention.
Switch form struct * to typedef usbg_* to provide convenient
API for user.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
44b21b0ae6 libusbgx: Hide definition of binding structure.
Hide definition of binding structure to avoid direct
access to its fields. Rename it to usbg_binding.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
1025541129 libusbgx: Hide definition of function structure.
Hide definition of function structure to avoid direct
access to its fields. Rename it to usbg_function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
9b886d172f libusbgx: Hide definition of config structure.
Hide definition of config structure to avoid direct
access to its fields. Rename it to usbg_confg.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
233bdd6575 libusbgx: Hide definition of gadget structure.
Remove definition of gadget structure to avoid direct
access to its fields. Rename that structure to usbg_gadget.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
0f4c36efc3 libusbgx: Hide definition of state structure.
Hide definition of state structure to avoid direct
access to its fields. Rename it to usbg_state.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
7c85291a51 libusbgx: Separate config attrs and strs form configuration.
Configuration, its attributes and strings are all logically
independent so should be placed in separate structures.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
e9f314a78a libusbgx: Separate gadget strings from gadget.
Gadget strings are not logically part of gadget, so should
be separated.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:33:56 +01:00
Krzysztof Opasiak
652d2dd8ca libusbgx: Change gadget attributes size and names.
Rename all gadget attributes to be consistent with usb
standard and libusb. Change also field size and order
to allow direct memcpy from libusb_device_descriptor.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:33:56 +01:00
Krzysztof Opasiak
6ce3bdaad3 libusbgx: Separate gadget attributes from gadget.
Gadget attributes should be placed in external structure
because they are almost that same as USB device descriptor.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:33:56 +01:00
Matt Porter
1a0f241233 libusbg: use /sys/kernel/config mount point in examples
Update documentation and example source code to reflect use of the
standard /sys/kernel/config mount point for configfs.

Signed-off-by: Matt Porter <mporter@linaro.org>
2014-01-21 07:58:24 -05:00
Matt Porter
14949f6764 libusbg: update preferred email address
Update email address for myself throughout the code.

Signed-off-by: Matt Porter <mporter@linaro.org>
2014-01-21 07:58:24 -05:00
Matt Porter
a371518d64 libusbg: rename gadget_*() -> usbg_*(), libusbg, and usbg.h
Rename library to libusbg. Moves the API include to usbg.h and
accordingly changes all API prefixes to usbg_*().

Signed-off-by: Matt Porter <mporter@linaro.org>
2014-01-21 07:58:24 -05:00
Matt Porter
a6a036a403 Initial release
Signed-off-by: Matt Porter <matt.porter@linaro.org>
2013-09-04 12:51:23 -04:00