- /*
- * Set up the probe mask for later configuration into the
- * flag register.
- */
- probe_bit = 1 << (probe->index);
- devc->probe_mask |= probe_bit;
-
- if (!probe->trigger)
- continue;
-
- /* Configure trigger mask and value. */
- stage = 0;
- for (tc = probe->trigger; tc && *tc; tc++) {
- devc->trigger_mask[stage] |= probe_bit;
- if (*tc == '1')
- devc->trigger_value[stage] |= probe_bit;
- stage++;
- if (stage > 3)
- /*
- * TODO: Only supporting parallel mode, with
- * up to 4 stages.
- */
- return SR_ERR;
+ devc->num_stages = g_slist_length(trigger->stages);
+ if (devc->num_stages > NUM_TRIGGER_STAGES) {
+ sr_err("This device only supports %d trigger stages.",
+ NUM_TRIGGER_STAGES);
+ return SR_ERR;
+ }
+
+ for (l = trigger->stages; l; l = l->next) {
+ stage = l->data;
+ for (m = stage->matches; m; m = m->next) {
+ match = m->data;
+ if (!match->channel->enabled)
+ /* Ignore disabled channels with a trigger. */
+ continue;
+ devc->trigger_mask[stage->stage] |= 1 << match->channel->index;
+ if (match->match == SR_TRIGGER_ONE)
+ devc->trigger_value[stage->stage] |= 1 << match->channel->index;