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)
{
int i;
struct sr_dev_plugin **plugins;
struct sr_dev_driver **drivers;
plugins = sr_hw_list();
if (!plugins[0]) {
sr_err("dev: %s: no supported devices/hwplugins", __func__);
drivers = sr_hw_list();
if (!drivers[0]) {
sr_err("dev: %s: no supported hardware drivers", __func__);
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
* of these out of the way first.
*/
for (i = 0; plugins[i]; i++)
sr_hw_init(plugins[i]);
for (i = 0; drivers[i]; i++)
sr_hw_init(drivers[i]);
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
* no longer needed. TODO: Using which API function?
*
* @param plugin TODO.
* If 'plugin' is NULL, the created device is a "virtual" one.
* @param plugin_index TODO
* @param driver TODO.
* If 'driver' is NULL, the created device is a "virtual" one.
* @param driver_index TODO
*
* @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,
int plugin_index)
SR_API struct sr_dev *sr_dev_new(const struct sr_dev_driver *driver,
int driver_index)
{
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)))) {
sr_err("dev: %s: dev malloc failed", __func__);
return NULL;
}
dev->plugin = (struct sr_dev_plugin *)plugin;
dev->plugin_index = plugin_index;
dev->driver = (struct sr_dev_driver *)driver;
dev->driver_index = driver_index;
devs = g_slist_append(devs, dev);
return dev;
@ -362,7 +362,7 @@ SR_API int sr_dev_trigger_set(struct sr_dev *dev, int probenum,
* TODO: Should return int?
*
* @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
* 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. */
}
if (!dev->plugin) {
sr_err("dev: %s: dev->plugin was NULL", __func__);
if (!dev->driver) {
sr_err("dev: %s: dev->driver was NULL", __func__);
return FALSE; /* TODO: SR_ERR_ARG. */
}
/* 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__);
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.
*
* @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 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)
{
if ((dev == NULL) || (dev->plugin == NULL))
if ((dev == NULL) || (dev->driver == NULL))
return SR_ERR_ARG;
if (data == NULL)
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)
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;
}
SR_PRIV struct sr_dev_plugin alsa_plugin_info = {
SR_PRIV struct sr_dev_driver alsa_driver_info = {
.name = "alsa",
.longname = "ALSA driver",
.api_version = 1,

View File

@ -1413,7 +1413,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
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",
.longname = "ASIX SIGMA",
.api_version = 1,

View File

@ -1111,7 +1111,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
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",
.longname = "ChronoVu LA8",
.api_version = 1,

View File

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

View File

@ -658,7 +658,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
return SR_OK;
}
SR_PRIV struct sr_dev_plugin fx2lafw_plugin_info = {
SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
.name = "fx2lafw",
.longname = "fx2lafw",
.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;
}
SR_PRIV struct sr_dev_plugin link_mso19_plugin_info = {
SR_PRIV struct sr_dev_driver link_mso19_driver_info = {
.name = "link-mso19",
.longname = "Link Instruments MSO-19",
.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;
}
SR_PRIV struct sr_dev_plugin ols_plugin_info = {
SR_PRIV struct sr_dev_driver ols_driver_info = {
.name = "ols",
.longname = "Openbench Logic Sniffer",
.api_version = 1,

View File

@ -893,7 +893,7 @@ static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
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",
.longname = "Saleae Logic",
.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;
}
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",
.longname = "Zeroplus Logic Cube LAP-C series",
.api_version = 1,

View File

@ -27,7 +27,7 @@
#include "sigrok-internal.h"
/*
* This enumerates which plugin capabilities correspond to user-settable
* This enumerates which driver capabilities correspond to user-settable
* options.
*/
/* TODO: This shouldn't be a global. */
@ -40,109 +40,109 @@ SR_API struct sr_hwcap_option sr_hwcap_options[] = {
};
#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
#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
#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
#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
#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
#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
#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
#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
#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
static struct sr_dev_plugin *plugins_list[] = {
static struct sr_dev_driver *drivers_list[] = {
#ifdef HAVE_LA_DEMO
&demo_plugin_info,
&demo_driver_info,
#endif
#ifdef HAVE_LA_SALEAE_LOGIC
&saleae_logic_plugin_info,
&saleae_logic_driver_info,
#endif
#ifdef HAVE_LA_OLS
&ols_plugin_info,
&ols_driver_info,
#endif
#ifdef HAVE_LA_ZEROPLUS_LOGIC_CUBE
&zeroplus_logic_cube_plugin_info,
&zeroplus_logic_cube_driver_info,
#endif
#ifdef HAVE_LA_ASIX_SIGMA
&asix_sigma_plugin_info,
&asix_sigma_driver_info,
#endif
#ifdef HAVE_LA_CHRONOVU_LA8
&chronovu_la8_plugin_info,
&chronovu_la8_driver_info,
#endif
#ifdef HAVE_LA_LINK_MSO19
&link_mso19_plugin_info,
&link_mso19_driver_info,
#endif
#ifdef HAVE_LA_ALSA
&alsa_plugin_info,
&alsa_driver_info,
#endif
#ifdef HAVE_LA_FX2LAFW
&fx2lafw_plugin_info,
&fx2lafw_driver_info,
#endif
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().
*
* @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
* plugin are instantiated.
* The specified driver is initialized, and all devices discovered by the
* 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_initialized_devs = 0;
struct sr_dev *dev;
char **probe_names;
sr_dbg("initializing %s plugin", plugin->name);
num_devs = plugin->init(NULL);
sr_dbg("initializing %s driver", driver->name);
num_devs = driver->init(NULL);
for (i = 0; i < num_devs; i++) {
num_probes = GPOINTER_TO_INT(
plugin->dev_info_get(i, SR_DI_NUM_PROBES));
probe_names = (char **)plugin->dev_info_get(i,
driver->dev_info_get(i, SR_DI_NUM_PROBES));
probe_names = (char **)driver->dev_info_get(i,
SR_DI_PROBE_NAMES);
if (!probe_names) {
sr_warn("hwplugin: %s: plugin %s does not return a "
"list of probe names", __func__, plugin->name);
sr_warn("hwdriver: %s: driver %s does not return a "
"list of probe names", __func__, driver->name);
continue;
}
dev = sr_dev_new(plugin, i);
dev = sr_dev_new(driver, i);
for (j = 0; j < num_probes; j++)
sr_dev_probe_add(dev, probe_names[j]);
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)
{
int i;
struct sr_dev_plugin **plugins;
struct sr_dev_driver **drivers;
plugins = sr_hw_list();
for (i = 0; plugins[i]; i++) {
if (plugins[i]->cleanup)
plugins[i]->cleanup();
drivers = sr_hw_list();
for (i = 0; drivers[i]; i++) {
if (drivers[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;
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;
}
@ -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;
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;
}
@ -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;
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;
}
@ -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.
*
* @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;
hwcaps = plugin->hwcap_get_all();
hwcaps = driver->hwcap_get_all();
for (i = 0; hwcaps[i]; i++) {
if (hwcaps[i] == hwcap)
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.
*

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);
num_probes = g_slist_length(o->dev->probes);
if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (o->dev->driver && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header);
g_free(ctx);

View File

@ -98,8 +98,8 @@ static int init(struct sr_output *o)
return SR_ERR_ARG;
}
if (!o->dev->plugin) {
sr_warn("la8 out: %s: o->dev->plugin was NULL", __func__);
if (!o->dev->driver) {
sr_warn("la8 out: %s: o->dev->driver was NULL", __func__);
return SR_ERR_ARG;
}
@ -122,8 +122,8 @@ static int init(struct sr_output *o)
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
/* TODO: Error checks. */
} else {
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;
}
if (!o->dev->plugin) {
sr_err("csv out: %s: o->dev->plugin was NULL", __func__);
if (!o->dev->driver) {
sr_err("csv out: %s: o->dev->driver was NULL", __func__);
return SR_ERR_ARG;
}
@ -92,8 +92,8 @@ static int init(struct sr_output *o)
num_probes = g_slist_length(o->dev->probes);
if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
/* TODO: Error checks. */
} else {
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;
}
if (!o->dev->plugin) {
sr_err("gnuplot out: %s: o->dev->plugin was NULL", __func__);
if (!o->dev->driver) {
sr_err("gnuplot out: %s: o->dev->driver was NULL", __func__);
return SR_ERR_ARG;
}
@ -101,8 +101,8 @@ static int init(struct sr_output *o)
num_probes = g_slist_length(o->dev->probes);
comment[0] = '\0';
if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) {
sr_err("gnuplot out: %s: sr_samplerate_string failed",
__func__);
@ -320,9 +320,9 @@ static int analog_init(struct sr_output *o)
num_probes = g_slist_length(o->dev->probes);
comment[0] = '\0';
if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (o->dev->driver && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header);
g_free(ctx);

View File

@ -60,9 +60,9 @@ static int init(struct sr_output *o)
}
ctx->unitsize = (num_enabled_probes + 7) / 8;
if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE))
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (o->dev->driver && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE))
samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
else
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);
num_probes = g_slist_length(o->dev->probes);
if (o->dev->plugin || sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (o->dev->driver || sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) {
g_free(ctx->header);
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",
PACKAGE, PACKAGE_VERSION);
if (o->dev->plugin && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
ctx->samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));
if (o->dev->driver && sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
ctx->samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {
g_string_free(ctx->header, TRUE);
g_free(ctx);

View File

@ -114,7 +114,7 @@ SR_API int sr_session_dev_clear(void)
* Add a device to the current session.
*
* @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.
*/
@ -127,13 +127,13 @@ SR_API int sr_session_dev_add(struct sr_dev *dev)
return SR_ERR_ARG;
}
if (!dev->plugin) {
sr_err("session: %s: dev->plugin was NULL", __func__);
if (!dev->driver) {
sr_err("session: %s: dev->driver was NULL", __func__);
return SR_ERR_ARG;
}
if (!dev->plugin->dev_open) {
sr_err("session: %s: dev->plugin->dev_open was NULL",
if (!dev->driver->dev_open) {
sr_err("session: %s: dev->driver->dev_open was NULL",
__func__);
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? */
}
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);
return ret;
}
@ -269,15 +269,15 @@ SR_API int sr_session_start(void)
return SR_ERR; /* TODO: SR_ERR_BUG? */
}
/* TODO: Check plugin_index validity? */
/* TODO: Check driver_index validity? */
sr_info("session: starting");
for (l = session->devs; l; l = l->next) {
dev = l->data;
/* TODO: Check for dev != NULL. */
if ((ret = dev->plugin->dev_acquisition_start(
dev->plugin_index, dev)) != SR_OK) {
if ((ret = dev->driver->dev_acquisition_start(
dev->driver_index, dev)) != SR_OK) {
sr_err("session: %s: could not start an acquisition "
"(%d)", __func__, ret);
break;
@ -352,7 +352,7 @@ SR_API int sr_session_halt(void)
* Stop the current session.
*
* 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.
*/
@ -372,11 +372,11 @@ SR_API int sr_session_stop(void)
for (l = session->devs; l; l = l->next) {
dev = l->data;
/* Check for dev != NULL. */
if (dev->plugin) {
if (dev->plugin->dev_acquisition_stop)
dev->plugin->dev_acquisition_stop(dev->plugin_index, dev);
if (dev->plugin->cleanup)
dev->plugin->cleanup();
if (dev->driver) {
if (dev->driver->dev_acquisition_stop)
dev->driver->dev_acquisition_stop(dev->driver_index, dev);
if (dev->driver->cleanup)
dev->driver->cleanup();
}
}
@ -434,8 +434,8 @@ SR_PRIV int sr_session_bus(struct sr_dev *dev,
return SR_ERR_ARG;
}
if (!dev->plugin) {
sr_err("session: %s: dev->plugin was NULL", __func__);
if (!dev->driver) {
sr_err("session: %s: dev->driver was NULL", __func__);
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;
}
SR_PRIV struct sr_dev_plugin session_driver = {
SR_PRIV struct sr_dev_driver session_driver = {
.name = "session",
.longname = "Session-emulating driver",
.api_version = 1,

View File

@ -28,7 +28,7 @@
#include "sigrok-internal.h"
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.
@ -116,20 +116,20 @@ SR_API int sr_session_load(const char *filename)
if (!strcmp(keys[j], "capturefile")) {
dev = sr_dev_new(&session_driver, devcnt);
if (devcnt == 0)
/* first device, init the plugin */
dev->plugin->init((char *)filename);
/* first device, init the driver */
dev->driver->init((char *)filename);
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);
} else if (!strcmp(keys[j], "samplerate")) {
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")) {
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")) {
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++) {
snprintf(probename, SR_MAX_PROBENAME_LEN, "%" PRIu64, p);
sr_dev_probe_add(dev, probename);
@ -216,8 +216,8 @@ int sr_session_save(const char *filename)
dev = l->data;
/* metadata */
fprintf(meta, "[device %d]\n", devcnt);
if (dev->plugin)
fprintf(meta, "driver = %s\n", dev->plugin->name);
if (dev->driver)
fprintf(meta, "driver = %s\n", dev->driver->name);
ds = dev->datastore;
if (ds) {
@ -226,8 +226,8 @@ int sr_session_save(const char *filename)
fprintf(meta, "unitsize = %d\n", ds->ds_unitsize);
fprintf(meta, "total probes = %d\n", g_slist_length(dev->probes));
if (sr_dev_has_hwcap(dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) dev->plugin->dev_info_get(
dev->plugin_index, SR_DI_CUR_SAMPLERATE));
samplerate = *((uint64_t *) dev->driver->dev_info_get(
dev->driver_index, SR_DI_CUR_SAMPLERATE));
s = sr_samplerate_string(samplerate);
fprintf(meta, "samplerate = %s\n", 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_err(const char *format, ...);
/*--- hwplugin.c ------------------------------------------------------------*/
/*--- hwdriver.c ------------------------------------------------------------*/
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 GSList *sr_dev_list(void);
SR_API struct sr_dev *sr_dev_new(const struct sr_dev_plugin *plugin,
int plugin_index);
SR_API struct sr_dev *sr_dev_new(const struct sr_dev_driver *driver,
int driver_index);
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,
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_out);
/*--- hwplugin.c ------------------------------------------------------------*/
/*--- hwdriver.c ------------------------------------------------------------*/
SR_API struct sr_dev_plugin **sr_hw_list(void);
SR_API int sr_hw_init(struct sr_dev_plugin *plugin);
SR_API gboolean sr_hw_has_hwcap(struct sr_dev_plugin *plugin, int hwcap);
SR_API struct sr_dev_driver **sr_hw_list(void);
SR_API int sr_hw_init(struct sr_dev_driver *driver);
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);
/*--- session.c -------------------------------------------------------------*/

View File

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