From: Jacob Potter Date: Sat, 13 Dec 2008 22:10:02 +0000 (-0500) Subject: add checksumrect utilities X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/0a9d0188bd22fed7eb3606d307e9dfd10c3357cf?ds=sidebyside add checksumrect utilities --- diff --git a/aseg-paging/Makefile b/aseg-paging/Makefile index ae63244..73d7feb 100644 --- a/aseg-paging/Makefile +++ b/aseg-paging/Makefile @@ -46,6 +46,7 @@ OBJS = ../ich2/smi.o \ ../net/rfb.o \ ../video/tnt2.o \ ../video/fb.o \ + ../video/checksumrect.o \ drivers.o \ ../lib/minilib.o \ ../lib/doprnt.o \ diff --git a/include/fb.h b/include/fb.h index 9ade9e7..19dae0b 100644 --- a/include/fb.h +++ b/include/fb.h @@ -1,6 +1,8 @@ #ifndef __FB_H #define __FB_H +#include + struct fbdevice; struct vmode; @@ -9,6 +11,7 @@ typedef enum { } format_t; typedef void (*getvmode_t)(void *); +typedef uint32_t (*checksum_rect_t)(int x, int y, int width, int height); struct vmode { int text:1; @@ -20,6 +23,7 @@ struct fbdevice { unsigned char *fbaddr; void *priv; getvmode_t getvmode; + checksum_rect_t checksum_rect; struct vmode curmode; }; diff --git a/video/checksumrect.c b/video/checksumrect.c new file mode 100644 index 0000000..f96c033 --- /dev/null +++ b/video/checksumrect.c @@ -0,0 +1,26 @@ +#include +#include + +uint32_t checksum_rect_generic32(int x, int y, int width, int height) { + + /* Generic checksum_rect function for video modes with 32-bit pixels + * (i.e. fb->curmode.bytestride = 4). + */ + + int scanline = fb->curmode.xres * 4; + uint32_t * lineaddr; + int i, j; + + uint32_t sum = 0; + + for (i = 0; i < height; i++) { + lineaddr = (uint32_t *)(fb->fbaddr + (i + y) * scanline); + + for (j = 0; j < width; j++) { + sum += lineaddr[j + x]; + } + } + + return sum; +} + diff --git a/video/checksumrect.h b/video/checksumrect.h new file mode 100644 index 0000000..8dd2a6d --- /dev/null +++ b/video/checksumrect.h @@ -0,0 +1,6 @@ +#ifndef _CHECKSUM_RECT_C +#define _CHECKSUM_RECT_H + +uint32_t checksum_rect_generic32(int x, int y, int width, int height); + +#endif diff --git a/video/tnt2.c b/video/tnt2.c index 32e646a..c04b067 100644 --- a/video/tnt2.c +++ b/video/tnt2.c @@ -5,6 +5,8 @@ #include #include +#include "checksumrect.h" + static void tnt2_getvmode(void *priv); static struct fbdevice tnt2_fb = { @@ -27,6 +29,7 @@ static void tnt2_getvmode(void *priv) tnt2_fb.curmode.format = FB_RGB888; tnt2_fb.curmode.bytestride = 4; tnt2_fb.curmode.text = 0; + tnt2_fb.checksum_rect = checksum_rect_generic32; break; case 0: tnt2_fb.curmode.text = 1;