]> sigrok.org Git - libsigrok.git/blobdiff - hwdriver.c
sr: fix sr_parse_triggerstring() to use probe numbers starting from 0
[libsigrok.git] / hwdriver.c
index 770823672a95203c118417a608191ab770f43185..ff9cc5f8dc58bce17f96cdff2b4a3bdd12b62fab 100644 (file)
@@ -148,6 +148,13 @@ SR_API int sr_driver_init(struct sr_dev_driver *driver)
 /**
  * Tell a hardware driver to scan for devices.
  *
+ * In addition to the detection, the devices that are found are also
+ * initialized automatically. On some devices, this involves a firmware upload,
+ * or other such measures.
+ *
+ * The order in which the system is scanned for devices is not specified. The
+ * caller should not assume or rely on any specific order.
+ *
  * @param driver The driver.
  * @param options A list of struct sr_hwopt options to pass to the driver's
  *             scanner.
@@ -177,6 +184,32 @@ SR_PRIV void sr_hw_cleanup_all(void)
        }
 }
 
+/**
+ * Returns information about the given driver or device instance.
+ *
+ * @param driver The sr_dev_driver struct to query.
+ * @param id The type of information, in the form of an SR_HWCAP_* option.
+ * @param data Pointer where the value. will be stored. Must not be NULL.
+ * @param sdi Pointer to the struct sr_dev_inst to be checked. Must not be NULL.
+ *
+ * @return SR_OK upon success or SR_ERR in case of error. Note SR_ERR_ARG
+ *         may be returned by the driver indicating it doesn't know that id,
+ *         but this is not to be flagged as an error by the caller; merely
+ *         as an indication that it's not applicable.
+ */
+SR_API int sr_info_get(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;
+
+       ret = driver->info_get(id, data, sdi);
+
+       return ret;
+}
+
 SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
                const char *vendor, const char *model, const char *version)
 {
@@ -312,10 +345,8 @@ SR_API gboolean sr_driver_hwcap_exists(struct sr_dev_driver *driver, int hwcap)
                return FALSE;
        }
 
-       if (!(hwcaps = driver->hwcap_get_all())) {
-               sr_err("hwdriver: %s: hwcap_get_all() returned NULL", __func__);
+       if (driver->info_get(SR_DI_HWCAPS, (const void **)&hwcaps, NULL) != SR_OK)
                return FALSE;
-       }
 
        for (i = 0; hwcaps[i]; i++) {
                if (hwcaps[i] == hwcap)