plat.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /*
  2. * PicoDrive
  3. * (C) notaz, 2010,2011
  4. *
  5. * This work is licensed under the terms of MAME license.
  6. * See COPYING file in the top-level directory.
  7. */
  8. #include <stdio.h>
  9. #include <unistd.h>
  10. #include <sys/types.h>
  11. #include <sys/stat.h>
  12. #include <fcntl.h>
  13. #include <sys/ioctl.h>
  14. #include <unistd.h>
  15. #include <linux/fb.h>
  16. #include <linux/omapfb.h>
  17. #include "../common/emu.h"
  18. #include "../common/menu.h"
  19. #include "../common/plat.h"
  20. #include "../common/arm_utils.h"
  21. #include "../common/input.h"
  22. #include "../linux/sndout_oss.h"
  23. #include "../linux/fbdev.h"
  24. #include "../linux/xenv.h"
  25. #include "plat.h"
  26. #include "asm_utils.h"
  27. #include "version.h"
  28. #include <pico/pico_int.h>
  29. #include <linux/input.h>
  30. static struct vout_fbdev *main_fb, *layer_fb;
  31. // g_layer_* - in use, g_layer_c* - configured custom
  32. int g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch;
  33. static int g_layer_x, g_layer_y;
  34. static int g_layer_w = 320, g_layer_h = 240;
  35. static int g_osd_fps_x, g_osd_y, doing_bg_frame;
  36. static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
  37. static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
  38. static unsigned char __attribute__((aligned(4))) fb_copy[g_screen_width * g_screen_height * 2];
  39. static void *temp_frame;
  40. unsigned char *PicoDraw2FB;
  41. const char *renderer_names[] = { NULL };
  42. const char *renderer_names32x[] = { NULL };
  43. static const char * const pandora_gpio_keys[KEY_MAX + 1] = {
  44. [0 ... KEY_MAX] = NULL,
  45. [KEY_UP] = "Up",
  46. [KEY_LEFT] = "Left",
  47. [KEY_RIGHT] = "Right",
  48. [KEY_DOWN] = "Down",
  49. [KEY_HOME] = "A",
  50. [KEY_PAGEDOWN] = "X",
  51. [KEY_END] = "B",
  52. [KEY_PAGEUP] = "Y",
  53. [KEY_RIGHTSHIFT]= "L",
  54. [KEY_RIGHTCTRL] = "R",
  55. [KEY_LEFTALT] = "Start",
  56. [KEY_LEFTCTRL] = "Select",
  57. [KEY_MENU] = "Pandora",
  58. };
  59. struct in_default_bind in_evdev_defbinds[] =
  60. {
  61. /* MXYZ SACB RLDU */
  62. { KEY_UP, IN_BINDTYPE_PLAYER12, 0 },
  63. { KEY_DOWN, IN_BINDTYPE_PLAYER12, 1 },
  64. { KEY_LEFT, IN_BINDTYPE_PLAYER12, 2 },
  65. { KEY_RIGHT, IN_BINDTYPE_PLAYER12, 3 },
  66. { KEY_S, IN_BINDTYPE_PLAYER12, 4 }, /* B */
  67. { KEY_D, IN_BINDTYPE_PLAYER12, 5 }, /* C */
  68. { KEY_A, IN_BINDTYPE_PLAYER12, 6 }, /* A */
  69. { KEY_ENTER, IN_BINDTYPE_PLAYER12, 7 },
  70. { KEY_BACKSLASH, IN_BINDTYPE_EMU, PEVB_MENU },
  71. { KEY_SPACE, IN_BINDTYPE_EMU, PEVB_MENU },
  72. /* Pandora */
  73. { KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, 4 },
  74. { KEY_END, IN_BINDTYPE_PLAYER12, 5 },
  75. { KEY_HOME, IN_BINDTYPE_PLAYER12, 6 },
  76. { KEY_LEFTALT, IN_BINDTYPE_PLAYER12, 7 },
  77. { KEY_RIGHTSHIFT,IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
  78. { KEY_RIGHTCTRL, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
  79. { KEY_LEFTCTRL, IN_BINDTYPE_EMU, PEVB_MENU },
  80. { 0, 0, 0 }
  81. };
  82. static int get_cpu_clock(void)
  83. {
  84. FILE *f;
  85. int ret = 0;
  86. f = fopen("/proc/pandora/cpu_mhz_max", "r");
  87. if (f) {
  88. fscanf(f, "%d", &ret);
  89. fclose(f);
  90. }
  91. return ret;
  92. }
  93. void pemu_prep_defconfig(void)
  94. {
  95. defaultConfig.EmuOpt |= EOPT_VSYNC|EOPT_16BPP;
  96. defaultConfig.s_PicoOpt |= POPT_EN_MCD_GFX|POPT_EN_MCD_PSYNC;
  97. defaultConfig.scaling = SCALE_2x2_3x2;
  98. }
  99. void pemu_validate_config(void)
  100. {
  101. currentConfig.CPUclock = get_cpu_clock();
  102. }
  103. static void osd_text(int x, int y, const char *text)
  104. {
  105. int len = strlen(text)*8;
  106. int i, h;
  107. len++;
  108. for (h = 0; h < 8; h++) {
  109. unsigned short *p;
  110. p = (unsigned short *)g_screen_ptr + x + g_screen_width*(y + h);
  111. for (i = len; i; i--, p++)
  112. *p = (*p>>2) & 0x39e7;
  113. }
  114. emu_text_out16(x, y, text);
  115. }
  116. static void draw_cd_leds(void)
  117. {
  118. int old_reg;
  119. old_reg = Pico_mcd->s68k_regs[0];
  120. if (0) {
  121. // 8-bit modes
  122. unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;
  123. unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;
  124. *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+ 4) =
  125. *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+ 4) =
  126. *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+ 4) = col_g;
  127. *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+12) =
  128. *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+12) =
  129. *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+12) = col_r;
  130. } else {
  131. // 16-bit modes
  132. unsigned int *p = (unsigned int *)((short *)g_screen_ptr + g_screen_width*2+4);
  133. unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;
  134. unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;
  135. *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;
  136. *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;
  137. *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;
  138. }
  139. }
  140. static int emuscan(unsigned int num)
  141. {
  142. DrawLineDest = (unsigned short *)g_screen_ptr + num * g_screen_width;
  143. return 0;
  144. }
  145. void pemu_finalize_frame(const char *fps, const char *notice)
  146. {
  147. if (notice && notice[0])
  148. osd_text(2, g_osd_y, notice);
  149. if (fps && fps[0] && (currentConfig.EmuOpt & EOPT_SHOW_FPS))
  150. osd_text(g_osd_fps_x, g_osd_y, fps);
  151. if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))
  152. draw_cd_leds();
  153. }
  154. void plat_video_flip(void)
  155. {
  156. g_screen_ptr = vout_fbdev_flip(layer_fb);
  157. // XXX: drain OS event queue here, maybe we'll actually use it someday..
  158. int dummy;
  159. xenv_update(&dummy);
  160. }
  161. void plat_video_toggle_renderer(int change, int is_menu)
  162. {
  163. }
  164. void plat_video_menu_enter(int is_rom_loaded)
  165. {
  166. }
  167. void plat_video_menu_begin(void)
  168. {
  169. }
  170. void plat_video_menu_end(void)
  171. {
  172. g_menuscreen_ptr = vout_fbdev_flip(main_fb);
  173. }
  174. void plat_video_wait_vsync(void)
  175. {
  176. vout_fbdev_wait_vsync(main_fb);
  177. }
  178. void plat_status_msg_clear(void)
  179. {
  180. vout_fbdev_clear_lines(layer_fb, g_osd_y, 8);
  181. }
  182. void plat_status_msg_busy_next(const char *msg)
  183. {
  184. plat_status_msg_clear();
  185. pemu_finalize_frame("", msg);
  186. plat_video_flip();
  187. emu_status_msg("");
  188. reset_timing = 1;
  189. }
  190. void plat_status_msg_busy_first(const char *msg)
  191. {
  192. plat_status_msg_busy_next(msg);
  193. }
  194. void plat_update_volume(int has_changed, int is_up)
  195. {
  196. static int prev_frame = 0, wait_frames = 0;
  197. int vol = currentConfig.volume;
  198. if (has_changed)
  199. {
  200. if (is_up) {
  201. if (vol < 99) vol++;
  202. } else {
  203. if (vol > 0) vol--;
  204. }
  205. wait_frames = 0;
  206. sndout_oss_setvol(vol, vol);
  207. currentConfig.volume = vol;
  208. emu_status_msg("VOL: %02i", vol);
  209. prev_frame = Pico.m.frame_count;
  210. }
  211. }
  212. static void make_bg(int no_scale)
  213. {
  214. unsigned short *s = (void *)fb_copy;
  215. int x, y;
  216. memset32(g_menubg_src_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2 / 4);
  217. if (!no_scale && g_menuscreen_w >= 640 && g_menuscreen_h >= 480) {
  218. unsigned int t, *d = g_menubg_src_ptr;
  219. d += (g_menuscreen_h / 2 - 480 / 2) * g_menuscreen_w / 2;
  220. d += (g_menuscreen_w / 2 - 640 / 2) / 2;
  221. for (y = 0; y < 240; y++, s += 320, d += g_menuscreen_w*2/2) {
  222. for (x = 0; x < 320; x++) {
  223. t = s[x];
  224. t |= t << 16;
  225. d[x] = d[x + g_menuscreen_w / 2] = t;
  226. }
  227. }
  228. return;
  229. }
  230. if (g_menuscreen_w >= 320 && g_menuscreen_h >= 240) {
  231. unsigned short *d = g_menubg_src_ptr;
  232. d += (g_menuscreen_h / 2 - 240 / 2) * g_menuscreen_w;
  233. d += (g_menuscreen_w / 2 - 320 / 2);
  234. for (y = 0; y < 240; y++, s += 320, d += g_menuscreen_w)
  235. memcpy(d, s, 320*2);
  236. return;
  237. }
  238. }
  239. void pemu_forced_frame(int no_scale, int do_emu)
  240. {
  241. doing_bg_frame = 1;
  242. emu_cmn_forced_frame(no_scale, do_emu);
  243. doing_bg_frame = 0;
  244. // making a copy because enabling the layer clears it's mem
  245. memcpy32((void *)fb_copy, g_screen_ptr, sizeof(fb_copy) / 4);
  246. make_bg(no_scale);
  247. }
  248. static void oss_write_nonblocking(int len)
  249. {
  250. // sndout_oss_can_write() is not reliable, only use with no_frmlimit
  251. if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))
  252. return;
  253. sndout_oss_write_nb(PsndOut, len);
  254. }
  255. void pemu_sound_start(void)
  256. {
  257. PsndOut = NULL;
  258. if (currentConfig.EmuOpt & EOPT_EN_SOUND)
  259. {
  260. int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;
  261. PsndRerate(Pico.m.frame_count ? 1 : 0);
  262. /*
  263. * for 44k stereo, we do 1470 samples/emu_frame
  264. * OMAP driver does power of 2 buffers, so we need at least 4K buffer.
  265. * The most we can lag is 1K samples, size of OMAP's McBSP FIFO,
  266. * with 2K sample buffer we might sometimes lag more than that,
  267. * thus causing underflows.
  268. */
  269. printf("starting audio: %i len: %i stereo: %i, pal: %i\n",
  270. PsndRate, PsndLen, is_stereo, Pico.m.pal);
  271. sndout_oss_start(PsndRate, is_stereo, 2);
  272. //sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
  273. PicoWriteSound = oss_write_nonblocking;
  274. plat_update_volume(0, 0);
  275. memset(sndBuffer, 0, sizeof(sndBuffer));
  276. PsndOut = sndBuffer;
  277. }
  278. }
  279. void pemu_sound_stop(void)
  280. {
  281. sndout_oss_stop();
  282. }
  283. void pemu_sound_wait(void)
  284. {
  285. // don't need to do anything, writes will block by themselves
  286. }
  287. void plat_debug_cat(char *str)
  288. {
  289. }
  290. static int pnd_setup_layer_(int fd, int enabled, int x, int y, int w, int h)
  291. {
  292. struct omapfb_plane_info pi;
  293. struct omapfb_mem_info mi;
  294. int ret;
  295. ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi);
  296. if (ret != 0) {
  297. perror("QUERY_PLANE");
  298. return -1;
  299. }
  300. ret = ioctl(fd, OMAPFB_QUERY_MEM, &mi);
  301. if (ret != 0) {
  302. perror("QUERY_MEM");
  303. return -1;
  304. }
  305. /* must disable when changing stuff */
  306. if (pi.enabled) {
  307. pi.enabled = 0;
  308. ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
  309. if (ret != 0)
  310. perror("SETUP_PLANE");
  311. }
  312. mi.size = 320*240*2*4;
  313. ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi);
  314. if (ret != 0) {
  315. perror("SETUP_MEM");
  316. return -1;
  317. }
  318. pi.pos_x = x;
  319. pi.pos_y = y;
  320. pi.out_width = w;
  321. pi.out_height = h;
  322. pi.enabled = enabled;
  323. ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
  324. if (ret != 0) {
  325. perror("SETUP_PLANE");
  326. return -1;
  327. }
  328. return 0;
  329. }
  330. int pnd_setup_layer(int enabled, int x, int y, int w, int h)
  331. {
  332. return pnd_setup_layer_(vout_fbdev_get_fd(layer_fb), enabled, x, y, w, h);
  333. }
  334. void pnd_restore_layer_data(void)
  335. {
  336. short *t = (short *)fb_copy + 320*240 / 2 + 160;
  337. // right now this is used by menu, which wants to preview something
  338. // so try to get something on the layer.
  339. if ((t[0] | t[5] | t[13]) == 0)
  340. memset32((void *)fb_copy, 0x07000700, sizeof(fb_copy) / 4);
  341. memcpy32(g_screen_ptr, (void *)fb_copy, 320*240*2 / 4);
  342. plat_video_flip();
  343. }
  344. static void apply_filter(int which)
  345. {
  346. char buf[128];
  347. int i;
  348. if (pnd_filter_list == NULL)
  349. return;
  350. for (i = 0; i < which; i++)
  351. if (pnd_filter_list[i] == NULL)
  352. return;
  353. if (pnd_filter_list[i] == NULL)
  354. return;
  355. snprintf(buf, sizeof(buf), "%s/op_videofir.sh %s", pnd_script_base, pnd_filter_list[i]);
  356. system(buf);
  357. }
  358. void emu_video_mode_change(int start_line, int line_count, int is_32cols)
  359. {
  360. int fb_w = 320, fb_h = 240, fb_left = 0, fb_right = 0, fb_top = 0, fb_bottom = 0;
  361. if (doing_bg_frame)
  362. return;
  363. PicoDrawSetOutFormat(PDF_RGB555, 1);
  364. PicoDrawSetCallbacks(emuscan, NULL);
  365. if (is_32cols) {
  366. fb_w = 256;
  367. fb_left = fb_right = 32;
  368. }
  369. switch (currentConfig.scaling) {
  370. case SCALE_1x1:
  371. g_layer_w = fb_w;
  372. g_layer_h = fb_h;
  373. break;
  374. case SCALE_2x2_3x2:
  375. g_layer_w = fb_w * (is_32cols ? 3 : 2);
  376. g_layer_h = fb_h * 2;
  377. break;
  378. case SCALE_2x2_2x2:
  379. g_layer_w = fb_w * 2;
  380. g_layer_h = fb_h * 2;
  381. break;
  382. case SCALE_FULLSCREEN:
  383. g_layer_w = 800;
  384. g_layer_h = 480;
  385. break;
  386. case SCALE_CUSTOM:
  387. g_layer_x = g_layer_cx;
  388. g_layer_y = g_layer_cy;
  389. g_layer_w = g_layer_cw;
  390. g_layer_h = g_layer_ch;
  391. break;
  392. }
  393. if (currentConfig.scaling != SCALE_CUSTOM) {
  394. // center the layer
  395. g_layer_x = 800 / 2 - g_layer_w / 2;
  396. g_layer_y = 480 / 2 - g_layer_h / 2;
  397. }
  398. switch (currentConfig.scaling) {
  399. case SCALE_FULLSCREEN:
  400. case SCALE_CUSTOM:
  401. fb_top = start_line;
  402. fb_h = line_count;
  403. break;
  404. }
  405. g_osd_fps_x = is_32cols ? 232 : 264;
  406. g_osd_y = fb_top + fb_h - 8;
  407. pnd_setup_layer(1, g_layer_x, g_layer_y, g_layer_w, g_layer_h);
  408. vout_fbdev_clear(layer_fb);
  409. vout_fbdev_resize(layer_fb, fb_w, fb_h, 16, fb_left, fb_right, fb_top, fb_bottom, 3);
  410. plat_video_flip();
  411. }
  412. void pemu_loop_prep(void)
  413. {
  414. static int pal_old = -1;
  415. static int filter_old = -1;
  416. char buf[128];
  417. if (currentConfig.CPUclock != get_cpu_clock()) {
  418. snprintf(buf, sizeof(buf), "unset DISPLAY; echo y | %s/op_cpuspeed.sh %d",
  419. pnd_script_base, currentConfig.CPUclock);
  420. system(buf);
  421. }
  422. if (Pico.m.pal != pal_old) {
  423. snprintf(buf, sizeof(buf), "%s/op_lcdrate.sh %d",
  424. pnd_script_base, Pico.m.pal ? 50 : 60);
  425. system(buf);
  426. pal_old = Pico.m.pal;
  427. }
  428. if (currentConfig.filter != filter_old) {
  429. apply_filter(currentConfig.filter);
  430. filter_old = currentConfig.filter;
  431. }
  432. // make sure there is no junk left behind the layer
  433. memset32(g_menuscreen_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2 / 4);
  434. g_menuscreen_ptr = vout_fbdev_flip(main_fb);
  435. // emu_video_mode_change will call pnd_setup_layer()
  436. // dirty buffers better go now than during gameplay
  437. sync();
  438. sleep(0);
  439. pemu_sound_start();
  440. }
  441. void pemu_loop_end(void)
  442. {
  443. pemu_sound_stop();
  444. /* do one more frame for menu bg */
  445. pemu_forced_frame(0, 1);
  446. pnd_setup_layer(0, g_layer_x, g_layer_y, g_layer_w, g_layer_h);
  447. }
  448. void plat_wait_till_us(unsigned int us_to)
  449. {
  450. unsigned int now;
  451. signed int diff;
  452. now = plat_get_ticks_us();
  453. // XXX: need to check NOHZ
  454. diff = (signed int)(us_to - now);
  455. if (diff > 10000) {
  456. //printf("sleep %d\n", us_to - now);
  457. usleep(diff * 15 / 16);
  458. now = plat_get_ticks_us();
  459. //printf(" wake %d\n", (signed)(us_to - now));
  460. }
  461. /*
  462. while ((signed int)(us_to - now) > 512) {
  463. spend_cycles(1024);
  464. now = plat_get_ticks_us();
  465. }
  466. */
  467. }
  468. void plat_early_init(void)
  469. {
  470. }
  471. void plat_init(void)
  472. {
  473. const char *main_fb_name, *layer_fb_name;
  474. int fd, ret, w, h;
  475. main_fb_name = getenv("FBDEV_MAIN");
  476. if (main_fb_name == NULL)
  477. main_fb_name = "/dev/fb0";
  478. layer_fb_name = getenv("FBDEV_LAYER");
  479. if (layer_fb_name == NULL)
  480. layer_fb_name = "/dev/fb1";
  481. // must set the layer up first to be able to use it
  482. fd = open(layer_fb_name, O_RDWR);
  483. if (fd == -1) {
  484. fprintf(stderr, "%s: ", layer_fb_name);
  485. perror("open");
  486. exit(1);
  487. }
  488. ret = pnd_setup_layer_(fd, 0, g_layer_x, g_layer_y, g_layer_w, g_layer_h);
  489. close(fd);
  490. if (ret != 0) {
  491. fprintf(stderr, "failed to set up layer, exiting.\n");
  492. exit(1);
  493. }
  494. xenv_init();
  495. w = h = 0;
  496. main_fb = vout_fbdev_init(main_fb_name, &w, &h, 16, 2);
  497. if (main_fb == NULL) {
  498. fprintf(stderr, "couldn't init fb: %s\n", main_fb_name);
  499. exit(1);
  500. }
  501. g_menuscreen_w = w;
  502. g_menuscreen_h = h;
  503. g_menuscreen_ptr = vout_fbdev_flip(main_fb);
  504. w = 320; h = 240;
  505. layer_fb = vout_fbdev_init(layer_fb_name, &w, &h, 16, 3);
  506. if (layer_fb == NULL) {
  507. fprintf(stderr, "couldn't init fb: %s\n", layer_fb_name);
  508. goto fail0;
  509. }
  510. if (w != g_screen_width || h != g_screen_height) {
  511. fprintf(stderr, "%dx%d not supported on %s\n", w, h, layer_fb_name);
  512. goto fail1;
  513. }
  514. g_screen_ptr = vout_fbdev_flip(layer_fb);
  515. temp_frame = calloc(g_menuscreen_w * g_menuscreen_h * 2, 1);
  516. if (temp_frame == NULL) {
  517. fprintf(stderr, "OOM\n");
  518. goto fail1;
  519. }
  520. g_menubg_ptr = temp_frame;
  521. g_menubg_src_ptr = temp_frame;
  522. PicoDraw2FB = temp_frame;
  523. sndout_oss_init();
  524. pnd_menu_init();
  525. in_set_config(in_name_to_id("evdev:gpio-keys"), IN_CFG_KEY_NAMES,
  526. pandora_gpio_keys, sizeof(pandora_gpio_keys));
  527. return;
  528. fail1:
  529. vout_fbdev_finish(layer_fb);
  530. fail0:
  531. vout_fbdev_finish(main_fb);
  532. exit(1);
  533. }
  534. void plat_finish(void)
  535. {
  536. sndout_oss_exit();
  537. vout_fbdev_finish(main_fb);
  538. xenv_finish();
  539. printf("all done\n");
  540. }