From patchwork Tue Apr 28 17:06:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3594 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 E2CFF60AF5 for ; Tue, 28 Apr 2020 19:07:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="T6vA86qT"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5F29172C for ; Tue, 28 Apr 2020 19:07:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1588093636; bh=sdfLLYrDwhQb8UjFKAxQq4mSDwFQhEguEaIAl2l0jCE=; h=From:To:Subject:Date:From; b=T6vA86qTzajSH0Uc32kXLtKttbziEvCjuQ5EKTFbtPxXvzCIgu5LIONThVj1aJYo/ +ymYRMMYiJ3Xk2xd4Q3TCOAG98jn/sg0cDHlApklhNPx+ZE9+2piwEHtBGGMeif/BN yBpmkX8vdpqS5K6w886JOKH6UyF3X7/n7Y7G6XG8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 28 Apr 2020 20:06:56 +0300 Message-Id: <20200428170656.21789-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: camera_sensor: Add model() function 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: Tue, 28 Apr 2020 17:07:17 -0000 Add a new model() function to the CameraSensor class to report the camera sensor model. Signed-off-by: Laurent Pinchart --- src/libcamera/camera_sensor.cpp | 24 ++++++++++++++++++++++++ src/libcamera/include/camera_sensor.h | 1 + 2 files changed, 25 insertions(+) Jacopo, I'll need this in pipeline handlers to obtain the sensor model, in order to construct a configuration file name, without having to generate the whole CameraSensorInfo. Is this OK with you ? As I've taken the implementation of the function from your code, should I add your Signed-off-by ? diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index c893b90979d8..55a9fbd71e69 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -163,6 +163,30 @@ int CameraSensor::init() return 0; } +/** + * \brief Retrieve the sensor model name + * + * The sensor model name is a free-formed string that uniquely identifies the + * sensor model. + * + * \return The sensor model name + */ +std::string CameraSensor::model() const +{ + /* + * Extract the camera sensor model name from the media entity name. + * + * \todo There is no standardized naming scheme for sensor entities + * in the Linux kernel at the moment. The most common naming scheme + * is the one obtained by associating the sensor name and its I2C + * device and bus addresses in the form of: "devname i2c-adapt:i2c-addr" + * Assume this is the standard naming scheme and parse the first part + * of the entity name to obtain "devname". + */ + std::string entityName = subdev_->entity()->name(); + return entityName.substr(0, entityName.find(' ')); +} + /** * \fn CameraSensor::entity() * \brief Retrieve the sensor media entity diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h index 5277f7f7fe87..e68185370eb2 100644 --- a/src/libcamera/include/camera_sensor.h +++ b/src/libcamera/include/camera_sensor.h @@ -33,6 +33,7 @@ public: int init(); + std::string model() const; const MediaEntity *entity() const { return entity_; } const std::vector &mbusCodes() const { return mbusCodes_; } const std::vector &sizes() const { return sizes_; }