2 * video output handling using plugin_lib
3 * (C) GraÅžvydas "notaz" Ignotas, 2011
5 * This work is licensed under the terms of any of these licenses
7 * - GNU GPL, version 2 or later.
8 * - GNU LGPL, version 2.1 or later.
9 * See the COPYING file in the top-level directory.
14 #include "../../frontend/plugin_lib.h"
16 static const struct rearmed_cbs *cbs;
17 static void *screen_buf;
29 static void check_mode_change(void)
31 static uint32_t old_status;
34 // width|rgb24 change?
35 if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || gpu.screen.h != old_h)
37 old_status = gpu.status.reg;
39 screen_buf = cbs->pl_vout_set_mode(gpu.screen.hres, gpu.screen.h,
40 (gpu.status.rgb24 && !cbs->only_16bpp) ? 24 : 16);
44 static void blit(void)
46 int x = gpu.screen.x & ~1; // alignment needed by blitter
50 uint16_t *vram = gpu.vram;
51 int stride = gpu.screen.hres;
55 fb_offs = y * 1024 + x;
56 dest = (uint8_t *)screen_buf;
58 // only do centering, at least for now
59 doffs = (stride - w) / 2 & ~1;
63 if (cbs->only_16bpp) {
65 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
67 fb_offs &= 1024*512-1;
68 bgr888_to_rgb565(dest, vram + fb_offs, w * 3);
72 dest += (doffs / 8) * 24;
73 for (; h-- > 0; dest += stride * 3, fb_offs += 1024)
75 fb_offs &= 1024*512-1;
76 bgr888_to_rgb888(dest, vram + fb_offs, w * 3);
83 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
85 fb_offs &= 1024*512-1;
86 bgr555_to_rgb565(dest, vram + fb_offs, w * 2);
90 screen_buf = cbs->pl_vout_flip();
93 void vout_update(void)
96 if (cbs->pl_vout_raw_flip)
97 cbs->pl_vout_raw_flip(gpu.screen.x, gpu.screen.y);
102 long GPUopen(void **unused)
104 gpu.frameskip.active = 0;
105 gpu.frameskip.frame_ready = 1;
108 screen_buf = cbs->pl_vout_flip();
114 cbs->pl_vout_close();
118 void vout_set_config(const struct rearmed_cbs *cbs_)
123 // vim:shiftwidth=2:expandtab