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>
#include <sys/mman.h>
#include <sys/time.h>
#include <errno.h>
+#include <sys/ioctl.h>
#include <dirent.h>
#include <libv4l2.h>
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