The Asix Sigma driver is aware of three firmware images, which are
required for acquisition with up to 50MHz, 100MHz, and 200MHz. The
previous implementation always downloaded the corresponding firmware
image whenever the sample rate has changed, which was redundant.
Skip the download when the new samplerate uses the same firmware as the
previously selected samplerate did. This results in faster responses in
the GUI when the samplerate selection changes.
Move assignments out of the variable declaration block for improved
readability while we are here.
unsigned char *buf;
unsigned char pins;
size_t buf_size;
- const char *firmware = sigma_firmware_files[firmware_idx];
- struct ftdi_context *ftdic = &devc->ftdic;
+ const char *firmware;
+ struct ftdi_context *ftdic;
+
+ /* Avoid downloading the same firmware multiple times. */
+ firmware = sigma_firmware_files[firmware_idx];
+ if (devc->cur_firmware == firmware_idx) {
+ sr_info("Not uploading firmware file '%s' again.", firmware);
+ return SR_OK;
+ }
/* Make sure it's an ASIX SIGMA. */
+ ftdic = &devc->ftdic;
ret = ftdi_usb_open_desc(ftdic, USB_VENDOR, USB_PRODUCT,
USB_DESCRIPTION, NULL);
if (ret < 0) {