]> sigrok.org Git - libsigrok.git/blobdiff - src/hwdriver.c
Pass driver struct pointer to driver callbacks.
[libsigrok.git] / src / hwdriver.c
index 239592d3ebc9157e35148d5d1d73091540e8c332..a9561d3e78953f96c57537291c3a93163ffe3a64 100644 (file)
@@ -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,20 @@ 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;
+
+       if (!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 drivers_list;
+       return combined_list;
 }
 
 /**
@@ -301,7 +315,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 +409,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 +427,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;
        }
 }