linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Urs Fässler" <urs.fassler@bytesatwork.ch>
To: daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, oliver.staebler@bytesatwork.ch,
	plagnioj@jcrosoft.com, tomi.valkeinen@ti.com,
	urs.fassler@bytesatwork.ch, geert@linux-m68k.org
Subject: [PATCH 1/2] logo: add option to return largest logo for a given resolution
Date: Tue, 07 Jul 2015 14:24:11 +0000	[thread overview]
Message-ID: <1436279052-17237-2-git-send-email-urs.fassler@bytesatwork.ch> (raw)
In-Reply-To: <1436279052-17237-1-git-send-email-urs.fassler@bytesatwork.ch>

New method to return the largest (in number of pixels) logo for a given
resolution.
One use case is for embedded systems when one kernel binary is compiled
but used on different machines (i.e. different device trees) with
different display resolutions.

Signed-off-by: Urs Fässler <urs.fassler@bytesatwork.ch>
---
 drivers/video/logo/Kconfig |  7 ++++
 drivers/video/logo/logo.c  | 86 +++++++++++++++++++++++++++++++++++++---------
 include/linux/linux_logo.h |  4 +++
 3 files changed, 80 insertions(+), 17 deletions(-)

diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 0037104..72bd185 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -15,6 +15,13 @@ config FB_LOGO_EXTRA
 	depends on FB=y
 	default y if SPU_BASE
 
+config FB_LOGO_LARGEST
+	bool "Use largest"
+	default n
+	help
+	  Returns the largest available bootup logo that fits the given
+	  resolution.
+
 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 10fbfd8..1b0d4c5 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -36,11 +36,55 @@ static int __init fb_logo_late_init(void)
 
 late_initcall(fb_logo_late_init);
 
