From patchwork Thu Oct 6 13:17:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17542 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 456A3C327C for ; Thu, 6 Oct 2022 13:17:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BA04C62CEC; Thu, 6 Oct 2022 15:17:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665062275; bh=w2S4d6v1gYSnFkQxkmqriKMoaRZOOgpuTDPY4i3E45Q=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=iboEPCyd0ZfKu2Fi3s9CS8+Nkhm/X+386CHXTOCiht3TaVTScZeXhvmGXFHqW0CYj m0WozV29k5WkvCYsAhwba1e6aEkJTnJPG1aoU82YKP9lJVC6N6NtnQyx6S91srwoc0 pKyAMhYj3EZB1rMNxEd6ijPAeBLeXvMEF1IMnPojRCZaH8EQsSd3vJstotbXbVQcUM CudLDmKU40yBD/+MbQMMqmA3EEYwpdGsB6uClc4biA8StEdHvSzcBxHy4hfhblv6tI KfhxEUnWAi5dNgBbRIbA2q+mRWKcT/2CdWxWoooXiBiQ/R15eVv/yGqv7o8GrwwUyh RXutg1XJNMZwA== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 11CA062CEC for ; Thu, 6 Oct 2022 15:17:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="k9DtKtBB"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id a3so2732276wrt.0 for ; Thu, 06 Oct 2022 06:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=63HV8gWPDPKpyvSeClm2tYYD+NWm1ekUi/dYqoq+cHU=; b=k9DtKtBBfaoGfunaN0lvccv9C9VMGcHM+ARTFsuIsG1YQjH+ddFeo8WqrTa5eCahVM EDwve+tN2IITJeHDhK/qNfFmizF+ffWaE0YR3sZsqtLg+3b3ayWzjuNc22wTn13TfxaY /GbErVdXZKBuDYaqz5UbvDzKfk0sIIsGANrQsbNoyUTj8yAIXAkLRBNPWDSfvGf3PAK6 G1pa5EANDvv7QtT4WDav6KXYqOY7W10zUgaj4XMEFoYmPUTtwGZDUyiWRy0OhXvtl2GT FVfNV2iDPSjBxtB0Wf0Q6IS1r01CYWVDITL3Q3Fki9Mc551ChmHYmchnjagmy29mm/06 V5eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=63HV8gWPDPKpyvSeClm2tYYD+NWm1ekUi/dYqoq+cHU=; b=Ua0QxSDCQCLRe19lT5zJhVQ+uQl83u/8I2zJISlLO6tihF6d1+K15HToSRChHuckVa O0sO/WzkaEiyuuIFQk6MITtn+WoHxuKn3vX4UNv3LOnPvyh2z8DA0Q6mdOV7b5tOYIKh tr+0vVWyF+gqlH9U+GM2EXhrjRCnZqGy2cy+YqCuB02es03JQr8QRBm+dLzGs3wRmyD8 YHNr+FIifN+AKMM+HqiBD8Q4zY69+/2I/u67lJC+K0U75L3VGM+QXxyUhyNxYSr9lvx6 9YcwbIf5Mn4PTt5dxc1FBryfIo9uIWwAMYZmRrXANzwZjTysQ+Sp1PLkxHzN1EI4wzo8 bTew== X-Gm-Message-State: ACrzQf1sk5uIH3gk62pCJVGBdcVxKVfvoIfplYQ4wmTacVKAsMO0kzn8 7C9zj3qBGjUoLoAItPXnD9lm9DmTS9+Pjw== X-Google-Smtp-Source: AMsMyM6swrIA9Y0OEkUQjIbf5mjOcMNg8P/GHOJHQMnNZMTYlvG87NN2nNo3d5qJ4mWBccrdwLAahA== X-Received: by 2002:a5d:414c:0:b0:22c:de8a:d233 with SMTP id c12-20020a5d414c000000b0022cde8ad233mr3370151wrq.194.1665062273353; Thu, 06 Oct 2022 06:17:53 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q18-20020a056000137200b0022cc7c32309sm17986049wrz.115.2022.10.06.06.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 06:17:52 -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 Subject: [libcamera-devel] [PATCH v2 01/10] camera_sensor: Add minimum and maximum line length to IPACameraSensorInfo X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add fields for minimum and maximum line length (in units of pixels) to the IPACameraSensorInfo structure. This replaces the existing lineLength field. Update the ipu3, raspberrypi and rkisp1 IPAs to use IPACameraSensorInfo::minLineLength instead of IPACameraSensorInfo::lineLength, as logically we will always want to use the fastest sensor readout by default. Since the IPAs now use minLineLength for their calculations, set the starting value of the V4L2_CID_HBLANK control to its minimum in CameraSensor::init(). Signed-off-by: Naushir Patuck Tested-by: Dave Stevenson Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/core.mojom | 21 +++++++++++++++------ src/ipa/ipu3/ipu3.cpp | 6 ++++-- src/ipa/raspberrypi/raspberrypi.cpp | 2 +- src/ipa/rkisp1/rkisp1.cpp | 2 +- src/libcamera/camera_sensor.cpp | 15 +++++++++++++-- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom index 74f3339e56f2..2bc3028c22d6 100644 --- a/include/libcamera/ipa/core.mojom +++ b/include/libcamera/ipa/core.mojom @@ -172,10 +172,17 @@ module libcamera; */ /** - * \var IPACameraSensorInfo::lineLength - * \brief Total line length in pixels + * \var IPACameraSensorInfo::minLineLength + * \brief The minimum line length in pixels * - * The total line length in pixel clock periods, including blanking. + * The minimum allowable line length in pixel clock periods, including blanking. + */ + +/** + * \var IPACameraSensorInfo::maxLineLength + * \brief The maximum line length in pixels + * + * The maximum allowable line length in pixel clock periods, including blanking. */ /** @@ -189,7 +196,7 @@ module libcamera; * To obtain the minimum frame duration: * * \verbatim - frameDuration(s) = minFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second) + frameDuration(s) = minFrameLength(lines) * minLineLength(pixels) / pixelRate(pixels per second) \endverbatim */ @@ -204,7 +211,7 @@ module libcamera; * To obtain the maximum frame duration: * * \verbatim - frameDuration(s) = maxFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second) + frameDuration(s) = maxFrameLength(lines) * maxLineLength(pixels) / pixelRate(pixels per second) \endverbatim */ struct IPACameraSensorInfo { @@ -217,7 +224,9 @@ struct IPACameraSensorInfo { Size outputSize; uint64 pixelRate; - uint32 lineLength; + + uint32 minLineLength; + uint32 maxLineLength; uint32 minFrameLength; uint32 maxFrameLength; diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index b93a09d40c39..7e26fc5639c2 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -336,7 +336,8 @@ int IPAIPU3::init(const IPASettings &settings, /* Clean context */ context_.configuration = {}; - context_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate; + context_.configuration.sensor.lineDuration = sensorInfo.minLineLength + * 1.0s / sensorInfo.pixelRate; /* Load the tuning data file. */ File file(settings.configurationFile); @@ -499,7 +500,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, context_.frameContexts.clear(); /* Initialise the sensor configuration. */ - context_.configuration.sensor.lineDuration = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate; + context_.configuration.sensor.lineDuration = sensorInfo_.minLineLength + * 1.0s / sensorInfo_.pixelRate; /* * Compute the sensor V4L2 controls to be used by the algorithms and diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 8d731435764e..358a119da222 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -356,7 +356,7 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) * Calculate the line length as the ratio between the line length in * pixels and the pixel rate. */ - mode_.lineLength = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate); + mode_.lineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate); /* * Set the frame length limits for the mode to ensure exposure and diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 32feb1682749..ddb22d98eb41 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -246,7 +246,7 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, context_.configuration.hw.revision = hwRevision_; context_.configuration.sensor.size = info.outputSize; - context_.configuration.sensor.lineDuration = info.lineLength * 1.0s / info.pixelRate; + context_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate; /* * When the AGC computes the new exposure values for a frame, it needs diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 911fd0beae4e..83f81d655395 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -176,6 +176,15 @@ int CameraSensor::init() if (ret) return ret; + /* Set HBLANK to the minimum as a starting value. */ + const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK); + ControlList ctrl(subdev_->controls()); + + ctrl.set(V4L2_CID_HBLANK, hblank.min().get()); + ret = subdev_->setControls(&ctrl); + if (ret) + return ret; + return applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff); } @@ -883,10 +892,12 @@ int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const return -EINVAL; } - int32_t hblank = ctrls.get(V4L2_CID_HBLANK).get(); - info->lineLength = info->outputSize.width + hblank; info->pixelRate = ctrls.get(V4L2_CID_PIXEL_RATE).get(); + const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK); + info->minLineLength = info->outputSize.width + hblank.min().get(); + info->maxLineLength = info->outputSize.width + hblank.max().get(); + const ControlInfo vblank = ctrls.infoMap()->at(V4L2_CID_VBLANK); info->minFrameLength = info->outputSize.height + vblank.min().get(); info->maxFrameLength = info->outputSize.height + vblank.max().get();