Q1:<div><br></div><div>1.   go to your linux kernel source driver/media/video directory.<div>2.   ls *v4l* and u can see all the v4l related kernel sources.</div><div>3.   one of these is v4l2-ioctl.c which implement the interface when userspace program makes an ioctl() call.</div>
<div>4.   all the parameters that userspace ioctl() can pass in are defined in, for eg:</div><div><br></div><div><div>/* debug help functions                                               */</div><div>static const char *v4l2_ioctls[] = {</div>
<div>        [_IOC_NR(VIDIOC_QUERYCAP)]         = &quot;VIDIOC_QUERYCAP&quot;,</div><div>        [_IOC_NR(VIDIOC_RESERVED)]         = &quot;VIDIOC_RESERVED&quot;,</div><div>        [_IOC_NR(VIDIOC_ENUM_FMT)]         = &quot;VIDIOC_ENUM_FMT&quot;,</div>
<div>        [_IOC_NR(VIDIOC_G_FMT)]            = &quot;VIDIOC_G_FMT&quot;,</div><div>        [_IOC_NR(VIDIOC_S_FMT)]            = &quot;VIDIOC_S_FMT&quot;,</div><div>        [_IOC_NR(VIDIOC_REQBUFS)]          = &quot;VIDIOC_REQBUFS&quot;,</div>
<div>        [_IOC_NR(VIDIOC_QUERYBUF)]         = &quot;VIDIOC_QUERYBUF&quot;,</div><div>        [_IOC_NR(VIDIOC_G_FBUF)]           = &quot;VIDIOC_G_FBUF&quot;,</div><div>        [_IOC_NR(VIDIOC_S_FBUF)]           = &quot;VIDIOC_S_FBUF&quot;,</div>
<div>        [_IOC_NR(VIDIOC_OVERLAY)]          = &quot;VIDIOC_OVERLAY&quot;,</div><div>        [_IOC_NR(VIDIOC_QBUF)]             = &quot;VIDIOC_QBUF&quot;,</div><div>        [_IOC_NR(VIDIOC_DQBUF)]            = &quot;VIDIOC_DQBUF&quot;,</div>
<div>        [_IOC_NR(VIDIOC_STREAMON)]         = &quot;VIDIOC_STREAMON&quot;,</div><div>        [_IOC_NR(VIDIOC_STREAMOFF)]        = &quot;VIDIOC_STREAMOFF&quot;,</div><div>        [_IOC_NR(VIDIOC_G_PARM)]           = &quot;VIDIOC_G_PARM&quot;,</div>
<div>        [_IOC_NR(VIDIOC_S_PARM)]           = &quot;VIDIOC_S_PARM&quot;,</div><div>        [_IOC_NR(VIDIOC_G_STD)]            = &quot;VIDIOC_G_STD&quot;,</div><div>        [_IOC_NR(VIDIOC_S_STD)]            = &quot;VIDIOC_S_STD&quot;,</div>
<div>        [_IOC_NR(VIDIOC_ENUMSTD)]          = &quot;VIDIOC_ENUMSTD&quot;,</div><div>        [_IOC_NR(VIDIOC_ENUMINPUT)]        = &quot;VIDIOC_ENUMINPUT&quot;,</div><div>        [_IOC_NR(VIDIOC_G_CTRL)]           = &quot;VIDIOC_G_CTRL&quot;,</div>
<div>        [_IOC_NR(VIDIOC_S_CTRL)]           = &quot;VIDIOC_S_CTRL&quot;,</div><div>        [_IOC_NR(VIDIOC_G_TUNER)]          = &quot;VIDIOC_G_TUNER&quot;,</div><div>        [_IOC_NR(VIDIOC_S_TUNER)]          = &quot;VIDIOC_S_TUNER&quot;,</div>
<div>        [_IOC_NR(VIDIOC_G_AUDIO)]          = &quot;VIDIOC_G_AUDIO&quot;,</div><div>        [_IOC_NR(VIDIOC_S_AUDIO)]          = &quot;VIDIOC_S_AUDIO&quot;,</div><div><br></div><div>etc etc.</div><div><br></div><div>and for eg, the first item in the list - the userspace example are:</div>
<div><br></div><div><a href="http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-querycap.html">http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-querycap.html</a></div><div><br></div><div>(or more generally, <a href="http://linuxtv.org/downloads/v4l-dvb-apis/">http://linuxtv.org/downloads/v4l-dvb-apis/</a>)</div>
<div><br></div><div>and another example is the v4l libraries:</div><div><br></div><div>libv4l-dev </div><div><br></div><div>and the whole series of V4L2 articles  (kernel) is here:</div><div><br></div><div><a href="http://lwn.net/Articles/203924/">http://lwn.net/Articles/203924/</a>   (your interests in ioctl() is here:   <a href="http://lwn.net/Articles/206765/">http://lwn.net/Articles/206765/</a>)</div>
<div><br></div><div>and here (kernel+userspace):</div><div><br></div><div><a href="http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Intro-to-V4L2/">http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Intro-to-V4L2/</a></div>
<div><br></div><div>and this (userspace):</div><div><br></div><div><a href="http://linuxtv.org/wiki/index.php/V4L2_Userspace_Library">http://linuxtv.org/wiki/index.php/V4L2_Userspace_Library</a></div><div><br></div><div>and your question on buffer management in the kernel:</div>
<div><br></div><div><a href="http://lwn.net/Articles/363349/">http://lwn.net/Articles/363349/</a></div><div><br></div><div>which also contains the answer to your question (NO, it is not the generic layer for ALL devices - only some radio + video + dvb devices).</div>
<div><br></div><div>Q2:</div><div><br></div><div>dont quite understand u, but definitely capture and output buffer are different, and memcpy operation can happened independently.</div><div><br></div><div>in videobuf2-core.c are defined all the core buffer operation:</div>
<div><br></div><div><div>EXPORT_SYMBOL(vb2_querybuf);</div><div>EXPORT_SYMBOL_GPL(vb2_reqbufs);</div><div>EXPORT_SYMBOL_GPL(vb2_create_bufs);</div><div>EXPORT_SYMBOL_GPL(vb2_plane_vaddr);</div><div>EXPORT_SYMBOL_GPL(vb2_plane_cookie);</div>
<div>EXPORT_SYMBOL_GPL(vb2_buffer_done);</div><div>EXPORT_SYMBOL_GPL(vb2_prepare_buf);</div><div>EXPORT_SYMBOL_GPL(vb2_qbuf);</div><div>EXPORT_SYMBOL_GPL(vb2_wait_for_all_buffers);</div><div>EXPORT_SYMBOL_GPL(vb2_dqbuf);</div>
<div>EXPORT_SYMBOL_GPL(vb2_streamon);</div><div>EXPORT_SYMBOL_GPL(vb2_streamoff);</div><div>EXPORT_SYMBOL_GPL(vb2_mmap);</div><div>EXPORT_SYMBOL_GPL(vb2_get_unmapped_area);</div><div>EXPORT_SYMBOL_GPL(vb2_poll);</div><div>
EXPORT_SYMBOL_GPL(vb2_queue_init);</div><div>EXPORT_SYMBOL_GPL(vb2_queue_release);</div><div>EXPORT_SYMBOL_GPL(vb2_read);</div><div>EXPORT_SYMBOL_GPL(vb2_write);</div></div><div><br></div><div>and v4l2-mem2mem.c:</div><div>
<br></div><div><div>EXPORT_SYMBOL(v4l2_m2m_get_vq);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_next_buf);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_buf_remove);</div><div>EXPORT_SYMBOL(v4l2_m2m_get_curr_priv);</div><div>EXPORT_SYMBOL(v4l2_m2m_job_finish);</div>
<div>EXPORT_SYMBOL_GPL(v4l2_m2m_reqbufs);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_querybuf);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_qbuf);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_dqbuf);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_streamon);</div>
<div>EXPORT_SYMBOL_GPL(v4l2_m2m_streamoff);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_poll);</div><div>EXPORT_SYMBOL(v4l2_m2m_mmap);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_init);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_release);</div>
<div>EXPORT_SYMBOL_GPL(v4l2_m2m_ctx_init);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_ctx_release);</div><div>EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue);</div></div><div><br></div><div>memcopy operation is vb2_mmap() or v4l2_m2m_mmap() for eg.</div>
<div><br></div><div>and for DMA it can be videobuf_dma_mmap() (for scatter-gather operation) etc etc.   Search the same directories for how these are used by the different drivers.</div><div><br></div><div>Q3:   device to device mapping, I think will be the &quot;mem2mem&quot; files in the kernel source:</div>
<div><br></div><div><div>mem2mem_testdev.c    v4l2-mem2mem.c  </div></div><div><br></div><div>and all the APIs u can use (inside kernel drivers) are listed above (as EXPORT symbol).</div><div><br></div><br><div class="gmail_quote">
On Mon, Feb 18, 2013 at 12:29 PM, Kaushal Billore <span dir="ltr">&lt;<a href="mailto:kaushalbillore@hotmail.com" target="_blank">kaushalbillore@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div><div dir="ltr"><div dir="ltr">I have some doubt regarding Linux kernel V4l2 API&#39;s.<br>When
 capture application calls Reqbuff ioctl to allocate n no of buffer 
which would belongs to v4l2 layer and display application calls the 
Reqbuff ioctl to allocate N no of buffer which would also belongs to 
device memory.<br><br>Question:<br>1. V4l2 maintains the generic layer 
for all devices in which buffers can be allocated by any device and can 
be handle by any device?<br><br>2. If not then while capturing the data 
from capture device can capture device allocated buffer gets filled and 
while displaying the same data  there memory copy happens between 
capture buffer and output buffers?<br><br>3. If not then I want to capture data from capture device and display onto display device through the v4l2 framework layer. <br>   <br>Awaiting for responce!<br><br>Thanks in advance <br>
<span class="HOEnZb"><font color="#888888">Kaushal <br>                                               </font></span></div>
                                               </div></div>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards,<br>Peter Teoh
</div></div>