gpu_neon: partially support range regs
[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"
13#include "../../frontend/arm_utils.h"
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{
30 static uint32_t old_status, old_h;
8dd855cd 31 int x = gpu.screen.x & ~1; // alignment needed by blitter
56f08d83 32 int y = gpu.screen.y;
33 int w = gpu.screen.w;
8dd855cd 34 int h = gpu.screen.h;
35 int stride = gpu.screen.hres;
36 int doffs;
56f08d83 37 uint16_t *srcs;
38 uint8_t *dest;
39
40 srcs = &gpu.vram[y * 1024 + x];
41
56f08d83 42 if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) // width|rgb24 change?
43 {
44 old_status = gpu.status.reg;
45 old_h = h;
8dd855cd 46 screen_buf = cbs->pl_fbdev_set_mode(stride, h, gpu.status.rgb24 ? 24 : 16);
56f08d83 47 }
8dd855cd 48
56f08d83 49 dest = screen_buf;
50
8dd855cd 51 // only do centering, at least for now
52 doffs = (stride - w) / 2 & ~1;
53
56f08d83 54 if (gpu.status.rgb24)
55 {
56#ifndef MAEMO
8dd855cd 57 dest += (doffs / 8) * 24;
58 for (; h-- > 0; dest += stride * 3, srcs += 1024)
56f08d83 59 {
60 bgr888_to_rgb888(dest, srcs, w * 3);
61 }
62#else
8dd855cd 63 dest += doffs * 2;
64 for (; h-- > 0; dest += stride * 2, srcs += 1024)
56f08d83 65 {
66 bgr888_to_rgb565(dest, srcs, w * 3);
67 }
68#endif
69 }
70 else
71 {
8dd855cd 72 dest += doffs * 2;
73 for (; h-- > 0; dest += stride * 2, srcs += 1024)
56f08d83 74 {
75 bgr555_to_rgb565(dest, srcs, w * 2);
76 }
77 }
78
79 screen_buf = cbs->pl_fbdev_flip();
80}
81
82void GPUupdateLace(void)
83{
84 if (!gpu.status.blanking)
85 blit();
86}
87
88long GPUopen(void)
89{
90 cbs->pl_fbdev_open();
91 screen_buf = cbs->pl_fbdev_flip();
92 return 0;
93}
94
95long GPUclose(void)
96{
97 cbs->pl_fbdev_close();
98 return 0;
99}
100
101void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_)
102{
103 cbs = cbs_;
104}
105
106// vim:shiftwidth=2:expandtab