Also improved the interface to find capabilities in a hardware plugin.
*/
SR_API int sr_init(void)
{
- return load_hwplugins();
+ return sr_hwplugins_load();
}
/**
* @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))
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;
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? */
}
{
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;
}
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;
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;
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;
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;
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? */
}
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;
}
{
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
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;
/* 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;
/* 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;
}
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? */
}
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? */
}
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;
}
{
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;
}
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? */
}
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? */
}
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;
}
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;
}
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;
{
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? */
}
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;
{
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;
{
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) {
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;
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;
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? */
}
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;
{
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;
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;
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;
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;
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;
{
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? */
}
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;
{
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
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;
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;
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);
{
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? */
}
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;
}
{
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
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;
}
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;
}
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;
}
#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);
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;
}
/**
- * 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.
*
* @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;
}
/**
- * 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;
/* 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;
/*--- hwplugin.c ------------------------------------------------------------*/
-SR_PRIV int load_hwplugins(void);
+SR_PRIV int sr_hwplugins_load(void);
SR_PRIV void sr_hwplugins_cleanup(void);
/*--- session.c -------------------------------------------------------------*/
/* 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);
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 --------------------------------------------------------------*/
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 -------------------------------------------------------------*/