summaryrefslogtreecommitdiff
path: root/hw/xfree86/modes/xf86Crtc.h
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-02-25 11:37:05 -0800
committerKeith Packard <keithp@keithp.com>2010-02-25 12:48:27 -0800
commitde86a3a3448f0a55c1cd99aee9ea80070a589877 (patch)
tree5f2ec35ee10dcdcdf96299397dd0f6ac9e994121 /hw/xfree86/modes/xf86Crtc.h
parentfbbadca7e88391e81ab0f470290f5eec36aa9ce7 (diff)
Allow for missing or disabled compat_output
When the compat output is missing (I don't think this is actually possible), or is disabled (and hence has no crtc), we would like to avoid dereferencing NULL pointers. This patch creates inline functions to extract the current compat output, crtc or associated RandR crtc structure, carefully checking for NULL pointers everywhere. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'hw/xfree86/modes/xf86Crtc.h')
-rw-r--r--hw/xfree86/modes/xf86Crtc.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 9baa956a3..68a968cc2 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -689,6 +689,32 @@ extern _X_EXPORT int xf86CrtcConfigPrivateIndex;
#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
+static _X_INLINE xf86OutputPtr
+xf86CompatOutput(ScrnInfoPtr pScrn)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ return config->output[config->compat_output];
+}
+
+static _X_INLINE xf86CrtcPtr
+xf86CompatCrtc(ScrnInfoPtr pScrn)
+{
+ xf86OutputPtr compat_output = xf86CompatOutput(pScrn);
+ if (!compat_output)
+ return NULL;
+ return compat_output->crtc;
+}
+
+static _X_INLINE RRCrtcPtr
+xf86CompatRRCrtc(ScrnInfoPtr pScrn)
+{
+ xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn);
+ if (!compat_crtc)
+ return NULL;
+ return compat_crtc->randr_crtc;
+}
+
+
/*
* Initialize xf86CrtcConfig structure
*/