{"id":19869,"url":"https://patchwork.libcamera.org/api/covers/19869/?format=json","web_url":"https://patchwork.libcamera.org/cover/19869/","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":"<20240416091357.211951-1-mzamazal@redhat.com>","date":"2024-04-16T09:13:36","name":"[v8,00/18] libcamera: introduce Software ISP and Software IPA","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"mbox":"https://patchwork.libcamera.org/cover/19869/mbox/","series":[{"id":4257,"url":"https://patchwork.libcamera.org/api/series/4257/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4257","date":"2024-04-16T09:13:36","name":"libcamera: introduce Software ISP and Software IPA","version":8,"mbox":"https://patchwork.libcamera.org/series/4257/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/19869/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 CDD1DBE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Apr 2024 09:14:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 03E716333E;\n\tTue, 16 Apr 2024 11:14:18 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D2E061B4F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2024 11:14:15 +0200 (CEST)","from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n\t[66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-696-WxkjMX0vNCOdpWmoaZy2Eg-1; Tue, 16 Apr 2024 05:14:10 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3332D80B516;\n\tTue, 16 Apr 2024 09:14:10 +0000 (UTC)","from nuthatch.redhat.com (unknown [10.45.225.245])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 3CDFE2026D06;\n\tTue, 16 Apr 2024 09:14:08 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"IaXgalYM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1713258854;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=1zIRfDBXasIwOOKfOxQ1flC29ecmdB8p0Ro33kXQg0Y=;\n\tb=IaXgalYMuTkXdnjOzTkgciQyUG+1NSN48011vvRZ30dvhLO9M6OAx+8sUoRc23WwPWY/gc\n\tIIAJeehtVOAiK22V2lIWHqBgISWBSdp+gWazZyDy78h5ZXFMhQnJBva4IMi+e2RfBWebGb\n\tww6Yjqi1qbo/spA0VaWSTptCuUlhD2c=","X-MC-Unique":"WxkjMX0vNCOdpWmoaZy2Eg-1","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tAndrei Konovalov <andrey.konovalov.ynk@gmail.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMaxime Ripard <mripard@redhat.com>, Pavel Machek <pavel@ucw.cz>,\n\tHans de Goede <hdegoede@redhat.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"[PATCH v8 00/18] libcamera: introduce Software ISP and Software IPA","Date":"Tue, 16 Apr 2024 11:13:36 +0200","Message-ID":"<20240416091357.211951-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.11.54.4","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain; charset=\"US-ASCII\"; x-default=true","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":"Here is v8 of the patch-set to add Software ISP support\nto libcamera / to the simple pipeline-handler.\n\nChanges in v8 vs v7:\n- Doc fixes in dma_heaps.cpp.\n- SharedMemObject::size -> SharedMemObject::kSize\n  (+ commit message expanded as suggested by Kieran).\n- My commit messages limited to the line length of 72.\n- All commit messages capitalized\n  (for consistency both within the branch and with other libcamera\n  commits).\n- Using Span directly rather than defining SharedMem::span.\n- Minor code changes in shared_mem_object.cpp as suggested by Laurent.\n- Forgotten use of a type alias added in black_level.h\n  (+ the type name capitalized).\n- Rebased on current master.\n- The dummy parameter dropped from setIspParams.\n\ngit branch for this v8 patch set:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/SoftwareISP-v11\nCI pipeline:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/pipelines/1154685\n(The debian10 failure looks unrelated.)\n\nChanges in v7 vs v6:\nLaurent's comments addressed, most notably:\n* Formatting changes.\n* Docstrings moved from *.h to *.cpp files.\n* Improvements of docstrings.\n* Miscellaneous refactorings without changing the code itself.\n* Added src/libcamera/software_isp/TODO.\n* Variables renamed:\n  - DmaHeapFlag flag -> type\n  - DmaHeapInfo.name -> deviceNodeName\n  - generally renames to snakeCase where applicable\n* DmaHeap no longer officially prefers CMA heap.\n* SharedMem::mem_ is a Span now and private; size_ dropped.\n* SharedMemObject template is limited to standard layout objects now.\n* A more specific #include used in soft_simple.cpp.\n* DebayerCpu::setDebayerFunctions no longer uses goto.\n* The benchmarking document reformated to 80 columns.\n* CameraSensorHelper patch integrated into preceding patches.\n\ngit branch for this v7 patch set:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/SoftwareISP-v10\nCI pipeline:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/pipelines/1145462\n\nChanges in v6 vs v5:\n- [06/18] libcamera: software_isp: Add SwStatsCpu class\n  Resolved a rebase conflict in meson.build.\n- [16/18] libcamera: Add \"Software ISP benchmarking\"\n  Fixed a trivial typo (Stefan).\n- [17/18] libcamera: software_isp: Apply black level compensation\n  A comment style adjusted (Kieran).\n  A common value extracted into a variable.\n\ngit branch for this v6 patch set:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/SoftwareISP-v09\n\nChanges in v5 vs v4:\n- CI fully passes now!\n- Fix some small typos / using unnamed const values pointed\n  out in Milan's reviews\n\nSince there have been no significant review comments on v4\nand since this fully passes CI now I believe that this version\nis ready for merging.\n\ngit branch for this v5 patch set:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/SoftwareISP-v08-for-ci\n\nOlder changelogs and links to git branches:\n\nChanges in v4 vs v3:\n- Andrey:\n  [05/18] \"libcamera: shared_mem_object: reorganize the code and document the SharedMemObject class\"\n  - documentation fixes\n  [09/18] \"libcamera: ipa: add Soft IPA\"\n  - Use int32_t for again*_ and exposure*_ as this matches\n    the value the corresponding ControlValue::get() returns\n  - Check for mmap() returning MAP_FAILED on error\n  - Drop std::move() called on const SharedFD & argument\n  - Replace #defines (EXPOSURE_OPTIMAL_VALUE etc) with const expressions\n  - Use std::clamp() to keep exposure_ and again_ between the *_min_ and\n    the *_max_\n  - add comment on non-linear gain value vs gain code\n  [10/18] \"libcamera: introduce SoftwareIsp\"\n  - Fix the check of if sharedParams_ were created OK\n  new [18/18] \"libcamera: Soft IPA: use CameraSensorHelper for analogue gain\"\n  - One can check if his camera sensor has the CameraSensorHelper implemented with something\n    like 'grep ^REGISTER_CAMERA_SENSOR_HELPER src/ipa/libipa/camera_sensor_helper.cpp'. If\n    the camera sensor used has no CameraSensorHelper, the Soft IPA works as before this patch.\n    This fallback option doesn't make the code nicer, and makes it harder to change the AE/AGC\n    algorithm to work faster, but I decided to keep it for now.\n- Milan:\n  [17/18] \"libcamera: software_isp: Apply black level compensation\"\n  - New patch adding black-level compensation autmatically detecting the\n    sensor blacklevel\n- Hans:\n  - Small typo changes in various comments/docs\n  - Replace typedef-s with using\n\nChanges in v3 vs v2:\n- The Software ISP now is always build when building the simple pipeline\n  handler, no more -Dpipelines=simple/simple. Instead whether the SoftISP\n  is used or not is based on the media-controller driver. For now it is\n  only enabled for the \"qcom-camss\" driver (Andrey)\n- SoftISP factory has been removed, there is a just a single SoftwareISP class now\n- Fix the multi-threading issues (Andrey)\n- Fully document the SharedMemObject and DmaHeap classes (Andrey)\n- Drop SwStats base (integrate into SwStatsCpu class)\n- Move headers for classes only used by the SoftISP into src/libcamera/software_isp\n- Move SwStats / SwDebayer docs into .cpp and extend it\n- Rename many foo_bar symbols to fooBar\n- Add constexpr kFooBar values for varies hardcoded sizes like\n  the yHistoGram having 16 bins and the gammalookuptable having 1024 entries\n- Make startFrame() and finishFrame() normal methods instead of\n  using function pointers for these\n- Document how/why an array of src pointers is passed to\n  the debayer functions\n- 12bpp unpacked raw bayer input support (Kieran)\n- Add \"Software ISP benchmarking\" doc\n\nChanges in v2 vs v1:\n- Integrated Dennis, Martti and Toon's auto-exposure algorithm\n  based on the paper which they found which gives us a nice\n  relatively simple AEC + AGC algorithm\n  TODO: Add link to paper to source + commit-message\n- Integrated Dennis' doxygen comments for all new classes, no more warnings!\n- Move AWB gain calculations to the IPA (Andrey)\n- Added 8 bpp and 10 bpp unpacked raw bayer input support (Hans)\n- Use dma-buf for the output FrameBuffer-s (Andrey)\n- Memcpy data from input FrameBuffers to a heap buffer on a line by line\n  basis to speedup debayering from uncached mem (Hans)\n- This addresses all \"open issues\" from the v1 posting\n\nChanges in v1 vs RFC-v2:\n- Add and use SwStats[Cpu] and Debayer[Cpu] classes\n- Rename linaro soft-IPA and soft-ISP implementations to simple following\n  the simple pipeline hander\n- Integrate Pavel's swstats and debayer improvements\n\nThis has been tested on:\n- Qualcomm RB5 board with a mezzanine board equipped with RPi camera v2 (Andrey)\n- Lenovo x13s, sc8280xp (Bryan)\n- Pinephone (Pavel)\n- Debix Model A (Milan)\n- Lenovo Thinkpad Yoga X1 yoga gen7/8, Alder Lake/Raptor Lake IPU6EP +\n  ov2740 10bpp packed + unpacked (Dennis / Hans)\n- Dell Latitude 9420, Tiger Lake IPU6 + ov01a1s (RGBI) sensor\n  (Martti, requires IGIG_GBGR_IGIG_GRGB patches on top)\n\ngit branch for v4 of the patch set:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/SoftwareISP-v07\n\ngit branch for v3 of the patch set:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/SoftwareISP-v06\n\ngit branch for v2 of the patch set:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/SoftwareISP-v05\n\ngit branch for v1 of the patch set:\nhttps://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/SoftwareISP-v04\n\nAndrei Konovalov (1):\n  libcamera: shared_mem_object: Reorganize the code and document the\n    SharedMemObject class\n\nAndrey Konovalov (8):\n  libcamera: pipeline: simple: fix size adjustment in validate()\n  libcamera: internal: Move dma_heaps.[h, cpp] to common directories\n  libcamera: dma_heaps: extend DmaHeap class to support system heap\n  libcamera: internal: Move SharedMemObject class to a common directory\n  libcamera: ipa: Add Soft IPA\n  libcamera: Introduce SoftwareIsp\n  libcamera: pipeline: simple: Rename converterBuffers_ and related vars\n  libcamera: pipeline: simple: Enable use of Soft ISP and Soft IPA\n\nHans de Goede (7):\n  libcamera: software_isp: Add SwStatsCpu class\n  libcamera: software_isp: Add Debayer base class\n  libcamera: software_isp: Add DebayerCpu class\n  libcamera: swstats_cpu: Add support for 8, 10 and 12 bpp unpacked\n    bayer input\n  libcamera: debayer_cpu: Add support for 8, 10 and 12 bpp unpacked\n    bayer input\n  libcamera: debayer_cpu: Add BGR888 output support\n  libcamera: Add \"Software ISP benchmarking\" documentation\n\nMilan Zamazal (2):\n  libcamera: shared_mem_object: Rename SIZE constant to `size'\n  libcamera: software_isp: Apply black level compensation\n\n Documentation/Doxyfile.in                     |   1 +\n Documentation/index.rst                       |   1 +\n Documentation/meson.build                     |   1 +\n Documentation/software-isp-benchmarking.rst   |  77 ++\n .../libcamera/internal}/dma_heaps.h           |  14 +-\n include/libcamera/internal/meson.build        |   3 +\n .../libcamera/internal/shared_mem_object.h    | 127 +++\n .../internal/software_isp/debayer_params.h    |  29 +\n .../internal/software_isp/meson.build         |   7 +\n .../internal/software_isp/software_isp.h      |  99 +++\n .../internal/software_isp/swisp_stats.h       |  49 ++\n include/libcamera/ipa/meson.build             |   1 +\n include/libcamera/ipa/soft.mojom              |  28 +\n meson_options.txt                             |   2 +-\n src/ipa/meson.build                           |   3 +\n src/ipa/simple/black_level.cpp                |  88 ++\n src/ipa/simple/black_level.h                  |  28 +\n src/ipa/simple/data/meson.build               |  10 +\n src/ipa/simple/data/uncalibrated.yaml         |   5 +\n src/ipa/simple/meson.build                    |  30 +\n src/ipa/simple/soft_simple.cpp                | 403 +++++++++\n src/libcamera/dma_heaps.cpp                   | 165 ++++\n src/libcamera/meson.build                     |   3 +\n .../pipeline/rpi/common/shared_mem_object.h   | 128 ---\n src/libcamera/pipeline/rpi/vc4/dma_heaps.cpp  |  90 --\n src/libcamera/pipeline/rpi/vc4/meson.build    |   1 -\n src/libcamera/pipeline/rpi/vc4/vc4.cpp        |   5 +-\n src/libcamera/pipeline/simple/simple.cpp      | 241 ++++--\n src/libcamera/shared_mem_object.cpp           | 236 +++++\n src/libcamera/software_isp/TODO               | 279 ++++++\n src/libcamera/software_isp/debayer.cpp        | 132 +++\n src/libcamera/software_isp/debayer.h          |  54 ++\n src/libcamera/software_isp/debayer_cpu.cpp    | 807 ++++++++++++++++++\n src/libcamera/software_isp/debayer_cpu.h      | 158 ++++\n src/libcamera/software_isp/meson.build        |  15 +\n src/libcamera/software_isp/software_isp.cpp   | 357 ++++++++\n src/libcamera/software_isp/swstats_cpu.cpp    | 432 ++++++++++\n src/libcamera/software_isp/swstats_cpu.h      |  97 +++\n 38 files changed, 3922 insertions(+), 284 deletions(-)\n create mode 100644 Documentation/software-isp-benchmarking.rst\n rename {src/libcamera/pipeline/rpi/vc4 => include/libcamera/internal}/dma_heaps.h (65%)\n create mode 100644 include/libcamera/internal/shared_mem_object.h\n create mode 100644 include/libcamera/internal/software_isp/debayer_params.h\n create mode 100644 include/libcamera/internal/software_isp/meson.build\n create mode 100644 include/libcamera/internal/software_isp/software_isp.h\n create mode 100644 include/libcamera/internal/software_isp/swisp_stats.h\n create mode 100644 include/libcamera/ipa/soft.mojom\n create mode 100644 src/ipa/simple/black_level.cpp\n create mode 100644 src/ipa/simple/black_level.h\n create mode 100644 src/ipa/simple/data/meson.build\n create mode 100644 src/ipa/simple/data/uncalibrated.yaml\n create mode 100644 src/ipa/simple/meson.build\n create mode 100644 src/ipa/simple/soft_simple.cpp\n create mode 100644 src/libcamera/dma_heaps.cpp\n delete mode 100644 src/libcamera/pipeline/rpi/common/shared_mem_object.h\n delete mode 100644 src/libcamera/pipeline/rpi/vc4/dma_heaps.cpp\n create mode 100644 src/libcamera/shared_mem_object.cpp\n create mode 100644 src/libcamera/software_isp/TODO\n create mode 100644 src/libcamera/software_isp/debayer.cpp\n create mode 100644 src/libcamera/software_isp/debayer.h\n create mode 100644 src/libcamera/software_isp/debayer_cpu.cpp\n create mode 100644 src/libcamera/software_isp/debayer_cpu.h\n create mode 100644 src/libcamera/software_isp/meson.build\n create mode 100644 src/libcamera/software_isp/software_isp.cpp\n create mode 100644 src/libcamera/software_isp/swstats_cpu.cpp\n create mode 100644 src/libcamera/software_isp/swstats_cpu.h"}