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.
15 #include "../../frontend/plugin_lib.h"
17 static const struct rearmed_cbs *cbs;
18 static void *screen_buf;
30 static void check_mode_change(void)
32 static uint32_t old_status;
35 // width|rgb24 change?
36 if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || gpu.screen.h != old_h)
38 old_status = gpu.status.reg;
40 screen_buf = cbs->pl_vout_set_mode(gpu.screen.hres, gpu.screen.h,
41 (gpu.status.rgb24 && !cbs->only_16bpp) ? 24 : 16);
45 static void blit(void)
47 int x = gpu.screen.x & ~1; // alignment needed by blitter
51 uint16_t *vram = gpu.vram;
52 int stride = gpu.screen.hres;
56 dest = (uint8_t *)screen_buf;
60 fb_offs = y * 1024 + x;
62 // only do centering, at least for now
63 doffs = (stride - w) / 2 & ~1;
67 if (cbs->only_16bpp) {
69 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
71 fb_offs &= 1024*512-1;
72 bgr888_to_rgb565(dest, vram + fb_offs, w * 3);
76 dest += (doffs / 8) * 24;
77 for (; h-- > 0; dest += stride * 3, fb_offs += 1024)
79 fb_offs &= 1024*512-1;
80 bgr888_to_rgb888(dest, vram + fb_offs, w * 3);
87 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
89 fb_offs &= 1024*512-1;
90 bgr555_to_rgb565(dest, vram + fb_offs, w * 2);
94 screen_buf = cbs->pl_vout_flip();
97 void vout_update(void)
100 if (cbs->pl_vout_raw_flip)
101 cbs->pl_vout_raw_flip(gpu.screen.x, gpu.screen.y);
106 void vout_blank(void)
109 if (cbs->pl_vout_raw_flip == NULL) {
110 int bytespp = gpu.status.rgb24 ? 3 : 2;
111 memset(screen_buf, 0, gpu.screen.hres * gpu.screen.h * bytespp);
112 screen_buf = cbs->pl_vout_flip();
116 long GPUopen(void **unused)
118 gpu.frameskip.active = 0;
119 gpu.frameskip.frame_ready = 1;
122 screen_buf = cbs->pl_vout_flip();
128 cbs->pl_vout_close();
132 void vout_set_config(const struct rearmed_cbs *cbs_)
137 // vim:shiftwidth=2:expandtab