+ drvc = di->priv;
+ devc = sdi->priv;
+ usb = sdi->conn;
+
+ devc->cb_data = cb_data;
+ devc->num_samples = 0;
+ devc->packet_len = 0;
+
+ /* Configure serial port parameters on USB-UART interface
+ * chip inside the device (just baudrate 2400 actually). */
+ cmd[0] = 0x09;
+ cmd[1] = 0x60;
+ ret = libusb_control_transfer(usb->devhdl, 0x21, 0x09, 0x0300, 0x00,
+ cmd, 2, 5);
+ if (ret != 2) {
+ sr_dbg("Failed to configure CH9325: %s", libusb_error_name(ret));
+ return SR_ERR;
+ }
+
+ /* Send header packet to the session bus. */
+ std_session_send_df_header(cb_data, LOG_PREFIX);
+
+ if (!(devc->xfer = libusb_alloc_transfer(0)))
+ return SR_ERR;
+
+ /* Length of payload to follow. */
+ cmd[0] = 0x01;
+ if (devc->data_source == DATA_SOURCE_LIVE)
+ cmd[1] = CMD_GET_LIVE;
+ else
+ cmd[1] = CMD_GET_STORED;
+
+ ret = libusb_bulk_transfer(usb->devhdl, EP_OUT, cmd, 2, &len, 5);
+ if (ret != 0 || len != 2) {
+ sr_dbg("Failed to start acquisition: %s", libusb_error_name(ret));
+ libusb_free_transfer(devc->xfer);
+ return SR_ERR;
+ }
+
+ libusb_fill_bulk_transfer(devc->xfer, usb->devhdl, EP_IN, devc->buf,
+ 8, uni_t_ut32x_receive_transfer, (void *)sdi, 15);
+ if (libusb_submit_transfer(devc->xfer) != 0) {
+ libusb_free_transfer(devc->xfer);
+ return SR_ERR;
+ }
+
+ usb_source_add(drvc->sr_ctx, 10, uni_t_ut32x_handle_events, (void *)sdi);