@@ -415,6 +415,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,
format->size.width = subdevFmt.format.width;
format->size.height = subdevFmt.format.height;
format->mbus_code = subdevFmt.format.code;
+ format->colorSpace = toColorSpace(subdevFmt.format);
return 0;
}
@@ -443,7 +444,13 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
subdevFmt.format.code = format->mbus_code;
subdevFmt.format.field = V4L2_FIELD_NONE;
- int ret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt);
+ int ret = fromColorSpace(format->colorSpace, subdevFmt.format);
+ if (ret < 0)
+ LOG(V4L2, Warning)
+ << "Setting color space unrecognised by V4L2: "
+ << ColorSpace::toString(format->colorSpace);
+
+ ret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt);
if (ret) {
LOG(V4L2, Error)
<< "Unable to set format on pad " << pad
@@ -454,6 +461,7 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
format->size.width = subdevFmt.format.width;
format->size.height = subdevFmt.format.height;
format->mbus_code = subdevFmt.format.code;
+ format->colorSpace = toColorSpace(subdevFmt.format);
return 0;
}