[{"id":25351,"web_url":"https://patchwork.libcamera.org/comment/25351/","msgid":"<Y0Cok6SHilqmrbs0@pendragon.ideasonboard.com>","date":"2022-10-07T22:30:43","subject":"Re: [libcamera-devel] [PATCH v2 02/10] ipa: raspberrypi: Add\n\tminimum and maximum line length fields to CameraMode","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Thu, Oct 06, 2022 at 02:17:36PM +0100, Naushir Patuck via libcamera-devel wrote:\n> Add fields for minimum and maximum line length duration to the CameraMode\n> structure. This replaces the existing lineLength field.\n> \n> Any use of the existing lineLength field is replaced by the new minLineLength\n> field, as logically we always want to use the fastest sensor readout by default.\n> \n> As a drive-by cosmetic change, split all fields in the CameraMode structure into\n> separate lines.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper.cpp           |  8 +++----\n>  src/ipa/raspberrypi/controller/camera_mode.h | 23 +++++++++++++-------\n>  src/ipa/raspberrypi/raspberrypi.cpp          | 13 ++++++-----\n>  3 files changed, 26 insertions(+), 18 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\n> index cac8f39ee763..42251ba29682 100644\n> --- a/src/ipa/raspberrypi/cam_helper.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper.cpp\n> @@ -64,13 +64,13 @@ void CamHelper::process([[maybe_unused]] StatisticsPtr &stats,\n>  uint32_t CamHelper::exposureLines(const Duration exposure) const\n>  {\n>  \tassert(initialized_);\n> -\treturn exposure / mode_.lineLength;\n> +\treturn exposure / mode_.minLineLength;\n>  }\n>  \n>  Duration CamHelper::exposure(uint32_t exposureLines) const\n>  {\n>  \tassert(initialized_);\n> -\treturn exposureLines * mode_.lineLength;\n> +\treturn exposureLines * mode_.minLineLength;\n>  }\n>  \n>  uint32_t CamHelper::getVBlanking(Duration &exposure,\n> @@ -86,8 +86,8 @@ uint32_t CamHelper::getVBlanking(Duration &exposure,\n>  \t * minFrameDuration and maxFrameDuration are clamped by the caller\n>  \t * based on the limits for the active sensor mode.\n>  \t */\n> -\tframeLengthMin = minFrameDuration / mode_.lineLength;\n> -\tframeLengthMax = maxFrameDuration / mode_.lineLength;\n> +\tframeLengthMin = minFrameDuration / mode_.minLineLength;\n> +\tframeLengthMax = maxFrameDuration / mode_.minLineLength;\n>  \n>  \t/*\n>  \t * Limit the exposure to the maximum frame duration requested, and\n> diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h\n> index a6ccf8c1c600..6bc35b771946 100644\n> --- a/src/ipa/raspberrypi/controller/camera_mode.h\n> +++ b/src/ipa/raspberrypi/controller/camera_mode.h\n> @@ -20,23 +20,30 @@ struct CameraMode {\n>  \t/* bit depth of the raw camera output */\n>  \tuint32_t bitdepth;\n>  \t/* size in pixels of frames in this mode */\n> -\tuint16_t width, height;\n> +\tuint16_t width;\n> +\tuint16_t height;\n>  \t/* size of full resolution uncropped frame (\"sensor frame\") */\n> -\tuint16_t sensorWidth, sensorHeight;\n> +\tuint16_t sensorWidth;\n> +\tuint16_t sensorHeight;\n>  \t/* binning factor (1 = no binning, 2 = 2-pixel binning etc.) */\n> -\tuint8_t binX, binY;\n> +\tuint8_t binX;\n> +\tuint8_t binY;\n>  \t/* location of top left pixel in the sensor frame */\n> -\tuint16_t cropX, cropY;\n> +\tuint16_t cropX;\n> +\tuint16_t cropY;\n>  \t/* scaling factor (so if uncropped, width*scaleX is sensorWidth) */\n> -\tdouble scaleX, scaleY;\n> +\tdouble scaleX;\n> +\tdouble scaleY;\n>  \t/* scaling of the noise compared to the native sensor mode */\n>  \tdouble noiseFactor;\n> -\t/* line time */\n> -\tlibcamera::utils::Duration lineLength;\n> +\t/* minimum and maximum line time */\n> +\tlibcamera::utils::Duration minLineLength;\n> +\tlibcamera::utils::Duration maxLineLength;\n>  \t/* any camera transform *not* reflected already in the camera tuning */\n>  \tlibcamera::Transform transform;\n>  \t/* minimum and maximum fame lengths in units of lines */\n\ns/fame/frame/ as another drive-by fix.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nNo need to resubmit for just this.\n\n> -\tuint32_t minFrameLength, maxFrameLength;\n> +\tuint32_t minFrameLength;\n> +\tuint32_t maxFrameLength;\n>  \t/* sensitivity of this mode */\n>  \tdouble sensitivity;\n>  };\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 358a119da222..67326bcf4a14 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -314,7 +314,7 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig)\n>  \t}\n>  \n>  \tstartConfig->dropFrameCount = dropFrameCount_;\n> -\tconst Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength;\n> +\tconst Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength;\n>  \tstartConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get<std::milli>();\n>  \n>  \tfirstStart_ = false;\n> @@ -356,7 +356,8 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo)\n>  \t * Calculate the line length as the ratio between the line length in\n>  \t * pixels and the pixel rate.\n>  \t */\n> -\tmode_.lineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate);\n> +\tmode_.minLineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate);\n> +\tmode_.maxLineLength = sensorInfo.maxLineLength * (1.0s / sensorInfo.pixelRate);\n>  \n>  \t/*\n>  \t * Set the frame length limits for the mode to ensure exposure and\n> @@ -458,8 +459,8 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\n>  \t * based on the current sensor mode.\n>  \t */\n>  \tControlInfoMap::Map ctrlMap = ipaControls;\n> -\tconst Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength;\n> -\tconst Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength;\n> +\tconst Duration minSensorFrameDuration = mode_.minFrameLength * mode_.minLineLength;\n> +\tconst Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength;\n>  \tctrlMap[&controls::FrameDurationLimits] =\n>  \t\tControlInfo(static_cast<int64_t>(minSensorFrameDuration.get<std::micro>()),\n>  \t\t\t    static_cast<int64_t>(maxSensorFrameDuration.get<std::micro>()));\n> @@ -1150,8 +1151,8 @@ void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\n>  \n>  void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration)\n>  {\n> -\tconst Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength;\n> -\tconst Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength;\n> +\tconst Duration minSensorFrameDuration = mode_.minFrameLength * mode_.minLineLength;\n> +\tconst Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength;\n>  \n>  \t/*\n>  \t * This will only be applied once AGC recalculations occur.","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 4DAF3BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 Oct 2022 22:30:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9CFC562D2A;\n\tSat,  8 Oct 2022 00:30:50 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 11CC662CEC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  8 Oct 2022 00:30:49 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6A3884E6;\n\tSat,  8 Oct 2022 00:30:48 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665181850;\n\tbh=NkLQqXVh6BGjrJdiW9PL8Sy5Wro0okyCNpy3i9ZQ08g=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=KPtuPmGQ/yWbKZ4V/0zjdeYBXgzBuIqptMZOJdSYcwNGhMIcFGOH13OHptCFnPqLj\n\t3EW2SOAGDsRgtbthQnzVyf6PDOWcKSc/9yu/uM1mN2I9Ewp5RwpMqjTNvHay/ThaOT\n\twk9ZZa5XvP+bHMaJzW++jjeX/0M8INoimOba4K7ddF7mbhlVN5vbhQZhW9XD4FhTNN\n\tmF1+X+gzN96ng43ATiYZRBx17S+Agov6nOISwjOzUQDRqnG2XXJCI7kFtpKS0tDvgd\n\tDoy4FyLOTk+cR1AujN5wsuOo8CkyklDo90kwZh5Ll7Z60qCWobORUEVX3bXve2wo9l\n\t3nIpkRilu3o/w==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1665181848;\n\tbh=NkLQqXVh6BGjrJdiW9PL8Sy5Wro0okyCNpy3i9ZQ08g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=k4J6keatVYAlJSP0XOf28IyhwUvFB1H+wmMj3AjFfbUz4c4rlxK12l1MPe3glKWcJ\n\tK3+XtFIxpBWFldt3m2JWQUhoJsT8UOMFCb9f4WawmTYSD2wcaX9+ubZfn8dixXov1F\n\tvLneySul3DcvwOPrgLb7iuVXtdHO10hkNNIAfz7U="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"k4J6keat\"; dkim-atps=neutral","Date":"Sat, 8 Oct 2022 01:30:43 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Y0Cok6SHilqmrbs0@pendragon.ideasonboard.com>","References":"<20221006131744.5179-1-naush@raspberrypi.com>\n\t<20221006131744.5179-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20221006131744.5179-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 02/10] ipa: raspberrypi: Add\n\tminimum and maximum line length fields to CameraMode","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]