@@ -651,9 +651,25 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi
*/
if (sensorMetadata_) {
V4L2SubdeviceFormat embeddedFormat = sensor_->embeddedDataFormat();
+ static const std::map<uint32_t, V4L2PixelFormat> metaFormats{
+ { MEDIA_BUS_FMT_META_8, V4L2PixelFormat(V4L2_META_FMT_GENERIC_8) },
+ { MEDIA_BUS_FMT_META_10, V4L2PixelFormat(V4L2_META_FMT_GENERIC_CSI2_10) },
+ { MEDIA_BUS_FMT_META_12, V4L2PixelFormat(V4L2_META_FMT_GENERIC_CSI2_12) },
+ { MEDIA_BUS_FMT_META_14, V4L2PixelFormat(V4L2_META_FMT_GENERIC_CSI2_14) },
+ };
+
+ const auto metaFormat = metaFormats.find(embeddedFormat.code);
+ if (metaFormat == metaFormats.end()) {
+ LOG(RPI, Error)
+ << "Unsupported metadata format "
+ << utils::hex(embeddedFormat.code, 4);
+ return -EINVAL;
+ }
+
V4L2DeviceFormat format{};
- format.fourcc = V4L2PixelFormat(V4L2_META_FMT_SENSOR_DATA);
+ format.fourcc = metaFormat->second;
format.planes[0].size = embeddedFormat.size.width * embeddedFormat.size.height;
+ format.size = embeddedFormat.size;
LOG(RPI, Debug) << "Setting embedded data format " << format;
ret = unicam_[Unicam::Embedded].dev()->setFormat(&format);
@@ -781,27 +797,6 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi
return ret;
}
- /*
- * Configure the Unicam embedded data output format only if the sensor
- * supports it.
- */
- if (sensorMetadata_) {
- V4L2SubdeviceFormat embeddedFormat;
-
- sensor_->device()->getFormat(1, &embeddedFormat);
- format = {};
- format.fourcc = V4L2PixelFormat(V4L2_META_FMT_SENSOR_DATA);
- format.planes[0].size = embeddedFormat.size.width * embeddedFormat.size.height;
-
- LOG(RPI, Debug) << "Setting embedded data format " << format.toString();
- ret = unicam_[Unicam::Embedded].dev()->setFormat(&format);
- if (ret) {
- LOG(RPI, Error) << "Failed to set format on Unicam embedded: "
- << format;
- return ret;
- }
- }
-
/* Figure out the smallest selection the ISP will allow. */
Rectangle testCrop(0, 0, 1, 1);
isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &testCrop);
V4L2_META_FMT_SENSOR_DATA was used in downstream kernels, but in upstream we use specific fourcc values for metadata formats of different bit-depths. Pick the correct one corresponding to the format configured on the unicam subdevice. Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> --- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 39 +++++++++++++++------------------- 1 file changed, 17 insertions(+), 22 deletions(-)