Show a patch.

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

{
    "id": 19312,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19312/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19312/",
    "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": "<20231212115046.102726-8-andrey.konovalov@linaro.org>",
    "date": "2023-12-12T11:50:46",
    "name": "[libcamera-devel,RFC,v2,7/7] libcamera: pipeline: simple: enable use of Soft ISP and Soft IPA",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8734437749f35ce32ecf7b47858d59ac28fd8c4c",
    "submitter": {
        "id": 25,
        "url": "https://patchwork.libcamera.org/api/1.1/people/25/?format=api",
        "name": "Andrey Konovalov",
        "email": "andrey.konovalov@linaro.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19312/mbox/",
    "series": [
        {
            "id": 4114,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4114/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4114",
            "date": "2023-12-12T11:50:39",
            "name": "libcamera: introduce Software ISP and Software IPA",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4114/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19312/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19312/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 ED333BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 Dec 2023 11:51:33 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9871462B33;\n\tTue, 12 Dec 2023 12:51:33 +0100 (CET)",
            "from mail-ej1-x635.google.com (mail-ej1-x635.google.com\n\t[IPv6:2a00:1450:4864:20::635])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 70BEE62B2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Dec 2023 12:51:31 +0100 (CET)",
            "by mail-ej1-x635.google.com with SMTP id\n\ta640c23a62f3a-a1da1017a09so676275566b.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Dec 2023 03:51:31 -0800 (PST)",
            "from Lat-5310.. ([87.116.161.153]) by smtp.gmail.com with ESMTPSA\n\tid\n\ttx17-20020a1709078e9100b00a1b75e0e061sm6213188ejc.130.2023.12.12.03.51.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 12 Dec 2023 03:51:29 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702381893;\n\tbh=2+oVwBiLoDG1CDdrv0bdoRdovwtqIl7Ba33ZLynjJBQ=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=yfxoTOwL6wtnVYF5uFsmnTyWz+0W7lYlm3ff8nb8piIrtodd+kWOdBxuko3FMnEnb\n\twfVOvxeJTybLuHAX+Vs6w8ykmXhWYHvnpMRHh09fWPH1Hfd6BFui/BxhGfCYNX/8Hy\n\tp9Jo+FrSSHBt6DP+ROMy5e4ctaYNxq3Arnb4zguLDTPH++3LQCDJsGerrxZmfI//cF\n\tLz1/HQytZLekMi8BuZvnaqe3hyjh8OOKuwcUQxaVjWZ+8rYWumUJ5iPIqMm/8OjBm2\n\tBJXyXd4hGmRWfC2gxS6xhmg9dvCGq2fKkI3ri0g3oufWsqLvivpDE45cg3hMRexRrT\n\tTGe9bEyBbBIgQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1702381891; x=1702986691;\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=DOT0/3W2904w/yNWAzyag1CLj3C5QSiWMpVEzLHWH2Q=;\n\tb=T9UiCMrjzG1aJcOOJAjvP5wOHE5x4K56eA/qs9e5rZe7nNcIsRSTBVjV2uSHbZOqc3\n\trxF4glrti8EtNiSq3LZX+zHmj1rcG8cN56IoxEj+fupSq9jzq7rBu4bAqjXmvKzMug/c\n\tcg3mWJaZDtFqXAf1vUapYnakro42npZJ1G2xtuQYUrZ15vWEgFf5nZpXxBslEs47P49K\n\t+jnWeGkedFmHiX6PfMod8U25yfseJ8nhP/BszEaf+IX9j25rK0RT5XCKL9ZFF0h6E2gz\n\tJxgNCx77Nv+bxy4dWxXr24yrQvw3rtDrvrrguEHRCdb7TQVhk0xfDByNQEO8+vzZ5gVL\n\taRew=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=linaro.org\n\theader.i=@linaro.org header.b=\"T9UiCMrj\"; \n\tdkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1702381891; x=1702986691;\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=DOT0/3W2904w/yNWAzyag1CLj3C5QSiWMpVEzLHWH2Q=;\n\tb=Qk/jyHFgzC4NKua122wUCRTVyhvMd7sFIfQ2ZVhXQ9PZI227KBUfH0U//i+PWQGeRp\n\tSilC5c6X6+GwCo46QiDbn+NDzgyix3M2ifaXaF2Z65XPygOLdOlTJpwXy+7vyge7RpOy\n\t3PFqGJ8R9/p04OkIz4djeOAmkUFcrZbOGwmXwWzjPU9fp8hS88NRoDfi+wSoBgdV7fYK\n\tucBS8rzW6UlVecQJ0fdVQWDspMcAOrrOucESWKloC8gfMiyzaut2OHGm15EUj75jhQjR\n\tHJjN4PVM1FoDNofH6d0TEzP3Ww05kfLlG5B/A3NHZGYtspZ75XI+CJy6WnfvJxpTow/y\n\t4uAA==",
        "X-Gm-Message-State": "AOJu0YwLO/P8sL1VU+W5ti4uhEYwatW2FECCqWiyKsWVn1tX2qWDighI\n\t1s2JrLXNRPOLC2t78PcYOmGgdeDiScbTuZO0LUU=",
        "X-Google-Smtp-Source": "AGHT+IGe2oAaT+rnR+kYKUmHpjoF6xyDshVKL4aTIMMapCtQSCTSleeQF4RpzMjmRK8dUVdryUZZfQ==",
        "X-Received": "by 2002:a17:907:510:b0:a19:a19b:78a5 with SMTP id\n\twj16-20020a170907051000b00a19a19b78a5mr2699050ejb.104.1702381889790; \n\tTue, 12 Dec 2023 03:51:29 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 12 Dec 2023 14:50:46 +0300",
        "Message-Id": "<20231212115046.102726-8-andrey.konovalov@linaro.org>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20231212115046.102726-1-andrey.konovalov@linaro.org>",
        "References": "<20231212115046.102726-1-andrey.konovalov@linaro.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC PATCH v2 7/7] libcamera: pipeline: simple:\n\tenable use of Soft ISP and Soft IPA",
        "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": "Andrey Konovalov via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Andrey Konovalov <andrey.konovalov@linaro.org>",
        "Cc": "mripard@redhat.com, g.martti@gmail.com, t.langendam@gmail.com,\n\tsrinivas.kandagatla@linaro.org, pavel@ucw.cz,\n\tbryan.odonoghue@linaro.org, admin@dennisbonke.com",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "To enable the Soft ISP and Soft IPA for simple pipeline handler\nconfigure the build with:\n  -Dpipelines=simple/linaro -Dipas=simple/linaro\n\nIf the pipeline uses Converter, Soft ISP and Soft IPA aren't\navailable.\n\nConfiguring the build with just:\n  -Dpipelines=simple\nmakes it to work like before - Soft ISP and Soft IPA aren't used.\n\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n---\n src/libcamera/pipeline/simple/simple.cpp | 106 ++++++++++++++++++-----\n 1 file changed, 83 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 878794f6..276e9d72 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -34,10 +34,10 @@\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/media_device.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n+#include \"libcamera/internal/software_isp.h\"\n #include \"libcamera/internal/v4l2_subdevice.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n \n-\n namespace libcamera {\n \n LOG_DEFINE_CATEGORY(SimplePipeline)\n@@ -274,6 +274,7 @@ public:\n \tbool useConversion_;\n \n \tstd::unique_ptr<Converter> converter_;\n+\tstd::unique_ptr<SoftwareIsp> swIsp_;\n \n private:\n \tvoid tryPipeline(unsigned int code, const Size &size);\n@@ -281,6 +282,9 @@ private:\n \n \tvoid conversionInputDone(FrameBuffer *buffer);\n \tvoid conversionOutputDone(FrameBuffer *buffer);\n+\n+\tvoid ispStatsReady(int dummy);\n+\tvoid setSensorControls(const ControlList &sensorControls);\n };\n \n class SimpleCameraConfiguration : public CameraConfiguration\n@@ -509,6 +513,25 @@ int SimpleCameraData::init()\n \t\t}\n \t}\n \n+\t/*\n+\t * Create Linaro's implementation of SoftwareIsp unconditionally if no converter is used\n+\t * - to be revisited\n+\t */\n+\tif (!converter_) {\n+\t\tswIsp_ = SoftwareIspFactoryBase::create(pipe, sensor_->controls());\n+\t\tif (!swIsp_) {\n+\t\t\tLOG(SimplePipeline, Warning)\n+\t\t\t\t<< \"Failed to create software ISP, disabling software debayering\";\n+\t\t\tswIsp_.reset();\n+\t\t} else {\n+\t\t\tswIsp_->inputBufferReady.connect(this, &SimpleCameraData::conversionInputDone);\n+\t\t\tswIsp_->outputBufferReady.connect(this, &SimpleCameraData::conversionOutputDone);\n+\t\t\tswIsp_->ispStatsReady.connect(this, &SimpleCameraData::ispStatsReady);\n+\n+\t\t\tswIsp_->getSignalSetSensorControls().connect(this, &SimpleCameraData::setSensorControls);\n+\t\t}\n+\t}\n+\n \tvideo_ = pipe->video(entities_.back().entity);\n \tASSERT(video_);\n \n@@ -599,12 +622,15 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)\n \t\tconfig.captureFormat = pixelFormat;\n \t\tconfig.captureSize = format.size;\n \n-\t\tif (!converter_) {\n-\t\t\tconfig.outputFormats = { pixelFormat };\n-\t\t\tconfig.outputSizes = config.captureSize;\n-\t\t} else {\n+\t\tif (converter_) {\n \t\t\tconfig.outputFormats = converter_->formats(pixelFormat);\n \t\t\tconfig.outputSizes = converter_->sizes(format.size);\n+\t\t} else if (swIsp_) {\n+\t\t\tconfig.outputFormats = swIsp_->formats(pixelFormat);\n+\t\t\tconfig.outputSizes = swIsp_->sizes(pixelFormat, format.size);\n+\t\t} else {\n+\t\t\tconfig.outputFormats = { pixelFormat };\n+\t\t\tconfig.outputSizes = config.captureSize;\n \t\t}\n \n \t\tconfigs_.push_back(config);\n@@ -750,9 +776,9 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n \t\t}\n \n \t\t/*\n-\t\t * The converter is in use. Requeue the internal buffer for\n-\t\t * capture (unless the stream is being stopped), and complete\n-\t\t * the request with all the user-facing buffers.\n+\t\t * The converter or Software ISP is in use. Requeue the internal\n+\t\t * buffer for capture (unless the stream is being stopped), and\n+\t\t * complete the request with all the user-facing buffers.\n \t\t */\n \t\tif (buffer->metadata().status != FrameMetadata::FrameCancelled)\n \t\t\tvideo_->queueBuffer(buffer);\n@@ -798,9 +824,9 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n \t\t\t\t\tbuffer->metadata().timestamp);\n \n \t/*\n-\t * Queue the captured and the request buffer to the converter if format\n-\t * conversion is needed. If there's no queued request, just requeue the\n-\t * captured buffer for capture.\n+\t * Queue the captured and the request buffer to the converter or Software\n+\t * ISP if format conversion is needed. If there's no queued request, just\n+\t * requeue the captured buffer for capture.\n \t */\n \tif (useConversion_) {\n \t\tif (conversionQueue_.empty()) {\n@@ -808,7 +834,11 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n \t\t\treturn;\n \t\t}\n \n-\t\tconverter_->queueBuffers(buffer, conversionQueue_.front());\n+\t\tif (converter_)\n+\t\t\tconverter_->queueBuffers(buffer, conversionQueue_.front());\n+\t\telse\n+\t\t\tswIsp_->queueBuffers(buffer, conversionQueue_.front());\n+\n \t\tconversionQueue_.pop();\n \t\treturn;\n \t}\n@@ -834,6 +864,18 @@ void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer)\n \t\tpipe->completeRequest(request);\n }\n \n+void SimpleCameraData::ispStatsReady([[maybe_unused]] int dummy)\n+{\n+\tswIsp_->processStats(sensor_->getControls({ V4L2_CID_ANALOGUE_GAIN,\n+\t\t\t\t\t\t    V4L2_CID_EXPOSURE }));\n+}\n+\n+void SimpleCameraData::setSensorControls(const ControlList &sensorControls)\n+{\n+\tControlList ctrls(sensorControls);\n+\tsensor_->setControls(&ctrls);\n+}\n+\n /* Retrieve all source pads connected to a sink pad through active routes. */\n std::vector<const MediaPad *> SimpleCameraData::routedSourcePads(MediaPad *sink)\n {\n@@ -1013,8 +1055,10 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n \t\t/* Set the stride, frameSize and bufferCount. */\n \t\tif (needConversion_) {\n \t\t\tstd::tie(cfg.stride, cfg.frameSize) =\n-\t\t\t\tdata_->converter_->strideAndFrameSize(cfg.pixelFormat,\n-\t\t\t\t\t\t\t\t      cfg.size);\n+\t\t\t\t(data_->converter_) ? data_->converter_->strideAndFrameSize(cfg.pixelFormat,\n+\t\t\t\t\t\t\t\t\t\t\t    cfg.size)\n+\t\t\t\t\t\t    : data_->swIsp_->strideAndFrameSize(cfg.pixelFormat,\n+\t\t\t\t\t\t\t\t\t\t\tcfg.size);\n \t\t\tif (cfg.stride == 0)\n \t\t\t\treturn Invalid;\n \t\t} else {\n@@ -1177,7 +1221,8 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \tinputCfg.stride = captureFormat.planes[0].bpl;\n \tinputCfg.bufferCount = kNumInternalBuffers;\n \n-\treturn data->converter_->configure(inputCfg, outputCfgs);\n+\treturn (data->converter_) ? data->converter_->configure(inputCfg, outputCfgs)\n+\t\t\t\t  : data->swIsp_->configure(inputCfg, outputCfgs);\n }\n \n int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n@@ -1191,8 +1236,10 @@ int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n \t * whether the converter is used or not.\n \t */\n \tif (data->useConversion_)\n-\t\treturn data->converter_->exportBuffers(data->streamIndex(stream),\n-\t\t\t\t\t\t       count, buffers);\n+\t\treturn (data->converter_) ? data->converter_->exportBuffers(data->streamIndex(stream),\n+\t\t\t\t\t\t\t\t\t    count, buffers)\n+\t\t\t\t\t  : data->swIsp_->exportBuffers(data->streamIndex(stream),\n+\t\t\t\t\t\t\t\t\tcount, buffers);\n \telse\n \t\treturn data->video_->exportBuffers(count, buffers);\n }\n@@ -1237,10 +1284,18 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL\n \t}\n \n \tif (data->useConversion_) {\n-\t\tret = data->converter_->start();\n-\t\tif (ret < 0) {\n-\t\t\tstop(camera);\n-\t\t\treturn ret;\n+\t\tif (data->converter_) {\n+\t\t\tret = data->converter_->start();\n+\t\t\tif (ret < 0) {\n+\t\t\t\tstop(camera);\n+\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t} else if (data->swIsp_) {\n+\t\t\tret = data->swIsp_->start();\n+\t\t\tif (ret < 0) {\n+\t\t\t\tstop(camera);\n+\t\t\t\treturn ret;\n+\t\t\t}\n \t\t}\n \n \t\t/* Queue all internal buffers for capture. */\n@@ -1256,8 +1311,13 @@ void SimplePipelineHandler::stopDevice(Camera *camera)\n \tSimpleCameraData *data = cameraData(camera);\n \tV4L2VideoDevice *video = data->video_;\n \n-\tif (data->useConversion_)\n-\t\tdata->converter_->stop();\n+\tif (data->useConversion_) {\n+\t\tif (data->converter_)\n+\t\t\tdata->converter_->stop();\n+\t\telse if (data->swIsp_) {\n+\t\t\tdata->swIsp_->stop();\n+\t\t}\n+\t}\n \n \tvideo->streamOff();\n \tvideo->releaseBuffers();\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "v2",
        "7/7"
    ]
}