via changes:

1. Initialize futex locks to zero on device init.
2. Remove some stray defines from via_drm.h
3. Prepare via_drm.h for drm client inclusion. The goal is to share a
    common file with common definitions.
4. Sync shared / shared-core via_drm.h
5. Bump minor, because of the futex lock initialization.
main
Thomas Hellstrom 2005-03-14 22:50:21 +00:00
parent a396617dbc
commit d2fd920095
8 changed files with 68 additions and 62 deletions

View File

@ -31,15 +31,16 @@
#ifndef _VIA_DEFINES_ #ifndef _VIA_DEFINES_
#define _VIA_DEFINES_ #define _VIA_DEFINES_
#define VIA_DMA_BUF_ORDER 12 #ifndef __KERNEL__
#define VIA_DMA_BUF_SZ (1 << VIA_DMA_BUF_ORDER) #include "via_drmclient.h"
#define VIA_DMA_BUF_NR 256 #endif
#define VIA_NR_SAREA_CLIPRECTS 8 #define VIA_NR_SAREA_CLIPRECTS 8
#define VIA_NR_XVMC_PORTS 10 #define VIA_NR_XVMC_PORTS 10
#define VIA_NR_XVMC_LOCKS 5 #define VIA_NR_XVMC_LOCKS 5
#define VIA_MAX_CACHELINE_SIZE 64 #define VIA_MAX_CACHELINE_SIZE 64
#define XVMCLOCKPTR(saPriv,lockNo) \ #define XVMCLOCKPTR(saPriv,lockNo) \
((volatile int *)(((((unsigned long) (saPriv)->XvMCLockArea) + \ ((volatile drm_hw_lock_t *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
(VIA_MAX_CACHELINE_SIZE - 1)) & \ (VIA_MAX_CACHELINE_SIZE - 1)) & \
~(VIA_MAX_CACHELINE_SIZE - 1)) + \ ~(VIA_MAX_CACHELINE_SIZE - 1)) + \
VIA_MAX_CACHELINE_SIZE*(lockNo))) VIA_MAX_CACHELINE_SIZE*(lockNo)))

View File

@ -28,11 +28,11 @@
#define DRIVER_NAME "via" #define DRIVER_NAME "via"
#define DRIVER_DESC "VIA Unichrome" #define DRIVER_DESC "VIA Unichrome"
#define DRIVER_DATE "20050214" #define DRIVER_DATE "20050314"
#define DRIVER_MAJOR 2 #define DRIVER_MAJOR 2
#define DRIVER_MINOR 4 #define DRIVER_MINOR 5
#define DRIVER_PATCHLEVEL 6 #define DRIVER_PATCHLEVEL 0
#include "via_verifier.h" #include "via_verifier.h"

View File

