Specjalistyczne rozwiązania informatyczne

Mini6410 and CAM130 camera

I lost some time trying to make this camera working using v4l2. Either Samsung driver is broken or I didn't provide some important ioctl's. I performed my tests on 2.6.28 kernel with fimc driver as .c sources and 2.6.38 kernel with already compiled binary drivers.

1. Capture mode

Enumerating capabilities returned: V4L2_CAP_VIDEO_CAPTURE and V4L2_CAP_VIDEO_OVERLAY. There are 4 possible formats:

  • YU12: 4:2:0, planar, Y-Cb-Cr
  • 422P: 4:2:2, planar, Y-Cb-Cr
  • YUYV: 4:2:2, packed, YCBYCR
  • UYVY: 4:2:2, packed

They don't work. ioctl(VIDIOC_S_FMT) doesn't return error, but it also doesn't fill properly v4l_fmt.fmt.pix.bytesperline and v4l_fmt.fmt.pix.sizeimage. Overriding these values doesn't help. Reading frames in "mmap" mode ends with "QUERYBUF for mmap failed 22: Invalid argument". read(fd,...) doesn't work either.

2. Overlay mode

Enumerating capabilities returned the same values as in capture mode. VIDIOC_G_FMT failed, but fimc sourcecode gave a hint that two formats are possible:

  • RGB565
  • RGB24

If FriendlyARM/qtopia can show image from the camera, then there must be some way to get these frames. Tracking cmos-camera application (it's closed source) ioctls helped a lot. I would never guess that:

  • overlay mode is used to capture frames
  • there is V4L2_CAP_VIDEO_CAPTURE capability, but mmap doesn't work
  • there is no support for V4L2_CAP_READWRITE capability, but you have to use read(fd,...)
  • RGB24 format gives you really RGB32 frames

I still don't know how to get better resolution than 640x512.

Anyway, if you want to capture some frames you have to:

int fd=open("/dev/video0", O_RDWR);
struct v4l2_framebuffer fb;
bzero(&fb,sizeof(fb));
fb.fmt.width=640;
fb.fmt.height=480;
fb.fmt.pixelformat=V4L2_PIX_FMT_RGB24;
ioctl(fd,VIDIOC_S_FBUF,&fb);
int some_int_1=1;
ioctl(fd, VIDIOC_OVERLAY, &some_int_1);
read(fd, buf, 640*480*3);
int some_int_0;
ioctl(fd, VIDIOC_OVERLAY, &some_int_0);

   © KLASTER 2017