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.
This commit is contained in:
Gerhard Sittig 2019-10-05 13:45:49 +02:00 committed by Uwe Hermann
parent cfdc80151b
commit ad4174c1d8
1 changed files with 25 additions and 0 deletions

View 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;
}