+#ifdef CONFIG_FB_LOGO_LARGEST
+bool fb_logo_valid(const struct linux_logo *logo, unsigned int width,
+		   unsigned int height)
+{
+	if (!logo)
+		return false;
+	if (logo->width > width)
+		return false;
+	if (logo->height > height)
+		return false;
+
+	return true;
+}
+
+const struct linux_logo * __init_refok fb_logo_larger(
+		const struct linux_logo *logo1, const struct linux_logo *logo2,
+		unsigned int width, unsigned int height)
+{
+	bool logo1_valid;
+	bool logo2_valid;
+
+	if (!width || !height)
+		return logo1;
+
+	logo1_valid = fb_logo_valid(logo1, width, height);
+	logo2_valid = fb_logo_valid(logo2, width, height);
+
+	if (!logo1_valid && !logo2_valid)
+		return NULL;
+	if (logo1_valid && !logo2_valid)
+		return logo1;
+	if (!logo1_valid && logo2_valid)
+		return logo2;
+
+	if (logo1->width*logo1->height > logo2->width*logo2->height)
+		return logo1;
+	else
+		return logo2;
+}
+#else
+#define fb_logo_larger(logo1, logo2, w, h)	(logo1)
+#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 * __init_refok fb_find_logo_largest(int depth,
+					unsigned int w, unsigned int h)
 {
 	const struct linux_logo *logo = NULL;
 
@@ -50,68 +94,76 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
 	if (depth >= 1) {
 #ifdef CONFIG_LOGO_LINUX_MONO
 		/* Generic Linux logo */
-		logo = &logo_linux_mono;
+		logo = fb_logo_larger(&logo_linux_mono, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_SUPERH_MONO
 		/* SuperH Linux logo */
-		logo = &logo_superh_mono;
+		logo = fb_logo_larger(&logo_superh_mono, logo, w, h);
 #endif
 	}
-	
+
 	if (depth >= 4) {
 #ifdef CONFIG_LOGO_LINUX_VGA16
 		/* Generic Linux logo */
-		logo = &logo_linux_vga16;
+		logo = fb_logo_larger(&logo_linux_vga16, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_BLACKFIN_VGA16
 		/* Blackfin processor logo */
-		logo = &logo_blackfin_vga16;
+		logo = fb_logo_larger(&logo_blackfin_vga16, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_SUPERH_VGA16
 		/* SuperH Linux logo */
-		logo = &logo_superh_vga16;
+		logo = fb_logo_larger(&logo_superh_vga16, logo, w, h);
 #endif
 	}
-	
+
 	if (depth >= 8) {
 #ifdef CONFIG_LOGO_LINUX_CLUT224
 		/* Generic Linux logo */
-		logo = &logo_linux_clut224;
+		logo = fb_logo_larger(&logo_linux_clut224, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_BLACKFIN_CLUT224
 		/* Blackfin Linux logo */
-		logo = &logo_blackfin_clut224;
+		logo = fb_logo_larger(&logo_blackfin_clut224, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_DEC_CLUT224
 		/* DEC Linux logo on MIPS/MIPS64 or ALPHA */
-		logo = &logo_dec_clut224;
+		logo = fb_logo_larger(&logo_dec_clut224, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_MAC_CLUT224
 		/* Macintosh Linux logo on m68k */
 		if (MACH_IS_MAC)
-			logo = &logo_mac_clut224;
+			logo = fb_logo_larger(&logo_mac_clut224, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_PARISC_CLUT224
 		/* PA-RISC Linux logo */
-		logo = &logo_parisc_clut224;
+		logo = fb_logo_larger(&logo_parisc_clut224, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_SGI_CLUT224
 		/* SGI Linux logo on MIPS/MIPS64 */
-		logo = &logo_sgi_clut224;
+		logo = fb_logo_larger(&logo_sgi_clut224, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_SUN_CLUT224
 		/* Sun Linux logo */
-		logo = &logo_sun_clut224;
+		logo = fb_logo_larger(&logo_sun_clut224, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_SUPERH_CLUT224
 		/* SuperH Linux logo */
-		logo = &logo_superh_clut224;
+		logo = fb_logo_larger(&logo_superh_clut224, logo, w, h);
 #endif
 #ifdef CONFIG_LOGO_M32R_CLUT224
 		/* M32R Linux logo */
-		logo = &logo_m32r_clut224;
+		logo = fb_logo_larger(&logo_m32r_clut224, logo, w, h);
 #endif
 	}
 	return logo;
 }
+#ifdef CONFIG_FB_LOGO_LARGEST
+EXPORT_SYMBOL_GPL(fb_find_logo_largest);
+#endif
+
+const struct linux_logo * __init_refok fb_find_logo(int depth)
+{
+	return fb_find_logo_largest(depth, 0, 0);
+}
 EXPORT_SYMBOL_GPL(fb_find_logo);
diff --git a/include/linux/linux_logo.h b/include/linux/linux_logo.h
index ca5bd91..f497e97 100644
--- a/include/linux/linux_logo.h
+++ b/include/linux/linux_logo.h
@@ -49,6 +49,10 @@ extern const struct linux_logo logo_m32r_clut224;
 extern const struct linux_logo logo_spe_clut224;
 
 extern const struct linux_logo *fb_find_logo(int depth);
+#ifdef CONFIG_FB_LOGO_LARGEST
+extern const struct linux_logo *fb_find_logo_largest(int depth,
+				unsigned int width, unsigned int height);
+#endif
 #ifdef CONFIG_FB_LOGO_EXTRA
 extern void fb_append_extra_logo(const struct linux_logo *logo,
 				 unsigned int n);
-- 
2.1.4


  reply	other threads:[~2015-07-07 14:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 14:24 [PATCH 0/2 v2] video/logo: add option to return largest logo for a given resolution Urs Fässler
2015-07-07 14:24 ` Urs Fässler [this message]
2015-07-07 14:24 ` [PATCH 2/2] fbdev: use largest logo if possible Urs Fässler

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=1436279052-17237-2-git-send-email-urs.fassler@bytesatwork.ch \
    --to=urs.fassler@bytesatwork.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=geert@linux-m68k.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver.staebler@bytesatwork.ch \
    --cc=plagnioj@jcrosoft.com \
    --cc=tomi.valkeinen@ti.com \
    /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 NNTP newsgroup(s).