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

66 commits

Author SHA1 Message Date
Gwenhael Goavec-Merou
45c14ef4d5 libusbgx: fix build with glibc-2.28 since <sys/sysmacros.h> is no more included by <sys/types.h>
Signed-off-by: Sid Spry R030t1@gmail.com
Signed-off-by: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
[Copy sign-offs from pull requst to commit msg]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2018-09-12 15:10:33 +02:00
ing. Federico Fuga
dccb4f19a6 libusbgx: Fix out of tree compilation
With the current 0.2.0 (999a6e5) the library can't be compiled
out ofthe tree:

libtool: compile:  gcc -DPACKAGE_NAME=\"libusbgx\" -DPACKAGE_TARNAME=\"libusbgx\" -DPACKAGE_VERSION=\"0.2.0\" "-DPACKAGE_STRING=\"libusbgx 0.2.0\"" -DPACKAGE_BUGREPORT=\"k.opasiak@samsung.com\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libusbgx\" -DVERSION=\"0.2.0\" "-D_GNU_SOURCE=/**/" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I../../src -I../../include/ -g -O2 -MT function/libusbgx_la-midi.lo -MD -MP -MF function/.deps/libusbgx_la-midi.Tpo -c ../../src/function/midi.c  -fPIC -DPIC -o function/.libs/libusbgx_la-midi.o
In file included from ../../src/usbg_common.c:13:0:
../../include/usbg/usbg.h:33:26: fatal error: usbg_version.h: File o directory non esistente
compilation terminated.

It compiled correctly on 904b04c.

To fix this issue let's add usbg subdirectory to include path.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2018-08-22 12:59:05 +02:00
Krzysztof Opasiak
0ab9f2f128 libusbgx: examples: Make show-gadgets aware of uac2 function
Allow user to show values of uac2 attributes instead of dummy
"UNKNOWN" string.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2018-01-17 16:13:58 +01:00
John Keeping
88cff3cbf7 libusbgx: examples: Add UAC2 function example
Show how to create a USB Audio Class 2 gadget.

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2018-01-17 16:12:56 +01:00
Krzysztof Opasiak
bfa2c29daa libusbgx: examples: Add rndis with OS descriptors support example
Add a program which shows how to use OS descriptors support
based on RNDIS example.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-12-12 14:06:36 +01:00
Krzysztof Opasiak
a91dd9d037 libusbgx: examples: Add example how to create gadget with HID function
Let's add some simple example how to create a gadget which includes
HID function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-03-03 14:05:37 +01:00
Krzysztof Opasiak
e323f6c0f9 libusbgx: examples: Allow show-gadgets to print HID function attrs
As libusbgx now supports also HID function so we may print its
attributes in our show-gadgets example. This may also be used
as example of getting HID attributes using generic functions.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-03-03 14:04:08 +01:00
Krzysztof Opasiak
e8e16af025 libusbgx: examples: Print strings in all available languages
Instead of printing strings only in US_EN let's make a use of
our new function and print all available strings.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-03-03 14:02:27 +01:00
Krzysztof Opasiak
56355fb34d libusbgx: Add usbg_free_config_strs()
This is a first step to get rid of static buffers from usbg_config_strs.

This function should be called to release memory allocated for
configuration string.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-03-02 16:56:27 +01:00
Krzysztof Opasiak
e0e525fc58 libusbgx: Add usbg_free_gadget_strs()
This is a first step to get rid of static buffers in usbg_gadget_strs.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-03-02 16:54:37 +01:00
Krzysztof Opasiak
67aaf8ea7e libusbgx: Use string name similar to USB spec
str_ser, str_prd and str_mnf are a little bit weird names
so let's replace them with names defined by USB spec.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-14 13:23:12 +01:00
Krzysztof Opasiak
3749ccec3d libusbgx: Remove typedefs for public structures
Let's remove typedefs from public structures to clearly
indicate users which structures can be accessed and which
should be used only as handles.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-14 13:03:26 +01:00
Krzysztof Opasiak
a23dee0c86 libusbgx: Use suitable prefix for usbg_function_type enum
Let's use USBG_ prefix for usbg_function_type enum values
to avoid users confusion.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-13 22:45:06 +01:00
Krzysztof Opasiak
77449edfe0 libusbgx: Add suitable copyrights
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-23 00:49:03 +01:00
Krzysztof Opasiak
54eff8a344 libusbgx: examples: Port all examples to new API
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-23 00:49:03 +01:00
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
Krzysztof Opasiak
2f09cdc9b6 libusbgx: examples: Make examples easier to read
Use the same order of structure initialization in all
examples.

Initialize gadget attributes and strings using:
	.member = val,
syntax to make examples easier to read.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Pawel Szewczyk
d9fb676d28 libusbgx: examples: add example of midi function usage
Support for midi function was recently added. This commit adds an example
program which shows how to create midi gadget with this function.

Signed-off-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é
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