{"id":15279,"url":"https://patchwork.libcamera.org/api/1.1/patches/15279/?format=json","web_url":"https://patchwork.libcamera.org/patch/15279/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220113141558.5805-2-david.plowman@raspberrypi.com>","date":"2022-01-13T14:15:57","name":"[libcamera-devel,v2,1/2] libcamera: camera_sensor: Clear camera flips after opening the device","commit_ref":"7f1e39e3e227ab9e2a80fb47abe397c515d5ba38","pull_url":null,"state":"accepted","archived":false,"hash":"cfcce83544323b059d1ea5a8072038d3145678fe","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15279/mbox/","series":[{"id":2893,"url":"https://patchwork.libcamera.org/api/1.1/series/2893/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2893","date":"2022-01-13T14:15:56","name":"Make sensor use its native Bayer order","version":2,"mbox":"https://patchwork.libcamera.org/series/2893/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15279/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15279/checks/","tags":{},"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 006D9C325A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Jan 2022 14:16:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 81887605A8;\n\tThu, 13 Jan 2022 15:16:06 +0100 (CET)","from mail-wr1-x436.google.com (mail-wr1-x436.google.com\n\t[IPv6:2a00:1450:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C40A5604F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jan 2022 15:16:03 +0100 (CET)","by mail-wr1-x436.google.com with SMTP id r28so10395199wrc.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jan 2022 06:16:03 -0800 (PST)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tb2sm3284584wrd.35.2022.01.13.06.16.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 13 Jan 2022 06:16:02 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"YnJ6M6i0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=1gghCCn3+u5hZC9uavWRxTF4TMcfMQGnUBz1f6/Oh/0=;\n\tb=YnJ6M6i0juUtUBdIosECvCj7DTXwnT5YpypjXgaf/n5sWBIo5+y4K9TKeUSLYaYYAf\n\t8UU7yzCxI7aJ+3MN5JN5jBUSlEygdLmu+FHWEQQyHGlJVDbpvlqci/HxTHagVNwNwXh5\n\tupeABzcrenoQcit5R9FQT0DhcPtPMBv3t4qzuGTwx8lITVotngTmjinrS6Spbcdv9cq/\n\tDXu6BY0Zv9QFb3HwFLUjz6N/weiC9K9ceePs/ps2vaZvCEvNJGarh7Gh1LrSWOLyPTY6\n\tlRgdAhSLUBqUUcAm+QUN5VdXZX2iSk3gURa11Wl5ODOfMoQvk9D53xtkSe9xg6LD4KtH\n\tCiBg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=1gghCCn3+u5hZC9uavWRxTF4TMcfMQGnUBz1f6/Oh/0=;\n\tb=MQvcqul7GgdK26HbfRDifNPSoakHq4PPr6k3Icc15bQtxA+Zvst6D9EDHhOkFxbBV+\n\tR8MgyeJJSX41XnJIjSaf2FFx2aVZk3n77AxSTbwqv+W72T2IbO7oYmN50Xy/GZ+q/1v6\n\tgf9SwWhhPaDDQW7jStj77hmrIgANZ6OJQPMWzK1i8/Be/wbINo6Ei2j6UVWiSdxE2A8n\n\tOTSBIAzuMzBrCmukx1g47tg03RRLw6UG2Wqlg/oS2+I2wIaZiMv74ChG6V5Nf+XHzCDP\n\tB4P6HGZTP3ipgKj4NZughAwnk9yD0bzH3aegi/5q8R6JzXgxBTkrv7ViM2ghOaRKBfy+\n\tS6+g==","X-Gm-Message-State":"AOAM53288/KAn48HX+uAPlH+4GEoM7OUiZUSDSCkW0+7YGRu+giigd8A\n\tNx2Tm1J09+DWSb+q9QKkrqIRQXmVUGyLf4uN","X-Google-Smtp-Source":"ABdhPJzXS103rFB6gTOQizdBRDwOoL8U1BL5epkL90/aQdd3ymnBF8BRYP2/c5On/tP/aGw0BobrGw==","X-Received":"by 2002:a5d:688c:: with SMTP id\n\th12mr4281225wru.421.1642083363223; \n\tThu, 13 Jan 2022 06:16:03 -0800 (PST)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 13 Jan 2022 14:15:57 +0000","Message-Id":"<20220113141558.5805-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20220113141558.5805-1-david.plowman@raspberrypi.com>","References":"<20220113141558.5805-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 1/2] libcamera: camera_sensor: Clear\n\tcamera flips after opening the device","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"We clear the V4L2_CID_HFLIP and V4L2_CID_VFLIP controls immediately\nafter opening the camera device. This means the camera's Bayer format\nand mbus codes will be in the sensor's \"native\" order, and we document\nthis to be the case so that it can be relied upon.\n\nClearing the flips is harmless where sensor flips do not affect the\nBayer order.\n\nThis also fixes a bug in the Raspberry Pi pipeline handler where the\nnative Bayer order was being computed wrongly, but the new behaviour\nhere will be helpful to other pipeline handlers too. A subsequent\ncommit will tidy up the Raspberry Pi pipeline handler in this area as\nit can now be simplified.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nFixes: 83a512816189 (pipeline: raspberrypi: Convert the pipeline handler to use media controller)\n---\n src/libcamera/camera_sensor.cpp | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)","diff":"diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex c3999d35..64f7f12c 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -107,6 +107,17 @@ int CameraSensor::init()\n \tif (ret < 0)\n \t\treturn ret;\n \n+\t/*\n+\t * Clear any flips to be sure we get the \"native\" Bayer order. This is\n+\t * harmless for sensors where the flips don't affect the Bayer order.\n+\t */\n+\tControlList ctrls(subdev_->controls());\n+\tif (subdev_->controls().find(V4L2_CID_HFLIP) != subdev_->controls().end())\n+\t\tctrls.set(V4L2_CID_HFLIP, 0);\n+\tif (subdev_->controls().find(V4L2_CID_VFLIP) != subdev_->controls().end())\n+\t\tctrls.set(V4L2_CID_VFLIP, 0);\n+\tsubdev_->setControls(&ctrls);\n+\n \t/* Enumerate, sort and cache media bus codes and sizes. */\n \tformats_ = subdev_->formats(pad_);\n \tif (formats_.empty()) {\n@@ -461,6 +472,11 @@ int CameraSensor::initProperties()\n /**\n  * \\fn CameraSensor::mbusCodes()\n  * \\brief Retrieve the media bus codes supported by the camera sensor\n+ *\n+ * Any Bayer formats are listed using the sensor's native Bayer order,\n+ * that is, with the effect of V4L2_CID_HFLIP and V4L2_CID_VFLIP undone\n+ * (where these controls exist).\n+ *\n  * \\return The supported media bus codes sorted in increasing order\n  */\n \n","prefixes":["libcamera-devel","v2","1/2"]}