modesetting: restart driver effort from other codebases
This starts a randr 1.2 compatible driver with cursors. TODO: libkms dirty handling server recycling.
This commit is contained in:
		
							parent
							
								
									e2f8315dae
								
							
						
					
					
						commit
						2a46189054
					
				| 
						 | 
				
			
			@ -25,19 +25,16 @@ SUBDIRS =
 | 
			
		|||
# _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@ \
 | 
			
		||||
	-I@GALLIUM_DIR@/src/gallium/include \
 | 
			
		||||
	-I@GALLIUM_DIR@/src/gallium/auxiliary
 | 
			
		||||
AM_CFLAGS = @XORG_CFLAGS@ @DRM_CFLAGS@ @UDEV_CFLAGS@
 | 
			
		||||
 | 
			
		||||
modesetting_drv_la_LTLIBRARIES = modesetting_drv.la
 | 
			
		||||
modesetting_drv_la_LDFLAGS = -module -avoid-version -ldrm
 | 
			
		||||
modesetting_drv_la_LDFLAGS = -module -avoid-version
 | 
			
		||||
modesetting_drv_la_LIBADD = @UDEV_LIBS@ @DRM_LIBS@
 | 
			
		||||
modesetting_drv_ladir = @moduledir@/drivers
 | 
			
		||||
 | 
			
		||||
modesetting_drv_la_SOURCES = \
 | 
			
		||||
	 driver.c \
 | 
			
		||||
	 driver.h \
 | 
			
		||||
	 output.c \
 | 
			
		||||
	 crtc.c \
 | 
			
		||||
	 dri2.c
 | 
			
		||||
	 drmmode_display.c
 | 
			
		||||
 | 
			
		||||
EXTRA_DIST =
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,307 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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>
 | 
			
		||||
 | 
			
		||||
