linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] video/logo: add option to return largest logo for a given resolution
@ 2015-07-03  8:38 Urs Fässler
  2015-07-03  8:38 ` [PATCH 1/3] video/logo: use list of logos to find logo Urs Fässler
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Urs Fässler @ 2015-07-03  8:38 UTC (permalink / raw)
  To: daniel.vetter, linux-fbdev, linux-kernel, oliver.staebler,
	plagnioj, tomi.valkeinen, urs.fassler

With this patches, the largest boot logo for a given display resolution is used.
We need that functionality since it is common that a product has variants which
differ only minimal in the hardware. Thus, we have the same kernel binary but
different device trees for different hardware / displays.
This patches allow use to show a full screen boot logo for every hardware
variant.

Urs Fässler (3):
  video/logo: use list of logos to find logo
  logo: add option to return largest logo for a given resolution
  fbdev: use largest logo if possible

 drivers/video/fbdev/core/fbmem.c |  21 ++++--
 drivers/video/logo/Kconfig       |   7 ++
 drivers/video/logo/logo.c        | 146 ++++++++++++++++++++++++++-------------
 include/linux/linux_logo.h       |   4 ++
 4 files changed, 124 insertions(+), 54 deletions(-)

-- 
2.1.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] video/logo: use list of logos to find logo
  2015-07-03  8:38 [PATCH 0/3] video/logo: add option to return largest logo for a given resolution Urs Fässler
@ 2015-07-03  8:38 ` Urs Fässler
  2015-07-03  9:13   ` Geert Uytterhoeven
  2015-07-03  8:38 ` [PATCH 2/3] logo: add option to return largest logo for a given resolution Urs Fässler
  2015-07-03  8:38 ` [PATCH 3/3] fbdev: use largest logo if possible Urs Fässler
  2 siblings, 1 reply; 5+ messages in thread
From: Urs Fässler @ 2015-07-03  8:38 UTC (permalink / raw)
  To: daniel.vetter, linux-fbdev, linux-kernel, oliver.staebler,
	plagnioj, tomi.valkeinen, urs.fassler

Refactoring of fb_find_logo: declare list of logos explicit and loop over
it to find a match.

Signed-off-by: Urs Fässler <urs.fassler@bytesatwork.ch>
---
 drivers/video/logo/logo.c | 109 ++++++++++++++++++++++++++--------------------
 1 file changed, 62 insertions(+), 47 deletions(-)

diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
index 10fbfd8..d0a44db 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -36,82 +36,97 @@ static int __init fb_logo_late_init(void)
 
 late_initcall(fb_logo_late_init);
 
-/* 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 || logos_freed)
-		return NULL;
-
-	if (depth >= 1) {
+static const struct linux_logo *logos[] __initconst = {
 #ifdef CONFIG_LOGO_LINUX_MONO
-		/* Generic Linux logo */
-		logo = &logo_linux_mono;
+	/* Generic Linux logo */
+	&logo_linux_mono,
 #endif
 #ifdef CONFIG_LOGO_SUPERH_MONO
-		/* SuperH Linux logo */
-		logo = &logo_superh_mono;
+	/* SuperH Linux logo */
+	&logo_superh_mono,
 #endif
-	}
-	
-	if (depth >= 4) {
 #ifdef CONFIG_LOGO_LINUX_VGA16
-		/* Generic Linux logo */
-		logo = &logo_linux_vga16;
+	/* Generic Linux logo */
+	&logo_linux_vga16,
 #endif
 #ifdef CONFIG_LOGO_BLACKFIN_VGA16
-		/* Blackfin processor logo */
-		logo = &logo_blackfin_vga16;
+	/* Blackfin processor logo */
+	&logo_blackfin_vga16,
 #endif
 #ifdef CONFIG_LOGO_SUPERH_VGA16
-		/* SuperH Linux logo */
-		logo = &logo_superh_vga16;
+	/* SuperH Linux logo */
+	&logo_superh_vga16,
 #endif
-	}
-	
-	if (depth >= 8) {
 #ifdef CONFIG_LOGO_LINUX_CLUT224
-		/* Generic Linux logo */
-		logo = &logo_linux_clut224;
+	/* Generic Linux logo */
+	&logo_linux_clut224,
 #endif
 #ifdef CONFIG_LOGO_BLACKFIN_CLUT224
-		/* Blackfin Linux logo */
-		logo = &logo_blackfin_clut224;
+	/* Blackfin Linux logo */
+	&logo_blackfin_clut224,
 #endif
 #ifdef CONFIG_LOGO_DEC_CLUT224
-		/* DEC Linux logo on MIPS/MIPS64 or ALPHA */
-		logo = &logo_dec_clut224;
+	/* DEC Linux logo on MIPS/MIPS64 or ALPHA */
+	&logo_dec_clut224,
 #endif
-#ifdef CONFIG_LOGO_MAC_CLUT224
-		/* Macintosh Linux logo on m68k */
-		if (MACH_IS_MAC)
-			logo = &logo_mac_clut224;
+#if defined(CONFIG_LOGO_MAC_CLUT224) && MACH_IS_MAC
+	/* Macintosh Linux logo on m68k */
+	&logo_mac_clut224,
 #endif
 #ifdef CONFIG_LOGO_PARISC_CLUT224
-		/* PA-RISC Linux logo */
-		logo = &logo_parisc_clut224;
+	/* PA-RISC Linux logo */
+	&logo_parisc_clut224,
 #endif
 #ifdef CONFIG_LOGO_SGI_CLUT224
-		/* SGI Linux logo on MIPS/MIPS64 */
-		logo = &logo_sgi_clut224;
+	/* SGI Linux logo on MIPS/MIPS64 */
+	&logo_sgi_clut224,
 #endif
 #ifdef CONFIG_LOGO_SUN_CLUT224
-		/* Sun Linux logo */
-		logo = &logo_sun_clut224;
+	/* Sun Linux logo */
+	&logo_sun_clut224,
 #endif
 #ifdef CONFIG_LOGO_SUPERH_CLUT224
-		/* SuperH Linux logo */
-		logo = &logo_superh_clut224;
+	/* SuperH Linux logo */
+	&logo_superh_clut224,
 #endif
 #ifdef CONFIG_LOGO_M32R_CLUT224
-		/* M32R Linux logo */
-		logo = &logo_m32r_clut224;
+	/* M32R Linux logo */
+	&logo_m32r_clut224,
 #endif
+	NULL
+};
+
+static bool type_depth_compatible(int type, int depth)
+{
+	switch (type) {
+	case LINUX_LOGO_MONO:
+		return depth >= 1;
+	case LINUX_LOGO_VGA16:
+		return depth >= 4;
+	case LINUX_LOGO_CLUT224:
+		return depth >= 8;
+	default:
+		return false;
 	}
+}
+
+/* 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 **logos_itr;
+
+	if (nologo || logos_freed)
+		return NULL;
+
+	for (logos_itr = logos; *logos_itr != NULL; logos_itr++)
+		if (type_depth_compatible((*logos_itr)->type, depth))
+			logo = *logos_itr;
+
 	return logo;
 }
 EXPORT_SYMBOL_GPL(fb_find_logo);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] logo: add option to return largest logo for a given resolution
  2015-07-03  8:38 [PATCH 0/3] video/logo: add option to return largest logo for a given resolution Urs Fässler
  2015-07-03  8:38 ` [PATCH 1/3] video/logo: use list of logos to find logo Urs Fässler
