Hello There, Guest! Register
Enjoy our site and services? You may donate to help fund server and domain costs. Donate Here for special benefits. You have donated $

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Homebrew creation for innotab
#11
(12-29-2014, 05:45 PM)rioray Wrote: thanks ,

I  finaly got him on IRC and he point me (by giving me his SDL moded source code) how to build an SDL sample working .
i point me also he use /dev/disp0 and chunkMem in his fbconv SDL video driver .  So big thank Mick .

finaly i respond to myself and post the basic to setup an basic framebuffer using /dev/disp0 , maybe usefull for someone else.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

#include <sys/types.h>
#include <sys/ioctl.h>

#include "mach/gp_display.h"
#include "mach/gp_chunkmem.h"

#include <tslib.h>

#define XRATIO 1.0f //1.5f
#define YRATIO 1.0f //1.134f

#define SCREEN_WIDTH  480
#define SCREEN_HEIGHT 272
#define SCREEN_DEPTH 16

#define BMP_WIDTH  SCREEN_WIDTH
#define BMP_HEIGHT SCREEN_HEIGHT
#define BMP_DEPTH  SCREEN_DEPTH

#define RGB565(r, g, b)  (((r) << (5+6)) | ((g) << 6) | (b))

#include "graph.h"

#define CLEAR(x) memset (&(x), 0, sizeof (x))

int main( int argc, char* args[] )
{
int done = 0;

/* dips variable */
int dispDev;
int chunkMem;
chunk_block_t priBlk;
gp_disp_res_t panelRes;
gp_bitmap_t priBitmap;
UINT16 *data;

/* tslib init */
char *tsdevice=NULL;
struct tsdev *ts;
if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) {
ts = ts_open(tsdevice,0);
} else {
ts = ts_open("/dev/input/event0", 0);
}
if (!ts) {
perror("ts_open");
exit(1);
}
if (ts_config(ts)) {
perror("ts_config");
exit(1);
}

/* Opening the device dispDev */
dispDev = open("/dev/disp0",O_RDWR);
fprintf(stderr,"dispDev = %d\n", dispDev);

ioctl(dispDev, DISPIO_SET_INITIAL, 0);
ioctl(dispDev, DISPIO_GET_PANEL_RESOLUTION, &panelRes);

/* Opening /dev/chunkmem */
chunkMem = open("/dev/chunkmem", O_RDWR);

/* Allocate primary frame buffer */
priBlk.size = (BMP_WIDTH) * (BMP_HEIGHT) *2;
ioctl(chunkMem, CHUNK_MEM_ALLOC, (unsigned long)&priBlk);

/* Set primary layer bitmap */
priBitmap.width = panelRes.width;
priBitmap.height = panelRes.height;
priBitmap.bpl = panelRes.width*2;
priBitmap.type = SP_BITMAP_RGB565;
priBitmap.pData = priBlk.addr;

ioctl(dispDev, DISPIO_SET_PRI_BITMAP, &priBitmap);

/* Enable primary layer */
ioctl(dispDev, DISPIO_SET_PRI_ENABLE, 1);
ioctl(dispDev, DISPIO_SET_UPDATE, 0);


while(done==0){

/* fill primary bitmap */
Draw_string((char*)priBitmap.pData, 50, 50,"Hello World innotab!", 20, 1, 2,0xffff,0x8080);
DrawBoxBmp((char*)priBitmap.pData,40,40, 200,40, RGB565(31, 11, 7));
DrawCircle((char*)priBitmap.pData,200, 100, 25,RGB565(31, 31, 31),1);
DrawFBoxBmp((char*)priBitmap.pData,50,100,100,50,RGB565(31, 0, 0));
DrawlineBmp((char*)priBitmap.pData,20,256,460,258,RGB565(0, 31, 0));

/* update and wait frame end */
ioctl(dispDev, DISPIO_SET_PRI_BITMAP, &priBitmap);
ioctl(dispDev, DISPIO_SET_PRI_ENABLE, 1);
ioctl(dispDev, DISPIO_SET_UPDATE, 0);
ioctl(dispDev, DISPIO_WAIT_FRAME_END, 0);


/* update tslib and exit if touch*/
struct ts_sample samp;
int ret;
ret = ts_read(ts, &samp, 1);
if (ret < 0) {
perror("ts_read");
goto fin;
}
if (ret != 1)
continue;

if (samp.pressure > 0)
fprintf(stderr,"%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec,samp.x, samp.y, samp.pressure);

int SX=(int)(samp.x/XRATIO);
int SY=(int)(samp.y/YRATIO);
if(SX>50 && SX<150 && SY>100 && SY<200)done=1;

}

fin:

close(dispDev);

ioctl(chunkMem, CHUNK_MEM_FREE, (unsigned long)&priBlk);
close(chunkMem);

return 0;
}

Well, this forum appears to be dead for a while... rioray, if by chance you could read it, i wonder if you have succeeded in porting or developping homebrew to a storio 2? Do you need a shell access with soldered wires to execute?
Reply


Forum Jump: