From 33125aed06d2175f197efa95645dba4f9bd962f2 Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Mon, 13 Feb 2017 12:49:27 +0100 Subject: [PATCH] CFbAccelCSHD2::setMode: Update for new framebuffer driver (full hd) --- src/driver/fb_accel_cs_hd2.cpp | 44 ++++++++++++++++++++++++++++++---- src/neutrino.cpp | 5 +++- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index 393e6396c..233254acc 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -185,21 +185,57 @@ void CFbAccelCSHD2::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_ CFrameBuffer::blitBox2FB(boxBuf, width, height, xoff, yoff); } -int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int) +int CFbAccelCSHD2::setMode(unsigned int nxRes, unsigned int nyRes, unsigned int nbpp) { + if (!available&&!active) + return -1; + + if (available >= 16588800) { /* new fb driver with maxres 1920x1080(*8) */ + screeninfo.xres_virtual=screeninfo.xres=nxRes; + screeninfo.yres_virtual=screeninfo.yres=nyRes; + screeninfo.height=0; + screeninfo.width=0; + screeninfo.xoffset=screeninfo.yoffset=0; + screeninfo.bits_per_pixel=nbpp; + + if (ioctl(fd, FBIOPUT_VSCREENINFO, &screeninfo)<0) + perror(LOGTAG "FBIOPUT_VSCREENINFO"); + + printf(LOGTAG "SetMode: %dbits, red %d:%d green %d:%d blue %d:%d transp %d:%d\n", + screeninfo.bits_per_pixel, screeninfo.red.length, screeninfo.red.offset, screeninfo.green.length, screeninfo.green.offset, screeninfo.blue.length, screeninfo.blue.offset, screeninfo.transp.length, screeninfo.transp.offset); + if ((screeninfo.xres != nxRes) || + (screeninfo.yres != nyRes) || + (screeninfo.bits_per_pixel != nbpp)) { + printf(LOGTAG "SetMode failed: wanted: %dx%dx%d, got %dx%dx%d\n", + nxRes, nyRes, nbpp, + screeninfo.xres, screeninfo.yres, screeninfo.bits_per_pixel); + return -1; + } + } + fb_fix_screeninfo _fix; if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix) < 0) { - perror("FBIOGET_FSCREENINFO"); + perror(LOGTAG "FBIOGET_FSCREENINFO"); return -1; } stride = _fix.line_length; if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) - printf("screen unblanking failed\n"); + printf(LOGTAG "screen unblanking failed\n"); xRes = screeninfo.xres; yRes = screeninfo.yres; bpp = screeninfo.bits_per_pixel; - printf(LOGTAG "%dx%dx%d line length %d. using hd2 graphics accelerator.\n", xRes, yRes, bpp, stride); + printf(LOGTAG "%dx%dx%d line length %d. using %s graphics accelerator.\n", xRes, yRes, bpp, stride, _fix.id); + +/* +max res 1280x720 + available 14745600 + stride 5120 +max res 1920x1080 + available 16588800 + stride 7680 +*/ + int needmem = stride * yRes * 2; if (available >= needmem) { diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 8ab84bd88..7861c9228 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -1815,7 +1815,10 @@ void CNeutrinoApp::CmdParser(int argc, char **argv) void CNeutrinoApp::SetupFrameBuffer() { frameBuffer->init(); - if(frameBuffer->setMode(720, 576, 8 * sizeof(fb_pixel_t))) { + /* Parameters only valid for hd2 hardware and new fb drivers, + all other hardware ignores these parameters */ +// if (frameBuffer->setMode(1280, 720, 8 * sizeof(fb_pixel_t)) == -1) { + if (frameBuffer->setMode(1920, 1080, 8 * sizeof(fb_pixel_t)) == -1) { dprintf(DEBUG_NORMAL, "Error while setting framebuffer mode\n"); exit(-1); }