struct omapfb_mem_info mi;
int ret;
+ memset(&pi, 0, sizeof(pi));
+ memset(&mi, 0, sizeof(mi));
+
ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi);
if (ret != 0) {
err_perror("QUERY_PLANE");
return 0;
}
+int read_vscreeninfo(const char *fbname, int *w, int *h)
+{
+ struct fb_var_screeninfo fbvar;
+ int ret, fd;
+
+ fd = open(fbname, O_RDWR);
+ if (fd == -1) {
+ err_perror("open %s", fbname);
+ return -1;
+ }
+
+ ret = ioctl(fd, FBIOGET_VSCREENINFO, &fbvar);
+ close(fd);
+
+ if (ret == -1) {
+ err_perror("ioctl %s", fbname);
+ return -1;
+ }
+
+ if (fbvar.xres == 0 || fbvar.yres == 0)
+ return -1;
+
+ *w = fbvar.xres;
+ *h = fbvar.yres;
+ return 0;
+}
+
int osdl_video_detect_screen(struct SDL_PrivateVideoData *pdata)
{
int fb_id, overlay_id = -1, screen_id = -1;
- struct fb_var_screeninfo fbvar;
char buff[64], screen_name[64];
const char *fbname;
struct stat status;
int w, h;
FILE *f;
+ pdata->phys_w = pdata->phys_h = 0;
+
fbname = get_fb_device();
/* Figure out screen resolution, we need to know default resolution
log("detected %dx%d '%s' (%d) screen attached to fb %d and overlay %d",
w, h, screen_name, screen_id, fb_id, overlay_id);
- pdata->screen_w = w;
- pdata->screen_h = h;
+ pdata->phys_w = w;
+ pdata->phys_h = h;
return 0;
skip_screen:
/* attempt to extract this from FB then */
- fd = open(fbname, O_RDWR);
- if (fd == -1) {
- err_perror("open %s", fbname);
- return -1;
+ ret = read_vscreeninfo(fbname, &pdata->phys_w, &pdata->phys_h);
+ if (ret != 0 && strcmp(fbname, "/dev/fb0") != 0) {
+ /* last resort */
+ ret = read_vscreeninfo("/dev/fb0", &pdata->phys_w, &pdata->phys_h);
}
- ret = ioctl(fd, FBIOGET_VSCREENINFO, &fbvar);
- close(fd);
- if (ret == -1) {
- err_perror("ioctl %s", fbname);
- return -1;
- }
-
- if (fbvar.xres == 0 || fbvar.yres == 0) {
+ if (ret != 0) {
err("VSCREENINFO has nothing meaningful");
return -1;
}
- pdata->screen_w = fbvar.xres;
- pdata->screen_h = fbvar.yres;
return 0;
}
int screen_w = w, screen_h = h;
int tmp_w, tmp_h;
const char *tmp;
+ int retval = -1;
int ret, fd;
- if (pdata->screen_w != 0)
- screen_w = pdata->screen_w;
- if (pdata->screen_h != 0)
- screen_h = pdata->screen_h;
+ pdata->layer_x = pdata->layer_y = pdata->layer_w = pdata->layer_h = 0;
+
+ if (pdata->phys_w != 0)
+ screen_w = pdata->phys_w;
+ if (pdata->phys_h != 0)
+ screen_h = pdata->phys_h;
fd = open(fbname, O_RDWR);
if (fd == -1) {
struct omapfb_saved_layer *slayer;
slayer = calloc(1, sizeof(*slayer));
if (slayer == NULL)
- return -1;
+ goto out;
ret = ioctl(fd, OMAPFB_QUERY_PLANE, &slayer->pi);
if (ret != 0) {
err_perror("QUERY_PLANE");
- return -1;
+ goto out;
}
ret = ioctl(fd, OMAPFB_QUERY_MEM, &slayer->mi);
if (ret != 0) {
err_perror("QUERY_MEM");
- return -1;
+ goto out;
}
pdata->saved_layer = slayer;
err("layer size specified incorrectly, "
"should be like 800x480");
}
- else {
- /* the layer can't be set larger than screen */
- tmp_w = w, tmp_h = h;
- if (w > screen_w)
- w = screen_w;
- if (h > screen_h)
- h = screen_h;
- if (w != tmp_w || h != tmp_h)
- log("layer resized %dx%d -> %dx%d to fit screen", tmp_w, tmp_h, w, h);
- }
+
+ /* the layer can't be set larger than screen */
+ tmp_w = w, tmp_h = h;
+ if (w > screen_w)
+ w = screen_w;
+ if (h > screen_h)
+ h = screen_h;
+ if (w != tmp_w || h != tmp_h)
+ log("layer resized %dx%d -> %dx%d to fit screen", tmp_w, tmp_h, w, h);
x = screen_w / 2 - w / 2;
y = screen_h / 2 - h / 2;
ret = osdl_setup_omapfb(fd, 1, x, y, w, h, width * height * ((bpp + 7) / 8) * 2);
- close(fd);
+ if (ret == 0) {
+ pdata->layer_x = x;
+ pdata->layer_y = y;
+ pdata->layer_w = w;
+ pdata->layer_h = h;
+ }
- return ret;
+ retval = ret;
+out:
+ close(fd);
+ return retval;
}
-int osdl_video_set_mode(struct SDL_PrivateVideoData *pdata,
- int width, int height, int bpp, int doublebuf)
+void *osdl_video_set_mode(struct SDL_PrivateVideoData *pdata,
+ int border_l, int border_r, int border_t, int border_b,
+ int width, int height, int bpp, int doublebuf)
{
const char *fbname;
+ void *result;
int ret;
fbname = get_fb_device();
ret = osdl_setup_omap_layer(pdata, fbname, width, height, bpp);
if (ret < 0)
- return -1;
+ return NULL;
pdata->fbdev = vout_fbdev_init(fbname, &width, &height, bpp, doublebuf ? 2 : 1);
if (pdata->fbdev == NULL)
- return -1;
+ return NULL;
+
+ if (border_l | border_r | border_t | border_b) {
+ width -= border_l + border_r;
+ height -= border_t + border_b;
+ result = vout_fbdev_resize(pdata->fbdev, width, height, bpp,
+ border_l, border_r, border_t, border_b, doublebuf ? 2 : 1);
+ }
+ else {
+ result = osdl_video_flip(pdata);
+ }
+ if (result == NULL) {
+ osdl_video_finish(pdata);
+ return NULL;
+ }
if (!pdata->xenv_up) {
ret = xenv_init();
pdata->xenv_up = 1;
}
- return 0;
+ return result;
}
void *osdl_video_flip(struct SDL_PrivateVideoData *pdata)
if (pdata->fbdev == NULL)
return NULL;
- if (gcfg_force_vsync)
+ if (pdata->cfg_force_vsync)
vout_fbdev_wait_vsync(pdata->fbdev);
return vout_fbdev_flip(pdata->fbdev);