[libcamera-devel,5/8] libcamera: pipeline: ipu3: frames: Add FrameInfo state tracing
diff mbox series

Message ID 20210312061131.854849-6-kieran.bingham@ideasonboard.com
State Changes Requested
Delegated to: Kieran Bingham
Headers show
Series
  • IPU3 Debug improvements
Related show

Commit Message

Kieran Bingham March 12, 2021, 6:11 a.m. UTC
Provide a toString() function on the IPU3Frames::Info structure so that
it can be reported during debug logs.

Provide a public helper on the IPU3Frames class to report the state of
all Info structures it holds.

This method can be used when debugging the contexts that are associated
with requests.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/pipeline/ipu3/frames.cpp | 23 +++++++++++++++++++++++
 src/libcamera/pipeline/ipu3/frames.h   |  4 ++++
 2 files changed, 27 insertions(+)

Comments

Laurent Pinchart March 14, 2021, 2:02 a.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Fri, Mar 12, 2021 at 06:11:28AM +0000, Kieran Bingham wrote:
> Provide a toString() function on the IPU3Frames::Info structure so that
> it can be reported during debug logs.
> 
> Provide a public helper on the IPU3Frames class to report the state of
> all Info structures it holds.
> 
> This method can be used when debugging the contexts that are associated
> with requests.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/pipeline/ipu3/frames.cpp | 23 +++++++++++++++++++++++
>  src/libcamera/pipeline/ipu3/frames.h   |  4 ++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/ipu3/frames.cpp b/src/libcamera/pipeline/ipu3/frames.cpp
> index 4198e2019f3f..b8b471c3c561 100644
> --- a/src/libcamera/pipeline/ipu3/frames.cpp
> +++ b/src/libcamera/pipeline/ipu3/frames.cpp
> @@ -131,4 +131,27 @@ IPU3Frames::Info *IPU3Frames::find(FrameBuffer *buffer)
>  	return nullptr;
>  }
>  
> +const std::string IPU3Frames::Info::toString() const
> +{
> +	std::stringstream ss;

Missing header (same in the Request patch that uses std::stringstream).

> +
> +	ss << request->toString()
> +	   << (metadataProcessed ? "" : "[!metadata]")
> +	   << (paramDequeued ? "" : "[!param]");
> +

Same comment as for Request::toString().

> +	return ss.str();
> +}
> +
> +void IPU3Frames::dump() const
> +{
> +	LOG(IPU3, Error) << "Frames:";

Debug ?

> +
> +	for (auto const &itInfo : frameInfo_) {

itInfo isn't an iterator, but a pair. You can name it elem, element,
entry, ... if you want a generic name.

> +		Info *info = itInfo.second.get();
> +
> +		LOG(IPU3, Error)

Debug ?

> +			<< " - " << info->toString();
> +	}
> +}
> +
>  } /* namespace libcamera */
> diff --git a/src/libcamera/pipeline/ipu3/frames.h b/src/libcamera/pipeline/ipu3/frames.h
> index 4acdf48eca9d..c769ae864d32 100644
> --- a/src/libcamera/pipeline/ipu3/frames.h
> +++ b/src/libcamera/pipeline/ipu3/frames.h
> @@ -34,6 +34,8 @@ public:
>  
>  		bool paramDequeued;
>  		bool metadataProcessed;
> +
> +		const std::string toString() const;

You can drop the first const, and you should include <string>.

>  	};
>  
>  	IPU3Frames();
> @@ -49,6 +51,8 @@ public:
>  	Info *find(unsigned int id);
>  	Info *find(FrameBuffer *buffer);
>  
> +	void dump() const;
> +
>  private:
>  	std::queue<FrameBuffer *> availableParamBuffers_;
>  	std::queue<FrameBuffer *> availableStatBuffers_;

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/frames.cpp b/src/libcamera/pipeline/ipu3/frames.cpp
index 4198e2019f3f..b8b471c3c561 100644
--- a/src/libcamera/pipeline/ipu3/frames.cpp
+++ b/src/libcamera/pipeline/ipu3/frames.cpp
@@ -131,4 +131,27 @@  IPU3Frames::Info *IPU3Frames::find(FrameBuffer *buffer)
 	return nullptr;
 }
 
+const std::string IPU3Frames::Info::toString() const
+{
+	std::stringstream ss;
+
+	ss << request->toString()
+	   << (metadataProcessed ? "" : "[!metadata]")
+	   << (paramDequeued ? "" : "[!param]");
+
+	return ss.str();
+}
+
+void IPU3Frames::dump() const
+{
+	LOG(IPU3, Error) << "Frames:";
+
+	for (auto const &itInfo : frameInfo_) {
+		Info *info = itInfo.second.get();
+
+		LOG(IPU3, Error)
+			<< " - " << info->toString();
+	}
+}
+
 } /* namespace libcamera */
diff --git a/src/libcamera/pipeline/ipu3/frames.h b/src/libcamera/pipeline/ipu3/frames.h
index 4acdf48eca9d..c769ae864d32 100644
--- a/src/libcamera/pipeline/ipu3/frames.h
+++ b/src/libcamera/pipeline/ipu3/frames.h
@@ -34,6 +34,8 @@  public:
 
 		bool paramDequeued;
 		bool metadataProcessed;
+
+		const std::string toString() const;
 	};
 
 	IPU3Frames();
@@ -49,6 +51,8 @@  public:
 	Info *find(unsigned int id);
 	Info *find(FrameBuffer *buffer);
 
+	void dump() const;
+
 private:
 	std::queue<FrameBuffer *> availableParamBuffers_;
 	std::queue<FrameBuffer *> availableStatBuffers_;