From patchwork Fri Feb 5 17:03:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11178 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 AC3C7BD160 for ; Fri, 5 Feb 2021 17:03:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2D3BB614BB; Fri, 5 Feb 2021 18:03:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pCEE4vMx"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9FF9C614B0 for ; Fri, 5 Feb 2021 18:03:21 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 28815316; Fri, 5 Feb 2021 18:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1612544601; bh=R6eDQmXWtc8B6DBF260QXZe6QpoGn6XwP7AELGBERo4=; h=From:To:Cc:Subject:Date:From; b=pCEE4vMxYHmIHubt33lYSF1fQpPToljUFR/vhNwQdthBpbvVEgbs2FuRQyzwEyV2A EIFiIXZ/85Zh8lUzV6mOjbqqlMub5QgzGEvFH5BiB16GFncQfgdjPzOPkA3+WeERlj A6YTVNJ+SQOkCMj1SQKYLC9ip5mX4mmiQPsbHn88= From: Kieran Bingham To: libcamera devel Date: Fri, 5 Feb 2021 17:03:17 +0000 Message-Id: <20210205170317.267605-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH] libcamera: camera_sensor: Report mandatory control 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We can not obtain the control names directly from V4L2 so create a map of the control name, when declaring the list of mandatory controls to enable a human readable print of any missing requirements. Signed-off-by: Kieran Bingham --- src/libcamera/camera_sensor.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index c9e8d49b7935..9a510108f171 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -346,18 +346,23 @@ 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_EXPOSURE, - V4L2_CID_HBLANK, - V4L2_CID_PIXEL_RATE, - V4L2_CID_VBLANK, + static struct { + uint32_t ctrl; + std::string name; + } mandatoryControls[] = { +#define MANDATORY_CONTROL(__ctrl) { __ctrl, #__ctrl } + MANDATORY_CONTROL(V4L2_CID_EXPOSURE), + MANDATORY_CONTROL(V4L2_CID_HBLANK), + MANDATORY_CONTROL(V4L2_CID_PIXEL_RATE), + MANDATORY_CONTROL(V4L2_CID_VBLANK), +#undef MANDATORY_CONTROL }; err = 0; - for (uint32_t ctrl : mandatoryControls) { - if (!controls.count(ctrl)) { + for (auto &c : mandatoryControls) { + if (!controls.count(c.ctrl)) { LOG(CameraSensor, Error) - << "Mandatory V4L2 control " << utils::hex(ctrl) + << "Mandatory V4L2 control " << c.name << " not available"; err = -EINVAL; }