[Concept,v2,07/16] sandbox: Provide a way to tell if the video is visible
Commit Message
From: Simon Glass <sjg@chromium.org>
Sandbox is often run with the display disabled, so even though it has a
video device, it is not being shown. Provide a way to detect this. For
all other platforms, we assume the display is shown, when there is a
video device.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add new patch to provide a way to tell if the video is visible
arch/sandbox/cpu/state.c | 7 +++++++
arch/sandbox/include/asm/state.h | 7 +++++++
include/video.h | 21 +++++++++++++++++++++
3 files changed, 35 insertions(+)
@@ -483,6 +483,13 @@ bool sandbox_serial_is_tty(void)
return state->serial_is_tty;
}
+bool sandbox_video_is_visible(void)
+{
+ struct sandbox_state *state = state_get_current();
+
+ return state->show_lcd;
+}
+
int state_init(void)
{
state = &main_state;
@@ -385,6 +385,13 @@ int state_load_other_fdt(const char **bufp, int *sizep);
*/
bool sandbox_serial_is_tty(void);
+/*
+ * sandbox_video_is_visible() - check if video display is showing
+ *
+ * Return: true if display is active, false if just using the serial console
+ */
+bool sandbox_video_is_visible(void);
+
/**
* Initialize the test system state
*/
@@ -8,6 +8,9 @@
#define _VIDEO_H_
#include <stdio_dev.h>
+#ifdef CONFIG_SANDBOX
+#include <asm/state.h>
+#endif
struct udevice;
@@ -460,4 +463,22 @@ int video_reserve_from_bloblist(struct video_handoff *ho);
*/
ulong video_get_fb(void);
+/**
+ * video_is_visible() - check if the video display is being used
+ *
+ * This does not indicate that there is actually a display, only that if there
+ * is one, we can assume it is present
+ *
+ * Return: true if any display is likely visible, false if not
+ */
+static inline bool video_is_visible(void)
+{
+#ifdef CONFIG_SANDBOX
+ return sandbox_video_is_visible();
+#else
+ /* assume that it is! */
+ return true;
+#endif
+}
+
#endif