X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvideo%2Fomapdss%2Fosdl_video.c;h=764b857bd932cd265228ca49b52659869fc1fa1b;hb=f11c56a62f5d270a7aea3e7d63c00bda01191a78;hp=6cd7b31e65f3e3521bcdc98bfb44acbde3d88b6b;hpb=b9a19b44575168f01926c0b99289a50f334447cf;p=sdl_omap.git diff --git a/src/video/omapdss/osdl_video.c b/src/video/omapdss/osdl_video.c index 6cd7b31..764b857 100644 --- a/src/video/omapdss/osdl_video.c +++ b/src/video/omapdss/osdl_video.c @@ -1,5 +1,5 @@ /* - * (C) Gražvydas "notaz" Ignotas, 2010 + * (C) Gražvydas "notaz" Ignotas, 2010-2011 * * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING file in the top-level directory. @@ -20,7 +20,7 @@ #include "omapsdl.h" #include "omapfb.h" #include "linux/fbdev.h" -#include "linux/oshide.h" +#include "linux/xenv.h" struct omapfb_saved_layer { struct omapfb_plane_info pi; @@ -42,6 +42,9 @@ static int osdl_setup_omapfb(int fd, int enabled, int x, int y, int w, int h, in 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"); @@ -62,11 +65,13 @@ static int osdl_setup_omapfb(int fd, int enabled, int x, int y, int w, int h, in err_perror("SETUP_PLANE"); } - mi.size = mem; - ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi); - if (ret != 0) { - err_perror("SETUP_MEM"); - return -1; + if (mi.size < mem) { + mi.size = mem; + ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi); + if (ret != 0) { + err_perror("SETUP_MEM"); + return -1; + } } pi.pos_x = x; @@ -78,6 +83,7 @@ static int osdl_setup_omapfb(int fd, int enabled, int x, int y, int w, int h, in ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi); if (ret != 0) { err_perror("SETUP_PLANE"); + err("(%d %d %d %d)\n", x, y, w, h); return -1; } @@ -120,6 +126,8 @@ int osdl_video_detect_screen(struct SDL_PrivateVideoData *pdata) 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 @@ -187,8 +195,8 @@ int osdl_video_detect_screen(struct SDL_PrivateVideoData *pdata) 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: @@ -211,8 +219,8 @@ skip_screen: return -1; } - pdata->screen_w = fbvar.xres; - pdata->screen_h = fbvar.yres; + pdata->phys_w = fbvar.xres; + pdata->phys_h = fbvar.yres; return 0; } @@ -221,13 +229,17 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, { int x = 0, y = 0, w = width, h = height; /* layer size and pos */ 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) { @@ -240,18 +252,18 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, 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; @@ -259,31 +271,48 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, tmp = getenv("SDL_OMAP_LAYER_SIZE"); if (tmp != NULL) { - int w_, h_; if (strcasecmp(tmp, "fullscreen") == 0) w = screen_w, h = screen_h; - else if (sscanf(tmp, "%dx%d", &w_, &h_) == 2) - w = w_, h = h_; + else if (sscanf(tmp, "%dx%d", &tmp_w, &tmp_h) == 2) + w = tmp_w, h = tmp_h; else err("layer size specified incorrectly, " "should be like 800x480"); } + /* 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) * 3); - close(fd); + ret = osdl_setup_omapfb(fd, 1, x, y, w, h, width * height * ((bpp + 7) / 8) * 2); + 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) +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; - bpp = 16; // FIXME - fbname = get_fb_device(); if (pdata->fbdev != NULL) { @@ -291,22 +320,35 @@ int osdl_video_set_mode(struct SDL_PrivateVideoData *pdata, int width, int heigh pdata->fbdev = NULL; } - omapsdl_config_from_env(); - 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, 0); + pdata->fbdev = vout_fbdev_init(fbname, &width, &height, bpp, doublebuf ? 2 : 1); if (pdata->fbdev == NULL) - return -1; + return NULL; - if (!pdata->oshide_done) { - oshide_init(); - pdata->oshide_done = 1; + 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; } - return 0; + if (!pdata->xenv_up) { + ret = xenv_init(); + if (ret == 0) + pdata->xenv_up = 1; + } + + return result; } void *osdl_video_flip(struct SDL_PrivateVideoData *pdata) @@ -314,7 +356,7 @@ 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); @@ -353,9 +395,9 @@ void osdl_video_finish(struct SDL_PrivateVideoData *pdata) pdata->saved_layer = NULL; } - if (pdata->oshide_done) { - oshide_finish(); - pdata->oshide_done = 0; + if (pdata->xenv_up) { + xenv_finish(); + pdata->xenv_up = 0; } }