Can NvBuf (V4L2_MEMORY_DMABUF) be used in across threads?

Hi,

(1) Can nvbuffer be used across threads?
We get v4l2 buf with V4L2_MEMORY_DMABUF type after VIDIOC_DQBUF, but we want to process this buffer in another thread. In this way, we want to get the next buffer in time. Is it feasible?

(2) Can i get the number of v4l2 buffers which are ready to DQBUF?

hello liuq1,

>> Q1
may I know what’s your actual use-case?
it’s two thread approach in low-level VI driver to enqueue/dequeue a capture buffer.
for instance,
$public_sources/kernel_src/kernel/nvidia-oot/drivers/media/platform/tegra/camera/vi/vi5_fops.c

static int vi5_channel_start_kthreads(struct tegra_channel *chan)
{
...
        chan->kthread_capture_start = kthread_run(
                tegra_channel_kthread_capture_enqueue, chan, chan->video->name);

        chan->kthread_capture_dequeue = kthread_run(
                tegra_channel_kthread_capture_dequeue, chan, chan->video->name);

>> Q2
did you meant the index of the capture buffer? please refer to vbuf->sequence.
for instance,
$public_sources/kernel_src/kernel/nvidia-oot/drivers/media/platform/tegra/camera/vi/vi5_fops.c

static void vi5_release_buffer(...)
{
        vbuf->sequence = chan->sequence++;   
        vb2_buffer_done(&vbuf->vb2_buf, buf->vb2_state);

Hi,

>> Q1
My application scenario is that after obtaining camera image data using a V4L2 DMA buffer, due to the fact that my processing time is longer than the frame rate, the current buffer data at the application layer has not been fully processed when the next V4L2 buffer arrives. Therefore, without making an additional copy of the data, I would like to pass this NV buffer to another thread for processing. Is this feasible?

>> Q2
Is there a way at the application layer to determine how many V4L2 buffers in the driver are in a ready state?

hello liuq1,

>> Q1
you may using appsink.
or… you may try to drop frames, or lower the frame-rate for testing.

>> Q2
there’s a queue for saving capture buffer,
you may check with below for the total number of buffers that are being allocated,
for instance,
$public_sources/kernel_src/kernel/nvidia-oot/drivers/media/platform/tegra/camera/vi/channel.c

static int tegra_channel_queue_setup(...)
{
...
        if (vi->fops && vi->fops->vi_setup_queue)
                return vi->fops->vi_setup_queue(chan, nbuffers);

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.