[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240214052412.22770-1-daniel.van.vugt@canonical.com>
Date: Wed, 14 Feb 2024 13:24:06 +0800
From: Daniel van Vugt <daniel.van.vugt@...onical.com>
To:
Cc: Daniel van Vugt <daniel.van.vugt@...onical.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Helge Deller <deller@....de>,
linux-fbdev@...r.kernel.org,
dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 1/2] dummycon: Add dummycon_(un)register_switch_notifier
To detect switch attempts before a real console exists. This will be
used for the same purpose as dummycon_(un)register_output_notifier,
for fbcon to detect a more polite time to take over.
Signed-off-by: Daniel van Vugt <daniel.van.vugt@...onical.com>
---
drivers/video/console/dummycon.c | 35 +++++++++++++++++++++++++++-----
include/linux/console.h | 2 ++
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index 14af5d9e13..55e9b600ce 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -83,6 +83,32 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)
/* Redraw, so that we get putc(s) for output done while blanked */
return 1;
}
+
+/* This is protected by the console_lock */
+static RAW_NOTIFIER_HEAD(dummycon_switch_nh);
+
+void dummycon_register_switch_notifier(struct notifier_block *nb)
+{
+ WARN_CONSOLE_UNLOCKED();
+
+ raw_notifier_chain_register(&dummycon_switch_nh, nb);
+}
+
+void dummycon_unregister_switch_notifier(struct notifier_block *nb)
+{
+ WARN_CONSOLE_UNLOCKED();
+
+ raw_notifier_chain_unregister(&dummycon_switch_nh, nb);
+}
+
+static int dummycon_switch(struct vc_data *vc)
+{
+ WARN_CONSOLE_UNLOCKED();
+
+ raw_notifier_call_chain(&dummycon_switch_nh, 0, vc);
+
+ return 0;
+}
#else
static void dummycon_putc(struct vc_data *vc, int c, int ypos, int xpos) { }
static void dummycon_putcs(struct vc_data *vc, const unsigned short *s,
@@ -91,6 +117,10 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)
{
return 0;
}
+static int dummycon_switch(struct vc_data *vc)
+{
+ return 0;
+}
#endif
static const char *dummycon_startup(void)
@@ -120,11 +150,6 @@ static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
return false;
}
-static int dummycon_switch(struct vc_data *vc)
-{
- return 0;
-}
-
/*
* The console `switch' structure for the dummy console
*
diff --git a/include/linux/console.h b/include/linux/console.h
index 779d388af8..8fd70ae623 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -531,5 +531,7 @@ extern void console_init(void);
/* For deferred console takeover */
void dummycon_register_output_notifier(struct notifier_block *nb);
void dummycon_unregister_output_notifier(struct notifier_block *nb);
+void dummycon_register_switch_notifier(struct notifier_block *nb);
+void dummycon_unregister_switch_notifier(struct notifier_block *nb);
#endif /* _LINUX_CONSOLE_H */
--
2.43.0
Powered by blists - more mailing lists