]> Joshua Wise's Git repositories - netwatch.git/blobdiff - hardware/video/generic.c
More churn moving files around.
[netwatch.git] / hardware / video / generic.c
diff --git a/hardware/video/generic.c b/hardware/video/generic.c
new file mode 100644 (file)
index 0000000..c35cd5d
--- /dev/null
@@ -0,0 +1,48 @@
+/* generic.c
+ * Helper functions for dealing with generic RGB888 framebuffers
+ * NetWatch system management mode administration console
+ *
+ * Copyright (c) 2008 Jacob Potter and Joshua Wise.  All rights reserved.
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms found in the file LICENSE in the root of this source tree.
+ *
+ */
+
+#include <stdint.h>
+#include <fb.h>
+#include <crc32.h>
+
+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;
+        unsigned char * lineaddr;
+        int i;
+
+        uint32_t sum = 0;
+
+        for (i = 0; i < height; i++) {
+                lineaddr = fb->fbaddr + (i + y) * scanline + (4 * x);
+
+                sum = crc32(lineaddr, width * 4, sum);
+        }
+
+        return sum;
+}
+
+void copy_pixels_generic32(char *buf, int x, int y, int width, int height)
+{
+       int cx, cy;
+       unsigned int *ibuf = (unsigned int *)buf;
+       unsigned int *fbuf;
+       for (cy = 0; cy < height; cy++)
+       {
+               fbuf = (unsigned int *)fb->fbaddr;
+               fbuf += (cy + y) * (fb->curmode.xres) + x;
+               for (cx = 0; cx < width; cx++)
+                       *(ibuf++) = *(fbuf++);
+       }
+}
This page took 0.024065 seconds and 4 git commands to generate.