aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/xorg/xorg_output.c
diff options
context:
space:
mode:
authorJakob Bornecrantz <[email protected]>2010-04-22 10:48:28 +0100
committerJakob Bornecrantz <[email protected]>2010-04-29 14:27:34 +0100
commit71d3961a47844baeaf5d0e4a4fd1001dee89d71b (patch)
treef3659c1afe109e744644d0d97789e57ab9bf76b6 /src/gallium/state_trackers/xorg/xorg_output.c
parent70ae8bf26fbbac58900237b815ce86c01d09eb96 (diff)
st/xorg: Get new connection status from kernel
Diffstat (limited to 'src/gallium/state_trackers/xorg/xorg_output.c')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_output.c59
1 files changed, 51 insertions, 8 deletions
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: */