[{"id":14480,"web_url":"https://patchwork.libcamera.org/comment/14480/","msgid":"<CAEmqJPr3WKJgO+LF+nX294n+-r8mrsxXiKvuFKRC1j0Jk=PJQA@mail.gmail.com>","date":"2021-01-08T15:38:01","subject":"Re: [libcamera-devel] [PATCH v4 4/8] libcamera: raspberrypi: Remove\n\tStaggeredCtrl","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Niklas,\n\nThank you for your patch.\n\n\nOn Tue, 15 Dec 2020 at 00:48, Niklas Söderlund <\nniklas.soderlund@ragnatech.se> wrote:\n\n> There are no users left, remove it.\n>\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n> ---\n>  .../pipeline/raspberrypi/meson.build          |   1 -\n>  .../pipeline/raspberrypi/staggered_ctrl.cpp   | 174 ------------------\n>  .../pipeline/raspberrypi/staggered_ctrl.h     |  96 ----------\n>  3 files changed, 271 deletions(-)\n>  delete mode 100644 src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp\n>  delete mode 100644 src/libcamera/pipeline/raspberrypi/staggered_ctrl.h\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/meson.build\n> b/src/libcamera/pipeline/raspberrypi/meson.build\n> index 7c5b6ff73741c968..f1a2f5ee72c2a0dd 100644\n> --- a/src/libcamera/pipeline/raspberrypi/meson.build\n> +++ b/src/libcamera/pipeline/raspberrypi/meson.build\n> @@ -4,5 +4,4 @@ libcamera_sources += files([\n>      'dma_heaps.cpp',\n>      'raspberrypi.cpp',\n>      'rpi_stream.cpp',\n> -    'staggered_ctrl.cpp',\n>  ])\n> diff --git a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp\n> b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp\n> deleted file mode 100644\n> index 62605c0fceee7d11..0000000000000000\n> --- a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp\n> +++ /dev/null\n> @@ -1,174 +0,0 @@\n> -/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> -/*\n> - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.\n> - *\n> - * staggered_ctrl.cpp - Helper for writing staggered ctrls to a V4L2\n> device.\n> - */\n> -\n> -#include \"staggered_ctrl.h\"\n> -\n> -#include <algorithm>\n> -\n> -#include <libcamera/controls.h>\n> -\n> -#include \"libcamera/internal/log.h\"\n> -#include \"libcamera/internal/utils.h\"\n> -#include \"libcamera/internal/v4l2_videodevice.h\"\n> -\n> -namespace libcamera {\n> -\n> -LOG_DEFINE_CATEGORY(RPI_S_W)\n> -\n> -namespace RPi {\n> -\n> -void StaggeredCtrl::init(V4L2VideoDevice *dev,\n> -         std::initializer_list<std::pair<const uint32_t, uint8_t>>\n> delayList)\n> -{\n> -       std::lock_guard<std::mutex> lock(lock_);\n> -\n> -       dev_ = dev;\n> -       delay_ = delayList;\n> -       ctrl_.clear();\n> -\n> -       /* Find the largest delay across all controls. */\n> -       maxDelay_ = 0;\n> -       for (auto const &p : delay_) {\n> -               LOG(RPI_S_W, Info) << \"Init ctrl \"\n> -                                  << utils::hex(p.first) << \" with delay \"\n> -                                  << static_cast<int>(p.second);\n> -               maxDelay_ = std::max(maxDelay_, p.second);\n> -       }\n> -\n> -       init_ = true;\n> -}\n> -\n> -void StaggeredCtrl::reset()\n> -{\n> -       std::lock_guard<std::mutex> lock(lock_);\n> -\n> -       int lastSetCount = setCount_;\n> -       std::unordered_map<uint32_t, int32_t> lastVal;\n> -\n> -       /* Reset the counters. */\n> -       setCount_ = getCount_ = 0;\n> -\n> -       /* Look for the last set values. */\n> -       for (auto const &c : ctrl_)\n> -               lastVal[c.first] = c.second[lastSetCount].value;\n> -\n> -       /* Apply the last set values as the next to be applied. */\n> -       ctrl_.clear();\n> -       for (auto &c : lastVal)\n> -               ctrl_[c.first][setCount_] = CtrlInfo(c.second);\n> -}\n> -\n> -bool StaggeredCtrl::set(uint32_t ctrl, int32_t value)\n> -{\n> -       std::lock_guard<std::mutex> lock(lock_);\n> -\n> -       /* Can we find this ctrl as one that is registered? */\n> -       if (delay_.find(ctrl) == delay_.end())\n> -               return false;\n> -\n> -       ctrl_[ctrl][setCount_].value = value;\n> -       ctrl_[ctrl][setCount_].updated = true;\n> -\n> -       return true;\n> -}\n> -\n> -bool StaggeredCtrl::set(std::initializer_list<std::pair<const uint32_t,\n> int32_t>> ctrlList)\n> -{\n> -       std::lock_guard<std::mutex> lock(lock_);\n> -\n> -       for (auto const &p : ctrlList) {\n> -               /* Can we find this ctrl? */\n> -               if (delay_.find(p.first) == delay_.end())\n> -                       return false;\n> -\n> -               ctrl_[p.first][setCount_] = CtrlInfo(p.second);\n> -       }\n> -\n> -       return true;\n> -}\n> -\n> -bool StaggeredCtrl::set(const ControlList &controls)\n> -{\n> -       std::lock_guard<std::mutex> lock(lock_);\n> -\n> -       for (auto const &p : controls) {\n> -               /* Can we find this ctrl? */\n> -               if (delay_.find(p.first) == delay_.end())\n> -                       return false;\n> -\n> -               ctrl_[p.first][setCount_] =\n> CtrlInfo(p.second.get<int32_t>());\n> -               LOG(RPI_S_W, Debug) << \"Setting ctrl \"\n> -                                   << utils::hex(p.first) << \" to \"\n> -                                   << ctrl_[p.first][setCount_].value\n> -                                   << \" at index \"\n> -                                   << setCount_;\n> -       }\n> -\n> -       return true;\n> -}\n> -\n> -int StaggeredCtrl::write()\n> -{\n> -       std::lock_guard<std::mutex> lock(lock_);\n> -       ControlList controls(dev_->controls());\n> -\n> -       for (auto &p : ctrl_) {\n> -               int delayDiff = maxDelay_ - delay_[p.first];\n> -               int index = std::max<int>(0, setCount_ - delayDiff);\n> -\n> -               if (p.second[index].updated) {\n> -                       /* We need to write this value out. */\n> -                       controls.set(p.first, p.second[index].value);\n> -                       p.second[index].updated = false;\n> -                       LOG(RPI_S_W, Debug) << \"Writing ctrl \"\n> -                                           << utils::hex(p.first) << \" to\n> \"\n> -                                           << p.second[index].value\n> -                                           << \" at index \"\n> -                                           << index;\n> -               }\n> -       }\n> -\n> -       nextFrame();\n> -       return dev_->setControls(&controls);\n> -}\n> -\n> -void StaggeredCtrl::get(std::unordered_map<uint32_t, int32_t> &ctrl,\n> uint8_t offset)\n> -{\n> -       std::lock_guard<std::mutex> lock(lock_);\n> -\n> -       /* Account for the offset to reset the getCounter. */\n> -       getCount_ += offset + 1;\n> -\n> -       ctrl.clear();\n> -       for (auto &p : ctrl_) {\n> -               int index = std::max<int>(0, getCount_ - maxDelay_);\n> -               ctrl[p.first] = p.second[index].value;\n> -               LOG(RPI_S_W, Debug) << \"Getting ctrl \"\n> -                                   << utils::hex(p.first) << \" to \"\n> -                                   << p.second[index].value\n> -                                   << \" at index \"\n> -                                   << index;\n> -       }\n> -}\n> -\n> -void StaggeredCtrl::nextFrame()\n> -{\n> -       /* Advance the control history to the next frame */\n> -       int prevCount = setCount_;\n> -       setCount_++;\n> -\n> -       LOG(RPI_S_W, Debug) << \"Next frame, set index is \" << setCount_;\n> -\n> -       for (auto &p : ctrl_) {\n> -               p.second[setCount_].value = p.second[prevCount].value;\n> -               p.second[setCount_].updated = false;\n> -       }\n> -}\n> -\n> -} /* namespace RPi */\n> -\n> -} /* namespace libcamera */\n> diff --git a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h\n> b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h\n> deleted file mode 100644\n> index 382fa31a685357f2..0000000000000000\n> --- a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h\n> +++ /dev/null\n> @@ -1,96 +0,0 @@\n> -/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> -/*\n> - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.\n> - *\n> - * staggered_ctrl.h - Helper for writing staggered ctrls to a V4L2 device.\n> - */\n> -#ifndef __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__\n> -#define __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__\n> -\n> -#include <array>\n> -#include <initializer_list>\n> -#include <mutex>\n> -#include <unordered_map>\n> -#include <utility>\n> -\n> -namespace libcamera {\n> -\n> -class ControlList;\n> -class V4L2VideoDevice;\n> -\n> -namespace RPi {\n> -\n> -class StaggeredCtrl\n> -{\n> -public:\n> -       StaggeredCtrl()\n> -               : init_(false), setCount_(0), getCount_(0), maxDelay_(0)\n> -       {\n> -       }\n> -\n> -       operator bool() const\n> -       {\n> -               return init_;\n> -       }\n> -\n> -       void init(V4L2VideoDevice *dev,\n> -                 std::initializer_list<std::pair<const uint32_t,\n> uint8_t>> delayList);\n> -       void reset();\n> -\n> -       void get(std::unordered_map<uint32_t, int32_t> &ctrl, uint8_t\n> offset = 0);\n> -\n> -       bool set(uint32_t ctrl, int32_t value);\n> -       bool set(std::initializer_list<std::pair<const uint32_t, int32_t>>\n> ctrlList);\n> -       bool set(const ControlList &controls);\n> -\n> -       int write();\n> -\n> -private:\n> -       void nextFrame();\n> -\n> -       /* listSize must be a power of 2. */\n> -       static constexpr int listSize = (1 << 4);\n> -       struct CtrlInfo {\n> -               CtrlInfo()\n> -                       : value(0), updated(false)\n> -               {\n> -               }\n> -\n> -               CtrlInfo(int32_t value_)\n> -                       : value(value_), updated(true)\n> -               {\n> -               }\n> -\n> -               int32_t value;\n> -               bool updated;\n> -       };\n> -\n> -       class CircularArray : public std::array<CtrlInfo, listSize>\n> -       {\n> -       public:\n> -               CtrlInfo &operator[](int index)\n> -               {\n> -                       return std::array<CtrlInfo,\n> listSize>::operator[](index & (listSize - 1));\n> -               }\n> -\n> -               const CtrlInfo &operator[](int index) const\n> -               {\n> -                       return std::array<CtrlInfo,\n> listSize>::operator[](index & (listSize - 1));\n> -               }\n> -       };\n> -\n> -       bool init_;\n> -       uint32_t setCount_;\n> -       uint32_t getCount_;\n> -       uint8_t maxDelay_;\n> -       V4L2VideoDevice *dev_;\n> -       std::unordered_map<uint32_t, uint8_t> delay_;\n> -       std::unordered_map<uint32_t, CircularArray> ctrl_;\n> -       std::mutex lock_;\n> -};\n> -\n> -} /* namespace RPi */\n> -\n> -} /* namespace libcamera */\n> -\n> -#endif /* __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__ */\n> --\n> 2.29.2\n>\n>","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 C8140C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 Jan 2021 15:38:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3DECD68055;\n\tFri,  8 Jan 2021 16:38:19 +0100 (CET)","from mail-lf1-x130.google.com (mail-lf1-x130.google.com\n\t[IPv6:2a00:1450:4864:20::130])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9623635C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 Jan 2021 16:38:17 +0100 (CET)","by mail-lf1-x130.google.com with SMTP id 23so23810204lfg.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 08 Jan 2021 07:38:17 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"S0apL0Yo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=8Tgc6P8HD+C0idDhjWu0wD07O6o7NN2NxO8EPpUSw3E=;\n\tb=S0apL0YoBFW/dJTJjlnDY9lgpa7dD5Z9SFgttu06CzyTeqijWH7k3ZtyKJ9ZyTqCRz\n\tatm56F5xaosfLtYaW30/4xlCSaXeVAae+xYf9/wItusJlnXpedrzu7tvXHs/8q+BpCta\n\tr68hXbchpKhkj1anqe7qYfGUobkwuBlXT5tN/LmYDwHGWidQFC+3HV//B3vv1ESo2Gps\n\tMfiaTTK+AhQwm90ih+xk2nArGt7l20uUkX3skGp/VvPk69eNo81aHXzoTxR1pLL/jWk1\n\tAReOVnmSjIzxefu+IJplFSkMinOExR6YmVb3i3rBM0lhBpVHxUI8ig1/YLWLexheG8c9\n\t9bqQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=8Tgc6P8HD+C0idDhjWu0wD07O6o7NN2NxO8EPpUSw3E=;\n\tb=hk9qvLzstZTvbn7QBAsJE41a3c9bWekEYj8kQpPvIQhnh6SN2ZW7JoS09HFBr4KlmL\n\tezMABGLrFsAMJs47g5t4iIah/5cswnMxaXeJer5MwPjoKWEJtoeE5fpg6Jn0LjVhepyc\n\tB+Z9ahpoFgHaOnFze/94Qx1fscVCZFSc7kkD5YVYaO+uqvy6BFPBbP3Nn3cvbh6Z53NR\n\tsM5fhS3tanMfl9IjPsuqs7JcU3E9teMiA3A2cIh6nnXRns3Ano8iNZtRoCHomWf0o3g+\n\tUaiLDbjoEtvlvrYxq4yZvEYCGhXTyUjPSc4GhCfZg1Dg6YRS1fNj3jZN1G30b34y4dTs\n\tXc6A==","X-Gm-Message-State":"AOAM533tfyt6WV97xc/Wh/frNzfTLNuAFve/xuR/VMvyvMbPsXLtAyqd\n\tVRHjzKTyMnJ0TNMZF6t6feapSkhdEQDC4Uq4VD3beg==","X-Google-Smtp-Source":"ABdhPJxGVjiRCzP4+F1Fou96Zqe4YvhYwYPwoLiYU89cyAE3ZwHOm+QP2ZHAfICmboEON9Eg7o8dVo+fXIU6jqTrUoo=","X-Received":"by 2002:a05:651c:503:: with SMTP id\n\to3mr1667525ljp.253.1610120297200; \n\tFri, 08 Jan 2021 07:38:17 -0800 (PST)","MIME-Version":"1.0","References":"<20201215004811.602429-1-niklas.soderlund@ragnatech.se>\n\t<20201215004811.602429-5-niklas.soderlund@ragnatech.se>","In-Reply-To":"<20201215004811.602429-5-niklas.soderlund@ragnatech.se>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Fri, 8 Jan 2021 15:38:01 +0000","Message-ID":"<CAEmqJPr3WKJgO+LF+nX294n+-r8mrsxXiKvuFKRC1j0Jk=PJQA@mail.gmail.com>","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v4 4/8] libcamera: raspberrypi: Remove\n\tStaggeredCtrl","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"multipart/mixed;\n\tboundary=\"===============8294003610508823986==\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]