]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
sr/cli/gtk/qt: s/get_dev_info/dev_info_get/.
[libsigrok.git] / hardware / asix-sigma / asix-sigma.c
index d2a7b6e857f2835a8f058c12ca0e4fd3fa77a617..77f3e3507787a2797caab5821ee680bfd1632d49 100644 (file)
@@ -41,7 +41,7 @@
 #define TRIGGER_TYPES                  "rf10"
 #define NUM_PROBES                     16
 
-static GSList *device_instances = NULL;
+static GSList *dev_insts = NULL;
 
 static uint64_t supported_samplerates[] = {
        SR_KHZ(200),
@@ -84,7 +84,7 @@ static struct sr_samplerates samplerates = {
        supported_samplerates,
 };
 
-static int capabilities[] = {
+static int hwcaps[] = {
        SR_HWCAP_LOGIC_ANALYZER,
        SR_HWCAP_SAMPLERATE,
        SR_HWCAP_CAPTURE_RATIO,
@@ -118,7 +118,7 @@ static const char *firmware_files[] = {
        "asix-sigma-phasor.fw", /* Frequency counter */
 };
 
-static int hw_stop_acquisition(int device_index, gpointer session_data);
+static int hw_stop_acquisition(int dev_index, gpointer session_data);
 
 static int sigma_read(void *buf, size_t size, struct sigma *sigma)
 {
@@ -415,13 +415,13 @@ static int bin2bitbang(const char *filename,
        return SR_OK;
 }
 
-static int hw_init(const char *deviceinfo)
+static int hw_init(const char *devinfo)
 {
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
        struct sigma *sigma;
 
        /* Avoid compiler warnings. */
-       (void)deviceinfo;
+       (void)devinfo;
 
        if (!(sigma = g_try_malloc(sizeof(struct sigma)))) {
                sr_err("sigma: %s: sigma malloc failed", __func__);
@@ -445,14 +445,15 @@ static int hw_init(const char *deviceinfo)
        sigma->use_triggers = 0;
 
        /* Register SIGMA device. */
-       sdi = sr_dev_inst_new(0, SR_ST_INITIALIZING,
-                       USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION);
-       if (!sdi)
+       if (!(sdi = sr_dev_inst_new(0, SR_ST_INITIALIZING, USB_VENDOR_NAME,
+                                   USB_MODEL_NAME, USB_MODEL_VERSION))) {
+               sr_err("sigma: %s: sdi was NULL", __func__);
                goto free;
+       }
 
        sdi->priv = sigma;
 
-       device_instances = g_slist_append(device_instances, sdi);
+       dev_insts = g_slist_append(dev_insts, sdi);
 
        /* We will open the device again when we need it. */
        ftdi_usb_close(&sigma->ftdic);
@@ -554,13 +555,13 @@ static int upload_firmware(int firmware_idx, struct sigma *sigma)
        return SR_OK;
 }
 
-static int hw_opendev(int device_index)
+static int hw_opendev(int dev_index)
 {
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
        struct sigma *sigma;
        int ret;
 
-       if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
+       if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
                return SR_ERR;
 
        sigma = sdi->priv;
@@ -580,8 +581,7 @@ static int hw_opendev(int device_index)
        return SR_OK;
 }
 
-static int set_samplerate(struct sr_device_instance *sdi,
-                         uint64_t samplerate)
+static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
 {
        int i, ret;
        struct sigma *sigma = sdi->priv;
@@ -624,7 +624,7 @@ static int set_samplerate(struct sr_device_instance *sdi,
  * The Sigma supports complex triggers using boolean expressions, but this
  * has not been implemented yet.
  */
-static int configure_probes(struct sr_device_instance *sdi, GSList *probes)
+static int configure_probes(struct sr_dev_inst *sdi, GSList *probes)
 {
        struct sigma *sigma = sdi->priv;
        struct sr_probe *probe;
@@ -698,12 +698,12 @@ static int configure_probes(struct sr_device_instance *sdi, GSList *probes)
        return SR_OK;
 }
 
-static int hw_closedev(int device_index)
+static int hw_closedev(int dev_index)
 {
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
        struct sigma *sigma;
 
-       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
                sr_err("sigma: %s: sdi was NULL", __func__);
                return SR_ERR; /* TODO: SR_ERR_ARG? */
        }
@@ -725,11 +725,11 @@ static int hw_closedev(int device_index)
 static int hw_cleanup(void)
 {
        GSList *l;
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
        int ret = SR_OK;
 
        /* Properly close all devices. */
-       for (l = device_instances; l; l = l->next) {
+       for (l = dev_insts; l; l = l->next) {
                if (!(sdi = l->data)) {
                        /* Log error, but continue cleaning up the rest. */
                        sr_err("sigma: %s: sdi was NULL, continuing", __func__);
@@ -738,27 +738,27 @@ static int hw_cleanup(void)
                }
                sr_dev_inst_free(sdi);
        }
-       g_slist_free(device_instances);
-       device_instances = NULL;
+       g_slist_free(dev_insts);
+       dev_insts = NULL;
 
        return ret;
 }
 
-static void *hw_get_device_info(int device_index, int device_info_id)
+static void *hw_dev_info_get(int dev_index, int dev_info_id)
 {
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
        struct sigma *sigma;
        void *info = NULL;
 
-       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
                sr_err("sigma: %s: sdi was NULL", __func__);
                return NULL;
        }
 
        sigma = sdi->priv;
 
-       switch (device_info_id) {
-       case SR_DI_INSTANCE:
+       switch (dev_info_id) {
+       case SR_DI_INST:
                info = sdi;
                break;
        case SR_DI_NUM_PROBES:
@@ -781,44 +781,44 @@ static void *hw_get_device_info(int device_index, int device_info_id)
        return info;
 }
 
-static int hw_get_status(int device_index)
+static int hw_get_status(int dev_index)
 {
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
 
-       sdi = sr_dev_inst_get(device_instances, device_index);
+       sdi = sr_dev_inst_get(dev_insts, dev_index);
        if (sdi)
                return sdi->status;
        else
                return SR_ST_NOT_FOUND;
 }
 
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
 {
-       return capabilities;
+       return hwcaps;
 }
 
-static int hw_set_configuration(int device_index, int capability, void *value)
+static int hw_config_set(int dev_index, int hwcap, void *value)
 {
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
        struct sigma *sigma;
        int ret;
 
-       if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
+       if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
                return SR_ERR;
 
        sigma = sdi->priv;
 
-       if (capability == SR_HWCAP_SAMPLERATE) {
+       if (hwcap == SR_HWCAP_SAMPLERATE) {
                ret = set_samplerate(sdi, *(uint64_t*) value);
-       } else if (capability == SR_HWCAP_PROBECONFIG) {
+       } else if (hwcap == SR_HWCAP_PROBECONFIG) {
                ret = configure_probes(sdi, value);
-       } else if (capability == SR_HWCAP_LIMIT_MSEC) {
+       } else if (hwcap == SR_HWCAP_LIMIT_MSEC) {
                sigma->limit_msec = *(uint64_t*) value;
                if (sigma->limit_msec > 0)
                        ret = SR_OK;
                else
                        ret = SR_ERR;
-       } else if (capability == SR_HWCAP_CAPTURE_RATIO) {
+       } else if (hwcap == SR_HWCAP_CAPTURE_RATIO) {
                sigma->capture_ratio = *(uint64_t*) value;
                if (sigma->capture_ratio < 0 || sigma->capture_ratio > 100)
                        ret = SR_ERR;
@@ -875,7 +875,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
                           uint16_t *lastsample, int triggerpos,
                           uint16_t limit_chunk, void *session_data)
 {
-       struct sr_device_instance *sdi = session_data;
+       struct sr_dev_inst *sdi = session_data;
        struct sigma *sigma = sdi->priv;
        uint16_t tsdiff, ts;
        uint16_t samples[65536 * sigma->samples_per_event];
@@ -1006,7 +1006,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
 
 static int receive_data(int fd, int revents, void *session_data)
 {
-       struct sr_device_instance *sdi = session_data;
+       struct sr_dev_inst *sdi = session_data;
        struct sigma *sigma = sdi->priv;
        struct sr_datafeed_packet packet;
        const int chunks_per_read = 32;
@@ -1252,9 +1252,9 @@ static int build_basic_trigger(struct triggerlut *lut, struct sigma *sigma)
        return SR_OK;
 }
 
-static int hw_start_acquisition(int device_index, gpointer session_data)
+static int hw_start_acquisition(int dev_index, gpointer session_data)
 {
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
        struct sigma *sigma;
        struct sr_datafeed_packet packet;
        struct sr_datafeed_header header;
@@ -1267,7 +1267,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data)
        /* Avoid compiler warnings. */
        (void)session_data;
 
-       if (!(sdi = sr_dev_inst_get(device_instances, device_index)))
+       if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
                return SR_ERR;
 
        sigma = sdi->priv;
@@ -1369,16 +1369,16 @@ static int hw_start_acquisition(int device_index, gpointer session_data)
        return SR_OK;
 }
 
-static int hw_stop_acquisition(int device_index, gpointer session_data)
+static int hw_stop_acquisition(int dev_index, gpointer session_data)
 {
-       struct sr_device_instance *sdi;
+       struct sr_dev_inst *sdi;
        struct sigma *sigma;
        uint8_t modestatus;
 
        /* Avoid compiler warnings. */
        (void)session_data;
 
-       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
                sr_err("sigma: %s: sdi was NULL", __func__);
                return SR_ERR_BUG;
        }
@@ -1411,7 +1411,7 @@ static int hw_stop_acquisition(int device_index, gpointer session_data)
        return SR_OK;
 }
 
-SR_PRIV struct sr_device_plugin asix_sigma_plugin_info = {
+SR_PRIV struct sr_dev_plugin asix_sigma_plugin_info = {
        .name = "asix-sigma",
        .longname = "ASIX SIGMA",
        .api_version = 1,
@@ -1419,10 +1419,10 @@ SR_PRIV struct sr_device_plugin asix_sigma_plugin_info = {
        .cleanup = hw_cleanup,
        .opendev = hw_opendev,
        .closedev = hw_closedev,
-       .get_device_info = hw_get_device_info,
+       .dev_info_get = hw_dev_info_get,
        .get_status = hw_get_status,
-       .get_capabilities = hw_get_capabilities,
-       .set_configuration = hw_set_configuration,
+       .hwcap_get_all = hw_hwcap_get_all,
+       .config_set = hw_config_set,
        .start_acquisition = hw_start_acquisition,
        .stop_acquisition = hw_stop_acquisition,
 };