- if (devc->cur_clock_source != selected) {
- devc->cur_clock_source = CLOCK_SOURCE_NONE;
- idx = selected;
- if (idx >= G_N_ELEMENTS(bitstream_map)) {
- sr_err("Clock source (%d) out of range", selected);
- return SR_ERR_BUG;
- }
- ret = lwla_send_bitstream(sdi->conn, bitstream_map[idx]);
+ if (sdi->status == SR_ST_INACTIVE)
+ choice = CONF_CLOCK_NONE;
+ else if (devc->cfg_clock_source == CLOCK_INTERNAL)
+ choice = CONF_CLOCK_INT;
+ else if (devc->cfg_clock_edge == EDGE_POSITIVE)
+ choice = CONF_CLOCK_EXT_RISE;
+ else
+ choice = CONF_CLOCK_EXT_FALL;
+
+ if (choice != devc->cur_clock_config) {
+ devc->cur_clock_config = CONF_CLOCK_NONE;
+ ret = lwla_send_bitstream(sdi->conn, bitstream_map[choice]);