View Single Post
Old 06-25-2015, 07:10 PM   #2
fastrobot
Connoisseur
fastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to beholdfastrobot is a marvel to behold
 
Posts: 53
Karma: 11844
Join Date: Jun 2014
Location: All over the place...
Device: KOBO AuraHD and GLO
One possibility....

It wasn't very difficult to write a framebuffer save and reload progarm, although I'm still having keyboard troubles; but if there already exists a program on the kobo -- let me know. Here's my version of a framebuffer save and restore if anyone else needs it for switching the framebuffer on the fly.

Code:
// fbswitch.c
//
// Strem new framebuffer in on stdin,
// Stream old framebuffer out on stdout,
// Include framebuffer configuration data when streaming framebuffer,
// so it may be restored identically.
// FIXME, maybe: IO restarting due to signal interruptions is not handled.h
//
// Examples of usage:
// echo -n | fbswitch | gzip - -c > /tmp/fb1.gz # only saves fb, no load.
// eg: zcat /tmp/fb0.gz | fbswitch | gzip - -c > /tmp/fb1.gz # save and load.

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include "mxcfb.h"

int main(void) {
	int fbfd=open("/dev/fb0",O_RDWR);
	struct fb_var_screeninfo vinfo;
	struct mxcfb_update_data region;
	char* buffer[1024];
	int n;

	if (fbfd<0) return errno;
	errno=0;

	// First, backup the old framebuffer	
	ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo );
	if (errno) return errno;
	write( STDOUT_FILENO, (void*)&vinfo, sizeof(vinfo) ); // Save fb configure 
	while( (n=read(fbfd, buffer, 1024))>0 ) write(1, buffer, n);
	if (n<0) return errno;
	close(1);

	close(fbfd);
	fbfd = open("/dev/fb0",O_RDWR );

	// Next, load the framebuffer from stdin (if available).
	n=read( STDIN_FILENO, (void*)&vinfo, sizeof(vinfo));
	if (n && (n!=sizeof(vinfo))) return 1; // Corrupted configuration.. error. 
	if (n!=sizeof(vinfo)) return 0; // No data at all, so nothing to load.

	vinfo.rotate ^= 0x2; // Readback of the orientation is buggy, fix it.

	// Set the framebuffer mode, for the new picture.
	ioctl(fbfd, FBIOPUT_VSCREENINFO, &vinfo );
	if (errno) return errno;

	// Load the picture into the framebuffer.	
	while( (n=read(STDIN_FILENO,buffer,1024))>0 ) write( fbfd, buffer, n );
	if (n<0) return errno;

	// Refresh the screen with the new framebuffer.
	region.update_marker=0;
	region.update_region.top=0;
	region.update_region.left=0;
	region.update_region.width=vinfo.xres;
	region.update_region.height=vinfo.yres;	
	region.waveform_mode = WAVEFORM_MODE_AUTO;
	region.update_mode = UPDATE_MODE_FULL;
	region.temp = TEMP_USE_AMBIENT;
	region.flags=0;	
	ioctl( fbfd, MXCFB_SEND_UPDATE, &region );
	if (errno) return errno;
	ioctl( fbfd, MXCFB_WAIT_FOR_UPDATE_COMPLETE, &region.update_marker );
	return errno;
}
Edit: Note, the rotation orientation read back on the Kobo AuraHD is buggy and a fix is included to exclusive or it with a value to correct the defect. On Kobo Glos, though -- the bug does not exist; and so the above fix is a bad idea. You can either remove the line, and recompile -- or hex edit the binary and change the byte 0x02 to 0x00 right about file offset 0x490 or 0x491 (endianness issues), which effectively makes the EOR/XOR into a nop. ENDEdit.

I still can't figure out how to get the external keyboard to be recognized.
And, now that I have the screen redrawing -- I just noticed that nickel not only is ignoring the special mouse swipe -- it ignores all mouse gestures completely..

I edited the binary of libnickel, and pickel, so that the path to the touchscreen /dev/input/event1 was changed to /tmp/input/event1 -- and then made a named fifo at /tmp/input/event1 -- which echoes all the data from the mouse found on /dev/input/event1 -- but apparently nickel is doing something interactive with the touch device driver, or else is testing for the device node numbers or something; because when I run lsof on nickel, the file is not open to either /tmp/input or /dev/input... It closes both of them.

I don't see any error messages in dmesg, but I do see a reference to setting the mouse parameters -- and so I'm thinking nickel is doing an ioctl which is porbably failing when it does it on a fifo ?

Quote:
[drivers/input/touchscreen/zforce_i2c.c-487] zforce_i2c_open()
[zForce_ir_touch_recv_data-175] command Activate (0) ...
[zForce_ir_touch_recv_data-184] command Resolution (0) ...
[zForce_ir_touch_recv_data-209] command Frequency (0) ...

Does anyone know how to find out for sure?
I tried to use strace on nickel in rcS -- and although it doesn't complain, the screen doesn't draw properly and I'm not getting a trace. Has anyone successfully straced nickel, and if so -- what command did you use, and where did you execute it ?

MD5Sums:
4b6fc11a58f88fca88f72b15186b45ed fbswitch.bz2
c8bbd94e1136865c939f76b43b79e2f9 fbswitch.c.bz2
Attached Files
File Type: bz2 fbswitch.bz2 (2.0 KB, 202 views)
File Type: bz2 fbswitch.c.bz2 (1.1 KB, 211 views)

Last edited by fastrobot; 06-29-2015 at 01:59 AM. Reason: Adding a note:
fastrobot is offline   Reply With Quote