remove gpu vblank callbacks
[pcsx_rearmed.git] / plugins / gpu_neon / vout_fb.c
CommitLineData
56f08d83 1/*
2 * (C) GraÅžvydas "notaz" Ignotas, 2011
3 *
4 * This work is licensed under the terms of any of these licenses
5 * (at your option):
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
8 * See the COPYING file in the top-level directory.
9 */
10
11#include "gpu.h"
12#include "../../frontend/plugin_lib.h"
a80ae4a0 13#include "../../frontend/cspace.h"
56f08d83 14
15static const struct rearmed_cbs *cbs;
16static void *screen_buf;
17
18int vout_init(void)
19{
20 return 0;
21}
22
23int vout_finish(void)
24{
25 return 0;
26}
27
28static void blit(void)
29{
6f2ee2be 30 static uint32_t old_status;
31 static int old_h;
8dd855cd 32 int x = gpu.screen.x & ~1; // alignment needed by blitter
56f08d83 33 int y = gpu.screen.y;
34 int w = gpu.screen.w;
8dd855cd 35 int h = gpu.screen.h;
5f26e402 36 uint16_t *vram = gpu.vram;
8dd855cd 37 int stride = gpu.screen.hres;
5f26e402 38 int fb_offs, doffs;
39 uint8_t *dest;
56f08d83 40
5f26e402 41 fb_offs = y * 1024 + x;
56f08d83 42
56f08d83 43 if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) // width|rgb24 change?
44 {
45 old_status = gpu.status.reg;
46 old_h = h;
9394ada5 47 screen_buf = cbs->pl_vout_set_mode(stride, h, gpu.status.rgb24 ? 24 : 16);
56f08d83 48 }
8dd855cd 49
6f2ee2be 50 dest = (uint8_t *)screen_buf;
56f08d83 51
8dd855cd 52 // only do centering, at least for now
53 doffs = (stride - w) / 2 & ~1;
54
56f08d83 55 if (gpu.status.rgb24)
56 {
57#ifndef MAEMO
8dd855cd 58 dest += (doffs / 8) * 24;
5f26e402 59 for (; h-- > 0; dest += stride * 3, fb_offs += 1024)
56f08d83 60 {
5f26e402 61 fb_offs &= 1024*512-1;
62 bgr888_to_rgb888(dest, vram + fb_offs, w * 3);
56f08d83 63 }
64#else
8dd855cd 65 dest += doffs * 2;
5f26e402 66 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
56f08d83 67 {
5f26e402 68 fb_offs &= 1024*512-1;
69 bgr888_to_rgb565(dest, vram + fb_offs, w * 3);
56f08d83 70 }
71#endif
72 }
73 else
74 {
8dd855cd 75 dest += doffs * 2;
5f26e402 76 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
56f08d83 77 {
5f26e402 78 fb_offs &= 1024*512-1;
79 bgr555_to_rgb565(dest, vram + fb_offs, w * 2);
56f08d83 80 }
81 }
82
9394ada5 83 screen_buf = cbs->pl_vout_flip();
56f08d83 84}
85
86void GPUupdateLace(void)
87{
19e7cf87 88 if (gpu.status.blanking || !gpu.state.fb_dirty)
fc84f618 89 return;
90
ea4a16e7 91 if (gpu.frameskip.set) {
5b745e5b 92 if (!gpu.frameskip.frame_ready && gpu.frameskip.skipped_blits < 9) {
19e7cf87 93 gpu.frameskip.skipped_blits++;
94 return;
95 }
96 gpu.frameskip.frame_ready = 0;
97 gpu.frameskip.skipped_blits = 0;
fc84f618 98 }
19e7cf87 99
100 renderer_flush_queues();
101 blit();
102 gpu.state.fb_dirty = 0;
56f08d83 103}
104
105long GPUopen(void)
106{
19e7cf87 107 gpu.frameskip.active = 0;
108 gpu.frameskip.frame_ready = 1;
fc84f618 109
9394ada5 110 cbs->pl_vout_open();
111 screen_buf = cbs->pl_vout_flip();
56f08d83 112 return 0;
113}
114
115long GPUclose(void)
116{
9394ada5 117 cbs->pl_vout_close();
56f08d83 118 return 0;
119}
120
121void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_)
122{
123 cbs = cbs_;
ea4a16e7 124 gpu.frameskip.set = cbs->frameskip;
125 gpu.frameskip.advice = &cbs->fskip_advice;
126 gpu.frameskip.active = 0;
127 gpu.frameskip.frame_ready = 1;
24de2dd4 128 gpu.state.hcnt = cbs->gpu_hcnt;
56f08d83 129}
130
131// vim:shiftwidth=2:expandtab