ni / usb3vision

Driver for USB3 Vision(TM) class devices
GNU General Public License v2.0
67 stars 31 forks source link

how 4 bytes or 8 bytes padding data come? #7

Open yilonglucky opened 4 years ago

yilonglucky commented 4 years ago

When using muti-ROI feature, or multiple buffers in the same urb, how to calculate the alignment_padding?

katieensign commented 4 years ago

Sorry for the late response, I had to try to refresh my memory on this code. The driver as it's written right now doesn't support the multi-ROI case of having multiple buffers in the same urb. If segmented transfers are enabled (!sg_constraint), there is the mechanism of indicating a segment size and some padding to skip over, but that's a subtle distinction because it's splitting up one image buffer into multiple chunks. Technically you should be able to do the same thing with multi-ROI, but the code is just not written to handle two or more image separate buffers in the same urb right now. If you were to try to change it, you'd have to tweak the API to be able to have N buffers passed in, and then page lock those and configure each of them for DMA as different elements in the scatter-gather list. I believe the alignment_padding calculation should stay the same, just calculating the total transfer size for all of the buffers and adding padding to ensure it's aligned with the transfer_alignment requirement calculated in u3v_core.c.

Hope this helps, Katie