From patchwork Fri Mar 1 21:21:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19621 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CD625BD160 for ; Fri, 1 Mar 2024 21:22:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8AC9062C94; Fri, 1 Mar 2024 22:22:05 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f/tl4/OZ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9AE1262C95 for ; Fri, 1 Mar 2024 22:22:03 +0100 (CET) Received: from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi [89.27.53.110]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 22A713AC3; Fri, 1 Mar 2024 22:21:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1709328109; bh=YSMuEhlQbv/mbS4xuvgyxPFDndM/NDOaJQLd/+dyulI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/tl4/OZWyxEdr0KcmhlIClcqeMYfdN+8uSizZo8p3aMRskgbJKeVBxQN+eIrK68r R2XVgCt9s0KQEd39Od+8n0kK/UK38P4t0ooejI4NtMzSVVJxsuNLrkk9pZEdxcimUl C9b0KS+6Tm9ePmhHD0i0oalM184PVZW0pOQBgJaQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH/RFC 30/32] pipeline: raspberrypi: vc4: Fix configuration of the embedded data node Date: Fri, 1 Mar 2024 23:21:19 +0200 Message-ID: <20240301212121.9072-31-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240301212121.9072-1-laurent.pinchart@ideasonboard.com> References: <20240301212121.9072-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sakari Ailus Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The Unicam embedded data video device suffers from two issues with the upstream driver: - The driver uses the generic metadata V4L2_META_FMT_GENERIC_* formats, instead of the downstream V4L2_META_FMT_SENSOR_DATA. - The driver requires the width and height of the embedded data stream to be configured. Fix them both. Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 81e0bc1b8f7a..2ff9b708d021 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -624,10 +624,25 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi * supports it. */ if (sensorMetadata_) { + static const std::map 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) }, + }; + V4L2SubdeviceFormat embeddedFormat = sensor_->embeddedDataFormat(); + 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.planes[0].size = embeddedFormat.size.width * embeddedFormat.size.height; + format.fourcc = metaFormat->second; + format.size = embeddedFormat.size; LOG(RPI, Debug) << "Setting embedded data format " << format; ret = unicam_[Unicam::Embedded].dev()->setFormat(&format);