[Concept,10/14] expo: Track the number of render calls

Message ID 20251006205856.2009292-11-sjg@u-boot.org
State New
Headers
Series expo: More mouse development for expo |

Commit Message

Simon Glass Oct. 6, 2025, 8:58 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Keep track of the frame count, i.e. the number of times that
expo_render() has been called since expo_enter_mode() was invoked.

Allow test mode to be enabled (if compiled in) by setting the 'expotest'
environment variable to 1.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

 boot/expo_test.c    | 21 +++++++++++++++++++++
 include/expo.h      |  4 ++++
 include/expo_test.h | 11 +++++++++++
 3 files changed, 36 insertions(+)
  

Patch

diff --git a/boot/expo_test.c b/boot/expo_test.c
index ecef8decc6e..269052a61cb 100644
--- a/boot/expo_test.c
+++ b/boot/expo_test.c
@@ -8,18 +8,39 @@ 
 
 #define LOG_CATEGORY	LOGC_EXPO
 
+#include <env.h>
+#include <errno.h>
 #include <expo.h>
 #include <expo_test.h>
+#include <log.h>
+#include <malloc.h>
 
 int expo_test_init(struct expo *exp)
 {
+	struct expo_test_mode *test;
+
+	test = calloc(1, sizeof(struct expo_test_mode));
+	if (!test)
+		return log_msg_ret("test", -ENOMEM);
+
+	test->enabled = env_get_yesno("expotest") == 1;
+	exp->test = test;
+
 	return 0;
 }
 
 void expo_test_uninit(struct expo *exp)
 {
+	free(exp->test);
+	exp->test = NULL;
 }
 
 void expo_test_update(struct expo *exp)
 {
+	struct expo_test_mode *test = exp->test;
+
+	if (!test)
+		return;
+
+	test->render_count++;
 }
diff --git a/include/expo.h b/include/expo.h
index 8ad7415b5a4..e9e71f4fe36 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -90,6 +90,8 @@  struct expo_action {
 	};
 };
 
+struct expo_test_mode;
+
 /**
  * struct expo_theme - theme for the expo
  *
@@ -139,6 +141,7 @@  struct expo_theme {
  * @priv: Private data for the controller
  * @done: Indicates that a cedit session is complete and the user has quit
  * @save: Indicates that cedit data should be saved, rather than discarded
+ * @test: Pointer to test mode information, NULL if not allocated
  * @theme: Information about fonts styles, etc.
  * @scene_head: List of scenes
  * @str_head: list of strings
@@ -165,6 +168,7 @@  struct expo {
 	void *priv;
 	bool done;
 	bool save;
+	struct expo_test_mode *test;
 	struct expo_theme theme;
 	struct list_head scene_head;
 	struct list_head str_head;
diff --git a/include/expo_test.h b/include/expo_test.h
index e1918ddeff2..ee4ae4611f7 100644
--- a/include/expo_test.h
+++ b/include/expo_test.h
@@ -9,6 +9,17 @@ 
 
 struct expo;
 
+/**
+ * struct expo_test_mode - Test mode information for expo
+ *
+ * @enabled: true if test mode is enabled
+ * @render_count: Number of calls to expo_render() since expo_enter_mode()
+ */
+struct expo_test_mode {
+	bool enabled;
+	int render_count;
+};
+
 #if CONFIG_IS_ENABLED(EXPO_TEST)
 
 /**