How to get memory address of the FileDescriptor of mmap() function in Linux, for Video4Linux

1k Views Asked by At

Good afternoon,

I am trying to determine the physical memory location of the buffer allocated by video for linux's IO_METHOD_MMAP

Looking through the mmap function,

    mmap(NULL /* start anywhere */,
                            buf.length,
                            PROT_READ | PROT_WRITE /* required */,
                            MAP_SHARED /* recommended */,
                            fd, //FileDescriptor
                            buf.m.offset);

I see that buf.m.offset is 0, then increments the by the buf.length value for each plane.

What I am looking for is the physcial address in memory for the filedescriptor (fd) created by /dev/video0 device.

This is on Im6.

The purpose of this is to pass that physical address to the Gpu,

Thanks,

1

There are 1 best solutions below

0
On

After the successful mmap you could open (e.g. using fopen), then sequentially read (e.g. using fgets) the textual (pipe-like) /proc/self/maps file (or also /proc/self/smaps).

See proc(5) and this answer.