4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
10 #include <sys/types.h>
13 #include <sys/ioctl.h>
15 #include <linux/omapfb.h>
17 #include "common/menu.h"
18 #include "linux/fbdev.h"
19 #include "linux/oshide.h"
20 #include "plugin_lib.h"
25 static struct vout_fbdev *main_fb;
26 int g_layer_x = 80, g_layer_y = 0;
27 int g_layer_w = 640, g_layer_h = 480;
29 struct vout_fbdev *layer_fb;
31 static int omap_setup_layer_(int fd, int enabled, int x, int y, int w, int h, int first_call)
33 struct omapfb_plane_info pi = { 0, };
34 struct omapfb_mem_info mi = { 0, };
37 ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi);
39 perror("QUERY_PLANE");
43 ret = ioctl(fd, OMAPFB_QUERY_MEM, &mi);
49 /* must disable when changing stuff */
52 ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
54 perror("SETUP_PLANE");
58 mi.size = 640*512*3*3;
59 ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi);
72 ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
74 perror("SETUP_PLANE");
81 int omap_enable_layer(int enabled)
83 return omap_setup_layer_(vout_fbdev_get_fd(layer_fb), enabled,
84 g_layer_x, g_layer_y, g_layer_w, g_layer_h, 0);
87 void plat_video_menu_enter(int is_rom_loaded)
89 g_menuscreen_ptr = vout_fbdev_resize(main_fb,
90 g_menuscreen_w, g_menuscreen_h, 16, 0, 0, 0, 0, 3);
91 if (g_menuscreen_ptr == NULL)
92 fprintf(stderr, "warning: vout_fbdev_resize failed\n");
95 void plat_video_menu_begin(void)
99 void plat_video_menu_end(void)
101 g_menuscreen_ptr = vout_fbdev_flip(main_fb);
104 void plat_video_menu_leave(void)
106 /* have to get rid of panning so that plugins that
107 * use fb0 and don't ever pan can work. */
108 vout_fbdev_clear(main_fb);
109 g_menuscreen_ptr = vout_fbdev_resize(main_fb,
110 g_menuscreen_w, g_menuscreen_h, 16, 0, 0, 0, 0, 1);
111 if (g_menuscreen_ptr == NULL)
112 fprintf(stderr, "warning: vout_fbdev_resize failed\n");
117 const char *main_fb_name, *layer_fb_name;
121 main_fb_name = getenv("FBDEV_MAIN");
122 if (main_fb_name == NULL)
123 main_fb_name = "/dev/fb0";
125 layer_fb_name = getenv("FBDEV_LAYER");
126 if (layer_fb_name == NULL)
127 layer_fb_name = "/dev/fb1";
129 // must set the layer up first to be able to use it
130 fd = open(layer_fb_name, O_RDWR);
132 fprintf(stderr, "%s: ", layer_fb_name);
137 ret = omap_setup_layer_(fd, 0, g_layer_x, g_layer_y, g_layer_w, g_layer_h, 1);
140 fprintf(stderr, "failed to set up layer, exiting.\n");
147 main_fb = vout_fbdev_init(main_fb_name, &w, &h, 16, 2);
148 if (main_fb == NULL) {
149 fprintf(stderr, "couldn't init fb: %s\n", main_fb_name);
155 g_menuscreen_ptr = vout_fbdev_flip(main_fb);
159 layer_fb = vout_fbdev_init(layer_fb_name, &w, &h, 16, 3);
160 if (layer_fb == NULL) {
161 fprintf(stderr, "couldn't init fb: %s\n", layer_fb_name);
165 temp_frame = calloc(g_menuscreen_w * g_menuscreen_h * 2, 1);
166 if (temp_frame == NULL) {
167 fprintf(stderr, "OOM\n");
170 g_menubg_ptr = temp_frame;
173 pandora_rescan_inputs();
178 vout_fbdev_finish(layer_fb);
180 vout_fbdev_finish(main_fb);
185 void plat_finish(void)
187 omap_enable_layer(0);
188 vout_fbdev_finish(layer_fb);
189 vout_fbdev_finish(main_fb);