Initial commit of new modesetting driver

This commit is contained in:
Alan Hourihane 2008-05-28 13:33:07 +01:00
commit 106bea5ad1
8 changed files with 1905 additions and 0 deletions

View File

@ -0,0 +1,12 @@
This is a stub file. This package has not yet had its complete licensing
information compiled. Please see the individual source files for details on
your rights to use and modify this software.
Please submit updated COPYING files to the Xorg bugzilla:
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
All licensing questions regarding this software should be directed at the
Xorg mailing list:
http://lists.freedesktop.org/mailman/listinfo/xorg

View File

@ -0,0 +1,42 @@
# Copyright 2005 Adam Jackson.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# on the rights to use, copy, modify, merge, publish, distribute, sub
# license, and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SUBDIRS =
# this is obnoxious:
# -module lets us name the module exactly how we want
# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
# _ladir passes a dummy rpath to libtool so the thing will actually link
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRI_CFLAGS@ @PCIACCESS_CFLAGS@ \
@XMODES_CFLAGS@
modesetting_drv_la_LTLIBRARIES = modesetting_drv.la
modesetting_drv_la_LDFLAGS = -module -avoid-version -ldrm
modesetting_drv_ladir = @moduledir@/drivers
modesetting_drv_la_SOURCES = \
driver.c \
driver.h \
output.c \
crtc.c \
exa.c
EXTRA_DIST =

View File

@ -0,0 +1,215 @@
/*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Author: Alan Hourihane <alanh@tungstengraphics.com>
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <xf86.h>
#include <xf86i2c.h>
#include <xf86Crtc.h>
#include "driver.h"
#include "xf86Modes.h"
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
static void
crtc_dpms(xf86CrtcPtr crtc, int mode)
{
ScrnInfoPtr pScrn = crtc->scrn;
switch (mode) {
case DPMSModeOn:
case DPMSModeStandby:
case DPMSModeSuspend:
break;
case DPMSModeOff:
break;
}
}
static Bool
crtc_lock(xf86CrtcPtr crtc)
{
return FALSE;
}
static void
crtc_unlock(xf86CrtcPtr crtc)
{
}
static void
crtc_prepare(xf86CrtcPtr crtc)
{
}
static void
crtc_commit(xf86CrtcPtr crtc)
{
}
static Bool
crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
DisplayModePtr adjusted_mode)
{
return TRUE;
}
static void
crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
DisplayModePtr adjusted_mode, int x, int y)
{
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
modesettingPtr ms = modesettingPTR(crtc->scrn);
xf86OutputPtr output = config->output[config->compat_output];
drmModeOutputPtr drm_output = output->driver_private;
drmModeCrtcPtr drm_crtc = crtc->driver_private;
struct drm_mode_modeinfo drm_mode;
drm_mode.clock = mode->Clock;
drm_mode.hdisplay = mode->HDisplay;
drm_mode.hsync_start = mode->HSyncStart;
drm_mode.hsync_end = mode->HSyncEnd;
drm_mode.htotal = mode->HTotal;
drm_mode.vdisplay = mode->VDisplay;
drm_mode.vsync_start = mode->VSyncStart;
drm_mode.vsync_end = mode->VSyncEnd;
drm_mode.vtotal = mode->VTotal;
drm_mode.flags = mode->Flags;
drm_mode.hskew = mode->HSkew;
drm_mode.vscan = mode->VScan;
drm_mode.vrefresh = mode->VRefresh;
strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN);
drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y,
&drm_output->output_id, 1, &drm_mode);
}
void
crtc_load_lut(xf86CrtcPtr crtc)
{
ScrnInfoPtr pScrn = crtc->scrn;
}
static void
crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue,
int size)
{
}
static void *
crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
{
ScrnInfoPtr pScrn = crtc->scrn;
return NULL;
}
static PixmapPtr
crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
{
ScrnInfoPtr pScrn = crtc->scrn;
return NULL;
}
static void
crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
{
ScrnInfoPtr pScrn = crtc->scrn;
}
static void
crtc_destroy(xf86CrtcPtr crtc)
{
drmModeFreeCrtc(crtc->driver_private);
}
static const xf86CrtcFuncsRec crtc_funcs = {
.dpms = crtc_dpms,
.save = NULL, /* XXX */
.restore = NULL, /* XXX */
.lock = crtc_lock,
.unlock = crtc_unlock,
.mode_fixup = crtc_mode_fixup,
.prepare = crtc_prepare,
.mode_set = crtc_mode_set,
.commit = crtc_commit,
.gamma_set = crtc_gamma_set,
.shadow_create = crtc_shadow_create,
.shadow_allocate = crtc_shadow_allocate,
.shadow_destroy = crtc_shadow_destroy,
// .set_cursor_colors = crtc_set_cursor_colors,
// .set_cursor_position = crtc_set_cursor_position,
// .show_cursor = crtc_show_cursor,
// .hide_cursor = crtc_hide_cursor,
// .load_cursor_image = crtc_load_cursor_image,
// .load_cursor_argb = crtc_load_cursor_argb,
.destroy = crtc_destroy, /* XXX */
};
void
crtc_init(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
xf86CrtcPtr crtc;
drmModeResPtr res;
drmModeCrtcPtr drm_crtc = NULL;
int c, k, p;
res = drmModeGetResources(ms->fd);
if (res == 0) {
ErrorF("Failed drmModeGetResources %d\n",errno);
return;
}
for (c = 0; c < res->count_crtcs; c++) {
drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]);
if (!drm_crtc)
continue;
crtc = xf86CrtcCreate(pScrn, &crtc_funcs);
if (crtc == NULL)
goto out;
crtc->driver_private = drm_crtc;
}
out:
drmModeFreeResources(res);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,88 @@
/*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Author: Alan Hourihane <alanh@tungstengraphics.com>
*
*/
#include <errno.h>
#include <drm.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "shadow.h"
#include "exa.h"
#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
typedef struct {
int lastInstance;
int refCount;
ScrnInfoPtr pScrn_1;
ScrnInfoPtr pScrn_2;
} EntRec, *EntPtr;
typedef struct _modesettingRec {
int fd;
unsigned int fb_id;
void *virtual;
drmBO bo;
EntPtr entityPrivate;
void (*PointerMoved)(int, int, int);
int Chipset;
EntityInfoPtr pEnt;
#if XSERVER_LIBPCIACCESS
struct pci_device *PciInfo;
#else
pciVideoPtr PciInfo;
PCITAG PciTag;
#endif
Bool noAccel;
Bool SWCursor;
CloseScreenProcPtr CloseScreen;
Bool directRenderingDisabled; /* DRI disabled in PreInit. */
Bool directRenderingEnabled; /* DRI enabled this generation. */
/* Broken-out options. */
OptionInfoPtr Options;
unsigned int SaveGeneration;
/* shadowfb */
CARD8 *shadowMem;
Bool shadowFB;
CreateScreenResourcesProcPtr createScreenResources;
ShadowUpdateProc update;
/* exa */
ExaDriverPtr pExa;
drmBO exa_bo;
} modesettingRec, *modesettingPtr;
#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))

