drivers: Drop unneeded or duplicate comments.

Drop various comments which are not really needed, too verbose, document
obvious things, are duplicated across all drivers, or simply incorrect.
This commit is contained in:
Uwe Hermann 2017-07-19 21:29:09 +02:00
parent c8e789fa0c
commit ca314e060f
116 changed files with 99 additions and 625 deletions

View File

@ -316,7 +316,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 10ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 10,
agdmm_receive_data, (void *)sdi);

View File

@ -68,13 +68,11 @@ struct agdmm_profile {
const struct agdmm_recv *recvs;
};
/* Private, per-device-instance driver context. */
struct dev_context {
const struct agdmm_profile *profile;
struct sr_sw_limits limits;
int data_source;
/* Runtime. */
const struct agdmm_job *jobs;
int current_job;
gboolean job_running;

View File

@ -192,7 +192,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
std_session_send_df_header(sdi);
/* Poll every 50ms, or whenever some data comes in. */
serial_source_add(sdi->session, serial, G_IO_IN, 50,
appa_55ii_receive_data, (void *)sdi);

View File

@ -36,13 +36,10 @@ enum {
DATA_SOURCE_MEMORY,
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Acquisition settings */
struct sr_sw_limits limits;
gboolean data_source; /**< Whether to read live samples or memory */
/* Temporary state across callbacks */
uint8_t buf[APPA_55II_BUF_SIZE];
unsigned int buf_len;
uint8_t log_buf[64];

View File

@ -153,7 +153,6 @@ static int config_list(uint32_t key, GVariant **data,
GVariantBuilder gvb;
if (!cg) {
/* No channel group: global options. */
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
} else {
switch (key) {
@ -288,7 +287,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
return SR_ERR;
}
/* Poll every 100ms, or whenever some data comes in. */
serial_source_add(sdi->session, serial, G_IO_IN, 100,
reloadpro_receive_data, (void *)sdi);

View File

@ -29,7 +29,6 @@
#define RELOADPRO_BUFSIZE 100
/** Private, per-device-instance driver context. */
struct dev_context {
struct sr_sw_limits limits;
uint8_t buf[RELOADPRO_BUFSIZE];

View File

@ -19,10 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* ASIX SIGMA/SIGMA2 logic analyzer driver
*/
#include <config.h>
#include "protocol.h"
@ -85,8 +81,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
ftdi_init(&devc->ftdic);
/* Look for SIGMAs. */
if ((ret = ftdi_usb_find_all(&devc->ftdic, &devlist,
USB_VENDOR, USB_PRODUCT)) <= 0) {
if (ret < 0)
@ -116,7 +110,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devc->capture_ratio = 50;
devc->use_triggers = 0;
/* Register SIGMA device. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INITIALIZING;
sdi->vendor = g_strdup(USB_VENDOR_NAME);
@ -127,7 +120,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sdi->priv = devc;
/* We will open the device again when we need it. */
ftdi_list_free(&devlist);
return std_scan_complete(di, g_slist_append(NULL, sdi));

View File

@ -677,7 +677,6 @@ SR_PRIV int sigma_convert_trigger(const struct sr_dev_inst *sdi)
return SR_OK;
}
/* Software trigger to determine exact trigger position. */
static int get_trigger_offset(uint8_t *samples, uint16_t last_sample,
struct sigma_trigger *t)

View File

@ -255,7 +255,6 @@ struct sigma_state {
uint16_t lastsample;
};
/* Private, per-device-instance driver context. */
struct dev_context {
struct ftdi_context ftdic;
uint64_t cur_samplerate;

View File

@ -195,7 +195,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
devc = sdi->priv;
if (!cg) {
/* No channel group: global options. */
switch (key) {
case SR_CONF_CHANNEL_CONFIG:
*data = g_variant_new_string(channel_modes[devc->channel_mode]);
@ -263,7 +262,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
ret = SR_OK;
devc = sdi->priv;
if (!cg) {
/* No channel group: global options. */
switch (key) {
case SR_CONF_CHANNEL_CONFIG:
sval = g_variant_get_string(data, NULL);
@ -294,7 +292,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
return SR_ERR_NA;
}
} else {
/* Channel group specified: per-channel options. */
/* We only ever have one channel per channel group in this driver. */
ch = cg->channels->data;
channel = ch->index;
@ -342,7 +339,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
devc = (sdi) ? sdi->priv : NULL;
if (!cg) {
/* No channel group: global options. */
switch (key) {
case SR_CONF_SCAN_OPTIONS:
case SR_CONF_DEVICE_OPTIONS:
@ -360,8 +356,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
return SR_ERR_NA;
}
} else {
/* Channel group specified: per-channel options. */
/* We only ever have one channel per channel group in this driver. */
ch = cg->channels->data;
channel = ch->index;

View File

@ -71,15 +71,11 @@ struct per_channel_config {
gboolean output_enabled_set;
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
const struct pps_model *model;
/* Acquisition state */
gboolean acquisition_running;
/* Operational state */
gboolean config_dirty;
struct per_channel_config *config;
/* Blocking write timeout for packet. */
@ -91,7 +87,6 @@ struct dev_context {
int channel_mode_set;
gboolean over_current_protection_set;
/* Temporary state across callbacks */
uint8_t packet[PACKET_SIZE];
int packet_size;

View File

@ -49,7 +49,6 @@ enum probe_type {
PROBE_TEMP,
};
/** Private, per-device-instance driver context. */
struct dev_context {
uint64_t samplerate;
struct sr_sw_limits limits;

View File

@ -21,7 +21,6 @@
#include "protocol.h"
#include "beaglelogic.h"
/* Scan options */
static const uint32_t scanopts[] = {
SR_CONF_NUM_LOGIC_CHANNELS,
};
@ -30,7 +29,6 @@ static const uint32_t drvopts[] = {
SR_CONF_LOGIC_ANALYZER,
};
/* Hardware capabilities */
static const uint32_t devopts[] = {
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
@ -40,7 +38,6 @@ static const uint32_t devopts[] = {
SR_CONF_NUM_LOGIC_CHANNELS | SR_CONF_GET,
};
/* Trigger matching capabilities */
static const int32_t soft_trigger_matches[] = {
SR_TRIGGER_ZERO,
SR_TRIGGER_ONE,
@ -120,10 +117,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
beaglelogic_set_sampleunit(devc);
beaglelogic_close(devc);
/* Signal */
sr_info("BeagleLogic device found at "BEAGLELOGIC_DEV_NODE);
/* Fill the channels */
for (i = 0; i < maxch; i++)
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
channel_names[i]);

View File

@ -32,13 +32,10 @@
#define SAMPLEUNIT_TO_BYTES(x) ((x) == 1 ? 1 : 2)
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
int max_channels;
uint32_t fw_ver;
/* Acquisition settings: see beaglelogic.h */
uint64_t cur_samplerate;
uint64_t limit_samples;
uint32_t sampleunit;
@ -49,7 +46,6 @@ struct dev_context {
uint32_t bufunitsize;
uint32_t buffersize;
/* Operational state */
int fd;
GPollFD pollfd;
int last_error;

View File

@ -101,7 +101,6 @@ static int dev_open(struct sr_dev_inst *sdi)
if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb)) < 0)
return SR_ERR;
/* Detach kernel drivers which grabbed this device (if any). */
if (libusb_kernel_driver_active(usb->devhdl, 0) == 1) {
ret = libusb_detach_kernel_driver(usb->devhdl, 0);
if (ret < 0) {
@ -112,7 +111,6 @@ static int dev_open(struct sr_dev_inst *sdi)
devc->detached_kernel_driver = 1;
}
/* Claim interface 0. */
if ((ret = libusb_claim_interface(usb->devhdl, 0)) < 0) {
sr_err("Failed to claim interface 0: %s.",
libusb_error_name(ret));

View File

@ -27,15 +27,9 @@
#define LOG_PREFIX "brymen-bm86x"
/** Private, per-device-instance driver context. */
struct dev_context {
/* Acquisition settings */
struct sr_sw_limits sw_limits;
/* Operational state */
int detached_kernel_driver;/**< Whether kernel driver was detached or not */
/* Temporary state across callbacks */
int detached_kernel_driver; /**< Whether kernel driver was detached or not */
int interrupt_pending;
};

View File

@ -110,13 +110,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (!conn)
return NULL;
if (serialcomm) {
/* Use the provided comm specs. */
if (serialcomm)
devices = brymen_scan(di, conn, serialcomm);
} else {
/* But 9600/8n1 should work all of the time. */
else
devices = brymen_scan(di, conn, "9600/8n1/dtr=1/rts=1");
}
return devices;
}
@ -149,7 +146,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->sw_limits);
std_session_send_df_header(sdi);
/* Poll every 50ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 50,
brymen_dmm_receive_data, (void *)sdi);

View File

@ -38,7 +38,6 @@ enum packet_len_status {
PACKET_INVALID_HEADER,
};
/** Private, per-device-instance driver context. */
struct dev_context {
struct sr_sw_limits sw_limits;

View File

@ -330,7 +330,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
std_session_send_df_header(sdi);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 150,
cem_dt_885x_receive_data, (void *)sdi);

View File

@ -87,23 +87,18 @@ enum {
DATA_SOURCE_MEMORY,
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Device state */
enum sr_mqflag cur_mqflags;
int recording;
int cur_meas_range;
int cur_data_source;
/* Acquisition settings */
uint64_t limit_samples;
/* Operational state */
int state;
uint64_t num_samples;
gboolean enable_data_source_memory;
/* Temporary state across callbacks */
unsigned char cmd;
unsigned char token;
int buf_len;

View File

@ -109,13 +109,10 @@ static GSList *scan(GSList *options, int idx)
if (!conn)
return NULL;
if (serialcomm) {
/* Use the provided comm specs. */
if (serialcomm)
devices = center_scan(conn, serialcomm, idx);
} else {
/* Try the default. */
else
devices = center_scan(conn, center_devs[idx].conn, idx);
}
return std_scan_complete(center_devs[idx].di, devices);
}
@ -149,7 +146,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
std_session_send_df_header(sdi);
/* Poll every 500ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 500,
center_devs[idx].receive_data, (void *)sdi);

View File

@ -51,7 +51,6 @@ extern SR_PRIV const struct center_dev_info center_devs[];
#define SERIAL_BUFSIZE 256
/** Private, per-device-instance driver context. */
struct dev_context {
struct sr_sw_limits sw_limits;

View File

@ -65,7 +65,6 @@ static int add_device(int model, struct libusb_device_descriptor *des,
ret = SR_OK;
/* Allocate memory for our private device context. */
devc = g_malloc0(sizeof(struct dev_context));
/* Set some sane defaults. */
@ -97,7 +96,6 @@ static int add_device(int model, struct libusb_device_descriptor *des,
/* We now know the device, set its max. samplerate as default. */
devc->cur_samplerate = devc->prof->max_samplerate;
/* Register the device with libsigrok. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("ChronoVu");
@ -231,7 +229,6 @@ static int dev_open(struct sr_dev_inst *sdi)
devc = sdi->priv;
/* Allocate memory for the FTDI context and initialize it. */
if (!(devc->ftdic = ftdi_new())) {
sr_err("Failed to initialize libftdi.");
return SR_ERR;
@ -240,7 +237,6 @@ static int dev_open(struct sr_dev_inst *sdi)
sr_dbg("Opening %s device (%04x:%04x).", devc->prof->modelname,
devc->usb_vid, devc->usb_pid);
/* Open the device. */
if ((ret = ftdi_usb_open_desc(devc->ftdic, devc->usb_vid,
devc->usb_pid, devc->prof->iproduct, NULL)) < 0) {
sr_err("Failed to open FTDI device (%d): %s.",
@ -248,21 +244,18 @@ static int dev_open(struct sr_dev_inst *sdi)
goto err_ftdi_free;
}
/* Purge RX/TX buffers in the FTDI chip. */
if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) {
sr_err("Failed to purge FTDI buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_ftdi_free;
}
/* Enable flow control in the FTDI chip. */
if ((ret = ftdi_setflowctrl(devc->ftdic, SIO_RTS_CTS_HS)) < 0) {
sr_err("Failed to enable FTDI flow control (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_ftdi_free;
}
/* Wait 100ms. */
g_usleep(100 * 1000);
return SR_OK;

View File

@ -44,28 +44,18 @@ enum {
struct cv_profile {
int model;
const char *modelname;
const char *iproduct; /* USB iProduct string */
const char *iproduct;
unsigned int num_channels;
uint64_t max_samplerate;
const int num_trigger_matches;
float trigger_constant;
};
/* Private, per-device-instance driver context. */
struct dev_context {
/** Device profile struct for this device. */
const struct cv_profile *prof;
/** FTDI device context (used by libftdi). */
struct ftdi_context *ftdic;
/** The currently configured samplerate of the device. */
uint64_t cur_samplerate;
/** The current sampling limit (in ms). */
uint64_t limit_msec;
/** The current sampling limit (in number of samples). */
uint64_t limit_samples;
/**
@ -124,7 +114,6 @@ struct dev_context {
uint64_t samplerates[255];
};
/* protocol.c */
extern SR_PRIV const char *cv_channel_names[];
extern const struct cv_profile cv_profiles[];
SR_PRIV void cv_fill_samplerates_if_needed(const struct sr_dev_inst *sdi);

View File

@ -110,7 +110,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 150ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 150,
colead_slm_receive_data, (void *)sdi);

View File

@ -31,7 +31,6 @@ enum {
COMMAND_SENT,
};
/** Private, per-device-instance driver context. */
struct dev_context {
struct sr_sw_limits limits;

View File

@ -17,14 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* <em>Conrad DIGI 35 CPU</em> power supply driver
*
* @internal
*/
#include <config.h>
#include "protocol.h"

View File

@ -17,12 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
* <em>Conrad DIGI 35 CPU</em> power supply driver
* @internal
*/
#include <config.h>
#include "protocol.h"

View File

@ -17,14 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* <em>Conrad DIGI 35 CPU</em> power supply driver
*
* @internal
*/
#ifndef LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H
#define LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H

View File

@ -34,7 +34,6 @@
/* Size of the analog pattern space per channel. */
#define ANALOG_BUFSIZE 4096
/* Private, per-device-instance driver context. */
struct dev_context {
uint64_t cur_samplerate;
uint64_t limit_samples;
@ -105,9 +104,6 @@ enum {
/* Analog patterns we can generate. */
enum {
/**
* Square wave.
*/
PATTERN_SQUARE,
PATTERN_SINE,
PATTERN_TRIANGLE,

View File

@ -67,7 +67,6 @@ static const uint32_t devopts[] = {
SR_CONF_CLOCK_EDGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
/* Names assigned to available edge slope choices. */
static const char *const signal_edge_names[] = {
[DS_EDGE_RISING] = "rising",
[DS_EDGE_FALLING] = "falling",
@ -223,7 +222,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
}
}
/* Skip if the device was not found. */
if (!prof)
continue;

View File

@ -112,16 +112,13 @@ struct dev_context {
*/
int64_t fw_updated;
/* Supported samplerates */
const uint64_t *samplerates;
int num_samplerates;
/* Device/capture settings */
uint64_t cur_samplerate;
uint64_t limit_samples;
uint64_t capture_ratio;
/* Operational settings */
gboolean acq_aborted;
unsigned int sent_samples;

View File

@ -210,7 +210,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 50,
fluke_receive_data, (void *)sdi);

View File

@ -46,12 +46,10 @@ struct flukedmm_profile {
int timeout;
};
/* Private, per-device-instance driver context. */
struct dev_context {
const struct flukedmm_profile *profile;
struct sr_sw_limits limits;
/* Runtime. */
char buf[FLUKEDMM_BUFSIZE];
int buflen;
int64_t cmd_sent_at;

View File

@ -111,7 +111,6 @@ static void scan_device(struct ftdi_context *ftdic,
return;
}
/* Allocate memory for our private device context. */
devc = g_malloc0(sizeof(struct dev_context));
/* Allocate memory for the incoming data. */
@ -138,7 +137,6 @@ static void scan_device(struct ftdi_context *ftdic,
}
sr_dbg("Found an FTDI device: %s.", model);
/* Register the device with libsigrok. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = vendor;
@ -214,7 +212,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
}
}
/* Allocate memory for the FTDI context (ftdic) and initialize it. */
ftdic = ftdi_new();
if (!ftdic) {
sr_err("Failed to initialize libftdi.");
@ -273,7 +270,6 @@ static int dev_open(struct sr_dev_inst *sdi)
goto err_ftdi_free;
}
/* Purge RX/TX buffers in the FTDI chip. */
ret = ftdi_usb_purge_buffers(devc->ftdic);
if (ret < 0) {
sr_err("Failed to purge FTDI RX/TX buffers (%d): %s.",
@ -281,7 +277,6 @@ static int dev_open(struct sr_dev_inst *sdi)
goto err_dev_open_close_ftdic;
}
/* Reset the FTDI bitmode. */
ret = ftdi_set_bitmode(devc->ftdic, 0x00, BITMODE_RESET);
if (ret < 0) {
sr_err("Failed to reset the FTDI chip bitmode (%d): %s.",

View File

@ -36,7 +36,6 @@ struct ftdi_chip_desc {
char *channel_names[];
};
/** Private, per-device-instance driver context. */
struct dev_context {
struct ftdi_context *ftdic;
const struct ftdi_chip_desc *desc;

View File

@ -268,7 +268,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
}
}
/* Skip if the device was not found. */
if (!prof)
continue;

View File

@ -98,16 +98,13 @@ struct dev_context {
*/
int64_t fw_updated;
/* Supported samplerates */
const uint64_t *samplerates;
int num_samplerates;
/* Device/capture settings */
uint64_t cur_samplerate;
uint64_t limit_samples;
uint64_t capture_ratio;
/* Operational settings */
gboolean trigger_fired;
gboolean acq_aborted;
gboolean sample_wide;

View File

@ -17,14 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* Gossen Metrawatt Metrahit 1x/2x drivers
*
* @internal
*/
#include <config.h>
#include <string.h>
#include "protocol.h"
@ -388,7 +380,6 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 40ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 40,
gmc_mh_1x_2x_receive_data, (void *)sdi);
@ -408,7 +399,6 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 40ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 40,
gmc_mh_2x_receive_data, (void *)sdi);

View File

@ -17,20 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* Gossen Metrawatt Metrahit 1x/2x drivers
*
* @internal
*/
#include <config.h>
#include <math.h>
#include <string.h>
#include "protocol.h"
/* Internal Headers */
static guchar calc_chksum_14(guchar *dta);
static int chk_msg14(struct sr_dev_inst *sdi);
@ -1283,9 +1274,7 @@ static void create_cmd_14(guchar addr, guchar func, guchar *params, guchar *buf)
}
}
/** Request one measurement from 2x multimeter (msg 8).
*
*/
/** Request one measurement from 2x multimeter (msg 8). */
int req_meas14(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -1361,7 +1350,8 @@ int req_stat14(const struct sr_dev_inst *sdi, gboolean power_on)
return SR_OK;
}
/** Decode model in "send mode".
/**
* Decode model in "send mode".
*
* @param[in] mcode Model code.
* @return Model code.

View File

@ -17,14 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* Gossen Metrawatt Metrahit 1x/2x drivers
*
* @internal
*/
#ifndef LIBSIGROK_HARDWARE_GMC_MH_1X_2X_PROTOCOL_H
#define LIBSIGROK_HARDWARE_GMC_MH_1X_2X_PROTOCOL_H
@ -84,15 +76,11 @@ enum model {
METRAHIT_29S = METRAHIT_28S + 1,
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
enum model model; /**< Model code. */
/* Acquisition settings */
struct sr_sw_limits limits;
/* Operational state */
gboolean settings_ok; /**< Settings msg received yet. */
int msg_type; /**< Message type (MSGID_INF, ...). */
int msg_len; /**< Message length (valid when msg, curr. type known).*/
@ -112,12 +100,10 @@ struct dev_context {
int64_t req_sent_at; /**< Request sent. */
gboolean response_pending; /**< Request sent, response is pending. */
/* Temporary state across callbacks */
uint8_t buf[GMC_BUFSIZE]; /**< Buffer for read callback */
int buflen; /**< Data len in buf */
};
/* Forward declarations */
SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg);
SR_PRIV int gmc_decode_model_bd(uint8_t mcode);

View File

@ -44,7 +44,6 @@ enum gds_state
WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE,
};
/** Private, per-device-instance driver context. */
struct dev_context {
enum gds_state state;
uint64_t cur_acq_frame;

View File

@ -92,7 +92,6 @@ struct scope_state {
uint64_t sample_rate;
};
/** Private, per-device-instance driver context. */
struct dev_context {
const void *model_config;
void *model_state;

View File

@ -25,6 +25,7 @@
static int set_mq_volt(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags);
static int set_mq_amp(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags);
static int set_mq_ohm(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags);
/*
* The source for the frequency measurement can be either AC voltage, AC+DC
* voltage, AC current, or AC+DC current. Configuring this is not yet

View File

@ -57,13 +57,10 @@ enum channel_conn {
CONN_REAR,
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
/* Information about rear card option, or NULL if unknown */
const struct rear_card_info *rear_card;
/* Acquisition settings */
enum sr_mq measurement_mq;
enum sr_mqflag measurement_mq_flags;
enum sr_unit measurement_unit;
@ -73,7 +70,6 @@ struct dev_context {
unsigned int num_active_channels;
struct sr_channel *current_channel;
/* Operational state */
enum acquisition_state acq_state;
enum channel_conn input_loc;
uint64_t num_samples;

View File

@ -29,9 +29,7 @@
#define MAX_RETRIES 4
#define NUM_CHANNELS 2
/** Private, per-device-instance driver context. */
struct dev_context {
/* Acquisition settings */
GSList *enabled_channel;
uint8_t channel;
uint8_t rate;
@ -42,7 +40,6 @@ struct dev_context {
uint8_t offset[2];
uint8_t gain[2];
/* Operational state */
uint64_t frame_limit;
uint64_t frame;
uint64_t probe[2];
@ -51,7 +48,6 @@ struct dev_context {
uint8_t retries;
gboolean adc2;
/* Temporary state across callbacks */
float *samples;
float factor;
gboolean state_known;

View File

@ -181,10 +181,6 @@ static int dev_open(struct sr_dev_inst *sdi)
if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK)
return SR_ERR;
/*
* Determine if a kernel driver is active on this interface and, if so,
* detach it.
*/
if (libusb_kernel_driver_active(usb->devhdl, USB_INTERFACE) == 1) {
ret = libusb_detach_kernel_driver(usb->devhdl, USB_INTERFACE);
if (ret < 0) {

View File

@ -640,10 +640,6 @@ SR_PRIV int sl2_get_device_info(struct sr_dev_driver *di,
if (sr_usb_open(drvc->sr_ctx->libusb_ctx, &usb) != SR_OK)
return SR_ERR;
/*
* Determine if a kernel driver is active on this interface and, if so,
* detach it.
*/
if (libusb_kernel_driver_active(usb.devhdl, USB_INTERFACE) == 1) {
ret = libusb_detach_kernel_driver(usb.devhdl,
USB_INTERFACE);

View File

@ -120,7 +120,6 @@ enum {
STATE_WAIT_DEVICE_READY
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Current selected samplerate. */
uint64_t samplerate;

View File

@ -38,7 +38,6 @@ static const uint32_t devopts[] = {
SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
/* Channels are numbered 1-9. */
static const char *channel_names[] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9",
};
@ -67,7 +66,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
(void)options;
/* Allocate memory for our private device context. */
devc = g_malloc0(sizeof(struct dev_context));
/* Allocate memory for the incoming compressed samples. */
@ -82,13 +80,11 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
goto err_free_compressed_buf;
}
/* Allocate memory for the FTDI context (ftdic) and initialize it. */
if (!(devc->ftdic = ftdi_new())) {
sr_err("Failed to initialize libftdi.");
goto err_free_sample_buf;
}
/* Check for the device and temporarily open it. */
ret = ftdi_usb_open_desc(devc->ftdic, USB_VENDOR_ID, USB_DEVICE_ID,
USB_IPRODUCT, NULL);
if (ret < 0) {
@ -99,7 +95,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
goto err_free_ftdic;
}
/* Register the device with libsigrok. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(USB_VENDOR_NAME);
@ -109,14 +104,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
for (i = 0; i < ARRAY_SIZE(channel_names); i++)
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_names[i]);
/* Close device. We'll reopen it again when we need it. */
scanaplus_close(devc);
return std_scan_complete(di, g_slist_append(NULL, sdi));
scanaplus_close(devc);
err_free_ftdic:
ftdi_free(devc->ftdic); /* NOT free() or g_free()! */
ftdi_free(devc->ftdic);
err_free_sample_buf:
g_free(devc->sample_buf);
err_free_compressed_buf:
@ -134,7 +128,6 @@ static int dev_open(struct sr_dev_inst *sdi)
devc = sdi->priv;
/* Select interface A, otherwise communication will fail. */
ret = ftdi_set_interface(devc->ftdic, INTERFACE_A);
if (ret < 0) {
sr_err("Failed to set FTDI interface A (%d): %s", ret,
@ -142,7 +135,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_ERR;
}
/* Open the device. */
ret = ftdi_usb_open_desc(devc->ftdic, USB_VENDOR_ID, USB_DEVICE_ID,
USB_IPRODUCT, NULL);
if (ret < 0) {
@ -151,14 +143,12 @@ static int dev_open(struct sr_dev_inst *sdi)
return SR_ERR;
}
/* Purge RX/TX buffers in the FTDI chip. */
if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) {
sr_err("Failed to purge FTDI RX/TX buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_dev_open_close_ftdic;
}
/* Reset the FTDI bitmode. */
ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_RESET);
if (ret < 0) {
sr_err("Failed to reset the FTDI chip bitmode (%d): %s.",
@ -166,7 +156,6 @@ static int dev_open(struct sr_dev_inst *sdi)
goto err_dev_open_close_ftdic;
}
/* Set FTDI bitmode to "sync FIFO". */
ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_SYNCFF);
if (ret < 0) {
sr_err("Failed to put FTDI chip into sync FIFO mode (%d): %s.",
@ -174,7 +163,6 @@ static int dev_open(struct sr_dev_inst *sdi)
goto err_dev_open_close_ftdic;
}
/* Set the FTDI latency timer to 2. */
ret = ftdi_set_latency_timer(devc->ftdic, 2);
if (ret < 0) {
sr_err("Failed to set FTDI latency timer (%d): %s.",
@ -182,7 +170,6 @@ static int dev_open(struct sr_dev_inst *sdi)
goto err_dev_open_close_ftdic;
}
/* Set the FTDI read data chunk size to 64kB. */
ret = ftdi_read_data_set_chunksize(devc->ftdic, 64 * 1024);
if (ret < 0) {
sr_err("Failed to set FTDI read data chunk size (%d): %s.",

View File

@ -31,15 +31,9 @@
#define COMPRESSED_BUF_SIZE (64 * 1024)
/* Private, per-device-instance driver context. */
struct dev_context {
/** FTDI device context (used by libftdi). */
struct ftdi_context *ftdic;
/** The current sampling limit (in ms). */
uint64_t limit_msec;
/** The current sampling limit (in number of samples). */
uint64_t limit_samples;
uint8_t *compressed_buf;

View File

@ -20,6 +20,7 @@
#include <config.h>
#include <string.h>
#include "protocol.h"
extern const uint64_t kecheng_kc_330b_sample_intervals[][2];
SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)

View File

@ -66,9 +66,7 @@ enum {
DEVICE_INACTIVE,
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Acquisition settings */
uint64_t limit_samples;
int sample_interval;
int alarm_low;
@ -76,7 +74,6 @@ struct dev_context {
enum sr_mqflag mqflags;
int data_source;
/* Operational state */
int state;
gboolean config_dirty;
uint64_t num_samples;
@ -84,9 +81,7 @@ struct dev_context {
struct libusb_transfer *xfer;
unsigned char buf[128];
/* Temporary state across callbacks */
gint64 last_live_request;
};
SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data);

View File

@ -147,7 +147,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 50ms, or whenever some data comes in. */
serial_source_add(sdi->session, serial, G_IO_IN, 50,
kern_scale_receive_data, (void *)sdi);

View File

@ -46,7 +46,6 @@ struct scale_info {
#define SCALE_BUFSIZE 256
/** Private, per-device-instance driver context. */
struct dev_context {
struct sr_sw_limits limits;

View File

@ -26,17 +26,13 @@ static const uint32_t scanopts[] = {
};
static const uint32_t drvopts[] = {
/* Device class */
SR_CONF_POWER_SUPPLY,
};
static const uint32_t devopts[] = {
/* Device class */
/* Acquisition modes. */
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
/* Device configuration */
SR_CONF_VOLTAGE | SR_CONF_GET,
SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_CURRENT | SR_CONF_GET,
@ -129,7 +125,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sr_dbg("Found: %s %s (idx %d, ID '%s').", models[model_id].vendor,
models[model_id].name, model_id, models[model_id].id);
/* Init device instance, etc. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(models[model_id].vendor);

View File

@ -17,12 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
* Korad KAxxxxP power supply driver
* @internal
*/
#ifndef LIBSIGROK_HARDWARE_KORAD_KAXXXXP_PROTOCOL_H
#define LIBSIGROK_HARDWARE_KORAD_KAXXXXP_PROTOCOL_H
@ -70,17 +64,13 @@ enum {
KAXXXXP_RECALL,
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
const struct korad_kaxxxxp_model *model; /**< Model information. */
/* Acquisition settings */
struct sr_sw_limits limits;
int64_t req_sent_at;
gboolean reply_pending;
/* Operational state */
float current; /**< Last current value [A] read from device. */
float current_max; /**< Output current set. */
float voltage; /**< Last voltage value [V] read from device. */
@ -92,7 +82,6 @@ struct dev_context {
gboolean ocp_enabled; /**< Output current protection enabled. */
gboolean ovp_enabled; /**< Output voltage protection enabled. */
/* Temporary state across callbacks */
int target; /**< What reply to expect. */
int program; /**< Program to store or recall. */
char reply[6];

View File

@ -39,9 +39,9 @@
#define SLEEP_US_LONG (5 * 1000)
#define SLEEP_US_SHORT (1 * 1000)
/** Private, per-device-instance driver context. */
struct dev_context {
const struct elusb_profile *profile;
/* Generic EL-USB */
unsigned char config[MAX_CONFIGBLOCK_SIZE];
unsigned int log_size;
@ -50,6 +50,7 @@ struct dev_context {
unsigned int logged_samples;
unsigned int rcvd_samples;
uint64_t limit_samples;
/* Model-specific */
/* EL-USB-CO: these are something like scaling and calibration values
* fixed per device, used to convert the sample values to CO ppm. */

View File

@ -33,7 +33,6 @@
struct samplerate_info;
/** Private, per-device-instance driver context. */
struct dev_context {
struct libusb_transfer *intr_xfer;
struct libusb_transfer *bulk_xfer;

View File

@ -504,6 +504,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
devc = sdi->priv;
scpi = sdi->conn;
/* Preset empty results. */
g_slist_free(devc->enabled_channels);
devc->enabled_channels = NULL;

View File

@ -76,7 +76,6 @@ struct scope_state {
uint64_t sample_rate;
};
/** Private, per-device-instance driver context. */
struct dev_context {
const void *model_config;
void *model_state;

View File

@ -374,7 +374,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
return SR_OK;
}
/* This stops acquisition on ALL devices, ignoring dev_index. */
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
stop_acquisition(sdi);

View File

@ -84,7 +84,6 @@ struct mso_prototrig {
uint8_t spimode;
};
/* Private, per-device-instance driver context. */
struct dev_context {
/* info */
uint8_t hwmodel;
@ -97,10 +96,11 @@ struct dev_context {
uint16_t offset_range;
uint64_t limit_samples;
uint64_t num_samples;
/* register cache */
uint8_t ctlbase1;
uint8_t ctlbase2;
/* state */
uint8_t la_threshold;
uint64_t cur_rate;
uint8_t dso_probe_attn;

View File

@ -18,14 +18,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* <em>Manson HCS-3xxx series</em> power supply driver
*
* @internal
*/
#include <config.h>
#include "protocol.h"
@ -35,17 +27,13 @@ static const uint32_t scanopts[] = {
};
static const uint32_t drvopts[] = {
/* Device class */
SR_CONF_POWER_SUPPLY,
};
static const uint32_t devopts[] = {
/* Device class */
/* Acquisition modes. */
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
/* Device configuration */
SR_CONF_VOLTAGE | SR_CONF_GET,
SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_CURRENT | SR_CONF_GET,
@ -137,7 +125,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
}
g_strfreev(tokens);
/* Init device instance, etc. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Manson");
@ -337,7 +324,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
devc->reply_pending = FALSE;
devc->req_sent_at = 0;
/* Poll every 10ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 10,
hcs_receive_data, (void *)sdi);

View File

@ -18,14 +18,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* <em>Manson HCS-3xxx Series</em> power supply driver
*
* @internal
*/
#include <config.h>
#include "protocol.h"

View File

@ -18,14 +18,6 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* <em>Manson HCS-3xxx Series</em> power supply driver
*
* @internal
*/
#ifndef LIBSIGROK_HARDWARE_MANSON_HCS_3XXX_PROTOCOL_H
#define LIBSIGROK_HARDWARE_MANSON_HCS_3XXX_PROTOCOL_H
@ -66,7 +58,6 @@ struct hcs_model {
double current[3]; /**< Min, max, step */
};
/** Private, per-device-instance driver context. */
struct dev_context {
const struct hcs_model *model; /**< Model information. */

View File

@ -365,7 +365,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
devc = (sdi) ? sdi->priv : NULL;
if (!cg) {
/* No channel group: global options. */
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
} else {
switch (key) {

View File

@ -34,15 +34,9 @@ struct maynuo_m97_model {
unsigned int max_power;
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
const struct maynuo_m97_model *model;
/* Acquisition settings */
struct sr_sw_limits limits;
/* Operational state */
int expecting_registers;
};

View File

@ -116,13 +116,10 @@ static GSList *scan(GSList *options, int idx)
if (!conn)
return NULL;
if (serialcomm) {
/* Use the provided comm specs. */
if (serialcomm)
devices = mic_scan(conn, serialcomm, idx);
} else {
/* Try the default. */
else
devices = mic_scan(conn, mic_devs[idx].conn, idx);
}
return devices;
}
@ -166,7 +163,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 100,
mic_devs[idx].receive_data, (void *)sdi);

View File

@ -51,7 +51,6 @@ extern SR_PRIV const struct mic_dev_info mic_devs[];
#define SERIAL_BUFSIZE 256
/** Private, per-device-instance driver context. */
struct dev_context {
struct sr_sw_limits limits;

View File

@ -18,14 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* <em>Motech LPS-30x series</em> power supply driver
*
* @internal
*/
#include <config.h>
#include <ctype.h>
#include <math.h>
@ -38,31 +30,23 @@ SR_PRIV int lps_cmd_ok(struct sr_serial_dev_inst *serial, const char *fmt, ...);
SR_PRIV int lps_cmd_reply(char *reply, struct sr_serial_dev_inst *serial, const char *fmt, ...);
SR_PRIV int lps_query_status(struct sr_dev_inst *sdi);
/* Serial communication parameters */
#define SERIALCOMM "2400/8n1/dtr=1/rts=1/flow=0"
#define VENDOR_MOTECH "Motech"
/** Driver scanning options. */
static const uint32_t scanopts[] = {
SR_CONF_CONN,
SR_CONF_SERIALCOMM,
};
/** Driver capabilities generic. */
static const uint32_t drvopts[] = {
/* Device class */
SR_CONF_POWER_SUPPLY,
};
/** Hardware capabilities generic. */
static const uint32_t devopts[] = {
/* Device class */
/* Acquisition modes. */
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
/* Device configuration */
SR_CONF_CHANNEL_CONFIG | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
@ -75,7 +59,7 @@ static const uint32_t devopts_ch12[] = {
SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
};
/** Hardware capabilities channel 3. (LPS-304/305 only). */
/** Hardware capabilities channel 3 (LPS-304/305 only). */
static const uint32_t devopts_ch3[] = {
SR_CONF_VOLTAGE | SR_CONF_GET,
SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
@ -133,8 +117,7 @@ static const struct lps_modelspec models[] = {
},
};
/** Send command to device with va_list.
*/
/** Send command to device with va_list. */
SR_PRIV int lps_send_va(struct sr_serial_dev_inst *serial, const char *fmt, va_list args)
{
int retc;
@ -155,8 +138,7 @@ SR_PRIV int lps_send_va(struct sr_serial_dev_inst *serial, const char *fmt, va_l
return SR_OK;
}
/** Send command to device.
*/
/** Send command to device. */
SR_PRIV int lps_send_req(struct sr_serial_dev_inst *serial, const char *fmt, ...)
{
int retc;
@ -367,8 +349,7 @@ SR_PRIV int lps_read_reply(struct sr_serial_dev_inst *serial, char **buf, int *b
return SR_ERR; /* Timeout! */
}
/** Scan for LPS-300 series device.
*/
/** Scan for LPS-300 series device. */
static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *options)
{
struct sr_dev_inst *sdi;
@ -523,7 +504,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
devc = sdi->priv;
if (!cg) {
/* No channel group: global options. */
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
case SR_CONF_LIMIT_MSEC:
@ -538,6 +518,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
/* We only ever have one channel per channel group in this driver. */
ch = cg->channels->data;
ch_idx = ch->index;
switch (key) {
case SR_CONF_VOLTAGE:
*data = g_variant_new_double(devc->channel_status[ch_idx].output_voltage_last);
@ -582,7 +563,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
return SR_ERR_NA;
if (!cg) {
/* No channel group: global options. */
switch (key) {
case SR_CONF_LIMIT_MSEC:
case SR_CONF_LIMIT_SAMPLES:
@ -609,7 +589,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
return SR_ERR_NA;
}
} else {
/* Channel group specified: per-channel options. */
/* We only ever have one channel per channel group in this driver. */
ch = cg->channels->data;
ch_idx = ch->index;
@ -679,7 +658,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
devc = (sdi) ? sdi->priv : NULL;
/* Device options, independent from channel groups. */
if (!cg) {
switch (key) {
case SR_CONF_SCAN_OPTIONS:
@ -699,9 +677,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
}
}
/* Device options, depending on channel groups. */
/* We only ever have one channel per channel group in this driver. */
ch = cg->channels->data;
ch_idx = ch->index;
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
if ((ch_idx == 0) || (ch_idx == 1)) /* CH1, CH2 */

View File

@ -18,14 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* <em>Motech LPS-30x series</em> power supply driver
*
* @internal
*/
#include <config.h>
#include <errno.h>
#include <string.h>

View File

@ -18,14 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* <em>Motech LPS-30x series</em> power supply driver
*
* @internal
*/
#ifndef LIBSIGROK_HARDWARE_MOTECH_LPS_30X_PROTOCOL_H
#define LIBSIGROK_HARDWARE_MOTECH_LPS_30X_PROTOCOL_H
@ -93,22 +85,17 @@ struct channel_status {
gdouble output_current_max;
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
const struct lps_modelspec *model;
/* Acquisition status */
gboolean acq_running; /**< Acquisition is running. */
struct sr_sw_limits limits;
acquisition_req acq_req; /**< Current request. */
uint8_t acq_req_pending; /**< Request pending. 0=none, 1=reply, 2=OK */
/* Operational state */
struct channel_status channel_status[MAX_CHANNELS];
guint8 tracking_mode; /**< 0=off, 1=Tracking from CH1, 2=Tracking from CH2. */
/* Temporary state across callbacks */
int64_t req_sent_at; /**< Request sent. */
gchar buf[LINELEN_MAX]; /**< Buffer for read callback */
int buflen; /**< Data len in buf */

View File

@ -17,11 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file
* Norma DM9x0/Siemens B102x DMMs driver.
* @internal
*/
#include <config.h>
#include "protocol.h"
@ -192,7 +187,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 100,
norma_dmm_receive_data, (void *)sdi);

View File

@ -17,14 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
*
* Norma DM9x0/Siemens B102x DMMs driver.
*
* @internal
*/
#include <config.h>
#include "protocol.h"

View File

@ -28,14 +28,6 @@
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
/**
* @file
*
* Norma DM9x0/Siemens B102x DMMs driver.
*
* @internal
*/
#define LOG_PREFIX "norma-dmm"
#define NMADMM_BUFSIZE 256
@ -57,21 +49,16 @@ struct nmadmm_req {
/** Strings for requests. */
extern const struct nmadmm_req nmadmm_requests[];
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
int type; /**< DM9x0, e.g. 5 = DM950 */
/* Acquisition settings */
struct sr_sw_limits limits;
/* Operational state */
int last_req; /**< Last request. */
int64_t req_sent_at; /**< Request sent. */
gboolean last_req_pending; /**< Last request not answered yet. */
int lowbatt; /**< Low battery. 1=low, 2=critical. */
/* Temporary state across callbacks */
uint8_t buf[NMADMM_BUFSIZE]; /**< Buffer for read callback */
int buflen; /**< Data len in buf */
};

View File

@ -66,15 +66,12 @@
#define FLAG_FILTER (1 << 1)
#define FLAG_DEMUX (1 << 0)
/* Private, per-device-instance driver context. */
struct dev_context {
/* Fixed device settings */
int max_channels;
uint32_t max_samples;
uint32_t max_samplerate;
uint32_t protocol_version;
/* Acquisition settings */
uint64_t cur_samplerate;
uint32_t cur_samplerate_divider;
uint64_t limit_samples;
@ -86,7 +83,6 @@ struct dev_context {
int num_stages;
uint16_t flag_reg;
/* Operational states */
unsigned int num_transfers;
unsigned int num_samples;
int num_bytes;
@ -94,7 +90,6 @@ struct dev_context {
int cnt_samples;
int cnt_samples_rle;
/* Temporary variables */
unsigned int rle_count;
unsigned char sample[4];
unsigned char tmp_sample[4];

View File

@ -306,7 +306,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
std_session_send_df_header(sdi);
/* Poll every 150ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 150,
pce_322a_receive_data, (void *)sdi);

View File

@ -68,17 +68,13 @@ enum {
MEM_STATE_GET_MEMORY_BLOCK,
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
uint64_t cur_mqflags;
uint8_t cur_meas_range;
/* Acquisition settings */
uint8_t cur_data_source;
uint64_t limit_samples;
/* Operational state */
uint64_t num_samples;
/* Memory reading state */
@ -88,7 +84,6 @@ struct dev_context {
uint16_t memory_block_counter; /* Number of memory blocks retrieved so far. */
uint8_t memory_block_cursor; /* Number of bytes retrieved in current memory block. */
/* Temporary state across callbacks. */
uint8_t buffer[BUFFER_SIZE];
int buffer_len;
int buffer_skip; /* Number of bytes to skip in memory mode. */

View File

@ -91,31 +91,24 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
devices = NULL;
/* Allocate memory for our private device context. */
devc = g_malloc0(sizeof(struct dev_context));
/* Device-specific settings */
devc->max_samplebytes = devc->max_samplerate = devc->protocol_version = 0;
/* Acquisition settings */
devc->limit_samples = devc->capture_ratio = 0;
devc->trigger_at = -1;
devc->channel_mask = 0xffffffff;
devc->flag_reg = 0;
/* Allocate memory for the incoming ftdi data. */
devc->ftdi_buf = g_malloc0(FTDI_BUF_SIZE);
/* Allocate memory for the FTDI context (ftdic) and initialize it. */
if (!(devc->ftdic = ftdi_new())) {
sr_err("Failed to initialize libftdi.");
goto err_free_ftdi_buf;;
}
/* Try to open the FTDI device */
if (p_ols_open(devc) != SR_OK) {
if (p_ols_open(devc) != SR_OK)
goto err_free_ftdic;
}
/* The discovery procedure is like this: first send the Reset
* command (0x00) 5 times, since the device could be anywhere
@ -166,7 +159,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
goto err_close_ftdic;
}
/* Close device. We'll reopen it again when we need it. */
p_ols_close(devc);
/* Parse the metadata. */
@ -184,7 +176,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
err_close_ftdic:
p_ols_close(devc);
err_free_ftdic:
ftdi_free(devc->ftdic); /* NOT free() or g_free()! */
ftdi_free(devc->ftdic);
err_free_ftdi_buf:
g_free(devc->ftdi_buf);
g_free(devc);

View File

@ -73,7 +73,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc)
/* Note: Caller checks devc and devc->ftdic. */
/* Select interface B, otherwise communication will fail. */
ret = ftdi_set_interface(devc->ftdic, INTERFACE_B);
if (ret < 0) {
sr_err("Failed to set FTDI interface B (%d): %s", ret,
@ -81,7 +80,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc)
return SR_ERR;
}
/* Check for the device and temporarily open it. */
ret = ftdi_usb_open_desc(devc->ftdic, USB_VENDOR_ID, USB_DEVICE_ID,
USB_IPRODUCT, NULL);
if (ret < 0) {
@ -92,14 +90,12 @@ SR_PRIV int p_ols_open(struct dev_context *devc)
return SR_ERR;
}
/* Purge RX/TX buffers in the FTDI chip. */
if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) {
sr_err("Failed to purge FTDI RX/TX buffers (%d): %s.",
ret, ftdi_get_error_string(devc->ftdic));
goto err_open_close_ftdic;
}
/* Reset the FTDI bitmode. */
ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_RESET);
if (ret < 0) {
sr_err("Failed to reset the FTDI chip bitmode (%d): %s.",
@ -107,7 +103,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc)
goto err_open_close_ftdic;
}
/* Set the FTDI latency timer to 16. */
ret = ftdi_set_latency_timer(devc->ftdic, 16);
if (ret < 0) {
sr_err("Failed to set FTDI latency timer (%d): %s.",
@ -115,7 +110,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc)
goto err_open_close_ftdic;
}
/* Set the FTDI read data chunk size to 64kB. */
ret = ftdi_read_data_set_chunksize(devc->ftdic, 64 * 1024);
if (ret < 0) {
sr_err("Failed to set FTDI read data chunk size (%d): %s.",

View File

@ -75,19 +75,15 @@
#define FLAG_FILTER (1 << 1)
#define FLAG_DEMUX (1 << 0)
/* Private, per-device-instance driver context. */
struct dev_context {
/** FTDI device context (used by libftdi). */
struct ftdi_context *ftdic;
uint8_t *ftdi_buf;
/* Fixed device settings */
int max_channels;
uint32_t max_samplebytes;
uint32_t max_samplerate;
uint32_t protocol_version;
/* Acquisition settings */
uint64_t cur_samplerate;
uint32_t cur_samplerate_divider;
uint32_t max_samples;
@ -101,7 +97,6 @@ struct dev_context {
int num_stages;
uint16_t flag_reg;
/* Operational states */
unsigned int num_transfers;
unsigned int num_samples;
int num_bytes;
@ -109,7 +104,6 @@ struct dev_context {
unsigned int cnt_samples;
int cnt_samples_rle;
/* Temporary variables */
unsigned int rle_count;
unsigned char sample[4];
unsigned char tmp_sample[4];

View File

@ -89,9 +89,7 @@ enum wait_events {
WAIT_STOP, /* Wait for scope stopping (only single shots) */
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Device model */
const struct rigol_ds_model *model;
enum data_format format;
@ -127,8 +125,6 @@ struct dev_context {
float trigger_level;
char *coupling[MAX_ANALOG_CHANNELS];
/* Operational state */
/* Number of frames received in total. */
uint64_t num_frames;
/* GSList entry for the current channel. */

View File

@ -41,9 +41,7 @@ struct rs_device_model {
double power_min;
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
const struct rs_device_model *model_config;
};

View File

@ -36,23 +36,18 @@
*/
#define CONV_BUFFER_SIZE (2 * 8 * 16384 + CONV_BATCH_SIZE)
/** Private, per-device-instance driver context. */
struct dev_context {
/* Acquisition settings */
unsigned int dig_channel_cnt;
uint16_t dig_channel_mask;
uint16_t dig_channel_masks[16];
uint64_t dig_samplerate;
/* Operational state */
uint32_t lfsr;
/* Temporary state across callbacks */
unsigned int num_transfers;
unsigned int submitted_transfers;
struct libusb_transfer **transfers;
/* Conversion buffer */
uint8_t *conv_buffer;
unsigned int conv_size;
unsigned int batch_index;

View File

@ -41,7 +41,6 @@ enum fpga_variant {
FPGA_VARIANT_MCUPRO /* mcupro clone v4.6 with Actel FPGA */
};
/** Private, per-device-instance driver context. */
struct dev_context {
/** Distinguishing between original Logic16 and clones */
enum fpga_variant fpga_variant;

View File

@ -439,7 +439,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
return SR_ERR_ARG;
if (cg)
/* Channel group specified. */
select_channel(sdi, cg->channels->data);
devc = sdi->priv;
@ -523,7 +522,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
devc = (sdi) ? sdi->priv : NULL;
if (!cg) {
/* No channel group: global options. */
switch (key) {
case SR_CONF_SCAN_OPTIONS:
case SR_CONF_DEVICE_OPTIONS:
@ -555,7 +553,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
return SR_ERR_NA;
}
} else {
/* Channel group specified. */
/*
* Per-channel-group options depending on a channel are actually
* done with the first channel. Channel groups in PPS can have

View File

@ -130,7 +130,6 @@ static const struct scpi_command chroma_61604_cmd[] = {
};
/* Chroma 62000 series DC source */
static const uint32_t chroma_62000_devopts[] = {
SR_CONF_CONTINUOUS,
};
@ -307,7 +306,6 @@ static const struct scpi_command rigol_dp800_cmd[] = {
};
/* HP 663xx series */
static const uint32_t hp_6630a_devopts[] = {
SR_CONF_CONTINUOUS,
SR_CONF_ENABLED | SR_CONF_SET,
@ -572,6 +570,7 @@ SR_PRIV const struct scpi_pps pps_profiles[] = {
agilent_n5700a_cmd,
.probe_channels = NULL,
},
/* Agilent N5767A */
{ "Agilent", "N5767A", 0,
ARRAY_AND_SIZE(agilent_n5700a_devopts),
@ -581,6 +580,7 @@ SR_PRIV const struct scpi_pps pps_profiles[] = {
agilent_n5700a_cmd,
.probe_channels = NULL,
},
/* Chroma 61604 */
{ "Chroma", "61604", 0,
ARRAY_AND_SIZE(chroma_61604_devopts),
@ -590,6 +590,7 @@ SR_PRIV const struct scpi_pps pps_profiles[] = {
chroma_61604_cmd,
.probe_channels = NULL,
},
/* Chroma 62000 series */
{ "Chroma", "620[0-9]{2}P-[0-9]{2,3}-[0-9]{1,3}", 0,
ARRAY_AND_SIZE(chroma_62000_devopts),
@ -599,6 +600,7 @@ SR_PRIV const struct scpi_pps pps_profiles[] = {
chroma_62000_cmd,
.probe_channels = chroma_62000p_probe_channels,
},
/* HP 6633A */
{ "HP", "6633A", 0,
ARRAY_AND_SIZE(hp_6630a_devopts),

View File

@ -136,17 +136,13 @@ enum acq_states {
STATE_STOP,
};
/** Private, per-device-instance driver context. */
struct dev_context {
/* Model-specific information */
const struct scpi_pps *device;
/* Operational state */
gboolean beeper_was_set;
struct channel_spec *channels;
struct channel_group_spec *channel_groups;
/* Temporary state across callbacks */
struct sr_channel *cur_channel;
};

View File

@ -168,7 +168,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi);
/* Poll every 50ms, or whenever some data comes in. */
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 50,
receive_data, (void *)sdi);

View File

@ -60,7 +60,6 @@ struct dmm_info {
#define DMM_BUFSIZE 256
/** Private, per-device-instance driver context. */
struct dev_context {
struct sr_sw_limits limits;

View File

@ -26,20 +26,14 @@
#include <libsigrok-internal.h>
#include "protocol.h"
/* Supported device scan options.
*/
static const uint32_t scanopts[] = {
SR_CONF_CONN,
};
/* Driver capabilities.
*/
static const uint32_t drvopts[] = {
SR_CONF_LOGIC_ANALYZER,
};
/* Supported trigger match conditions.
*/
static const int32_t trigger_matches[] = {
SR_TRIGGER_ZERO,
SR_TRIGGER_ONE,
@ -47,22 +41,16 @@ static const int32_t trigger_matches[] = {
SR_TRIGGER_FALLING,
};
/* Names assigned to available trigger sources.
*/
static const char *const trigger_source_names[] = {
[TRIGGER_CHANNELS] = "CH",
[TRIGGER_EXT_TRG] = "TRG",
};
/* Names assigned to available edge slope choices.
*/
static const char *const signal_edge_names[] = {
[EDGE_POSITIVE] = "r",
[EDGE_NEGATIVE] = "f",
};
/* Create a new sigrok device instance for the indicated LWLA model.
*/
static struct sr_dev_inst *dev_inst_new(const struct model_info *model)
{
struct sr_dev_inst *sdi;
@ -70,7 +58,6 @@ static struct sr_dev_inst *dev_inst_new(const struct model_info *model)
int i;
char name[8];
/* Initialize private device context. */
devc = g_malloc0(sizeof(struct dev_context));
devc->model = model;
devc->active_fpga_config = FPGA_NOCONF;
@ -78,16 +65,13 @@ static struct sr_dev_inst *dev_inst_new(const struct model_info *model)
devc->samplerate = model->samplerates[0];
devc->channel_mask = (UINT64_C(1) << model->num_channels) - 1;
/* Create sigrok device instance. */
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup(VENDOR_NAME);
sdi->model = g_strdup(model->name);
sdi->priv = devc;
/* Generate list of logic channels. */
for (i = 0; i < model->num_channels; i++) {
/* The LWLA series simply number channels from CH1 to CHxx. */
g_snprintf(name, sizeof(name), "CH%d", i + 1);
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
}
@ -148,8 +132,6 @@ static struct sr_dev_inst *dev_inst_new_matching(GSList *conn_matches,
return sdi;
}
/* Scan for SysClk LWLA devices and create a device instance for each one.
*/
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
GSList *conn_devices, *devices, *node;
@ -236,8 +218,6 @@ static int drain_usb(struct sr_usb_dev_inst *usb, unsigned int endpoint)
return SR_OK;
}
/* Open and initialize device.
*/
static int dev_open(struct sr_dev_inst *sdi)
{
struct drv_context *drvc;
@ -300,7 +280,6 @@ static int dev_open(struct sr_dev_inst *sdi)
return ret;
}
/* Shutdown and close device. */
static int dev_close(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -344,8 +323,6 @@ static int has_devopt(const struct model_info *model, uint32_t key)
return FALSE;
}
/* Read device configuration setting.
*/
static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
@ -426,8 +403,6 @@ static int lookup_index(GVariant *value, const char *const *table, int len)
return -1;
}
/* Write device configuration setting.
*/
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
@ -501,8 +476,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
return SR_OK;
}
/* Apply channel configuration change.
*/
static int config_channel_set(const struct sr_dev_inst *sdi,
struct sr_channel *ch, unsigned int changes)
{
@ -532,8 +505,7 @@ static int config_channel_set(const struct sr_dev_inst *sdi,
return SR_OK;
}
/* Derive trigger masks from the session's trigger configuration.
*/
/* Derive trigger masks from the session's trigger configuration. */
static int prepare_trigger_masks(const struct sr_dev_inst *sdi)
{
uint64_t trigger_mask, trigger_values, trigger_edge_mask;
@ -598,8 +570,6 @@ static int prepare_trigger_masks(const struct sr_dev_inst *sdi)
return SR_OK;
}
/* Apply current device configuration to the hardware.
*/
static int config_commit(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -688,8 +658,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
return lwla_start_acquisition(sdi);
}
/* Request that a running capture operation be stopped.
*/
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -704,8 +672,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
return SR_OK;
}
/* SysClk LWLA driver descriptor.
*/
static struct sr_dev_driver sysclk_lwla_driver_info = {
.name = "sysclk-lwla",
.longname = "SysClk LWLA series",

View File

@ -69,8 +69,7 @@ struct sr_usb_dev_inst;
*/
#define PACKET_SIZE (5000 * 4 * 5)
/** LWLA protocol command ID codes.
*/
/** LWLA protocol command ID codes. */
enum command_id {
CMD_READ_REG = 1,
CMD_WRITE_REG = 2,
@ -89,22 +88,19 @@ enum status_flag {
STATUS_MEM_AVAIL = 1 << 6,
};
/** LWLA1034 run-length encoding states.
*/
/** LWLA1034 run-length encoding states. */
enum rle_state {
RLE_STATE_DATA,
RLE_STATE_LEN
};
/** Register address/value pair.
*/
/** Register address/value pair. */
struct regval {
unsigned int reg;
uint32_t val;
};
/** LWLA sample acquisition and decompression state.
*/
/** LWLA sample acquisition and decompression state. */
struct acquisition_state {
uint64_t samples_max; /* maximum number of samples to process */
uint64_t samples_done; /* number of samples sent to the session bus */

View File

@ -21,28 +21,22 @@
#include "lwla.h"
#include "protocol.h"
/* Number of logic channels.
*/
/* Number of logic channels. */
#define NUM_CHANNELS 16
/* Unit size for the sigrok logic datafeed.
*/
/* Unit size for the sigrok logic datafeed. */
#define UNIT_SIZE ((NUM_CHANNELS + 7) / 8)
/* Size of the acquisition buffer in device memory units.
*/
/* Size of the acquisition buffer in device memory units. */
#define MEMORY_DEPTH (256 * 1024) /* 256k x 32 bit */
/* Capture memory read start address.
*/
/* Capture memory read start address. */
#define READ_START_ADDR 2
/* Number of device memory units (32 bit) to read at a time.
*/
/* Number of device memory units (32 bit) to read at a time. */
#define READ_CHUNK_LEN 250
/** LWLA1016 register addresses.
*/
/** LWLA1016 register addresses. */
enum reg_addr {
REG_CHAN_MASK = 0x1000, /* bit mask of enabled channels */
@ -64,15 +58,13 @@ enum reg_addr {
REG_DIV_COUNT = 0x10BC, /* write */
};
/** Flag bits for REG_MEM_CTRL.
*/
/** Flag bits for REG_MEM_CTRL. */
enum mem_ctrl_flag {
MEM_CTRL_RESET = 1 << 0,
MEM_CTRL_WRITE = 1 << 1,
};
/** Flag bits for REG_CAP_CTRL.
*/
/** Flag bits for REG_CAP_CTRL. */
enum cap_ctrl_flag {
CAP_CTRL_FIFO32_FULL = 1 << 0, /* "fifo32_ful" bit */
CAP_CTRL_FIFO64_FULL = 1 << 1, /* "fifo64_ful" bit */
@ -83,22 +75,19 @@ enum cap_ctrl_flag {
CAP_CTRL_CNTR_NOT_ENDR = 1 << 6, /* "cntr_not_endr" bit */
};
/* Available FPGA configurations.
*/
/* Available FPGA configurations. */
enum fpga_config {
FPGA_100 = 0, /* 100 MS/s, no compression */
FPGA_100_TS, /* 100 MS/s, timing-state mode */
};
/* FPGA bitstream resource filenames.
*/
/* FPGA bitstream resource filenames. */
static const char bitstream_map[][32] = {
[FPGA_100] = "sysclk-lwla1016-100.rbf",
[FPGA_100_TS] = "sysclk-lwla1016-100-ts.rbf",
};
/* Demangle incoming sample data from the transfer buffer.
*/
/* Demangle incoming sample data from the transfer buffer. */
static void read_response(struct acquisition_state *acq)
{
uint32_t *in_p, *out_p;
@ -136,8 +125,7 @@ static void read_response(struct acquisition_state *acq)
acq->samples_done += run_samples;
}
/* Demangle and decompress incoming sample data from the transfer buffer.
*/
/* Demangle and decompress incoming sample data from the transfer buffer. */
static void read_response_rle(struct acquisition_state *acq)
{
uint32_t *in_p;
@ -233,8 +221,7 @@ static int test_read_memory(const struct sr_dev_inst *sdi,
return SR_OK;
}
/* Select and transfer FPGA bitstream for the current configuration.
*/
/* Select and transfer FPGA bitstream for the current configuration. */
static int apply_fpga_config(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -259,8 +246,7 @@ static int apply_fpga_config(const struct sr_dev_inst *sdi)
return ret;
}
/* Perform initialization self test.
*/
/* Perform initialization self test. */
static int device_init_check(const struct sr_dev_inst *sdi)
{
static const struct regval mem_reset[] = {
@ -443,8 +429,7 @@ static int handle_response(const struct sr_dev_inst *sdi)
return SR_OK;
}
/* Model descriptor for the LWLA1016.
*/
/* Model descriptor for the LWLA1016. */
SR_PRIV const struct model_info lwla1016_info = {
.name = "LWLA1016",
.num_channels = NUM_CHANNELS,

View File

@ -21,24 +21,19 @@
#include "lwla.h"
#include "protocol.h"
/* Number of logic channels.
*/
/* Number of logic channels. */
#define NUM_CHANNELS 34
/* Bit mask covering all logic channels.
*/
/* Bit mask covering all logic channels. */
#define ALL_CHANNELS_MASK ((UINT64_C(1) << NUM_CHANNELS) - 1)
/* Unit size for the sigrok logic datafeed.
*/
/* Unit size for the sigrok logic datafeed. */
#define UNIT_SIZE ((NUM_CHANNELS + 7) / 8)
/* Size of the acquisition buffer in device memory units.
*/
/* Size of the acquisition buffer in device memory units. */
#define MEMORY_DEPTH (256 * 1024) /* 256k x 36 bit */
/* Capture memory read start address.
*/
/* Capture memory read start address. */
#define READ_START_ADDR 4
/* Number of device memory units (36 bit) to read at a time. Slices of 8
@ -56,8 +51,7 @@
*/
#define READ_CHUNK_LEN (28 * 8)
/* Bit mask for the RLE repeat-count-follows flag.
*/
/* Bit mask for the RLE repeat-count-follows flag. */
#define RLE_FLAG_LEN_FOLLOWS (UINT64_C(1) << 35)
/* Start index and count for bulk long register reads.
@ -67,8 +61,7 @@
#define READ_LREGS_START LREG_MEM_FILL
#define READ_LREGS_COUNT (LREG_STATUS + 1 - READ_LREGS_START)
/** LWLA1034 register addresses.
*/
/** LWLA1034 register addresses. */
enum reg_addr {
REG_MEM_CTRL = 0x1074, /* capture buffer control */
REG_MEM_FILL = 0x1078, /* capture buffer fill level */
@ -82,15 +75,13 @@ enum reg_addr {
REG_LONG_HIGH = 0x10BC, /* long register high word */
};
/** Flag bits for REG_MEM_CTRL.
*/
/** Flag bits for REG_MEM_CTRL. */
enum mem_ctrl_flag {
MEM_CTRL_WRITE = 1 << 0, /* "wr1rd0" bit */
MEM_CTRL_CLR_IDX = 1 << 1, /* "clr_idx" bit */
};
/* LWLA1034 long register addresses.
*/
/* LWLA1034 long register addresses. */
enum long_reg_addr {
LREG_CHAN_MASK = 0, /* channel enable mask */
LREG_DIV_COUNT = 1, /* clock divider max count */
@ -107,8 +98,7 @@ enum long_reg_addr {
LREG_TEST_ID = 100, /* constant test ID */
};
/** Flag bits for LREG_CAP_CTRL.
*/
/** Flag bits for LREG_CAP_CTRL. */
enum cap_ctrl_flag {
CAP_CTRL_TRG_EN = 1 << 0, /* "trg_en" bit */
CAP_CTRL_CLR_TIMEBASE = 1 << 2, /* "do_clr_timebase" bit */
@ -117,8 +107,7 @@ enum cap_ctrl_flag {
CAP_CTRL_CLR_COUNTER = 1 << 6, /* "clr_cntr0" bit */
};
/* Available FPGA configurations.
*/
/* Available FPGA configurations. */
enum fpga_config {
FPGA_OFF = 0, /* FPGA shutdown config */
FPGA_INT, /* internal clock config */
@ -126,8 +115,7 @@ enum fpga_config {
FPGA_EXTNEG, /* external clock, falling edge config */
};
/* FPGA bitstream resource filenames.
*/
/* FPGA bitstream resource filenames. */
static const char bitstream_map[][32] = {
[FPGA_OFF] = "sysclk-lwla1034-off.rbf",
[FPGA_INT] = "sysclk-lwla1034-int.rbf",
@ -135,8 +123,7 @@ static const char bitstream_map[][32] = {
[FPGA_EXTNEG] = "sysclk-lwla1034-extneg.rbf",
};
/* Read 64-bit long register.
*/
/* Read 64-bit long register. */
static int read_long_reg(const struct sr_usb_dev_inst *usb,
uint32_t addr, uint64_t *value)
{
@ -164,8 +151,7 @@ static int read_long_reg(const struct sr_usb_dev_inst *usb,
return SR_OK;
}
/* Queue access sequence for a long register write.
*/
/* Queue access sequence for a long register write. */
static void queue_long_regval(struct acquisition_state *acq,
uint32_t addr, uint64_t value)
{
@ -175,8 +161,7 @@ static void queue_long_regval(struct acquisition_state *acq,
lwla_queue_regval(acq, REG_LONG_STROBE, 0);
}
/* Helper to fill in the long register bulk write command.
*/
/* Helper to fill in the long register bulk write command. */
static inline void bulk_long_set(struct acquisition_state *acq,
unsigned int idx, uint64_t value)
{
@ -186,8 +171,7 @@ static inline void bulk_long_set(struct acquisition_state *acq,
acq->xfer_buf_out[4 * idx + 6] = LWLA_WORD_3(value);
}
/* Helper for dissecting the response to a long register bulk read.
*/
/* Helper for dissecting the response to a long register bulk read. */
static inline uint64_t bulk_long_get(const struct acquisition_state *acq,
unsigned int idx)
{
@ -317,8 +301,7 @@ static int detect_short_transfer_quirk(const struct sr_dev_inst *sdi)
return SR_ERR;
}
/* Select and transfer FPGA bitstream for the current configuration.
*/
/* Select and transfer FPGA bitstream for the current configuration. */
static int apply_fpga_config(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -347,8 +330,7 @@ static int apply_fpga_config(const struct sr_dev_inst *sdi)
return ret;
}
/* Perform initialization self test.
*/
/* Perform initialization self test. */
static int device_init_check(const struct sr_dev_inst *sdi)
{
uint64_t value;
@ -369,8 +351,7 @@ static int device_init_check(const struct sr_dev_inst *sdi)
return detect_short_transfer_quirk(sdi);
}
/* Set up the device in preparation for an acquisition session.
*/
/* Set up the device in preparation for an acquisition session. */
static int setup_acquisition(const struct sr_dev_inst *sdi)
{
static const struct regval capture_init[] = {
@ -565,8 +546,7 @@ static int handle_response(const struct sr_dev_inst *sdi)
return SR_OK;
}
/** Model descriptor for the LWLA1034.
*/
/** Model descriptor for the LWLA1034. */
SR_PRIV const struct model_info lwla1034_info = {
.name = "LWLA1034",
.num_channels = NUM_CHANNELS,

View File

@ -22,8 +22,7 @@
#include "protocol.h"
#include "lwla.h"
/* Submit an already filled-in USB transfer.
*/
/* Submit an already filled-in USB transfer. */
static int submit_transfer(struct dev_context *devc,
struct libusb_transfer *xfer)
{
@ -40,8 +39,7 @@ static int submit_transfer(struct dev_context *devc,
return SR_OK;
}
/* Set up transfer for the next register in a write sequence.
*/
/* Set up transfer for the next register in a write sequence. */
static void next_reg_write(struct acquisition_state *acq)
{
struct regval *regval;
@ -56,8 +54,7 @@ static void next_reg_write(struct acquisition_state *acq)
acq->xfer_out->length = 4 * sizeof(acq->xfer_buf_out[0]);
}
/* Set up transfer for the next register in a read sequence.
*/
/* Set up transfer for the next register in a read sequence. */
static void next_reg_read(struct acquisition_state *acq)
{
unsigned int addr;
@ -70,8 +67,7 @@ static void next_reg_read(struct acquisition_state *acq)
acq->xfer_out->length = 2 * sizeof(acq->xfer_buf_out[0]);
}
/* Decode the response to a register read request.
*/
/* Decode the response to a register read request. */
static int read_reg_response(struct acquisition_state *acq)
{
uint32_t value;
@ -87,8 +83,7 @@ static int read_reg_response(struct acquisition_state *acq)
return SR_OK;
}
/* Enter a new state and submit the corresponding request to the device.
*/
/* Enter a new state and submit the corresponding request to the device. */
static int submit_request(const struct sr_dev_inst *sdi,
enum protocol_state state)
{
@ -123,8 +118,7 @@ static int submit_request(const struct sr_dev_inst *sdi,
return submit_transfer(devc, acq->xfer_out);
}
/* Evaluate and act on the response to a capture status request.
*/
/* Evaluate and act on the response to a capture status request. */
static void handle_status_response(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -160,8 +154,7 @@ static void handle_status_response(const struct sr_dev_inst *sdi)
}
}
/* Evaluate and act on the response to a capture length request.
*/
/* Evaluate and act on the response to a capture length request. */
static void handle_length_response(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -191,8 +184,7 @@ static void handle_length_response(const struct sr_dev_inst *sdi)
submit_request(sdi, STATE_READ_PREPARE);
}
/* Evaluate and act on the response to a capture memory read request.
*/
/* Evaluate and act on the response to a capture memory read request. */
static void handle_read_response(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -250,8 +242,7 @@ static void handle_read_response(const struct sr_dev_inst *sdi)
submit_request(sdi, STATE_READ_FINISH);
}
/* Destroy and unset the acquisition state record.
*/
/* Destroy and unset the acquisition state record. */
static void clear_acquisition_state(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -269,8 +260,7 @@ static void clear_acquisition_state(const struct sr_dev_inst *sdi)
}
}
/* USB I/O source callback.
*/
/* USB I/O source callback. */
static int transfer_event(int fd, int revents, void *cb_data)
{
const struct sr_dev_inst *sdi;
@ -321,8 +311,7 @@ static int transfer_event(int fd, int revents, void *cb_data)
return G_SOURCE_REMOVE;
}
/* USB output transfer completion callback.
*/
/* USB output transfer completion callback. */
static void LIBUSB_CALL transfer_out_completed(struct libusb_transfer *transfer)
{
const struct sr_dev_inst *sdi;
@ -386,8 +375,7 @@ static void LIBUSB_CALL transfer_out_completed(struct libusb_transfer *transfer)
}
}
/* USB input transfer completion callback.
*/
/* USB input transfer completion callback. */
static void LIBUSB_CALL transfer_in_completed(struct libusb_transfer *transfer)
{
const struct sr_dev_inst *sdi;
@ -448,8 +436,7 @@ static void LIBUSB_CALL transfer_in_completed(struct libusb_transfer *transfer)
}
}
/* Set up the acquisition state record.
*/
/* Set up the acquisition state record. */
static int init_acquisition_state(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;

View File

@ -46,46 +46,40 @@
struct acquisition_state;
/* USB vendor and product IDs.
*/
/* USB vendor and product IDs. */
enum {
USB_VID_SYSCLK = 0x2961,
USB_PID_LWLA1016 = 0x6688,
USB_PID_LWLA1034 = 0x6689,
};
/* USB device characteristics.
*/
/* USB device characteristics. */
enum {
USB_CONFIG = 1,
USB_INTERFACE = 0,
USB_TIMEOUT_MS = 1000,
};
/** USB device end points.
*/
/** USB device end points. */
enum usb_endpoint {
EP_COMMAND = 2,
EP_CONFIG = 4,
EP_REPLY = 6 | LIBUSB_ENDPOINT_IN
};
/** LWLA1034 clock sources.
*/
/** LWLA1034 clock sources. */
enum clock_source {
CLOCK_INTERNAL = 0,
CLOCK_EXT_CLK,
};
/** LWLA1034 trigger sources.
*/
/** LWLA1034 trigger sources. */
enum trigger_source {
TRIGGER_CHANNELS = 0,
TRIGGER_EXT_TRG,
};
/** Edge choices for the LWLA1034 external clock and trigger inputs.
*/
/** Edge choices for the LWLA1034 external clock and trigger inputs. */
enum signal_edge {
EDGE_POSITIVE = 0,
EDGE_NEGATIVE,
@ -96,8 +90,7 @@ enum {
FPGA_NOCONF = -1,
};
/** Acquisition protocol states.
*/
/** Acquisition protocol states. */
enum protocol_state {
/* idle states */
STATE_IDLE = 0,
@ -114,8 +107,6 @@ enum protocol_state {
STATE_READ_REQUEST,
};
/** Private, per-device-instance driver context.
*/
struct dev_context {
uint64_t samplerate; /* requested samplerate */
uint64_t limit_msec; /* requested capture duration in ms */
@ -142,8 +133,7 @@ struct dev_context {
enum signal_edge cfg_trigger_slope; /* ext trigger slope setting */
};
/** LWLA model descriptor.
*/
/** LWLA model descriptor. */
struct model_info {
char name[12];
int num_channels;

View File

@ -153,7 +153,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
std_session_send_df_header(sdi);
/* Poll every 50ms, or whenever some data comes in. */
serial_source_add(sdi->session, serial, G_IO_IN, 50,
teleinfo_receive_data, (void *)sdi);

View File

@ -37,15 +37,9 @@ enum optarif {
#define TELEINFO_BUF_SIZE 256
/** Private, per-device-instance driver context. */
struct dev_context {
/* Acquisition settings */
struct sr_sw_limits sw_limits;
/* Operational state */
enum optarif optarif; /**< The device mode (which measures are reported) */
/* Temporary state across callbacks */
uint8_t buf[TELEINFO_BUF_SIZE];
int buf_len;
};

View File

@ -111,7 +111,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
/* Hardcode the 435 for now.*/
/* Hardcode the 435 for now. */
if (strcmp(product, "testo 435/635/735"))
continue;

Some files were not shown because too many files have changed in this diff Show More