struct crtc_private
 | 
			
		||||
{
 | 
			
		||||
    drmModeCrtcPtr drm_crtc;
 | 
			
		||||
 | 
			
		||||
    /* hwcursor */
 | 
			
		||||
    drmBO cursor_bo;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
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];
 | 
			
		||||
    drmModeConnectorPtr drm_connector = output->driver_private;
 | 
			
		||||
    struct crtc_private *crtcp = crtc->driver_private;
 | 
			
		||||
    drmModeCrtcPtr drm_crtc = crtcp->drm_crtc;
 | 
			
		||||
    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;
 | 
			
		||||
    if (!mode->name)
 | 
			
		||||
	xf86SetModeDefaultName(mode);
 | 
			
		||||
    strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN);
 | 
			
		||||
 | 
			
		||||
    drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y,
 | 
			
		||||
		   &drm_connector->connector_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)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    struct crtc_private *crtcp = crtc->driver_private;
 | 
			
		||||
 | 
			
		||||
    if (crtcp->cursor_bo.handle)
 | 
			
		||||
	drmBOUnreference(ms->fd, &crtcp->cursor_bo);
 | 
			
		||||
 | 
			
		||||
    drmModeFreeCrtc(crtcp->drm_crtc);
 | 
			
		||||
    xfree(crtcp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
 | 
			
		||||
{
 | 
			
		||||
    unsigned char *ptr;
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    struct crtc_private *crtcp = crtc->driver_private;
 | 
			
		||||
 | 
			
		||||
    if (!crtcp->cursor_bo.handle)
 | 
			
		||||
	drmBOCreate(ms->fd, 64 * 64 * 4, 0, NULL,
 | 
			
		||||
		    DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE
 | 
			
		||||
		    | DRM_BO_FLAG_NO_EVICT | DRM_BO_FLAG_MAPPABLE |
 | 
			
		||||
		    DRM_BO_FLAG_MEM_VRAM,
 | 
			
		||||
		    DRM_BO_HINT_DONT_FENCE, &crtcp->cursor_bo);
 | 
			
		||||
 | 
			
		||||
    drmBOMap(ms->fd, &crtcp->cursor_bo, DRM_BO_FLAG_WRITE,
 | 
			
		||||
	     DRM_BO_HINT_DONT_FENCE, (void **)&ptr);
 | 
			
		||||
 | 
			
		||||
    if (ptr)
 | 
			
		||||
	memcpy(ptr, image, 64 * 64 * 4);
 | 
			
		||||
 | 
			
		||||
    drmBOUnmap(ms->fd, &crtcp->cursor_bo);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    struct crtc_private *crtcp = crtc->driver_private;
 | 
			
		||||
 | 
			
		||||
    drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
crtc_show_cursor(xf86CrtcPtr crtc)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    struct crtc_private *crtcp = crtc->driver_private;
 | 
			
		||||
 | 
			
		||||
    if (crtcp->cursor_bo.handle)
 | 
			
		||||
	drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id,
 | 
			
		||||
			 crtcp->cursor_bo.handle, 64, 64);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
crtc_hide_cursor(xf86CrtcPtr crtc)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    struct crtc_private *crtcp = crtc->driver_private;
 | 
			
		||||
 | 
			
		||||
    drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const xf86CrtcFuncsRec crtc_funcs = {
 | 
			
		||||
    .dpms = crtc_dpms,
 | 
			
		||||
    .save = NULL,
 | 
			
		||||
    .restore = NULL,
 | 
			
		||||
    .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_position = crtc_set_cursor_position,
 | 
			
		||||
    .show_cursor = crtc_show_cursor,
 | 
			
		||||
    .hide_cursor = crtc_hide_cursor,
 | 
			
		||||
    .load_cursor_image = NULL,	       /* lets convert to argb only */
 | 
			
		||||
    .set_cursor_colors = NULL,	       /* using argb only */
 | 
			
		||||
    .load_cursor_argb = crtc_load_cursor_argb,
 | 
			
		||||
    .destroy = crtc_destroy,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
cursor_destroy(xf86CrtcPtr crtc)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(crtc->scrn);
 | 
			
		||||
    struct crtc_private *crtcp = crtc->driver_private;
 | 
			
		||||
 | 
			
		||||
    if (crtcp->cursor_bo.handle) {
 | 
			
		||||
	drmBOSetStatus(ms->fd, &crtcp->cursor_bo, 0, 0, 0, 0, 0);
 | 
			
		||||
	drmBOUnreference(ms->fd, &crtcp->cursor_bo);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
crtc_init(ScrnInfoPtr pScrn)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(pScrn);
 | 
			
		||||
    xf86CrtcPtr crtc;
 | 
			
		||||
    drmModeResPtr res;
 | 
			
		||||
    drmModeCrtcPtr drm_crtc = NULL;
 | 
			
		||||
    struct crtc_private *crtcp;
 | 
			
		||||
    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;
 | 
			
		||||
 | 
			
		||||
	crtcp = xcalloc(1, sizeof(struct crtc_private));
 | 
			
		||||
	if (!crtcp) {
 | 
			
		||||
	    xf86CrtcDestroy(crtc);
 | 
			
		||||
	    goto out;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	crtcp->drm_crtc = drm_crtc;
 | 
			
		||||
 | 
			
		||||
	crtc->driver_private = crtcp;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  out:
 | 
			
		||||
    drmModeFreeResources(res);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,128 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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"
 | 
			
		||||
 | 
			
		||||
#include "dri2.h"
 | 
			
		||||
 | 
			
		||||
extern unsigned int
 | 
			
		||||
driGetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
driLock(ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(pScrn);
 | 
			
		||||
 | 
			
		||||
    if (!ms->lock_held)
 | 
			
		||||
	DRM_LOCK(ms->fd, ms->lock, ms->context, 0);
 | 
			
		||||
 | 
			
		||||
    ms->lock_held = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
driUnlock(ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(pScrn);
 | 
			
		||||
 | 
			
		||||
    if (ms->lock_held)
 | 
			
		||||
	DRM_UNLOCK(ms->fd, ms->lock, ms->context);
 | 
			
		||||
 | 
			
		||||
    ms->lock_held = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
driBeginClipNotify(ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    driLock(pScreen);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
driEndClipNotify(ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    driUnlock(pScreen);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct __DRILock
 | 
			
		||||
{
 | 
			
		||||
    unsigned int block_header;
 | 
			
		||||
    drm_hw_lock_t lock;
 | 
			
		||||
    unsigned int next_id;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define DRI2_SAREA_BLOCK_HEADER(type, size) (((type) << 16) | (size))
 | 
			
		||||
#define DRI2_SAREA_BLOCK_LOCK		0x0001
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
driScreenInit(ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(pScrn);
 | 
			
		||||
    DRI2InfoRec dri2info;
 | 
			
		||||
    const char *driverName;
 | 
			
		||||
    unsigned int sarea_handle;
 | 
			
		||||
    struct __DRILock *DRILock;
 | 
			
		||||
    void *p;
 | 
			
		||||
 | 
			
		||||
    dri2info.version = 1;
 | 
			
		||||
    dri2info.fd = ms->fd;
 | 
			
		||||
    dri2info.driverSareaSize = sizeof(struct __DRILock);
 | 
			
		||||
    dri2info.driverName = "i915";      /* FIXME */
 | 
			
		||||
    dri2info.getPixmapHandle = driGetPixmapHandle;
 | 
			
		||||
    dri2info.beginClipNotify = driBeginClipNotify;
 | 
			
		||||
    dri2info.endClipNotify = driEndClipNotify;
 | 
			
		||||
 | 
			
		||||
    p = DRI2ScreenInit(pScreen, &dri2info);
 | 
			
		||||
    if (!p)
 | 
			
		||||
	return;
 | 
			
		||||
 | 
			
		||||
    DRILock = p;
 | 
			
		||||
    DRILock->block_header =
 | 
			
		||||
	DRI2_SAREA_BLOCK_HEADER(DRI2_SAREA_BLOCK_LOCK, sizeof *DRILock);
 | 
			
		||||
    ms->lock = &DRILock->lock;
 | 
			
		||||
    ms->context = 1;
 | 
			
		||||
    DRILock->next_id = 2;
 | 
			
		||||
    driLock(pScreen);
 | 
			
		||||
 | 
			
		||||
    DRI2Connect(pScreen, &ms->fd, &driverName, &sarea_handle);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
driCloseScreen(ScreenPtr pScreen)
 | 
			
		||||
{
 | 
			
		||||
    driUnlock(pScreen);
 | 
			
		||||
    DRI2CloseScreen(pScreen);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -34,10 +34,8 @@
 | 
			
		|||
#include "xf86.h"
 | 
			
		||||
#include "xf86_OSproc.h"
 | 
			
		||||
#include "compiler.h"
 | 
			
		||||
#include "xf86RAC.h"
 | 
			
		||||
#include "xf86PciInfo.h"
 | 
			
		||||
#include "xf86Pci.h"
 | 
			
		||||
#include "xf86Resources.h"
 | 
			
		||||
#include "mipointer.h"
 | 
			
		||||
#include "micmap.h"
 | 
			
		||||
#include <X11/extensions/randr.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -59,8 +57,6 @@
 | 
			
		|||
static void AdjustFrame(int scrnIndex, int x, int y, int flags);
 | 
			
		||||
static Bool CloseScreen(int scrnIndex, ScreenPtr pScreen);
 | 
			
		||||
static Bool EnterVT(int scrnIndex, int flags);
 | 
			
		||||
static Bool SaveHWState(ScrnInfoPtr pScrn);
 | 
			
		||||
static Bool RestoreHWState(ScrnInfoPtr pScrn);
 | 
			
		||||
static void Identify(int flags);
 | 
			
		||||
static const OptionInfoRec *AvailableOptions(int chipid, int busid);
 | 
			
		||||
static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +78,7 @@ static Bool Probe(DriverPtr drv, int flags);
 | 
			
		|||
 | 
			
		||||
#if XSERVER_LIBPCIACCESS
 | 
			
		||||
static const struct pci_id_match device_match[] = {
 | 
			
		||||
    {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0},
 | 
			
		||||
    {0x8086, 0x0046, 0xffff, 0xffff, 0, 0, 0},
 | 
			
		||||
    {0, 0, 0},
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -107,12 +103,12 @@ _X_EXPORT DriverRec modesetting = {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static SymTabRec Chipsets[] = {
 | 
			
		||||
    {0x2592, "Intel Graphics Device"},
 | 
			
		||||
    {0x0046, "Intel Graphics Device"},
 | 
			
		||||
    {-1, NULL}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static PciChipsets PciDevices[] = {
 | 
			
		||||
    {0x2592, 0x2592, RES_SHARED_VGA},
 | 
			
		||||
    {0x2592, 0x0046, RES_SHARED_VGA},
 | 
			
		||||
    {-1, -1, RES_UNDEFINED}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -126,24 +122,6 @@ static const OptionInfoRec Options[] = {
 | 
			
		|||
    {-1, NULL, OPTV_NONE, {0}, FALSE}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const char *fbSymbols[] = {
 | 
			
		||||
    "fbPictureInit",
 | 
			
		||||
    "fbScreenInit",
 | 
			
		||||
    NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const char *ddcSymbols[] = {
 | 
			
		||||
    "xf86PrintEDID",
 | 
			
		||||
    "xf86SetDDCproperties",
 | 
			
		||||
    NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const char *i2cSymbols[] = {
 | 
			
		||||
    "xf86CreateI2CBusRec",
 | 
			
		||||
    "xf86I2CBusInit",
 | 
			
		||||
    NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int modesettingEntityIndex = -1;
 | 
			
		||||
 | 
			
		||||
static MODULESETUPPROTO(Setup);
 | 
			
		||||
| 
						 | 
				
			
			@ -174,12 +152,6 @@ Setup(pointer module, pointer opts, int *errmaj, int *errmin)
 | 
			
		|||
	setupDone = 1;
 | 
			
		||||
	xf86AddDriver(&modesetting, module, HaveDriverFuncs);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Tell the loader about symbols from other modules that this module
 | 
			
		||||
	 * might refer to.
 | 
			
		||||
	 */
 | 
			
		||||
	LoaderRefSymLists(fbSymbols, ddcSymbols, NULL);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * The return value must be non-NULL on success even though there
 | 
			
		||||
	 * is no TearDownProc.
 | 
			
		||||
| 
						 | 
				
			
			@ -225,7 +197,7 @@ pci_probe(DriverPtr driver,
 | 
			
		|||
	entity = xf86GetEntityInfo(entity_num);
 | 
			
		||||
 | 
			
		||||
	switch (device->device_id) {
 | 
			
		||||
	case 0x2592:
 | 
			
		||||
	case 0x0046:
 | 
			
		||||
	    scrn->PreInit = PreInit;
 | 
			
		||||
	    scrn->ScreenInit = ScreenInit;
 | 
			
		||||
	    scrn->SwitchMode = SwitchMode;
 | 
			
		||||
| 
						 | 
				
			
			@ -358,8 +330,8 @@ Probe(DriverPtr drv, int flags)
 | 
			
		|||
	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    xfree(usedChips);
 | 
			
		||||
    xfree(devSections);
 | 
			
		||||
    free(usedChips);
 | 
			
		||||
    free(devSections);
 | 
			
		||||
 | 
			
		||||
    return foundScreen;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -385,76 +357,11 @@ FreeRec(ScrnInfoPtr pScrn)
 | 
			
		|||
    if (!pScrn->driverPrivate)
 | 
			
		||||
	return;
 | 
			
		||||
 | 
			
		||||
    xfree(pScrn->driverPrivate);
 | 
			
		||||
    free(pScrn->driverPrivate);
 | 
			
		||||
 | 
			
		||||
    pScrn->driverPrivate = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
ProbeDDC(ScrnInfoPtr pScrn, int index)
 | 
			
		||||
{
 | 
			
		||||
    ConfiguredMonitor = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Bool
 | 
			
		||||
CreateFrontBuffer(ScrnInfoPtr pScrn)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(pScrn);
 | 
			
		||||
    ScreenPtr pScreen = pScrn->pScreen;
 | 
			
		||||
    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
 | 
			
		||||
    Bool fbAccessDisabled;
 | 
			
		||||
    int flags;
 | 
			
		||||
 | 
			
		||||
    pScreen->ModifyPixmapHeader(rootPixmap,
 | 
			
		||||
				pScrn->virtualX, pScrn->virtualY,
 | 
			
		||||
				pScrn->depth, pScrn->bitsPerPixel,
 | 
			
		||||
				pScrn->displayWidth * pScrn->bitsPerPixel / 8,
 | 
			
		||||
				NULL);
 | 
			
		||||
    drmModeAddFB(ms->fd,
 | 
			
		||||
		 pScrn->virtualX,
 | 
			
		||||
		 pScrn->virtualY,
 | 
			
		||||
		 pScrn->depth,
 | 
			
		||||
		 pScrn->bitsPerPixel,
 | 
			
		||||
		 pScrn->displayWidth * pScrn->bitsPerPixel / 8,
 | 
			
		||||
		 driGetPixmapHandle(rootPixmap, &flags), &ms->fb_id);
 | 
			
		||||
 | 
			
		||||
    pScrn->frameX0 = 0;
 | 
			
		||||
    pScrn->frameY0 = 0;
 | 
			
		||||
    AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Bool
 | 
			
		||||
crtc_resize(ScrnInfoPtr pScrn, int width, int height)
 | 
			
		||||
{
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(pScrn);
 | 
			
		||||
    ScreenPtr pScreen = pScrn->pScreen;
 | 
			
		||||
    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
 | 
			
		||||
    Bool fbAccessDisabled;
 | 
			
		||||
    CARD8 *fbstart;
 | 
			
		||||
 | 
			
		||||
    if (width == pScrn->virtualX && height == pScrn->virtualY)
 | 
			
		||||
	return TRUE;
 | 
			
		||||
 | 
			
		||||
    ErrorF("RESIZING TO %dx%d\n", width, height);
 | 
			
		||||
 | 
			
		||||
    pScrn->virtualX = width;
 | 
			
		||||
    pScrn->virtualY = height;
 | 
			
		||||
 | 
			
		||||
    /* HW dependent - FIXME */
 | 
			
		||||
    pScrn->displayWidth = pScrn->virtualX;
 | 
			
		||||
 | 
			
		||||
    drmModeRmFB(ms->fd, ms->fb_id);
 | 
			
		||||
 | 
			
		||||
    /* now create new frontbuffer */
 | 
			
		||||
    return CreateFrontBuffer(pScrn);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const xf86CrtcConfigFuncsRec crtc_config_funcs = {
 | 
			
		||||
    crtc_resize
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static Bool
 | 
			
		||||
PreInit(ScrnInfoPtr pScrn, int flags)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -476,8 +383,7 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 | 
			
		|||
    pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
 | 
			
		||||
 | 
			
		||||
    if (flags & PROBE_DETECT) {
 | 
			
		||||
	ProbeDDC(pScrn, pEnt->index);
 | 
			
		||||
	return TRUE;
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Allocate driverPrivate */
 | 
			
		||||
| 
						 | 
				
			
			@ -503,10 +409,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 | 
			
		|||
    } else
 | 
			
		||||
	ms->entityPrivate = NULL;
 | 
			
		||||
 | 
			
		||||
    if (xf86RegisterResources(ms->pEnt->index, NULL, ResNone)) {
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (xf86IsEntityShared(pScrn->entityList[0])) {
 | 
			
		||||
	if (xf86IsPrimInitDone(pScrn->entityList[0])) {
 | 
			
		||||
	    /* do something */
 | 
			
		||||
| 
						 | 
				
			
			@ -515,7 +417,7 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 | 
			
		|||
	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    BusID = xalloc(64);
 | 
			
		||||
    BusID = malloc(64);
 | 
			
		||||
    sprintf(BusID, "PCI:%d:%d:%d",
 | 
			
		||||
#if XSERVER_LIBPCIACCESS
 | 
			
		||||
	    ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
 | 
			
		||||
| 
						 | 
				
			
			@ -528,11 +430,9 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 | 
			
		|||
	);
 | 
			
		||||
 | 
			
		||||
    ms->fd = drmOpen(NULL, BusID);
 | 
			
		||||
 | 
			
		||||
    if (ms->fd < 0)
 | 
			
		||||
	return FALSE;
 | 
			
		||||
 | 
			
		||||
    pScrn->racMemFlags = RAC_FB | RAC_COLORMAP;
 | 
			
		||||
    pScrn->monitor = pScrn->confScreen->monitor;
 | 
			
		||||
    pScrn->progClock = TRUE;
 | 
			
		||||
    pScrn->rgbBits = 8;
 | 
			
		||||
| 
						 | 
				
			
			@ -562,36 +462,21 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 | 
			
		|||
 | 
			
		||||
    /* Process the options */
 | 
			
		||||
    xf86CollectOptions(pScrn, NULL);
 | 
			
		||||
    if (!(ms->Options = xalloc(sizeof(Options))))
 | 
			
		||||
    if (!(ms->Options = malloc(sizeof(Options))))
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    memcpy(ms->Options, Options, sizeof(Options));
 | 
			
		||||
    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
 | 
			
		||||
 | 
			
		||||
    /* Allocate an xf86CrtcConfig */
 | 
			
		||||
    xf86CrtcConfigInit(pScrn, &crtc_config_funcs);
 | 
			
		||||
    xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 | 
			
		||||
 | 
			
		||||
    max_width = 8192;
 | 
			
		||||
    max_height = 8192;
 | 
			
		||||
    xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height);
 | 
			
		||||
 | 
			
		||||
    if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) {
 | 
			
		||||
	ms->SWCursor = TRUE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SaveHWState(pScrn);
 | 
			
		||||
 | 
			
		||||
    crtc_init(pScrn);
 | 
			
		||||
    output_init(pScrn);
 | 
			
		||||
 | 
			
		||||
    if (!xf86InitialConfiguration(pScrn, TRUE)) {
 | 
			
		||||
	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n");
 | 
			
		||||
	RestoreHWState(pScrn);
 | 
			
		||||
	return FALSE;
 | 
			
		||||
    ms->drmmode.fd = ms->fd;
 | 
			
		||||
    if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
 | 
			
		||||
	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
 | 
			
		||||
	goto fail;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    RestoreHWState(pScrn);
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * If the driver can do gamma correction, it should call xf86SetGamma() here.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -618,29 +503,13 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 | 
			
		|||
	return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    xf86LoaderReqSymLists(fbSymbols, NULL);
 | 
			
		||||
 | 
			
		||||
#ifdef DRI2
 | 
			
		||||
    xf86LoadSubModule(pScrn, "dri2");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Bool
 | 
			
		||||
SaveHWState(ScrnInfoPtr pScrn)
 | 
			
		||||
{
 | 
			
		||||
    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Bool
 | 
			
		||||
RestoreHWState(ScrnInfoPtr pScrn)
 | 
			
		||||
{
 | 
			
		||||
    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
    fail:
 | 
			
		||||
    return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Bool
 | 
			
		||||
| 
						 | 
				
			
			@ -651,26 +520,25 @@ CreateScreenResources(ScreenPtr pScreen)
 | 
			
		|||
    PixmapPtr rootPixmap;
 | 
			
		||||
    Bool ret;
 | 
			
		||||
    int flags;
 | 
			
		||||
 | 
			
		||||
    void *pixels;
 | 
			
		||||
    pScreen->CreateScreenResources = ms->createScreenResources;
 | 
			
		||||
    ret = pScreen->CreateScreenResources(pScreen);
 | 
			
		||||
    pScreen->CreateScreenResources = CreateScreenResources;
 | 
			
		||||
 | 
			
		||||
    if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
 | 
			
		||||
      return FALSE;
 | 
			
		||||
 | 
			
		||||
    drmmode_uevent_init(pScrn, &ms->drmmode);
 | 
			
		||||
 | 
			
		||||
    drmmode_map_cursor_bos(pScrn, &ms->drmmode);
 | 
			
		||||
    pixels = drmmode_map_front_bo(&ms->drmmode);
 | 
			
		||||
    if (!pixels)
 | 
			
		||||
	return FALSE;
 | 
			
		||||
 | 
			
		||||
    rootPixmap = pScreen->GetScreenPixmap(pScreen);
 | 
			
		||||
 | 
			
		||||
    if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
 | 
			
		||||
    if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels))
 | 
			
		||||
	FatalError("Couldn't adjust screen pixmap\n");
 | 
			
		||||
 | 
			
		||||
    drmModeAddFB(ms->fd,
 | 
			
		||||
		 pScrn->virtualX,
 | 
			
		||||
		 pScrn->virtualY,
 | 
			
		||||
		 pScrn->depth,
 | 
			
		||||
		 pScrn->bitsPerPixel,
 | 
			
		||||
		 pScrn->displayWidth * pScrn->bitsPerPixel / 8,
 | 
			
		||||
		 driGetPixmapHandle(rootPixmap, &flags), &ms->fb_id);
 | 
			
		||||
 | 
			
		||||
    AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
 | 
			
		||||
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -688,7 +556,7 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 | 
			
		|||
    if (ms->fd < 0) {
 | 
			
		||||
	char *BusID;
 | 
			
		||||
 | 
			
		||||
	BusID = xalloc(64);
 | 
			
		||||
	BusID = malloc(64);
 | 
			
		||||
	sprintf(BusID, "PCI:%d:%d:%d",
 | 
			
		||||
#if XSERVER_LIBPCIACCESS
 | 
			
		||||
		((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
 | 
			
		||||
| 
						 | 
				
			
			@ -710,6 +578,8 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 | 
			
		|||
 | 
			
		||||
    /* HW dependent - FIXME */
 | 
			
		||||
    pScrn->displayWidth = pScrn->virtualX;
 | 
			
		||||
    if (!drmmode_create_initial_bos(pScrn, &ms->drmmode))
 | 
			
		||||
	return FALSE;
 | 
			
		||||
 | 
			
		||||
    miClearVisualTypes();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -782,10 +652,6 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 | 
			
		|||
    if (serverGeneration == 1)
 | 
			
		||||
	xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 | 
			
		||||
 | 
			
		||||
#ifdef DRI2
 | 
			
		||||
    driScreenInit(pScreen);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    return EnterVT(scrnIndex, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -822,7 +688,7 @@ LeaveVT(int scrnIndex, int flags)
 | 
			
		|||
    for (o = 0; o < config->num_crtc; o++) {
 | 
			
		||||
	xf86CrtcPtr crtc = config->crtc[o];
 | 
			
		||||
 | 
			
		||||
	cursor_destroy(crtc);
 | 
			
		||||
	//	cursor_destroy(crtc);
 | 
			
		||||
 | 
			
		||||
	if (crtc->rotatedPixmap || crtc->rotatedData) {
 | 
			
		||||
	    crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
 | 
			
		||||
| 
						 | 
				
			
			@ -834,16 +700,6 @@ LeaveVT(int scrnIndex, int flags)
 | 
			
		|||
 | 
			
		||||
    drmModeRmFB(ms->fd, ms->fb_id);
 | 
			
		||||
 | 
			
		||||
    RestoreHWState(pScrn);
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    drmMMLock(ms->fd, DRM_BO_MEM_VRAM, 1, 0);
 | 
			
		||||
    drmMMLock(ms->fd, DRM_BO_MEM_TT, 1, 0);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef DRI2
 | 
			
		||||
    driLock(pScrn->pScreen);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    pScrn->vtSema = FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -856,29 +712,6 @@ EnterVT(int scrnIndex, int flags)
 | 
			
		|||
    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(pScrn);
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    if (pScrn->vtSema) {
 | 
			
		||||
	drmMMUnlock(ms->fd, DRM_BO_MEM_VRAM, 1);
 | 
			
		||||
	drmMMUnlock(ms->fd, DRM_BO_MEM_TT, 1);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef DRI2
 | 
			
		||||
    driUnlock(pScrn->pScreen);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Only save state once per server generation since that's what most
 | 
			
		||||
     * drivers do.  Could change this to save state at each VT enter.
 | 
			
		||||
     */
 | 
			
		||||
    if (ms->SaveGeneration != serverGeneration) {
 | 
			
		||||
	ms->SaveGeneration = serverGeneration;
 | 
			
		||||
	SaveHWState(pScrn);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!flags)			       /* signals startup as we'll do this in CreateScreenResources */
 | 
			
		||||
	CreateFrontBuffer(pScrn);
 | 
			
		||||
 | 
			
		||||
    if (!xf86SetDesiredModes(pScrn))
 | 
			
		||||
	return FALSE;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -899,16 +732,13 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen)
 | 
			
		|||
    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
 | 
			
		||||
    modesettingPtr ms = modesettingPTR(pScrn);
 | 
			
		||||
 | 
			
		||||
    drmmode_uevent_fini(pScrn, &ms->drmmode);
 | 
			
		||||
 | 
			
		||||
    drmmode_free_bos(pScrn, &ms->drmmode);
 | 
			
		||||
 | 
			
		||||
    if (pScrn->vtSema) {
 | 
			
		||||
	LeaveVT(scrnIndex, 0);
 | 
			
		||||
#if 0
 | 
			
		||||
	drmMMUnlock(ms->fd, DRM_BO_MEM_VRAM, 1);
 | 
			
		||||
	drmMMUnlock(ms->fd, DRM_BO_MEM_TT, 1);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
#ifdef DRI2
 | 
			
		||||
    driCloseScreen(pScreen);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    pScreen->CreateScreenResources = ms->createScreenResources;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,9 +30,8 @@
 | 
			
		|||
#include <errno.h>
 | 
			
		||||
#include <drm.h>
 | 
			
		||||
#include <xf86drm.h>
 | 
			
		||||
#include <xf86drmMode.h>
 | 
			
		||||
#include <xf86mm.h>
 | 
			
		||||
 | 
			
		||||
#include "drmmode_display.h"
 | 
			
		||||
#define DRV_ERROR(msg)	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
| 
						 | 
				
			
			@ -72,10 +71,7 @@ typedef struct _modesettingRec
 | 
			
		|||
 | 
			
		||||
    void *driver;
 | 
			
		||||
 | 
			
		||||
    /* dri2 */
 | 
			
		||||
    drm_context_t context;
 | 
			
		||||
    drm_hw_lock_t *lock;
 | 
			
		||||
    int lock_held;
 | 
			
		||||
    drmmode_rec drmmode;
 | 
			
		||||
} modesettingRec, *modesettingPtr;
 | 
			
		||||
 | 
			
		||||
#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,125 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright © 2007 Red Hat, Inc.
 | 
			
		||||
 *
 | 
			
		||||
 * 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, sublicense,
 | 
			
		||||
 * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
 | 
			
		||||
 * THE AUTHORS OR COPYRIGHT HOLDERS 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.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *     Dave Airlie <airlied@redhat.com>
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
#ifndef DRMMODE_DISPLAY_H
 | 
			
		||||
#define DRMMODE_DISPLAY_H
 | 
			
		||||
 | 
			
		||||
#include "xf86drmMode.h"
 | 
			
		||||
#ifdef HAVE_UDEV
 | 
			
		||||
#include "libudev.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct dumb_bo {
 | 
			
		||||
  uint32_t handle;
 | 
			
		||||
  uint32_t size;
 | 
			
		||||
  void *ptr;
 | 
			
		||||
  int map_count;
 | 
			
		||||
  uint32_t pitch;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  int fd;
 | 
			
		||||
  unsigned fb_id;
 | 
			
		||||
  drmModeResPtr mode_res;
 | 
			
		||||
  drmModeFBPtr mode_fb;
 | 
			
		||||
  int cpp;
 | 
			
		||||
  ScrnInfoPtr scrn;
 | 
			
		||||
#ifdef HAVE_UDEV
 | 
			
		||||
  struct udev_monitor *uevent_monitor;
 | 
			
		||||
  InputHandlerProc uevent_handler;
 | 
			
		||||
#endif
 | 
			
		||||
  drmEventContext event_context;
 | 
			
		||||
  struct dumb_bo *front_bo;
 | 
			
		||||
} drmmode_rec, *drmmode_ptr;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  drmmode_ptr drmmode;
 | 
			
		||||
  unsigned old_fb_id;
 | 
			
		||||
  int flip_count;
 | 
			
		||||
  void *event_data;
 | 
			
		||||
  unsigned int fe_frame;
 | 
			
		||||
  unsigned int fe_tv_sec;
 | 
			
		||||
  unsigned int fe_tv_usec;
 | 
			
		||||
} drmmode_flipdata_rec, *drmmode_flipdata_ptr;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  drmmode_flipdata_ptr flipdata;
 | 
			
		||||
  Bool dispatch_me;
 | 
			
		||||
} drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
    drmmode_ptr drmmode;
 | 
			
		||||
    drmModeCrtcPtr mode_crtc;
 | 
			
		||||
    int hw_id;
 | 
			
		||||
    struct dumb_bo *cursor_bo;
 | 
			
		||||
  //    struct radeon_bo *rotate_bo;
 | 
			
		||||
    unsigned rotate_fb_id;
 | 
			
		||||
    uint16_t lut_r[256], lut_g[256], lut_b[256];
 | 
			
		||||
} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
    drmModePropertyPtr mode_prop;
 | 
			
		||||
    uint64_t value;
 | 
			
		||||
    int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
 | 
			
		||||
    Atom *atoms;
 | 
			
		||||
} drmmode_prop_rec, *drmmode_prop_ptr;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
    drmmode_ptr drmmode;
 | 
			
		||||
    int output_id;
 | 
			
		||||
    drmModeConnectorPtr mode_output;
 | 
			
		||||
    drmModeEncoderPtr *mode_encoders;
 | 
			
		||||
    drmModePropertyBlobPtr edid_blob;
 | 
			
		||||
    int dpms_enum_id;
 | 
			
		||||
    int num_props;
 | 
			
		||||
    drmmode_prop_ptr props;
 | 
			
		||||
    int enc_mask;
 | 
			
		||||
    int enc_clone_mask;
 | 
			
		||||
} drmmode_output_private_rec, *drmmode_output_private_ptr;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
 | 
			
		||||
//extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr);
 | 
			
		||||
//extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo);
 | 
			
		||||
void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y, int flags);
 | 
			
		||||
extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 | 
			
		||||
extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 | 
			
		||||
extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
 | 
			
		||||
 | 
			
		||||
extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 | 
			
		||||
extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 | 
			
		||||
 | 
			
		||||
extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling);
 | 
			
		||||
extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
 | 
			
		||||
extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
 | 
			
		||||
 | 
			
		||||
//Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *data, int ref_crtc_hw_id);
 | 
			
		||||
Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 | 
			
		||||
void *drmmode_map_front_bo(drmmode_ptr drmmode);
 | 
			
		||||
Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 | 
			
		||||
void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,292 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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 char *connector_enum_list[] = {
 | 
			
		||||
    "Unknown",
 | 
			
		||||
    "VGA",
 | 
			
		||||
    "DVI-I",
 | 
			
		||||
    "DVI-D",
 | 
			
		||||
    "DVI-A",
 | 
			
		||||
    "Composite",
 | 
			
		||||
    "SVIDEO",
 | 
			
		||||
    "LVDS",
 | 
			
		||||
    "Component",
 | 
			
		||||
    "9-pin DIN",
 | 
			
		||||
    "DisplayPort",
 | 
			
		||||
    "HDMI Type A",
 | 
			
		||||
    "HDMI Type B",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
    drmModeConnectorPtr drm_connector = output->driver_private;
 | 
			
		||||
 | 
			
		||||
    switch (drm_connector->connection) {
 | 
			
		||||
    case DRM_MODE_CONNECTED:
 | 
			
		||||
	return XF86OutputStatusConnected;
 | 
			
		||||
    case DRM_MODE_DISCONNECTED:
 | 
			
		||||
	return XF86OutputStatusDisconnected;
 | 
			
		||||
    default:
 | 
			
		||||
	return XF86OutputStatusUnknown;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static DisplayModePtr
 | 
			
		||||
get_modes(xf86OutputPtr output)
 | 
			
		||||
{
 | 
			
		||||
    drmModeConnectorPtr drm_connector = output->driver_private;
 | 
			
		||||
    struct drm_mode_modeinfo *drm_mode = NULL;
 | 
			
		||||
    DisplayModePtr modes = NULL, mode = NULL;
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < drm_connector->count_modes; i++) {
 | 
			
		||||
	drm_mode = &drm_connector->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)
 | 
			
		||||
{
 | 
			
		||||
    drmModeFreeConnector(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;
 | 
			
		||||
    drmModeConnectorPtr drm_connector = NULL;
 | 
			
		||||
    drmModeEncoderPtr drm_encoder = NULL;
 | 
			
		||||
    drmModeCrtcPtr crtc;
 | 
			
		||||
    char *name;
 | 
			
		||||
    int c, v, p;
 | 
			
		||||
 | 
			
		||||
    res = drmModeGetResources(ms->fd);
 | 
			
		||||
    if (res == 0) {
 | 
			
		||||
	DRV_ERROR("Failed drmModeGetResources\n");
 | 
			
		||||
	return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (c = 0; c < res->count_connectors; c++) {
 | 
			
		||||
	drm_connector = drmModeGetConnector(ms->fd, res->connectors[c]);
 | 
			
		||||
	if (!drm_connector)
 | 
			
		||||
	    goto out;
 | 
			
		||||
 | 
			
		||||
	for (p = 0; p < drm_connector->count_props; p++) {
 | 
			
		||||
	    drmModePropertyPtr prop;
 | 
			
		||||
 | 
			
		||||
	    prop = drmModeGetProperty(ms->fd, drm_connector->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]);
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	name = connector_enum_list[drm_connector->connector_type];
 | 
			
		||||
 | 
			
		||||
	output = xf86OutputCreate(pScrn, &output_funcs, name);
 | 
			
		||||
	if (!output)
 | 
			
		||||
	    continue;
 | 
			
		||||
 | 
			
		||||
	drm_encoder = drmModeGetEncoder(ms->fd, drm_connector->encoders[0]);
 | 
			
		||||
	if (drm_encoder) {
 | 
			
		||||
	    output->possible_crtcs = drm_encoder->crtcs;
 | 
			
		||||
	    output->possible_clones = drm_encoder->clones;
 | 
			
		||||
	} else {
 | 
			
		||||
	    output->possible_crtcs = 0;
 | 
			
		||||
	    output->possible_clones = 0;
 | 
			
		||||
	}
 | 
			
		||||
	output->driver_private = drm_connector;
 | 
			
		||||
	output->subpixel_order = SubPixelHorizontalRGB;
 | 
			
		||||
	output->interlaceAllowed = FALSE;
 | 
			
		||||
	output->doubleScanAllowed = FALSE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  out:
 | 
			
		||||
    drmModeFreeResources(res);
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue