From patchwork Thu Nov 3 10:40:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 17749 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 8667BBD16B for ; Thu, 3 Nov 2022 10:40:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C490663081; Thu, 3 Nov 2022 11:40:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1667472034; bh=F9/8KhYbmBz+V9WLlTiKINNg8rfHTzOjwyi+hj4fkUg=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vij1bjoWVBNB5kuN3fYbrcKtwu2k9mAfO4QuM55RQIMUB5u9/7/W0b5juTmBI47Qr h64HziXOAE9fmuvnXel6oJce4f0MbaL0kUoV+FnmS44+XaYSAFJN6u4/aXL17WveDu I7i1xVCyuEGgcpdd1wyajuTPPa4wCd5WHgJkVKUDHpBAZ/r1x19kVbFn4+rqTqHTzm 43dY+9HnJLtJTweLMB7OFCHRkwQ8pC8BNXLlJBfq6Fi/S7Jd1GJdjLYHmyXP82uWqs 5WaJL1+CU/QmYUvU7jSUROjt0sO/K+xw2EGPMd5jiJ1P2HVs9P40VC5sn9S9m0RuMo QDXgYU3VGkWNQ== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9847263037 for ; Thu, 3 Nov 2022 11:40:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="crBd1uMm"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id ja4-20020a05600c556400b003cf6e77f89cso3602987wmb.0 for ; Thu, 03 Nov 2022 03:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kp9fCueUqf0NkLs2a3gGIvcV/hSjaiEeWq/CMbcFQWk=; b=crBd1uMm+t5wp+/PbFqqfW2TKEdO4n33ZrxhbP7q75aSs5RWF2J7wiTvkxNqr8+ybB WD5sa/vXoTTvvz6XBRoF3AjzQwGKdJEiNwA9AIE+n+SvB5X+yFGSnMsEfz6cjEaDVwuq XOWruSFxxs2wl570xJ7pAw+S6EzdImS/3HBYiSdDRnnj7wbdDGqN2LFevLlBylEljFiF 6e9l+bfpCIajQ/tblOxoghW3dcePQsfW0TTnPYf1SFfUiwSgx7+6i/XwIDaYgoNuuXUr zAhPJ77QcOnvaZ12iaaQFIr5sQhbeAV6RMXPt36aIJ7tfXiCVc/mrHGgtVawtE19Wcmc Fzhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=kp9fCueUqf0NkLs2a3gGIvcV/hSjaiEeWq/CMbcFQWk=; b=qlBaTeCrufgTnP0upXT3DIW1wK90Us1WAK3Xjjbszq4t2TBShLEVO45o5RRaI12CXN aqhFiJfqKAqYQ9RkeXTrBIA9G7miWBm38fC1aTG5Y4c9vQv/XHvq12jueQ//Jxrd3FQT Ka1pDKH9Wetc1dktEsRHlJ1cjITlm8cfdwKw/uXhrZGtqCK0S1gBf99Sj6pue6GCksdN Ys1J6CxOsWG/bHb4JIPVaSAbTbGoVQ4alfzFOsqa6uL6Buj5ivp/+1sbJO8lmgCuPVBA +uACZAak6EzM4RPc386K5hYwPoVVFXsXbUTvL2hcVX8r6XyLDoA5bTUfGp0Fvvapq8QK jwdw== X-Gm-Message-State: ACrzQf2RXqOMhUM8i9GZJOcy2Fw5DEhhsmkUgVekTdK6O+iCvpD+G72S XUd64+OUZz9NdVlYBcVRIpGO1pOCgq9Q9g== X-Google-Smtp-Source: AMsMyM5uyTcGR4WeHVCysVaDxqdk9NW/zp2VMISXJ7B1lWJS9PT+MH3icYX3jY21YIYUF8oWiDm4Xg== X-Received: by 2002:a05:600c:1c88:b0:3c6:d9a5:a083 with SMTP id k8-20020a05600c1c8800b003c6d9a5a083mr29021958wms.54.1667472031803; Thu, 03 Nov 2022 03:40:31 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id f15-20020a5d50cf000000b0022e36c1113fsm516363wrt.13.2022.11.03.03.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 03:40:31 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Nov 2022 10:40:25 +0000 Message-Id: <20221103104027.4197-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 0/2] Resolve invalid attempts to set sensor flip controls 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: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi everyone (Warning: may affect all pipeline handlers!) I wanted to start the ball rolling on this. The problem is that when we enumerate the cameras in the system, we try to set some of the controls (specifically the HFLIP and VFLIP ones, and also later HBLANK). But this will fail if we don't "own" the camera, for example, it is already in use elsewhere. These patches address just the flip bits and not the HBLANK, though I think the latter is a more straightforward problem. The flip bits are troublesome because they affect the reported Bayer orders. So here the idea is to store the formats in the sensor's native Bayer order, as we were doing before. Only we can't reset the flip bits now, we have to query them and transform any Bayer formats the sensor gives us back into the native order. Two patches implement this: 1. The first patch adds a function to turn BayerFormats back into mbus codes. I couldn't see that we had functions to do this already, but please correct me if I missed something! 2. The second patch queries the flip bits and transforms any BayerFormats back into the native order to be stored. As I said, this potentially affects all pipeline handlers, which is why I left it "RFC" for the moment. I did take a look through them all to see what we might need to do: raspberrypi.cpp I think this PH is OK. We assume we're given the native Bayer order and transform it according to the final sensor transform, setting the flip bits every time. We update the format in any raw stream to match. uvcvideo.cpp, simple.cpp These appear to hardcode the transform to the Identity. I think mostly they should be OK because the formats here won't be raw and you can't have raw streams (?). Probably they should clear the flip bits to zero where these controls exist, perhaps someone who knows more about them could comment. rkisp1.cpp: Seems to force the transform to the Identity as well. So I think this is like the above ones, it should be OK though it probably needs to clear the sensor flip bits as well. ipu3.cpp: This one does handle transforms and appears to set the flip bits, so that's good. I couldn't see it transforming the Bayer order for raw streams correctly, so that probably wants checking. (To be fair, this looks suspect already and is not made worse by these changes!) Thoughts and opinions gratefully received, as always. Thanks! David David Plowman (2): libcamera: bayer_format: Add toMbusCode method libcamera: camera_sensor: Do not clear camera flips when listing formats include/libcamera/internal/bayer_format.h | 1 + src/libcamera/bayer_format.cpp | 12 ++++++ src/libcamera/camera_sensor.cpp | 51 +++++++++++++++++++---- 3 files changed, 56 insertions(+), 8 deletions(-)