]> sigrok.org Git - libsigrok.git/commitdiff
ols: introduce metadata quirks support, unbreak Logic Shrimp
authorGerhard Sittig <redacted>
Sat, 5 Oct 2019 11:45:49 +0000 (13:45 +0200)
committerUwe Hermann <redacted>
Thu, 7 Nov 2019 22:16:06 +0000 (23:16 +0100)
Introduce quirks support for devices which provide incomplete metadata.
Add conservative logic to unbreak the Logic Shrimp. Amend previously
received information when it was incomplete, but don't interfere if a
future firmware version fixes the issue.

Without this change, the device gets detected but "has zero channels"
and would be unusable. Because when a device provides metadata, these
details are used exclusively, no fallbacks apply.

src/hardware/openbench-logic-sniffer/protocol.c

index b9383ddd1e440d50b582980163d926fb9f9f3035..e6adae0ac42dd68360bec7d6767143b3e11886aa 100644 (file)
@@ -158,6 +158,28 @@ static void ols_channel_new(struct sr_dev_inst *sdi, int num_chan)
        devc->max_channels = num_chan;
 }
 
+static void metadata_quirks(struct sr_dev_inst *sdi)
+{
+       struct dev_context *devc;
+       gboolean is_shrimp;
+
+       if (!sdi)
+               return;
+       devc = sdi->priv;
+       if (!devc)
+               return;
+
+       is_shrimp = sdi->model && strcmp(sdi->model, "Shrimp1.0") == 0;
+       if (is_shrimp) {
+               if (!devc->max_channels)
+                       ols_channel_new(sdi, 4);
+               if (!devc->max_samples)
+                       devc->max_samples = 256 * 1024;
+               if (!devc->max_samplerate)
+                       devc->max_samplerate = SR_MHZ(20);
+       }
+}
+
 SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
 {
        struct sr_dev_inst *sdi;
@@ -290,6 +312,9 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
        g_string_free(devname, FALSE);
        g_string_free(version, FALSE);
 
+       /* Optionally amend received metadata, model specific quirks. */
+       metadata_quirks(sdi);
+
        return sdi;
 }