X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fopenbench-logic-sniffer%2Fols.c;h=6f914a8c8991851dac884897d025fb3de3b773fe;hb=c073af80f89d8bce8675068d084c96e0cf37bb4f;hp=5a73cfc7a7974c445a496788e44ac097fb045993;hpb=26bf9d56c079889cd493376b341ab75acee795f7;p=libsigrok.git diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 5a73cfc7..6f914a8c 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -131,13 +131,16 @@ static int send_longcommand(int fd, uint8_t command, uint32_t data) return SR_OK; } -static int configure_probes(struct dev_context *devc, const GSList *probes) +static int configure_probes(const struct sr_dev_inst *sdi) { + struct dev_context *devc; const struct sr_probe *probe; const GSList *l; int probe_bit, stage, i; char *tc; + devc = sdi->priv; + devc->probe_mask = 0; for (i = 0; i < NUM_TRIGGER_STAGES; i++) { devc->trigger_mask[i] = 0; @@ -145,7 +148,7 @@ static int configure_probes(struct dev_context *devc, const GSList *probes) } devc->num_stages = 0; - for (l = probes; l; l = l->next) { + for (l = sdi->probes; l; l = l->next) { probe = (const struct sr_probe *)l->data; if (!probe->enabled) continue; @@ -366,7 +369,7 @@ static int hw_init(void) if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) { sr_err("ols: driver context malloc failed."); - return SR_ERR; + return SR_ERR_MALLOC; } odi->priv = drvc; @@ -516,6 +519,15 @@ hw_init_free_ports: return devices; } +static GSList *hw_dev_list(void) +{ + struct drv_context *drvc; + + drvc = odi->priv; + + return drvc->instances; +} + static int hw_dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -667,9 +679,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, case SR_HWCAP_SAMPLERATE: ret = set_samplerate(sdi, *(const uint64_t *)value); break; - case SR_HWCAP_PROBECONFIG: - ret = configure_probes(devc, (const GSList *)value); - break; case SR_HWCAP_LIMIT_SAMPLES: tmp_u64 = value; if (*tmp_u64 < MIN_NUM_SAMPLES) @@ -754,6 +763,7 @@ static int receive_data(int fd, int revents, void *cb_data) */ sr_source_remove(fd); sr_source_add(fd, G_IO_IN, 30, receive_data, cb_data); + /* TODO: Check malloc return code. */ devc->raw_sample_buf = g_try_malloc(devc->limit_samples * 4); if (!devc->raw_sample_buf) { sr_err("ols: %s: devc->raw_sample_buf malloc failed", @@ -920,6 +930,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, if (sdi->status != SR_ST_ACTIVE) return SR_ERR; + if (configure_probes(sdi) != SR_OK) { + sr_err("ols: failed to configured probes"); + return SR_ERR; + } + /* * Enable/disable channel groups in the flag register according to the * probe mask. Calculate this here, because num_channels is needed @@ -1058,10 +1073,8 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, } /* TODO: This stops acquisition on ALL devices, ignoring dev_index. */ -static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi, - void *cb_data) +static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) { - /* Avoid compiler warnings. */ (void)cb_data; @@ -1077,6 +1090,8 @@ SR_PRIV struct sr_dev_driver ols_driver_info = { .init = hw_init, .cleanup = hw_cleanup, .scan = hw_scan, + .dev_list = hw_dev_list, + .dev_clear = hw_cleanup, .dev_open = hw_dev_open, .dev_close = hw_dev_close, .info_get = hw_info_get,