well.. that's better than "Level 0"
I did (of course) have a quick look at the code...
The good news? there isn't much of it.
The bad news? IIRC the framebuffer is a tiny bit different on the 4... and it's in c... and the FB is one of the things I never got my head around yet....
but assuming it works like I THINK it works... it's a collection of of lines of X (width * the bit size) * Y height. That sound right?
And I also suck so badly at c it's not funny...
The code is below.
Happy to hack on it with you. Others may jump in.
the actual compilation is the easy part.
TCC or simply a
premade Toolchain can both do the job. (
2007q3 is not a bad choice if you want that option or you could try the
2012.03 also)
So.... Here's the code.
Spoiler:
PHP Code:
// scroll.c - simple framebuffer scroller for kindle with (partially)
// broken eink display
//
// usage:
// scroll [percent] [type]
//
// percent: optional percent of display height to scroll (0 to 100, default = 10).
// type : optional display update type (value 0 to 2, default = 1):
// 0 = no flash (fast, but slight ghosting)
// 1 = quality (full flash update, cleanest display)
// 2 = speed (very fast, black and white only)
//
// *** Disclaimers and whatnot:
//
// This is just a simple quick-and-dirty hack.
// It could use some error checking, and more features.
//
// There is no "secret sauce" here (such as intellectual "Property",
// whatever that is), nothing to protect, no license needed.
//
// As always, please do not sue me if you poke your eye out with
// this code, or somehow manage to injure your brain or otherwise
// maim yourself, your stuff, or your loved ones with it.
//
// Enjoy, compliments of geekmaster...
//
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#define FB_UPDATE_AREA 0x46dd
int main(int argc, char** argv) {
int pct = 10;
int fx = 1; // full flash update
int y, height, width, width_bytes, fb_bytes;
struct fb_var_screeninfo screeninfo;
unsigned char *pfb = NULL, *psave = NULL;
struct update_area_t
{
int x1, y1, x2, y2, fx;
__u8 *buffer;
} ua;
// get optional command-line params
if (argc > 1) pct = atoi(argv[1]); // scroll percent (0-100)
if (argc > 2) fx = atoi(argv[2]); // update type (0-2)
// open framebuffer and get screen size (assume 4 bpp)
int fdFB = open("/dev/fb0", O_RDWR);
ioctl(fdFB, FBIOGET_VSCREENINFO, &screeninfo);
height = screeninfo.yres;
width = screeninfo.xres;
width_bytes = width / 2;
fb_bytes = height * width_bytes;
// map and copy framebuffer
pfb = (unsigned char*)mmap(0, fb_bytes, PROT_READ|PROT_WRITE,
MAP_SHARED, fdFB, 0);
psave = malloc(fb_bytes);
memcpy(psave, pfb, fb_bytes);
// copy swapped slices back to framebuffer
y = height * pct / 100;
memcpy(pfb + y * width_bytes, psave, (height - y) * width_bytes);
memcpy(pfb, psave + (height - y) * width_bytes, y * width_bytes);
// trigger framebuffer update
ua.x1 = 0;
ua.y1 = 0;
ua.x2 = width;
ua.y2 = height;
ua.buffer = NULL;
ua.fx = fx; // update type
ioctl(fdFB, FB_UPDATE_AREA, &ua);
// cleanup
free (psave);
munmap(pfb, fb_bytes);
close(fdFB);
}
so....
Step one I guess would be to throw this on a 4 and see what breaks...
OKAY... That was a shock... it just "worked" LOL! Vertically though.. not L -> R
Step two... figure out HOW the fb if different
Let me go remember how you get that info
EDIT:
ah yeah
[root@kindle root]#
cat /sys/class/graphics/fb0/ (presses tab and...)
Code:
/sys/class/graphics/fb0/bits_per_pixel /sys/class/graphics/fb0/pan
/sys/class/graphics/fb0/blank /sys/class/graphics/fb0/power/
/sys/class/graphics/fb0/console /sys/class/graphics/fb0/rotate
/sys/class/graphics/fb0/cursor /sys/class/graphics/fb0/state
/sys/class/graphics/fb0/dev /sys/class/graphics/fb0/stride
/sys/class/graphics/fb0/device/ /sys/class/graphics/fb0/subsystem/
/sys/class/graphics/fb0/mode /sys/class/graphics/fb0/uevent
/sys/class/graphics/fb0/modes /sys/class/graphics/fb0/virtual_size
/sys/class/graphics/fb0/name
so we have to just
cat some of those values to check our facts...