sr: add probe list to device instance
There is no point in libsigrok copying probe lists around. The driver now builds a list of probes according to the model device it found, and will make that available to a frontend. The frontend thus has a reference of what the driver has, including default names, and doesn't need libsigrok to provide an unnecessary level of abstraction. The sr_probe_new() library-private function is a helper for drivers.
This commit is contained in:
parent
80bf042635
commit
47211d65b4
20
hwdriver.c
20
hwdriver.c
|
@ -193,6 +193,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
|
||||||
sdi->vendor = vendor ? g_strdup(vendor) : NULL;
|
sdi->vendor = vendor ? g_strdup(vendor) : NULL;
|
||||||
sdi->model = model ? g_strdup(model) : NULL;
|
sdi->model = model ? g_strdup(model) : NULL;
|
||||||
sdi->version = version ? g_strdup(version) : NULL;
|
sdi->version = version ? g_strdup(version) : NULL;
|
||||||
|
sdi->probes = NULL;
|
||||||
sdi->priv = NULL;
|
sdi->priv = NULL;
|
||||||
|
|
||||||
return sdi;
|
return sdi;
|
||||||
|
@ -222,6 +223,25 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
|
||||||
g_free(sdi);
|
g_free(sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SR_PRIV struct sr_probe *sr_probe_new(int index, int type,
|
||||||
|
gboolean enabled, const char *name)
|
||||||
|
{
|
||||||
|
struct sr_probe *probe;
|
||||||
|
|
||||||
|
if (!(probe = g_try_malloc0(sizeof(struct sr_probe)))) {
|
||||||
|
sr_err("hwdriver: probe malloc failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
probe->index = index;
|
||||||
|
probe->type = type;
|
||||||
|
probe->enabled = enabled;
|
||||||
|
if (name)
|
||||||
|
probe->name = g_strdup(name);
|
||||||
|
|
||||||
|
return probe;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBUSB_1_0
|
#ifdef HAVE_LIBUSB_1_0
|
||||||
|
|
||||||
SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus,
|
SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus,
|
||||||
|
|
|
@ -91,6 +91,8 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
|
||||||
const char *vendor, const char *model, const char *version);
|
const char *vendor, const char *model, const char *version);
|
||||||
SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, int dev_index);
|
SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, int dev_index);
|
||||||
SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
|
SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
|
||||||
|
SR_PRIV struct sr_probe *sr_probe_new(int index, int type,
|
||||||
|
gboolean enabled, const char *name);
|
||||||
|
|
||||||
SR_PRIV int sr_source_remove(int fd);
|
SR_PRIV int sr_source_remove(int fd);
|
||||||
SR_PRIV int sr_source_add(int fd, int events, int timeout,
|
SR_PRIV int sr_source_add(int fd, int events, int timeout,
|
||||||
|
|
|
@ -250,7 +250,7 @@ struct sr_dev {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SR_PROBE_TYPE_LOGIC,
|
SR_PROBE_LOGIC,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sr_probe {
|
struct sr_probe {
|
||||||
|
@ -402,6 +402,7 @@ struct sr_dev_inst {
|
||||||
char *vendor;
|
char *vendor;
|
||||||
char *model;
|
char *model;
|
||||||
char *version;
|
char *version;
|
||||||
|
GSList *probes;
|
||||||
void *priv;
|
void *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue