Module Name:    src
Committed By:   jmcneill
Date:           Sun Feb  6 23:25:18 UTC 2011

Modified Files:
        src/sys/arch/amd64/conf: GENERIC
        src/sys/arch/evbarm/conf: MPCSA_GENERIC
        src/sys/arch/evbppc/conf: VIRTEX_DFC
        src/sys/arch/evbppc/virtex/dev: tft.c tftvar.h
        src/sys/arch/x86/x86: x86_machdep.c
        src/sys/dev/pci: radeonfb.c radeonfbvar.h
        src/sys/dev/splash: files.splash splash.c splash.h
        src/sys/dev/wsfb: genfb.c
        src/sys/kern: subr_autoconf.c
Removed Files:
        src/sys/dev/splash/images: bikeshed.h netbsd-small.h netbsd.h

Log Message:
- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbarm/conf/MPCSA_GENERIC
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/evbppc/conf/VIRTEX_DFC
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbppc/virtex/dev/tft.c \
    src/sys/arch/evbppc/virtex/dev/tftvar.h
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/radeonfb.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/radeonfbvar.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/splash/files.splash
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/splash/splash.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/splash/splash.h
cvs rdiff -u -r1.1 -r0 src/sys/dev/splash/images/bikeshed.h \
    src/sys/dev/splash/images/netbsd-small.h \
    src/sys/dev/splash/images/netbsd.h
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/wsfb/genfb.c
cvs rdiff -u -r1.212 -r1.213 src/sys/kern/subr_autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.300 src/sys/arch/amd64/conf/GENERIC:1.301
--- src/sys/arch/amd64/conf/GENERIC:1.300	Wed Jan 26 00:25:55 2011
+++ src/sys/arch/amd64/conf/GENERIC	Sun Feb  6 23:25:16 2011
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.300 2011/01/26 00:25:55 pooka Exp $
+# $NetBSD: GENERIC,v 1.301 2011/02/06 23:25:16 jmcneill Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.300 $"
+#ident 		"GENERIC-$Revision: 1.301 $"
 
 maxusers	64		# estimated number of users
 
@@ -245,7 +245,6 @@
 #options 	VGA_RASTERCONSOLE
 # enable splash screen support; requires genfb or radeonfb
 #options        SPLASHSCREEN
-#options        SPLASHSCREEN_PROGRESS
 
 # Kernel root file system and dump configuration.
 config		netbsd	root on ? type ?

Index: src/sys/arch/evbarm/conf/MPCSA_GENERIC
diff -u src/sys/arch/evbarm/conf/MPCSA_GENERIC:1.17 src/sys/arch/evbarm/conf/MPCSA_GENERIC:1.18
--- src/sys/arch/evbarm/conf/MPCSA_GENERIC:1.17	Tue Nov 23 11:13:56 2010
+++ src/sys/arch/evbarm/conf/MPCSA_GENERIC	Sun Feb  6 23:25:16 2011
@@ -1,4 +1,4 @@
-# $NetBSD: MPCSA_GENERIC,v 1.17 2010/11/23 11:13:56 hannken Exp $
+# $NetBSD: MPCSA_GENERIC,v 1.18 2011/02/06 23:25:16 jmcneill Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.17 $"
+#ident 		"GENERIC-$Revision: 1.18 $"
 
 maxusers	32		# estimated number of users
 
@@ -250,7 +250,6 @@
 #options 	VGA_RASTERCONSOLE
 # enable splash screen support; requires hw driver support
 #options 	SPLASHSCREEN
-#options 	SPLASHSCREEN_PROGRESS
 
 # Kernel root file system and dump configuration.
 #config		netbsd root on sd0c type ffs

Index: src/sys/arch/evbppc/conf/VIRTEX_DFC
diff -u src/sys/arch/evbppc/conf/VIRTEX_DFC:1.11 src/sys/arch/evbppc/conf/VIRTEX_DFC:1.12
--- src/sys/arch/evbppc/conf/VIRTEX_DFC:1.11	Tue Nov 23 11:13:57 2010
+++ src/sys/arch/evbppc/conf/VIRTEX_DFC	Sun Feb  6 23:25:17 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: VIRTEX_DFC,v 1.11 2010/11/23 11:13:57 hannken Exp $
+#	$NetBSD: VIRTEX_DFC,v 1.12 2011/02/06 23:25:17 jmcneill Exp $
 #
 # VIRTEX_DFC
 #
@@ -145,8 +145,6 @@
 #options 	WSDISPLAY_DEFAULTSCREENS=4
 options 	FONT_VT220L8x16
 #options 	SPLASHSCREEN
-#options 	SPLASHSCREEN_PROGRESS
-#options 	SPLASHSCREEN_IMAGE="\"dev/splash/images/netbsd-small.h\""
 
 # Kernel root file system and dump configuration.
 #config		netbsd	root on ? type ?

