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

46 commits

Author SHA1 Message Date
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
bbc3fcdb76 libusbgx: Add example with mass storage function
Mass storage support has been recently added to libusbgx.
This commit adds an example program which show how to create
gadget with this function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@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
8c9547cca5 libusbgx: Fix compilation warnings
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:41:57 +01:00
Krzysztof Opasiak
915152c0bd libusbgx: Add example how to use usbg_udc structure
This example shows how to learn what udcs are available
in system and also how to find out what gadgets are
enabled on them.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:41:57 +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
67a56d406c libusbgx: Fix out-of-tree builds
The include flag should point to the source directory, not the build
directory.

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>

Rebased onto kopasiak/master.

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:46:03 +01:00
Krzysztof Opasiak
fa0acfd45b libusbgx: examples: Add gadget-import sample app
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:45:13 +01:00
Krzysztof Opasiak
54cb10a795 libusbgx: examples: Add sample application to export gadget
Add sample C code which shows how to use new functionality
of libusbg - gadget export. This program allows to export
chosen gadget from configfs to a file.

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:44:09 +01:00
Krzysztof Opasiak
d676006829 libusbgx: Add example to show how to create ffs functions.
Add example which demonstartes two ways of creating ffs
based usb functions.

How to set-up gadget using this example:
1) Run gadget-ffs

2) Mount both instances:
 $ mount my_dev_name -t functionfs /path/to/mount/dir1
 $ mount my_awesome_dev_name -t functionfs /path/to/mount/dir2

3) Run ffs daemons for both instances:
 $ my-ffs-daemon /path/to/mount/dir1
 $ my-ffs-daemon /path/to/mount/dir2

4) Enable your gadget:
 $ echo "my_udc_name" > /sys/kernel/config/usb_gadget/g1/UDC

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:31 +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
2104b7e1fe libusbgx: Update examples to new API functionality.
Removing gadget/config/function/binding functionality
has been added to API so add example of how to use it.

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:05 +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
709c04fab9 libusbgx: Add return value to config related functions.
Each usbg_set_config_*() may fail so it should have
a return value to notify user about reason of failure.

To be consistent with rest of API usbg_create_config()
should also return error code to notify user about reasons
of failure instead of binary information (NULL or not).

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
5ab3f47865 libusbgx: Add return value to usb function related functions.
Each usbg_set_*() may fail so it should have a return value
to notify user about reason of failure.

To be consistent with rest of API usbg_create_function()
should also return error code to notify user about reasons
of failure instead of binary information (NULL or not).

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
b1aa35521a libusbgx: Add return value to gadget creation functions.
Functions related to gadget creation should return error codes
instead of pointer.

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
93ab85191c libusbgx: Update examples to new API.
API of library has been changed, so it is necessary
to update examples of library usage.

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
42c6bc3e56 libusbgx: Add functions for get/set function attributes.
Add usbg_get_function_attrs() and usbg_get_function_type()
to aviod direct access to function structure members.

Add usbg_set_function_attrs() to allow set all function\
attributes with one call.

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
b44baf9d2e libusbgx: Add set/get config attrs/strings functions.
Add usbg_set_config_attrs() function to allow setting
all attributes with one call. Add also getter for attrs
to avoid direct accessing of configuration fields.

Add usbg_set_config_strs() to be consistent with gadget
API.

Change usbg_create_config() to allow configuration creation
and attribute setting with one call.

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
2a0e2bc756 libusbgx: Add functions to set all strs and attrs with one call.
Rename usbg_create_gadget() to usbg_create_vid_pid().
dd usbg_create_gadget() to allow gadget creation
with given attributes and strings. Add usbg_set_gadget_attrs()
which allow to set all attributes with one call. Add
usbg_set_gadget_strs() which allow to set all strings with
one call.

Gadget structure creation and initialization has been moved to
usbg_create_empty_gadget() to avoid copy-paste same code in
usbg_create_gadget_vid_pid() and usbg_create_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
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
Krzysztof Opasiak
b8dd6d8f9a libusbgx: Fix gadget-acm-ecm example to cleanup at exit.
Make use of previously unused variable ret to cleanup
after successful gadget creation.

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
c07046b8f5 Fork from libusbg project
As libusbg project looks for a dead for over a year it
has been forked and now it is developed as:

	libusbg-neXt (libusbgx)

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:33:32 +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