]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
sr: Made sample rate lists const
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index 0ea4030d7b1fcffb2f81f191275f43fa3a17fab8..a40a17ac486b850426ea6b2d57693a4c6bce3a3a 100644 (file)
@@ -70,7 +70,7 @@ static const struct fx2lafw_profile supported_fx2[] = {
        { 0, 0, 0, 0, 0, 0, 0 }
 };
 
-static int hwcaps[] = {
+static const int hwcaps[] = {
        SR_HWCAP_LOGIC_ANALYZER,
        SR_HWCAP_SAMPLERATE,
 
@@ -95,7 +95,7 @@ static const char *probe_names[] = {
        NULL,
 };
 
-static uint64_t supported_samplerates[] = {
+static const uint64_t supported_samplerates[] = {
        SR_KHZ(20),
        SR_KHZ(25),
        SR_KHZ(50),
@@ -115,7 +115,7 @@ static uint64_t supported_samplerates[] = {
        0,
 };
 
-static struct sr_samplerates samplerates = {
+static const struct sr_samplerates samplerates = {
        0,
        0,
        0,
@@ -125,7 +125,7 @@ static struct sr_samplerates samplerates = {
 static GSList *dev_insts = NULL;
 static libusb_context *usb_context = NULL;
 
-static int hw_dev_config_set(int dev_index, int hwcap, void *value);
+static int hw_dev_config_set(int dev_index, int hwcap, const void *value);
 static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
 
 /**
@@ -546,7 +546,7 @@ static int hw_cleanup(void)
        return ret;
 }
 
-static void *hw_dev_info_get(int dev_index, int dev_info_id)
+static const void *hw_dev_info_get(int dev_index, int dev_info_id)
 {
        struct sr_dev_inst *sdi;
        struct context *ctx;
@@ -584,12 +584,12 @@ static int hw_dev_status_get(int dev_index)
        return sdi->status;
 }
 
-static int *hw_hwcap_get_all(void)
+static const int *hw_hwcap_get_all(void)
 {
        return hwcaps;
 }
 
-static int hw_dev_config_set(int dev_index, int hwcap, void *value)
+static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
 {
        struct sr_dev_inst *sdi;
        struct context *ctx;
@@ -600,12 +600,12 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
        ctx = sdi->priv;
 
        if (hwcap == SR_HWCAP_SAMPLERATE) {
-               ctx->cur_samplerate = *(uint64_t *)value;
+               ctx->cur_samplerate = *(const uint64_t *)value;
                ret = SR_OK;
        } else if (hwcap == SR_HWCAP_PROBECONFIG) {
                ret = configure_probes(ctx, (GSList *) value);
        } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) {
-               ctx->limit_samples = *(uint64_t *)value;
+               ctx->limit_samples = *(const uint64_t *)value;
                ret = SR_OK;
        } else {
                ret = SR_ERR;
@@ -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);