+static int config_probe_set(const struct sr_dev_inst *sdi,
+ struct sr_channel *ch, unsigned int changes)
+{
+ uint64_t channel_bit;
+ uint64_t trigger_mask;
+ uint64_t trigger_values;
+ uint64_t trigger_edge_mask;
+ struct dev_context *devc;
+
+ devc = sdi->priv;
+ if (!devc)
+ return SR_ERR_DEV_CLOSED;
+
+ if (ch->index < 0 || ch->index >= NUM_PROBES) {
+ sr_err("Channel index %d out of range.", ch->index);
+ return SR_ERR_BUG;
+ }
+ channel_bit = (uint64_t)1 << ch->index;
+
+ if ((changes & SR_PROBE_SET_ENABLED) != 0) {
+ /* Enable or disable input channel for this channel. */
+ if (ch->enabled)
+ devc->channel_mask |= channel_bit;
+ else
+ devc->channel_mask &= ~channel_bit;
+ }
+
+ if ((changes & SR_PROBE_SET_TRIGGER) != 0) {
+ trigger_mask = devc->trigger_mask & ~channel_bit;
+ trigger_values = devc->trigger_values & ~channel_bit;
+ trigger_edge_mask = devc->trigger_edge_mask & ~channel_bit;
+
+ if (ch->trigger && ch->trigger[0] != '\0') {
+ if (ch->trigger[1] != '\0') {
+ sr_warn("Trigger configuration \"%s\" with "
+ "multiple stages is not supported.",
+ ch->trigger);
+ return SR_ERR_ARG;
+ }
+ /* Enable trigger for this channel. */
+ trigger_mask |= channel_bit;
+
+ /* Configure edge mask and trigger value. */
+ switch (ch->trigger[0]) {
+ case '1': trigger_values |= channel_bit;
+ case '0': break;
+
+ case 'r': trigger_values |= channel_bit;
+ case 'f': trigger_edge_mask |= channel_bit;
+ break;
+ default:
+ sr_warn("Trigger type '%c' is not supported.",
+ ch->trigger[0]);
+ return SR_ERR_ARG;
+ }
+ }
+ /* Store validated trigger setup. */
+ devc->trigger_mask = trigger_mask;
+ devc->trigger_values = trigger_values;
+ devc->trigger_edge_mask = trigger_edge_mask;
+ }
+
+ return SR_OK;
+}
+
+static int config_commit(const struct sr_dev_inst *sdi)
+{
+ if (sdi->status != SR_ST_ACTIVE) {
+ sr_err("Device not ready (status %d).", (int)sdi->status);
+ return SR_ERR;
+ }
+
+ return lwla_set_clock_config(sdi);
+}
+