{"id":19207,"url":"https://patchwork.libcamera.org/api/patches/19207/?format=json","web_url":"https://patchwork.libcamera.org/patch/19207/","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":"<20231113100851.73886-1-alain.volmat@foss.st.com>","date":"2023-11-13T10:08:51","name":"[libcamera-devel] libcamera: camera_sensor: only access V4L_CID_HBLANK if existing","commit_ref":"882d04d740eec4176d5639a30ac282b89ed49d10","pull_url":null,"state":"accepted","archived":false,"hash":"96adf7cfba77c86c1c2eca799b36f0995ee670f5","submitter":{"id":162,"url":"https://patchwork.libcamera.org/api/people/162/?format=json","name":"Alain Volmat","email":"alain.volmat@foss.st.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19207/mbox/","series":[{"id":4072,"url":"https://patchwork.libcamera.org/api/series/4072/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4072","date":"2023-11-13T10:08:51","name":"[libcamera-devel] libcamera: camera_sensor: only access V4L_CID_HBLANK if existing","version":1,"mbox":"https://patchwork.libcamera.org/series/4072/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19207/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19207/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 07440C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Nov 2023 10:09:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 541B5629BA;\n\tMon, 13 Nov 2023 11:09:34 +0100 (CET)","from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com\n\t[185.132.182.106])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 066B761DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Nov 2023 11:09:32 +0100 (CET)","from pps.filterd (m0288072.ppops.net [127.0.0.1])\n\tby mx07-00178001.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id\n\t3AD91I2u021403 for <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Nov 2023 11:09:31 +0100","from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35])\n\tby mx07-00178001.pphosted.com (PPS) with ESMTPS id 3u9ywkxmf7-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256\n\tverify=NOT) for <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Nov 2023 11:09:31 +0100 (CET)","from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20])\n\tby beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2F36710005B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Nov 2023 11:09:30 +0100 (CET)","from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69])\n\tby euls16034.sgp.st.com (STMicroelectronics) with ESMTP id\n\tBB32221058B for <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Nov 2023 11:09:30 +0100 (CET)","from localhost (10.129.178.213) by SHFDAG1NODE1.st.com\n\t(10.75.129.69) with Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27;\n\tMon, 13 Nov 2023 11:09:30 +0100"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1699870174;\n\tbh=EVFLfY2DpUKJHLC+lQ4LI9zhHvKU117OkI0DHmS5T/A=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=Zy9Dv815YwmJXDVPlY+VwBhD8do54kUe4QTDAhOcsh8V2H1KIAO+NzQQot6aIFJTU\n\t/BtEUtUBIb84Ev0geBIgfhIY/gmnEaESc/kHIIT5Rx7QdYgY0/u4nxkS2e04KKLaoK\n\thHi5BbXQjeSwD0IYiz62oW63rGjtOWL65Yj7YXM4UzXDfw865IVP6YKriw5IUCiXjF\n\t75E+fsmHprZ0j9IIqPkP55MFIS/un/fTj19sOvM1EEuyaWhwtqi4iOgMX7Xp+mXAif\n\t1UFdJLOOmA3d+kgcxDB4o9X94Gl9K1Vn774EPSgXFAFM3d399zvJgWIOqKV+SzNMRd\n\tx9yadsf5OWzog==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=\n\tfrom:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding:content-type; s=selector1; bh=Tb4u4/w\n\tXJr6gYP+RHqyBPpapYjfVGYDq4X98JQDQqb8=; b=eug3nk/F4OY9Tan9uMnie/5\n\tJ19cp1M4kmoEPyB4acpAMLwDduDTXD8i0HOfyqMRxyepVjFi3db2YlWyePW35S15\n\tA76l0rJ4m334uxUVBfWtH1cinig+iCYy+A0uM0hNhVyWiMi7LgGkcG67HVJGbbw2\n\tOgxUQn+uP39qKjn/1sAclozsdEqkoaksa7U1ZQ3DhKTAbf9xktD+U+McAv271PZa\n\tul+JKN1coMvh21c2QBtW2ED3hyhjiZ+5tMz0VltEEUbWxx6EEfR22MR1DluXtHAJ\n\thYIJVf/DXo8bw79F/hoKqaeeNIVUp936gwr7l27xLKesq9/3r01OcqjAijky93Q=\n\t="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=foss.st.com\n\theader.i=@foss.st.com header.b=\"eug3nk/F\"; \n\tdkim-atps=neutral","To":"<libcamera-devel@lists.libcamera.org>","Date":"Mon, 13 Nov 2023 11:08:51 +0100","Message-ID":"<20231113100851.73886-1-alain.volmat@foss.st.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain","X-Originating-IP":"[10.129.178.213]","X-ClientProxiedBy":"SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE1.st.com\n\t(10.75.129.69)","X-Proofpoint-Virus-Version":"vendor=baseguard\n\tengine=ICAP:2.0.272, Aquarius:18.0.987, Hydra:6.0.619,\n\tFMLib:17.11.176.26\n\tdefinitions=2023-11-12_24,2023-11-09_01,2023-05-22_02","Subject":"[libcamera-devel] [PATCH] libcamera: camera_sensor: only access\n\tV4L_CID_HBLANK if existing","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":"Alain Volmat via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Alain Volmat <alain.volmat@foss.st.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Correct a crash in CameraSensor::init when trying to set the\nV4L2_CID_HBLANK control on sensor not implementing this control.\nThe HBLANK sensor not being mandatory for non-RAW sensors, it can\nhappen that the sensor does not expose this control.\nPerform check against availability of the control prior to usage in\norder to avoid the crash.\n\nSigned-off-by: Alain Volmat <alain.volmat@foss.st.com>\n---\n src/libcamera/camera_sensor.cpp | 24 +++++++++++++-----------\n 1 file changed, 13 insertions(+), 11 deletions(-)","diff":"diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex d9261672..0ef78d9c 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -197,17 +197,19 @@ int CameraSensor::init()\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+\tif (ctrls.infoMap()->find(V4L2_CID_HBLANK) != ctrls.infoMap()->end()) {\n+\t\tconst ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n+\t\tconst int32_t hblankMin = hblank.min().get<int32_t>();\n+\t\tconst int32_t hblankMax = hblank.max().get<int32_t>();\n+\n+\t\tif (hblankMin != hblankMax) {\n+\t\t\tControlList ctrl(subdev_->controls());\n+\n+\t\t\tctrl.set(V4L2_CID_HBLANK, hblankMin);\n+\t\t\tret = subdev_->setControls(&ctrl);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t}\n \t}\n \n \treturn applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);\n","prefixes":["libcamera-devel"]}