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;
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;
}
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;
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;
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,