]> sigrok.org Git - libsigrok.git/commitdiff
hantek-dso: move buffer sizes to device context
authorBert Vermeulen <redacted>
Tue, 2 Apr 2013 18:54:44 +0000 (20:54 +0200)
committerBert Vermeulen <redacted>
Thu, 11 Apr 2013 16:32:08 +0000 (18:32 +0200)
There are only two sizes for every device: 10k and the complete
per-channel buffer size. This can be doubled if one channel is disabled.

hardware/hantek-dso/api.c
hardware/hantek-dso/dso.c
hardware/hantek-dso/dso.h

index 27f37e7f44ecc0ab29d72854f6f411c1c9c7c533..dc0332eb2701d10c36cb59836ac2c54975bba3ef 100644 (file)
@@ -56,29 +56,38 @@ static const char *probe_names[] = {
        NULL,
 };
 
+static const uint64_t buffersizes_32k[] = {
+       10240, 32768,
+};
+static const uint64_t buffersizes_512k[] = {
+       10240, 524288,
+};
+static const uint64_t buffersizes_14k[] = {
+       10240, 14336,
+};
+
 static const struct dso_profile dev_profiles[] = {
        {       0x04b4, 0x2090, 0x04b5, 0x2090,
                "Hantek", "DSO-2090",
+               buffersizes_32k,
                FIRMWARE_DIR "/hantek-dso-2090.fw" },
        {       0x04b4, 0x2150, 0x04b5, 0x2150,
                "Hantek", "DSO-2150",
+               buffersizes_32k,
                FIRMWARE_DIR "/hantek-dso-2150.fw" },
        {       0x04b4, 0x2250, 0x04b5, 0x2250,
                "Hantek", "DSO-2250",
+               buffersizes_512k,
                FIRMWARE_DIR "/hantek-dso-2250.fw" },
        {       0x04b4, 0x5200, 0x04b5, 0x5200,
                "Hantek", "DSO-5200",
+               buffersizes_14k,
                FIRMWARE_DIR "/hantek-dso-5200.fw" },
        {       0x04b4, 0x520a, 0x04b5, 0x520a,
                "Hantek", "DSO-5200A",
+               buffersizes_512k,
                FIRMWARE_DIR "/hantek-dso-5200A.fw" },
-       { 0, 0, 0, 0, 0, 0, 0 },
-};
-
-static const uint64_t buffersizes[] = {
-       10240,
-       32768,
-       /* TODO: 65535 */
+       { 0, 0, 0, 0, 0, 0, 0, 0 },
 };
 
 static const uint64_t timebases[][2] = {
@@ -437,13 +446,13 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
                break;
        case SR_CONF_BUFFERSIZE:
                tmp_u64 = g_variant_get_uint64(data);
-               for (i = 0; buffersizes[i]; i++) {
-                       if (buffersizes[i] == tmp_u64) {
+               for (i = 0; i < 2; i++) {
+                       if (devc->profile->buffersizes[i] == tmp_u64) {
                                devc->framesize = tmp_u64;
                                break;
                        }
                }
-               if (buffersizes[i] == 0)
+               if (i == 2)
                        ret = SR_ERR_ARG;
                break;
        case SR_CONF_TIMEBASE:
@@ -531,9 +540,14 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
 
 static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
 {
+       struct dev_context *devc;
 
        (void)sdi;
 
+       if (!sdi)
+               return SR_ERR_ARG;
+
+       devc = sdi->priv;
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
@@ -541,7 +555,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
                break;
        case SR_CONF_BUFFERSIZE:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
-                               buffersizes, ARRAY_SIZE(buffersizes), sizeof(uint64_t));
+                               devc->profile->buffersizes, 2, sizeof(uint64_t));
                break;
        case SR_CONF_COUPLING:
                *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling));
index 66d6978f24bbd3d720d8796bc8315c7cfafd1b6a..3fd99593e1a1a6f349ea85c15f2fe3484b5d79ea 100644 (file)
@@ -280,8 +280,7 @@ SR_PRIV int dso_set_trigger_samplerate(struct dev_context *devc)
 
        /* Timebase fast */
        sr_dbg("Time base index: %d.", devc->timebase);
-       switch (devc->framesize) {
-       case FRAMESIZE_SMALL:
+       if (devc->framesize == FRAMESIZE_SMALL) {
                if (devc->timebase < TIME_20us)
                        tmp = 0;
                else if (devc->timebase == TIME_20us)
@@ -292,8 +291,7 @@ SR_PRIV int dso_set_trigger_samplerate(struct dev_context *devc)
                        tmp = 3;
                else if (devc->timebase >= TIME_200us)
                        tmp = 4;
-               break;
-       case FRAMESIZE_LARGE:
+       } else {
                if (devc->timebase < TIME_40us) {
                        sr_err("Timebase < 40us only supported with 10K buffer.");
                        return SR_ERR_ARG;
@@ -306,7 +304,6 @@ SR_PRIV int dso_set_trigger_samplerate(struct dev_context *devc)
                        tmp = 3;
                else if (devc->timebase >= TIME_400us)
                        tmp = 4;
-               break;
        }
        cmdstring[2] |= (tmp & 0x07) << 5;
 
index 8d543b62921d36608d1ec4602471a269429def8b..b4f563464fda352a8b57fc3f976e50596c4308d4 100644 (file)
@@ -55,8 +55,8 @@
 /* Hantek DSO-specific protocol values */
 #define EEPROM_CHANNEL_OFFSETS  0x08
 
+/* All models have this for their "fast" mode. */
 #define FRAMESIZE_SMALL         10240
-#define FRAMESIZE_LARGE         32768
 
 enum control_requests {
        CTRL_READ_EEPROM = 0xa2,
@@ -163,6 +163,7 @@ struct dso_profile {
        uint16_t fw_pid;
        char *vendor;
        char *model;
+       const uint64_t *buffersizes;
        char *firmware;
 };