+ return SR_ERR_SAMPLERATE;
+
+ if (samplerate <= SR_MHZ(50)) {
+ ret = upload_firmware(0, ctx);
+ ctx->num_probes = 16;
+ }
+ if (samplerate == SR_MHZ(100)) {
+ ret = upload_firmware(1, ctx);
+ ctx->num_probes = 8;
+ }
+ else if (samplerate == SR_MHZ(200)) {
+ ret = upload_firmware(2, ctx);
+ ctx->num_probes = 4;
+ }
+
+ ctx->cur_samplerate = samplerate;
+ ctx->period_ps = 1000000000000 / samplerate;
+ ctx->samples_per_event = 16 / ctx->num_probes;
+ ctx->state.state = SIGMA_IDLE;
+
+ sr_info("sigma: Firmware uploaded");
+
+ return ret;
+}
+
+/*
+ * In 100 and 200 MHz mode, only a single pin rising/falling can be
+ * set as trigger. In other modes, two rising/falling triggers can be set,
+ * in addition to value/mask trigger for any number of probes.
+ *
+ * The Sigma supports complex triggers using boolean expressions, but this
+ * has not been implemented yet.
+ */
+static int configure_probes(struct sr_dev_inst *sdi, GSList *probes)
+{
+ struct context *ctx = sdi->priv;
+ struct sr_probe *probe;
+ GSList *l;
+ int trigger_set = 0;
+ int probebit;
+
+ memset(&ctx->trigger, 0, sizeof(struct sigma_trigger));
+
+ for (l = probes; l; l = l->next) {
+ probe = (struct sr_probe *)l->data;
+ probebit = 1 << (probe->index - 1);
+
+ if (!probe->enabled || !probe->trigger)
+ continue;
+
+ if (ctx->cur_samplerate >= SR_MHZ(100)) {
+ /* Fast trigger support. */
+ if (trigger_set) {
+ sr_err("sigma: ASIX SIGMA only supports a single "
+ "pin trigger in 100 and 200MHz mode.");
+ return SR_ERR;
+ }
+ if (probe->trigger[0] == 'f')
+ ctx->trigger.fallingmask |= probebit;
+ else if (probe->trigger[0] == 'r')
+ ctx->trigger.risingmask |= probebit;
+ else {
+ sr_err("sigma: ASIX SIGMA only supports "
+ "rising/falling trigger in 100 "
+ "and 200MHz mode.");
+ return SR_ERR;
+ }