fx2lafw: Add analog sampling handler
This will be needed for the MSO support of the CWAV USBee AX and clones.
This commit is contained in:
parent
7b5d1c64fc
commit
7e5ccff2ec
|
@ -710,7 +710,10 @@ static int start_transfers(const struct sr_dev_inst *sdi)
|
|||
devc->submitted_transfers++;
|
||||
}
|
||||
|
||||
devc->send_data_proc = la_send_data_proc;
|
||||
if (devc->profile->dev_caps & DEV_CAPS_AX_ANALOG)
|
||||
devc->send_data_proc = mso_send_data_proc;
|
||||
else
|
||||
devc->send_data_proc = la_send_data_proc;
|
||||
|
||||
/* Send header packet to the session bus. */
|
||||
std_session_send_df_header(sdi, LOG_PREFIX);
|
||||
|
@ -802,6 +805,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
struct drv_context *drvc;
|
||||
struct dev_context *devc;
|
||||
int timeout, ret;
|
||||
size_t size;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
return SR_ERR_DEV_CLOSED;
|
||||
|
@ -822,6 +826,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
if (devc->dslogic) {
|
||||
dslogic_trigger_request(sdi);
|
||||
} else {
|
||||
size = fx2lafw_get_buffer_size(devc);
|
||||
/* Prepare for analog sampling. */
|
||||
if (devc->profile->dev_caps & DEV_CAPS_AX_ANALOG) {
|
||||
/* We need a buffer half the size of a transfer. */
|
||||
devc->logic_buffer = g_try_malloc(size / 2);
|
||||
devc->analog_buffer = g_try_malloc(
|
||||
sizeof(float) * size / 2);
|
||||
}
|
||||
start_transfers(sdi);
|
||||
if ((ret = fx2lafw_command_start_acquisition(sdi)) != SR_OK) {
|
||||
fx2lafw_abort_acquisition(devc);
|
||||
|
|
|
@ -339,6 +339,10 @@ static void finish_acquisition(struct sr_dev_inst *sdi)
|
|||
devc->num_transfers = 0;
|
||||
g_free(devc->transfers);
|
||||
|
||||
/* Free the deinterlace buffers if we had them */
|
||||
g_free(devc->logic_buffer);
|
||||
g_free(devc->analog_buffer);
|
||||
|
||||
if (devc->stl) {
|
||||
soft_trigger_logic_free(devc->stl);
|
||||
devc->stl = NULL;
|
||||
|
@ -382,7 +386,52 @@ static void resubmit_transfer(struct libusb_transfer *transfer)
|
|||
|
||||
}
|
||||
|
||||
SR_PRIV void la_send_data_proc(void *cb_data,
|
||||
SR_PRIV void mso_send_data_proc(struct dev_context *devc,
|
||||
uint8_t *data, size_t length, size_t sample_width)
|
||||
{
|
||||
size_t i;
|
||||
sample_width = sample_width;
|
||||
length /= 2;
|
||||
|
||||
sr_dbg("mso_send_data_proc length = %d", length);
|
||||
|
||||
/* Send the logic */
|
||||
for(i = 0; i < length; i++) {
|
||||
devc->logic_buffer[i] = data[i * 2];
|
||||
devc->analog_buffer[i] = data[i * 2 + 1] - 128.0f;
|
||||
};
|
||||
|
||||
const struct sr_datafeed_logic logic = {
|
||||
.length = length,
|
||||
.unitsize = 1,
|
||||
.data = devc->logic_buffer
|
||||
};
|
||||
|
||||
const struct sr_datafeed_packet logic_packet = {
|
||||
.type = SR_DF_LOGIC,
|
||||
.payload = &logic
|
||||
};
|
||||
sr_session_send(devc->cb_data, &logic_packet);
|
||||
|
||||
const struct sr_datafeed_analog_old analog = {
|
||||
.num_samples = length,
|
||||
.mq = SR_MQ_VOLTAGE,
|
||||
.unit = SR_UNIT_VOLT,
|
||||
.mqflags = SR_MQFLAG_DC,
|
||||
.data = devc->analog_buffer
|
||||
};
|
||||
|
||||
const struct sr_datafeed_packet analog_packet = {
|
||||
.type = SR_DF_ANALOG_OLD,
|
||||
.payload = &analog
|
||||
};
|
||||
|
||||
sr_dbg("mso_send_data_proc length = %d", length);
|
||||
sr_session_send(devc->cb_data, &analog_packet);
|
||||
|
||||
}
|
||||
|
||||
SR_PRIV void la_send_data_proc(struct dev_context *devc,
|
||||
uint8_t *data, size_t length, size_t sample_width)
|
||||
{
|
||||
const struct sr_datafeed_logic logic = {
|
||||
|
@ -396,7 +445,7 @@ SR_PRIV void la_send_data_proc(void *cb_data,
|
|||
.payload = &logic
|
||||
};
|
||||
|
||||
sr_session_send(cb_data, &packet);
|
||||
sr_session_send(devc->cb_data, &packet);
|
||||
}
|
||||
|
||||
SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transfer)
|
||||
|
@ -466,7 +515,7 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
|
|||
else
|
||||
num_samples = cur_sample_count;
|
||||
|
||||
devc->send_data_proc(devc->cb_data,
|
||||
devc->send_data_proc(devc,
|
||||
(uint8_t*)transfer->buffer,
|
||||
num_samples * unitsize,
|
||||
unitsize);
|
||||
|
@ -482,7 +531,7 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
|
|||
num_samples > devc->limit_samples - devc->sent_samples)
|
||||
num_samples = devc->limit_samples - devc->sent_samples;
|
||||
|
||||
devc->send_data_proc(devc->cb_data,
|
||||
devc->send_data_proc(devc,
|
||||
(uint8_t*)transfer->buffer + trigger_offset * unitsize,
|
||||
num_samples * unitsize,
|
||||
unitsize);
|
||||
|
|
|
@ -122,8 +122,10 @@ struct dev_context {
|
|||
unsigned int num_transfers;
|
||||
struct libusb_transfer **transfers;
|
||||
struct sr_context *ctx;
|
||||
void (*send_data_proc)(void *cb_data,
|
||||
void (*send_data_proc)(struct dev_context *devc,
|
||||
uint8_t *data, size_t length, size_t sample_width);
|
||||
uint8_t *logic_buffer;
|
||||
float *analog_buffer;
|
||||
|
||||
/* Is this a DSLogic? */
|
||||
gboolean dslogic;
|
||||
|
@ -142,7 +144,9 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
|
|||
SR_PRIV size_t fx2lafw_get_buffer_size(struct dev_context *devc);
|
||||
SR_PRIV unsigned int fx2lafw_get_number_of_transfers(struct dev_context *devc);
|
||||
SR_PRIV unsigned int fx2lafw_get_timeout(struct dev_context *devc);
|
||||
SR_PRIV void la_send_data_proc(void *cb_data, uint8_t *data, size_t length,
|
||||
SR_PRIV void la_send_data_proc(struct dev_context *devc, uint8_t *data, size_t length,
|
||||
size_t sample_width);
|
||||
SR_PRIV void mso_send_data_proc(struct dev_context *devc, uint8_t *data, size_t length,
|
||||
size_t sample_width);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue