]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/rigol-ds/api.c
drivers: Replace struct voltage_threshold with an array.
[libsigrok.git] / src / hardware / rigol-ds / api.c
index dd535eda5deee159ed8d689601c6ce51a2d0c488..bdbdbc0e7e75e840a97e314ebbd7b438cf5433f9 100644 (file)
@@ -127,52 +127,22 @@ static const uint64_t vdivs[][2] = {
 };
 
 static const char *trigger_sources[] = {
-       "CH1",
-       "CH2",
-       "CH3",
-       "CH4",
-       "EXT",
-       "AC Line",
-       "D0",
-       "D1",
-       "D2",
-       "D3",
-       "D4",
-       "D5",
-       "D6",
-       "D7",
-       "D8",
-       "D9",
-       "D10",
-       "D11",
-       "D12",
-       "D13",
-       "D14",
-       "D15",
+       "CH1", "CH2", "CH3", "CH4",
+       "EXT", "AC Line",
+       "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+       "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15",
 };
 
 static const char *trigger_slopes[] = {
-       "r",
-       "f",
+       "r", "f",
 };
 
 static const char *coupling[] = {
-       "AC",
-       "DC",
-       "GND",
+       "AC", "DC", "GND",
 };
 
 static const uint64_t probe_factor[] = {
-       1,
-       2,
-       5,
-       10,
-       20,
-       50,
-       100,
-       200,
-       500,
-       1000,
+       1, 2, 5, 10, 20, 50, 100, 200, 500, 1000,
 };
 
 /* Do not change the order of entries */
@@ -203,8 +173,8 @@ static const struct rigol_ds_vendor supported_vendors[] = {
 };
 
 #define VENDOR(x) &supported_vendors[x]
-/* vendor, series, protocol, max timebase, min vdiv, number of horizontal divs,
- * live waveform samples, memory buffer samples */
+/* vendor, series/name, protocol, data format, max timebase, min vdiv,
+ * number of horizontal divs, live waveform samples, memory buffer samples */
 static const struct rigol_ds_series supported_series[] = {
        [VS5000] = {VENDOR(RIGOL), "VS5000", PROTOCOL_V1, FORMAT_RAW,
                {50, 1}, {2, 1000}, 14, 2048, 0},
@@ -499,8 +469,8 @@ static int digital_frame_size(const struct sr_dev_inst *sdi)
        }
 }
 
-static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_get(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
        struct sr_channel *ch;
@@ -643,8 +613,8 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
        return SR_OK;
 }
 
-static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_set(uint32_t key, GVariant *data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
        uint64_t p, q;
@@ -744,10 +714,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                }
                break;
        case SR_CONF_VDIV:
-               if (!cg) {
-                       sr_err("No channel group specified.");
+               if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
-               }
                g_variant_get(data, "(tt)", &p, &q);
                for (i = 0; i < devc->model->analog_channels; i++) {
                        if (cg == devc->analog_groups[i]) {
@@ -767,10 +735,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                sr_dbg("Didn't set vdiv, unknown channel(group).");
                return SR_ERR_NA;
        case SR_CONF_COUPLING:
-               if (!cg) {
-                       sr_err("No channel group specified.");
+               if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
-               }
                tmp_str = g_variant_get_string(data, NULL);
                for (i = 0; i < devc->model->analog_channels; i++) {
                        if (cg == devc->analog_groups[i]) {
@@ -789,10 +755,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                sr_dbg("Didn't set coupling, unknown channel(group).");
                return SR_ERR_NA;
        case SR_CONF_PROBE_FACTOR:
-               if (!cg) {
-                       sr_err("No channel group specified.");
+               if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
-               }
                p = g_variant_get_uint64(data);
                for (i = 0; i < devc->model->analog_channels; i++) {
                        if (cg == devc->analog_groups[i]) {
@@ -834,8 +798,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        return ret;
 }
 
-static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_list(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        unsigned int i;
        struct dev_context *devc;
@@ -876,7 +840,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        return SR_ERR_ARG;
                if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
-               *data = std_gvar_tuple_array((const uint64_t (*)[][2])devc->vdivs, devc->num_vdivs);
+               *data = std_gvar_tuple_array(devc->vdivs, devc->num_vdivs);
                break;
        case SR_CONF_TIMEBASE:
                if (!devc)
@@ -884,7 +848,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        return SR_ERR_ARG;
                if (devc->num_timebases <= 0)
                        return SR_ERR_NA;
-               *data = std_gvar_tuple_array((const uint64_t (*)[][2])devc->timebases, devc->num_timebases);
+               *data = std_gvar_tuple_array(devc->timebases, devc->num_timebases);
                break;
        case SR_CONF_TRIGGER_SOURCE:
                if (!devc)