From patchwork Fri Oct 23 10:58:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28571 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 54FA4C324C for ; Fri, 23 Oct 2026 10:58:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F031268FAD; Fri, 23 Oct 2026 12:58:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CapAWrfA"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C14B868FA1 for ; Fri, 23 Oct 2026 12:58:47 +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 608F5104A; Fri, 23 Oct 2026 12:56:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792752998; bh=sPGFc8hyv3iJQPsR+WwvUtc1BscyQ0jNVVkdhV+ui04=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CapAWrfAjuC87fWyKok5JmeiszuP2MuNkN1XzD0P/TaAsaL9cJ6wEkfKXxSOomGv9 jcXgU8MIkFvEmNs2VjaPqzDmysppthW+E9cf/Cc6SxO9EZ5Ze3zeIoRNn22KUt6Q7+ S1N2vrh6w6DhHJcqDFr626Vta17g/2FE0ecwiOkA= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:09 +0530 Subject: [PATCH WIP RFC 01/26] include: linux: Update uAPI headers to v7.3 + Common Raw Sensor Model MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-1-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=11571; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=sPGFc8hyv3iJQPsR+WwvUtc1BscyQ0jNVVkdhV+ui04=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3Drq7mbnuq5lqzmaXPd3I1T8A9bAliRxwi3 gzj5jniATuJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9wwAKCRBD3pH5JJpx RcZoD/wMVz0QCPSFhycfktnB0UrPQA7ZCuISh8nv9WdJWuNc1a4q0JIeicek2+5aC74mu0IGlIp QH8qAEQhzeawD8jyA91dzTx81VTaJa4lzVQDefPUyHea5qT4j2wy5rouyBlqjMBD9LcobomiA+C 5FnbUQKuYeD3Xf9nx+ewANRy46sLbp/33Ails7tBY5ZT/QDvTzkZDnlPMly2LAcAfzvFw9ZVRyj KRgdbEnqfhq1Nvu1GbP/O66Tyxj41XKJIHSEydLIiVd4sjCgDyRBrC/I6uu67oiS4aEID7mPe9c XedkFOjReCHl0z6Q6ayIrWaQoutQg0bRgIjcDNkp7XBwiYlDp+4iLC1N0idFXq6e9kjTPhTHBk5 qvrKbnC5f7pmL9WWi7r/p+gz5MjPp6tDfQiCFzbaU+3kDKP3MNqMujpcw1qXVoNu9aNjMT7D7nK E9u6hKZiTGBp/r4uvy23eYzIZkEHXGWFVNvfFxAAVumb85wRNPeHSeSByKMfTj0lVAz101LqzFF 0Zvl77vJjtBIYvrhZxySz1+DhbV/YedXycQj8rK+cjymXI8jDMNoPqq1x+bMHFRnU73ylXUbf0T P3Syv3d0maTYmh/YrVrjr8xtjqR+KLIQ9LTJVHU523uGqWlReGtZlgCkdC9one3pn65/VKpFRnA GaVzIk8T6gtG/dQ== 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" Update the linux headers to v7.3-rc1 (only bits relevant to libcamera as usual), along with the new format definitions and flags introduced by the Common Raw Sensor Model, which is currently under review on the linux-media list. Link: https://lore.kernel.org/all/20260409201501.975242-1-sakari.ailus@linux.intel.com/ Signed-off-by: Jai Luthra --- include/linux/media-bus-format.h | 12 ++++++--- include/linux/v4l2-controls.h | 58 +++++++++++++++++++++++++++++++++++++++- include/linux/v4l2-subdev.h | 15 ++++++++++- include/linux/videodev2.h | 27 ++++++++++++++----- 4 files changed, 100 insertions(+), 12 deletions(-) diff --git a/include/linux/media-bus-format.h b/include/linux/media-bus-format.h index 3e1c867e9073..40912155c741 100644 --- a/include/linux/media-bus-format.h +++ b/include/linux/media-bus-format.h @@ -190,8 +190,14 @@ #define MEDIA_BUS_FMT_META_20 0x8006 #define MEDIA_BUS_FMT_META_24 0x8007 -/* Specific metadata formats. Next is 0x9003. */ -#define MEDIA_BUS_FMT_CCS_EMBEDDED 0x9001 -#define MEDIA_BUS_FMT_OV2740_EMBEDDED 0x9002 +/* Generic (CFA independent) pixel data formats. Next is 0x9009. */ +#define MEDIA_BUS_FMT_RAW_8 0x9001 +#define MEDIA_BUS_FMT_RAW_10 0x9002 +#define MEDIA_BUS_FMT_RAW_12 0x9003 +#define MEDIA_BUS_FMT_RAW_14 0x9004 +#define MEDIA_BUS_FMT_RAW_16 0x9005 +#define MEDIA_BUS_FMT_RAW_20 0x9006 +#define MEDIA_BUS_FMT_RAW_24 0x9007 +#define MEDIA_BUS_FMT_RAW_28 0x9008 #endif /* __LINUX_MEDIA_BUS_FORMAT_H */ diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h index aff5280b63cc..d130e3538e8a 100644 --- a/include/linux/v4l2-controls.h +++ b/include/linux/v4l2-controls.h @@ -121,6 +121,15 @@ enum v4l2_colorfx { */ #define V4L2_CID_USER_MEYE_BASE (V4L2_CID_USER_BASE + 0x1000) +/* + * The base for the vim2m driver controls. + * We reserve 16 controls for this driver. + * The vim2m control range clashed with the meye control range, which was not + * intended, but since the meye driver has been removed, we can just keep the + * vim2m control range. + */ +#define V4L2_CID_USER_VIM2M_BASE (V4L2_CID_USER_BASE + 0x1000) + /* The base for the bttv driver controls. * We reserve 32 controls for this driver. */ #define V4L2_CID_USER_BTTV_BASE (V4L2_CID_USER_BASE + 0x1010) @@ -177,7 +186,6 @@ enum v4l2_colorfx { * We reserve 128 controls for this driver. */ #define V4L2_CID_USER_CCS_BASE (V4L2_CID_USER_BASE + 0x10f0) - /* * The base for Allegro driver controls. * We reserve 16 controls for this driver. @@ -233,6 +241,18 @@ enum v4l2_colorfx { */ #define V4L2_CID_USER_MALI_C55_BASE (V4L2_CID_USER_BASE + 0x1230) +/* + * The base for the ST DCMIPP driver controls. + * We reserve 16 controls for this driver + */ +#define V4L2_CID_USER_DCMIPP_BASE (V4L2_CID_USER_BASE + 0x1240) + +/* + * The base for IT6625/IT6626 driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_IT6625_BASE (V4L2_CID_USER_BASE + 0x1250) + /* MPEG-class control IDs */ /* The MPEG controls are applicable to all codec controls * and the 'MPEG' part of the define is historical */ @@ -461,6 +481,8 @@ enum v4l2_mpeg_video_intra_refresh_period_type { V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_CYCLIC = 1, }; +#define V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION (V4L2_CID_CODEC_BASE + 238) + /* CIDs for the MPEG-2 Part 2 (H.262) codec */ #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270) enum v4l2_mpeg_video_mpeg2_level { @@ -1232,6 +1254,36 @@ enum v4l2_jpeg_chroma_subsampling { #define V4L2_CID_UNIT_CELL_SIZE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 8) #define V4L2_CID_NOTIFY_GAINS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 9) +#define V4L2_CID_CFA_PATTERN (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 10) +#define V4L2_CFA_PATTERN_GRBG 0x00000000 +#define V4L2_CFA_PATTERN_RGGB 0x00000001 +#define V4L2_CFA_PATTERN_BGGR 0x00000002 +#define V4L2_CFA_PATTERN_GBRG 0x00000003 +#define V4L2_CFA_PATTERN_MONO 0x00010000 + +#define V4L2_CID_CFA_PATTERN_FLIP (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 11) +#define V4L2_CFA_PATTERN_FLIP_HORIZONTAL (1U << 0) +#define V4L2_CFA_PATTERN_FLIP_VERTICAL (1U << 1) +#define V4L2_CFA_PATTERN_FLIP_BOTH \ + (V4L2_CFA_PATTERN_FLIP_HORIZONTAL | V4L2_CFA_PATTERN_FLIP_VERTICAL) + +#define V4L2_CID_METADATA_LAYOUT (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 12) +#define V4L2_METADATA_LAYOUT_CCS 1U +#define V4L2_METADATA_LAYOUT_OV2740 2U + +#define V4L2_CID_BINNING_FACTORS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 13) +#define V4L2_BINNING_FACTORS_MAKE(hnum, hdem, vnum, vdem) \ + (((__u64)(0xffff & hnum) << 48) | ((__u64)(0xffff & hdem) << 32) | \ + ((__u64)(0xffff & vnum) << 16) | (__u64)(0xffff & vdem)) +#define V4L2_BINNING_FACTORS_HNUM(binning) (__u16)((binning >> 48) & 0xffff) +#define V4L2_BINNING_FACTORS_HDEM(binning) (__u16)((binning >> 32) & 0xffff) +#define V4L2_BINNING_FACTORS_VNUM(binning) (__u16)((binning >> 16) & 0xffff) +#define V4L2_BINNING_FACTORS_VDEM(binning) (__u16)(binning & 0xffff) +#define V4L2_CID_SUBSAMPLING_HORIZONTAL (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 14) +#define V4L2_CID_SUBSAMPLING_VERTICAL (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 15) + +#define V4L2_CID_FRAME_LENGTH_LINES (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 16) +#define V4L2_CID_LINE_LENGTH_PIXELS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 17) /* Image processing controls */ @@ -1243,6 +1295,10 @@ enum v4l2_jpeg_chroma_subsampling { #define V4L2_CID_TEST_PATTERN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3) #define V4L2_CID_DEINTERLACING_MODE (V4L2_CID_IMAGE_PROC_CLASS_BASE + 4) #define V4L2_CID_DIGITAL_GAIN (V4L2_CID_IMAGE_PROC_CLASS_BASE + 5) +#define V4L2_CID_CONFIG_MODEL (V4L2_CID_IMAGE_PROC_CLASS_BASE + 6) + +#define V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR (1U << 0) +#define V4L2_CONFIG_MODEL_MIPI_CCS (1U << 1) /* DV-class control IDs defined by V4L2 */ #define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900) diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h index 839b1329afb2..9d5ba062be19 100644 --- a/include/linux/v4l2-subdev.h +++ b/include/linux/v4l2-subdev.h @@ -196,8 +196,11 @@ struct v4l2_subdev_capability { /* The v4l2 sub-device video device node is registered in read-only mode. */ #define V4L2_SUBDEV_CAP_RO_SUBDEV 0x00000001 +/* Reserved, old STREAMS bit libcamera used before API stabilisation. */ +/* #define V4L2_SUBDEV_CAP_STREAMS_PRELIMINARY 0x00000002 */ + /* The v4l2 sub-device supports routing and multiplexed streams. */ -#define V4L2_SUBDEV_CAP_STREAMS 0x00000002 +#define V4L2_SUBDEV_CAP_STREAMS 0x00000004 /* * Is the route active? An active route will start when streaming is enabled @@ -209,6 +212,10 @@ struct v4l2_subdev_capability { * unset. */ #define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1) +/* + * Is the route static? Routes with the STATIC flag are not removable. + */ +#define V4L2_SUBDEV_ROUTE_FL_STATIC (1U << 2) /** * struct v4l2_subdev_route - A route inside a subdev @@ -263,6 +270,12 @@ struct v4l2_subdev_routing { */ #define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH (1ULL << 1) +/* + * The client is aware of the common raw sensor model and expects that on camera + * sensor UAPI where supported. + */ +#define V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR (1ULL << 2) + /** * struct v4l2_subdev_client_capability - Capabilities of the client accessing * the subdev diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index e14c78ed51b2..129728c8bf89 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -718,6 +718,16 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16 GRGR.. BGBG.. */ #define V4L2_PIX_FMT_SRGGB16 v4l2_fourcc('R', 'G', '1', '6') /* 16 RGRG.. GBGB.. */ +/* Generic CSI-2 packed raw pixel formats */ +#define V4L2_PIX_FMT_RAW_8 v4l2_fourcc('R', 'A', 'W', '8') +#define V4L2_PIX_FMT_RAW_CSI2_10 v4l2_fourcc('R', 'A', 'C', 'A') +#define V4L2_PIX_FMT_RAW_CSI2_12 v4l2_fourcc('R', 'A', 'C', 'C') +#define V4L2_PIX_FMT_RAW_CSI2_14 v4l2_fourcc('R', 'A', 'C', 'E') +#define V4L2_PIX_FMT_RAW_16 v4l2_fourcc('R', 'A', 'W', 'G') +#define V4L2_PIX_FMT_RAW_CSI2_20 v4l2_fourcc('R', 'A', 'C', 'K') +#define V4L2_PIX_FMT_RAW_24 v4l2_fourcc('R', 'A', 'W', 'O') +#define V4L2_PIX_FMT_RAW_CSI2_28 v4l2_fourcc('R', 'A', 'C', 'S') + /* HSV formats */ #define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3') #define V4L2_PIX_FMT_HSV32 v4l2_fourcc('H', 'S', 'V', '4') @@ -843,7 +853,6 @@ struct v4l2_pix_format { #define V4L2_META_FMT_D4XX v4l2_fourcc('D', '4', 'X', 'X') /* D4XX Payload Header metadata */ #define V4L2_META_FMT_UVC_MSXU_1_5 v4l2_fourcc('U', 'V', 'C', 'M') /* UVC MSXU metadata */ #define V4L2_META_FMT_VIVID v4l2_fourcc('V', 'I', 'V', 'D') /* Vivid Metadata */ -#define V4L2_META_FMT_SENSOR_DATA v4l2_fourcc('S', 'E', 'N', 'S') /* Sensor Ancillary metadata */ #define V4L2_META_FMT_BCM2835_ISP_STATS v4l2_fourcc('B', 'S', 'T', 'A') /* BCM2835 ISP stats */ #define V4L2_META_FMT_BCM2835_ISP_PARAMS v4l2_fourcc('B', 'C', 'M', 'P') /* BCM2835 ISP params */ @@ -865,17 +874,21 @@ struct v4l2_pix_format { #define V4L2_META_FMT_MALI_C55_PARAMS v4l2_fourcc('C', '5', '5', 'P') /* ARM Mali-C55 Parameters */ #define V4L2_META_FMT_MALI_C55_STATS v4l2_fourcc('C', '5', '5', 'S') /* ARM Mali-C55 3A Statistics */ +/* Vendor specific - used for Dreamchip RPP-X1 ISP */ +#define V4L2_META_FMT_RPPX1_PARAMS v4l2_fourcc('D', 'R', '1', 'P') /* Dreamchip RPP-X1 Parameters */ +#define V4L2_META_FMT_RPPX1_STATS v4l2_fourcc('D', 'R', '1', 'S') /* Dreamchip RPP-X1 Statistics */ + /* * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when * adding new ones! */ #define V4L2_META_FMT_GENERIC_8 v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */ -#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */ -#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */ -#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */ -#define V4L2_META_FMT_GENERIC_CSI2_16 v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */ -#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */ -#define V4L2_META_FMT_GENERIC_CSI2_24 v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'E', 'C', 'A') /* 10-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'E', 'C', 'C') /* 12-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'E', 'C', 'E') /* 14-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_16 v4l2_fourcc('M', 'E', 'T', 'G') /* Generic 16-bit 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'E', 'C', 'K') /* 20-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_24 v4l2_fourcc('M', 'E', 'T', 'O') /* Generic 24-bit 8-bit metadata */ /* priv field value to indicates that subsequent fields are valid. */ #define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe From patchwork Fri Oct 23 10:58:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28572 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 2951BC324C for ; Fri, 23 Oct 2026 10:58:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB60E68FB0; Fri, 23 Oct 2026 12:58:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iR7vElPb"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 23EB368F9F for ; Fri, 23 Oct 2026 12:58:53 +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 A60E11E4; Fri, 23 Oct 2026 12:56:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753004; bh=BJYrZL4jXrC03mirIhEf3pzbHmaS9D7KZCDY22Gv3mc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iR7vElPbjgXQyO0uTszJlkoAafpBvuwLaBM3S+YvuQXd206bpJ2xERNmyeXr6FwZV xIf8pXyimfO3d3iKVKFpxj+T7DapW1zlXaVOBS+onboayBhH9CXNhdeIUwyEY1GIbZ IF6ed9zcipls04bzniTrOro6wRLiMGnAnSL0OhjM= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:10 +0530 Subject: [PATCH WIP RFC 02/26] libcamera: v4l2_subdevice: Add mediaBusInfo for generic raw formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-2-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=34179; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=BJYrZL4jXrC03mirIhEf3pzbHmaS9D7KZCDY22Gv3mc=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3EIS8y0kfumhPcO+8aTG9zdTBrDVuQkfhFZ 9Z0emXXtwKJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9xAAKCRBD3pH5JJpx RWbGD/9ZKooSTCePVq+OZ0RadmNiF0+8rp1FcYhipjL7szc/u0zfuMJ8KLf5X62rqCETRnz1yCe IsE26QDPS0D1xr+dviqdCpjjzKwKnspb7+cgMd265NMNNdB+wFIY5Jyhct7+uyYAZ6WI00ebAwI jqYWh1Xf4k0iGmDUA+z6lP3L+c33WJ0M86KyJSvMaE+NWX82f3lgaf6AIseFzHW1SH1f59At8h/ uRsZCZIKX63IPoawvRC0xE+uTOTPDbGXvKcCVzXD3CJtw98IJ+YhilG0wrayACj+t+zZdRgkf4Q jxJg0NJ7qh4NEc+p6wffhqohJX0e9F9miQDDRY0I0JPB0c/eIgA2zepRXeY52P++Skz/cvbteqv BgPfAMXw3LgLmQZ+lB/Gim1AmyLYhXvsiJ+HGFThrnjXwCHxKlC1znoK4JEQgEKLdayFU+TyvQU 2M7r1aT1yxisjAcHdoy386PS9DxK1n858zUu9i0AU/L83FnRlfTbXcieqJIQgIOKcXa9TJczEkA fkemsjGZxbqRs8MzoNnMvN9SQmaR5M/OS4xNJ3+tYYdudVehVPnsJAhbBwh8SZ9406NMbNq3MZE gDiDiFDCWPT/Ax2Rx0Na3ftc+ooqIMHOR/mlN/xdD0RGpaSp84ge+dUg7niIFG6CcDmUGVfZ/u1 T6SHcj3+POv27ZA== 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" The generic RAW formats are used by the new Common Raw Sensor Model. Add media bus information for the new mbus codes. Also add a new boolean property so pipelines that don't yet support the new codes can easily ignore them. Signed-off-by: Jai Luthra --- include/libcamera/internal/v4l2_subdevice.h | 1 + src/libcamera/v4l2_subdevice.cpp | 178 +++++++++++++++++++++++++--- 2 files changed, 161 insertions(+), 18 deletions(-) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index c37a82afa881..93003ccf3532 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -49,6 +49,7 @@ public: Type type; unsigned int bitsPerPixel; PixelFormatInfo::ColourEncoding colourEncoding; + bool genericRaw; }; struct V4L2SubdeviceCapability final : v4l2_subdev_capability { diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index a69de154e8bb..db5eab9a709d 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -96,6 +96,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE, { .name = "RGB444_2X8_PADHI_LE", @@ -103,6 +104,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE, { .name = "RGB555_2X8_PADHI_BE", @@ -110,6 +112,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE, { .name = "RGB555_2X8_PADHI_LE", @@ -117,6 +120,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB565_1X16, { .name = "RGB565_1X16", @@ -124,6 +128,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_BGR565_2X8_BE, { .name = "BGR565_2X8_BE", @@ -131,6 +136,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_BGR565_2X8_LE, { .name = "BGR565_2X8_LE", @@ -138,6 +144,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB565_2X8_BE, { .name = "RGB565_2X8_BE", @@ -145,6 +152,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB565_2X8_LE, { .name = "RGB565_2X8_LE", @@ -152,6 +160,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB666_1X18, { .name = "RGB666_1X18", @@ -159,6 +168,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 18, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_BGR888_1X24, { .name = "BGR888_1X24", @@ -166,6 +176,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB888_1X24, { .name = "RGB888_1X24", @@ -173,6 +184,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB888_2X12_BE, { .name = "RGB888_2X12_BE", @@ -180,6 +192,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB888_2X12_LE, { .name = "RGB888_2X12_LE", @@ -187,6 +200,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB121212_1X36, { .name = "RGB121212_1X36", @@ -194,6 +208,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 36, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_RGB202020_1X60, { .name = "RGB202020_1X60", @@ -201,6 +216,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 60, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_ARGB8888_1X32, { .name = "ARGB8888_1X32", @@ -208,6 +224,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 32, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_Y8_1X8, { .name = "Y8_1X8", @@ -215,6 +232,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_UV8_1X8, { .name = "UV8_1X8", @@ -222,6 +240,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_UYVY8_1_5X8, { .name = "UYVY8_1_5X8", @@ -229,6 +248,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_VYUY8_1_5X8, { .name = "VYUY8_1_5X8", @@ -236,6 +256,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUYV8_1_5X8, { .name = "YUYV8_1_5X8", @@ -243,6 +264,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YVYU8_1_5X8, { .name = "YVYU8_1_5X8", @@ -250,6 +272,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_UYVY8_2X8, { .name = "UYVY8_2X8", @@ -257,6 +280,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_VYUY8_2X8, { .name = "VYUY8_2X8", @@ -264,6 +288,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUYV8_2X8, { .name = "YUYV8_2X8", @@ -271,6 +296,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YVYU8_2X8, { .name = "YVYU8_2X8", @@ -278,6 +304,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_Y10_1X10, { .name = "Y10_1X10", @@ -285,6 +312,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_UYVY10_2X10, { .name = "UYVY10_2X10", @@ -292,6 +320,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_VYUY10_2X10, { .name = "VYUY10_2X10", @@ -299,6 +328,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUYV10_2X10, { .name = "YUYV10_2X10", @@ -306,6 +336,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YVYU10_2X10, { .name = "YVYU10_2X10", @@ -313,6 +344,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_Y12_1X12, { .name = "Y12_1X12", @@ -320,6 +352,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_Y16_1X16, { .name = "Y16_1X16", @@ -327,6 +360,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_UYVY8_1X16, { .name = "UYVY8_1X16", @@ -334,6 +368,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_VYUY8_1X16, { .name = "VYUY8_1X16", @@ -341,6 +376,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUYV8_1X16, { .name = "YUYV8_1X16", @@ -348,6 +384,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YVYU8_1X16, { .name = "YVYU8_1X16", @@ -355,6 +392,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YDYUYDYV8_1X16, { .name = "YDYUYDYV8_1X16", @@ -362,6 +400,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_UYVY10_1X20, { .name = "UYVY10_1X20", @@ -369,6 +408,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_VYUY10_1X20, { .name = "VYUY10_1X20", @@ -376,6 +416,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUYV10_1X20, { .name = "YUYV10_1X20", @@ -383,6 +424,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YVYU10_1X20, { .name = "YVYU10_1X20", @@ -390,6 +432,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUV8_1X24, { .name = "YUV8_1X24", @@ -397,6 +440,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUV10_1X30, { .name = "YUV10_1X30", @@ -404,6 +448,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 30, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_AYUV8_1X32, { .name = "AYUV8_1X32", @@ -411,6 +456,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 32, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_UYVY12_2X12, { .name = "UYVY12_2X12", @@ -418,6 +464,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_VYUY12_2X12, { .name = "VYUY12_2X12", @@ -425,6 +472,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUYV12_2X12, { .name = "YUYV12_2X12", @@ -432,6 +480,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YVYU12_2X12, { .name = "YVYU12_2X12", @@ -439,6 +488,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_UYVY12_1X24, { .name = "UYVY12_1X24", @@ -446,6 +496,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_VYUY12_1X24, { .name = "VYUY12_1X24", @@ -453,6 +504,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YUYV12_1X24, { .name = "YUYV12_1X24", @@ -460,6 +512,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_YVYU12_1X24, { .name = "YVYU12_1X24", @@ -467,6 +520,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR8_1X8, { .name = "SBGGR8_1X8", @@ -474,6 +528,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGBRG8_1X8, { .name = "SGBRG8_1X8", @@ -481,6 +536,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGRBG8_1X8, { .name = "SGRBG8_1X8", @@ -488,6 +544,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SRGGB8_1X8, { .name = "SRGGB8_1X8", @@ -495,6 +552,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, { .name = "SBGGR10_ALAW8_1X8", @@ -502,6 +560,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, { .name = "SGBRG10_ALAW8_1X8", @@ -509,6 +568,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, { .name = "SGRBG10_ALAW8_1X8", @@ -516,6 +576,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, { .name = "SRGGB10_ALAW8_1X8", @@ -523,6 +584,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, { .name = "SBGGR10_DPCM8_1X8", @@ -530,6 +592,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, { .name = "SGBRG10_DPCM8_1X8", @@ -537,6 +600,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, { .name = "SGRBG10_DPCM8_1X8", @@ -544,6 +608,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, { .name = "SRGGB10_DPCM8_1X8", @@ -551,6 +616,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, { .name = "SBGGR10_2X8_PADHI_BE", @@ -558,6 +624,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, { .name = "SBGGR10_2X8_PADHI_LE", @@ -565,6 +632,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, { .name = "SBGGR10_2X8_PADLO_BE", @@ -572,6 +640,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, { .name = "SBGGR10_2X8_PADLO_LE", @@ -579,6 +648,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR10_1X10, { .name = "SBGGR10_1X10", @@ -586,6 +656,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGBRG10_1X10, { .name = "SGBRG10_1X10", @@ -593,6 +664,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGRBG10_1X10, { .name = "SGRBG10_1X10", @@ -600,6 +672,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SRGGB10_1X10, { .name = "SRGGB10_1X10", @@ -607,6 +680,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR12_1X12, { .name = "SBGGR12_1X12", @@ -614,6 +688,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGBRG12_1X12, { .name = "SGBRG12_1X12", @@ -621,6 +696,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGRBG12_1X12, { .name = "SGRBG12_1X12", @@ -628,6 +704,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SRGGB12_1X12, { .name = "SRGGB12_1X12", @@ -635,6 +712,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR14_1X14, { .name = "SBGGR14_1X14", @@ -642,6 +720,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 14, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGBRG14_1X14, { .name = "SGBRG14_1X14", @@ -649,6 +728,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 14, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGRBG14_1X14, { .name = "SGRBG14_1X14", @@ -656,6 +736,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 14, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SRGGB14_1X14, { .name = "SRGGB14_1X14", @@ -663,62 +744,71 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 14, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR16_1X16, { .name = "SBGGR16_1X16", .code = MEDIA_BUS_FMT_SBGGR16_1X16, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGBRG16_1X16, { .name = "SGBRG16_1X16", .code = MEDIA_BUS_FMT_SGBRG16_1X16, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGRBG16_1X16, { .name = "SGRBG16_1X16", .code = MEDIA_BUS_FMT_SGRBG16_1X16, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SRGGB16_1X16, { .name = "SRGGB16_1X16", .code = MEDIA_BUS_FMT_SRGGB16_1X16, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 16, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SBGGR20_1X20, { .name = "SBGGR20_1X20", .code = MEDIA_BUS_FMT_SBGGR20_1X20, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGBRG20_1X20, { .name = "SGBRG20_1X20", .code = MEDIA_BUS_FMT_SGBRG20_1X20, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SGRBG20_1X20, { .name = "SGRBG20_1X20", .code = MEDIA_BUS_FMT_SGRBG20_1X20, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_SRGGB20_1X20, { .name = "SRGGB20_1X20", .code = MEDIA_BUS_FMT_SRGGB20_1X20, .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 20, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, /* \todo Clarify colour encoding for HSV formats */ { MEDIA_BUS_FMT_AHSV8888_1X32, { @@ -727,6 +817,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 32, .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .genericRaw = false, } }, { MEDIA_BUS_FMT_JPEG_1X8, { .name = "JPEG_1X8", @@ -734,6 +825,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Image, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .genericRaw = false, } }, { MEDIA_BUS_FMT_METADATA_FIXED, { .name = "METADATA_FIXED", @@ -741,6 +833,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Metadata, .bitsPerPixel = 0, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_META_8, { .name = "META_8", @@ -748,6 +841,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Metadata, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_META_10, { .name = "META_10", @@ -755,6 +849,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Metadata, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_META_12, { .name = "META_12", @@ -762,6 +857,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Metadata, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_META_14, { .name = "META_14", @@ -769,6 +865,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Metadata, .bitsPerPixel = 14, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_META_16, { .name = "META_16", @@ -776,6 +873,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Metadata, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_META_20, { .name = "META_20", @@ -783,6 +881,7 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Metadata, .bitsPerPixel = 20, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, { MEDIA_BUS_FMT_META_24, { .name = "META_24", @@ -790,20 +889,63 @@ const std::map mediaBusFormatInfo{ .type = MediaBusFormatInfo::Type::Metadata, .bitsPerPixel = 24, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = false, } }, - { MEDIA_BUS_FMT_CCS_EMBEDDED, { - .name = "CCS_EMBEDDED", - .code = MEDIA_BUS_FMT_CCS_EMBEDDED, - .type = MediaBusFormatInfo::Type::EmbeddedData, - .bitsPerPixel = 0, + { MEDIA_BUS_FMT_RAW_8, { + .name = "RAW_8", + .code = MEDIA_BUS_FMT_RAW_8, + .type = MediaBusFormatInfo::Type::Image, + .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = true, } }, - { MEDIA_BUS_FMT_OV2740_EMBEDDED, { - .name = "OV2740_EMBEDDED", - .code = MEDIA_BUS_FMT_CCS_EMBEDDED, - .type = MediaBusFormatInfo::Type::EmbeddedData, - .bitsPerPixel = 0, + { MEDIA_BUS_FMT_RAW_10, { + .name = "RAW_10", + .code = MEDIA_BUS_FMT_RAW_10, + .type = MediaBusFormatInfo::Type::Image, + .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = true, + } }, + { MEDIA_BUS_FMT_RAW_12, { + .name = "RAW_12", + .code = MEDIA_BUS_FMT_RAW_12, + .type = MediaBusFormatInfo::Type::Image, + .bitsPerPixel = 12, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = true, + } }, + { MEDIA_BUS_FMT_RAW_14, { + .name = "RAW_14", + .code = MEDIA_BUS_FMT_RAW_14, + .type = MediaBusFormatInfo::Type::Image, + .bitsPerPixel = 14, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = true, + } }, + { MEDIA_BUS_FMT_RAW_16, { + .name = "RAW_16", + .code = MEDIA_BUS_FMT_RAW_16, + .type = MediaBusFormatInfo::Type::Image, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = true, + } }, + { MEDIA_BUS_FMT_RAW_20, { + .name = "RAW_20", + .code = MEDIA_BUS_FMT_RAW_20, + .type = MediaBusFormatInfo::Type::Image, + .bitsPerPixel = 20, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = true, + } }, + { MEDIA_BUS_FMT_RAW_24, { + .name = "RAW_24", + .code = MEDIA_BUS_FMT_RAW_24, + .type = MediaBusFormatInfo::Type::Image, + .bitsPerPixel = 24, + .colourEncoding = PixelFormatInfo::ColourEncodingRAW, + .genericRaw = true, } }, }; From patchwork Fri Oct 23 10:58:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28573 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 CB217C324C for ; Fri, 23 Oct 2026 10:58:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8247668FAB; Fri, 23 Oct 2026 12:58:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NJEsIAdx"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 70FD568FA6 for ; Fri, 23 Oct 2026 12:58:58 +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 4A641E4E; Fri, 23 Oct 2026 12:56:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753009; bh=AhGT4FPmpa9myU+nQxSA0qee8i4RAI2D4Ucyh0KHY/Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NJEsIAdxcsvVyNgDjvdEiEuXFxKFrZPQkKYP5XZ0vOJSVPn3Sv23PMeiuiKY141Su IemewpEv3lzxiYsYXGpvenrmb6Rmw8GvQvcSWfPHiEYjfFQqPL8lhMoNb41TH2BkRK bKncgrGU/PkzS49YCl6Rl+upZkhAi2smT1ELpkUU= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:11 +0530 Subject: [PATCH WIP RFC 03/26] libcamera: v4l2_pixelformat: Update to latest version of generic META formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-3-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=1133; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=AhGT4FPmpa9myU+nQxSA0qee8i4RAI2D4Ucyh0KHY/Y=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3F+CmjKMZQ6UmcRqALt6PtxYNdTv/3ugdzL 090vzHpvzOJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9xQAKCRBD3pH5JJpx RZTED/46f/yGxyLB1A/+HKujWNxy4GOQTjPLILbcuOg7Zv8DIAqiT3MEYRl675B8FurgDJ7lhfV WcRe+ZSJ3B1UEDVoURUyXlgMT4fJQgWR7aK1zMlCQkXRCknsjRxjGi6pntsYj07cgjwEXZ1nVod OVhC1D0x9za0M1ciqu8nI5uIYE5z59wEvu1HJExtrKpnliKQWcg258YZuLGZDQ/9OdGOAAgAjra 3YbppaaHksvMm1LcKxzXznWaP3U8DJzJeZaycsB/o67MQGy4gmQmoakAX4M34VHQ/k1ymwSj0/H jrzWPOjdGN2DQlN525sEgrFpNUPEWpW3bx3JGY1Sjxu9EcFVEVvSCZEatJrl/uQzC9QaeNKblTt eTXF9O0qeXYhJAby7jcJuGJ1/g62YeJAk1rGGYrBuTZ3fywYFTBCLtV8TBwuCy5pRQ5nocfYCMb trF5d4TMwV54YoHljNvlIXxHgnusbBORm5CnGq2mnQ0s1hEMIYGs6Da5LDBpEDTl0GFvHUYxo+3 kCYMGIZtyUhysqWgc9wUT7VPryZyIpdRdl4ox4fWkgJ5dgaawe6lH9a/haatrA2EHdq7Kk5sCqU 9PYtLhqEnrc1ystbcN5jbKlVl0srNwMIGmZ1xSsJyIzB5MmdkxiFRqpyfVQcCgnhZ2VsFo9iWw5 Jrvw9rRX9HDogVw== 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" The 16 and 24-bit generic metadata format macros no longer mention _CSI2_ in the unmerged series that introduce them, as there is no packing needed for sizes divisble by 8 bits. Update their usage in libcamera to match. Fixes: 99b54c2c55a8 ("libcamera: v4l2_videodevice: Update to the new kernel metadata API") Signed-off-by: Jai Luthra --- src/libcamera/v4l2_pixelformat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index e8b3eb9c1394..c3e01a10e72a 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -397,9 +397,9 @@ bool V4L2PixelFormat::isGenericLineBasedMetadata() const case V4L2_META_FMT_GENERIC_CSI2_10: case V4L2_META_FMT_GENERIC_CSI2_12: case V4L2_META_FMT_GENERIC_CSI2_14: - case V4L2_META_FMT_GENERIC_CSI2_16: + case V4L2_META_FMT_GENERIC_16: case V4L2_META_FMT_GENERIC_CSI2_20: - case V4L2_META_FMT_GENERIC_CSI2_24: + case V4L2_META_FMT_GENERIC_24: return true; default: return false; 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); From patchwork Fri Oct 23 10:58:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28575 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 7553CC3302 for ; Fri, 23 Oct 2026 10:59:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3196968FAB; Fri, 23 Oct 2026 12:59:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NaBCM8H3"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 541D268FA6 for ; Fri, 23 Oct 2026 12:59:09 +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 17E751E4; Fri, 23 Oct 2026 12:56:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753020; bh=QwffuVXIcVmMk/aVQ0Yt/tFivYebB/OPSzrLZqhOihc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NaBCM8H3xHV1iFYlhNGToGjVEmU1IOqUQePU/6WcUMHqHbMG/vkkEuC38GtBmCink h882Afx6NJTdnLEOAmg9hjCJDg75ywmmgBjTymmuKs3O5SdOuLzRwn7jsMsBrN9TEX c6piVI6CLafcsDIoZxpouIF2w78kRbMFjBHtbyO0= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:13 +0530 Subject: [PATCH WIP RFC 05/26] include: uapi: videodev2: Add formats for unpacked RAW MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-5-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=1668; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=QwffuVXIcVmMk/aVQ0Yt/tFivYebB/OPSzrLZqhOihc=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3HCyBUuVtciKEyr2b0bFJhGhpvAIrU0btBI JxLwwMXOn6JAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9xwAKCRBD3pH5JJpx RQbdD/97d1ujW/aTyFcFpAtVkgLcn9zifLnVWbr4RoXCN675jyMrR0oHotc+4ty7IOo43KOUYj8 FyVcTtE+I0Vh7N6jETSrZakbpDxgPVT0MNBtqUW50DON8wvZgcHb16GXFoIBbagarXXWvDEsAKL 8usDESOe/I4/3FTiQQJVzz7mJuFadGvaRqjlZIe4sR3/vTND7H1LlsF6YSe7Y7wbUSKBD+VFbIh /CgtwM1rsNEcZ3ppf8MKjBVm6i7Ld/SBVwip9DgC9O6x9JhEatBYl9P8yd4cN7/t9GS/x47o/oH sonwgN8UiKvnsF7ESIOJg6PEK1eIyfgLOOHpAMpR4Sfa4/Rfi3vjoN1Z0V++hTtTKedFEW8lebV 9Xll4KwBciLedL+WfYtvHq7d1Drjst3epQMphAnRd3F7ah7XM20zS3qX1R0wam/2HFCbZGqBmqt iUsgIXrzR3k4dtOT1YsEz+J2EhpHhWVNR8RlPdpKQmMuC+cR8LnBLir+k7Oz/B7S6nEaFsShDJV McB84ECqfmNn4Xj9qYyR0p5KxeOpirJ7I6Jbt+IgriMr5jjYZ+x2t26dOmmpj7ep/BJWhFcU4Vu F5Wvho99IUJVY96F+t7VwVYof4ZBFngqF9tuQ5dr9uq9FWmUNq3Mox8Pf5tCgLDvaWhW6+Wc9Eg kvvcgYqtKPg+Sgw== 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" The upstream series that introduced generic raw formats did not support unpacked variants for RAW12, RAW14 etc. These were supported by the old-style mbus codes, so add them in our header for now to prevent breaking pipelines that use them. Signed-off-by: Jai Luthra --- include/linux/videodev2.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 129728c8bf89..05bd394b1a67 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -720,12 +720,17 @@ struct v4l2_pix_format { /* Generic CSI-2 packed raw pixel formats */ #define V4L2_PIX_FMT_RAW_8 v4l2_fourcc('R', 'A', 'W', '8') +#define V4L2_PIX_FMT_RAW_10 v4l2_fourcc('R', 'A', 'W', 'A') +#define V4L2_PIX_FMT_RAW_12 v4l2_fourcc('R', 'A', 'W', 'C') +#define V4L2_PIX_FMT_RAW_14 v4l2_fourcc('R', 'A', 'W', 'E') +#define V4L2_PIX_FMT_RAW_16 v4l2_fourcc('R', 'A', 'W', 'G') +#define V4L2_PIX_FMT_RAW_20 v4l2_fourcc('R', 'A', 'W', 'K') +#define V4L2_PIX_FMT_RAW_24 v4l2_fourcc('R', 'A', 'W', 'O') +#define V4L2_PIX_FMT_RAW_28 v4l2_fourcc('R', 'A', 'W', 'S') #define V4L2_PIX_FMT_RAW_CSI2_10 v4l2_fourcc('R', 'A', 'C', 'A') #define V4L2_PIX_FMT_RAW_CSI2_12 v4l2_fourcc('R', 'A', 'C', 'C') #define V4L2_PIX_FMT_RAW_CSI2_14 v4l2_fourcc('R', 'A', 'C', 'E') -#define V4L2_PIX_FMT_RAW_16 v4l2_fourcc('R', 'A', 'W', 'G') #define V4L2_PIX_FMT_RAW_CSI2_20 v4l2_fourcc('R', 'A', 'C', 'K') -#define V4L2_PIX_FMT_RAW_24 v4l2_fourcc('R', 'A', 'W', 'O') #define V4L2_PIX_FMT_RAW_CSI2_28 v4l2_fourcc('R', 'A', 'C', 'S') /* HSV formats */ From patchwork Fri Oct 23 10:58:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28576 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 DD504C324C for ; Fri, 23 Oct 2026 10:59:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AA55368FB7; Fri, 23 Oct 2026 12:59:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tidd7F3K"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 25E3368FA6 for ; Fri, 23 Oct 2026 12:59:14 +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 EAA0412D6; Fri, 23 Oct 2026 12:57:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753025; bh=1ODl9cZsYJzrjIEQvMQ0X7NW3Ay3zdU9c85HhMCn7As=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tidd7F3KFl6i0uMwN4j0gPC1DWnurSyJkoGtQP6oYSuIBohg4g2Mixke4+AKVmMVO Ebw26tcFxqAydSFu1z3yLqyILNEBmDpjGOHMu0kHtc5JCvSrHe0bMEa1Eb3nX/BZmi FOLhiqUaDKCYQiaVA+lnq1zaA0fUGIlLp69lkkos= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:14 +0530 Subject: [PATCH WIP RFC 06/26] include: uapi: videodev2: Add RAW device-specific bayer formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-6-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=2599; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=1ODl9cZsYJzrjIEQvMQ0X7NW3Ay3zdU9c85HhMCn7As=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3Ik4UBUcnYz4Bph9C+unM3laNjrNbrgbvoj 5znQcJJGK+JAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9yAAKCRBD3pH5JJpx RUcsD/403peajxd5JuCGfk45jkWUI+OShx4J1OFXo++gZjbe3gxZeCa3kYbBkQ/NK5uj/PVJDvv dvND4dTeA6c/FKE/6ohM4cZ/7K96cVxsgwh9dSoJJP8E4kYJCkzE3864L/iAy17MM1A5f2uqMxe Fyy4YTykgjhbG13Ccdt9cujuosMyds6oVLcdFRdNL5r523cQTvQXnz71citiH4ZyKDoCFzl90gK D5OGci/1CeJ0FNhyaw2N9xkDhTIoo2yDtyVIsvVN8FT4UVeqsnO/i7emScc9LQSXPJkxu9t+D4f t/vKoFXGSQ1Uoi8F++oj8cL12ZOFlenI/AusUjUPLS8vlHubYy5FNlr/8y26N0FaIALicYWpzmY Jrue13ANiiZjPzPaMGzBAQD0aJlPlBuyl6zsghH+usYrpaCbO6RHxfayyC+muusBJymVW/gv+jo Uvp4ay4MQbBXLvxN8DgwvAxd+p7wJ3LhUV0NgHbBMXtsyxT5T10lgrfsa3X0JRn08UaPZr7mgPT yb39lGBS5auJY3hkLaFXEll9E0EInDYQDpYwUuY/6MGE57rvdAtUCXRhARd+uUqgA22htkQQ1or nlVK1wrz9cl4x6NYOJlvDjuWbD/yskgJqnhTnUGio1ALNHo3twrqL92yQfBek/TzioO/AtmLxRg BNNQhnoNj6CCGSw== 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" Some devices pack or compress raw formats before storing them to memory. They defined custom V4L2 fourcc codes that were specific to the bayer-order. Now that the kernel has support for generic RAW media bus codes, add their counterpart V4L2 fourcc codes for the device-specific packing or compression too. Signed-off-by: Jai Luthra --- include/linux/videodev2.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 05bd394b1a67..fd72673d4638 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -812,17 +812,20 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_HEXTILE v4l2_fourcc('H', 'X', 'T', 'L') /* Hextile compressed */ /* 10bit raw packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */ +#define V4L2_PIX_FMT_IPU3_RAW10 v4l2_fourcc('i', 'p', '3', 'x') /* IPU3 packed 10-bit generic bayer */ #define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */ #define V4L2_PIX_FMT_IPU3_SGBRG10 v4l2_fourcc('i', 'p', '3', 'g') /* IPU3 packed 10-bit GBRG bayer */ #define V4L2_PIX_FMT_IPU3_SGRBG10 v4l2_fourcc('i', 'p', '3', 'G') /* IPU3 packed 10-bit GRBG bayer */ #define V4L2_PIX_FMT_IPU3_SRGGB10 v4l2_fourcc('i', 'p', '3', 'r') /* IPU3 packed 10-bit RGGB bayer */ /* Raspberry Pi PiSP compressed formats. */ +#define V4L2_PIX_FMT_PISP_COMP1_RAW v4l2_fourcc('P', 'C', '1', 'x') /* PiSP 8-bit mode 1 compressed raw format */ #define V4L2_PIX_FMT_PISP_COMP1_RGGB v4l2_fourcc('P', 'C', '1', 'R') /* PiSP 8-bit mode 1 compressed RGGB bayer */ #define V4L2_PIX_FMT_PISP_COMP1_GRBG v4l2_fourcc('P', 'C', '1', 'G') /* PiSP 8-bit mode 1 compressed GRBG bayer */ #define V4L2_PIX_FMT_PISP_COMP1_GBRG v4l2_fourcc('P', 'C', '1', 'g') /* PiSP 8-bit mode 1 compressed GBRG bayer */ #define V4L2_PIX_FMT_PISP_COMP1_BGGR v4l2_fourcc('P', 'C', '1', 'B') /* PiSP 8-bit mode 1 compressed BGGR bayer */ #define V4L2_PIX_FMT_PISP_COMP1_MONO v4l2_fourcc('P', 'C', '1', 'M') /* PiSP 8-bit mode 1 compressed monochrome */ +#define V4L2_PIX_FMT_PISP_COMP2_RAW v4l2_fourcc('P', 'C', '2', 'x') /* PiSP 8-bit mode 2 compressed raw format */ #define V4L2_PIX_FMT_PISP_COMP2_RGGB v4l2_fourcc('P', 'C', '2', 'R') /* PiSP 8-bit mode 2 compressed RGGB bayer */ #define V4L2_PIX_FMT_PISP_COMP2_GRBG v4l2_fourcc('P', 'C', '2', 'G') /* PiSP 8-bit mode 2 compressed GRBG bayer */ #define V4L2_PIX_FMT_PISP_COMP2_GBRG v4l2_fourcc('P', 'C', '2', 'g') /* PiSP 8-bit mode 2 compressed GBRG bayer */ From patchwork Fri Oct 23 10:58:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28577 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 7559CC324C for ; Fri, 23 Oct 2026 10:59:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3172168FB6; Fri, 23 Oct 2026 12:59:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VZOUN3Ql"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 492A868FA6 for ; Fri, 23 Oct 2026 12:59:20 +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 10E4612B2; Fri, 23 Oct 2026 12:57:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753031; bh=DVgmyCD1U0ItVkBVLQE0ZFxQAfsouLvl3bv/NyrmOuo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VZOUN3QlJ4OHcoQR0yaSsldtbXKQDirpaDWXQtAplTr7ll810Ra3dZZ8AGb+GLOJx rhgNFBAlqgzCsU7Jb/znzzQZQliqDbo9c0QzCBEbsmfiIUvxrda7+CCcmz7JAV3DCr GtzGy+hh9HkLEzI5uutHapneHxnRZHKmknIqGH0A= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:15 +0530 Subject: [PATCH WIP RFC 07/26] libcamera: Drop MediaBusFormatInfo::Type::EmbeddedData MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-7-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=2432; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=DVgmyCD1U0ItVkBVLQE0ZFxQAfsouLvl3bv/NyrmOuo=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3JR0oFUW5euxQFmS3uppdLj794fAGVNE3rq 344239Kq7yJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9yQAKCRBD3pH5JJpx RUxVD/9LZD2F/4yhJDNGR68hb+99Z0+EpUhMd2UgVRbWS4w5aRsHTleu5kMChcl8n0h3c9mAuFp OPEy/jUkKjMHShvbFgBfuUFlhq13PKgfGhLHqQODUsNLy56u5mWMVKPFmL/KDjUkFtnKFBDZ2hc q+kqI2Tm3L7qV4erJ/Ck5HCOz69AdyRJqxrRNR8/bjZ3Ww2xiyTGy1m91DAt4wUybIgDm59sBgZ Ggw+Nl32rJJ+QskymDoLAtiERJVa8wgsXu2JKfbRFLP2OcLUl3xNkCthURNcS5xOcR1K9FA056J lgKRU3URT6wSx+jzhnf2wnc4zIGne5yRCABQO4anRs2lFxUsbQasneeWniY+mGc1aAxcDonOyAG B+6S7M9SMEacRBTZfxJPBCA6nFi9A98At4WwT2Kn1QtF7h1zMNRAhUOrDjC2reIBrGc9RSCp6uY 2w1/HNIGxTQwlpxAys9DqbXl1za9FBA2UDP7Q99Rknh73+XmM7VCksFUIlKCcSBLLukkvhmEHsv yBivI/i+KMFNT//QYBSNCGfP8Ph13vv3u88n1d+LEdthxs7VXGsZANqq8S1dismbtdZfHdA3vt3 13oK+2xdxuz+QkoWosi9bj1UMpmD/7D+/8NKM8jUalYdL30kUW7ZE+XfK1DDXRp1YK/SyXPBrzt b0rtKt4/F40JtHg== 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" The layout used by the sensor for the sensor registers or other metadata transmitted through the embedded line is advertised through the new V4L2_CID_METADATA_LAYOUT control, as opposed to being tied the mbus code advertised by the sensor on the sink pad. So drop the Type:EmbeddedData from the enum. Also drop the check for it in the CameraSensorRaw class. Signed-off-by: Jai Luthra --- include/libcamera/internal/v4l2_subdevice.h | 1 - src/libcamera/sensor/camera_sensor_raw.cpp | 13 ------------- src/libcamera/v4l2_subdevice.cpp | 3 --- 3 files changed, 17 deletions(-) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index 93003ccf3532..510963aea668 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -37,7 +37,6 @@ public: enum class Type { Image, Metadata, - EmbeddedData, }; bool isValid() const { return code != 0; } diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index 75479813c533..59799a1c150c 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -311,19 +311,6 @@ std::optional CameraSensorRaw::init() break; case MediaBusFormatInfo::Type::Metadata: - /* - * Skip metadata streams that are not sensor embedded - * data. The source stream reports a generic metadata - * format, check the sink stream for the exact format. - */ - formats = subdev_->formats(route.sink); - if (formats.size() != 1) - continue; - - if (MediaBusFormatInfo::info(formats.cbegin()->first).type != - MediaBusFormatInfo::Type::EmbeddedData) - continue; - if (streams_.edata) { LOG(CameraSensor, Error) << "Multiple internal embedded data streams (" diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index db5eab9a709d..36f17e23da8e 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -81,9 +81,6 @@ LOG_DECLARE_CATEGORY(V4L2) * * \var MediaBusFormatInfo::Type::Metadata * \brief The format describes generic metadata - * - * \var MediaBusFormatInfo::Type::EmbeddedData - * \brief The format describes sensor embedded data */ namespace { From patchwork Fri Oct 23 10:58:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28578 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 07E59C324C for ; Fri, 23 Oct 2026 10:59:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B869168FBE; Fri, 23 Oct 2026 12:59:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cqoWcd/v"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B15D968FA6 for ; Fri, 23 Oct 2026 12:59:25 +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 8EAEC145C; Fri, 23 Oct 2026 12:57:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753036; bh=+Wbyz6pnmyBhob5XYnzX12XAHv1+JiQ5ucmBujm3cIk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cqoWcd/vF2NKcY+fCMSHivtvmLZS0gcqvec3m7NGIn7P8fvuMT2Wbaob6SJ084BxA qTiBQ8gxxAtyzMdlq7VrrID/XspGavd6Ah1wV12CnE4Q4d2tQwMBaRMux+/FIiSasc k5fgoqhEAGGdrD+vOVWlb1eyYdYV1IFjz4/txFSA= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:16 +0530 Subject: [PATCH WIP RFC 08/26] libcamera: camera_sensor_raw: Read the new CFA_PATTERN control MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-8-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=3509; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=+Wbyz6pnmyBhob5XYnzX12XAHv1+JiQ5ucmBujm3cIk=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3KBW44slN1/gv0w2I7JOPtxHELE7bZRIai6 yF+O4yCcDKJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9ygAKCRBD3pH5JJpx RTlxEACJt27OZ00KxKOKECBpe9oGfwzVy578kemDjP0fYW0K3P7OnN5VPhNAZTezkZ9uOINYMpl 7vjklbE0F0bhF3tiH1kokxlzZuT6Aei3PtdglK4RD7AOd7z3KOaJZuJSmrlSnA7KOfar1rTq1rt PwzjQZPklk4nCcmuPl2lvQUzxECtvIB50LyzNavM8XnXWK81ZlaYfZqm7NUuKMp+ClM5MHrl7mP hW58a4UBLq7st404/Gu+NRL/1c5682ZoKy8r+rezcY3hs48ikREkUS2C8tGAIGi97S9q4ed8vC1 sUNJl4DdYmwg5QzHWciIKos2hkwMyJl6bKaE/iEMv0rU85HbmddVLizJkEzuGssdYPO+AZy6dlV caxgnebCn+NrG3OvBtyhP9HsVks6PNgjys8cpsEzsWjqcClGFymCL/k7HShsPED+ehGwLSbSLZL fDwzUIXS2mTf3PhwYTmxwNW4WOZ4aSLBuTAkwelPkpTvTHSm6ITNDXlZr9Fv5mR0jL/UmrJ5YTF AaxuqXKdoG74G7f7hOVkDoZqUxKlndA10LRZObswor3Vb1kLDqKyV4+LuH3I5OhvEbZsMWr7Ru2 rvlAwDVfiBFncRQf2L7D/LnX6HhPPZQ7Ck7P9Nf9xrIz0NUcZ+wzprOx48W5r1rNldh5LfNOKme O/S3bAdUbRyo4VA== 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" The raw sensor model now supports generic media bus codes, and new V4L2 controls on the sensor subdevice for querying the color filter array order and if flips affect the readout order. Make sure both controls are present, and use them instead. TODO: Use the CFA_PATTERN_FLIP control instead of reading the MODIFY_LAYOUT flag of H/VFLIP controls. Signed-off-by: Jai Luthra --- src/libcamera/sensor/camera_sensor_raw.cpp | 58 ++++++++++++++++++------------ 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index 59799a1c150c..b7ac9d90f523 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -346,29 +346,6 @@ std::optional CameraSensorRaw::init() * array order for the image stream. */ - /* - * Get the native sensor CFA pattern. It is simpler to retrieve it from - * the internal image sink pad as it is guaranteed to expose a single - * format, and is not affected by flips. - */ - V4L2Subdevice::Formats formats = subdev_->formats(streams_.image.sink); - if (formats.size() != 1) { - LOG(CameraSensor, Error) - << "Image pad has " << formats.size() - << " formats, expected 1"; - return { -EINVAL }; - } - - uint32_t nativeFormat = formats.cbegin()->first; - const BayerFormat &bayerFormat = BayerFormat::fromMbusCode(nativeFormat); - if (!bayerFormat.isValid()) { - LOG(CameraSensor, Error) - << "Invalid native format " << nativeFormat; - return { 0 }; - } - - cfaPattern_ = bayerFormat.order; - /* * Retrieve and cache the media bus codes and sizes on the source image * stream. @@ -454,6 +431,8 @@ std::optional CameraSensorRaw::init() static constexpr uint32_t mandatoryControls[] = { V4L2_CID_ANALOGUE_GAIN, V4L2_CID_CAMERA_ORIENTATION, + V4L2_CID_CFA_PATTERN, + V4L2_CID_CFA_PATTERN_FLIP, V4L2_CID_EXPOSURE, V4L2_CID_HBLANK, V4L2_CID_PIXEL_RATE, @@ -479,6 +458,38 @@ std::optional CameraSensorRaw::init() return { ret }; } + /* + * Get the native sensor CFA pattern. + */ + ControlList ctrls = subdev_->getControls({ { V4L2_CID_CFA_PATTERN } }); + if (ctrls.empty()) { + LOG(CameraSensor, Error) + << "Failed to retrieve CFA_PATTERN control"; + return -EINVAL; + } + + int cfaPattern = ctrls.get(V4L2_CID_CFA_PATTERN).get(); + + switch (cfaPattern) { + case V4L2_CFA_PATTERN_GRBG: + cfaPattern_ = BayerFormat::GRBG; + break; + case V4L2_CFA_PATTERN_RGGB: + cfaPattern_ = BayerFormat::RGGB; + break; + case V4L2_CFA_PATTERN_BGGR: + cfaPattern_ = BayerFormat::BGGR; + break; + case V4L2_CFA_PATTERN_GBRG: + cfaPattern_ = BayerFormat::GBRG; + break; + default: + LOG(CameraSensor, Error) + << "Unsupported CFA pattern " + << cfaPattern; + return -EINVAL; + } + /* Verify if sensor supports horizontal/vertical flips. */ auto queryFlip = [&](uint32_t id, const char *name) -> std::pair { const struct v4l2_query_ext_ctrl *flipInfo = subdev_->controlInfo(id); @@ -491,6 +502,7 @@ std::optional CameraSensorRaw::init() return { true, flipInfo->flags & V4L2_CTRL_FLAG_MODIFY_LAYOUT }; }; + /* FIXME: Replace with query to V4L2_CID_CFA_PATTERN_FLIP */ auto hflip = queryFlip(V4L2_CID_HFLIP, "horizontal"); auto vflip = queryFlip(V4L2_CID_VFLIP, "vertical"); From patchwork Fri Oct 23 10:58:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28579 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 9F123C324C for ; Fri, 23 Oct 2026 10:59:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 579FE68FAE; Fri, 23 Oct 2026 12:59:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SO/X/QwN"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1850A68FA6 for ; Fri, 23 Oct 2026 12:59:31 +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 CDF271C9B; Fri, 23 Oct 2026 12:57:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753042; bh=sWUDQC26jbLGjRAViEgRgaphlD08yxVgFHCFCkd5uew=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SO/X/QwNwCmWccukAjYPw8hpcOVxC1uIkuxhBrS1ZK4JnUWXxKqXLmo1PWhwON0YA q3E9MEFYSTRVN93C8e7dPCoVt5RnefUdGXoaRMon/tcnADnKRLJKBxBr/7x90QjS9h xv95Dz5SN9P0MlUxUU+F6qLbcbGkHosJHSa8UMPA= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:17 +0530 Subject: [PATCH WIP RFC 09/26] libcamera: camera_sensor_raw: Enumerate formats using sink pads MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-9-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=1326; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=sWUDQC26jbLGjRAViEgRgaphlD08yxVgFHCFCkd5uew=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3LCYkM960/XjgDpCPXY7RMPbyLbvpcvmPC/ 1+Nm8mDZpSJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9ywAKCRBD3pH5JJpx RWZaEADMaZK8VKnitJM+ebrAMyJwTzivxgHD1L4RUazmOGygweMmunWdNe9ns+ODUp9wx2cic4X yUGXeVyGHrYwSFojygybUGbM6jAkPqBTPXJRFfhKStc3vuK4H0H7rdz7KC3pMgAJ4Uov8Wj/l+d uoxNKOwC3c6xZUghfr8JUSY9kWEqeZfol7ZUr8EU+Zs+GNCrkNOvJfp4nusjl8Us5NdiqYpE4if Wb7Qj8FK9W+XTGriBoR1DkRTHwEsSPaJ9cWnO6QOBGxJd9QPtFk0KPSjAP1W3MOwooFT0nJs9o0 wJd/qmWLhik2cT7VyqLgs+UHoWzSwBmnaRVHK8cozzMjes9Q9EzY2T+YT3D8oRP1US/n46UrP1k kTfT9KtkMzUy5SWnhaQnmZmxueJY3tD68UyjH4acyKCE4Z+K1OI4jn9frnRphU/AD/BFbIl8j3+ ZFCZWP41QNinGsjwJ9XSaWqaA7EBZtZDNN6TEEsT6MXA79Y27GB9syTJx9mfEYF1LRTDMr/wZGb OFBLZWLYIzC1FL8mClgdaQdKwLIeh7PhkbQ2UTV9kkC+RJJUYVFKTso8skgPT1bdtNjDG91VlRF 6acLnL2EDOkCn/pVH/bl897+D+Xr4W2dCZdhTFIaR0Jpj9oXbgfkQ9DUGcKx1yj+9QtFYCA+9hl 2DHFZkLwVUOcs6Q== 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" The sensor may enumerate multiple formats when queried for a source pad/stream, as it can pad or sometimes truncate the data before putting it on the bus. But it is guaranteed to enumerate a single format (native size) on the internal pad. Use that to figure out the identify the type of a stream, as it is cleaner. Signed-off-by: Jai Luthra --- src/libcamera/sensor/camera_sensor_raw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index b7ac9d90f523..29ea9406ad0d 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -276,7 +276,7 @@ std::optional CameraSensorRaw::init() } /* Identify the stream type based on the supported formats. */ - V4L2Subdevice::Formats formats = subdev_->formats(route.source); + V4L2Subdevice::Formats formats = subdev_->formats(route.sink); std::optional type; @@ -291,7 +291,7 @@ std::optional CameraSensorRaw::init() if (!type) { LOG(CameraSensor, Warning) - << "No known format on pad " << route.source; + << "No known format on pad " << route.sink; continue; } From patchwork Fri Oct 23 10:58:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28580 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 2266FC324C for ; Fri, 23 Oct 2026 10:59:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D22D068FC4; Fri, 23 Oct 2026 12:59:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L23bZ2Is"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E614B68FAB for ; Fri, 23 Oct 2026 12:59:36 +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 A3AF11CF5; Fri, 23 Oct 2026 12:57:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753048; bh=MtKUxehNNCYd5U/ICeFqfiVe3+MklLaDpozIX4qK3xY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=L23bZ2Is+glqeaiArbZHJdgnEgN4h0cZjkkh4IVBSvsKkSZnIHl3ICObiCVbsB14m lSyP7H7o1uQBzUwqBjt63qkSpeIUvAjk2UUHKny1KU0xfaMPvBLC21dBbw9rlzp8VS 3bTmzkwoxxmIzOaOu0VZyK2TbVmquuhlZfv/Z/jU= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:18 +0530 Subject: [PATCH WIP RFC 10/26] libcamera: camera_sensor_raw: Check for CONFIG_MODEL MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-10-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=1295; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=MtKUxehNNCYd5U/ICeFqfiVe3+MklLaDpozIX4qK3xY=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3Mx3IL7y9LxhaKyy10DtI8qwz08QAv2RkrS LQpjFr7CeGJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9zAAKCRBD3pH5JJpx RWqDD/sESZZNBAZExyYmBmtU6f98iAqi5qJfHrJwiQg2CPjonayc9n67sbHNvwduiodoM4+0aUn kX0I92GacLxjuOh0jICjW1IMDVXCJcaIN5akbitVf6spCe2wmp1XYTNiQDWluvh3wCHd2O0YgoE 6WFPSYZbBarFhNzWWo8xotPYQH2rIY5LMJB7J/UgA2fsbmzv4meQcxRhPT76jJaly3yPrSFb5WJ xS77PSD73U7RZE/xvL9p+ldaimXs6aKMRZmkq3YMG6pO77aGBHxWVF2FI4713Gx5oiFBjADbka3 b8XmiP+6YeBprNZcIxPP29yopDyO5Mvx+2L08bF0TQvzem1L+6v12rz+xGJJ7Z2wnMdYskO7MOm ksa37yXi4wbmU1BOc2RInEwRKBG14bD6hNplPVlbMHTMYpUTJsheUBWlWKdeuT3qqGM75vSRQPh keL2sTRV3cg0pj7SHV6MFS2LiVCsmQIWLzxuAIYat+1p+D+g2ruDTRg3l0f1Rr7c2rHyRa2aROb OAZ1XBly7E1cxYjUapH/5diWn4OvYIZYNNEEvbenD3SFdiDos3yISxV3bk0kMkG+go6++X7QcAi hGEezima+7qdrOqSr6vSKUDek5daNox2gO5+9LcJ7+HI/8KAwYS3wqiURE+GRBcZTReP0fox04s usNBAf/rb1G5D3Q== 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" Query the V4L2_CID_CONFIG_MODEL control on the sensor sub-device, and only match it with the CameraRawSensor class if the COMMON_RAW_SENSOR bit is set. Signed-off-by: Jai Luthra --- src/libcamera/sensor/camera_sensor_raw.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index 29ea9406ad0d..d8874a7c5e1a 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -241,6 +241,23 @@ std::optional CameraSensorRaw::init() if (ret) return { ret }; + /* Ensure CONFIG_MODEL is set to COMMON_RAW_SENSOR */ + ControlList configModel = subdev_->getControls({ { V4L2_CID_CONFIG_MODEL } }); + if (configModel.empty()) { + LOG(CameraSensor, Debug) + << entity_->name() << ": control " + << "V4L2_CID_CONFIG_MODEL not available"; + return { 0 }; + } + + int32_t model = configModel.get(V4L2_CID_CONFIG_MODEL).get(); + if (!(model & V4L2_CONFIG_MODEL_COMMON_RAW_SENSOR)) { + LOG(CameraSensor, Debug) + << entity_->name() + << ": Common raw sensor model not supported"; + return { 0 }; + } + /* * 1. Identify the pads. */ From patchwork Fri Oct 23 10:58:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28581 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 D18FFC324C for ; Fri, 23 Oct 2026 10:59:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 88D8F68FC3; Fri, 23 Oct 2026 12:59:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Cou1e+pS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7ED3368FAB for ; Fri, 23 Oct 2026 12:59:43 +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 392471D0F; Fri, 23 Oct 2026 12:57:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753054; bh=PiEY8zN72On+lVmeHRZEZmxchAcmiq6iQO6iDZYQMCk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Cou1e+pSCnnzBkFw8CRLHJIjK8YlFQIN96uIBaqcKwxVsZ0Fq44DYXPExlPd45//W XcqoGAkYrqSqL9U9r+E21ZAumR57MSi6NGZ/oO1yO4dOwSWslFUKei+oSB45l5VajJ PGE3J46ZH1l6leplDEX54uM2boZDoR0+2AH7IvsE= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:19 +0530 Subject: [PATCH WIP RFC 11/26] libcamera: Support raw sensor model MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-11-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=2330; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=PiEY8zN72On+lVmeHRZEZmxchAcmiq6iQO6iDZYQMCk=; b=kA0DAAoBQ96R+SSacUUByyZiAGrbPc2gLLkRi9Nd1frwVC+c48rx9dQMpOcLvW8QIx+Cl0TJz okCMwQAAQoAHRYhBE3g2Bjl1XXo1FqvxUPekfkkmnFFBQJq2z3NAAoJEEPekfkkmnFFyfoP/1d9 KPt1QBKcs3DC6+AX+Gb4SqElX+TaFkY/nQQBYPFDUb584fnMzATsQ6yYnrbKj6eeTJ2wJhvLHIN L1m3uOCUqVGR5veurhA0Dii72oxTSeSTt82ke+eYzeGvJ0oReUa6Tni1S0jMgdBPGxPGMrUtyme tMKnZ/xR9fTe12L6VXjj/FkazSX6pumClcE2UN4Uq5cTEAhITurv7qcrONGW8SPgSHiOsbfUbMK 9g78DNXmNS35lIEVE+OQwp5YWmf1cjKztY6BSiAryhl35OX6EmVehw5O4jtyXTtJ67Dqsrojhle Uo2I7+v4O8CMTIisuY0PCrv8cjc8fz4/m2ZBUDCElwCLrPhle2kBwRW1yxSXcNXH/dKb83AQiME jSKNb5sJwb+niMQ9V7QD/TLc3cPDWe1s08ZRwd4J8Dk6DJq4GWe9Lt5ETMSjAKqvRi5yNekVlJZ giVaPjXfnR5+0+CH40Gzl6yVYB+WGKPx1F0O5cNQe/Uev0Z2HVVlG75H6atNCLdLJZK6J1zOxVP Wr4xSOTZb1+OJUeD7vWlFq+mExsu5mXeEWFlZOCmM+xaUGYJNGNw0Di6x82nPY2S5qwMwBn27X4 HbfnrbwzxFmGzCSb/1bnXxanQF8NjsVln8W7/UAvqFHi5qMj8Ze58+APkfWuSbf20qtsWmadfC9 De3uI 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" Now that the raw sensor model is fully supported, set the client capability bit V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR when interacting with V4L2 subdevices. Also bump the priority back up for the CameraRawSensor class, so it is matched first for sensors that support the new model. Signed-off-by: Jai Luthra --- This commit needs to be at the very end of the series before merging. I've kept it in the middle to ease review for now, as it is a WIP series. --- src/libcamera/sensor/camera_sensor_raw.cpp | 2 +- src/libcamera/v4l2_subdevice.cpp | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index d8874a7c5e1a..5301bc6d9f8c 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -1187,6 +1187,6 @@ std::string CameraSensorRaw::logPrefix() const return "'" + entity_->name() + "'"; } -REGISTER_CAMERA_SENSOR(CameraSensorRaw, -200) +REGISTER_CAMERA_SENSOR(CameraSensorRaw, 0) } /* namespace libcamera */ diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 36f17e23da8e..28f962bbdd10 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -1281,19 +1281,21 @@ int V4L2Subdevice::open() return ret; } + struct v4l2_subdev_client_capability clientCaps{}; + clientCaps.capabilities = V4L2_SUBDEV_CLIENT_CAP_COMMON_RAW_SENSOR; + /* If the subdev supports streams, enable the streams API. */ if (caps_.hasStreams()) { - struct v4l2_subdev_client_capability clientCaps{}; - clientCaps.capabilities = V4L2_SUBDEV_CLIENT_CAP_STREAMS; + clientCaps.capabilities |= V4L2_SUBDEV_CLIENT_CAP_STREAMS; + } - ret = ioctl(VIDIOC_SUBDEV_S_CLIENT_CAP, &clientCaps); - if (ret < 0) { - ret = -errno; - LOG(V4L2, Error) - << "Unable to set client capabilities: " - << strerror(-ret); - return ret; - } + ret = ioctl(VIDIOC_SUBDEV_S_CLIENT_CAP, &clientCaps); + if (ret < 0 && errno != ENOTTY) { + ret = -errno; + LOG(V4L2, Error) + << "Unable to set client capabilities: " + << strerror(-ret); + return ret; } return 0; From patchwork Fri Oct 23 10:58:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28582 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 6E238C324C for ; Fri, 23 Oct 2026 10:59:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 277C368FC8; Fri, 23 Oct 2026 12:59:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="C4iJbWMj"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 28F8568FAB for ; Fri, 23 Oct 2026 12:59:50 +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 75CCB1E92; Fri, 23 Oct 2026 12:57:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753061; bh=xi0f4OLya5Qx3QsZ5mlPl/jT9BrlIOBm3LdOK+PlLrQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C4iJbWMjEGpv8/uy3X0e3vz6A5VFBpztx63q5rt2MgQHCI6HcEiBuWc8c6oGs0qEO GLgHZQJqQnSxrRdqpJgrq1pFwp51Q8H9sokVPiWnNTlStQRuEFtJb7zbIMxe7WrYKv 5P2Gn2F0JSzxm2KiLy75SQdvHV+LNDabP3XAelCk= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:20 +0530 Subject: [PATCH WIP RFC 12/26] libcamera: bayer_format: Introduce a ColorFilterArray class MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-12-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=85213; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=xi0f4OLya5Qx3QsZ5mlPl/jT9BrlIOBm3LdOK+PlLrQ=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3ODOFWUyyUgctQtQMWA60sfkt1WGK9CTp6q xRhgOo2MC+JAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9zgAKCRBD3pH5JJpx RdkED/4jEuiJWW3EfBupEp2BjN/4xxPRbnSe8fv/iIcdRlIlo7C4izKazg+XyLfZNeqgOZ//FmR f8JXxjS8wbxsmwYzFymr6xy3Tnk22KU6ZlNHGtu22KkEHfPmXvy4wdBmEucTrMIBX6G8oEoTZXQ n5v7bCYUvdv5tb7IYhj9CXSd3I+dizETAYIoxqyHnp02PiE9CR6AkWZK4sOGNg7ClgZiJA/qrrF Fj5FlTqk5ApwzTs+5r6hWvm55Kt+9PvsgNLZ2Tl0wVBVIu7IDN3I/FS1gRRQIwNEYpcFkvinRRU AcDSSKqzDSWe+mUC9vk+W3xfUqGlcPpUE1r5ukTtMuFfpD38Q+h41Zcui8PVpHqnBSxL/1MxesG pPu6o15/U3upNRC2nLd79PoLGUzF5wZEQAPjgjPQh2PuNIRhu9vR8O5LNuo8QFr/fxKr02yVZ0S Rkz1NOim7wFftOUNllcNvPhX9rQmdMQtjQYEfODzYE1LP/CrekkfVKjUOQRhuMaoA2EBQ0kzf+g LgjVLk7coe9FPaLAUisl6wldvEZQksjvccqmfaK9QibEbyGZlsxtrj73KgDJw45E7NmDq4U4WGw FqIKL5+LzAGW9JLypK5wsLzvYDGOMSrcQgfsTl0b0K8967AJ48k4QcVloAWaEsd6MfqRx+u2Yny tDmUsD2wkFT26VQ== 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" Following the common raw sensor model in V4L2, we want to separate out the bayer order of the color filter array along with the explosion of permutations caused by them, from the actual raw format transmitted on the bus, which is relatively simple (bitdepth, packing and compression). As a first step, separate out the bayer order into a separate ColorFilterArray class. This is still used by and tied closely to the BayerFormat class for now. Keep this new header external as in subsequent commits the CFA will be exposed through the StreamConfiguration to applications. Make sure all references to the BayerFormat::Order are replaced throughout the codebase. No functional changes intended in this commit. Signed-off-by: Jai Luthra --- include/libcamera/color_filter_array.h | 58 ++++ include/libcamera/internal/bayer_format.h | 18 +- include/libcamera/internal/camera_sensor.h | 4 +- .../libcamera/internal/software_isp/swstats_cpu.h | 2 +- include/libcamera/meson.build | 1 + src/ipa/mali-c55/algorithms/agc.cpp | 14 +- src/ipa/mali-c55/algorithms/agc.h | 5 +- src/ipa/mali-c55/ipa_context.h | 5 +- src/ipa/mali-c55/mali-c55.cpp | 4 +- src/libcamera/bayer_format.cpp | 268 ++++++----------- src/libcamera/color_filter_array.cpp | 334 +++++++++++++++++++++ src/libcamera/meson.build | 1 + src/libcamera/pipeline/mali-c55/mali-c55.cpp | 11 +- .../pipeline/rpi/common/pipeline_base.cpp | 5 +- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 66 ++-- src/libcamera/pipeline/simple/simple.cpp | 3 +- src/libcamera/sensor/camera_sensor_legacy.cpp | 43 +-- src/libcamera/sensor/camera_sensor_raw.cpp | 36 +-- src/libcamera/software_isp/debayer.cpp | 8 +- src/libcamera/software_isp/debayer.h | 2 +- src/libcamera/software_isp/debayer_cpu.cpp | 58 ++-- src/libcamera/software_isp/debayer_cpu.h | 2 +- src/libcamera/software_isp/debayer_egl.cpp | 6 +- src/libcamera/software_isp/swstats_cpu.cpp | 26 +- test/bayer-format.cpp | 40 +-- 25 files changed, 671 insertions(+), 349 deletions(-) diff --git a/include/libcamera/color_filter_array.h b/include/libcamera/color_filter_array.h new file mode 100644 index 000000000000..167a4a3ff323 --- /dev/null +++ b/include/libcamera/color_filter_array.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Ideas on Board Oy + * + * Bayer Color Filter Array patterns + */ + +#pragma once + +#include +#include +#include +#include + +#include "libcamera/internal/v4l2_pixelformat.h" + +namespace libcamera { + +enum class Transform; + +class ColorFilterArray +{ +public: + enum Order : uint8_t { + BGGR = 0, + GBRG = 1, + GRBG = 2, + RGGB = 3, + MONO = 4 + }; + + constexpr ColorFilterArray() : order(Order::BGGR) + { + } + + constexpr ColorFilterArray(Order o) + : order(o) + { + } + + static std::optional fromMbusCode(unsigned int mbusCode); + static std::optional fromV4L2PixelFormat(V4L2PixelFormat v4l2Format); + unsigned int toMbusCode(uint8_t bitDepth) const; + + std::string toString() const; + + bool operator==(const ColorFilterArray &other) const { + return this->order == other.order; + } + + ColorFilterArray transform(Transform t) const; + + Order order; +}; + +std::ostream &operator<<(std::ostream &out, const ColorFilterArray &f); + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 5c14bb5fb2d5..701e063edcc5 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -11,6 +11,7 @@ #include #include +#include #include #include "libcamera/internal/v4l2_pixelformat.h" @@ -22,14 +23,6 @@ enum class Transform; class BayerFormat { public: - enum Order : uint8_t { - BGGR = 0, - GBRG = 1, - GRBG = 2, - RGGB = 3, - MONO = 4 - }; - enum class Packing : uint16_t { None = 0, CSI2 = 1, @@ -39,12 +32,12 @@ public: }; constexpr BayerFormat() - : order(Order::BGGR), bitDepth(0), packing(Packing::None) + : cfa(ColorFilterArray()), bitDepth(0), packing(Packing::None) { } - constexpr BayerFormat(Order o, uint8_t b, Packing p) - : order(o), bitDepth(b), packing(p) + constexpr BayerFormat(ColorFilterArray c, uint8_t b, Packing p) + : cfa(c), bitDepth(b), packing(p) { } @@ -57,9 +50,8 @@ public: static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format); PixelFormat toPixelFormat() const; static BayerFormat fromPixelFormat(PixelFormat format); - BayerFormat transform(Transform t) const; - Order order; + ColorFilterArray cfa; uint8_t bitDepth; Packing packing; diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 2a2f1f2c936d..a0f27ac11735 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -16,13 +16,13 @@ #include +#include #include #include #include #include #include -#include "libcamera/internal/bayer_format.h" #include "libcamera/internal/camera_sensor_properties.h" #include "libcamera/internal/v4l2_subdevice.h" @@ -72,7 +72,7 @@ public: virtual const ControlList &properties() const = 0; virtual int sensorInfo(IPACameraSensorInfo *info) const = 0; virtual Transform computeTransform(Orientation *orientation) const = 0; - virtual BayerFormat::Order bayerOrder(Transform t) const = 0; + virtual ColorFilterArray bayerOrder(Transform t) const = 0; virtual Orientation mountingOrientation() const = 0; virtual const ControlInfoMap &controls() const = 0; diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index 551870921862..1594e520c5ba 100644 --- a/include/libcamera/internal/software_isp/swstats_cpu.h +++ b/include/libcamera/internal/software_isp/swstats_cpu.h @@ -88,7 +88,7 @@ private: using statsProcessFn = void (SwStatsCpu::*)(const uint8_t *src[], SwIspStats &stats); using processFrameFn = void (SwStatsCpu::*)(MappedFrameBuffer &in); - int setupStandardBayerOrder(BayerFormat::Order order); + int setupStandardBayerOrder(ColorFilterArray::Order order); /* Bayer 8 bpp unpacked */ void statsBGGR8Line0(const uint8_t *src[], SwIspStats &stats); /* Bayer 10 bpp unpacked */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 30ea76f9470a..70bd0ccbed9e 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -5,6 +5,7 @@ libcamera_include_dir = 'libcamera' / 'libcamera' libcamera_public_headers = files([ 'camera.h', 'camera_manager.h', + 'color_filter_array.h', 'color_space.h', 'controls.h', 'fence.h', diff --git a/src/ipa/mali-c55/algorithms/agc.cpp b/src/ipa/mali-c55/algorithms/agc.cpp index 2c747da89170..8600e7d61922 100644 --- a/src/ipa/mali-c55/algorithms/agc.cpp +++ b/src/ipa/mali-c55/algorithms/agc.cpp @@ -54,28 +54,28 @@ uint32_t AgcStatistics::decodeBinValue(uint16_t binVal) * colour channels would be populated, and they may not be in the same * planes as calculated here. */ -int AgcStatistics::setBayerOrderIndices(BayerFormat::Order bayerOrder) +int AgcStatistics::setBayerOrderIndices(ColorFilterArray::Order cfaOrder) { - switch (bayerOrder) { - case BayerFormat::Order::RGGB: + switch (cfaOrder) { + case ColorFilterArray::Order::RGGB: rIndex_ = 0; grIndex_ = 1; gbIndex_ = 2; bIndex_ = 3; break; - case BayerFormat::Order::GRBG: + case ColorFilterArray::Order::GRBG: grIndex_ = 0; rIndex_ = 1; bIndex_ = 2; gbIndex_ = 3; break; - case BayerFormat::Order::GBRG: + case ColorFilterArray::Order::GBRG: gbIndex_ = 0; bIndex_ = 1; rIndex_ = 2; grIndex_ = 3; break; - case BayerFormat::Order::BGGR: + case ColorFilterArray::Order::BGGR: bIndex_ = 0; gbIndex_ = 1; grIndex_ = 2; @@ -83,7 +83,7 @@ int AgcStatistics::setBayerOrderIndices(BayerFormat::Order bayerOrder) break; default: LOG(MaliC55Agc, Error) - << "Invalid bayer format " << bayerOrder; + << "Invalid bayer format " << cfaOrder; return -EINVAL; } diff --git a/src/ipa/mali-c55/algorithms/agc.h b/src/ipa/mali-c55/algorithms/agc.h index 809a57c53acc..26c8dc78bc4b 100644 --- a/src/ipa/mali-c55/algorithms/agc.h +++ b/src/ipa/mali-c55/algorithms/agc.h @@ -8,8 +8,7 @@ #pragma once #include - -#include "libcamera/internal/bayer_format.h" +#include #include "libipa/agc.h" #include "libipa/histogram.h" @@ -28,7 +27,7 @@ public: { } - int setBayerOrderIndices(BayerFormat::Order bayerOrder); + int setBayerOrderIndices(ColorFilterArray::Order cfaOrder); uint32_t decodeBinValue(uint16_t binVal); void parseStatistics(const mali_c55_stats_buffer *stats); diff --git a/src/ipa/mali-c55/ipa_context.h b/src/ipa/mali-c55/ipa_context.h index cd370e25fcca..8915a8b82d57 100644 --- a/src/ipa/mali-c55/ipa_context.h +++ b/src/ipa/mali-c55/ipa_context.h @@ -8,12 +8,11 @@ #pragma once #include +#include #include #include -#include "libcamera/internal/bayer_format.h" - #include #include #include @@ -31,7 +30,7 @@ struct IPASessionConfiguration { agc::Session agc; struct { - BayerFormat::Order bayerOrder; + ColorFilterArray::Order bayerOrder; uint32_t blackLevel; } sensor; }; diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp index 9a2918cf2cf1..d07c6666f7c5 100644 --- a/src/ipa/mali-c55/mali-c55.cpp +++ b/src/ipa/mali-c55/mali-c55.cpp @@ -17,11 +17,11 @@ #include #include +#include #include #include #include -#include "libcamera/internal/bayer_format.h" #include "libcamera/internal/mapped_framebuffer.h" #include "libcamera/internal/yaml_parser.h" @@ -171,7 +171,7 @@ int IPAMaliC55::configure(const IPAConfigInfo &ipaConfig, uint8_t bayerOrder, const IPACameraSensorInfo &info = ipaConfig.sensorInfo; - context_.configuration.sensor.bayerOrder = static_cast(bayerOrder); + context_.configuration.sensor.bayerOrder = static_cast(bayerOrder); if (auto bl = context_.camHelper->blackLevel()) { /* diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 3dab91fc5f4b..c0d5af33dd17 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -14,6 +14,7 @@ #include +#include #include #include @@ -29,26 +30,8 @@ namespace libcamera { * \brief Class to represent a raw image Bayer format * * This class encodes the different Bayer formats in such a way that they can - * be easily manipulated. For example, the bit depth or Bayer order can be - * easily altered - the Bayer order can even be "transformed" in the same - * manner as happens in many sensors when their horizontal or vertical "flip" - * controls are set. - */ - -/** - * \enum BayerFormat::Order - * \brief The order of the colour channels in the Bayer pattern - * - * \var BayerFormat::BGGR - * \brief B then G on the first row, G then R on the second row. - * \var BayerFormat::GBRG - * \brief G then B on the first row, R then G on the second row. - * \var BayerFormat::GRBG - * \brief G then R on the first row, B then G on the second row. - * \var BayerFormat::RGGB - * \brief R then G on the first row, G then B on the second row. - * \var BayerFormat::MONO - * \brief Monochrome image data, there is no colour filter array. + * be easily manipulated. For example the bit depth, packing and color order of + * the format transmitted over the bus can be modified and transformed. */ /** @@ -78,9 +61,9 @@ struct BayerFormatComparator { else if (lhs.bitDepth > rhs.bitDepth) return false; - if (lhs.order < rhs.order) + if (lhs.cfa.order < rhs.cfa.order) return true; - else if (lhs.order > rhs.order) + else if (lhs.cfa.order > rhs.cfa.order) return false; if (lhs.packing < rhs.packing) @@ -96,143 +79,143 @@ struct Formats { }; const std::map bayerToFormat{ - { { BayerFormat::BGGR, 8, BayerFormat::Packing::None }, + { { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None }, { formats::SBGGR8, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) } }, - { { BayerFormat::GBRG, 8, BayerFormat::Packing::None }, + { { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None }, { formats::SGBRG8, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) } }, - { { BayerFormat::GRBG, 8, BayerFormat::Packing::None }, + { { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None }, { formats::SGRBG8, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) } }, - { { BayerFormat::RGGB, 8, BayerFormat::Packing::None }, + { { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None }, { formats::SRGGB8, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) } }, - { { BayerFormat::BGGR, 10, BayerFormat::Packing::None }, + { { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None }, { formats::SBGGR10, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) } }, - { { BayerFormat::GBRG, 10, BayerFormat::Packing::None }, + { { ColorFilterArray::GBRG, 10, BayerFormat::Packing::None }, { formats::SGBRG10, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) } }, - { { BayerFormat::GRBG, 10, BayerFormat::Packing::None }, + { { ColorFilterArray::GRBG, 10, BayerFormat::Packing::None }, { formats::SGRBG10, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) } }, - { { BayerFormat::RGGB, 10, BayerFormat::Packing::None }, + { { ColorFilterArray::RGGB, 10, BayerFormat::Packing::None }, { formats::SRGGB10, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) } }, - { { BayerFormat::BGGR, 10, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::BGGR, 10, BayerFormat::Packing::CSI2 }, { formats::SBGGR10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) } }, - { { BayerFormat::GBRG, 10, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::GBRG, 10, BayerFormat::Packing::CSI2 }, { formats::SGBRG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) } }, - { { BayerFormat::GRBG, 10, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::GRBG, 10, BayerFormat::Packing::CSI2 }, { formats::SGRBG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) } }, - { { BayerFormat::RGGB, 10, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::RGGB, 10, BayerFormat::Packing::CSI2 }, { formats::SRGGB10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) } }, - { { BayerFormat::BGGR, 10, BayerFormat::Packing::IPU3 }, + { { ColorFilterArray::BGGR, 10, BayerFormat::Packing::IPU3 }, { formats::SBGGR10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) } }, - { { BayerFormat::GBRG, 10, BayerFormat::Packing::IPU3 }, + { { ColorFilterArray::GBRG, 10, BayerFormat::Packing::IPU3 }, { formats::SGBRG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) } }, - { { BayerFormat::GRBG, 10, BayerFormat::Packing::IPU3 }, + { { ColorFilterArray::GRBG, 10, BayerFormat::Packing::IPU3 }, { formats::SGRBG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) } }, - { { BayerFormat::RGGB, 10, BayerFormat::Packing::IPU3 }, + { { ColorFilterArray::RGGB, 10, BayerFormat::Packing::IPU3 }, { formats::SRGGB10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) } }, - { { BayerFormat::BGGR, 12, BayerFormat::Packing::None }, + { { ColorFilterArray::BGGR, 12, BayerFormat::Packing::None }, { formats::SBGGR12, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) } }, - { { BayerFormat::GBRG, 12, BayerFormat::Packing::None }, + { { ColorFilterArray::GBRG, 12, BayerFormat::Packing::None }, { formats::SGBRG12, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) } }, - { { BayerFormat::GRBG, 12, BayerFormat::Packing::None }, + { { ColorFilterArray::GRBG, 12, BayerFormat::Packing::None }, { formats::SGRBG12, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) } }, - { { BayerFormat::RGGB, 12, BayerFormat::Packing::None }, + { { ColorFilterArray::RGGB, 12, BayerFormat::Packing::None }, { formats::SRGGB12, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) } }, - { { BayerFormat::BGGR, 12, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::BGGR, 12, BayerFormat::Packing::CSI2 }, { formats::SBGGR12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) } }, - { { BayerFormat::GBRG, 12, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::GBRG, 12, BayerFormat::Packing::CSI2 }, { formats::SGBRG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) } }, - { { BayerFormat::GRBG, 12, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::GRBG, 12, BayerFormat::Packing::CSI2 }, { formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } }, - { { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::RGGB, 12, BayerFormat::Packing::CSI2 }, { formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } }, - { { BayerFormat::BGGR, 14, BayerFormat::Packing::None }, + { { ColorFilterArray::BGGR, 14, BayerFormat::Packing::None }, { formats::SBGGR14, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14) } }, - { { BayerFormat::GBRG, 14, BayerFormat::Packing::None }, + { { ColorFilterArray::GBRG, 14, BayerFormat::Packing::None }, { formats::SGBRG14, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14) } }, - { { BayerFormat::GRBG, 14, BayerFormat::Packing::None }, + { { ColorFilterArray::GRBG, 14, BayerFormat::Packing::None }, { formats::SGRBG14, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14) } }, - { { BayerFormat::RGGB, 14, BayerFormat::Packing::None }, + { { ColorFilterArray::RGGB, 14, BayerFormat::Packing::None }, { formats::SRGGB14, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14) } }, - { { BayerFormat::BGGR, 14, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::BGGR, 14, BayerFormat::Packing::CSI2 }, { formats::SBGGR14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P) } }, - { { BayerFormat::GBRG, 14, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::GBRG, 14, BayerFormat::Packing::CSI2 }, { formats::SGBRG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P) } }, - { { BayerFormat::GRBG, 14, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::GRBG, 14, BayerFormat::Packing::CSI2 }, { formats::SGRBG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P) } }, - { { BayerFormat::RGGB, 14, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::RGGB, 14, BayerFormat::Packing::CSI2 }, { formats::SRGGB14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P) } }, - { { BayerFormat::BGGR, 16, BayerFormat::Packing::None }, + { { ColorFilterArray::BGGR, 16, BayerFormat::Packing::None }, { formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } }, - { { BayerFormat::GBRG, 16, BayerFormat::Packing::None }, + { { ColorFilterArray::GBRG, 16, BayerFormat::Packing::None }, { formats::SGBRG16, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) } }, - { { BayerFormat::GRBG, 16, BayerFormat::Packing::None }, + { { ColorFilterArray::GRBG, 16, BayerFormat::Packing::None }, { formats::SGRBG16, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) } }, - { { BayerFormat::RGGB, 16, BayerFormat::Packing::None }, + { { ColorFilterArray::RGGB, 16, BayerFormat::Packing::None }, { formats::SRGGB16, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) } }, - { { BayerFormat::BGGR, 16, BayerFormat::Packing::PISP1 }, + { { ColorFilterArray::BGGR, 16, BayerFormat::Packing::PISP1 }, { formats::BGGR_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR) } }, - { { BayerFormat::GBRG, 16, BayerFormat::Packing::PISP1 }, + { { ColorFilterArray::GBRG, 16, BayerFormat::Packing::PISP1 }, { formats::GBRG_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG) } }, - { { BayerFormat::GRBG, 16, BayerFormat::Packing::PISP1 }, + { { ColorFilterArray::GRBG, 16, BayerFormat::Packing::PISP1 }, { formats::GRBG_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG) } }, - { { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, + { { ColorFilterArray::RGGB, 16, BayerFormat::Packing::PISP1 }, { formats::RGGB_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB) } }, - { { BayerFormat::MONO, 8, BayerFormat::Packing::None }, + { { ColorFilterArray::MONO, 8, BayerFormat::Packing::None }, { formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } }, - { { BayerFormat::MONO, 10, BayerFormat::Packing::None }, + { { ColorFilterArray::MONO, 10, BayerFormat::Packing::None }, { formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } }, - { { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::MONO, 10, BayerFormat::Packing::CSI2 }, { formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } }, - { { BayerFormat::MONO, 12, BayerFormat::Packing::None }, + { { ColorFilterArray::MONO, 12, BayerFormat::Packing::None }, { formats::R12, V4L2PixelFormat(V4L2_PIX_FMT_Y12) } }, - { { BayerFormat::MONO, 12, BayerFormat::Packing::CSI2 }, + { { ColorFilterArray::MONO, 12, BayerFormat::Packing::CSI2 }, { formats::R12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y12P) } }, - { { BayerFormat::MONO, 16, BayerFormat::Packing::None }, + { { ColorFilterArray::MONO, 16, BayerFormat::Packing::None }, { formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } }, - { { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 }, + { { ColorFilterArray::MONO, 16, BayerFormat::Packing::PISP1 }, { formats::MONO_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_MONO) } }, }; const std::unordered_map mbusCodeToBayer{ - { MEDIA_BUS_FMT_SBGGR8_1X8, { BayerFormat::BGGR, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG8_1X8, { BayerFormat::GBRG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG8_1X8, { BayerFormat::GRBG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB8_1X8, { BayerFormat::RGGB, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, { BayerFormat::BGGR, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, { BayerFormat::GBRG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, { BayerFormat::GRBG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, { BayerFormat::RGGB, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, { BayerFormat::BGGR, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, { BayerFormat::GBRG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, { BayerFormat::GRBG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, { BayerFormat::RGGB, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, { BayerFormat::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, { BayerFormat::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, { BayerFormat::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, { BayerFormat::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_1X10, { BayerFormat::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG10_1X10, { BayerFormat::GBRG, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG10_1X10, { BayerFormat::GRBG, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB10_1X10, { BayerFormat::RGGB, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR12_1X12, { BayerFormat::BGGR, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG12_1X12, { BayerFormat::GBRG, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG12_1X12, { BayerFormat::GRBG, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB12_1X12, { BayerFormat::RGGB, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR14_1X14, { BayerFormat::BGGR, 14, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG14_1X14, { BayerFormat::GBRG, 14, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG14_1X14, { BayerFormat::GRBG, 14, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB14_1X14, { BayerFormat::RGGB, 14, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR16_1X16, { BayerFormat::BGGR, 16, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR20_1X20, { BayerFormat::BGGR, 20, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG20_1X20, { BayerFormat::GBRG, 20, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG20_1X20, { BayerFormat::GRBG, 20, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB20_1X20, { BayerFormat::RGGB, 20, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_Y12_1X12, { BayerFormat::MONO, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_Y16_1X16, { BayerFormat::MONO, 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR8_1X8, { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG8_1X8, { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG8_1X8, { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB8_1X8, { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_1X10, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG10_1X10, { ColorFilterArray::GBRG, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG10_1X10, { ColorFilterArray::GRBG, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB10_1X10, { ColorFilterArray::RGGB, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR12_1X12, { ColorFilterArray::BGGR, 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG12_1X12, { ColorFilterArray::GBRG, 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG12_1X12, { ColorFilterArray::GRBG, 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB12_1X12, { ColorFilterArray::RGGB, 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR14_1X14, { ColorFilterArray::BGGR, 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG14_1X14, { ColorFilterArray::GBRG, 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG14_1X14, { ColorFilterArray::GRBG, 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB14_1X14, { ColorFilterArray::RGGB, 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR16_1X16, { ColorFilterArray::BGGR, 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG16_1X16, { ColorFilterArray::GBRG, 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG16_1X16, { ColorFilterArray::GRBG, 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB16_1X16, { ColorFilterArray::RGGB, 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR20_1X20, { ColorFilterArray::BGGR, 20, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG20_1X20, { ColorFilterArray::GBRG, 20, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG20_1X20, { ColorFilterArray::GRBG, 20, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB20_1X20, { ColorFilterArray::RGGB, 20, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y8_1X8, { ColorFilterArray::MONO, 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y10_1X10, { ColorFilterArray::MONO, 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y12_1X12, { ColorFilterArray::MONO, 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y16_1X16, { ColorFilterArray::MONO, 16, BayerFormat::Packing::None } }, }; } /* namespace */ @@ -243,9 +226,9 @@ const std::unordered_map mbusCodeToBayer{ */ /** - * \fn BayerFormat::BayerFormat(Order o, uint8_t b, Packing p) + * \fn BayerFormat::BayerFormat(ColorFilterArray c, uint8_t b, Packing p) * \brief Construct a BayerFormat from explicit values - * \param[in] o The order of the Bayer pattern + * \param[in] c The color filter array pattern * \param[in] b The bit depth of the Bayer samples * \param[in] p The type of packing applied to the pixel values */ @@ -291,7 +274,7 @@ std::string BayerFormat::toString() const */ bool operator==(const BayerFormat &lhs, const BayerFormat &rhs) { - return lhs.order == rhs.order && lhs.bitDepth == rhs.bitDepth && + return lhs.cfa.order == rhs.cfa.order && lhs.bitDepth == rhs.bitDepth && lhs.packing == rhs.packing; } @@ -303,21 +286,13 @@ bool operator==(const BayerFormat &lhs, const BayerFormat &rhs) */ std::ostream &operator<<(std::ostream &out, const BayerFormat &f) { - static const char *orderStrings[] = { - "BGGR-", - "GBRG-", - "GRBG-", - "RGGB-", - "MONO-" - }; - - if (!f.isValid() || f.order > BayerFormat::MONO) { + if (!f.isValid() || f.cfa.order > ColorFilterArray::MONO) { out << "INVALID"; return out; } /* The cast is required to avoid bitDepth being interpreted as a char. */ - out << orderStrings[f.order] << static_cast(f.bitDepth); + out << f.cfa << "-" << static_cast(f.bitDepth); if (f.packing == BayerFormat::Packing::CSI2) out << "-CSI2P"; @@ -398,53 +373,8 @@ BayerFormat BayerFormat::fromPixelFormat(PixelFormat format) } /** - * \brief Apply a transform to this BayerFormat - * \param[in] t The transform to apply - * - * Applying a transform to an image stored in a Bayer format affects the Bayer - * order. For example, performing a horizontal flip on the Bayer pattern RGGB - * causes the RG rows of pixels to become GR, and the GB rows to become BG. The - * transformed image would have a GRBG order. Performing a vertical flip on the - * Bayer pattern RGGB causes the GB rows to come before the RG ones and the - * transformed image would have GBRG order. Applying both vertical and - * horizontal flips on the Bayer patter RGGB results in transformed images with - * BGGR order. The bit depth and modifiers are not affected. - * - * Horizontal and vertical flips are applied before transpose. - * - * \return The transformed Bayer format - */ -BayerFormat BayerFormat::transform(Transform t) const -{ - BayerFormat result = *this; - - if (order == MONO) - return result; - - /* - * Observe that flipping bit 0 of the Order enum performs a horizontal - * mirror on the Bayer pattern (e.g. RG/GB goes to GR/BG). Similarly, - * flipping bit 1 performs a vertical mirror operation on it (e.g RG/GB - * goes to GB/RG). Applying both vertical and horizontal flips - * combines vertical and horizontal mirroring on the Bayer pattern - * (e.g. RG/GB goes to BG/GR). Hence: - */ - if (!!(t & Transform::HFlip)) - result.order = static_cast(result.order ^ 1); - if (!!(t & Transform::VFlip)) - result.order = static_cast(result.order ^ 2); - - if (!!(t & Transform::Transpose) && result.order == 1) - result.order = static_cast(2); - else if (!!(t & Transform::Transpose) && result.order == 2) - result.order = static_cast(1); - - return result; -} - -/** - * \var BayerFormat::order - * \brief The order of the colour channels in the Bayer pattern + * \var BayerFormat::cfa + * \brief The color filter array pattern */ /** diff --git a/src/libcamera/color_filter_array.cpp b/src/libcamera/color_filter_array.cpp new file mode 100644 index 000000000000..7cec14d2dce4 --- /dev/null +++ b/src/libcamera/color_filter_array.cpp @@ -0,0 +1,334 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Ideas on Board Oy + * + * Class to represent Bayer Color Filter Array patterns + */ + +#include + +#include +#include +#include +#include + +#include + +#include +#include "libcamera/internal/v4l2_pixelformat.h" + +/** + * \file color_filter_array.cpp + * \brief Class to represent and manipulate patterns of the color filter array + */ + +namespace libcamera { + +/** + * \class ColorFilterArray + * \brief Class to represent a color filter array + * + * This class encodes the different patterns of the color filter array in such + * a way that they can be easily manipulated. For example the order can be + * "transformed" in the same manner as happens in many sensors when their + * horizontal or vertical "flip" controls are set. + */ + +/** + * \enum ColorFilterArray::Order + * \brief Different ordering of color channels in a filter array + * + * \var ColorFilterArray::BGGR + * \brief B then G on the first row, G then R on the second row. + * \var ColorFilterArray::GBRG + * \brief G then B on the first row, R then G on the second row. + * \var ColorFilterArray::GRBG + * \brief G then R on the first row, B then G on the second row. + * \var ColorFilterArray::RGGB + * \brief R then G on the first row, G then B on the second row. + * \var ColorFilterArray::MONO + * \brief Monochrome image data, there is no color filter array. + */ + +namespace { + +const std::unordered_map mbusCodeToCFA { + { MEDIA_BUS_FMT_SBGGR8_1X8, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SGBRG8_1X8, ColorFilterArray::GBRG }, + { MEDIA_BUS_FMT_SGRBG8_1X8, ColorFilterArray::GRBG }, + { MEDIA_BUS_FMT_SRGGB8_1X8, ColorFilterArray::RGGB }, + { MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, ColorFilterArray::GBRG }, + { MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, ColorFilterArray::GRBG }, + { MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, ColorFilterArray::RGGB }, + { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, ColorFilterArray::GBRG }, + { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, ColorFilterArray::GRBG }, + { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, ColorFilterArray::RGGB }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SBGGR10_1X10, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SGBRG10_1X10, ColorFilterArray::GBRG }, + { MEDIA_BUS_FMT_SGRBG10_1X10, ColorFilterArray::GRBG }, + { MEDIA_BUS_FMT_SRGGB10_1X10, ColorFilterArray::RGGB }, + { MEDIA_BUS_FMT_SBGGR12_1X12, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SGBRG12_1X12, ColorFilterArray::GBRG }, + { MEDIA_BUS_FMT_SGRBG12_1X12, ColorFilterArray::GRBG }, + { MEDIA_BUS_FMT_SRGGB12_1X12, ColorFilterArray::RGGB }, + { MEDIA_BUS_FMT_SBGGR14_1X14, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SGBRG14_1X14, ColorFilterArray::GBRG }, + { MEDIA_BUS_FMT_SGRBG14_1X14, ColorFilterArray::GRBG }, + { MEDIA_BUS_FMT_SRGGB14_1X14, ColorFilterArray::RGGB }, + { MEDIA_BUS_FMT_SBGGR16_1X16, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SGBRG16_1X16, ColorFilterArray::GBRG }, + { MEDIA_BUS_FMT_SGRBG16_1X16, ColorFilterArray::GRBG }, + { MEDIA_BUS_FMT_SRGGB16_1X16, ColorFilterArray::RGGB }, + { MEDIA_BUS_FMT_SBGGR20_1X20, ColorFilterArray::BGGR }, + { MEDIA_BUS_FMT_SGBRG20_1X20, ColorFilterArray::GBRG }, + { MEDIA_BUS_FMT_SGRBG20_1X20, ColorFilterArray::GRBG }, + { MEDIA_BUS_FMT_SRGGB20_1X20, ColorFilterArray::RGGB }, + { MEDIA_BUS_FMT_Y8_1X8, ColorFilterArray::MONO }, + { MEDIA_BUS_FMT_Y10_1X10, ColorFilterArray::MONO }, + { MEDIA_BUS_FMT_Y12_1X12, ColorFilterArray::MONO }, + { MEDIA_BUS_FMT_Y16_1X16, ColorFilterArray::MONO }, +}; + +struct CfaMbusEntry { + ColorFilterArray cfa; + uint8_t bitDepth; + + bool operator<(const CfaMbusEntry& o) const { + return std::tie(cfa.order, bitDepth) < std::tie(o.cfa.order, o.bitDepth); + } +}; + +const std::map cfaBitDepthToMbusCode{ + { { ColorFilterArray::BGGR, 8 }, MEDIA_BUS_FMT_SBGGR8_1X8 }, + { { ColorFilterArray::BGGR, 10 }, MEDIA_BUS_FMT_SBGGR10_1X10 }, + { { ColorFilterArray::BGGR, 12 }, MEDIA_BUS_FMT_SBGGR12_1X12 }, + { { ColorFilterArray::BGGR, 14 }, MEDIA_BUS_FMT_SBGGR14_1X14 }, + { { ColorFilterArray::BGGR, 16 }, MEDIA_BUS_FMT_SBGGR16_1X16 }, + { { ColorFilterArray::BGGR, 20 }, MEDIA_BUS_FMT_SBGGR20_1X20 }, + { { ColorFilterArray::GBRG, 8 }, MEDIA_BUS_FMT_SGBRG8_1X8 }, + { { ColorFilterArray::GBRG, 10 }, MEDIA_BUS_FMT_SGBRG10_1X10 }, + { { ColorFilterArray::GBRG, 12 }, MEDIA_BUS_FMT_SGBRG12_1X12 }, + { { ColorFilterArray::GBRG, 14 }, MEDIA_BUS_FMT_SGBRG14_1X14 }, + { { ColorFilterArray::GBRG, 16 }, MEDIA_BUS_FMT_SGBRG16_1X16 }, + { { ColorFilterArray::GBRG, 20 }, MEDIA_BUS_FMT_SGBRG20_1X20 }, + { { ColorFilterArray::GRBG, 8 }, MEDIA_BUS_FMT_SGRBG8_1X8 }, + { { ColorFilterArray::GRBG, 10 }, MEDIA_BUS_FMT_SGRBG10_1X10 }, + { { ColorFilterArray::GRBG, 12 }, MEDIA_BUS_FMT_SGRBG12_1X12 }, + { { ColorFilterArray::GRBG, 14 }, MEDIA_BUS_FMT_SGRBG14_1X14 }, + { { ColorFilterArray::GRBG, 16 }, MEDIA_BUS_FMT_SGRBG16_1X16 }, + { { ColorFilterArray::GRBG, 20 }, MEDIA_BUS_FMT_SGRBG20_1X20 }, + { { ColorFilterArray::RGGB, 8 }, MEDIA_BUS_FMT_SRGGB8_1X8 }, + { { ColorFilterArray::RGGB, 10 }, MEDIA_BUS_FMT_SRGGB10_1X10 }, + { { ColorFilterArray::RGGB, 12 }, MEDIA_BUS_FMT_SRGGB12_1X12 }, + { { ColorFilterArray::RGGB, 14 }, MEDIA_BUS_FMT_SRGGB14_1X14 }, + { { ColorFilterArray::RGGB, 16 }, MEDIA_BUS_FMT_SRGGB16_1X16 }, + { { ColorFilterArray::RGGB, 20 }, MEDIA_BUS_FMT_SRGGB20_1X20 }, + { { ColorFilterArray::MONO, 8 }, MEDIA_BUS_FMT_Y8_1X8 }, + { { ColorFilterArray::MONO, 10 }, MEDIA_BUS_FMT_Y10_1X10 }, + { { ColorFilterArray::MONO, 12 }, MEDIA_BUS_FMT_Y12_1X12 }, + { { ColorFilterArray::MONO, 16 }, MEDIA_BUS_FMT_Y16_1X16 }, +}; + +const std::unordered_map v4l2FormatToCFA { + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR), ColorFilterArray::BGGR }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG), ColorFilterArray::GBRG }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG), ColorFilterArray::GRBG }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB), ColorFilterArray::RGGB }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_MONO), ColorFilterArray::MONO }, + { V4L2PixelFormat(V4L2_PIX_FMT_GREY), ColorFilterArray::MONO }, + { V4L2PixelFormat(V4L2_PIX_FMT_Y10), ColorFilterArray::MONO }, + { V4L2PixelFormat(V4L2_PIX_FMT_Y10P), ColorFilterArray::MONO }, + { V4L2PixelFormat(V4L2_PIX_FMT_Y12), ColorFilterArray::MONO }, + { V4L2PixelFormat(V4L2_PIX_FMT_Y12P), ColorFilterArray::MONO }, + { V4L2PixelFormat(V4L2_PIX_FMT_Y16), ColorFilterArray::MONO }, +}; + +} /* namespace */ + +/** + * \fn ColorFilterArray::ColorFilterArray() + * \brief Construct an empty (and invalid) ColorFilterArray + */ + +/** + * \fn ColorFilterArray::ColorFilterArray(Order o) + * \brief Construct a ColorFilterArray from an explicit order value + * \param[in] o The order of color channels in the filter array + */ + +/** + * \brief Retrieve the ColorFilterArray associated with a media bus code + * \param[in] mbusCode The media bus code to convert into a ColorFilterArray + * + * The media bus code numeric identifiers are defined by the V4L2 specification. + */ +std::optional ColorFilterArray::fromMbusCode(unsigned int mbusCode) +{ + const auto it = mbusCodeToCFA.find(mbusCode); + + if (it == mbusCodeToCFA.end()) + return std::nullopt; + else + return it->second; +} + +/** + * \brief Retrieve the ColorFilterArray associated with a V4L2PixelFormat + * \param[in] v4l2Format The raw format to convert into a ColorFilterArray + * + * The media bus code numeric identifiers are defined by the V4L2 specification. + */ +std::optional ColorFilterArray::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) +{ + const auto it = v4l2FormatToCFA.find(v4l2Format); + + if (it == v4l2FormatToCFA.end()) + return std::nullopt; + else + return it->second; +} + +/** + * \brief Retrieve the media bus code for this ColorFilterArray and bit depth + * \param[in] bitDepth The bit depth of the samples transmitted over the bus + * \return The media bus code, or 0 if no code exists for the combination + * + * The returned code is the order-specific sensor bus code (e.g. + * MEDIA_BUS_FMT_SBGGR10_1X10). + */ +unsigned int ColorFilterArray::toMbusCode(uint8_t bitDepth) const +{ + const auto it = cfaBitDepthToMbusCode.find({*this, bitDepth}); + + if (it == cfaBitDepthToMbusCode.end()) + return 0; + else + return it->second; +} + +/** + * \brief Assemble and return a readable string representation of the + * ColorFilterArray + * \return A string describing the ColorFilterArray + */ +std::string ColorFilterArray::toString() const +{ + std::stringstream ss; + ss << *this; + + return ss.str(); +} + +/** + * \brief Insert a text representation of a ColorFilterArrays into an output stream + * \param[in] out The output stream + * \param[in] f The ColorFilterArray + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const ColorFilterArray &f) +{ + switch (f.order) { + case ColorFilterArray::BGGR: + return out << "BGGR"; + case ColorFilterArray::GBRG: + return out << "GBRG"; + case ColorFilterArray::GRBG: + return out << "GRBG"; + case ColorFilterArray::RGGB: + return out << "RGGB"; + case ColorFilterArray::MONO: + return out << "MONO"; + default: + return out << "INVALID"; + } +} + +/** + * \brief Apply a transform to this ColorFilterArray + * \param[in] t The transform to apply + * + * Applying a transform to an image captured via a ColorFilterArray affects the + * color order. For example, performing a horizontal flip on the pattern 2x2 + * RGGB causes the RG rows of pixels to become GR, and the GB rows to become + * BG. The transformed image would have a GRBG order. Performing a vertical + * flip on the 2x2 pattern RGGB causes the GB rows to come before the RG ones + * and the transformed image would have GBRG order. Applying both vertical and + * horizontal flips on the 2x2 pattern RGGB results in transformed images with + * BGGR order. + * + * Horizontal and vertical flips are applied before transpose. + * + * \return The transformed pattern as a ColorFilterArray + */ +ColorFilterArray ColorFilterArray::transform(Transform t) const +{ + ColorFilterArray result = *this; + + if (order == MONO) + return result; + + /* + * Observe that flipping bit 0 of the Order enum performs a horizontal + * mirror on the Bayer pattern (e.g. RG/GB goes to GR/BG). Similarly, + * flipping bit 1 performs a vertical mirror operation on it (e.g RG/GB + * goes to GB/RG). Applying both vertical and horizontal flips + * combines vertical and horizontal mirroring on the Bayer pattern + * (e.g. RG/GB goes to BG/GR). Hence: + */ + if (!!(t & Transform::HFlip)) + result.order = static_cast(result.order ^ 1); + if (!!(t & Transform::VFlip)) + result.order = static_cast(result.order ^ 2); + + if (!!(t & Transform::Transpose) && result.order == 1) + result.order = static_cast(2); + else if (!!(t & Transform::Transpose) && result.order == 2) + result.order = static_cast(1); + + return result; +} + +/** + * \var ColorFilterArray::order + * \brief The order of the color channels in the filter array + */ + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 17c1b2cb3479..056f30252eaf 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -22,6 +22,7 @@ libcamera_internal_sources = files([ 'camera_controls.cpp', 'camera_lens.cpp', 'clock_recovery.cpp', + 'color_filter_array.cpp', 'control_serializer.cpp', 'control_validator.cpp', 'converter.cpp', diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 73a03373c833..af518d0b2c28 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -328,7 +329,7 @@ int MaliC55CameraData::pixfmtToMbusCode(const PixelFormat &pixFmt) const if (!sdBayerFormat.isValid()) continue; - if (sdBayerFormat.order != bayerFormat.order) + if (sdBayerFormat.cfa.order != bayerFormat.cfa.order) continue; if (sdBayerFormat.bitDepth > bitDepth) { @@ -368,7 +369,7 @@ const PixelFormat &MaliC55CameraData::bestRawFormat() const continue; BayerFormat bayer = BayerFormat::fromMbusCode(rawCode); - if (bayer.order == sensorBayer.order) + if (bayer.cfa.order == sensorBayer.cfa.order) return pixFmt; } } @@ -1175,14 +1176,14 @@ int PipelineHandlerMaliC55::configure(Camera *camera, ipaConfig.sensorControls = data->sensor()->controls(); /* - * And we also need to tell the IPA the bayerOrder of the data (as + * And we also need to tell the IPA the cfaOrder of the data (as * affected by any flips that we've configured) */ const Transform &combinedTransform = maliConfig->combinedTransform(); - BayerFormat::Order bayerOrder = data->sensor()->bayerOrder(combinedTransform); + ColorFilterArray::Order cfaOrder = data->sensor()->bayerOrder(combinedTransform); ControlInfoMap ipaControls; - ret = data->ipa_->configure(ipaConfig, utils::to_underlying(bayerOrder), + ret = data->ipa_->configure(ipaConfig, utils::to_underlying(cfaOrder), &ipaControls); if (ret) { LOG(MaliC55, Error) << "Failed to configure IPA"; diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index d6ce2dbf5cee..7ea48f62cc3d 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -75,7 +76,7 @@ bool isMonoSensor(std::unique_ptr &sensor) unsigned int mbusCode = sensor->mbusCodes()[0]; const BayerFormat &bayer = BayerFormat::fromMbusCode(mbusCode); - return bayer.order == BayerFormat::Order::MONO; + return bayer.cfa.order == ColorFilterArray::Order::MONO; } const std::vector validColorSpaces = { @@ -256,7 +257,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() */ BayerFormat cfgBayer = BayerFormat::fromPixelFormat(rawStream->pixelFormat); - cfgBayer.order = data_->sensor_->bayerOrder(combinedTransform_); + cfgBayer.cfa = data_->sensor_->bayerOrder(combinedTransform_); if (rawStream->pixelFormat != cfgBayer.toPixelFormat()) { rawStream->pixelFormat = cfgBayer.toPixelFormat(); diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index d0103adbe17c..b4a5f87aa93d 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -56,32 +56,32 @@ constexpr unsigned int DefaultCompressionOffset = 2048; constexpr unsigned int DefaultCompressionMode = 1; const std::vector> BayerToMbusCodeMap{ - { { BayerFormat::BGGR, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR8_1X8, }, - { { BayerFormat::GBRG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG8_1X8, }, - { { BayerFormat::GRBG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG8_1X8, }, - { { BayerFormat::RGGB, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB8_1X8, }, - { { BayerFormat::BGGR, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR10_1X10, }, - { { BayerFormat::GBRG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG10_1X10, }, - { { BayerFormat::GRBG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG10_1X10, }, - { { BayerFormat::RGGB, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB10_1X10, }, - { { BayerFormat::BGGR, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR12_1X12, }, - { { BayerFormat::GBRG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG12_1X12, }, - { { BayerFormat::GRBG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG12_1X12, }, - { { BayerFormat::RGGB, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB12_1X12, }, - { { BayerFormat::BGGR, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR14_1X14, }, - { { BayerFormat::GBRG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG14_1X14, }, - { { BayerFormat::GRBG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG14_1X14, }, - { { BayerFormat::RGGB, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB14_1X14, }, - { { BayerFormat::BGGR, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR16_1X16, }, - { { BayerFormat::GBRG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG16_1X16, }, - { { BayerFormat::GRBG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG16_1X16, }, - { { BayerFormat::RGGB, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB16_1X16, }, - { { BayerFormat::BGGR, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SBGGR16_1X16, }, - { { BayerFormat::GBRG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGBRG16_1X16, }, - { { BayerFormat::GRBG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGRBG16_1X16, }, - { { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, }, - { { BayerFormat::MONO, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_Y16_1X16, }, - { { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_Y16_1X16, }, + { { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR8_1X8, }, + { { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG8_1X8, }, + { { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG8_1X8, }, + { { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB8_1X8, }, + { { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR10_1X10, }, + { { ColorFilterArray::GBRG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG10_1X10, }, + { { ColorFilterArray::GRBG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG10_1X10, }, + { { ColorFilterArray::RGGB, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB10_1X10, }, + { { ColorFilterArray::BGGR, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR12_1X12, }, + { { ColorFilterArray::GBRG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG12_1X12, }, + { { ColorFilterArray::GRBG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG12_1X12, }, + { { ColorFilterArray::RGGB, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB12_1X12, }, + { { ColorFilterArray::BGGR, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR14_1X14, }, + { { ColorFilterArray::GBRG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG14_1X14, }, + { { ColorFilterArray::GRBG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG14_1X14, }, + { { ColorFilterArray::RGGB, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB14_1X14, }, + { { ColorFilterArray::BGGR, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR16_1X16, }, + { { ColorFilterArray::GBRG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG16_1X16, }, + { { ColorFilterArray::GRBG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG16_1X16, }, + { { ColorFilterArray::RGGB, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB16_1X16, }, + { { ColorFilterArray::BGGR, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SBGGR16_1X16, }, + { { ColorFilterArray::GBRG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGBRG16_1X16, }, + { { ColorFilterArray::GRBG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGRBG16_1X16, }, + { { ColorFilterArray::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, }, + { { ColorFilterArray::MONO, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_Y16_1X16, }, + { { ColorFilterArray::MONO, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_Y16_1X16, }, }; unsigned int bayerToMbusCode(const BayerFormat &bayer) @@ -100,7 +100,7 @@ unsigned int bayerToMbusCode(const BayerFormat &bayer) uint32_t mbusCodeUnpacked16(unsigned int code) { BayerFormat bayer = BayerFormat::fromMbusCode(code); - BayerFormat bayer16(bayer.order, 16, BayerFormat::Packing::None); + BayerFormat bayer16(bayer.cfa.order, 16, BayerFormat::Packing::None); return bayerToMbusCode(bayer16); } @@ -109,16 +109,16 @@ uint8_t toPiSPBayerOrder(V4L2PixelFormat format) { BayerFormat bayer = BayerFormat::fromV4L2PixelFormat(format); - switch (bayer.order) { - case BayerFormat::Order::BGGR: + switch (bayer.cfa.order) { + case ColorFilterArray::Order::BGGR: return PISP_BAYER_ORDER_BGGR; - case BayerFormat::Order::GBRG: + case ColorFilterArray::Order::GBRG: return PISP_BAYER_ORDER_GBRG; - case BayerFormat::Order::GRBG: + case ColorFilterArray::Order::GRBG: return PISP_BAYER_ORDER_GRBG; - case BayerFormat::Order::RGGB: + case ColorFilterArray::Order::RGGB: return PISP_BAYER_ORDER_RGGB; - case BayerFormat::Order::MONO: + case ColorFilterArray::Order::MONO: return PISP_BAYER_ORDER_GREYSCALE; default: ASSERT(0); diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 35c29ceca1bb..816759632976 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -32,6 +32,7 @@ #include #include +#include "libcamera/internal/bayer_format.h" #include "libcamera/internal/camera.h" #include "libcamera/internal/camera_manager.h" #include "libcamera/internal/camera_sensor.h" @@ -1534,7 +1535,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) * pattern. */ BayerFormat cfgBayer = BayerFormat::fromPixelFormat(pipeConfig->captureFormat); - cfgBayer.order = data->sensor_->bayerOrder(config->combinedTransform()); + cfgBayer.cfa.order = data->sensor_->bayerOrder(config->combinedTransform()); videoFormat = cfgBayer.toV4L2PixelFormat(); } diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index cf7410bcee4c..8f47b77dc7c4 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ #include #include +#include #include #include #include @@ -41,7 +43,6 @@ namespace libcamera { -class BayerFormat; class CameraLens; class MediaEntity; class SensorConfiguration; @@ -88,7 +89,7 @@ public: const ControlList &properties() const override { return properties_; } int sensorInfo(IPACameraSensorInfo *info) const override; Transform computeTransform(Orientation *orientation) const override; - BayerFormat::Order bayerOrder(Transform t) const override; + ColorFilterArray bayerOrder(Transform t) const override; Orientation mountingOrientation() const override { return mountingOrientation_; } const ControlInfoMap &controls() const override; @@ -134,7 +135,7 @@ private: Rectangle pixelArrayArea_; Rectangle readableArea_; Rectangle activeArea_; - const BayerFormat *bayerFormat_; + std::optional cfa_; bool supportHFlips_; bool supportVFlips_; bool flipsAlterBayerOrder_; @@ -156,7 +157,7 @@ private: CameraSensorLegacy::CameraSensorLegacy(const MediaEntity *entity) : entity_(entity), pad_(UINT_MAX), staticProps_(nullptr), - bayerFormat_(nullptr), supportHFlips_(false), supportVFlips_(false), + cfa_(std::nullopt), supportHFlips_(false), supportVFlips_(false), flipsAlterBayerOrder_(false), properties_(properties::properties) { } @@ -264,9 +265,9 @@ int CameraSensorLegacy::init() /* Get the color filter array pattern (only for RAW sensors). */ for (unsigned int mbusCode : mbusCodes_) { - const BayerFormat &bayerFormat = BayerFormat::fromMbusCode(mbusCode); - if (bayerFormat.isValid()) { - bayerFormat_ = &bayerFormat; + auto cfa = ColorFilterArray::fromMbusCode(mbusCode); + if (cfa) { + cfa_ = *cfa; break; } } @@ -445,7 +446,7 @@ int CameraSensorLegacy::validateSensorDriver() << "See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information"; } - if (!bayerFormat_) + if (!cfa_) return 0; /* @@ -640,22 +641,22 @@ int CameraSensorLegacy::initProperties() properties_.set(properties::PixelArrayActiveAreas, { activeArea_ }); /* Color filter array pattern, register only for RAW sensors. */ - if (bayerFormat_) { + if (cfa_) { int32_t cfa; - switch (bayerFormat_->order) { - case BayerFormat::BGGR: + switch (cfa_->order) { + case ColorFilterArray::BGGR: cfa = properties::draft::BGGR; break; - case BayerFormat::GBRG: + case ColorFilterArray::GBRG: cfa = properties::draft::GBRG; break; - case BayerFormat::GRBG: + case ColorFilterArray::GRBG: cfa = properties::draft::GRBG; break; - case BayerFormat::RGGB: + case ColorFilterArray::RGGB: cfa = properties::draft::RGGB; break; - case BayerFormat::MONO: + case ColorFilterArray::MONO: cfa = properties::draft::MONO; break; } @@ -881,7 +882,7 @@ V4L2Subdevice::Stream CameraSensorLegacy::imageStream() const int CameraSensorLegacy::sensorInfo(IPACameraSensorInfo *info) const { - if (!bayerFormat_) + if (!cfa_) return -EINVAL; info->model = model(); @@ -982,20 +983,20 @@ Transform CameraSensorLegacy::computeTransform(Orientation *orientation) const return transform; } -BayerFormat::Order CameraSensorLegacy::bayerOrder(Transform t) const +ColorFilterArray CameraSensorLegacy::bayerOrder(Transform t) const { /* Return a defined by meaningless value for non-Bayer sensors. */ - if (!bayerFormat_) - return BayerFormat::Order::BGGR; + if (!cfa_) + return ColorFilterArray::BGGR; if (!flipsAlterBayerOrder_) - return bayerFormat_->order; + return *cfa_; /* * Apply the transform to the native (i.e. untransformed) Bayer order, * using the rest of the Bayer format supplied by the caller. */ - return bayerFormat_->transform(t).order; + return cfa_->transform(t); } const ControlInfoMap &CameraSensorLegacy::controls() const diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index 5301bc6d9f8c..c703db31d658 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -42,7 +43,6 @@ namespace libcamera { -class BayerFormat; class CameraLens; class MediaEntity; class SensorConfiguration; @@ -93,7 +93,7 @@ public: const ControlList &properties() const override { return properties_; } int sensorInfo(IPACameraSensorInfo *info) const override; Transform computeTransform(Orientation *orientation) const override; - BayerFormat::Order bayerOrder(Transform t) const override; + ColorFilterArray bayerOrder(Transform t) const override; Orientation mountingOrientation() const override { return mountingOrientation_; } const ControlInfoMap &controls() const override; @@ -144,7 +144,7 @@ private: Rectangle pixelArrayArea_; Rectangle readableArea_; Rectangle activeArea_; - BayerFormat::Order cfaPattern_; + ColorFilterArray cfa_; bool supportHFlips_; bool supportVFlips_; bool flipsAlterBayerOrder_; @@ -489,16 +489,19 @@ std::optional CameraSensorRaw::init() switch (cfaPattern) { case V4L2_CFA_PATTERN_GRBG: - cfaPattern_ = BayerFormat::GRBG; + cfa_ = ColorFilterArray::GRBG; break; case V4L2_CFA_PATTERN_RGGB: - cfaPattern_ = BayerFormat::RGGB; + cfa_ = ColorFilterArray::RGGB; break; case V4L2_CFA_PATTERN_BGGR: - cfaPattern_ = BayerFormat::BGGR; + cfa_ = ColorFilterArray::BGGR; break; case V4L2_CFA_PATTERN_GBRG: - cfaPattern_ = BayerFormat::GBRG; + cfa_ = ColorFilterArray::GBRG; + break; + case V4L2_CFA_PATTERN_MONO: + cfa_ = ColorFilterArray::MONO; break; default: LOG(CameraSensor, Error) @@ -667,20 +670,20 @@ int CameraSensorRaw::initProperties() /* Color filter array pattern. */ uint32_t cfa; - switch (cfaPattern_) { - case BayerFormat::BGGR: + switch (cfa_.order) { + case ColorFilterArray::BGGR: cfa = properties::draft::BGGR; break; - case BayerFormat::GBRG: + case ColorFilterArray::GBRG: cfa = properties::draft::GBRG; break; - case BayerFormat::GRBG: + case ColorFilterArray::GRBG: cfa = properties::draft::GRBG; break; - case BayerFormat::RGGB: + case ColorFilterArray::RGGB: cfa = properties::draft::RGGB; break; - case BayerFormat::MONO: + case ColorFilterArray::MONO: default: cfa = properties::draft::MONO; break; @@ -1112,17 +1115,16 @@ Transform CameraSensorRaw::computeTransform(Orientation *orientation) const return transform; } -BayerFormat::Order CameraSensorRaw::bayerOrder(Transform t) const +ColorFilterArray CameraSensorRaw::bayerOrder(Transform t) const { if (!flipsAlterBayerOrder_) - return cfaPattern_; + return cfa_; /* * Apply the transform to the native (i.e. untransformed) Bayer order, * using the rest of the Bayer format supplied by the caller. */ - BayerFormat format{ cfaPattern_, 8, BayerFormat::Packing::None }; - return format.transform(t).order; + return cfa_.transform(t); } const ControlInfoMap &CameraSensorRaw::controls() const diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 4f6659000edb..9862f4e29538 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -330,13 +330,13 @@ void Debayer::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *inpu } /** - * \fn void Debayer::isStandardBayerOrder(BayerFormat::Order order) + * \fn void Debayer::isStandardBayerOrder(ColorFilterArray::Order order) * \brief Common method to validate standard 2x2 Bayer pattern of 2 Green, 1 Blue, 1 Red pixels */ -bool Debayer::isStandardBayerOrder(BayerFormat::Order order) +bool Debayer::isStandardBayerOrder(ColorFilterArray::Order order) { - return order == BayerFormat::BGGR || order == BayerFormat::GBRG || - order == BayerFormat::GRBG || order == BayerFormat::RGGB; + return order == ColorFilterArray::BGGR || order == ColorFilterArray::GBRG || + order == ColorFilterArray::GRBG || order == ColorFilterArray::RGGB; } } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index e30a05279c18..d5240a1e42a2 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -87,7 +87,7 @@ private: protected: void dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output); - static bool isStandardBayerOrder(BayerFormat::Order order); + static bool isStandardBayerOrder(ColorFilterArray::Order order); }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 91867baa656a..56850a7b30c7 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -442,7 +442,7 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf if ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10 || bayerFormat.bitDepth == 12) && bayerFormat.packing == BayerFormat::Packing::None && - isStandardBayerOrder(bayerFormat.order)) { + isStandardBayerOrder(bayerFormat.cfa.order)) { config.bpp = (bayerFormat.bitDepth + 7) & ~7; config.patternSize.width = 2; config.patternSize.height = 2; @@ -452,7 +452,7 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf if (bayerFormat.bitDepth == 10 && bayerFormat.packing == BayerFormat::Packing::CSI2 && - isStandardBayerOrder(bayerFormat.order)) { + isStandardBayerOrder(bayerFormat.cfa.order)) { config.bpp = 10; config.patternSize.width = 4; /* 5 bytes per *4* pixels */ config.patternSize.height = 2; @@ -462,7 +462,7 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf if (bayerFormat.bitDepth == 12 && bayerFormat.packing == BayerFormat::Packing::CSI2 && - isStandardBayerOrder(bayerFormat.order)) { + isStandardBayerOrder(bayerFormat.cfa.order)) { config.bpp = 12; config.patternSize.width = 2; /* 3 bytes per *2* pixels */ config.patternSize.height = 2; @@ -479,18 +479,18 @@ int DebayerCpu::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf * Check for standard Bayer orders and set xShift_ and swap debayer0/1, so that * a single pair of BGGR debayer functions can be used for all 4 standard orders. */ -int DebayerCpu::setupStandardBayerOrder(BayerFormat::Order order) +int DebayerCpu::setupStandardBayerOrder(ColorFilterArray::Order order) { switch (order) { - case BayerFormat::BGGR: + case ColorFilterArray::BGGR: break; - case BayerFormat::GBRG: + case ColorFilterArray::GBRG: xShift_ = 1; /* BGGR -> GBRG */ break; - case BayerFormat::GRBG: + case ColorFilterArray::GRBG: std::swap(debayer0_, debayer1_); /* BGGR -> GRBG */ break; - case BayerFormat::RGGB: + case ColorFilterArray::RGGB: xShift_ = 1; /* BGGR -> GBRG */ std::swap(debayer0_, debayer1_); /* GBRG -> RGGB */ break; @@ -540,18 +540,18 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, /* Swap R and B in bayer order to generate BGR888 instead of RGB888 */ swapRedBlueGains_ = true; - switch (bayerFormat.order) { - case BayerFormat::BGGR: - bayerFormat.order = BayerFormat::RGGB; + switch (bayerFormat.cfa.order) { + case ColorFilterArray::BGGR: + bayerFormat.cfa.order = ColorFilterArray::RGGB; break; - case BayerFormat::GBRG: - bayerFormat.order = BayerFormat::GRBG; + case ColorFilterArray::GBRG: + bayerFormat.cfa.order = ColorFilterArray::GRBG; break; - case BayerFormat::GRBG: - bayerFormat.order = BayerFormat::GBRG; + case ColorFilterArray::GRBG: + bayerFormat.cfa.order = ColorFilterArray::GBRG; break; - case BayerFormat::RGGB: - bayerFormat.order = BayerFormat::BGGR; + case ColorFilterArray::RGGB: + bayerFormat.cfa.order = ColorFilterArray::BGGR; break; default: return invalidFmt(); @@ -563,7 +563,7 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, if ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10 || bayerFormat.bitDepth == 12) && bayerFormat.packing == BayerFormat::Packing::None && - isStandardBayerOrder(bayerFormat.order)) { + isStandardBayerOrder(bayerFormat.cfa.order)) { switch (bayerFormat.bitDepth) { case 8: SET_DEBAYER_METHODS(debayer8_BGBG_BGR888, debayer8_GRGR_BGR888) @@ -575,23 +575,23 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, SET_DEBAYER_METHODS(debayer12_BGBG_BGR888, debayer12_GRGR_BGR888) break; } - setupStandardBayerOrder(bayerFormat.order); + setupStandardBayerOrder(bayerFormat.cfa.order); return 0; } if (bayerFormat.bitDepth == 10 && bayerFormat.packing == BayerFormat::Packing::CSI2) { - switch (bayerFormat.order) { - case BayerFormat::BGGR: + switch (bayerFormat.cfa.order) { + case ColorFilterArray::BGGR: SET_DEBAYER_METHODS(debayer10P_BGBG_BGR888, debayer10P_GRGR_BGR888) return 0; - case BayerFormat::GBRG: + case ColorFilterArray::GBRG: SET_DEBAYER_METHODS(debayer10P_GBGB_BGR888, debayer10P_RGRG_BGR888) return 0; - case BayerFormat::GRBG: + case ColorFilterArray::GRBG: SET_DEBAYER_METHODS(debayer10P_GRGR_BGR888, debayer10P_BGBG_BGR888) return 0; - case BayerFormat::RGGB: + case ColorFilterArray::RGGB: SET_DEBAYER_METHODS(debayer10P_RGRG_BGR888, debayer10P_GBGB_BGR888) return 0; default: @@ -601,17 +601,17 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, if (bayerFormat.bitDepth == 12 && bayerFormat.packing == BayerFormat::Packing::CSI2) { - switch (bayerFormat.order) { - case BayerFormat::BGGR: + switch (bayerFormat.cfa.order) { + case ColorFilterArray::BGGR: SET_DEBAYER_METHODS(debayer12P_BGBG_BGR888, debayer12P_GRGR_BGR888) return 0; - case BayerFormat::GBRG: + case ColorFilterArray::GBRG: SET_DEBAYER_METHODS(debayer12P_GBGB_BGR888, debayer12P_RGRG_BGR888) return 0; - case BayerFormat::GRBG: + case ColorFilterArray::GRBG: SET_DEBAYER_METHODS(debayer12P_GRGR_BGR888, debayer12P_BGBG_BGR888) return 0; - case BayerFormat::RGGB: + case ColorFilterArray::RGGB: SET_DEBAYER_METHODS(debayer12P_RGRG_BGR888, debayer12P_GBGB_BGR888) return 0; default: diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index ae570893bf13..8e27cbae4763 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -122,7 +122,7 @@ private: void debayer12P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]); static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); - int setupStandardBayerOrder(BayerFormat::Order order); + int setupStandardBayerOrder(ColorFilterArray::Order order); int setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputFormat, bool ccmEnabled); diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 33933b11db70..3f3d2d5f0763 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -63,7 +63,7 @@ int DebayerEGL::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf if ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10) && bayerFormat.packing == BayerFormat::Packing::None && - isStandardBayerOrder(bayerFormat.order)) { + isStandardBayerOrder(bayerFormat.cfa.order)) { config.bpp = (bayerFormat.bitDepth + 7) & ~7; config.patternSize.width = 2; config.patternSize.height = 2; @@ -73,7 +73,7 @@ int DebayerEGL::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf if (bayerFormat.bitDepth == 10 && bayerFormat.packing == BayerFormat::Packing::CSI2 && - isStandardBayerOrder(bayerFormat.order)) { + isStandardBayerOrder(bayerFormat.cfa.order)) { config.bpp = 10; config.patternSize.width = 4; /* 5 bytes per *4* pixels */ config.patternSize.height = 2; @@ -83,7 +83,7 @@ int DebayerEGL::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &conf if (bayerFormat.bitDepth == 12 && bayerFormat.packing == BayerFormat::Packing::CSI2 && - isStandardBayerOrder(bayerFormat.order)) { + isStandardBayerOrder(bayerFormat.cfa.order)) { config.bpp = 12; config.patternSize.width = 2; /* 3 bytes per *2* pixels */ config.patternSize.height = 2; diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 7fb77ce7ddd6..58503f30a818 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -429,22 +429,22 @@ void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId) * Check if order is a standard Bayer order and setup xShift_ and swapLines_ * so that a single BGGR stats function can be used for all 4 standard orders. */ -int SwStatsCpu::setupStandardBayerOrder(BayerFormat::Order order) +int SwStatsCpu::setupStandardBayerOrder(ColorFilterArray::Order order) { switch (order) { - case BayerFormat::BGGR: + case ColorFilterArray::BGGR: xShift_ = 0; swapLines_ = false; break; - case BayerFormat::GBRG: + case ColorFilterArray::GBRG: xShift_ = 1; /* BGGR -> GBRG */ swapLines_ = false; break; - case BayerFormat::GRBG: + case ColorFilterArray::GRBG: xShift_ = 0; swapLines_ = true; /* BGGR -> GRBG */ break; - case BayerFormat::RGGB: + case ColorFilterArray::RGGB: xShift_ = 1; /* BGGR -> GBRG */ swapLines_ = true; /* GBRG -> RGGB */ break; @@ -474,7 +474,7 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg, unsigned int stat BayerFormat::fromPixelFormat(inputCfg.pixelFormat); if (bayerFormat.packing == BayerFormat::Packing::None && - setupStandardBayerOrder(bayerFormat.order) == 0) { + setupStandardBayerOrder(bayerFormat.cfa.order) == 0) { processFrame_ = &SwStatsCpu::processBayerFrame2; switch (bayerFormat.bitDepth) { case 8: @@ -509,16 +509,16 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg, unsigned int stat sumShift_ = 0; processFrame_ = &SwStatsCpu::processBayerFrame2; - switch (bayerFormat.order) { - case BayerFormat::BGGR: - case BayerFormat::GRBG: + switch (bayerFormat.cfa.order) { + case ColorFilterArray::BGGR: + case ColorFilterArray::GRBG: stats0_ = (bitDepth == 10) ? &SwStatsCpu::statsBGGR10PLine0 : &SwStatsCpu::statsBGGR12PLine0; - swapLines_ = bayerFormat.order == BayerFormat::GRBG; + swapLines_ = bayerFormat.cfa.order == ColorFilterArray::GRBG; return 0; - case BayerFormat::GBRG: - case BayerFormat::RGGB: + case ColorFilterArray::GBRG: + case ColorFilterArray::RGGB: stats0_ = (bitDepth == 10) ? &SwStatsCpu::statsGBRG10PLine0 : &SwStatsCpu::statsGBRG12PLine0; - swapLines_ = bayerFormat.order == BayerFormat::RGGB; + swapLines_ = bayerFormat.cfa.order == ColorFilterArray::RGGB; return 0; default: break; diff --git a/test/bayer-format.cpp b/test/bayer-format.cpp index f8d1980498c1..3ff7d3bfab97 100644 --- a/test/bayer-format.cpp +++ b/test/bayer-format.cpp @@ -30,7 +30,7 @@ protected: } /* A correct Bayer format has to be valid. */ - bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None); + bayerFmt = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); if (!bayerFmt.isValid()) { cerr << "A correct BayerFormat has to be valid." << endl; @@ -41,8 +41,8 @@ protected: * Two bayer formats created with the same order and bit depth * have to be equal. */ - bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None); - BayerFormat bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8, + bayerFmt = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); + BayerFormat bayerFmtExpect = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); if (bayerFmt != bayerFmtExpect) { cerr << "Comparison of identical formats failed." @@ -54,8 +54,8 @@ protected: * Two Bayer formats created with the same order but with a * different bitDepth are not equal. */ - bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None); - bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 12, + bayerFmt = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); + bayerFmtExpect = BayerFormat(ColorFilterArray::BGGR, 12, BayerFormat::Packing::None); if (bayerFmt == bayerFmtExpect) { cerr << "Comparison of different formats failed." @@ -95,7 +95,7 @@ protected: * when we convert the V4L2PixelFormat (V4L2_PIX_FMT_SBGGR8) * to a Bayer format. */ - bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8, + bayerFmtExpect = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); v4l2Fmt = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8); bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2Fmt); @@ -123,7 +123,7 @@ protected: * Test if a valid Bayer format can be converted to a * string representation. */ - bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None); + bayerFmt = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); if (bayerFmt.toString() != "BGGR-8") { cerr << "String representation != 'BGGR-8' (got: '" << bayerFmt.toString() << "' ) " << endl; @@ -145,10 +145,11 @@ protected: * Perform a horizontal Flip and make sure that the * order is adjusted accordingly. */ - bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None); - bayerFmtExpect = BayerFormat(BayerFormat::GBRG, 8, + bayerFmt = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); + bayerFmtExpect = BayerFormat(ColorFilterArray::GBRG, 8, BayerFormat::Packing::None); - BayerFormat hFlipFmt = bayerFmt.transform(Transform::HFlip); + BayerFormat hFlipFmt = bayerFmt; + hFlipFmt.cfa = bayerFmt.cfa.transform(Transform::HFlip); if (hFlipFmt != bayerFmtExpect) { cerr << "Horizontal flip of 'BGGR-8' should result in '" << bayerFmtExpect << "', got: '" @@ -160,10 +161,11 @@ protected: * Perform a vertical Flip and make sure that * the order is adjusted accordingly. */ - bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None); - bayerFmtExpect = BayerFormat(BayerFormat::GRBG, 8, + bayerFmt = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); + bayerFmtExpect = BayerFormat(ColorFilterArray::GRBG, 8, BayerFormat::Packing::None); - BayerFormat vFlipFmt = bayerFmt.transform(Transform::VFlip); + BayerFormat vFlipFmt = bayerFmt; + vFlipFmt.cfa = bayerFmt.cfa.transform(Transform::VFlip); if (vFlipFmt != bayerFmtExpect) { cerr << "Vertical flip of 'BGGR-8' should result in '" << bayerFmtExpect << "', got: '" @@ -176,9 +178,9 @@ protected: * pixels on the bottom left to top right diagonal and make * sure, that it doesn't change. */ - bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None); - BayerFormat transposeFmt = bayerFmt.transform( - Transform::Transpose); + bayerFmt = BayerFormat(ColorFilterArray::BGGR, 8, BayerFormat::Packing::None); + BayerFormat transposeFmt = bayerFmt; + transposeFmt.cfa = bayerFmt.cfa.transform( Transform::Transpose); if (transposeFmt != bayerFmt) { cerr << "Transpose with both green pixels on the " << "antidiagonal should not change the order " @@ -192,10 +194,10 @@ protected: * on the bottom left to top right diagonal and make sure * that their positions are switched. */ - bayerFmt = BayerFormat(BayerFormat::GBRG, 8, BayerFormat::Packing::None); - bayerFmtExpect = BayerFormat(BayerFormat::GRBG, 8, + bayerFmt = BayerFormat(ColorFilterArray::GBRG, 8, BayerFormat::Packing::None); + bayerFmtExpect = BayerFormat(ColorFilterArray::GRBG, 8, BayerFormat::Packing::None); - transposeFmt = bayerFmt.transform(Transform::Transpose); + transposeFmt.cfa = bayerFmt.cfa.transform(Transform::Transpose); if (transposeFmt != bayerFmtExpect) { cerr << "Transpose with the red & blue pixels on the " << "antidiagonal should switch their position " From patchwork Fri Oct 23 10:58:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28583 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 9244DC324C for ; Fri, 23 Oct 2026 10:59:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 22C1D68FD2; Fri, 23 Oct 2026 12:59:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vbWkFZ1s"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 65B2B68FAB for ; Fri, 23 Oct 2026 12:59:55 +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 33EB61F2B; Fri, 23 Oct 2026 12:57:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753066; bh=XE4Lq+qgvvdQ+oa1PVyg6jFqWJKqWyQ2jK41mEBS6Yc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vbWkFZ1sG49Y4zCj+Oj/wQk+o/TqyutPoUQA2ImzJbHlii6YXmr0vE27v+jeFfdgd AGzurDgcTvPGHZW8rS1e5JSxqfWoj5nfXz/aESv1cHoaWuhMDdw6hoU++PCn2oNp8c B2bsEEovWPcRm+f5e0VfroBC7fJf/agkz40Zhc/k= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:21 +0530 Subject: [PATCH WIP RFC 13/26] include: uapi: drm_fourcc: Add 14-bit R format MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-13-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=1356; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=XE4Lq+qgvvdQ+oa1PVyg6jFqWJKqWyQ2jK41mEBS6Yc=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3PBujXIo/4Z74RQ1RJlbrccQ3BxKDU8ZhbH UEnB+36nySJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats9zwAKCRBD3pH5JJpx RSa/D/4j/dYPVRDwqdTEwcZ+N+MpFPCSPmdm3Uk4bWgQBnVhg441HPRbsuiiUKkKAPDP3TCyyLy mckfd1pI9s/VZgM5iEGj08UEEQv5aUf0VTFiG4b14OQTAl2TVkn18b7XY4qgmkbknupgkuTBtED VuGmKTAwoUuspq6J+8l+blZkQAABrs6E+IO8ro8rAKygOnu+R4UZDz7uR5GznIn4jrSR1GBnF9Y hYZQXM+fHHfkfm0qwHkO0/uyQlaVHcV2dmI7UWaCnxSdbsGrgeNMjuX+SgMEd/QvkrNfln5Ba5B WcM7zgAmXGI9VTkh9WN6VLO3fuLdez96DzXOzjfBw/vIDq8iQLSi8Xx3P8c1IwO/65ozPBM/1K7 oXJzWm1C3LpAqDgVVfvpVNn5URFruZJRG7IKeWP41qNpyp1Ptd9hf3me0zA+gROEUu1hm7i3sZz zR6Y6niMUakWVMzwI1mTg+wNaaK0BH6teMJ8B07+wI16V2vcqAwuvszsM4lGHeEnTvFs3pk4GcZ MiPdM65pegBkbqErwsUervCwsxDKJk5+GBIPJK3+udhRLwTtFO6hFjWRzwl+ujzblDchLzW6oMZ cdUPql0T0AkdG4msrR3mtmrGW9lCoj7IHcfDzn0R/SJeQ4kPT2XMTX51BwWMbxwBan3gdbPtf55 m2AIUXKrPIZIT1w== 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" Add a fourcc code for 14-bit RAW data. Also add it to formats.yaml. Signed-off-by: Jai Luthra --- include/linux/drm_fourcc.h | 3 +++ src/libcamera/formats.yaml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index 8e2a6abae62f..c1703fc03cbd 100644 --- a/include/linux/drm_fourcc.h +++ b/include/linux/drm_fourcc.h @@ -128,6 +128,9 @@ extern "C" { /* 12 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ') /* [15:0] x:R 4:12 little endian */ +/* 14 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R14 fourcc_code('R', '1', '4', ' ') /* [15:0] x:R 2:14 little endian */ + /* 16 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index 2d54d391ca01..d256fd2c1bfe 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -11,6 +11,8 @@ formats: fourcc: DRM_FORMAT_R10 - R12: fourcc: DRM_FORMAT_R12 + - R14: + fourcc: DRM_FORMAT_R14 - R16: fourcc: DRM_FORMAT_R16 From patchwork Fri Oct 23 10:58:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28584 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 E527AC324C for ; Fri, 23 Oct 2026 11:00:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7F10668FD5; Fri, 23 Oct 2026 13:00:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XYBO0auz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B94568FAB for ; Fri, 23 Oct 2026 13:00:01 +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 AAA5F1F3D; Fri, 23 Oct 2026 12:57:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753072; bh=67KPdihOtgdGSwRQdTgzl5wXJJsnK+oZLBcU+Auima0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XYBO0auzHNS2lfXX7skd6ntg9NWlSbwjhD4nWpcz/lj0w07U991xYL8byxdXBGCPc p1uNZSkiMO1thDGxrU1DOfO+9LLEAp731kFZbsfWbqMH4v8r2gEC91hbMVY7KgSUE1 i0vuW8RNpY3ep0B87EwDT1lP86U327PklXRX4Yhk= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:22 +0530 Subject: [PATCH WIP RFC 14/26] libcamera: formats: Switch to generic layout-agnostic formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-14-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=29795; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=67KPdihOtgdGSwRQdTgzl5wXJJsnK+oZLBcU+Auima0=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3QI2EDhj66IIAnOEN0cdrNVXP6+vz7/pXfb PyQ+FymQZeJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats90AAKCRBD3pH5JJpx RWPTEACCKQ91XgYHeFcVeaaAy/7yqdQ7yYOkPa1lg7qCdx0IA5d7JeFpAnPmazu0yUo7nPhQ2lE OQdllF7lCfapdvCA/VKunCU4mmp3pC7ZVwAfITLoJsZX2wEf8/WUtVfCZrs8LXVSSSRiS4zgCSB fxlAb3Bzytos/HImZG5pK7p4tiKtKVQOfJHNX4VzvhGP2JSpg2/fBzHy4+KZsG+pgA/2uqXpEjL fAzgXIe3NxHO/IyQQenciZCShZaxxWSFuyiaPrYCxMsMlemH5MjhdcUxYwpZCSWDvaTh3I7FyrV JxWFjPObPMDhgGbPSGAIUGitLDLbf9dQoTJHNWzgHgDwMvkawodihtHCDHGyBFEmwg1WfmJrXc9 3bZq3ztPLRdhGmqA7kO5qDf4xUVkrowEBGHjB3YmKTCkjiC6FTzb4HQkXBBLbBvDjDWWJ6JOIsm g0bP9vhLytibA1fDY9lWUFFpfd7td2PzV3UuJBe5JYrEP9pgO5ORoLD48TbbKoyOGSFSocsrHNo yMtLEOTn8TA9Vh9/xqZoR9mLcVItIGT0f6Q2yV4Ctr98Wx230KB3Nv/c7Bv6TnV8Z02coGXGdaK GSXf6tk/iR1lYPTDaXL7WCwbxpP9qwtjfq8Mott+cYvQsA27uYsKMCpJaSkZUzLtaVM6wJthFVK XxsgsQds43fscKA== 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" The new common raw sensor model in V4L2 separates out the layout of pixel data (bayer order, embedded line layout etc.) from the bit-depth and packing used on the bus. Follow suit throughout libcamera, by dropping the old PixelFormats that encoded the bayer-order, and switching to generic formats for raw streams. Signed-off-by: Jai Luthra --- For the WIP series I decided to drop the old formats altogether to make the migration easier internally. Once the migration is complete, I will add them back in, but warning the external users that these are now deprecated. --- src/libcamera/formats.cpp | 440 +++++++++---------------------------- src/libcamera/formats.yaml | 136 +++--------- src/libcamera/v4l2_pixelformat.cpp | 90 +++++--- 3 files changed, 183 insertions(+), 483 deletions(-) diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index bfcdfc08960d..2a79a3b6c7f8 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -568,330 +568,144 @@ const std::map pixelFormatInfo{ } }, /* Bayer formats. */ - { formats::SBGGR8, { - .name = "SBGGR8", - .format = formats::SBGGR8, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), }, + { formats::RAW8, { + .name = "RAW8", + .format = formats::RAW8, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_RAW_8), + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8), + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8), + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8), + }, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = false, .pixelsPerGroup = 2, .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG8, { - .name = "SGBRG8", - .format = formats::SGBRG8, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8), }, - .bitsPerPixel = 8, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG8, { - .name = "SGRBG8", - .format = formats::SGRBG8, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8), }, - .bitsPerPixel = 8, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB8, { - .name = "SRGGB8", - .format = formats::SRGGB8, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8), }, - .bitsPerPixel = 8, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SBGGR10, { - .name = "SBGGR10", - .format = formats::SBGGR10, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10), }, + { formats::RAW10, { + .name = "RAW10", + .format = formats::RAW10, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_RAW_10), + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10), + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10), + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10), + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10), + }, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = false, .pixelsPerGroup = 2, .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG10, { - .name = "SGBRG10", - .format = formats::SGBRG10, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG10, { - .name = "SGRBG10", - .format = formats::SGRBG10, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB10, { - .name = "SRGGB10", - .format = formats::SRGGB10, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SBGGR10_CSI2P, { - .name = "SBGGR10_CSI2P", - .format = formats::SBGGR10_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P), }, + { formats::RAW10_CSI2P, { + .name = "RAW10_CSI2P", + .format = formats::RAW10_CSI2P, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_10), + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P), + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P), + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P), + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P), + }, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = true, .pixelsPerGroup = 4, .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG10_CSI2P, { - .name = "SGBRG10_CSI2P", - .format = formats::SGBRG10_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 4, - .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG10_CSI2P, { - .name = "SGRBG10_CSI2P", - .format = formats::SGRBG10_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 4, - .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB10_CSI2P, { - .name = "SRGGB10_CSI2P", - .format = formats::SRGGB10_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 4, - .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SBGGR12, { - .name = "SBGGR12", - .format = formats::SBGGR12, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), }, + { formats::RAW12, { + .name = "RAW12", + .format = formats::RAW12, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_RAW_12), + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12), + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12), + }, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = false, .pixelsPerGroup = 2, .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG12, { - .name = "SGBRG12", - .format = formats::SGBRG12, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), }, - .bitsPerPixel = 12, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG12, { - .name = "SGRBG12", - .format = formats::SGRBG12, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12), }, - .bitsPerPixel = 12, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB12, { - .name = "SRGGB12", - .format = formats::SRGGB12, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12), }, - .bitsPerPixel = 12, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SBGGR12_CSI2P, { - .name = "SBGGR12_CSI2P", - .format = formats::SBGGR12_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P), }, + { formats::RAW12_CSI2P, { + .name = "RAW12_CSI2P", + .format = formats::RAW12_CSI2P, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_12), + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P), + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P), + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P), + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P), + }, .bitsPerPixel = 12, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = true, .pixelsPerGroup = 2, .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG12_CSI2P, { - .name = "SGBRG12_CSI2P", - .format = formats::SGBRG12_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P), }, - .bitsPerPixel = 12, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 2, - .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG12_CSI2P, { - .name = "SGRBG12_CSI2P", - .format = formats::SGRBG12_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P), }, - .bitsPerPixel = 12, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 2, - .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB12_CSI2P, { - .name = "SRGGB12_CSI2P", - .format = formats::SRGGB12_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P), }, - .bitsPerPixel = 12, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 2, - .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SBGGR14, { - .name = "SBGGR14", - .format = formats::SBGGR14, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14), }, + { formats::RAW14, { + .name = "RAW14", + .format = formats::RAW14, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_RAW_14), + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14), + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14), + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14), + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14), + }, .bitsPerPixel = 14, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = false, .pixelsPerGroup = 2, .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG14, { - .name = "SGBRG14", - .format = formats::SGBRG14, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14), }, - .bitsPerPixel = 14, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG14, { - .name = "SGRBG14", - .format = formats::SGRBG14, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14), }, - .bitsPerPixel = 14, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB14, { - .name = "SRGGB14", - .format = formats::SRGGB14, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14), }, - .bitsPerPixel = 14, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SBGGR14_CSI2P, { - .name = "SBGGR14_CSI2P", - .format = formats::SBGGR14_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P), }, + { formats::RAW14_CSI2P, { + .name = "RAW14_CSI2P", + .format = formats::RAW14_CSI2P, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_14), + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P), + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P), + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P), + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P), + }, .bitsPerPixel = 14, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = true, .pixelsPerGroup = 4, .planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG14_CSI2P, { - .name = "SGBRG14_CSI2P", - .format = formats::SGBRG14_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P), }, - .bitsPerPixel = 14, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 4, - .planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG14_CSI2P, { - .name = "SGRBG14_CSI2P", - .format = formats::SGRBG14_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P), }, - .bitsPerPixel = 14, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 4, - .planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB14_CSI2P, { - .name = "SRGGB14_CSI2P", - .format = formats::SRGGB14_CSI2P, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P), }, - .bitsPerPixel = 14, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 4, - .planes = {{ { 7, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SBGGR16, { - .name = "SBGGR16", - .format = formats::SBGGR16, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16), }, + { formats::RAW16, { + .name = "RAW16", + .format = formats::RAW16, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_RAW_16), + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16), + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16), + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16), + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16), + }, .bitsPerPixel = 16, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = false, .pixelsPerGroup = 2, .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG16, { - .name = "SGBRG16", - .format = formats::SGBRG16, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16), }, - .bitsPerPixel = 16, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG16, { - .name = "SGRBG16", - .format = formats::SGRBG16, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16), }, - .bitsPerPixel = 16, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB16, { - .name = "SRGGB16", - .format = formats::SRGGB16, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16), }, - .bitsPerPixel = 16, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = false, - .pixelsPerGroup = 2, - .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SBGGR10_IPU3, { - .name = "SBGGR10_IPU3", - .format = formats::SBGGR10_IPU3, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10), }, + { formats::RAW10_IPU3, { + .name = "RAW10_IPU3", + .format = formats::RAW10_IPU3, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_RAW10), + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10), + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10), + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10), + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10), + }, .bitsPerPixel = 10, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = true, @@ -899,70 +713,16 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 25, .planes = {{ { 32, 1 }, { 0, 0 }, { 0, 0 } }}, } }, - { formats::SGBRG10_IPU3, { - .name = "SGBRG10_IPU3", - .format = formats::SGBRG10_IPU3, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 25, - .planes = {{ { 32, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SGRBG10_IPU3, { - .name = "SGRBG10_IPU3", - .format = formats::SGRBG10_IPU3, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 25, - .planes = {{ { 32, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::SRGGB10_IPU3, { - .name = "SRGGB10_IPU3", - .format = formats::SRGGB10_IPU3, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10), }, - .bitsPerPixel = 10, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 25, - .planes = {{ { 32, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::BGGR_PISP_COMP1, { - .name = "BGGR_PISP_COMP1", - .format = formats::BGGR_PISP_COMP1, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR), }, - .bitsPerPixel = 8, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 2, - .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::GBRG_PISP_COMP1, { - .name = "GBRG_PISP_COMP1", - .format = formats::GBRG_PISP_COMP1, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG), }, - .bitsPerPixel = 8, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 2, - .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::GRBG_PISP_COMP1, { - .name = "GRBG_PISP_COMP1", - .format = formats::GRBG_PISP_COMP1, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG), }, - .bitsPerPixel = 8, - .colourEncoding = PixelFormatInfo::ColourEncodingRAW, - .packed = true, - .pixelsPerGroup = 2, - .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, - } }, - { formats::RGGB_PISP_COMP1, { - .name = "RGGB_PISP_COMP1", - .format = formats::RGGB_PISP_COMP1, - .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB), }, + { formats::RAW_PISP_COMP1, { + .name = "RAW_PISP_COMP1", + .format = formats::RAW_PISP_COMP1, + .v4l2Formats = { + V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RAW), + V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR), + V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG), + V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG), + V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB), + }, .bitsPerPixel = 8, .colourEncoding = PixelFormatInfo::ColourEncodingRAW, .packed = true, diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index d256fd2c1bfe..d71c65078587 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -16,6 +16,16 @@ formats: - R16: fourcc: DRM_FORMAT_R16 + - R10_CSI2P: + fourcc: DRM_FORMAT_R10 + mod: MIPI_FORMAT_MOD_CSI2_PACKED + - R12_CSI2P: + fourcc: DRM_FORMAT_R12 + mod: MIPI_FORMAT_MOD_CSI2_PACKED + - R14_CSI2P: + fourcc: DRM_FORMAT_R14 + mod: MIPI_FORMAT_MOD_CSI2_PACKED + - RGB565: fourcc: DRM_FORMAT_RGB565 - RGB565_BE: @@ -92,123 +102,35 @@ formats: - MJPEG: fourcc: DRM_FORMAT_MJPEG - - SRGGB8: - fourcc: DRM_FORMAT_SRGGB8 - - SGRBG8: - fourcc: DRM_FORMAT_SGRBG8 - - SGBRG8: - fourcc: DRM_FORMAT_SGBRG8 - - SBGGR8: - fourcc: DRM_FORMAT_SBGGR8 + - RAW8: + fourcc: DRM_FORMAT_R8 + - RAW10: + fourcc: DRM_FORMAT_R10 + - RAW12: + fourcc: DRM_FORMAT_R12 + - RAW14: + fourcc: DRM_FORMAT_R14 + - RAW16: + fourcc: DRM_FORMAT_R16 - - SRGGB10: - fourcc: DRM_FORMAT_SRGGB10 - - SGRBG10: - fourcc: DRM_FORMAT_SGRBG10 - - SGBRG10: - fourcc: DRM_FORMAT_SGBRG10 - - SBGGR10: - fourcc: DRM_FORMAT_SBGGR10 - - - SRGGB12: - fourcc: DRM_FORMAT_SRGGB12 - - SGRBG12: - fourcc: DRM_FORMAT_SGRBG12 - - SGBRG12: - fourcc: DRM_FORMAT_SGBRG12 - - SBGGR12: - fourcc: DRM_FORMAT_SBGGR12 - - - SRGGB14: - fourcc: DRM_FORMAT_SRGGB14 - - SGRBG14: - fourcc: DRM_FORMAT_SGRBG14 - - SGBRG14: - fourcc: DRM_FORMAT_SGBRG14 - - SBGGR14: - fourcc: DRM_FORMAT_SBGGR14 - - - SRGGB16: - fourcc: DRM_FORMAT_SRGGB16 - - SGRBG16: - fourcc: DRM_FORMAT_SGRBG16 - - SGBRG16: - fourcc: DRM_FORMAT_SGBRG16 - - SBGGR16: - fourcc: DRM_FORMAT_SBGGR16 - - - R10_CSI2P: + - RAW10_CSI2P: fourcc: DRM_FORMAT_R10 mod: MIPI_FORMAT_MOD_CSI2_PACKED - - R12_CSI2P: + - RAW12_CSI2P: fourcc: DRM_FORMAT_R12 mod: MIPI_FORMAT_MOD_CSI2_PACKED - - - SRGGB10_CSI2P: - fourcc: DRM_FORMAT_SRGGB10 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SGRBG10_CSI2P: - fourcc: DRM_FORMAT_SGRBG10 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SGBRG10_CSI2P: - fourcc: DRM_FORMAT_SGBRG10 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SBGGR10_CSI2P: - fourcc: DRM_FORMAT_SBGGR10 + - RAW14_CSI2P: + fourcc: DRM_FORMAT_R14 mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SRGGB12_CSI2P: - fourcc: DRM_FORMAT_SRGGB12 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SGRBG12_CSI2P: - fourcc: DRM_FORMAT_SGRBG12 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SGBRG12_CSI2P: - fourcc: DRM_FORMAT_SGBRG12 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SBGGR12_CSI2P: - fourcc: DRM_FORMAT_SBGGR12 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - - SRGGB14_CSI2P: - fourcc: DRM_FORMAT_SRGGB14 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SGRBG14_CSI2P: - fourcc: DRM_FORMAT_SGRBG14 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SGBRG14_CSI2P: - fourcc: DRM_FORMAT_SGBRG14 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - SBGGR14_CSI2P: - fourcc: DRM_FORMAT_SBGGR14 - mod: MIPI_FORMAT_MOD_CSI2_PACKED - - - SRGGB10_IPU3: - fourcc: DRM_FORMAT_SRGGB10 - mod: IPU3_FORMAT_MOD_PACKED - - SGRBG10_IPU3: - fourcc: DRM_FORMAT_SGRBG10 - mod: IPU3_FORMAT_MOD_PACKED - - SGBRG10_IPU3: - fourcc: DRM_FORMAT_SGBRG10 - mod: IPU3_FORMAT_MOD_PACKED - - SBGGR10_IPU3: - fourcc: DRM_FORMAT_SBGGR10 + - RAW10_IPU3: + fourcc: DRM_FORMAT_R10 mod: IPU3_FORMAT_MOD_PACKED - - RGGB_PISP_COMP1: - fourcc: DRM_FORMAT_SRGGB16 - mod: PISP_FORMAT_MOD_COMPRESS_MODE1 - - GRBG_PISP_COMP1: - fourcc: DRM_FORMAT_SGRBG16 - mod: PISP_FORMAT_MOD_COMPRESS_MODE1 - - GBRG_PISP_COMP1: - fourcc: DRM_FORMAT_SGBRG16 - mod: PISP_FORMAT_MOD_COMPRESS_MODE1 - - BGGR_PISP_COMP1: - fourcc: DRM_FORMAT_SBGGR16 - mod: PISP_FORMAT_MOD_COMPRESS_MODE1 - MONO_PISP_COMP1: fourcc: DRM_FORMAT_R16 mod: PISP_FORMAT_MOD_COMPRESS_MODE1 + - RAW_PISP_COMP1: + fourcc: DRM_FORMAT_R16 + mod: PISP_FORMAT_MOD_COMPRESS_MODE1 ... diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index c3e01a10e72a..d51987c5ad8a 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -145,78 +145,96 @@ const std::map vpf2pf{ { formats::R16, "16-bit Greyscale" } }, /* Bayer formats. */ + { V4L2PixelFormat(V4L2_PIX_FMT_RAW_8), + { formats::RAW8, "8-bit Raw" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), - { formats::SBGGR8, "8-bit Bayer BGBG/GRGR" } }, + { formats::RAW8, "8-bit Bayer BGBG/GRGR" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8), - { formats::SGBRG8, "8-bit Bayer GBGB/RGRG" } }, + { formats::RAW8, "8-bit Bayer GBGB/RGRG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8), - { formats::SGRBG8, "8-bit Bayer GRGR/BGBG" } }, + { formats::RAW8, "8-bit Bayer GRGR/BGBG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8), - { formats::SRGGB8, "8-bit Bayer RGRG/GBGB" } }, + { formats::RAW8, "8-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RAW_10), + { formats::RAW10, "10-bit Raw" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10), - { formats::SBGGR10, "10-bit Bayer BGBG/GRGR" } }, + { formats::RAW10, "10-bit Bayer BGBG/GRGR" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10), - { formats::SGBRG10, "10-bit Bayer GBGB/RGRG" } }, + { formats::RAW10, "10-bit Bayer GBGB/RGRG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10), - { formats::SGRBG10, "10-bit Bayer GRGR/BGBG" } }, + { formats::RAW10, "10-bit Bayer GRGR/BGBG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10), - { formats::SRGGB10, "10-bit Bayer RGRG/GBGB" } }, + { formats::RAW10, "10-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_10), + { formats::RAW10_CSI2P, "10-bit Raw Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P), - { formats::SBGGR10_CSI2P, "10-bit Bayer BGBG/GRGR Packed" } }, + { formats::RAW10_CSI2P, "10-bit Bayer BGBG/GRGR Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P), - { formats::SGBRG10_CSI2P, "10-bit Bayer GBGB/RGRG Packed" } }, + { formats::RAW10_CSI2P, "10-bit Bayer GBGB/RGRG Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P), - { formats::SGRBG10_CSI2P, "10-bit Bayer GRGR/BGBG Packed" } }, + { formats::RAW10_CSI2P, "10-bit Bayer GRGR/BGBG Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P), - { formats::SRGGB10_CSI2P, "10-bit Bayer RGRG/GBGB Packed" } }, + { formats::RAW10_CSI2P, "10-bit Bayer RGRG/GBGB Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RAW_12), + { formats::RAW12, "12-bit Raw" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12), - { formats::SBGGR12, "12-bit Bayer BGBG/GRGR" } }, + { formats::RAW12, "12-bit Bayer BGBG/GRGR" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12), - { formats::SGBRG12, "12-bit Bayer GBGB/RGRG" } }, + { formats::RAW12, "12-bit Bayer GBGB/RGRG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12), - { formats::SGRBG12, "12-bit Bayer GRGR/BGBG" } }, + { formats::RAW12, "12-bit Bayer GRGR/BGBG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12), - { formats::SRGGB12, "12-bit Bayer RGRG/GBGB" } }, + { formats::RAW12, "12-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_12), + { formats::RAW12_CSI2P, "12-bit Raw Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P), - { formats::SBGGR12_CSI2P, "12-bit Bayer BGBG/GRGR Packed" } }, + { formats::RAW12_CSI2P, "12-bit Bayer BGBG/GRGR Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P), - { formats::SGBRG12_CSI2P, "12-bit Bayer GBGB/RGRG Packed" } }, + { formats::RAW12_CSI2P, "12-bit Bayer GBGB/RGRG Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P), - { formats::SGRBG12_CSI2P, "12-bit Bayer GRGR/BGBG Packed" } }, + { formats::RAW12_CSI2P, "12-bit Bayer GRGR/BGBG Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P), - { formats::SRGGB12_CSI2P, "12-bit Bayer RGRG/GBGB Packed" } }, + { formats::RAW12_CSI2P, "12-bit Bayer RGRG/GBGB Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RAW_14), + { formats::RAW14, "14-bit Raw" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14), - { formats::SBGGR14, "14-bit Bayer BGBG/GRGR" } }, + { formats::RAW14, "14-bit Bayer BGBG/GRGR" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14), - { formats::SGBRG14, "14-bit Bayer GBGB/RGRG" } }, + { formats::RAW14, "14-bit Bayer GBGB/RGRG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14), - { formats::SGRBG14, "14-bit Bayer GRGR/BGBG" } }, + { formats::RAW14, "14-bit Bayer GRGR/BGBG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14), - { formats::SRGGB14, "14-bit Bayer RGRG/GBGB" } }, + { formats::RAW14, "14-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_14), + { formats::RAW14_CSI2P, "14-bit Raw Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P), - { formats::SBGGR14_CSI2P, "14-bit Bayer BGBG/GRGR Packed" } }, + { formats::RAW14_CSI2P, "14-bit Bayer BGBG/GRGR Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P), - { formats::SGBRG14_CSI2P, "14-bit Bayer GBGB/RGRG Packed" } }, + { formats::RAW14_CSI2P, "14-bit Bayer GBGB/RGRG Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P), - { formats::SGRBG14_CSI2P, "14-bit Bayer GRGR/BGBG Packed" } }, + { formats::RAW14_CSI2P, "14-bit Bayer GRGR/BGBG Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P), - { formats::SRGGB14_CSI2P, "14-bit Bayer RGRG/GBGB Packed" } }, + { formats::RAW14_CSI2P, "14-bit Bayer RGRG/GBGB Packed" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RAW_16), + { formats::RAW16, "16-bit Raw" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16), - { formats::SBGGR16, "16-bit Bayer BGBG/GRGR" } }, + { formats::RAW16, "16-bit Bayer BGBG/GRGR" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16), - { formats::SGBRG16, "16-bit Bayer GBGB/RGRG" } }, + { formats::RAW16, "16-bit Bayer GBGB/RGRG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16), - { formats::SGRBG16, "16-bit Bayer GRGR/BGBG" } }, + { formats::RAW16, "16-bit Bayer GRGR/BGBG" } }, { V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16), - { formats::SRGGB16, "16-bit Bayer RGRG/GBGB" } }, + { formats::RAW16, "16-bit Bayer RGRG/GBGB" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RAW), + { formats::RAW_PISP_COMP1, "16-bit Raw PiSP Compress Mode 1" } }, { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR), - { formats::BGGR_PISP_COMP1, "16-bit Bayer BGBG/GRGR PiSP Compress Mode 1" } }, + { formats::RAW_PISP_COMP1, "16-bit Bayer BGBG/GRGR PiSP Compress Mode 1" } }, { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG), - { formats::GBRG_PISP_COMP1, "16-bit Bayer GBGB/RGRG PiSP Compress Mode 1" } }, + { formats::RAW_PISP_COMP1, "16-bit Bayer GBGB/RGRG PiSP Compress Mode 1" } }, { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG), - { formats::GRBG_PISP_COMP1, "16-bit Bayer GRGR/BGBG PiSP Compress Mode 1" } }, + { formats::RAW_PISP_COMP1, "16-bit Bayer GRGR/BGBG PiSP Compress Mode 1" } }, { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB), - { formats::RGGB_PISP_COMP1, "16-bit Bayer RGRG/GBGB PiSP Compress Mode 1" } }, + { formats::RAW_PISP_COMP1, "16-bit Bayer RGRG/GBGB PiSP Compress Mode 1" } }, { V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_MONO), { formats::MONO_PISP_COMP1, "16-bit Mono PiSP Compress Mode 1" } }, From patchwork Fri Oct 23 10:58:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28585 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 A43B3C324C for ; Fri, 23 Oct 2026 11:00:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4CDD068FD8; Fri, 23 Oct 2026 13:00:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wkezBhBN"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E957168FC8 for ; Fri, 23 Oct 2026 13:00:05 +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 ABD272365; Fri, 23 Oct 2026 12:57:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753077; bh=Etl9cKvOrPXyrZ5Tb1MREL6BWY3jDDqzEo+elXJCmuQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=wkezBhBNbC6lv677XfklA3k4FCBmyhfXsJ+J4c+kIOZviYLxtvW5HOIuEUwuECapw YawwoTuhSNIa3PAMJs6zbnVOvvLnwtcbz5eFqwUmx6//3x37jstV7sKVLXopN5jFIS 0ebMLrTRzng5JE8DIYyZkMYNiXIQ+ZqCwSpt6n6U= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:23 +0530 Subject: [PATCH WIP RFC 15/26] HACK: libcamera: formats: Add a modifier for RAW colorspace MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-15-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=2602; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=Etl9cKvOrPXyrZ5Tb1MREL6BWY3jDDqzEo+elXJCmuQ=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3RT9O+ImvOGfmeXvlLP5lGb4xNmIi/iS8RS 6WXFAqa03KJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats90QAKCRBD3pH5JJpx RctlD/sGsgF6btXgiiy1fV6wqD13etapWimlpmFVZO7tVk7uCUL5ZLmy46ulA18hBpLMKa430LG 153P6XcM20g+u8Q9SNjFlS4s2zuayVq9y8XsDtQynGhk3cjd1tlCs5SXWZ9kbKbue6uMmvdqa/f a2uTyd9nNx0Zv49DWSKWM8QndNfpqwfPxGvgm4T8YHITY237FZpSzH09xksJZw5UXkFU7iNQkuX Y4Jv6h+7Twto5E59tmuFAnqcZiiplhQiHO8bmJM7NdtsNyUWk3QnwyMnWCItKjJZnyIkgpD6rbG dggC1VZTqIVCO0GwvbSP7Upz5AAcHlP0toF8aMtnxPFGITGP0VA7fzcHDgaawMzZDYOUlT8BsTO U/ep11kfEWjFOFA/TyHFH8Yi2tnK7saWDe9HbM++cwkktCYaywQUQUxhHgNbcKID/t8L5dCG44V NGEGoIYjtU+6UIqB0A6w0bemLaYifEsXSqtYgXJBwzBcnfd1R/tIuAe+UI+QYNitrbVoKJM36BU 2J4HyVQnZqhu9PR385pNzB7iG7kM4YXBndCSY+KYYTLQrzw3UbuAPKHHzE8zFfFR6CK9ZqHlRpF Cq4xOrirSpKJgqWaNcuZNPgGu0sKxdMJ2sAEk8EmJbK2W2t6VrQtvXU0deozd8ljkhTEpj27g+N dTMBR3M0F6q2cDw== 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" This is a temporary HACK, as we don't have a way to communicate to libcamera users through the fourcc if a pixel format is coming from a RAW sensor with a valid bayer ordering, or if it is monochrome (YUV colorspace) data that can be used directly without any demosaicing. Signed-off-by: Jai Luthra --- include/linux/drm_fourcc.h | 4 ++++ src/libcamera/formats.yaml | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index c1703fc03cbd..f226d2667b9d 100644 --- a/include/linux/drm_fourcc.h +++ b/include/linux/drm_fourcc.h @@ -1858,9 +1858,13 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) * pixel, in the same order. */ #define MIPI_FORMAT_MOD_CSI2_PACKED fourcc_mod_code(MIPI, 1) +#define MIPI_FORMAT_MOD_CSI2_RAW fourcc_mod_code(MIPI, 2) +#define MIPI_FORMAT_MOD_CSI2_RAW_PACKED fourcc_mod_code(MIPI, 3) #define PISP_FORMAT_MOD_COMPRESS_MODE1 fourcc_mod_code(RPI, 1) #define PISP_FORMAT_MOD_COMPRESS_MODE2 fourcc_mod_code(RPI, 2) +#define PISP_FORMAT_MOD_COMPRESS_RAW_MODE1 fourcc_mod_code(RPI, 3) +#define PISP_FORMAT_MOD_COMPRESS_RAW_MODE2 fourcc_mod_code(RPI, 4) #if defined(__cplusplus) } diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index d71c65078587..5ed16d29f341 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -104,24 +104,29 @@ formats: - RAW8: fourcc: DRM_FORMAT_R8 + mod: MIPI_FORMAT_MOD_CSI2_RAW - RAW10: fourcc: DRM_FORMAT_R10 + mod: MIPI_FORMAT_MOD_CSI2_RAW - RAW12: fourcc: DRM_FORMAT_R12 + mod: MIPI_FORMAT_MOD_CSI2_RAW - RAW14: fourcc: DRM_FORMAT_R14 + mod: MIPI_FORMAT_MOD_CSI2_RAW - RAW16: fourcc: DRM_FORMAT_R16 + mod: MIPI_FORMAT_MOD_CSI2_RAW - RAW10_CSI2P: fourcc: DRM_FORMAT_R10 - mod: MIPI_FORMAT_MOD_CSI2_PACKED + mod: MIPI_FORMAT_MOD_CSI2_RAW_PACKED - RAW12_CSI2P: fourcc: DRM_FORMAT_R12 - mod: MIPI_FORMAT_MOD_CSI2_PACKED + mod: MIPI_FORMAT_MOD_CSI2_RAW_PACKED - RAW14_CSI2P: fourcc: DRM_FORMAT_R14 - mod: MIPI_FORMAT_MOD_CSI2_PACKED + mod: MIPI_FORMAT_MOD_CSI2_RAW_PACKED - RAW10_IPU3: fourcc: DRM_FORMAT_R10 @@ -132,5 +137,5 @@ formats: mod: PISP_FORMAT_MOD_COMPRESS_MODE1 - RAW_PISP_COMP1: fourcc: DRM_FORMAT_R16 - mod: PISP_FORMAT_MOD_COMPRESS_MODE1 + mod: PISP_FORMAT_MOD_COMPRESS_RAW_MODE1 ... From patchwork Fri Oct 23 10:58:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28586 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 89F21C324C for ; Fri, 23 Oct 2026 11:00:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2230368FDB; Fri, 23 Oct 2026 13:00:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="u6ky2BRr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2362068FB7 for ; Fri, 23 Oct 2026 13:00:11 +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 F07022830; Fri, 23 Oct 2026 12:58:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753082; bh=LI70pq+ztCKASZoW44bzJiJb8encCc7pCF6BKqntlK4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=u6ky2BRrVbyxp8YiJ/ONJLYNgnpxxUPd7gKh3/cOrC8RWhPRu4CGa0bGY53Jvc1BZ 9P2OQTKmqPuCToN4h0ZaiPUDcjCX8SA4FRReGAz0lDtGSSfillL+RSYCU7hZucMbln Kd4F8Dn3E8ZrxddSygKUKCUVUU92WLGZryCfhWbE= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:24 +0530 Subject: [PATCH WIP RFC 16/26] libcamera: v4l2_pixelformat: Add toNonGeneric() helper MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-16-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=7857; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=LI70pq+ztCKASZoW44bzJiJb8encCc7pCF6BKqntlK4=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3Sq2VlRPHwNC5SYjiinj7Ks54Rx2pBzeZyT Ks2sVYfnlqJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats90gAKCRBD3pH5JJpx RT8eD/96OOeJy9NX+16xYk8J8kvboqH7Q8OIX/BiGHpn9NiygDsiSgWFv0fNWpjeByHc4m3oTMB ScC6/gr0Somozk+7orp5dz4TVfOJAR70mpsiTw1Zl1nJFkrkUQ5mO7/9ryiUb60+idl9QZ8WwsS L93PV/9gUFWDTQ8ebmPqK5ahBkADi1uudRUHl1+x988xlgUP6umhs+OoGTrWzl656FXGOLBKTRc 7H7rknUHcsnZ900cjZ4ulYa/yJv+CGGB4rM8t7uusuU1VqrBcwklQs/KpXAqwJveNfV8LpviuLo lc56iBXnLeSEozKy6j4BT18Qmz92Y6+sTWF5DSweHP90b3mihud5UF/sCDFJO7X/gZK3S4UEpkn PArsmhimgnOchm0QzMja9WBFkEJdj1bPdPnvzyBp0kyfZq0XbI0a3j+kOTbeDrWyn/dDEL/y86h ByX3XJvsf5iICt2G+TbrF8KufjOmInsZbiCaeBzNc0R4Sm/pzi3AL73lok0TOtZWhp3Jd3UQmcG miUhIb/q8KJ5H/vJNHL++WhhikPSB1b4+oMK8Xh6rV+WFA7l8mMsr41cq/4ROSxHHZUKSFykz6S xBtOPgve88JAgFefSUjWHZ97v7lMLEBtpCdZWXFt5ICYMxlSMTgdphs4+MicqMv1Ba0H/Cl5xwk Yxw1I7KZwVLjKLQ== 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" Many pipelines may not support the generic RAW format fourccs immediately. Add a toNonGeneric() helper that gives the bayer-order specific fourcc value given a PixelFormat and a ColorFilterArray. Signed-off-by: Jai Luthra --- include/libcamera/internal/v4l2_pixelformat.h | 3 + src/libcamera/v4l2_pixelformat.cpp | 127 ++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h index 543eb21b3c07..2e0991a59a6d 100644 --- a/include/libcamera/internal/v4l2_pixelformat.h +++ b/include/libcamera/internal/v4l2_pixelformat.h @@ -20,6 +20,8 @@ namespace libcamera { +class ColorFilterArray; + class V4L2PixelFormat { public: @@ -48,6 +50,7 @@ public: PixelFormat toPixelFormat(bool warn = true) const; static const std::vector & fromPixelFormat(const PixelFormat &pixelFormat); + bool toNonGeneric(const ColorFilterArray cfa); bool isGenericLineBasedMetadata() const; diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index d51987c5ad8a..ca479edb49c2 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -14,6 +14,7 @@ #include +#include #include #include @@ -245,6 +246,111 @@ const std::map vpf2pf{ { formats::MJPEG, "JPEG JFIF" } }, }; +struct FormatWithCfa { + V4L2PixelFormat pixfmt; + ColorFilterArray cfa; + + bool operator<(const FormatWithCfa &other) const + { + return std::tie(pixfmt, cfa.order) < + std::tie(other.pixfmt, other.cfa.order); + } +}; + +const std::map generic2specific { + /* 8-bit */ + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_8), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_8), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_8), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_8), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) }, + /* 10-bit */ + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_10), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_10), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_10), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_10), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_10), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_10), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_10), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_10), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) }, + /* 12-bit */ + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_12), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_12), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_12), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_12), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_12), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_12), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_12), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_12), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) }, + /* 14-bit */ + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_14), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_14), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_14), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_14), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_14), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_14), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_14), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_14), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P) }, + /* 16-bit */ + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_16), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_16), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_16), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_16), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) }, + /* Monochrome */ + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_8), ColorFilterArray::MONO }, + V4L2PixelFormat(V4L2_PIX_FMT_GREY) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_10), ColorFilterArray::MONO }, + V4L2PixelFormat(V4L2_PIX_FMT_Y10) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_10), ColorFilterArray::MONO }, + V4L2PixelFormat(V4L2_PIX_FMT_Y10P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_12), ColorFilterArray::MONO }, + V4L2PixelFormat(V4L2_PIX_FMT_Y12) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_12), ColorFilterArray::MONO }, + V4L2PixelFormat(V4L2_PIX_FMT_Y12P) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_RAW_16), ColorFilterArray::MONO }, + V4L2PixelFormat(V4L2_PIX_FMT_Y16) }, + /* IPU3 */ + { { V4L2PixelFormat(V4L2_PIX_FMT_IPU3_RAW10), ColorFilterArray::BGGR }, + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_IPU3_RAW10), ColorFilterArray::GBRG }, + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_IPU3_RAW10), ColorFilterArray::GRBG }, + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) }, + { { V4L2PixelFormat(V4L2_PIX_FMT_IPU3_RAW10), ColorFilterArray::RGGB }, + V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) }, +}; + } /* namespace */ /** @@ -390,6 +496,27 @@ V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat) return info.v4l2Formats; } +/** + * \brief Convert a generic V4L2PixelFormat to a specific one given a color + * filter array pattern. + * \param[in] cfa Color filter array pattern + * + * If no specific variant is known for the combination, the format is left + * unmodified and false is returned. + * + * \return True if the format is converted, false otherwise + */ +bool V4L2PixelFormat::toNonGeneric(const ColorFilterArray cfa) +{ + const auto it = generic2specific.find({*this, cfa}); + if (it != generic2specific.end()) { + *this = it->second; + return true; + } + + return false; +} + /** * \brief Test if a V4L2PixelFormat is one of the line based generic metadata * formats From patchwork Fri Oct 23 10:58:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28587 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 3B945C324C for ; Fri, 23 Oct 2026 11:00:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E7DAD68FCE; Fri, 23 Oct 2026 13:00:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VMMkAzJV"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 53C7D68FBF for ; Fri, 23 Oct 2026 13:00:16 +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 08F05104A; Fri, 23 Oct 2026 12:58:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753087; bh=liksVoGYePIdyMNgcNXYOuIOINiNUZn8O7qLaSyiLak=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VMMkAzJVwtVJWc5UvKPG6ObRG3Fw1IR01VrotCWVEeRSZa2tkkH24I7K4odFBpuYy 7X7EG3hNwifDgakcUGQzc4jEYXfnC9eJZUUtJZzzfrXbT6NjmLHTnJkkpkDZdCdi/N /HVAXHIWwwYUus3gR/te7TbCvsBpKKtLHYdQeQwA= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:25 +0530 Subject: [PATCH WIP RFC 17/26] libcamera: bayer_format: Strip out ColorFilterArray from BayerFormat MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-17-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=20083; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=liksVoGYePIdyMNgcNXYOuIOINiNUZn8O7qLaSyiLak=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3THEa9XLZ/UlVwbaNq8tkdnm7FBp57Wic0U j/5CY6/RkWJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats90wAKCRBD3pH5JJpx Re3HEADTtqYVBgIBl7qciqXLwnbmWSUeY1ZZynioL+GQfTMlS85PFetM9Z+akjYV7+dLSnArvQH L49PjPVrCoYAvM0NTyjbeQtH0pk87bqZu5qKu9wzs0R2Oi0kIUjjp+eAxB2Jj/q7/wD0mUDmYRF IdIGELC3bEx2ihzxMh08S3qlk054v5fQ9MzylAwHFXyBUUiVRk7oefO6CcXWAta4Hw/Qmf0V1ao mSFLTLDN6BgObT8MoCk7yDZsrIb04ul6OqkNeve5IIP+G0vqUZ57Fjz2r++4yNCVci+zGZmPhHp dxj9kn9ki/E16+a9aINfLwgNot0AjHqWrL4E+FoMZbCu0DwbdXMUaLL/IiLM7vs9gWJohWHmB8m f1mnlFAWglZkaugmOYh/H3JO6fIwlQPYlveTRvLcQ/lVgM3eB+AnRWG9m+LDRq+thnBdzBYyLtW GrabBUAtcPN7cWRsYsSvuytAHvdcosUuVs6I9BD+izho0nTon5XvGqoe1W4b16auE5w8hq54MBX WPeCw27nOAPNuD6JMIxrQiSkNZKQvkIjX9uYsxNoQSjtkh1r6jZml9O0J1jr2RLNINjFsbPEKT8 a0+ZEH9DKkuksyUr0SVCbClpVvVBI9fjXg+goKgkRlEsIvaw57Wnz5VKHxz/fDa4fT77x+8CwQ0 Wc7Pq9T1BOfo1mQ== 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" Now that we have generic PixelFormats in place, complete the splitting of the ColorFilterArray from the BayerFormat class that we started a few commits before. This is a breaking change for most pipelines. Signed-off-by: Jai Luthra --- include/libcamera/internal/bayer_format.h | 10 +- src/libcamera/bayer_format.cpp | 233 ++++++++++-------------------- 2 files changed, 80 insertions(+), 163 deletions(-) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 701e063edcc5..2981f5b3f50d 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -11,15 +11,12 @@ #include #include -#include #include #include "libcamera/internal/v4l2_pixelformat.h" namespace libcamera { -enum class Transform; - class BayerFormat { public: @@ -32,12 +29,12 @@ public: }; constexpr BayerFormat() - : cfa(ColorFilterArray()), bitDepth(0), packing(Packing::None) + : bitDepth(0), packing(Packing::None) { } - constexpr BayerFormat(ColorFilterArray c, uint8_t b, Packing p) - : cfa(c), bitDepth(b), packing(p) + constexpr BayerFormat(uint8_t b, Packing p) + : bitDepth(b), packing(p) { } @@ -51,7 +48,6 @@ public: PixelFormat toPixelFormat() const; static BayerFormat fromPixelFormat(PixelFormat format); - ColorFilterArray cfa; uint8_t bitDepth; Packing packing; diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index c0d5af33dd17..9a4581a6f021 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -14,9 +14,7 @@ #include -#include #include -#include /** * \file bayer_format.h @@ -30,8 +28,10 @@ namespace libcamera { * \brief Class to represent a raw image Bayer format * * This class encodes the different Bayer formats in such a way that they can - * be easily manipulated. For example the bit depth, packing and color order of - * the format transmitted over the bus can be modified and transformed. + * be easily manipulated. For example the bit depth and packing of the format + * transmitted over the bus can be modified. The order of the colour channels + * itself is not encoded in a BayerFormat: it is described separately by the + * ColorFilterArray associated with the stream. */ /** @@ -61,11 +61,6 @@ struct BayerFormatComparator { else if (lhs.bitDepth > rhs.bitDepth) return false; - if (lhs.cfa.order < rhs.cfa.order) - return true; - else if (lhs.cfa.order > rhs.cfa.order) - return false; - if (lhs.packing < rhs.packing) return true; else @@ -79,143 +74,76 @@ struct Formats { }; const std::map bayerToFormat{ - { { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None }, - { formats::SBGGR8, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) } }, - { { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None }, - { formats::SGBRG8, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) } }, - { { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None }, - { formats::SGRBG8, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) } }, - { { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None }, - { formats::SRGGB8, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) } }, - { { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None }, - { formats::SBGGR10, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) } }, - { { ColorFilterArray::GBRG, 10, BayerFormat::Packing::None }, - { formats::SGBRG10, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) } }, - { { ColorFilterArray::GRBG, 10, BayerFormat::Packing::None }, - { formats::SGRBG10, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) } }, - { { ColorFilterArray::RGGB, 10, BayerFormat::Packing::None }, - { formats::SRGGB10, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) } }, - { { ColorFilterArray::BGGR, 10, BayerFormat::Packing::CSI2 }, - { formats::SBGGR10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) } }, - { { ColorFilterArray::GBRG, 10, BayerFormat::Packing::CSI2 }, - { formats::SGBRG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) } }, - { { ColorFilterArray::GRBG, 10, BayerFormat::Packing::CSI2 }, - { formats::SGRBG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) } }, - { { ColorFilterArray::RGGB, 10, BayerFormat::Packing::CSI2 }, - { formats::SRGGB10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) } }, - { { ColorFilterArray::BGGR, 10, BayerFormat::Packing::IPU3 }, - { formats::SBGGR10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) } }, - { { ColorFilterArray::GBRG, 10, BayerFormat::Packing::IPU3 }, - { formats::SGBRG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) } }, - { { ColorFilterArray::GRBG, 10, BayerFormat::Packing::IPU3 }, - { formats::SGRBG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) } }, - { { ColorFilterArray::RGGB, 10, BayerFormat::Packing::IPU3 }, - { formats::SRGGB10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) } }, - { { ColorFilterArray::BGGR, 12, BayerFormat::Packing::None }, - { formats::SBGGR12, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) } }, - { { ColorFilterArray::GBRG, 12, BayerFormat::Packing::None }, - { formats::SGBRG12, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) } }, - { { ColorFilterArray::GRBG, 12, BayerFormat::Packing::None }, - { formats::SGRBG12, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) } }, - { { ColorFilterArray::RGGB, 12, BayerFormat::Packing::None }, - { formats::SRGGB12, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) } }, - { { ColorFilterArray::BGGR, 12, BayerFormat::Packing::CSI2 }, - { formats::SBGGR12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) } }, - { { ColorFilterArray::GBRG, 12, BayerFormat::Packing::CSI2 }, - { formats::SGBRG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) } }, - { { ColorFilterArray::GRBG, 12, BayerFormat::Packing::CSI2 }, - { formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } }, - { { ColorFilterArray::RGGB, 12, BayerFormat::Packing::CSI2 }, - { formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } }, - { { ColorFilterArray::BGGR, 14, BayerFormat::Packing::None }, - { formats::SBGGR14, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14) } }, - { { ColorFilterArray::GBRG, 14, BayerFormat::Packing::None }, - { formats::SGBRG14, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14) } }, - { { ColorFilterArray::GRBG, 14, BayerFormat::Packing::None }, - { formats::SGRBG14, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14) } }, - { { ColorFilterArray::RGGB, 14, BayerFormat::Packing::None }, - { formats::SRGGB14, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14) } }, - { { ColorFilterArray::BGGR, 14, BayerFormat::Packing::CSI2 }, - { formats::SBGGR14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR14P) } }, - { { ColorFilterArray::GBRG, 14, BayerFormat::Packing::CSI2 }, - { formats::SGBRG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG14P) } }, - { { ColorFilterArray::GRBG, 14, BayerFormat::Packing::CSI2 }, - { formats::SGRBG14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG14P) } }, - { { ColorFilterArray::RGGB, 14, BayerFormat::Packing::CSI2 }, - { formats::SRGGB14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB14P) } }, - { { ColorFilterArray::BGGR, 16, BayerFormat::Packing::None }, - { formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } }, - { { ColorFilterArray::GBRG, 16, BayerFormat::Packing::None }, - { formats::SGBRG16, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) } }, - { { ColorFilterArray::GRBG, 16, BayerFormat::Packing::None }, - { formats::SGRBG16, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) } }, - { { ColorFilterArray::RGGB, 16, BayerFormat::Packing::None }, - { formats::SRGGB16, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) } }, - { { ColorFilterArray::BGGR, 16, BayerFormat::Packing::PISP1 }, - { formats::BGGR_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_BGGR) } }, - { { ColorFilterArray::GBRG, 16, BayerFormat::Packing::PISP1 }, - { formats::GBRG_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GBRG) } }, - { { ColorFilterArray::GRBG, 16, BayerFormat::Packing::PISP1 }, - { formats::GRBG_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_GRBG) } }, - { { ColorFilterArray::RGGB, 16, BayerFormat::Packing::PISP1 }, - { formats::RGGB_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RGGB) } }, - { { ColorFilterArray::MONO, 8, BayerFormat::Packing::None }, - { formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } }, - { { ColorFilterArray::MONO, 10, BayerFormat::Packing::None }, - { formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } }, - { { ColorFilterArray::MONO, 10, BayerFormat::Packing::CSI2 }, - { formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } }, - { { ColorFilterArray::MONO, 12, BayerFormat::Packing::None }, - { formats::R12, V4L2PixelFormat(V4L2_PIX_FMT_Y12) } }, - { { ColorFilterArray::MONO, 12, BayerFormat::Packing::CSI2 }, - { formats::R12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y12P) } }, - { { ColorFilterArray::MONO, 16, BayerFormat::Packing::None }, - { formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } }, - { { ColorFilterArray::MONO, 16, BayerFormat::Packing::PISP1 }, - { formats::MONO_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_MONO) } }, + { { 8, BayerFormat::Packing::None }, + { formats::RAW8, V4L2PixelFormat(V4L2_PIX_FMT_RAW_8) } }, + { { 10, BayerFormat::Packing::None }, + { formats::RAW10, V4L2PixelFormat(V4L2_PIX_FMT_RAW_10) } }, + { { 10, BayerFormat::Packing::CSI2 }, + { formats::RAW10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_10) } }, + { { 10, BayerFormat::Packing::IPU3 }, + { formats::RAW10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_RAW10) } }, + { { 12, BayerFormat::Packing::None }, + { formats::RAW12, V4L2PixelFormat(V4L2_PIX_FMT_RAW_12) } }, + { { 12, BayerFormat::Packing::CSI2 }, + { formats::RAW12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_12) } }, + { { 14, BayerFormat::Packing::None }, + { formats::RAW14, V4L2PixelFormat(V4L2_PIX_FMT_RAW_14) } }, + { { 14, BayerFormat::Packing::CSI2 }, + { formats::RAW14_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CSI2_14) } }, + { { 16, BayerFormat::Packing::None }, + { formats::RAW16, V4L2PixelFormat(V4L2_PIX_FMT_RAW_16) } }, + { { 16, BayerFormat::Packing::PISP1 }, + { formats::RAW_PISP_COMP1, V4L2PixelFormat(V4L2_PIX_FMT_PISP_COMP1_RAW) } }, }; const std::unordered_map mbusCodeToBayer{ - { MEDIA_BUS_FMT_SBGGR8_1X8, { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG8_1X8, { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG8_1X8, { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB8_1X8, { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR10_1X10, { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG10_1X10, { ColorFilterArray::GBRG, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG10_1X10, { ColorFilterArray::GRBG, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB10_1X10, { ColorFilterArray::RGGB, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR12_1X12, { ColorFilterArray::BGGR, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG12_1X12, { ColorFilterArray::GBRG, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG12_1X12, { ColorFilterArray::GRBG, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB12_1X12, { ColorFilterArray::RGGB, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR14_1X14, { ColorFilterArray::BGGR, 14, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG14_1X14, { ColorFilterArray::GBRG, 14, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG14_1X14, { ColorFilterArray::GRBG, 14, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB14_1X14, { ColorFilterArray::RGGB, 14, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR16_1X16, { ColorFilterArray::BGGR, 16, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG16_1X16, { ColorFilterArray::GBRG, 16, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG16_1X16, { ColorFilterArray::GRBG, 16, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB16_1X16, { ColorFilterArray::RGGB, 16, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SBGGR20_1X20, { ColorFilterArray::BGGR, 20, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGBRG20_1X20, { ColorFilterArray::GBRG, 20, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SGRBG20_1X20, { ColorFilterArray::GRBG, 20, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_SRGGB20_1X20, { ColorFilterArray::RGGB, 20, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_Y8_1X8, { ColorFilterArray::MONO, 8, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_Y10_1X10, { ColorFilterArray::MONO, 10, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_Y12_1X12, { ColorFilterArray::MONO, 12, BayerFormat::Packing::None } }, - { MEDIA_BUS_FMT_Y16_1X16, { ColorFilterArray::MONO, 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_RAW_8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, { 8, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR10_1X10, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG10_1X10, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG10_1X10, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB10_1X10, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y10_1X10, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_RAW_10, { 10, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR12_1X12, { 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG12_1X12, { 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG12_1X12, { 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB12_1X12, { 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_RAW_12, { 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y12_1X12, { 12, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR14_1X14, { 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG14_1X14, { 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG14_1X14, { 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB14_1X14, { 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_RAW_14, { 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y14_1X14, { 14, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR16_1X16, { 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG16_1X16, { 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG16_1X16, { 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB16_1X16, { 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_RAW_16, { 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_Y16_1X16, { 16, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SBGGR20_1X20, { 20, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGBRG20_1X20, { 20, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SGRBG20_1X20, { 20, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_SRGGB20_1X20, { 20, BayerFormat::Packing::None } }, + { MEDIA_BUS_FMT_RAW_20, { 20, BayerFormat::Packing::None } }, }; } /* namespace */ @@ -226,9 +154,8 @@ const std::unordered_map mbusCodeToBayer{ */ /** - * \fn BayerFormat::BayerFormat(ColorFilterArray c, uint8_t b, Packing p) + * \fn BayerFormat::BayerFormat(uint8_t b, Packing p) * \brief Construct a BayerFormat from explicit values - * \param[in] c The color filter array pattern * \param[in] b The bit depth of the Bayer samples * \param[in] p The type of packing applied to the pixel values */ @@ -270,12 +197,11 @@ std::string BayerFormat::toString() const /** * \brief Compare two BayerFormats for equality - * \return True if order, bitDepth and packing are equal, or false otherwise + * \return True if bitDepth and packing are equal, or false otherwise */ bool operator==(const BayerFormat &lhs, const BayerFormat &rhs) { - return lhs.cfa.order == rhs.cfa.order && lhs.bitDepth == rhs.bitDepth && - lhs.packing == rhs.packing; + return lhs.bitDepth == rhs.bitDepth && lhs.packing == rhs.packing; } /** @@ -286,13 +212,13 @@ bool operator==(const BayerFormat &lhs, const BayerFormat &rhs) */ std::ostream &operator<<(std::ostream &out, const BayerFormat &f) { - if (!f.isValid() || f.cfa.order > ColorFilterArray::MONO) { + if (!f.isValid()) { out << "INVALID"; return out; } /* The cast is required to avoid bitDepth being interpreted as a char. */ - out << f.cfa << "-" << static_cast(f.bitDepth); + out << "RAW-" << static_cast(f.bitDepth); if (f.packing == BayerFormat::Packing::CSI2) out << "-CSI2P"; @@ -309,7 +235,7 @@ std::ostream &operator<<(std::ostream &out, const BayerFormat &f) /** * \fn bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs) * \brief Compare two BayerFormats for inequality - * \return True if either order, bitdepth or packing are not equal, or false + * \return True if either bitdepth or packing are not equal, or false * otherwise */ @@ -372,11 +298,6 @@ BayerFormat BayerFormat::fromPixelFormat(PixelFormat format) return BayerFormat(); } -/** - * \var BayerFormat::cfa - * \brief The color filter array pattern - */ - /** * \var BayerFormat::bitDepth * \brief The bit depth of the samples in the Bayer pattern From patchwork Fri Oct 23 10:58:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28588 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 C3A95C324C for ; Fri, 23 Oct 2026 11:00:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 79D5468FBF; Fri, 23 Oct 2026 13:00:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GqerBKnp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7140A68FBF for ; Fri, 23 Oct 2026 13:00:23 +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 EFEE32335; Fri, 23 Oct 2026 12:58:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753094; bh=oE7wKxkZ037gLOJfiY7EQ1gFdMRR4M5vkeK5HjOf9bc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GqerBKnpohFbmk9GnJfGOjpFXPSZvnOT1MQ2AMoyxBAsU3w9N3LPweFlSNpF6mQac T361y1bIr0q/3+N3RUweQngROwsmy3uTMKhy3c+Bi+SumzGMX2oj0YqegWWEZUZHwH 8h6+cI23GyK/6NZce09aj3Q44fKb0d9Y4Muq39rY= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:26 +0530 Subject: [PATCH WIP RFC 18/26] libcamera: stream: Add bayerOrder for raw formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-18-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=1649; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=oE7wKxkZ037gLOJfiY7EQ1gFdMRR4M5vkeK5HjOf9bc=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3UeqYj5GOSTRHkkjHHij5sMAjEgWRXcwzR6 WCXHZx2HsWJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats91AAKCRBD3pH5JJpx RfX/EACRs/QOESpjwRJxHY9vxpZmnhzodnnZMX629ERLmW15g29hzYr7Kk/r/7kk2D9dR2yCLV9 FCYuqwebD2HWyMB1F6k5ixEYtiW5aw2RbTK0Vss2VabwtSxbi+4dEyi/wPcm3Bh/zepIoSoUMLf 5gpMzzupYSEHEuPagmpblvsofmYb4IQx+Ug0a7+5RxyqAFgzcpoNztaPKZjkwTTcjy+62nbYHx5 S3FtjiJXFUn+QOAJIVdXcE2Gr8yliotE+hkRIyBnYwUwfLdxJFNRDbb5/ey5sA3Q/RZJw3V/iCz 2ekVCYaBCdsnwI25HlA/QEnUhHfYmTVgSOneyk0EO7XLs3QKxoJlUK96EovmNQFCeCEP6upUVDC TZ/L+wZSIqs8uEjcK7TX7RxAvQzOGQYLvGhuxNw5lw1wQxXWZZ5I8tsWJQXJpN/L8uJOL1bFx7M n10LpmuqHi2O8CBQNzkoDLdHbnxzxSVMg8+Si7SZuPvnPiGknsUI+JUeh9o3StKumb5g8NdHUJo uSxHrq1K8KpTeRlb7YUXMQH7Es+SD1HfGDRir9P4fLplXPWrd1ExJ418rbto0EnGk/K3RrjVhgh 9mq7sbkTEZ3D2/TU/zlFFfsuxt0egyjxoIKw40yhNi2rEjMvLpHkFak71bbiy4FhFZjMGP8sQl4 gXKWC4e4KL8ifkQ== 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" Now that we only use bayer-independent PixelFormats, communicate the bayer order through an optional property in StreamConfiguration for raw streams so applications can process them correctly. Signed-off-by: Jai Luthra --- include/libcamera/stream.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index b5e8f0a9a22d..afc8f07f99f1 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -50,6 +51,22 @@ struct StreamConfiguration { std::optional colorSpace; + /** + * \brief The color filter array pattern of the raw data of the stream + * + * This field is only meaningful for streams with a raw pixel format. + * Pipeline handlers populate it in + * CameraConfiguration::generateConfiguration() with the sensor's + * native color filter array pattern, and adjust it in + * CameraConfiguration::validate() for any transform applied to the + * sensor data. + * + * A ColorFilterArray::MONO value indicates monochrome raw data + * without a color filter array. The field is left unset for non-raw + * streams. + */ + std::optional bayerOrder; + Stream *stream() const { return stream_; } void setStream(Stream *stream) { stream_ = stream; } const StreamFormats &formats() const { return formats_; } From patchwork Fri Oct 23 10:58:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28589 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 4C6F6C324C for ; Fri, 23 Oct 2026 11:00:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1829868FE0; Fri, 23 Oct 2026 13:00:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="A4U2Wk/s"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B08EC68FD7 for ; Fri, 23 Oct 2026 13:00:28 +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 7EC4F1212; Fri, 23 Oct 2026 12:58:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753099; bh=VSuxURlzYQNd4HhNqD5AfTC9F9T7Rq7BQs+zlJKCM7M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=A4U2Wk/sTI8Ad/K9u7am6XVzBRAsNUdL1l/6TMCF9BqfHQ2UESz+huAosDowGJea5 q/Ek4sl05e0/jF5ygF5oGcx5vvTAXkLumE0YI2EnyeWUSZYWuhRoMYE6vrzESmPkDI 2iGp1L8ZpQKv+Bxl0RwoQqL8yVyE8kqeM6qxH0m8= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:27 +0530 Subject: [PATCH WIP RFC 19/26] libcamera: camera_sensor: Add helpers for isRaw() and isMono() MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-19-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=3303; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=VSuxURlzYQNd4HhNqD5AfTC9F9T7Rq7BQs+zlJKCM7M=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3VgpE14qGmA/SnL8dAL+krnQDZu5rIOWj+j f1aVA/XgK2JAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats91QAKCRBD3pH5JJpx RQvJD/47u8tDu4ptvQ/s5qdpjOgnUB+k671DPGfwOVwd5a3JExm7VzGhWsz5hzM7pfaehZm/vsZ T491sRnHD9uqxED0JyBGG46SCn6/uA2KesHYodqDkxVpYjmHf5xwrICMChOwj3mZkKp5+BHDy7l N+KJWD7HCL9TbjRZi1AGyEPdc3zReNqYumqQZoXR7NKD2YlKvpyCsb3tZnn8WECQEeE0cf2skCI Xq+4b9/5fEnV8AdyzNNc7uyKC827iTxhWT0rzzON5hxp3vmxGcN0w3KmZkqx7WT1yxouJy1ZJfl 3kIoDDWO/WOdK1cDW7zFS5PGHHyCp9A/gU52yFvh9YSGLWzE6GkgfDmC+yKs7AlzuU0ZgRp/p3O wXdM9EbCChSYUPsJIMrGSAgszqnBaziQpgNsL7jsmff2aah/Idw7cw+o1ZVh1nGBRTcXoLrHqF4 +ThYj9VjLe2CbHHALsdBLt4n0ivEdo9Hcc0KdtYshW98DfmING17lZP3v3e8PbzIV9nEoGzgbuW O36ycTm0DRa60uNHm+6ZdnhhQsYeqp4edLYyJGF7qVwoBY3uFLcFYCgKo+Qa0hoPJbfG43aEwnU XXR0rLZZ3CyQR9kV+Yv6E0XFIhP3YjHoIFC1dld4relqy5pomOIt3eP61PG9SeILgWcdufveFK+ 1elYE3/WFMA8WKA== 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" Pipeline handlers often want to check if a sensor is monochrome, or gives a processed RGB/YUV image instead of a RAW one, as it may require special handling or skipping the ISP block altogether. Add helpers for it in CameraSensor to make their life easier. Signed-off-by: Jai Luthra --- include/libcamera/internal/camera_sensor.h | 2 ++ src/libcamera/sensor/camera_sensor_legacy.cpp | 8 +++++--- src/libcamera/sensor/camera_sensor_raw.cpp | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index a0f27ac11735..948e0523ab64 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -74,6 +74,8 @@ public: virtual Transform computeTransform(Orientation *orientation) const = 0; virtual ColorFilterArray bayerOrder(Transform t) const = 0; virtual Orientation mountingOrientation() const = 0; + virtual bool isMono() const = 0; + virtual bool isRaw() const = 0; virtual const ControlInfoMap &controls() const = 0; virtual ControlList getControls(std::span ids) = 0; diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index 8f47b77dc7c4..d1bfcd020c64 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -91,6 +91,8 @@ public: Transform computeTransform(Orientation *orientation) const override; ColorFilterArray bayerOrder(Transform t) const override; Orientation mountingOrientation() const override { return mountingOrientation_; } + bool isMono() const override { return cfa_ && cfa_ == ColorFilterArray::MONO; } + bool isRaw() const override { return cfa_.has_value(); } const ControlInfoMap &controls() const override; ControlList getControls(std::span ids) override; @@ -882,7 +884,7 @@ V4L2Subdevice::Stream CameraSensorLegacy::imageStream() const int CameraSensorLegacy::sensorInfo(IPACameraSensorInfo *info) const { - if (!cfa_) + if (!isRaw()) return -EINVAL; info->model = model(); @@ -986,8 +988,8 @@ Transform CameraSensorLegacy::computeTransform(Orientation *orientation) const ColorFilterArray CameraSensorLegacy::bayerOrder(Transform t) const { /* Return a defined by meaningless value for non-Bayer sensors. */ - if (!cfa_) - return ColorFilterArray::BGGR; + if (!isRaw()) + return ColorFilterArray::MONO; if (!flipsAlterBayerOrder_) return *cfa_; diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index c703db31d658..e45f2225b779 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -104,6 +104,8 @@ public: testPatternModes() const override { return testPatternModes_; } int setTestPatternMode(controls::draft::TestPatternModeEnum mode) override; const CameraSensorProperties::SensorDelays &sensorDelays() override; + bool isMono() const override { return cfa_ == ColorFilterArray::MONO; } + bool isRaw() const override { return true; } protected: std::string logPrefix() const override; From patchwork Fri Oct 23 10:58:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28590 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 D9D95C324C for ; Fri, 23 Oct 2026 11:00:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8BE9168FEA; Fri, 23 Oct 2026 13:00:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mDIVTkX/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A0B6068FD7 for ; Fri, 23 Oct 2026 13:00:33 +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 6464D1E4; Fri, 23 Oct 2026 12:58:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753104; bh=lSGdpBhMtCC4W4mXO09O2Y4Fm/FYUv82i6AUrMs5dJ8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mDIVTkX/gUNTT+jyXTbqdrK+SBkMYHa8PnZVgvHtY+Bk7J3m4owOaLIuNONGFHNxg 4knQVgBotKj6qU6ZQGLyar7vEcfp92o0Glkmw7k4JvskiOAAQHvZkcvSrOxUPhEcYq wac+GcnznlGAYYBuZRPJh55ywmAT9LZ4L1hgjjVs= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:28 +0530 Subject: [PATCH WIP RFC 20/26] pipeline: rpi: Use CameraSensor::isMono() helper MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-20-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=1500; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=lSGdpBhMtCC4W4mXO09O2Y4Fm/FYUv82i6AUrMs5dJ8=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3W6gcOItdt10tmJoHQeKz1yDNugDOdfzXd3 48Mb1whS1+JAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats91gAKCRBD3pH5JJpx RdnxEACNi50GtSCtirLBfZEMeB8rBdk6j0D9qitEeNlu0BQrVhmKdbZdO1vDALVrMpmZ4pDrTDc 384oVaqzuq3qr2PHmrdrffv0GTSAQYBGtTFpJnr/qU27r6CicP37+6ZGVFkvMLjG9V/70iDLHNc r8sWb182yUfeJB4xRJzslCEIQh9Zpjl6lDfaos4rUFAhRUWbyFRvtTSR2gqk0Pc2X4vnrlbDfkM 9pLFGYskTLXfCIc1HkocioZzbzXHlK1WNcvBNVNFozUSn2cWW/cR5Ng0aoUd4EhvJ/R8rfAe7KA SC6FhDJRc7ranzpTl042ClGAytI+cM3Oc2XAWsJOP00WhwxH7dyNt1wiCRm84zNvQ25iy+k0RIv 5H2N0q+g7L1qnerZjK8HkgGvbxSX200ivvoh7PXx+0Bf7HUVQTZJkxuz6za/EcExWWUjIO5EOeW lAgeNA0PJbZYd4Z0/Eouca8YK8I/lld6JTekRJtvIBnUm5FusDuYv4evKUoX5AFhD9p42TiIbQI oBO8wlqOkHtVBsIEnD/MBuDslKeug/r6b7Ui/p2xNTbo4DJK0ioLQ30I5pxpvYRPqQgmtX06OzP H1wZnDZpcTfxBgpeEEspKlIYlMn7gnTZkXPgGzrs8j5AEY5SZwWF9CbfWferOdk+KtAUAURS0bb cmF0u9a+CYSa0Zw== 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" With the raw sensor model in place, the media bus codes may no longer indicate the bayer order or if the pixel data is monochrome. Rely on the newly introduced CameraSensor::isMono() helper instead. Signed-off-by: Jai Luthra --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 7ea48f62cc3d..435f460bbf8c 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -71,14 +71,6 @@ mbusCodeToPixelFormat(unsigned int code, BayerFormat::Packing packingReq) return pix; } -bool isMonoSensor(std::unique_ptr &sensor) -{ - unsigned int mbusCode = sensor->mbusCodes()[0]; - const BayerFormat &bayer = BayerFormat::fromMbusCode(mbusCode); - - return bayer.cfa.order == ColorFilterArray::Order::MONO; -} - const std::vector validColorSpaces = { ColorSpace::Sycc, ColorSpace::Smpte170m, @@ -1190,7 +1182,7 @@ int CameraData::loadIPA(ipa::RPi::InitResult *result) /* The configuration (tuning file) is made from the sensor name. */ std::string model = sensor_->model(); - if (isMonoSensor(sensor_)) + if (sensor_->isMono()) model += "_mono"; std::string configurationFile = ipa_->configurationFile(model + ".json"); From patchwork Fri Oct 23 10:58:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28591 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 54BBAC324C for ; Fri, 23 Oct 2026 11:00:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2237C68FE8; Fri, 23 Oct 2026 13:00:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Qajv8YTX"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EF34568FE5 for ; Fri, 23 Oct 2026 13:00:37 +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 CDA3D12D6; Fri, 23 Oct 2026 12:58:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753109; bh=fBQRv/f3Z6yDrO16DncjcYjMDZmFw8mwxKvou8oKYYE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Qajv8YTX7BrjIYp6PmhsEgdNDnFKjyem63b2F1PD1nwzMcrV/i5gUGj7E9KohWv5q CQ8Igwr7CwGRc1rOcsdhp0pHZ72TepQ1+ZoThSmiViWuavMtUBVa46/8kMzwQ59Zr7 753aOocUtlC11k91gcmiz74GSNR9XChOTIAXlfic= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:29 +0530 Subject: [PATCH WIP RFC 21/26] pipeline: rpi: Split bayerOrder from PixelFormat MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-21-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=1997; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=fBQRv/f3Z6yDrO16DncjcYjMDZmFw8mwxKvou8oKYYE=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3XSREAo+ETi2vMEZQHeVH0hOQ16NsKWNeW7 WkwYgbWVzCJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats91wAKCRBD3pH5JJpx RRz5D/4ulqOKnAyACyc23DwNbD7TbNax7zhtz6B0/DYd2l+lPe6P2NHU2fOVUcMLI0jSBDAhCXJ eXT7U0fbt+1cY/8cjwpiH8PkB703Dii2ZmQUw1Zds2mO/aFwFJ6KzhPmpc41DXvsHF9tpM6NmVO JX92atm0fQNKySpDxrVmKoM6qkTFYc1SrSW+ZW8rUaY8imBYgpX75MHMwmROKVhr4JKSwr+HCAz VxAnXYWp/x5cExsZlZf9OYdHmx0mv6cc292dXHcvVuVpyYOljdf2zeUjxPzKZB9aKFrhk78cSqE lFggWI5JXNLQar9xMaFcu7Jq/lPtJ3Nbsp9j5LoYjJpw3bMw2t0F8S1FiWDoUGbybwhQqr2mihB ajBGMbRLYltViztCcT0vMwLQ1fY+dh1tMSmP1kI6rHN+X0/MSqywwKK8Sy3XOf9FxKC000QhbSW ENwkq7kaQGAzMcQBCEUgop2hDSKb6/errCSTxM67059H1rGVYanvIZXBCLPb3XDSgUTxAs4gWO0 CXwnnprtQH9kILL/QQyXVeSfWWo6Tq1W1a0/u0JLDlnsKuLKAVUpkM8Vs9ebcla+pfSHOjmxzas 61t9RchX0u9Neb6AYzLbzAAtemOQmlhodLhdiJNFYlivCFf0ZK2wqZZb0+Lkre+YzBAi2KpQL4Q l+JMbioUowJITbw== 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" With only generic (bayer-order independent) formats supported throughout libcamera now, ensure that we populate StreamConfiguration::bayerOrder when generating new configurations, and update them during validate() depending upon the combined flips and transforms. Signed-off-by: Jai Luthra --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 435f460bbf8c..8453c8668542 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -248,11 +248,10 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * to the user request. */ - BayerFormat cfgBayer = BayerFormat::fromPixelFormat(rawStream->pixelFormat); - cfgBayer.cfa = data_->sensor_->bayerOrder(combinedTransform_); + ColorFilterArray cfa = data_->sensor_->bayerOrder(combinedTransform_); - if (rawStream->pixelFormat != cfgBayer.toPixelFormat()) { - rawStream->pixelFormat = cfgBayer.toPixelFormat(); + if (!rawStream->bayerOrder || rawStream->bayerOrder.value() != cfa) { + rawStream->bayerOrder = cfa; status = Adjusted; } } @@ -500,6 +499,16 @@ PipelineHandlerBase::generateConfiguration(Camera *camera, std::spansensor_->bayerOrder(Transform::Identity); + config->addConfiguration(cfg); } From patchwork Fri Oct 23 10:58:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28592 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 E6FCEC324C for ; Fri, 23 Oct 2026 11:00:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A17D668FF1; Fri, 23 Oct 2026 13:00:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tKJZLHLh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 743BD68FCB for ; Fri, 23 Oct 2026 13:00:42 +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 4A9A712B2; Fri, 23 Oct 2026 12:58:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753113; bh=ZnWrVI3VqLLar8HzlxXoyx/6ZoZfVuyZbZAz6m/eYec=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tKJZLHLheuy8eisUI10vzaPN1R5muDojcjmZMWWM0A3CKGqrY4qfRixAm14bKQ6wj u7Xih53Mo0gl2kEbPTbCq+MSbObLc6CALGj0U2sDW0SfkXRcEnDfUOA5a9YnOpgjKM FRZM5p9IyXTiTrMoWpAUjOjJka2kyJeY3mDOinHs= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:30 +0530 Subject: [PATCH WIP RFC 22/26] pipeline: rpi: Prefer generic raw formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-22-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=1991; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=ZnWrVI3VqLLar8HzlxXoyx/6ZoZfVuyZbZAz6m/eYec=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3YK+ZlHk2Nw68jz8H5YeI+qWm5kv+Kiczjq 8lSb3oxjgSJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats92AAKCRBD3pH5JJpx RaV+D/9vAHbZgHUUbs6oKXz2fpQu2Yz2EaAhIrZtiMIA6hKqgKh/IYSAQKCYyqYw83V4I2qamFr eYxNkjZ1YFpdK/XrfkmcyGqmi7FjsAJOAtCTCAncBlFVtP23Fyt3iMRAkybq1Cw+VTkFNvFC7SL GjPZsbeWyAApk3joym7dRvC5k1danK8apFKgZ9MLVvW338aKTVSL1hyWamXVHAloKQdA3t3FjL5 ietPEy0PbdOjyQCbf9B7ijUfzQN+hKoW3QUCL3CXxtxbbSPXtz3gnPiPBYC520hjkvzXxpWATRA KADYxRY99BUZPMhB4U/C+swFHvmVAGgbKjH/0k3K2jekh4Ms1aP8gn0ago7u2cCoZY++Kn6stav DDlWz/Cm8JE6gISrDAhOjQcUJhzSV4rKlqnscEHVy3DqdcXBjU7MqBMjqJiHj9/3XAH2yPwWs2M Ep2rCW2JTGnl1IACu+Ueo0WGTCVdYe4gASsuSeXxBs5uYPzTikp5+j1y7vAazJP9kyXNchsZ68K uP5wEjbRxSUoiHG/Ssng0akNUS9FyPmxfppvVQgkBVollgWHIRy6ourDFN3I8AFVRBFuCp7GNNO CujIo/hdjH7D7Y+rFJYL9LiK7VH7Y2GdgbIYcV2o9je+pykZ0ulViDEQncVCaD1YjuVsdjyt87d QZCqWuOP+FTM8Xw== 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" Most sensors that support the new common raw sensor model advertise both generic raw formats, and legacy bayer-specific formats. Break the tie by preferring the generic formats by a smidge, as all the Raspberry Pi drivers involved in the capture path (unicam, bcm2835-isp, cfe and pisp) can work with the newer media bus codes. Signed-off-by: Jai Luthra --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 8453c8668542..081866aa68ab 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -964,6 +964,7 @@ V4L2SubdeviceFormat CameraData::findBestFormat(const Size &req, unsigned int bit constexpr float penaltyAr = 1500.0; constexpr float penaltyBitDepth = 500.0; + constexpr float penaltyNonGeneric = 1.0; /* Calculate the closest/best mode from the user requested size. */ for (const auto &[mbusCode, sizes] : sensorFormats_) { @@ -987,14 +988,19 @@ V4L2SubdeviceFormat CameraData::findBestFormat(const Size &req, unsigned int bit /* Add any penalties... this is not an exact science! */ score += utils::abs_diff(info.bitsPerPixel, bitDepth) * penaltyBitDepth; + /* Break ties when sensor advertises both legacy and generic codes */ + if (MediaBusFormatInfo::info(mbusCode).genericRaw == false) + score += penaltyNonGeneric; + if (score <= bestScore) { bestScore = score; bestFormat.code = mbusCode; bestFormat.size = size; } - LOG(RPI, Debug) << "Format: " << size - << " fmt " << *format + LOG(RPI, Debug) << "Format: " << *format + << "_" << utils::hex(mbusCode, 4) + << "_" << size << " Score: " << score << " (best " << bestScore << ")"; } From patchwork Fri Oct 23 10:58:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28593 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 A170EC324C for ; Fri, 23 Oct 2026 11:00:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 680D268FCB; Fri, 23 Oct 2026 13:00:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="laUvmczL"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F82768FCB for ; Fri, 23 Oct 2026 13:00:47 +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 380954D89; Fri, 23 Oct 2026 12:58:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753118; bh=0y/oA1+KGIZFtpUSbpLciZ3rgOYFMLbyKWl6eRIjsUo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=laUvmczLH/WbnDuOgZ1aSqyAfYjRQs0tgMSrz/3mBlE2+pn0H9IG9ieTVkTHqQMvd VwIkqj2WcJ96CRxUUBVkbZ4TmTYPOWoMc2P5kwU0sfUl5Yc7DXw4MkIHJkhVhNP2fL i7RO8V2Y0AuFVlZVX0Lp5uvCcQUj2bJaf3deP5/A= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:31 +0530 Subject: [PATCH WIP RFC 23/26] pipeline: rpi: pisp: Migrate to RAW formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-23-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=8761; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=0y/oA1+KGIZFtpUSbpLciZ3rgOYFMLbyKWl6eRIjsUo=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3ZXpI2W6zcN9i8BNShFdi+xj9EzsSO2UA8z +RUBQ8y/jmJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats92QAKCRBD3pH5JJpx RdasEAC5/My0nBb/3jYhcs2VzT9ealBbKPPjfkfcgV+MD2H9xKps3VbmG/fq0DQNUS8dZ3GSyF9 KjoMSG04PnAfKoBQ4OVPWWkAOnZjMFRwW9I2JvL+n8UmcjXq3H7RV4lTQ63Pt5+4DZ8q1UEaoG/ PMLpzlglIgP/L+hpreadIRahqHC34tDujCK1HMkJjs8mpeyRYSyW4EcUMHNMBO9g6eT3LJgf63g 3oqR7wKIqrSCbG5QHJyPhMPNxPbsuP6JqxmwHH3MTkTL2c0NBLFaFuoALkJ36r8Ky40lr/xenfx 7peFLJqyNSGi46L/4H2Cl8T01JqGNEXCJw1t6HJl11aX2LLsnaApuRawczEavXfUWzwLD24BHoo wM6Plm3bCoFLZ5cEse9vursEkcTIdMG3dNyAyj7sBbAb60VZZvKpM6eUGVD9S6Mvu7U6QMo5C2B 6i56P4GjT6/Jg+P1gxd7huKBX+/cr7dSyhZj5toW+UIgOR3tZmU3neml/K+hvFFoGzrI78tTBHg m7TFTdwiA6dZYXuD45glD1uAC8FLEr5QA9tn6yeHZhKry5YsMMF9KadZ8ibdpQlf3wXlJILM+W3 Pm2ocTOp0K4i2xonv79l2jWLX5GzcwzZ9MwHTJnOj0Tfr6SWu1CtxZLSUGvXTLMAEyPTVhiddcN QyNeIINyOPHv6AA== 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" Both the PiSP CFE and BE drivers support the new generic RAW formats, so switch to using those. Both of those hardware blocks need to know the bayer order of the incoming raw data. They used to extract it from the media bus codes before, which is no longer possible. Instead pass it explicitly to them by fetching it from the CameraSensor::bayerOrder() helper. Also drop the now unnecessary mbusCodeUnpacked16() helper. Signed-off-by: Jai Luthra --- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 76 ++++++++++++-------------------- 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index b4a5f87aa93d..41e1b46a1136 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include "libcamera/internal/device_enumerator.h" @@ -56,32 +57,12 @@ constexpr unsigned int DefaultCompressionOffset = 2048; constexpr unsigned int DefaultCompressionMode = 1; const std::vector> BayerToMbusCodeMap{ - { { ColorFilterArray::BGGR, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR8_1X8, }, - { { ColorFilterArray::GBRG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG8_1X8, }, - { { ColorFilterArray::GRBG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG8_1X8, }, - { { ColorFilterArray::RGGB, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB8_1X8, }, - { { ColorFilterArray::BGGR, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR10_1X10, }, - { { ColorFilterArray::GBRG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG10_1X10, }, - { { ColorFilterArray::GRBG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG10_1X10, }, - { { ColorFilterArray::RGGB, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB10_1X10, }, - { { ColorFilterArray::BGGR, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR12_1X12, }, - { { ColorFilterArray::GBRG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG12_1X12, }, - { { ColorFilterArray::GRBG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG12_1X12, }, - { { ColorFilterArray::RGGB, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB12_1X12, }, - { { ColorFilterArray::BGGR, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR14_1X14, }, - { { ColorFilterArray::GBRG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG14_1X14, }, - { { ColorFilterArray::GRBG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG14_1X14, }, - { { ColorFilterArray::RGGB, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB14_1X14, }, - { { ColorFilterArray::BGGR, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR16_1X16, }, - { { ColorFilterArray::GBRG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG16_1X16, }, - { { ColorFilterArray::GRBG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG16_1X16, }, - { { ColorFilterArray::RGGB, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB16_1X16, }, - { { ColorFilterArray::BGGR, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SBGGR16_1X16, }, - { { ColorFilterArray::GBRG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGBRG16_1X16, }, - { { ColorFilterArray::GRBG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGRBG16_1X16, }, - { { ColorFilterArray::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, }, - { { ColorFilterArray::MONO, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_Y16_1X16, }, - { { ColorFilterArray::MONO, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_Y16_1X16, }, + { { 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_8, }, + { { 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_10, }, + { { 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_12, }, + { { 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_14, }, + { { 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_RAW_16, }, + { { 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_RAW_16, }, }; unsigned int bayerToMbusCode(const BayerFormat &bayer) @@ -97,19 +78,9 @@ unsigned int bayerToMbusCode(const BayerFormat &bayer) return 0; } -uint32_t mbusCodeUnpacked16(unsigned int code) +uint8_t toPiSPBayerOrder(const ColorFilterArray &cfa) { - BayerFormat bayer = BayerFormat::fromMbusCode(code); - BayerFormat bayer16(bayer.cfa.order, 16, BayerFormat::Packing::None); - - return bayerToMbusCode(bayer16); -} - -uint8_t toPiSPBayerOrder(V4L2PixelFormat format) -{ - BayerFormat bayer = BayerFormat::fromV4L2PixelFormat(format); - - switch (bayer.cfa.order) { + switch (cfa.order) { case ColorFilterArray::Order::BGGR: return PISP_BAYER_ORDER_BGGR; case ColorFilterArray::Order::GBRG: @@ -816,9 +787,10 @@ private: int configureEntities(V4L2SubdeviceFormat sensorFormat, V4L2SubdeviceFormat &embeddedFormat); - int configureCfe(); + int configureCfe(const ColorFilterArray &bayerOrder); bool calculateCscConfiguration(const V4L2DeviceFormat &v4l2Format, pisp_be_ccm_config &csc); - int configureBe(const std::optional &yuvColorSpace); + int configureBe(const std::optional &yuvColorSpace, + const ColorFilterArray &bayerOrder); void platformSetIspCrop(unsigned int index, const Rectangle &ispCrop) override; @@ -1444,6 +1416,13 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf V4L2VideoDevice *cfe = cfe_[Cfe::Output0].dev(); V4L2DeviceFormat cfeFormat; + /* + * The sensor bayer order is the order of the data arriving at the + * CFE Frontend, as affected by any transform applied to the sensor. + */ + ColorFilterArray sensorBayerOrder = + sensor_->bayerOrder(rpiConfig->combinedTransform_); + /* * See which streams are requested, and route the user * StreamConfiguration appropriately. @@ -1454,7 +1433,7 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf * mbus code right at the start. */ V4L2SubdeviceFormat sensorFormatMod = rpiConfig->sensorFormat_; - sensorFormatMod.code = mbusCodeUnpacked16(sensorFormatMod.code); + sensorFormatMod.code = MEDIA_BUS_FMT_RAW_16; cfeFormat = RPi::PipelineHandlerBase::toV4L2DeviceFormat(cfe, sensorFormatMod, BayerFormat::Packing::PISP1); @@ -1679,10 +1658,10 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf } configureEntities(rpiConfig->sensorFormat_, embeddedFormat); - configureCfe(); + configureCfe(sensorBayerOrder); if (beEnabled_) - configureBe(rpiConfig->yuvColorSpace_); + configureBe(rpiConfig->yuvColorSpace_, sensorBayerOrder); return 0; } @@ -1915,7 +1894,7 @@ void PiSPCameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers, bool handleState(); } -int PiSPCameraData::configureCfe() +int PiSPCameraData::configureCfe(const ColorFilterArray &bayerOrder) { V4L2DeviceFormat cfeFormat; cfe_[Cfe::Output0].dev()->getFormat(&cfeFormat); @@ -1927,7 +1906,7 @@ int PiSPCameraData::configureCfe() global.enables &= ~PISP_FE_ENABLE_COMPRESS0; global.enables |= PISP_FE_ENABLE_OUTPUT0; - global.bayer_order = toPiSPBayerOrder(cfeFormat.fourcc); + global.bayer_order = toPiSPBayerOrder(bayerOrder); pisp_image_format_config image = toPiSPImageFormat(cfeFormat); pisp_fe_input_config input = {}; @@ -2002,7 +1981,8 @@ bool PiSPCameraData::calculateCscConfiguration(const V4L2DeviceFormat &v4l2Forma return false; } -int PiSPCameraData::configureBe(const std::optional &yuvColorSpace) +int PiSPCameraData::configureBe(const std::optional &yuvColorSpace, + const ColorFilterArray &bayerOrder) { pisp_image_format_config inputFormat; V4L2DeviceFormat cfeFormat; @@ -2025,7 +2005,7 @@ int PiSPCameraData::configureBe(const std::optional &yuvColorSpace) PISP_BE_RGB_ENABLE_CSC1); global.bayer_enables |= PISP_BE_BAYER_ENABLE_INPUT; - global.bayer_order = toPiSPBayerOrder(cfeFormat.fourcc); + global.bayer_order = toPiSPBayerOrder(bayerOrder); if (PISP_IMAGE_FORMAT_COMPRESSED(inputFormat.format)) { pisp_decompress_config decompress; @@ -2249,7 +2229,7 @@ int PiSPCameraData::configureEntities(V4L2SubdeviceFormat sensorFormat, } V4L2SubdeviceFormat feFormat = sensorFormat; - feFormat.code = mbusCodeUnpacked16(sensorFormat.code); + feFormat.code = MEDIA_BUS_FMT_RAW_16; ret = feSubdev_->setFormat(feVideoSinkPad, &feFormat); if (ret) return ret; From patchwork Fri Oct 23 10:58:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28594 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 44784C324C for ; Fri, 23 Oct 2026 11:00:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EB0F168FF0; Fri, 23 Oct 2026 13:00:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Il3N43cN"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 00F2668FD3 for ; Fri, 23 Oct 2026 13:00:52 +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 CBBE24E46; Fri, 23 Oct 2026 12:58:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753123; bh=3pp1jCtegNZZJe9WezSIxD6zTYQj2CLaA7fGES0u5K0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Il3N43cN5lm59UET9C7YzDImOfDXYuctdHwxyChSlujHwOV1/TeBo7So1sOHxJLjE ussF+vrOk6IxwsVnDl0VK1QlN2Uyahr4XXi4T/UF2Iwuh/+uFZk8vWoRzuCZklleyi zPwefdKbIy6S3B24mCTdl1I0g4G5ziGUO9zOTl1A= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:32 +0530 Subject: [PATCH WIP RFC 24/26] pipeline: rpi: vc4: Migrate to generic RAW formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-24-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=2415; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=3pp1jCtegNZZJe9WezSIxD6zTYQj2CLaA7fGES0u5K0=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3a0nzGWCS3RN0X3UntTIsjs31GCNnXa8ayH ZqgpDsjBz6JAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats92gAKCRBD3pH5JJpx RX+8D/0YOnzJG5Rh1LmziZ6NS2ameAkHx8G+10K/CRZt9VKvgRKv1cBYMr1UsTF0L0jXQUxHbqX hK4uMI4M3Sccis0EYpDtEeOcA2/iCHNZUOvC9ad/vJiNVPPRj4k15uHrTrZX9DayjFwQHYWUq8W HDP0WF+6kB7QIa6+xEzqbrBVaJk2GgAW+yHPn/fi9rhdvJF3U4XhgKdUzHh6PcLkS2EjJk1JgQW CRgyLjapgg/j2XjFPB+xEYkMqaqhbiMSUOcnJpRwsHNP8ha5a1Mfq5MrdepaCt1LwIVLdcnLdrQ sXAmYjsWpVPPpjgTc9NAE36NIZTId56Ap8QU+AEm1L0pzND1xHbUvq0O0Rd2X2qRGIbeH1bgzLl VDFcG5l5aMAEVbNPaD8FBn+7qtLa9CqMfS5BgaPJej3zJInkane1SlQDweKCFj0KVOokgs6MztH DveNc8GYCjpWHU3Mp23EXo82k8LBR/f7TmbqyZdO6aoXEGbCz3sA6fQT0KtrORuf0SVQKbJcChB KCbnO5HNbcSdYD3Si5I0HCQERizkL3owIO6VBXX5YACIY/xubOY9W03zH6MQ86ZlkhVyGoLOOuS H3cfMXHyGDVrpyiwF9TgwL40ec0KIjb1eutVgJAUbzcbQw7u3pp4+yAP42GNSp0Q33ylQh0zd15 WbE5NQv+x2zbCqg== 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" Unicam supports both the new media bus codes and fourcc values. VC4 ISP unfortunately uses fourcc values to talk to the firmware, so we instead convert the new generic fourcc to the legacy (bayer-order specific) values before configuring it. Signed-off-by: Jai Luthra --- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 3236cc70c6a4..efd393a5c4a6 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -15,6 +15,7 @@ #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/dma_buf_allocator.h" +#include "libcamera/internal/v4l2_pixelformat.h" #include "libcamera/internal/v4l2_subdevice.h" #include "../common/pipeline_base.h" @@ -622,6 +623,14 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi V4L2VideoDevice *unicam = unicam_[Unicam::Image].dev(); V4L2DeviceFormat unicamFormat; + /* + * The sensor bayer order is the order of the data arriving at the + * Unicam image input, as affected by any transform applied to the + * sensor. + */ + ColorFilterArray sensorBayerOrder = + sensor_->bayerOrder(rpiConfig->combinedTransform_); + /* * See which streams are requested, and route the user * StreamConfiguration appropriately. @@ -641,9 +650,13 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi if (ret) return ret; + V4L2DeviceFormat ispFormat = unicamFormat; + ispFormat.fourcc.toNonGeneric(sensorBayerOrder); + LOG(RPI, Info) << "Sensor: " << sensor_->id() << " - Selected sensor format: " << rpiConfig->sensorFormat_ - << " - Selected unicam format: " << unicamFormat; + << " - Selected unicam format: " << unicamFormat + << " - Selected ISP input format: " << ispFormat; /* * Configure the Unicam embedded data output format only if the sensor @@ -684,7 +697,7 @@ int Vc4CameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConfi * 3. Configure the ISP. */ - ret = isp_[Isp::Input].dev()->setFormat(&unicamFormat); + ret = isp_[Isp::Input].dev()->setFormat(&ispFormat); if (ret) return ret; From patchwork Fri Oct 23 10:58:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28595 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 D389FC324C for ; Fri, 23 Oct 2026 11:00:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8A06968FED; Fri, 23 Oct 2026 13:00:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P2u47+y7"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3FBEC68FD3 for ; Fri, 23 Oct 2026 13:00:56 +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 1CD8A4F03; Fri, 23 Oct 2026 12:58:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753127; bh=BEO1XETINLB0lHCqGXF56NmXiRrc1/OzDmHvBhf3d+o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=P2u47+y7S7tGsQyb2KsaWDSXPNWX5sC2Rbch5ECClazHaP/4nP7YvDoIIct3Cp+aP PX7gjLbqzCUh2Uq9LJENB5PFkMUYExu3Yd3pe5ATXvxiInPZMxMlLer6LQNEEN2kGL ZXrERIy9rhuoLhgsJeX6+BcVuHrU7bIJ/lxwvZj4= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:33 +0530 Subject: [PATCH WIP RFC 25/26] pipeline: mali-c55: Use generic RAW formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-25-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=11619; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=BEO1XETINLB0lHCqGXF56NmXiRrc1/OzDmHvBhf3d+o=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3amrBoM54D30WaT7aRQ1V5tHOH9wdRiWpaC Y1C24QyFmmJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats92gAKCRBD3pH5JJpx RaFlEADDyT6cQKe0zBbG64BE2k1obgl7XPBaDUk8IzPsaxFGsRjSkG1PE8wkj4hH6Saemiq+0Jl 782Tsi751l8skP4JVnTKzSTMZeo82qd6+wu7TP6Ts727BaMkksMaQ9SGsIdjd8ZsLkVcgGE8n6s CHoLo1gxKB85IiTWxpHeNSuD2xH1PI8b1DgLJWny3CMe7dSk92bayJQtMoPfbSpjHOpfPJ3nRH5 dsroDVoKvmG8n1u4g4TFgypD2NeFTO4TZwKi3o+sEoyKIArJOxImf7vaXwHvvXJEhLNqiXMWh4f JqbuF7kmvf06mBlmcsjbOgEk278qE519YG9pOfrbwE8VpzKFXLEwaikQp15ljFqiuGkYkeqAsn1 NpT+sam8jEJuGrIYld8Va0BbWecZAgko3KaZQcVO15NtAx1o7Ae4GX7Pdcd3kAdKCE/tlv/oFnS QwTXiHnmWk9LYgvc8D1K9E7dH5XlA669fZkEsD5iNyupd1LrRkIvMN1DLqg9aXROb/YKaKXinxl skoiHcR+Vr+k8U9wLwaTCkojkEP8sOJtG2yft38XGU4wnyeZFjfYvnTEK0YY/Q2Gm9wJDwqvnwt pgQLhqRhFjQuJArouH06RC9F8Zu9wsbort2rDMRNvfwwkXqJuXrywe22jwiEkFfoiAJUsQAkmkU OpGfQtLTLrAgp+w== 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" Split the CFA from the pixel format. Ensure we populate the CFA order for the source (sensor, memory, TPG) in generateConfiguration() and update it during validate() depending upon the transformations. With generic formats the logic for selecting output pixel formats for raw streams is quite simplified, as we only work with 16-bit, which is formats::RAW16. So we no longer need adjustRawFormat() helper, and can replace it with a simple check to ensure the sensor advertises raw formats. We still need to figure out the source mbus code that has the largest possible bit-depth, so we repurpose pixfmtToMbusCode() to look for one, given a CFA order. Note that the Mali-C55 kernel drivers are not yet updated to work with the new generic media bus codes, so we skip those. Signed-off-by: Jai Luthra --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 162 ++++++++++++--------------- 1 file changed, 70 insertions(+), 92 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index af518d0b2c28..421f3d925a3f 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -76,10 +76,7 @@ const std::map maliC55FmtToCode = { { formats::NV21, MEDIA_BUS_FMT_YUV10_1X30 }, /* RAW formats, FR pipe only. */ - { formats::SGBRG16, MEDIA_BUS_FMT_SGBRG16_1X16 }, - { formats::SRGGB16, MEDIA_BUS_FMT_SRGGB16_1X16 }, - { formats::SBGGR16, MEDIA_BUS_FMT_SBGGR16_1X16 }, - { formats::SGRBG16, MEDIA_BUS_FMT_SGRBG16_1X16 }, + { formats::RAW16, MEDIA_BUS_FMT_RAW_16 }, }; constexpr Size kMaliC55MinInputSize = { 640, 480 }; @@ -191,13 +188,33 @@ public: }, input_); } - int pixfmtToMbusCode(const PixelFormat &pixFmt) const; - const PixelFormat &bestRawFormat() const; + ColorFilterArray bayerOrder(Transform t) const + { + return std::visit(utils::overloaded{ + [&](const Tpg &tpg) -> ColorFilterArray { + V4L2Subdevice::Formats formats = tpg.sd_->formats(0); + for (const auto &[code, sizes] : formats) { + auto cfa = ColorFilterArray::fromMbusCode(code); + if (cfa) + return cfa.value(); + } + return ColorFilterArray::MONO; + }, + [&](const Inline &in) -> ColorFilterArray { + return in.sensor_->bayerOrder(t); + }, + [&](const Memory &mem) -> ColorFilterArray { + return mem.cru_->sensor()->bayerOrder(t); + }, + }, input_); + } + + int bestMbusCode(ColorFilterArray cfa) const; + bool isSensorRaw() const; void updateControls(const ControlInfoMap &ipaControls); - PixelFormat adjustRawFormat(const PixelFormat &pixFmt) const; - Size adjustRawSizes(const PixelFormat &pixFmt, const Size &rawSize) const; + Size adjustRawSizes(const Size &rawSize, unsigned int rawCode) const; Stream frStream_; Stream dsStream_; @@ -305,21 +322,13 @@ void MaliC55CameraData::setSensorControls(const ControlList &sensorControls) } /* - * The Mali C55 ISP can only produce 16-bit RAW output in bypass modes, but the - * sensors connected to it might produce 8/10/12/16 bits. We simply search the - * sensor's supported formats for the one with a matching bayer order and the - * greatest bitdepth. + * The Mali C55 ISP can only accept as input RAW20 and can only produce as + * output RAW16. The sensors connected to it might produce 8/10/12/16 bits. + * We simply search the sensor's supported formats for the one with greatest + * bitdepth and matches the bayer color filter array order. */ -int MaliC55CameraData::pixfmtToMbusCode(const PixelFormat &pixFmt) const +int MaliC55CameraData::bestMbusCode(ColorFilterArray cfa) const { - auto it = maliC55FmtToCode.find(pixFmt); - if (it == maliC55FmtToCode.end()) - return -EINVAL; - - BayerFormat bayerFormat = BayerFormat::fromMbusCode(it->second); - if (!bayerFormat.isValid()) - return -EINVAL; - V4L2Subdevice::Formats formats = subdev()->formats(0); unsigned int sensorMbusCode = 0; unsigned int bitDepth = 0; @@ -329,7 +338,12 @@ int MaliC55CameraData::pixfmtToMbusCode(const PixelFormat &pixFmt) const if (!sdBayerFormat.isValid()) continue; - if (sdBayerFormat.cfa.order != bayerFormat.cfa.order) + /* The pipeline currently does not support generic codes */ + if (MediaBusFormatInfo::info(code).genericRaw) + continue; + + auto c = ColorFilterArray::fromMbusCode(code); + if (!c || c != cfa) continue; if (sdBayerFormat.bitDepth > bitDepth) { @@ -344,38 +358,20 @@ int MaliC55CameraData::pixfmtToMbusCode(const PixelFormat &pixFmt) const return sensorMbusCode; } -/* - * Find a RAW PixelFormat supported by both the ISP and the sensor. - * - * The situation is mildly complicated by the fact that we expect the sensor to - * output something like RAW8/10/12/16, but the ISP can only accept as input - * RAW20 and can only produce as output RAW16. The one constant in that is the - * bayer order of the data, so we'll simply check that the sensor produces a - * format with a bayer order that matches that of one of the formats we support, - * and select that. - */ -const PixelFormat &MaliC55CameraData::bestRawFormat() const +bool MaliC55CameraData::isSensorRaw() const { - static const PixelFormat invalidPixFmt = {}; + if (!std::holds_alternative(input_)) + return this->sensor()->isRaw(); for (const auto &fmt : subdev()->formats(0)) { BayerFormat sensorBayer = BayerFormat::fromMbusCode(fmt.first); - if (!sensorBayer.isValid()) - continue; - - for (const auto &[pixFmt, rawCode] : maliC55FmtToCode) { - if (!isFormatRaw(pixFmt)) - continue; - - BayerFormat bayer = BayerFormat::fromMbusCode(rawCode); - if (bayer.cfa.order == sensorBayer.cfa.order) - return pixFmt; - } + if (sensorBayer.isValid()) + return true; } - LOG(MaliC55, Error) << "Sensor doesn't provide a compatible format"; - return invalidPixFmt; + LOG(MaliC55, Error) << "Sensor doesn't provide a raw bayer format"; + return false; } void MaliC55CameraData::updateControls(const ControlInfoMap &ipaControls) @@ -402,34 +398,13 @@ void MaliC55CameraData::updateControls(const ControlInfoMap &ipaControls) controlInfo_ = ControlInfoMap(std::move(controls), controls::controls); } -/* - * Make sure the provided raw pixel format is supported and adjust it to - * one of the supported ones if it's not. - */ -PixelFormat MaliC55CameraData::adjustRawFormat(const PixelFormat &rawFmt) const -{ - /* Make sure the RAW mbus code is supported by the image source. */ - int rawCode = pixfmtToMbusCode(rawFmt); - if (rawCode < 0) - return bestRawFormat(); - - const auto rawSizes = sizes(rawCode); - if (rawSizes.empty()) - return bestRawFormat(); - - return rawFmt; -} - -Size MaliC55CameraData::adjustRawSizes(const PixelFormat &rawFmt, const Size &size) const +Size MaliC55CameraData::adjustRawSizes(const Size &size, + unsigned int rawCode) const { /* Expand the RAW size to the minimum ISP input size. */ Size rawSize = size.expandedTo(kMaliC55MinInputSize); /* Check if the size is natively supported. */ - int rawCode = pixfmtToMbusCode(rawFmt); - if (rawCode < 0) - return {}; - const auto rawSizes = sizes(rawCode); auto sizeIt = std::find(rawSizes.begin(), rawSizes.end(), rawSize); if (sizeIt != rawSizes.end()) @@ -552,21 +527,28 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate() rawConfig = &config; } + /* Populate a valid sensor mbus code */ + ColorFilterArray cfa = data_->bayerOrder(combinedTransform_); + int code = data_->bestMbusCode(cfa); + if (code < 0) + return Invalid; + + sensorFormat_.code = code; + /* * The C55 can not upscale. Limit the configuration to the ISP * capabilities and the sensor resolution. */ Size maxSize = kMaliC55MaxSize.boundedTo(data_->resolution()); if (rawConfig) { - /* - * \todo Take into account the Bayer components ordering once - * we support rotations. - */ - PixelFormat rawFormat = - data_->adjustRawFormat(rawConfig->pixelFormat); + if (!rawConfig->bayerOrder || + rawConfig->bayerOrder.value() != cfa) { + rawConfig->bayerOrder = cfa; + status = Adjusted; + } - if (!rawFormat.isValid()) - return Invalid; + /* C55 can only produce 16-bit raw output */ + PixelFormat rawFormat = formats::RAW16; if (rawFormat != rawConfig->pixelFormat) { LOG(MaliC55, Debug) @@ -576,7 +558,7 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate() } Size rawSize = - data_->adjustRawSizes(rawFormat, rawConfig->size); + data_->adjustRawSizes(rawConfig->size, sensorFormat_.code); if (rawSize != rawConfig->size) { LOG(MaliC55, Debug) << "RAW sizes adjusted to " << rawSize; @@ -637,19 +619,15 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate() /* If there's a RAW config, sensor configuration follows it. */ if (rawConfig) { - sensorFormat_.code = data_->pixfmtToMbusCode(rawConfig->pixelFormat); sensorFormat_.size = rawConfig->size.expandedTo(minSensorSize); return status; } /* If there's no RAW config, compute the sensor configuration here. */ - PixelFormat rawFormat = data_->bestRawFormat(); - if (!rawFormat.isValid()) + if (!data_->isSensorRaw()) return Invalid; - sensorFormat_.code = data_->pixfmtToMbusCode(rawFormat); - uint16_t distance = std::numeric_limits::max(); const auto sizes = data_->sizes(sensorFormat_.code); Size bestSize; @@ -799,6 +777,7 @@ PipelineHandlerMaliC55::generateConfiguration(Camera *camera, std::unique_ptr config = std::make_unique(data); bool frPipeAvailable = true; + ColorFilterArray cameraCfa = data->bayerOrder(Transform::Identity); if (roles.empty()) return config; @@ -838,12 +817,8 @@ PipelineHandlerMaliC55::generateConfiguration(Camera *camera, break; case StreamRole::Raw: - pixelFormat = data->bestRawFormat(); - if (!pixelFormat.isValid()) { - LOG(MaliC55, Error) - << "Camera does not support RAW formats"; + if (!data->isSensorRaw()) return nullptr; - } size = data->resolution(); break; @@ -865,7 +840,7 @@ PipelineHandlerMaliC55::generateConfiguration(Camera *camera, if (isRaw) { /* Make sure the mbus code is supported. */ - int rawCode = data->pixfmtToMbusCode(pixFmt); + int rawCode = data->bestMbusCode(cameraCfa); if (rawCode < 0) continue; @@ -896,6 +871,9 @@ PipelineHandlerMaliC55::generateConfiguration(Camera *camera, cfg.bufferCount = 4; cfg.size = size; + if (role == StreamRole::Raw) + cfg.bayerOrder = cameraCfa; + config->addConfiguration(cfg); } @@ -1180,10 +1158,10 @@ int PipelineHandlerMaliC55::configure(Camera *camera, * affected by any flips that we've configured) */ const Transform &combinedTransform = maliConfig->combinedTransform(); - ColorFilterArray::Order cfaOrder = data->sensor()->bayerOrder(combinedTransform); + ColorFilterArray cfa = data->bayerOrder(combinedTransform); ControlInfoMap ipaControls; - ret = data->ipa_->configure(ipaConfig, utils::to_underlying(cfaOrder), + ret = data->ipa_->configure(ipaConfig, utils::to_underlying(cfa.order), &ipaControls); if (ret) { LOG(MaliC55, Error) << "Failed to configure IPA"; From patchwork Fri Oct 23 10:58:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28596 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 D8918C324C for ; Fri, 23 Oct 2026 11:01:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9224D68FD8; Fri, 23 Oct 2026 13:01:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XS31QMQe"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4756368FCF for ; Fri, 23 Oct 2026 13:01:02 +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 08BDC4F05; Fri, 23 Oct 2026 12:58:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753133; bh=hV1xM93sZeH73N+ZqTsYnz4VtRes6iTO5GcbpDGX3/Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XS31QMQekdWQXXxx4CGzRB/1ru/Bu22tTJmzMh6xWbTMtP5l0zGdHVmf6GY31lSIH ea+ET+v2EzIjmN8Biu1H7hlyCuOTmvgl6JhomrE5P/Uhq+WoisTmI5XcOVj2xFcc6b De8bZyW/gYtlHHEhyEUwbXnQYCnARXyLrYjdSnko= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:34 +0530 Subject: [PATCH WIP RFC 26/26] apps: dng_writer: Split cfa pattern handling MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-26-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=10571; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=hV1xM93sZeH73N+ZqTsYnz4VtRes6iTO5GcbpDGX3/Y=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3brmOP52V5syHMzLLABxQUIpXFA0dKqyhNI dVqpDQiUM6JAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats92wAKCRBD3pH5JJpx RUWUEADJ5quJEtSmgyQPNyN9H66WzrukUdx+1l1zdllCdheLkckG16A1NTi1aU0nWjfs2Klih/E d1lbg4ZYfd1NOSbaBIDiVKDDFVr5A81R0admhCGTL3JOCedAc4DHBkSNJED+qQnmG+Gmkb5MoBI a1Ahm3Hpb/URn7ObC6XAkGdqcWu69vlAfxT6dFbSk0Ukmal4drfHotFcxs/JKN7ZXTrPf8F2VO8 hty36Kdd8t7vbujLMGJZn+CN7E8L9KihSe2LoEpqFDGNjwa52GVvK4rEeeslCuAJkoJeYFD3App Z8v0s7aP8vhBaRDs5mHHlM5U4hkktrkYnK5oTBOI2Lz+2TJDbWcEzJJr4NihYE5O2f5KaIRk9mr TFbANiN9MVHsPsHlx6P2sbeU5eeBkNDOoTw56JHTL4tTqMWVLtuidVgv2lbBnVLxW8H3sP65UUW aFonjHrswb6b2+Mb4x+XWyR2jQmmHYD05xkEbfR9nk8mXZ521FynKTgmr0OYW/59PP0eYxbix0A ePK9fBd8RpfLjyoMYADBhwEy8NUtMe5oeF3WIKK8k0hmNDAg+RsYU4TUnKfQGmJOFN+Aa1U3vEx CyrYTlhng5cwbqahlYmwM0mR12M/6+4QZtZ0XjxjaqbK7nWEn809BS8+MZPrSL49BFvckvf+eMC c8R11nWX6leVvGQ== 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" Simplify the formatInfo table by switching to the new generic pixel formats. For populating the color filter array pattern fields in the TIFF metadata, read it from the StreamConfiguration. Signed-off-by: Jai Luthra --- src/apps/common/dng_writer.cpp | 189 ++++++++++------------------------------- 1 file changed, 43 insertions(+), 146 deletions(-) diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp index 0d9b725b939f..ab2b244b1cdf 100644 --- a/src/apps/common/dng_writer.cpp +++ b/src/apps/common/dng_writer.cpp @@ -8,13 +8,16 @@ #include "dng_writer.h" #include +#include #include #include #include +#include #include #include +#include #include #include #include @@ -27,9 +30,10 @@ enum CFAPatternColour : uint8_t { CFAPatternBlue = 2, }; +typedef std::array CFAPattern; + struct FormatInfo { uint8_t bitsPerSample; - CFAPatternColour pattern[4]; void (*packScanline)(void *output, const void *input, unsigned int width); void (*thumbScanline)(const FormatInfo &info, void *output, @@ -347,176 +351,63 @@ void thumbScanlineIPU3([[maybe_unused]] const FormatInfo &info, void *output, } const std::map formatInfo = { - { formats::SBGGR8, { + { formats::RAW8, { .bitsPerSample = 8, - .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed }, .packScanline = packScanlineRaw8, .thumbScanline = thumbScanlineRaw_CSI2P, } }, - { formats::SGBRG8, { - .bitsPerSample = 8, - .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen }, - .packScanline = packScanlineRaw8, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SGRBG8, { - .bitsPerSample = 8, - .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen }, - .packScanline = packScanlineRaw8, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SRGGB8, { - .bitsPerSample = 8, - .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue }, - .packScanline = packScanlineRaw8, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SBGGR10, { + { formats::RAW10, { .bitsPerSample = 10, - .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed }, .packScanline = packScanlineRaw10, .thumbScanline = thumbScanlineRaw, } }, - { formats::SGBRG10, { - .bitsPerSample = 10, - .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen }, - .packScanline = packScanlineRaw10, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SGRBG10, { - .bitsPerSample = 10, - .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen }, - .packScanline = packScanlineRaw10, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SRGGB10, { - .bitsPerSample = 10, - .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue }, - .packScanline = packScanlineRaw10, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SBGGR12, { + { formats::RAW12, { .bitsPerSample = 12, - .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed }, .packScanline = packScanlineRaw12, .thumbScanline = thumbScanlineRaw, } }, - { formats::SGBRG12, { - .bitsPerSample = 12, - .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen }, - .packScanline = packScanlineRaw12, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SGRBG12, { - .bitsPerSample = 12, - .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen }, - .packScanline = packScanlineRaw12, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SRGGB12, { - .bitsPerSample = 12, - .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue }, - .packScanline = packScanlineRaw12, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SBGGR16, { + { formats::RAW16, { .bitsPerSample = 16, - .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed }, .packScanline = packScanlineRaw16, .thumbScanline = thumbScanlineRaw, } }, - { formats::SGBRG16, { - .bitsPerSample = 16, - .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen }, - .packScanline = packScanlineRaw16, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SGRBG16, { - .bitsPerSample = 16, - .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen }, - .packScanline = packScanlineRaw16, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SRGGB16, { - .bitsPerSample = 16, - .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue }, - .packScanline = packScanlineRaw16, - .thumbScanline = thumbScanlineRaw, - } }, - { formats::SBGGR10_CSI2P, { + { formats::RAW10_CSI2P, { .bitsPerSample = 10, - .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed }, .packScanline = packScanlineRaw10_CSI2P, .thumbScanline = thumbScanlineRaw_CSI2P, } }, - { formats::SGBRG10_CSI2P, { - .bitsPerSample = 10, - .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen }, - .packScanline = packScanlineRaw10_CSI2P, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SGRBG10_CSI2P, { - .bitsPerSample = 10, - .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen }, - .packScanline = packScanlineRaw10_CSI2P, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SRGGB10_CSI2P, { - .bitsPerSample = 10, - .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue }, - .packScanline = packScanlineRaw10_CSI2P, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SBGGR12_CSI2P, { + { formats::RAW12_CSI2P, { .bitsPerSample = 12, - .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed }, .packScanline = packScanlineRaw12_CSI2P, .thumbScanline = thumbScanlineRaw_CSI2P, } }, - { formats::SGBRG12_CSI2P, { - .bitsPerSample = 12, - .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen }, - .packScanline = packScanlineRaw12_CSI2P, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SGRBG12_CSI2P, { - .bitsPerSample = 12, - .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen }, - .packScanline = packScanlineRaw12_CSI2P, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SRGGB12_CSI2P, { - .bitsPerSample = 12, - .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue }, - .packScanline = packScanlineRaw12_CSI2P, - .thumbScanline = thumbScanlineRaw_CSI2P, - } }, - { formats::SBGGR10_IPU3, { + { formats::RAW10_IPU3, { .bitsPerSample = 16, - .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed }, - .packScanline = packScanlineIPU3, - .thumbScanline = thumbScanlineIPU3, - } }, - { formats::SGBRG10_IPU3, { - .bitsPerSample = 16, - .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen }, - .packScanline = packScanlineIPU3, - .thumbScanline = thumbScanlineIPU3, - } }, - { formats::SGRBG10_IPU3, { - .bitsPerSample = 16, - .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen }, - .packScanline = packScanlineIPU3, - .thumbScanline = thumbScanlineIPU3, - } }, - { formats::SRGGB10_IPU3, { - .bitsPerSample = 16, - .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue }, .packScanline = packScanlineIPU3, .thumbScanline = thumbScanlineIPU3, } }, }; +static constexpr std::pair patterns[] = { + { ColorFilterArray::BGGR, { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed } }, + { ColorFilterArray::GBRG, { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen } }, + { ColorFilterArray::GRBG, { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen } }, + { ColorFilterArray::RGGB, { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue } }, +}; + +static std::optional findCfaPattern(const std::optional cfa) +{ + if (!cfa) + return std::nullopt; + + for (const auto &[key, pattern] : patterns) { + if (key.order == cfa.value().order) + return pattern; + } + + return std::nullopt; +} + } /* namespace */ int DNGWriter::write(const char *filename, const Camera *camera, @@ -534,6 +425,12 @@ int DNGWriter::write(const char *filename, const Camera *camera, } const FormatInfo *info = &it->second; + const auto pattern = findCfaPattern(config.bayerOrder); + if (!pattern) { + std::cerr << "Unknown color filter array pattern" << std::endl; + return -EINVAL; + } + TIFF *tif = TIFFOpen(filename, "w"); if (!tif) { std::cerr << "Failed to open tiff file" << std::endl; @@ -696,9 +593,9 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, cfaRepeatPatternDim); if (TIFFLIB_VERSION < 20201219) - TIFFSetField(tif, TIFFTAG_CFAPATTERN, info->pattern); + TIFFSetField(tif, TIFFTAG_CFAPATTERN, pattern.value().data()); else - TIFFSetField(tif, TIFFTAG_CFAPATTERN, 4, info->pattern); + TIFFSetField(tif, TIFFTAG_CFAPATTERN, 4, pattern.value().data()); TIFFSetField(tif, TIFFTAG_CFAPLANECOLOR, 3, cfaPlaneColor); TIFFSetField(tif, TIFFTAG_CFALAYOUT, 1); @@ -715,14 +612,14 @@ int DNGWriter::write(const char *filename, const Camera *camera, * Map it to the TIFF tag that is specified in CFA pattern * order. */ - unsigned int green = (info->pattern[0] == CFAPatternRed || - info->pattern[1] == CFAPatternRed) + unsigned int green = (pattern.value()[0] == CFAPatternRed || + pattern.value()[1] == CFAPatternRed) ? 0 : 1; for (unsigned int i = 0; i < 4; ++i) { unsigned int level; - switch (info->pattern[i]) { + switch (pattern.value()[i]) { case CFAPatternRed: level = levels[0]; break;