drivers: use new sr_config struct

Sending an SR_DF_META packet at the start of every stream is not
mandatory; the frontend should ask for what it needs, and any extra
information the driver wants to send will come in due time.
This commit is contained in:
Bert Vermeulen 2013-01-06 17:41:30 +01:00
parent 9a5693a5ac
commit 1987b8d63e
20 changed files with 44 additions and 186 deletions

View File

@ -109,7 +109,7 @@ static GSList *hw_scan(GSList *options)
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
struct sr_hwopt *opt;
struct sr_config *src;
struct sr_probe *probe;
struct sr_serial_dev_inst *serial;
GSList *l, *devices;
@ -123,13 +123,13 @@ static GSList *hw_scan(GSList *options)
devices = NULL;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
opt = l->data;
switch (opt->hwopt) {
src = l->data;
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
case SR_HWOPT_SERIALCOMM:
serialcomm = opt->value;
serialcomm = src->value;
break;
}
}
@ -309,7 +309,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
if (!(devc = sdi->priv)) {
@ -329,13 +328,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
sr_dbg("Sending SR_DF_META_ANALOG.");
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
sr_session_send(devc->cb_data, &packet);
/* Poll every 100ms, or whenever some data comes in. */
sr_source_add(devc->serial->fd, G_IO_IN, 100, agdmm_receive_data, (void *)sdi);

View File

@ -196,7 +196,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
int count, ret;
char *endianness;
@ -287,13 +286,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
sr_dbg("Sending SR_DF_META_ANALOG packet.");
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = devc->num_probes;
sr_session_send(devc->cb_data, &packet);
/* Poll every 10ms, or whenever some data comes in. */
sr_source_add(devc->ufds[0].fd, devc->ufds[0].events, 10,
alsa_receive_data, (void *)sdi);

View File

@ -1271,7 +1271,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
struct dev_context *devc;
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
struct sr_datafeed_meta_logic meta;
struct clockselect_50 clockselect;
int frac, triggerpin, ret;
uint8_t triggerselect = 0;
@ -1382,13 +1381,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header->starttime, NULL);
sr_session_send(devc->session_dev_id, packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = devc->cur_samplerate;
meta.num_probes = devc->num_probes;
sr_session_send(devc->session_dev_id, packet);
/* Add capture source. */
sr_source_add(0, G_IO_IN, 10, receive_data, (void *)sdi);

View File

@ -421,7 +421,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_logic meta;
uint8_t buf[4];
int bytes_written;
@ -477,13 +476,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(devc->session_dev_id, &packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.payload = &meta;
meta.samplerate = devc->cur_samplerate;
meta.num_probes = NUM_PROBES;
sr_session_send(devc->session_dev_id, &packet);
/* Time when we should be done (for detecting trigger timeouts). */
devc->done = (devc->divcount + 1) * 0.08388608 + time(NULL)
+ devc->trigger_timeout;

View File

@ -92,7 +92,7 @@ static GSList *hw_scan(GSList *options)
struct drv_context *drvc;
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_hwopt *opt;
struct sr_config *src;
struct sr_probe *probe;
GSList *devices, *l;
const char *conn, *serialcomm;
@ -103,13 +103,13 @@ static GSList *hw_scan(GSList *options)
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
opt = l->data;
switch (opt->hwopt) {
src = l->data;
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
case SR_HWOPT_SERIALCOMM:
serialcomm = opt->value;
serialcomm = src->value;
break;
}
}
@ -253,7 +253,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
if (!(devc = sdi->priv)) {
@ -273,13 +272,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
sr_dbg("Sending SR_DF_META_ANALOG.");
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
sr_session_send(devc->cb_data, &packet);
/* Poll every 150ms, or whenever some data comes in. */
sr_source_add(devc->serial->fd, G_IO_IN, 150, colead_slm_receive_data,
(void *)sdi);

View File

@ -390,7 +390,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
struct sr_datafeed_meta_logic meta;
struct dev_context *devc;
(void)sdi;
@ -452,13 +451,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header->starttime, NULL);
sr_session_send(devc->session_dev_id, packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = cur_samplerate;
meta.num_probes = NUM_PROBES;
sr_session_send(devc->session_dev_id, packet);
/* We use this timestamp to decide how many more samples to send. */
devc->starttime = g_get_monotonic_time();

View File

@ -194,20 +194,20 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
static GSList *hw_scan(GSList *options)
{
struct sr_hwopt *opt;
struct sr_config *src;
GSList *l, *devices;
int i;
const char *conn, *serialcomm;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
opt = l->data;
switch (opt->hwopt) {
src = l->data;
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
case SR_HWOPT_SERIALCOMM:
serialcomm = opt->value;
serialcomm = src->value;
break;
}
}
@ -343,7 +343,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
if (!(devc = sdi->priv)) {
@ -363,13 +362,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
sr_dbg("Sending SR_DF_META_ANALOG.");
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
sr_session_send(devc->cb_data, &packet);
/* Poll every 100ms, or whenever some data comes in. */
sr_source_add(devc->serial->fd, G_IO_IN, 50, fluke_receive_data, (void *)sdi);

View File

@ -928,7 +928,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_logic meta;
struct dev_context *devc;
struct drv_context *drvc;
struct libusb_transfer *transfer;
@ -998,13 +997,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(cb_data, &packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.payload = &meta;
meta.samplerate = devc->cur_samplerate;
meta.num_probes = devc->sample_wide ? 16 : 8;
sr_session_send(cb_data, &packet);
if ((ret = command_start_acquisition(devc->usb->devhdl,
devc->cur_samplerate, devc->sample_wide)) != SR_OK) {
abort_acquisition(devc);

View File

@ -842,7 +842,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
const struct libusb_pollfd **lupfd;
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
struct drv_context *drvc = di->priv;
int i;
@ -878,12 +877,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = NUM_PROBES;
sr_session_send(cb_data, &packet);
return SR_OK;
}

View File

@ -26,7 +26,6 @@
#define USB_CONFIGURATION 1
#define DSO_EP_IN 0x86
#define DSO_EP_OUT 0x02
#define NUM_PROBES 2
/* FX2 renumeration delay in ms */
#define MAX_RENUM_DELAY_MS 3000

View File

@ -89,7 +89,7 @@ static GSList *hw_scan(GSList *options)
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb;
struct sr_hwopt *opt;
struct sr_config *src;
GSList *usb_devices, *devices, *l;
const char *conn;
@ -105,10 +105,10 @@ static GSList *hw_scan(GSList *options)
conn = NULL;
for (l = options; l; l = l->next) {
opt = l->data;
switch (opt->hwopt) {
src = l->data;
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
}
}
@ -335,7 +335,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
struct drv_context *drvc = di->priv;
struct libusb_transfer *xfer_in, *xfer_out;
@ -429,12 +428,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
devc->log_size = xfer_in->buffer[1] + (xfer_in->buffer[2] << 8);
libusb_free_transfer(xfer_out);
/* Send metadata about the SR_DF_ANALOG packets to come. */
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
sr_session_send(devc->cb_data, &packet);
pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
for (i = 0; pfd[i]; i++) {
/* Handle USB events every 100ms, for decent latency. */

View File

@ -74,19 +74,19 @@ static GSList *hw_scan(GSList *options)
const char *conn = NULL;
const char *serialcomm = NULL;
GSList *l;
struct sr_hwopt *opt;
struct sr_config *src;
struct udev *udev;
(void)options;
for (l = options; l; l = l->next) {
opt = l->data;
switch (opt->hwopt) {
src = l->data;
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
case SR_HWOPT_SERIALCOMM:
serialcomm = opt->value;
serialcomm = src->value;
break;
}
}
@ -399,7 +399,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
struct sr_datafeed_meta_logic meta;
struct dev_context *devc;
int ret = SR_ERR;
@ -469,12 +468,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header->starttime, NULL);
sr_session_send(cb_data, packet);
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = devc->cur_rate;
meta.num_probes = NUM_PROBES;
sr_session_send(cb_data, packet);
g_free(header);
g_free(packet);

View File

@ -158,7 +158,7 @@ static GSList *hw_scan(GSList *options)
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb;
struct sr_hwopt *opt;
struct sr_config *src;
struct sr_probe *probe;
libusb_device *dev;
GSList *usb_devices, *devices, *l;
@ -177,10 +177,10 @@ static GSList *hw_scan(GSList *options)
conn = NULL;
for (l = options; l; l = l->next) {
opt = l->data;
switch (opt->hwopt) {
src = l->data;
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
}
}

View File

@ -71,7 +71,7 @@ static int hw_init(struct sr_context *sr_ctx)
static GSList *hw_scan(GSList *options)
{
struct sr_hwopt *opt;
struct sr_config *src;
struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
@ -89,13 +89,13 @@ static GSList *hw_scan(GSList *options)
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
opt = l->data;
switch (opt->hwopt) {
src = l->data;
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
case SR_HWOPT_SERIALCOMM:
serialcomm = opt->value;
serialcomm = src->value;
break;
}
}
@ -336,7 +336,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
struct sr_datafeed_meta_logic meta;
struct dev_context *devc;
uint32_t trigger_config[4];
uint32_t data;
@ -479,13 +478,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header->starttime, NULL);
sr_session_send(cb_data, packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet->type = SR_DF_META_LOGIC;
packet->payload = &meta;
meta.samplerate = devc->cur_samplerate;
meta.num_probes = NUM_PROBES;
sr_session_send(cb_data, packet);
g_free(header);
g_free(packet);

View File

@ -26,8 +26,6 @@
#include "libsigrok-internal.h"
#include "protocol.h"
#define NUM_PROBES 2
static const int hwcaps[] = {
SR_HWCAP_OSCILLOSCOPE,
SR_HWCAP_LIMIT_SAMPLES,
@ -448,7 +446,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
char buf[256];
int len;
@ -467,12 +464,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = NUM_PROBES;
sr_session_send(cb_data, &packet);
rigol_ds1xx2_send_data(devc->fd, ":CHAN1:SCAL?\n");
len = read(devc->fd, buf, sizeof(buf));
buf[len] = 0;

View File

@ -293,19 +293,19 @@ scan_cleanup:
static GSList *hw_scan(GSList *options, int dmm)
{
struct sr_hwopt *opt;
struct sr_config *src;
GSList *l, *devices;
const char *conn, *serialcomm;
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
opt = l->data;
switch (opt->hwopt) {
src = l->data;
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
case SR_HWOPT_SERIALCOMM:
serialcomm = opt->value;
serialcomm = src->value;
break;
}
}
@ -430,7 +430,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
if (!(devc = sdi->priv)) {
@ -458,13 +457,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
sr_dbg("Sending SR_DF_META_ANALOG.");
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
sr_session_send(devc->cb_data, &packet);
/* Poll every 50ms, or whenever some data comes in. */
sr_source_add(devc->serial->fd, G_IO_IN, 50,
dmms[dmm].receive_data, (void *)sdi);

View File

@ -88,7 +88,7 @@ static GSList *hw_scan(GSList *options)
struct drv_context *drvc;
struct dev_context *devc;
struct sr_dev_inst *sdi;
struct sr_hwopt *opt;
struct sr_config *src;
struct sr_probe *probe;
GSList *devices, *l;
const char *conn, *serialcomm;
@ -99,19 +99,19 @@ static GSList *hw_scan(GSList *options)
conn = serialcomm = NULL;
for (l = options; l; l = l->next) {
if (!(opt = l->data)) {
if (!(src = l->data)) {
sr_err("Invalid option data, skipping.");
continue;
}
switch (opt->hwopt) {
switch (src->key) {
case SR_HWOPT_CONN:
conn = opt->value;
conn = src->value;
break;
case SR_HWOPT_SERIALCOMM:
serialcomm = opt->value;
serialcomm = src->value;
break;
default:
sr_err("Unknown option %d, skipping.", opt->hwopt);
sr_err("Unknown option %d, skipping.", src->key);
break;
}
}
@ -245,7 +245,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
devc = sdi->priv;
@ -259,13 +258,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
sr_dbg("Sending SR_DF_META_ANALOG.");
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
sr_session_send(devc->cb_data, &packet);
/* Poll every 500ms, or whenever some data comes in. */
sr_source_add(devc->serial->fd, G_IO_IN, 500,
tondaj_sl_814_receive_data, (void *)sdi);

View File

@ -262,7 +262,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
devc = sdi->priv;
@ -279,13 +278,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
sr_dbg("Sending SR_DF_META_ANALOG.");
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
sr_session_send(devc->cb_data, &packet);
if (!strcmp(di->name, "uni-t-ut61d")) {
sr_source_add(0, 0, 10 /* poll_timeout */,
uni_t_ut61d_receive_data, (void *)sdi);

View File

@ -385,7 +385,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
struct dev_context *devc;
struct drv_context *drvc = di->priv;
const struct libusb_pollfd **pfd;
@ -410,12 +409,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
header.feed_version = 1;
sr_session_send(devc->cb_data, &packet);
/* Send metadata about the SR_DF_ANALOG packets to come. */
packet.type = SR_DF_META_ANALOG;
packet.payload = &meta;
meta.num_probes = 1;
sr_session_send(devc->cb_data, &packet);
pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
for (i = 0; pfd[i]; i++) {
/* Handle USB events every 100ms, for decent latency. */

View File

@ -686,7 +686,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
struct sr_datafeed_header header;
struct sr_datafeed_meta_logic meta;
//uint64_t samples_read;
int res;
unsigned int packet_num;
@ -726,13 +725,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
gettimeofday(&header.starttime, NULL);
sr_session_send(cb_data, &packet);
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META_LOGIC;
packet.payload = &meta;
meta.samplerate = devc->cur_samplerate;
meta.num_probes = devc->num_channels;
sr_session_send(cb_data, &packet);
if (!(buf = g_try_malloc(PACKET_SIZE))) {
sr_err("zp: %s: buf malloc failed", __func__);
return SR_ERR_MALLOC;