#define RUNSTATE_TRGD_BIT (1UL << 2)
#define RUNSTATE_POST_BIT (1UL << 3)
-/* Properties related to the layout of capture data downloads. */
+/*
+ * Properties related to the layout of capture data downloads.
+ *
+ * TODO Check the layout of 32 channel models' capture data. Could it be
+ * 3x (u32 + u8) instead of 5x (u16 + u8) perhaps? Same 16 bytes chunk
+ * but fewer packets per chunk and thus per transfer? Which questions
+ * the NUM_PACKETS_IN_CHUNK literal, maybe needs to be a runtime value?
+ */
#define NUM_PACKETS_IN_CHUNK 5
#define TRANSFER_PACKET_LENGTH 16
to_read = devc->n_bytes_to_read;
if (to_read >= LA2016_USB_BUFSZ) /* Multiple transfers. */
to_read = LA2016_USB_BUFSZ;
- else /* One transfer. */
- to_read = (to_read + (LA2016_EP6_PKTSZ-1)) & ~(LA2016_EP6_PKTSZ-1);
+ to_read += LA2016_EP6_PKTSZ - 1;
+ to_read /= LA2016_EP6_PKTSZ;
+ to_read *= LA2016_EP6_PKTSZ;
buffer = g_try_malloc(to_read);
if (!buffer) {
sr_dbg("USB bulk transfer size %d bytes.", (int)to_read);
*/
if (to_read >= LA2016_USB_BUFSZ)
to_read = LA2016_USB_BUFSZ;
- else
- to_read = (to_read + (LA2016_EP6_PKTSZ-1)) & ~(LA2016_EP6_PKTSZ-1);
+ to_read += LA2016_EP6_PKTSZ - 1;
+ to_read /= LA2016_EP6_PKTSZ;
+ to_read *= LA2016_EP6_PKTSZ;
libusb_fill_bulk_transfer(transfer,
usb->devhdl, USB_EP_CAPTURE_DATA | LIBUSB_ENDPOINT_IN,
transfer->buffer, to_read,