diff options
author | Jakob Bornecrantz <[email protected]> | 2010-04-22 10:48:28 +0100 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2010-04-29 14:27:34 +0100 |
commit | 71d3961a47844baeaf5d0e4a4fd1001dee89d71b (patch) | |
tree | f3659c1afe109e744644d0d97789e57ab9bf76b6 /src | |
parent | 70ae8bf26fbbac58900237b815ce86c01d09eb96 (diff) |
st/xorg: Get new connection status from kernel
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_crtc.c | 7 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_output.c | 59 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_tracker.h | 3 |
3 files changed, 57 insertions, 12 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 669bd9edcf0..f9022a9f934 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -90,11 +90,10 @@ crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); modesettingPtr ms = modesettingPTR(crtc->scrn); xf86OutputPtr output = NULL; - drmModeConnectorPtr drm_connector; struct crtc_private *crtcp = crtc->driver_private; drmModeCrtcPtr drm_crtc = crtcp->drm_crtc; drmModeModeInfo drm_mode; - int i, ret; + int i, ret, connector_id; for (i = 0; i < config->num_output; output = NULL, i++) { output = config->output[i]; @@ -106,7 +105,7 @@ crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, if (!output) return FALSE; - drm_connector = output->driver_private; + connector_id = xorg_output_get_id(output); drm_mode.clock = mode->Clock; drm_mode.hdisplay = mode->HDisplay; @@ -127,7 +126,7 @@ crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, drm_mode.name[DRM_DISPLAY_MODE_LEN - 1] = '\0'; ret = drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, - &drm_connector->connector_id, 1, &drm_mode); + &connector_id, 1, &drm_mode); if (ret) return FALSE; diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c index 13c3fb97e3b..056098f76b4 100644 --- a/src/gallium/state_trackers/xorg/xorg_output.c +++ b/src/gallium/state_trackers/xorg/xorg_output.c @@ -51,6 +51,13 @@ #include "xorg_tracker.h" +struct output_private +{ + drmModeConnectorPtr drm_connector; + + int c; +}; + static char *output_enum_list[] = { "Unknown", "VGA", @@ -82,22 +89,38 @@ output_dpms(xf86OutputPtr output, int mode) static xf86OutputStatus output_detect(xf86OutputPtr output) { - drmModeConnectorPtr drm_connector = output->driver_private; + modesettingPtr ms = modesettingPTR(output->scrn); + struct output_private *priv = output->driver_private; + drmModeConnectorPtr drm_connector; + xf86OutputStatus status; + + drm_connector = drmModeGetConnector(ms->fd, priv->drm_connector->connector_id); + if (drm_connector) { + drmModeFreeConnector(priv->drm_connector); + priv->drm_connector = drm_connector; + } else { + drm_connector = priv->drm_connector; + } switch (drm_connector->connection) { case DRM_MODE_CONNECTED: - return XF86OutputStatusConnected; + status = XF86OutputStatusConnected; + break; case DRM_MODE_DISCONNECTED: - return XF86OutputStatusDisconnected; + status = XF86OutputStatusDisconnected; + break; default: - return XF86OutputStatusUnknown; + status = XF86OutputStatusUnknown; } + + return status; } static DisplayModePtr output_get_modes(xf86OutputPtr output) { - drmModeConnectorPtr drm_connector = output->driver_private; + struct output_private *priv = output->driver_private; + drmModeConnectorPtr drm_connector = priv->drm_connector; drmModeModeInfoPtr drm_mode = NULL; DisplayModePtr modes = NULL, mode = NULL; int i; @@ -161,7 +184,10 @@ output_get_property(xf86OutputPtr output, Atom property) static void output_destroy(xf86OutputPtr output) { - drmModeFreeConnector(output->driver_private); + struct output_private *priv = output->driver_private; + drmModeFreeConnector(priv->drm_connector); + xfree(priv); + output->driver_private = NULL; } static const xf86OutputFuncsRec output_funcs = { @@ -188,6 +214,7 @@ xorg_output_init(ScrnInfoPtr pScrn) drmModeResPtr res; drmModeConnectorPtr drm_connector = NULL; drmModeEncoderPtr drm_encoder = NULL; + struct output_private *priv; char name[32]; int c, v, p; @@ -226,9 +253,16 @@ xorg_output_init(ScrnInfoPtr pScrn) drm_connector->connector_type_id); + priv = xcalloc(sizeof(*priv), 1); + if (!priv) { + continue; + } + output = xf86OutputCreate(pScrn, &output_funcs, name); - if (!output) + if (!output) { + xfree(priv); continue; + } drm_encoder = drmModeGetEncoder(ms->fd, drm_connector->encoders[0]); if (drm_encoder) { @@ -238,7 +272,9 @@ xorg_output_init(ScrnInfoPtr pScrn) output->possible_crtcs = 0; output->possible_clones = 0; } - output->driver_private = drm_connector; + priv->c = c; + priv->drm_connector = drm_connector; + output->driver_private = priv; output->subpixel_order = SubPixelHorizontalRGB; output->interlaceAllowed = FALSE; output->doubleScanAllowed = FALSE; @@ -248,4 +284,11 @@ xorg_output_init(ScrnInfoPtr pScrn) drmModeFreeResources(res); } +unsigned +xorg_output_get_id(xf86OutputPtr output) +{ + struct output_private *priv = output->driver_private; + return priv->drm_connector->connector_id; +} + /* vim: set sw=4 ts=8 sts=4: */ diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h index cb6773424a8..8d9c2a097ed 100644 --- a/src/gallium/state_trackers/xorg/xorg_tracker.h +++ b/src/gallium/state_trackers/xorg/xorg_tracker.h @@ -192,6 +192,9 @@ xorg_crtc_cursor_destroy(xf86CrtcPtr crtc); void xorg_output_init(ScrnInfoPtr pScrn); +unsigned +xorg_output_get_id(xf86OutputPtr output); + /*********************************************************************** * xorg_xv.c |