It was actually used in one way: the session file loaded abused it for
passing in the filename -- something it definitely wasn't intended for.
This now uses the proper way to pass arguments to a driver: the new
SR_HWCAP_SESSIONFILE.
The OLS driver could also use it as an indication of the serial port to
use instead of actively probing all serial ports on the system, but there
wasn't any frontend code that passed in such a parameter, making it
entirely useless. That will soon be handled differently with the new
scan() API call, regardless.
13 files changed:
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct context *ctx;
{
struct sr_dev_inst *sdi;
struct context *ctx;
char serial_txt[10];
uint32_t serial;
char serial_txt[10];
uint32_t serial;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("sigma: %s: ctx malloc failed", __func__);
return SR_ERR_MALLOC;
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("sigma: %s: ctx malloc failed", __func__);
return SR_ERR_MALLOC;
/* Function prototypes. */
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
/* Function prototypes. */
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
int ret;
struct sr_dev_inst *sdi;
struct context *ctx;
unsigned int i;
{
int ret;
struct sr_dev_inst *sdi;
struct context *ctx;
unsigned int i;
- /* Avoid compiler errors. */
- (void)devinfo;
-
/* Allocate memory for our private driver context. */
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("la8: %s: struct context malloc failed", __func__);
/* Allocate memory for our private driver context. */
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("la8: %s: struct context malloc failed", __func__);
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
{
struct sr_dev_inst *sdi;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) {
sr_err("demo: %s: sr_dev_inst_new failed", __func__);
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) {
sr_err("demo: %s: sr_dev_inst_new failed", __func__);
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
int devcnt = 0;
int i, j;
int devcnt = 0;
int i, j;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
if (libusb_init(&usb_context) != 0) {
sr_warn("fx2lafw: Failed to initialize libusb.");
return 0;
if (libusb_init(&usb_context) != 0) {
sr_warn("fx2lafw: Failed to initialize libusb.");
return 0;
SR_PRIV libusb_context *genericdmm_usb_context = NULL;
SR_PRIV libusb_context *genericdmm_usb_context = NULL;
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct context *ctx;
int devcnt = 0;
{
struct sr_dev_inst *sdi;
struct context *ctx;
int devcnt = 0;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
if (libusb_init(&genericdmm_usb_context) != 0) {
sr_err("genericdmm: Failed to initialize USB.");
return 0;
if (libusb_init(&genericdmm_usb_context) != 0) {
sr_err("genericdmm: Failed to initialize USB.");
return 0;
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
libusb_device **devlist;
int err, devcnt, i, j;
libusb_device **devlist;
int err, devcnt, i, j;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
if (libusb_init(&usb_context) != 0) {
sr_err("hantek-dso: Failed to initialize USB.");
return 0;
if (libusb_init(&usb_context) != 0) {
sr_err("hantek-dso: Failed to initialize USB.");
return 0;
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
int devcnt = 0;
{
struct sr_dev_inst *sdi;
int devcnt = 0;
struct udev_list_entry *devs, *dev_list_entry;
struct context *ctx;
struct udev_list_entry *devs, *dev_list_entry;
struct context *ctx;
/* It's easier to map usb<->serial using udev */
/*
* FIXME: On windows we can get the same information from the
/* It's easier to map usb<->serial using udev */
/*
* FIXME: On windows we can get the same information from the
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct context *ctx;
{
struct sr_dev_inst *sdi;
struct context *ctx;
- if (devinfo)
- ports = g_slist_append(NULL, g_strdup(devinfo));
- else
- /* No specific device given, so scan all serial ports. */
- ports = list_serial_ports();
-
+ /* Scan all serial ports. */
+ ports = list_serial_ports();
num_ports = g_slist_length(ports);
if (!(fds = g_try_malloc0(num_ports * sizeof(GPollFD)))) {
num_ports = g_slist_length(ports);
if (!(fds = g_try_malloc0(num_ports * sizeof(GPollFD)))) {
-static int hw_init(const char *devinfo)
+static int hw_init(void)
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
{
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
int ret, devcnt, i;
struct context *ctx;
int ret, devcnt, i;
struct context *ctx;
- /* Avoid compiler warnings. */
- (void)devinfo;
-
/* Allocate memory for our private driver context. */
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("zp: %s: ctx malloc failed", __func__);
/* Allocate memory for our private driver context. */
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("zp: %s: ctx malloc failed", __func__);
char **probe_names;
sr_dbg("initializing %s driver", driver->name);
char **probe_names;
sr_dbg("initializing %s driver", driver->name);
- num_devs = driver->init(NULL);
+ num_devs = driver->init();
for (i = 0; i < num_devs; i++) {
num_probes = GPOINTER_TO_INT(
driver->dev_info_get(i, SR_DI_NUM_PROBES));
for (i = 0; i < num_devs; i++) {
num_probes = GPOINTER_TO_INT(
driver->dev_info_get(i, SR_DI_NUM_PROBES));
/*--- Special stuff -------------------------------------------------*/
/*--- Special stuff -------------------------------------------------*/
+ /** Session filename */
+ SR_HWCAP_SESSIONFILE,
+
/* TODO: Better description. */
/** The device supports specifying a capturefile to inject. */
SR_HWCAP_CAPTUREFILE,
/* TODO: Better description. */
/** The device supports specifying a capturefile to inject. */
SR_HWCAP_CAPTUREFILE,
char *name;
char *longname;
int api_version;
char *name;
char *longname;
int api_version;
- int (*init) (const char *devinfo);
int (*cleanup) (void);
/* Device-specific */
int (*cleanup) (void);
/* Device-specific */
#define CHUNKSIZE (512 * 1024)
struct session_vdev {
#define CHUNKSIZE (512 * 1024)
struct session_vdev {
char *capturefile;
struct zip *archive;
struct zip_file *capfile;
char *capturefile;
struct zip *archive;
struct zip_file *capfile;
-static char *sessionfile = NULL;
static GSList *dev_insts = NULL;
static const int hwcaps[] = {
SR_HWCAP_CAPTUREFILE,
static GSList *dev_insts = NULL;
static const int hwcaps[] = {
SR_HWCAP_CAPTUREFILE,
-static int hw_init(const char *devinfo)
+static int hw_init(void)
- sessionfile = g_strdup(devinfo);
sr_session_source_remove(-1);
sr_session_source_remove(-1);
sr_info("session driver: setting samplerate to %" PRIu64,
vdev->samplerate);
break;
sr_info("session driver: setting samplerate to %" PRIu64,
vdev->samplerate);
break;
+ case SR_HWCAP_SESSIONFILE:
+ vdev->sessionfile = g_strdup(value);
+ sr_info("session driver: setting sessionfile to %s",
+ vdev->sessionfile);
+ break;
case SR_HWCAP_CAPTUREFILE:
vdev->capturefile = g_strdup(value);
sr_info("session driver: setting capturefile to %s",
case SR_HWCAP_CAPTUREFILE:
vdev->capturefile = g_strdup(value);
sr_info("session driver: setting capturefile to %s",
if (!(vdev = get_vdev_by_index(dev_index)))
return SR_ERR;
if (!(vdev = get_vdev_by_index(dev_index)))
return SR_ERR;
- sr_info("session_driver: opening archive %s file %s", sessionfile,
+ sr_info("session_driver: opening archive %s file %s", vdev->sessionfile,
- if (!(vdev->archive = zip_open(sessionfile, 0, &ret))) {
+ if (!(vdev->archive = zip_open(vdev->sessionfile, 0, &ret))) {
sr_err("session driver: Failed to open session file '%s': "
sr_err("session driver: Failed to open session file '%s': "
- "zip error %d\n", sessionfile, ret);
+ "zip error %d\n", vdev->sessionfile, ret);
return SR_ERR;
}
if (zip_stat(vdev->archive, vdev->capturefile, 0, &zs) == -1) {
sr_err("session driver: Failed to check capture file '%s' in "
return SR_ERR;
}
if (zip_stat(vdev->archive, vdev->capturefile, 0, &zs) == -1) {
sr_err("session driver: Failed to check capture file '%s' in "
- "session file '%s'.", vdev->capturefile, sessionfile);
+ "session file '%s'.", vdev->capturefile, vdev->sessionfile);
return SR_ERR;
}
if (!(vdev->capfile = zip_fopen(vdev->archive, vdev->capturefile, 0))) {
sr_err("session driver: Failed to open capture file '%s' in "
return SR_ERR;
}
if (!(vdev->capfile = zip_fopen(vdev->archive, vdev->capturefile, 0))) {
sr_err("session driver: Failed to open capture file '%s' in "
- "session file '%s'.", vdev->capturefile, sessionfile);
+ "session file '%s'.", vdev->capturefile, vdev->sessionfile);
dev = sr_dev_new(&session_driver, devcnt);
if (devcnt == 0)
/* first device, init the driver */
dev = sr_dev_new(&session_driver, devcnt);
if (devcnt == 0)
/* first device, init the driver */
- dev->driver->init((char *)filename);
+ dev->driver->dev_config_set(devcnt, SR_HWCAP_SESSIONFILE, filename);
dev->driver->dev_config_set(devcnt, SR_HWCAP_CAPTUREFILE, val);
g_ptr_array_add(capturefiles, val);
} else if (!strcmp(keys[j], "samplerate")) {
dev->driver->dev_config_set(devcnt, SR_HWCAP_CAPTUREFILE, val);
g_ptr_array_add(capturefiles, val);
} else if (!strcmp(keys[j], "samplerate")) {