From patchwork Tue Nov 22 08:30:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 17828 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6D8D0BDE6B for ; Tue, 22 Nov 2022 08:30:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B81EF6331A; Tue, 22 Nov 2022 09:30:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669105817; bh=PAeZ7Yq3lE9hxPgsBvw9g/fzoun0uNpSukZ3A7/lQDo=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=0d6YrnzYZcTmeyYulVOgTYEQpssegVIOkGw2AcaKK8xY+NkvdGcl6nuLW88x3D50m HS43FNR53CwY5cWEUXqIQUonPP4DQLp4jh9Z4oG3wxYC4q8sCbQqxMQbh5RQzScQ1i X3vjGd44uxV0m8M/0mQZKp5opPkhQrFAJPLZcUQXJ/Wyp7low1tZrao4liGAYsrJET H5mPFWXhZUhOBbjhAvRbokI5fJJ9h9fwWTEjCSx6PUVc818tZwXJi3ZlH4jouj0547 ApPEVhTthVX4IIE43+DHIxgGkCBcbBitgR2NJAvgoT3XezpIyMJ6VKeqVaMxnW/faE 1zZ2WrY3MrEmA== Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [IPv6:2001:4b98:dc4:8::230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E27F9632EA for ; Tue, 22 Nov 2022 09:30:15 +0100 (CET) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 39609240006; Tue, 22 Nov 2022 08:30:14 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Nov 2022 09:30:05 +0100 Message-Id: <20221122083005.5239-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: camera_sensor: Print missing controls names X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Since the very beginning the camera sensor class has validated the controls available from the camera sensor driver, and complained accordingly when any of them was missing. The complaint message reported however only the numerical identifier of the V4L2 control, making debugging harder. Associate to each control a human readable identifier and use it in debug messages. Signed-off-by: Jacopo Mondi Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- src/libcamera/camera_sensor.cpp | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index ea373458a164..0780ce5a7007 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -213,31 +213,31 @@ int CameraSensor::validateSensorDriver() * Optional controls are used to register optional sensor properties. If * not present, some values will be defaulted. */ - static constexpr uint32_t optionalControls[] = { - V4L2_CID_CAMERA_SENSOR_ROTATION, + static const std::map optionalControls = { + { V4L2_CID_CAMERA_SENSOR_ROTATION, "Rotation" }, }; const ControlIdMap &controls = subdev_->controls().idmap(); - for (uint32_t ctrl : optionalControls) { + for (const auto &[ctrl, name] : optionalControls) { if (!controls.count(ctrl)) LOG(CameraSensor, Debug) - << "Optional V4L2 control " << utils::hex(ctrl) - << " not supported"; + << "Optional V4L2 control '" << name + << "' not supported"; } /* * Recommended controls are similar to optional controls, but will * become mandatory in the near future. Be loud if they're missing. */ - static constexpr uint32_t recommendedControls[] = { - V4L2_CID_CAMERA_ORIENTATION, + static const std::map recommendedControls = { + { V4L2_CID_CAMERA_ORIENTATION, "Orientation" }, }; - for (uint32_t ctrl : recommendedControls) { + for (const auto &[ctrl, name] : recommendedControls) { if (!controls.count(ctrl)) { LOG(CameraSensor, Warning) - << "Recommended V4L2 control " << utils::hex(ctrl) - << " not supported"; + << "Recommended V4L2 control '" << name + << "' not supported"; err = -EINVAL; } } @@ -300,20 +300,20 @@ int CameraSensor::validateSensorDriver() * For raw sensors, make sure the sensor driver supports the controls * required by the CameraSensor class. */ - static constexpr uint32_t mandatoryControls[] = { - V4L2_CID_ANALOGUE_GAIN, - V4L2_CID_EXPOSURE, - V4L2_CID_HBLANK, - V4L2_CID_PIXEL_RATE, - V4L2_CID_VBLANK, + static const std::map mandatoryControls = { + { V4L2_CID_ANALOGUE_GAIN, "Analogue gain" }, + { V4L2_CID_EXPOSURE, "Exposure" }, + { V4L2_CID_HBLANK, "Horizontal blanking" }, + { V4L2_CID_PIXEL_RATE, "Pixel Rate" }, + { V4L2_CID_VBLANK, "Vertical blanking" } }; err = 0; - for (uint32_t ctrl : mandatoryControls) { + for (const auto &[ctrl, name] : mandatoryControls) { if (!controls.count(ctrl)) { LOG(CameraSensor, Error) - << "Mandatory V4L2 control " << utils::hex(ctrl) - << " not available"; + << "Mandatory V4L2 control '" << name + << "' not available"; err = -EINVAL; } }