mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
spark: do not scale framebuffer for PAL mode
Downscaling potentially looks bad and leads to ugly artifacts. So for PAL mode, do not scale at all, just use the old-fashioned big font look of dbox2 or tripledragon. Only scale for modes bigger than 720p.
This commit is contained in:
@@ -64,8 +64,9 @@ static int bpafd = -1;
|
|||||||
static fb_pixel_t *backbuffer = NULL;
|
static fb_pixel_t *backbuffer = NULL;
|
||||||
static int fake_xRes = 0;
|
static int fake_xRes = 0;
|
||||||
static int fake_yRes = 0;
|
static int fake_yRes = 0;
|
||||||
static int fake_stride = 0;
|
|
||||||
static int backbuf_sz = 0;
|
static int backbuf_sz = 0;
|
||||||
|
static int max_backbuf_sz = 0;
|
||||||
|
static bool scaling = false;
|
||||||
|
|
||||||
void CFrameBuffer::waitForIdle(void)
|
void CFrameBuffer::waitForIdle(void)
|
||||||
{
|
{
|
||||||
@@ -153,12 +154,26 @@ void CFrameBuffer::init(const char * const fbDevice)
|
|||||||
stride = xRes * bpp / 8;
|
stride = xRes * bpp / 8;
|
||||||
printf("FB: %dx%dx%d line length %d.\n", xRes, yRes, bpp, stride);
|
printf("FB: %dx%dx%d line length %d.\n", xRes, yRes, bpp, stride);
|
||||||
|
|
||||||
fake_xRes = DEFAULT_XRES;
|
/* PAL and 720p mode is unscaled, but 1080 modes are not */
|
||||||
fake_yRes = DEFAULT_YRES;
|
scaling = (xRes > 1280);
|
||||||
screeninfo.xres = DEFAULT_XRES;
|
|
||||||
screeninfo.yres = DEFAULT_YRES;
|
if (xRes > 720)
|
||||||
screeninfo.xres_virtual = DEFAULT_XRES;
|
{
|
||||||
screeninfo.yres_virtual = DEFAULT_YRES;
|
/* HDTV mode */
|
||||||
|
fake_xRes = DEFAULT_XRES;
|
||||||
|
fake_yRes = DEFAULT_YRES;
|
||||||
|
screeninfo.xres = DEFAULT_XRES;
|
||||||
|
screeninfo.yres = DEFAULT_YRES;
|
||||||
|
screeninfo.xres_virtual = DEFAULT_XRES;
|
||||||
|
screeninfo.yres_virtual = DEFAULT_YRES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* PAL mode */
|
||||||
|
fake_xRes = xRes;
|
||||||
|
fake_yRes = yRes;
|
||||||
|
}
|
||||||
|
|
||||||
screeninfo.bits_per_pixel = 32;
|
screeninfo.bits_per_pixel = 32;
|
||||||
backbuf_sz = stride * yRes;
|
backbuf_sz = stride * yRes;
|
||||||
|
|
||||||
@@ -189,7 +204,9 @@ printf("FB: %dx%dx%d line length %d.\n", xRes, yRes, bpp, stride);
|
|||||||
}
|
}
|
||||||
BPAMemAllocMemData bpa_data;
|
BPAMemAllocMemData bpa_data;
|
||||||
bpa_data.bpa_part = (char *)"LMI_VID";
|
bpa_data.bpa_part = (char *)"LMI_VID";
|
||||||
bpa_data.mem_size = backbuf_sz;
|
/* allocate maximum possibly needed amount of memory */
|
||||||
|
max_backbuf_sz = 1920 * 1080 * sizeof(fb_pixel_t);
|
||||||
|
bpa_data.mem_size = max_backbuf_sz;
|
||||||
int res;
|
int res;
|
||||||
res = ioctl(bpafd, BPAMEMIO_ALLOCMEM, &bpa_data);
|
res = ioctl(bpafd, BPAMEMIO_ALLOCMEM, &bpa_data);
|
||||||
if (res)
|
if (res)
|
||||||
@@ -220,7 +237,7 @@ printf("FB: %dx%dx%d line length %d.\n", xRes, yRes, bpp, stride);
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(backbuffer, 0, backbuf_sz);
|
memset(backbuffer, 0, max_backbuf_sz);
|
||||||
cache_size = 0;
|
cache_size = 0;
|
||||||
|
|
||||||
/* Windows Colors */
|
/* Windows Colors */
|
||||||
@@ -298,7 +315,7 @@ CFrameBuffer::~CFrameBuffer()
|
|||||||
if (backbuffer)
|
if (backbuffer)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "CFrameBuffer: unmap backbuffer\n");
|
fprintf(stderr, "CFrameBuffer: unmap backbuffer\n");
|
||||||
munmap(backbuffer, backbuf_sz);
|
munmap(backbuffer, max_backbuf_sz);
|
||||||
}
|
}
|
||||||
if (bpafd != -1)
|
if (bpafd != -1)
|
||||||
{
|
{
|
||||||
@@ -479,7 +496,7 @@ void CFrameBuffer::paintBoxRel(const int _x, const int _y, const int _dx, const
|
|||||||
|
|
||||||
int add = 0;
|
int add = 0;
|
||||||
/* hack to remove artefacts caused by rounding in scaling mode */
|
/* hack to remove artefacts caused by rounding in scaling mode */
|
||||||
if (xRes > 1280 && col == backgroundColor)
|
if (scaling && col == backgroundColor)
|
||||||
add = 1;
|
add = 1;
|
||||||
|
|
||||||
int x = scaleX(_x);
|
int x = scaleX(_x);
|
||||||
@@ -1524,6 +1541,45 @@ void CFrameBuffer::resize(int format)
|
|||||||
bpp = 32;
|
bpp = 32;
|
||||||
stride = xRes * bpp / 8;
|
stride = xRes * bpp / 8;
|
||||||
fprintf(stderr, "CFrameBuffer::resize(%d): %d x %d\n", format, xRes, yRes);
|
fprintf(stderr, "CFrameBuffer::resize(%d): %d x %d\n", format, xRes, yRes);
|
||||||
|
|
||||||
|
/* reacquire parameters...
|
||||||
|
* TODO: this is duplicated code from ::init() function */
|
||||||
|
if (ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo) < 0)
|
||||||
|
perror("FBIOGET_VSCREENINFO");
|
||||||
|
|
||||||
|
xRes = screeninfo.xres;
|
||||||
|
yRes = screeninfo.yres;
|
||||||
|
bpp = 32;
|
||||||
|
stride = xRes * bpp / 8;
|
||||||
|
|
||||||
|
scaling = (xRes > 1280);
|
||||||
|
|
||||||
|
if (xRes > 720)
|
||||||
|
{
|
||||||
|
fake_xRes = DEFAULT_XRES;
|
||||||
|
fake_yRes = DEFAULT_YRES;
|
||||||
|
screeninfo.xres = DEFAULT_XRES;
|
||||||
|
screeninfo.yres = DEFAULT_YRES;
|
||||||
|
screeninfo.xres_virtual = DEFAULT_XRES;
|
||||||
|
screeninfo.yres_virtual = DEFAULT_YRES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fake_xRes = xRes;
|
||||||
|
fake_yRes = yRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("FB:resize %dx%dx%d line length %d. scaling: %d\n", xRes, yRes, bpp, stride, scaling);
|
||||||
|
|
||||||
|
screeninfo.bits_per_pixel = 32;
|
||||||
|
backbuf_sz = stride * yRes;
|
||||||
|
|
||||||
|
int p = (xRes > 720); /* 0 == SDTV, 1 == HDTV */
|
||||||
|
g_settings.screen_preset = p;
|
||||||
|
g_settings.screen_StartX = p ? g_settings.screen_StartX_lcd : g_settings.screen_StartX_crt;
|
||||||
|
g_settings.screen_StartY = p ? g_settings.screen_StartY_lcd : g_settings.screen_StartY_crt;
|
||||||
|
g_settings.screen_EndX = p ? g_settings.screen_EndX_lcd : g_settings.screen_EndX_crt;
|
||||||
|
g_settings.screen_EndY = p ? g_settings.screen_EndY_lcd : g_settings.screen_EndY_crt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFrameBuffer::blitRect(int x, int y, int width, int height, unsigned long color)
|
void CFrameBuffer::blitRect(int x, int y, int width, int height, unsigned long color)
|
||||||
@@ -1592,6 +1648,8 @@ void CFrameBuffer::update(void)
|
|||||||
|
|
||||||
int CFrameBuffer::scaleX(const int x, bool clamp)
|
int CFrameBuffer::scaleX(const int x, bool clamp)
|
||||||
{
|
{
|
||||||
|
if (!scaling)
|
||||||
|
return x;
|
||||||
unsigned int mul = x * xRes;
|
unsigned int mul = x * xRes;
|
||||||
mul = mul / DEFAULT_XRES + (((mul % DEFAULT_XRES) >= (DEFAULT_XRES / 2)) ? 1 : 0);
|
mul = mul / DEFAULT_XRES + (((mul % DEFAULT_XRES) >= (DEFAULT_XRES / 2)) ? 1 : 0);
|
||||||
if (clamp && mul > xRes)
|
if (clamp && mul > xRes)
|
||||||
@@ -1601,6 +1659,8 @@ int CFrameBuffer::scaleX(const int x, bool clamp)
|
|||||||
|
|
||||||
int CFrameBuffer::scaleY(const int y, bool clamp)
|
int CFrameBuffer::scaleY(const int y, bool clamp)
|
||||||
{
|
{
|
||||||
|
if (!scaling)
|
||||||
|
return y;
|
||||||
unsigned int mul = y * yRes;
|
unsigned int mul = y * yRes;
|
||||||
mul = mul / DEFAULT_YRES + (((mul % DEFAULT_YRES) >= (DEFAULT_YRES / 2)) ? 1 : 0);
|
mul = mul / DEFAULT_YRES + (((mul % DEFAULT_YRES) >= (DEFAULT_YRES / 2)) ? 1 : 0);
|
||||||
if (clamp && mul > yRes)
|
if (clamp && mul > yRes)
|
||||||
|
Reference in New Issue
Block a user