From: Bert Vermeulen Date: Fri, 25 Jan 2013 00:24:42 +0000 (+0100) Subject: New driver API function: config_list() X-Git-Tag: dsupstream~321 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c5fb502f9773ecf6df83a32ab82bcd1b70fa857f;p=libsigrok.git New driver API function: config_list() This takes an sr_config key and returns a list of possible values for that key to be submitted with config_set(). The format of the list and its contents is dependent on the key. This will replace the SR_DI_* keys that returned such a list before, such as SR_DI_SAMPLERATES. --- diff --git a/hwdriver.c b/hwdriver.c index 9bb097e8..439d4c78 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -329,6 +329,22 @@ SR_API int sr_info_get(struct sr_dev_driver *driver, int id, return ret; } +SR_API int sr_config_list(struct sr_dev_driver *driver, int id, + const void **data, const struct sr_dev_inst *sdi) +{ + int ret; + + if (driver == NULL || data == NULL) + return SR_ERR; + + if (!driver->config_list) + return SR_ERR; + + ret = driver->config_list(id, data, sdi); + + return ret; +} + /** * Find out if a hardware driver has a specific capability. * diff --git a/libsigrok.h b/libsigrok.h index 90e5e537..b4d929ef 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -599,6 +599,8 @@ struct sr_dev_driver { const struct sr_dev_inst *sdi); int (*config_set) (int id, const void *value, const struct sr_dev_inst *sdi); + int (*config_list) (int info_id, const void **data, + const struct sr_dev_inst *sdi); /* Device-specific */ int (*dev_open) (struct sr_dev_inst *sdi); diff --git a/proto.h b/proto.h index ea74e8fe..667b6ecc 100644 --- a/proto.h +++ b/proto.h @@ -72,6 +72,8 @@ SR_API int sr_driver_init(struct sr_context *ctx, SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options); SR_API int sr_info_get(struct sr_dev_driver *driver, int id, const void **data, const struct sr_dev_inst *sdi); +SR_API int sr_config_list(struct sr_dev_driver *driver, int id, + const void **data, const struct sr_dev_inst *sdi); SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap); SR_API const struct sr_config_info *sr_config_info_get(int key); SR_API const struct sr_config_info *sr_config_info_name_get(const char *optname);