Hi,<div><br></div><div>I&#39;m currently converting my windows driver for a broadcast video card to Linux. This conversion raised a lot of questions/issues, and I believe I solved most of them. Yet, I still have some issues and would like some advice.</div>
<div><br></div><div>In windows video data acquisition and playing were done through asynchronous IOCTL calls. I used METHOD_NEITHER for reference. The whole mechanism is simple, let&#39;s take an example for play :</div><div>
<br></div><div>- User mode has a Video Buffer, an Audio Buffer and an Ancillary data buffer (Timecode, and other smpte&#39;s stuff).</div><div>- User mode create a struct that gives 3 pointers to the buffers (Audio/Video/Anc) and also various sideband info (Nb of audio samples, size of buffers? ...), and call my IOCTL : IOCTL_PLAY_NEW_FRAME</div>
<div>- In my driver, I store sideband info in an internal structure, I map all 3 buffers into Physical Memory, then I start a Dma Transfer to the Board (using SG I/O).</div><div>- The card trig an Interrupt and I complete the request.</div>
<div><br></div><div>Now on Linux :</div><div>I first though that I would simply use ioctl capability to achieve that kind of functionnality. Using flag O_DIRECT, I had the feeling that it was possible. BUT if you have been attentive to the previous parts, you&#39;ll see that I&#39;ve mentioned the fact that these ioctls were asynchronous. And that is my issue. I don&#39;t think that ioctl can be managed as aio read/write.</div>
<div>I need the async functionnality to allow user mode post many play buffer, and to have the driver accumulate them in a fifo until that fifo is full.</div><div><br></div><div>I see that there are aio_write facilities that match perfectly my async scenario, but I can&#39;t find a way to supply multiple buffers (all part of the same frame) along a description of what is in these buffers. I think of a workaround that would be for a single play frame:</div>
<div><br></div><div>BASIC_PLAY_FRAME_OPERATION</div><div>- Use io_submit to submit a write op to the driver. In the buffer, have in fact a structure representing the frame I want to send including the 3 usermode buffers. I assume that if I do not set O_DIRECT Flag, the buffer will be copied into kernel space so that I can access it with __copy_from_user.</div>
<div>- The driver then maps and lock the 3 buffers in physical memory and trig a SG DMA transfer.</div><div>- Once the transfer is done (interrupt driven), complete the aio.</div><div>END_OF_BASIC_PLAY_FRAME_OPERATION</div>
<div><br></div><div>To achieve the final goal, submit multiple BASIC_PLAY_FRAME_OPERATION.</div><div><br></div><div>So my questions :</div><div>- Do you believe that my proposed workaround will work ?</div><div>- Are there other simpler alternatives ?</div>
<div><br></div><div>Thanks for you answers/comments.</div><div><br></div><div>Regards,</div><div>Fred. </div>