Mastering Linux Device Driver Development by John Madieu
Author:John Madieu
Language: eng
Format: epub
Publisher: Packt Publishing Pvt Ltd
Published: 2021-01-22T00:00:00+00:00
read should contain operations needed to implement the read() system call. Most of the time, the videobuf2-V4L2 helper vb2_fop_read is enough.
write is not needed in our case as it is for an OUTPUT type device. However, using vb2_fop_write here does the job.
unlocked_ioctl must be set to video_ioctl2 if you use v4l2_ioctl_ops. The next section explains this in detail. This V4L2 core helper is a wrapper around __video_do_ioctl(), which handles the real logic, and which routes each ioctl to the appropriate callback in vdev->ioctl_ops, which is where individual ioctl handlers are defined.
mmap should contain operations needed to implement the mmap() system call. Most of the time, the videobuf2-V4L2 helper vb2_fop_mmap is enough, unless additional elements are required prior to performing mapping. Video buffers in the kernel (allocated in response to the VIDIOC_REQBUFS ioctl) have to be mapped individually prior to being accessed in the user space. This is the purpose of this .mmap callback, which just has to map one, and only one, video buffer to the user space. Information needed to map a buffer to a user space is queried to the kernel using the VIDIOC_QUERYBUF ioctl. Given the vma parameter, you can grab a pointer to the corresponding video buffer as follows:struct vb2_queue *q = container_of_myqueue_wrapper();
unsigned long off = vma->vm_pgoff << PAGE_SHIFT;
struct vb2_buffer *vb;
unsigned int buffer = 0, plane = 0;
for (i = 0; i < q->num_buffers; i++) {
struct vb2_buffer *buf = q->bufs[i];
/* The below assume we are on a single-planar system,
* else we would have loop over each plane
*/
if (buf->planes[0].m.offset == off)
break;
return i;
}
videobuf_queue_unlock(myqueue);
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
2021 Beginners Guide to Python Programming Language: A Crash Course to Mastering Python in One Hour by Elmer Gary & Elmer Gary(1830)
API Testing and Development with Postman by Dave Westerveld(1540)
Learning C# by Developing Games with Unity 2020 by Harrison Ferrone(1504)
Machine Learning for Algorithmic Trading by Stefan Jansen(1469)
Software Architecture for Busy Developers by Stéphane Eyskens(1460)
Hands-On ROS for Robotics Programming by Bernardo Ronquillo Japón(1440)
Delphi GUI Programming with FireMonkey by Andrea Magni(1300)
Cloud Native with Kubernetes by Alexander Raul(1269)
Game Development Projects with Unreal Engine by Hammad Fozi & Goncalo Marques & David Pereira & Devin Sherry(1253)
Automate It with Zapier by Kelly Goss(1222)
Software Architecture Patterns for Serverless Systems by John Gilbert(1217)
Datadog Cloud Monitoring Quick Start Guide by Thomas Kurian Theakanath(1194)
Practical System Programming for Rust Developers by Prabhu Eshwarla(1192)
Practical Node-RED Programming by Taiji Hagino(1181)
Mastering React Test-Driven Development by Daniel Irvine(1164)
Delphi Programming Projects by William Duarte(1158)
Learn Spring for Android Application Development by S. M. Mohi Us Sunnat(1123)
Ghidra Software Reverse Engineering for Beginners by A. P. David(1123)
Developing Multi-Platform Apps with Visual Studio Code by Ovais Mehboob Ahmed Khan & Khusro Habib & Chris Dias(1119)