From: Bert Vermeulen Date: Sun, 22 Apr 2012 18:06:19 +0000 (+0200) Subject: sr: change all drivers to use SR_DF_META_LOGIC X-Git-Tag: dsupstream~953 X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=f366e86c68071fa7888259aa3963b213caa81b51;p=libsigrok.git sr: change all drivers to use SR_DF_META_LOGIC --- diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 3c2f269a..39e2dbed 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -1265,6 +1265,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) struct context *ctx; 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; @@ -1366,17 +1367,23 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) return SR_ERR_MALLOC; } - /* Add capture source. */ - sr_source_add(0, G_IO_IN, 10, receive_data, sdi); - /* Send header packet to the session bus. */ packet->type = SR_DF_HEADER; packet->payload = header; header->feed_version = 1; gettimeofday(&header->starttime, NULL); - header->samplerate = ctx->cur_samplerate; - header->num_logic_probes = ctx->num_probes; sr_session_send(ctx->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 = ctx->cur_samplerate; + meta.num_probes = ctx->num_probes; + sr_session_send(ctx->session_dev_id, packet); + + /* Add capture source. */ + sr_source_add(0, G_IO_IN, 10, receive_data, sdi); + g_free(header); g_free(packet); diff --git a/hardware/chronovu-la8/chronovu-la8.c b/hardware/chronovu-la8/chronovu-la8.c index 06de6340..ee112ed0 100644 --- a/hardware/chronovu-la8/chronovu-la8.c +++ b/hardware/chronovu-la8/chronovu-la8.c @@ -1016,6 +1016,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) struct context *ctx; struct sr_datafeed_packet packet; struct sr_datafeed_header header; + struct sr_datafeed_meta_logic meta; uint8_t buf[4]; int bytes_written; @@ -1069,8 +1070,13 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) packet.payload = &header; header.feed_version = 1; gettimeofday(&header.starttime, NULL); - header.samplerate = ctx->cur_samplerate; - header.num_logic_probes = NUM_PROBES; + sr_session_send(ctx->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 = ctx->cur_samplerate; + meta.num_probes = NUM_PROBES; sr_session_send(ctx->session_dev_id, &packet); /* Time when we should be done (for detecting trigger timeouts). */ diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 48f7cf52..51644fc4 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -414,6 +414,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) { struct sr_datafeed_packet *packet; struct sr_datafeed_header *header; + struct sr_datafeed_meta_logic meta; struct context *ctx; /* TODO: 'ctx' is never g_free()'d? */ @@ -473,9 +474,15 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) packet->payload = header; header->feed_version = 1; gettimeofday(&header->starttime, NULL); - header->samplerate = cur_samplerate; - header->num_logic_probes = NUM_PROBES; sr_session_send(ctx->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(ctx->session_dev_id, packet); + g_free(header); g_free(packet); diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index 0ea4030d..0f839b57 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -794,6 +794,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) struct sr_dev_inst *sdi; struct sr_datafeed_packet *packet; struct sr_datafeed_header *header; + struct sr_datafeed_meta_logic meta; struct context *ctx; struct libusb_transfer *transfer; const struct libusb_pollfd **lupfd; @@ -848,9 +849,15 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) packet->payload = header; header->feed_version = 1; gettimeofday(&header->starttime, NULL); - header->samplerate = ctx->cur_samplerate; - header->num_logic_probes = ctx->profile->num_probes; 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 = ctx->cur_samplerate; + meta.num_probes = ctx->profile->num_probes; + sr_session_send(cb_data, packet); + g_free(header); g_free(packet); diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 1a9b5555..8862db24 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -876,6 +876,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) { struct sr_datafeed_packet *packet; struct sr_datafeed_header *header; + struct sr_datafeed_meta_logic meta; struct sr_dev_inst *sdi; struct context *ctx; uint32_t trigger_config[4]; @@ -1015,8 +1016,13 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) packet->payload = (unsigned char *)header; header->feed_version = 1; gettimeofday(&header->starttime, NULL); - header->samplerate = ctx->cur_samplerate; - header->num_logic_probes = NUM_PROBES; + 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 = ctx->cur_samplerate; + meta.num_probes = NUM_PROBES; sr_session_send(cb_data, packet); g_free(header); diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index ec0e6a2b..d27fb39b 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -633,6 +633,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) 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; @@ -667,8 +668,13 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) packet.payload = &header; header.feed_version = 1; gettimeofday(&header.starttime, NULL); - header.samplerate = ctx->cur_samplerate; - header.num_logic_probes = ctx->num_channels; + 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 = ctx->cur_samplerate; + meta.num_probes = ctx->num_channels; sr_session_send(cb_data, &packet); if (!(buf = g_try_malloc(PACKET_SIZE))) { diff --git a/input/binary.c b/input/binary.c index 89a6b25b..4d6c4246 100644 --- a/input/binary.c +++ b/input/binary.c @@ -67,6 +67,7 @@ static int loadfile(struct sr_input *in, const char *filename) { struct sr_datafeed_header header; struct sr_datafeed_packet packet; + struct sr_datafeed_meta_logic meta; struct sr_datafeed_logic logic; unsigned char buffer[CHUNKSIZE]; int fd, size, num_probes; @@ -78,13 +79,18 @@ static int loadfile(struct sr_input *in, const char *filename) /* send header */ header.feed_version = 1; - header.num_logic_probes = num_probes; - header.samplerate = 0; gettimeofday(&header.starttime, NULL); packet.type = SR_DF_HEADER; packet.payload = &header; sr_session_send(in->vdev, &packet); + /* Send metadata about the SR_DF_LOGIC packets to come. */ + packet.type = SR_DF_META_LOGIC; + packet.payload = &meta; + meta.samplerate = 0; + meta.num_probes = num_probes; + sr_session_send(in->vdev, &packet); + /* chop up the input file into chunks and feed it into the session bus */ packet.type = SR_DF_LOGIC; packet.payload = &logic; diff --git a/input/chronovu_la8.c b/input/chronovu_la8.c index b9f14dd3..79f83cc9 100644 --- a/input/chronovu_la8.c +++ b/input/chronovu_la8.c @@ -123,6 +123,7 @@ static int loadfile(struct sr_input *in, const char *filename) { struct sr_datafeed_header header; struct sr_datafeed_packet packet; + struct sr_datafeed_meta_logic meta; struct sr_datafeed_logic logic; uint8_t buf[PACKET_SIZE], divcount; int i, fd, size, num_probes; @@ -153,8 +154,13 @@ static int loadfile(struct sr_input *in, const char *filename) packet.payload = &header; header.feed_version = 1; gettimeofday(&header.starttime, NULL); - header.num_logic_probes = num_probes; - header.samplerate = samplerate; + sr_session_send(in->vdev, &packet); + + /* Send metadata about the SR_DF_LOGIC packets to come. */ + packet.type = SR_DF_META_LOGIC; + packet.payload = &meta; + meta.samplerate = samplerate; + meta.num_probes = num_probes; sr_session_send(in->vdev, &packet); /* TODO: Handle trigger point. */ diff --git a/session_driver.c b/session_driver.c index b64ce3a3..32b8e905 100644 --- a/session_driver.c +++ b/session_driver.c @@ -274,6 +274,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) struct session_vdev *vdev; struct sr_datafeed_header *header; struct sr_datafeed_packet *packet; + struct sr_datafeed_meta_logic meta; int ret; if (!(vdev = get_vdev_by_index(dev_index))) @@ -318,9 +319,15 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) packet->payload = (unsigned char *)header; header->feed_version = 1; gettimeofday(&header->starttime, NULL); - header->samplerate = vdev->samplerate; - header->num_logic_probes = vdev->num_probes; 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 = vdev->samplerate; + meta.num_probes = vdev->num_probes; + sr_session_send(cb_data, packet); + g_free(header); g_free(packet);