Show a patch.

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

{
    "id": 3654,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3654/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3654/",
    "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": "<20200501152745.437777-4-niklas.soderlund@ragnatech.se>",
    "date": "2020-05-01T15:27:45",
    "name": "[libcamera-devel,v2,3/3] qcam: Add RAW capture support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "0aff54895285d13234dd481a4a222df4f4be5928",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3654/mbox/",
    "series": [
        {
            "id": 867,
            "url": "https://patchwork.libcamera.org/api/1.1/series/867/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=867",
            "date": "2020-05-01T15:27:42",
            "name": "qcam: Add RAW capture support",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/867/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3654/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3654/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D8ED603F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 May 2020 17:28:07 +0200 (CEST)",
            "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 5a83473f-8bc0-11ea-aeed-005056917f90;\n\tFri, 01 May 2020 17:28:05 +0200 (CEST)"
        ],
        "X-Halon-ID": "5a83473f-8bc0-11ea-aeed-005056917f90",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  1 May 2020 17:27:45 +0200",
        "Message-Id": "<20200501152745.437777-4-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.26.2",
        "In-Reply-To": "<20200501152745.437777-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200501152745.437777-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 3/3] qcam: Add RAW capture support",
        "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>",
        "X-List-Received-Date": "Fri, 01 May 2020 15:28:07 -0000"
    },
    "content": "Add a toolbar button that captures RAW data to disk. The button is only\nenabled if the camera is configured to provide a raw stream to the\napplication.\n\nOnly when the capture action is triggered will a request with a raw\nbuffer be queued to the camera.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/qcam/assets/feathericons/feathericons.qrc |  1 +\n src/qcam/main_window.cpp                      | 40 ++++++++++++++++++-\n src/qcam/main_window.h                        |  6 +++\n 3 files changed, 46 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/qcam/assets/feathericons/feathericons.qrc b/src/qcam/assets/feathericons/feathericons.qrc\nindex c4eb7a0be6884373..fc8213928ece70ea 100644\n--- a/src/qcam/assets/feathericons/feathericons.qrc\n+++ b/src/qcam/assets/feathericons/feathericons.qrc\n@@ -1,5 +1,6 @@\n <!DOCTYPE RCC><RCC version=\"1.0\">\n <qresource>\n+<file>./aperture.svg</file>\n <file>./camera-off.svg</file>\n <file>./play-circle.svg</file>\n <file>./save.svg</file>\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex dc8824dae4669a7e..1c9948b98a231e05 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -48,7 +48,8 @@ public:\n };\n \n MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n-\t: options_(options), cm_(cm), allocator_(nullptr), isCapturing_(false)\n+\t: options_(options), cm_(cm), allocator_(nullptr), isCapturing_(false),\n+\t  captureRaw_(false)\n {\n \tint ret;\n \n@@ -144,6 +145,14 @@ int MainWindow::createToolbars()\n \taction->setShortcut(QKeySequence::SaveAs);\n \tconnect(action, &QAction::triggered, this, &MainWindow::saveImageAs);\n \n+\t/* Save Raw action. */\n+\taction = toolbar_->addAction(QIcon::fromTheme(\"camera-photo\",\n+\t\t\t\t\t\t      QIcon(\":aperture.svg\")),\n+\t\t\t\t     \"Save Raw\");\n+\taction->setEnabled(false);\n+\tconnect(action, &QAction::triggered, this, &MainWindow::saveRaw);\n+\tsaveRaw_ = action;\n+\n \treturn 0;\n }\n \n@@ -369,6 +378,9 @@ int MainWindow::startCapture()\n \n \tadjustSize();\n \n+\t/* Configure the raw capture button. */\n+\tsaveRaw_->setEnabled(config_->size() == 2);\n+\n \t/* Allocate and map buffers. */\n \tallocator_ = new FrameBufferAllocator(camera_);\n \tfor (StreamConfiguration &config : *config_) {\n@@ -474,6 +486,7 @@ void MainWindow::stopCapture()\n \t\treturn;\n \n \tviewfinder_->stop();\n+\tsaveRaw_->setEnabled(false);\n \n \tint ret = camera_->stop();\n \tif (ret)\n@@ -524,6 +537,11 @@ void MainWindow::saveImageAs()\n \twriter.write(image);\n }\n \n+void MainWindow::saveRaw()\n+{\n+\tcaptureRaw_ = true;\n+}\n+\n /* -----------------------------------------------------------------------------\n  * Request Completion Handling\n  */\n@@ -567,6 +585,9 @@ void MainWindow::processCapture()\n \tif (buffers.count(vfStream_))\n \t\tprocessViewfinder(buffers[vfStream_]);\n \n+\tif (buffers.count(rawStream_))\n+\t\tprocessRaw(buffers[rawStream_]);\n+\n \t/*\n \t * Return buffers so they can be reused. No processing involving\n \t * a buffer can happen after they are returned to the free list.\n@@ -603,6 +624,13 @@ void MainWindow::processViewfinder(FrameBuffer *buffer)\n \tviewfinder_->render(buffer, &mappedBuffers_[buffer]);\n }\n \n+void MainWindow::processRaw(FrameBuffer *buffer)\n+{\n+\tconst MappedBuffer &mapped = mappedBuffers_[buffer];\n+\n+\tdngWriter_.write(camera_.get(), rawStream_, buffer, mapped.memory);\n+}\n+\n void MainWindow::queueRequest(FrameBuffer *buffer)\n {\n \tRequest *request = camera_->createRequest();\n@@ -613,5 +641,15 @@ void MainWindow::queueRequest(FrameBuffer *buffer)\n \n \trequest->addBuffer(vfStream_, buffer);\n \n+\tif (captureRaw_) {\n+\t\tQMutexLocker locker(&mutex_);\n+\n+\t\tif (!freeBuffers_[rawStream_].isEmpty()) {\n+\t\t\trequest->addBuffer(rawStream_,\n+\t\t\t\t\t   freeBuffers_[rawStream_].dequeue());\n+\t\t\tcaptureRaw_ = false;\n+\t\t}\n+\t}\n+\n \tcamera_->queueRequest(request);\n }\ndiff --git a/src/qcam/main_window.h b/src/qcam/main_window.h\nindex 4856ecc10729159c..068eb2e38277768e 100644\n--- a/src/qcam/main_window.h\n+++ b/src/qcam/main_window.h\n@@ -24,6 +24,7 @@\n #include <libcamera/stream.h>\n \n #include \"../cam/stream_options.h\"\n+#include \"dng_writer.h\"\n #include \"viewfinder.h\"\n \n using namespace libcamera;\n@@ -55,6 +56,7 @@ private Q_SLOTS:\n \tvoid toggleCapture(bool start);\n \n \tvoid saveImageAs();\n+\tvoid saveRaw();\n \n \tvoid queueRequest(FrameBuffer *buffer);\n \n@@ -70,11 +72,13 @@ private:\n \tvoid requestComplete(Request *request);\n \tvoid processCapture();\n \tvoid processViewfinder(FrameBuffer *buffer);\n+\tvoid processRaw(FrameBuffer *buffer);\n \n \t/* UI elements */\n \tQToolBar *toolbar_;\n \tQAction *startStopAction_;\n \tQComboBox *cameraCombo_;\n+\tQAction *saveRaw_;\n \tViewFinder *viewfinder_;\n \n \tQIcon iconPlay_;\n@@ -96,11 +100,13 @@ private:\n \n \t/* Capture state, buffers queue and statistics */\n \tbool isCapturing_;\n+\tbool captureRaw_;\n \tStream *vfStream_;\n \tStream *rawStream_;\n \tstd::map<Stream *, QQueue<FrameBuffer *>> freeBuffers_;\n \tQQueue<std::map<Stream *, FrameBuffer *>> doneQueue_;\n \tQMutex mutex_; /* Protects freeBuffers_ and doneQueue_ */\n+\tDNGWriter dngWriter_;\n \n \tuint64_t lastBufferTime_;\n \tQElapsedTimer frameRateInterval_;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "3/3"
    ]
}