/* xf86drmCompat.c -- User-level interface to old DRM device drivers
*
* Copyright 2002 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, 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
* PRECISION INSIGHT 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.
*
* Backwards compatability modules broken out by:
* Jens Owen <jens@tungstengraphics.com>
*
*/
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmCompat.c,v 1.1 2002/10/30 12:52:33 alanh Exp $ */
#ifdef XFree86Server
# include "xf86.h"
# include "xf86_OSproc.h"
# include "xf86_ansic.h"
# define _DRM_MALLOC xalloc
# define _DRM_FREE xfree
# ifndef XFree86LOADER
# include <sys/mman.h>
# endif
#else
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <string.h>
# include <ctype.h>
# include <fcntl.h>
# include <errno.h>
# include <signal.h>
# include <sys/types.h>
# include <sys/ioctl.h>
# include <sys/mman.h>
# include <sys/time.h>
# ifdef DRM_USE_MALLOC
# define _DRM_MALLOC malloc
# define _DRM_FREE free
extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
extern int xf86RemoveSIGIOHandler(int fd);
# else
# include <X11/Xlibint.h>
# define _DRM_MALLOC Xmalloc
# define _DRM_FREE Xfree
# endif
#endif
/* Not all systems have MAP_FAILED defined */
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
#endif
#ifdef __linux__
#include <sys/sysmacros.h> /* for makedev() */
#endif
#include "xf86drm.h"
#include "xf86drmCompat.h"
#include "drm.h"
#include "mga_drm.h"
#include "r128_drm.h"
#include <inttypes.h> /* for int64_t & friends */
#include "radeon_drm.h"
#ifndef __FreeBSD__
#include "sis_drm.h"
#include "i810_drm.h"
#include "i830_drm.h"
#endif
/* WARNING: Do not change, or add, anything to this file. It is only provided
* for binary backwards compatability with the old driver specific DRM
* extensions used before XFree86 4.3.
*/
#ifndef __FreeBSD__
/* I810 */
Bool drmI810CleanupDma(int driSubFD)
{
drm_i810_init_t init;
memset(&init, 0, sizeof(drm_i810_init_t));
init.func = I810_CLEANUP_DMA;
if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) {
return 0; /* FALSE */
}
return 1; /* TRUE */
}
Bool drmI810InitDma(int driSubFD, drmCompatI810Init *info)
{
drm_i810_init_t init;
memset(&init, 0, sizeof(drm_i810_init_t));
init.func = I810_INIT_DMA;
init.mmio_offset = info->mmio_offset;
init.buffers_offset = info->buffers_offset;
init.ring_start = info->start;
init.ring_end = info->end;
init.ring_size = info->size;
init.sarea_priv_offset = info->sarea_off;
init.front_offset = info->front_offset;
init.back_offset = info->back_offset;
init.depth_offset = info->depth_offset;
init.overlay_offset = info->overlay_offset;
init.overlay_physical = info->overlay_physical;
init.w = info->w;
init.h = info->h;
init.pitch = info->pitch;
init.pitch_bits = info->pitch_bits;
if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) {
return 0; /* FALSE */
}
return 1; /* TRUE */
}
#endif /* __FreeBSD__ */
/* Mga */
#define MGA_IDLE_RETRY 2048
int drmMGAInitDMA( int fd, drmCompatMGAInit *info )
{
drm_mga_init_t init;
memset( &init, 0, sizeof(drm_mga_init_t) );
init.func = MGA_INIT_DMA;
init.sarea_priv_offset = info->sarea_priv_offset;
init.sgram = info->sgram;
|