[v3,4/4] apps: cam: Print control direction information
diff mbox series

Message ID 20241129091916.298359-5-paul.elder@ideasonboard.com
State New
Headers show
Series
  • Add direction field to ControlId
Related show

Commit Message

Paul Elder Nov. 29, 2024, 9:19 a.m. UTC
Now that there is support for retrieving the allowed directions of a
control, print this information when listing controls.

Sample output:
$ cam --list-controls -c 2
Using camera Virtual0 as cam0
Control: [inout] draft::FaceDetectMode:
  - FaceDetectModeOff (0)
Control: [in   ] libcamera::FrameDurationLimits: [16666..33333]
   Size: 2

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
No change in v3

Changes in v2:
- s/i/in/, s/o/out/ so that the output is easier to read
---
 src/apps/cam/camera_session.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Kieran Bingham Dec. 6, 2024, 1:02 p.m. UTC | #1
Quoting Paul Elder (2024-11-29 09:19:16)
> Now that there is support for retrieving the allowed directions of a
> control, print this information when listing controls.
> 
> Sample output:
> $ cam --list-controls -c 2
> Using camera Virtual0 as cam0
> Control: [inout] draft::FaceDetectMode:
>   - FaceDetectModeOff (0)
> Control: [in   ] libcamera::FrameDurationLimits: [16666..33333]
>    Size: 2
> 

Looks good.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> ---
> No change in v3
> 
> Changes in v2:
> - s/i/in/, s/o/out/ so that the output is easier to read
> ---
>  src/apps/cam/camera_session.cpp | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
> index 6e9890ccfda1..9e93482775c3 100644
> --- a/src/apps/cam/camera_session.cpp
> +++ b/src/apps/cam/camera_session.cpp
> @@ -159,12 +159,18 @@ CameraSession::~CameraSession()
>  void CameraSession::listControls() const
>  {
>         for (const auto &[id, info] : camera_->controls()) {
> +               std::stringstream io;
> +               io << "["
> +                  << (id->isInput() ? "in" : "  ")
> +                  << (id->isOutput() ? "out" : "   ")
> +                  << "] ";
> +
>                 if (info.values().empty()) {
> -                       std::cout << "Control: "
> +                       std::cout << "Control: " << io.str()
>                                   << id->vendor() << "::" << id->name() << ": "
>                                   << info.toString() << std::endl;
>                 } else {
> -                       std::cout << "Control: "
> +                       std::cout << "Control: " << io.str()
>                                   << id->vendor() << "::" << id->name() << ":"
>                                   << std::endl;
>                         for (const auto &value : info.values()) {
> -- 
> 2.39.2
>
Laurent Pinchart Dec. 6, 2024, 1:16 p.m. UTC | #2
Hi Paul,

Thank you for the patch.

On Fri, Nov 29, 2024 at 06:19:16PM +0900, Paul Elder wrote:
> Now that there is support for retrieving the allowed directions of a
> control, print this information when listing controls.
> 
> Sample output:
> $ cam --list-controls -c 2
> Using camera Virtual0 as cam0
> Control: [inout] draft::FaceDetectMode:
>   - FaceDetectModeOff (0)
> Control: [in   ] libcamera::FrameDurationLimits: [16666..33333]
>    Size: 2
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

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

> ---
> No change in v3
> 
> Changes in v2:
> - s/i/in/, s/o/out/ so that the output is easier to read
> ---
>  src/apps/cam/camera_session.cpp | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
> index 6e9890ccfda1..9e93482775c3 100644
> --- a/src/apps/cam/camera_session.cpp
> +++ b/src/apps/cam/camera_session.cpp
> @@ -159,12 +159,18 @@ CameraSession::~CameraSession()
>  void CameraSession::listControls() const
>  {
>  	for (const auto &[id, info] : camera_->controls()) {
> +		std::stringstream io;
> +		io << "["
> +		   << (id->isInput() ? "in" : "  ")
> +		   << (id->isOutput() ? "out" : "   ")
> +		   << "] ";
> +
>  		if (info.values().empty()) {
> -			std::cout << "Control: "
> +			std::cout << "Control: " << io.str()
>  				  << id->vendor() << "::" << id->name() << ": "
>  				  << info.toString() << std::endl;
>  		} else {
> -			std::cout << "Control: "
> +			std::cout << "Control: " << io.str()
>  				  << id->vendor() << "::" << id->name() << ":"
>  				  << std::endl;
>  			for (const auto &value : info.values()) {

Patch
diff mbox series

diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index 6e9890ccfda1..9e93482775c3 100644
--- a/src/apps/cam/camera_session.cpp
+++ b/src/apps/cam/camera_session.cpp
@@ -159,12 +159,18 @@  CameraSession::~CameraSession()
 void CameraSession::listControls() const
 {
 	for (const auto &[id, info] : camera_->controls()) {
+		std::stringstream io;
+		io << "["
+		   << (id->isInput() ? "in" : "  ")
+		   << (id->isOutput() ? "out" : "   ")
+		   << "] ";
+
 		if (info.values().empty()) {
-			std::cout << "Control: "
+			std::cout << "Control: " << io.str()
 				  << id->vendor() << "::" << id->name() << ": "
 				  << info.toString() << std::endl;
 		} else {
-			std::cout << "Control: "
+			std::cout << "Control: " << io.str()
 				  << id->vendor() << "::" << id->name() << ":"
 				  << std::endl;
 			for (const auto &value : info.values()) {