Posted Jun 16, 2011 6:52 UTC (Thu) by hverkuil (subscriber, #41056)
Parent article: The videobuf2 API
Well, locking is explained in Documentation/video4linux/v4l2-framework, section "v4l2_file_operations and locking". But it doesn't mention videobuf2 (must be fixed) and should probably be expanded/improved a bit.
But in a nutshell: you either set the 'lock' field in struct video_device to a mutex and then the framework will take care of serialization of file operations (mostly ioctls) for you, or you leave it at NULL and you have to do your own locking.
I tend to advocate using the framework serialization rather than doing it yourself since the chances of actually getting the locking right in a complex driver if you do it yourself are pretty close to zero, especially after the driver has undergone a few years of maintenance.