Hi all, I have a question about V4L2.

I am investigating making my own drivers for a new camera for an android phone. However, I cannot understand how the existing driver works. I am just debugging the kernel by making verbose messages in the dmesg log. I see that it makes a VIDIOC_DQBUF/QBUF ioctl calls.

struct v4l2_buffer {
__u32 index;
__u32 type;
__u32 bytesused;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
__u32 memory;
union {
__u32 offset;
unsigned long userptr;
struct v4l2_plane * planes;
__s32 fd;
} m;
__u32 length;
__u32 reserved2;
__u32 reserved;
};


I am looking at the struct that is passed back and forth in the ioctl call, and I see that type=9 which is multiplanar, and memory=userptr.

So based on the definition I have to dig into the v4l2_plane structure inside the union. And I see

that v4l2_plane is:

struct v4l2_plane {
__u32 bytesused;
__u32 length;
union {
__u32 mem_offset;
unsigned long userptr;
__s32 fd;
} m;
__u32 data_offset;
__u32 reserved[11];
};

so based on the memory type field I look into the

ioctlbuf->m.planes[0].m.userptr

and I get a value of 0x59

huh? how can a userptr be 0x59? I printed it for many calls and it is always less than 0xff. So I cannot trace where the ioctl call puts the camera data buffers. I have to be able to debug into that buffer for my task.

Is there some kind of pointer table that userptr indexes into?

thanks in advance