Index: src/sys/arch/evbppc/virtex/dev/tft.c
diff -u src/sys/arch/evbppc/virtex/dev/tft.c:1.2 src/sys/arch/evbppc/virtex/dev/tft.c:1.3
--- src/sys/arch/evbppc/virtex/dev/tft.c:1.2	Sun Mar  4 05:59:46 2007
+++ src/sys/arch/evbppc/virtex/dev/tft.c	Sun Feb  6 23:25:17 2011
@@ -1,4 +1,4 @@
-/* 	$NetBSD: tft.c,v 1.2 2007/03/04 05:59:46 christos Exp $ */
+/* 	$NetBSD: tft.c,v 1.3 2011/02/06 23:25:17 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2006 Jachym Holecek
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tft.c,v 1.2 2007/03/04 05:59:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tft.c,v 1.3 2011/02/06 23:25:17 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -119,20 +119,8 @@
 	sc->sc_sp_info.si_stride = ri->ri_stride;
 	sc->sc_sp_info.si_fillrect = NULL;
 
-	splash_render(&sc->sc_sp_info, SPLASH_F_CENTER | SPLASH_F_FILL);
-#endif
-
-#ifdef	SPLASHSCREEN_PROGRESS
-	sc->sc_sp_progress.sp_top = (sc->sc_height / 8) * 7;
-	sc->sc_sp_progress.sp_width = (sc->sc_width / 4) * 3;
-	sc->sc_sp_progress.sp_left = (sc->sc_width -
-	    sc->sc_sp_progress.sp_width) / 2;
-	sc->sc_sp_progress.sp_height = 20;
-	sc->sc_sp_progress.sp_state = -1;
-	sc->sc_sp_progress.sp_si = &sc->sc_sp_info;
-
-	splash_progress_init(&sc->sc_sp_progress);
-	SCREEN_DISABLE_DRAWING(&sc->sc_vc_screen);
+	if (splash_render(&sc->sc_sp_info, SPLASH_F_CENTER|SPLASH_F_FILL) == 0)
+		SCREEN_DISABLE_DRAWING(&sc->sc_vc_screen);
 #endif
 
 	if (sc->sc_sdhook == NULL) {
Index: src/sys/arch/evbppc/virtex/dev/tftvar.h
diff -u src/sys/arch/evbppc/virtex/dev/tftvar.h:1.2 src/sys/arch/evbppc/virtex/dev/tftvar.h:1.3
--- src/sys/arch/evbppc/virtex/dev/tftvar.h:1.2	Sun Mar  4 05:59:46 2007
+++ src/sys/arch/evbppc/virtex/dev/tftvar.h	Sun Feb  6 23:25:17 2011
@@ -1,4 +1,4 @@
-/* 	$NetBSD: tftvar.h,v 1.2 2007/03/04 05:59:46 christos Exp $ */
+/* 	$NetBSD: tftvar.h,v 1.3 2011/02/06 23:25:17 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2006 Jachym Holecek
@@ -59,9 +59,6 @@
 #ifdef SPLASHSCREEN
 	struct splash_info 	sc_sp_info;
 #endif
-#ifdef SPLASHSCREEN_PROGRESS
-	struct splash_progress 	sc_sp_progress;
-#endif
 };
 
 void 		tft_attach(device_t, struct wsdisplay_accessops *);

Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.44 src/sys/arch/x86/x86/x86_machdep.c:1.45
--- src/sys/arch/x86/x86/x86_machdep.c:1.44	Thu Oct 21 11:17:54 2010
+++ src/sys/arch/x86/x86/x86_machdep.c	Sun Feb  6 23:25:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.44 2010/10/21 11:17:54 yamt Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.45 2011/02/06 23:25:17 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,10 +31,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.44 2010/10/21 11:17:54 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.45 2011/02/06 23:25:17 jmcneill Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
+#include "opt_splash.h"
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -56,6 +57,7 @@
 #include <x86/nmi.h>
 #include <x86/pio.h>
 
+#include <dev/splash/splash.h>
 #include <dev/isa/isareg.h>
 #include <dev/ic/i8042reg.h>
 
@@ -150,15 +152,27 @@
 	bi = (struct bi_modulelist_entry *)((uint8_t *)biml + sizeof(*biml));
 	bimax = bi + biml->num;
 	for (; bi < bimax; bi++) {
-		if (bi->type != BI_MODULE_ELF) {
+		switch (bi->type) {
+		case BI_MODULE_ELF:
+			aprint_debug("Prep module path=%s len=%d pa=%x\n", 
+			    bi->path, bi->len, bi->base);
+			KASSERT(trunc_page(bi->base) == bi->base);
+			module_prime((void *)((uintptr_t)bi->base + KERNBASE),
+			    bi->len);
+			break;
+		case BI_MODULE_IMAGE:
+#ifdef SPLASHSCREEN
+			aprint_debug("Splash image path=%s len=%d pa=%x\n", 
+			    bi->path, bi->len, bi->base);
+			KASSERT(trunc_page(bi->base) == bi->base);
+			splash_setimage(
+			    (void *)((uintptr_t)bi->base + KERNBASE), bi->len);
+#endif
+			break;
+		default:
 			aprint_debug("Skipping non-ELF module\n");
-			continue;
+			break;
 		}
-		aprint_debug("Prep module path=%s len=%d pa=%x\n", bi->path,
-		    bi->len, bi->base);
-		KASSERT(trunc_page(bi->base) == bi->base);
-		(void)module_prime((void *)((uintptr_t)bi->base + KERNBASE),
-		    bi->len);
 	}
 }
 #endif	/* MODULAR */

