View Single Post
Old 03-22-2013, 02:07 AM   #4
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,491
Karma: 5977000
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
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 argcchar** argv) {
    
int pct 10;
    
int fx 1// full flash update
    
int yheightwidthwidth_bytesfb_bytes;
    
struct fb_var_screeninfo screeninfo;
    
unsigned char *pfb NULL, *psave NULL;
    
struct update_area_t
    
{
        
int x1y1x2y2fx;
        
__u8 *buffer;
    } 
ua;

    
// get optional command-line params
    
if (argc 1pct atoi(argv[1]);  // scroll percent (0-100)
    
if (argc 2fx atoi(argv[2]);   // update type (0-2)

    // open framebuffer and get screen size (assume 4 bpp)
    
int fdFB open("/dev/fb0"O_RDWR);
    
ioctl(fdFBFBIOGET_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(0fb_bytesPROT_READ|PROT_WRITE,
        
MAP_SHAREDfdFB0);
    
psave malloc(fb_bytes);
    
memcpy(psavepfbfb_bytes);

    
// copy swapped slices back to framebuffer
    
height pct 100;
    
memcpy(pfb width_bytespsave, (height y) * width_bytes);
    
memcpy(pfbpsave + (height y) * width_byteswidth_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(fdFBFB_UPDATE_AREA, &ua);

    
// cleanup
    
free (psave);
    
munmap(pfbfb_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...

Last edited by twobob; 03-22-2013 at 04:28 PM. Reason: added links to tools
twobob is offline   Reply With Quote