2 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Author: Alan Hourihane <alanh@tungstengraphics.com>
27 * Author: Jakob Bornecrantz <wallbraker@gmail.com>
31 #include "xorg-server.h"
43 #include <sys/types.h>
45 #ifdef HAVE_XEXTPROTO_71
46 #include <X11/extensions/dpmsconst.h>
49 #include <X11/extensions/dpms.h>
52 #include "X11/Xatom.h"
54 #include "xorg_tracker.h"
56 static char *connector_enum_list
[] = {
73 create_resources(xf86OutputPtr output
)
75 #ifdef RANDR_12_INTERFACE
76 #endif /* RANDR_12_INTERFACE */
80 dpms(xf86OutputPtr output
, int mode
)
84 static xf86OutputStatus
85 detect(xf86OutputPtr output
)
87 drmModeConnectorPtr drm_connector
= output
->driver_private
;
89 switch (drm_connector
->connection
) {
90 case DRM_MODE_CONNECTED
:
91 return XF86OutputStatusConnected
;
92 case DRM_MODE_DISCONNECTED
:
93 return XF86OutputStatusDisconnected
;
95 return XF86OutputStatusUnknown
;
100 get_modes(xf86OutputPtr output
)
102 drmModeConnectorPtr drm_connector
= output
->driver_private
;
103 drmModeModeInfoPtr drm_mode
= NULL
;
104 DisplayModePtr modes
= NULL
, mode
= NULL
;
107 for (i
= 0; i
< drm_connector
->count_modes
; i
++) {
108 drm_mode
= &drm_connector
->modes
[i
];
110 mode
= xcalloc(1, sizeof(DisplayModeRec
));
114 mode
->Clock
= drm_mode
->clock
;
115 mode
->HDisplay
= drm_mode
->hdisplay
;
116 mode
->HSyncStart
= drm_mode
->hsync_start
;
117 mode
->HSyncEnd
= drm_mode
->hsync_end
;
118 mode
->HTotal
= drm_mode
->htotal
;
119 mode
->VDisplay
= drm_mode
->vdisplay
;
120 mode
->VSyncStart
= drm_mode
->vsync_start
;
121 mode
->VSyncEnd
= drm_mode
->vsync_end
;
122 mode
->VTotal
= drm_mode
->vtotal
;
123 mode
->Flags
= drm_mode
->flags
;
124 mode
->HSkew
= drm_mode
->hskew
;
125 mode
->VScan
= drm_mode
->vscan
;
126 mode
->VRefresh
= xf86ModeVRefresh(mode
);
127 mode
->Private
= (void *)drm_mode
;
128 xf86SetModeDefaultName(mode
);
129 modes
= xf86ModesAdd(modes
, mode
);
130 xf86PrintModeline(0, mode
);
138 mode_valid(xf86OutputPtr output
, DisplayModePtr pMode
)
143 #ifdef RANDR_12_INTERFACE
145 set_property(xf86OutputPtr output
, Atom property
, RRPropertyValuePtr value
)
149 #endif /* RANDR_12_INTERFACE */
151 #ifdef RANDR_13_INTERFACE
153 get_property(xf86OutputPtr output
, Atom property
)
157 #endif /* RANDR_13_INTERFACE */
160 destroy(xf86OutputPtr output
)
162 drmModeFreeConnector(output
->driver_private
);
165 static const xf86OutputFuncsRec output_funcs
= {
166 .create_resources
= create_resources
,
167 #ifdef RANDR_12_INTERFACE
168 .set_property
= set_property
,
170 #ifdef RANDR_13_INTERFACE
171 .get_property
= get_property
,
176 .get_modes
= get_modes
,
177 .mode_valid
= mode_valid
,
182 output_init(ScrnInfoPtr pScrn
)
184 modesettingPtr ms
= modesettingPTR(pScrn
);
185 xf86OutputPtr output
;
187 drmModeConnectorPtr drm_connector
= NULL
;
188 drmModeEncoderPtr drm_encoder
= NULL
;
192 res
= drmModeGetResources(ms
->fd
);
194 DRV_ERROR("Failed drmModeGetResources\n");
198 for (c
= 0; c
< res
->count_connectors
; c
++) {
199 drm_connector
= drmModeGetConnector(ms
->fd
, res
->connectors
[c
]);
204 for (p
= 0; p
< drm_connector
->count_props
; p
++) {
205 drmModePropertyPtr prop
;
207 prop
= drmModeGetProperty(ms
->fd
, drm_connector
->props
[p
]);
211 ErrorF("VALUES %d\n", prop
->count_values
);
213 for (v
= 0; v
< prop
->count_values
; v
++)
214 ErrorF("%s %lld\n", prop
->name
, prop
->values
[v
]);
222 snprintf(name
, 32, "%s%d",
223 connector_enum_list
[drm_connector
->connector_type
],
224 drm_connector
->connector_type_id
);
227 output
= xf86OutputCreate(pScrn
, &output_funcs
, name
);
231 drm_encoder
= drmModeGetEncoder(ms
->fd
, drm_connector
->encoders
[0]);
233 output
->possible_crtcs
= drm_encoder
->possible_crtcs
;
234 output
->possible_clones
= drm_encoder
->possible_clones
;
236 output
->possible_crtcs
= 0;
237 output
->possible_clones
= 0;
239 output
->driver_private
= drm_connector
;
240 output
->subpixel_order
= SubPixelHorizontalRGB
;
241 output
->interlaceAllowed
= FALSE
;
242 output
->doubleScanAllowed
= FALSE
;
246 drmModeFreeResources(res
);
249 /* vim: set sw=4 ts=8 sts=4: */