sr/cli/gtk/qt/: s/plugin/driver/.

This commit is contained in:
Uwe Hermann 2012-02-28 23:52:30 +01:00
parent 2285cf9bc5
commit c09f0b578c
25 changed files with 157 additions and 157 deletions

View File

@ -60,21 +60,21 @@ static GSList *devs = NULL;
SR_API int sr_dev_scan(void) SR_API int sr_dev_scan(void)
{ {
int i; int i;
struct sr_dev_plugin **plugins; struct sr_dev_driver **drivers;
plugins = sr_hw_list(); drivers = sr_hw_list();
if (!plugins[0]) { if (!drivers[0]) {
sr_err("dev: %s: no supported devices/hwplugins", __func__); sr_err("dev: %s: no supported hardware drivers", __func__);
return SR_ERR; /* TODO: More specific error? */ return SR_ERR; /* TODO: More specific error? */
} }
/* /*
* Initialize all plugins first. Since the init() call may involve * Initialize all drivers first. Since the init() call may involve
* a firmware upload and associated delay, we may as well get all * a firmware upload and associated delay, we may as well get all
* of these out of the way first. * of these out of the way first.
*/ */
for (i = 0; plugins[i]; i++) for (i = 0; drivers[i]; i++)
sr_hw_init(plugins[i]); sr_hw_init(drivers[i]);
return SR_OK; return SR_OK;
} }
@ -111,26 +111,26 @@ SR_API GSList *sr_dev_list(void)
* It is the caller's responsibility to g_free() the allocated memory when * It is the caller's responsibility to g_free() the allocated memory when
* no longer needed. TODO: Using which API function? * no longer needed. TODO: Using which API function?
* *
* @param plugin TODO. * @param driver TODO.
* If 'plugin' is NULL, the created device is a "virtual" one. * If 'driver' is NULL, the created device is a "virtual" one.
* @param plugin_index TODO * @param driver_index TODO
* *
* @return Pointer to the newly allocated device, or NULL upon errors. * @return Pointer to the newly allocated device, or NULL upon errors.
*/ */
SR_API struct sr_dev *sr_dev_new(const struct sr_dev_plugin *plugin, SR_API struct sr_dev *sr_dev_new(const struct sr_dev_driver *driver,
int plugin_index) int driver_index)
{ {
struct sr_dev *dev; struct sr_dev *dev;
/* TODO: Check if plugin_index valid? */ /* TODO: Check if driver_index valid? */
if (!(dev = g_try_malloc0(sizeof(struct sr_dev)))) { if (!(dev = g_try_malloc0(sizeof(struct sr_dev)))) {
sr_err("dev: %s: dev malloc failed", __func__); sr_err("dev: %s: dev malloc failed", __func__);
return NULL; return NULL;
} }
dev->plugin = (struct sr_dev_plugin *)plugin; dev->driver = (struct sr_dev_driver *)driver;
dev->plugin_index = plugin_index; dev->driver_index = driver_index;
devs = g_slist_append(devs, dev); devs = g_slist_append(devs, dev);
return dev; return dev;
@ -362,7 +362,7 @@ SR_API int sr_dev_trigger_set(struct sr_dev *dev, int probenum,
* TODO: Should return int? * TODO: Should return int?
* *
* @param dev Pointer to the device to be checked. Must not be NULL. * @param dev Pointer to the device to be checked. Must not be NULL.
* The device's 'plugin' field must not be NULL either. * The device's 'driver' field must not be NULL either.
* @param hwcap The capability that should be checked (whether it's supported * @param hwcap The capability that should be checked (whether it's supported
* by the specified device). * by the specified device).
* *
@ -379,14 +379,14 @@ SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap)
return FALSE; /* TODO: SR_ERR_ARG. */ return FALSE; /* TODO: SR_ERR_ARG. */
} }
if (!dev->plugin) { if (!dev->driver) {
sr_err("dev: %s: dev->plugin was NULL", __func__); sr_err("dev: %s: dev->driver was NULL", __func__);
return FALSE; /* TODO: SR_ERR_ARG. */ return FALSE; /* TODO: SR_ERR_ARG. */
} }
/* TODO: Sanity check on 'hwcap'. */ /* TODO: Sanity check on 'hwcap'. */
if (!(hwcaps = dev->plugin->hwcap_get_all())) { if (!(hwcaps = dev->driver->hwcap_get_all())) {
sr_err("dev: %s: dev has no capabilities", __func__); sr_err("dev: %s: dev has no capabilities", __func__);
return FALSE; /* TODO: SR_ERR*. */ return FALSE; /* TODO: SR_ERR*. */
} }
@ -407,7 +407,7 @@ SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap)
* Returns information about the given device. * Returns information about the given device.
* *
* @param dev Pointer to the device to be checked. Must not be NULL. * @param dev Pointer to the device to be checked. Must not be NULL.
* The device's 'plugin' field must not be NULL either. * The device's 'driver' field must not be NULL either.
* @param id The type of information. * @param id The type of information.
* @param data The return value. Must not be NULL. * @param data The return value. Must not be NULL.
* *
@ -416,13 +416,13 @@ SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap)
*/ */
SR_API int sr_dev_info_get(const struct sr_dev *dev, int id, const void **data) SR_API int sr_dev_info_get(const struct sr_dev *dev, int id, const void **data)
{ {
if ((dev == NULL) || (dev->plugin == NULL)) if ((dev == NULL) || (dev->driver == NULL))
return SR_ERR_ARG; return SR_ERR_ARG;
if (data == NULL) if (data == NULL)
return SR_ERR_ARG; return SR_ERR_ARG;
*data = dev->plugin->dev_info_get(dev->plugin_index, id); *data = dev->driver->dev_info_get(dev->driver_index, id);
if (*data == NULL) if (*data == NULL)
return SR_ERR; return SR_ERR;

View File

@ -395,7 +395,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin alsa_plugin_info = { SR_PRIV struct sr_dev_driver alsa_driver_info = {
.name = "alsa", .name = "alsa",
.longname = "ALSA driver", .longname = "ALSA driver",
.api_version = 1, .api_version = 1,

View File

@ -1413,7 +1413,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin asix_sigma_plugin_info = { SR_PRIV struct sr_dev_driver asix_sigma_driver_info = {
.name = "asix-sigma", .name = "asix-sigma",
.longname = "ASIX SIGMA", .longname = "ASIX SIGMA",
.api_version = 1, .api_version = 1,

View File

@ -1111,7 +1111,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin chronovu_la8_plugin_info = { SR_PRIV struct sr_dev_driver chronovu_la8_driver_info = {
.name = "chronovu-la8", .name = "chronovu-la8",
.longname = "ChronoVu LA8", .longname = "ChronoVu LA8",
.api_version = 1, .api_version = 1,

View File

@ -493,7 +493,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin demo_plugin_info = { SR_PRIV struct sr_dev_driver demo_driver_info = {
.name = "demo", .name = "demo",
.longname = "Demo driver and pattern generator", .longname = "Demo driver and pattern generator",
.api_version = 1, .api_version = 1,

View File

@ -658,7 +658,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin fx2lafw_plugin_info = { SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
.name = "fx2lafw", .name = "fx2lafw",
.longname = "fx2lafw", .longname = "fx2lafw",
.api_version = 1, .api_version = 1,

View File

@ -834,7 +834,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin link_mso19_plugin_info = { SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
.name = "link-mso19", .name = "link-mso19",
.longname = "Link Instruments MSO-19", .longname = "Link Instruments MSO-19",
.api_version = 1, .api_version = 1,

View File

@ -1036,7 +1036,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin ols_plugin_info = { SR_PRIV struct sr_dev_driver ols_driver_info = {
.name = "ols", .name = "ols",
.longname = "Openbench Logic Sniffer", .longname = "Openbench Logic Sniffer",
.api_version = 1, .api_version = 1,

View File

@ -893,7 +893,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin saleae_logic_plugin_info = { SR_PRIV struct sr_dev_driver saleae_logic_driver_info = {
.name = "saleae-logic", .name = "saleae-logic",
.longname = "Saleae Logic", .longname = "Saleae Logic",
.api_version = 1, .api_version = 1,

View File

@ -714,7 +714,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin zeroplus_logic_cube_plugin_info = { SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = {
.name = "zeroplus-logic-cube", .name = "zeroplus-logic-cube",
.longname = "Zeroplus Logic Cube LAP-C series", .longname = "Zeroplus Logic Cube LAP-C series",
.api_version = 1, .api_version = 1,

View File

@ -27,7 +27,7 @@
#include "sigrok-internal.h" #include "sigrok-internal.h"
/* /*
* This enumerates which plugin capabilities correspond to user-settable * This enumerates which driver capabilities correspond to user-settable
* options. * options.
*/ */
/* TODO: This shouldn't be a global. */ /* TODO: This shouldn't be a global. */
@ -40,109 +40,109 @@ SR_API struct sr_hwcap_option sr_hwcap_options[] = {
}; };
#ifdef HAVE_LA_DEMO #ifdef HAVE_LA_DEMO
extern SR_PRIV struct sr_dev_plugin demo_plugin_info; extern SR_PRIV struct sr_dev_driver demo_driver_info;
#endif #endif
#ifdef HAVE_LA_SALEAE_LOGIC #ifdef HAVE_LA_SALEAE_LOGIC
extern SR_PRIV struct sr_dev_plugin saleae_logic_plugin_info; extern SR_PRIV struct sr_dev_driver saleae_logic_driver_info;
#endif #endif
#ifdef HAVE_LA_OLS #ifdef HAVE_LA_OLS
extern SR_PRIV struct sr_dev_plugin ols_plugin_info; extern SR_PRIV struct sr_dev_driver ols_driver_info;
#endif #endif
#ifdef HAVE_LA_ZEROPLUS_LOGIC_CUBE #ifdef HAVE_LA_ZEROPLUS_LOGIC_CUBE
extern SR_PRIV struct sr_dev_plugin zeroplus_logic_cube_plugin_info; extern SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info;
#endif #endif
#ifdef HAVE_LA_ASIX_SIGMA #ifdef HAVE_LA_ASIX_SIGMA
extern SR_PRIV struct sr_dev_plugin asix_sigma_plugin_info; extern SR_PRIV struct sr_dev_driver asix_sigma_driver_info;
#endif #endif
#ifdef HAVE_LA_CHRONOVU_LA8 #ifdef HAVE_LA_CHRONOVU_LA8
extern SR_PRIV struct sr_dev_plugin chronovu_la8_plugin_info; extern SR_PRIV struct sr_dev_driver chronovu_la8_driver_info;
#endif #endif
#ifdef HAVE_LA_LINK_MSO19 #ifdef HAVE_LA_LINK_MSO19
extern SR_PRIV struct sr_dev_plugin link_mso19_plugin_info; extern SR_PRIV struct sr_dev_driver link_mso19_driver_info;
#endif #endif
#ifdef HAVE_LA_ALSA #ifdef HAVE_LA_ALSA
extern SR_PRIV struct sr_dev_plugin alsa_plugin_info; extern SR_PRIV struct sr_dev_driver alsa_driver_info;
#endif #endif
#ifdef HAVE_LA_FX2LAFW #ifdef HAVE_LA_FX2LAFW
extern SR_PRIV struct sr_dev_plugin fx2lafw_plugin_info; extern SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
#endif #endif
static struct sr_dev_plugin *plugins_list[] = { static struct sr_dev_driver *drivers_list[] = {
#ifdef HAVE_LA_DEMO #ifdef HAVE_LA_DEMO
&demo_plugin_info, &demo_driver_info,
#endif #endif
#ifdef HAVE_LA_SALEAE_LOGIC #ifdef HAVE_LA_SALEAE_LOGIC
&saleae_logic_plugin_info, &saleae_logic_driver_info,
#endif #endif
#ifdef HAVE_LA_OLS #ifdef HAVE_LA_OLS
&ols_plugin_info, &ols_driver_info,
#endif #endif
#ifdef HAVE_LA_ZEROPLUS_LOGIC_CUBE #ifdef HAVE_LA_ZEROPLUS_LOGIC_CUBE
&zeroplus_logic_cube_plugin_info, &zeroplus_logic_cube_driver_info,
#endif #endif
#ifdef HAVE_LA_ASIX_SIGMA #ifdef HAVE_LA_ASIX_SIGMA
&asix_sigma_plugin_info, &asix_sigma_driver_info,
#endif #endif
#ifdef HAVE_LA_CHRONOVU_LA8 #ifdef HAVE_LA_CHRONOVU_LA8
&chronovu_la8_plugin_info, &chronovu_la8_driver_info,
#endif #endif
#ifdef HAVE_LA_LINK_MSO19 #ifdef HAVE_LA_LINK_MSO19
&link_mso19_plugin_info, &link_mso19_driver_info,
#endif #endif
#ifdef HAVE_LA_ALSA #ifdef HAVE_LA_ALSA
&alsa_plugin_info, &alsa_driver_info,
#endif #endif
#ifdef HAVE_LA_FX2LAFW #ifdef HAVE_LA_FX2LAFW
&fx2lafw_plugin_info, &fx2lafw_driver_info,
#endif #endif
NULL, NULL,
}; };
/** /**
* Return the list of loaded hardware plugins. * Return the list of loaded hardware drivers.
* *
* The list of plugins is initialized from sr_init(), and can only be reset * The list of drivers is initialized from sr_init(), and can only be reset
* by calling sr_exit(). * by calling sr_exit().
* *
* @return Pointer to the NULL-terminated list of hardware plugin pointers. * @return Pointer to the NULL-terminated list of hardware driver pointers.
*/ */
SR_API struct sr_dev_plugin **sr_hw_list(void) SR_API struct sr_dev_driver **sr_hw_list(void)
{ {
return plugins_list; return drivers_list;
} }
/** /**
* Initialize a hardware plugin. * Initialize a hardware driver.
* *
* The specified plugin is initialized, and all devices discovered by the * The specified driver is initialized, and all devices discovered by the
* plugin are instantiated. * driver are instantiated.
* *
* @param plugin The plugin to initialize. * @param driver The driver to initialize.
* *
* @return The number of devices found and instantiated by the plugin. * @return The number of devices found and instantiated by the driver.
*/ */
SR_API int sr_hw_init(struct sr_dev_plugin *plugin) SR_API int sr_hw_init(struct sr_dev_driver *driver)
{ {
int num_devs, num_probes, i, j; int num_devs, num_probes, i, j;
int num_initialized_devs = 0; int num_initialized_devs = 0;
struct sr_dev *dev; struct sr_dev *dev;
char **probe_names; char **probe_names;
sr_dbg("initializing %s plugin", plugin->name); sr_dbg("initializing %s driver", driver->name);
num_devs = plugin->init(NULL); num_devs = driver->init(NULL);
for (i = 0; i < num_devs; i++) { for (i = 0; i < num_devs; i++) {
num_probes = GPOINTER_TO_INT( num_probes = GPOINTER_TO_INT(
plugin->dev_info_get(i, SR_DI_NUM_PROBES)); driver->dev_info_get(i, SR_DI_NUM_PROBES));
probe_names = (char **)plugin->dev_info_get(i, probe_names = (char **)driver->dev_info_get(i,
SR_DI_PROBE_NAMES); SR_DI_PROBE_NAMES);
if (!probe_names) { if (!probe_names) {
sr_warn("hwplugin: %s: plugin %s does not return a " sr_warn("hwdriver: %s: driver %s does not return a "
"list of probe names", __func__, plugin->name); "list of probe names", __func__, driver->name);
continue; continue;
} }
dev = sr_dev_new(plugin, i); dev = sr_dev_new(driver, i);
for (j = 0; j < num_probes; j++) for (j = 0; j < num_probes; j++)
sr_dev_probe_add(dev, probe_names[j]); sr_dev_probe_add(dev, probe_names[j]);
num_initialized_devs++; num_initialized_devs++;
@ -154,12 +154,12 @@ SR_API int sr_hw_init(struct sr_dev_plugin *plugin)
SR_PRIV void sr_hw_cleanup_all(void) SR_PRIV void sr_hw_cleanup_all(void)
{ {
int i; int i;
struct sr_dev_plugin **plugins; struct sr_dev_driver **drivers;
plugins = sr_hw_list(); drivers = sr_hw_list();
for (i = 0; plugins[i]; i++) { for (i = 0; drivers[i]; i++) {
if (plugins[i]->cleanup) if (drivers[i]->cleanup)
plugins[i]->cleanup(); drivers[i]->cleanup();
} }
} }
@ -169,7 +169,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
if (!(sdi = g_try_malloc(sizeof(struct sr_dev_inst)))) { if (!(sdi = g_try_malloc(sizeof(struct sr_dev_inst)))) {
sr_err("hwplugin: %s: sdi malloc failed", __func__); sr_err("hwdriver: %s: sdi malloc failed", __func__);
return NULL; return NULL;
} }
@ -216,7 +216,7 @@ SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus,
struct sr_usb_dev_inst *udi; struct sr_usb_dev_inst *udi;
if (!(udi = g_try_malloc(sizeof(struct sr_usb_dev_inst)))) { if (!(udi = g_try_malloc(sizeof(struct sr_usb_dev_inst)))) {
sr_err("hwplugin: %s: udi malloc failed", __func__); sr_err("hwdriver: %s: udi malloc failed", __func__);
return NULL; return NULL;
} }
@ -243,7 +243,7 @@ SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(const char *port,
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (!(serial = g_try_malloc(sizeof(struct sr_serial_dev_inst)))) { if (!(serial = g_try_malloc(sizeof(struct sr_serial_dev_inst)))) {
sr_err("hwplugin: %s: serial malloc failed", __func__); sr_err("hwdriver: %s: serial malloc failed", __func__);
return NULL; return NULL;
} }
@ -259,18 +259,18 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial)
} }
/** /**
* Find out if a hardware plugin has a specific capability. * Find out if a hardware driver has a specific capability.
* *
* @param plugin The hardware plugin in which to search for the capability. * @param driver The hardware driver in which to search for the capability.
* @param hwcap The capability to find in the list. * @param hwcap The capability to find in the list.
* *
* @return TRUE if found, FALSE otherwise. * @return TRUE if found, FALSE otherwise.
*/ */
SR_API gboolean sr_hw_has_hwcap(struct sr_dev_plugin *plugin, int hwcap) SR_API gboolean sr_hw_has_hwcap(struct sr_dev_driver *driver, int hwcap)
{ {
int *hwcaps, i; int *hwcaps, i;
hwcaps = plugin->hwcap_get_all(); hwcaps = driver->hwcap_get_all();
for (i = 0; hwcaps[i]; i++) { for (i = 0; hwcaps[i]; i++) {
if (hwcaps[i] == hwcap) if (hwcaps[i] == hwcap)
return TRUE; return TRUE;
@ -280,7 +280,7 @@ SR_API gboolean sr_hw_has_hwcap(struct sr_dev_plugin *plugin, int hwcap)
} }
/** /**
* Get a hardware plugin capability option. * Get a hardware driver capability option.
* *
* @param hwcap The capability to get. * @param hwcap The capability to get.
* *

View File

@ -135,9 +135,9 @@ static int init(struct sr_output *o, int default_spl, enum outputmode mode)
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
num_probes = g_slist_length(o->dev->probes); num_probes = g_slist_length(o->dev->probes);
if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) { if (o->dev->driver && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) { if (!(samplerate_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header); g_free(ctx->header);
g_free(ctx); g_free(ctx);

View File

@ -98,8 +98,8 @@ static int init(struct sr_output *o)
return SR_ERR_ARG; return SR_ERR_ARG;
} }
if (!o->dev->plugin) { if (!o->dev->driver) {
sr_warn("la8 out: %s: o->dev->plugin was NULL", __func__); sr_warn("la8 out: %s: o->dev->driver was NULL", __func__);
return SR_ERR_ARG; return SR_ERR_ARG;
} }
@ -122,8 +122,8 @@ static int init(struct sr_output *o)
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8; ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) { if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
/* TODO: Error checks. */ /* TODO: Error checks. */
} else { } else {
samplerate = 0; /* TODO: Error or set some value? */ samplerate = 0; /* TODO: Error or set some value? */

View File

@ -66,8 +66,8 @@ static int init(struct sr_output *o)
return SR_ERR_ARG; return SR_ERR_ARG;
} }
if (!o->dev->plugin) { if (!o->dev->driver) {
sr_err("csv out: %s: o->dev->plugin was NULL", __func__); sr_err("csv out: %s: o->dev->driver was NULL", __func__);
return SR_ERR_ARG; return SR_ERR_ARG;
} }
@ -92,8 +92,8 @@ static int init(struct sr_output *o)
num_probes = g_slist_length(o->dev->probes); num_probes = g_slist_length(o->dev->probes);
if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) { if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
/* TODO: Error checks. */ /* TODO: Error checks. */
} else { } else {
samplerate = 0; /* TODO: Error or set some value? */ samplerate = 0; /* TODO: Error or set some value? */

View File

@ -71,8 +71,8 @@ static int init(struct sr_output *o)
return SR_ERR_ARG; return SR_ERR_ARG;
} }
if (!o->dev->plugin) { if (!o->dev->driver) {
sr_err("gnuplot out: %s: o->dev->plugin was NULL", __func__); sr_err("gnuplot out: %s: o->dev->driver was NULL", __func__);
return SR_ERR_ARG; return SR_ERR_ARG;
} }
@ -101,8 +101,8 @@ static int init(struct sr_output *o)
num_probes = g_slist_length(o->dev->probes); num_probes = g_slist_length(o->dev->probes);
comment[0] = '\0'; comment[0] = '\0';
if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) { if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) { if (!(frequency_s = sr_samplerate_string(samplerate))) {
sr_err("gnuplot out: %s: sr_samplerate_string failed", sr_err("gnuplot out: %s: sr_samplerate_string failed",
__func__); __func__);
@ -320,9 +320,9 @@ static int analog_init(struct sr_output *o)
num_probes = g_slist_length(o->dev->probes); num_probes = g_slist_length(o->dev->probes);
comment[0] = '\0'; comment[0] = '\0';
if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) { if (o->dev->driver && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) { if (!(frequency_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header); g_free(ctx->header);
g_free(ctx); g_free(ctx);

View File

@ -60,9 +60,9 @@ static int init(struct sr_output *o)
} }
ctx->unitsize = (num_enabled_probes + 7) / 8; ctx->unitsize = (num_enabled_probes + 7) / 8;
if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) if (o->dev->driver && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE))
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
else else
samplerate = 0; samplerate = 0;

View File

@ -110,9 +110,9 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
num_probes = g_slist_length(o->dev->probes); num_probes = g_slist_length(o->dev->probes);
if (o->dev->plugin || sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) { if (o->dev->driver || sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) { if (!(samplerate_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header); g_free(ctx->header);
g_free(ctx); g_free(ctx);

View File

@ -84,9 +84,9 @@ static int init(struct sr_output *o)
g_string_append_printf(ctx->header, "$version %s %s $end\n", g_string_append_printf(ctx->header, "$version %s %s $end\n",
PACKAGE, PACKAGE_VERSION); PACKAGE, PACKAGE_VERSION);
if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) { if (o->dev->driver && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
ctx->samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( ctx->samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) { if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {
g_string_free(ctx->header, TRUE); g_string_free(ctx->header, TRUE);
g_free(ctx); g_free(ctx);

View File

@ -114,7 +114,7 @@ SR_API int sr_session_dev_clear(void)
* Add a device to the current session. * Add a device to the current session.
* *
* @param dev The device to add to the current session. Must not be NULL. * @param dev The device to add to the current session. Must not be NULL.
* Also, dev->plugin and dev->plugin->dev_open must not be NULL. * Also, dev->driver and dev->driver->dev_open must not be NULL.
* *
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments. * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
*/ */
@ -127,13 +127,13 @@ SR_API int sr_session_dev_add(struct sr_dev *dev)
return SR_ERR_ARG; return SR_ERR_ARG;
} }
if (!dev->plugin) { if (!dev->driver) {
sr_err("session: %s: dev->plugin was NULL", __func__); sr_err("session: %s: dev->driver was NULL", __func__);
return SR_ERR_ARG; return SR_ERR_ARG;
} }
if (!dev->plugin->dev_open) { if (!dev->driver->dev_open) {
sr_err("session: %s: dev->plugin->dev_open was NULL", sr_err("session: %s: dev->driver->dev_open was NULL",
__func__); __func__);
return SR_ERR_ARG; return SR_ERR_ARG;
} }
@ -143,7 +143,7 @@ SR_API int sr_session_dev_add(struct sr_dev *dev)
return SR_ERR; /* TODO: SR_ERR_BUG? */ return SR_ERR; /* TODO: SR_ERR_BUG? */
} }
if ((ret = dev->plugin->dev_open(dev->plugin_index)) != SR_OK) { if ((ret = dev->driver->dev_open(dev->driver_index)) != SR_OK) {
sr_err("session: %s: dev_open failed (%d)", __func__, ret); sr_err("session: %s: dev_open failed (%d)", __func__, ret);
return ret; return ret;
} }
@ -269,15 +269,15 @@ SR_API int sr_session_start(void)
return SR_ERR; /* TODO: SR_ERR_BUG? */ return SR_ERR; /* TODO: SR_ERR_BUG? */
} }
/* TODO: Check plugin_index validity? */ /* TODO: Check driver_index validity? */
sr_info("session: starting"); sr_info("session: starting");
for (l = session->devs; l; l = l->next) { for (l = session->devs; l; l = l->next) {
dev = l->data; dev = l->data;
/* TODO: Check for dev != NULL. */ /* TODO: Check for dev != NULL. */
if ((ret = dev->plugin->dev_acquisition_start( if ((ret = dev->driver->dev_acquisition_start(
dev->plugin_index, dev)) != SR_OK) { dev->driver_index, dev)) != SR_OK) {
sr_err("session: %s: could not start an acquisition " sr_err("session: %s: could not start an acquisition "
"(%d)", __func__, ret); "(%d)", __func__, ret);
break; break;
@ -352,7 +352,7 @@ SR_API int sr_session_halt(void)
* Stop the current session. * Stop the current session.
* *
* The current session is stopped immediately, with all acquisition sessions * The current session is stopped immediately, with all acquisition sessions
* being stopped and hardware plugins cleaned up. * being stopped and hardware drivers cleaned up.
* *
* @return SR_OK upon success, SR_ERR_BUG if no session exists. * @return SR_OK upon success, SR_ERR_BUG if no session exists.
*/ */
@ -372,11 +372,11 @@ SR_API int sr_session_stop(void)
for (l = session->devs; l; l = l->next) { for (l = session->devs; l; l = l->next) {
dev = l->data; dev = l->data;
/* Check for dev != NULL. */ /* Check for dev != NULL. */
if (dev->plugin) { if (dev->driver) {
if (dev->plugin->dev_acquisition_stop) if (dev->driver->dev_acquisition_stop)
dev->plugin->dev_acquisition_stop(dev->plugin_index, dev); dev->driver->dev_acquisition_stop(dev->driver_index, dev);
if (dev->plugin->cleanup) if (dev->driver->cleanup)
dev->plugin->cleanup(); dev->driver->cleanup();
} }
} }
@ -434,8 +434,8 @@ SR_PRIV int sr_session_bus(struct sr_dev *dev,
return SR_ERR_ARG; return SR_ERR_ARG;
} }
if (!dev->plugin) { if (!dev->driver) {
sr_err("session: %s: dev->plugin was NULL", __func__); sr_err("session: %s: dev->driver was NULL", __func__);
return SR_ERR_ARG; return SR_ERR_ARG;
} }

View File

@ -331,7 +331,7 @@ static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_plugin session_driver = { SR_PRIV struct sr_dev_driver session_driver = {
.name = "session", .name = "session",
.longname = "Session-emulating driver", .longname = "Session-emulating driver",
.api_version = 1, .api_version = 1,

View File

@ -28,7 +28,7 @@
#include "sigrok-internal.h" #include "sigrok-internal.h"
extern struct sr_session *session; extern struct sr_session *session;
extern SR_PRIV struct sr_dev_plugin session_driver; extern SR_PRIV struct sr_dev_driver session_driver;
/** /**
* Load the session from the specified filename. * Load the session from the specified filename.
@ -116,20 +116,20 @@ SR_API int sr_session_load(const char *filename)
if (!strcmp(keys[j], "capturefile")) { if (!strcmp(keys[j], "capturefile")) {
dev = sr_dev_new(&session_driver, devcnt); dev = sr_dev_new(&session_driver, devcnt);
if (devcnt == 0) if (devcnt == 0)
/* first device, init the plugin */ /* first device, init the driver */
dev->plugin->init((char *)filename); dev->driver->init((char *)filename);
sr_session_dev_add(dev); sr_session_dev_add(dev);
dev->plugin->dev_config_set(devcnt, SR_HWCAP_CAPTUREFILE, val); dev->driver->dev_config_set(devcnt, SR_HWCAP_CAPTUREFILE, val);
g_ptr_array_add(capturefiles, val); g_ptr_array_add(capturefiles, val);
} else if (!strcmp(keys[j], "samplerate")) { } else if (!strcmp(keys[j], "samplerate")) {
sr_parse_sizestring(val, &tmp_u64); sr_parse_sizestring(val, &tmp_u64);
dev->plugin->dev_config_set(devcnt, SR_HWCAP_SAMPLERATE, &tmp_u64); dev->driver->dev_config_set(devcnt, SR_HWCAP_SAMPLERATE, &tmp_u64);
} else if (!strcmp(keys[j], "unitsize")) { } else if (!strcmp(keys[j], "unitsize")) {
tmp_u64 = strtoull(val, NULL, 10); tmp_u64 = strtoull(val, NULL, 10);
dev->plugin->dev_config_set(devcnt, SR_HWCAP_CAPTURE_UNITSIZE, &tmp_u64); dev->driver->dev_config_set(devcnt, SR_HWCAP_CAPTURE_UNITSIZE, &tmp_u64);
} else if (!strcmp(keys[j], "total probes")) { } else if (!strcmp(keys[j], "total probes")) {
total_probes = strtoull(val, NULL, 10); total_probes = strtoull(val, NULL, 10);
dev->plugin->dev_config_set(devcnt, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes); dev->driver->dev_config_set(devcnt, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes);
for (p = 0; p < total_probes; p++) { for (p = 0; p < total_probes; p++) {
snprintf(probename, SR_MAX_PROBENAME_LEN, "%" PRIu64, p); snprintf(probename, SR_MAX_PROBENAME_LEN, "%" PRIu64, p);
sr_dev_probe_add(dev, probename); sr_dev_probe_add(dev, probename);
@ -216,8 +216,8 @@ int sr_session_save(const char *filename)
dev = l->data; dev = l->data;
/* metadata */ /* metadata */
fprintf(meta, "[device %d]\n", devcnt); fprintf(meta, "[device %d]\n", devcnt);
if (dev->plugin) if (dev->driver)
fprintf(meta, "driver = %s\n", dev->plugin->name); fprintf(meta, "driver = %s\n", dev->driver->name);
ds = dev->datastore; ds = dev->datastore;
if (ds) { if (ds) {
@ -226,8 +226,8 @@ int sr_session_save(const char *filename)
fprintf(meta, "unitsize = %d\n", ds->ds_unitsize); fprintf(meta, "unitsize = %d\n", ds->ds_unitsize);
fprintf(meta, "total probes = %d\n", g_slist_length(dev->probes)); fprintf(meta, "total probes = %d\n", g_slist_length(dev->probes));
if (sr_dev_has_hwcap(dev, SR_HWCAP_SAMPLERATE)) { if (sr_dev_has_hwcap(dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) dev->plugin->dev_info_get( samplerate = *((uint64_t *) dev->driver->dev_info_get(
dev->plugin_index, SR_DI_CUR_SAMPLERATE)); dev->driver_index, SR_DI_CUR_SAMPLERATE));
s = sr_samplerate_string(samplerate); s = sr_samplerate_string(samplerate);
fprintf(meta, "samplerate = %s\n", s); fprintf(meta, "samplerate = %s\n", s);
g_free(s); g_free(s);

View File

@ -76,7 +76,7 @@ SR_PRIV int sr_info(const char *format, ...);
SR_PRIV int sr_warn(const char *format, ...); SR_PRIV int sr_warn(const char *format, ...);
SR_PRIV int sr_err(const char *format, ...); SR_PRIV int sr_err(const char *format, ...);
/*--- hwplugin.c ------------------------------------------------------------*/ /*--- hwdriver.c ------------------------------------------------------------*/
SR_PRIV void sr_hw_cleanup_all(void); SR_PRIV void sr_hw_cleanup_all(void);

View File

@ -49,8 +49,8 @@ SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
SR_API int sr_dev_scan(void); SR_API int sr_dev_scan(void);
SR_API GSList *sr_dev_list(void); SR_API GSList *sr_dev_list(void);
SR_API struct sr_dev *sr_dev_new(const struct sr_dev_plugin *plugin, SR_API struct sr_dev *sr_dev_new(const struct sr_dev_driver *driver,
int plugin_index); int driver_index);
SR_API int sr_dev_probe_add(struct sr_dev *dev, const char *name); SR_API int sr_dev_probe_add(struct sr_dev *dev, const char *name);
SR_API struct sr_probe *sr_dev_probe_find(const struct sr_dev *dev, SR_API struct sr_probe *sr_dev_probe_find(const struct sr_dev *dev,
int probenum); int probenum);
@ -69,11 +69,11 @@ SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
uint64_t length_in, char **data_out, uint64_t length_in, char **data_out,
uint64_t *length_out); uint64_t *length_out);
/*--- hwplugin.c ------------------------------------------------------------*/ /*--- hwdriver.c ------------------------------------------------------------*/
SR_API struct sr_dev_plugin **sr_hw_list(void); SR_API struct sr_dev_driver **sr_hw_list(void);
SR_API int sr_hw_init(struct sr_dev_plugin *plugin); SR_API int sr_hw_init(struct sr_dev_driver *driver);
SR_API gboolean sr_hw_has_hwcap(struct sr_dev_plugin *plugin, int hwcap); SR_API gboolean sr_hw_has_hwcap(struct sr_dev_driver *driver, int hwcap);
SR_API struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap); SR_API struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap);
/*--- session.c -------------------------------------------------------------*/ /*--- session.c -------------------------------------------------------------*/

View File

@ -94,7 +94,7 @@ extern "C" {
typedef int (*sr_receive_data_callback) (int fd, int revents, void *user_data); typedef int (*sr_receive_data_callback) (int fd, int revents, void *user_data);
/* Data types used by hardware plugins for dev_config_set() */ /* Data types used by hardware drivers for dev_config_set() */
enum { enum {
SR_T_UINT64, SR_T_UINT64,
SR_T_CHAR, SR_T_CHAR,
@ -169,15 +169,15 @@ struct sr_datastore {
/* /*
* This represents a generic device connected to the system. * This represents a generic device connected to the system.
* For device-specific information, ask the plugin. The plugin_index refers * For device-specific information, ask the driver. The driver_index refers
* to the device index within that plugin; it may be handling more than one * to the device index within that driver; it may be handling more than one
* device. All relevant plugin calls take a dev_index parameter for this. * device. All relevant driver calls take a dev_index parameter for this.
*/ */
struct sr_dev { struct sr_dev {
/* Which plugin handles this device */ /* Which driver handles this device */
struct sr_dev_plugin *plugin; struct sr_dev_driver *driver;
/* A plugin may handle multiple devices of the same type */ /* A driver may handle multiple devices of the same type */
int plugin_index; int driver_index;
/* List of struct sr_probe* */ /* List of struct sr_probe* */
GSList *probes; GSList *probes;
/* Data acquired by this device, if any */ /* Data acquired by this device, if any */
@ -196,7 +196,7 @@ struct sr_probe {
char *trigger; char *trigger;
}; };
/* Hardware plugin capabilities */ /* Hardware driver capabilities */
enum { enum {
SR_HWCAP_DUMMY = 0, /* Used to terminate lists. Must be 0! */ SR_HWCAP_DUMMY = 0, /* Used to terminate lists. Must be 0! */
@ -338,8 +338,8 @@ struct sr_samplerates {
uint64_t *list; uint64_t *list;
}; };
struct sr_dev_plugin { struct sr_dev_driver {
/* Plugin-specific */ /* Driver-specific */
char *name; char *name;
char *longname; char *longname;
int api_version; int api_version;

View File

@ -136,7 +136,7 @@ SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
} }
tokens = g_strsplit(triggerstring, ",", max_probes); tokens = g_strsplit(triggerstring, ",", max_probes);
trigger_types = dev->plugin->dev_info_get(0, SR_DI_TRIGGER_TYPES); trigger_types = dev->driver->dev_info_get(0, SR_DI_TRIGGER_TYPES);
if (trigger_types == NULL) if (trigger_types == NULL)
return NULL; return NULL;