From patchwork Wed May 8 08:03:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 20012 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 A8ADEBDE6B for ; Wed, 8 May 2024 08:04:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E51766343B; Wed, 8 May 2024 10:04:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="B4XkqaVr"; dkim-atps=neutral Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 39B7A6342A for ; Wed, 8 May 2024 10:04:01 +0200 (CEST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-41bca450fa3so25960805e9.2 for ; Wed, 08 May 2024 01:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1715155440; x=1715760240; 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=oPpBfzgcOt84SvUYH5rr6nfm4TxLEN8TNbvq4qlFgLs=; b=B4XkqaVrtnnK8fyKVRDMh33i/kTLfZq2ezcdPCoEVT70t8Ai6L9DXT7VkyEzAYfcfQ zuCRWS7I5BXU6JJh9F4ck0xMrr7nTKuLYrpZbkruyqtn0mL/q1+nXj9hFzL9rgw2g1r0 7fvUCYHqF6emLj1Jl1JUFGsdcOqTzqFvibdoWtMMKygBIM0i5T8R7oPnNcZ0nmmXVVYY azpYqjnD0zPUmNVAOFAODj5WnratOmMQaaUmuMjwQdJA8mJAvugWD9uGla3HeRa5rtWI f4RrHKViDqt6/MWpzjHvT6gdppEd8wOvC1CJzB1Zdyg4Dxa9MmsuOWMKM6taFZDca9g2 CsAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715155440; x=1715760240; 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=oPpBfzgcOt84SvUYH5rr6nfm4TxLEN8TNbvq4qlFgLs=; b=olNVYgG2rTVVZ/kZ+EAunSeGOS43AgRgG9azkdVByvHp9eLDIuRrRKOsYkkVmnIOlc 2D4LR3tKpIyJJ1HvG3p0lcXhzw+z7Uh9sLJzqZdC3LvoC2v2xucUBXF89dHDJ3mfzDC6 LT2sujAQiKU45eSmZ+NzuXMwdam/ERdxPhi9+GwLImL6lagyC3fC4GMyjP7rk1HaQiDs OkKoQhDEjGmLQMafK110ngrF5R0wHjW+EJRNy4mzbcQZ5iU6A+JrtP4zIti1yWfenJPi 3q4xmsCCv5+Z9gCuz2f0umXF6PIy3EgkzeTsSa6f34lbRLj7qat7W6K15G2q9moLUCev or8Q== X-Gm-Message-State: AOJu0YwBh1nf/DqfXs1s2C8HXcOfGHCimvGM9ZEUaK1M8AkqrFmvpRzA AbDqbFm7hChXi9cc3m9fC9eY+6P1ui/fSu8YOSDl4n51b1bw2komd2d/H1jWK0bbbX6vRLlqk5B D X-Google-Smtp-Source: AGHT+IHmFjbl03atCaVWAB600hkG1LEup/qRawzg+VyCpXgnpG6wU3v8PTZAmRnw9/3bqRvJe9Fh8Q== X-Received: by 2002:a05:600c:3555:b0:41a:7ab1:fd98 with SMTP id 5b1f17b1804b1-41f71ebf886mr13144645e9.21.1715155440543; Wed, 08 May 2024 01:04:00 -0700 (PDT) Received: from localhost.localdomain ([188.39.149.98]) by smtp.gmail.com with ESMTPSA id w16-20020a05600c475000b0041c14061c71sm1351944wmo.15.2024.05.08.01.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:04:00 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v2 1/6] libcamera: formats: Add RGB48 formats Date: Wed, 8 May 2024 09:03:56 +0100 Message-Id: <20240508080401.14850-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240508080401.14850-1-naush@raspberrypi.com> References: <20240508080401.14850-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 Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- include/linux/drm_fourcc.h | 4 ++++ include/linux/videodev2.h | 2 ++ src/libcamera/formats.cpp | 20 ++++++++++++++++++++ src/libcamera/formats.yaml | 5 +++++ src/libcamera/v4l2_pixelformat.cpp | 4 ++++ 5 files changed, 35 insertions(+) diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index d6c83d9c49f4..5133a6551a34 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') /* [47:0] R:G:B 16:16:16 little endian */ +#define DRM_FORMAT_BGR161616 fourcc_code('B', 'G', '4', '8') /* [47:0] B:G:R 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..4fdd91494041 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -555,6 +555,8 @@ struct v4l2_pix_format { /* RGB formats (6 or 8 bytes per pixel) */ #define V4L2_PIX_FMT_BGR48_12 v4l2_fourcc('B', '3', '1', '2') /* 48 BGR 12-bit per component */ +#define V4L2_PIX_FMT_BGR48 v4l2_fourcc('B', 'G', 'R', '6') /* 48 BGR 16-bit per component */ +#define V4L2_PIX_FMT_RGB48 v4l2_fourcc('R', 'G', 'B', '6') /* 48 RGB 16-bit per component */ #define V4L2_PIX_FMT_ABGR64_12 v4l2_fourcc('B', '4', '1', '2') /* 64 BGRA 12-bit per component */ /* Grey formats */ 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),