[libcamera-devel] [PATCH v2 1/3] cam: Do not assume Location is available
paul.elder at ideasonboard.com
paul.elder at ideasonboard.com
Mon Mar 22 06:47:12 CET 2021
Hi Jacopo,
On Fri, Mar 19, 2021 at 02:01:18PM +0100, Jacopo Mondi wrote:
> In preparation to register the Location property only if the firware
> interface provides it, do not assume it is available and build the
> camera name using the camera sensor model as a fallback.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
> ---
> src/cam/main.cpp | 32 ++++++++++++++++++++------------
> 1 file changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index e01be63a7058..c087cdd97332 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -379,18 +379,26 @@ std::string const 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;
> + if (props.contains(properties::Location)) {
> + 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;
> + }
> + } else if (props.contains(properties::Model)) {
> + /*
> + * If the camera location is not availble use the camera model
> + * to build the camera name.
> + */
> + name = "'" + props.get(properties::Model) + "'";
> }
>
> name += " (" + camera->id() + ")";
> --
> 2.30.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
More information about the libcamera-devel
mailing list