From: Bert Vermeulen Date: Sun, 20 Jan 2013 14:45:09 +0000 (+0100) Subject: Use new SR_DF_META packet. X-Git-Tag: dsupstream~335 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2df1e81970b38bd4edb6e219ad295c8a83315797;p=libsigrok.git Use new SR_DF_META packet. Since input modules determine a samplerate by reading from their file format (or having it overridden with an option), they need to pass this up to the frontend. --- diff --git a/input/binary.c b/input/binary.c index 6e11cde0..3d4418ca 100644 --- a/input/binary.c +++ b/input/binary.c @@ -100,8 +100,9 @@ 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_meta meta; struct sr_datafeed_logic logic; + struct sr_config *src; unsigned char buffer[CHUNKSIZE]; int fd, size, num_probes; struct context *ctx; @@ -120,12 +121,13 @@ static int loadfile(struct sr_input *in, const char *filename) packet.payload = &header; sr_session_send(in->sdi, &packet); - /* Send metadata about the SR_DF_LOGIC packets to come. */ - packet.type = SR_DF_META_LOGIC; - packet.payload = &meta; - meta.samplerate = ctx->samplerate; - meta.num_probes = num_probes; - sr_session_send(in->sdi, &packet); + if (ctx->samplerate) { + packet.type = SR_DF_META; + packet.payload = &meta; + src = sr_config_make(SR_HWCAP_SAMPLERATE, (const void *)&ctx->samplerate); + meta.config = g_slist_append(NULL, src); + sr_session_send(in->sdi, &packet); + } /* Chop up the input file into chunks & send it to the session bus. */ packet.type = SR_DF_LOGIC; diff --git a/input/chronovu_la8.c b/input/chronovu_la8.c index 146d9da9..c3913789 100644 --- a/input/chronovu_la8.c +++ b/input/chronovu_la8.c @@ -139,8 +139,9 @@ 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_meta meta; struct sr_datafeed_logic logic; + struct sr_config *src; uint8_t buf[PACKET_SIZE], divcount; int i, fd, size, num_probes; uint64_t samplerate; @@ -173,10 +174,10 @@ static int loadfile(struct sr_input *in, const char *filename) sr_session_send(in->sdi, &packet); /* Send metadata about the SR_DF_LOGIC packets to come. */ - packet.type = SR_DF_META_LOGIC; + packet.type = SR_DF_META; packet.payload = &meta; - meta.samplerate = samplerate; - meta.num_probes = num_probes; + src = sr_config_make(SR_HWCAP_SAMPLERATE, (const void *)&samplerate); + meta.config = g_slist_append(NULL, src); sr_session_send(in->sdi, &packet); /* TODO: Handle trigger point. */ diff --git a/input/vcd.c b/input/vcd.c index 138aa3c1..25192f88 100644 --- a/input/vcd.c +++ b/input/vcd.c @@ -545,9 +545,11 @@ 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_meta meta; + struct sr_config *src; FILE *file; struct context *ctx; + uint64_t samplerate; ctx = in->internal; @@ -569,10 +571,11 @@ static int loadfile(struct sr_input *in, const char *filename) sr_session_send(in->sdi, &packet); /* Send metadata about the SR_DF_LOGIC packets to come. */ - packet.type = SR_DF_META_LOGIC; + packet.type = SR_DF_META; packet.payload = &meta; - meta.samplerate = ctx->samplerate / ctx->downsample; - meta.num_probes = ctx->probecount; + samplerate = ctx->samplerate / ctx->downsample; + src = sr_config_make(SR_HWCAP_SAMPLERATE, (const void *)&samplerate); + meta.config = g_slist_append(NULL, src); sr_session_send(in->sdi, &packet); /* Parse the contents of the VCD file */