From patchwork Thu May 2 08:09:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19977 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 73814C328F for ; Thu, 2 May 2024 08:09:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8F18663418; Thu, 2 May 2024 10:09:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="P6lj9Y6k"; dkim-atps=neutral Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 10D316340B for ; Thu, 2 May 2024 10:09:35 +0200 (CEST) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2dd7e56009cso98780051fa.3 for ; Thu, 02 May 2024 01:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1714637374; x=1715242174; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d4TDHiBB6Rh+xnd2xbxCQ+sH6nTZDPAAOhH8KoklCv8=; b=P6lj9Y6kXaARvBeQ23B4arz5ePhYhRKE3eZ1uyw4zvukxbf7Qkcf2T+H/ysyHtWp9m betPzizut8Q/GhBOWiZXsh368dmRvE/vafn3QstImWiqbfxx24tER+QxDXisNWXhh+LU /d/I62nTuo2+/0jh6XjJ2jS4cS1dypFjwMiAdedzI6ZIu9YqTfWHQBqLX/ZIXhQNFIKv IWWQl+OWI+sddeKrUW117aJldSUJetVLFhAzcMPbf9EBuU546njm/rcrhjKMB8w4XpAw gIa1F52BoocRSrxqmzgWn6WLCrX/rKEKbDLpDI7COjqJ39va7HIxmkLUXAZF9ey8LLr6 mCaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714637374; x=1715242174; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d4TDHiBB6Rh+xnd2xbxCQ+sH6nTZDPAAOhH8KoklCv8=; b=ld6uptmT+xWmKaXlQZ/65rYnhQ1snPQ4fxBYMXMDQfW2Hq4NqVQfE3k9ftQzV8Nrvw mM+PNJ5C/lOOSQaXd1n7/XSNxX391iV5BaRz+0ux/zIxAvS2IXN9pLxcPnXRlFs/nl7m az4pOWO1PQsWQROWqWIzoRpTfQIsaTpm8ujqELNLg/3jPz8VBAqRZdMKQmGuJtmy1LFT Q4HZ25QNyBGScmMqB7Mzs24HSchgXeyF9deYZDawhf5VrpaqbBTwcghHCF/+F+vN83Ck 6WterTJdUBh0Hgktvk9l9xFrlDbmILy+g78SkTIv6MCgwGAoou1JaCs0d+0wo+QUPxpL RK0g== X-Gm-Message-State: AOJu0Yyqg5paxN7M9FNx7sl9hnyRumX4DD+6DKLp7MmVqNhHx7OV9L6i re0Ascv70+equ5zedQiQXY0a5qTMCs95ClD8zQf76UzM9vTT+vlp3UcOM/yY187O0sWQv0s01St o X-Google-Smtp-Source: AGHT+IHamrPP0OAoxGpGuzQS+yl2c4+zswiBCe9W40MPQRFbC4VPbnWCz3LvK7CT86GYAks7hC8e4A== X-Received: by 2002:a2e:80d4:0:b0:2df:e705:7b4 with SMTP id r20-20020a2e80d4000000b002dfe70507b4mr750538ljg.10.1714637373913; Thu, 02 May 2024 01:09:33 -0700 (PDT) Received: from localhost.localdomain ([188.39.149.98]) by smtp.gmail.com with ESMTPSA id p12-20020a05600c1d8c00b0041bcb898984sm1049970wms.31.2024.05.02.01.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 01:09:33 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 1/5] libcamera: formats: Add RGB48 formats Date: Thu, 2 May 2024 09:09:21 +0100 Message-Id: <20240502080925.31730-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502080925.31730-1-naush@raspberrypi.com> References: <20240502080925.31730-1-naush@raspberrypi.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add support for 16-bps (48-bpp) RGB output formats. These new formats are define for the RGB and BGR ordering. Signed-off-by: Naushir Patuck --- include/linux/drm_fourcc.h | 4 ++++ include/linux/videodev2.h | 4 ++++ src/libcamera/formats.cpp | 20 ++++++++++++++++++++ src/libcamera/formats.yaml | 5 +++++ src/libcamera/v4l2_pixelformat.cpp | 4 ++++ 5 files changed, 37 insertions(+) diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index d6c83d9c49f4..4ee421b95730 100644 --- a/include/linux/drm_fourcc.h +++ b/include/linux/drm_fourcc.h @@ -210,6 +210,10 @@ extern "C" { #define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ #define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ +/* 48 bpp RGB */ +#define DRM_FORMAT_RGB161616 fourcc_code('R', 'G', '4', '8') /* [48:0] R:G:B 16:16:16 little endian */ +#define DRM_FORMAT_BGR161616 fourcc_code('B', 'G', '4', '8') /* [48:0] R:G:B 16:16:16 little endian */ + /* 64 bpp RGB */ #define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8') /* [63:0] x:R:G:B 16:16:16:16 little endian */ #define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */ diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 7e556911c9e1..ba48d2c89726 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -557,6 +557,10 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_BGR48_12 v4l2_fourcc('B', '3', '1', '2') /* 48 BGR 12-bit per component */ #define V4L2_PIX_FMT_ABGR64_12 v4l2_fourcc('B', '4', '1', '2') /* 64 BGRA 12-bit per component */ +/* RGB formats (6 bytes per pixel) */ +#define V4L2_PIX_FMT_BGR48 v4l2_fourcc('B', 'G', 'R', '6') /* 16 BGR-16-16-16 */ +#define V4L2_PIX_FMT_RGB48 v4l2_fourcc('R', 'G', 'B', '6') /* 16 RGB-16-16-16 */ + /* Grey formats */ #define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ #define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */ diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 955c3fba8b8d..21a7719e84c4 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -270,6 +270,26 @@ const std::map pixelFormatInfo{ .pixelsPerGroup = 1, .planes = {{ { 4, 1 }, { 0, 0 }, { 0, 0 } }}, } }, + { formats::BGR161616, { + .name = "BGR161616", + .format = formats::BGR161616, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_RGB48), }, + .bitsPerPixel = 48, + .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, + { formats::RGB161616, { + .name = "RGB161616", + .format = formats::RGB161616, + .v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_BGR48), }, + .bitsPerPixel = 48, + .colourEncoding = PixelFormatInfo::ColourEncodingRGB, + .packed = false, + .pixelsPerGroup = 1, + .planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }}, + } }, /* YUV packed formats. */ { formats::YUYV, { diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml index d8a379923b56..bde2cc803b98 100644 --- a/src/libcamera/formats.yaml +++ b/src/libcamera/formats.yaml @@ -43,6 +43,11 @@ formats: - BGRA8888: fourcc: DRM_FORMAT_BGRA8888 + - RGB161616: + fourcc: DRM_FORMAT_RGB161616 + - BGR161616: + fourcc: DRM_FORMAT_BGR161616 + - YUYV: fourcc: DRM_FORMAT_YUYV - YVYU: diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 731dc10f1d73..efb6f2940235 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -71,6 +71,10 @@ const std::map vpf2pf{ { formats::BGRA8888, "32-bit ARGB 8-8-8-8" } }, { V4L2PixelFormat(V4L2_PIX_FMT_BGRA32), { formats::RGBA8888, "32-bit ABGR 8-8-8-8" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_RGB48), + { formats::BGR161616, "48-bit RGB 16-16-16" } }, + { V4L2PixelFormat(V4L2_PIX_FMT_BGR48), + { formats::RGB161616, "48-bit BGR 16-16-16" } }, /* YUV packed formats. */ { V4L2PixelFormat(V4L2_PIX_FMT_YUYV),