socsvn commit: r269390 - soc2014/seiya/bootsplash/sys/dev/fb
seiya at FreeBSD.org
seiya at FreeBSD.org
Wed Jun 11 10:33:40 UTC 2014
Author: seiya
Date: Wed Jun 11 10:33:38 2014
New Revision: 269390
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269390
Log:
support animation
Currenly it supports only BMP image whose size is 1024 pixels wide and vertically long.
Each frame sould be 768 pixels high. Animation loops forever for now.
Modified:
soc2014/seiya/bootsplash/sys/dev/fb/bmp.c
soc2014/seiya/bootsplash/sys/dev/fb/bmp.h
soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c
Modified: soc2014/seiya/bootsplash/sys/dev/fb/bmp.c
==============================================================================
--- soc2014/seiya/bootsplash/sys/dev/fb/bmp.c Wed Jun 11 09:31:09 2014 (r269389)
+++ soc2014/seiya/bootsplash/sys/dev/fb/bmp.c Wed Jun 11 10:33:38 2014 (r269390)
@@ -101,20 +101,19 @@
printf("splash: unsupported compression format\n");
return(1); /* unsupported compression format */
}
-
+
/* palette details */
- bmp_info->ncols = (bmf->bmfi.bmiHeader.biClrUsed);
- bzero(bmp_info->palette,sizeof(bmp_info->palette));
+ bmp_info->ncols = bmf->bmfi.bmiHeader.biClrUsed;
+ bzero(bmp_info->palette, sizeof(bmp_info->palette));
if (bmp_info->ncols == 0) { /* uses all of them */
bmp_info->ncols = 1 << bmf->bmfi.bmiHeader.biBitCount;
}
- if ((bmp_info->height > bmp_info->sheight) ||
- (bmp_info->width > bmp_info->swidth) ||
- (bmp_info->ncols > (1 << sdepth))) {
- if (bootverbose)
- printf("splash: beyond screen capacity (%dx%d, %d colors)\n",
- bmp_info->width, bmp_info->height, bmp_info->ncols);
- return(1);
+
+ if ((bmp_info->width > bmp_info->swidth) || (bmp_info->ncols > (1 << sdepth))) {
+ if (bootverbose)
+ printf("splash: beyond screen capacity (%dx%d, %d colors)\n",
+ bmp_info->width, bmp_info->height, bmp_info->ncols);
+ return(1);
}
/* read palette */
@@ -123,6 +122,7 @@
bmp_info->palette[pind][1] = bmf->bmfi.bmiColors[pind].rgbGreen;
bmp_info->palette[pind][2] = bmf->bmfi.bmiColors[pind].rgbBlue;
}
+
return(0);
}
@@ -136,9 +136,10 @@
*/
int
bmp_draw(video_adapter_t *adp, BMP_INFO *bmp_info, int sx, int sy, int iy,
- int height, int width)
+ int width, int height)
{
int i;
+ static int cleared;
if (bmp_info->data == NULL) { /* init failed, do nothing */
return(1);
@@ -147,7 +148,12 @@
/* clear the screen */
bmp_info->vidmem = (u_char *)adp->va_window;
bmp_info->adp = adp;
- vidd_clear(adp);
+
+ if(!cleared){
+ vidd_clear(adp);
+ cleared = 1;
+ }
+
vidd_set_win_org(adp, 0);
bmp_info->bank = 0;
Modified: soc2014/seiya/bootsplash/sys/dev/fb/bmp.h
==============================================================================
--- soc2014/seiya/bootsplash/sys/dev/fb/bmp.h Wed Jun 11 09:31:09 2014 (r269389)
+++ soc2014/seiya/bootsplash/sys/dev/fb/bmp.h Wed Jun 11 10:33:38 2014 (r269390)
@@ -100,6 +100,6 @@
int bmp_init(BMP_INFO *bmp_info, char *data, int swidth, int sheight, int sdepth);
int bmp_draw(video_adapter_t *adp, BMP_INFO *bmp_info, int vx, int vy, int iy,
- int height, int width);
+ int width, int height);
#endif /* _FB_BMP_H_ */
Modified: soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c
==============================================================================
--- soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Wed Jun 11 09:31:09 2014 (r269389)
+++ soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Wed Jun 11 10:33:38 2014 (r269390)
@@ -46,7 +46,7 @@
static int draw_bmp(video_adapter_t *adp, BMP_INFO *bmp_info, int y, int height, int width);
static video_adapter_t *adp;
-
+BMP_INFO bmp_info;
int
bsplash_early_init(video_adapter_t *_adp)
@@ -61,21 +61,31 @@
{
caddr_t image = NULL;
void *p;
- BMP_INFO bmp_info;
// get a pointer to the first image
image = preload_search_by_type("bsplash_image");
- if (image == NULL)
+
+ if (image == NULL){
+ printf("bsplash: failed to load BMP\n");
return 1;
+ }
+
p = preload_fetch_addr(image);
- if (load_bmp(adp, &bmp_info, p) != 0)
+ if (load_bmp(adp, &bmp_info, p) != 0){
printf("bsplash: failed to load BMP\n");
+ return 1;
+ }
- timeout(update_animation, NULL, 15);
+ if (vidd_set_mode(adp, M_VESA_CG1024x768) != 0)
+ return 1;
- if (draw_bmp(adp, &bmp_info, 0, -1, -1) != 0)
+ if (draw_bmp(adp, &bmp_info, 0, 1024, 768) != 0){
printf("bsplash: failed to draw BMP\n");
+ return 1;
+ }
+
+ timeout(update_animation, NULL, 1);
return 0;
}
@@ -84,8 +94,16 @@
static void
update_animation(void *unused)
{
- /* TODO */
- timeout(update_animation, NULL, 15);
+ static int y = 0;
+
+ if (draw_bmp(adp, &bmp_info, y, 1024, 768) == 0){
+ y += 768;
+ }else{
+ y = 0;
+ draw_bmp(adp, &bmp_info, y, 1024, 768); /* try again */
+ }
+
+ timeout(update_animation, NULL, 1);
}
@@ -106,13 +124,10 @@
static int
-draw_bmp(video_adapter_t *adp, BMP_INFO *bmp_info, int y, int height, int width)
+draw_bmp(video_adapter_t *adp, BMP_INFO *bmp_info, int y, int width, int height)
{
- if (vidd_set_mode(adp, M_VESA_CG1024x768) != 0)
- return 1;
-
- if (bmp_draw(adp, bmp_info, 0, 0, y, height, width))
+ if (bmp_draw(adp, bmp_info, 0, 0, y, width, height))
return 1;
return 0;
More information about the svn-soc-all
mailing list