+SR_PRIV int hmo_update_sample_rate(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc;
+ struct scope_state *state;
+ struct scope_config *config;
+
+ int tmp;
+ unsigned int i;
+ float tmp_float;
+ gboolean channel_found;
+ char tmp_str[MAX_COMMAND_SIZE];
+ char chan_name[20];
+
+ devc = sdi->priv;
+ config = devc->model_config;
+ state = devc->model_state;
+ channel_found = FALSE;
+
+ for (i = 0; i < config->analog_channels; ++i) {
+ if (state->analog_channels[i].state) {
+ g_snprintf(chan_name, sizeof(chan_name), "CHAN%d", i + 1);
+ g_snprintf(tmp_str, sizeof(tmp_str),
+ (*config->scpi_dialect)[SCPI_CMD_GET_SAMPLE_RATE_LIVE],
+ chan_name);
+ channel_found = TRUE;
+ break;
+ }
+ }
+
+ if (!channel_found) {
+ for (i = 0; i < config->digital_pods; i++) {
+ if (state->digital_pods[i]) {
+ g_snprintf(chan_name, sizeof(chan_name), "POD%d", i);
+ g_snprintf(tmp_str, sizeof(tmp_str),
+ (*config->scpi_dialect)[SCPI_CMD_GET_SAMPLE_RATE_LIVE],
+ chan_name);
+ channel_found = TRUE;
+ break;
+ }
+ }
+ }
+
+ /* No channel is active, ask the instrument for the sample rate
+ * in single shot mode */
+ if (!channel_found) {
+ if (sr_scpi_get_float(sdi->conn,
+ (*config->scpi_dialect)[SCPI_CMD_GET_SAMPLE_RATE],
+ &tmp_float) != SR_OK)
+ return SR_ERR;
+
+ state->sample_rate = tmp_float;
+ } else {
+ if (sr_scpi_get_int(sdi->conn, tmp_str, &tmp) != SR_OK)
+ return SR_ERR;
+ state->sample_rate = tmp / (((float) (*config->timebases)[state->timebase][0] /
+ (*config->timebases)[state->timebase][1]) *
+ config->num_xdivs);
+ }
+
+ return SR_OK;
+}
+
+SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi)