diff options
author | Pawel Szewczyk <p.szewczyk@samsung.com> | 2015-05-19 17:33:49 +0200 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-05-21 15:39:56 +0200 |
commit | b18c56c4526e910a961bbe110d0172ee5a1327dc (patch) | |
tree | 9fade2d325eaca965c52e27c65368cc7312e8c02 | |
parent | 1d9b188fa5c8b763e54a01ef9e2db97278af2030 (diff) | |
download | libusbg-b18c56c4526e910a961bbe110d0172ee5a1327dc.tar.gz libusbg-b18c56c4526e910a961bbe110d0172ee5a1327dc.tar.bz2 libusbg-b18c56c4526e910a961bbe110d0172ee5a1327dc.zip |
libusbg: schemes: Allow to export midi function
Add support for exporting midi function to gadget scheme.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r-- | src/usbg_schemes_libconfig.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/usbg_schemes_libconfig.c b/src/usbg_schemes_libconfig.c index f860a46..bb856dc 100644 --- a/src/usbg_schemes_libconfig.c +++ b/src/usbg_schemes_libconfig.c @@ -438,6 +438,53 @@ out: } +static int usbg_export_f_midi_attrs(usbg_f_midi_attrs *attrs, + config_setting_t *root) +{ + config_setting_t *node; + int cfg_ret; + int ret = USBG_ERROR_NO_MEM; + +#define ADD_F_MIDI_INT_ATTR(attr, minval) \ + do { \ + if ((int)attrs->attr < minval) { \ + ret = USBG_ERROR_INVALID_VALUE; \ + goto out; \ + } \ + node = config_setting_add(root, #attr, CONFIG_TYPE_INT);\ + if (!node) \ + goto out; \ + cfg_ret = config_setting_set_int(node, attrs->attr); \ + if (cfg_ret != CONFIG_TRUE) { \ + ret = USBG_ERROR_OTHER_ERROR; \ + goto out; \ + } \ + } while (0) + + ADD_F_MIDI_INT_ATTR(index, INT_MIN); + + node = config_setting_add(root, "id", CONFIG_TYPE_STRING); + if (!node) + goto out; + + cfg_ret = config_setting_set_string(node, attrs->id); + if (cfg_ret != CONFIG_TRUE) { + ret = USBG_ERROR_OTHER_ERROR; + goto out; + } + + ADD_F_MIDI_INT_ATTR(in_ports, 0); + ADD_F_MIDI_INT_ATTR(out_ports, 0); + ADD_F_MIDI_INT_ATTR(buflen, 0); + ADD_F_MIDI_INT_ATTR(qlen, 0); + +#undef ADD_F_MIDI_INT_ATTR + + ret = USBG_SUCCESS; +out: + return ret; +} + static int usbg_export_function_attrs(usbg_function *f, config_setting_t *root) { config_setting_t *node; @@ -469,6 +516,10 @@ static int usbg_export_function_attrs(usbg_function *f, config_setting_t *root) ret = usbg_export_f_ms_attrs(&f_attrs.attrs.ms, root); break; + case USBG_F_ATTRS_MIDI: + ret = usbg_export_f_midi_attrs(&f_attrs.attrs.midi, root); + break; + case USBG_F_ATTRS_PHONET: /* Don't export ifname because it is read only */ case USBG_F_ATTRS_FFS: |