summaryrefslogtreecommitdiff
path: root/examples
AgeCommit message (Collapse)AuthorFilesLines
2016-09-23Revert "common: fix minor issues."taeyoung2-2/+2
This reverts commit d25dbaed77aeb19345d57af73f64989a1d5e6265. Change-Id: Ic6abcb23180f4b015b41a994b36f78607bd0081c Signed-off-by: taeyoung <ty317.kim@samsung.com>
2016-09-23common: fix minor issues.submit/tizen/20160923.084807taeyoung2-2/+2
- thread unsafe functions are removed. - sprintf is changed to snprintf Change-Id: I129984005ae538496a1135cbc8a191f588a432ff Signed-off-by: taeyoung <ty317.kim@samsung.com>
2015-05-19libusbg: examples: Use digital format for bMaxPacketSize0Krzysztof Opasiak5-5/+5
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-05-19libusbg: examples: Print bcdUSB and bcdDevice as BCD not HEXKrzysztof Opasiak1-2/+7
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-05-19libusbg: examples: Print gadget data in the same order as lsusb.Krzysztof Opasiak1-3/+3
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-05-19libusbg: examples: Make examples easier to readKrzysztof Opasiak4-58/+64
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-05-19libusbg: examples: add example of midi function usagePawel Szewczyk2-1/+119
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-05-19libusbg: Update show-gadgets example to support MIDI gadgetsDominic Sacré1-0/+13
Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de> Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-05-19libusbg: Format switch statements more consistentlyDominic Sacré1-0/+4
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-04-27libusbg: Add example with mass storage functionKrzysztof Opasiak2-1/+160
Mass storage support has been recently added to libusbg. 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-04-27libusbg: Update example to show also mass storage functionKrzysztof Opasiak1-0/+17
Mass storage functions has been recently added to libusbg 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-04-16libusbg: Introduce usbg_cleanup_function_attrs() functionKrzysztof Opasiak1-0/+2
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-04-16libusbg: Make a use of usbg_f_attrs_typeKrzysztof Opasiak2-19/+19
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-03-06libusbg: Fix compilation warningsKrzysztof Opasiak1-1/+0
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2014-10-23libusbg: Add example how to use usbg_udc structureKrzysztof Opasiak2-1/+63
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>
2014-10-23libusbg: Rework API to use usbg_udc structureKrzysztof Opasiak2-13/+14
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>
2014-10-23libusbg: Simplify getting names form library structuresKrzysztof Opasiak1-11/+31
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>
2014-09-10Fix out-of-tree buildsKoen Kooi1-1/+1
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>
2014-09-10libusbg: examples: Add gadget-import sample appKrzysztof Opasiak2-1/+81
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2014-08-25libusbg: examples: Add sample application to export gadgetKrzysztof Opasiak2-1/+83
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>
2014-07-05libusbg: Add example to show how to create ffs functions.Krzysztof Opasiak2-1/+156
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>
2014-07-05libusbg: Update show gadget example support ffs functions.Krzysztof Opasiak1-0/+3
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2014-07-05libusbg: Update examples to new API functionality.Krzysztof Opasiak2-1/+116
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>
2014-04-03libusbg: Use config ID and label instead of config name.Krzysztof Opasiak2-6/+7
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>
2014-04-03libusbg: Replace usage of function name with type and instance.Krzysztof Opasiak1-7/+13
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>
2014-03-11libusbg: Update examples to use returned error codes.Krzysztof Opasiak2-10/+81
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>
2014-03-11libusbg: Add return value to config related functions.Krzysztof Opasiak1-2/+2
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>
2014-03-11libusbg: Add return value to usb function related functions.Krzysztof Opasiak1-6/+6
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>
2014-03-11libusbg: Add return value to gadget creation functions.Krzysztof Opasiak1-2/+2
Functions related to gadget creation should return error codes instead of pointer. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2014-03-10libusbg: Add error handling to usbg_init() and related functions.Krzysztof Opasiak2-4/+6
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>
2014-03-10libusbg: Refresh config strings while each get.Krzysztof Opasiak1-1/+1
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>
2014-03-10libusbg: Refresh gadget strings while each get.Krzysztof Opasiak1-1/+1
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>
2014-03-10libusbg: Remove unused variables to make compiler happy.Krzysztof Opasiak2-2/+0
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2014-02-19libusbg: Update examples to new API.Krzysztof Opasiak1-6/+24
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>
2014-02-19libusbg: Rename all public structures to usbg convention.Krzysztof Opasiak1-5/+5
Switch form struct * to typedef usbg_* to provide convenient API for user. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2014-02-19libusbg: Hide definition of binding structure.Krzysztof Opasiak1-4/+5
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>
2014-02-19libusbg: Hide definition of function structure.Krzysztof Opasiak2-16/+24
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>
2014-02-19libusbg: Hide definition of config structure.Krzysztof Opasiak2-3/+3
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>
2014-02-19libusbg: Hide definition of gadget structure.Krzysztof Opasiak2-20/+42
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>
2014-02-19libusbg: Hide definition of state structure.Krzysztof Opasiak2-2/+2
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>
2014-02-19libusbg: Add functions for get/set function attributes.Krzysztof Opasiak1-3/+3
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>
2014-02-19libusbg: Add set/get config attrs/strings functions.Krzysztof Opasiak1-1/+1
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>
2014-02-19libusbg: Separate config attrs and strs form configuration.Krzysztof Opasiak1-3/+3
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>
2014-02-19libusbg: Add functions to set all strs and attrs with one call.Krzysztof Opasiak1-1/+1
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>
2014-02-19libusbg: Separate gadget strings from gadget.Krzysztof Opasiak1-3/+3
Gadget strings are not logically part of gadget, so should be separated. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2014-02-19libusbg: Change gadget attributes size and names.Krzysztof Opasiak1-9/+9
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>
2014-02-19libusbg: Separate gadget attributes from gadget.Krzysztof Opasiak1-9/+9
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>
2014-01-28libusbg: Fix gadget-acm-ecm example to cleanup at exit.Krzysztof Opasiak1-10/+10
Make use of previously unused variable ret to cleanup after successful gadget creation. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2014-01-21libusbg: use /sys/kernel/config mount point in examplesMatt Porter2-2/+2
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-21libusbg: update preferred email addressMatt Porter2-2/+2
Update email address for myself throughout the code. Signed-off-by: Matt Porter <mporter@linaro.org>