{"id":11075,"url":"https://patchwork.libcamera.org/api/patches/11075/?format=json","web_url":"https://patchwork.libcamera.org/patch/11075/","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":"<20210131181722.5410-4-laurent.pinchart@ideasonboard.com>","date":"2021-01-31T18:17:22","name":"[libcamera-devel,3/3] libcamera: camera_sensor: Check control availability from idmap","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"60cabd8b1b522c47eee936cb7290166cd48c87e8","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":{"id":14,"url":"https://patchwork.libcamera.org/api/users/14/?format=json","username":"pinchartl","first_name":"Laurent","last_name":"Pinchart","email":"laurent.pinchart@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/11075/mbox/","series":[{"id":1631,"url":"https://patchwork.libcamera.org/api/series/1631/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1631","date":"2021-01-31T18:17:19","name":"Restore CameraSensor usage for YUV sensors","version":1,"mbox":"https://patchwork.libcamera.org/series/1631/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11075/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11075/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 52BADBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 31 Jan 2021 18:17:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7E298683D9;\n\tSun, 31 Jan 2021 19:17:51 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 968D5683D0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 31 Jan 2021 19:17:47 +0100 (CET)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 38F9C8A0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 31 Jan 2021 19:17:47 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"G+4r1oL1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1612117067;\n\tbh=dcJwG2XpfNR/G2aAvoQAU0d4wh+95hkGxA1ahstmEqw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=G+4r1oL1gaRk7g5PwUj7pvYkLXOh/GBDymHH9bTCFb9fvObTcL2RtS5ffT0dnKjqk\n\twnVoBnvBywFDFbOk671CVLFHn1hW/c7kqkyJ0AJLcLdQAuMTirU0+MqLNCxaCYoGYN\n\tx/NECPL7UAL41jgs+PUUPNt14GYxdsOH/42tcGNg=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 31 Jan 2021 20:17:22 +0200","Message-Id":"<20210131181722.5410-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.28.0","In-Reply-To":"<20210131181722.5410-1-laurent.pinchart@ideasonboard.com>","References":"<20210131181722.5410-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 3/3] libcamera: camera_sensor: Check\n\tcontrol availability from idmap","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The presence of mandatory and optional controls is checked in\nCameraSensor::validateSensorDriver() by trying to retrieve them. This\ncases an error message to be printed in the V4L2Device class if an\noptional control isn't present, while this isn't an error.\n\nTo fix this, use the control idmap reported by the V4L2Device to check\nfor control availability. The function can now print the whole list of\nmissing controls, making debugging easier.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/camera_sensor.cpp | 31 +++++++++++++++++++++----------\n 1 file changed, 21 insertions(+), 10 deletions(-)","diff":"diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 10713d3a0c29..85813befbf58 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -250,14 +250,18 @@ int CameraSensor::validateSensorDriver()\n \t * Optional controls are used to register optional sensor properties. If\n \t * not present, some values will be defaulted.\n \t */\n-\tconst std::vector<uint32_t> optionalControls{\n+\tstatic constexpr uint32_t optionalControls[] = {\n \t\tV4L2_CID_CAMERA_ORIENTATION,\n \t\tV4L2_CID_CAMERA_SENSOR_ROTATION,\n \t};\n \n-\tControlList ctrls = subdev_->getControls(optionalControls);\n-\tif (ctrls.empty())\n-\t\tLOG(CameraSensor, Debug) << \"Optional V4L2 controls not supported\";\n+\tconst ControlIdMap &controls = subdev_->controls().idmap();\n+\tfor (uint32_t ctrl : optionalControls) {\n+\t\tif (!controls.count(ctrl))\n+\t\t\tLOG(CameraSensor, Debug)\n+\t\t\t\t<< \"Optional V4L2 control \" << utils::hex(ctrl)\n+\t\t\t\t<< \" not supported\";\n+\t}\n \n \t/*\n \t * Make sure the required selection targets are supported.\n@@ -312,21 +316,28 @@ int CameraSensor::validateSensorDriver()\n \t * For raw sensors, make sure the sensor driver supports the controls\n \t * required by the CameraSensor class.\n \t */\n-\tconst std::vector<uint32_t> mandatoryControls{\n+\tstatic constexpr uint32_t mandatoryControls[] = {\n \t\tV4L2_CID_EXPOSURE,\n \t\tV4L2_CID_HBLANK,\n \t\tV4L2_CID_PIXEL_RATE,\n \t};\n \n-\tctrls = subdev_->getControls(mandatoryControls);\n-\tif (ctrls.empty()) {\n-\t\tLOG(CameraSensor, Error)\n-\t\t\t<< \"Mandatory V4L2 controls not available\";\n+\terr = 0;\n+\tfor (uint32_t ctrl : mandatoryControls) {\n+\t\tif (!controls.count(ctrl)) {\n+\t\t\tLOG(CameraSensor, Error)\n+\t\t\t\t<< \"Mandatory V4L2 control \" << utils::hex(ctrl)\n+\t\t\t\t<< \" not available\";\n+\t\t\terr = -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (err) {\n \t\tLOG(CameraSensor, Error)\n \t\t\t<< \"The sensor kernel driver needs to be fixed\";\n \t\tLOG(CameraSensor, Error)\n \t\t\t<< \"See Documentation/sensor_driver_requirements.rst in the libcamera sources for more information\";\n-\t\treturn -EINVAL;\n+\t\treturn err;\n \t}\n \n \treturn 0;\n","prefixes":["libcamera-devel","3/3"]}