public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Miguel Boton <waninkoko@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] logo: random logo selection option
Date: Sat, 12 Sep 2009 01:03:40 +0200	[thread overview]
Message-ID: <200909120103.41128.mboton@gmail.com> (raw)

If we select more than one logo in the kernel configuration, only the 'latest' one gets
displayed. Because of this the other logos do not ever have a chance to be displayed.

This patch adds a selectable option to display a random logo during the bootup process.
This way the kernel will be able to display any available logo, making the bootup process
a little different every time ;)

Signed-off-by: Miguel Boton <mboton@gmail.com>
--
 drivers/video/logo/Kconfig |    8 +++
 drivers/video/logo/logo.c  |  113 +++++++++++++++++++++++++------------------
 2 files changed, 74 insertions(+), 47 deletions(-)

diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 39ac49e..8b79ef5 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -15,6 +15,15 @@ config FB_LOGO_EXTRA
 	depends on FB=y
 	default y if SPU_BASE
 
+config LOGO_RANDOM
+	bool "Select random available logo"
+	default n
+	help
+	  This option enables random logo selection from available logos
+	  during the bootup process.
+
+comment "Available logos"
+
 config LOGO_LINUX_MONO
 	bool "Standard black and white Linux logo"
 	default y
diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
index ea7a8cc..f90c21b 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -13,6 +13,10 @@
 #include <linux/stddef.h>
 #include <linux/module.h>
 
+#ifdef CONFIG_LOGO_RANDOM
+#include <linux/random.h>
+#endif
+
 #ifdef CONFIG_M68K
 #include <asm/setup.h>
 #endif
@@ -25,82 +29,97 @@ static int nologo;
 module_param(nologo, bool, 0);
 MODULE_PARM_DESC(nologo, "Disables startup logo");
 
-/* logo's are marked __initdata. Use __init_refok to tell
- * modpost that it is intended that this function uses data
- * marked __initdata.
- */
-const struct linux_logo * __init_refok fb_find_logo(int depth)
-{
-	const struct linux_logo *logo = NULL;
-
-	if (nologo)
-		return NULL;
-
-	if (depth >= 1) {
+/* Monochromatic logos */
+static const struct linux_logo *logo_mono[] = {
 #ifdef CONFIG_LOGO_LINUX_MONO
-		/* Generic Linux logo */
-		logo = &logo_linux_mono;
+	&logo_linux_mono,		/* Generic Linux logo */
 #endif
 #ifdef CONFIG_LOGO_SUPERH_MONO
-		/* SuperH Linux logo */
-		logo = &logo_superh_mono;
+	&logo_superh_mono,		/* SuperH Linux logo */
 #endif
-	}
-	
-	if (depth >= 4) {
+};
+
+/* 16-colour logos */
+static const struct linux_logo *logo_vga16[] = {
 #ifdef CONFIG_LOGO_LINUX_VGA16
-		/* Generic Linux logo */
-		logo = &logo_linux_vga16;
+	&logo_linux_vga16,		/* Generic Linux logo */
 #endif
 #ifdef CONFIG_LOGO_BLACKFIN_VGA16
-		/* Blackfin processor logo */
-		logo = &logo_blackfin_vga16;
+	&logo_blackfin_vga16,		/* Blackfin processor logo */
 #endif
 #ifdef CONFIG_LOGO_SUPERH_VGA16
-		/* SuperH Linux logo */
-		logo = &logo_superh_vga16;
+	&logo_superh_vga16,		/* SuperH Linux logo */
 #endif
-	}
-	
-	if (depth >= 8) {
+};
+
+/* 224-colour logos */
+static const struct linux_logo *logo_clut224[] = {
 #ifdef CONFIG_LOGO_LINUX_CLUT224
-		/* Generic Linux logo */
-		logo = &logo_linux_clut224;
+	&logo_linux_clut224,		/* Generic Linux logo */
 #endif
 #ifdef CONFIG_LOGO_BLACKFIN_CLUT224
-		/* Blackfin Linux logo */
-		logo = &logo_blackfin_clut224;
+	&logo_blackfin_clut224,		/* Blackfin Linux logo */
 #endif
 #ifdef CONFIG_LOGO_DEC_CLUT224
-		/* DEC Linux logo on MIPS/MIPS64 or ALPHA */
-		logo = &logo_dec_clut224;
+	&logo_dec_clut224,		/* DEC Linux logo on MIPS/MIPS64 or ALPHA */
 #endif
 #ifdef CONFIG_LOGO_MAC_CLUT224
-		/* Macintosh Linux logo on m68k */
-		if (MACH_IS_MAC)
-			logo = &logo_mac_clut224;
+	&logo_mac_clut224,		/* Macintosh Linux logo on m68k */
 #endif
 #ifdef CONFIG_LOGO_PARISC_CLUT224
-		/* PA-RISC Linux logo */
-		logo = &logo_parisc_clut224;
+	&logo_parisc_clut224,		/* PA-RISC Linux logo */
 #endif
 #ifdef CONFIG_LOGO_SGI_CLUT224
-		/* SGI Linux logo on MIPS/MIPS64 and VISWS */
-		logo = &logo_sgi_clut224;
+	&logo_sgi_clut224,		/* SGI Linux logo on MIPS/MIPS64 and VISWS */
 #endif
 #ifdef CONFIG_LOGO_SUN_CLUT224
-		/* Sun Linux logo */
-		logo = &logo_sun_clut224;
+	&logo_sun_clut224,		/* Sun Linux logo */
 #endif
 #ifdef CONFIG_LOGO_SUPERH_CLUT224
-		/* SuperH Linux logo */
-		logo = &logo_superh_clut224;
+	&logo_superh_clut224,		/* SuperH Linux logo */
 #endif
 #ifdef CONFIG_LOGO_M32R_CLUT224
-		/* M32R Linux logo */
-		logo = &logo_m32r_clut224;
+	&logo_m32r_clut224,		/* M32R Linux logo */
 #endif
+};
+
+#ifdef CONFIG_LOGO_RANDOM
+#define LOGO_INDEX(s)	(get_random_int() % s)
+#else
+#define LOGO_INDEX(s)	(s - 1)
+#endif
+
+/* logo's are marked __initdata. Use __init_refok to tell
+ * modpost that it is intended that this function uses data
+ * marked __initdata.
+ */
+const struct linux_logo * __init_refok fb_find_logo(int depth)
+{
+	const struct linux_logo *logo = NULL;
+	const struct linux_logo **array = NULL;
+	unsigned int size;
+
+	if (nologo)
+		return NULL;
+
+	/* Select logo array */
+	if (depth >= 1) {
+		array = logo_mono;
+		size = ARRAY_SIZE(logo_mono);
+	}
+	if (depth >= 4) {
+		array = logo_vga16;
+		size = ARRAY_SIZE(logo_vga16);
+	}
+	if (depth >= 8) {
+		array = logo_clut224;
+		size = ARRAY_SIZE(logo_clut224);
 	}
+
+	/* We've got some logos to display */
+	if (array && size)
+		logo = array[LOGO_INDEX(size)];
+
 	return logo;
 }
 EXPORT_SYMBOL_GPL(fb_find_logo);

             reply	other threads:[~2009-09-11 23:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-11 23:03 Miguel Boton [this message]
2009-09-12  5:44 ` [PATCH] logo: random logo selection option Matt Mackall
2009-09-12  7:25   ` Geert Uytterhoeven

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=200909120103.41128.mboton@gmail.com \
    --to=waninkoko@gmail.com \
    --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