aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/XvMC/hw/via
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/XvMC/hw/via')
-rw-r--r--nx-X11/lib/XvMC/hw/via/driDrawable.c176
-rw-r--r--nx-X11/lib/XvMC/hw/via/driDrawable.h64
-rw-r--r--nx-X11/lib/XvMC/hw/via/unichrome/Imakefile51
-rw-r--r--nx-X11/lib/XvMC/hw/via/unichrome/viaLowLevel.c1056
-rw-r--r--nx-X11/lib/XvMC/hw/via/unichromeProA/Imakefile50
-rw-r--r--nx-X11/lib/XvMC/hw/via/unichromeProA/viaLowLevelPro.c1465
-rw-r--r--nx-X11/lib/XvMC/hw/via/viaLowLevel.h148
-rw-r--r--nx-X11/lib/XvMC/hw/via/viaXvMC.c1964
-rw-r--r--nx-X11/lib/XvMC/hw/via/viaXvMCPriv.h198
-rw-r--r--nx-X11/lib/XvMC/hw/via/xf86dri.c592
-rw-r--r--nx-X11/lib/XvMC/hw/via/xf86dri.h121
-rw-r--r--nx-X11/lib/XvMC/hw/via/xf86dristr.h343
12 files changed, 0 insertions, 6228 deletions
diff --git a/nx-X11/lib/XvMC/hw/via/driDrawable.c b/nx-X11/lib/XvMC/hw/via/driDrawable.c
deleted file mode 100644
index 35934d89d..000000000
--- a/nx-X11/lib/XvMC/hw/via/driDrawable.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*****************************************************************************
- * driDrawable.c: Lean Version of DRI utilities.
- *
- * Copyright (c) 2005 Thomas Hellstrom. 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 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
- * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <X11/Xlibint.h>
-#include <X11/Xutil.h>
-#include "xf86drm.h"
-#include "drm.h"
-#include "xf86dri.h"
-#include "drm_sarea.h"
-#include "driDrawable.h"
-
-
-static unsigned
-drawStamp(volatile drm_sarea_t *pSarea, int index)
-{
- return pSarea->drawableTable[index].stamp;
-}
-
-int
-getDRIDrawableInfoLocked(void *drawHash, Display *display, int screen, Drawable draw,
- unsigned lockFlags, int drmFD, drm_context_t drmContext,
- drmAddress sarea, Bool updateInfo, drawableInfo **info,
- unsigned long infoSize)
-{
- drawableInfo *drawInfo;
- void *res;
- drm_drawable_t drmDraw=0;
- volatile drm_sarea_t *pSarea = (drm_sarea_t *) sarea;
- drm_clip_rect_t *clipFront, *clipBack;
-
- int ret;
-
-
- if (drmHashLookup(drawHash, (unsigned long) draw, &res)) {
-
- /*
- * The drawable is unknown to us. Create it and put it in the
- * hash table.
- */
-
- DRM_UNLOCK(drmFD, &pSarea->lock, drmContext);
- if (!uniDRICreateDrawable(display, screen, draw,
- &drmDraw)) {
- DRM_LOCK(drmFD, &pSarea->lock, drmContext, lockFlags);
- return 1;
- }
- DRM_LOCK(drmFD, &pSarea->lock, drmContext, lockFlags);
-
-
- drawInfo = (drawableInfo *) malloc(infoSize);
- if (!drawInfo) return 1;
-
- drawInfo->drmDraw = drmDraw;
- drawInfo->stamp = 0;
- drawInfo->clipFront = 0;
- drawInfo->clipBack = 0;
-
- drmHashInsert( drawHash, (unsigned long) draw, drawInfo);
-
- } else {
- drawInfo = res;
- }
-
-
- drawInfo->touched = FALSE;
- while (!drawInfo->clipFront || drawInfo->stamp != drawStamp(pSarea, drawInfo->index)) {
-
- /*
- * The drawable has been touched since we last got info about it.
- * obtain new info from the X server.
- */
-
- drawInfo->touched = TRUE;
-
- if (updateInfo || !drawInfo->clipFront) {
- DRM_UNLOCK(drmFD, &pSarea->lock, drmContext);
-
- ret = uniDRIGetDrawableInfo(display, screen, draw,
- &drawInfo->index, &drawInfo->stamp, &drawInfo->x,
- &drawInfo->y, &drawInfo->w, &drawInfo->h,
- &drawInfo->numClipFront, &clipFront,
- &drawInfo->backX, &drawInfo->backY,
- &drawInfo->numClipBack, &clipBack);
-
- DRM_LIGHT_LOCK(drmFD, &pSarea->lock, drmContext);
-
- /*
- * Error. Probably the drawable is destroyed. Return error and old values.
- */
-
- if (!ret) {
- free(drawInfo);
- drawInfo = NULL;
- drmHashDelete(drawHash, (unsigned long) draw);
-
- DRM_UNLOCK(drmFD, &pSarea->lock, drmContext);
- uniDRIDestroyDrawable( display, screen, draw);
- DRM_LOCK(drmFD, &pSarea->lock, drmContext, lockFlags);
-
- return 1;
- }
-
- if (drawInfo->stamp != drawStamp(pSarea, drawInfo->index)) {
-
- /*
- * The info is already outdated. Sigh. Have another go.
- */
-
- XFree(clipFront);
- XFree(clipBack);
- continue;
- }
-
- if (drawInfo->clipFront) XFree(drawInfo->clipFront);
- drawInfo->clipFront = clipFront;
- if (drawInfo->clipBack) XFree(drawInfo->clipBack);
- drawInfo->clipBack = clipBack;
- } else {
- if (!drawInfo->clipFront) drawInfo->clipFront = (drm_clip_rect_t *) ~0UL;
- drawInfo->stamp = drawStamp(pSarea, drawInfo->index);
- }
- }
- *info = drawInfo;
- return 0;
-}
-
-void
-driDestroyHashContents(void *drawHash)
-{
- unsigned long key;
- void *content;
- drawableInfo *drawInfo;
-
-
- if (drmHashFirst(drawHash, &key, &content) < 1)
- return;
- drawInfo = (drawableInfo *) content;
- if (drawInfo->clipBack) XFree(drawInfo->clipBack);
- if (drawInfo->clipFront) XFree(drawInfo->clipFront);
- free(drawInfo);
- while(drmHashNext(drawHash, &key, &content) == 1) {
- drawInfo = (drawableInfo *) content;
- if (drawInfo->clipBack) XFree(drawInfo->clipBack);
- if (drawInfo->clipFront) XFree(drawInfo->clipFront);
- free(drawInfo);
- }
-
- return ;
-}
-
-
diff --git a/nx-X11/lib/XvMC/hw/via/driDrawable.h b/nx-X11/lib/XvMC/hw/via/driDrawable.h
deleted file mode 100644
index e5651058b..000000000
--- a/nx-X11/lib/XvMC/hw/via/driDrawable.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************************
- * driDrawable.h: Lean Version of DRI utilities.
- *
- * Copyright (c) 2005 Thomas Hellstrom. 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 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
- * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
- */
-
-#ifndef _DRIDRAWABLE_H
-#define _DRIDRAWABLE_H
-
-typedef struct _drawableInfo {
- drm_drawable_t drmDraw;
- unsigned stamp;
- unsigned index;
- drm_clip_rect_t *clipFront;
- drm_clip_rect_t *clipBack;
- int x;
- int y;
- int w;
- int h;
- int backX;
- int backY;
- int numClipFront;
- int numClipBack;
- Bool touched;
-} drawableInfo;
-
-/*
- * Get updated info about the drawable "draw". The drawableInfo record returned is malloced
- * and administrated internally. Never free it unless you know exactly what you are doing.
- * The drm hash table "drawHash" needs to be initialized externally.
- */
-
-extern int
-getDRIDrawableInfoLocked (void *drawHash, Display *display, int screen, Drawable draw,
- unsigned lockFlags, int drmFD, drm_context_t drmContext,
- drmAddress sarea, Bool updateInfo, drawableInfo **info,
- unsigned long infoSize);
-
-/*
- * Free all resources created by the above function. Typically done on exit.
- */
-
-extern void
-driDestroyHashContents(void *drawHash);
-
-#endif
diff --git a/nx-X11/lib/XvMC/hw/via/unichrome/Imakefile b/nx-X11/lib/XvMC/hw/via/unichrome/Imakefile
deleted file mode 100644
index bc9120972..000000000
--- a/nx-X11/lib/XvMC/hw/via/unichrome/Imakefile
+++ /dev/null
@@ -1,51 +0,0 @@
-#define DoNormalLib NormalLibXvMC
-#define DoSharedLib SharedLibXvMC
-#define DoDebugLib DebugLibXvMC
-#define DoProfileLib ProfileLibXvMC
-#define LibName viaXvMC
-#define SoRev SOXVMCREV
-#define LibHeaders NO
-
-#include <Threads.tmpl>
-
-#ifdef SharedXvMCReqs
-REQUIREDLIBS = SharedXvMCReqs -lXv
-#endif
-
-#if Malloc0ReturnsNull
-ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
-#endif
-
- DEFINES = $(ALLOC_DEFINES) -DTRUE=1 -DFALSE=0
- INCLUDES = -I$(XINCLUDESRC) -I$(INCLUDESRC) -I$(XLIBSRC) -I$(EXTINCSRC) \
- -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(DRMSRCDIR)/shared-core \
- -I$(XF86OSSRC)/linux/drm/kernel -I$(XF86DRIVERSRC)/via
- SRCS = viaLowLevel.c
- OBJS = viaXvMC.o viaLowLevel.o xf86drm.o xf86drmHash.o \
- xf86drmRandom.o xf86drmSL.o xf86dri.o driDrawable.o
- LINTLIBS = $(LINTXLIB)
-
-
-#include <Library.tmpl>
-
-
-#if defined(LinuxArchitecture)
-
-LIBDRM_DIR = ../../../../../extras/drm/libdrm
-
-LinkSourceFile(xf86drm.c,$(LIBDRM_DIR))
-LinkSourceFile(xf86drmHash.c,$(LIBDRM_DIR))
-LinkSourceFile(xf86drmRandom.c,$(LIBDRM_DIR))
-LinkSourceFile(xf86drmSL.c,$(LIBDRM_DIR))
-LinkSourceFile(viaLowLevel.h,..)
-LinkSourceFile(driDrawable.h,..)
-LinkSourceFile(viaXvMCPriv.h,..)
-LinkSourceFile(xf86dri.h,..)
-LinkSourceFile(xf86dristr.h,..)
-LinkSourceFile(xf86dri.c,..)
-LinkSourceFile(driDrawable.c,..)
-LinkSourceFile(viaXvMC.c,..)
-#endif
-
-DependTarget()
-
diff --git a/nx-X11/lib/XvMC/hw/via/unichrome/viaLowLevel.c b/nx-X11/lib/XvMC/hw/via/unichrome/viaLowLevel.c
deleted file mode 100644
index 1add1ca5d..000000000
--- a/nx-X11/lib/XvMC/hw/via/unichrome/viaLowLevel.c
+++ /dev/null
@@ -1,1056 +0,0 @@
-/*****************************************************************************
- * VIA Unichrome XvMC extension client lib.
- *
- * Copyright (c) 2004 Thomas Hellström. All rights reserved.
- * Copyright (c) 2003 Andreas Robinson. 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 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
- * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
- */
-
-
-/*
- * Low-level functions that deal directly with the hardware. In the future,
- * these functions might be implemented in a kernel module. Also, some of them
- * would benefit from DMA.
- *
- * Authors: Andreas Robinson 2003. Thomas Hellström 2004.
- */
-
-
-
-#include "viaXvMCPriv.h"
-#include "viaLowLevel.h"
-#include <time.h>
-#include <sys/time.h>
-#include <stdio.h>
-
-typedef struct{
- CARD32 agp_buffer[LL_AGP_CMDBUF_SIZE];
- CARD32 pci_buffer[LL_PCI_CMDBUF_SIZE];
- unsigned agp_pos;
- unsigned pci_pos;
- unsigned flip_pos;
- int use_agp;
- int agp_mode;
- int agp_header_start;
- int agp_index;
- int fd;
- drm_context_t *drmcontext;
- drmLockPtr hwLock;
- drmAddress mmioAddress;
- drmAddress fbAddress;
- unsigned fbStride;
- unsigned fbDepth;
- unsigned width;
- unsigned height;
- unsigned curWaitFlags;
- int performLocking;
- unsigned errors;
- drm_via_mem_t tsMem;
- CARD32 tsOffset;
- volatile CARD32 *tsP;
- CARD32 curTimeStamp;
- CARD32 lastReadTimeStamp;
- int agpSync;
- CARD32 agpSyncTimeStamp;
- unsigned chipId;
-}XvMCLowLevel;
-
-
-
-
-
-/*
- * For Other architectures than i386 these might have to be modified for
- * bigendian etc.
- */
-
-#define MPEGIN(xl,reg) \
- *((volatile CARD32 *)(((CARD8 *)(xl)->mmioAddress) + 0xc00 + (reg)))
-
-#define VIDIN(ctx,reg) \
- *((volatile CARD32 *)(((CARD8 *)(ctx)->mmioAddress) + 0x200 + (reg)))
-
-#define REGIN(ctx,reg) \
- *((volatile CARD32 *)(((CARD8 *)(ctx)->mmioAddress) + 0x0000 + (reg)))
-
-#define HQV_CONTROL 0x1D0
-#define HQV_SRC_STARTADDR_Y 0x1D4
-#define HQV_SRC_STARTADDR_U 0x1D8
-#define HQV_SRC_STARTADDR_V 0x1DC
-#define HQV_MINIFY_DEBLOCK 0x1E8
-
-#define HQV_SW_FLIP 0x00000010
-#define HQV_FLIP_STATUS 0x00000001
-#define HQV_SUBPIC_FLIP 0x00008000
-#define HQV_FLIP_ODD 0x00000020
-#define HQV_DEINTERLACE 0x00010000
-#define HQV_FIELD_2_FRAME 0x00020000
-#define HQV_FRAME_2_FIELD 0x00040000
-#define HQV_FIELD_UV 0x00100000
-#define HQV_DEBLOCK_HOR 0x00008000
-#define HQV_DEBLOCK_VER 0x80000000
-
-#define V_COMPOSE_MODE 0x98
-#define V1_COMMAND_FIRE 0x80000000
-#define V3_COMMAND_FIRE 0x40000000
-
-/* SUBPICTURE Registers */
-#define SUBP_CONTROL_STRIDE 0x1C0
-#define SUBP_STARTADDR 0x1C4
-#define RAM_TABLE_CONTROL 0x1C8
-#define RAM_TABLE_READ 0x1CC
-
-/* SUBP_CONTROL_STRIDE 0x3c0 */
-#define SUBP_HQV_ENABLE 0x00010000
-#define SUBP_IA44 0x00020000
-#define SUBP_AI44 0x00000000
-#define SUBP_STRIDE_MASK 0x00001fff
-#define SUBP_CONTROL_MASK 0x00070000
-
-/* RAM_TABLE_CONTROL 0x3c8 */
-#define RAM_TABLE_RGB_ENABLE 0x00000007
-
-
-#define VIA_REG_STATUS 0x400
-#define VIA_REG_GEMODE 0x004
-#define VIA_REG_SRCBASE 0x030
-#define VIA_REG_DSTBASE 0x034
-#define VIA_REG_PITCH 0x038
-#define VIA_REG_SRCCOLORKEY 0x01C
-#define VIA_REG_KEYCONTROL 0x02C
-#define VIA_REG_SRCPOS 0x008
-#define VIA_REG_DSTPOS 0x00C
-#define VIA_REG_GECMD 0x000
-#define VIA_REG_DIMENSION 0x010 /* width and height */
-#define VIA_REG_FGCOLOR 0x018
-
-
-#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
-#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
-#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
-#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
-#define VIA_GEM_8bpp 0x00000000
-#define VIA_GEM_16bpp 0x00000100
-#define VIA_GEM_32bpp 0x00000300
-#define VIA_GEC_BLT 0x00000001
-#define VIA_PITCH_ENABLE 0x80000000
-#define VIA_GEC_INCX 0x00000000
-#define VIA_GEC_DECY 0x00004000
-#define VIA_GEC_INCY 0x00000000
-#define VIA_GEC_DECX 0x00008000
-#define VIA_GEC_FIXCOLOR_PAT 0x00002000
-
-
-#define VIA_BLIT_CLEAR 0x00
-#define VIA_BLIT_COPY 0xCC
-#define VIA_BLIT_FILL 0xF0
-#define VIA_BLIT_SET 0xFF
-
-#define VIA_SYNCWAITTIMEOUT 50000 /* Might be a bit conservative */
-#define VIA_DMAWAITTIMEOUT 150000
-#define VIA_VIDWAITTIMEOUT 50000
-#define VIA_XVMC_DECODERTIMEOUT 50000 /*(microseconds)*/
-
-#define H1_ADDR(val) (((val) >> 2) | 0xF0000000)
-#define WAITFLAGS(xl, flags) \
- (xl)->curWaitFlags |= (flags)
-#define BEGIN_RING_AGP(xl,size) \
- do { \
- if ((xl)->agp_pos > (LL_AGP_CMDBUF_SIZE-(size))) { \
- agpFlush(xl); \
- } \
- } while(0)
-#define OUT_RING_AGP(xl, val) \
- (xl)->agp_buffer[(xl)->agp_pos++] = (val)
-#define OUT_RING_QW_AGP(xl, val1, val2) \
- do { \
- (xl)->agp_buffer[(xl)->agp_pos++] = (val1); \
- (xl)->agp_buffer[(xl)->agp_pos++] = (val2); \
- } while (0)
-
-
-#define LL_HW_LOCK(xl) \
- do { \
- DRM_LOCK((xl)->fd,(xl)->hwLock,*(xl)->drmcontext,0); \
- } while(0);
-#define LL_HW_UNLOCK(xl) \
- do { \
- DRM_UNLOCK((xl)->fd,(xl)->hwLock,*(xl)->drmcontext); \
- } while(0);
-
-
-/*
- * We want to have two concurrent types of thread taking the hardware
- * lock simulataneously. One is the video out thread that needs immediate
- * access to flip an image. The other is everything else which may have
- * the lock for quite some time. This is only so the video out thread can
- * sneak in and display an image while other resources are busy.
- */
-
-
-void
-hwlLock(void *xlp, int videoLock)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- LL_HW_LOCK(xl);
-}
-
-void
-hwlUnlock(void *xlp, int videoLock)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- LL_HW_UNLOCK(xl);
-}
-
-static unsigned
-timeDiff(struct timeval *now,struct timeval *then) {
- return (now->tv_usec >= then->tv_usec) ?
- now->tv_usec - then->tv_usec :
- 1000000 - (then->tv_usec - now->tv_usec);
-}
-
-void
-setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- xl->agpSync = val;
- xl->agpSyncTimeStamp = timeStamp;
-}
-
-CARD32
-viaDMATimeStampLowLevel(void *xlp)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- if (xl->use_agp) {
- viaBlit(xl, 32, xl->tsOffset, 1, xl->tsOffset, 1, 1, 1, 0, 0,
- VIABLIT_FILL, xl->curTimeStamp);
- return xl->curTimeStamp++;
- }
- return 0;
-}
-
-static void
-viaDMAWaitTimeStamp(XvMCLowLevel *xl, CARD32 timeStamp, int doSleep)
-{
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
-
- if (xl->use_agp && (timeStamp > xl->lastReadTimeStamp)) {
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
-
- while(timeStamp > (xl->lastReadTimeStamp = *xl->tsP)) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
- if((timeStamp > (xl->lastReadTimeStamp = *xl->tsP))) {
- xl->errors |= LL_DMA_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
- }
-}
-
-static int
-viaDMAInitTimeStamp(XvMCLowLevel *xl)
-{
- int ret = 0;
-
- if (xl->use_agp) {
- xl->tsMem.context = *(xl->drmcontext);
- xl->tsMem.size = 64;
- xl->tsMem.type = VIA_MEM_VIDEO;
- if (drmCommandWriteRead(xl->fd, DRM_VIA_ALLOCMEM, &xl->tsMem, sizeof(xl->tsMem)) < 0)
- return ret;
- if (xl->tsMem.size != 64)
- return -1;
- xl->tsOffset = (xl->tsMem.offset + 31) & ~31;
- xl->tsP = (CARD32 *)xl->fbAddress + (xl->tsOffset >> 2);
- xl->curTimeStamp = 1;
- *xl->tsP = 0;
- }
- return 0;
-}
-
-static int
-viaDMACleanupTimeStamp(XvMCLowLevel *xl)
-{
-
- if (!(xl->tsMem.size) || !xl->use_agp) return 0;
- return drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, &xl->tsMem, sizeof(xl->tsMem));
-}
-
-
-static CARD32
-viaMpegGetStatus(XvMCLowLevel *xl)
-{
- return MPEGIN(xl,0x54);
-}
-
-static int
-viaMpegIsBusy(XvMCLowLevel *xl, CARD32 mask, CARD32 idle)
-{
- CARD32 tmp = viaMpegGetStatus(xl);
-
- /*
- * Error detected.
- * FIXME: Are errors really shown when error concealment is on?
- */
-
- if (tmp & 0x70) return 0;
-
- return (tmp & mask) != idle;
-}
-
-
-static void
-syncDMA(XvMCLowLevel *xl, unsigned int doSleep)
-{
-
- /*
- * Ideally, we'd like to have an interrupt wait here, but, according to second hand
- * information, the hardware does not support this, although earlier S3 chips do that.
- * It is therefore not implemented into the DRM, and we'll do a user space wait here.
- */
-
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
-
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
- while( !(REGIN(xl, VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY)) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
- if( !(REGIN(xl, VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY)) {
- xl->errors |= LL_DMA_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
- while( REGIN(xl, VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY ) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
- if( REGIN(xl, VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY ) {
- xl->errors |= LL_DMA_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
-}
-
-static void
-syncVideo(XvMCLowLevel *xl, unsigned int doSleep)
-{
- /*
- * Wait for HQV completion. Nothing strange here. We assume that the HQV
- * Handles syncing to the V1 / V3 engines by itself. It should be safe to
- * always wait for SUBPIC_FLIP completion although subpictures are not always
- * used.
- */
-
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
-
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
- while(VIDIN(xl, HQV_CONTROL) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP)) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_SYNCWAITTIMEOUT) {
- if(VIDIN(xl, HQV_CONTROL) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP)) {
- xl->errors |= LL_VIDEO_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
-}
-
-static void
-syncAccel(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep)
-{
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
- CARD32 mask = ((mode & LL_MODE_2D) ? VIA_2D_ENG_BUSY : 0) |
- ((mode & LL_MODE_3D) ? VIA_3D_ENG_BUSY : 0);
-
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
- while( REGIN(xl, VIA_REG_STATUS) & mask) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_SYNCWAITTIMEOUT) {
- if( REGIN(xl, VIA_REG_STATUS) & mask) {
- xl->errors |= LL_ACCEL_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
-}
-
-
-static void
-syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep)
-{
- /*
- * Ideally, we'd like to have an interrupt wait here, but from information from VIA
- * at least the MPEG completion interrupt is broken on the CLE266, which was
- * discovered during validation of the chip.
- */
-
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
- CARD32 busyMask = 0;
- CARD32 idleVal = 0;
- CARD32 ret;
-
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
- if (mode & LL_MODE_DECODER_SLICE) {
- busyMask = VIA_SLICEBUSYMASK;
- idleVal = VIA_SLICEIDLEVAL;
- }
- if (mode & LL_MODE_DECODER_IDLE) {
- busyMask |= VIA_BUSYMASK;
- idleVal = VIA_IDLEVAL;
- }
- while(viaMpegIsBusy(xl, busyMask, idleVal)) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_XVMC_DECODERTIMEOUT) {
- if (viaMpegIsBusy(xl, busyMask, idleVal)) {
- xl->errors |= LL_DECODER_TIMEDOUT;
- }
- break;
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
-
- ret = viaMpegGetStatus(xl);
- if (ret & 0x70) {
- xl->errors |= ((ret & 0x70) >> 3);
- }
- return;
-}
-
-static void
-pciFlush(XvMCLowLevel *xl)
-{
- int ret;
- drm_via_cmdbuffer_t b;
- unsigned mode=xl->curWaitFlags;
-
- b.buf = (char *)xl->pci_buffer;
- b.size = xl->pci_pos * sizeof(CARD32);
- if (xl->performLocking) hwlLock(xl,0);
- if ((mode != LL_MODE_VIDEO) && (mode != 0))
- syncDMA(xl, 0);
- if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D))
- syncAccel(xl, mode, 0);
- if (mode & LL_MODE_VIDEO)
- syncVideo(xl, 0);
- if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
- syncMpeg(xl, mode, 0);
- ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b));
- if (xl->performLocking) hwlUnlock(xl,0);
- if (ret) {
- xl->errors |= LL_PCI_COMMAND_ERR;
- }
- xl->pci_pos = 0;
- xl->curWaitFlags = 0;
-}
-
-static void
-agpFlush(XvMCLowLevel *xl)
-{
- drm_via_cmdbuffer_t b;
- int ret;
-
- if (xl->use_agp) {
- b.buf = (char *)xl->agp_buffer;
- b.size = xl->agp_pos * sizeof(CARD32);
- if (xl->agpSync) {
- syncXvMCLowLevel(xl, LL_MODE_DECODER_IDLE, 1, xl->agpSyncTimeStamp);
- xl->agpSync = 0;
- }
- if (xl->performLocking) hwlLock(xl,0);
- do {
- ret = drmCommandWrite(xl->fd, DRM_VIA_CMDBUFFER, &b, sizeof(b));
- } while (-EAGAIN == ret);
- if (xl->performLocking) hwlUnlock(xl,0);
-
- if (ret) {
- xl->errors |= LL_AGP_COMMAND_ERR;
- } else {
- xl->agp_pos = 0;
- }
- xl->curWaitFlags &= LL_MODE_VIDEO;
- } else {
- unsigned mode=xl->curWaitFlags;
-
- b.buf = (char *)xl->agp_buffer;
- b.size = xl->agp_pos * sizeof(CARD32);
- if (xl->performLocking) hwlLock(xl,0);
- if ((mode != LL_MODE_VIDEO) && (mode != 0))
- syncDMA(xl, 0);
- if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D))
- syncAccel(xl, mode, 0);
- if (mode & LL_MODE_VIDEO)
- syncVideo(xl, 0);
- if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
- syncMpeg(xl, mode, 0);
- ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b));
- if (xl->performLocking) hwlUnlock(xl,0);
- if (ret) {
- xl->errors |= LL_PCI_COMMAND_ERR;
- }
- xl->agp_pos = 0;
- xl->curWaitFlags = 0;
- }
-}
-
-unsigned
-flushXvMCLowLevel(void *xlp)
-{
- unsigned
- errors;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- if(xl->pci_pos) pciFlush(xl);
- if(xl->agp_pos) agpFlush(xl);
- errors = xl->errors;
- xl->errors = 0;
- return errors;
-}
-
-void
-flushPCIXvMCLowLevel(void *xlp)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- if(xl->pci_pos) pciFlush(xl);
- if (!xl->use_agp && xl->agp_pos) agpFlush(xl);
-}
-
-
-__inline static void pciCommand(XvMCLowLevel *xl, unsigned offset, unsigned value, unsigned flags)
-{
- if (xl->pci_pos > (LL_PCI_CMDBUF_SIZE-2)) pciFlush(xl);
- if (flags) xl->curWaitFlags |= flags;
- xl->pci_buffer[xl->pci_pos++] = (offset >> 2) | 0xF0000000;
- xl->pci_buffer[xl->pci_pos++] = value;
-}
-
-void
-viaMpegSetSurfaceStride(void *xlp, ViaXvMCContext *ctx)
-{
- CARD32 y_stride = ctx->yStride;
- CARD32 uv_stride = y_stride >> 1;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
-
- BEGIN_RING_AGP(xl, 2);
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc50), (y_stride >> 3) | ((uv_stride >> 3) << 16));
- WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
-}
-
-
-void
-viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs,
- unsigned vOffs, unsigned yStride, unsigned uvStride)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- pciCommand(xl,HQV_SRC_STARTADDR_Y | 0x200,yOffs,LL_MODE_VIDEO);
- pciCommand(xl,HQV_SRC_STARTADDR_U | 0x200,uOffs,0);
- pciCommand(xl,HQV_SRC_STARTADDR_V | 0x200,vOffs,0);
-}
-
-void
-viaVideoSWFlipLocked(void *xlp, unsigned flags,
- int progressiveSequence)
-{
- CARD32 andWd,orWd;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- andWd = 0;
- orWd = 0;
-
- if ((flags & XVMC_FRAME_PICTURE) == XVMC_BOTTOM_FIELD) {
- andWd = 0xFFFFFFFFU;
- orWd = HQV_FIELD_UV |
- HQV_DEINTERLACE |
- HQV_FIELD_2_FRAME |
- HQV_FRAME_2_FIELD |
- HQV_SW_FLIP |
- HQV_FLIP_ODD |
- HQV_FLIP_STATUS |
- HQV_SUBPIC_FLIP;
- } else if ((flags & XVMC_FRAME_PICTURE) == XVMC_TOP_FIELD) {
- andWd = ~HQV_FLIP_ODD;
- orWd = HQV_FIELD_UV |
- HQV_DEINTERLACE |
- HQV_FIELD_2_FRAME |
- HQV_FRAME_2_FIELD |
- HQV_SW_FLIP |
- HQV_FLIP_STATUS |
- HQV_SUBPIC_FLIP;
- } else if ((flags & XVMC_FRAME_PICTURE) == XVMC_FRAME_PICTURE) {
- andWd = ~(HQV_DEINTERLACE |
- HQV_FRAME_2_FIELD |
- HQV_FIELD_2_FRAME |
- HQV_FIELD_UV);
- orWd = HQV_SW_FLIP |
- HQV_FLIP_STATUS |
- HQV_SUBPIC_FLIP;
- }
- if (progressiveSequence) {
- andWd &= ~HQV_FIELD_UV;
- orWd &= ~HQV_FIELD_UV;
- }
-
- pciCommand(xl,HQV_CONTROL | 0x200,(VIDIN(xl,HQV_CONTROL) & andWd) | orWd, 0);
-}
-
-void
-viaMpegSetFB(void *xlp,unsigned i,
- unsigned yOffs,
- unsigned uOffs,
- unsigned vOffs)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- i *= 12;
- BEGIN_RING_AGP(xl, 6);
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc20 + i), yOffs >> 3);
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc24 + i), uOffs >> 3);
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc28 + i), vOffs >> 3);
- WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
-}
-
-void
-viaMpegBeginPicture(void *xlp,ViaXvMCContext *ctx,
- unsigned width,
- unsigned height,
- const XvMCMpegControl *control) {
-
- unsigned j, mb_width, mb_height;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- mb_width = (width + 15) >> 4;
-
- mb_height =
- ((control->mpeg_coding == XVMC_MPEG_2) &&
- (control->flags & XVMC_PROGRESSIVE_SEQUENCE)) ?
- 2*((height+31) >> 5) : (((height+15) >> 4));
-
- BEGIN_RING_AGP(xl, 144);
- WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
-
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc00),
- ((control->picture_structure & XVMC_FRAME_PICTURE) << 2) |
- ((control->picture_coding_type & 3) << 4) |
- ((control->flags & XVMC_ALTERNATE_SCAN) ? (1 << 6) : 0));
-
- if (!(ctx->intraLoaded)) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc5c), 0);
- for (j = 0; j < 64; j += 4) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc60),
- ctx->intra_quantiser_matrix[j] |
- (ctx->intra_quantiser_matrix[j+1] << 8) |
- (ctx->intra_quantiser_matrix[j+2] << 16) |
- (ctx->intra_quantiser_matrix[j+3] << 24));
- }
- ctx->intraLoaded = 1;
- }
-
- if (!(ctx->nonIntraLoaded)) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc5c), 1);
- for (j = 0; j < 64; j += 4) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc60),
- ctx->non_intra_quantiser_matrix[j] |
- (ctx->non_intra_quantiser_matrix[j+1] << 8) |
- (ctx->non_intra_quantiser_matrix[j+2] << 16) |
- (ctx->non_intra_quantiser_matrix[j+3] << 24));
- }
- ctx->nonIntraLoaded = 1;
- }
-
- if (!(ctx->chromaIntraLoaded)) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc5c), 2);
- for (j = 0; j < 64; j += 4) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc60),
- ctx->chroma_intra_quantiser_matrix[j] |
- (ctx->chroma_intra_quantiser_matrix[j+1] << 8) |
- (ctx->chroma_intra_quantiser_matrix[j+2] << 16) |
- (ctx->chroma_intra_quantiser_matrix[j+3] << 24));
- }
- ctx->chromaIntraLoaded = 1;
- }
-
- if (!(ctx->chromaNonIntraLoaded)) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc5c), 3);
- for (j = 0; j < 64; j += 4) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc60),
- ctx->chroma_non_intra_quantiser_matrix[j] |
- (ctx->chroma_non_intra_quantiser_matrix[j+1] << 8) |
- (ctx->chroma_non_intra_quantiser_matrix[j+2] << 16) |
- (ctx->chroma_non_intra_quantiser_matrix[j+3] << 24));
- }
- ctx->chromaNonIntraLoaded = 1;
- }
-
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc90),
- ((mb_width * mb_height) & 0x3fff) |
- ((control->flags & XVMC_PRED_DCT_FRAME) ? ( 1 << 14) : 0) |
- ((control->flags & XVMC_TOP_FIELD_FIRST) ? (1 << 15) : 0 ) |
- ((control->mpeg_coding == XVMC_MPEG_2) ? (1 << 16) : 0) |
- ((mb_width & 0xff) << 18));
-
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc94),
- ((control->flags & XVMC_CONCEALMENT_MOTION_VECTORS) ? 1 : 0) |
- ((control->flags & XVMC_Q_SCALE_TYPE) ? 2 : 0) |
- ((control->intra_dc_precision & 3) << 2) |
- (((1 + 0x100000 / mb_width) & 0xfffff) << 4) |
- ((control->flags & XVMC_INTRA_VLC_FORMAT) ? (1 << 24) : 0));
-
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc98),
- (((control->FHMV_range) & 0xf) << 0) |
- (((control->FVMV_range) & 0xf) << 4) |
- (((control->BHMV_range) & 0xf) << 8) |
- (((control->BVMV_range) & 0xf) << 12) |
- ((control->flags & XVMC_SECOND_FIELD) ? (1 << 20) : 0) |
- (0x0a6 << 16));
-
-}
-
-
-
-void
-viaMpegReset(void *xlp)
-{
- int i,j;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- BEGIN_RING_AGP(xl, 100);
- WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
-
- for (i = 0; i < 14; i++)
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc08) ,0);
-
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc98), 0x400000);
-
- for (i = 0; i < 6; i++) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc0c), 0x43 | 0x20);
- for (j = 0xc10; j < 0xc20; j += 4)
- OUT_RING_QW_AGP(xl, H1_ADDR(j), 0);
- }
-
-
- OUT_RING_QW_AGP(xl,H1_ADDR(0xc0c), 0xc3 | 0x20);
- for (j = 0xc10; j < 0xc20; j += 4)
- OUT_RING_QW_AGP(xl,H1_ADDR(j),0);
-
-}
-
-void
-viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode)
-{
- int i, n, r;
- CARD32* buf;
- int count;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
-
- if (xl->errors & (LL_DECODER_TIMEDOUT |
- LL_IDCT_FIFO_ERROR |
- LL_SLICE_FIFO_ERROR |
- LL_SLICE_FAULT)) return;
-
- n = nBytes >> 2;
- if (sCode) nBytes += 4;
- r = nBytes & 3;
- buf = (CARD32*) slice;
-
- if (r) nBytes += 4 - r;
-
- nBytes += 8;
-
- BEGIN_RING_AGP(xl, 4);
- WAITFLAGS(xl, LL_MODE_DECODER_IDLE);
-
- OUT_RING_QW_AGP(xl, H1_ADDR(0xc9c), nBytes);
-
- if (sCode) OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), sCode);
-
- i = 0;
- count = 0;
-
- do {
- count += (LL_AGP_CMDBUF_SIZE -20) >> 1;
- count = (count > n) ? n : count;
- BEGIN_RING_AGP(xl, (count - i) << 1);
-
- for (; i < count; i++) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), *buf++);
- }
- } while (i < n);
-
- BEGIN_RING_AGP(xl, 6);
-
- if (r) {
- OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), *buf & ((1 << (r << 3)) - 1));
- }
- OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), 0);
- OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), 0);
-
-}
-
-void
-viaVideoSubPictureOffLocked(void *xlp) {
-
- CARD32 stride;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
-
- stride = VIDIN(xl,SUBP_CONTROL_STRIDE);
-
- pciCommand(xl, SUBP_CONTROL_STRIDE | 0x200, stride & ~SUBP_HQV_ENABLE,LL_MODE_VIDEO);
-}
-
-void
-viaVideoSubPictureLocked(void *xlp,ViaXvMCSubPicture *pViaSubPic) {
-
- unsigned i;
- CARD32 cWord;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
-
- for (i=0; i<VIA_SUBPIC_PALETTE_SIZE; ++i) {
- pciCommand(xl, RAM_TABLE_CONTROL | 0x200, pViaSubPic->palette[i],LL_MODE_VIDEO);
- }
-
- pciCommand(xl, SUBP_STARTADDR | 0x200, pViaSubPic->offset, 0);
- cWord = (pViaSubPic->stride & SUBP_STRIDE_MASK) | SUBP_HQV_ENABLE;
- cWord |= (pViaSubPic->ia44) ? SUBP_IA44 : SUBP_AI44;
- pciCommand(xl, SUBP_CONTROL_STRIDE | 0x200, cWord, 0);
-}
-
-void
-viaBlit(void *xlp,unsigned bpp,unsigned srcBase,
- unsigned srcPitch,unsigned dstBase,unsigned dstPitch,
- unsigned w,unsigned h,int xdir,int ydir, unsigned blitMode,
- unsigned color)
-{
-
- CARD32 dwGEMode = 0, srcY=0, srcX, dstY=0, dstX;
- CARD32 cmd;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
-
- if (!w || !h)
- return;
-
- switch (bpp) {
- case 16:
- dwGEMode |= VIA_GEM_16bpp;
- break;
- case 32:
- dwGEMode |= VIA_GEM_32bpp;
- break;
- default:
- dwGEMode |= VIA_GEM_8bpp;
- break;
- }
-
- srcX = srcBase & 31;
- dstX = dstBase & 31;
- switch (bpp) {
- case 16:
- dwGEMode |= VIA_GEM_16bpp;
- srcX >>= 2;
- dstX >>= 2;
- break;
- case 32:
- dwGEMode |= VIA_GEM_32bpp;
- srcX >>= 4;
- dstX >>= 4;
- break;
- default:
- dwGEMode |= VIA_GEM_8bpp;
- break;
- }
-
- BEGIN_RING_AGP(xl, 20);
- WAITFLAGS(xl, LL_MODE_2D);
-
-
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_GEMODE), dwGEMode);
- cmd = 0;
-
- if (xdir < 0) {
- cmd |= VIA_GEC_DECX;
- srcX += (w - 1);
- dstX += (w - 1);
- }
- if (ydir < 0) {
- cmd |= VIA_GEC_DECY;
- srcY += (h - 1);
- dstY += (h - 1);
- }
-
- switch(blitMode) {
- case VIABLIT_TRANSCOPY:
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_SRCCOLORKEY), color);
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_KEYCONTROL), 0x4000);
- cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
- break;
- case VIABLIT_FILL:
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_FGCOLOR), color);
- cmd |= VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
- break;
- default:
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_KEYCONTROL), 0x0);
- cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
- }
-
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_SRCBASE), (srcBase & ~31) >> 3);
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_DSTBASE), (dstBase & ~31) >> 3);
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_PITCH), VIA_PITCH_ENABLE |
- (srcPitch >> 3) | (((dstPitch) >> 3) << 16));
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_SRCPOS), ((srcY << 16) | srcX));
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_DSTPOS), ((dstY << 16) | dstX));
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_DIMENSION), (((h - 1) << 16) | (w - 1)));
- OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_GECMD), cmd);
-}
-
-unsigned
-syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep,
- CARD32 timeStamp)
-{
- unsigned
- errors;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- if (mode == 0) {
- errors = xl->errors;
- xl->errors = 0;
- return errors;
- }
-
- if ((mode & (LL_MODE_VIDEO | LL_MODE_3D)) || !xl->use_agp) {
- if (xl->performLocking)
- hwlLock(xl,0);
- if ((mode != LL_MODE_VIDEO))
- syncDMA(xl, doSleep);
- if (mode & LL_MODE_3D)
- syncAccel(xl, mode, doSleep);
- if (mode & LL_MODE_VIDEO)
- syncVideo(xl, doSleep);
- if (xl->performLocking)
- hwlUnlock(xl,0);
- } else {
- viaDMAWaitTimeStamp(xl, timeStamp, doSleep);
- }
-
- if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
- syncMpeg(xl, mode, doSleep);
-
- errors = xl->errors;
- xl->errors = 0;
-
- return errors;
-}
-
-
-extern void
-*initXvMCLowLevel(int fd, drm_context_t *ctx,
- drmLockPtr hwLock, drmAddress mmioAddress,
- drmAddress fbAddress, unsigned fbStride, unsigned fbDepth,
- unsigned width, unsigned height, int useAgp, unsigned chipId )
-
-{
- int ret;
-
- XvMCLowLevel *xl = (XvMCLowLevel *)malloc(sizeof(XvMCLowLevel));
- if (!xl) return NULL;
-
- xl->agp_pos = 0;
- xl->pci_pos = 0;
- xl->use_agp = useAgp;
- xl->fd = fd;
- xl->drmcontext = ctx;
- xl->hwLock = hwLock;
- xl->mmioAddress = mmioAddress;
- xl->fbAddress = fbAddress;
- xl->curWaitFlags = 0;
- xl->performLocking = 1;
- xl->errors = 0;
- xl->agpSync = 0;
- ret = viaDMAInitTimeStamp(xl);
- if (ret) {
- free(xl);
- return NULL;
- }
- return xl;
-}
-
-void
-setLowLevelLocking(void *xlp, int performLocking)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- xl->performLocking = performLocking;
-}
-
-void
-closeXvMCLowLevel(void *xlp)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- viaDMACleanupTimeStamp(xl);
- free(xl);
-}
-
diff --git a/nx-X11/lib/XvMC/hw/via/unichromeProA/Imakefile b/nx-X11/lib/XvMC/hw/via/unichromeProA/Imakefile
deleted file mode 100644
index f87ae9b05..000000000
--- a/nx-X11/lib/XvMC/hw/via/unichromeProA/Imakefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#define DoNormalLib NormalLibXvMC
-#define DoSharedLib SharedLibXvMC
-#define DoDebugLib DebugLibXvMC
-#define DoProfileLib ProfileLibXvMC
-#define LibName viaXvMCPro
-#define SoRev SOXVMCREV
-#define LibHeaders NO
-
-#include <Threads.tmpl>
-
-#ifdef SharedXvMCReqs
-REQUIREDLIBS = SharedXvMCReqs -lXv
-#endif
-
-#if Malloc0ReturnsNull
-ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
-#endif
-
- DEFINES = $(ALLOC_DEFINES) -DTRUE=1 -DFALSE=0
- INCLUDES = -I$(XINCLUDESRC) -I$(INCLUDESRC) -I$(XLIBSRC) -I$(EXTINCSRC) \
- -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(DRMSRCDIR)/shared-core \
- -I$(XF86OSSRC)/linux/drm/kernel -I$(XF86DRIVERSRC)/via
- SRCS = viaLowLevelPro.c
- OBJS = viaXvMC.o viaLowLevelPro.o xf86drm.o xf86drmHash.o \
- xf86drmRandom.o xf86drmSL.o xf86dri.o driDrawable.o
- LINTLIBS = $(LINTXLIB)
-
-
-#include <Library.tmpl>
-
-
-#if defined(LinuxArchitecture)
-LIBDRM_DIR = ../../../../../extras/drm/libdrm
-
-LinkSourceFile(xf86drm.c,$(LIBDRM_DIR))
-LinkSourceFile(xf86drmHash.c,$(LIBDRM_DIR))
-LinkSourceFile(xf86drmRandom.c,$(LIBDRM_DIR))
-LinkSourceFile(xf86drmSL.c,$(LIBDRM_DIR))
-LinkSourceFile(viaLowLevel.h,..)
-LinkSourceFile(driDrawable.h,..)
-LinkSourceFile(viaXvMCPriv.h,..)
-LinkSourceFile(xf86dri.h,..)
-LinkSourceFile(xf86dristr.h,..)
-LinkSourceFile(xf86dri.c,..)
-LinkSourceFile(driDrawable.c,..)
-LinkSourceFile(viaXvMC.c,..)
-#endif
-
-DependTarget()
-
diff --git a/nx-X11/lib/XvMC/hw/via/unichromeProA/viaLowLevelPro.c b/nx-X11/lib/XvMC/hw/via/unichromeProA/viaLowLevelPro.c
deleted file mode 100644
index 666166c96..000000000
--- a/nx-X11/lib/XvMC/hw/via/unichromeProA/viaLowLevelPro.c
+++ /dev/null
@@ -1,1465 +0,0 @@
-/*****************************************************************************
- * VIA Unichrome XvMC extension client lib.
- *
- * Copyright (c) 2004 Thomas Hellström. All rights reserved.
- * Copyright (c) 2003 Andreas Robinson. 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 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
- * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
- */
-
-
-/*
- * Low-level functions that deal directly with the hardware. In the future,
- * these functions might be implemented in a kernel module. Also, some of them
- * would benefit from DMA.
- *
- * Authors:
- * Andreas Robinson 2003. (Initial decoder interface functions).
- * Thomas Hellstrom 2004, 2005 (Blitting functions, AGP and locking, Unichrome Pro Video AGP).
- * Ivor Hewitt 2005 (Unichrome Pro modifications and merging).
- */
-
-/* IH
- * I've left the proReg or-ing in case we need/want to implement the V1/V3
- * register toggle too, which also moves the register locations.
- * The CN400 has dual mpeg decoders, not sure at the moment whether these
- * are also operated through independent registers also.
- */
-
-#undef VIDEO_DMA
-#define HQV_USE_IRQ
-#define UNICHROME_PRO
-
-#include "viaXvMCPriv.h"
-#include "viaLowLevel.h"
-#include "driDrawable.h"
-#include <time.h>
-#include <sys/time.h>
-#include <stdio.h>
-
-typedef enum {ll_init, ll_agpBuf, ll_pciBuf, ll_timeStamp, ll_llBuf}
- LLState;
-
-
-typedef struct {
- drm_via_mem_t mem;
- unsigned offset;
- unsigned stride;
- unsigned height;
-} LowLevelBuffer;
-
-struct _XvMCLowLevel;
-
-typedef struct _ViaCommandBuffer {
- CARD32 *buf;
- CARD32 waitFlags;
- unsigned pos;
- unsigned bufSize;
- int mode;
- int header_start;
- int rindex;
- void (*flushFunc)(struct _ViaCommandBuffer *cb, struct _XvMCLowLevel *xl);
-} ViaCommandBuffer;
-
-typedef struct _XvMCLowLevel{
- ViaCommandBuffer agpBuf, pciBuf, *videoBuf;
- int use_agp;
- int fd;
- drm_context_t *drmcontext;
- drmLockPtr hwLock;
- drmAddress mmioAddress;
- drmAddress fbAddress;
- unsigned fbStride;
- unsigned fbDepth;
- unsigned width;
- unsigned height;
- int performLocking;
- unsigned errors;
- drm_via_mem_t tsMem;
- CARD32 tsOffset;
- volatile CARD32 *tsP;
- CARD32 curTimeStamp;
- CARD32 lastReadTimeStamp;
- int agpSync;
- CARD32 agpSyncTimeStamp;
- unsigned chipId;
-
- /*
- * Data for video-engine less display
- */
-
- XvMCRegion sRegion;
- XvMCRegion dRegion;
- LowLevelBuffer scale;
- LowLevelBuffer back;
- Bool downScaling;
- CARD32 downScaleW;
- CARD32 downScaleH;
- CARD32 upScaleW;
- CARD32 upScaleH;
- unsigned fetch;
- unsigned line;
- LLState state;
-}XvMCLowLevel;
-
-
-/*
- * For Other architectures than i386 these might have to be modified for
- * bigendian etc.
- */
-
-
-#define MPEGIN(xl,reg) \
- *((volatile CARD32 *)(((CARD8 *)(xl)->mmioAddress) + 0xc00 + (reg)))
-
-#define VIDIN(ctx,reg) \
- *((volatile CARD32 *)(((CARD8 *)(ctx)->mmioAddress) + 0x200 + (reg)))
-
-#define REGIN(ctx,reg) \
- *((volatile CARD32 *)(((CARD8 *)(ctx)->mmioAddress) + 0x0000 + (reg)))
-
-#define HQV_CONTROL 0x1D0
-#define HQV_SRC_OFFSET 0x1CC
-#define HQV_SRC_STARTADDR_Y 0x1D4
-#define HQV_SRC_STARTADDR_U 0x1D8
-#define HQV_SRC_STARTADDR_V 0x1DC
-#define HQV_MINIFY_DEBLOCK 0x1E8
-
-#define REG_HQV1_INDEX 0x00001000
-
-#define HQV_SW_FLIP 0x00000010
-#define HQV_FLIP_STATUS 0x00000001
-#define HQV_SUBPIC_FLIP 0x00008000
-#define HQV_FLIP_ODD 0x00000020
-#define HQV_DEINTERLACE 0x00010000
-#define HQV_FIELD_2_FRAME 0x00020000
-#define HQV_FRAME_2_FIELD 0x00040000
-#define HQV_FIELD_UV 0x00100000
-#define HQV_DEBLOCK_HOR 0x00008000
-#define HQV_DEBLOCK_VER 0x80000000
-#define HQV_YUV420 0xC0000000
-#define HQV_YUV422 0x80000000
-#define HQV_ENABLE 0x08000000
-#define HQV_GEN_IRQ 0x00000080
-
-#define HQV_SCALE_ENABLE 0x00000800
-#define HQV_SCALE_DOWN 0x00001000
-
-#define V_COMPOSE_MODE 0x98
-#define V1_COMMAND_FIRE 0x80000000
-#define V3_COMMAND_FIRE 0x40000000
-
-/* SUBPICTURE Registers */
-#define SUBP_CONTROL_STRIDE 0x1C0
-#define SUBP_STARTADDR 0x1C4
-#define RAM_TABLE_CONTROL 0x1C8
-#define RAM_TABLE_READ 0x1CC
-
-/* SUBP_CONTROL_STRIDE 0x3c0 */
-#define SUBP_HQV_ENABLE 0x00010000
-#define SUBP_IA44 0x00020000
-#define SUBP_AI44 0x00000000
-#define SUBP_STRIDE_MASK 0x00001fff
-#define SUBP_CONTROL_MASK 0x00070000
-
-/* RAM_TABLE_CONTROL 0x3c8 */
-#define RAM_TABLE_RGB_ENABLE 0x00000007
-
-
-#define VIA_REG_STATUS 0x400
-#define VIA_REG_GEMODE 0x004
-#define VIA_REG_SRCBASE 0x030
-#define VIA_REG_DSTBASE 0x034
-#define VIA_REG_PITCH 0x038
-#define VIA_REG_SRCCOLORKEY 0x01C
-#define VIA_REG_KEYCONTROL 0x02C
-#define VIA_REG_SRCPOS 0x008
-#define VIA_REG_DSTPOS 0x00C
-#define VIA_REG_GECMD 0x000
-#define VIA_REG_DIMENSION 0x010 /* width and height */
-#define VIA_REG_FGCOLOR 0x018
-
-
-#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
-#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
-#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
-#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
-#define VIA_GEM_8bpp 0x00000000
-#define VIA_GEM_16bpp 0x00000100
-#define VIA_GEM_32bpp 0x00000300
-#define VIA_GEC_BLT 0x00000001
-#define VIA_PITCH_ENABLE 0x80000000
-#define VIA_GEC_INCX 0x00000000
-#define VIA_GEC_DECY 0x00004000
-#define VIA_GEC_INCY 0x00000000
-#define VIA_GEC_DECX 0x00008000
-#define VIA_GEC_FIXCOLOR_PAT 0x00002000
-
-
-#define VIA_BLIT_CLEAR 0x00
-#define VIA_BLIT_COPY 0xCC
-#define VIA_BLIT_FILL 0xF0
-#define VIA_BLIT_SET 0xFF
-
-#define VIA_SYNCWAITTIMEOUT 50000 /* Might be a bit conservative */
-#define VIA_DMAWAITTIMEOUT 150000
-#define VIA_VIDWAITTIMEOUT 50000
-#define VIA_XVMC_DECODERTIMEOUT 50000 /*(microseconds)*/
-
-#define VIA_AGP_HEADER5 0xFE040000
-#define VIA_AGP_HEADER6 0xFE050000
-
-typedef struct{
- CARD32 data;
- Bool set;
-} HQVRegister;
-
-
-#define H1_ADDR(val) (((val) >> 2) | 0xF0000000)
-#define WAITFLAGS(cb, flags) \
- (cb)->waitFlags |= (flags)
-#define BEGIN_RING_AGP(cb, xl, size) \
- do { \
- if ((cb)->pos > ((cb)->bufSize-(size))) { \
- cb->flushFunc(cb, xl); \
- } \
- } while(0)
-#define OUT_RING_AGP(cb, val) do{ \
- (cb)->buf[(cb)->pos++] = (val); \
- } while(0);
-
-#define OUT_RING_QW_AGP(cb, val1, val2) \
- do { \
- (cb)->buf[(cb)->pos++] = (val1); \
- (cb)->buf[(cb)->pos++] = (val2); \
- } while (0)
-
-
-#define BEGIN_HEADER5_AGP(cb, xl, index) \
- do { \
- BEGIN_RING_AGP(cb, xl, 8); \
- (cb)->mode = VIA_AGP_HEADER5; \
- (cb)->rindex = (index); \
- (cb)->header_start = (cb)->pos; \
- (cb)->pos += 4; \
- } while (0)
-
-#define BEGIN_HEADER6_AGP(cb, xl) \
- do { \
- BEGIN_RING_AGP(cb, xl, 8); \
- (cb)->mode = VIA_AGP_HEADER6; \
- (cb)->header_start = (cb)->pos; \
- (cb)->pos += 4; \
- } while (0)
-
-#define BEGIN_HEADER5_DATA(cb, xl, size, index) \
- do { \
- if ((cb)->pos > ((cb)->bufSize - ((size) + 16))) { \
- cb->flushFunc(cb, xl); \
- BEGIN_HEADER5_AGP(cb, xl, index); \
- } else if ((cb)->mode && (((cb)->mode != VIA_AGP_HEADER5) || \
- ((cb)->rindex != index))) { \
- finish_header_agp(cb); \
- BEGIN_HEADER5_AGP((cb), xl, (index)); \
- } else if (cb->mode != VIA_AGP_HEADER5) { \
- BEGIN_HEADER5_AGP((cb), xl, (index)); \
- } \
- }while(0)
-
-#define BEGIN_HEADER6_DATA(cb, xl, size) \
- do{ \
- if ((cb)->pos > (cb->bufSize-(((size) << 1) + 16))) { \
- cb->flushFunc(cb, xl); \
- BEGIN_HEADER6_AGP(cb, xl); \
- } else if ((cb)->mode && ((cb)->mode != VIA_AGP_HEADER6)) { \
- finish_header_agp(cb); \
- BEGIN_HEADER6_AGP(cb, xl); \
- } \
- else if ((cb->mode != VIA_AGP_HEADER6)) { \
- BEGIN_HEADER6_AGP(cb, (xl)); \
- } \
- }while(0)
-
-#define HQV_SHADOW_BASE 0x3CC
-#define HQV_SHADOW_SIZE 13
-
-#define SETHQVSHADOW(shadow, offset, value) \
- do { \
- HQVRegister *r = (shadow) + (((offset) - HQV_SHADOW_BASE) >> 2); \
- r->data = (value); \
- r->set = TRUE; \
- } while(0)
-
-#define GETHQVSHADOW(shadow, offset) ((shadow)[(offset - HQV_SHADOW_BASE) >> 2].data)
-
-#define LL_HW_LOCK(xl) \
- do { \
- DRM_LOCK((xl)->fd,(xl)->hwLock,*(xl)->drmcontext,0); \
- } while(0);
-#define LL_HW_UNLOCK(xl) \
- do { \
- DRM_UNLOCK((xl)->fd,(xl)->hwLock,*(xl)->drmcontext); \
- } while(0);
-
-static HQVRegister hqvShadow[HQV_SHADOW_SIZE];
-
-
-static void
-initHQVShadow(HQVRegister *r)
-{
- int i;
-
- for(i=0; i<HQV_SHADOW_SIZE; ++i) {
- r->data = 0;
- r++->set = FALSE;
- }
-}
-
-static void
-setHQVDeblocking(HQVRegister *shadow, Bool on, Bool lowPass)
-{
- CARD32 tmp = GETHQVSHADOW(shadow, 0x3DC);
-
- if (!on) {
- tmp &= ~(1 << 27);
- SETHQVSHADOW(shadow, 0x3DC , tmp);
- return;
- }
-
- tmp |= (8 << 16) | (1 << 27);
- if (lowPass)
- tmp |= (1 << 26);
- SETHQVSHADOW(shadow, 0x3DC , tmp);
-
- tmp = GETHQVSHADOW(shadow, 0x3D4);
- tmp |= (6 << 27);
- SETHQVSHADOW(shadow, 0x3D4, tmp);
-
- tmp = GETHQVSHADOW(shadow, 0x3D8);
- tmp |= (19 << 27);
- SETHQVSHADOW(shadow, 0x3D8, tmp);
-}
-
-static void
-setHQVStartAddress(HQVRegister *shadow, unsigned yOffs, unsigned uOffs,
- unsigned stride, unsigned format)
-{
- CARD32 tmp = GETHQVSHADOW(shadow, 0x3D4);
-
- tmp |= yOffs & 0x03FFFFF0;
- SETHQVSHADOW(shadow, 0x3D4, tmp);
- tmp = GETHQVSHADOW(shadow, 0x3D8);
- tmp |= uOffs & 0x03FFFFF0;
- SETHQVSHADOW(shadow, 0x3D8, tmp);
- tmp = GETHQVSHADOW(shadow, 0x3F8);
- tmp |= (stride & 0x1FF8);
- SETHQVSHADOW(shadow, 0x3F8, tmp);
- tmp = GETHQVSHADOW(shadow, 0x3D0);
-
- if (format == 0) {
- /*
- * NV12
- */
- tmp |= (0x0C << 28);
- } else if (format == 1) {
- /*
- * RGB16
- */
- tmp |= (0x02 << 28);
- } else if (format == 2) {
- /*
- * RGB32
- */
- ;
- }
- SETHQVSHADOW(shadow, 0x3D0, tmp);
-}
-
-static void
-setHQVDeinterlacing(HQVRegister *shadow, CARD32 frameType)
-{
- CARD32 tmp = GETHQVSHADOW(shadow, 0x3D0);
-
-
- if ((frameType & XVMC_FRAME_PICTURE) == XVMC_TOP_FIELD) {
- tmp |= HQV_FIELD_UV |
- HQV_DEINTERLACE |
- HQV_FIELD_2_FRAME |
- HQV_FRAME_2_FIELD;
- } else if ((frameType & XVMC_FRAME_PICTURE) == XVMC_BOTTOM_FIELD) {
- tmp |= HQV_FIELD_UV |
- HQV_DEINTERLACE |
- HQV_FIELD_2_FRAME |
- HQV_FRAME_2_FIELD |
- HQV_FLIP_ODD;
- }
- SETHQVSHADOW(shadow, 0x3D0, tmp);
-}
-
-static void
-setHQVTripleBuffer(HQVRegister *shadow, Bool on)
-{
- CARD32 tmp = GETHQVSHADOW(shadow, 0x3D0);
-
- if (on)
- tmp |= ( 1 << 26 );
- else
- tmp &= ~( 1 << 26 );
- SETHQVSHADOW(shadow, 0x3D0, tmp);
-}
-
-static void
-finish_header_agp(ViaCommandBuffer *cb)
-{
- int
- numDWords,i;
- CARD32
- *hb;
-
- if (!cb->mode) return;
- numDWords = cb->pos - cb->header_start - 4;
- hb = cb->buf + cb->header_start;
- switch (cb->mode) {
- case VIA_AGP_HEADER5:
- hb[0] = VIA_AGP_HEADER5 | cb->rindex;
- hb[1] = numDWords ;
- hb[2] = 0x00F50000; /* SW debug flag. (?) */
- break;
- default:
- hb[0] = VIA_AGP_HEADER6;
- hb[1] = numDWords >> 1 ;
- hb[2] = 0x00F60000; /* SW debug flag. (?) */
- break;
- }
- hb[3] = 0;
- if (numDWords & 3) {
- for (i=0; i<(4 - (numDWords & 3)); ++i)
- OUT_RING_AGP(cb, 0x00000000);
- }
- cb->mode = 0;
-}
-
-void
-hwlLock(void *xlp, int videoLock)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- LL_HW_LOCK(xl);
-}
-
-void
-hwlUnlock(void *xlp, int videoLock)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- LL_HW_UNLOCK(xl);
-}
-
-static unsigned
-timeDiff(struct timeval *now,struct timeval *then) {
- return (now->tv_usec >= then->tv_usec) ?
- now->tv_usec - then->tv_usec :
- 1000000 - (then->tv_usec - now->tv_usec);
-}
-
-void
-setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- xl->agpSync = val;
- xl->agpSyncTimeStamp = timeStamp;
-}
-
-CARD32
-viaDMATimeStampLowLevel(void *xlp)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- if (xl->use_agp) {
- viaBlit(xl, 32, xl->tsOffset, 1, xl->tsOffset, 1, 1, 1, 0, 0,
- VIABLIT_FILL, xl->curTimeStamp);
- return xl->curTimeStamp++;
- }
- return 0;
-}
-
-static void
-viaDMAWaitTimeStamp(XvMCLowLevel *xl, CARD32 timeStamp, int doSleep)
-{
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
-
- if (xl->use_agp && (xl->lastReadTimeStamp - timeStamp > (1 << 23))) {
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
-
- while(((xl->lastReadTimeStamp = *xl->tsP) - timeStamp) > (1 << 23)) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
- if(((xl->lastReadTimeStamp = *xl->tsP) - timeStamp) > (1 << 23)) {
- xl->errors |= LL_DMA_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
- }
-}
-
-static int
-viaDMAInitTimeStamp(XvMCLowLevel *xl)
-{
- int ret = 0;
-
- if (xl->use_agp) {
- xl->tsMem.context = *(xl->drmcontext);
- xl->tsMem.size = 64;
- xl->tsMem.type = VIA_MEM_VIDEO;
- if ((ret = drmCommandWriteRead(xl->fd, DRM_VIA_ALLOCMEM,
- &xl->tsMem, sizeof(xl->tsMem))) < 0)
- return ret;
- if (xl->tsMem.size != 64)
- return -1;
- xl->tsOffset = (xl->tsMem.offset + 31) & ~31;
- xl->tsP = (CARD32 *)xl->fbAddress + (xl->tsOffset >> 2);
- xl->curTimeStamp = 1;
- *xl->tsP = 0;
- }
- return 0;
-}
-
-static int
-viaDMACleanupTimeStamp(XvMCLowLevel *xl)
-{
-
- if (!(xl->tsMem.size) || !xl->use_agp) return 0;
- return drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, &xl->tsMem, sizeof(xl->tsMem));
-}
-
-
-static CARD32
-viaMpegGetStatus(XvMCLowLevel *xl)
-{
- return MPEGIN(xl,0x54);
-}
-
-static int
-viaMpegIsBusy(XvMCLowLevel *xl, CARD32 mask, CARD32 idle)
-{
- CARD32 tmp = viaMpegGetStatus(xl);
-
- /*
- * Error detected.
- * FIXME: Are errors really shown when error concealment is on?
- */
-
- if (tmp & 0x70) return 0;
-
- return (tmp & mask) != idle;
-}
-
-
-static void
-syncDMA(XvMCLowLevel *xl, unsigned int doSleep)
-{
-
- /*
- * Ideally, we'd like to have an interrupt wait here, but, according to second hand
- * information, the hardware does not support this, although earlier S3 chips do that.
- * It is therefore not implemented into the DRM, and we'll do a user space wait here.
- */
-
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
-
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
- while( !(REGIN(xl, VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY)) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
- if( !(REGIN(xl, VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY)) {
- xl->errors |= LL_DMA_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
- while( REGIN(xl, VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY ) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_DMAWAITTIMEOUT) {
- if( REGIN(xl, VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY ) {
- xl->errors |= LL_DMA_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
-}
-
-#ifdef HQV_USE_IRQ
-static void
-syncVideo(XvMCLowLevel *xl, unsigned int doSleep)
-{
- int proReg = REG_HQV1_INDEX;
-
- /*
- * Wait for HQV completion using completion interrupt. Nothing strange here.
- * Note that the interrupt handler clears the HQV_FLIP_STATUS bit, so we
- * can't wait on that one.
- */
-
- if ((VIDIN(xl, HQV_CONTROL|proReg) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP))) {
- drm_via_irqwait_t irqw;
- irqw.request.irq = 1;
- irqw.request.type = VIA_IRQ_ABSOLUTE;
- if (drmCommandWriteRead(xl->fd, DRM_VIA_WAIT_IRQ, &irqw, sizeof(irqw)) < 0)
- xl->errors |= LL_VIDEO_TIMEDOUT;
- }
-}
-#else
-static void
-syncVideo(XvMCLowLevel *xl, unsigned int doSleep)
-{
- /*
- * Wait for HQV completion. Nothing strange here. We assume that the HQV
- * Handles syncing to the V1 / V3 engines by itself. It should be safe to
- * always wait for SUBPIC_FLIP completion although subpictures are not always
- * used.
- */
-
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
-
- int proReg = REG_HQV1_INDEX;
-
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
- while((VIDIN(xl, HQV_CONTROL|proReg) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP )) ) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_SYNCWAITTIMEOUT) {
- if((VIDIN(xl, HQV_CONTROL|proReg) & (HQV_SW_FLIP | HQV_SUBPIC_FLIP )) ) {
- xl->errors |= LL_VIDEO_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
-}
-#endif
-
-static void
-syncAccel(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep)
-{
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
- CARD32 mask = ((mode & LL_MODE_2D) ? VIA_2D_ENG_BUSY : 0) |
- ((mode & LL_MODE_3D) ? VIA_3D_ENG_BUSY : 0);
-
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
- while( REGIN(xl, VIA_REG_STATUS) & mask) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_SYNCWAITTIMEOUT) {
- if( REGIN(xl, VIA_REG_STATUS) & mask) {
- xl->errors |= LL_ACCEL_TIMEDOUT;
- break;
- }
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
-}
-
-
-static void
-syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep)
-{
- /*
- * Ideally, we'd like to have an interrupt wait here, but from information from VIA
- * at least the MPEG completion interrupt is broken on the CLE266, which was
- * discovered during validation of the chip.
- */
-
- struct timeval now, then;
- struct timezone here;
- struct timespec sleep, rem;
- CARD32 busyMask = 0;
- CARD32 idleVal = 0;
- CARD32 ret;
-
- sleep.tv_nsec = 1;
- sleep.tv_sec = 0;
- here.tz_minuteswest = 0;
- here.tz_dsttime = 0;
- gettimeofday(&then,&here);
- if (mode & LL_MODE_DECODER_SLICE) {
- busyMask = VIA_SLICEBUSYMASK;
- idleVal = VIA_SLICEIDLEVAL;
- }
- if (mode & LL_MODE_DECODER_IDLE) {
- busyMask |= VIA_BUSYMASK;
- idleVal = VIA_IDLEVAL;
- }
- while(viaMpegIsBusy(xl, busyMask, idleVal)) {
- gettimeofday(&now,&here);
- if (timeDiff(&now,&then) > VIA_XVMC_DECODERTIMEOUT) {
- if (viaMpegIsBusy(xl, busyMask, idleVal)) {
- xl->errors |= LL_DECODER_TIMEDOUT;
- }
- break;
- }
- if (doSleep) nanosleep(&sleep, &rem);
- }
-
- ret = viaMpegGetStatus(xl);
- if (ret & 0x70) {
- xl->errors |= ((ret & 0x70) >> 3);
- }
- return;
-}
-
-static void
-pciFlush(ViaCommandBuffer *cb, XvMCLowLevel *xl)
-{
- int ret;
- drm_via_cmdbuffer_t b;
- unsigned mode = cb->waitFlags;
-
- finish_header_agp(cb);
- b.buf = (char *)cb->buf;
- b.size = cb->pos * sizeof(CARD32);
- if (xl->performLocking) hwlLock(xl,0);
- if (((mode == LL_MODE_VIDEO) && (xl->videoBuf == &xl->agpBuf)) ||
- ((mode != LL_MODE_VIDEO) && (mode != 0)))
- syncDMA(xl, 0);
- if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D)) {
- syncAccel(xl, mode, 0);
- }
- if (mode & LL_MODE_VIDEO) {
- syncVideo(xl, 1);
- }
- if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE)) {
- syncMpeg(xl, mode, 0);
- }
- ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b));
- if (xl->performLocking) hwlUnlock(xl,0);
- if (ret) {
- xl->errors |= LL_PCI_COMMAND_ERR;
- }
- cb->pos = 0;
- cb->waitFlags = 0;
-}
-
-static void
-agpFlush(ViaCommandBuffer *cb, XvMCLowLevel *xl)
-{
- drm_via_cmdbuffer_t b;
- int ret;
- int i;
-
- finish_header_agp(cb);
- if (xl->use_agp) {
- b.buf = (char *)cb->buf;
- b.size = cb->pos * sizeof(CARD32);
- if (xl->agpSync) {
- syncXvMCLowLevel(xl, LL_MODE_DECODER_IDLE, 1, xl->agpSyncTimeStamp);
- xl->agpSync = 0;
- }
- if (xl->performLocking) hwlLock(xl,0);
- do {
- ret = drmCommandWrite(xl->fd, DRM_VIA_CMDBUFFER, &b, sizeof(b));
- } while (-EAGAIN == ret);
- if (xl->performLocking) hwlUnlock(xl,0);
-
- if (ret) {
- xl->errors |= LL_AGP_COMMAND_ERR;
- for(i=0; i<cb->pos; i+=2) {
- printf("0x%x, 0x%x\n", (unsigned) cb->buf[i], (unsigned) cb->buf[i+1]);
- }
- exit(-1);
- } else {
- cb->pos = 0;
- }
- cb->waitFlags &= LL_MODE_VIDEO; /* FIXME: Check this! */
- } else {
- unsigned mode=cb->waitFlags;
-
- b.buf = (char *)cb->buf;
- b.size = cb->pos * sizeof(CARD32);
- if (xl->performLocking) hwlLock(xl,0);
- if (((mode == LL_MODE_VIDEO) && (cb == &xl->agpBuf)) ||
- ((mode != LL_MODE_VIDEO) && (mode != 0)))
- syncDMA(xl, 0);
- if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D))
- syncAccel(xl, mode, 0);
- if (mode & LL_MODE_VIDEO)
- syncVideo(xl, 1);
- if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
- syncMpeg(xl, mode, 0);
- ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b));
- if (xl->performLocking) hwlUnlock(xl,0);
- if (ret) {
- xl->errors |= LL_PCI_COMMAND_ERR;
- }
- cb->pos = 0;
- cb->waitFlags = 0;
- }
-}
-
-static void
-uploadHQVShadow(XvMCLowLevel *xl, unsigned offset, HQVRegister *shadow,
- Bool flip)
-{
- int i;
- CARD32 tmp;
- ViaCommandBuffer *cb = xl->videoBuf;
-
- BEGIN_HEADER6_DATA(cb, xl, HQV_SHADOW_SIZE);
- WAITFLAGS(cb, LL_MODE_VIDEO);
-
- if (shadow[0].set)
- OUT_RING_QW_AGP(cb, 0x3CC + offset, 0);
-
- for (i=2; i < HQV_SHADOW_SIZE; ++i) {
- if (shadow[i].set) {
- OUT_RING_QW_AGP(cb, offset + HQV_SHADOW_BASE + ( i << 2) , shadow[i].data);
- shadow[i].set = FALSE;
- }
- }
-
- /*
- * Finally the control register for flip.
- */
-
- if (flip) {
- tmp = GETHQVSHADOW( shadow, 0x3D0);
- OUT_RING_QW_AGP(cb, offset + HQV_CONTROL + 0x200 ,
- HQV_ENABLE | HQV_GEN_IRQ | HQV_SUBPIC_FLIP | HQV_SW_FLIP | tmp);
- }
- shadow[0].set = FALSE;
- shadow[1].set = FALSE;
-}
-
-
-
-
-unsigned
-flushXvMCLowLevel(void *xlp)
-{
- unsigned
- errors;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
-
- if(xl->pciBuf.pos) pciFlush(&xl->pciBuf, xl);
- if(xl->agpBuf.pos) agpFlush(&xl->agpBuf, xl);
- errors = xl->errors;
- if (errors) printf("Error 0x%x\n", errors);
- xl->errors = 0;
- return errors;
-}
-
-void
-flushPCIXvMCLowLevel(void *xlp)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
-
- if(xl->pciBuf.pos) pciFlush(&xl->pciBuf, xl);
- if ((!xl->use_agp && xl->agpBuf.pos)) agpFlush(&xl->agpBuf, xl);
-}
-
-
-void
-viaMpegSetSurfaceStride(void *xlp, ViaXvMCContext *ctx)
-{
- CARD32 y_stride = ctx->yStride;
- CARD32 uv_stride = y_stride >> 1;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- ViaCommandBuffer *cb = &xl->agpBuf;
-
- BEGIN_HEADER6_DATA(cb, xl, 1);
- OUT_RING_QW_AGP(cb, 0xc50, (y_stride >> 3) | ((uv_stride >> 3) << 16));
- WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
-}
-
-
-void
-viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs,
- unsigned vOffs, unsigned yStride, unsigned uvStride)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- initHQVShadow(hqvShadow);
- setHQVStartAddress(hqvShadow, yOffs, vOffs, yStride, 0);
- if (xl->videoBuf == &xl->agpBuf)
- syncDMA(xl, 1);
- syncVideo(xl, 1);
- uploadHQVShadow(xl, REG_HQV1_INDEX, hqvShadow, FALSE);
- xl->videoBuf->flushFunc(xl->videoBuf, xl);
-}
-
-void
-viaVideoSWFlipLocked(void *xlp, unsigned flags,
- Bool progressiveSequence)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- setHQVDeinterlacing(hqvShadow, flags);
- setHQVDeblocking(hqvShadow,( (flags & XVMC_FRAME_PICTURE) == XVMC_FRAME_PICTURE), TRUE);
- setHQVTripleBuffer(hqvShadow, TRUE);
- if (xl->videoBuf == &xl->agpBuf)
- syncDMA(xl, 1);
- syncVideo(xl, 1);
- uploadHQVShadow(xl, REG_HQV1_INDEX, hqvShadow, TRUE);
- xl->videoBuf->flushFunc(xl->videoBuf, xl);
-}
-
-
-void
-viaMpegSetFB(void *xlp,unsigned i,
- unsigned yOffs,
- unsigned uOffs,
- unsigned vOffs)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- ViaCommandBuffer *cb = &xl->agpBuf;
-
- i *= (4*2);
- BEGIN_HEADER6_DATA(cb,xl, 2);
- OUT_RING_QW_AGP(cb, 0xc28 + i, yOffs >> 3);
- OUT_RING_QW_AGP(cb, 0xc2c + i, vOffs >> 3);
-
- WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
-}
-
-void
-viaMpegBeginPicture(void *xlp,ViaXvMCContext *ctx,
- unsigned width,
- unsigned height,
- const XvMCMpegControl *control) {
-
- unsigned j, mb_width, mb_height;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- ViaCommandBuffer *cb = &xl->agpBuf;
-
- mb_width = (width + 15) >> 4;
-
- mb_height =
- ((control->mpeg_coding == XVMC_MPEG_2) &&
- (control->flags & XVMC_PROGRESSIVE_SEQUENCE)) ?
- 2*((height+31) >> 5) : (((height+15) >> 4));
-
- BEGIN_HEADER6_DATA(cb,xl, 72);
- WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
-
- OUT_RING_QW_AGP(cb, 0xc00,
- ((control->picture_structure & XVMC_FRAME_PICTURE) << 2) |
- ((control->picture_coding_type & 3) << 4) |
- ((control->flags & XVMC_ALTERNATE_SCAN) ? (1 << 6) : 0));
-
- if (!(ctx->intraLoaded)) {
- OUT_RING_QW_AGP(cb, 0xc5c, 0);
- for (j = 0; j < 64; j += 4) {
- OUT_RING_QW_AGP(cb, 0xc60,
- ctx->intra_quantiser_matrix[j] |
- (ctx->intra_quantiser_matrix[j+1] << 8) |
- (ctx->intra_quantiser_matrix[j+2] << 16) |
- (ctx->intra_quantiser_matrix[j+3] << 24));
- }
- ctx->intraLoaded = 1;
- }
-
- if (!(ctx->nonIntraLoaded)) {
- OUT_RING_QW_AGP(cb, 0xc5c, 1);
- for (j = 0; j < 64; j += 4) {
- OUT_RING_QW_AGP(cb, 0xc60,
- ctx->non_intra_quantiser_matrix[j] |
- (ctx->non_intra_quantiser_matrix[j+1] << 8) |
- (ctx->non_intra_quantiser_matrix[j+2] << 16) |
- (ctx->non_intra_quantiser_matrix[j+3] << 24));
- }
- ctx->nonIntraLoaded = 1;
- }
-
- if (!(ctx->chromaIntraLoaded)) {
- OUT_RING_QW_AGP(cb, 0xc5c, 2);
- for (j = 0; j < 64; j += 4) {
- OUT_RING_QW_AGP(cb, 0xc60,
- ctx->chroma_intra_quantiser_matrix[j] |
- (ctx->chroma_intra_quantiser_matrix[j+1] << 8) |
- (ctx->chroma_intra_quantiser_matrix[j+2] << 16) |
- (ctx->chroma_intra_quantiser_matrix[j+3] << 24));
- }
- ctx->chromaIntraLoaded = 1;
- }
-
- if (!(ctx->chromaNonIntraLoaded)) {
- OUT_RING_QW_AGP(cb, 0xc5c, 3);
- for (j = 0; j < 64; j += 4) {
- OUT_RING_QW_AGP(cb, 0xc60,
- ctx->chroma_non_intra_quantiser_matrix[j] |
- (ctx->chroma_non_intra_quantiser_matrix[j+1] << 8) |
- (ctx->chroma_non_intra_quantiser_matrix[j+2] << 16) |
- (ctx->chroma_non_intra_quantiser_matrix[j+3] << 24));
- }
- ctx->chromaNonIntraLoaded = 1;
- }
-
- OUT_RING_QW_AGP(cb, 0xc90,
- ((mb_width * mb_height) & 0x3fff) |
- ((control->flags & XVMC_PRED_DCT_FRAME) ? ( 1 << 14) : 0) |
- ((control->flags & XVMC_TOP_FIELD_FIRST) ? (1 << 15) : 0 ) |
- ((control->mpeg_coding == XVMC_MPEG_2) ? (1 << 16) : 0) |
- ((mb_width & 0xff) << 18));
-
- OUT_RING_QW_AGP(cb, 0xc94,
- ((control->flags & XVMC_CONCEALMENT_MOTION_VECTORS) ? 1 : 0) |
- ((control->flags & XVMC_Q_SCALE_TYPE) ? 2 : 0) |
- ((control->intra_dc_precision & 3) << 2) |
- (((1 + 0x100000 / mb_width) & 0xfffff) << 4) |
- ((control->flags & XVMC_INTRA_VLC_FORMAT) ? (1 << 24) : 0));
-
- OUT_RING_QW_AGP(cb, 0xc98,
- (((control->FHMV_range) & 0xf) << 0) |
- (((control->FVMV_range) & 0xf) << 4) |
- (((control->BHMV_range) & 0xf) << 8) |
- (((control->BVMV_range) & 0xf) << 12) |
- ((control->flags & XVMC_SECOND_FIELD) ? (1 << 20) : 0) |
- (0x0a6 << 16));
-
-}
-
-
-
-void
-viaMpegReset(void *xlp)
-{
- int i,j;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- ViaCommandBuffer *cb = &xl->agpBuf;
-
- BEGIN_HEADER6_DATA(cb,xl, 99);
- WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
-
- OUT_RING_QW_AGP(cb, 0xcf0 ,0);
-
- for (i = 0; i < 6; i++) {
- OUT_RING_QW_AGP(cb, 0xcc0 ,0);
- OUT_RING_QW_AGP(cb, 0xc0c, 0x43|0x20 );
- for (j = 0xc10; j < 0xc20; j += 4)
- OUT_RING_QW_AGP(cb, j, 0);
- }
-
- OUT_RING_QW_AGP(cb, 0xc0c, 0x1c3);
- for (j = 0xc10; j < 0xc20; j += 4)
- OUT_RING_QW_AGP(cb,j,0);
-
- for (i = 0; i < 19; i++)
- OUT_RING_QW_AGP(cb, 0xc08 ,0);
-
- OUT_RING_QW_AGP(cb, 0xc98, 0x400000);
-
- for (i = 0; i < 6; i++) {
- OUT_RING_QW_AGP(cb, 0xcc0 ,0);
- OUT_RING_QW_AGP(cb, 0xc0c, 0x1c3|0x20);
- for (j = 0xc10; j < 0xc20; j += 4)
- OUT_RING_QW_AGP(cb,j,0);
- }
- OUT_RING_QW_AGP(cb, 0xcf0 ,0);
-
-}
-
-void
-viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode)
-{
- int i, n, r;
- CARD32* buf;
- int count;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- ViaCommandBuffer *cb = &xl->agpBuf;
-
- if (xl->errors & (LL_DECODER_TIMEDOUT |
- LL_IDCT_FIFO_ERROR |
- LL_SLICE_FIFO_ERROR |
- LL_SLICE_FAULT)) return;
-
- n = nBytes >> 2;
- if (sCode) nBytes += 4;
- r = nBytes & 3;
- buf = (CARD32*) slice;
-
- if (r) nBytes += 4 - r;
-
- nBytes += 8;
-
- BEGIN_HEADER6_DATA(cb,xl, 2);
- WAITFLAGS(cb, LL_MODE_DECODER_IDLE);
- OUT_RING_QW_AGP(cb, 0xc9c, nBytes);
-
- if (sCode) OUT_RING_QW_AGP(cb, 0xca0, sCode);
-
- i = 0;
- count = 0;
-
- do {
- count += (LL_AGP_CMDBUF_SIZE -20);
- count = (count > n) ? n : count;
- BEGIN_HEADER5_DATA(cb, xl, (count - i), 0xca0);
-
- for (; i < count; i++) {
- OUT_RING_AGP(cb, *buf++);
- }
- finish_header_agp(cb);
- } while (i < n);
-
- BEGIN_HEADER5_DATA(cb, xl, 3, 0xca0);
-
- if (r) {
- OUT_RING_AGP(cb, *buf & ((1 << (r << 3)) - 1));
- }
- OUT_RING_AGP(cb,0);
- OUT_RING_AGP(cb,0);
- finish_header_agp(cb);
-}
-
-void
-viaVideoSubPictureOffLocked(void *xlp) {
-
- CARD32 stride;
- int proReg = REG_HQV1_INDEX;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- ViaCommandBuffer *cb = xl->videoBuf;
-
- if (xl->videoBuf == &xl->agpBuf)
- syncDMA(xl, 1);
- stride = VIDIN(xl,proReg|SUBP_CONTROL_STRIDE);
- WAITFLAGS(cb, LL_MODE_VIDEO);
- BEGIN_HEADER6_DATA(cb, xl, 1);
- OUT_RING_QW_AGP(cb, proReg|SUBP_CONTROL_STRIDE | 0x200, stride & ~SUBP_HQV_ENABLE);
-}
-
-void
-viaVideoSubPictureLocked(void *xlp, ViaXvMCSubPicture *pViaSubPic) {
-
- unsigned i;
- CARD32 cWord;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- int proReg = REG_HQV1_INDEX;
- ViaCommandBuffer *cb = xl->videoBuf;
-
- if (xl->videoBuf == &xl->agpBuf)
- syncDMA(xl, 1);
- WAITFLAGS(cb, LL_MODE_VIDEO);
- BEGIN_HEADER6_DATA(cb, xl, VIA_SUBPIC_PALETTE_SIZE + 2);
- for (i=0; i<VIA_SUBPIC_PALETTE_SIZE; ++i) {
- OUT_RING_QW_AGP(cb, proReg|RAM_TABLE_CONTROL | 0x200, pViaSubPic->palette[i]);
- }
-
- cWord = (pViaSubPic->stride & SUBP_STRIDE_MASK) | SUBP_HQV_ENABLE;
- cWord |= (pViaSubPic->ia44) ? SUBP_IA44 : SUBP_AI44;
- OUT_RING_QW_AGP(cb, proReg|SUBP_STARTADDR | 0x200, pViaSubPic->offset);
- OUT_RING_QW_AGP(cb, proReg|SUBP_CONTROL_STRIDE | 0x200, cWord);
-}
-
-void
-viaBlit(void *xlp,unsigned bpp,unsigned srcBase,
- unsigned srcPitch,unsigned dstBase,unsigned dstPitch,
- unsigned w,unsigned h,int xdir,int ydir, unsigned blitMode,
- unsigned color)
-{
-
- CARD32 dwGEMode = 0, srcY=0, srcX, dstY=0, dstX;
- CARD32 cmd;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- ViaCommandBuffer *cb = &xl->agpBuf;
-
- if (!w || !h)
- return;
-
- finish_header_agp(cb);
-
- switch (bpp) {
- case 16:
- dwGEMode |= VIA_GEM_16bpp;
- break;
- case 32:
- dwGEMode |= VIA_GEM_32bpp;
- break;
- default:
- dwGEMode |= VIA_GEM_8bpp;
- break;
- }
-
- srcX = srcBase & 31;
- dstX = dstBase & 31;
- switch (bpp) {
- case 16:
- dwGEMode |= VIA_GEM_16bpp;
- srcX >>= 2;
- dstX >>= 2;
- break;
- case 32:
- dwGEMode |= VIA_GEM_32bpp;
- srcX >>= 4;
- dstX >>= 4;
- break;
- default:
- dwGEMode |= VIA_GEM_8bpp;
- break;
- }
-
- BEGIN_RING_AGP(cb, xl, 20);
- WAITFLAGS(cb, LL_MODE_2D);
-
-
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_GEMODE), dwGEMode);
- cmd = 0;
-
- if (xdir < 0) {
- cmd |= VIA_GEC_DECX;
- srcX += (w - 1);
- dstX += (w - 1);
- }
- if (ydir < 0) {
- cmd |= VIA_GEC_DECY;
- srcY += (h - 1);
- dstY += (h - 1);
- }
-
- switch(blitMode) {
- case VIABLIT_TRANSCOPY:
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_SRCCOLORKEY), color);
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_KEYCONTROL), 0x4000);
- cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
- break;
- case VIABLIT_FILL:
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_FGCOLOR), color);
- cmd |= VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
- break;
- default:
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_KEYCONTROL), 0x0);
- cmd |= VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
- }
-
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_SRCBASE), (srcBase & ~31) >> 3);
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_DSTBASE), (dstBase & ~31) >> 3);
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_PITCH), VIA_PITCH_ENABLE |
- (srcPitch >> 3) | (((dstPitch) >> 3) << 16));
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_SRCPOS), ((srcY << 16) | srcX));
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_DSTPOS), ((dstY << 16) | dstX));
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_DIMENSION), (((h - 1) << 16) | (w - 1)));
- OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_GECMD), cmd);
-}
-
-unsigned
-syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep,
- CARD32 timeStamp)
-{
- unsigned
- errors;
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
-
- if (mode == 0) {
- errors = xl->errors;
- xl->errors = 0;
- return errors;
- }
-
- if ((mode & (LL_MODE_VIDEO | LL_MODE_3D)) || !xl->use_agp) {
- if (xl->performLocking)
- hwlLock(xl,0);
- if ((xl->videoBuf == &xl->agpBuf) || (mode != LL_MODE_VIDEO))
- syncDMA(xl, doSleep);
- if (mode & LL_MODE_3D)
- syncAccel(xl, mode, doSleep);
- if (mode & LL_MODE_VIDEO)
- syncVideo(xl, doSleep);
- if (xl->performLocking)
- hwlUnlock(xl,0);
- } else {
- viaDMAWaitTimeStamp(xl, timeStamp, doSleep);
- }
-
- if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE))
- syncMpeg(xl, mode, doSleep);
-
- errors = xl->errors;
- xl->errors = 0;
-
- return errors;
-}
-
-static int
-updateLowLevelBuf(XvMCLowLevel *xl, LowLevelBuffer *buf,
- unsigned width, unsigned height)
-{
- unsigned
- stride, size;
- drm_via_mem_t *mem = &buf->mem;
- int ret;
-
- stride = (width + 31) & ~31;
- size = stride * height + (xl->fbDepth >> 3);
-
- if (size != mem->size) {
- if (mem->size)
- drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, mem, sizeof(*mem));
- mem->context = *(xl->drmcontext);
- mem->size = size;
- mem->type = VIA_MEM_VIDEO;
-
- if (((ret = drmCommandWriteRead(xl->fd, DRM_VIA_ALLOCMEM, mem, sizeof(mem))) < 0) ||
- mem->size != size) {
- mem->size = 0;
- return -1;
- }
- }
-
- buf->offset = (mem->offset + 31) & ~31;
- buf->stride = stride;
- buf->height = height;
- return 0;
-}
-
-static void
-cleanupLowLevelBuf(XvMCLowLevel *xl, LowLevelBuffer *buf)
-{
- drm_via_mem_t *mem = &buf->mem;
-
- if (mem->size)
- drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, mem, sizeof(mem));
- mem->size = 0;
-}
-
-
-static void
-*releaseXvMCLowLevel(XvMCLowLevel *xl)
-{
- switch(xl->state) {
- case ll_llBuf:
- cleanupLowLevelBuf(xl, &xl->scale);
- case ll_timeStamp:
- viaDMACleanupTimeStamp(xl);
- case ll_pciBuf:
- free(xl->pciBuf.buf);
- case ll_agpBuf:
- free(xl->agpBuf.buf);
- case ll_init:
- free(xl);
- default:
- ;
- }
- return NULL;
-}
-
-
-void
-*initXvMCLowLevel(int fd, drm_context_t *ctx,
- drmLockPtr hwLock, drmAddress mmioAddress,
- drmAddress fbAddress, unsigned fbStride, unsigned fbDepth,
- unsigned width, unsigned height, int useAgp, unsigned chipId )
-{
- XvMCLowLevel *xl = (XvMCLowLevel *)malloc(sizeof(XvMCLowLevel));
-
- if (!xl) return NULL;
- xl->state = ll_init;
-
- xl->agpBuf.buf = (CARD32 *)malloc(LL_AGP_CMDBUF_SIZE * sizeof(CARD32));
- if (!xl->agpBuf.buf) return releaseXvMCLowLevel(xl);
- xl->state = ll_agpBuf;
- xl->agpBuf.bufSize = LL_AGP_CMDBUF_SIZE;
- xl->agpBuf.flushFunc = &agpFlush;
- xl->agpBuf.pos = 0;
- xl->agpBuf.mode = 0;
- xl->agpBuf.waitFlags = 0;
-
- xl->pciBuf.buf = (CARD32 *)malloc(LL_PCI_CMDBUF_SIZE * sizeof(CARD32));
- if (!xl->pciBuf.buf) return releaseXvMCLowLevel(xl);
- xl->state = ll_pciBuf;
- xl->pciBuf.bufSize = LL_PCI_CMDBUF_SIZE;
- xl->pciBuf.flushFunc = &pciFlush;
- xl->pciBuf.pos = 0;
- xl->pciBuf.mode = 0;
- xl->pciBuf.waitFlags = 0;
-
- xl->use_agp = useAgp;
- xl->fd = fd;
- xl->drmcontext = ctx;
- xl->hwLock = hwLock;
- xl->mmioAddress = mmioAddress;
- xl->fbAddress = fbAddress;
- xl->fbDepth = fbDepth;
- xl->fbStride = fbStride;
- xl->width = width;
- xl->height = height;
- xl->performLocking = 1;
- xl->errors = 0;
- xl->agpSync = 0;
- xl->chipId = chipId;
-
- if (viaDMAInitTimeStamp(xl))
- return releaseXvMCLowLevel(xl);
- xl->state = ll_timeStamp;
-
- xl->scale.mem.size = 0;
- xl->back.mem.size = 0;
-
- if (updateLowLevelBuf(xl, &xl->scale, width, height))
- return releaseXvMCLowLevel(xl);
- xl->state = ll_llBuf;
-
-#ifdef VIDEO_DMA
- xl->videoBuf = &xl->agpBuf;
-#else
- xl->videoBuf = &xl->pciBuf;
-#endif
-
- return xl;
-}
-
-void
-setLowLevelLocking(void *xlp, int performLocking)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- xl->performLocking = performLocking;
-}
-
-void
-closeXvMCLowLevel(void *xlp)
-{
- XvMCLowLevel *xl = (XvMCLowLevel *) xlp;
- releaseXvMCLowLevel(xl);
-}
diff --git a/nx-X11/lib/XvMC/hw/via/viaLowLevel.h b/nx-X11/lib/XvMC/hw/via/viaLowLevel.h
deleted file mode 100644
index 12e5fe373..000000000
--- a/nx-X11/lib/XvMC/hw/via/viaLowLevel.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*****************************************************************************
- * VIA Unichrome XvMC extension client lib.
- *
- * Copyright (c) 2004 The Unichrome Project. 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 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
- * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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: Thomas Hellström 2004 - 2005.
- */
-
-
-#ifndef VIA_LOWLEVEL_H
-#define VIA_LOWLEVEL_H
-
-
-/*
- * The below define is cache size sensitive. Increasing the AGP buffer size
- * will enable the library to do deeper pipelining, but will degrade the
- * performance in the drm dma command verifier.
- */
-
-#define LL_AGP_CMDBUF_SIZE (4096*2)
-#define LL_PCI_CMDBUF_SIZE (4096)
-
-#define LL_MODE_DECODER_SLICE 0x01
-#define LL_MODE_DECODER_IDLE 0x02
-#define LL_MODE_VIDEO 0x04
-#define LL_MODE_2D 0x08
-#define LL_MODE_3D 0x10
-
-/*
- * Errors
- */
-
-#define LL_DECODER_TIMEDOUT 0x00000001
-#define LL_IDCT_FIFO_ERROR 0x00000002
-#define LL_SLICE_FIFO_ERROR 0x00000004
-#define LL_SLICE_FAULT 0x00000008
-#define LL_DMA_TIMEDOUT 0x00000010
-#define LL_VIDEO_TIMEDOUT 0x00000020
-#define LL_ACCEL_TIMEDOUT 0x00000040
-#define LL_PCI_COMMAND_ERR 0x00000080
-#define LL_AGP_COMMAND_ERR 0x00000100
-
-#define VIA_SLICEBUSYMASK 0x00000200
-#define VIA_BUSYMASK 0x00000207
-#define VIA_SLICEIDLEVAL 0x00000200
-#define VIA_IDLEVAL 0x00000204
-
-#include "via_drm.h"
-#include "viaXvMCPriv.h"
-
-#define setRegion(xx,yy,ww,hh,region) \
- do { \
- (region).x = (xx); \
- (region).y = (yy); \
- (region).w = (ww); \
- (region).h = (hh); \
- } while(0)
-
-#define regionEqual(r1, r2) \
- ((r1).x == (r2).x && \
- (r1).y == (r2).y && \
- (r1).w == (r2).w && \
- (r1).h == (r2).h)
-
-
-
-extern void
-*initXvMCLowLevel(int fd, drm_context_t *ctx,
- drmLockPtr hwLock, drmAddress mmioAddress,
- drmAddress fbAddress, unsigned fbStride, unsigned fbDepth,
- unsigned width, unsigned height, int useAgp, unsigned chipId );
-
-extern void setLowLevelLocking(void *xlp, int perFormLocking);
-extern void closeXvMCLowLevel(void *xlp);
-extern void flushPCIXvMCLowLevel(void *xlp);
-extern CARD32 viaDMATimeStampLowLevel(void *xlp);
-extern void setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp);
-
-
-/*
- * These two functions also return and clear the current error status.
- */
-
-extern unsigned flushXvMCLowLevel(void *xlp);
-extern unsigned syncXvMCLowLevel(void *xlp, unsigned int mode,
- unsigned int doSleep, CARD32 timeStamp);
-
-extern void hwlUnlock(void *xlp, int videoLock);
-extern void hwlLock(void *xlp, int videoLock);
-
-extern void viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs,
- unsigned vOffs, unsigned yStride, unsigned uvStride);
-
-extern void viaMpegReset(void *xlp);
-extern void viaMpegWriteSlice(void *xlp, CARD8* slice,
- int nBytes, CARD32 sCode);
-extern void viaMpegSetSurfaceStride(void *xlp, ViaXvMCContext *ctx);
-extern void viaMpegSetFB(void *xlp,unsigned i, unsigned yOffs,
- unsigned uOffs, unsigned vOffs);
-extern void viaMpegBeginPicture(void *xlp, ViaXvMCContext *ctx,unsigned width,
- unsigned height,const XvMCMpegControl *control);
-
-/*
- * Low-level Video functions in viaLowLevel.c
- */
-
-
-extern void viaBlit(void *xlp,unsigned bpp,unsigned srcBase,
- unsigned srcPitch,unsigned dstBase,unsigned dstPitch,
- unsigned w,unsigned h,int xdir,int ydir,
- unsigned blitMode, unsigned color);
-
-extern void viaVideoSWFlipLocked(void *xlp, unsigned flags,
- int progressiveSequence);
-
-extern void viaVideoSubPictureLocked(void *xlp,ViaXvMCSubPicture *pViaSubPic);
-extern void viaVideoSubPictureOffLocked(void *xlp);
-
-
-
-
-#define PCI_CHIP_VT3204 0x3108 /* K8M800 */
-#define PCI_CHIP_VT3259 0x3118 /* PM800/PM880/CN400 */
-#define PCI_CHIP_CLE3122 0x3122 /* CLE266 */
-#define PCI_CHIP_VT3205 0x7205 /* KM400 */
-
-#endif
diff --git a/nx-X11/lib/XvMC/hw/via/viaXvMC.c b/nx-X11/lib/XvMC/hw/via/viaXvMC.c
deleted file mode 100644
index eebc87ea8..000000000
--- a/nx-X11/lib/XvMC/hw/via/viaXvMC.c
+++ /dev/null
@@ -1,1964 +0,0 @@
-/*****************************************************************************
- * VIA Unichrome XvMC extension client lib.
- *
- * Copyright (c) 2004-2005 Thomas Hellström. 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 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
- * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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: Thomas Hellström, 2004.
- *Bugfixes by among others Pascal Brisset and Terry Barnaby.
- *DRI protocol support by Thomas Hellström, 2005.
- */
-
-#undef WAITPAUSE
-
-#include "viaXvMCPriv.h"
-#include "viaLowLevel.h"
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <time.h>
-#include <fourcc.h>
-#include <X11/extensions/Xv.h>
-#include <xf86drm.h>
-#include <pthread.h>
-#include <X11/extensions/vldXvMC.h>
-#include "xf86dri.h"
-#include "driDrawable.h"
-
-#define SAREAPTR(ctx) ((ViaXvMCSAreaPriv *) \
- (((CARD8 *)(ctx)->sAreaAddress) + \
- (ctx)->sAreaPrivOffset))
-
-
-
-static int error_base;
-static int event_base;
-static unsigned numContexts = 0;
-static int globalFD;
-static drmAddress sAreaAddress;
-static drmAddress fbAddress;
-static drmAddress mmioAddress;
-
-
-#define FOURCC_XVMC (('C' << 24) + ('M' << 16) + ('V' << 8) + 'X')
-
-#define ppthread_mutex_lock(arg) \
- { \
- pthread_mutex_lock(arg); \
- } \
-
-#define ppthread_mutex_unlock(arg) \
- { \
- pthread_mutex_unlock(arg); \
- } \
-
-static unsigned yOffs (ViaXvMCSurface *srf)
-{
- return srf->offsets[0];
-}
-
-static unsigned vOffs (ViaXvMCSurface *srf)
-{
- return srf->offsets[0] + srf->yStride * srf->height;
-}
-
-static unsigned uOffs (ViaXvMCSurface *srf)
-{
- return srf->offsets[0] + ( srf->yStride * srf->height) +
- (srf->yStride >> 1) * (srf->height >> 1);
-}
-
-
-static void defaultQMatrices(ViaXvMCContext *ctx)
-{
- int i;
-
- static const char intra[64] = {
- 8, 16, 19, 22, 26, 27, 29, 34, 16, 16, 22, 24, 27, 29, 34, 37,
- 19, 22, 26, 27, 29, 34, 34, 38, 22, 22, 26, 27, 29, 34, 37, 40,
- 22, 26, 27, 29, 32, 35, 40, 48, 26, 27, 29, 32, 35, 40, 48, 58,
- 26, 27, 29, 34, 38, 46, 56, 69, 27, 29, 35, 38, 46, 56, 69, 83
- };
-
- for( i=0; i<64; ++i) {
- ctx->intra_quantiser_matrix[i] = intra[i];
- ctx->non_intra_quantiser_matrix[i] = 16;
- }
- ctx->intraLoaded = 0;
- ctx->nonIntraLoaded = 0;
-}
-
-
-static void releaseDecoder(ViaXvMCContext *ctx,int clearCtx)
-{
- volatile ViaXvMCSAreaPriv *sAPriv;
-
- sAPriv = SAREAPTR(ctx);
- UNICHROME_UNLOCK(ctx->fd, UNICHROME_LOCK_DECODER1, sAPriv, ctx->drmcontext);
-}
-
-
-static int grabDecoder( ViaXvMCContext *ctx, int *hadLastLock)
-{
- volatile ViaXvMCSAreaPriv *sAPriv = SAREAPTR(ctx);
- int retFtx, lc;
-
- /*
- * Try to grab the decoder. If it is not available we will sleep until
- * it becomes available or for a maximum of 20 ms.
- * Then try to grab it again, unless a timeout occured. If the decoder is
- * available, the lock should be reasonably fast.
- */
-
- if (ctx->haveDecoder) {
- flushXvMCLowLevel(ctx->xl); /* Ignore errors here. */
-
- /*fprintf(stderr,"ViaXvMC: ERROR: Trying to re-lock decoder.\n"); */
- *hadLastLock = 1;
- return 0;
- }
- UNICHROME_LOCK(ctx->fd, UNICHROME_LOCK_DECODER1, sAPriv, ctx->drmcontext, lc,
- retFtx);
- *hadLastLock = (ctx->drmcontext == lc);
-
- return retFtx;
-}
-
-static void setupAttribDesc(Display *display, XvPortID port,
- const ViaXvMCAttrHolder *attrib,
- XvAttribute attribDesc[])
-{
- XvAttribute *XvAttribs,*curAD;
- int num;
- unsigned i,j;
-
- XLockDisplay(display);
- XvAttribs = XvQueryPortAttributes(display, port, &num);
- for(i=0; i<attrib->numAttr; ++i) {
- curAD = attribDesc + i;
- curAD->flags = 0;
- curAD->min_value = 0;
- curAD->max_value = 0;
- curAD->name = NULL;
- for(j=0; j<num; ++j) {
- if (attrib->attributes[i].attribute ==
- XInternAtom(display,XvAttribs[j].name,TRUE)) {
- *curAD = XvAttribs[j];
- curAD->name = strdup(XvAttribs[j].name);
- break;
- }
- }
- }
- if (XvAttribs) XFree(XvAttribs);
- XUnlockDisplay(display);
-
-}
-
-static void releaseAttribDesc(int numAttr, XvAttribute attribDesc[])
-{
- int i;
-
- for (i=0; i<numAttr; ++i) {
- if (attribDesc[i].name)
- free(attribDesc[i].name);
- }
-}
-
-static Status releaseContextResources(Display *display, XvMCContext *context,
- int freePrivate, Status errType)
-{
- ViaXvMCContext *pViaXvMC = (ViaXvMCContext *) context->privData;
-
- switch(pViaXvMC->resources) {
- case context_drawHash:
- driDestroyHashContents( pViaXvMC->drawHash );
- drmHashDestroy( pViaXvMC->drawHash );
- case context_lowLevel:
- closeXvMCLowLevel(pViaXvMC->xl);
- case context_mutex:
- pthread_mutex_destroy(&pViaXvMC->ctxMutex);
- case context_drmContext:
- XLockDisplay(display);
- uniDRIDestroyContext(display, pViaXvMC->screen, pViaXvMC->id);
- XUnlockDisplay(display);
- case context_sAreaMap:
- numContexts--;
- if (numContexts == 0)
- drmUnmap(pViaXvMC->sAreaAddress,pViaXvMC->sAreaSize);
- case context_fbMap:
- if (numContexts == 0)
- drmUnmap(pViaXvMC->fbAddress,pViaXvMC->fbSize);
- case context_mmioMap:
- if (numContexts == 0)
- drmUnmap(pViaXvMC->mmioAddress,pViaXvMC->mmioSize);
- case context_fd:
- if (numContexts == 0) {
- if (pViaXvMC->fd >= 0)
- drmClose(pViaXvMC->fd);
- }
- pViaXvMC->fd = -1;
- case context_driConnection:
- if (numContexts == 0) {
- XLockDisplay(display);
- uniDRICloseConnection(display, pViaXvMC->screen);
- XUnlockDisplay(display);
- }
- case context_context:
- XLockDisplay(display);
- _xvmc_destroy_context(display, context);
- XUnlockDisplay(display);
- if (!freePrivate) break;
- default:
- free(pViaXvMC);
- }
- return errType;
-}
-
-Status XvMCCreateContext(Display *display, XvPortID port,
- int surface_type_id, int width, int height, int flags,
- XvMCContext *context)
-{
- ViaXvMCContext *pViaXvMC;
- int priv_count;
- uint *priv_data;
- uint magic;
- unsigned i;
- Status ret;
- int major, minor;
- ViaXvMCCreateContextRec *tmpComm;
- drmVersionPtr drmVer;
- char *curBusID;
- int isCapable;
-
- /*
- * Verify Obvious things first
- */
-
- if(context == NULL) {
- return XvMCBadContext;
- }
-
- if(!(flags & XVMC_DIRECT)) {
- fprintf(stderr,"Indirect Rendering not supported! Using Direct.\n");
- }
-
- /*
- *FIXME: Check $DISPLAY for legal values here
- */
-
- context->surface_type_id = surface_type_id;
- context->width = (unsigned short)((width + 15) & ~15);
- context->height = (unsigned short)((height + 15) & ~15);
- context->flags = flags;
- context->port = port;
-
- /*
- * Width, Height, and flags are checked against surface_type_id
- * and port for validity inside the X server, no need to check
- * here.
- */
-
- /* Allocate private Context data */
- context->privData = (void *)malloc(sizeof(ViaXvMCContext));
- if(!context->privData) {
- fprintf(stderr,"Unable to allocate resources for XvMC context.\n");
- return BadAlloc;
- }
-
- pViaXvMC = (ViaXvMCContext *)context->privData;
- pViaXvMC->resources = context_none;
-
- /* Verify the XvMC extension exists */
-
- XLockDisplay(display);
- if(! XvMCQueryExtension(display, &event_base,
- &error_base)) {
- fprintf(stderr,"XvMC Extension is not available!\n");
- free(pViaXvMC);
- XUnlockDisplay(display);
- return BadAlloc;
- }
-
- /* Verify XvMC version */
- ret = XvMCQueryVersion(display, &major, &minor);
- if(ret) {
- fprintf(stderr,"XvMCQuery Version Failed, unable to determine "
- "protocol version!\n");
- }
- XUnlockDisplay(display);
-
- /* FIXME: Check Major and Minor here */
-
- XLockDisplay(display);
- if((ret = _xvmc_create_context(display, context, &priv_count,
- &priv_data))) {
- XUnlockDisplay(display);
- fprintf(stderr,"Unable to create XvMC Context.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- XUnlockDisplay(display);
-
- /*
- * Check size and version of returned data.
- */
-
- tmpComm = ( ViaXvMCCreateContextRec *) priv_data;
- if(priv_count != (sizeof(ViaXvMCCreateContextRec) >> 2)) {
- fprintf(stderr,"_xvmc_create_context() returned incorrect "
- "data size!\n");
- fprintf(stderr,"\tExpected %d, got %d\n",
- (int) (sizeof(ViaXvMCCreateContextRec) >> 2),
- (int) priv_count);
- XFree(priv_data);
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- pViaXvMC->resources = context_context;
-
- if ((tmpComm->major != VIAXVMC_MAJOR) ||
- (tmpComm->minor != VIAXVMC_MINOR)) {
- fprintf(stderr,"Version mismatch between the X via driver\n"
- "and the XvMC library. Cannot continue!\n");
- XFree(priv_data);
- return releaseContextResources(display, context, 1, BadAlloc);
- }
-
- pViaXvMC->ctxNo = tmpComm->ctxNo;
- pViaXvMC->fbOffset = tmpComm->fbOffset;
- pViaXvMC->fbSize = tmpComm->fbSize;
- pViaXvMC->mmioOffset = tmpComm->mmioOffset;
- pViaXvMC->mmioSize = tmpComm->mmioSize;
- pViaXvMC->sAreaSize = tmpComm->sAreaSize;
- pViaXvMC->sAreaPrivOffset = tmpComm->sAreaPrivOffset;
- pViaXvMC->decoderOn = 0;
- pViaXvMC->xvMCPort = tmpComm->xvmc_port;
- pViaXvMC->useAGP = tmpComm->useAGP;
- pViaXvMC->attrib = tmpComm->initAttrs;
- pViaXvMC->screen = tmpComm->screen;
- pViaXvMC->depth = tmpComm->depth;
- pViaXvMC->stride = tmpComm->stride;
- pViaXvMC->chipId = tmpComm->chipId;
-
- /*
- * Must free the private data we were passed from X
- */
-
- XFree(priv_data);
-
- /*
- * Check for direct rendering capable, establish DRI and DRM connections,
- * map framebuffer, DRI shared area and read-only register areas.
- * Initial checking for drm has already been done by the server.
- * Only do this for the first context we create.
- */
-
- if (numContexts == 0) {
- XLockDisplay(display);
- ret = uniDRIQueryDirectRenderingCapable(display, pViaXvMC->screen, &isCapable);
- if (!ret || !isCapable) {
- XUnlockDisplay(display);
- fprintf(stderr,"Direct Rendering is not available on this system!\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
-
- if (!uniDRIOpenConnection(display, pViaXvMC->screen, &pViaXvMC->sAreaOffset,
- &curBusID)) {
- XUnlockDisplay(display);
- fprintf(stderr,"Could not open DRI connection to X server!\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- XUnlockDisplay(display);
-
- strncpy(pViaXvMC->busIdString,curBusID,20);
- pViaXvMC->busIdString[20] = '\0';
- XFree(curBusID);
-
- pViaXvMC->resources = context_driConnection;
-
- if((pViaXvMC->fd = drmOpen("via",pViaXvMC->busIdString)) < 0) {
- fprintf(stderr,"DRM Device for via could not be opened.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- globalFD = pViaXvMC->fd;
- pViaXvMC->resources = context_fd;
-
- if (NULL == (drmVer = drmGetVersion(pViaXvMC->fd))) {
- fprintf(stderr,
- "viaXvMC: Could not get drm version.");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- if (((drmVer->version_major != 2 ) || (drmVer->version_minor < 0))) {
- fprintf(stderr,
- "viaXvMC: Kernel drm is not compatible with XvMC.\n");
- fprintf(stderr,
- "viaXvMC: Kernel drm version: %d.%d.%d "
- "and I need at least version 2.0.0.\n"
- "Please update.\n",
- drmVer->version_major,drmVer->version_minor,
- drmVer->version_patchlevel);
- drmFreeVersion(drmVer);
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- drmFreeVersion(drmVer);
- drmGetMagic(pViaXvMC->fd,&magic);
-
- XLockDisplay(display);
- if (!uniDRIAuthConnection(display, pViaXvMC->screen, magic)) {
- XUnlockDisplay(display);
- fprintf(stderr, "viaXvMC: X server did not allow DRI. Check permissions.\n");
- XFree(priv_data);
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- XUnlockDisplay(display);
-
- /*
- * Map the register memory
- */
-
- if(drmMap(pViaXvMC->fd,pViaXvMC->mmioOffset,
- pViaXvMC->mmioSize,&mmioAddress) < 0) {
- fprintf(stderr,"Unable to map the display chip mmio registers.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- pViaXvMC->mmioAddress = mmioAddress;
- pViaXvMC->resources = context_mmioMap;
-
- /*
- * Map Framebuffer memory
- */
-
- if(drmMap(pViaXvMC->fd,pViaXvMC->fbOffset,
- pViaXvMC->fbSize,&fbAddress) < 0) {
- fprintf(stderr,"Unable to map XvMC Framebuffer.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- pViaXvMC->fbAddress = fbAddress;
- pViaXvMC->resources = context_fbMap;
-
-
- /*
- * Map DRI Sarea.
- */
-
- if(drmMap(pViaXvMC->fd,pViaXvMC->sAreaOffset,
- pViaXvMC->sAreaSize,&sAreaAddress) < 0) {
- fprintf(stderr,"Unable to map DRI SAREA.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- } else {
- pViaXvMC->fd = globalFD;
- pViaXvMC->mmioAddress = mmioAddress;
- pViaXvMC->fbAddress = fbAddress;
- }
-
- pViaXvMC->sAreaAddress = sAreaAddress;
- pViaXvMC->resources = context_sAreaMap;
- numContexts++;
-
- /*
- * Find a matching visual. Important only for direct drawing to the visible
- * frame-buffer.
- */
-
- XLockDisplay(display);
- ret = XMatchVisualInfo(display, pViaXvMC->screen,
- (pViaXvMC->depth == 32) ? 24 : pViaXvMC->depth, TrueColor,
- &pViaXvMC->visualInfo);
- XUnlockDisplay(display);
- if (!ret) {
- fprintf(stderr, "viaXvMC: Could not find a matching TrueColor visual.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
-
- if (!uniDRICreateContext(display, pViaXvMC->screen, pViaXvMC->visualInfo.visual,
- &pViaXvMC->id, &pViaXvMC->drmcontext)) {
-
- fprintf(stderr, "viaXvMC: Could not create DRI context.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
-
- pViaXvMC->resources = context_drmContext;
-
- for (i=0; i<VIA_MAX_RENDSURF; ++i) {
- pViaXvMC->rendSurf[i] = 0;
- }
- pViaXvMC->lastSrfDisplaying = ~0;
- setupAttribDesc(display, port, &pViaXvMC->attrib, pViaXvMC->attribDesc);
-
- pViaXvMC->hwLock = (drmLockPtr) pViaXvMC->sAreaAddress;
- defaultQMatrices(pViaXvMC);
- pViaXvMC->chromaIntraLoaded = 1;
- pViaXvMC->chromaNonIntraLoaded = 1;
- pViaXvMC->yStride = (width + 31) & ~31;
- pViaXvMC->haveDecoder = 0;
- pViaXvMC->attribChanged = 1;
- pViaXvMC->haveXv = 0;
- pViaXvMC->port = context->port;
- pthread_mutex_init(&pViaXvMC->ctxMutex,NULL);
- pViaXvMC->resources = context_mutex;
- pViaXvMC->timeStamp = 0;
- setRegion(0,0,-1,-1,pViaXvMC->sRegion);
- setRegion(0,0,-1,-1,pViaXvMC->dRegion);
-
- if (NULL == (pViaXvMC->xl =
- initXvMCLowLevel(pViaXvMC->fd, &pViaXvMC->drmcontext,
- pViaXvMC->hwLock, pViaXvMC->mmioAddress,
- pViaXvMC->fbAddress, pViaXvMC->stride, pViaXvMC->depth,
- context->width, context->height,
- pViaXvMC->useAGP, pViaXvMC->chipId))) {
-
- fprintf(stderr,"ViaXvMC: Could not allocate timestamp blit area.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- pViaXvMC->resources = context_lowLevel;
- setAGPSyncLowLevel(pViaXvMC->xl, 1, 0);
-
- if (NULL == (pViaXvMC->drawHash = drmHashCreate())) {
- fprintf(stderr,"ViaXvMC: Could not allocate drawable hash table.\n");
- return releaseContextResources(display, context, 1, BadAlloc);
- }
- pViaXvMC->resources = context_drawHash;
-
-
- if (numContexts == 1) {
- hwlLock(pViaXvMC->xl,1);
- setLowLevelLocking(pViaXvMC->xl,0);
- viaVideoSubPictureOffLocked(pViaXvMC->xl);
- flushXvMCLowLevel(pViaXvMC->xl);
- setLowLevelLocking(pViaXvMC->xl,1);
- hwlUnlock(pViaXvMC->xl,1);
- }
-
- return Success;
-}
-
-
-Status XvMCDestroyContext(Display *display, XvMCContext *context)
-{
- ViaXvMCContext *pViaXvMC;
-
-
- if(context == NULL) {
- return (error_base + XvMCBadContext);
- }
- if(NULL == (pViaXvMC = context->privData)) {
- return (error_base + XvMCBadContext);
- }
-
- /*
- * Release decoder if we have it. In case of crash or termination
- * before XvMCDestroyContext, the X server will take care of this.
- */
-
- releaseAttribDesc(pViaXvMC->attrib.numAttr,pViaXvMC->attribDesc);
- releaseDecoder(pViaXvMC,1);
- return releaseContextResources(display, context, 1, Success);
-}
-
-Status XvMCCreateSurface( Display *display, XvMCContext *context,
- XvMCSurface *surface)
-{
- ViaXvMCContext *pViaXvMC;
- ViaXvMCSurface *pViaSurface;
- int priv_count;
- unsigned *priv_data;
- unsigned i;
- Status ret;
-
- if((surface == NULL) || (context == NULL) || (display == NULL)){
- return BadValue;
- }
-
- pViaXvMC = (ViaXvMCContext *)context->privData;
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
-
- if(pViaXvMC == NULL) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return (error_base + XvMCBadContext);
- }
-
- pViaSurface = surface->privData = (ViaXvMCSurface *)malloc(sizeof(ViaXvMCSurface));
- if(!surface->privData) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadAlloc;
- }
- XLockDisplay(display);
- if((ret = _xvmc_create_surface(display, context, surface,
- &priv_count, &priv_data))) {
- XUnlockDisplay(display);
- free(pViaSurface);
- fprintf(stderr,"Unable to create XvMC Surface.\n");
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return ret;
- }
- XUnlockDisplay(display);
-
- pViaSurface->srfNo = priv_data[0];
-
- /*
- * Store framebuffer offsets to the buffers allocated for this surface.
- * For some chipset revisions, surfaces may be double-buffered.
- */
-
- pViaSurface->numBuffers = priv_data[1];
- for (i=0; i < pViaSurface->numBuffers; ++i) {
- pViaSurface->offsets[i] = priv_data[i+2];
- }
- pViaSurface->curBuf = 0;
-
-
- /* Free data returned from xvmc_create_surface */
-
- XFree(priv_data);
-
- pViaSurface->width = context->width;
- pViaSurface->height = context->height;
- pViaSurface->yStride = pViaXvMC->yStride;
- pViaSurface->privContext = pViaXvMC;
- pViaSurface->privSubPic = NULL;
- pViaSurface->needsSync = 0;
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-Status XvMCDestroySurface(Display *display, XvMCSurface *surface)
-{
- ViaXvMCSurface *pViaSurface;
-
- if((display == NULL) || (surface == NULL)) {
- return BadValue;
- }
- if(surface->privData == NULL) {
- return (error_base + XvMCBadSurface);
- }
-
- pViaSurface = (ViaXvMCSurface *)surface->privData;
-
- XLockDisplay(display);
- _xvmc_destroy_surface(display,surface);
- XUnlockDisplay(display);
-
- free(pViaSurface);
- surface->privData = NULL;
- return Success;
-}
-
-Status XvMCPutSlice2(Display *display,XvMCContext *context, char *slice,
- int nBytes, int sliceCode)
-{
- ViaXvMCContext *pViaXvMC;
- CARD32 sCode = 0x00010000 | (sliceCode & 0xFF) << 24;
-
- if((display == NULL) || (context == NULL)) {
- return BadValue;
- }
- if(NULL == (pViaXvMC = context->privData)) {
- return (error_base + XvMCBadContext);
- }
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- if (!pViaXvMC->haveDecoder) {
- fprintf(stderr,"XvMCPutSlice: This context does not own decoder!\n");
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadAlloc;
- }
-
- viaMpegWriteSlice(pViaXvMC->xl, (CARD8 *)slice, nBytes, sCode);
-
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-Status XvMCPutSlice(Display *display,XvMCContext *context, char *slice,
- int nBytes)
-{
- ViaXvMCContext *pViaXvMC;
-
- if((display == NULL) || (context == NULL)) {
- return BadValue;
- }
- if(NULL == (pViaXvMC = context->privData)) {
- return (error_base + XvMCBadContext);
- }
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
-
- if (!pViaXvMC->haveDecoder) {
- fprintf(stderr,"XvMCPutSlice: This context does not own decoder!\n");
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadAlloc;
- }
-
- viaMpegWriteSlice(pViaXvMC->xl, (CARD8 *)slice, nBytes, 0);
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-
-static Status updateXVOverlay(Display *display,ViaXvMCContext *pViaXvMC,
- ViaXvMCSurface *pViaSurface, Drawable draw,
- short srcx, short srcy, unsigned short srcw,
- unsigned short srch,short destx,short desty,
- unsigned short destw,unsigned short desth)
-{
- ViaXvMCCommandBuffer buf;
- ViaXvMCSubPicture *pViaSubPic;
- Status ret;
-
- if (!pViaXvMC->haveXv) {
- pViaXvMC->xvImage =
- XvCreateImage(display,pViaXvMC->port,FOURCC_XVMC,
- (char *)&buf,pViaSurface->width,
- pViaSurface->height);
- pViaXvMC->gc = XCreateGC(display,draw,0,0);
- pViaXvMC->haveXv = 1;
- }
- pViaXvMC->draw = draw;
- pViaXvMC->xvImage->data = (char *)&buf;
-
- buf.command = (pViaXvMC->attribChanged) ?
- VIA_XVMC_COMMAND_FDISPLAY : VIA_XVMC_COMMAND_DISPLAY;
- buf.ctxNo = pViaXvMC->ctxNo | VIA_XVMC_VALID;
- buf.srfNo = pViaSurface->srfNo | VIA_XVMC_VALID;
- pViaSubPic = pViaSurface->privSubPic;
- buf.subPicNo = ((NULL == pViaSubPic) ? 0 : pViaSubPic->srfNo )
- | VIA_XVMC_VALID;
- buf.attrib = pViaXvMC->attrib;
-
- XLockDisplay(display);
-
- if ((ret = XvPutImage(display,pViaXvMC->port,draw,pViaXvMC->gc,
- pViaXvMC->xvImage,srcx,srcy,srcw,srch,
- destx,desty,destw,desth))) {
- XUnlockDisplay(display);
- return ret;
- }
- XSync(display, 0);
- XUnlockDisplay(display);
- pViaXvMC->attribChanged = 0;
- return Success;
-}
-
-
-Status XvMCPutSurface(Display *display,XvMCSurface *surface,Drawable draw,
- short srcx, short srcy, unsigned short srcw,
- unsigned short srch,short destx,short desty,
- unsigned short destw,unsigned short desth, int flags)
-{
- /*
- * This function contains some hairy locking logic. What we really want to
- * do is to flip the picture ASAP, to get a low latency and smooth playback.
- * However, if somebody else used the overlay since we used it last or if it is
- * our first time, we'll have to call X to update the overlay first. Otherwise
- * we'll do the overlay update once we've flipped. Since we release the hardware
- * lock when we call X, X needs to verify using the SAREA that nobody else flipped
- * in a picture between the lock release and the X server control. Similarly
- * when the overlay update returns, we have to make sure that we still own the
- * overlay.
- */
-
- ViaXvMCSurface *pViaSurface;
- ViaXvMCContext *pViaXvMC;
- ViaXvMCSubPicture *pViaSubPic;
- volatile ViaXvMCSAreaPriv *sAPriv;
- Status ret;
- unsigned dispSurface, lastSurface;
- int overlayUpdated;
- drawableInfo *drawInfo;
- XvMCRegion sReg, dReg;
- Bool forceUpdate = FALSE;
-
- if((display == NULL) || (surface == NULL)) {
- return BadValue;
- }
- if(NULL == (pViaSurface = surface->privData )) {
- return (error_base + XvMCBadSurface);
- }
- if (NULL == (pViaXvMC = pViaSurface->privContext)) {
- return (error_base + XvMCBadContext);
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- pViaSubPic = pViaSurface->privSubPic;
- sAPriv = SAREAPTR( pViaXvMC );
-
- setRegion(srcx, srcy, srcw, srch, sReg);
- setRegion(destx, desty, destw, desth, dReg);
-
-
- if ((!regionEqual(sReg, pViaXvMC->sRegion)) ||
- (!regionEqual(dReg, pViaXvMC->dRegion))) {
-
- /*
- * Force update of the video overlay to match the new format.
- */
-
- pViaXvMC->sRegion = sReg;
- pViaXvMC->dRegion = dReg;
- forceUpdate = TRUE;
- }
-
-
- hwlLock(pViaXvMC->xl,1);
-
- if (getDRIDrawableInfoLocked(pViaXvMC->drawHash, display, pViaXvMC->screen, draw, 0,
- pViaXvMC->fd, pViaXvMC->drmcontext, pViaXvMC->sAreaAddress,
- FALSE, &drawInfo, sizeof(*drawInfo))) {
-
- hwlUnlock(pViaXvMC->xl,1);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadAccess;
- }
-
- setLowLevelLocking(pViaXvMC->xl,0);
-
-
- /*
- * Put a surface ID in the SAREA to "authenticate" to the
- * X server.
- */
-
- dispSurface = sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort];
- lastSurface = pViaXvMC->lastSrfDisplaying;
- sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort] =
- pViaXvMC->lastSrfDisplaying = pViaSurface->srfNo | VIA_XVMC_VALID;
- overlayUpdated = 0;
-
- viaVideoSetSWFLipLocked(pViaXvMC->xl, yOffs(pViaSurface), uOffs(pViaSurface),
- vOffs(pViaSurface), pViaSurface->yStride, pViaSurface->yStride >> 1);
-
- while ((lastSurface != dispSurface) || forceUpdate) {
-
- forceUpdate = FALSE;
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- setLowLevelLocking(pViaXvMC->xl,1);
- hwlUnlock(pViaXvMC->xl,1);
-
- /*
- * We weren't the last to display. Update the overlay before flipping.
- */
-
- ret = updateXVOverlay(display,pViaXvMC,pViaSurface,draw,srcx,srcy,srcw,
- srch,destx,desty,destw,desth);
- if (ret) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return ret;
- }
-
- hwlLock(pViaXvMC->xl,1);
-
- if (getDRIDrawableInfoLocked(pViaXvMC->drawHash, display, pViaXvMC->screen, draw, 0,
- pViaXvMC->fd, pViaXvMC->drmcontext, pViaXvMC->sAreaAddress,
- FALSE, &drawInfo, sizeof(*drawInfo))) {
-
- hwlUnlock(pViaXvMC->xl,1);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadAccess;
- }
-
- setLowLevelLocking(pViaXvMC->xl,0);
- lastSurface = pViaSurface->srfNo | VIA_XVMC_VALID;
- dispSurface = sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort];
- overlayUpdated = 1;
- }
-
-
- /*
- * Subpictures
- */
-
- if (NULL != pViaSubPic) {
- if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort]
- != (pViaSubPic->srfNo | VIA_XVMC_VALID)) {
- sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] =
- pViaSubPic->srfNo | VIA_XVMC_VALID;
- viaVideoSubPictureLocked(pViaXvMC->xl, pViaSubPic);
- }
- } else {
- if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] & VIA_XVMC_VALID) {
- viaVideoSubPictureOffLocked(pViaXvMC->xl);
- sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] &= ~VIA_XVMC_VALID;
- }
- }
-
- /*
- * Flip
- */
-
- viaVideoSWFlipLocked(pViaXvMC->xl, flags, pViaSurface->progressiveSequence);
- flushXvMCLowLevel(pViaXvMC->xl);
-
- setLowLevelLocking(pViaXvMC->xl,1);
- hwlUnlock(pViaXvMC->xl,1);
-
- if (overlayUpdated || !drawInfo->touched ) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
- }
-
- /*
- * Update overlay
- */
-
- ret = updateXVOverlay(display,pViaXvMC,pViaSurface,draw,srcx,srcy,srcw,
- srch,destx,desty,destw,desth);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return ret;
-
-}
-
-Status XvMCBeginSurface(Display *display,
- XvMCContext *context,
- XvMCSurface *target_surface,
- XvMCSurface *past_surface,
- XvMCSurface *future_surface,
- const XvMCMpegControl *control)
-{
- ViaXvMCSurface *targS,*futS,*pastS;
- ViaXvMCContext *pViaXvMC;
- int hadDecoderLast;
- CARD32 timeStamp;
-
- if((display == NULL) || (context == NULL) || (target_surface == NULL)) {
- return BadValue;
- }
-
- pViaXvMC = context->privData;
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- if (grabDecoder(pViaXvMC, &hadDecoderLast)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadAlloc;
- }
- pViaXvMC->haveDecoder = 1;
-
- /*
- * We need to wait for decoder idle at next flush, since hardware doesn't queue
- * beginsurface requests until the decoder is idle. This is
- * done by waiting on the last previous timestamp, or if there was another context
- * having the decoder before us, by emitting a new one.
- */
-
- if (pViaXvMC->useAGP) {
- if (!hadDecoderLast || pViaXvMC->timeStamp == 0) {
- timeStamp = viaDMATimeStampLowLevel(pViaXvMC->xl);
- if (flushXvMCLowLevel(pViaXvMC->xl)) {
- releaseDecoder(pViaXvMC, 0);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadAlloc;
- }
- pViaXvMC->timeStamp = timeStamp;
- } else {
- timeStamp = pViaXvMC->timeStamp;
- }
- setAGPSyncLowLevel(pViaXvMC->xl, 1, timeStamp);
- }
-
- if (!hadDecoderLast || !pViaXvMC->decoderOn) {
- pViaXvMC->intraLoaded = 0;
- pViaXvMC->nonIntraLoaded = 0;
- }
-
- viaMpegReset(pViaXvMC->xl);
-
- targS = (ViaXvMCSurface *)target_surface->privData;
- futS = NULL;
- pastS = NULL;
-
-
- pViaXvMC->rendSurf[0] = targS->srfNo | VIA_XVMC_VALID;
- if (future_surface) {
- futS = (ViaXvMCSurface *)future_surface->privData;
- futS->needsSync = 0;
- }
- if (past_surface) {
- pastS = (ViaXvMCSurface *)past_surface->privData;
- pastS->needsSync = 0;
- }
-
-
- targS->progressiveSequence = (control->flags & XVMC_PROGRESSIVE_SEQUENCE);
- targS->topFieldFirst = (control->flags & XVMC_TOP_FIELD_FIRST);
- targS->privSubPic = NULL;
-
- viaMpegSetSurfaceStride(pViaXvMC->xl,pViaXvMC);
-
- viaMpegSetFB(pViaXvMC->xl,0,yOffs(targS),uOffs(targS),vOffs(targS));
- if (past_surface) {
- viaMpegSetFB(pViaXvMC->xl,1,yOffs(pastS),uOffs(pastS),vOffs(pastS));
- } else {
- viaMpegSetFB(pViaXvMC->xl,1,0,0,0);
- }
-
- if (future_surface) {
- viaMpegSetFB(pViaXvMC->xl,2,yOffs(futS),uOffs(futS),vOffs(futS));
- } else {
- viaMpegSetFB(pViaXvMC->xl,2,0,0,0);
- }
-
- viaMpegBeginPicture(pViaXvMC->xl,pViaXvMC,context->width,context->height,control);
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- targS->needsSync = 1;
- targS->syncMode = LL_MODE_DECODER_IDLE;
- pViaXvMC->decoderOn = 1;
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-
-Status XvMCSyncSurface(Display *display,XvMCSurface *surface)
-{
- ViaXvMCSurface *pViaSurface;
- ViaXvMCContext *pViaXvMC;
- unsigned i;
-
- if((display == NULL) || (surface == NULL)) {
- return BadValue;
- }
- if(surface->privData == NULL) {
- return (error_base + XvMCBadSurface);
- }
-
- pViaSurface = (ViaXvMCSurface *)surface->privData;
- pViaXvMC = pViaSurface->privContext;
-
- if(pViaXvMC == NULL) {
- return (error_base + XvMCBadSurface);
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
-
- if (pViaSurface->needsSync) {
- CARD32 timeStamp = pViaSurface->timeStamp;
- int syncMode = pViaSurface->syncMode;
-
- if (pViaXvMC->useAGP) {
-
- syncMode = (pViaSurface->syncMode == LL_MODE_2D ||
- pViaSurface->timeStamp < pViaXvMC->timeStamp) ?
- LL_MODE_2D : LL_MODE_DECODER_IDLE;
- if (pViaSurface->syncMode != LL_MODE_2D)
- timeStamp = pViaXvMC->timeStamp;
-
- } else if (syncMode != LL_MODE_2D &&
- pViaXvMC->rendSurf[0] != (pViaSurface->srfNo | VIA_XVMC_VALID)) {
-
- pViaSurface->needsSync = 0;
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
- }
-
- if (syncXvMCLowLevel(pViaXvMC->xl, syncMode, 1,
- pViaSurface->timeStamp)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadValue;
- }
- pViaSurface->needsSync = 0;
- }
-
- if (pViaXvMC->rendSurf[0] == (pViaSurface->srfNo | VIA_XVMC_VALID)) {
- pViaSurface->needsSync = 0;
- for (i=0; i<VIA_MAX_RENDSURF; ++i) {
- pViaXvMC->rendSurf[i] = 0;
- }
- }
-
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-Status XvMCLoadQMatrix(Display *display, XvMCContext *context,
- const XvMCQMatrix *qmx)
-{
- ViaXvMCContext
- *pViaXvMC;
-
- if((display == NULL) || (context == NULL)) {
- return BadValue;
- }
- if(NULL == (pViaXvMC = context->privData)) {
- return (error_base + XvMCBadContext);
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- if (qmx->load_intra_quantiser_matrix) {
- memcpy(pViaXvMC->intra_quantiser_matrix,
- qmx->intra_quantiser_matrix,
- sizeof(qmx->intra_quantiser_matrix));
- pViaXvMC->intraLoaded = 0;
- }
-
- if (qmx->load_non_intra_quantiser_matrix) {
- memcpy(pViaXvMC->non_intra_quantiser_matrix,
- qmx->non_intra_quantiser_matrix,
- sizeof(qmx->non_intra_quantiser_matrix));
- pViaXvMC->nonIntraLoaded = 0;
- }
-
- if (qmx->load_chroma_intra_quantiser_matrix) {
- memcpy(pViaXvMC->chroma_intra_quantiser_matrix,
- qmx->chroma_intra_quantiser_matrix,
- sizeof(qmx->chroma_intra_quantiser_matrix));
- pViaXvMC->chromaIntraLoaded = 0;
- }
-
- if (qmx->load_chroma_non_intra_quantiser_matrix) {
- memcpy(pViaXvMC->chroma_non_intra_quantiser_matrix,
- qmx->chroma_non_intra_quantiser_matrix,
- sizeof(qmx->chroma_non_intra_quantiser_matrix));
- pViaXvMC->chromaNonIntraLoaded = 0;
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
-
- return Success;
-}
-
-/*
- * Below, we provide functions unusable for this implementation, but for
- * standard completeness.
- */
-
-
-Status XvMCRenderSurface
-(
- Display *display,
- XvMCContext *context,
- unsigned int picture_structure,
- XvMCSurface *target_surface,
- XvMCSurface *past_surface,
- XvMCSurface *future_surface,
- unsigned int flags,
- unsigned int num_macroblocks,
- unsigned int first_macroblock,
- XvMCMacroBlockArray *macroblock_array,
- XvMCBlockArray *blocks
- )
-{
- return (error_base + XvMCBadContext);
-}
-
-Status XvMCCreateBlocks
-(
- Display *display,
- XvMCContext *context,
- unsigned int num_blocks,
- XvMCBlockArray * block
- )
-{
- return (error_base + XvMCBadContext);
-}
-
-Status XvMCDestroyBlocks (Display *display, XvMCBlockArray * block)
-{
- return Success;
-}
-
-Status XvMCCreateMacroBlocks
-(
- Display *display,
- XvMCContext *context,
- unsigned int num_blocks,
- XvMCMacroBlockArray * blocks
- )
-{
- return (error_base + XvMCBadContext);
-}
-
-Status XvMCDestroyMacroBlocks(Display *display, XvMCMacroBlockArray * block)
-{
- return (error_base + XvMCBadContext);
-}
-
-Status XvMCCreateSubpicture( Display *display,
- XvMCContext *context,
- XvMCSubpicture *subpicture,
- unsigned short width,
- unsigned short height,
- int xvimage_id)
-{
- ViaXvMCContext *pViaXvMC;
- ViaXvMCSubPicture *pViaSubPic;
- int priv_count;
- unsigned *priv_data;
- Status ret;
-
- if((subpicture == NULL) || (context == NULL) || (display == NULL)){
- return BadValue;
- }
-
- pViaXvMC = (ViaXvMCContext *)context->privData;
- if(pViaXvMC == NULL) {
- return (error_base + XvMCBadContext);
- }
-
- subpicture->privData = (ViaXvMCSubPicture *)
- malloc(sizeof(ViaXvMCSubPicture));
- if(!subpicture->privData) {
- return BadAlloc;
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- subpicture->width = context->width;
- subpicture->height = context->height;
- subpicture->xvimage_id = xvimage_id;
- pViaSubPic = (ViaXvMCSubPicture *)subpicture->privData;
-
- XLockDisplay(display);
- if((ret = _xvmc_create_subpicture(display, context, subpicture,
- &priv_count, &priv_data))) {
- XUnlockDisplay(display);
- free(pViaSubPic);
- fprintf(stderr,"Unable to create XvMC Subpicture.\n");
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return ret;
- }
- XUnlockDisplay(display);
-
-
- subpicture->num_palette_entries = VIA_SUBPIC_PALETTE_SIZE;
- subpicture->entry_bytes = 3;
- strncpy(subpicture->component_order,"YUV",4);
- pViaSubPic->srfNo = priv_data[0];
- pViaSubPic->offset = priv_data[1];
- pViaSubPic->stride = (subpicture->width + 31) & ~31;
- pViaSubPic->privContext = pViaXvMC;
- pViaSubPic->ia44 = (xvimage_id == FOURCC_IA44);
- pViaSubPic->needsSync = 0;
-
- /* Free data returned from _xvmc_create_subpicture */
-
- XFree(priv_data);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-Status
-XvMCSetSubpicturePalette (Display *display, XvMCSubpicture *subpicture,
- unsigned char *palette)
-{
- ViaXvMCSubPicture *pViaSubPic;
- ViaXvMCContext *pViaXvMC;
- volatile ViaXvMCSAreaPriv *sAPriv;
- unsigned i;
- CARD32 tmp;
-
- if((subpicture == NULL) || (display == NULL)){
- return BadValue;
- }
- if(subpicture->privData == NULL) {
- return (error_base + XvMCBadSubpicture);
- }
- pViaSubPic = (ViaXvMCSubPicture *) subpicture->privData;
- for (i=0; i < VIA_SUBPIC_PALETTE_SIZE; ++i) {
- tmp = *palette++ << 8;
- tmp |= *palette++ << 16;
- tmp |= *palette++ << 24;
- tmp |= ((i & 0x0f) << 4) | 0x07;
- pViaSubPic->palette[i] = tmp;
- }
-
- pViaXvMC = pViaSubPic->privContext;
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- sAPriv = SAREAPTR( pViaXvMC );
- hwlLock(pViaXvMC->xl,1);
- setLowLevelLocking(pViaXvMC->xl,0);
-
- /*
- * If the subpicture is displaying, Immeadiately update it with the
- * new palette.
- */
-
- if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] ==
- (pViaSubPic->srfNo | VIA_XVMC_VALID)) {
- viaVideoSubPictureLocked(pViaXvMC->xl,pViaSubPic);
- }
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- setLowLevelLocking(pViaXvMC->xl,1);
- hwlUnlock(pViaXvMC->xl,1);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-
-static int findOverlap(unsigned width,unsigned height,
- short *dstX, short *dstY,
- short *srcX, short *srcY,
- unsigned short *areaW, unsigned short *areaH)
-{
- int
- w,h;
- unsigned
- mWidth,mHeight;
-
- w = *areaW;
- h = *areaH;
-
- if ((*dstX >= width) || (*dstY >= height))
- return 1;
- if (*dstX < 0) {
- w += *dstX;
- *srcX -= *dstX;
- *dstX = 0;
- }
- if (*dstY < 0) {
- h += *dstY;
- *srcY -= *dstY;
- *dstY = 0;
- }
- if ((w <= 0) || ((h <= 0)))
- return 1;
- mWidth = width - *dstX;
- mHeight = height - *dstY;
- *areaW = (w <= mWidth) ? w : mWidth;
- *areaH = (h <= mHeight) ? h : mHeight;
- return 0;
-}
-
-
-
-Status XvMCClearSubpicture (
- Display *display,
- XvMCSubpicture *subpicture,
- short x,
- short y,
- unsigned short width,
- unsigned short height,
- unsigned int color
- )
-{
-
- ViaXvMCContext *pViaXvMC;
- ViaXvMCSubPicture *pViaSubPic;
- short dummyX,dummyY;
- unsigned long bOffs;
-
- if((subpicture == NULL) || (display == NULL)) {
- return BadValue;
- }
- if(subpicture->privData == NULL) {
- return (error_base + XvMCBadSubpicture);
- }
- pViaSubPic = (ViaXvMCSubPicture *) subpicture->privData;
- pViaXvMC = pViaSubPic->privContext;
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
-
- /* Clip clearing area so that it fits inside subpicture. */
-
- if (findOverlap(subpicture->width, subpicture->height, &x, &y,
- &dummyX, &dummyY, &width, &height)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
- }
-
- bOffs = pViaSubPic->offset + y*pViaSubPic->stride + x;
- viaBlit(pViaXvMC->xl, 8, 0, pViaSubPic->stride, bOffs, pViaSubPic->stride,
- width, height, 1, 1, VIABLIT_FILL, color);
- pViaSubPic->needsSync = 1;
- pViaSubPic->timeStamp = viaDMATimeStampLowLevel(pViaXvMC->xl);
- if (flushXvMCLowLevel(pViaXvMC->xl)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadValue;
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-Status
-XvMCCompositeSubpicture (
- Display *display,
- XvMCSubpicture *subpicture,
- XvImage *image,
- short srcx,
- short srcy,
- unsigned short width,
- unsigned short height,
- short dstx,
- short dsty
- )
-{
-
- unsigned i;
- ViaXvMCContext *pViaXvMC;
- ViaXvMCSubPicture *pViaSubPic;
- CARD8 *dAddr, *sAddr;
-
- if((subpicture == NULL) || (display == NULL) || (image == NULL)){
- return BadValue;
- }
- if(NULL == (pViaSubPic = (ViaXvMCSubPicture *)subpicture->privData)) {
- return (error_base + XvMCBadSubpicture);
- }
-
- pViaXvMC = pViaSubPic->privContext;
-
-
- if (image->id != subpicture->xvimage_id)
- return BadMatch;
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
-
-
- /*
- * Clip copy area so that it fits inside subpicture and image.
- */
-
- if (findOverlap(subpicture->width, subpicture->height,
- &dstx, &dsty, &srcx, &srcy, &width, &height)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
- }
- if (findOverlap(image->width, image->height,
- &srcx, &srcy, &dstx, &dsty, &width, &height)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
- }
-
- if (pViaSubPic->needsSync) {
- if (syncXvMCLowLevel(pViaXvMC->xl, LL_MODE_2D, 0, pViaSubPic->timeStamp)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadValue;
- }
- pViaSubPic->needsSync = 0;
- }
-
- for(i=0; i<height; ++i) {
- dAddr = (((CARD8 *)pViaXvMC->fbAddress) +
- (pViaSubPic->offset + (dsty+i)*pViaSubPic->stride + dstx));
- sAddr = (((CARD8 *)image->data) +
- (image->offsets[0] + (srcy+i)*image->pitches[0] + srcx));
- memcpy(dAddr,sAddr,width);
- }
-
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-
-
-Status
-XvMCBlendSubpicture (
- Display *display,
- XvMCSurface *target_surface,
- XvMCSubpicture *subpicture,
- short subx,
- short suby,
- unsigned short subw,
- unsigned short subh,
- short surfx,
- short surfy,
- unsigned short surfw,
- unsigned short surfh
- )
-{
- ViaXvMCSurface *pViaSurface;
- ViaXvMCSubPicture *pViaSubPic;
-
- if((display == NULL) || target_surface == NULL){
- return BadValue;
- }
-
- if (subx || suby || surfx || surfy ||
- (subw != surfw) || (subh != surfh)) {
- fprintf(stderr,"ViaXvMC: Only completely overlapping subpicture "
- "supported.\n");
- return BadValue;
- }
-
- if(NULL == (pViaSurface = target_surface->privData)) {
- return (error_base + XvMCBadSurface);
- }
-
- if (subpicture) {
-
- if(NULL == (pViaSubPic = subpicture->privData)) {
- return (error_base + XvMCBadSubpicture);
- }
-
- pViaSurface->privSubPic = pViaSubPic;
- } else {
- pViaSurface->privSubPic = NULL;
- }
- return Success;
-}
-
-Status
-XvMCBlendSubpicture2 (
- Display *display,
- XvMCSurface *source_surface,
- XvMCSurface *target_surface,
- XvMCSubpicture *subpicture,
- short subx,
- short suby,
- unsigned short subw,
- unsigned short subh,
- short surfx,
- short surfy,
- unsigned short surfw,
- unsigned short surfh
- )
-{
- ViaXvMCSurface *pViaSurface,*pViaSSurface;
- ViaXvMCSubPicture *pViaSubPic;
- ViaXvMCContext *pViaXvMC;
-
- unsigned width,height;
-
- if((display == NULL) || target_surface == NULL || source_surface == NULL){
- return BadValue;
- }
-
- if (subx || suby || surfx || surfy ||
- (subw != surfw) || (subh != surfh)) {
- fprintf(stderr,"ViaXvMC: Only completely overlapping subpicture "
- "supported.\n");
- return BadMatch;
- }
-
- if(NULL == (pViaSurface = target_surface->privData)) {
- return (error_base + XvMCBadSurface);
- }
-
- if(NULL == (pViaSSurface = source_surface->privData)) {
- return (error_base + XvMCBadSurface);
- }
- pViaXvMC = pViaSurface->privContext;
- width = pViaSSurface->width;
- height = pViaSSurface->height;
- if (width != pViaSurface->width || height != pViaSSurface->height) {
- return BadMatch;
- }
-
- if (XvMCSyncSurface(display,source_surface)) {
- return BadValue;
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- viaBlit(pViaXvMC->xl, 8, yOffs(pViaSSurface), pViaSSurface->yStride,
- yOffs(pViaSurface), pViaSurface->yStride,
- width, height, 1, 1, VIABLIT_COPY, 0);
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- if (pViaXvMC->chipId != PCI_CHIP_VT3259) {
-
- /*
- * YV12 Chroma blit.
- */
-
- viaBlit(pViaXvMC->xl, 8, uOffs(pViaSSurface), pViaSSurface->yStride >> 1,
- uOffs(pViaSurface), pViaSurface->yStride >> 1,
- width >> 1, height >> 1, 1, 1, VIABLIT_COPY, 0);
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- viaBlit(pViaXvMC->xl, 8, vOffs(pViaSSurface), pViaSSurface->yStride >> 1,
- vOffs(pViaSurface), pViaSurface->yStride >> 1,
- width >> 1, height >> 1, 1, 1, VIABLIT_COPY, 0);
- } else {
-
- /*
- * NV12 Chroma blit.
- */
-
- viaBlit(pViaXvMC->xl, 8, vOffs(pViaSSurface), pViaSSurface->yStride,
- vOffs(pViaSurface), pViaSurface->yStride,
- width, height >> 1, 1, 1, VIABLIT_COPY, 0);
- }
- pViaSurface->needsSync = 1;
- pViaSurface->syncMode = LL_MODE_2D;
- pViaSurface->timeStamp = viaDMATimeStampLowLevel(pViaXvMC->xl);
- if (flushXvMCLowLevel(pViaXvMC->xl)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadValue;
- }
- if (subpicture) {
-
- if(NULL == (pViaSubPic = subpicture->privData)) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return (error_base + XvMCBadSubpicture);
- }
-
- pViaSurface->privSubPic = pViaSubPic;
- } else {
- pViaSurface->privSubPic = NULL;
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-
-Status
-XvMCSyncSubpicture (Display *display, XvMCSubpicture *subpicture)
-{
- ViaXvMCSubPicture *pViaSubPic;
- ViaXvMCContext *pViaXvMC;
- Status retVal=0;
-
- if((display == NULL) || subpicture == NULL){
- return BadValue;
- }
- if(NULL == (pViaSubPic = subpicture->privData)) {
- return (error_base + XvMCBadSubpicture);
- }
-
- pViaXvMC = pViaSubPic->privContext;
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- if (pViaSubPic->needsSync) {
- if (syncXvMCLowLevel(pViaXvMC->xl, LL_MODE_2D,
- 0, pViaSubPic->timeStamp)) {
- retVal = BadValue;
- }
- pViaSubPic->needsSync = 0;
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return retVal;
-}
-
-Status
-XvMCFlushSubpicture (Display *display, XvMCSubpicture *subpicture)
-{
- ViaXvMCSubPicture *pViaSubPic;
-
- if((display == NULL) || subpicture == NULL){
- return BadValue;
- }
- if(NULL == (pViaSubPic = subpicture->privData)) {
- return (error_base + XvMCBadSubpicture);
- }
-
- return Success;
-}
-
-Status
-XvMCDestroySubpicture (Display *display, XvMCSubpicture *subpicture)
-{
- ViaXvMCSubPicture *pViaSubPic;
- ViaXvMCContext *pViaXvMC;
- volatile ViaXvMCSAreaPriv *sAPriv;
-
- if((display == NULL) || subpicture == NULL){
- return BadValue;
- }
- if(NULL == (pViaSubPic = subpicture->privData)) {
- return (error_base + XvMCBadSubpicture);
- }
- pViaXvMC = pViaSubPic->privContext;
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
-
-
- sAPriv = SAREAPTR(pViaXvMC);
- hwlLock(pViaXvMC->xl,1);
- setLowLevelLocking(pViaXvMC->xl,0);
- if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] ==
- ( pViaSubPic->srfNo | VIA_XVMC_VALID )) {
- viaVideoSubPictureOffLocked(pViaXvMC->xl);
- sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] = 0;
- }
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- setLowLevelLocking(pViaXvMC->xl,1);
- hwlUnlock(pViaXvMC->xl,1);
-
- XLockDisplay(display);
- _xvmc_destroy_subpicture(display,subpicture);
- XUnlockDisplay(display);
-
- free(pViaSubPic);
- subpicture->privData = NULL;
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
-
- return Success;
-}
-
-Status
-XvMCGetSubpictureStatus (Display *display, XvMCSubpicture *subpic, int *stat)
-{
- ViaXvMCSubPicture *pViaSubPic;
- ViaXvMCContext *pViaXvMC;
- volatile ViaXvMCSAreaPriv *sAPriv;
-
-
- if((display == NULL) || subpic == NULL){
- return BadValue;
- }
- if(NULL == (pViaSubPic = subpic->privData)) {
- return (error_base + XvMCBadSubpicture);
- }
- if (stat) {
- *stat = 0;
- pViaXvMC = pViaSubPic->privContext;
- sAPriv = SAREAPTR( pViaXvMC );
- if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] ==
- (pViaSubPic->srfNo | VIA_XVMC_VALID))
- *stat |= XVMC_DISPLAYING;
- }
- return Success;
-}
-
-Status
-XvMCFlushSurface (Display *display, XvMCSurface *surface)
-{
- ViaXvMCSurface *pViaSurface;
- ViaXvMCContext *pViaXvMC;
- Status ret;
-
- if((display == NULL) || surface == NULL){
- return BadValue;
- }
- if(NULL == (pViaSurface = surface->privData)) {
- return (error_base + XvMCBadSurface);
- }
-
- pViaXvMC = pViaSurface->privContext;
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- if (pViaSurface->needsSync)
- pViaSurface->timeStamp = pViaXvMC->timeStamp =
- viaDMATimeStampLowLevel(pViaXvMC->xl);
- ret = (flushXvMCLowLevel(pViaXvMC->xl)) ? BadValue : Success;
- if (pViaXvMC->rendSurf[0] == (pViaSurface->srfNo | VIA_XVMC_VALID)) {
- hwlLock(pViaXvMC->xl,0);
- pViaXvMC->haveDecoder = 0;
- releaseDecoder(pViaXvMC, 0);
- hwlUnlock(pViaXvMC->xl,0);
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return ret;
-}
-
-Status
-XvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat)
-{
- ViaXvMCSurface *pViaSurface;
- ViaXvMCContext *pViaXvMC;
- volatile ViaXvMCSAreaPriv *sAPriv;
- unsigned i;
- int ret = 0;
-
- if((display == NULL) || surface == NULL){
- return BadValue;
- }
- if(NULL == (pViaSurface = surface->privData)) {
- return (error_base + XvMCBadSurface);
- }
- if (stat) {
- *stat = 0;
- pViaXvMC = pViaSurface->privContext;
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- sAPriv = SAREAPTR( pViaXvMC );
- if (sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort]
- == (pViaSurface->srfNo | VIA_XVMC_VALID))
- *stat |= XVMC_DISPLAYING;
- for (i=0; i<VIA_MAX_RENDSURF; ++i) {
- if(pViaXvMC->rendSurf[i] ==
- (pViaSurface->srfNo | VIA_XVMC_VALID)) {
- *stat |= XVMC_RENDERING;
- break;
- }
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- }
- return ret;
-}
-
-XvAttribute *
-XvMCQueryAttributes (
- Display *display,
- XvMCContext *context,
- int *number
- )
-{
- ViaXvMCContext *pViaXvMC;
- XvAttribute *ret;
- unsigned long siz;
-
- *number = 0;
- if ((display == NULL) || (context == NULL)) {
- return NULL;
- }
-
- if (NULL == (pViaXvMC = context->privData)) {
- return NULL;
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- if (NULL != (ret = (XvAttribute *)
- malloc(siz = VIA_NUM_XVMC_ATTRIBUTES*sizeof(XvAttribute)))) {
- memcpy(ret,pViaXvMC->attribDesc,siz);
- *number = VIA_NUM_XVMC_ATTRIBUTES;
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
-
- return ret;
-}
-
-Status
-XvMCSetAttribute (
- Display *display,
- XvMCContext *context,
- Atom attribute,
- int value
- )
-{
- int found;
- unsigned i;
- ViaXvMCContext *pViaXvMC;
- ViaXvMCCommandBuffer buf;
-
- if ((display == NULL) || (context == NULL)) {
- return (error_base + XvMCBadContext);
- }
-
- if (NULL == (pViaXvMC = context->privData)) {
- return (error_base + XvMCBadContext);
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
-
- found = 0;
- for (i=0; i < pViaXvMC->attrib.numAttr; ++i) {
- if (attribute == pViaXvMC->attrib.attributes[i].attribute) {
- if ((!(pViaXvMC->attribDesc[i].flags & XvSettable)) ||
- value < pViaXvMC->attribDesc[i].min_value ||
- value > pViaXvMC->attribDesc[i].max_value)
- return BadValue;
- pViaXvMC->attrib.attributes[i].value = value;
- found = 1;
- pViaXvMC->attribChanged = 1;
- break;
- }
- }
- if (!found) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return BadMatch;
- }
- if (pViaXvMC->haveXv) {
- buf.command = VIA_XVMC_COMMAND_ATTRIBUTES;
- pViaXvMC->xvImage->data = (char *)&buf;
- buf.ctxNo = pViaXvMC->ctxNo | VIA_XVMC_VALID;
- buf.attrib = pViaXvMC->attrib;
- XLockDisplay(display);
- pViaXvMC->attribChanged =
- XvPutImage(display,pViaXvMC->port,pViaXvMC->draw,
- pViaXvMC->gc,
- pViaXvMC->xvImage,0,0,1,1,0,0,1,1);
- XUnlockDisplay(display);
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
-
-
-Status
-XvMCGetAttribute (
- Display *display,
- XvMCContext *context,
- Atom attribute,
- int *value
- )
-{
- int found;
- unsigned i;
- ViaXvMCContext *pViaXvMC;
-
- if ((display == NULL) || (context == NULL)) {
- return (error_base + XvMCBadContext);
- }
-
- if (NULL == (pViaXvMC = context->privData)) {
- return (error_base + XvMCBadContext);
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- found = 0;
- for (i=0; i < pViaXvMC->attrib.numAttr; ++i) {
- if (attribute == pViaXvMC->attrib.attributes[i].attribute) {
- if (pViaXvMC->attribDesc[i].flags & XvGettable) {
- *value = pViaXvMC->attrib.attributes[i].value;
- found = 1;
- break;
- }
- }
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
-
- if (!found)
- return BadMatch;
- return Success;
-}
-
-
-Status XvMCHideSurface(Display *display,XvMCSurface *surface)
-{
-
- ViaXvMCSurface *pViaSurface;
- ViaXvMCContext *pViaXvMC;
- ViaXvMCSubPicture *pViaSubPic;
- volatile ViaXvMCSAreaPriv *sAPriv;
- ViaXvMCCommandBuffer buf;
- Status ret;
-
- if ((display == NULL) || (surface == NULL)) {
- return BadValue;
- }
- if (NULL == (pViaSurface = surface->privData )) {
- return (error_base + XvMCBadSurface);
- }
- if (NULL == (pViaXvMC = pViaSurface->privContext)) {
- return (error_base + XvMCBadContext);
- }
-
- ppthread_mutex_lock( &pViaXvMC->ctxMutex );
- if (!pViaXvMC->haveXv) {
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
- }
-
- sAPriv = SAREAPTR( pViaXvMC );
- hwlLock(pViaXvMC->xl,1);
-
- if (sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort] !=
- (pViaSurface->srfNo | VIA_XVMC_VALID)) {
- hwlUnlock(pViaXvMC->xl,1);
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
- }
- setLowLevelLocking(pViaXvMC->xl,0);
- if (NULL != (pViaSubPic = pViaSurface->privSubPic)) {
- if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] ==
- (pViaSubPic->srfNo | VIA_XVMC_VALID)) {
- sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] &= ~VIA_XVMC_VALID;
- viaVideoSubPictureOffLocked(pViaXvMC->xl);
- }
- }
- flushPCIXvMCLowLevel(pViaXvMC->xl);
- setLowLevelLocking(pViaXvMC->xl,1);
- hwlUnlock(pViaXvMC->xl,1);
-
- buf.command = VIA_XVMC_COMMAND_UNDISPLAY;
- buf.ctxNo = pViaXvMC->ctxNo | VIA_XVMC_VALID;
- buf.srfNo = pViaSurface->srfNo | VIA_XVMC_VALID;
- pViaXvMC->xvImage->data = (char *)&buf;
- if ((ret = XvPutImage(display,pViaXvMC->port,pViaXvMC->draw,
- pViaXvMC->gc,
- pViaXvMC->xvImage,0,0,1,1,0,0,1,1))) {
- fprintf(stderr,"XvMCPutSurface: Hiding overlay failed.\n");
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return ret;
- }
- ppthread_mutex_unlock( &pViaXvMC->ctxMutex );
- return Success;
-}
diff --git a/nx-X11/lib/XvMC/hw/via/viaXvMCPriv.h b/nx-X11/lib/XvMC/hw/via/viaXvMCPriv.h
deleted file mode 100644
index de4976a25..000000000
--- a/nx-X11/lib/XvMC/hw/via/viaXvMCPriv.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************************
- * VIA Unichrome XvMC extension client lib.
- *
- * Copyright (c) 2004 Thomas Hellström. 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 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
- * AUTHOR(S) OR COPYRIGHT HOLDER(S) 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.
- */
-
-#ifndef _VIAXVMCPRIV_H
-#define _VIAXVMCPRIV_H 1
-
-#include <X11/Xlibint.h>
-#include <X11/extensions/XvMC.h>
-#include <X11/extensions/XvMClib.h>
-#include <stdlib.h>
-#include <X11/Xutil.h>
-#include <X11/extensions/vldXvMC.h>
-#include "via_xvmc.h"
-
-typedef struct{
- int x;
- int y;
- int w;
- int h;
-} XvMCRegion;
-
-
-extern Status _xvmc_create_context(Display *dpy, XvMCContext *context,
- int *priv_count, uint **priv_data);
-extern Status _xvmc_destroy_context(Display *dpy, XvMCContext *context);
-extern Status _xvmc_create_surface(Display *dpy, XvMCContext *context,
- XvMCSurface *surface, int *priv_count,
- uint **priv_data);
-extern Status _xvmc_destroy_surface(Display *dpy, XvMCSurface *surface);
-extern Status _xvmc_create_subpicture(Display *dpy, XvMCContext *context,
- XvMCSubpicture *subpicture,
- int *priv_count, uint **priv_data);
-extern Status _xvmc_destroy_subpicture(Display *dpy,
- XvMCSubpicture *subpicture);
-
-#define VIA_SUBPIC_PALETTE_SIZE 16 /*Number of colors in subpicture palette*/
-#define VIA_CBUFFERSIZE 4096 /*Hardware command buffer size*/
-#define VIA_MAX_BUFS 2 /*Number of YUV buffers per surface*/
-#define VIA_MAX_RENDSURF 3 /*Maximum numbers of surfaces per context
- that can answer RENDERING to a rendering
- query*/
-
-typedef enum{
- context_drawHash,
- context_lowLevel,
- context_mutex,
- context_sAreaMap,
- context_fbMap,
- context_mmioMap,
- context_drmContext,
- context_fd,
- context_driConnection,
- context_context,
- context_none
-} ContextRes;
-
-
-typedef struct{
- unsigned ctxNo; /* XvMC private context reference number */
- pthread_mutex_t ctxMutex; /* Mutex for multi-threading. Not used */
- drm_context_t drmcontext; /* The drm context */
- drm_handle_t fbOffset; /* Handle to drm frame-buffer area */
- drm_handle_t mmioOffset; /* Handle to drm mmio area */
- drm_handle_t sAreaOffset; /* Handle to drm shared memory area */
- unsigned fbSize; /* Size of drm frame-buffer area */
- unsigned mmioSize; /* Size of drm mmio area */
- unsigned sAreaSize; /* Size of drm shared memory area */
- unsigned sAreaPrivOffset; /* Offset in sarea to private part */
- drmAddress fbAddress; /* Virtual address of frame buffer area */
- drmAddress mmioAddress; /* Virtual address of mmio area */
- drmAddress sAreaAddress; /* Virtual address of shared memory area */
- char busIdString[21]; /* Busid of video card */
- unsigned yStride; /* Y stride of surfaces in this context */
- int fd; /* FD for connection to drm module */
- unsigned char intra_quantiser_matrix[64];
- unsigned char non_intra_quantiser_matrix[64];
- unsigned char chroma_intra_quantiser_matrix[64];
- unsigned char chroma_non_intra_quantiser_matrix[64];
- unsigned rendSurf[VIA_MAX_RENDSURF]; /* Which surfaces answer rendering to
- a rendering query */
- int decoderOn; /* Decoder switched on ? */
- int intraLoaded; /* Intra quantiser matrix loaded in
- decoder? */
- int nonIntraLoaded; /* Non-Intra quantiser matrix loaded
- in decoder */
- int chromaIntraLoaded;
- int chromaNonIntraLoaded;
- int haveDecoder; /* Does this context own decoder? */
- int attribChanged; /* Attributes have changed and need to
- be uploaded to Xv at next frame
- display */
- drmLockPtr hwLock; /* Virtual address Pointer to the
- heavyweight drm hardware lock */
- unsigned xvMCPort; /* XvMC private port. Corresponds to
- an Xv port, but not by number */
- ViaXvMCAttrHolder attrib; /* This contexts attributes and their
- values */
- XvAttribute attribDesc[VIA_NUM_XVMC_ATTRIBUTES]; /* Attribute decriptions */
- int useAGP; /* Use the AGP ringbuffer to upload data to the chip */
- void *xl; /* Lowlevel context. Opaque to us. */
- int haveXv; /* Have I initialized the Xv
- connection for this surface? */
- XvImage *xvImage; /* Fake Xv Image used for command
- buffer transport to the X server */
- GC gc; /* X GC needed for displaying */
- Drawable draw; /* Drawable to undisplay from */
- XvPortID port; /* Xv Port ID when displaying */
- int lastSrfDisplaying;
- ContextRes resources;
- CARD32 timeStamp;
- CARD32 videoTimeStamp;
- XID id;
- unsigned screen;
- unsigned depth;
- unsigned stride;
- XVisualInfo visualInfo;
- void *drawHash;
- CARD32 chipId;
- XvMCRegion sRegion;
- XvMCRegion dRegion;
-}ViaXvMCContext;
-
-typedef struct{
- pthread_mutex_t subMutex; /* Currently not used. */
- unsigned srfNo; /* XvMC private surface number */
- unsigned offset; /* Offset into frame-buffer area */
- unsigned stride; /* Storage stride */
- unsigned width; /* Width */
- unsigned height; /* Height */
- CARD32 palette[VIA_SUBPIC_PALETTE_SIZE]; /* YUV Palette */
- ViaXvMCContext *privContext; /* Pointer to context private data */
- int ia44; /* IA44 or AI44 format */
- int needsSync;
- CARD32 timeStamp;
-}ViaXvMCSubPicture;
-
-
-typedef struct{
- pthread_mutex_t srfMutex; /* For multithreading. Not used. */
- pthread_cond_t bufferAvailable; /* For multithreading. Not used. */
- unsigned srfNo; /* XvMC private surface numbers */
- unsigned numBuffers; /* Number of picture buffers */
- unsigned curBuf; /* Which is the current buffer? */
- unsigned offsets[VIA_MAX_BUFS]; /* Offsets of picture buffers
- into the frame-buffer area */
- unsigned yStride; /* Stride of YUV420 Y component. */
- unsigned width; /* Dimensions */
- unsigned height;
- int progressiveSequence; /* Mpeg progressive picture? Hmm? */
- ViaXvMCContext *privContext; /* XvMC context private part. */
- ViaXvMCSubPicture *privSubPic; /* Subpicture to be blended when
- displaying. NULL if none. */
- int needsSync;
- int syncMode;
- CARD32 timeStamp;
- int topFieldFirst;
-}ViaXvMCSurface;
-
-/*
- * Take and release the global drm hardware lock.
- */
-
-#define HW_LOCK(ctx) \
- DRM_LOCK((ctx)->fd,(ctx)->hwLock,(ctx)->drmcontext,0)
-#define HW_UNLOCK(ctx) \
- DRM_UNLOCK((ctx)->fd,(ctx->hwLock),(ctx)->drmcontext)
-
-/*
- * Low-level Mpeg functions in viaLowLevel.c
- */
-
-#define VIABLIT_TRANSCOPY 0
-#define VIABLIT_COPY 1
-#define VIABLIT_FILL 2
-
-
-#endif
diff --git a/nx-X11/lib/XvMC/hw/via/xf86dri.c b/nx-X11/lib/XvMC/hw/via/xf86dri.c
deleted file mode 100644
index dd1d1e072..000000000
--- a/nx-X11/lib/XvMC/hw/via/xf86dri.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-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 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Jens Owen <jens@tungstengraphics.com>
- * Rickard E. (Rik) Faith <faith@valinux.com>
- *
- */
-
-/* THIS IS NOT AN X CONSORTIUM STANDARD */
-
-#define NEED_REPLIES
-#include <X11/Xlibint.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-/* #include "glheader.h" */
-#include "xf86dristr.h"
-
-static XExtensionInfo _xf86dri_info_data;
-static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
-static char xf86dri_extension_name[] = XF86DRINAME;
-
-#define uniDRICheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, xf86dri_extension_name, val)
-
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-
-static int close_display(Display *dpy, XExtCodes *extCodes);
-static /* const */ XExtensionHooks xf86dri_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info,
- xf86dri_extension_name,
- &xf86dri_extension_hooks,
- 0, NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
-
-
-/*****************************************************************************
- * *
- * public XFree86-DRI Extension routines *
- * *
- *****************************************************************************/
-
-#if 0
-#include <stdio.h>
-#define TRACE(msg) fprintf(stderr,"uniDRI%s\n", msg);
-#else
-#define TRACE(msg)
-#endif
-
-
- Bool uniDRIQueryExtension (dpy, event_basep, error_basep)
- Display *dpy;
- int *event_basep, *error_basep;
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- TRACE("QueryExtension...");
- if (XextHasExtension(info)) {
- *event_basep = info->codes->first_event;
- *error_basep = info->codes->first_error;
- TRACE("QueryExtension... return True");
- return True;
- } else {
- TRACE("QueryExtension... return False");
- return False;
- }
-}
-
- Bool uniDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
- Display* dpy;
- int* majorVersion;
- int* minorVersion;
- int* patchVersion;
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIQueryVersionReply rep;
- xXF86DRIQueryVersionReq *req;
-
- TRACE("QueryVersion...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIQueryVersion;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("QueryVersion... return False");
- return False;
- }
- *majorVersion = rep.majorVersion;
- *minorVersion = rep.minorVersion;
- *patchVersion = rep.patchVersion;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("QueryVersion... return True");
- return True;
-}
-
- Bool uniDRIQueryDirectRenderingCapable(dpy, screen, isCapable)
- Display* dpy;
- int screen;
- Bool* isCapable;
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIQueryDirectRenderingCapableReply rep;
- xXF86DRIQueryDirectRenderingCapableReq *req;
-
- TRACE("QueryDirectRenderingCapable...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIQueryDirectRenderingCapable, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
- req->screen = screen;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("QueryDirectRenderingCapable... return False");
- return False;
- }
- *isCapable = rep.isCapable;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("QueryDirectRenderingCapable... return True");
- return True;
-}
-
- Bool uniDRIOpenConnection(dpy, screen, hSAREA, busIdString)
- Display* dpy;
- int screen;
- drm_handle_t * hSAREA;
- char **busIdString;
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIOpenConnectionReply rep;
- xXF86DRIOpenConnectionReq *req;
-
- TRACE("OpenConnection...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIOpenConnection, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIOpenConnection;
- req->screen = screen;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("OpenConnection... return False");
- return False;
- }
-
- *hSAREA = rep.hSAREALow;
-#ifdef LONG64
- *hSAREA |= ((drm_handle_t)rep.hSAREAHigh) << 32;
-#endif
-
- if (rep.length) {
- if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
- _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("OpenConnection... return False");
- return False;
- }
- _XReadPad(dpy, *busIdString, rep.busIdStringLength);
- } else {
- *busIdString = NULL;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("OpenConnection... return True");
- return True;
-}
-
- Bool uniDRIAuthConnection(dpy, screen, magic)
- Display* dpy;
- int screen;
- drm_magic_t magic;
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIAuthConnectionReq *req;
- xXF86DRIAuthConnectionReply rep;
-
- TRACE("AuthConnection...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIAuthConnection, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIAuthConnection;
- req->screen = screen;
- req->magic = magic;
- rep.authenticated = 0;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("AuthConnection... return False");
- return False;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("AuthConnection... return True");
- return True;
-}
-
- Bool uniDRICloseConnection(dpy, screen)
- Display* dpy;
- int screen;
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRICloseConnectionReq *req;
-
- TRACE("CloseConnection...");
-
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRICloseConnection, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRICloseConnection;
- req->screen = screen;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CloseConnection... return True");
- return True;
-}
-
- Bool uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion,
- ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
- Display* dpy;
- int screen;
- int* ddxDriverMajorVersion;
- int* ddxDriverMinorVersion;
- int* ddxDriverPatchVersion;
- char** clientDriverName;
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIGetClientDriverNameReply rep;
- xXF86DRIGetClientDriverNameReq *req;
-
- TRACE("GetClientDriverName...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIGetClientDriverName, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIGetClientDriverName;
- req->screen = screen;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetClientDriverName... return False");
- return False;
- }
-
- *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
- *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
- *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
-
- if (rep.length) {
- if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
- _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetClientDriverName... return False");
- return False;
- }
- _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
- } else {
- *clientDriverName = NULL;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetClientDriverName... return True");
- return True;
-}
-
- Bool uniDRICreateContextWithConfig(dpy, screen, configID, context,
- hHWContext)
- Display* dpy;
- int screen;
- int configID;
- XID* context;
- drm_context_t * hHWContext;
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRICreateContextReply rep;
- xXF86DRICreateContextReq *req;
-
- TRACE("CreateContext...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRICreateContext, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRICreateContext;
- req->visual = configID;
- req->screen = screen;
- *context = XAllocID(dpy);
- req->context = *context;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CreateContext... return False");
- return False;
- }
- *hHWContext = rep.hHWContext;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CreateContext... return True");
- return True;
-}
-
- Bool uniDRICreateContext(dpy, screen, visual, context, hHWContext)
- Display* dpy;
- int screen;
- Visual* visual;
- XID* context;
- drm_context_t * hHWContext;
-{
- return uniDRICreateContextWithConfig( dpy, screen, visual->visualid,
- context, hHWContext );
-}
-
- Bool uniDRIDestroyContext( Display * ndpy, int screen,
- XID context )
-{
- Display * const dpy = (Display *) ndpy;
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIDestroyContextReq *req;
-
- TRACE("DestroyContext...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIDestroyContext, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIDestroyContext;
- req->screen = screen;
- req->context = context;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("DestroyContext... return True");
- return True;
-}
-
-Bool uniDRICreateDrawable( Display * ndpy, int screen,
- Drawable drawable, drm_drawable_t * hHWDrawable )
-{
- Display * const dpy = (Display *) ndpy;
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRICreateDrawableReply rep;
- xXF86DRICreateDrawableReq *req;
-
- TRACE("CreateDrawable...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRICreateDrawable, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRICreateDrawable;
- req->screen = screen;
- req->drawable = drawable;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CreateDrawable... return False");
- return False;
- }
- *hHWDrawable = rep.hHWDrawable;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CreateDrawable... return True");
- return True;
-}
-
-Bool uniDRIDestroyDrawable( Display * ndpy, int screen,
- Drawable drawable )
-{
- Display * const dpy = (Display *) ndpy;
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIDestroyDrawableReq *req;
-
- TRACE("DestroyDrawable...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIDestroyDrawable, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIDestroyDrawable;
- req->screen = screen;
- req->drawable = drawable;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("DestroyDrawable... return True");
- return True;
-}
-
- Bool uniDRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
- unsigned int* index, unsigned int* stamp,
- int* X, int* Y, int* W, int* H,
- int* numClipRects, drm_clip_rect_t ** pClipRects,
- int* backX, int* backY,
- int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIGetDrawableInfoReply rep;
- xXF86DRIGetDrawableInfoReq *req;
- int total_rects;
-
- TRACE("GetDrawableInfo...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIGetDrawableInfo, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIGetDrawableInfo;
- req->screen = screen;
- req->drawable = drawable;
-
- if (!_XReply(dpy, (xReply *)&rep, 1, xFalse))
- {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDrawableInfo... return False");
- return False;
- }
- *index = rep.drawableTableIndex;
- *stamp = rep.drawableTableStamp;
- *X = (int)rep.drawableX;
- *Y = (int)rep.drawableY;
- *W = (int)rep.drawableWidth;
- *H = (int)rep.drawableHeight;
- *numClipRects = rep.numClipRects;
- total_rects = *numClipRects;
-
- *backX = rep.backX;
- *backY = rep.backY;
- *numBackClipRects = rep.numBackClipRects;
- total_rects += *numBackClipRects;
-
-#if 0
- /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
- * backwards compatibility (Because of the >> 2 shift) but the fix
- * enables multi-threaded apps to work.
- */
- if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) -
- SIZEOF(xGenericReply) +
- total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
- _XEatData(dpy, rep.length);
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDrawableInfo... return False");
- return False;
- }
-#endif
-
- if (*numClipRects) {
- int len = sizeof(drm_clip_rect_t) * (*numClipRects);
-
- *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
- if (*pClipRects)
- _XRead(dpy, (char*)*pClipRects, len);
- } else {
- *pClipRects = NULL;
- }
-
- if (*numBackClipRects) {
- int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
-
- *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
- if (*pBackClipRects)
- _XRead(dpy, (char*)*pBackClipRects, len);
- } else {
- *pBackClipRects = NULL;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDrawableInfo... return True");
- return True;
-}
-
- Bool uniDRIGetDeviceInfo(dpy, screen, hFrameBuffer,
- fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate)
- Display* dpy;
- int screen;
- drm_handle_t * hFrameBuffer;
- int* fbOrigin;
- int* fbSize;
- int* fbStride;
- int* devPrivateSize;
- void** pDevPrivate;
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIGetDeviceInfoReply rep;
- xXF86DRIGetDeviceInfoReq *req;
-
- TRACE("GetDeviceInfo...");
- uniDRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIGetDeviceInfo, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIGetDeviceInfo;
- req->screen = screen;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDeviceInfo... return False");
- return False;
- }
-
- *hFrameBuffer = rep.hFrameBufferLow;
-#ifdef LONG64
- *hFrameBuffer |= ((drm_handle_t)rep.hFrameBufferHigh) << 32;
-#endif
-
- *fbOrigin = rep.framebufferOrigin;
- *fbSize = rep.framebufferSize;
- *fbStride = rep.framebufferStride;
- *devPrivateSize = rep.devPrivateSize;
-
- if (rep.length) {
- if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
- _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDeviceInfo... return False");
- return False;
- }
- _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
- } else {
- *pDevPrivate = NULL;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDeviceInfo... return True");
- return True;
-}
-
diff --git a/nx-X11/lib/XvMC/hw/via/xf86dri.h b/nx-X11/lib/XvMC/hw/via/xf86dri.h
deleted file mode 100644
index f82b573fe..000000000
--- a/nx-X11/lib/XvMC/hw/via/xf86dri.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.8 2002/10/30 12:51:25 alanh Exp $ */
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-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 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.
-
-**************************************************************************/
-
-/**
- * \file xf86dri.h
- * Protocol numbers and function prototypes for DRI X protocol.
- *
- * \author Kevin E. Martin <martin@valinux.com>
- * \author Jens Owen <jens@tungstengraphics.com>
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- */
-
-#ifndef _XF86DRI_H_
-#define _XF86DRI_H_
-
-#include <X11/Xfuncproto.h>
-#include <xf86drm.h>
-
-#define X_XF86DRIQueryVersion 0
-#define X_XF86DRIQueryDirectRenderingCapable 1
-#define X_XF86DRIOpenConnection 2
-#define X_XF86DRICloseConnection 3
-#define X_XF86DRIGetClientDriverName 4
-#define X_XF86DRICreateContext 5
-#define X_XF86DRIDestroyContext 6
-#define X_XF86DRICreateDrawable 7
-#define X_XF86DRIDestroyDrawable 8
-#define X_XF86DRIGetDrawableInfo 9
-#define X_XF86DRIGetDeviceInfo 10
-#define X_XF86DRIAuthConnection 11
-#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
-#define X_XF86DRICloseFullScreen 13 /* Deprecated */
-
-#define XF86DRINumberEvents 0
-
-#define XF86DRIClientNotLocal 0
-#define XF86DRIOperationNotSupported 1
-#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
-
-#ifndef _XF86DRI_SERVER_
-
-
-_XFUNCPROTOBEGIN
-
-Bool uniDRIQueryExtension( Display *dpy, int *event_base, int *error_base );
-
-Bool uniDRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
- int *patchVersion );
-
-Bool uniDRIQueryDirectRenderingCapable( Display *dpy, int screen,
- Bool *isCapable );
-
-Bool uniDRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
- char **busIDString );
-
-Bool uniDRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
-
-Bool uniDRICloseConnection( Display *dpy, int screen );
-
-Bool uniDRIGetClientDriverName( Display *dpy, int screen,
- int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
- int *ddxDriverPatchVersion, char **clientDriverName );
-
-Bool uniDRICreateContext( Display *dpy, int screen, Visual *visual,
- XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
-
-Bool uniDRICreateContextWithConfig( Display *dpy, int screen, int configID,
- XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
-
-extern Bool uniDRIDestroyContext( Display *dpy, int screen,
- XID context_id );
-
-extern Bool uniDRICreateDrawable( Display *dpy, int screen,
- Drawable drawable, drm_drawable_t *hHWDrawable );
-
-extern Bool uniDRIDestroyDrawable( Display *dpy, int screen,
- Drawable drawable);
-
-Bool uniDRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
- unsigned int *index, unsigned int *stamp,
- int *X, int *Y, int *W, int *H,
- int *numClipRects, drm_clip_rect_t ** pClipRects,
- int *backX, int *backY,
- int *numBackClipRects, drm_clip_rect_t **pBackClipRects );
-
-Bool uniDRIGetDeviceInfo( Display *dpy, int screen,
- drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize,
- int *fbStride, int *devPrivateSize, void **pDevPrivate );
-
-_XFUNCPROTOEND
-
-#endif /* _XF86DRI_SERVER_ */
-
-#endif /* _XF86DRI_H_ */
-
diff --git a/nx-X11/lib/XvMC/hw/via/xf86dristr.h b/nx-X11/lib/XvMC/hw/via/xf86dristr.h
deleted file mode 100644
index ac05b183b..000000000
--- a/nx-X11/lib/XvMC/hw/via/xf86dristr.h
+++ /dev/null
@@ -1,343 +0,0 @@
-/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.10 2002/10/30 12:51:25 alanh Exp $ */
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-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 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Jens Owen <jens@tungstengraphics.com>
- * Rickard E. (Rik) Fiath <faith@valinux.com>
- *
- */
-
-#ifndef _XF86DRISTR_H_
-#define _XF86DRISTR_H_
-
-#include "xf86dri.h"
-
-#define XF86DRINAME "XFree86-DRI"
-
-/* The DRI version number. This was originally set to be the same of the
- * XFree86 version number. However, this version is really indepedent of
- * the XFree86 version.
- *
- * Version History:
- * 4.0.0: Original
- * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02
- * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02
- */
-#define XF86DRI_MAJOR_VERSION 4
-#define XF86DRI_MINOR_VERSION 1
-#define XF86DRI_PATCH_VERSION 0
-
-typedef struct _XF86DRIQueryVersion {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIQueryVersion */
- CARD16 length B16;
-} xXF86DRIQueryVersionReq;
-#define sz_xXF86DRIQueryVersionReq 4
-
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD16 majorVersion B16; /* major version of DRI protocol */
- CARD16 minorVersion B16; /* minor version of DRI protocol */
- CARD32 patchVersion B32; /* patch version of DRI protocol */
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
-} xXF86DRIQueryVersionReply;
-#define sz_xXF86DRIQueryVersionReply 32
-
-typedef struct _XF86DRIQueryDirectRenderingCapable {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
- CARD16 length B16;
- CARD32 screen B32;
-} xXF86DRIQueryDirectRenderingCapableReq;
-#define sz_xXF86DRIQueryDirectRenderingCapableReq 8
-
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- BOOL isCapable;
- BOOL pad2;
- BOOL pad3;
- BOOL pad4;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
- CARD32 pad8 B32;
- CARD32 pad9 B32;
-} xXF86DRIQueryDirectRenderingCapableReply;
-#define sz_xXF86DRIQueryDirectRenderingCapableReply 32
-
-typedef struct _XF86DRIOpenConnection {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIOpenConnection */
- CARD16 length B16;
- CARD32 screen B32;
-} xXF86DRIOpenConnectionReq;
-#define sz_xXF86DRIOpenConnectionReq 8
-
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 hSAREALow B32;
- CARD32 hSAREAHigh B32;
- CARD32 busIdStringLength B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
- CARD32 pad8 B32;
-} xXF86DRIOpenConnectionReply;
-#define sz_xXF86DRIOpenConnectionReply 32
-
-typedef struct _XF86DRIAuthConnection {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICloseConnection */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 magic B32;
-} xXF86DRIAuthConnectionReq;
-#define sz_xXF86DRIAuthConnectionReq 12
-
-typedef struct {
- BYTE type;
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 authenticated B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
-} xXF86DRIAuthConnectionReply;
-#define zx_xXF86DRIAuthConnectionReply 32
-
-typedef struct _XF86DRICloseConnection {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICloseConnection */
- CARD16 length B16;
- CARD32 screen B32;
-} xXF86DRICloseConnectionReq;
-#define sz_xXF86DRICloseConnectionReq 8
-
-typedef struct _XF86DRIGetClientDriverName {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIGetClientDriverName */
- CARD16 length B16;
- CARD32 screen B32;
-} xXF86DRIGetClientDriverNameReq;
-#define sz_xXF86DRIGetClientDriverNameReq 8
-
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 ddxDriverMajorVersion B32;
- CARD32 ddxDriverMinorVersion B32;
- CARD32 ddxDriverPatchVersion B32;
- CARD32 clientDriverNameLength B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
-} xXF86DRIGetClientDriverNameReply;
-#define sz_xXF86DRIGetClientDriverNameReply 32
-
-typedef struct _XF86DRICreateContext {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICreateContext */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 visual B32;
- CARD32 context B32;
-} xXF86DRICreateContextReq;
-#define sz_xXF86DRICreateContextReq 16
-
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 hHWContext B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
-} xXF86DRICreateContextReply;
-#define sz_xXF86DRICreateContextReply 32
-
-typedef struct _XF86DRIDestroyContext {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIDestroyContext */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 context B32;
-} xXF86DRIDestroyContextReq;
-#define sz_xXF86DRIDestroyContextReq 12
-
-typedef struct _XF86DRICreateDrawable {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICreateDrawable */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
-} xXF86DRICreateDrawableReq;
-#define sz_xXF86DRICreateDrawableReq 12
-
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 hHWDrawable B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
-} xXF86DRICreateDrawableReply;
-#define sz_xXF86DRICreateDrawableReply 32
-
-typedef struct _XF86DRIDestroyDrawable {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIDestroyDrawable */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
-} xXF86DRIDestroyDrawableReq;
-#define sz_xXF86DRIDestroyDrawableReq 12
-
-typedef struct _XF86DRIGetDrawableInfo {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIGetDrawableInfo */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
-} xXF86DRIGetDrawableInfoReq;
-#define sz_xXF86DRIGetDrawableInfoReq 12
-
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 drawableTableIndex B32;
- CARD32 drawableTableStamp B32;
- INT16 drawableX B16;
- INT16 drawableY B16;
- INT16 drawableWidth B16;
- INT16 drawableHeight B16;
- CARD32 numClipRects B32;
- INT16 backX B16;
- INT16 backY B16;
- CARD32 numBackClipRects B32;
-} xXF86DRIGetDrawableInfoReply;
-
-#define sz_xXF86DRIGetDrawableInfoReply 36
-
-
-typedef struct _XF86DRIGetDeviceInfo {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIGetDeviceInfo */
- CARD16 length B16;
- CARD32 screen B32;
-} xXF86DRIGetDeviceInfoReq;
-#define sz_xXF86DRIGetDeviceInfoReq 8
-
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 hFrameBufferLow B32;
- CARD32 hFrameBufferHigh B32;
- CARD32 framebufferOrigin B32;
- CARD32 framebufferSize B32;
- CARD32 framebufferStride B32;
- CARD32 devPrivateSize B32;
-} xXF86DRIGetDeviceInfoReply;
-#define sz_xXF86DRIGetDeviceInfoReply 32
-
-typedef struct _XF86DRIOpenFullScreen {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIOpenFullScreen */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
-} xXF86DRIOpenFullScreenReq;
-#define sz_xXF86DRIOpenFullScreenReq 12
-
-typedef struct {
- BYTE type;
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 isFullScreen B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
-} xXF86DRIOpenFullScreenReply;
-#define sz_xXF86DRIOpenFullScreenReply 32
-
-typedef struct _XF86DRICloseFullScreen {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICloseFullScreen */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
-} xXF86DRICloseFullScreenReq;
-#define sz_xXF86DRICloseFullScreenReq 12
-
-typedef struct {
- BYTE type;
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
-} xXF86DRICloseFullScreenReply;
-#define sz_xXF86DRICloseFullScreenReply 32
-
-
-#endif /* _XF86DRISTR_H_ */