- if (des.idVendor == USB_VENDOR) {
- /*
- * Definitely a Zeroplus.
- * TODO: Any way to detect specific model/version in
- * the zeroplus range?
- */
- sdi = sigrok_device_instance_new(devcnt,
- ST_INACTIVE, USB_VENDOR_NAME,
- USB_MODEL_NAME, USB_MODEL_VERSION);
- if (!sdi)
- return 0;
- device_instances =
- g_slist_append(device_instances, sdi);
- sdi->usb = usb_device_instance_new(
- libusb_get_bus_number(devlist[i]),
- libusb_get_device_address(devlist[i]), NULL);
- devcnt++;
+ prof = NULL;
+ for (j = 0; j < zeroplus_models[j].vid; j++) {
+ if (des.idVendor == zeroplus_models[j].vid &&
+ des.idProduct == zeroplus_models[j].pid) {
+ prof = &zeroplus_models[j];
+ }
+ }
+ /* Skip if the device was not found */
+ if (!prof)
+ continue;
+ sr_info("zp: Found ZEROPLUS model %s", prof->model_name);
+
+ /* Register the device with libsigrok. */
+ if (!(sdi = sr_dev_inst_new(devcnt, SR_ST_INACTIVE,
+ VENDOR_NAME, prof->model_name, NULL))) {
+ sr_err("zp: %s: sr_dev_inst_new failed", __func__);
+ return NULL;
+ }
+ sdi->driver = zdi;
+
+ /* Allocate memory for our private driver context. */
+ if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
+ sr_err("zp: %s: devc malloc failed", __func__);
+ return NULL;
+ }
+ sdi->priv = devc;
+ devc->num_channels = prof->channels;
+#ifdef ZP_EXPERIMENTAL
+ devc->max_memory_size = 128 * 1024;
+ devc->max_samplerate = 200;
+#else
+ devc->max_memory_size = prof->sample_depth * 1024;
+ devc->max_samplerate = prof->max_sampling_freq;
+#endif
+ devc->max_samplerate *= SR_MHZ(1);
+ devc->memory_size = MEMORY_SIZE_8K;
+ // memset(devc->trigger_buffer, 0, NUM_TRIGGER_STAGES);
+
+ /* Fill in probelist according to this device's profile. */
+ for (j = 0; j < devc->num_channels; j++) {
+ if (!(probe = sr_probe_new(j, SR_PROBE_LOGIC, TRUE,
+ probe_names[j])))
+ return NULL;
+ sdi->probes = g_slist_append(sdi->probes, probe);