Skip to contentSkip to conversation

Unable to write V4L2 capture buffers to O_DIRECT file

DISCUSSION David Müller 1 participant 1 message Feb 27, 2016 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hello

I'm trying to store data received from a V4L2 capture device to a SATA storage device.

For performance reasons, i would like to do the writing using a file opened with the O_DIRECT flag.

As a test, I have modified the v4lcap example code to support writing output files directly (-F option) and to select IO mode (-B option).

Running this code results in a -EFAULT error returned by the write() function used to write to the output file as shown below:

/ # v4lcap -c 2 -o -F /dev/sda1 -Bd
IO: O_DIRECT mode
error writing file: Bad address

        buf: 0x76ac8000, size: 0x2DC800
.error writing file: Bad address
        buf: 0x767eb000, size: 0x2DC800

Without "O_DIRECT", the v4lcap tool works ok but the overall performance is pretty bad.

/ # v4lcap -c 2 -o -F /dev/sda1 -Bb
IO: normal mode
..

Any ideas/hints how to fix this?

HW: i.MX6Q based custom board
SW: kernel 4.2.0 + some patches (mainly CSI capture related)

Dave