From patchwork Sat Sep 28 15:22:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2052 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 828E861922 for ; Sat, 28 Sep 2019 17:23:00 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EBF23593 for ; Sat, 28 Sep 2019 17:22:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1569684180; bh=vao5iALY/vN1YmzjFMh1vippKydG18ciC8Arig9X120=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gesKac9kMX31yuCrQ9pQMJXhCSIJknnJyFt4uERtDFcadnbK/HciS1jUz5wDMbgW6 xgp7f7nkeD3/xaKOi29nk2ub+rfzjcEzLL1Sd7w1NXw6giYDg2XX8w8xS4z6iz3CU/ pPaPsKAvwZ5Hych+Wm0b4p6CJ2+6J5L0pMtx9k2A= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 28 Sep 2019 18:22:36 +0300 Message-Id: <20190928152238.23752-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190928152238.23752-1-laurent.pinchart@ideasonboard.com> References: <20190928152238.23752-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 10/12] libcamera: Add ControlValidator 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-List-Received-Date: Sat, 28 Sep 2019 15:23:01 -0000 The new abstract ControlValidator class defines an interface that will be used by the ControlList class to validate controls. This will allow controls to the validated against different object types, such as Camera and V4L2Device. Signed-off-by: Laurent Pinchart --- src/libcamera/control_validator.cpp | 45 +++++++++++++++++++++++ src/libcamera/include/control_validator.h | 27 ++++++++++++++ src/libcamera/include/meson.build | 1 + src/libcamera/meson.build | 1 + 4 files changed, 74 insertions(+) create mode 100644 src/libcamera/control_validator.cpp create mode 100644 src/libcamera/include/control_validator.h diff --git a/src/libcamera/control_validator.cpp b/src/libcamera/control_validator.cpp new file mode 100644 index 000000000000..8e5cf3c3e3ee --- /dev/null +++ b/src/libcamera/control_validator.cpp @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_validator.cpp - Control validator + */ + +#include "control_validator.h" + +/** + * \file control_validator.h + * \brief Abstract control validator + */ + +namespace libcamera { + +/** + * \class ControlValidator + * \brief Interface for the control validator + * + * The ControlValidator class is used by the ControlList class to validate + * controls added to the list. It is an abstract class providing an interface + * for object-specific control validation, such a Camera controls and V4L2 + * controls. + */ + +/** + * \fn ControlValidator::name() + * \brief Retrieve the name of the object associated with the validator + * \return The name of the object associated with the validator + */ + +/** + * \fn ControlValidator::validate() + * \brief Validate a control + * \param[in] id The control ID + * + * This method validates the control \a id against the object corresponding to + * the validator. It shall at least validate that the control is applicable to + * the object instance, and may perform additional checks. + * + * \return True if the control is valid, false otherwise + */ + +} /* namespace libcamera */ diff --git a/src/libcamera/include/control_validator.h b/src/libcamera/include/control_validator.h new file mode 100644 index 000000000000..3598b18f2f26 --- /dev/null +++ b/src/libcamera/include/control_validator.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_validator.h - Control validator + */ +#ifndef __LIBCAMERA_CONTROL_VALIDATOR_H__ +#define __LIBCAMERA_CONTROL_VALIDATOR_H__ + +#include + +namespace libcamera { + +class ControlId; + +class ControlValidator +{ +public: + virtual ~ControlValidator() {} + + virtual const std::string &name() const = 0; + virtual bool validate(const ControlId &id) const = 0; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_CONTROL_VALIDATOR_H__ */ diff --git a/src/libcamera/include/meson.build b/src/libcamera/include/meson.build index 933be8543a8d..1cf47204f2b5 100644 --- a/src/libcamera/include/meson.build +++ b/src/libcamera/include/meson.build @@ -1,5 +1,6 @@ libcamera_headers = files([ 'camera_sensor.h', + 'control_validator.h', 'device_enumerator.h', 'device_enumerator_sysfs.h', 'device_enumerator_udev.h', diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 8123d1d5bee9..984cb9985f49 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -6,6 +6,7 @@ libcamera_sources = files([ 'camera_sensor.cpp', 'controls.cpp', 'control_ids.cpp', + 'control_validator.cpp', 'device_enumerator.cpp', 'device_enumerator_sysfs.cpp', 'event_dispatcher.cpp',