@@ -90,7 +90,7 @@ static int command_start_acquisition(const struct sr_dev_inst *sdi)
9090
9191 /* Compute the sample rate. */
9292 if (!(devc -> profile -> dev_caps & DEV_CAPS_FX3 ) &&
93- devc -> sample_wide && samplerate > MAX_16BIT_SAMPLE_RATE ) {
93+ devc -> unitsize > 1 && samplerate > MAX_16BIT_SAMPLE_RATE ) {
9494 sr_err ("Unable to sample at %" PRIu64 "Hz "
9595 "when collecting 16-bit samples." , samplerate );
9696 return SR_ERR ;
@@ -131,8 +131,10 @@ static int command_start_acquisition(const struct sr_dev_inst *sdi)
131131 cmd .sample_delay_l = delay & 0xff ;
132132
133133 /* Select the sampling width. */
134- cmd .flags |= devc -> sample_wide ? CMD_START_FLAGS_SAMPLE_16BIT :
135- CMD_START_FLAGS_SAMPLE_8BIT ;
134+ cmd .flags |= devc -> unitsize == 4 ? CMD_START_FLAGS_SAMPLE_32BIT :
135+ (devc -> unitsize == 3 ? CMD_START_FLAGS_SAMPLE_24BIT :
136+ (devc -> unitsize == 2 ? CMD_START_FLAGS_SAMPLE_16BIT :
137+ CMD_START_FLAGS_SAMPLE_8BIT ));
136138 /* Enable CTL2 clock. */
137139 cmd .flags |= (g_slist_length (devc -> enabled_analog_channels ) > 0 ) ? CMD_START_FLAGS_CLK_CTL2 : 0 ;
138140
@@ -270,7 +272,7 @@ SR_PRIV struct dev_context *fx2lafw_dev_new(void)
270272 devc -> limit_frames = 1 ;
271273 devc -> limit_samples = 0 ;
272274 devc -> capture_ratio = 0 ;
273- devc -> sample_wide = FALSE ;
275+ devc -> unitsize = 1 ;
274276 devc -> num_frames = 0 ;
275277 devc -> stl = NULL ;
276278
@@ -445,7 +447,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
445447 libusb_error_name (transfer -> status ), transfer -> actual_length );
446448
447449 /* Save incoming transfer before reusing the transfer struct. */
448- unitsize = devc -> sample_wide ? 2 : 1 ;
450+ unitsize = devc -> unitsize ;
449451 cur_sample_count = transfer -> actual_length / unitsize ;
450452 processed_samples = 0 ;
451453
@@ -486,6 +488,8 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
486488 num_samples = cur_sample_count - processed_samples ;
487489 if (devc -> limit_samples && devc -> sent_samples + num_samples > devc -> limit_samples )
488490 num_samples = devc -> limit_samples - devc -> sent_samples ;
491+ else
492+ num_samples = cur_sample_count ;
489493
490494 devc -> send_data_proc (sdi , (uint8_t * )transfer -> buffer + processed_samples * unitsize ,
491495 num_samples * unitsize , unitsize );
@@ -574,7 +578,9 @@ static int configure_channels(const struct sr_dev_inst *sdi)
574578 * Use wide sampling if either any of the LA channels 8..15 is enabled,
575579 * and/or at least one analog channel is enabled.
576580 */
577- devc -> sample_wide = channel_mask > 0xff || num_analog > 0 ;
581+ devc -> unitsize = channel_mask > 0xffffff ? 4 :
582+ (channel_mask > 0xffff ? 3 :
583+ (channel_mask > 0xff || num_analog > 0 ? 2 : 1 ));
578584
579585 return SR_OK ;
580586}
@@ -593,6 +599,12 @@ static size_t get_buffer_size(struct dev_context *devc)
593599 * a multiple of 1024.
594600 */
595601 s = 10 * to_bytes_per_ms (devc -> cur_samplerate );
602+ if (devc -> unitsize == 3 ) {
603+ /* Make it a multiple of 3K, to make sure we have an
604+ integral number of samples */
605+ s += 3 * 1024 ;
606+ s -= s % (3 * 1024 );
607+ }
596608 return (s + 1023 ) & ~1023 ;
597609}
598610
0 commit comments