Patch Detail
Show a patch.
GET /api/1.1/patches/17811/?format=api
{ "id": 17811, "url": "https://patchwork.libcamera.org/api/1.1/patches/17811/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17811/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20221117185204.11625-1-xavier.roumegue@oss.nxp.com>", "date": "2022-11-17T18:52:03", "name": "[libcamera-devel,v3,1/2] libcamera: Declare generic converter interface", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "25589e4f596c75531062c42d0774f71ca775af68", "submitter": { "id": 107, "url": "https://patchwork.libcamera.org/api/1.1/people/107/?format=api", "name": "Xavier Roumegue", "email": "xavier.roumegue@oss.nxp.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17811/mbox/", "series": [ { "id": 3616, "url": "https://patchwork.libcamera.org/api/1.1/series/3616/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3616", "date": "2022-11-17T18:52:03", "name": "[libcamera-devel,v3,1/2] libcamera: Declare generic converter interface", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3616/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17811/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17811/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 3270EBD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Nov 2022 18:52:42 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9C2686309B;\n\tThu, 17 Nov 2022 19:52:41 +0100 (CET)", "from EUR05-VI1-obe.outbound.protection.outlook.com\n\t(mail-vi1eur05on20623.outbound.protection.outlook.com\n\t[IPv6:2a01:111:f400:7d00::623])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 84A0F61F31\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Nov 2022 19:52:39 +0100 (CET)", "from PAXPR04MB8703.eurprd04.prod.outlook.com\n\t(2603:10a6:102:21e::22)\n\tby DU2PR04MB8678.eurprd04.prod.outlook.com (2603:10a6:10:2dd::14)\n\twith Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13;\n\tThu, 17 Nov 2022 18:52:37 +0000", "from PAXPR04MB8703.eurprd04.prod.outlook.com\n\t([fe80::14d3:8e4:cf07:810d]) by\n\tPAXPR04MB8703.eurprd04.prod.outlook.com\n\t([fe80::14d3:8e4:cf07:810d%3]) with mapi id 15.20.5813.020;\n\tThu, 17 Nov 2022 18:52:36 +0000" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1668711161;\n\tbh=8O8U4bTo4NoGlE26T2Tv/aS1WIJg7tL/shel8TE6Qa8=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=xS1dIZ3fEahTvxg4SUoHcNp48mNgNjuTqz/wMhhfYwR4Wl9CHVHduJx9oksY6YqoZ\n\t5Vfo6MNqM7A0i3qoAWPVzU6KwtqSmu7UhniSBfXeB19LWNUrtSgartRCY7qmqKR/Us\n\t6TwJQLlzGzd79lcbNEhSAjNmhZ1CmF/8V80OFbiI3/egkv8IVTluvoHQeD+tqxM5np\n\tXbyegiJoUVkpzrhyQxHIRFv+rvBat6duMtOi3tfZOQy135G07TZnbjmXs2TE2QQ9G/\n\t3fqGIs0zyobfNAHce1vYqxCyccYCy3JNx5YPBKyVZD/a9dADPJ+lGVS6/+LnyBEM4S\n\tvImjNFiI887/Q==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com;\n\ts=selector2-NXP1-onmicrosoft-com;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=TTrE46uE/qr5toOQV7XNykZr8uUlV1ej973RN51LeLw=;\n\tb=KAeYnRLshlMn3fPGzkQypJkTVLSA4d03CGr7FrbIvBdf/SLShGoBy/H++c91A0Zm7xvD3AZTm/roo0X2ExPmnbyAs8MZvBEmPfIAZ4S/Eam2drTXYznTm3zb+24ddTQa/p0GQUro2fs7yPkmh/biZftzX4hAH7wyOWN3K/rw/Y0=" ], "Authentication-Results": [ "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=NXP1.onmicrosoft.com\n\theader.i=@NXP1.onmicrosoft.com\n\theader.b=\"KAeYnRLs\"; dkim-atps=neutral", "dkim=none (message not signed)\n\theader.d=none;dmarc=none action=none header.from=oss.nxp.com;" ], "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n\tb=V+/8R7px7Q9V3FSdh9t0MXN2gyXoNcpvd72bNq9sWKx4NMq7IXN68LewQiMRspI6Pb6tJJGlSEvV95YIdH5C/z+etpF1hWMnbBV/Py/uVhRf+oQufa9P72dTAYB/XdkKbOCEDiP0rdjpigMwvCVSAtKQuKdFirgjIJRH1EtiJH5Q3936Gsng0Bhs93DlcuxXdE0yi2mHkinRTWV+urM0c/IIrHTlr9Xd6v/sqE3cP8J6FKObfHzS42pbdvUUZ2WL2Q4xRrkP/ACJ+2lc1qtT1qLtjG+9B5W2VfahGF9rMlE2fTz7eRxOhHWv9HcLLVeCaaj+UuEs3UYfFLJ8BJT2Iw==", "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n\ts=arcselector9901;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n\tbh=TTrE46uE/qr5toOQV7XNykZr8uUlV1ej973RN51LeLw=;\n\tb=nhc53PkpyFWtv0nwuTptLf34F6lZmPcx+/62iZS+qhlngsD5PrIM8cbFFP7MVD/SpgSwbmzY8POuS8m8yOF3LaUR5feeETPGXHyGsGgrcGFMR53Oq3NJ7/MTv/AeR8gMVCY87TucpyHDaAxODn/QmE12tBynPvnyySaySLs0y0/h0BYGhDC+374UdrQg2lG0/6LCAGQpCt+mFllwD4Bemi8e4ZVzb5p6S3B7MBv+RF5CrwDnuIHMS8QJaZ6D8EkU0fsTRZ+/2hReGxWRZRzZLK57bFT9KSUYA6yyH6XPetBcuRaGCv81QJgkoVY/GYQyVPaVwOeBfIrbUwmcKkefVA==", "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass\n\tsmtp.mailfrom=oss.nxp.com;\n\tdmarc=pass action=none header.from=oss.nxp.com; \n\tdkim=pass header.d=oss.nxp.com; arc=none", "To": "jacopo@jmondi.org,\n\tlaurent.pinchart@ideasonboard.com", "Date": "Thu, 17 Nov 2022 19:52:03 +0100", "Message-Id": "<20221117185204.11625-1-xavier.roumegue@oss.nxp.com>", "X-Mailer": "git-send-email 2.38.1", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-ClientProxiedBy": "PR3P191CA0006.EURP191.PROD.OUTLOOK.COM\n\t(2603:10a6:102:54::11) To PAXPR04MB8703.eurprd04.prod.outlook.com\n\t(2603:10a6:102:21e::22)", "MIME-Version": "1.0", "X-MS-Exchange-MessageSentRepresentingType": "1", "X-MS-PublicTrafficType": "Email", "X-MS-TrafficTypeDiagnostic": "PAXPR04MB8703:EE_|DU2PR04MB8678:EE_", "X-MS-Office365-Filtering-Correlation-Id": "132bb525-c1e5-4bb0-492b-08dac8cce403", "X-MS-Exchange-SharedMailbox-RoutingAgent-Processed": "True", "X-MS-Exchange-SenderADCheck": "1", "X-MS-Exchange-AntiSpam-Relay": "0", "X-Microsoft-Antispam": "BCL:0;", "X-Microsoft-Antispam-Message-Info": "pVfdAIuX78ubgqdcV0g0rPj94YaznSNZ4oQcG/M+Yr8BPmFq2FtTsbBeSM4PD6b9oqWlJLGuaD/Hw/XnHLDFv7SOgkQw8eNpyxBg+c3suWMI+0drL01frN+ZPQNr7Bx4HTHo2pnS8hASUxEGvPzNtG/Lbwky0Qt7bDsRbpOIxZyq0i07PZw+zX1uJgXpP+qSozKphYgrKkWa3dFSe9qA9hVMSm1sxQ9aos3T4Ejw/KMfs3Iqe3ZQSx3M24dZhT2kPM3N8hI7N37tZUOdTC7U0IPQ9A6A7/AW9GJENZ8K1chL+qWacE38vtJlexh7junxSjgWamentxpTIVIlkaO9mjNrScQZKjNL7TnJllysOtH0ei8d+F0DItVZRi3qKZjxKaL2hiReoxjQ1N4K+obMvmLGx690+dONxf3HFfX0Aj88xKRjclRdJZfaHXsU9vtHHnyOXt8DzOmeCRLCw6h6j9gOKPmzv9U6FUsN7yvKUqDaLHuFX9P2oMiqJ2u/ku8NrXazGHXHqRML41sB7H94WeSFXi7cDwTSEYxSkqZZXC0S+aCy9NjIxeyRuZV1jDyuf0VXrVpWMUY64MPer8gSyrJMP0FFauGSc4ON5utVSi+1Sc00GfQAYO2fWK43p28yK6i7j9UgBZSIENcO+P/5GQXwPY248TjXeEru0Gl9aQfv9ySiELe16h0jz18jmuQ5", "X-Forefront-Antispam-Report": "CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n\tIPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:;\n\tCAT:NONE; \n\tSFS:(13230022)(4636009)(136003)(376002)(366004)(39860400002)(346002)(396003)(451199015)(52116002)(6666004)(6506007)(6512007)(44832011)(30864003)(8676002)(8936002)(4326008)(66476007)(66556008)(66946007)(5660300002)(38100700002)(1076003)(186003)(2616005)(41300700001)(478600001)(6486002)(316002)(86362001)(2906002)(66899015)(83380400001)(41533002);\n\tDIR:OUT; SFP:1101; ", "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1", "X-MS-Exchange-AntiSpam-MessageData-0": "s99lxbnvuAlAe/5efLM5+pGJtpSsLvgaiSuRnyQ/OwehDAwuM0Fn+dof5Uw5HBVL/lwOrnqRBFU7Z3pxsCPlMF9mDXOdQD1d85b53dLSbOWDZ6B4ezkE79qFQTMI1BFAgv/TB4qhTa/1KAzTAPPZDEUGdDIpm4bLpGAwbH7+aFpiqpygBSKNqJAiazKR5x9Qy0FVdqrWaFr0OXHLv+Av/8ppce6fhsMLGL7L4qQ+j+MUl2KC8TD3PCHb8KnGoIhiP6oMYlmuXZoPrSUc0BUy4y0vpSMKhWPmY1lom8YfgElv/pDYNf1W4kxlnYjQOWg1Khy7lGxCP2Ep87q4GxdUYBDN0EKGoDA2rJrxXCb83fsLFpRIqr1/HL4vDOqDAPiml7wfYXqhXCPRHFy6uV+eFiDxaNDsAkaC4YqhaSzBV524BU67VAxwn+2dIvsR15m9FdfX1m07jl9/071jZCVrzB8WhLz11WMlQjNhD5w3h9+JDMFLuK8Wj/6/91q2LvbadkDlRzLISNLY5PN0SG2rK4oh3LVTXmLA0plGd4CpISCDi468Ad15nVDwY8KA3t+O0J5UqDI0BqDxpZUECixN0MguYpxHYtcLTVlZQJAEkKm0nbCmiL3+NTQecucBB0LU9t/4RhRhYGeuGmWeTn1mUcCxaP6mLfX8adpn25JyD5ZH/8JF3fqqSetmPkB/YIzFUM5/W2ztV62HM5xEyotKsMm+F0SKyPQFujeJvPYIzuuOVDJ8cIo9L0KqVvDysGcE5bWwPF6/93e6hMAhe9X+Hiz9kw/fYl7b1AnD4a39JIYC6wZaUbHUgUq3U61TK+gtYL5cLOIsgOEsjeqSOOGH8VxNi2HCN/WTDtRFKia5+a/T1/YOGOEkpMJcm3vV6SB2PAdA+LCKnsU8G09ohmdpZbrdOa3HJ8a/hUDvNEJwP359Hd79yvEh3x4oHvrrwkdSMQuX4wXfPugutrwIot4j1SaaiAZQO9pnssdXmJ31EvUr6HjoU3IyNPSROn6AK85OYkJumlu1FRH6Xa3Gqn1+qqHU0ZM5au1OPvyjPwAK6li8ZcK/GPLV4eFR74vxNteYRSdtuXk/KaZGIq9UDCT7ww2RUoB5zqr96d9tV16nMpB5BQJXhokRsH7+DfYTxtHFE8g/GCoolLhlSv9hmpc24sxzAWuFZgcb4FSdGA86h8YWx5JmHsWAMHlYb9HK086bXhC6OkpfGs11NzhOmtqgS8T2pprT5MQ0L7y8Jmzf28/A3HkcloQGVv8weiWtO4oVOkhieTw7QQQzxgEOSi561YAR0Rqn/jBmiS6RS52tNCSXvdzBgXsn5vunn29Cxxk/9Jr1RWec0KcpzZe7EubRhy1x4RylVGWPwFTqTGtc0sCRAmYeVtRQ5CkJaHO5dQHW5xGFAZ98yQZANWeHtMeHNsI+EUyjWoU3ZccvdHRFpEeZKfvel9tC2V+gxD4VAShdGqO8VF3E7WfbMsahWg4zoG38wi3/JgM3rc14polRKSSFpOXCL2VgS83EAbJiVpV4FDEK28Jo2AthCwmv1IEYVN/uQOwDtiFOKw+ZeH5BM4kV7qbHyyT2NCIzfkq6Gor94ku8ruQZHn/5T9zO2cIhQzXEITllBm4jwyps1D8UU7FhuEaWQfgmKcYpZ9yXXk6SzdLAyp/oWCTiTUGhNCamnw==", "X-OriginatorOrg": "oss.nxp.com", "X-MS-Exchange-CrossTenant-Network-Message-Id": "132bb525-c1e5-4bb0-492b-08dac8cce403", "X-MS-Exchange-CrossTenant-AuthSource": "PAXPR04MB8703.eurprd04.prod.outlook.com", "X-MS-Exchange-CrossTenant-AuthAs": "Internal", "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "17 Nov 2022 18:52:36.8940\n\t(UTC)", "X-MS-Exchange-CrossTenant-FromEntityHeader": "Hosted", "X-MS-Exchange-CrossTenant-Id": "686ea1d3-bc2b-4c6f-a92c-d99c5c301635", "X-MS-Exchange-CrossTenant-MailboxType": "HOSTED", "X-MS-Exchange-CrossTenant-UserPrincipalName": "DIWgVut8AUK2CWjCdFE/Ll8Ki/IHjak0JDu1S0943zEUyJUaTqCEUyIcbuUR1ku0zdnXJq5KZZ9y6S1Z1AwwJg==", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "DU2PR04MB8678", "Subject": "[libcamera-devel] [PATCH v3 1/2] libcamera: Declare generic\n\tconverter interface", "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>", "From": "Xavier Roumegue via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Xavier Roumegue <xavier.roumegue@oss.nxp.com>", "Cc": "libcamera-devel@lists.libcamera.org", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Declare a converter Abstract Base Class intended to provide generic\ninterfaces to hardware offering size and format conversion services on\nstreams. This is mainly based on the public interfaces of the current\nconverter class implementation found in the simple pipeline handler.\n\nThe main change is the introduction of loadConfiguration() function\nwhich can be used by the concrete implementation to load hardware\nspecific runtime parameters defined by the application.\n\nSigned-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/converter.h | 109 ++++++++\n include/libcamera/internal/meson.build | 1 +\n src/libcamera/converter.cpp | 331 +++++++++++++++++++++++++\n src/libcamera/meson.build | 1 +\n 4 files changed, 442 insertions(+)\n create mode 100644 include/libcamera/internal/converter.h\n create mode 100644 src/libcamera/converter.cpp", "diff": "diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h\nnew file mode 100644\nindex 00000000..c02911c4\n--- /dev/null\n+++ b/include/libcamera/internal/converter.h\n@@ -0,0 +1,109 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Laurent Pinchart\n+ * Copyright 2022 NXP\n+ *\n+ * converter.h - Generic format converter interface\n+ */\n+\n+#pragma once\n+\n+#include <initializer_list>\n+#include <map>\n+#include <memory>\n+#include <string>\n+#include <tuple>\n+#include <vector>\n+\n+#include <libcamera/base/class.h>\n+#include <libcamera/base/signal.h>\n+\n+#include <libcamera/geometry.h>\n+#include <libcamera/pixel_format.h>\n+\n+namespace libcamera {\n+\n+class FrameBuffer;\n+class MediaDevice;\n+class Size;\n+class SizeRange;\n+struct StreamConfiguration;\n+\n+class Converter\n+{\n+public:\n+\tConverter(MediaDevice *media);\n+\tvirtual ~Converter();\n+\n+\tvirtual int loadConfiguration(const std::string &filename) = 0;\n+\n+\tvirtual bool isValid() const = 0;\n+\n+\tvirtual std::vector<PixelFormat> formats(PixelFormat input) = 0;\n+\tvirtual SizeRange sizes(const Size &input) = 0;\n+\n+\tvirtual std::tuple<unsigned int, unsigned int>\n+\tstrideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0;\n+\n+\tvirtual int configure(const StreamConfiguration &inputCfg,\n+\t\t\t const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs) = 0;\n+\tvirtual int exportBuffers(unsigned int output, unsigned int count,\n+\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;\n+\n+\tvirtual int start() = 0;\n+\tvirtual void stop() = 0;\n+\n+\tvirtual int queueBuffers(FrameBuffer *input,\n+\t\t\t\t const std::map<unsigned int, FrameBuffer *> &outputs) = 0;\n+\n+\tSignal<FrameBuffer *> inputBufferReady;\n+\tSignal<FrameBuffer *> outputBufferReady;\n+\n+\tconst std::string &deviceNode() const { return deviceNode_; };\n+\n+private:\n+\tstd::string deviceNode_;\n+};\n+\n+class ConverterFactoryBase\n+{\n+public:\n+\tConverterFactoryBase(const std::string name, std::initializer_list<std::string> aliases);\n+\tvirtual ~ConverterFactoryBase() = default;\n+\n+\tconst std::vector<std::string> &aliases() const { return aliases_; }\n+\n+\tstatic std::unique_ptr<Converter> create(MediaDevice *media);\n+\tstatic std::vector<ConverterFactoryBase *> &factories();\n+\tstatic std::vector<std::string> names();\n+\n+private:\n+\tLIBCAMERA_DISABLE_COPY_AND_MOVE(ConverterFactoryBase)\n+\n+\tstatic void registerType(ConverterFactoryBase *factory);\n+\n+\tvirtual std::unique_ptr<Converter> createInstance(MediaDevice *media) const = 0;\n+\n+\tstd::string name_;\n+\tstd::vector<std::string> aliases_;\n+};\n+\n+template<typename _Converter>\n+class ConverterFactory : public ConverterFactoryBase\n+{\n+public:\n+\tConverterFactory(const char *name, std::initializer_list<std::string> aliases)\n+\t\t: ConverterFactoryBase(name, aliases)\n+\t{\n+\t}\n+\n+\tstd::unique_ptr<Converter> createInstance(MediaDevice *media) const override\n+\t{\n+\t\treturn std::make_unique<_Converter>(media);\n+\t}\n+};\n+\n+#define REGISTER_CONVERTER(name, converter, ...) \\\n+\tstatic ConverterFactory<converter> global_##converter##Factory(name, { __VA_ARGS__ });\n+\n+} /* namespace libcamera */\ndiff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 7a780d48..8f50d755 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -19,6 +19,7 @@ libcamera_internal_headers = files([\n 'camera_sensor_properties.h',\n 'control_serializer.h',\n 'control_validator.h',\n+ 'converter.h',\n 'delayed_controls.h',\n 'device_enumerator.h',\n 'device_enumerator_sysfs.h',\ndiff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp\nnew file mode 100644\nindex 00000000..1ab3c9f6\n--- /dev/null\n+++ b/src/libcamera/converter.cpp\n@@ -0,0 +1,331 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright 2022 NXP\n+ *\n+ * converter.cpp - Generic format converter interface\n+ */\n+\n+#include \"libcamera/internal/converter.h\"\n+\n+#include <algorithm>\n+\n+#include <libcamera/base/log.h>\n+\n+#include \"libcamera/internal/media_device.h\"\n+\n+/**\n+ * \\file internal/converter.h\n+ * \\brief Abstract converter\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(Converter)\n+\n+/**\n+ * \\class Converter\n+ * \\brief Abstract Base Class for converter\n+ *\n+ * The Converter class is an Abstract Base Class defining the interfaces of\n+ * converter implementations.\n+ *\n+ * Converters offer scaling and pixel format conversion services on a input\n+ * stream. The converter can output multiple streams with individual conversion\n+ * parameters from the same input stream.\n+ */\n+\n+/**\n+ * \\brief Construct a Converter instance\n+ * \\param[in] media The media device implementing the converter\n+ *\n+ * This seeks for the entity implementing data streaming function in the media\n+ * graph entities and use its device node as converter device node.\n+ */\n+Converter::Converter(MediaDevice *media)\n+{\n+\tconst std::vector<MediaEntity *> &entities = media->entities();\n+\tauto it = std::find_if(entities.begin(), entities.end(),\n+\t\t\t [](MediaEntity *entity) {\n+\t\t\t\t return entity->function() == MEDIA_ENT_F_IO_V4L;\n+\t\t\t });\n+\tif (it == entities.end()) {\n+\t\tLOG(Converter, Error)\n+\t\t\t<< \"No entity suitable for implementing a converter in \"\n+\t\t\t<< media->driver() << \" entities list.\";\n+\t\treturn;\n+\t}\n+\n+\tdeviceNode_ = (*it)->deviceNode();\n+}\n+\n+Converter::~Converter()\n+{\n+}\n+\n+/**\n+ * \\fn Converter::loadConfiguration()\n+ * \\brief Load converter configuration from file\n+ * \\param[in] filename The file name path\n+ *\n+ * Load converter dependent configuration parameters to apply on the hardware.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+\n+/**\n+ * \\fn Converter::isValid()\n+ * \\brief Check if the converter configuration is valid\n+ * \\return True is the converter is valid, false otherwise\n+ */\n+\n+/**\n+ * \\fn Converter::formats()\n+ * \\brief Retrieve the list of supported pixel formats for an input pixel format\n+ * \\param[in] input Input pixel format to retrieve output pixel format list for\n+ * \\return The list of supported output pixel formats\n+ */\n+\n+/**\n+ * \\fn Converter::sizes()\n+ * \\brief Retrieve the range of minimum and maximum output sizes for an input size\n+ * \\param[in] input Input stream size to retrieve range for\n+ * \\return A range of output image sizes\n+ */\n+\n+/**\n+ * \\fn Converter::strideAndFrameSize()\n+ * \\brief Retrieve the output stride and frame size for an input configutation\n+ * \\param[in] pixelFormat Input stream pixel format\n+ * \\param[in] size Input stream size\n+ * \\return A tuple indicating the stride and frame size or an empty tuple on error\n+ */\n+\n+/**\n+ * \\fn Converter::configure()\n+ * \\brief Configure a set of output stream conversion from an input stream\n+ * \\param[in] inputCfg Input stream configuration\n+ * \\param[out] outputCfgs A list of output stream configurations\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+\n+/**\n+ * \\fn Converter::exportBuffers()\n+ * \\brief Export buffers from the converter device\n+ * \\param[in] output Output stream index exporting the buffers\n+ * \\param[in] count Number of buffers to allocate\n+ * \\param[out] buffers Vector to store allocated buffers\n+ *\n+ * This function operates similarly as V4L2VideoDevice::exportBuffers() on the\n+ * output stream indicated by the \\a output index.\n+ *\n+ * \\return The number of allocated buffers on success or a negative error code\n+ * otherwise\n+ */\n+\n+/**\n+ * \\fn Converter::start()\n+ * \\brief Start the converter streaming operation\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+\n+/**\n+ * \\fn Converter::stop()\n+ * \\brief Stop the converter streaming operation\n+ */\n+\n+/**\n+ * \\fn Converter::queueBuffers()\n+ * \\brief Queue buffers to converter device\n+ * \\param[in] input The frame buffer to apply the conversion\n+ * \\param[out] outputs The container holding the output stream indexes and\n+ * their respective frame buffer outputs.\n+ *\n+ * This function queues the \\a input frame buffer on the output streams of the\n+ * \\a outputs map key and retrieve the output frame buffer indicated by the\n+ * buffer map value.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+\n+/**\n+ * \\var Converter::inputBufferReady\n+ * \\brief A signal emitted when the input frame buffer completes\n+ */\n+\n+/**\n+ * \\var Converter::outputBufferReady\n+ * \\brief A signal emitted when the output frame buffer completes\n+ */\n+\n+/**\n+ * \\fn Converter::deviceNode()\n+ * \\brief The converter device node attribute accessor\n+ * \\return The converter device node string\n+ */\n+\n+/**\n+ * \\class ConverterFactoryBase\n+ * \\brief Base class for converter factories\n+ *\n+ * The ConverterFactoryBase class is the base of all specializations of the\n+ * ConverterFactory class template. It implements the factory registration,\n+ * maintains a registry of factories, and provides access to the registered\n+ * factories.\n+ */\n+\n+/**\n+ * \\brief Construct a converter factory base\n+ * \\param[in] name Name of the converter class\n+ * \\param[in] aliases Name aliases of the converter class\n+ *\n+ * Creating an instance of the factory base registers it with the global list of\n+ * factories, accessible through the factories() function.\n+ *\n+ * The factory \\a name is used as unique identifier. If the converter\n+ * implementation fully relies on a generic framework, the name should be the\n+ * same as the framework. Otherwise, if the implementation is specialized, the\n+ * factory name should match the driver name implementing the function.\n+ *\n+ * The factory \\a aliases holds a list of driver names implementing a generic\n+ * subsystem without any personalizations.\n+ */\n+ConverterFactoryBase::ConverterFactoryBase(const std::string name, std::initializer_list<std::string> aliases)\n+\t: name_(name), aliases_(aliases)\n+{\n+\tregisterType(this);\n+}\n+\n+/**\n+ * \\fn ConverterFactoryBase::aliases()\n+ * \\return The names aliases\n+ */\n+\n+/**\n+ * \\brief Create an instance of the converter corresponding to a named factory\n+ * \\param[in] media Name of the factory\n+ *\n+ * \\return A unique pointer to a new instance of the converter subclass\n+ * corresponding to the named factory or one of its alias. Otherwise a null\n+ * pointer if no such factory exists\n+ */\n+std::unique_ptr<Converter> ConverterFactoryBase::create(MediaDevice *media)\n+{\n+\tconst std::vector<ConverterFactoryBase *> &factories =\n+\t\tConverterFactoryBase::factories();\n+\n+\tfor (const ConverterFactoryBase *factory : factories) {\n+\t\tconst std::vector<std::string> &aliases = factory->aliases();\n+\t\tauto it = std::find(aliases.begin(), aliases.end(), media->driver());\n+\n+\t\tif (it == aliases.end() && media->driver() != factory->name_)\n+\t\t\tcontinue;\n+\n+\t\tLOG(Converter, Debug)\n+\t\t\t<< \"Creating converter from \"\n+\t\t\t<< factory->name_ << \" factory with \"\n+\t\t\t<< (it == aliases.end() ? \"no\" : media->driver()) << \" alias.\";\n+\n+\t\treturn factory->createInstance(media);\n+\t}\n+\n+\treturn nullptr;\n+}\n+\n+/**\n+ * \\brief Add a converter class to the registry\n+ * \\param[in] factory Factory to use to construct the converter class\n+ *\n+ * The caller is responsible to guarantee the uniqueness of the converter name.\n+ */\n+void ConverterFactoryBase::registerType(ConverterFactoryBase *factory)\n+{\n+\tstd::vector<ConverterFactoryBase *> &factories =\n+\t\tConverterFactoryBase::factories();\n+\n+\tfactories.push_back(factory);\n+}\n+\n+/**\n+ * \\brief Retrieve the list of all converter factory names\n+ * \\return The list of all converter factory names\n+ */\n+std::vector<std::string> ConverterFactoryBase::names()\n+{\n+\tstd::vector<std::string> list;\n+\n+\tstd::vector<ConverterFactoryBase *> &factories =\n+\t\tConverterFactoryBase::factories();\n+\n+\tfor (ConverterFactoryBase *factory : factories) {\n+\t\tlist.push_back(factory->name_);\n+\t\tfor (auto alias : factory->aliases())\n+\t\t\tlist.push_back(alias);\n+\t}\n+\n+\treturn list;\n+}\n+\n+/**\n+ * \\brief Retrieve the list of all converter factories\n+ * \\return The list of converter factories\n+ */\n+std::vector<ConverterFactoryBase *> &ConverterFactoryBase::factories()\n+{\n+\t/*\n+\t * The static factories map is defined inside the function to ensure\n+\t * it gets initialized on first use, without any dependency on link\n+\t * order.\n+\t */\n+\tstatic std::vector<ConverterFactoryBase *> factories;\n+\treturn factories;\n+}\n+\n+/**\n+ * \\var ConverterFactoryBase::name_\n+ * \\brief The name of the factory\n+ */\n+\n+/**\n+ * \\var ConverterFactoryBase::aliases_\n+ * \\brief The list holding the factory aliases\n+ */\n+\n+/**\n+ * \\class ConverterFactory\n+ * \\brief Registration of ConverterFactory classes and creation of instances\n+ * \\param _Converter The converter class type for this factory\n+ *\n+ * To facilitate discovery and instantiation of Converter classes, the\n+ * ConverterFactory class implements auto-registration of converter helpers.\n+ * Each Converter subclass shall register itself using the REGISTER_CONVERTER()\n+ * macro, which will create a corresponding instance of a ConverterFactory\n+ * subclass and register it with the static list of factories.\n+ */\n+\n+/**\n+ * \\fn ConverterFactory::ConverterFactory(const char *name, std::initializer_list<std::string> aliases)\n+ * \\brief Construct a converter factory\n+ * \\details \\copydetails ConverterFactoryBase::ConverterFactoryBase\n+ *\n+ */\n+\n+/**\n+ * \\fn ConverterFactory::createInstance() const\n+ * \\brief Create an instance of the Converter corresponding to the factory\n+ * \\param[in] media Media device pointer\n+ * \\return A unique pointer to a newly constructed instance of the Converter\n+ * subclass corresponding to the factory\n+ */\n+\n+/**\n+ * \\def REGISTER_CONVERTER\n+ * \\brief Register a converter with the Converter factory\n+ * \\param[in] name Converter name used to register the class\n+ * \\param[in] converter Class name of Converter derived class to register\n+ * \\param[in] ... Optional list of alias names\n+ *\n+ * Register a Converter subclass with the factory and make it available to try\n+ * and match converters.\n+ */\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 0494e808..e9d0324e 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -13,6 +13,7 @@ libcamera_sources = files([\n 'controls.cpp',\n 'control_serializer.cpp',\n 'control_validator.cpp',\n+ 'converter.cpp',\n 'delayed_controls.cpp',\n 'device_enumerator.cpp',\n 'device_enumerator_sysfs.cpp',\n", "prefixes": [ "libcamera-devel", "v3", "1/2" ] }