[libcamera-devel,1/2] libcamera: media_device: expose media graph model name

Message ID 20190121153005.19110-2-niklas.soderlund@ragnatech.se
State Accepted
Headers show
Series
  • libcamera: add basic uvcvideo pipeline handler
Related show

Commit Message

Niklas Söderlund Jan. 21, 2019, 3:30 p.m. UTC
Pipeline handlers such as the upcoming ucvideo handler needs the model
name to properly name the Camera object it creates. Store the model name
when querying the media device info and handle it in a similar fashion
as the driver name which is already retrieved.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/include/media_device.h | 2 ++
 src/libcamera/media_device.cpp       | 7 +++++++
 2 files changed, 9 insertions(+)

Comments

Laurent Pinchart Jan. 21, 2019, 9 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Mon, Jan 21, 2019 at 04:30:04PM +0100, Niklas Söderlund wrote:
> Pipeline handlers such as the upcoming ucvideo handler needs the model

s/needs/need/

> name to properly name the Camera object it creates. Store the model name

s/object it creates/objects they create/

> when querying the media device info and handle it in a similar fashion
> as the driver name which is already retrieved.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

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

> ---
>  src/libcamera/include/media_device.h | 2 ++
>  src/libcamera/media_device.cpp       | 7 +++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
> index a8dec0d3347bd5fc..d96b8ec718427011 100644
> --- a/src/libcamera/include/media_device.h
> +++ b/src/libcamera/include/media_device.h
> @@ -36,6 +36,7 @@ public:
>  
>  	const std::string driver() const { return driver_; }
>  	const std::string devnode() const { return devnode_; }
> +	const std::string model() const { return model_; }
>  
>  	const std::vector<MediaEntity *> &entities() const { return entities_; }
>  	MediaEntity *getEntityByName(const std::string &name) const;
> @@ -50,6 +51,7 @@ public:
>  private:
>  	std::string driver_;
>  	std::string devnode_;
> +	std::string model_;
>  	int fd_;
>  	bool valid_;
>  	bool acquired_;
> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> index a346296bc38e8f3d..b315e4f383b3bbb1 100644
> --- a/src/libcamera/media_device.cpp
> +++ b/src/libcamera/media_device.cpp
> @@ -162,6 +162,7 @@ int MediaDevice::open()
>  	}
>  
>  	driver_ = info.driver;
> +	model_ = info.model;
>  
>  	return 0;
>  }
> @@ -285,6 +286,12 @@ int MediaDevice::populate()
>   * \return The MediaDevice devnode path
>   */
>  
> +/**
> + * \fn MediaDevice::model()
> + * \brief Retrieve the media device model name
> + * \return The MediaDevice model name
> + */
> +
>  /**
>   * \fn MediaDevice::entities()
>   * \brief Retrieve the list of entities in the media graph

Patch

diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
index a8dec0d3347bd5fc..d96b8ec718427011 100644
--- a/src/libcamera/include/media_device.h
+++ b/src/libcamera/include/media_device.h
@@ -36,6 +36,7 @@  public:
 
 	const std::string driver() const { return driver_; }
 	const std::string devnode() const { return devnode_; }
+	const std::string model() const { return model_; }
 
 	const std::vector<MediaEntity *> &entities() const { return entities_; }
 	MediaEntity *getEntityByName(const std::string &name) const;
@@ -50,6 +51,7 @@  public:
 private:
 	std::string driver_;
 	std::string devnode_;
+	std::string model_;
 	int fd_;
 	bool valid_;
 	bool acquired_;
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index a346296bc38e8f3d..b315e4f383b3bbb1 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -162,6 +162,7 @@  int MediaDevice::open()
 	}
 
 	driver_ = info.driver;
+	model_ = info.model;
 
 	return 0;
 }
@@ -285,6 +286,12 @@  int MediaDevice::populate()
  * \return The MediaDevice devnode path
  */
 
+/**
+ * \fn MediaDevice::model()
+ * \brief Retrieve the media device model name
+ * \return The MediaDevice model name
+ */
+
 /**
  * \fn MediaDevice::entities()
  * \brief Retrieve the list of entities in the media graph