qv4l2: bypass libv4l2 when obtaining the colorspace
authorHans Verkuil <hansverk@cisco.com>
Fri, 18 Jul 2014 11:57:29 +0000 (13:57 +0200)
committerHans Verkuil <hansverk@cisco.com>
Fri, 18 Jul 2014 11:57:29 +0000 (13:57 +0200)
libv4l2 does not update the colorspace information when it should.
So just for the purpose of reading the colorspace information we
bypass libv4l2 and do a direct VIDIOC_G_FMT to the driver.

I kept forgetting why I wasn't getting the right colorspace results
and everytime it took me a while before I realized that the colorspace
was wrong.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
utils/qv4l2/qv4l2.cpp

index b1c3001..2f9b000 100644 (file)
@@ -57,6 +57,7 @@ extern "C" {
 #include <sys/mman.h>
 #include <sys/time.h>
 #include <errno.h>
+#include <sys/ioctl.h>
 #include <dirent.h>
 #include <libv4l2.h>
 
@@ -981,7 +982,10 @@ void ApplicationWindow::updateColorspace()
        if (colorspace == 0) {
                v4l2_format fmt;
 
-               g_fmt(m_genTab->bufType(), fmt);
+               fmt.type = m_genTab->bufType();
+               // don't use the wrapped ioctl since it doesn't
+               // update colorspace correctly.
+               ::ioctl(fd(), VIDIOC_G_FMT, &fmt);
                if (m_genTab->isPlanar())
                        colorspace = fmt.fmt.pix_mp.colorspace;
                else