@ 2015-07-03  8:38 ` Urs Fässler
  2015-07-03  8:38 ` [PATCH 3/3] fbdev: use largest logo if possible Urs Fässler
  2 siblings, 0 replies; 5+ messages in thread
From: Urs Fässler @ 2015-07-03  8:38 UTC (permalink / raw)
  To: daniel.vetter, linux-fbdev, linux-kernel, oliver.staebler,
	plagnioj, tomi.valkeinen, urs.fassler

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  | 43 ++++++++++++++++++++++++++++++++++++++++---
 include/linux/linux_logo.h |  4 ++++
 3 files changed, 51 insertions(+), 3 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 d0a44db..4a6da90 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -111,11 +111,35 @@ static bool type_depth_compatible(int type, int depth)
 	}
 }
 
+#ifdef CONFIG_FB_LOGO_LARGEST
+static bool resolution_compatible(const struct linux_logo *logo,
+	unsigned int width, unsigned int height)
+{
+	if (width && height)
+		return (logo->width <= width) && (logo->height <= height);
+	else
+		return true;
+}
+
+static const struct linux_logo * __init_refok fb_logo_larger(
+		const struct linux_logo *logo1, const struct linux_logo *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)
+#define resolution_compatible(logo, w, h)	(true)
+#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 width, unsigned int height)
 {
 	const struct linux_logo *logo = NULL;
 	const struct linux_logo **logos_itr;
@@ -124,9 +148,22 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
 		return NULL;
 
 	for (logos_itr = logos; *logos_itr != NULL; logos_itr++)
-		if (type_depth_compatible((*logos_itr)->type, depth))
-			logo = *logos_itr;
+		if (type_depth_compatible((*logos_itr)->type, depth) &&
+		    resolution_compatible(*logos_itr, width, height)) {
+			if (logo)
+				logo = fb_logo_larger(logo, *logos_itr);
+			else
+				logo = *logos_itr;
+		}
 
 	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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] fbdev: use largest logo if possible
  2015-07-03  8:38 [PATCH 0/3] video/logo: add option to return largest logo for a given resolution Urs Fässler
  2015-07-03  8:38 ` [PATCH 1/3] video/logo: use list of logos to find logo Urs Fässler
  2015-07-03  8:38 ` [PATCH 2/3] logo: add option to return largest logo for a given resolution Urs Fässler
