mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2026-05-05 00:48:08 +02:00
Added basic framework for drmCommand interface for new HW specific
extensions that need to be passed to the kernel DRM drivers. The old
style interface will be frozen with 4.2 and contained in the
xf86drmCompat.c module for backwards compatability.
This version only has RadeonInitCP transitioned to the new interface. All
the other driver specific drm calls still need to be converted.
This commit is contained in:
parent
2ab6ff7190
commit
ed7b270ac3
6 changed files with 198 additions and 3 deletions
|
|
@ -1407,4 +1407,44 @@ int drmRemoveSIGIOHandler(int fd)
|
|||
|
||||
return xf86RemoveSIGIOHandler(fd);
|
||||
}
|
||||
|
||||
int drmCommandNone(int fd, unsigned long drmCommandIndex)
|
||||
{
|
||||
void *data = NULL; /* dummy */
|
||||
unsigned long request;
|
||||
|
||||
request = DRM_IO( DRM_COMMAND_BASE + drmCommandIndex);
|
||||
|
||||
return ioctl(fd, request, data);
|
||||
}
|
||||
|
||||
int drmCommandRead(int fd, unsigned long drmCommandIndex,
|
||||
void *data, unsigned long size )
|
||||
{
|
||||
unsigned long request;
|
||||
|
||||
request = DRM_IOR( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
|
||||
return ioctl(fd, request, data);
|
||||
}
|
||||
|
||||
int drmCommandWrite(int fd, unsigned long drmCommandIndex,
|
||||
void *data, unsigned long size )
|
||||
{
|
||||
unsigned long request;
|
||||
|
||||
request = DRM_IOW( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
|
||||
return ioctl(fd, request, data);
|
||||
}
|
||||
|
||||
int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
|
||||
void *data, unsigned long size )
|
||||
{
|
||||
unsigned long request;
|
||||
|
||||
request = DRM_IOWR( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
|
||||
return ioctl(fd, request, data);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
126
libdrm/xf86drmCompat.c
Normal file
126
libdrm/xf86drmCompat.c
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/* xf86drmCompat.c -- User-level interface to old DRM devices
|
||||
*
|
||||
* Copyright 2000 VA Linx Systems, Inc., Fremont, California.
|
||||
* 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.
|
||||
*
|
||||
* Original Authors:
|
||||
* Gareth Hughes <gareth@valinux.com>
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
*
|
||||
* Backwards compatability modules broken out by:
|
||||
* Jens Owen <jens@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v 1.4 2001/08/27 17:40:59 dawes 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"
|
||||
|
||||
|
||||
/* WARNING: Do not change, or add, anything to this file. It is only provided
|
||||
* for backwards compatability with the old driver specific DRM extensions
|
||||
* found in XFree86 4.0, 4.1 and 4.2.
|
||||
*/
|
||||
|
||||
|
||||
int drmRadeonInitCP( int fd, drmCompatRadeonInit *info )
|
||||
{
|
||||
drm_radeon_init_t init;
|
||||
|
||||
memset( &init, 0, sizeof(drm_radeon_init_t) );
|
||||
|
||||
init.func = RADEON_INIT_CP;
|
||||
init.sarea_priv_offset = info->sarea_priv_offset;
|
||||
init.is_pci = info->is_pci;
|
||||
init.cp_mode = info->cp_mode;
|
||||
init.agp_size = info->agp_size;
|
||||
init.ring_size = info->ring_size;
|
||||
init.usec_timeout = info->usec_timeout;
|
||||
|
||||
init.fb_bpp = info->fb_bpp;
|
||||
init.front_offset = info->front_offset;
|
||||
init.front_pitch = info->front_pitch;
|
||||
init.back_offset = info->back_offset;
|
||||
init.back_pitch = info->back_pitch;
|
||||
|
||||
init.depth_bpp = info->depth_bpp;
|
||||
init.depth_offset = info->depth_offset;
|
||||
init.depth_pitch = info->depth_pitch;
|
||||
|
||||
init.fb_offset = info->fb_offset;
|
||||
init.mmio_offset = info->mmio_offset;
|
||||
init.ring_offset = info->ring_offset;
|
||||
init.ring_rptr_offset = info->ring_rptr_offset;
|
||||
init.buffers_offset = info->buffers_offset;
|
||||
init.agp_textures_offset = info->agp_textures_offset;
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_CP_INIT, &init ) ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
10
linux/drm.h
10
linux/drm.h
|
|
@ -428,6 +428,14 @@ typedef struct drm_scatter_gather {
|
|||
#define DRM_IOCTL_SG_ALLOC DRM_IOW( 0x38, drm_scatter_gather_t)
|
||||
#define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, drm_scatter_gather_t)
|
||||
|
||||
/* Device specfic ioctls should only be in their respective headers,
|
||||
* however, a few device specific ioctls defined before XFree86 4.3
|
||||
* are left here to preserve compatability. Do not add new device
|
||||
* specific ioctls here.
|
||||
*
|
||||
* The device specific ioctl range is 0x40 to 0x79. */
|
||||
#define DRM_COMMAND_BASE 0x40
|
||||
|
||||
/* MGA specific ioctls */
|
||||
#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
|
||||
#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x41, drm_lock_t)
|
||||
|
|
@ -475,7 +483,7 @@ typedef struct drm_scatter_gather {
|
|||
#define DRM_IOCTL_R128_CLEAR2 DRM_IOW( 0x51, drm_r128_clear2_t)
|
||||
|
||||
/* Radeon specific ioctls */
|
||||
#define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( 0x40, drm_radeon_init_t)
|
||||
#define DRM_COMPAT_IOCTL_RADEON_CP_INIT DRM_IOW( 0x40, drm_radeon_init_t)
|
||||
#define DRM_IOCTL_RADEON_CP_START DRM_IO( 0x41)
|
||||
#define DRM_IOCTL_RADEON_CP_STOP DRM_IOW( 0x42, drm_radeon_cp_stop_t)
|
||||
#define DRM_IOCTL_RADEON_CP_RESET DRM_IO( 0x43)
|
||||
|
|
|
|||
|
|
@ -236,7 +236,12 @@ typedef struct {
|
|||
|
||||
/* WARNING: If you change any of these defines, make sure to change the
|
||||
* defines in the Xserver file (xf86drmRadeon.h)
|
||||
*
|
||||
* KW: actually it's illegal to change any of this (backwards compatibility).
|
||||
*/
|
||||
|
||||
#define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( 0x40, drm_radeon_init_t)
|
||||
|
||||
typedef struct drm_radeon_init {
|
||||
enum {
|
||||
RADEON_INIT_CP = 0x01,
|
||||
|
|
|
|||
|
|
@ -428,6 +428,14 @@ typedef struct drm_scatter_gather {
|
|||
#define DRM_IOCTL_SG_ALLOC DRM_IOW( 0x38, drm_scatter_gather_t)
|
||||
#define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, drm_scatter_gather_t)
|
||||
|
||||
/* Device specfic ioctls should only be in their respective headers,
|
||||
* however, a few device specific ioctls defined before XFree86 4.3
|
||||
* are left here to preserve compatability. Do not add new device
|
||||
* specific ioctls here.
|
||||
*
|
||||
* The device specific ioctl range is 0x40 to 0x79. */
|
||||
#define DRM_COMMAND_BASE 0x40
|
||||
|
||||
/* MGA specific ioctls */
|
||||
#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
|
||||
#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x41, drm_lock_t)
|
||||
|
|
@ -475,7 +483,7 @@ typedef struct drm_scatter_gather {
|
|||
#define DRM_IOCTL_R128_CLEAR2 DRM_IOW( 0x51, drm_r128_clear2_t)
|
||||
|
||||
/* Radeon specific ioctls */
|
||||
#define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( 0x40, drm_radeon_init_t)
|
||||
#define DRM_COMPAT_IOCTL_RADEON_CP_INIT DRM_IOW( 0x40, drm_radeon_init_t)
|
||||
#define DRM_IOCTL_RADEON_CP_START DRM_IO( 0x41)
|
||||
#define DRM_IOCTL_RADEON_CP_STOP DRM_IOW( 0x42, drm_radeon_cp_stop_t)
|
||||
#define DRM_IOCTL_RADEON_CP_RESET DRM_IO( 0x43)
|
||||
|
|
|
|||
10
shared/drm.h
10
shared/drm.h
|
|
@ -428,6 +428,14 @@ typedef struct drm_scatter_gather {
|
|||
#define DRM_IOCTL_SG_ALLOC DRM_IOW( 0x38, drm_scatter_gather_t)
|
||||
#define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, drm_scatter_gather_t)
|
||||
|
||||
/* Device specfic ioctls should only be in their respective headers,
|
||||
* however, a few device specific ioctls defined before XFree86 4.3
|
||||
* are left here to preserve compatability. Do not add new device
|
||||
* specific ioctls here.
|
||||
*
|
||||
* The device specific ioctl range is 0x40 to 0x79. */
|
||||
#define DRM_COMMAND_BASE 0x40
|
||||
|
||||
/* MGA specific ioctls */
|
||||
#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
|
||||
#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x41, drm_lock_t)
|
||||
|
|
@ -475,7 +483,7 @@ typedef struct drm_scatter_gather {
|
|||
#define DRM_IOCTL_R128_CLEAR2 DRM_IOW( 0x51, drm_r128_clear2_t)
|
||||
|
||||
/* Radeon specific ioctls */
|
||||
#define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( 0x40, drm_radeon_init_t)
|
||||
#define DRM_COMPAT_IOCTL_RADEON_CP_INIT DRM_IOW( 0x40, drm_radeon_init_t)
|
||||
#define DRM_IOCTL_RADEON_CP_START DRM_IO( 0x41)
|
||||
#define DRM_IOCTL_RADEON_CP_STOP DRM_IOW( 0x42, drm_radeon_cp_stop_t)
|
||||
#define DRM_IOCTL_RADEON_CP_RESET DRM_IO( 0x43)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue