From patchwork Tue Jan 23 13:34:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 19461 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 B2D24C323E for ; Tue, 23 Jan 2024 13:34:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0F95462916; Tue, 23 Jan 2024 14:34:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="j6EF4vpb"; 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 CD94F628E9 for ; Tue, 23 Jan 2024 14:34:14 +0100 (CET) Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F34B31571; Tue, 23 Jan 2024 14:33:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706016781; bh=Aobi3CiX9A7FLyxyTnAeGitxwQueJMjxYVfRP7LZ9gw=; h=From:To:Cc:Subject:Date:From; b=j6EF4vpbx5KymjOJBuFBXYbn8Vhaw4pu341vXe58nXNodNeA4JeQx7OmyzyWg+2r+ UiZ0QfbuB+qFBGVgMps8H16Z8MNAxl4htcCceJSGyUFwCt2Csb3MJiS+ZLLLaJuXCJ 3sc9l83s8w7nWfupsTCMXhTYKkPWiP9MEjFi+eWo= From: Kieran Bingham To: libcamera devel Subject: [PATCH] libcamera: formats: Add 16-bit mono format Date: Tue, 23 Jan 2024 13:34:10 +0000 Message-Id: <20240123133410.4130945-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Naushir Patuck Add the relevant definitions for a 16-bit mono pixel and media-bus format. Signed-off-by: Naushir Patuck Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Kieran Bingham --- Patch cherry-picked from https://github.com/raspberrypi/libcamera/commit/d8c775077c33f7475c5d4828ce3e374d5769b59c and rebased on top of the recent df770d4b0a6d ("include: linux: Update kernel headers to version v6.7". src/libcamera/bayer_format.cpp | 3 +++ src/libcamera/formats.cpp | 10 ++++++++++ src/libcamera/formats.yaml | 2 ++ src/libcamera/v4l2_pixelformat.cpp | 2 ++ src/libcamera/v4l2_subdevice.cpp | 1 + 5 files changed, 18 insertions(+) diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 3bf15fb48f36..2f55d33a915d 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -168,8 +168,11 @@ const std::map bayerToFormat{ { formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } }, { { BayerFormat::MONO, 10, BayerFormat::Packing::None }, { formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } }, + { { BayerFormat::MONO, 16, BayerFormat::Packing::None }, + { formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } }, { { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 }, { formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } }, + }; const std::unordered_map mbusCodeToBayer{ diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 447e623803c7..46ccd43ba63a 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -507,6 +507,16 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 1, .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, } }, + { formats::R16, { + .name = "R16", + .format = formats::R16, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y16), }, + .bitsPerPixel = 16, + .colourEncoding = PixelFormatInfo::ColourEncodingYUV, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, { formats::R10_CSI2P, { .name = "R10_CSI2P", .format = formats::R10_CSI2P, diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index 539ac0b33084..d8a379923b56 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 + - R16: + fourcc: DRM_FORMAT_R16 - RGB565: fourcc: DRM_FORMAT_RGB565 diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 5551c62eb39b..731dc10f1d73 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -135,6 +135,8 @@ const std::map vpf2pf{ { formats::R10_CSI2P, "10-bit Greyscale Packed" } }, { V4L2PixelFormat(V4L2_PIX_FMT_Y12), { formats::R12, "12-bit Greyscale" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_Y16), + { formats::R16, "16-bit Greyscale" } }, /* Bayer formats. */ { V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8), diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 75ad11e55272..265240dbd405 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -88,6 +88,7 @@ const std::map formatInfoMap = { { MEDIA_BUS_FMT_YUYV10_2X10, { 20, "YUYV10_2X10", PixelFormatInfo::ColourEncodingYUV } }, { MEDIA_BUS_FMT_YVYU10_2X10, { 20, "YVYU10_2X10", PixelFormatInfo::ColourEncodingYUV } }, { MEDIA_BUS_FMT_Y12_1X12, { 12, "Y12_1X12", PixelFormatInfo::ColourEncodingYUV } }, + { MEDIA_BUS_FMT_Y16_1X16, { 16, "Y16_1X16", PixelFormatInfo::ColourEncodingYUV } }, { MEDIA_BUS_FMT_UYVY8_1X16, { 16, "UYVY8_1X16", PixelFormatInfo::ColourEncodingYUV } }, { MEDIA_BUS_FMT_VYUY8_1X16, { 16, "VYUY8_1X16", PixelFormatInfo::ColourEncodingYUV } }, { MEDIA_BUS_FMT_YUYV8_1X16, { 16, "YUYV8_1X16", PixelFormatInfo::ColourEncodingYUV } },