Index: src/sys/dev/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.41 src/sys/dev/pci/radeonfb.c:1.42
--- src/sys/dev/pci/radeonfb.c:1.41	Sat Jan 22 15:14:28 2011
+++ src/sys/dev/pci/radeonfb.c	Sun Feb  6 23:25:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.41 2011/01/22 15:14:28 cegger Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.42 2011/02/06 23:25:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.41 2011/01/22 15:14:28 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.42 2011/02/06 23:25:17 jmcneill Exp $");
 
 #define RADEONFB_DEFAULT_DEPTH 8
 
@@ -873,24 +873,12 @@
 			wsdisplay_cnattach(dp->rd_wsscreens, ri, 0, 0,
 			    defattr);
 #ifdef SPLASHSCREEN
-			splash_render(&dp->rd_splash,
-			    SPLASH_F_CENTER|SPLASH_F_FILL);
-#else
-			vcons_replay_msgbuf(&dp->rd_vscreen);
-#endif
-
-#ifdef SPLASHSCREEN_PROGRESS
-			dp->rd_progress.sp_top = (dp->rd_virty / 8) * 7;
-			dp->rd_progress.sp_width = (dp->rd_virtx / 4) * 3;
-			dp->rd_progress.sp_left = (dp->rd_virtx -
-			    dp->rd_progress.sp_width) / 2;
-			dp->rd_progress.sp_height = 20;
-			dp->rd_progress.sp_state = -1;
-			dp->rd_progress.sp_si = &dp->rd_splash;
-			splash_progress_init(&dp->rd_progress);
-			SCREEN_DISABLE_DRAWING(&dp->rd_vscreen);
+			if (splash_render(&dp->rd_splash,
+			    SPLASH_F_CENTER|SPLASH_F_FILL) == 0)
+				SCREEN_DISABLE_DRAWING(&dp->rd_vscreen);
+			else
 #endif