View File

@ -0,0 +1,235 @@
/*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Author: Alan Hourihane <alanh@tungstengraphics.com>
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "xf86.h"
#include "xf86_OSproc.h"
#include "driver.h"
static void
ExaWaitMarker(ScreenPtr pScreen, int marker)
{
}
static int
ExaMarkSync(ScreenPtr pScreen)
{
/*
* See ExaWaitMarker.
*/
return 1;
}
Bool
ExaPrepareAccess(PixmapPtr pPix, int index)
{
ScreenPtr pScreen = pPix->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
return TRUE;
}
void
ExaFinishAccess(PixmapPtr pPix, int index)
{
ScreenPtr pScreen = pPix->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
}
static void
ExaDone(PixmapPtr pPixmap)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
}
static void
ExaDoneComposite(PixmapPtr pPixmap)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
}
static Bool
ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planeMask))
return FALSE;
/* can't do depth 4 */
if (pPixmap->drawable.depth == 4)
return FALSE;
return TRUE;
}
static void
ExaSolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
}
static Bool
ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
int ydir, int alu, Pixel planeMask)
{
ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
/* can't do depth 4 */
if (pSrcPixmap->drawable.depth == 4 || pDstPixmap->drawable.depth == 4)
return FALSE;
return TRUE;
}
static void
ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
int width, int height)
{
ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
}
static Bool
ExaPrepareComposite(int op, PicturePtr pSrcPicture,
PicturePtr pMaskPicture, PicturePtr pDstPicture,
PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
return FALSE;
}
static Bool
ExaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src,
int src_pitch)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
return FALSE;
}
static void
ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
int dstX, int dstY, int width, int height)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
}
static Bool
ExaCheckComposite(int op,
PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture)
{
DrawablePtr pDraw = pSrcPicture->pDrawable;
int w = pDraw->width;
int h = pDraw->height;
return TRUE;
}
static Bool
ExaPixmapIsOffscreen(PixmapPtr p)
{
ScreenPtr pScreen = p->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
return FALSE;
}
void
ExaClose(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
exaDriverFini(pScrn->pScreen);
drmBOUnreference(ms->fd, &ms->exa_bo);
}
ExaDriverPtr
ExaInit(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
ExaDriverPtr pExa;
pExa = exaDriverAlloc();
if (!pExa) {
goto out_err;
}
/* Create a 256KB offscreen area */
drmBOCreate(ms->fd, 256 * 1024, 0, NULL, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_MEM_TT, DRM_BO_HINT_DONT_FENCE, &ms->exa_bo);
memset(pExa, 0, sizeof(*pExa));
pExa->exa_major = 2;
pExa->exa_minor = 2;
pExa->memoryBase = ms->exa_bo.virtual;
pExa->offScreenBase = 0;
pExa->memorySize = ms->exa_bo.size;
pExa->pixmapOffsetAlign = 8;
pExa->pixmapPitchAlign = 32 * 4;
pExa->flags = EXA_OFFSCREEN_PIXMAPS;
pExa->maxX = 8191; /* FIXME */
pExa->maxY = 8191; /* FIXME */
pExa->WaitMarker = ExaWaitMarker;
pExa->MarkSync = ExaMarkSync;
pExa->PrepareSolid = ExaPrepareSolid;
pExa->Solid = ExaSolid;
pExa->DoneSolid = ExaDone;
pExa->PrepareCopy = ExaPrepareCopy;
pExa->Copy = ExaCopy;
pExa->DoneCopy = ExaDone;
pExa->CheckComposite = ExaCheckComposite;
pExa->PrepareComposite = ExaPrepareComposite;
pExa->Composite = ExaComposite;
pExa->DoneComposite = ExaDoneComposite;
pExa->PixmapIsOffscreen = ExaPixmapIsOffscreen;
pExa->PrepareAccess = ExaPrepareAccess;
pExa->FinishAccess = ExaFinishAccess;
pExa->UploadToScreen = ExaUploadToScreen;
if (!exaDriverInit(pScrn->pScreen, pExa)) {
goto out_err;
}
return pExa;
out_err:
ExaClose(pScrn);
return NULL;
}

