X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvideo%2Fomapdss%2Fosdl_video.c;h=fc5e6677c8bdb37a360dfb01460a0c9b4d761769;hb=34edc246b9d81a1bbb3a60733d84db327859a362;hp=2c2226455c3005a144dd5dd86f04ddc409c768a4;hpb=455c8c43b353b60ebbb70caa09ae87be49520838;p=sdl_omap.git diff --git a/src/video/omapdss/osdl_video.c b/src/video/omapdss/osdl_video.c index 2c22264..fc5e667 100644 --- a/src/video/omapdss/osdl_video.c +++ b/src/video/omapdss/osdl_video.c @@ -115,10 +115,36 @@ static int read_sysfs(const char *fname, char *buff, size_t size) 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; @@ -201,26 +227,17 @@ int osdl_video_detect_screen(struct SDL_PrivateVideoData *pdata) 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 = ioctl(fd, FBIOGET_VSCREENINFO, &fbvar); - close(fd); - if (ret == -1) { - err_perror("ioctl %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); } - if (fbvar.xres == 0 || fbvar.yres == 0) { + if (ret != 0) { err("VSCREENINFO has nothing meaningful"); return -1; } - pdata->phys_w = fbvar.xres; - pdata->phys_h = fbvar.yres; return 0; } @@ -231,6 +248,7 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, int screen_w = w, screen_h = h; int tmp_w, tmp_h; const char *tmp; + int retval = -1; int ret, fd; pdata->layer_x = pdata->layer_y = pdata->layer_w = pdata->layer_h = 0; @@ -251,18 +269,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; @@ -278,16 +296,15 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, 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; @@ -298,9 +315,11 @@ static int osdl_setup_omap_layer(struct SDL_PrivateVideoData *pdata, pdata->layer_w = w; pdata->layer_h = h; } - close(fd); - return ret; + retval = ret; +out: + close(fd); + return retval; } void *osdl_video_set_mode(struct SDL_PrivateVideoData *pdata,