Good Options for per-frame processing in video driver?

I need to do some processing synchronized with an incoming video stream at the
frame rate (extracting Closed Captioning data from the Video Receiver chip). Any
suggestions about how to do this? We have our own camera driver, but this really
just creates the necessary config structures and adds the v4l2 device. The CSI
input is all handled behind the scenes. Are there any callback options that will
be called per frame?

If it were possible to interrupt on a GPIO line it might be possible to add the
support on the board to do this, but I didn’t see any posts on the forum about how
to do this.

The userspace option is to add a GStreamer element that triggers the reads every
time a frame goes through, but I’d rather have the timing more tightly coupled.

Any other options?

Thanks in Advance

Cary

hello cobrien,

am I understand correctly that you would like to have implementation for each capture frame.
please check below Argus sample code snippet, this event thread execute for every capture frames.

<i>$l4t-r32.1/tegra_multimedia_api/argus/apps/camera/modules/EventThread.cpp</i>

bool EventThread::threadExecute()
{
...
        if (iEvent->getEventType() == Argus::EVENT_TYPE_CAPTURE_COMPLETE)
        {

or, you could check from the kernel sources, please search below function call.
this function also execute for every capture request.

<i>$l4t-r32.1/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c</i>

vb2_buffer_done();

Thanks, I was finally able to get this to work.

We are using a gstreamer-based version, so I used the second approach and
added a callback hook in channel.c, which I set with a callback function
to my kernel module driver. I’m sure there are much better ways to
do this, but it works.

Only one of the vb2_buffer_done() calls was called periodically when video
was being captured. I have a multi-input system, so I had to use
chan->video.minor, the minor device number of the /dev/videoN device,
to differentiate between the inputs.

The data reading is much more reliable than the polled method I was using
before.

I moved the accepted answer to this so more details would be available.