From patchwork Thu May 27 08:45:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12442 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 10ADDBDB80 for ; Thu, 27 May 2021 08:45:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 23A2168927; Thu, 27 May 2021 10:45:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="K/6QZSZr"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B81A9602AA for ; Thu, 27 May 2021 10:45:46 +0200 (CEST) Received: by mail-wm1-x32f.google.com with SMTP id f75-20020a1c1f4e0000b0290171001e7329so2011870wmf.1 for ; Thu, 27 May 2021 01:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RCI3hhF/EoJAco3nftLQ9AcYiWBuuPTIAtAYs593new=; b=K/6QZSZrAqewhQUodA5PmVhOncUoooLWH6jFfnVrbi4XOz5BUrJks6XRKBek//r6JN 5pYi8PD4H2MaykDyEvq6K872/sRet9At/8FuH9GlwimHA0C9e5LmhSOaBYzIATSSqnf+ 9Vypp2Ne10TxPqO80EoFmTe2jwJEjBO7pCR+qskSXLzaRw2U3cKUxxcHTzcsvnL3BM5g TFrs5dMkG6ijNgatUVIL//+OolMMRn4PBE65Io0IYi9FSNTsM0JL5g6QTwY6/ZUS3gP1 YR4Gr7hu0ERF76nLLKrmvc/G5W2/VweFBqqzLKJxF15V6V3Ry7AFmTQwHA54m5hiyWbX u9NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RCI3hhF/EoJAco3nftLQ9AcYiWBuuPTIAtAYs593new=; b=i+SD1dYErYBlqPgoQ29CQ0zBanawa5N67jvHQxkqyCMgfAOyrArejmquh4NZmAwppi JlLRojUqHlGZbpodeFLF+1YLnC6zE2BN3Y2YuExdkjmBmmRDxwUh1f5/i/dn11WwIpve 3UeTM519z/6U6Y0qQ2+oVbpKLZyMrhKe8TJ0RJlfN6MhA3LLvd+hQ4nWdxJd3oRb2FHp edXav0pFMY3dS4e4h9LT5E4NE+1WhD0V8mQgq7PQXIRoNS5X0MxXV66IlLesztdy+1W2 gzzGPuxRE+02YRgvLb9i6TcwRheCSt7dRlq4RIdHr+tz5c7rah07klDlw7OaIuzpJY5O ZYDA== X-Gm-Message-State: AOAM533PGJNs+TjIWjD5nlVxMBd5TFTUYPbCy8IMPfLvSf59tzXWrQg0 Xa/dJPuGCmOzbYXSnXXHdYXu0youcOOEvA== X-Google-Smtp-Source: ABdhPJxdTGfsKOL4sqyqDmY4lw0eMoril/tnqItk0pQHMY5DAGqjqZNZnmLln9d8ZnoP0QAy4fmPZg== X-Received: by 2002:a05:600c:35c3:: with SMTP id r3mr7191755wmq.63.1622105145969; Thu, 27 May 2021 01:45:45 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id q11sm2325553wrx.80.2021.05.27.01.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 01:45:45 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 27 May 2021 09:45:38 +0100 Message-Id: <20210527084540.9983-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 0/2] Raspberrypi: support per-mode camera sensitivities 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi Here's an implementation of "per-mode camera sensitivities", following on from a recent discussion email. This is taking the "don't lie, even a little" approach, which I am inclined to prefer. There are two patches as follows, though still some outstanding questions. 1. The first patch adds a "sensitivity" field to our camera mode structure. The main question here is how to set this value correctly. - For now, I've just used a virtual function in the CamHelper. This is dead simple and it works. (Though the sensor that needs this function is still unreleased.) - But should I be using the sensor database? I'd have to add fields for "full resolution sensitivity", "2x2 binned sensitivity" as a minimum, though why stop there? There could be many different binning modes! Also, I'd have to get this through to the IPA. Would that mean writing a serialiser/deserialiser? Some clues on how to do that would be helpful, I looked at ipa_data_serializer.cpp but it was quite intimidating... - Or would we be better getting the value from the driver? That might need a new read-only V4L2 control. And how would we pass that to the IPA, in the IPACameraSensorInfo? It already has mode-dependent fields... 2. The second patch takes care of the changing sensitivity in the AEC/AGC, when the SwitchMode method is called. Finally, I think there's still a problem with this approach. Suppose you wanted to run preview, then do a capture with the same output brightness, but selecting the exposure and gain explicitly for yourself. You simply can't do this without knowing the sensitivity of the camera modes. So how could we report this? Note that signalling it in metadata with completed requests is too late - the typical pattern would be: Stop camera -> Reconfigure camera -> Recalculate exposure/gain -> Start camera Opinions both sought and appreciated! Best regards David David Plowman (2): ipa: raspberrypi: Add sensitivity field to camera mode ipa: raspberrypi: AGC: handle modes with different sensitivities src/ipa/raspberrypi/cam_helper.cpp | 5 ++++ src/ipa/raspberrypi/cam_helper.hpp | 3 +++ src/ipa/raspberrypi/controller/camera_mode.h | 2 ++ src/ipa/raspberrypi/controller/rpi/agc.cpp | 25 ++++++++++++++++---- src/ipa/raspberrypi/controller/rpi/agc.hpp | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 12 ++++++++++ 6 files changed, 43 insertions(+), 5 deletions(-)