From patchwork Wed Feb 24 09:48:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11371 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 64B2EBD808 for ; Wed, 24 Feb 2021 09:48:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA48868A33; Wed, 24 Feb 2021 10:48:52 +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="Tq11+pHW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 40E9A6040F for ; Wed, 24 Feb 2021 10:48:52 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 895328E8; Wed, 24 Feb 2021 10:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614160132; bh=KeZdTDFRt/WBoFGtuupy9Hr1uWUsA4uj7HCYW1m4TZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tq11+pHWDDJlpEV8I56wLCSKzuPkp5F1suSPuSPZ5lFAU9l5GCcOFej6aDw7bmgXK l2eAQMqvDjYkcXj0wEuq/vpk8eeOuDk5atlLujZ/lEkIlDVhr9LjSHjJESu2t5EIW1 9MlceMFykvfQ2JQ+LlWDy5LgAtJ1P6sjxcaQBPlg= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Feb 2021 18:48:31 +0900 Message-Id: <20210224094833.24219-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224094833.24219-1-paul.elder@ideasonboard.com> References: <20210224094833.24219-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/2] libcamera: camera_sensor: Print warning when orientation is unknown 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" Print a warning when the orientation of a sensor is unknown. The location property is still defaulted to external. Also add a recommended controls list, similar to the optional and mandatory controls list, to handle controls in a similar situation in the future. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- Changes in v3: - add recommendedControls Changes in v2: - expand the warning message --- src/libcamera/camera_sensor.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index c9e8d49b..8a1b9bd2 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -276,12 +276,13 @@ int CameraSensor::init() int CameraSensor::validateSensorDriver() { + int err = 0; + /* * 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_ORIENTATION, V4L2_CID_CAMERA_SENSOR_ROTATION, }; @@ -293,6 +294,23 @@ int CameraSensor::validateSensorDriver() << " 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, + }; + + for (uint32_t ctrl : recommendedControls) { + if (!controls.count(ctrl)) { + LOG(CameraSensor, Warning) + << "Recommended V4L2 control " << utils::hex(ctrl) + << " not supported"; + err = -EINVAL; + } + } + /* * Make sure the required selection targets are supported. * @@ -303,7 +321,6 @@ int CameraSensor::validateSensorDriver() * \todo Make support for selection targets mandatory as soon as all * test platforms have been updated. */ - int err = 0; Rectangle rect; int ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &rect); if (ret) { @@ -446,6 +463,8 @@ int CameraSensor::initProperties() break; } } else { + LOG(CameraSensor, Warning) + << "Failed to retrieve the camera location, setting to External"; propertyValue = properties::CameraLocationExternal; } properties_.set(properties::Location, propertyValue);