{"id":20829,"url":"https://patchwork.libcamera.org/api/patches/20829/?format=json","web_url":"https://patchwork.libcamera.org/patch/20829/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240808071433.10724-1-naush@raspberrypi.com>","date":"2024-08-08T07:14:33","name":"libcamera: formats: Adding Support for Y12P","commit_ref":"f87bf964fc108675c48b168e9b1d2629a3461bef","pull_url":null,"state":"accepted","archived":false,"hash":"a59fe7406a9aadf144ca97bc1cb3ece6aa6c4e72","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20829/mbox/","series":[{"id":4499,"url":"https://patchwork.libcamera.org/api/series/4499/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4499","date":"2024-08-08T07:14:33","name":"libcamera: formats: Adding Support for Y12P","version":1,"mbox":"https://patchwork.libcamera.org/series/4499/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20829/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20829/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 363E7BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Aug 2024 07:14:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D005F6338D;\n\tThu,  8 Aug 2024 09:14:30 +0200 (CEST)","from mail-wm1-x332.google.com (mail-wm1-x332.google.com\n\t[IPv6:2a00:1450:4864:20::332])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 53E556337F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Aug 2024 09:14:28 +0200 (CEST)","by mail-wm1-x332.google.com with SMTP id\n\t5b1f17b1804b1-4281ca54fd3so4546035e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 08 Aug 2024 00:14:28 -0700 (PDT)","from naush-laptop.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4290c74a9d2sm7506775e9.27.2024.08.08.00.14.26\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 08 Aug 2024 00:14:26 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"GopI11xU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1723101267; x=1723706067;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=wrCYY9Ks7e6nUe3FTRF2ERCt3Gd9uXxWpFoenV0ryHg=;\n\tb=GopI11xU1IKpgBIzSPsen/Hatdohqft37K9JfWzTVASOKNJx9QhUSEJ9EWJMcN5DSx\n\tgoWzRXvwMA3BpZqXK4lEgZth77YV7Jh2V7Ij0OgoGx6EKUKGQS1X/x3D80FdtE9/WNVn\n\tyOXQzC6/Nv8TWxL1aoTiRPigSINON5Wj+SgT4qS9cED9tvfEKqfgrKdDw9D774RC3npY\n\t94BrG6Smo7q4/HkOZ/hAtTfSBDEZA/KxfaVa6R1rEeMccC/9zrDOBEFu8yZd6Bk1LwDe\n\tL/WmvXNvtxHaNymB4UMHyWajwvMcF64IqpLwUMPBJ2c08tKDnFNyrQmV//D2CkKfTp2R\n\tmrDA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1723101267; x=1723706067;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=wrCYY9Ks7e6nUe3FTRF2ERCt3Gd9uXxWpFoenV0ryHg=;\n\tb=lDJZOuKH/0pO8dny0Dj4XtWTLdBBy+8UpWsLaJPtV2bga8ivzcWFkG8zloVcJOE2EO\n\tRQ8dos1j7sDnepdtgmk/cQcm9rx3DajhRkQ51qSgugk8snVOs7Mo0IzP0uVc5/DP6yRs\n\tt86f+ESOpIOdNk0H3CPsole7BLIkHU+kqKiauZtmvFNMutdOEE2gmdhjWHIkw7ykjocz\n\tZrEaPlT8AloFY1/t4FLqsObA1CxLJPAGjmJpxwKkUBhhN7o7tH4pWxbUk5wu3B1tr4nS\n\tnsSEPGWwAq/wPrx7fz6BLXHN4HjX3ncCHVQ9BJiKF7aQICVXND43TNtSUMMuSHc7HLXH\n\tmIoQ==","X-Gm-Message-State":"AOJu0YzVmvvLQc/m6QBqyGMZgXpnF95iAbDcj9w5acwfikpxVhRl3hcV\n\tH8IUGw4UXB6s0xlqbh8mzmjhipzMCnsOcLETBqkjfPrBmyPQX9EvTa1GD0J1E2FaXVF0laCC5bH\n\tB","X-Google-Smtp-Source":"AGHT+IGcPtpo8eCPPEXGSCRlC8Nr29qWBUrouCNuwMA1uwsPh6vmiO4lp5RduNzj+RkO0Wig1lkGog==","X-Received":"by 2002:a05:600c:6c8e:b0:428:1e8c:ff75 with SMTP id\n\t5b1f17b1804b1-4290af48098mr8111355e9.35.1723101266905; \n\tThu, 08 Aug 2024 00:14:26 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"will whang <will@willwhang.com>, Naushir Patuck <naush@raspberrypi.com>","Subject":"[PATCH] libcamera: formats: Adding Support for Y12P","Date":"Thu,  8 Aug 2024 08:14:33 +0100","Message-Id":"<20240808071433.10724-1-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20240807080344.12780-2-naush@raspberrypi.com>","References":"<20240807080344.12780-2-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: will whang <will@willwhang.com>\n\nAdd support for a 12-bit Mono format named formats::R12_CSI2P.\n\nThis format is added to support the IMX585 mono sensor, which uses the\nMEDIA_BUS_FMT_Y12_1X12 media bus format.\n\nSigned-off-by: will whang <will@willwhang.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/libcamera/bayer_format.cpp     |  2 ++\n src/libcamera/formats.cpp          | 10 ++++++++++\n src/libcamera/formats.yaml         |  3 +++\n src/libcamera/v4l2_pixelformat.cpp |  2 ++\n 4 files changed, 17 insertions(+)","diff":"diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\nindex 014f716d28f7..c2120d1c16d7 100644\n--- a/src/libcamera/bayer_format.cpp\n+++ b/src/libcamera/bayer_format.cpp\n@@ -184,6 +184,8 @@ const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{\n \t\t{ formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },\n \t{ { BayerFormat::MONO, 12, BayerFormat::Packing::None },\n \t\t{ formats::R12, V4L2PixelFormat(V4L2_PIX_FMT_Y12) } },\n+\t{ { BayerFormat::MONO, 12, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::R12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y12P) } },\n \t{ { BayerFormat::MONO, 16, BayerFormat::Packing::None },\n \t\t{ formats::R16, V4L2PixelFormat(V4L2_PIX_FMT_Y16) } },\n \t{ { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 },\ndiff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex cf41f2c261ed..f338fc373f33 100644\n--- a/src/libcamera/formats.cpp\n+++ b/src/libcamera/formats.cpp\n@@ -527,6 +527,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.pixelsPerGroup = 4,\n \t\t.planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},\n \t} },\n+\t{ formats::R12_CSI2P, {\n+\t\t.name = \"R12_CSI2P\",\n+\t\t.format = formats::R12_CSI2P,\n+\t\t.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_Y12P), },\n+\t\t.bitsPerPixel = 12,\n+\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n+\t\t.packed = true,\n+\t\t.pixelsPerGroup = 2,\n+\t\t.planes = {{ { 3, 1 }, { 0, 0 }, { 0, 0 } }},\n+\t} },\n \t{ formats::R12, {\n \t\t.name = \"R12\",\n \t\t.format = formats::R12,\ndiff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml\nindex fe027a7cce70..2d54d391ca01 100644\n--- a/src/libcamera/formats.yaml\n+++ b/src/libcamera/formats.yaml\n@@ -138,6 +138,9 @@ formats:\n   - R10_CSI2P:\n       fourcc: DRM_FORMAT_R10\n       mod: MIPI_FORMAT_MOD_CSI2_PACKED\n+  - R12_CSI2P:\n+      fourcc: DRM_FORMAT_R12\n+      mod: MIPI_FORMAT_MOD_CSI2_PACKED\n \n   - SRGGB10_CSI2P:\n       fourcc: DRM_FORMAT_SRGGB10\ndiff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\nindex 70568335b266..eb9ac2224fd1 100644\n--- a/src/libcamera/v4l2_pixelformat.cpp\n+++ b/src/libcamera/v4l2_pixelformat.cpp\n@@ -139,6 +139,8 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{\n \t\t{ formats::R10_CSI2P, \"10-bit Greyscale Packed\" } },\n \t{ V4L2PixelFormat(V4L2_PIX_FMT_Y12),\n \t\t{ formats::R12, \"12-bit Greyscale\" } },\n+\t{ V4L2PixelFormat(V4L2_PIX_FMT_Y12P),\n+\t\t{ formats::R12_CSI2P, \"12-bit Greyscale Packed\" } },\n \t{ V4L2PixelFormat(V4L2_PIX_FMT_Y16),\n \t\t{ formats::R16, \"16-bit Greyscale\" } },\n \n","prefixes":[]}