{"id":17749,"url":"https://patchwork.libcamera.org/api/covers/17749/?format=json","web_url":"https://patchwork.libcamera.org/cover/17749/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20221103104027.4197-1-david.plowman@raspberrypi.com>","date":"2022-11-03T10:40:25","name":"[libcamera-devel,RFC,0/2] Resolve invalid attempts to set sensor flip controls","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"mbox":"https://patchwork.libcamera.org/cover/17749/mbox/","series":[{"id":3595,"url":"https://patchwork.libcamera.org/api/series/3595/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3595","date":"2022-11-03T10:40:25","name":"Resolve invalid attempts to set sensor flip controls","version":1,"mbox":"https://patchwork.libcamera.org/series/3595/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/17749/comments/","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8667BBD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  3 Nov 2022 10:40:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C490663081;\n\tThu,  3 Nov 2022 11:40:34 +0100 (CET)","from mail-wm1-x329.google.com (mail-wm1-x329.google.com\n\t[IPv6:2a00:1450:4864:20::329])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9847263037\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Nov 2022 11:40:32 +0100 (CET)","by mail-wm1-x329.google.com with SMTP id\n\tja4-20020a05600c556400b003cf6e77f89cso3602987wmb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 03 Nov 2022 03:40:32 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tf15-20020a5d50cf000000b0022e36c1113fsm516363wrt.13.2022.11.03.03.40.30\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 03 Nov 2022 03:40:31 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1667472034;\n\tbh=F9/8KhYbmBz+V9WLlTiKINNg8rfHTzOjwyi+hj4fkUg=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=vij1bjoWVBNB5kuN3fYbrcKtwu2k9mAfO4QuM55RQIMUB5u9/7/W0b5juTmBI47Qr\n\th64HziXOAE9fmuvnXel6oJce4f0MbaL0kUoV+FnmS44+XaYSAFJN6u4/aXL17WveDu\n\tI7i1xVCyuEGgcpdd1wyajuTPPa4wCd5WHgJkVKUDHpBAZ/r1x19kVbFn4+rqTqHTzm\n\t43dY+9HnJLtJTweLMB7OFCHRkwQ8pC8BNXLlJBfq6Fi/S7Jd1GJdjLYHmyXP82uWqs\n\t5WaJL1+CU/QmYUvU7jSUROjt0sO/K+xw2EGPMd5jiJ1P2HVs9P40VC5sn9S9m0RuMo\n\tQDXgYU3VGkWNQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=kp9fCueUqf0NkLs2a3gGIvcV/hSjaiEeWq/CMbcFQWk=;\n\tb=crBd1uMm+t5wp+/PbFqqfW2TKEdO4n33ZrxhbP7q75aSs5RWF2J7wiTvkxNqr8+ybB\n\tWD5sa/vXoTTvvz6XBRoF3AjzQwGKdJEiNwA9AIE+n+SvB5X+yFGSnMsEfz6cjEaDVwuq\n\tXOWruSFxxs2wl570xJ7pAw+S6EzdImS/3HBYiSdDRnnj7wbdDGqN2LFevLlBylEljFiF\n\t6e9l+bfpCIajQ/tblOxoghW3dcePQsfW0TTnPYf1SFfUiwSgx7+6i/XwIDaYgoNuuXUr\n\tzAhPJ77QcOnvaZ12iaaQFIr5sQhbeAV6RMXPt36aIJ7tfXiCVc/mrHGgtVawtE19Wcmc\n\tFzhw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"crBd1uMm\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=kp9fCueUqf0NkLs2a3gGIvcV/hSjaiEeWq/CMbcFQWk=;\n\tb=qlBaTeCrufgTnP0upXT3DIW1wK90Us1WAK3Xjjbszq4t2TBShLEVO45o5RRaI12CXN\n\taqhFiJfqKAqYQ9RkeXTrBIA9G7miWBm38fC1aTG5Y4c9vQv/XHvq12jueQ//Jxrd3FQT\n\tKa1pDKH9Wetc1dktEsRHlJ1cjITlm8cfdwKw/uXhrZGtqCK0S1gBf99Sj6pue6GCksdN\n\tYs1J6CxOsWG/bHb4JIPVaSAbTbGoVQ4alfzFOsqa6uL6Buj5ivp/+1sbJO8lmgCuPVBA\n\t+uACZAak6EzM4RPc386K5hYwPoVVFXsXbUTvL2hcVX8r6XyLDoA5bTUfGp0Fvvapq8QK\n\tjwdw==","X-Gm-Message-State":"ACrzQf2RXqOMhUM8i9GZJOcy2Fw5DEhhsmkUgVekTdK6O+iCvpD+G72S\n\tXUd64+OUZz9NdVlYBcVRIpGO1pOCgq9Q9g==","X-Google-Smtp-Source":"AMsMyM5uyTcGR4WeHVCysVaDxqdk9NW/zp2VMISXJ7B1lWJS9PT+MH3icYX3jY21YIYUF8oWiDm4Xg==","X-Received":"by 2002:a05:600c:1c88:b0:3c6:d9a5:a083 with SMTP id\n\tk8-20020a05600c1c8800b003c6d9a5a083mr29021958wms.54.1667472031803; \n\tThu, 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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 0/2] Resolve invalid attempts to set\n\tsensor flip controls","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Hi everyone\n\n(Warning: may affect all pipeline handlers!)\n\nI wanted to start the ball rolling on this. The problem is that when\nwe enumerate the cameras in the system, we try to set some of the\ncontrols (specifically the HFLIP and VFLIP ones, and also later\nHBLANK). But this will fail if we don't \"own\" the camera, for example,\nit is already in use elsewhere.\n\nThese patches address just the flip bits and not the HBLANK, though I\nthink the latter is a more straightforward problem. The flip bits are\ntroublesome because they affect the reported Bayer orders.\n\nSo here the idea is to store the formats in the sensor's native Bayer\norder, as we were doing before. Only we can't reset the flip bits now,\nwe have to query them and transform any Bayer formats the sensor gives\nus back into the native order. Two patches implement this:\n\n1. The first patch adds a function to turn BayerFormats back into mbus\ncodes. I couldn't see that we had functions to do this already, but\nplease correct me if I missed something!\n\n2. The second patch queries the flip bits and transforms any\nBayerFormats back into the native order to be stored.\n\nAs I said, this potentially affects all pipeline handlers, which is\nwhy I left it \"RFC\" for the moment. I did take a look through them all\nto see what we might need to do:\n\nraspberrypi.cpp\n\nI think this PH is OK. We assume we're given the native Bayer order\nand transform it according to the final sensor transform, setting the\nflip bits every time. We update the format in any raw stream to match.\n\nuvcvideo.cpp, simple.cpp\n\nThese appear to hardcode the transform to the Identity. I think mostly\nthey should be OK because the formats here won't be raw and you can't\nhave raw streams (?). Probably they should clear the flip bits to zero\nwhere these controls exist, perhaps someone who knows more about them\ncould comment.\n\nrkisp1.cpp:\n\nSeems to force the transform to the Identity as well. So I think this\nis like the above ones, it should be OK though it probably needs to\nclear the sensor flip bits as well.\n\nipu3.cpp:\n\nThis one does handle transforms and appears to set the flip bits, so\nthat's good. I couldn't see it transforming the Bayer order for raw\nstreams correctly, so that probably wants checking. (To be fair, this\nlooks suspect already and is not made worse by these changes!)\n\nThoughts and opinions gratefully received, as always.\n\nThanks!\nDavid\n\nDavid Plowman (2):\n  libcamera: bayer_format: Add toMbusCode method\n  libcamera: camera_sensor: Do not clear camera flips when listing\n    formats\n\n include/libcamera/internal/bayer_format.h |  1 +\n src/libcamera/bayer_format.cpp            | 12 ++++++\n src/libcamera/camera_sensor.cpp           | 51 +++++++++++++++++++----\n 3 files changed, 56 insertions(+), 8 deletions(-)"}