Home | History | Annotate | Line # | Download | only in splash
splash.c revision 1.8.6.2
      1  1.8.6.2    bouyer /* $NetBSD: splash.c,v 1.8.6.2 2011/02/17 12:00:16 bouyer Exp $ */
      2      1.1  jmcneill 
      3      1.1  jmcneill /*-
      4      1.1  jmcneill  * Copyright (c) 2006 Jared D. McNeill <jmcneill (at) invisible.ca>
      5      1.1  jmcneill  * All rights reserved.
      6      1.1  jmcneill  *
      7      1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      8      1.1  jmcneill  * modification, are permitted provided that the following conditions
      9      1.1  jmcneill  * are met:
     10      1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     11      1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     12      1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15      1.6    martin  * 3. All advertising materials mentioning features or use of this software
     16      1.6    martin  *    must display the following acknowledgement:
     17      1.6    martin  *        This product includes software developed by the NetBSD
     18      1.6    martin  *        Foundation, Inc. and its contributors.
     19      1.6    martin  * 4. Neither the name of The NetBSD Foundation nor the names of its
     20      1.6    martin  *    contributors may be used to endorse or promote products derived
     21      1.6    martin  *    from this software without specific prior written permission.
     22      1.1  jmcneill  *
     23      1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24      1.1  jmcneill  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25      1.1  jmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26      1.1  jmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27      1.1  jmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28      1.1  jmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29      1.1  jmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30      1.1  jmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31      1.1  jmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32      1.1  jmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33      1.1  jmcneill  * POSSIBILITY OF SUCH DAMAGE.
     34      1.1  jmcneill  */
     35      1.1  jmcneill 
     36      1.1  jmcneill #include <sys/cdefs.h>
     37  1.8.6.2    bouyer __KERNEL_RCSID(0, "$NetBSD: splash.c,v 1.8.6.2 2011/02/17 12:00:16 bouyer Exp $");
     38      1.1  jmcneill 
     39      1.1  jmcneill #include "opt_splash.h"
     40      1.1  jmcneill 
     41      1.1  jmcneill /* XXX */
     42  1.8.6.1    bouyer #define NSPLASH8  1
     43      1.1  jmcneill #define	NSPLASH16 1
     44      1.1  jmcneill #define	NSPLASH32 1
     45      1.1  jmcneill 
     46      1.1  jmcneill #include <sys/param.h>
     47      1.8     ahoka #include <sys/device.h>
     48      1.1  jmcneill #include <sys/systm.h>
     49      1.1  jmcneill #include <sys/types.h>
     50      1.1  jmcneill #include <sys/kernel.h>
     51      1.1  jmcneill #include <sys/kthread.h>
     52      1.1  jmcneill 
     53      1.1  jmcneill #include <dev/splash/splash.h>
     54  1.8.6.1    bouyer #include <dev/stbi/stbi.h>
     55      1.1  jmcneill 
     56      1.1  jmcneill #ifdef SPLASHSCREEN
     57      1.1  jmcneill 
     58  1.8.6.1    bouyer static struct {
     59  1.8.6.1    bouyer 	const u_char	*data;
     60  1.8.6.1    bouyer 	size_t		datalen;
     61  1.8.6.1    bouyer } splash_image = { NULL, 0 };
     62  1.8.6.1    bouyer 
     63  1.8.6.1    bouyer #define SPLASH_INDEX(r, g, b)						\
     64  1.8.6.1    bouyer 	((((r) >> 6) << 4) | (((g) >> 6) << 2) | (((b) >> 6) << 0))
     65  1.8.6.1    bouyer 
     66  1.8.6.1    bouyer static uint8_t splash_palette[SPLASH_CMAP_SIZE][3] = {
     67  1.8.6.1    bouyer 	{ 0x00, 0x00, 0x00 },
     68  1.8.6.1    bouyer 	{ 0x00, 0x00, 0x55 },
     69  1.8.6.1    bouyer 	{ 0x00, 0x00, 0xaa },
     70  1.8.6.1    bouyer 	{ 0x00, 0x00, 0xff },
     71  1.8.6.1    bouyer 	{ 0x00, 0x55, 0x00 },
     72  1.8.6.1    bouyer 	{ 0x00, 0x55, 0x55 },
     73  1.8.6.1    bouyer 	{ 0x00, 0x55, 0xaa },
     74  1.8.6.1    bouyer 	{ 0x00, 0x55, 0xff },
     75  1.8.6.1    bouyer 	{ 0x00, 0xaa, 0x00 },
     76  1.8.6.1    bouyer 	{ 0x00, 0xaa, 0x55 },
     77  1.8.6.1    bouyer 	{ 0x00, 0xaa, 0xaa },
     78  1.8.6.1    bouyer 	{ 0x00, 0xaa, 0xff },
     79  1.8.6.1    bouyer 	{ 0x00, 0xff, 0x00 },
     80  1.8.6.1    bouyer 	{ 0x00, 0xff, 0x55 },
     81  1.8.6.1    bouyer 	{ 0x00, 0xff, 0xaa },
     82  1.8.6.1    bouyer 	{ 0x00, 0xff, 0xff },
     83  1.8.6.1    bouyer 	{ 0x55, 0x00, 0x00 },
     84  1.8.6.1    bouyer 	{ 0x55, 0x00, 0x55 },
     85  1.8.6.1    bouyer 	{ 0x55, 0x00, 0xaa },
     86  1.8.6.1    bouyer 	{ 0x55, 0x00, 0xff },
     87  1.8.6.1    bouyer 	{ 0x55, 0x55, 0x00 },
     88  1.8.6.1    bouyer 	{ 0x55, 0x55, 0x55 },
     89  1.8.6.1    bouyer 	{ 0x55, 0x55, 0xaa },
     90  1.8.6.1    bouyer 	{ 0x55, 0x55, 0xff },
     91  1.8.6.1    bouyer 	{ 0x55, 0xaa, 0x00 },
     92  1.8.6.1    bouyer 	{ 0x55, 0xaa, 0x55 },
     93  1.8.6.1    bouyer 	{ 0x55, 0xaa, 0xaa },
     94  1.8.6.1    bouyer 	{ 0x55, 0xaa, 0xff },
     95  1.8.6.1    bouyer 	{ 0x55, 0xff, 0x00 },
     96  1.8.6.1    bouyer 	{ 0x55, 0xff, 0x55 },
     97  1.8.6.1    bouyer 	{ 0x55, 0xff, 0xaa },
     98  1.8.6.1    bouyer 	{ 0x55, 0xff, 0xff },
     99  1.8.6.1    bouyer 	{ 0xaa, 0x00, 0x00 },
    100  1.8.6.1    bouyer 	{ 0xaa, 0x00, 0x55 },
    101  1.8.6.1    bouyer 	{ 0xaa, 0x00, 0xaa },
    102  1.8.6.1    bouyer 	{ 0xaa, 0x00, 0xff },
    103  1.8.6.1    bouyer 	{ 0xaa, 0x55, 0x00 },
    104  1.8.6.1    bouyer 	{ 0xaa, 0x55, 0x55 },
    105  1.8.6.1    bouyer 	{ 0xaa, 0x55, 0xaa },
    106  1.8.6.1    bouyer 	{ 0xaa, 0x55, 0xff },
    107  1.8.6.1    bouyer 	{ 0xaa, 0xaa, 0x00 },
    108  1.8.6.1    bouyer 	{ 0xaa, 0xaa, 0x55 },
    109  1.8.6.1    bouyer 	{ 0xaa, 0xaa, 0xaa },
    110  1.8.6.1    bouyer 	{ 0xaa, 0xaa, 0xff },
    111  1.8.6.1    bouyer 	{ 0xaa, 0xff, 0x00 },
    112  1.8.6.1    bouyer 	{ 0xaa, 0xff, 0x55 },
    113  1.8.6.1    bouyer 	{ 0xaa, 0xff, 0xaa },
    114  1.8.6.1    bouyer 	{ 0xaa, 0xff, 0xff },
    115  1.8.6.1    bouyer 	{ 0xff, 0x00, 0x00 },
    116  1.8.6.1    bouyer 	{ 0xff, 0x00, 0x55 },
    117  1.8.6.1    bouyer 	{ 0xff, 0x00, 0xaa },
    118  1.8.6.1    bouyer 	{ 0xff, 0x00, 0xff },
    119  1.8.6.1    bouyer 	{ 0xff, 0x55, 0x00 },
    120  1.8.6.1    bouyer 	{ 0xff, 0x55, 0x55 },
    121  1.8.6.1    bouyer 	{ 0xff, 0x55, 0xaa },
    122  1.8.6.1    bouyer 	{ 0xff, 0x55, 0xff },
    123  1.8.6.1    bouyer 	{ 0xff, 0xaa, 0x00 },
    124  1.8.6.1    bouyer 	{ 0xff, 0xaa, 0x55 },
    125  1.8.6.1    bouyer 	{ 0xff, 0xaa, 0xaa },
    126  1.8.6.1    bouyer 	{ 0xff, 0xaa, 0xff },
    127  1.8.6.1    bouyer 	{ 0xff, 0xff, 0x00 },
    128  1.8.6.1    bouyer 	{ 0xff, 0xff, 0x55 },
    129  1.8.6.1    bouyer 	{ 0xff, 0xff, 0xaa },
    130  1.8.6.1    bouyer 	{ 0xff, 0xff, 0xff },
    131  1.8.6.1    bouyer };
    132      1.1  jmcneill 
    133      1.1  jmcneill #if NSPLASH8 > 0
    134      1.1  jmcneill static void	splash_render8(struct splash_info *, const char *, int,
    135      1.1  jmcneill 			       int, int, int, int);
    136      1.1  jmcneill #endif
    137      1.1  jmcneill #if NSPLASH16 > 0
    138      1.1  jmcneill static void	splash_render16(struct splash_info *, const char *, int,
    139      1.1  jmcneill 				int, int, int, int);
    140      1.1  jmcneill #endif
    141      1.1  jmcneill #if NSPLASH32 > 0
    142      1.1  jmcneill static void	splash_render32(struct splash_info *, const char *, int,
    143      1.1  jmcneill 				int, int, int, int);
    144      1.1  jmcneill #endif
    145      1.1  jmcneill 
    146  1.8.6.1    bouyer int
    147  1.8.6.1    bouyer splash_setimage(const void *imgdata, size_t imgdatalen)
    148  1.8.6.1    bouyer {
    149  1.8.6.1    bouyer 	if (splash_image.data != NULL) {
    150  1.8.6.1    bouyer 		aprint_debug("WARNING: %s: already initialized\n", __func__);
    151  1.8.6.1    bouyer 		return EBUSY;
    152  1.8.6.1    bouyer 	}
    153  1.8.6.1    bouyer 
    154  1.8.6.2    bouyer 	aprint_verbose("%s: splash image @ %p, %zu bytes\n",
    155  1.8.6.1    bouyer 	    __func__, imgdata, imgdatalen);
    156  1.8.6.1    bouyer 	splash_image.data = imgdata;
    157  1.8.6.1    bouyer 	splash_image.datalen = imgdatalen;
    158  1.8.6.1    bouyer 
    159  1.8.6.1    bouyer 	return 0;
    160  1.8.6.1    bouyer }
    161  1.8.6.1    bouyer 
    162  1.8.6.1    bouyer int
    163  1.8.6.1    bouyer splash_get_cmap(int index, uint8_t *r, uint8_t *g, uint8_t *b)
    164  1.8.6.1    bouyer {
    165  1.8.6.1    bouyer 	if (index < SPLASH_CMAP_OFFSET ||
    166  1.8.6.1    bouyer 	    index >= SPLASH_CMAP_OFFSET + SPLASH_CMAP_SIZE)
    167  1.8.6.1    bouyer 		return ERANGE;
    168  1.8.6.1    bouyer 
    169  1.8.6.1    bouyer 	*r = splash_palette[index - SPLASH_CMAP_OFFSET][0];
    170  1.8.6.1    bouyer 	*g = splash_palette[index - SPLASH_CMAP_OFFSET][1];
    171  1.8.6.1    bouyer 	*b = splash_palette[index - SPLASH_CMAP_OFFSET][2];
    172  1.8.6.1    bouyer 
    173  1.8.6.1    bouyer 	return 0;
    174  1.8.6.1    bouyer }
    175  1.8.6.1    bouyer 
    176  1.8.6.1    bouyer int
    177      1.1  jmcneill splash_render(struct splash_info *si, int flg)
    178      1.1  jmcneill {
    179  1.8.6.1    bouyer 	char *data = NULL;
    180  1.8.6.1    bouyer 	int xoff, yoff, width, height, comp;
    181  1.8.6.1    bouyer 	int error = 0;
    182  1.8.6.1    bouyer 
    183  1.8.6.1    bouyer 	if (splash_image.data == NULL) {
    184  1.8.6.1    bouyer 		aprint_error("WARNING: %s: not initialized\n", __func__);
    185  1.8.6.1    bouyer 		return ENXIO;
    186  1.8.6.1    bouyer 	}
    187  1.8.6.1    bouyer 
    188  1.8.6.1    bouyer 	data = stbi_load_from_memory(splash_image.data,
    189  1.8.6.1    bouyer 	    splash_image.datalen, &width, &height, &comp, STBI_rgb);
    190  1.8.6.1    bouyer 	if (data == NULL) {
    191  1.8.6.1    bouyer 		aprint_error("WARNING: couldn't load splash image: %s\n",
    192  1.8.6.1    bouyer 		    stbi_failure_reason());
    193  1.8.6.1    bouyer 		return EINVAL;
    194  1.8.6.1    bouyer 	}
    195  1.8.6.1    bouyer 	aprint_debug("%s: splash loaded, width %d height %d comp %d\n",
    196  1.8.6.1    bouyer 	    __func__, width, height, comp);
    197      1.1  jmcneill 
    198      1.1  jmcneill 	/* XXX */
    199      1.1  jmcneill 	if (flg & SPLASH_F_CENTER) {
    200  1.8.6.1    bouyer 		xoff = (si->si_width - width) / 2;
    201  1.8.6.1    bouyer 		yoff = (si->si_height - height) / 2;
    202      1.1  jmcneill 	} else
    203      1.1  jmcneill 		xoff = yoff = 0;
    204      1.1  jmcneill 
    205      1.1  jmcneill 	switch (si->si_depth) {
    206      1.1  jmcneill #if NSPLASH8 > 0
    207      1.1  jmcneill 	case 8:
    208  1.8.6.1    bouyer 		splash_render8(si, data, xoff, yoff, width, height, flg);
    209      1.1  jmcneill 		break;
    210      1.1  jmcneill #endif
    211      1.1  jmcneill #if NSPLASH16 > 0
    212      1.1  jmcneill 	case 16:
    213  1.8.6.1    bouyer 		splash_render16(si, data, xoff, yoff, width, height, flg);
    214      1.1  jmcneill 		break;
    215      1.1  jmcneill #endif
    216      1.1  jmcneill #if NSPLASH32 > 0
    217      1.1  jmcneill 	case 32:
    218  1.8.6.1    bouyer 		splash_render32(si, data, xoff, yoff, width, height, flg);
    219      1.1  jmcneill 		break;
    220      1.1  jmcneill #endif
    221      1.1  jmcneill 	default:
    222      1.1  jmcneill 		aprint_error("WARNING: Splash not supported at %dbpp\n",
    223      1.1  jmcneill 		    si->si_depth);
    224  1.8.6.1    bouyer 		error = EINVAL;
    225      1.1  jmcneill 	}
    226      1.1  jmcneill 
    227  1.8.6.1    bouyer 	if (data)
    228  1.8.6.1    bouyer 		stbi_image_free(data);
    229  1.8.6.1    bouyer 
    230  1.8.6.1    bouyer 	return error;
    231      1.1  jmcneill }
    232      1.1  jmcneill 
    233      1.1  jmcneill #if NSPLASH8 > 0
    234  1.8.6.1    bouyer 
    235      1.1  jmcneill static void
    236      1.1  jmcneill splash_render8(struct splash_info *si, const char *data, int xoff, int yoff,
    237      1.1  jmcneill 	       int swidth, int sheight, int flg)
    238      1.1  jmcneill {
    239  1.8.6.1    bouyer 	const char *d;
    240  1.8.6.1    bouyer 	u_char *fb, *p;
    241  1.8.6.1    bouyer 	u_char pix[3];
    242      1.1  jmcneill 	int x, y, i;
    243      1.1  jmcneill 	int filled;
    244      1.1  jmcneill 
    245      1.1  jmcneill 	fb = si->si_bits;
    246  1.8.6.1    bouyer 
    247      1.1  jmcneill 	if (flg & SPLASH_F_FILL)
    248      1.1  jmcneill 		filled = 0;
    249      1.1  jmcneill 	else
    250      1.1  jmcneill 		filled = 1;
    251      1.1  jmcneill 
    252  1.8.6.1    bouyer 	d = data;
    253  1.8.6.1    bouyer 	fb += xoff + yoff * si->si_stride;
    254  1.8.6.1    bouyer 
    255      1.1  jmcneill 	for (y = 0; y < sheight; y++) {
    256      1.1  jmcneill 		for (x = 0; x < swidth; x++) {
    257  1.8.6.1    bouyer 			pix[0] = *d++;
    258  1.8.6.1    bouyer 			pix[1] = *d++;
    259  1.8.6.1    bouyer 			pix[2] = *d++;
    260      1.1  jmcneill 			if (filled == 0) {
    261  1.8.6.1    bouyer 				p = si->si_bits;
    262  1.8.6.1    bouyer 				i = 0;
    263  1.8.6.1    bouyer 				while (i < si->si_height*si->si_stride) {
    264  1.8.6.1    bouyer 					p[i] = SPLASH_INDEX(
    265  1.8.6.1    bouyer 					    pix[0], pix[1], pix[2]) +
    266  1.8.6.1    bouyer 					    SPLASH_CMAP_OFFSET;
    267  1.8.6.1    bouyer 					i++;
    268  1.8.6.1    bouyer 				}
    269      1.1  jmcneill 				filled = 1;
    270      1.1  jmcneill 			}
    271  1.8.6.1    bouyer 			fb[x] = SPLASH_INDEX(pix[0], pix[1], pix[2]) +
    272  1.8.6.1    bouyer 				    SPLASH_CMAP_OFFSET;
    273      1.1  jmcneill 		}
    274      1.1  jmcneill 		fb += si->si_width;
    275      1.1  jmcneill 	}
    276      1.1  jmcneill 
    277      1.1  jmcneill 	/* If we've just written to the shadow fb, copy it to the display */
    278      1.1  jmcneill 	if (si->si_hwbits) {
    279      1.1  jmcneill 		if (flg & SPLASH_F_FILL) {
    280      1.1  jmcneill 			memcpy(si->si_hwbits, si->si_bits,
    281  1.8.6.1    bouyer 			    si->si_height*si->si_width);
    282      1.1  jmcneill 		} else {
    283      1.1  jmcneill 			u_char *rp, *hrp;
    284      1.1  jmcneill 
    285      1.1  jmcneill 			rp = si->si_bits + xoff + (yoff * si->si_width);
    286      1.1  jmcneill 			hrp = si->si_hwbits + xoff + (yoff * si->si_width);
    287      1.1  jmcneill 
    288      1.1  jmcneill 			for (y = 0; y < sheight; y++) {
    289      1.1  jmcneill 				memcpy(hrp, rp, swidth);
    290      1.1  jmcneill 				rp += si->si_stride;
    291  1.8.6.1    bouyer 				hrp += si->si_stride;
    292      1.1  jmcneill 			}
    293      1.1  jmcneill 		}
    294      1.1  jmcneill 	}
    295      1.1  jmcneill 
    296      1.1  jmcneill 	return;
    297      1.1  jmcneill }
    298      1.1  jmcneill #endif /* !NSPLASH8 > 0 */
    299      1.1  jmcneill 
    300      1.1  jmcneill #if NSPLASH16 > 0
    301      1.1  jmcneill #define RGBTO16(b, o, x, c)					\
    302      1.1  jmcneill 	do {							\
    303      1.1  jmcneill 		uint16_t *_ptr = (uint16_t *)(&(b)[(o)]);	\
    304      1.1  jmcneill 		*_ptr = (((c)[(x)*3+0] / 8) << 11) |		\
    305      1.1  jmcneill 			(((c)[(x)*3+1] / 4) << 5) |		\
    306      1.1  jmcneill 			(((c)[(x)*3+2] / 8) << 0);		\
    307      1.1  jmcneill 	} while (0)
    308      1.1  jmcneill 
    309      1.1  jmcneill static void
    310      1.1  jmcneill splash_render16(struct splash_info *si, const char *data, int xoff, int yoff,
    311      1.1  jmcneill 		int swidth, int sheight, int flg)
    312      1.1  jmcneill {
    313      1.1  jmcneill 	const char *d;
    314      1.1  jmcneill 	u_char *fb, *p;
    315      1.1  jmcneill 	u_char pix[3];
    316      1.1  jmcneill 	int x, y, i;
    317      1.1  jmcneill 	int filled;
    318      1.1  jmcneill 
    319      1.1  jmcneill 	fb = si->si_bits;
    320      1.1  jmcneill 
    321      1.1  jmcneill 	if (flg & SPLASH_F_FILL)
    322      1.1  jmcneill 		filled = 0;
    323      1.1  jmcneill 	else
    324      1.1  jmcneill 		filled = 1;
    325      1.1  jmcneill 
    326      1.1  jmcneill 	d = data;
    327      1.1  jmcneill 	fb += xoff * 2 + yoff * si->si_stride;
    328      1.1  jmcneill 
    329      1.1  jmcneill 	for (y = 0; y < sheight; y++) {
    330      1.1  jmcneill 		for (x = 0; x < swidth; x++) {
    331  1.8.6.1    bouyer 			pix[0] = *d++;
    332  1.8.6.1    bouyer 			pix[1] = *d++;
    333  1.8.6.1    bouyer 			pix[2] = *d++;
    334      1.1  jmcneill 			if (filled == 0) {
    335      1.1  jmcneill 				p = si->si_bits;
    336      1.1  jmcneill 				i = 0;
    337      1.1  jmcneill 				while (i < si->si_height*si->si_stride) {
    338      1.1  jmcneill 					RGBTO16(p, i, 0, pix);
    339      1.1  jmcneill 					i += 2;
    340      1.1  jmcneill 				}
    341      1.1  jmcneill 				filled = 1;
    342      1.1  jmcneill 			}
    343      1.1  jmcneill 			RGBTO16(fb, x*2, 0, pix);
    344      1.1  jmcneill 		}
    345      1.1  jmcneill 		fb += si->si_stride;
    346      1.1  jmcneill 	}
    347      1.1  jmcneill 
    348      1.1  jmcneill 	/* If we've just written to the shadow fb, copy it to the display */
    349      1.1  jmcneill 	if (si->si_hwbits) {
    350      1.1  jmcneill 		if (flg & SPLASH_F_FILL) {
    351      1.1  jmcneill 			memcpy(si->si_hwbits, si->si_bits,
    352      1.1  jmcneill 			    si->si_height*si->si_stride);
    353      1.1  jmcneill 		} else {
    354      1.1  jmcneill 			u_char *rp, *hrp;
    355      1.1  jmcneill 
    356      1.1  jmcneill 			rp = si->si_bits + (xoff * 2) + (yoff * si->si_stride);
    357      1.1  jmcneill 			hrp = si->si_hwbits + (xoff * 2) +
    358      1.1  jmcneill 			    (yoff * si->si_stride);
    359      1.1  jmcneill 
    360      1.1  jmcneill 			for (y = 0; y < sheight; y++) {
    361      1.1  jmcneill 				memcpy(hrp, rp, swidth * 2);
    362      1.1  jmcneill 				rp += si->si_stride;
    363      1.1  jmcneill 				hrp += si->si_stride;
    364      1.1  jmcneill 			}
    365      1.1  jmcneill 		}
    366      1.1  jmcneill 	}
    367      1.1  jmcneill 
    368      1.1  jmcneill 	return;
    369      1.1  jmcneill }
    370      1.1  jmcneill #undef RGBTO16
    371      1.1  jmcneill #endif /* !NSPLASH16 > 0 */
    372      1.1  jmcneill 
    373      1.1  jmcneill #if NSPLASH32 > 0
    374      1.1  jmcneill static void
    375      1.1  jmcneill splash_render32(struct splash_info *si, const char *data, int xoff, int yoff,
    376      1.1  jmcneill 		int swidth, int sheight, int flg)
    377      1.1  jmcneill {
    378      1.1  jmcneill 	const char *d;
    379      1.1  jmcneill 	u_char *fb, *p;
    380      1.1  jmcneill 	u_char pix[3];
    381      1.1  jmcneill 	int x, y, i;
    382      1.1  jmcneill 	int filled;
    383      1.1  jmcneill 
    384      1.1  jmcneill 	fb = si->si_bits;
    385      1.1  jmcneill 
    386      1.1  jmcneill 	if (flg & SPLASH_F_FILL)
    387      1.1  jmcneill 		filled = 0;
    388      1.1  jmcneill 	else
    389      1.1  jmcneill 		filled = 1;
    390      1.1  jmcneill 
    391      1.1  jmcneill 	d = data;
    392      1.1  jmcneill 	fb += xoff * 4 + yoff * si->si_stride;
    393      1.1  jmcneill 
    394      1.1  jmcneill 	for (y = 0; y < sheight; y++) {
    395      1.1  jmcneill 		for (x = 0; x < swidth; x++) {
    396  1.8.6.1    bouyer 			pix[0] = *d++;
    397  1.8.6.1    bouyer 			pix[1] = *d++;
    398  1.8.6.1    bouyer 			pix[2] = *d++;
    399      1.1  jmcneill 			if (filled == 0) {
    400      1.1  jmcneill 				p = si->si_bits;
    401      1.1  jmcneill 				i = 0;
    402      1.1  jmcneill 				while (i < si->si_height*si->si_stride) {
    403      1.1  jmcneill 					p[i++] = pix[2];
    404      1.1  jmcneill 					p[i++] = pix[1];
    405      1.1  jmcneill 					p[i++] = pix[0];
    406      1.1  jmcneill 					p[i++] = 0;
    407      1.1  jmcneill 				}
    408      1.1  jmcneill 				filled = 1;
    409      1.1  jmcneill 			}
    410      1.1  jmcneill 			fb[x*4+0] = pix[2];
    411      1.1  jmcneill 			fb[x*4+1] = pix[1];
    412      1.1  jmcneill 			fb[x*4+2] = pix[0];
    413      1.1  jmcneill 			fb[x*4+3] = 0;
    414      1.1  jmcneill 		}
    415      1.1  jmcneill 		fb += si->si_stride;
    416      1.1  jmcneill 	}
    417      1.1  jmcneill 
    418      1.1  jmcneill 	/* If we've just written to the shadow fb, copy it to the display */
    419      1.1  jmcneill 	if (si->si_hwbits) {
    420      1.1  jmcneill 		if (flg & SPLASH_F_FILL) {
    421      1.1  jmcneill 			memcpy(si->si_hwbits, si->si_bits,
    422      1.1  jmcneill 			    si->si_height*si->si_stride);
    423      1.1  jmcneill 		} else {
    424      1.1  jmcneill 			u_char *rp, *hrp;
    425      1.1  jmcneill 
    426      1.1  jmcneill 			rp = si->si_bits + (xoff * 4) + (yoff * si->si_stride);
    427      1.1  jmcneill 			hrp = si->si_hwbits + (xoff * 4) +
    428      1.1  jmcneill 			    (yoff * si->si_stride);
    429      1.1  jmcneill 
    430      1.1  jmcneill 			for (y = 0; y < sheight; y++) {
    431      1.1  jmcneill 				memcpy(hrp, rp, swidth * 4);
    432      1.1  jmcneill 				rp += si->si_stride;
    433      1.1  jmcneill 				hrp += si->si_stride;
    434      1.1  jmcneill 			}
    435      1.1  jmcneill 		}
    436      1.1  jmcneill 	}
    437      1.1  jmcneill 
    438      1.1  jmcneill 	return;
    439      1.1  jmcneill }
    440      1.1  jmcneill #endif /* !NSPLASH32 > 0 */
    441      1.1  jmcneill 
    442      1.1  jmcneill #endif /* !SPLASHSCREEN */
    443