{"id":17844,"url":"https://patchwork.libcamera.org/api/1.1/patches/17844/?format=json","web_url":"https://patchwork.libcamera.org/patch/17844/","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":"<20221123113644.1778-2-david.plowman@raspberrypi.com>","date":"2022-11-23T11:36:44","name":"[libcamera-devel,v2,1/1] libcamera: camera_sensor: Reset HBLANK when setting the format","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6f0d18e489e7b8643b595a64fe80934c0ac0cd81","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/17844/mbox/","series":[{"id":3631,"url":"https://patchwork.libcamera.org/api/1.1/series/3631/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3631","date":"2022-11-23T11:36:43","name":"Resolve invalid attempt to set sensor HBLANK control","version":2,"mbox":"https://patchwork.libcamera.org/series/3631/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17844/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17844/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 E492EBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Nov 2022 11:36:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0749B6331A;\n\tWed, 23 Nov 2022 12:36:51 +0100 (CET)","from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F88663313\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Nov 2022 12:36:49 +0100 (CET)","by mail-wm1-x32a.google.com with SMTP id\n\ti64-20020a1c3b43000000b003d016c21100so1207807wma.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Nov 2022 03:36:49 -0800 (PST)","from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:e4a2:3070:eea4:e434])\n\tby smtp.gmail.com with ESMTPSA id\n\tm9-20020a05600c4f4900b003b95ed78275sm2203219wmq.20.2022.11.23.03.36.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 23 Nov 2022 03:36:47 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669203411;\n\tbh=Yv3FcNCjx+mp2HRPxn8kQoa0Tn/sOjMGdIOI3i+xSa8=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=ShJHYC9WChONvTVRHUVxv7ekLO8dJAWx80VRfll03h3zD8NKJRIuePl6K0jcYEHcR\n\t9diGQtfqKHcGOCM2/UPtdzcSM0RWsmHugWs6QcimZ/RhVoc2vYlVPFQtY7236+J+qM\n\tPI85Jv9Gw8JTLMXvq4KEZR/X1GLqImZk8CnGCVUEr+KgcYBPp68VOYDSm0HdFt4Vnm\n\tn+DleN2SnthrU4XIi8A7lANRxZWW6QdzJp7XpLrmEwfiefmGyZW+t77sZugPcSf+IS\n\tufHhhQVSP1MUR6IqLImYSLS3Amh7VW4SLMY/5j0YpEdId9VF34XoJxqsr//iDPJD70\n\t//sR224cfjTeg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=ayiEryo2nEyP7V0oD7bge2QPW9437kXooGA/K6dlQVw=;\n\tb=ED1bspjkoA7bNXwETjq5syRlKcyl9dm7cMaSZRTHyb+J4SkSuhJayQ+xgZo8F32Ane\n\tCVcl/PyJ6MNdN0DUn3EhWbJk7VPwrI5/OEXwREROb8v/yGr+MPj8IbCbL61oK1P899wC\n\t/WRIbrxoRTS1FWbcbl7UohuL+8syd9Cqz0cW+2OJZxv1gX+BR7gvCQy0t90x12G74W2n\n\thyys1uJvrA+5Eqw6ihfWnf3DseophEgXxy/kB5vBqFggObHvh2aYj2L8OaUo8R++Hnk0\n\t5RlGQ0/qxSbWISGigo0vnnt2E8VgjmZxKWbb6qtVirW8n7gcutySe8LOCRnbckbwJhJh\n\tR90A=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"ED1bspjk\"; 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:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=ayiEryo2nEyP7V0oD7bge2QPW9437kXooGA/K6dlQVw=;\n\tb=JNI5tS1DnLa3FJrIGQihUG9II51IV7bkteLSLoV4zg6sDfhNeYoJSrGf01uuCi8TN5\n\t9tibZAIQG4tRn/H5k6AKQlWAylmQqmxGpcLL0C89m7/E+5Jo1pN3W5DS7HTKrj5Cd2tm\n\t2GqMutCpOXrYP+1TmOWKvnmodm/XKmyx5Or7HH7DB/U7U6do5t7zV35UIICaVMZ4Isvo\n\tCebeKQ9snijUo7f6kcgf6t4zRR/Wumh19kv2ZgDzsjJhtufci2ANrmrmHDIrplhgAT9B\n\tQ9sq5QR8INb4gUW0tlSr7hA3RrtdkrQUwF0y8Gk7DvnMPYRmmChugoByvXuZJQyK67Mt\n\tiPoA==","X-Gm-Message-State":"ANoB5plfCyPAJr6w69Aiam8k0BYj4U/Ea+gHU+nGVghQSQK41eCDV9y2\n\tQHReev7U0twtF38HGkvsbVM0+X4Pg56eyw==","X-Google-Smtp-Source":"AA0mqf5ZKupg5j0Nuoh8fd3/BmPu66ZMRgSEw8iSm0ik8AaWTcqjQqc7umZV0XKAdSapxzGI5hrZoQ==","X-Received":"by 2002:a1c:f216:0:b0:3c6:c2ae:278b with SMTP id\n\ts22-20020a1cf216000000b003c6c2ae278bmr19469779wmc.127.1669203408617; \n\tWed, 23 Nov 2022 03:36:48 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 23 Nov 2022 11:36:44 +0000","Message-Id":"<20221123113644.1778-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20221123113644.1778-1-david.plowman@raspberrypi.com>","References":"<20221123113644.1778-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 1/1] libcamera: camera_sensor: Reset\n\tHBLANK when setting the format","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":"We no longer reset the HBLANK in init because we may not own the\ncamera and the operation may fail. Instead, we reset it when we set\nthe camera format so that all pipeline handlers, even ones that do not\ncontrol HBLANK themselves, will have a well-defined value.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/libcamera/camera_sensor.cpp | 53 ++++++++++++++++-----------------\n 1 file changed, 26 insertions(+), 27 deletions(-)","diff":"diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 572a313a..ec7bb0e7 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -176,32 +176,6 @@ int CameraSensor::init()\n \tif (ret)\n \t\treturn ret;\n \n-\t/*\n-\t * Set HBLANK to the minimum to start with a well-defined line length,\n-\t * allowing IPA modules that do not modify HBLANK to use the sensor\n-\t * minimum line length in their calculations.\n-\t *\n-\t * At present, there is no way of knowing if a control is read-only.\n-\t * As a workaround, assume that if the minimum and maximum values of\n-\t * the V4L2_CID_HBLANK control are the same, it implies the control\n-\t * is read-only.\n-\t *\n-\t * \\todo The control API ought to have a flag to specify if a control\n-\t * is read-only which could be used below.\n-\t */\n-\tconst ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n-\tconst int32_t hblankMin = hblank.min().get<int32_t>();\n-\tconst int32_t hblankMax = hblank.max().get<int32_t>();\n-\n-\tif (hblankMin != hblankMax) {\n-\t\tControlList ctrl(subdev_->controls());\n-\n-\t\tctrl.set(V4L2_CID_HBLANK, hblankMin);\n-\t\tret = subdev_->setControls(&ctrl);\n-\t\tif (ret)\n-\t\t\treturn ret;\n-\t}\n-\n \treturn applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);\n }\n \n@@ -748,7 +722,32 @@ int CameraSensor::setFormat(V4L2SubdeviceFormat *format)\n \t\treturn ret;\n \n \tupdateControlInfo();\n-\treturn 0;\n+\n+\t/*\n+\t * Set HBLANK to the minimum to start with a well-defined line length,\n+\t * allowing IPA modules that do not modify HBLANK to use the sensor\n+\t * minimum line length in their calculations.\n+\t *\n+\t * At present, there is no way of knowing if a control is read-only.\n+\t * As a workaround, assume that if the minimum and maximum values of\n+\t * the V4L2_CID_HBLANK control are the same, it implies the control\n+\t * is read-only.\n+\t *\n+\t * \\todo The control API ought to have a flag to specify if a control\n+\t * is read-only which could be used below.\n+\t */\n+\tconst ControlInfo hblank = controls().at(V4L2_CID_HBLANK);\n+\tconst int32_t hblankMin = hblank.min().get<int32_t>();\n+\tconst int32_t hblankMax = hblank.max().get<int32_t>();\n+\n+\tif (hblankMin != hblankMax) {\n+\t\tControlList ctrl(subdev_->controls());\n+\n+\t\tctrl.set(V4L2_CID_HBLANK, hblankMin);\n+\t\tret = subdev_->setControls(&ctrl);\n+\t}\n+\n+\treturn ret;\n }\n \n /**\n","prefixes":["libcamera-devel","v2","1/1"]}