aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-04-23 04:55:35 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-04-23 05:30:45 (GMT)
commitdf0903e41a99ec125ab7c10c264c478a101c526c (patch)
treef6e6a7ca5967a31bee7690bc472d19839a827c42
parentecf003c4e11ce67b52b748e90711d03f49b718c8 (diff)
Better handle DGA support
This patch were imported from Fedora 12 set of patches for xawtv. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--console/v4l-conf.c24
-rw-r--r--libng/plugins/drv0-v4l2.c2
-rw-r--r--x11/xt.c23
3 files changed, 45 insertions, 4 deletions
diff --git a/console/v4l-conf.c b/console/v4l-conf.c
index fd9919f..3d51d4f 100644
--- a/console/v4l-conf.c
+++ b/console/v4l-conf.c
@@ -221,6 +221,21 @@ displayinfo_x11(Display *dpy, struct DISPLAYINFO *d)
}
}
+#ifdef HAVE_LIBXXF86DGA
+static int dga_error = 0;
+static int dga_error_base;
+static int (*orig_xfree_error_handler)(Display *, XErrorEvent *);
+
+static int dga_error_handler(Display *d, XErrorEvent *e)
+{
+ if (e->error_code == (dga_error_base + XF86DGANoDirectVideoMode)) {
+ dga_error = 1;
+ return 0;
+ }
+ return orig_xfree_error_handler(d, e);
+}
+#endif
+
static void
displayinfo_dga(Display *dpy, struct DISPLAYINFO *d)
{
@@ -228,7 +243,7 @@ displayinfo_dga(Display *dpy, struct DISPLAYINFO *d)
int width,bar,foo,major,minor,flags=0;
void *base = NULL;
- if (!XF86DGAQueryExtension(dpy,&foo,&bar)) {
+ if (!XF86DGAQueryExtension(dpy,&foo,&dga_error_base)) {
fprintf(stderr,"WARNING: Your X-Server has no DGA support.\n");
return;
}
@@ -240,7 +255,14 @@ displayinfo_dga(Display *dpy, struct DISPLAYINFO *d)
fprintf(stderr,"WARNING: No DGA support available for this display.\n");
return;
}
+ orig_xfree_error_handler = XSetErrorHandler(dga_error_handler);
XF86DGAGetVideoLL(dpy,XDefaultScreen(dpy),(void*)&base,&width,&foo,&bar);
+ XSync(dpy, 0);
+ XSetErrorHandler(orig_xfree_error_handler);
+ if (dga_error) {
+ fprintf(stderr,"WARNING: No DGA direct video mode for this display.\n");
+ return;
+ }
d->bpl = width * d->bpp/8;
d->base = base;
#else
diff --git a/libng/plugins/drv0-v4l2.c b/libng/plugins/drv0-v4l2.c
index b8eb3f4..29ef804 100644
--- a/libng/plugins/drv0-v4l2.c
+++ b/libng/plugins/drv0-v4l2.c
@@ -592,7 +592,7 @@ v4l2_setupfb(void *handle, struct ng_video_fmt *fmt, void *base)
return -1;
/* double-check settings */
- if (NULL != base && h->ov_fb.base != base) {
+ if ((NULL != base && h->ov_fb.base != base) || h->ov_fb.base == NULL) {
fprintf(stderr,"v4l2: WARNING: framebuffer base address mismatch\n");
fprintf(stderr,"v4l2: me=%p v4l=%p\n",base,h->ov_fb.base);
h->ov_error = 1;
diff --git a/x11/xt.c b/x11/xt.c
index 16b2639..f9b0d74 100644
--- a/x11/xt.c
+++ b/x11/xt.c
@@ -1247,18 +1247,21 @@ FilterAction(Widget widget, XEvent *event,
}
/*----------------------------------------------------------------------*/
+#ifdef HAVE_LIBXXF86DGA
+static int xfree_dga_error_base;
+#endif
void
xfree_dga_init(Display *dpy)
{
#ifdef HAVE_LIBXXF86DGA
- int flags,foo,bar,ma,mi;
+ int flags,foo,ma,mi;
if (!do_overlay)
return;
if (args.dga) {
- if (XF86DGAQueryExtension(dpy,&foo,&bar)) {
+ if (XF86DGAQueryExtension(dpy,&foo,&xfree_dga_error_base)) {
XF86DGAQueryDirectVideo(dpy,XDefaultScreen(dpy),&flags);
if (flags & XF86DGADirectPresent) {
XF86DGAQueryVersion(dpy,&ma,&mi);
@@ -1348,6 +1351,19 @@ xfree_xinerama_init(Display *dpy)
#endif
}
+#ifdef HAVE_LIBXXF86DGA
+static int (*orig_xfree_error_handler)(Display *, XErrorEvent *);
+
+static int xfree_dga_error_handler(Display *d, XErrorEvent *e)
+{
+ if (e->error_code == (xfree_dga_error_base + XF86DGANoDirectVideoMode)) {
+ have_dga = 0;
+ return 0;
+ }
+ return orig_xfree_error_handler(d, e);
+}
+#endif
+
void
grabber_init()
{
@@ -1358,8 +1374,11 @@ grabber_init()
#ifdef HAVE_LIBXXF86DGA
if (have_dga) {
int bar,fred;
+ orig_xfree_error_handler = XSetErrorHandler(xfree_dga_error_handler);
XF86DGAGetVideoLL(dpy,XDefaultScreen(dpy),(void*)&base,
&screen.bytesperline,&bar,&fred);
+ XSync(dpy, 0);
+ XSetErrorHandler(orig_xfree_error_handler);
}
#endif
if (!do_overlay) {

Privacy Policy