Show a patch.

GET /api/1.1/patches/22951/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22951,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/22951/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22951/",
    "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": "<20250314174200.1015493-1-barnabas.pocze@ideasonboard.com>",
    "date": "2025-03-14T17:42:00",
    "name": "[v1] libcamera: pipeline: Put single file pipelines into anonymous namespace",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "280eeb911a04c7e25c8b87272d99e2216c9d007d",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/1.1/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22951/mbox/",
    "series": [
        {
            "id": 5059,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5059/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5059",
            "date": "2025-03-14T17:42:00",
            "name": "[v1] libcamera: pipeline: Put single file pipelines into anonymous namespace",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5059/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22951/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22951/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 4CA7DC32F4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Mar 2025 17:42:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C7A768946;\n\tFri, 14 Mar 2025 18:42:06 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61EAF6052C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Mar 2025 18:42:04 +0100 (CET)",
            "from pb-laptop.local (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B2B94606\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Mar 2025 18:40:24 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VCH2mF8a\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1741974024;\n\tbh=muc1kjJnODsd8yucuJin1V/mFBxQ980w2HUIjsuJy6E=;\n\th=From:To:Subject:Date:From;\n\tb=VCH2mF8a3wMYuTd8G0W2OQD6XdgDzJMpU+AndaUp0nEBncqtlGRcLbIy5YLTb58bi\n\t8TngANiffkOFjy0V3qHw6Kb+0zjj1hwZ1YW0TkWq9S5BkI+G1WvmrBurbS6tSF/Gez\n\timoEo75V6NKwKPB/pbkdqV9KgWobonqTXl1YeWMA=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v1] libcamera: pipeline: Put single file pipelines into\n\tanonymous namespace",
        "Date": "Fri, 14 Mar 2025 18:42:00 +0100",
        "Message-ID": "<20250314174200.1015493-1-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.48.1",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "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": "Putting a symbol into an anonymous namespace gives its internal linkage.\nThis is useful for a couple reasons:\n  * the compiler can do more optimizations (e.g. inlining);\n  * fewer symbols are exported from the DSO;\n  * unused symbols can be better diagnosed.\n\nFor example, as it turns out, `PipelineHandlerMaliC55::applyScalerCrop()`\nis not actually used, which was not diagnosed previously.\n\nSimilarly, `ISICameraData::pipe()` is also not used, it is removed.\n\nThis could be done with the other pipeline handlers, but is not done,\ndue to the issues caused by the log category symbols and to avoid\ninconsistencies where half of a pipeline handler is in one namespace\nwhile the other half is somewhere else.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/pipeline/imx8-isi/imx8-isi.cpp |  13 +--\n src/libcamera/pipeline/mali-c55/mali-c55.cpp | 104 +------------------\n src/libcamera/pipeline/simple/simple.cpp     |   6 +-\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp |   6 +-\n src/libcamera/pipeline/vimc/vimc.cpp         |   6 +-\n 5 files changed, 20 insertions(+), 115 deletions(-)\n\n--\n2.48.1",
    "diff": "diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\nindex 4e66b3368..421328536 100644\n--- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n+++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n@@ -31,7 +31,9 @@\n\n #include \"linux/media-bus-format.h\"\n\n-namespace libcamera {\n+namespace {\n+\n+using namespace libcamera;\n\n LOG_DEFINE_CATEGORY(ISI)\n\n@@ -50,8 +52,6 @@ public:\n \t\tstreams_.resize(2);\n \t}\n\n-\tPipelineHandlerISI *pipe();\n-\n \tint init();\n\n \tunsigned int pipeIndex(const Stream *stream)\n@@ -149,11 +149,6 @@ private:\n  * Camera Data\n  */\n\n-PipelineHandlerISI *ISICameraData::pipe()\n-{\n-\treturn static_cast<PipelineHandlerISI *>(Camera::Private::pipe());\n-}\n-\n /* Open and initialize pipe components. */\n int ISICameraData::init()\n {\n@@ -1113,4 +1108,4 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer)\n\n REGISTER_PIPELINE_HANDLER(PipelineHandlerISI, \"imx8-isi\")\n\n-} /* namespace libcamera */\n+} /* namespace */\ndiff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\nindex a05e11fcc..17cae9b96 100644\n--- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n+++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n@@ -52,7 +52,9 @@ bool isFormatRaw(const libcamera::PixelFormat &pixFmt)\n\n } /* namespace */\n\n-namespace libcamera {\n+namespace {\n+\n+using namespace libcamera;\n\n LOG_DEFINE_CATEGORY(MaliC55)\n\n@@ -677,8 +679,6 @@ private:\n \t\t\t\t     const StreamConfiguration &config,\n \t\t\t\t     V4L2SubdeviceFormat &subdevFormat);\n\n-\tvoid applyScalerCrop(Camera *camera, const ControlList &controls);\n-\n \tbool registerMaliCamera(std::unique_ptr<MaliC55CameraData> data,\n \t\t\t\tconst std::string &name);\n \tbool registerTPGCamera(MediaLink *link);\n@@ -1270,102 +1270,6 @@ void PipelineHandlerMaliC55::stopDevice(Camera *camera)\n \tfreeBuffers(camera);\n }\n\n-void PipelineHandlerMaliC55::applyScalerCrop(Camera *camera,\n-\t\t\t\t\t     const ControlList &controls)\n-{\n-\tMaliC55CameraData *data = cameraData(camera);\n-\n-\tconst auto &scalerCrop = controls.get<Rectangle>(controls::ScalerCrop);\n-\tif (!scalerCrop)\n-\t\treturn;\n-\n-\tif (!data->sensor_) {\n-\t\tLOG(MaliC55, Error) << \"ScalerCrop not supported for TPG\";\n-\t\treturn;\n-\t}\n-\n-\tRectangle nativeCrop = *scalerCrop;\n-\n-\tIPACameraSensorInfo sensorInfo;\n-\tint ret = data->sensor_->sensorInfo(&sensorInfo);\n-\tif (ret) {\n-\t\tLOG(MaliC55, Error) << \"Failed to retrieve sensor info\";\n-\t\treturn;\n-\t}\n-\n-\t/*\n-\t * The ScalerCrop rectangle re-scaling in the ISP crop rectangle\n-\t * comes straight from the RPi pipeline handler.\n-\t *\n-\t * Create a version of the crop rectangle aligned to the analogue crop\n-\t * rectangle top-left coordinates and scaled in the [analogue crop to\n-\t * output frame] ratio to take into account binning/skipping on the\n-\t * sensor.\n-\t */\n-\tRectangle ispCrop = nativeCrop.translatedBy(-sensorInfo.analogCrop\n-\t\t\t\t\t\t\t       .topLeft());\n-\tispCrop.scaleBy(sensorInfo.outputSize, sensorInfo.analogCrop.size());\n-\n-\t/*\n-\t * The crop rectangle should be:\n-\t * 1. At least as big as ispMinCropSize_, once that's been\n-\t *    enlarged to the same aspect ratio.\n-\t * 2. With the same mid-point, if possible.\n-\t * 3. But it can't go outside the sensor area.\n-\t */\n-\tRectangle ispMinCrop{ 0, 0, 640, 480 };\n-\tSize minSize = ispMinCrop.size().expandedToAspectRatio(nativeCrop.size());\n-\tSize size = ispCrop.size().expandedTo(minSize);\n-\tispCrop = size.centeredTo(ispCrop.center())\n-\t\t      .enclosedIn(Rectangle(sensorInfo.outputSize));\n-\n-\t/*\n-\t * As the resizer can't upscale, the crop rectangle has to be larger\n-\t * than the larger stream output size.\n-\t */\n-\tSize maxYuvSize;\n-\tfor (MaliC55Pipe &pipe : pipes_) {\n-\t\tif (!pipe.stream)\n-\t\t\tcontinue;\n-\n-\t\tconst StreamConfiguration &config = pipe.stream->configuration();\n-\t\tif (isFormatRaw(config.pixelFormat)) {\n-\t\t\tLOG(MaliC55, Debug) << \"Cannot crop with a RAW stream\";\n-\t\t\treturn;\n-\t\t}\n-\n-\t\tSize streamSize = config.size;\n-\t\tif (streamSize.width > maxYuvSize.width)\n-\t\t\tmaxYuvSize.width = streamSize.width;\n-\t\tif (streamSize.height > maxYuvSize.height)\n-\t\t\tmaxYuvSize.height = streamSize.height;\n-\t}\n-\n-\tispCrop.size().expandTo(maxYuvSize);\n-\n-\t/*\n-\t * Now apply the scaler crop to each enabled output. This overrides the\n-\t * crop configuration performed at configure() time and can cause\n-\t * square pixels if the crop rectangle and scaler output FOV ratio are\n-\t * different.\n-\t */\n-\tfor (MaliC55Pipe &pipe : pipes_) {\n-\t\tif (!pipe.stream)\n-\t\t\tcontinue;\n-\n-\t\t/* Create a copy to avoid setSelection() to modify ispCrop. */\n-\t\tRectangle pipeCrop = ispCrop;\n-\t\tret = pipe.resizer->setSelection(0, V4L2_SEL_TGT_CROP, &pipeCrop);\n-\t\tif (ret) {\n-\t\t\tLOG(MaliC55, Error)\n-\t\t\t\t<< \"Failed to apply crop to \"\n-\t\t\t\t<< (pipe.stream == &data->frStream_ ?\n-\t\t\t\t    \"FR\" : \"DS\") << \" pipe\";\n-\t\t\treturn;\n-\t\t}\n-\t}\n-}\n-\n int PipelineHandlerMaliC55::queueRequestDevice(Camera *camera, Request *request)\n {\n \tMaliC55CameraData *data = cameraData(camera);\n@@ -1752,4 +1656,4 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n\n REGISTER_PIPELINE_HANDLER(PipelineHandlerMaliC55, \"mali-c55\")\n\n-} /* namespace libcamera */\n+} /* namespace */\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 6e039bf35..4d9943d61 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -41,7 +41,9 @@\n #include \"libcamera/internal/v4l2_subdevice.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n\n-namespace libcamera {\n+namespace {\n+\n+using namespace libcamera;\n\n LOG_DEFINE_CATEGORY(SimplePipeline)\n\n@@ -1751,4 +1753,4 @@ void SimplePipelineHandler::releasePipeline(SimpleCameraData *data)\n\n REGISTER_PIPELINE_HANDLER(SimplePipelineHandler, \"simple\")\n\n-} /* namespace libcamera */\n+} /* namespace */\ndiff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 7470b5627..dedcac89b 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -32,7 +32,9 @@\n #include \"libcamera/internal/sysfs.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n\n-namespace libcamera {\n+namespace {\n+\n+using namespace libcamera;\n\n LOG_DEFINE_CATEGORY(UVC)\n\n@@ -804,4 +806,4 @@ void UVCCameraData::imageBufferReady(FrameBuffer *buffer)\n\n REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC, \"uvcvideo\")\n\n-} /* namespace libcamera */\n+} /* namespace */\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex 07273bd2b..f86ee5206 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -42,7 +42,9 @@\n #include \"libcamera/internal/v4l2_subdevice.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n\n-namespace libcamera {\n+namespace {\n+\n+using namespace libcamera;\n\n LOG_DEFINE_CATEGORY(VIMC)\n\n@@ -646,4 +648,4 @@ void VimcCameraData::paramsComputed([[maybe_unused]] unsigned int id,\n\n REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc, \"vimc\")\n\n-} /* namespace libcamera */\n+} /* namespace */\n",
    "prefixes": [
        "v1"
    ]
}