-
+				vcons_replay_msgbuf(&dp->rd_vscreen);
 		} else {
 
 			/*
@@ -903,9 +891,9 @@
 
 			radeonfb_modeswitch(dp);
 #ifdef SPLASHSCREEN
-			splash_render(&dp->rd_splash,
-			    SPLASH_F_CENTER|SPLASH_F_FILL);
-			SCREEN_DISABLE_DRAWING(&dp->rd_vscreen);
+			if (splash_render(&dp->rd_splash,
+			    SPLASH_F_CENTER|SPLASH_F_FILL) == 0)
+				SCREEN_DISABLE_DRAWING(&dp->rd_vscreen);
 #endif
 		}
 
@@ -1066,15 +1054,6 @@
 #else
 		return ENODEV;
 #endif
-	case WSDISPLAYIO_SPROGRESS:
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-		dp->rd_progress.sp_force = 1;
-		splash_progress_update(&dp->rd_progress);
-		dp->rd_progress.sp_force = 0;
-		return 0;
-#else
-		return ENODEV;
-#endif
 	case WSDISPLAYIO_GETPARAM:
 		param = (struct wsdisplay_param *)d;
 		if (param->param == WSDISPLAYIO_PARAM_BACKLIGHT) {

Index: src/sys/dev/pci/radeonfbvar.h
diff -u src/sys/dev/pci/radeonfbvar.h:1.10 src/sys/dev/pci/radeonfbvar.h:1.11
--- src/sys/dev/pci/radeonfbvar.h:1.10	Wed Nov  3 00:49:02 2010
+++ src/sys/dev/pci/radeonfbvar.h	Sun Feb  6 23:25:17 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: radeonfbvar.h,v 1.10 2010/11/03 00:49:02 macallan Exp $ */
+/* $NetBSD: radeonfbvar.h,v 1.11 2011/02/06 23:25:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -201,10 +201,6 @@
 #ifdef SPLASHSCREEN
 	struct splash_info	rd_splash;
 #endif
-
-#ifdef SPLASHSCREEN_PROGRESS
-	struct splash_progress	rd_progress;
-#endif
 };
 
 struct radeon_tmds_pll {

Index: src/sys/dev/splash/files.splash
diff -u src/sys/dev/splash/files.splash:1.2 src/sys/dev/splash/files.splash:1.3
--- src/sys/dev/splash/files.splash:1.2	Sun Feb 19 01:39:54 2006
+++ src/sys/dev/splash/files.splash	Sun Feb  6 23:25:18 2011
@@ -1,7 +1,6 @@
-# $NetBSD: files.splash,v 1.2 2006/02/19 01:39:54 macallan Exp $
+# $NetBSD: files.splash,v 1.3 2011/02/06 23:25:18 jmcneill Exp $
 
-define splash
+define splash: stbi
 file dev/splash/splash.c	splash
 
-defflag opt_splash.h	SPLASHSCREEN SPLASHSCREEN_PROGRESS
-defparam opt_splash.h	SPLASHSCREEN_IMAGE
+defflag opt_splash.h	SPLASHSCREEN

Index: src/sys/dev/splash/splash.c
diff -u src/sys/dev/splash/splash.c:1.8 src/sys/dev/splash/splash.c:1.9
--- src/sys/dev/splash/splash.c:1.8	Mon Feb 22 05:55:10 2010
+++ src/sys/dev/splash/splash.c	Sun Feb  6 23:25:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: splash.c,v 1.8 2010/02/22 05:55:10 ahoka Exp $ */
+/* $NetBSD: splash.c,v 1.9 2011/02/06 23:25:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2006 Jared D. McNeill <[email protected]>
@@ -34,12 +34,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: splash.c,v 1.8 2010/02/22 05:55:10 ahoka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: splash.c,v 1.9 2011/02/06 23:25:18 jmcneill Exp $");
 
 #include "opt_splash.h"
 
 /* XXX */
-#define	NSPLASH8 1
+#define NSPLASH8  1
 #define	NSPLASH16 1
 #define	NSPLASH32 1
 
@@ -51,29 +51,84 @@
 #include <sys/kthread.h>
 
 #include <dev/splash/splash.h>
-
-#if !defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-#error "options SPLASHSCREEN_PROGRESS requires SPLASHSCREEN"
-#endif
-
-#ifdef __HAVE_CPU_COUNTER
-#include <sys/cpu.h>
-#include <machine/cpu_counter.h>
-#endif
-
-#ifndef SPLASHSCREEN_IMAGE
-#define SPLASHSCREEN_IMAGE "dev/splash/images/netbsd.h"
-#endif
+#include <dev/stbi/stbi.h>
 
 #ifdef SPLASHSCREEN
-#include SPLASHSCREEN_IMAGE
 
-#ifdef SPLASHSCREEN_PROGRESS
-struct splash_progress *splash_progress_state;
-#ifdef __HAVE_CPU_COUNTER
-static uint64_t splash_last_update;
-#endif
-#endif
+static struct {
+	const u_char	*data;
+	size_t		datalen;
+} splash_image = { NULL, 0 };
+
+#define SPLASH_INDEX(r, g, b)						\
+	((((r) >> 6) << 4) | (((g) >> 6) << 2) | (((b) >> 6) << 0))
+
+static uint8_t splash_palette[SPLASH_CMAP_SIZE][3] = {
+	{ 0x00, 0x00, 0x00 },
+	{ 0x00, 0x00, 0x55 },
+	{ 0x00, 0x00, 0xaa },
+	{ 0x00, 0x00, 0xff },
+	{ 0x00, 0x55, 0x00 },
+	{ 0x00, 0x55, 0x55 },
+	{ 0x00, 0x55, 0xaa },
+	{ 0x00, 0x55, 0xff },
+	{ 0x00, 0xaa, 0x00 },
+	{ 0x00, 0xaa, 0x55 },
+	{ 0x00, 0xaa, 0xaa },
+	{ 0x00, 0xaa, 0xff },
+	{ 0x00, 0xff, 0x00 },
+	{ 0x00, 0xff, 0x55 },
+	{ 0x00, 0xff, 0xaa },
+	{ 0x00, 0xff, 0xff },
+	{ 0x55, 0x00, 0x00 },
+	{ 0x55, 0x00, 0x55 },
+	{ 0x55, 0x00, 0xaa },
+	{ 0x55, 0x00, 0xff },
+	{ 0x55, 0x55, 0x00 },
+	{ 0x55, 0x55, 0x55 },
+	{ 0x55, 0x55, 0xaa },
+	{ 0x55, 0x55, 0xff },
+	{ 0x55, 0xaa, 0x00 },
+	{ 0x55, 0xaa, 0x55 },
+	{ 0x55, 0xaa, 0xaa },
+	{ 0x55, 0xaa, 0xff },
+	{ 0x55, 0xff, 0x00 },
+	{ 0x55, 0xff, 0x55 },
+	{ 0x55, 0xff, 0xaa },
+	{ 0x55, 0xff, 0xff },
+	{ 0xaa, 0x00, 0x00 },
+	{ 0xaa, 0x00, 0x55 },
+	{ 0xaa, 0x00, 0xaa },
+	{ 0xaa, 0x00, 0xff },
+	{ 0xaa, 0x55, 0x00 },
+	{ 0xaa, 0x55, 0x55 },
+	{ 0xaa, 0x55, 0xaa },
+	{ 0xaa, 0x55, 0xff },
+	{ 0xaa, 0xaa, 0x00 },
+	{ 0xaa, 0xaa, 0x55 },
+	{ 0xaa, 0xaa, 0xaa },
+	{ 0xaa, 0xaa, 0xff },
+	{ 0xaa, 0xff, 0x00 },
+	{ 0xaa, 0xff, 0x55 },
+	{ 0xaa, 0xff, 0xaa },
+	{ 0xaa, 0xff, 0xff },
+	{ 0xff, 0x00, 0x00 },
+	{ 0xff, 0x00, 0x55 },
+	{ 0xff, 0x00, 0xaa },
+	{ 0xff, 0x00, 0xff },
+	{ 0xff, 0x55, 0x00 },
+	{ 0xff, 0x55, 0x55 },
+	{ 0xff, 0x55, 0xaa },
+	{ 0xff, 0x55, 0xff },
+	{ 0xff, 0xaa, 0x00 },
+	{ 0xff, 0xaa, 0x55 },
+	{ 0xff, 0xaa, 0xaa },
+	{ 0xff, 0xaa, 0xff },
+	{ 0xff, 0xff, 0x00 },
+	{ 0xff, 0xff, 0x55 },
+	{ 0xff, 0xff, 0xaa },
+	{ 0xff, 0xff, 0xff },
+};
 
 #if NSPLASH8 > 0
 static void	splash_render8(struct splash_info *, const char *, int,
@@ -88,75 +143,133 @@
 				int, int, int, int);
 #endif
 
-void
+int
+splash_setimage(const void *imgdata, size_t imgdatalen)
+{
+	if (splash_image.data != NULL) {
+		aprint_debug("WARNING: %s: already initialized\n", __func__);
+		return EBUSY;
+	}
+
+	aprint_verbose("%s: splash image @ %p, %d bytes\n",
+	    __func__, imgdata, imgdatalen);
+	splash_image.data = imgdata;
+	splash_image.datalen = imgdatalen;
+
+	return 0;
+}
+
+int
+splash_get_cmap(int index, uint8_t *r, uint8_t *g, uint8_t *b)
+{
+	if (index < SPLASH_CMAP_OFFSET ||
+	    index >= SPLASH_CMAP_OFFSET + SPLASH_CMAP_SIZE)
+		return ERANGE;
+
+	*r = splash_palette[index - SPLASH_CMAP_OFFSET][0];
+	*g = splash_palette[index - SPLASH_CMAP_OFFSET][1];
+	*b = splash_palette[index - SPLASH_CMAP_OFFSET][2];
+
+	return 0;
+}
+
+int
 splash_render(struct splash_info *si, int flg)
 {
-	int xoff, yoff;
+	char *data = NULL;
+	int xoff, yoff, width, height, comp;
+	int error = 0;
+
+	if (splash_image.data == NULL) {
+		aprint_error("WARNING: %s: not initialized\n", __func__);
+		return ENXIO;
+	}
+
+	data = stbi_load_from_memory(splash_image.data,
+	    splash_image.datalen, &width, &height, &comp, STBI_rgb);
+	if (data == NULL) {
+		aprint_error("WARNING: couldn't load splash image: %s\n",
+		    stbi_failure_reason());
+		return EINVAL;
+	}
+	aprint_debug("%s: splash loaded, width %d height %d comp %d\n",
+	    __func__, width, height, comp);
 
 	/* XXX */
 	if (flg & SPLASH_F_CENTER) {
-		xoff = (si->si_width - _splash_width) / 2;
-		yoff = (si->si_height - _splash_height) / 2;
+		xoff = (si->si_width - width) / 2;
+		yoff = (si->si_height - height) / 2;
 	} else
 		xoff = yoff = 0;
 
 	switch (si->si_depth) {
 #if NSPLASH8 > 0
 	case 8:
-		splash_render8(si, _splash_header_data, xoff, yoff,
-		    _splash_width, _splash_height, flg);
+		splash_render8(si, data, xoff, yoff, width, height, flg);
 		break;
 #endif
 #if NSPLASH16 > 0
 	case 16:
-		splash_render16(si, _splash_header_data, xoff, yoff,
-		    _splash_width, _splash_height, flg);
+		splash_render16(si, data, xoff, yoff, width, height, flg);
 		break;
 #endif
 #if NSPLASH32 > 0
 	case 32:
-		splash_render32(si, _splash_header_data, xoff, yoff,
-		    _splash_width, _splash_height, flg);
+		splash_render32(si, data, xoff, yoff, width, height, flg);
 		break;
 #endif
 	default:
 		aprint_error("WARNING: Splash not supported at %dbpp\n",
 		    si->si_depth);
-		break;
+		error = EINVAL;
 	}
 
-	return;
+	if (data)
+		stbi_image_free(data);
+
+	return error;
 }
 
 #if NSPLASH8 > 0
+
 static void
 splash_render8(struct splash_info *si, const char *data, int xoff, int yoff,
 	       int swidth, int sheight, int flg)
 {
-	const char *p;
-	u_char *fb, pix;
+	const char *d;
+	u_char *fb, *p;
+	u_char pix[3];
 	int x, y, i;
 	int filled;
 
 	fb = si->si_bits;
+
 	if (flg & SPLASH_F_FILL)
 		filled = 0;
 	else
 		filled = 1;
 
-	p = data;
-	fb += xoff + (yoff * si->si_width);
+	d = data;
+	fb += xoff + yoff * si->si_stride;
+
 	for (y = 0; y < sheight; y++) {
 		for (x = 0; x < swidth; x++) {
-			pix = *p++;
-			pix += SPLASH_CMAP_OFFSET;
+			pix[0] = *d++;
+			pix[1] = *d++;
+			pix[2] = *d++;
 			if (filled == 0) {
-				for (i = 0; i < (si->si_width * si->si_height);
-				     i++)
-					si->si_bits[i] = pix;
+				p = si->si_bits;
+				i = 0;
+				while (i < si->si_height*si->si_stride) {
+					p[i] = SPLASH_INDEX(
+					    pix[0], pix[1], pix[2]) +
+					    SPLASH_CMAP_OFFSET;
+					i++;
+				}
 				filled = 1;
 			}
-			fb[x] = pix;
+			fb[x] = SPLASH_INDEX(pix[0], pix[1], pix[2]) +
+				    SPLASH_CMAP_OFFSET;
 		}
 		fb += si->si_width;
 	}
@@ -165,7 +278,7 @@
 	if (si->si_hwbits) {
 		if (flg & SPLASH_F_FILL) {
 			memcpy(si->si_hwbits, si->si_bits,
-			    si->si_width*si->si_height);
+			    si->si_height*si->si_width);
 		} else {
 			u_char *rp, *hrp;
 
@@ -174,8 +287,8 @@
 
 			for (y = 0; y < sheight; y++) {
 				memcpy(hrp, rp, swidth);
-				hrp += si->si_stride;
 				rp += si->si_stride;
+				hrp += si->si_stride;
 			}
 		}
 	}
@@ -215,7 +328,9 @@
 
 	for (y = 0; y < sheight; y++) {
 		for (x = 0; x < swidth; x++) {
-			_SPLASH_HEADER_PIXEL(d, pix);
+			pix[0] = *d++;
+			pix[1] = *d++;
+			pix[2] = *d++;
 			if (filled == 0) {
 				p = si->si_bits;
 				i = 0;
@@ -278,7 +393,9 @@
 
 	for (y = 0; y < sheight; y++) {
 		for (x = 0; x < swidth; x++) {
-			_SPLASH_HEADER_PIXEL(d, pix);
+			pix[0] = *d++;
+			pix[1] = *d++;
+			pix[2] = *d++;
 			if (filled == 0) {
 				p = si->si_bits;
 				i = 0;
@@ -322,115 +439,4 @@
 }
 #endif /* !NSPLASH32 > 0 */
 
-#ifdef SPLASHSCREEN_PROGRESS
-
-static void
-splash_progress_render(struct splash_progress *sp)
-{
-	struct splash_info *si;
-	int i;
-	int w;
-	int spacing;
-	int xoff;
-	int yoff;
-	int flg;
-
-	si = sp->sp_si;
-	flg = 0;
-
-	/* where should we draw the pulsers? */
-	yoff = (si->si_height / 8) * 7;
-	w = _pulse_off_width * SPLASH_PROGRESS_NSTATES;
-	xoff = (si->si_width / 4) * 3;
-	spacing = _pulse_off_width; /* XXX */
-
-	for (i = 0; i < SPLASH_PROGRESS_NSTATES; i++) {
-		const char *d = (sp->sp_state == i ? _pulse_on_header_data :
-				 _pulse_off_header_data);
-		switch (si->si_depth) {
-#if NSPLASH8 > 0
-		case 8:
-			splash_render8(si, d, (xoff + (i * spacing)),
-			    yoff, _pulse_off_width, _pulse_off_height, flg);
-			break;
-#endif
-#if NSPLASH16 > 0
-		case 16:
-			splash_render16(si, d, (xoff + (i * spacing)),
-			    yoff, _pulse_off_width, _pulse_off_height, flg);
-			break;
-#endif
-#if NSPLASH32 > 0
-		case 32:
-			splash_render32(si, d, (xoff + (i * spacing)),
-			    yoff, _pulse_off_width, _pulse_off_height, flg);
-			break;
-#endif
-		default:
-			/* do nothing */
-			break;
-		}
-	}
-}
-
-static int
-splash_progress_stop(device_t dev)
-{
-	struct splash_progress *sp;
-
-	sp = (struct splash_progress *)dev;
-	sp->sp_running = 0;
-
-	return 0;
-}
-
-void
-splash_progress_init(struct splash_progress *sp)
-{
-#ifdef __HAVE_CPU_COUNTER
-	if (cpu_hascounter())
-		splash_last_update = cpu_counter();
-	else
-		splash_last_update = 0;
-#endif
-
-	sp->sp_running = 1;
-	sp->sp_force = 0;
-	splash_progress_state = sp;
-	splash_progress_render(sp);
-	config_finalize_register((device_t)sp, splash_progress_stop);
-
-	return;
-}
-
-void
-splash_progress_update(struct splash_progress *sp)
-{
-	if (sp->sp_running == 0 && sp->sp_force == 0)
-		return;
-
-#ifdef __HAVE_CPU_COUNTER
-	if (cpu_hascounter()) {
-		uint64_t now;
-
-		if (splash_last_update == 0) {
-			splash_last_update = cpu_counter();
-		} else {
-			now = cpu_counter();
-			if (splash_last_update + cpu_frequency(curcpu())/4 >
-			    now)
-				return;
-			splash_last_update = now;
-		}
-	}
-#endif
-	sp->sp_state++;
-	if (sp->sp_state >= SPLASH_PROGRESS_NSTATES)
-		sp->sp_state = 0;
-
-	splash_progress_render(sp);
-}
-
-#endif /* !SPLASHSCREEN_PROGRESS */
-
 #endif /* !SPLASHSCREEN */

Index: src/sys/dev/splash/splash.h
diff -u src/sys/dev/splash/splash.h:1.4 src/sys/dev/splash/splash.h:1.5
--- src/sys/dev/splash/splash.h:1.4	Tue May 12 14:45:43 2009
+++ src/sys/dev/splash/splash.h	Sun Feb  6 23:25:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: splash.h,v 1.4 2009/05/12 14:45:43 cegger Exp $ */
+/* $NetBSD: splash.h,v 1.5 2011/02/06 23:25:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2006 Jared D. McNeill <[email protected]>
@@ -41,7 +41,7 @@
 #ifdef SPLASHSCREEN
 
 #define	SPLASH_CMAP_OFFSET	(16 * 3)
-#define	SPLASH_CMAP_SIZE	(64 + 32)
+#define	SPLASH_CMAP_SIZE	64
 
 struct splash_info {
 	int	si_depth;
@@ -52,23 +52,6 @@
 	void	(*si_fillrect)(struct splash_info *, int, int, int, int, int);
 };
 
-#ifdef SPLASHSCREEN_PROGRESS
-struct splash_progress {
-	device_t sp_dev; /* XXX needed for config_finalize */
-	int	sp_top;
-	int	sp_left;
-	int	sp_width;
-	int	sp_height;
-#define	SPLASH_PROGRESS_NSTATES 5
-	int	sp_state;
-	int	sp_running;
-	int	sp_force;
-
-	struct splash_info *	sp_si;
-	struct callout 		sp_callout;
-};
-#endif /* !SPLASHSCREEN_PROGRESS */
-
 #define	SPLASH_F_NONE	0x00	/* Nothing special */
 #define	SPLASH_F_CENTER	0x01	/* Center splash image */
 #define	SPLASH_F_FILL	0x02	/* Fill the rest of the screen with
@@ -76,12 +59,9 @@
 				 * in the splash image
 				 */
 
-void	splash_render(struct splash_info *, int);
-
-#ifdef SPLASHSCREEN_PROGRESS
-void	splash_progress_init(struct splash_progress *);
-void	splash_progress_update(struct splash_progress *);
-#endif /* !SPLASHSCREEN_PROGRESS */
+int	splash_setimage(const void *, size_t);
+int	splash_render(struct splash_info *, int);
+int	splash_get_cmap(int, uint8_t *, uint8_t *, uint8_t *);
 
 #endif /* !SPLASHSCREEN */
 

Index: src/sys/dev/wsfb/genfb.c
diff -u src/sys/dev/wsfb/genfb.c:1.32 src/sys/dev/wsfb/genfb.c:1.33
--- src/sys/dev/wsfb/genfb.c:1.32	Thu Oct  7 07:53:53 2010
+++ src/sys/dev/wsfb/genfb.c	Sun Feb  6 23:25:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfb.c,v 1.32 2010/10/07 07:53:53 macallan Exp $ */
+/*	$NetBSD: genfb.c,v 1.33 2011/02/06 23:25:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.32 2010/10/07 07:53:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.33 2011/02/06 23:25:17 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -192,6 +192,9 @@
 	long defattr;
 	int i, j;
 	bool console;
+#ifdef SPLASHSCREEN
+	int error = ENXIO;
+#endif
 
 	dict = device_properties(sc->sc_dev);
 	prop_dictionary_get_bool(dict, "is_console", &console);
@@ -271,26 +274,23 @@
 		sc->sc_cmap_red[i] = rasops_cmap[j];
 		sc->sc_cmap_green[i] = rasops_cmap[j + 1];
 		sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
-		genfb_putpalreg(sc, i, rasops_cmap[j], rasops_cmap[j + 1],
-		    rasops_cmap[j + 2]);
 		j += 3;
 #else
-		if(i >= SPLASH_CMAP_OFFSET &&
+		if (i >= SPLASH_CMAP_OFFSET &&
 		    i < SPLASH_CMAP_OFFSET + SPLASH_CMAP_SIZE) {
-			sc->sc_cmap_red[i] = _splash_header_data_cmap[j][0];
-			sc->sc_cmap_green[i] = _splash_header_data_cmap[j][1];
-			sc->sc_cmap_blue[i] = _splash_header_data_cmap[j][2];
+			splash_get_cmap(i,
+			    &sc->sc_cmap_red[i],
+			    &sc->sc_cmap_green[i],
+			    &sc->sc_cmap_blue[i]);
 		} else {
 			sc->sc_cmap_red[i] = rasops_cmap[j];
 			sc->sc_cmap_green[i] = rasops_cmap[j + 1];
 			sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
-			genfb_putpalreg(sc, i, rasops_cmap[j],
-				rasops_cmap[j + 1],
-				rasops_cmap[j + 2]);
 		}
 		j += 3;
 #endif
 	}
+	genfb_restore_palette(sc);
 
 #ifdef SPLASHSCREEN
 	sc->sc_splash.si_depth = sc->sc_depth;
@@ -300,17 +300,14 @@
 	sc->sc_splash.si_height = sc->sc_height;
 	sc->sc_splash.si_stride = sc->sc_stride;
 	sc->sc_splash.si_fillrect = NULL;
-	if (!DISABLESPLASH)
-		splash_render(&sc->sc_splash, SPLASH_F_CENTER|SPLASH_F_FILL);
-#ifdef SPLASHSCREEN_PROGRESS
-	sc->sc_progress.sp_top = (sc->sc_height / 8) * 7;
-	sc->sc_progress.sp_width = (sc->sc_width / 4) * 3;
-	sc->sc_progress.sp_left = (sc->sc_width / 8) * 7;
-	sc->sc_progress.sp_height = 20;
-	sc->sc_progress.sp_state = -1;
-	sc->sc_progress.sp_si = &sc->sc_splash;
-	splash_progress_init(&sc->sc_progress);
-#endif
+	if (!DISABLESPLASH) {
+		error = splash_render(&sc->sc_splash,
+		    SPLASH_F_CENTER|SPLASH_F_FILL);
+		if (error) {
+			SCREEN_ENABLE_DRAWING(&sc->sc_console_screen);
+			vcons_replay_msgbuf(&sc->sc_console_screen);
+		}
+	}
 #else
 	vcons_replay_msgbuf(&sc->sc_console_screen);
 #endif
@@ -324,7 +321,7 @@
 	aa.accesscookie = &sc->vd;
 
 #ifdef GENFB_DISABLE_TEXT
-	if (!DISABLESPLASH)
+	if (!DISABLESPLASH && error == 0)
 		SCREEN_DISABLE_DRAWING(&sc->sc_console_screen);
 #endif
 
@@ -392,30 +389,14 @@
 				SCREEN_DISABLE_DRAWING(&sc->sc_console_screen);
 				splash_render(&sc->sc_splash,
 						SPLASH_F_CENTER|SPLASH_F_FILL);
-#if defined(SPLASHSCREEN_PROGRESS)
-				sc->sc_progress.sp_running = 1;
-#endif
 			} else {
 				SCREEN_ENABLE_DRAWING(&sc->sc_console_screen);
-#if defined(SPLASHSCREEN_PROGRESS)
-				sc->sc_progress.sp_running = 0;
-#endif
 			}
 			vcons_redraw_screen(ms);
 			return 0;
 #else
 			return ENODEV;
 #endif
-		case WSDISPLAYIO_SPROGRESS:
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-			sc->sc_progress.sp_force = 1;
-			splash_progress_update(&sc->sc_progress);
-			sc->sc_progress.sp_force = 0;
-			vcons_redraw_screen(ms);
-			return 0;
-#else
-			return ENODEV;
-#endif
 		case WSDISPLAYIO_GETPARAM:
 			param = (struct wsdisplay_param *)data;
 			if (sc->sc_backlight == NULL)

Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.212 src/sys/kern/subr_autoconf.c:1.213
--- src/sys/kern/subr_autoconf.c:1.212	Mon Jan 31 23:07:16 2011
+++ src/sys/kern/subr_autoconf.c	Sun Feb  6 23:25:17 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.212 2011/01/31 23:07:16 dyoung Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.213 2011/02/06 23:25:17 jmcneill Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.212 2011/01/31 23:07:16 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.213 2011/02/06 23:25:17 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -112,14 +112,6 @@
 
 #include <machine/limits.h>
 
-#if defined(__i386__) && defined(_KERNEL_OPT)
-#include "opt_splash.h"
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-#include <dev/splash/splash.h>
-extern struct splash_progress *splash_progress_state;
-#endif
-#endif
-
 /*
  * Autoconfiguration subroutines.
  */
@@ -1048,11 +1040,6 @@
 {
 	cfdata_t cf;
 
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-	if (splash_progress_state)
-		splash_progress_update(splash_progress_state);
-#endif
-
 	if ((cf = config_search_loc(submatch, parent, ifattr, locs, aux)))
 		return(config_attach_loc(parent, cf, locs, aux, print));
 	if (print) {
@@ -1061,11 +1048,6 @@
 		aprint_normal("%s", msgs[(*print)(aux, device_xname(parent))]);
 	}
 
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-	if (splash_progress_state)
-		splash_progress_update(splash_progress_state);
-#endif
-
 	return NULL;
 }
 
@@ -1418,11 +1400,6 @@
 	struct cftable *ct;
 	const char *drvname;
 
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-	if (splash_progress_state)
-		splash_progress_update(splash_progress_state);
-#endif
-
 	dev = config_devalloc(parent, cf, locs);
 	if (!dev)
 		panic("config_attach: allocation of device softc failed");
@@ -1473,15 +1450,7 @@
 	/* Let userland know */
 	devmon_report_device(dev, true);
 
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-	if (splash_progress_state)
-		splash_progress_update(splash_progress_state);
-#endif
 	(*dev->dv_cfattach->ca_attach)(parent, dev, aux);
-#if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_PROGRESS)
-	if (splash_progress_state)
-		splash_progress_update(splash_progress_state);
-#endif
 
 	if (!device_pmf_is_registered(dev))
 		aprint_debug_dev(dev, "WARNING: power management not supported\n");

Reply via email to