summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xdpyinfo.c138
1 files changed, 77 insertions, 61 deletions
diff --git a/xdpyinfo.c b/xdpyinfo.c
index e873831..1125aa4 100644
--- a/xdpyinfo.c
+++ b/xdpyinfo.c
@@ -771,6 +771,35 @@ print_dga_info(Display *dpy, char *extname)
#define V_PCSYNC 0x080
#define V_NCSYNC 0x100
+static void
+print_XF86VidMode_modeline(
+ unsigned int dotclock,
+ unsigned short hdisplay,
+ unsigned short hsyncstart,
+ unsigned short hsyncend,
+ unsigned short htotal,
+ unsigned short vdisplay,
+ unsigned short vsyncstart,
+ unsigned short vsyncend,
+ unsigned short vtotal,
+ unsigned int flags)
+{
+ printf(" %6.2f %4d %4d %4d %4d %4d %4d %4d %4d ",
+ (float)dotclock/1000.0,
+ hdisplay, hsyncstart, hsyncend, htotal,
+ vdisplay, vsyncstart, vsyncend, vtotal);
+ if (flags & V_PHSYNC) printf(" +hsync");
+ if (flags & V_NHSYNC) printf(" -hsync");
+ if (flags & V_PVSYNC) printf(" +vsync");
+ if (flags & V_NVSYNC) printf(" -vsync");
+ if (flags & V_INTERLACE) printf(" interlace");
+ if (flags & V_CSYNC) printf(" composite");
+ if (flags & V_PCSYNC) printf(" +csync");
+ if (flags & V_NCSYNC) printf(" -csync");
+ if (flags & V_DBLSCAN) printf(" doublescan");
+ printf("\n");
+}
+
static int
print_XF86VidMode_info(Display *dpy, char *extname)
{
@@ -783,72 +812,59 @@ print_XF86VidMode_info(Display *dpy, char *extname)
return 0;
print_standard_extension_info(dpy, extname, majorrev, minorrev);
- if (!XF86VidModeGetMonitor(dpy, DefaultScreen(dpy), &monitor))
- return 0;
- printf(" Monitor Information:\n");
- printf(" Vendor: %s, Model: %s\n",
- monitor.vendor == NULL ? "" : monitor.vendor,
- monitor.model == NULL ? "" : monitor.model);
- printf(" Num hsync: %d, Num vsync: %d\n", monitor.nhsync, monitor.nvsync);
- for (i = 0; i < monitor.nhsync; i++) {
- printf(" hsync range %d: %6.2f - %6.2f\n", i, monitor.hsync[i].lo,
- monitor.hsync[i].hi);
- }
- for (i = 0; i < monitor.nvsync; i++) {
- printf(" vsync range %d: %6.2f - %6.2f\n", i, monitor.vsync[i].lo,
- monitor.vsync[i].hi);
+ if (XF86VidModeGetMonitor(dpy, DefaultScreen(dpy), &monitor)) {
+ printf(" Monitor Information:\n");
+ printf(" Vendor: %s, Model: %s\n",
+ monitor.vendor == NULL ? "" : monitor.vendor,
+ monitor.model == NULL ? "" : monitor.model);
+ printf(" Num hsync: %d, Num vsync: %d\n",
+ monitor.nhsync, monitor.nvsync);
+ for (i = 0; i < monitor.nhsync; i++) {
+ printf(" hsync range %d: %6.2f - %6.2f\n", i,
+ monitor.hsync[i].lo, monitor.hsync[i].hi);
+ }
+ for (i = 0; i < monitor.nvsync; i++) {
+ printf(" vsync range %d: %6.2f - %6.2f\n", i,
+ monitor.vsync[i].lo, monitor.vsync[i].hi);
+ }
+ XFree(monitor.vendor);
+ XFree(monitor.model);
+ XFree(monitor.hsync);
+ XFree(monitor.vsync);
+ } else {
+ printf(" Monitor Information not available\n");
}
- XFree(monitor.vendor);
- XFree(monitor.model);
- XFree(monitor.hsync);
- XFree(monitor.vsync);
if ((majorrev > 0) || (majorrev == 0 && minorrev > 5)) {
- if (!XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &modecount,
- &modelines))
- return 0;
- printf(" Available Video Mode Settings:\n");
- printf(" Clock Hdsp Hbeg Hend Httl Vdsp Vbeg Vend Vttl Flags\n");
- for (i = 0; i < modecount; i++) {
- printf(" %6.2f %4d %4d %4d %4d %4d %4d %4d %4d ",
- (float)modelines[i]->dotclock/1000.0,
- modelines[i]->hdisplay, modelines[i]->hsyncstart,
- modelines[i]->hsyncend, modelines[i]->htotal,
- modelines[i]->vdisplay, modelines[i]->vsyncstart,
- modelines[i]->vsyncend, modelines[i]->vtotal);
- if (modelines[i]->flags & V_PHSYNC) printf(" +hsync");
- if (modelines[i]->flags & V_NHSYNC) printf(" -hsync");
- if (modelines[i]->flags & V_PVSYNC) printf(" +vsync");
- if (modelines[i]->flags & V_NVSYNC) printf(" -vsync");
- if (modelines[i]->flags & V_INTERLACE) printf(" interlace");
- if (modelines[i]->flags & V_CSYNC) printf(" composite");
- if (modelines[i]->flags & V_PCSYNC) printf(" +csync");
- if (modelines[i]->flags & V_NCSYNC) printf(" -csync");
- if (modelines[i]->flags & V_DBLSCAN) printf(" doublescan");
- printf("\n");
+ if (XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &modecount,
+ &modelines)) {
+ printf(" Available Video Mode Settings:\n");
+ printf(" Clock Hdsp Hbeg Hend Httl Vdsp Vbeg Vend Vttl Flags\n");
+ for (i = 0; i < modecount; i++) {
+ print_XF86VidMode_modeline
+ (modelines[i]->dotclock, modelines[i]->hdisplay,
+ modelines[i]->hsyncstart, modelines[i]->hsyncend,
+ modelines[i]->htotal, modelines[i]->vdisplay,
+ modelines[i]->vsyncstart, modelines[i]->vsyncend,
+ modelines[i]->vtotal, modelines[i]->flags);
+ }
+ XFree(modelines);
+ } else {
+ printf(" Available Video Mode Settings not available\n");
}
- XFree(modelines);
- if (!XF86VidModeGetModeLine(dpy, DefaultScreen(dpy),
- &dotclock, &modeline))
- return 0;
- printf(" Current Video Mode Setting:\n");
- printf(" %6.2f %4d %4d %4d %4d %4d %4d %4d %4d ",
- (float)dotclock/1000.0,
- modeline.hdisplay, modeline.hsyncstart,
- modeline.hsyncend, modeline.htotal,
- modeline.vdisplay, modeline.vsyncstart,
- modeline.vsyncend, modeline.vtotal);
- if (modeline.flags & V_PHSYNC) printf(" +hsync");
- if (modeline.flags & V_NHSYNC) printf(" -hsync");
- if (modeline.flags & V_PVSYNC) printf(" +vsync");
- if (modeline.flags & V_NVSYNC) printf(" -vsync");
- if (modeline.flags & V_INTERLACE) printf(" interlace");
- if (modeline.flags & V_CSYNC) printf(" composite");
- if (modeline.flags & V_PCSYNC) printf(" +csync");
- if (modeline.flags & V_NCSYNC) printf(" -csync");
- if (modeline.flags & V_DBLSCAN) printf(" doublescan");
- printf("\n");
+ if (XF86VidModeGetModeLine(dpy, DefaultScreen(dpy),
+ &dotclock, &modeline)) {
+ printf(" Current Video Mode Setting:\n");
+ print_XF86VidMode_modeline(dotclock,
+ modeline.hdisplay, modeline.hsyncstart,
+ modeline.hsyncend, modeline.htotal,
+ modeline.vdisplay, modeline.vsyncstart,
+ modeline.vsyncend, modeline.vtotal,
+ modeline.flags);
+ } else {
+ printf(" Current Video Mode Setting not available\n");
+ }
}
return 1;