@ -67,8 +67,10 @@ static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init)
dev_priv->agpAddr = init->agpAddr; dev_priv->agpAddr = init->agpAddr;
for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i])); DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i]));
XVMCLOCKPTR(dev_priv->sarea_priv, i)->lock = 0;
}
dev->dev_private = (void *)dev_priv; dev->dev_private = (void *)dev_priv;
@ -109,6 +111,7 @@ int via_map_init(DRM_IOCTL_ARGS)
return -EINVAL; return -EINVAL;
} }
int via_decoder_futex(DRM_IOCTL_ARGS) int via_decoder_futex(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
@ -123,7 +126,7 @@ int via_decoder_futex(DRM_IOCTL_ARGS)
if (fx.lock > VIA_NR_XVMC_LOCKS) if (fx.lock > VIA_NR_XVMC_LOCKS)
return -EFAULT; return -EFAULT;
lock = XVMCLOCKPTR(sAPriv, fx.lock); lock = (int *)XVMCLOCKPTR(sAPriv, fx.lock);
switch (fx.func) { switch (fx.func) {
case VIA_FUTEX_WAIT: case VIA_FUTEX_WAIT:

View File

@ -179,10 +179,9 @@ int via_final_context(struct drm_device *dev, int context)
*/ */
for (i=0; i < VIA_NR_XVMC_LOCKS; ++i) { for (i=0; i < VIA_NR_XVMC_LOCKS; ++i) {
lock = XVMCLOCKPTR(sAPriv, i); lock = (int *) XVMCLOCKPTR(sAPriv, i);
if ( (_DRM_LOCKING_CONTEXT( *lock ) == context) && if ( (_DRM_LOCKING_CONTEXT( *lock ) == context)) {
(_DRM_LOCK_IS_HELD( *lock ))) { if (_DRM_LOCK_IS_HELD( *lock ) && (*lock & _DRM_LOCK_CONT)) {
if ( *lock & _DRM_LOCK_CONT) {
DRM_WAKEUP( &(dev_priv->decoder_queue[i])); DRM_WAKEUP( &(dev_priv->decoder_queue[i]));
} }
*lock = 0; *lock = 0;

View File

@ -30,11 +30,11 @@
#define DRIVER_NAME "via" #define DRIVER_NAME "via"
#define DRIVER_DESC "VIA Unichrome" #define DRIVER_DESC "VIA Unichrome"
#define DRIVER_DATE "20050214" #define DRIVER_DATE "20050314"
#define DRIVER_MAJOR 2 #define DRIVER_MAJOR 2
#define DRIVER_MINOR 4 #define DRIVER_MINOR 5
#define DRIVER_PATCHLEVEL 6 #define DRIVER_PATCHLEVEL 0
#define DRIVER_IOCTLS \ #define DRIVER_IOCTLS \
[DRM_IOCTL_NR(DRM_IOCTL_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0 }, \

View File

@ -31,15 +31,16 @@
#ifndef _VIA_DEFINES_ #ifndef _VIA_DEFINES_
#define _VIA_DEFINES_ #define _VIA_DEFINES_
#define VIA_DMA_BUF_ORDER 12 #ifndef __KERNEL__
#define VIA_DMA_BUF_SZ (1 << VIA_DMA_BUF_ORDER) #include "via_drmclient.h"
#define VIA_DMA_BUF_NR 256 #endif
#define VIA_NR_SAREA_CLIPRECTS 8 #define VIA_NR_SAREA_CLIPRECTS 8
#define VIA_NR_XVMC_PORTS 10 #define VIA_NR_XVMC_PORTS 10
#define VIA_NR_XVMC_LOCKS 5 #define VIA_NR_XVMC_LOCKS 5
#define VIA_MAX_CACHELINE_SIZE 64 #define VIA_MAX_CACHELINE_SIZE 64
#define XVMCLOCKPTR(saPriv,lockNo) \ #define XVMCLOCKPTR(saPriv,lockNo) \
((volatile int *)(((((unsigned long) (saPriv)->XvMCLockArea) + \ ((volatile drm_hw_lock_t *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
(VIA_MAX_CACHELINE_SIZE - 1)) & \ (VIA_MAX_CACHELINE_SIZE - 1)) & \
~(VIA_MAX_CACHELINE_SIZE - 1)) + \ ~(VIA_MAX_CACHELINE_SIZE - 1)) + \
VIA_MAX_CACHELINE_SIZE*(lockNo))) VIA_MAX_CACHELINE_SIZE*(lockNo)))
@ -60,18 +61,31 @@
#define VIA_UPLOAD_ALL 0xff #define VIA_UPLOAD_ALL 0xff
/* VIA specific ioctls */ /* VIA specific ioctls */
#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(0x40, drm_via_mem_t) #define DRM_VIA_ALLOCMEM 0x00
#define DRM_IOCTL_VIA_FREEMEM DRM_IOW(0x41, drm_via_mem_t) #define DRM_VIA_FREEMEM 0x01
#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(0x42, drm_via_agp_t) #define DRM_VIA_AGP_INIT 0x02
#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(0x43, drm_via_fb_t) #define DRM_VIA_FB_INIT 0x03
#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(0x44, drm_via_init_t) #define DRM_VIA_MAP_INIT 0x04
#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW(0x45, drm_via_futex_t) #define DRM_VIA_DEC_FUTEX 0x05
#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(0x47, drm_via_dma_init_t) #define NOT_USED
#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW(0x48, drm_via_cmdbuffer_t) #define DRM_VIA_DMA_INIT 0x07
#define DRM_IOCTL_VIA_FLUSH DRM_IO(0x49) #define DRM_VIA_CMDBUFFER 0x08
#define DRM_IOCTL_VIA_PCICMD DRM_IOW(0x4A, drm_via_cmdbuffer_t) #define DRM_VIA_FLUSH 0x09
#define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR(0x4B, drm_via_cmdbuf_size_t) #define DRM_VIA_PCICMD 0x0a
#define DRM_VIA_CMDBUF_SIZE 0x0b
#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
#define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
#define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
#define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
#define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
drm_via_cmdbuf_size_t)
/* Indices into buf.Setup where various bits of state are mirrored per /* Indices into buf.Setup where various bits of state are mirrored per
* context and per buffer. These can be fired at the card as a unit, * context and per buffer. These can be fired at the card as a unit,
@ -89,19 +103,19 @@
#define VIDEO 0 #define VIDEO 0
#define AGP 1 #define AGP 1
typedef struct { typedef struct {
unsigned long offset; uint32_t offset;
unsigned long size; uint32_t size;
} drm_via_agp_t; } drm_via_agp_t;
typedef struct { typedef struct {
unsigned long offset; uint32_t offset;
unsigned long size; uint32_t size;
} drm_via_fb_t; } drm_via_fb_t;
typedef struct { typedef struct {
uint32_t context; uint32_t context;
uint32_t type; uint32_t type;
unsigned long size; uint32_t size;
unsigned long index; unsigned long index;
unsigned long offset; unsigned long offset;
} drm_via_mem_t; } drm_via_mem_t;
@ -177,20 +191,6 @@ typedef struct _drm_via_sarea {
} drm_via_sarea_t; } drm_via_sarea_t;
typedef struct _drm_via_flush_agp {
unsigned int offset;
unsigned int size;
unsigned int index;
int discard; /* client is finished with the buffer? */
} drm_via_flush_agp_t;
typedef struct _drm_via_flush_sys {
unsigned int offset;
unsigned int size;
unsigned long index;
int discard; /* client is finished with the buffer? */
} drm_via_flush_sys_t;
typedef struct _drm_via_cmdbuf_size { typedef struct _drm_via_cmdbuf_size {
enum { enum {
VIA_CMDBUF_SPACE = 0x01, VIA_CMDBUF_SPACE = 0x01,
@ -200,6 +200,7 @@ typedef struct _drm_via_cmdbuf_size {
uint32_t size; uint32_t size;
} drm_via_cmdbuf_size_t; } drm_via_cmdbuf_size_t;
#ifdef __KERNEL__ #ifdef __KERNEL__
int via_fb_init(DRM_IOCTL_ARGS); int via_fb_init(DRM_IOCTL_ARGS);

View File

@ -69,8 +69,10 @@ int via_do_init_map(drm_device_t * dev, drm_via_init_t * init)
dev_priv->agpAddr = init->agpAddr; dev_priv->agpAddr = init->agpAddr;
for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i])); DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i]));
XVMCLOCKPTR(dev_priv->sarea_priv, i)->lock = 0;
}
dev->dev_private = (void *)dev_priv; dev->dev_private = (void *)dev_priv;
@ -111,6 +113,7 @@ int via_map_init(DRM_IOCTL_ARGS)
return -EINVAL; return -EINVAL;
} }
int via_decoder_futex(DRM_IOCTL_ARGS) int via_decoder_futex(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
@ -125,7 +128,7 @@ int via_decoder_futex(DRM_IOCTL_ARGS)
if (fx.lock > VIA_NR_XVMC_LOCKS) if (fx.lock > VIA_NR_XVMC_LOCKS)
return -EFAULT; return -EFAULT;
lock = XVMCLOCKPTR(sAPriv, fx.lock); lock = (int *)XVMCLOCKPTR(sAPriv, fx.lock);
switch (fx.func) { switch (fx.func) {
case VIA_FUTEX_WAIT: case VIA_FUTEX_WAIT:

View File

@ -177,10 +177,9 @@ int via_final_context(struct drm_device *dev, int context)
*/ */
for (i=0; i < VIA_NR_XVMC_LOCKS; ++i) { for (i=0; i < VIA_NR_XVMC_LOCKS; ++i) {
lock = XVMCLOCKPTR(sAPriv, i); lock = (int *) XVMCLOCKPTR(sAPriv, i);
if ( (_DRM_LOCKING_CONTEXT( *lock ) == context) && if ( (_DRM_LOCKING_CONTEXT( *lock ) == context)) {
(_DRM_LOCK_IS_HELD( *lock ))) { if (_DRM_LOCK_IS_HELD( *lock ) && (*lock & _DRM_LOCK_CONT)) {
if ( *lock & _DRM_LOCK_CONT) {
DRM_WAKEUP( &(dev_priv->decoder_queue[i])); DRM_WAKEUP( &(dev_priv->decoder_queue[i]));
} }
*lock = 0; *lock = 0;