View File

@ -0,0 +1,285 @@
/*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Author: Alan Hourihane <alanh@tungstengraphics.com>
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <xf86.h>
#include <xf86i2c.h>
#include <xf86Crtc.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
#include "X11/Xatom.h"
#include "driver.h"
static void
dpms(xf86OutputPtr output, int mode)
{
}
static void
save(xf86OutputPtr output)
{
}
static void
restore(xf86OutputPtr output)
{
}
static int
mode_valid(xf86OutputPtr output, DisplayModePtr pMode)
{
return MODE_OK;
}
static Bool
mode_fixup(xf86OutputPtr output, DisplayModePtr mode,
DisplayModePtr adjusted_mode)
{
return TRUE;
}
static void
prepare(xf86OutputPtr output)
{
dpms(output, DPMSModeOff);
}
static void
mode_set(xf86OutputPtr output, DisplayModePtr mode,
DisplayModePtr adjusted_mode)
{
}
static void
commit(xf86OutputPtr output)
{
dpms(output, DPMSModeOn);
if (output->scrn->pScreen != NULL)
xf86_reload_cursors(output->scrn->pScreen);
}
static xf86OutputStatus
detect(xf86OutputPtr output)
{
drmModeOutputPtr drm_output = output->driver_private;
switch (drm_output->connection) {
case DRM_MODE_CONNECTED:
return XF86OutputStatusConnected;
case DRM_MODE_DISCONNECTED:
return XF86OutputStatusDisconnected;
default:
return XF86OutputStatusUnknown;
}
}
static DisplayModePtr
get_modes(xf86OutputPtr output)
{
drmModeOutputPtr drm_output = output->driver_private;
struct drm_mode_modeinfo *drm_mode = NULL;
DisplayModePtr modes = NULL, mode = NULL;
int i;
for (i = 0; i < drm_output->count_modes; i++) {
drm_mode = &drm_output->modes[i];
if (drm_mode) {
mode = xcalloc(1, sizeof(DisplayModeRec));
if (!mode)
continue;
mode->type = 0;
mode->Clock = drm_mode->clock;
mode->HDisplay = drm_mode->hdisplay;
mode->HSyncStart = drm_mode->hsync_start;
mode->HSyncEnd = drm_mode->hsync_end;
mode->HTotal = drm_mode->htotal;
mode->VDisplay = drm_mode->vdisplay;
mode->VSyncStart = drm_mode->vsync_start;
mode->VSyncEnd = drm_mode->vsync_end;
mode->VTotal = drm_mode->vtotal;
mode->Flags = drm_mode->flags;
mode->HSkew = drm_mode->hskew;
mode->VScan = drm_mode->vscan;
mode->VRefresh = xf86ModeVRefresh(mode);
mode->Private = (void *)drm_mode;
xf86SetModeDefaultName(mode);
modes = xf86ModesAdd(modes, mode);
xf86PrintModeline(0, mode);
}
}
return modes;
}
static void
destroy(xf86OutputPtr output)
{
drmModeFreeOutput(output->driver_private);
}
static void
create_resources(xf86OutputPtr output)
{
#ifdef RANDR_12_INTERFACE
#endif /* RANDR_12_INTERFACE */
}
#ifdef RANDR_12_INTERFACE
static Bool
set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value)
{
return TRUE;
}
#endif /* RANDR_12_INTERFACE */
#ifdef RANDR_13_INTERFACE
static Bool
get_property(xf86OutputPtr output, Atom property)
{
return TRUE;
}
#endif /* RANDR_13_INTERFACE */
#ifdef RANDR_GET_CRTC_INTERFACE
static xf86CrtcPtr
get_crtc(xf86OutputPtr output)
{
return NULL;
}
#endif
static const xf86OutputFuncsRec output_funcs = {
.create_resources = create_resources,
.dpms = dpms,
.save = save,
.restore = restore,
.mode_valid = mode_valid,
.mode_fixup = mode_fixup,
.prepare = prepare,
.mode_set = mode_set,
.commit = commit,
.detect = detect,
.get_modes = get_modes,
#ifdef RANDR_12_INTERFACE
.set_property = set_property,
#endif
#ifdef RANDR_13_INTERFACE
.get_property = get_property,
#endif
.destroy = destroy,
#ifdef RANDR_GET_CRTC_INTERFACE
.get_crtc = get_crtc,
#endif
};
void
output_init(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
xf86OutputPtr output;
drmModeResPtr res;
drmModeOutputPtr drm_output = NULL;
drmModeCrtcPtr crtc;
char *name;
int o, v, p;
res = drmModeGetResources(ms->fd);
if (res == 0) {
DRV_ERROR("Failed drmModeGetResources\n");
return;
}
for (o = 0; o < res->count_outputs; o++) {
drm_output = drmModeGetOutput(ms->fd, res->outputs[o]);
if (!drm_output)
goto out;
for (p = 0; p < drm_output->count_props; p++) {
drmModePropertyPtr prop;
prop = drmModeGetProperty(ms->fd, drm_output->props[p]);
name = NULL;
if (prop) {
ErrorF("VALUES %d\n",prop->count_values);
for (v=0;v<prop->count_values;v++)
ErrorF("%s %lld\n", prop->name, prop->values[v]);
for (v=0;v<prop->count_enums;v++) {
ErrorF("%s %s\n", prop->name, prop->enums[v].name);
if (drm_output->prop_values[p] == prop->enums[v].value) {
if (!strncmp("Connector Type", prop->name, 14)) {
ErrorF("WE'VE GOT %s\n",prop->enums[v].name);
name = xalloc(strlen(prop->enums[v].name));
strncpy(name, prop->enums[v].name, strlen(name));
}
}
if (name) break;
}
if (name) break;
}
}
if (!name)
continue;
output = xf86OutputCreate(pScrn, &output_funcs, name);
if (!output)
continue;
free(name);
output->possible_crtcs = drm_output->crtcs;
output->possible_clones = drm_output->clones;
output->driver_private = drm_output;
output->subpixel_order = SubPixelHorizontalRGB;
output->interlaceAllowed = FALSE;
output->doubleScanAllowed = FALSE;
}
out:
drmModeFreeResources(res);
}