#include #include #include #include #include #include #include "log.h" #include "fbinit.h" static int fb_fd = -1; static void dump_fixed_info(const struct fb_fix_screeninfo *p) { Log(LDEBUG, "--Fixed screen info follows--"); Log(LDEBUG, "ID=%s SMEM@0x%08x/%u TYPE=%u TYPEAUX=%u VIZ=%u", p->id, p->smem_start, p->smem_len, p->type, p->type_aux, p->visual); Log(LDEBUG, "XPAN=%u YPAN=%u YWRAP=%u LINELEN=%u", p->xpanstep, p->ypanstep, p->ywrapstep, p->line_length); Log(LDEBUG, "MMIO@0x%08x/%u ACCEL=%02x CAP=%08x", p->mmio_start, p->mmio_len, p->accel, p->capabilities); Log(LDEBUG, "--ends--"); } static void dump_var_info(const struct fb_var_screeninfo *p) { Log(LDEBUG, "--Variable screen info follows--"); Log(LDEBUG, "RES=(%u,%u) VRES=(%u,%u) OFS=(%u,%u) BPP=%u GS=%u", p->xres, p->yres, p->xres_virtual, p->yres_virtual, p->xoffset, p->yoffset, p->bits_per_pixel, p->grayscale); Log(LDEBUG, "RedBits: ofs=%u len=%u mright=%u", p->red.offset, p->red.length, p->red.msb_right); Log(LDEBUG, "GreenBits: ofs=%u len=%u mright=%u", p->green.offset, p->green.length, p->green.msb_right); Log(LDEBUG, "BlueBits: ofs=%u len=%u mright=%u", p->blue.offset, p->blue.length, p->blue.msb_right); Log(LDEBUG, "XparBits: ofs=%u len=%u mright=%u", p->transp.offset, p->transp.length, p->transp.msb_right); Log(LDEBUG, "NONSTD=%u ACTIV=%u PSIZ=(%u,%u) AFLG=%08x", p->nonstd, p->activate, p->width, p->height, p->accel_flags); Log(LDEBUG, "PIXCLK=%u LM=%u RM=%u TM=%u BM=%u HSYNC=%u VSYNC=%u", p->pixclock, p->left_margin, p->right_margin, p->upper_margin, p->lower_margin, p->hsync_len, p->vsync_len); Log(LDEBUG, "SYNC=%u VMODE=%u ROT=%u COLORSP=%u", p->sync, p->vmode, p->rotate, p->colorspace); Log(LDEBUG, "--ends--"); } int Fb_setup(void) { struct fb_fix_screeninfo fixed; struct fb_var_screeninfo var; fb_fd = open("/dev/fb1", O_RDWR); if (fb_fd == -1) { Log(LFATAL, "Unable to open framebuffer (%d)", errno); return -1; } if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fixed)) { Log(LFATAL, "Could not get fixed screen info (%d)", errno); return -1; } dump_fixed_info(&fixed); if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &var)) { Log(LFATAL, "Could not get variable screen info (%d)", errno); return -1; } dump_var_info(&var); /* additional initialization here */ return 0; } void Fb_cleanup(void) { /* additional cleanup here */ close(fb_fd); }