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