{"id":17542,"url":"https://patchwork.libcamera.org/api/patches/17542/?format=json","web_url":"https://patchwork.libcamera.org/patch/17542/","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":"<20221006131744.5179-2-naush@raspberrypi.com>","date":"2022-10-06T13:17:35","name":"[libcamera-devel,v2,01/10] camera_sensor: Add minimum and maximum line length to IPACameraSensorInfo","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a7fdd87b1c8a9d491a88b75c4b9405f4e8a7550f","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17542/mbox/","series":[{"id":3537,"url":"https://patchwork.libcamera.org/api/series/3537/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3537","date":"2022-10-06T13:17:34","name":"Raspberry Pi: Horizontal blanking control","version":2,"mbox":"https://patchwork.libcamera.org/series/3537/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17542/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17542/checks/","tags":{},"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 456A3C327C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  6 Oct 2022 13:17:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BA04C62CEC;\n\tThu,  6 Oct 2022 15:17:55 +0200 (CEST)","from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com\n\t[IPv6:2a00:1450:4864:20::42e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 11CA062CEC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Oct 2022 15:17:54 +0200 (CEST)","by mail-wr1-x42e.google.com with SMTP id a3so2732276wrt.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 06 Oct 2022 06:17:54 -0700 (PDT)","from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tq18-20020a056000137200b0022cc7c32309sm17986049wrz.115.2022.10.06.06.17.52\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 06 Oct 2022 06:17:52 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665062275;\n\tbh=w2S4d6v1gYSnFkQxkmqriKMoaRZOOgpuTDPY4i3E45Q=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=iboEPCyd0ZfKu2Fi3s9CS8+Nkhm/X+386CHXTOCiht3TaVTScZeXhvmGXFHqW0CYj\n\tm0WozV29k5WkvCYsAhwba1e6aEkJTnJPG1aoU82YKP9lJVC6N6NtnQyx6S91srwoc0\n\tpKyAMhYj3EZB1rMNxEd6ijPAeBLeXvMEF1IMnPojRCZaH8EQsSd3vJstotbXbVQcUM\n\tCudLDmKU40yBD/+MbQMMqmA3EEYwpdGsB6uClc4biA8StEdHvSzcBxHy4hfhblv6tI\n\tKfhxEUnWAi5dNgBbRIbA2q+mRWKcT/2CdWxWoooXiBiQ/R15eVv/yGqv7o8GrwwUyh\n\tRXutg1XJNMZwA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date;\n\tbh=63HV8gWPDPKpyvSeClm2tYYD+NWm1ekUi/dYqoq+cHU=;\n\tb=k9DtKtBBfaoGfunaN0lvccv9C9VMGcHM+ARTFsuIsG1YQjH+ddFeo8WqrTa5eCahVM\n\tEDwve+tN2IITJeHDhK/qNfFmizF+ffWaE0YR3sZsqtLg+3b3ayWzjuNc22wTn13TfxaY\n\t/GbErVdXZKBuDYaqz5UbvDzKfk0sIIsGANrQsbNoyUTj8yAIXAkLRBNPWDSfvGf3PAK6\n\tG1pa5EANDvv7QtT4WDav6KXYqOY7W10zUgaj4XMEFoYmPUTtwGZDUyiWRy0OhXvtl2GT\n\tFVfNV2iDPSjBxtB0Wf0Q6IS1r01CYWVDITL3Q3Fki9Mc551ChmHYmchnjagmy29mm/06\n\tV5eQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"k9DtKtBB\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date;\n\tbh=63HV8gWPDPKpyvSeClm2tYYD+NWm1ekUi/dYqoq+cHU=;\n\tb=Ua0QxSDCQCLRe19lT5zJhVQ+uQl83u/8I2zJISlLO6tihF6d1+K15HToSRChHuckVa\n\tO0sO/WzkaEiyuuIFQk6MITtn+WoHxuKn3vX4UNv3LOnPvyh2z8DA0Q6mdOV7b5tOYIKh\n\ttr+0vVWyF+gqlH9U+GM2EXhrjRCnZqGy2cy+YqCuB02es03JQr8QRBm+dLzGs3wRmyD8\n\tYHNr+FIifN+AKMM+HqiBD8Q4zY69+/2I/u67lJC+K0U75L3VGM+QXxyUhyNxYSr9lvx6\n\t9YcwbIf5Mn4PTt5dxc1FBryfIo9uIWwAMYZmRrXANzwZjTysQ+Sp1PLkxHzN1EI4wzo8\n\tbTew==","X-Gm-Message-State":"ACrzQf1sk5uIH3gk62pCJVGBdcVxKVfvoIfplYQ4wmTacVKAsMO0kzn8\n\t7C9zj3qBGjUoLoAItPXnD9lm9DmTS9+Pjw==","X-Google-Smtp-Source":"AMsMyM6swrIA9Y0OEkUQjIbf5mjOcMNg8P/GHOJHQMnNZMTYlvG87NN2nNo3d5qJ4mWBccrdwLAahA==","X-Received":"by 2002:a5d:414c:0:b0:22c:de8a:d233 with SMTP id\n\tc12-20020a5d414c000000b0022cde8ad233mr3370151wrq.194.1665062273353; \n\tThu, 06 Oct 2022 06:17:53 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  6 Oct 2022 14:17:35 +0100","Message-Id":"<20221006131744.5179-2-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20221006131744.5179-1-naush@raspberrypi.com>","References":"<20221006131744.5179-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 01/10] camera_sensor: Add minimum and\n\tmaximum line length to IPACameraSensorInfo","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add fields for minimum and maximum line length (in units of pixels) to the\nIPACameraSensorInfo structure. This replaces the existing lineLength field.\n\nUpdate the ipu3, raspberrypi and rkisp1 IPAs to use IPACameraSensorInfo::minLineLength\ninstead of IPACameraSensorInfo::lineLength, as logically we will always want to\nuse the fastest sensor readout by default.\n\nSince the IPAs now use minLineLength for their calculations, set the starting\nvalue of the V4L2_CID_HBLANK control to its minimum in CameraSensor::init().\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>\n---\n include/libcamera/ipa/core.mojom    | 21 +++++++++++++++------\n src/ipa/ipu3/ipu3.cpp               |  6 ++++--\n src/ipa/raspberrypi/raspberrypi.cpp |  2 +-\n src/ipa/rkisp1/rkisp1.cpp           |  2 +-\n src/libcamera/camera_sensor.cpp     | 15 +++++++++++++--\n 5 files changed, 34 insertions(+), 12 deletions(-)","diff":"diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom\nindex 74f3339e56f2..2bc3028c22d6 100644\n--- a/include/libcamera/ipa/core.mojom\n+++ b/include/libcamera/ipa/core.mojom\n@@ -172,10 +172,17 @@ module libcamera;\n  */\n \n /**\n- * \\var IPACameraSensorInfo::lineLength\n- * \\brief Total line length in pixels\n+ * \\var IPACameraSensorInfo::minLineLength\n+ * \\brief The minimum line length in pixels\n  *\n- * The total line length in pixel clock periods, including blanking.\n+ * The minimum allowable line length in pixel clock periods, including blanking.\n+ */\n+\n+/**\n+ * \\var IPACameraSensorInfo::maxLineLength\n+ * \\brief The maximum line length in pixels\n+ *\n+ * The maximum allowable line length in pixel clock periods, including blanking.\n  */\n \n /**\n@@ -189,7 +196,7 @@ module libcamera;\n  * To obtain the minimum frame duration:\n  *\n  * \\verbatim\n-       frameDuration(s) = minFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second)\n+       frameDuration(s) = minFrameLength(lines) * minLineLength(pixels) / pixelRate(pixels per second)\n    \\endverbatim\n  */\n \n@@ -204,7 +211,7 @@ module libcamera;\n  * To obtain the maximum frame duration:\n  *\n  * \\verbatim\n-       frameDuration(s) = maxFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second)\n+       frameDuration(s) = maxFrameLength(lines) * maxLineLength(pixels) / pixelRate(pixels per second)\n    \\endverbatim\n  */\n struct IPACameraSensorInfo {\n@@ -217,7 +224,9 @@ struct IPACameraSensorInfo {\n \tSize outputSize;\n \n \tuint64 pixelRate;\n-\tuint32 lineLength;\n+\n+\tuint32 minLineLength;\n+\tuint32 maxLineLength;\n \n \tuint32 minFrameLength;\n \tuint32 maxFrameLength;\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex b93a09d40c39..7e26fc5639c2 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -336,7 +336,8 @@ int IPAIPU3::init(const IPASettings &settings,\n \n \t/* Clean context */\n \tcontext_.configuration = {};\n-\tcontext_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate;\n+\tcontext_.configuration.sensor.lineDuration = sensorInfo.minLineLength\n+\t\t\t\t\t\t     * 1.0s / sensorInfo.pixelRate;\n \n \t/* Load the tuning data file. */\n \tFile file(settings.configurationFile);\n@@ -499,7 +500,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \tcontext_.frameContexts.clear();\n \n \t/* Initialise the sensor configuration. */\n-\tcontext_.configuration.sensor.lineDuration = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;\n+\tcontext_.configuration.sensor.lineDuration = sensorInfo_.minLineLength\n+\t\t\t\t\t\t     * 1.0s / sensorInfo_.pixelRate;\n \n \t/*\n \t * Compute the sensor V4L2 controls to be used by the algorithms and\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 8d731435764e..358a119da222 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -356,7 +356,7 @@ 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.lineLength * (1.0s / sensorInfo.pixelRate);\n+\tmode_.lineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate);\n \n \t/*\n \t * Set the frame length limits for the mode to ensure exposure and\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 32feb1682749..ddb22d98eb41 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -246,7 +246,7 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n \tcontext_.configuration.hw.revision = hwRevision_;\n \n \tcontext_.configuration.sensor.size = info.outputSize;\n-\tcontext_.configuration.sensor.lineDuration = info.lineLength * 1.0s / info.pixelRate;\n+\tcontext_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate;\n \n \t/*\n \t * When the AGC computes the new exposure values for a frame, it needs\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 911fd0beae4e..83f81d655395 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -176,6 +176,15 @@ int CameraSensor::init()\n \tif (ret)\n \t\treturn ret;\n \n+\t/* Set HBLANK to the minimum as a starting value. */\n+\tconst ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n+\tControlList ctrl(subdev_->controls());\n+\n+\tctrl.set(V4L2_CID_HBLANK, hblank.min().get<int32_t>());\n+\tret = subdev_->setControls(&ctrl);\n+\tif (ret)\n+\t\treturn ret;\n+\n \treturn applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);\n }\n \n@@ -883,10 +892,12 @@ int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const\n \t\treturn -EINVAL;\n \t}\n \n-\tint32_t hblank = ctrls.get(V4L2_CID_HBLANK).get<int32_t>();\n-\tinfo->lineLength = info->outputSize.width + hblank;\n \tinfo->pixelRate = ctrls.get(V4L2_CID_PIXEL_RATE).get<int64_t>();\n \n+\tconst ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n+\tinfo->minLineLength = info->outputSize.width + hblank.min().get<int32_t>();\n+\tinfo->maxLineLength = info->outputSize.width + hblank.max().get<int32_t>();\n+\n \tconst ControlInfo vblank = ctrls.infoMap()->at(V4L2_CID_VBLANK);\n \tinfo->minFrameLength = info->outputSize.height + vblank.min().get<int32_t>();\n \tinfo->maxFrameLength = info->outputSize.height + vblank.max().get<int32_t>();\n","prefixes":["libcamera-devel","v2","01/10"]}