SR_CONF_CAPTURE_RATIO,
};
-SR_PRIV const uint64_t ikalogic_scanalogic2_samplerates[NUM_SAMPLERATES] = {
+SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = {
SR_KHZ(1.25),
SR_KHZ(10),
SR_KHZ(50),
for (l = usb_devices; l; l = l->next) {
usb = l->data;
- ret = ikalogic_scanalogic2_get_device_info(*usb, &dev_info);
- if (ret != SR_OK) {
- sr_warn("Failed to get device information.");
+ if ((ret = sl2_get_device_info(*usb, &dev_info)) < 0) {
+ sr_warn("Failed to get device information: %d.", ret);
sr_usb_dev_inst_free(usb);
continue;
}
devc->next_state = STATE_IDLE;
/* Set default samplerate. */
- ikalogic_scanalogic2_set_samplerate(sdi, DEFAULT_SAMPLERATE);
+ sl2_set_samplerate(sdi, DEFAULT_SAMPLERATE);
/* Set default capture ratio. */
devc->capture_ratio = 0;
}
}
- ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
- if (ret) {
+ if ((ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE)) < 0) {
sr_err("Failed to claim interface: %s.",
libusb_error_name(ret));
return SR_ERR;
}
libusb_fill_control_transfer(devc->xfer_in, usb->devhdl,
- devc->xfer_buf_in, ikalogic_scanalogic2_receive_transfer_in,
+ devc->xfer_buf_in, sl2_receive_transfer_in,
sdi, USB_TIMEOUT);
libusb_fill_control_transfer(devc->xfer_out, usb->devhdl,
- devc->xfer_buf_out, ikalogic_scanalogic2_receive_transfer_out,
+ devc->xfer_buf_out, sl2_receive_transfer_out,
sdi, USB_TIMEOUT);
memset(buffer, 0, sizeof(buffer));
buffer[0] = CMD_RESET;
- ret = ikalogic_scanalogic2_transfer_out(usb->devhdl, buffer);
- if (ret != PACKET_LENGTH) {
+ if ((ret = sl2_transfer_out(usb->devhdl, buffer)) != PACKET_LENGTH) {
sr_err("Device reset failed: %s.", libusb_error_name(ret));
return SR_ERR;
}
* and thereby close the connection.
*/
buffer[0] = CMD_IDLE;
- ret = ikalogic_scanalogic2_transfer_out(usb->devhdl, buffer);
- if (ret != PACKET_LENGTH) {
+ if ((ret = sl2_transfer_out(usb->devhdl, buffer)) != PACKET_LENGTH) {
sr_err("Failed to set device in idle state: %s.",
libusb_error_name(ret));
return SR_ERR;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
limit_samples = g_variant_get_uint64(data);
- ret = ikalogic_scanalogic2_set_limit_samples(sdi,
- limit_samples);
+ ret = sl2_set_limit_samples(sdi, limit_samples);
break;
case SR_CONF_SAMPLERATE:
samplerate = g_variant_get_uint64(data);
- ret = ikalogic_scanalogic2_set_samplerate(sdi, samplerate);
+ ret = sl2_set_samplerate(sdi, samplerate);
break;
case SR_CONF_CAPTURE_RATIO:
capture_ratio = g_variant_get_uint64(data);
- ret = ikalogic_scanalogic2_set_capture_ratio(sdi,
- capture_ratio);
+ ret = sl2_set_capture_ratio(sdi, capture_ratio);
break;
default:
return SR_ERR_NA;
case SR_CONF_SAMPLERATE:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
- ikalogic_scanalogic2_samplerates,
- ARRAY_SIZE(ikalogic_scanalogic2_samplerates),
+ sl2_samplerates, ARRAY_SIZE(sl2_samplerates),
sizeof(uint64_t));
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
*data = g_variant_builder_end(&gvb);
* The trigger must be configured first because the calculation of the
* pre and post trigger samples depends on a configured trigger.
*/
- ikalogic_scanalogic2_configure_trigger(sdi);
- ikalogic_scanalogic2_calculate_trigger_samples(sdi);
+ sl2_configure_trigger(sdi);
+ sl2_calculate_trigger_samples(sdi);
trigger_bytes = devc->pre_trigger_bytes + devc->post_trigger_bytes;
extern struct sr_dev_driver ikalogic_scanalogic2_driver_info;
static struct sr_dev_driver *di = &ikalogic_scanalogic2_driver_info;
-extern uint64_t ikalogic_scanalogic2_samplerates[NUM_SAMPLERATES];
+extern uint64_t sl2_samplerates[NUM_SAMPLERATES];
static void stop_acquisition(struct sr_dev_inst *sdi)
{
}
}
-SR_PRIV int ikalogic_scanalogic2_receive_data(int fd, int revents,
- void *cb_data)
+SR_PRIV int ikalogic_scanalogic2_receive_data(int fd, int revents, void *cb_data)
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
return TRUE;
}
-SR_PRIV void ikalogic_scanalogic2_receive_transfer_in(
- struct libusb_transfer *transfer)
+SR_PRIV void sl2_receive_transfer_in( struct libusb_transfer *transfer)
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
}
}
-SR_PRIV void ikalogic_scanalogic2_receive_transfer_out(
- struct libusb_transfer *transfer)
+SR_PRIV void sl2_receive_transfer_out( struct libusb_transfer *transfer)
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
}
}
-SR_PRIV int ikalogic_scanalogic2_set_samplerate(const struct sr_dev_inst *sdi,
+SR_PRIV int sl2_set_samplerate(const struct sr_dev_inst *sdi,
uint64_t samplerate)
{
struct dev_context *devc;
devc = sdi->priv;
for (i = 0; i < NUM_SAMPLERATES; i++) {
- if (ikalogic_scanalogic2_samplerates[i] == samplerate) {
+ if (sl2_samplerates[i] == samplerate) {
devc->samplerate = samplerate;
devc->samplerate_id = NUM_SAMPLERATES - i - 1;
return SR_OK;
return SR_ERR_ARG;
}
-SR_PRIV int ikalogic_scanalogic2_set_limit_samples(
- const struct sr_dev_inst *sdi, uint64_t limit_samples)
+SR_PRIV int sl2_set_limit_samples(const struct sr_dev_inst *sdi,
+ uint64_t limit_samples)
{
struct dev_context *devc;
return SR_OK;
}
-SR_PRIV void ikalogic_scanalogic2_configure_trigger(
- const struct sr_dev_inst *sdi)
+SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_probe *probe;
devc->trigger_channel, devc->trigger_type);
}
-SR_PRIV int ikalogic_scanalogic2_set_capture_ratio(
- const struct sr_dev_inst *sdi, uint64_t capture_ratio)
+SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
+ uint64_t capture_ratio)
{
struct dev_context *devc;
return SR_OK;
}
-SR_PRIV int ikalogic_scanalogic2_set_after_trigger_delay(
- const struct sr_dev_inst *sdi, uint64_t after_trigger_delay)
+SR_PRIV int sl2_set_after_trigger_delay(const struct sr_dev_inst *sdi,
+ uint64_t after_trigger_delay)
{
struct dev_context *devc;
return SR_OK;
}
-SR_PRIV void ikalogic_scanalogic2_calculate_trigger_samples(
- const struct sr_dev_inst *sdi)
+SR_PRIV void sl2_calculate_trigger_samples(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
uint64_t pre_trigger_samples, post_trigger_samples;
devc->post_trigger_bytes = post_trigger_bytes;
}
-SR_PRIV int ikalogic_scanalogic2_get_device_info(struct sr_usb_dev_inst usb,
+SR_PRIV int sl2_get_device_info(struct sr_usb_dev_inst usb,
struct device_info *dev_info)
{
struct drv_context *drvc;
* device information.
*/
buffer[0] = CMD_RESET;
- ret = ikalogic_scanalogic2_transfer_out(usb.devhdl, buffer);
-
- if (ret != PACKET_LENGTH) {
+ if ((ret = sl2_transfer_out(usb.devhdl, buffer)) != PACKET_LENGTH) {
sr_err("Resetting of device failed: %s.",
libusb_error_name(ret));
libusb_release_interface(usb.devhdl, USB_INTERFACE);
}
buffer[0] = CMD_INFO;
- ret = ikalogic_scanalogic2_transfer_out(usb.devhdl, buffer);
-
- if (ret != PACKET_LENGTH) {
+ if ((ret = sl2_transfer_out(usb.devhdl, buffer)) != PACKET_LENGTH) {
sr_err("Requesting of device information failed: %s.",
libusb_error_name(ret));
libusb_release_interface(usb.devhdl, USB_INTERFACE);
return SR_ERR;
}
- ret = ikalogic_scanalogic2_transfer_in(usb.devhdl, buffer);
-
- if (ret != PACKET_LENGTH) {
+ if ((ret = sl2_transfer_in(usb.devhdl, buffer)) != PACKET_LENGTH) {
sr_err("Receiving of device information failed: %s.",
libusb_error_name(ret));
libusb_release_interface(usb.devhdl, USB_INTERFACE);
dev_info->fw_ver_minor = buffer[6];
buffer[0] = CMD_RESET;
- ret = ikalogic_scanalogic2_transfer_out(usb.devhdl, buffer);
-
- if (ret != PACKET_LENGTH) {
+ if ((ret = sl2_transfer_out(usb.devhdl, buffer)) != PACKET_LENGTH) {
sr_err("Device reset failed: %s.", libusb_error_name(ret));
libusb_release_interface(usb.devhdl, USB_INTERFACE);
libusb_close(usb.devhdl);
* and thereby close the connection.
*/
buffer[0] = CMD_IDLE;
- ret = ikalogic_scanalogic2_transfer_out(usb.devhdl, buffer);
-
- if (ret != PACKET_LENGTH) {
+ if ((ret = sl2_transfer_out(usb.devhdl, buffer)) != PACKET_LENGTH) {
sr_err("Failed to set device in idle state: %s.",
libusb_error_name(ret));
libusb_release_interface(usb.devhdl, USB_INTERFACE);
return SR_OK;
}
-SR_PRIV int ikalogic_scanalogic2_transfer_in(libusb_device_handle *dev_handle,
- uint8_t *data)
+SR_PRIV int sl2_transfer_in(libusb_device_handle *dev_handle, uint8_t *data)
{
return libusb_control_transfer(dev_handle, USB_REQUEST_TYPE_IN,
USB_HID_SET_REPORT, USB_HID_REPORT_TYPE_FEATURE, USB_INTERFACE,
(unsigned char *)data, PACKET_LENGTH, USB_TIMEOUT);
}
-SR_PRIV int ikalogic_scanalogic2_transfer_out(libusb_device_handle *dev_handle,
- uint8_t *data)
+SR_PRIV int sl2_transfer_out(libusb_device_handle *dev_handle, uint8_t *data)
{
return libusb_control_transfer(dev_handle, USB_REQUEST_TYPE_OUT,
USB_HID_SET_REPORT, USB_HID_REPORT_TYPE_FEATURE, USB_INTERFACE,
gboolean transfer_error;
};
-SR_PRIV int ikalogic_scanalogic2_receive_data(int fd, int revents,
- void *cb_data);
-SR_PRIV void ikalogic_scanalogic2_receive_transfer_in(
- struct libusb_transfer *transfer);
-SR_PRIV void ikalogic_scanalogic2_receive_transfer_out(
- struct libusb_transfer *transfer);
-SR_PRIV int ikalogic_scanalogic2_set_samplerate(const struct sr_dev_inst *sdi,
+SR_PRIV int ikalogic_scanalogic2_receive_data(int fd, int revents, void *cb_data);
+SR_PRIV void sl2_receive_transfer_in(struct libusb_transfer *transfer);
+SR_PRIV void sl2_receive_transfer_out(struct libusb_transfer *transfer);
+SR_PRIV int sl2_set_samplerate(const struct sr_dev_inst *sdi,
uint64_t samplerate);
-SR_PRIV int ikalogic_scanalogic2_set_limit_samples(
- const struct sr_dev_inst *sdi, uint64_t limit_samples);
-SR_PRIV void ikalogic_scanalogic2_configure_trigger(
- const struct sr_dev_inst *sdi);
-SR_PRIV int ikalogic_scanalogic2_set_capture_ratio(
- const struct sr_dev_inst *sdi, uint64_t capture_ratio);
-SR_PRIV int ikalogic_scanalogic2_set_after_trigger_delay(
- const struct sr_dev_inst *sdi, uint64_t after_trigger_delay);
-SR_PRIV void ikalogic_scanalogic2_calculate_trigger_samples(
- const struct sr_dev_inst *sdi);
-SR_PRIV int ikalogic_scanalogic2_get_device_info(struct sr_usb_dev_inst usb,
+SR_PRIV int sl2_set_limit_samples(const struct sr_dev_inst *sdi,
+ uint64_t limit_samples);
+SR_PRIV void sl2_configure_trigger(const struct sr_dev_inst *sdi);
+SR_PRIV int sl2_set_capture_ratio(const struct sr_dev_inst *sdi,
+ uint64_t capture_ratio);
+SR_PRIV int sl2_set_after_trigger_delay(const struct sr_dev_inst *sdi,
+ uint64_t after_trigger_delay);
+SR_PRIV void sl2_calculate_trigger_samples(const struct sr_dev_inst *sdi);
+SR_PRIV int sl2_get_device_info(struct sr_usb_dev_inst usb,
struct device_info *dev_info);
-SR_PRIV int ikalogic_scanalogic2_transfer_in(libusb_device_handle *dev_handle,
- uint8_t *data);
-SR_PRIV int ikalogic_scanalogic2_transfer_out(libusb_device_handle *dev_handle,
- uint8_t *data);
+SR_PRIV int sl2_transfer_in(libusb_device_handle *dev_handle, uint8_t *data);
+SR_PRIV int sl2_transfer_out(libusb_device_handle *dev_handle, uint8_t *data);
#endif