{"id":14668,"url":"https://patchwork.libcamera.org/api/covers/14668/?format=json","web_url":"https://patchwork.libcamera.org/cover/14668/","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":"<20211120111313.106621-1-jacopo@jmondi.org>","date":"2021-11-20T11:13:01","name":"[libcamera-devel,v2,00/12,WIP] libcamera: Add support for Fence","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/cover/14668/mbox/","series":[{"id":2739,"url":"https://patchwork.libcamera.org/api/series/2739/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2739","date":"2021-11-20T11:13:01","name":"libcamera: Add support for Fence","version":2,"mbox":"https://patchwork.libcamera.org/series/2739/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/14668/comments/","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 96D86BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 20 Nov 2021 11:12:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CD8A56032C;\n\tSat, 20 Nov 2021 12:12:23 +0100 (CET)","from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 747E26032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 20 Nov 2021 12:12:22 +0100 (CET)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id D6CF7100005;\n\tSat, 20 Nov 2021 11:12:21 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 20 Nov 2021 12:13:01 +0100","Message-Id":"<20211120111313.106621-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.33.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 00/12] [WIP] libcamera: Add support for\n\tFence","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":"Marked as WIP as I've not completed the documentation yet, as I wish to\nvalidate the API first. Also, I'm sure I've missed pieces here and there but I\nwant this out to discuss it before getting it into a mergeable state.\n\nReworked the API as suggested and discussed in v1.\n\nv1->v2:\n\nMajor changes:\n- removed notifiers and timers from Fence. A Fence is now an wrapper that owns\n  a file descriptor\n- Add timers and notifiers to Request::Private and add the\n  Request::Private::prepare interface\n\nSmaller changes:\n- Expand Request::Private to move all internal fields\n- Remove Fence move semantic. A Fence lives in a Framebuffer.\n- A few minor patches on top\n\nFence application API:\n\n1 unique_ptr<Fence> fence = make_unique<Fence>(FileDescriptor &fd);\n2 request->addBuffer(..., move(fence))\n3\tframeBuffer.set(fence)\n4 camera->queueRequest(request)\n5\tpipelineHandler.queueRequest()\n6 \t\trequest.prepare()\n7\t\trequest.prepared.emit()\n8\t\tpipelineHandler.doQueueRequest()\n9\t\t\tif (request.privateState.Ready())\n10\t\t\t\tdoQueueRequestDevice(request)\n11\t\t\telse\n12\t\t\t\trequest->cancel()\n13 requestCompleted()\n14\tif buffer.fence()\n15\t\tFileDescriptor fd = std::move(buffer.fence.fd())\n\nWhat I don't like\n\n- It's a clunky API\n\n\tFileDescriptor fenceFd = FileDescriptor(std::move(buffer.fence));\n\tstd::unique_ptr<Fence> fence = std::make_unique<Fence>(fenceFd);\n\tdescriptor->request_->addBuffer(cameraStream->stream(),\n\t\t\t\t\tframeBuffer, std::move(fence));\n\n- Fence creation with a FileDescriptor & does not enforce that the\n  FileDescriptor should not have duplicated the integer file descriptor\n\n- Fence constructor takes a FileDescriptor &, but moves the FileDescriptor\n  internally not to duplicate the fd. The FileDescriptor passed as reference is\n  invalidated but nothing in the API suggests so\n\n- Request::addBuffer() moves the Fence to the Framebuffer not to the request\n  even if the function prototype suggest differently\n\n- The API to extract the FileDescritptor from a completed request requires\n  the user to now that it has to move the FileDescritpro out, nothing suggest\n  that\n\n- Request now has Request::Private::Status and Request::Status\n\n- Fence are an empty wrapper around a FileDescriptor. That's ok-ish as it\n  allows to support more synchronization methods in future without changing the\n  API towards the Fence class users\n\n- Timeouts are per-request not per fence. If we need to have it per-fence the\n  core infrastructure need to be changed\n\nBuildbot https://buildbot.libcamera.org/#/builders/1/builds/54\n\nCTS:\n\n=======================================================\n=============== Summary ===============\nTotal Run time: 19m 58s\n1/1 modules completed\nTotal Tests       : 231\nPASSED            : 230\nFAILED            : 1\n============== End of Results ==============\n============================================\n\nThanks\n   j\n\nJacopo Mondi (11):\n  libcamera: fence: Introduce Fence\n  libcamera: framebuffer: private: Add Fence\n  libcamera: request: Add Fence to Request::addBuffer()\n  test: fence: Add test for the Fence class\n  libcamera: pipeline_handler: Split request queueing\n  libcamera: pipeline: Introduce stopDevice()\n  libcamera: request: Add Request::Private::prepare()\n  libcamera: pipeline_handler: Prepare Request\n  android: Remove CameraWorker\n  test: camera: Fix trivial spelling mistaken\n  libcamera: Add tracing to meson summary\n\nLaurent Pinchart (1):\n  libcamera: request: Make Request class Extensible\n\n include/libcamera/fence.h                     |  36 ++\n include/libcamera/framebuffer.h               |   3 +\n include/libcamera/internal/fence.h            |  37 ++\n include/libcamera/internal/framebuffer.h      |   9 +\n include/libcamera/internal/meson.build        |   2 +\n include/libcamera/internal/pipeline_handler.h |   9 +-\n include/libcamera/internal/request.h          |  72 +++\n .../libcamera/internal/tracepoints/request.tp |  18 +-\n include/libcamera/meson.build                 |   1 +\n include/libcamera/request.h                   |  22 +-\n meson.build                                   |   1 +\n src/android/camera_device.cpp                 |  43 +-\n src/android/camera_device.h                   |   3 -\n src/android/camera_request.cpp                |   3 +-\n src/android/camera_request.h                  |   3 +-\n src/android/camera_worker.cpp                 | 129 -----\n src/android/camera_worker.h                   |  72 ---\n src/android/meson.build                       |   1 -\n src/libcamera/fence.cpp                       | 104 ++++\n src/libcamera/framebuffer.cpp                 |  26 +\n src/libcamera/meson.build                     |   4 +\n src/libcamera/pipeline/ipu3/ipu3.cpp          |   4 +-\n .../pipeline/raspberrypi/raspberrypi.cpp      |   4 +-\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      |   4 +-\n src/libcamera/pipeline/simple/simple.cpp      |   4 +-\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |   4 +-\n src/libcamera/pipeline/vimc/vimc.cpp          |   4 +-\n src/libcamera/pipeline_handler.cpp            |  97 +++-\n src/libcamera/request.cpp                     | 462 ++++++++++++++----\n test/camera/capture.cpp                       |   2 +-\n test/fence.cpp                                | 339 +++++++++++++\n test/meson.build                              |   1 +\n 32 files changed, 1160 insertions(+), 363 deletions(-)\n create mode 100644 include/libcamera/fence.h\n create mode 100644 include/libcamera/internal/fence.h\n create mode 100644 include/libcamera/internal/request.h\n delete mode 100644 src/android/camera_worker.cpp\n delete mode 100644 src/android/camera_worker.h\n create mode 100644 src/libcamera/fence.cpp\n create mode 100644 test/fence.cpp\n\n--\n2.33.1"}