diff --git a/backend.c b/backend.c index 308041ef..34771f76 100644 --- a/backend.c +++ b/backend.c @@ -28,7 +28,7 @@ */ SR_API int sr_init(void) { - return load_hwplugins(); + return sr_hwplugins_load(); } /** diff --git a/device.c b/device.c index d504f8b5..790264ac 100644 --- a/device.c +++ b/device.c @@ -416,7 +416,7 @@ SR_API gboolean sr_dev_has_hwcap(const struct sr_device *device, int hwcap) * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or SR_ERR * upon other errors. */ -int sr_dev_get_info(const struct sr_device *device, int id, +SR_API int sr_dev_info_get(const struct sr_device *device, int id, const void **data) { if ((device == NULL) || (device->plugin == NULL)) diff --git a/hardware/alsa/alsa.c b/hardware/alsa/alsa.c index d4ee7bb1..b04b2216 100644 --- a/hardware/alsa/alsa.c +++ b/hardware/alsa/alsa.c @@ -97,7 +97,7 @@ static int hw_opendev(int device_index) struct alsa *alsa; int err; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; alsa = sdi->priv; @@ -131,7 +131,7 @@ static int hw_closedev(int device_index) struct sr_device_instance *sdi; struct alsa *alsa; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("alsa: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -154,7 +154,7 @@ static int hw_cleanup(void) { struct sr_device_instance *sdi; - if (!(sdi = sr_get_dev_inst(device_instances, 0))) { + if (!(sdi = sr_dev_inst_get(device_instances, 0))) { sr_err("alsa: %s: sdi was NULL", __func__); return SR_ERR_BUG; } @@ -171,7 +171,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) struct alsa *alsa; void *info = NULL; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return NULL; alsa = sdi->priv; @@ -214,7 +214,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) struct sr_device_instance *sdi; struct alsa *alsa; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; alsa = sdi->priv; @@ -300,7 +300,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) int count; int err; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; alsa = sdi->priv; diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index ea071dc7..74b88725 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -559,7 +559,7 @@ static int hw_opendev(int device_index) struct sigma *sigma; int ret; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; sigma = sdi->priv; @@ -702,7 +702,7 @@ static int hw_closedev(int device_index) struct sr_device_instance *sdi; struct sigma *sigma; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("sigma: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -750,7 +750,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) struct sigma *sigma; void *info = NULL; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("It's NULL.\n"); return NULL; } @@ -785,7 +785,7 @@ static int hw_get_status(int device_index) { struct sr_device_instance *sdi; - sdi = sr_get_dev_inst(device_instances, device_index); + sdi = sr_dev_inst_get(device_instances, device_index); if (sdi) return sdi->status; else @@ -803,7 +803,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) struct sigma *sigma; int ret; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; sigma = sdi->priv; @@ -1267,7 +1267,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) /* Avoid compiler warnings. */ (void)session_data; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; sigma = sdi->priv; @@ -1378,7 +1378,7 @@ static int hw_stop_acquisition(int device_index, gpointer session_data) /* Avoid compiler warnings. */ (void)session_data; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("asix: %s: sdi was NULL", __func__); return SR_ERR_BUG; } diff --git a/hardware/chronovu-la8/chronovu-la8.c b/hardware/chronovu-la8/chronovu-la8.c index 3c675e8e..189d7a8c 100644 --- a/hardware/chronovu-la8/chronovu-la8.c +++ b/hardware/chronovu-la8/chronovu-la8.c @@ -564,7 +564,7 @@ static int hw_opendev(int device_index) struct sr_device_instance *sdi; struct la8 *la8; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -651,7 +651,7 @@ static int hw_closedev(int device_index) struct sr_device_instance *sdi; struct la8 *la8; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -722,7 +722,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) sr_spew("la8: entering %s", __func__); - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return NULL; } @@ -766,7 +766,7 @@ static int hw_get_status(int device_index) { struct sr_device_instance *sdi; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("la8: %s: sdi was NULL, device not found", __func__); return SR_ST_NOT_FOUND; } @@ -790,7 +790,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) sr_spew("la8: entering %s", __func__); - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -1044,7 +1044,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) sr_spew("la8: entering %s", __func__); - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -1116,7 +1116,7 @@ static int hw_stop_acquisition(int device_index, gpointer session_data) sr_dbg("la8: stopping acquisition"); - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR_BUG; } diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 785dd559..ae473627 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -185,7 +185,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) struct sr_device_instance *sdi; void *info = NULL; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("demo: %s: sdi was NULL", __func__); return NULL; } diff --git a/hardware/link-mso19/link-mso19.c b/hardware/link-mso19/link-mso19.c index 62c3882e..62640ebf 100644 --- a/hardware/link-mso19/link-mso19.c +++ b/hardware/link-mso19/link-mso19.c @@ -550,7 +550,7 @@ static int hw_opendev(int device_index) struct mso *mso; int ret = SR_ERR; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return ret; mso = sdi->priv; @@ -590,7 +590,7 @@ static int hw_closedev(int device_index) { struct sr_device_instance *sdi; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("mso19: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -612,7 +612,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) struct mso *mso; void *info = NULL; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return NULL; mso = sdi->priv; @@ -643,7 +643,7 @@ static int hw_get_status(int device_index) { struct sr_device_instance *sdi; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ST_NOT_FOUND; return sdi->status; @@ -658,7 +658,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) { struct sr_device_instance *sdi; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; switch (capability) { @@ -755,7 +755,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) struct sr_datafeed_header header; int ret = SR_ERR; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return ret; mso = sdi->priv; diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 8035a647..c322f789 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -485,7 +485,7 @@ static int hw_opendev(int device_index) struct sr_device_instance *sdi; struct ols_device *ols; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; ols = sdi->priv; @@ -504,7 +504,7 @@ static int hw_closedev(int device_index) struct sr_device_instance *sdi; struct ols_device *ols; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("ols: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -561,7 +561,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) struct ols_device *ols; void *info; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return NULL; ols = sdi->priv; @@ -594,7 +594,7 @@ static int hw_get_status(int device_index) { struct sr_device_instance *sdi; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ST_NOT_FOUND; return sdi->status; @@ -645,7 +645,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) int ret; uint64_t *tmp_u64; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; ols = sdi->priv; @@ -885,7 +885,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) int num_channels; int i; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; ols = sdi->priv; diff --git a/hardware/saleae-logic/saleae-logic.c b/hardware/saleae-logic/saleae-logic.c index 08f98669..42884715 100644 --- a/hardware/saleae-logic/saleae-logic.c +++ b/hardware/saleae-logic/saleae-logic.c @@ -173,7 +173,7 @@ static int sl_open_device(int device_index) struct fx2_device *fx2; int err, skip, i; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; fx2 = sdi->priv; @@ -397,7 +397,7 @@ static int hw_opendev(int device_index) struct fx2_device *fx2; int timediff, err; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; fx2 = sdi->priv; @@ -449,7 +449,7 @@ static int hw_closedev(int device_index) { struct sr_device_instance *sdi; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("logic: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -503,7 +503,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) struct fx2_device *fx2; void *info = NULL; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return NULL; fx2 = sdi->priv; @@ -535,7 +535,7 @@ static int hw_get_status(int device_index) { struct sr_device_instance *sdi; - sdi = sr_get_dev_inst(device_instances, device_index); + sdi = sr_dev_inst_get(device_instances, device_index); if (sdi) return sdi->status; else @@ -632,7 +632,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) int ret; uint64_t *tmp_u64; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; fx2 = sdi->priv; @@ -815,7 +815,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) int size, i; unsigned char *buf; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return SR_ERR; fx2 = sdi->priv; fx2->session_data = session_data; diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index fe80a188..07db8a0e 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -245,7 +245,7 @@ static struct sr_device_instance *zp_open_device(int device_index) struct libusb_device_descriptor des; int err, i; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) return NULL; libusb_get_device_list(usb_context, &devlist); @@ -474,7 +474,7 @@ static int hw_closedev(int device_index) { struct sr_device_instance *sdi; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -514,7 +514,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) struct zp *zp; void *info; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return NULL; } @@ -557,7 +557,7 @@ static int hw_get_status(int device_index) { struct sr_device_instance *sdi; - sdi = sr_get_dev_inst(device_instances, device_index); + sdi = sr_dev_inst_get(device_instances, device_index); if (sdi) return sdi->status; else @@ -604,7 +604,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) uint64_t *tmp_u64; struct zp *zp; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return SR_ERR; } @@ -641,7 +641,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) unsigned char *buf; struct zp *zp; - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return SR_ERR; } @@ -711,7 +711,7 @@ static int hw_stop_acquisition(int device_index, gpointer session_device_id) packet.type = SR_DF_END; sr_session_bus(session_device_id, &packet); - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return SR_ERR_BUG; } diff --git a/hwplugin.c b/hwplugin.c index f73d0082..6caa39db 100644 --- a/hwplugin.c +++ b/hwplugin.c @@ -68,7 +68,7 @@ extern struct sr_device_plugin alsa_plugin_info; #endif /* TODO: No linked list needed, this can be a simple array. */ -SR_PRIV int load_hwplugins(void) +SR_PRIV int sr_hwplugins_load(void) { #ifdef HAVE_LA_DEMO plugins = g_slist_append(plugins, (gpointer *)&demo_plugin_info); @@ -187,7 +187,7 @@ SR_PRIV struct sr_device_instance *sr_dev_inst_new(int index, int status, return sdi; } -SR_PRIV struct sr_device_instance *sr_get_dev_inst( +SR_PRIV struct sr_device_instance *sr_dev_inst_get( GSList *device_instances, int device_index) { struct sr_device_instance *sdi; @@ -264,7 +264,7 @@ SR_PRIV void sr_serial_dev_inst_free( } /** - * Find out if a list of hardware plugin capabilities has a specific cap. + * Find out if a hardware plugin has a specific capability. * * @param capabilities A NULL-terminated integer array of capabilities, as * returned by a plugin's get_capabilities() function. @@ -272,10 +272,11 @@ SR_PRIV void sr_serial_dev_inst_free( * * @return TRUE if found, FALSE otherwise. */ -SR_API gboolean sr_has_hwcap(int *capabilities, int hwcap) +SR_API gboolean sr_hwplugin_has_hwcap(struct sr_device_plugin *plugin, int hwcap) { - int i; + int *capabilities, i; + capabilities = plugin->get_capabilities(); for (i = 0; capabilities[i]; i++) { if (capabilities[i] == hwcap) return TRUE; @@ -285,14 +286,14 @@ SR_API gboolean sr_has_hwcap(int *capabilities, int hwcap) } /** - * Find a hardware plugin capability option parameter structure. + * Find a hardware plugin capability option. * * @param hwcap The capability to find * * @return A struct with information about the parameter, or NULL * if not found. */ -SR_API struct sr_hwcap_option *sr_find_hwcap_option(int hwcap) +SR_API struct sr_hwcap_option *sr_hwplugins_hwcap_get(int hwcap) { int i; diff --git a/session_driver.c b/session_driver.c index ab146826..6002639e 100644 --- a/session_driver.c +++ b/session_driver.c @@ -59,7 +59,7 @@ static struct session_vdevice *get_vdevice_by_index(int device_index) /* TODO: Sanity checks on device_index. */ - if (!(sdi = sr_get_dev_inst(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { sr_err("session driver: %s: device instance with device " "index %d was not found", __func__, device_index); return NULL; diff --git a/sigrok-internal.h b/sigrok-internal.h index d5916ed5..4f4a7389 100644 --- a/sigrok-internal.h +++ b/sigrok-internal.h @@ -77,7 +77,7 @@ SR_PRIV int sr_err(const char *format, ...); /*--- hwplugin.c ------------------------------------------------------------*/ -SR_PRIV int load_hwplugins(void); +SR_PRIV int sr_hwplugins_load(void); SR_PRIV void sr_hwplugins_cleanup(void); /*--- session.c -------------------------------------------------------------*/ @@ -88,7 +88,7 @@ SR_PRIV int sr_session_bus(struct sr_device *device, /* Generic device instances */ SR_PRIV struct sr_device_instance *sr_dev_inst_new(int index, int status, const char *vendor, const char *model, const char *version); -SR_PRIV struct sr_device_instance *sr_get_dev_inst( +SR_PRIV struct sr_device_instance *sr_dev_inst_get( GSList *device_instances, int device_index); SR_PRIV void sr_dev_inst_free(struct sr_device_instance *sdi); diff --git a/sigrok-proto.h b/sigrok-proto.h index fd6bcd0a..5c4cfa85 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -60,7 +60,7 @@ SR_API int sr_dev_trigger_clear(struct sr_device *device); SR_API int sr_dev_trigger_set(struct sr_device *device, int probenum, const char *trigger); SR_API gboolean sr_dev_has_hwcap(const struct sr_device *device, int hwcap); -SR_API int sr_dev_get_info(const struct sr_device *device, int id, +SR_API int sr_dev_info_get(const struct sr_device *device, int id, const void **data); /*--- filter.c --------------------------------------------------------------*/ @@ -74,8 +74,8 @@ SR_API int sr_filter_probes(int in_unitsize, int out_unitsize, SR_API GSList *sr_hwplugins_list(void); SR_API int sr_hwplugin_init(struct sr_device_plugin *plugin); -SR_API gboolean sr_has_hwcap(int *capabilities, int hwcap); -SR_API struct sr_hwcap_option *sr_find_hwcap_option(int hwcap); +SR_API gboolean sr_hwplugin_has_hwcap(struct sr_device_plugin *plugin, int hwcap); +SR_API struct sr_hwcap_option *sr_hwplugins_hwcap_get(int hwcap); /*--- session.c -------------------------------------------------------------*/