mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-31 14:50:14 +01:00
Converted all the radeon specific drm calls to drmCommand interface for 2D
driver. 3D driver is not converted, yet...I don't expect a full build
to work at this point.
This commit is contained in:
parent
ed7b270ac3
commit
a0effcf496
2 changed files with 334 additions and 15 deletions
|
|
@ -1410,41 +1410,53 @@ int drmRemoveSIGIOHandler(int fd)
|
|||
|
||||
int drmCommandNone(int fd, unsigned long drmCommandIndex)
|
||||
{
|
||||
void *data = NULL; /* dummy */
|
||||
unsigned long request;
|
||||
void *data = NULL; /* dummy */
|
||||
unsigned long request;
|
||||
|
||||
request = DRM_IO( DRM_COMMAND_BASE + drmCommandIndex);
|
||||
request = DRM_IO( DRM_COMMAND_BASE + drmCommandIndex);
|
||||
|
||||
return ioctl(fd, request, data);
|
||||
if (ioctl(fd, request, data)) {
|
||||
return -errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drmCommandRead(int fd, unsigned long drmCommandIndex,
|
||||
void *data, unsigned long size )
|
||||
{
|
||||
unsigned long request;
|
||||
unsigned long request;
|
||||
|
||||
request = DRM_IOR( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
request = DRM_IOR( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
|
||||
return ioctl(fd, request, data);
|
||||
if (ioctl(fd, request, data)) {
|
||||
return -errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drmCommandWrite(int fd, unsigned long drmCommandIndex,
|
||||
void *data, unsigned long size )
|
||||
{
|
||||
unsigned long request;
|
||||
unsigned long request;
|
||||
|
||||
request = DRM_IOW( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
request = DRM_IOW( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
|
||||
return ioctl(fd, request, data);
|
||||
if (ioctl(fd, request, data)) {
|
||||
return -errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
|
||||
void *data, unsigned long size )
|
||||
{
|
||||
unsigned long request;
|
||||
unsigned long request;
|
||||
|
||||
request = DRM_IOWR( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
request = DRM_IOWR( DRM_COMMAND_BASE + drmCommandIndex, size);
|
||||
|
||||
return ioctl(fd, request, data);
|
||||
if (ioctl(fd, request, data)) {
|
||||
return -errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -81,10 +81,58 @@ extern int xf86RemoveSIGIOHandler(int fd);
|
|||
|
||||
|
||||
/* 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.
|
||||
* for binary backwards compatability with the old driver specific DRM
|
||||
* extensions used before XFree86 4.3.
|
||||
*/
|
||||
|
||||
/* I810 */
|
||||
/*
|
||||
drmI810CleanupDma
|
||||
drmI810InitDma
|
||||
*/
|
||||
|
||||
/* Mga */
|
||||
/*
|
||||
drmMGAAgpBlit
|
||||
drmMGACleanupDMA
|
||||
drmMGAClear
|
||||
drmMGAEngineReset
|
||||
drmMGAFlushDMA
|
||||
drmMGAFlushIndices
|
||||
drmMGAFlushVertexBuffer
|
||||
drmMGAFullScreen
|
||||
drmMGAInitDMA
|
||||
drmMGASwapBuffers
|
||||
drmMGATextureLoad
|
||||
*/
|
||||
|
||||
/* R128 */
|
||||
/*
|
||||
drmR128CleanupCCE
|
||||
drmR128Clear
|
||||
drmR128EngineReset
|
||||
drmR128FlushIndices
|
||||
drmR128FlushIndirectBuffer
|
||||
drmR128FlushVertexBuffer
|
||||
drmR128FullScreen
|
||||
drmR128InitCCE
|
||||
drmR128PolygonStipple
|
||||
drmR128ReadDepthPixels
|
||||
drmR128ReadDepthSpan
|
||||
drmR128ResetCCE
|
||||
drmR128StartCCE
|
||||
drmR128StopCCE
|
||||
drmR128SwapBuffers
|
||||
drmR128TextureBlit
|
||||
drmR128WaitForIdleCCE
|
||||
drmR128WriteDepthPixels
|
||||
drmR128WriteDepthSpan
|
||||
*/
|
||||
|
||||
/* Radeon */
|
||||
|
||||
#define RADEON_BUFFER_RETRY 32
|
||||
#define RADEON_IDLE_RETRY 16
|
||||
|
||||
int drmRadeonInitCP( int fd, drmCompatRadeonInit *info )
|
||||
{
|
||||
|
|
@ -124,3 +172,262 @@ int drmRadeonInitCP( int fd, drmCompatRadeonInit *info )
|
|||
}
|
||||
}
|
||||
|
||||
int drmRadeonCleanupCP( int fd )
|
||||
{
|
||||
drm_radeon_init_t init;
|
||||
|
||||
memset( &init, 0, sizeof(drm_radeon_init_t) );
|
||||
|
||||
init.func = RADEON_CLEANUP_CP;
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_CP_INIT, &init ) ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonStartCP( int fd )
|
||||
{
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_CP_START, NULL ) ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonStopCP( int fd )
|
||||
{
|
||||
drm_radeon_cp_stop_t stop;
|
||||
int ret, i = 0;
|
||||
|
||||
stop.flush = 1;
|
||||
stop.idle = 1;
|
||||
|
||||
ret = ioctl( fd, DRM_IOCTL_RADEON_CP_STOP, &stop );
|
||||
|
||||
if ( ret == 0 ) {
|
||||
return 0;
|
||||
} else if ( errno != EBUSY ) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
stop.flush = 0;
|
||||
|
||||
do {
|
||||
ret = ioctl( fd, DRM_IOCTL_RADEON_CP_STOP, &stop );
|
||||
} while ( ret && errno == EBUSY && i++ < RADEON_IDLE_RETRY );
|
||||
|
||||
if ( ret == 0 ) {
|
||||
return 0;
|
||||
} else if ( errno != EBUSY ) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
stop.idle = 0;
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_CP_STOP, &stop ) ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonResetCP( int fd )
|
||||
{
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_CP_RESET, NULL ) ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonWaitForIdleCP( int fd )
|
||||
{
|
||||
int ret, i = 0;
|
||||
|
||||
do {
|
||||
ret = ioctl( fd, DRM_IOCTL_RADEON_CP_IDLE, NULL );
|
||||
} while ( ret && errno == EBUSY && i++ < RADEON_IDLE_RETRY );
|
||||
|
||||
if ( ret == 0 ) {
|
||||
return 0;
|
||||
} else {
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonEngineReset( int fd )
|
||||
{
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_RESET, NULL ) ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonFullScreen( int fd, int enable )
|
||||
{
|
||||
drm_radeon_fullscreen_t fs;
|
||||
|
||||
if ( enable ) {
|
||||
fs.func = RADEON_INIT_FULLSCREEN;
|
||||
} else {
|
||||
fs.func = RADEON_CLEANUP_FULLSCREEN;
|
||||
}
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_FULLSCREEN, &fs ) ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonSwapBuffers( int fd )
|
||||
{
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_SWAP, NULL ) ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonClear( int fd, unsigned int flags,
|
||||
unsigned int clear_color, unsigned int clear_depth,
|
||||
unsigned int color_mask, unsigned int stencil,
|
||||
void *b, int nbox )
|
||||
{
|
||||
drm_radeon_clear_t clear;
|
||||
drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
|
||||
drm_clip_rect_t *boxes = (drm_clip_rect_t *)b;
|
||||
int i;
|
||||
|
||||
clear.flags = flags;
|
||||
clear.clear_color = clear_color;
|
||||
clear.clear_depth = clear_depth;
|
||||
clear.color_mask = color_mask;
|
||||
clear.depth_mask = stencil; /* misnamed field in ioctl */
|
||||
clear.depth_boxes = depth_boxes;
|
||||
|
||||
/* We can remove this when we do real depth clears, instead of
|
||||
* rendering a rectangle into the depth buffer. This prevents
|
||||
* floating point calculations being done in the kernel.
|
||||
*/
|
||||
for ( i = 0 ; i < nbox ; i++ ) {
|
||||
depth_boxes[i].f[CLEAR_X1] = (float)boxes[i].x1;
|
||||
depth_boxes[i].f[CLEAR_Y1] = (float)boxes[i].y1;
|
||||
depth_boxes[i].f[CLEAR_X2] = (float)boxes[i].x2;
|
||||
depth_boxes[i].f[CLEAR_Y2] = (float)boxes[i].y2;
|
||||
depth_boxes[i].f[CLEAR_DEPTH] = (float)clear_depth;
|
||||
}
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_CLEAR, &clear ) < 0 ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonFlushVertexBuffer( int fd, int prim, int index,
|
||||
int count, int discard )
|
||||
{
|
||||
drm_radeon_vertex_t v;
|
||||
|
||||
v.prim = prim;
|
||||
v.idx = index;
|
||||
v.count = count;
|
||||
v.discard = discard;
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_VERTEX, &v ) < 0 ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonFlushIndices( int fd, int prim, int index,
|
||||
int start, int end, int discard )
|
||||
{
|
||||
drm_radeon_indices_t elts;
|
||||
|
||||
elts.prim = prim;
|
||||
elts.idx = index;
|
||||
elts.start = start;
|
||||
elts.end = end;
|
||||
elts.discard = discard;
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_INDICES, &elts ) < 0 ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonLoadTexture( int fd, int offset, int pitch, int format, int width,
|
||||
int height, drmCompatRadeonTexImage *image )
|
||||
{
|
||||
drm_radeon_texture_t tex;
|
||||
drm_radeon_tex_image_t tmp;
|
||||
int ret;
|
||||
|
||||
tex.offset = offset;
|
||||
tex.pitch = pitch;
|
||||
tex.format = format;
|
||||
tex.width = width;
|
||||
tex.height = height;
|
||||
tex.image = &tmp;
|
||||
|
||||
/* This gets updated by the kernel when a multipass blit is needed.
|
||||
*/
|
||||
memcpy( &tmp, image, sizeof(drm_radeon_tex_image_t) );
|
||||
|
||||
do {
|
||||
ret = ioctl( fd, DRM_IOCTL_RADEON_TEXTURE, &tex );
|
||||
} while ( ret && errno == EAGAIN );
|
||||
|
||||
if ( ret == 0 ) {
|
||||
return 0;
|
||||
} else {
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonPolygonStipple( int fd, unsigned int *mask )
|
||||
{
|
||||
drm_radeon_stipple_t stipple;
|
||||
|
||||
stipple.mask = mask;
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_STIPPLE, &stipple ) < 0 ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int drmRadeonFlushIndirectBuffer( int fd, int index,
|
||||
int start, int end, int discard )
|
||||
{
|
||||
drm_radeon_indirect_t ind;
|
||||
|
||||
ind.idx = index;
|
||||
ind.start = start;
|
||||
ind.end = end;
|
||||
ind.discard = discard;
|
||||
|
||||
if ( ioctl( fd, DRM_IOCTL_RADEON_INDIRECT, &ind ) < 0 ) {
|
||||
return -errno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* SiS */
|
||||
/*
|
||||
drmSiSAgpInit
|
||||
*/
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue