From patchwork Fri Oct 23 10:58:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28574 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 B3A43C324C for ; Fri, 23 Oct 2026 10:59:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6688E68FAB; Fri, 23 Oct 2026 12:59:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UZ+7OiZk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C3FE68FA6 for ; Fri, 23 Oct 2026 12:59:04 +0200 (CEST) Received: from mail.ideasonboard.com (unknown [IPv6:2401:4900:1c30:59f6:be2b:2877:6bc4:392]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 244F81212; Fri, 23 Oct 2026 12:56:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753015; bh=nyhGKA3KIYY+xC/frdYIjkYThOZDiMr7igxc/8i4+Fs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UZ+7OiZkU1Vpj/2eo2NnvDvmoTntUR6OItXLQsIT0NGRHoIlGB3jWZf4rHCbbQ5J4 c4uoWxuDmaBMm+Ps2rjfPPKXZ7LdfmBgo25CMK5PDHLdEEwa8z956YrNwg6JOntCnQ hYlb+rl9y+S96ph2bl5g9b0+LBuwqlk8Lizy8fYo= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:12 +0530 Subject: [PATCH WIP RFC 04/26] pipeline: rpi: vc4: Map subdev metadata formats to V4L2 fourcc MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-4-eadb9948901b@ideasonboard.com> References: <20261023-b4-raw-model-v1-0-eadb9948901b@ideasonboard.com> In-Reply-To: <20261023-b4-raw-model-v1-0-eadb9948901b@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Laurent Pinchart , Kieran Bingham , Sakari Ailus , Naushir Patuck , Jai Luthra X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2878; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=nyhGKA3KIYY+xC/frdYIjkYThOZDiMr7igxc/8i4+Fs=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3G1JBFQGeJ4u/ggAABcmEt3+pXMLdbXKrhS B3SX4VASUGJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9xgAKCRBD3pH5JJpx RYuOD/9MYzLJUPdLGLOQvlJAiV2xJwv7R3sLP8o57tbMWaO1r7Wq/L+WCyzNgYnq6a9DiIRoD9C PGtWEW7gzB0lKVtervNNIA/yQLRj85pf46mqFU3pIaikiJsStQIMWOX6Au/qKm5tQIb4CmAc1PX m2QOInoqbckOi4tMnOh70+5f4tjqB+r5xTYlCyqIcik8RJwD83tgmx4UEiEqNt00RK8vdsIwfM8 7pe1OK01NkTIsQfMPIIsIieIUw8+lBzBTSzW0pCpcmt7yvJCzoGm+twAWpzPVFbFkbHpcA+KoyN cFh8MAMSGz6lnyN+nUFowRcW5eM8qxE/tUnqF8WBsZ/wdNQnVdKgSOQP3tDaFDRf6X69EcL50cc Hw91Rg7uzunnPrn6geCAOHw3bTzuhszYvkWIyGvSPxRAUPnTGEP8FuDSRnaqKiqQLeWXWabruuN 4Eq2hn5J3OXNbvxXpPTUSKgZsktmAf39bU6NDElHpnIkVptm5vl+c/Gl7X3c7ogH92z5B4tDbgS EoiqKAdtw7THHs2Vp0Tn+AxQ+ZeiIYpTmrkaCWZladMUw+1wJBiRWCI79AjlJ1qWaWOQO/4pLgu 8eY1M4h04caR23/QD5JwAhTXbM42kXBdslisBhHLdYe0wk8WKe06DVX9GKqn8O+wQAAz9tk7kDI 5vyCcU2JsyFWO9w== X-Developer-Key: i=jai.luthra@ideasonboard.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 39 +++++++++++++++------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index a84cd0107764..3236cc70c6a4 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -651,9 +651,25 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi */ if (sensorMetadata_) { V4L2SubdeviceFormat embeddedFormat = sensor_->embeddedDataFormat(); + 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) }, + }; + + 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);