From patchwork Sat Jan 23 05:17:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 10969 X-Patchwork-Delegate: paul.elder@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 815FCC0F2B for ; Sat, 23 Jan 2021 05:17:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4EC7768299; Sat, 23 Jan 2021 06:17:25 +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="EyxFgFZH"; dkim-atps=neutral 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 0AF0B68261 for ; Sat, 23 Jan 2021 06:17:24 +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 12F90813; Sat, 23 Jan 2021 06:17:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1611379042; bh=cGMm4a8BNd/BSZwtFQp+QkkR5Coh5AJ2kWJs8uISCKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EyxFgFZH0rSvO6z3AJw01bJ1Q3LbRGc3/8g+dELH/rOV7yVYS6V3hbEiWt6DSDVxB mpv2zmyFGl61NYhObegBWLLpNKVhnAJIQcZC7UnxFQjoSXDiP2Qhu/sMBzHtqaf3Gm sWvtZpDl8eeSFI1O76JX0s7gorFQsbZLiei4HFXw= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Sat, 23 Jan 2021 14:17:00 +0900 Message-Id: <20210123051704.188117-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210123051704.188117-1-paul.elder@ideasonboard.com> References: <20210123051704.188117-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/8] android: camera_device: Load make and model from platform settings 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" In ChromeOS the camera make and model is saved in /var/cache/camera/camera.prop. Load and save these values at construction time, if available. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - rename cameraMake_ and cameraModel_ to maker_ and model_ Changes in v2: - use fstream instead of File and split --- src/android/camera_device.cpp | 23 +++++++++++++++++++++++ src/android/camera_device.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 3983c6dc..592e2d43 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -9,6 +9,7 @@ #include "camera_ops.h" #include "post_processor.h" +#include #include #include #include @@ -351,6 +352,28 @@ CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr &camer * streamConfiguration. */ maxJpegBufferSize_ = 13 << 20; /* 13631488 from USB HAL */ + + maker_ = "libcamera"; + model_ = "cameraModel"; + + /* \todo Support getting properties on Android */ + std::ifstream fstream("/var/cache/camera/camera.prop"); + if (!fstream.is_open()) + return; + + std::string line; + while (std::getline(fstream, line)) { + std::string::size_type delimPos = line.find("="); + if (delimPos == std::string::npos) + continue; + std::string key = line.substr(0, delimPos); + std::string val = line.substr(delimPos + 1); + + if (!key.compare("ro.product.model")) + model_ = val; + else if (!key.compare("ro.product.manufacturer")) + maker_ = val; + } } CameraDevice::~CameraDevice() diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 597d11fc..058a3f9a 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -55,6 +55,8 @@ public: return config_.get(); } + const std::string &cameraMake() const { return maker_; } + const std::string &cameraModel() const { return model_; } int facing() const { return facing_; } int orientation() const { return orientation_; } unsigned int maxJpegBufferSize() const { return maxJpegBufferSize_; } @@ -125,6 +127,9 @@ private: std::map formatsMap_; std::vector streams_; + std::string maker_; + std::string model_; + int facing_; int orientation_;