Linux-fbdev Archive mirror
 help / color / mirror / Atom feed
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Cc: Daniel van Vugt <daniel.van.vugt@canonical.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Helge Deller <deller@gmx.de>,
	linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] dummycon: Add dummycon_(un)register_switch_notifier
Date: Fri,  2 Feb 2024 16:53:54 +0800	[thread overview]
Message-ID: <20240202085408.23251-1-daniel.van.vugt@canonical.com> (raw)

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@canonical.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


             reply	other threads:[~2024-02-02  8:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02  8:53 Daniel van Vugt [this message]
2024-02-02  8:53 ` [PATCH 2/2] fbcon: Defer console takeover for splash screens to first switch Daniel van Vugt
2024-02-02 19:46   ` Mario Limonciello
2024-02-06 10:10     ` [PATCH v2 1/2] dummycon: Add dummycon_(un)register_switch_notifier Daniel van Vugt
2024-02-06 10:10       ` [PATCH v2 2/2] fbcon: Defer console takeover for splash screens to first switch Daniel van Vugt
2024-02-06 14:21         ` Daniel Vetter
2024-02-06 15:41           ` Mario Limonciello
2024-02-07  2:03             ` Daniel van Vugt
2024-02-07  9:51               ` Daniel Vetter
2024-02-07 20:21                 ` Mario Limonciello
2024-02-08  1:16                   ` Daniel van Vugt
2024-02-09 10:58                     ` Daniel Vetter
2024-02-13  7:01                       ` Daniel van Vugt
2024-02-14  5:24                         ` [PATCH v3 1/2] dummycon: Add dummycon_(un)register_switch_notifier Daniel van Vugt
2024-02-14  5:24                           ` [PATCH v3 2/2] fbcon: Defer console takeover for splash screens to first switch Daniel van Vugt
2024-02-15 19:40                             ` Mario Limonciello
2024-02-19  9:02                               ` [PATCH v4 1/2] dummycon: Add dummycon_(un)register_switch_notifier Daniel van Vugt
2024-02-19  9:02                                 ` [PATCH v4 2/2] fbcon: Defer console takeover for splash screens to first switch Daniel van Vugt
2024-02-22 11:08                                   ` Maxime Ripard
2024-02-22 16:25                                     ` Mario Limonciello
2024-02-26 18:23   ` [PATCH " Hans de Goede
2024-02-27  1:06     ` Daniel van Vugt
2024-02-27 13:47       ` Hans de Goede
2024-02-28  2:00         ` Daniel van Vugt
2024-02-28 11:54           ` Hans de Goede
2024-02-28 18:09             ` Mario Limonciello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240202085408.23251-1-daniel.van.vugt@canonical.com \
    --to=daniel.van.vugt@canonical.com \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).