[libcamera-devel] [PATCH v2 5/9] android: camera_device: Load make and model from platform settings

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Jan 21 21:34:56 CET 2021


Hi Paul,

Thank you for the patch.

On Thu, Jan 21, 2021 at 07:15:45PM +0900, Paul Elder wrote:
> 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 <paul.elder at ideasonboard.com>
> 
> ---
> 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 d2a8e876..16d5b472 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 <fstream>
>  #include <sys/mman.h>
>  #include <tuple>
>  #include <vector>
> @@ -344,6 +345,28 @@ CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camer
>  	 *  streamConfiguration.
>  	 */
>  	maxJpegBufferSize_ = 13 << 20; /* 13631488 from USB HAL */
> +
> +	cameraMake_ = "libcamera";
> +	cameraModel_ = "cameraModel";
> +
> +	/* \todo Support getting properties on Android */
> +	std::ifstream fstream("/var/cache/camera/camera.prop");
> +	if (!fstream.is_open())
> +		return;
> +
> +	std::string line;
> +	while (getline(fstream, line)) {

s/getline/std::getline/

> +		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"))
> +			cameraModel_ = val;
> +		if (!key.compare("ro.product.manufacturer"))

s/if/else if/

> +			cameraMake_ = val;
> +	}
>  }
>  
>  CameraDevice::~CameraDevice()
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 0874c80f..a285d0a1 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -56,6 +56,8 @@ public:
>  		return config_.get();
>  	}
>  
> +	const std::string &cameraMake() const { return cameraMake_; }
> +	const std::string &cameraModel() const { return cameraModel_; }

Maybe just maker() and model() as the class is called *Camera*Device ?
(make() sounds weird, hence the proposed maker())

>  	int facing() const { return facing_; }
>  	int orientation() const { return orientation_; }
>  	unsigned int maxJpegBufferSize() const { return maxJpegBufferSize_; }
> @@ -127,6 +129,9 @@ private:
>  	std::map<int, libcamera::PixelFormat> formatsMap_;
>  	std::vector<CameraStream> streams_;
>  
> +	std::string cameraMake_;
> +	std::string cameraModel_;

Same here ?

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> +
>  	int facing_;
>  	int orientation_;
>  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list