From patchwork Mon Jun 26 13:08:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18759 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 6BB5ABE175 for ; Mon, 26 Jun 2023 13:08:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A6574628C0; Mon, 26 Jun 2023 15:08:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1687784917; bh=Q3Lwx6XH+Oc1BoiMWGu5EfNDrmZLWL2BEGkQvWCEbic=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=z8JdMTcrGNcMmakkI/B38wUhSDA0ieH6uZmRR5k9bzGajSOo1jqDF2vfO/IwG+KZt AddDXmc/3Axbm8I1qM9Tq4dWPOWtrmn4yJFkrP0ULJ5/yorkWPnVDGM2HHbme1uk6o Q4oF4c5YlTqA0KeKZCxfMjaDp6CSDmgYCunRv7ohYFTa7tpokSF6e6mLwtBsaCswJ1 DF/7hqVoO5ud6zaXBvZTcNrCoO+W2vWUHhGYn4GW9Ior0+V+UZOf8hJRIVz9nyRLQC R25t4gGFPIribWnuAbTNddNcqo54MeJb6Hpc4idwk70NqV2BAhgrmhiMQbCkorrxJj MxPl0+KO0W/XQ== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C6C8628BB for ; Mon, 26 Jun 2023 15:08:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="nQrQjOhV"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3112f256941so2895744f8f.1 for ; Mon, 26 Jun 2023 06:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1687784915; x=1690376915; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lfhqtO9D3edc5jlbyLSsJgI8I8JaMS7UlBA82m9l4Ac=; b=nQrQjOhV9/Z5KYoLikCY1nch79VR36ivMLoIL22F+7D5kSSWMkOBUEopMLY/NZyAVB AyddwHnfjDCqLACXk3N00MDdRoaEN7XHUltAaO8PnZuKntpbj6Cd+U+e72hmdpCrAnUS JWuKMCoIpoEcq9GArSoB9BXvfyemezQrkdqTAXymeAqFvmNhhnf9pWvFJGDONoWwx3UN 26YJFV86txmfBned4VfSVa1b3WqM5YLbp7eijbTRkgrXtZabIRIHhjJjom4TVYC+6H0G fASUEXO5NLO6t8MUi5T14WiaGP57A29Lxvd0vE5Sz0XQzFtaZX73bpB34DBj/w9IATb9 WroQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687784915; x=1690376915; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lfhqtO9D3edc5jlbyLSsJgI8I8JaMS7UlBA82m9l4Ac=; b=kKzmZpG6M5CSZjHlJbXKv8z0mEXhXLCBTG6YVRNNHsszGG3pynBKWt7phTgjySN5Nh UGOuayIokN6/TCn1NiLZK3pBU/Z4qay8GnKc0OgNozGsweFbplZp/+v4bVYSrvuwNtwH DvN26r3473rzXdolcSQcDoG9idzydLuCgZrJAZKxeaerJWvy9aZ1Nl9c5bInPeeJSkcz rsu5sUGA9hb6Xl5CTQdL6ZiYBvqtw9iRghmXDmQqD7peoIxQPL8FNuOAvfez7m0QhtuJ Qgom5Tnh9rrqFtfWawK8ZxVPrT+MJunkW8WXj80+gHY4wmW2ADjT0B1ulQbcjTKdm4m5 tf3w== X-Gm-Message-State: AC+VfDzHiTovs+05FuidMLXRsOHbXwhKeyAticHnl7mooLbv4evAZhCx PQk6iAWdTJFCQaQ5m8iHXQ76Yepp5O7qUg9gnYjZyw== X-Google-Smtp-Source: ACHHUZ47Rv85b1PjugBdagp8FASwXbidetHmjmbbi4OgwSxVJmgqWtL2K3Tn7f+HGKddL4rUgTi0cA== X-Received: by 2002:adf:ea90:0:b0:30f:c5b1:23ef with SMTP id s16-20020adfea90000000b0030fc5b123efmr21502445wrm.41.1687784915451; Mon, 26 Jun 2023 06:08:35 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f1-20020a5d5681000000b0030647449730sm7429589wrv.74.2023.06.26.06.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 06:08:34 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 26 Jun 2023 14:08:33 +0100 Message-Id: <20230626130833.15895-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] ipa: rpi: imx708: Fix mode switch drop frame count 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 Cc: Nick Hollinghurst Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The imx708 must drop a single frame on startup - but only when in HDR mode. Non-HDR modes do not need to drop frames. Fix the logic in hideFramesModeSwitch() which currently unconditionally advertises to drop one frame. Unfortunately there is no clear way to tell if the sensor is in the HDR mode. So for now, look the resolution and framerate to deduce this. Additionally ensure we override hideFramesStartup() and return the same number as hideFramesModeSwitch(). Bug: https://github.com/raspberrypi/libcamera-apps/issues/524 Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/rpi/cam_helper/cam_helper_imx708.cpp | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp index 641ba18f4b9d..2cd7afdbd8ec 100644 --- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp +++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp @@ -21,6 +21,8 @@ using namespace RPiController; using namespace libcamera; using libcamera::utils::Duration; +using namespace std::literals::chrono_literals; + namespace libcamera { LOG_DECLARE_CATEGORY(IPARPI) } @@ -56,7 +58,8 @@ public: int &vblankDelay, int &hblankDelay) const override; bool sensorEmbeddedDataPresent() const override; double getModeSensitivity(const CameraMode &mode) const override; - unsigned int hideFramesModeSwitch() const override { return 1; } // seems to be required for HDR + unsigned int hideFramesModeSwitch() const override; + unsigned int hideFramesStartup() const; private: /* @@ -225,6 +228,26 @@ double CamHelperImx708::getModeSensitivity(const CameraMode &mode) const return (mode.width > 2304) ? 1.0 : 2.0; } +unsigned int CamHelperImx708::hideFramesModeSwitch() const +{ + /* + * We need to drop the first startup frame in HDR mode. + * Unfortunately the only way to currently determine if the sensor is in + * the HDR mode is to match with the resolution and framerate - the HDR + * mode only runs upto 30fps. + */ + if (mode_.width == 2304 && mode_.height == 1296 && + mode_.minFrameDuration <= 1.0s / 30) + return 1; + else + return 0; +} + +unsigned int CamHelperImx708::hideFramesStartup() const +{ + return hideFramesModeSwitch(); +} + void CamHelperImx708::populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const {