From patchwork Tue Jun 27 13:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18764 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 63B19BDB1D for ; Tue, 27 Jun 2023 13:06:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 82369628BA; Tue, 27 Jun 2023 15:06:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1687871161; bh=hwkbu2ZlaGEEVQAULyS5Pi4znBIDLwSMszR3Efp+LV8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=T76PVADCGVWSqgaXFj9/II9VeVDomZhw8akME8gUM7MtFSAxYjcTcDrbRgZ+DneJH ZPToZC4gln3Iyk4cwcIlDGo+eGA4ABlad9X5N+1vCKsZ1P2NuO9g79nvdf7cUdedBU 6XzmdLxNN7Exvvhl/5bc5S4a/t9B3a2gm4R0I8ElQpsUPMa6yNJ53dUPyFTQmAxZVJ cgk8a0f432r3T3+EC2ejbHHoLF1O8SOLgdoJGlY9ZCV/tIVdbGSzMVqYC8NkBhFIIH DMxdaN0/G2J6IF1w85PXkApVQwotJaFRCtISq81r64TZUEM5VA1bB6P0+FYJwgft5b xRV14H4FPllCw== Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A00761E3F for ; Tue, 27 Jun 2023 15:05:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="hS6f8/AK"; dkim-atps=neutral Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4fb7589b187so3264065e87.1 for ; Tue, 27 Jun 2023 06:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1687871158; x=1690463158; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=H+BCB52QV4NnlSj2RspJGxO3zLDy++cQU4hki3qIVyY=; b=hS6f8/AKWd+hnFPYdlPEcd/Out4A76h5VsPlfauFyjctHtYAwA1GNX4JZQimQ2N/qJ Fm2/9131Dk/XfdxwyqEfR9nKk4W7aEg6Am7rOtJGEP7FhFvcJuhOnNiV89a1TOucZRu8 gW9iQ0jU8cP1AJuew/W/Kt0y79B+hA4tZyU/Gh4NqlQD5+4F3NGt6a4IDVMxH8aB7/aw 2sJYaxwWeDYnYjw21XvTJzhI5Dy2Ne7EuUNYnuEYXYLmC27M97jmsLB43OuboLzGiaGC ptU+or9ld2i2t+74Ao3v+9gIuZg8hufAffoe08odcxApHZpRilf9dfwmeb6N35DwaX6C A4Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687871158; x=1690463158; 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=H+BCB52QV4NnlSj2RspJGxO3zLDy++cQU4hki3qIVyY=; b=HtWMqfMpyEfI7n/bRMXtvKFNy7NdPoUfcEHDbNsMZIrfrhz13/oBeL5Rsb0Wt15VUC Ex/yC0o3003ahViOnYEoVScinPpUnCBp+LGljCscnMU+broI2gOuDZHB7tUfDOtz3nHS pPkfh7AO5s3lpXuZ7CXIe6suJo4/nkezD2PKHYxbMTHq6H1eqV2IrabCyiMgU7oz1y6N wIdO+BuL1nl5yUdCSEAq1eyg0Aj2hkMQMWSE116FIpm/+ZNu2JLe7s2mIUNENIJDMKkw 8ckuZgy/BBnVZaJOtq61AX8ZqJqliYso9Z+NK2ZCcbUVM6LIO5o2hS/0i71+6CFYPI9l QhMw== X-Gm-Message-State: AC+VfDwkdpk1/61WhZcK7Yedz5i/x361lvg44f4ChtxGkK9tusdB9eP7 5TdlA2FBbWpG+ZQK/KoPr91UprFnOlMTvn/b0RAvkQ== X-Google-Smtp-Source: ACHHUZ7VCeQPlfiZYPQhjYtm8+3A9BwztHb1nF41yLiOxpMjAvskx2w9mnb7cKkaYmTPdMa1gox0PA== X-Received: by 2002:a19:661a:0:b0:4f6:2b51:2f74 with SMTP id a26-20020a19661a000000b004f62b512f74mr16844920lfc.52.1687871158114; Tue, 27 Jun 2023 06:05:58 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id c13-20020a7bc00d000000b003f735ba7736sm10860597wmb.46.2023.06.27.06.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 06:05:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Jun 2023 14:05:53 +0100 Message-Id: <20230627130553.26940-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] 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 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changes since v1: - Fix a typo in the comparison statement. --- 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..9bc0272dd4c1 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 / 32) + return 1; + else + return 0; +} + +unsigned int CamHelperImx708::hideFramesStartup() const +{ + return hideFramesModeSwitch(); +} + void CamHelperImx708::populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const {