pandora: use hw scaler (resolves 32x+sms), frontend refactoring
[libpicofe.git] / pandora / plat.c
diff --git a/pandora/plat.c b/pandora/plat.c
new file mode 100644 (file)
index 0000000..5992f73
--- /dev/null
@@ -0,0 +1,646 @@
+// (c) Copyright 2006-2009 notaz, All rights reserved.\r
+// Free for non-commercial use.\r
+\r
+// For commercial use, separate licencing terms must be obtained.\r
+\r
+#include <stdio.h>\r
+#include <unistd.h>\r
+#include <stdarg.h>\r
+#include <sys/types.h>\r
+#include <sys/stat.h>\r
+#include <fcntl.h>\r
+#include <sys/ioctl.h>\r
+#include <unistd.h>\r
+#include <linux/fb.h>\r
+#include <linux/omapfb.h>\r
+\r
+#include "../common/emu.h"\r
+#include "../common/menu.h"\r
+#include "../common/plat.h"\r
+#include "../common/arm_utils.h"\r
+#include "../linux/sndout_oss.h"\r
+#include "../linux/fbdev.h"\r
+#include "plat.h"\r
+#include "asm_utils.h"\r
+#include "version.h"\r
+\r
+#include <pico/pico_int.h>\r
+\r
+\r
+static struct vout_fbdev *main_fb, *layer_fb;\r
+static int g_layer_x, g_layer_y;\r
+static int g_layer_w = 320, g_layer_h = 240;\r
+static int g_osd_fps_x, g_osd_y;\r
+\r
+static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";\r
+static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
+static unsigned char __attribute__((aligned(4))) temp_frame[g_menuscreen_w * g_menuscreen_h * 2];\r
+static unsigned char __attribute__((aligned(4))) fb_copy[g_screen_width * g_screen_height * 2];\r
+unsigned char *PicoDraw2FB = temp_frame;\r
+const char *renderer_names[] = { NULL };\r
+const char *renderer_names32x[] = { NULL };\r
+char cpu_clk_name[] = "Max CPU clock";\r
+\r
+static int get_cpu_clock(void)\r
+{\r
+       FILE *f;\r
+       int ret = 0;\r
+       f = fopen("/proc/pandora/cpu_mhz_max", "r");\r
+       if (f) {\r
+               fscanf(f, "%d", &ret);\r
+               fclose(f);\r
+       }\r
+       return ret;\r
+}\r
+\r
+void pemu_prep_defconfig(void)\r
+{\r
+       defaultConfig.EmuOpt |= EOPT_VSYNC|EOPT_16BPP;\r
+       defaultConfig.s_PicoOpt |= POPT_EN_MCD_GFX|POPT_EN_MCD_PSYNC;\r
+       defaultConfig.scaling = SCALE_2x2_3x2;\r
+}\r
+\r
+void pemu_validate_config(void)\r
+{\r
+       currentConfig.CPUclock = get_cpu_clock();\r
+}\r
+\r
+static void osd_text(int x, int y, const char *text)\r
+{\r
+       int len = strlen(text)*8;\r
+       int i, h;\r
+\r
+       len++;\r
+       for (h = 0; h < 8; h++) {\r
+               unsigned short *p;\r
+               p = (unsigned short *)g_screen_ptr + x + g_screen_width*(y + h);\r
+               for (i = len; i; i--, p++)\r
+                       *p = (*p>>2) & 0x39e7;\r
+       }\r
+       emu_text_out16(x, y, text);\r
+}\r
+\r
+static void draw_cd_leds(void)\r
+{\r
+       int old_reg;\r
+       old_reg = Pico_mcd->s68k_regs[0];\r
+\r
+       if (0) {\r
+               // 8-bit modes\r
+               unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
+               unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+ 4) =\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+ 4) =\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+ 4) = col_g;\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+12) =\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+12) =\r
+               *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+12) = col_r;\r
+       } else {\r
+               // 16-bit modes\r
+               unsigned int *p = (unsigned int *)((short *)g_screen_ptr + g_screen_width*2+4);\r
+               unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;\r
+               unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;\r
+               *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
+               *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
+               *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;\r
+       }\r
+}\r
+\r
+static int emuscan(unsigned int num)\r
+{\r
+       DrawLineDest = (unsigned short *)g_screen_ptr + num * g_screen_width;\r
+\r
+       return 0;\r
+}\r
+\r
+void pemu_finalize_frame(const char *fps, const char *notice)\r
+{\r
+       if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {\r
+               if (notice)\r
+                       osd_text(2, g_osd_y, notice);\r
+               if (currentConfig.EmuOpt & EOPT_SHOW_FPS)\r
+                       osd_text(g_osd_fps_x, g_osd_y, fps);\r
+       }\r
+       if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))\r
+               draw_cd_leds();\r
+}\r
+\r
+void plat_video_flip(void)\r
+{\r
+       g_screen_ptr = vout_fbdev_flip(layer_fb);\r
+}\r
+\r
+void plat_video_toggle_renderer(int change, int is_menu)\r
+{\r
+}\r
+\r
+void plat_video_menu_enter(int is_rom_loaded)\r
+{\r
+}\r
+\r
+void plat_video_menu_begin(void)\r
+{\r
+       memcpy32(g_menuscreen_ptr, g_menubg_ptr, g_menuscreen_w * g_menuscreen_h * 2 / 4);\r
+}\r
+\r
+void plat_video_menu_end(void)\r
+{\r
+       g_menuscreen_ptr = vout_fbdev_flip(main_fb);\r
+}\r
+\r
+void plat_video_wait_vsync(void)\r
+{\r
+       vout_fbdev_wait_vsync(main_fb);\r
+}\r
+\r
+void plat_status_msg_clear(void)\r
+{\r
+       vout_fbdev_clear_lines(layer_fb, g_screen_height - 8, 8);\r
+}\r
+\r
+void plat_status_msg_busy_next(const char *msg)\r
+{\r
+       plat_status_msg_clear();\r
+       pemu_finalize_frame("", msg);\r
+       plat_video_flip();\r
+       emu_status_msg("");\r
+       reset_timing = 1;\r
+}\r
+\r
+void plat_status_msg_busy_first(const char *msg)\r
+{\r
+       plat_status_msg_busy_next(msg);\r
+}\r
+\r
+void plat_update_volume(int has_changed, int is_up)\r
+{\r
+       static int prev_frame = 0, wait_frames = 0;\r
+       int vol = currentConfig.volume;\r
+\r
+       if (has_changed)\r
+       {\r
+               if (is_up) {\r
+                       if (vol < 99) vol++;\r
+               } else {\r
+                       if (vol >  0) vol--;\r
+               }\r
+               wait_frames = 0;\r
+               sndout_oss_setvol(vol, vol);\r
+               currentConfig.volume = vol;\r
+               emu_status_msg("VOL: %02i", vol);\r
+               prev_frame = Pico.m.frame_count;\r
+       }\r
+}\r
+\r
+void pemu_forced_frame(int opts, int no_scale)\r
+{\r
+       int oldscale = currentConfig.scaling;\r
+       int po_old = PicoOpt;\r
+\r
+       if (no_scale) {\r
+               currentConfig.scaling = SCALE_1x1;\r
+               emu_video_mode_change(8, 224, 0);\r
+       }\r
+\r
+       PicoOpt |= opts|POPT_ACC_SPRITES;\r
+\r
+       Pico.m.dirtyPal = 1;\r
+       PicoFrameDrawOnly();\r
+\r
+       PicoOpt = po_old;\r
+       currentConfig.scaling = oldscale;\r
+}\r
+\r
+static void updateSound(int len)\r
+{\r
+       unsigned int t;\r
+\r
+       len <<= 1;\r
+       if (PicoOpt & POPT_EN_STEREO)\r
+               len <<= 1;\r
+\r
+       // sndout_oss_can_write() not reliable..\r
+       if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))\r
+               return;\r
+\r
+       /* avoid writing audio when lagging behind to prevent audio lag */\r
+       if (PicoSkipFrame == 2)\r
+               return;\r
+\r
+       t = plat_get_ticks_ms();\r
+       sndout_oss_write(PsndOut, len);\r
+       t = plat_get_ticks_ms() - t;\r
+       if (t > 1)\r
+               printf("audio lag %u\n", t);\r
+}\r
+\r
+void pemu_sound_start(void)\r
+{\r
+       int target_fps = Pico.m.pal ? 50 : 60;\r
+\r
+       PsndOut = NULL;\r
+\r
+       if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
+       {\r
+               int snd_excess_add, frame_samples;\r
+               int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
+\r
+               PsndRerate(Pico.m.frame_count ? 1 : 0);\r
+\r
+               frame_samples = PsndLen;\r
+               snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps;\r
+               if (snd_excess_add != 0)\r
+                       frame_samples++;\r
+\r
+               /*\r
+                * for 44k stereo, we do 1470 samples/frame\r
+                * OMAP driver does power of 2 buffers, so we need at least 4K buffer.\r
+                * The most we can lag is 1K samples, size of OMAP's McBSP FIFO,\r
+                * with 2K sample buffer we might sometimes lag more than that,\r
+                * thus causing underflows.\r
+                */\r
+               printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
+                       PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);\r
+               sndout_oss_start(PsndRate, frame_samples * 2, is_stereo);\r
+               //sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
+               PicoWriteSound = updateSound;\r
+               plat_update_volume(0, 0);\r
+               memset(sndBuffer, 0, sizeof(sndBuffer));\r
+               PsndOut = sndBuffer;\r
+       }\r
+}\r
+\r
+void pemu_sound_stop(void)\r
+{\r
+       sndout_oss_stop();\r
+}\r
+\r
+void pemu_sound_wait(void)\r
+{\r
+       // don't need to do anything, writes will block by themselves\r
+}\r
+\r
+void plat_debug_cat(char *str)\r
+{\r
+}\r
+\r
+static int pnd_setup_layer_(int fd, int enabled, int x, int y, int w, int h)\r
+{\r
+       struct omapfb_plane_info pi;\r
+       struct omapfb_mem_info mi;\r
+       int ret;\r
+\r
+       ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi);\r
+       if (ret != 0) {\r
+               perror("QUERY_PLANE");\r
+               return -1;\r
+       }\r
+\r
+       ret = ioctl(fd, OMAPFB_QUERY_MEM, &mi);\r
+       if (ret != 0) {\r
+               perror("QUERY_MEM");\r
+               return -1;\r
+       }\r
+\r
+       /* must disable when changing stuff */\r
+       if (pi.enabled) {\r
+               pi.enabled = 0;\r
+               ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);\r
+               if (ret != 0)\r
+                       perror("SETUP_PLANE");\r
+       }\r
+\r
+       mi.size = 320*240*2*4;\r
+       ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi);\r
+       if (ret != 0) {\r
+               perror("SETUP_MEM");\r
+               return -1;\r
+       }\r
+\r
+       pi.pos_x = x;\r
+       pi.pos_y = y;\r
+       pi.out_width = w;\r
+       pi.out_height = h;\r
+       pi.enabled = enabled;\r
+\r
+       ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);\r
+       if (ret != 0) {\r
+               perror("SETUP_PLANE");\r
+               return -1;\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+int pnd_setup_layer(int enabled, int x, int y, int w, int h)\r
+{\r
+       return pnd_setup_layer_(vout_fbdev_get_fd(layer_fb), enabled, x, y, w, h);\r
+}\r
+\r
+void pnd_restore_layer_data(void)\r
+{\r
+       short *t = ((short *)fb_copy)[320*240 / 2 + 160];\r
+\r
+       // right now this is used by menu, which wants to preview something\r
+       // so try to get something on the layer.\r
+       if ((t[0] | t[5] | t[13]) == 0)\r
+               memset32((void *)fb_copy, 0x07000700, sizeof(fb_copy) / 4);\r
+\r
+       memcpy32(g_screen_ptr, (void *)fb_copy, 320*240*2 / 4);\r
+       plat_video_flip();\r
+}\r
+\r
+static void apply_filter(int which)\r
+{\r
+       char buf[128];\r
+       int i;\r
+\r
+       if (pnd_filter_list == NULL)\r
+               return;\r
+\r
+       for (i = 0; i < which; i++)\r
+               if (pnd_filter_list[i] == NULL)\r
+                       return;\r
+\r
+       if (pnd_filter_list[i] == NULL)\r
+               return;\r
+\r
+       snprintf(buf, sizeof(buf), "%s/op_videofir.sh %s", pnd_script_base, pnd_filter_list[i]);\r
+       system(buf);\r
+}\r
+\r
+void emu_video_mode_change(int start_line, int line_count, int is_32cols)\r
+{\r
+       int fb_w = 320, fb_h = 240, fb_left = 0, fb_right = 0, fb_top = 0, fb_bottom = 0;\r
+\r
+       PicoScanBegin = emuscan;\r
+       PicoScanEnd = NULL;\r
+       PicoDrawSetOutFormat(PDF_RGB555, 1);\r
+\r
+       if (is_32cols) {\r
+               fb_w = 256;\r
+               fb_left = fb_right = 32;\r
+       }\r
+\r
+       switch (currentConfig.scaling) {\r
+       case SCALE_1x1:\r
+               g_layer_w = fb_w;\r
+               g_layer_h = fb_h;\r
+               break;\r
+       case SCALE_2x2_3x2:\r
+               g_layer_w = fb_w * (is_32cols ? 3 : 2);\r
+               g_layer_h = fb_h * 2;\r
+               break;\r
+       case SCALE_2x2_2x2:\r
+               g_layer_w = fb_w * 2;\r
+               g_layer_h = fb_h * 2;\r
+               break;\r
+       case SCALE_FULLSCREEN:\r
+               g_layer_w = 800;\r
+               g_layer_h = 480;\r
+               break;\r
+       case SCALE_CUSTOM:\r
+               g_layer_x = g_layer_cx;\r
+               g_layer_y = g_layer_cy;\r
+               g_layer_w = g_layer_cw;\r
+               g_layer_h = g_layer_ch;\r
+               break;\r
+       }\r
+\r
+       if (currentConfig.scaling != SCALE_CUSTOM) {\r
+               // center the layer\r
+               g_layer_x = 800 / 2 - g_layer_w / 2;\r
+               g_layer_y = 480 / 2 - g_layer_h / 2;\r
+       }\r
+\r
+       switch (currentConfig.scaling) {\r
+       case SCALE_FULLSCREEN:\r
+       case SCALE_CUSTOM:\r
+               fb_top = start_line;\r
+               fb_h = line_count;\r
+               break;\r
+       }\r
+       g_osd_fps_x = is_32cols ? 232 : 264;\r
+       g_osd_y = fb_top + fb_h - 8;\r
+\r
+       pnd_setup_layer(1, g_layer_x, g_layer_y, g_layer_w, g_layer_h);\r
+       vout_fbdev_resize(layer_fb, fb_w, fb_h, fb_left, fb_right, fb_top, fb_bottom, 0);\r
+       vout_fbdev_clear(layer_fb);\r
+}\r
+\r
+static void make_bg(void)\r
+{\r
+       unsigned short *s = (void *)fb_copy;\r
+       unsigned int t, *d = (unsigned int *)g_menubg_src_ptr + 80 / 2;\r
+       int x, y;\r
+\r
+       memset32(g_menubg_src_ptr, 0, 800 * 480 * 2 / 4);\r
+\r
+       for (y = 0; y < 240; y++, s += 320, d += 800*2/2) {\r
+               for (x = 0; x < 320; x++) {\r
+                       t = s[x];\r
+                       t |= t << 16;\r
+                       d[x] = d[x + 800 / 2] = t;\r
+               }\r
+       }\r
+}\r
+\r
+void pemu_loop_prep(void)\r
+{\r
+       static int pal_old = -1;\r
+       static int filter_old = -1;\r
+       char buf[128];\r
+\r
+       if (currentConfig.CPUclock != get_cpu_clock()) {\r
+               snprintf(buf, sizeof(buf), "unset DISPLAY; echo y | %s/op_cpuspeed.sh %d",\r
+                        pnd_script_base, currentConfig.CPUclock);\r
+               system(buf);\r
+       }\r
+\r
+       if (Pico.m.pal != pal_old) {\r
+               snprintf(buf, sizeof(buf), "%s/op_lcdrate.sh %d",\r
+                        pnd_script_base, Pico.m.pal ? 50 : 60);\r
+               system(buf);\r
+               pal_old = Pico.m.pal;\r
+       }\r
+\r
+       if (currentConfig.filter != filter_old) {\r
+               apply_filter(currentConfig.filter);\r
+               filter_old = currentConfig.filter;\r
+       }\r
+\r
+       // make sure there is no junk left behind the layer\r
+       memset32(g_menuscreen_ptr, 0, 800 * 480 * 2 / 4);\r
+       g_menuscreen_ptr = vout_fbdev_flip(main_fb);\r
+\r
+       // emu_video_mode_change will call pnd_setup_layer()\r
+\r
+       // dirty buffers better go now than during gameplay\r
+       sync();\r
+       sleep(0);\r
+\r
+       pemu_sound_start();\r
+}\r
+\r
+void pemu_loop_end(void)\r
+{\r
+       int po_old = PicoOpt;\r
+       int eo_old = currentConfig.EmuOpt;\r
+\r
+       pemu_sound_stop();\r
+       memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
+\r
+       /* do one more frame for menu bg */\r
+       PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES;\r
+       currentConfig.EmuOpt |= EOPT_16BPP;\r
+\r
+       PicoDrawSetOutFormat(PDF_RGB555, 1);\r
+       Pico.m.dirtyPal = 1;\r
+       PicoFrame();\r
+\r
+       // making a copy because enabling the layer clears it's mem\r
+       memcpy32((void *)fb_copy, g_screen_ptr, sizeof(fb_copy) / 4);\r
+       make_bg();\r
+\r
+       pnd_setup_layer(0, g_layer_x, g_layer_y, g_layer_w, g_layer_h);\r
+\r
+       PicoOpt = po_old;\r
+       currentConfig.EmuOpt = eo_old;\r
+}\r
+\r
+void plat_wait_till_us(unsigned int us_to)\r
+{\r
+       unsigned int now;\r
+       signed int diff;\r
+\r
+       now = plat_get_ticks_us();\r
+\r
+       // XXX: need to check NOHZ\r
+       diff = (signed int)(us_to - now);\r
+       if (diff > 10000) {\r
+               //printf("sleep %d\n", us_to - now);\r
+               usleep(diff * 15 / 16);\r
+               now = plat_get_ticks_us();\r
+               //printf(" wake %d\n", (signed)(us_to - now));\r
+       }\r
+/*\r
+       while ((signed int)(us_to - now) > 512) {\r
+               spend_cycles(1024);\r
+               now = plat_get_ticks_us();\r
+       }\r
+*/\r
+}\r
+\r
+const char *plat_get_credits(void)\r
+{\r
+       return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n"\r
+               "Credits:\n"\r
+               "fDave: Cyclone 68000 core,\n"\r
+               "      base code of PicoDrive\n"\r
+               "Reesy & FluBBa: DrZ80 core\n"\r
+               "MAME devs: YM2612 and SN76496 cores\n"\r
+               "Pandora team: Pandora\n"\r
+               "Inder, ketchupgun: graphics\n"\r
+               "\n"\r
+               "special thanks (for docs, ideas):\n"\r
+               " Charles MacDonald, Haze,\n"\r
+               " Stephane Dallongeville,\n"\r
+               " Lordus, Exophase, Rokas,\n"\r
+               " Nemesis, Tasco Deluxe";\r
+}\r
+\r
+#include "../linux/oshide.h"\r
+\r
+void plat_early_init(void)\r
+{\r
+}\r
+\r
+void plat_init(void)\r
+{\r
+       const char *main_fb_name, *layer_fb_name;\r
+       int fd, ret, w, h;\r
+\r
+       main_fb_name = getenv("FBDEV_MAIN");\r
+       if (main_fb_name == NULL)\r
+               main_fb_name = "/dev/fb0";\r
+\r
+       layer_fb_name = getenv("FBDEV_LAYER");\r
+       if (layer_fb_name == NULL)\r
+               layer_fb_name = "/dev/fb1";\r
+\r
+       // must set the layer up first to be able to use it\r
+       fd = open(layer_fb_name, O_RDWR);\r
+       if (fd == -1) {\r
+               fprintf(stderr, "%s: ", layer_fb_name);\r
+               perror("open");\r
+               exit(1);\r
+       }\r
+\r
+       ret = pnd_setup_layer_(fd, 0, g_layer_x, g_layer_y, g_layer_w, g_layer_h);\r
+       close(fd);\r
+       if (ret != 0) {\r
+               fprintf(stderr, "failed to set up layer, exiting.\n");\r
+               exit(1);\r
+       }\r
+\r
+       oshide_init();\r
+\r
+       w = h = 0;\r
+       main_fb = vout_fbdev_init(main_fb_name, &w, &h, 0);\r
+       if (main_fb == NULL) {\r
+               fprintf(stderr, "couldn't init fb: %s\n", main_fb_name);\r
+               exit(1);\r
+       }\r
+\r
+       if (w != g_menuscreen_w || h != g_menuscreen_h) {\r
+               fprintf(stderr, "%dx%d not supported on %s\n", w, h, main_fb_name);\r
+               goto fail0;\r
+       }\r
+       g_menuscreen_ptr = vout_fbdev_flip(main_fb);\r
+\r
+       w = 320; h = 240;\r
+       layer_fb = vout_fbdev_init(layer_fb_name, &w, &h, 0);\r
+       if (layer_fb == NULL) {\r
+               fprintf(stderr, "couldn't init fb: %s\n", layer_fb_name);\r
+               goto fail0;\r
+       }\r
+\r
+       if (w != g_screen_width || h != g_screen_height) {\r
+               fprintf(stderr, "%dx%d not supported on %s\n", w, h, layer_fb_name);\r
+               goto fail1;\r
+       }\r
+       g_screen_ptr = vout_fbdev_flip(layer_fb);\r
+\r
+       g_menubg_ptr = temp_frame;\r
+       g_menubg_src_ptr = temp_frame;\r
+\r
+       sndout_oss_init();\r
+       pnd_menu_init();\r
+       return;\r
+\r
+fail1:\r
+       vout_fbdev_finish(layer_fb);\r
+fail0:\r
+       vout_fbdev_finish(main_fb);\r
+       exit(1);\r
+}\r
+\r
+void plat_finish(void)\r
+{\r
+       sndout_oss_exit();\r
+       vout_fbdev_finish(main_fb);\r
+       oshide_finish();\r
+\r
+       printf("all done\n");\r
+}\r
+\r
+/* lprintf */\r
+void lprintf(const char *fmt, ...)\r
+{\r
+       va_list vl;\r
+\r
+       va_start(vl, fmt);\r
+       vprintf(fmt, vl);\r
+       va_end(vl);\r
+}\r
+\r