fbClass::fbClass(const char *fb)
{
- lfb=0;
- fb_fix_screeninfo fix;
m_manual_blit=-1;
instance=this;
locked=0;
+ available=0;
cmap.start=0;
cmap.len=256;
cmap.red=red;
fd=open(fb, O_RDWR);
if (fd<0)
+ {
perror(fb);
- else if (ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo)<0)
+ goto nolfb;
+ }
+
+
+ if (ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo)<0)
+ {
perror("FBIOGET_VSCREENINFO");
- else if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)<0)
+ goto nolfb;
+ }
+
+ memcpy(&oldscreen, &screeninfo, sizeof(screeninfo));
+
+ fb_fix_screeninfo fix;
+ if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)<0)
+ {
perror("FBIOGET_FSCREENINFO");
- else
+ goto nolfb;
+ }
+
+ available=fix.smem_len;
+ eDebug("%dk video mem", available/1024);
+ lfb=(unsigned char*)mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0);
+ if (!lfb)
{
- memcpy(&oldscreen, &screeninfo, sizeof(screeninfo));
- available=fix.smem_len;
- lfb=(unsigned char*)mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0);
- if (!lfb)
- perror("mmap");
- else
- {
- showConsole(0);
- enableManualBlit();
- stride=fix.line_length;
- }
+ perror("mmap");
+ goto nolfb;
}
+
+ showConsole(0);
+
+ enableManualBlit();
+ return;
+nolfb:
+ lfb=0;
+ printf("framebuffer not available.\n");
return;
}
screeninfo.xoffset=screeninfo.yoffset=0;
screeninfo.bits_per_pixel=nbpp;
- if (lfb) {
- munmap(lfb, available);
- lfb = 0;
+ switch (nbpp) {
+ case 16:
+ // ARGB 1555
+ screeninfo.transp.offset = 15;
+ screeninfo.transp.length = 1;
+ screeninfo.red.offset = 10;
+ screeninfo.red.length = 5;
+ screeninfo.green.offset = 5;
+ screeninfo.green.length = 5;
+ screeninfo.blue.offset = 0;
+ screeninfo.blue.length = 5;
+ break;
+ case 32:
+ // ARGB 8888
+ screeninfo.transp.offset = 24;
+ screeninfo.transp.length = 8;
+ screeninfo.red.offset = 16;
+ screeninfo.red.length = 8;
+ screeninfo.green.offset = 8;
+ screeninfo.green.length = 8;
+ screeninfo.blue.offset = 0;
+ screeninfo.blue.length = 8;
+ break;
}
if (ioctl(fd, FBIOPUT_VSCREENINFO, &screeninfo)<0)
xRes=screeninfo.xres;
yRes=screeninfo.yres;
bpp=screeninfo.bits_per_pixel;
-
fb_fix_screeninfo fix;
if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)<0)
{
perror("FBIOGET_FSCREENINFO");
printf("fb failed\n");
- goto nolfb;
- }
-
- available=fix.smem_len;
- eDebug("%dk video mem", available/1024);
- lfb=(unsigned char*)mmap(0, available, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0);
- if (!lfb)
- {
- perror("mmap");
- goto nolfb;
}
-
stride=fix.line_length;
-
+ memset(lfb, 0, stride*yRes);
return 0;
-nolfb:
- lfb=0;
- eFatal("framebuffer no more ready after SetMode(%d, %d, %d)", nxRes, nyRes, nbpp);
- return -1;
}
int fbClass::setOffset(int off)