From 8dd855cd6cdab41d1e38637a020681137eceb457 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 16 Jun 2011 01:07:35 +0300 Subject: [PATCH] gpu_neon: partially support range regs --- plugins/gpu_neon/gpu.c | 43 ++++++++++++++++++++++++++++++++------ plugins/gpu_neon/gpu.h | 2 ++ plugins/gpu_neon/vout_fb.c | 28 +++++++++++++------------ 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/plugins/gpu_neon/gpu.c b/plugins/gpu_neon/gpu.c index bacb05b2..c43fd311 100644 --- a/plugins/gpu_neon/gpu.c +++ b/plugins/gpu_neon/gpu.c @@ -14,6 +14,7 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define unlikely(x) __builtin_expect((x), 0) +#define noinline __attribute__((noinline)) //#define log_io printf #define log_io(...) @@ -34,15 +35,40 @@ long GPUshutdown(void) return vout_finish(); } +static noinline void update_width(void) +{ + int sw = gpu.screen.x2 - gpu.screen.x1; + if (sw <= 0 || sw >= 2560) + // full width + gpu.screen.w = gpu.screen.hres; + else + gpu.screen.w = sw * gpu.screen.hres / 2560; +} + +static noinline void update_height(void) +{ + int sh = gpu.screen.y2 - gpu.screen.y1; + if (gpu.status.dheight) + sh *= 2; + if (sh <= 0) + sh = gpu.screen.vres; + + gpu.screen.h = sh; +} + void GPUwriteStatus(uint32_t data) { static const short hres[8] = { 256, 368, 320, 384, 512, 512, 640, 640 }; static const short vres[4] = { 240, 480, 256, 480 }; uint32_t cmd = data >> 24; - switch (data >> 24) { + if (cmd < ARRAY_SIZE(gpu.regs)) + gpu.regs[cmd] = data; + + switch (cmd) { case 0x00: gpu.status.reg = 0x14802000; + gpu.status.blanking = 1; break; case 0x03: gpu.status.blanking = data & 1; @@ -54,19 +80,24 @@ void GPUwriteStatus(uint32_t data) gpu.screen.x = data & 0x3ff; gpu.screen.y = (data >> 10) & 0x3ff; break; + case 0x06: + gpu.screen.x1 = data & 0xfff; + gpu.screen.x2 = (data >> 12) & 0xfff; + update_width(); + break; case 0x07: gpu.screen.y1 = data & 0x3ff; gpu.screen.y2 = (data >> 10) & 0x3ff; + update_height(); break; case 0x08: gpu.status.reg = (gpu.status.reg & ~0x7f0000) | ((data & 0x3F) << 17) | ((data & 0x40) << 10); - gpu.screen.w = hres[(gpu.status.reg >> 16) & 7]; - gpu.screen.h = vres[(gpu.status.reg >> 19) & 3]; + gpu.screen.hres = hres[(gpu.status.reg >> 16) & 7]; + gpu.screen.vres = vres[(gpu.status.reg >> 19) & 3]; + update_width(); + update_height(); break; } - - if (cmd < ARRAY_SIZE(gpu.regs)) - gpu.regs[cmd] = data; } const unsigned char cmd_lengths[256] = diff --git a/plugins/gpu_neon/gpu.h b/plugins/gpu_neon/gpu.h index ebf26400..8813a447 100644 --- a/plugins/gpu_neon/gpu.h +++ b/plugins/gpu_neon/gpu.h @@ -45,7 +45,9 @@ struct psx_gpu { }; } status; struct { + int hres, vres; int x, y, w, h; + int x1, x2; int y1, y2; } screen; struct { diff --git a/plugins/gpu_neon/vout_fb.c b/plugins/gpu_neon/vout_fb.c index 7b77d789..fdcfd512 100644 --- a/plugins/gpu_neon/vout_fb.c +++ b/plugins/gpu_neon/vout_fb.c @@ -28,39 +28,40 @@ int vout_finish(void) static void blit(void) { static uint32_t old_status, old_h; - int x = gpu.screen.x & ~3; // alignment needed by blitter + int x = gpu.screen.x & ~1; // alignment needed by blitter int y = gpu.screen.y; int w = gpu.screen.w; - int h; + int h = gpu.screen.h; + int stride = gpu.screen.hres; + int doffs; uint16_t *srcs; uint8_t *dest; srcs = &gpu.vram[y * 1024 + x]; - h = gpu.screen.y2 - gpu.screen.y1; - if (gpu.status.dheight) - h *= 2; - - if (h <= 0) - return; - if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) // width|rgb24 change? { old_status = gpu.status.reg; old_h = h; - screen_buf = cbs->pl_fbdev_set_mode(w, h, gpu.status.rgb24 ? 24 : 16); + screen_buf = cbs->pl_fbdev_set_mode(stride, h, gpu.status.rgb24 ? 24 : 16); } + dest = screen_buf; + // only do centering, at least for now + doffs = (stride - w) / 2 & ~1; + if (gpu.status.rgb24) { #ifndef MAEMO - for (; h-- > 0; dest += w * 3, srcs += 1024) + dest += (doffs / 8) * 24; + for (; h-- > 0; dest += stride * 3, srcs += 1024) { bgr888_to_rgb888(dest, srcs, w * 3); } #else - for (; h-- > 0; dest += w * 2, srcs += 1024) + dest += doffs * 2; + for (; h-- > 0; dest += stride * 2, srcs += 1024) { bgr888_to_rgb565(dest, srcs, w * 3); } @@ -68,7 +69,8 @@ static void blit(void) } else { - for (; h-- > 0; dest += w * 2, srcs += 1024) + dest += doffs * 2; + for (; h-- > 0; dest += stride * 2, srcs += 1024) { bgr555_to_rgb565(dest, srcs, w * 2); } -- 2.39.5