From patchwork Thu Jan 13 14:15:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 15278 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 CB943BF415 for ; Thu, 13 Jan 2022 14:16:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0BA7260931; Thu, 13 Jan 2022 15:16:05 +0100 (CET) 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="tD3mwsaF"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D2355604F4 for ; Thu, 13 Jan 2022 15:16:02 +0100 (CET) Received: by mail-wm1-x32e.google.com with SMTP id l4so3963223wmq.3 for ; Thu, 13 Jan 2022 06:16:02 -0800 (PST) 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=XLkteIYOkjfpJvJPYrD7aDyyVOmx8YdVUWBTDuRLV9g=; b=tD3mwsaFcfEDDKP6UOiaAKsKIfvUv9n0Ko4VVaVV3iDX9W4fHuoaQM7bvURpPKJAdO CJd7nySX11dtgiB/ptinkBOj3NzuRliSdx81Bz5wj6IWv/NS7mB4QQtvMbcEqorHW9gV cNMEjFqrKE/bJEr+nfHnmzJiGHOk4GcgHYHm0hcm1sWU7zCcT+rp2rfE3g4RgAnsmK+m o9quGGkNBakzZnryTLPqzuTjI+lm04uGBK3XAh5cmKyQD1o1fhiN5D51VlcUt09NeO8h ZkhoHRNwWt+xbPpZ5CvUp1xSHxqnzqWzGwzdsuGSxWQNGhC47Mw+4gh//zB9f8Icr+tN bf8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XLkteIYOkjfpJvJPYrD7aDyyVOmx8YdVUWBTDuRLV9g=; b=ng500QRXeNZN0/EXjguhTXQuqwbq6ZCMI8QydQrot5dYZQ1bCOZIfimR/Rd0AJmKGN KaP59j4jaDG7UFTLZmuPkt/JBzw282pGFE+H3d9kKKFcMuYVT2f7cbIn175uKKxnFQBJ 1exx3o9JIBeik84IdN8FuxV5HvIyQZu1EoGS+yGTyKb7m/uHfOQ8mkONGJicBzfOOlyf n8YNgceK9+TyS99tpj/Qkqpisvib3gOeISKfpGR6d/tRZgZ7sypaIBOK1IrA/aQyx0cV V0TNqdcIRvj/acIdnAlYmLnK82z3fpw9C7ufy4wbIeQlIPdUA25aqKeTodjPcqcBKJis XMXQ== X-Gm-Message-State: AOAM531ZKh7UUVUr16+APrDCsFC8YQqxLaaQBkKHcyLsp3S0BEzZfig+ PrA0mWNj1se3BxjiQirn+Eh/2+98LX2Aod6s X-Google-Smtp-Source: ABdhPJxqbosdBnIB7Md0TZx+t1LNqzkyoxklI4JKPP0z7Spa5bgi770yxKkDmXpiEVEQs7t/4iGDtQ== X-Received: by 2002:a7b:c772:: with SMTP id x18mr3952875wmk.158.1642083362230; Thu, 13 Jan 2022 06:16:02 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id b2sm3284584wrd.35.2022.01.13.06.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jan 2022 06:16:01 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 13 Jan 2022 14:15:56 +0000 Message-Id: <20220113141558.5805-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 0/2] Make sensor use its native Bayer order 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 everyone This patch is a replacement for a patch formerly titled "Fix calculation of sensor's native Bayer order". In this version we resolve an anomaly where the Bayer orders in CameraSensor::init() were not well-defined - they can depend on whatever hflip/vflip settings the camera happens to have when opened. A bug was introduced when the Raspberry Pi moved over to using media controller whereby it ended up getting the wrong native Bayer order (it was trying to clear the h/vflip bits, only it was too late because the sensor had already cached the formats). So anyway, the consequence of this was that the Bayer order in any raw stream would frequently be wrong, meaning it would also be incorrect in DNG files which is how I noticed it - the tuning tool was producing garbage! I also suspect that other pipeline handlers (e.g. IPU3) may have similar problems, I don't know if anyone has tested the behaviour of DNG files when different transforms are requested of the sensor. Perhaps someone can enlighten me on that? But the change in this patch set seems like it will be helpful to other PHs as well. So there are 2 commits here: 1. The first commit resets the h/vflip bits of the sensor when it is opened, so that we know we shall get the true native Bayer order. 2. The 2nd commit just simplifies the RPi implementation a little, now that we can rely on the sensor's formats using the native order. I'm definitely open to suggestions on this - my previous attempt left the camera sensor alone and made the PH reverse engineer the true Bayer order from the current formats and the sensor's current flip settings. But this seems a bit fussy, particularly when other pipeline handlers must surely copy this somewhat ugly behaviour (or not work). Thanks! David David Plowman (2): libcamera: camera_sensor: Clear camera flips after opening the device pipeline: raspberrypi: Simplify calculation of sensor's native Bayer order src/libcamera/camera_sensor.cpp | 16 ++++++++++++++++ .../pipeline/raspberrypi/raspberrypi.cpp | 9 ++------- 2 files changed, 18 insertions(+), 7 deletions(-)