From: Gerhard Sittig Date: Sat, 5 Oct 2019 11:45:49 +0000 (+0200) Subject: ols: introduce metadata quirks support, unbreak Logic Shrimp X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ad4174c1d8b0a282e56322b81213e80caccf4081;p=libsigrok.git ols: introduce metadata quirks support, unbreak Logic Shrimp 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. --- diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index b9383ddd..e6adae0a 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -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; }