From: notaz Date: Thu, 30 Dec 2010 23:24:56 +0000 (+0000) Subject: fbdev: resize: do single ioctl in nonerror path X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c2179d3563c9425270dee114167e7149528e8bd;p=libpicofe.git fbdev: resize: do single ioctl in nonerror path git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@913 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/linux/fbdev.c b/linux/fbdev.c index bcef0fc..da73b1a 100644 --- a/linux/fbdev.c +++ b/linux/fbdev.c @@ -74,43 +74,45 @@ void *vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, ioctl(fbdev->fd, FBIOBLANK, FB_BLANK_UNBLANK); if (fbdev->fbvar_new.bits_per_pixel != bpp || - w != fbdev->fbvar_new.xres || - h != fbdev->fbvar_new.yres || - w_total != fbdev->fbvar_new.xres_virtual || - h_total > fbdev->fbvar_new.yres_virtual || - left_border != fbdev->fbvar_new.xoffset) { + fbdev->fbvar_new.xres != w || + fbdev->fbvar_new.yres != h || + fbdev->fbvar_new.xres_virtual != w_total|| + fbdev->fbvar_new.yres_virtual < h_total || + fbdev->fbvar_new.xoffset != left_border || + fbdev->buffer_count != buffer_cnt) + { + if (fbdev->fbvar_new.bits_per_pixel != bpp || + w != fbdev->fbvar_new.xres || h != fbdev->fbvar_new.yres) + printf(" switching to %dx%d@%d\n", w, h, bpp); + fbdev->fbvar_new.xres = w; fbdev->fbvar_new.yres = h; fbdev->fbvar_new.xres_virtual = w_total; - fbdev->fbvar_new.yres_virtual = h_total; + fbdev->fbvar_new.yres_virtual = h_total * buffer_cnt; fbdev->fbvar_new.xoffset = left_border; fbdev->fbvar_new.yoffset = top_border; fbdev->fbvar_new.bits_per_pixel = bpp; - printf(" switching to %dx%d@%d\n", w, h, bpp); + fbdev->buffer_count = buffer_cnt; + fbdev->buffer_write = 1; // seems to help a bit to avoid glitches vout_fbdev_wait_vsync(fbdev); ret = ioctl(fbdev->fd, FBIOPUT_VSCREENINFO, &fbdev->fbvar_new); if (ret == -1) { - perror("FBIOPUT_VSCREENINFO ioctl"); - return NULL; - } - - fbdev->buffer_write = 1; - } - - fbdev->buffer_count = buffer_cnt; - - if (fbdev->fbvar_new.yres_virtual < h_total * fbdev->buffer_count) { - fbdev->fbvar_new.yres_virtual = h_total * fbdev->buffer_count; - ret = ioctl(fbdev->fd, FBIOPUT_VSCREENINFO, &fbdev->fbvar_new); - if (ret == -1) { + // retry with no multibuffering + fbdev->fbvar_new.yres_virtual = h_total; + ret = ioctl(fbdev->fd, FBIOPUT_VSCREENINFO, &fbdev->fbvar_new); + if (ret == -1) { + perror("FBIOPUT_VSCREENINFO ioctl"); + return NULL; + } fbdev->buffer_count = 1; fbdev->buffer_write = 0; fprintf(stderr, "Warning: failed to increase virtual resolution, " - "doublebuffering disabled\n"); + "multibuffering disabled\n"); } + } fbdev->fb_size = w_total * h_total * bpp / 8; @@ -126,8 +128,9 @@ void *vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, fbdev->mem = mmap(0, mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev->fd, 0); if (fbdev->mem == MAP_FAILED && fbdev->buffer_count > 1) { - fprintf(stderr, "Warning: can't map %zd bytes, doublebuffering disabled\n", fbdev->mem_size); + fprintf(stderr, "Warning: can't map %zd bytes, doublebuffering disabled\n", mem_size); fbdev->buffer_count = 1; + fbdev->buffer_write = 0; mem_size = fbdev->fb_size; fbdev->mem = mmap(0, mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev->fd, 0); }