From patchwork Tue Sep 29 14:46:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9856 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 0DDB1C3B5C for ; Tue, 29 Sep 2020 14:47:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AE103621D8; Tue, 29 Sep 2020 16:46:59 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D4AE760365 for ; Tue, 29 Sep 2020 16:46:57 +0200 (CEST) X-Halon-ID: 9eda1012-0262-11eb-9823-005056917f90 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 9eda1012-0262-11eb-9823-005056917f90; Tue, 29 Sep 2020 16:46:56 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Sep 2020 16:46:42 +0200 Message-Id: <20200929144648.429397-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> References: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 1/7] libcamera: properties: Add model property 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" The model name must to the extent possible describe the sensor. For most devices this is the model name of the sensor. While for some devices the sensor model is unavailable as the sensor or the entire camera is part of a larger unit and exposed as a black-box to the system. In such cases the model name of the smallest component closest to the sensor must be used. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- * Changes since v5 - Expand description. - Changes so much by now I reluctantly have to drop Kieran's R-b :-( * Changes since v4 - Expand description. * Changes since v3 - s/as ASCII/in ASCII/ --- src/libcamera/property_ids.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml index 74ad0195d6310367..3f634503a7f201e3 100644 --- a/src/libcamera/property_ids.yaml +++ b/src/libcamera/property_ids.yaml @@ -387,6 +387,29 @@ controls: | | +--------------------+ + - Model: + type: string + description: | + The model name must to the extent possible describe the sensor. For most + devices this is the model name of the sensor. While for some devices the + sensor model is unavailable as the sensor or the entire camera is part + of a larger unit and exposed as a black-box to the system. In such cases + the model name of the smallest component closest to the sensor must be + used. + + The model name is not meant to be a camera name displayed to the + end-user, but may be combined with other camera information to create a + camera name. + + The model name is not guaranteed to be unique in the system nor is + it guaranteed to be stable or have any other properties required to make + it a good candidate to be used as a permanent identifier of a camera. + + The model name shall describe the camera in a human readable format and + shall be encoded in ASCII. + + Example model names are 'ov5670', 'imx219' or 'Logitech Webcam C930e'. + - UnitCellSize: type: Size description: | From patchwork Tue Sep 29 14:46:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9857 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 7E00FC3B5C for ; Tue, 29 Sep 2020 14:47:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 58E76621C9; Tue, 29 Sep 2020 16:47:03 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CD73B60365 for ; Tue, 29 Sep 2020 16:47:01 +0200 (CEST) X-Halon-ID: 9f344298-0262-11eb-9823-005056917f90 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 9f344298-0262-11eb-9823-005056917f90; Tue, 29 Sep 2020 16:46:59 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Sep 2020 16:46:43 +0200 Message-Id: <20200929144648.429397-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> References: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 2/7] libcamera: utils: Add method to remove non-ASCII characters 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" Add method that removes non-ASCII characters from a string. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain --- * Changes since v5 - Update documentation. * Changes since v4 - Update documentation. * Changes since v3 - Fix spelling in comment. - Rename to toAscii() --- include/libcamera/internal/utils.h | 2 ++ src/libcamera/utils.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h index a1b644b0345bdb48..ebb2c4038e196f05 100644 --- a/include/libcamera/internal/utils.h +++ b/include/libcamera/internal/utils.h @@ -190,6 +190,8 @@ private: details::StringSplitter split(const std::string &str, const std::string &delim); +std::string toAscii(const std::string &str); + std::string libcameraBuildPath(); std::string libcameraSourcePath(); diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index a5232902191eec85..da85c9c24340ae3b 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -334,6 +334,23 @@ details::StringSplitter split(const std::string &str, const std::string &delim) return details::StringSplitter(str, delim); } +/** + * \brief Remove any non-ASCII characters from a string + * \param[in] str The string to strip + * + * Remove all non-ASCII characters from a string. + * + * \return A string equal to \a str stripped out of all non-ASCII characters + */ +std::string toAscii(const std::string &str) +{ + std::string ret; + for (const char &c : str) + if (!(c & 0x80)) + ret += c; + return ret; +} + /** * \brief Check if libcamera is installed or not * From patchwork Tue Sep 29 14:46:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9858 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 9C1D5C3B5C for ; Tue, 29 Sep 2020 14:47:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7769060BD3; Tue, 29 Sep 2020 16:47:04 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CBE6360BD3 for ; Tue, 29 Sep 2020 16:47:02 +0200 (CEST) X-Halon-ID: a188b193-0262-11eb-9823-005056917f90 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id a188b193-0262-11eb-9823-005056917f90; Tue, 29 Sep 2020 16:47:01 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Sep 2020 16:46:44 +0200 Message-Id: <20200929144648.429397-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> References: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 3/7] libcamera: camera_sensor: Set sensor model property 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" Set the sensor model property. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- * Changes since v1 - Ensure model string only contains ASCII characters. --- src/libcamera/camera_sensor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index d2679a4b80ce0d42..78c7ceec7c449674 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -200,6 +200,8 @@ int CameraSensor::init() else model_ = entityName; + properties_.set(properties::Model, utils::toAscii(model_)); + /* Create and open the subdev. */ subdev_ = std::make_unique(entity_); int ret = subdev_->open(); From patchwork Tue Sep 29 14:46:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9859 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 D41ACC3B5C for ; Tue, 29 Sep 2020 14:47:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B1745621DE; Tue, 29 Sep 2020 16:47:05 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CA94E621D6 for ; Tue, 29 Sep 2020 16:47:04 +0200 (CEST) X-Halon-ID: a22c3091-0262-11eb-9823-005056917f90 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id a22c3091-0262-11eb-9823-005056917f90; Tue, 29 Sep 2020 16:47:03 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Sep 2020 16:46:45 +0200 Message-Id: <20200929144648.429397-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> References: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 4/7] libcamera: pipeline: uvcvideo: Initialize CameraData from MediaDevice 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" The UVCCameraData::init() is the only consumer of the default entry in the media graph, move the lookup of it into the init() function and pass it the MediaDevice. This is done in preparation to extend the CameraData initialization to consume more information from the MediaDevice. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- * Changes since v3 - s/form/from/ --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index ba0efc8b893b4a69..eff866b692a926cf 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -44,7 +44,7 @@ public: delete video_; } - int init(MediaEntity *entity); + int init(MediaDevice *media); void addControl(uint32_t cid, const ControlInfo &v4l2info, ControlInfoMap::Map *ctrls); void bufferReady(FrameBuffer *buffer); @@ -463,18 +463,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) std::unique_ptr data = std::make_unique(this); - /* Locate and initialise the camera data with the default video node. */ - const std::vector &entities = media->entities(); - auto entity = std::find_if(entities.begin(), entities.end(), - [](MediaEntity *entity) { - return entity->flags() & MEDIA_ENT_FL_DEFAULT; - }); - if (entity == entities.end()) { - LOG(UVC, Error) << "Could not find a default video device"; - return false; - } - - if (data->init(*entity)) + if (data->init(media)) return false; /* Create and register the camera. */ @@ -494,12 +483,23 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) return true; } -int UVCCameraData::init(MediaEntity *entity) +int UVCCameraData::init(MediaDevice *media) { int ret; + /* Locate and initialise the camera data with the default video node. */ + const std::vector &entities = media->entities(); + auto entity = std::find_if(entities.begin(), entities.end(), + [](MediaEntity *entity) { + return entity->flags() & MEDIA_ENT_FL_DEFAULT; + }); + if (entity == entities.end()) { + LOG(UVC, Error) << "Could not find a default video device"; + return -ENODEV; + } + /* Create and open the video device. */ - video_ = new V4L2VideoDevice(entity); + video_ = new V4L2VideoDevice(*entity); ret = video_->open(); if (ret) return ret; From patchwork Tue Sep 29 14:46:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9860 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 28F09C3B5C for ; Tue, 29 Sep 2020 14:47:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 05378621EE; Tue, 29 Sep 2020 16:47:07 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CA976621EA for ; Tue, 29 Sep 2020 16:47:05 +0200 (CEST) X-Halon-ID: a35913a2-0262-11eb-9823-005056917f90 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id a35913a2-0262-11eb-9823-005056917f90; Tue, 29 Sep 2020 16:47:04 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Sep 2020 16:46:46 +0200 Message-Id: <20200929144648.429397-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> References: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 5/7] libcamera: pipeline: uvcvideo: Set sensor model property 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" Set the sensor model property from the model reported in the media graph. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- * Changes since v1 - Ensure model string only contains ASCII characters. --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index eff866b692a926cf..8ec0dac1e68918d3 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -511,6 +511,7 @@ int UVCCameraData::init(MediaDevice *media) * Until then, treat all UVC cameras as external. */ properties_.set(properties::Location, properties::CameraLocationExternal); + properties_.set(properties::Model, utils::toAscii(media->model())); /* Initialise the supported controls. */ ControlInfoMap::Map ctrls; From patchwork Tue Sep 29 14:46:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9861 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 44944C3B5C for ; Tue, 29 Sep 2020 14:47:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 22A0B621C9; Tue, 29 Sep 2020 16:47:09 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D211F621C9 for ; Tue, 29 Sep 2020 16:47:06 +0200 (CEST) X-Halon-ID: a3f5f31d-0262-11eb-9823-005056917f90 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id a3f5f31d-0262-11eb-9823-005056917f90; Tue, 29 Sep 2020 16:47:05 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Sep 2020 16:46:47 +0200 Message-Id: <20200929144648.429397-7-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> References: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 6/7] cam: Print user-friendly camera 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" Instead of only printing the camera ID which is not intended for humans to read and parse create a more user friendly string when printing camera names. The ID is still printed as it is one option used to select camera using the --camera option. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- * Changes since v5 - Rework camera name. * Changes since v4 - Make cameraName() member of CamApp. * Changes since v1 - Only print user-friendly names when listing cameras. - Update format of user-friendly names printed. - Update commit message. --- src/cam/main.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 244720b491f5c462..311df171a21f6152 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -45,6 +45,8 @@ private: int infoConfiguration(); int run(); + std::string cameraName(const Camera *camera); + static CamApp *app_; OptionsParser::Options options_; CameraManager *cm_; @@ -340,7 +342,7 @@ int CamApp::run() unsigned int index = 1; for (const std::shared_ptr &cam : cm_->cameras()) { - std::cout << index << ": " << cam->id() << std::endl; + std::cout << index << ": " << cameraName(cam.get()) << std::endl; index++; } } @@ -378,6 +380,30 @@ int CamApp::run() return 0; } +std::string CamApp::cameraName(const Camera *camera) +{ + const ControlList &props = camera->properties(); + std::string name; + + switch (props.get(properties::Location)) { + case properties::CameraLocationFront: + name = "Internal front camera"; + break; + case properties::CameraLocationBack: + name = "Internal back camera"; + break; + case properties::CameraLocationExternal: + name = "External camera"; + if (props.contains(properties::Model)) + name += " '" + props.get(properties::Model) + "'"; + break; + } + + name += " (" + camera->id() + ")"; + + return name; +} + void signalHandler([[maybe_unused]] int signal) { std::cout << "Exiting" << std::endl; From patchwork Tue Sep 29 14:46:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9862 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 6B0FEC3B5C for ; Tue, 29 Sep 2020 14:47:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 44061621DC; Tue, 29 Sep 2020 16:47:11 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2EE3A60365 for ; Tue, 29 Sep 2020 16:47:10 +0200 (CEST) X-Halon-ID: a493c868-0262-11eb-9823-005056917f90 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id a493c868-0262-11eb-9823-005056917f90; Tue, 29 Sep 2020 16:47:08 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Sep 2020 16:46:48 +0200 Message-Id: <20200929144648.429397-8-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> References: <20200929144648.429397-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 7/7] qcam: dng_writer: Record camera model 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" Record the model property of the camera if available. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- * Changes since v5 - Do not set TIFFTAG_UNIQUECAMERAMODEL as it should also contain a true maker. Add a todo to track this. --- src/qcam/dng_writer.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index 030d1387118d91e9..34c8df5a51badf3d 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -15,6 +15,7 @@ #include #include +#include using namespace libcamera; @@ -353,6 +354,8 @@ int DNGWriter::write(const char *filename, const Camera *camera, [[maybe_unused]] const FrameBuffer *buffer, const void *data) { + const ControlList &cameraProperties = camera->properties(); + const auto it = formatInfo.find(config.pixelFormat); if (it == formatInfo.cend()) { std::cerr << "Unsupported pixel format" << std::endl; @@ -387,9 +390,13 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFSetField(tif, TIFFTAG_DNGBACKWARDVERSION, version); TIFFSetField(tif, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); TIFFSetField(tif, TIFFTAG_MAKE, "libcamera"); - /* \todo Report a real model string instead of id. */ - TIFFSetField(tif, TIFFTAG_MODEL, camera->id().c_str()); - TIFFSetField(tif, TIFFTAG_UNIQUECAMERAMODEL, camera->id().c_str()); + + if (cameraProperties.contains(properties::Model)) { + std::string model = cameraProperties.get(properties::Model); + TIFFSetField(tif, TIFFTAG_MODEL, model.c_str()); + /* \todo set TIFFTAG_UNIQUECAMERAMODEL. */ + } + TIFFSetField(tif, TIFFTAG_SOFTWARE, "qcam"); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);