@ 2015-07-03  8:38 ` Urs Fässler
  2 siblings, 0 replies; 5+ messages in thread
From: Urs Fässler @ 2015-07-03  8:38 UTC (permalink / raw)
  To: daniel.vetter, linux-fbdev, linux-kernel, oliver.staebler,
	plagnioj, tomi.valkeinen, urs.fassler

If CONFIG_FB_LOGO_LARGEST is set, fbdev uses the largest boot logo to
display.

Signed-off-by: Urs Fässler <urs.fassler@bytesatwork.ch>
---
 drivers/video/fbdev/core/fbmem.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 0705d88..319f168 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -595,7 +595,7 @@ static inline int fb_show_extra_logos(struct fb_info *info, int y, int rotate)
 int fb_prepare_logo(struct fb_info *info, int rotate)
 {
 	int depth = fb_get_color_depth(&info->var, &info->fix);
-	unsigned int yres;
+	unsigned int xres, yres;
 
 	memset(&fb_logo, 0, sizeof(struct logo_data));
 
@@ -616,18 +616,25 @@ int fb_prepare_logo(struct fb_info *info, int rotate)
 		depth = 4;
 	}
 
-	/* Return if no suitable logo was found */
+	if (rotate = FB_ROTATE_UR || rotate = FB_ROTATE_UD) {
+		xres = info->var.xres;
+		yres = info->var.yres;
+	} else {
+		xres = info->var.yres;
+		yres = info->var.xres;
+	}
+
+#ifdef CONFIG_FB_LOGO_LARGEST
+	fb_logo.logo = fb_find_logo_largest(depth, xres, yres);
+#else
 	fb_logo.logo = fb_find_logo(depth);
+#endif
 
+	/* Return if no suitable logo was found */
 	if (!fb_logo.logo) {
 		return 0;
 	}
 
-	if (rotate = FB_ROTATE_UR || rotate = FB_ROTATE_UD)
-		yres = info->var.yres;
-	else
-		yres = info->var.xres;
-
 	if (fb_logo.logo->height > yres) {
 		fb_logo.logo = NULL;
 		return 0;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] video/logo: use list of logos to find logo
  2015-07-03  8:38 ` [PATCH 1/3] video/logo: use list of logos to find logo Urs Fässler
@ 2015-07-03  9:13   ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2015-07-03  9:13 UTC (permalink / raw)
  To: Urs Fässler
  Cc: Daniel Vetter, Linux Fbdev development list,
	linux-kernel@vger.kernel.org, oliver.staebler,
	Jean-Christophe PLAGNIOL-VILLARD, Tomi Valkeinen

On Fri, Jul 3, 2015 at 10:38 AM, Urs Fässler <urs.fassler@bytesatwork.ch> wrote:
> -#ifdef CONFIG_LOGO_MAC_CLUT224
> -               /* Macintosh Linux logo on m68k */
> -               if (MACH_IS_MAC)
> -                       logo = &logo_mac_clut224;
> +#if defined(CONFIG_LOGO_MAC_CLUT224) && MACH_IS_MAC
> +       /* Macintosh Linux logo on m68k */
> +       &logo_mac_clut224,
>  #endif

That won't work, as depending on kernel configuration, MACH_IS_MAC
can be a run-time test, cfr.

arch/m68k/include/asm/setup.h:#  define MACH_IS_MAC (0)
arch/m68k/include/asm/setup.h:#  define MACH_IS_MAC (m68k_machtype = MACH_MAC)
arch/m68k/include/asm/setup.h:#  define MACH_IS_MAC (1)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-07-03  9:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-03  8:38 [PATCH 0/3] video/logo: add option to return largest logo for a given resolution Urs Fässler
2015-07-03  8:38 ` [PATCH 1/3] video/logo: use list of logos to find logo Urs Fässler
2015-07-03  9:13   ` Geert Uytterhoeven
2015-07-03  8:38 ` [PATCH 2/3] logo: add option to return largest logo for a given resolution Urs Fässler
2015-07-03  8:38 ` [PATCH 3/3] fbdev: use largest logo if possible Urs Fässler

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).