X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhwdriver.c;h=d11bcccc44712c0b02bc820a7d4d7c1f11db0162;hb=1a8639164e4e44a43fe1558e30823606f7b607b3;hp=239592d3ebc9157e35148d5d1d73091540e8c332;hpb=9ed444e6226c5d36b637708864361429f77f07a8;p=libsigrok.git diff --git a/src/hwdriver.c b/src/hwdriver.c index 239592d3..d11bcccc 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -31,7 +31,7 @@ #define LOG_PREFIX "hwdriver" /** @endcond */ -extern SR_PRIV struct sr_dev_driver *drivers_list[]; +extern SR_PRIV struct sr_dev_driver **drivers_lists[]; /** * @file @@ -101,8 +101,8 @@ static struct sr_config_info sr_config_info_data[] = { "Trigger matches", NULL}, {SR_CONF_SAMPLE_INTERVAL, SR_T_UINT64, "sample_interval", "Sample interval", NULL}, - {SR_CONF_NUM_TIMEBASE, SR_T_INT32, "num_timebase", - "Number of time bases", NULL}, + {SR_CONF_NUM_HDIV, SR_T_INT32, "num_hdiv", + "Number of horizontal divisions", NULL}, {SR_CONF_NUM_VDIV, SR_T_INT32, "num_vdiv", "Number of vertical divisions", NULL}, {SR_CONF_SPL_WEIGHT_FREQ, SR_T_STRING, "spl_weight_freq", @@ -183,6 +183,8 @@ static struct sr_config_info sr_config_info_data[] = { "Power off", NULL}, {SR_CONF_DATA_SOURCE, SR_T_STRING, "data_source", "Data source", NULL}, + {SR_CONF_PROBE_FACTOR, SR_T_UINT64, "probe_factor", + "Probe factor", NULL}, /* Acquisition modes, sample limiting */ {SR_CONF_LIMIT_MSEC, SR_T_UINT64, "limit_time", @@ -263,8 +265,21 @@ SR_PRIV int sr_variant_type_check(uint32_t key, GVariant *value) */ SR_API struct sr_dev_driver **sr_driver_list(void) { + static struct sr_dev_driver **combined_list = NULL; + struct sr_dev_driver ***lists, **drivers; + GArray *array; - return drivers_list; + if (combined_list) + return combined_list; + + array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *)); + for (lists = drivers_lists; *lists; lists++) + for (drivers = *lists; *drivers; drivers++) + g_array_append_val(array, *drivers); + combined_list = (struct sr_dev_driver **)array->data; + g_array_free(array, FALSE); + + return combined_list; } /** @@ -301,7 +316,7 @@ SR_API int sr_driver_init(struct sr_context *ctx, struct sr_dev_driver *driver) } sr_spew("Initializing driver '%s'.", driver->name); - if ((ret = driver->init(ctx)) < 0) + if ((ret = driver->init(driver, ctx)) < 0) sr_err("Failed to initialize the driver: %d.", ret); return ret; @@ -395,7 +410,7 @@ SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options) return NULL; } - l = driver->scan(options); + l = driver->scan(driver, options); sr_spew("Scan of '%s' found %d devices.", driver->name, g_slist_length(l)); @@ -413,7 +428,8 @@ SR_PRIV void sr_hw_cleanup_all(void) drivers = sr_driver_list(); for (i = 0; drivers[i]; i++) { if (drivers[i]->cleanup) - drivers[i]->cleanup(); + drivers[i]->cleanup(drivers[i]); + drivers[i]->priv = NULL; } }