diff options
author | Thomas Hellstrom <unichrome@shipmail.org> | 2006-01-13 14:10:18 +0000 |
---|---|---|
committer | Thomas Hellstrom <unichrome@shipmail.org> | 2006-01-13 14:10:18 +0000 |
commit | 0f5c2df6f518225a05da96e22499628c6fbdcc69 (patch) | |
tree | e7ce12da994d7640efd9ba8fcd3f01720c34b57d | |
parent | 7fe7f02e8b3edc5fbf962f99a3f567342fde24e1 (diff) |
Sync XvMC libs with Openchrome revision 140. (Minor changes) Run indent on
xvmc libs and restructure the directory layout.
-rw-r--r-- | ChangeLog | 69 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/xvmc/Makefile.am | 47 | ||||
-rw-r--r-- | src/xvmc/driDrawable.c | 240 | ||||
-rw-r--r-- | src/xvmc/driDrawable.h | 14 | ||||
-rw-r--r-- | src/xvmc/unichrome/.cvsignore | 6 | ||||
-rw-r--r-- | src/xvmc/unichrome/Makefile.am | 11 | ||||
-rw-r--r-- | src/xvmc/unichromeProA/.cvsignore | 6 | ||||
-rw-r--r-- | src/xvmc/unichromeProA/Makefile.am | 11 | ||||
-rw-r--r-- | src/xvmc/viaLowLevel.c (renamed from src/xvmc/unichrome/viaLowLevel.c) | 672 | ||||
-rw-r--r-- | src/xvmc/viaLowLevel.h | 59 | ||||
-rw-r--r-- | src/xvmc/viaLowLevelPro.c (renamed from src/xvmc/unichromeProA/viaLowLevelPro.c) | 1020 | ||||
-rw-r--r-- | src/xvmc/viaXvMC.c | 1273 | ||||
-rw-r--r-- | src/xvmc/viaXvMCPriv.h | 227 | ||||
-rw-r--r-- | src/xvmc/xf86dri.c | 351 | ||||
-rw-r--r-- | src/xvmc/xf86dri.h | 71 | ||||
-rw-r--r-- | src/xvmc/xf86dristr.h | 465 |
17 files changed, 2385 insertions, 2161 deletions
@@ -1,3 +1,72 @@ +2006-01-13 Thomas Hellstrom <unichrome-at-shipmail-dot-org> + + * configure.ac: + * src/xvmc/Makefile.am: + * src/xvmc/driDrawable.c: (drawStamp), (getDRIDrawableInfoLocked), + (driDestroyHashContents): + * src/xvmc/driDrawable.h: + * src/xvmc/unichrome/.cvsignore: + * src/xvmc/unichrome/Makefile.am: + * src/xvmc/unichrome/viaLowLevel.c: + * src/xvmc/unichromeProA/.cvsignore: + * src/xvmc/unichromeProA/Makefile.am: + * src/xvmc/unichromeProA/viaLowLevelPro.c: + * src/xvmc/viaLowLevel.c: (hwlLock), (hwlUnlock), (timeDiff), + (setAGPSyncLowLevel), (viaDMATimeStampLowLevel), + (viaDMAWaitTimeStamp), (viaDMAInitTimeStamp), + (viaDMACleanupTimeStamp), (viaMpegGetStatus), (viaMpegIsBusy), + (syncDMA), (syncVideo), (syncAccel), (syncMpeg), (pciFlush), + (agpFlush), (flushXvMCLowLevel), (flushPCIXvMCLowLevel), + (pciCommand), (viaMpegSetSurfaceStride), (viaVideoSetSWFLipLocked), + (viaVideoSWFlipLocked), (viaMpegSetFB), (viaMpegBeginPicture), + (viaMpegReset), (viaMpegWriteSlice), (viaVideoSubPictureOffLocked), + (viaVideoSubPictureLocked), (viaBlit), (syncXvMCLowLevel), + (initXvMCLowLevel), (setLowLevelLocking), (closeXvMCLowLevel): + * src/xvmc/viaLowLevel.h: + * src/xvmc/viaLowLevelPro.c: (initHQVShadow), + (setHQVHWDeinterlacing), (setHQVDeblocking), (setHQVStartAddress), + (setHQVColorSpaceConversion), (setHQVFetchLine), (setHQVScale), + (setHQVSingleDestination), (setHQVDeinterlacing), + (setHQVTripleBuffer), (finish_header_agp), (hwlLock), (hwlUnlock), + (timeDiff), (setAGPSyncLowLevel), (viaDMATimeStampLowLevel), + (viaDMAWaitTimeStamp), (viaDMAInitTimeStamp), + (viaDMACleanupTimeStamp), (viaMpegGetStatus), (viaMpegIsBusy), + (syncDMA), (syncVideo), (syncAccel), (syncMpeg), (pciFlush), + (agpFlush), (uploadHQVDeinterlace), (uploadHQVShadow), + (flushXvMCLowLevel), (flushPCIXvMCLowLevel), + (viaMpegSetSurfaceStride), (viaVideoSetSWFLipLocked), + (viaVideoSWFlipLocked), (viaMpegSetFB), (viaMpegBeginPicture), + (viaMpegReset), (viaMpegWriteSlice), (viaVideoSubPictureOffLocked), + (viaVideoSubPictureLocked), (viaBlit), (syncXvMCLowLevel), + (updateLowLevelBuf), (cleanupLowLevelBuf), (releaseXvMCLowLevel), + (initXvMCLowLevel), (setLowLevelLocking), (closeXvMCLowLevel), + (computeDownScaling), (computeHQVScaleAndFilter), + (setupBackBuffer): + * src/xvmc/viaXvMC.c: (yOffs), (vOffs), (uOffs), + (defaultQMatrices), (releaseDecoder), (grabDecoder), + (setupAttribDesc), (releaseAttribDesc), (releaseContextResources), + (XvMCCreateContext), (XvMCDestroyContext), (XvMCCreateSurface), + (XvMCDestroySurface), (XvMCPutSlice2), (XvMCPutSlice), + (updateXVOverlay), (XvMCPutSurface), (XvMCBeginSurface), + (XvMCSyncSurface), (XvMCLoadQMatrix), (XvMCRenderSurface), + (XvMCCreateBlocks), (XvMCDestroyBlocks), (XvMCCreateMacroBlocks), + (XvMCDestroyMacroBlocks), (XvMCCreateSubpicture), + (XvMCSetSubpicturePalette), (findOverlap), (XvMCClearSubpicture), + (XvMCCompositeSubpicture), (XvMCBlendSubpicture), + (XvMCBlendSubpicture2), (XvMCSyncSubpicture), + (XvMCFlushSubpicture), (XvMCDestroySubpicture), + (XvMCGetSubpictureStatus), (XvMCFlushSurface), + (XvMCGetSurfaceStatus), (XvMCQueryAttributes), (XvMCSetAttribute), + (XvMCGetAttribute), (XvMCHideSurface): + * src/xvmc/viaXvMCPriv.h: + * src/xvmc/xf86dri.c: (uniDRIDestroyContext), + (uniDRICreateDrawable), (uniDRIDestroyDrawable), + (uniDRIGetDrawableInfo): + * src/xvmc/xf86dri.h: + * src/xvmc/xf86dristr.h: + Sync XvMC libs with Openchrome revision 140. (Minor changes) + Run indent on xvmc libs and restructure the directory layout. + 2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org> * configure.ac: diff --git a/configure.ac b/configure.ac index 3bf6f5d..a685013 100644 --- a/configure.ac +++ b/configure.ac @@ -111,6 +111,8 @@ AC_SUBST([moduledir]) DRIVER_NAME=via AC_SUBST([DRIVER_NAME]) +AC_DEFINE(VIA_HAVE_EXA, 1, [Build support for Exa]) + XORG_MANPAGE_SECTIONS XORG_RELEASE_VERSION @@ -118,7 +120,5 @@ AC_OUTPUT([ Makefile src/Makefile src/xvmc/Makefile - src/xvmc/unichrome/Makefile - src/xvmc/unichromeProA/Makefile man/Makefile ]) diff --git a/src/xvmc/Makefile.am b/src/xvmc/Makefile.am index d093d0a..dec32db 100644 --- a/src/xvmc/Makefile.am +++ b/src/xvmc/Makefile.am @@ -1,11 +1,40 @@ if XVMC -SUBDIRS = unichrome unichromeProA -endif +lib_LTLIBRARIES=libviaXvMC.la libviaXvMCPro.la -EXTRA_DIST = driDrawable.c \ - driDrawable.h \ - xf86dri.c \ - xf86dri.h \ - xf86dristr.h \ - viaXvMCPriv.h \ - viaLowLevel.h +libviaXvMC_la_SOURCES = \ + driDrawable.c \ + driDrawable.h \ + viaLowLevel.c \ + viaLowLevel.h \ + viaXvMC.c \ + viaXvMCPriv.h \ + xf86dri.c \ + xf86dri.h \ + xf86dristr.h + +libviaXvMCPro_la_SOURCES = \ + driDrawable.c \ + driDrawable.h \ + viaLowLevelPro.c \ + viaLowLevel.h \ + viaXvMC.c \ + viaXvMCPriv.h \ + xf86dri.c \ + xf86dri.h \ + xf86dristr.h + +AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(top_srcdir)/src -DTRUE=1 -DFALSE=0 +libviaXvMC_la_LDFLAGS = @DRI_LIBS@ -version-number 1:0:0 +else +libviaXvMCPro_la_SOURCES = \ + driDrawable.c \ + driDrawable.h \ + viaLowLevelPro.c \ + viaLowLevel.c \ + viaLowLevel.h \ + viaXvMC.c \ + viaXvMCPriv.h \ + xf86dri.c \ + xf86dri.h \ + xf86dristr.h +endif
\ No newline at end of file diff --git a/src/xvmc/driDrawable.c b/src/xvmc/driDrawable.c index 35934d8..8386334 100644 --- a/src/xvmc/driDrawable.c +++ b/src/xvmc/driDrawable.c @@ -22,9 +22,6 @@ * DEALINGS IN THE SOFTWARE. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif #include <X11/Xlibint.h> #include <X11/Xutil.h> @@ -34,143 +31,144 @@ #include "drm_sarea.h" #include "driDrawable.h" - static unsigned -drawStamp(volatile drm_sarea_t *pSarea, int index) +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) +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; + 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 +void driDestroyHashContents(void *drawHash) { unsigned long key; void *content; drawableInfo *drawInfo; - - if (drmHashFirst(drawHash, &key, &content) < 1) + if (drmHashFirst(drawHash, &key, &content) < 1) return; drawInfo = (drawableInfo *) content; - if (drawInfo->clipBack) XFree(drawInfo->clipBack); - if (drawInfo->clipFront) XFree(drawInfo->clipFront); + if (drawInfo->clipBack) + XFree(drawInfo->clipBack); + if (drawInfo->clipFront) + XFree(drawInfo->clipFront); free(drawInfo); - while(drmHashNext(drawHash, &key, &content) == 1) { + while (drmHashNext(drawHash, &key, &content) == 1) { drawInfo = (drawableInfo *) content; - if (drawInfo->clipBack) XFree(drawInfo->clipBack); - if (drawInfo->clipFront) XFree(drawInfo->clipFront); + if (drawInfo->clipBack) + XFree(drawInfo->clipBack); + if (drawInfo->clipFront) + XFree(drawInfo->clipFront); free(drawInfo); } - - return ; + + return; } - - diff --git a/src/xvmc/driDrawable.h b/src/xvmc/driDrawable.h index e565105..a758c7c 100644 --- a/src/xvmc/driDrawable.h +++ b/src/xvmc/driDrawable.h @@ -25,7 +25,8 @@ #ifndef _DRIDRAWABLE_H #define _DRIDRAWABLE_H -typedef struct _drawableInfo { +typedef struct _drawableInfo +{ drm_drawable_t drmDraw; unsigned stamp; unsigned index; @@ -49,16 +50,15 @@ typedef struct _drawableInfo { */ 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); +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); +extern void driDestroyHashContents(void *drawHash); #endif diff --git a/src/xvmc/unichrome/.cvsignore b/src/xvmc/unichrome/.cvsignore deleted file mode 100644 index 9730646..0000000 --- a/src/xvmc/unichrome/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.la -*.lo diff --git a/src/xvmc/unichrome/Makefile.am b/src/xvmc/unichrome/Makefile.am deleted file mode 100644 index 6f77cf3..0000000 --- a/src/xvmc/unichrome/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ - -lib_LTLIBRARIES=libviaXvMC.la - -libviaXvMC_la_SOURCES = \ - viaLowLevel.c \ - ../driDrawable.c \ - ../viaXvMC.c \ - ../xf86dri.c - -libviaXvMC_la_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(top_srcdir)/src -I$(top_srcdir)/src/xvmc -DTRUE=1 -DFALSE=0 -libviaXvMC_la_LDFLAGS = @DRI_LIBS@ -version-number 1:0:0 diff --git a/src/xvmc/unichromeProA/.cvsignore b/src/xvmc/unichromeProA/.cvsignore deleted file mode 100644 index 9730646..0000000 --- a/src/xvmc/unichromeProA/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.la -*.lo diff --git a/src/xvmc/unichromeProA/Makefile.am b/src/xvmc/unichromeProA/Makefile.am deleted file mode 100644 index 60eeb00..0000000 --- a/src/xvmc/unichromeProA/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ - -lib_LTLIBRARIES=libviaXvMCPro.la - -libviaXvMCPro_la_SOURCES = \ - viaLowLevelPro.c \ - ../driDrawable.c \ - ../viaXvMC.c \ - ../xf86dri.c - -libviaXvMCPro_la_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -I$(top_srcdir)/src -I$(top_srcdir)/src/xvmc -DTRUE=1 -DFALSE=0 -libviaXvMCPro_la_LDFLAGS = @DRI_LIBS@ -version-number 1:0:0 diff --git a/src/xvmc/unichrome/viaLowLevel.c b/src/xvmc/viaLowLevel.c index 1add1ca..b9d180c 100644 --- a/src/xvmc/unichrome/viaLowLevel.c +++ b/src/xvmc/viaLowLevel.c @@ -23,7 +23,6 @@ * 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 @@ -32,21 +31,20 @@ * 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{ +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 use_agp; int agp_mode; int agp_header_start; int agp_index; @@ -70,11 +68,7 @@ typedef struct{ int agpSync; CARD32 agpSyncTimeStamp; unsigned chipId; -}XvMCLowLevel; - - - - +} XvMCLowLevel; /* * For Other architectures than i386 these might have to be modified for @@ -94,7 +88,7 @@ typedef struct{ #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_MINIFY_DEBLOCK 0x1E8 #define HQV_SW_FLIP 0x00000010 #define HQV_FLIP_STATUS 0x00000001 @@ -108,8 +102,8 @@ typedef struct{ #define HQV_DEBLOCK_VER 0x80000000 #define V_COMPOSE_MODE 0x98 -#define V1_COMMAND_FIRE 0x80000000 -#define V3_COMMAND_FIRE 0x40000000 +#define V1_COMMAND_FIRE 0x80000000 +#define V3_COMMAND_FIRE 0x40000000 /* SUBPICTURE Registers */ #define SUBP_CONTROL_STRIDE 0x1C0 @@ -127,25 +121,23 @@ typedef struct{ /* 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_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_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_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 @@ -157,16 +149,15 @@ typedef struct{ #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_SYNCWAITTIMEOUT 50000 /* Might be a bit conservative */ #define VIA_DMAWAITTIMEOUT 150000 #define VIA_VIDWAITTIMEOUT 50000 -#define VIA_XVMC_DECODERTIMEOUT 50000 /*(microseconds)*/ +#define VIA_XVMC_DECODERTIMEOUT 50000 /*(microseconds) */ #define H1_ADDR(val) (((val) >> 2) | 0xF0000000) #define WAITFLAGS(xl, flags) \ @@ -184,7 +175,6 @@ typedef struct{ (xl)->agp_buffer[(xl)->agp_pos++] = (val1); \ (xl)->agp_buffer[(xl)->agp_pos++] = (val2); \ } while (0) - #define LL_HW_LOCK(xl) \ do { \ @@ -195,7 +185,6 @@ typedef struct{ 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 @@ -204,31 +193,31 @@ typedef struct{ * sneak in and display an image while other resources are busy. */ - -void -hwlLock(void *xlp, int videoLock) +void +hwlLock(void *xlp, int videoLock) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; LL_HW_LOCK(xl); } -void -hwlUnlock(void *xlp, int videoLock) +void +hwlUnlock(void *xlp, int videoLock) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; LL_HW_UNLOCK(xl); } - -static unsigned -timeDiff(struct timeval *now,struct timeval *then) { + +static unsigned +timeDiff(struct timeval *now, struct timeval *then) +{ return (now->tv_usec >= then->tv_usec) ? - now->tv_usec - then->tv_usec : + now->tv_usec - then->tv_usec : 1000000 - (then->tv_usec - now->tv_usec); } -void +void setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; @@ -237,21 +226,21 @@ setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp) xl->agpSyncTimeStamp = timeStamp; } -CARD32 +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); + 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) +static void +viaDMAWaitTimeStamp(XvMCLowLevel * xl, CARD32 timeStamp, int doSleep) { struct timeval now, then; struct timezone here; @@ -262,23 +251,24 @@ viaDMAWaitTimeStamp(XvMCLowLevel *xl, CARD32 timeStamp, int doSleep) 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))) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } } } -static int -viaDMAInitTimeStamp(XvMCLowLevel *xl) +static int +viaDMAInitTimeStamp(XvMCLowLevel * xl) { int ret = 0; @@ -286,35 +276,37 @@ viaDMAInitTimeStamp(XvMCLowLevel *xl) 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) + 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->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) +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)); + 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) +static CARD32 +viaMpegGetStatus(XvMCLowLevel * xl) { - return MPEGIN(xl,0x54); + return MPEGIN(xl, 0x54); } -static int -viaMpegIsBusy(XvMCLowLevel *xl, CARD32 mask, CARD32 idle) +static int +viaMpegIsBusy(XvMCLowLevel * xl, CARD32 mask, CARD32 idle) { CARD32 tmp = viaMpegGetStatus(xl); @@ -323,14 +315,14 @@ viaMpegIsBusy(XvMCLowLevel *xl, CARD32 mask, CARD32 idle) * FIXME: Are errors really shown when error concealment is on? */ - if (tmp & 0x70) return 0; + if (tmp & 0x70) + return 0; return (tmp & mask) != idle; } - -static void -syncDMA(XvMCLowLevel *xl, unsigned int doSleep) +static void +syncDMA(XvMCLowLevel * xl, unsigned int doSleep) { /* @@ -347,31 +339,33 @@ syncDMA(XvMCLowLevel *xl, unsigned int doSleep) 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)) { + 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); + 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 ) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } } -static void -syncVideo(XvMCLowLevel *xl, unsigned int doSleep) +static void +syncVideo(XvMCLowLevel * xl, unsigned int doSleep) { /* * Wait for HQV completion. Nothing strange here. We assume that the HQV @@ -379,7 +373,7 @@ syncVideo(XvMCLowLevel *xl, unsigned int doSleep) * always wait for SUBPIC_FLIP completion although subpictures are not always * used. */ - + struct timeval now, then; struct timezone here; struct timespec sleep, rem; @@ -388,21 +382,22 @@ syncVideo(XvMCLowLevel *xl, unsigned int doSleep) 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)) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } } -static void -syncAccel(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) +static void +syncAccel(XvMCLowLevel * xl, unsigned int mode, unsigned int doSleep) { struct timeval now, then; struct timezone here; @@ -414,22 +409,22 @@ syncAccel(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) 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) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } } - -static void -syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) +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 @@ -448,7 +443,7 @@ syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) sleep.tv_sec = 0; here.tz_minuteswest = 0; here.tz_dsttime = 0; - gettimeofday(&then,&here); + gettimeofday(&then, &here); if (mode & LL_MODE_DECODER_SLICE) { busyMask = VIA_SLICEBUSYMASK; idleVal = VIA_SLICEIDLEVAL; @@ -457,17 +452,18 @@ syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) busyMask |= VIA_BUSYMASK; idleVal = VIA_IDLEVAL; } - while(viaMpegIsBusy(xl, busyMask, idleVal)) { - gettimeofday(&now,&here); - if (timeDiff(&now,&then) > VIA_XVMC_DECODERTIMEOUT) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } - + ret = viaMpegGetStatus(xl); if (ret & 0x70) { xl->errors |= ((ret & 0x70) >> 3); @@ -475,35 +471,37 @@ syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) return; } -static void -pciFlush(XvMCLowLevel *xl) +static void +pciFlush(XvMCLowLevel * xl) { int ret; drm_via_cmdbuffer_t b; - unsigned mode=xl->curWaitFlags; - + 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)) + 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) + 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 (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) + +static void +agpFlush(XvMCLowLevel * xl) { drm_via_cmdbuffer_t b; int ret; @@ -512,15 +510,18 @@ agpFlush(XvMCLowLevel *xl) 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); + syncXvMCLowLevel(xl, LL_MODE_DECODER_IDLE, 1, + xl->agpSyncTimeStamp); xl->agpSync = 0; } - if (xl->performLocking) hwlLock(xl,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 (xl->performLocking) + hwlUnlock(xl, 0); + if (ret) { xl->errors |= LL_AGP_COMMAND_ERR; } else { @@ -528,91 +529,96 @@ agpFlush(XvMCLowLevel *xl) } xl->curWaitFlags &= LL_MODE_VIDEO; } else { - unsigned mode=xl->curWaitFlags; - + 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)) + 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)) + if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D)) syncAccel(xl, mode, 0); - if (mode & LL_MODE_VIDEO) + 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 (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 +flushXvMCLowLevel(void *xlp) { - unsigned - errors; + unsigned errors; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; - - if(xl->pci_pos) pciFlush(xl); - if(xl->agp_pos) agpFlush(xl); + + if (xl->pci_pos) + pciFlush(xl); + if (xl->agp_pos) + agpFlush(xl); errors = xl->errors; xl->errors = 0; return errors; } -void -flushPCIXvMCLowLevel(void *xlp) +void +flushPCIXvMCLowLevel(void *xlp) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; - if(xl->pci_pos) pciFlush(xl); - if (!xl->use_agp && xl->agp_pos) agpFlush(xl); + 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) +__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; + 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) +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)); + OUT_RING_QW_AGP(xl, H1_ADDR(0xc50), + (y_stride >> 3) | ((uv_stride >> 3) << 16)); WAITFLAGS(xl, LL_MODE_DECODER_IDLE); } - -void +void viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs, - unsigned vOffs, unsigned yStride, unsigned uvStride) + 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); + 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) + +void +viaVideoSWFlipLocked(void *xlp, unsigned flags, int progressiveSequence) { - CARD32 andWd,orWd; + CARD32 andWd, orWd; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; andWd = 0; @@ -620,45 +626,35 @@ viaVideoSWFlipLocked(void *xlp, unsigned flags, if ((flags & XVMC_FRAME_PICTURE) == XVMC_BOTTOM_FIELD) { andWd = 0xFFFFFFFFU; - orWd = HQV_FIELD_UV | - HQV_DEINTERLACE | + 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; + 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 | + orWd = HQV_FIELD_UV | + HQV_DEINTERLACE | HQV_FIELD_2_FRAME | HQV_FRAME_2_FIELD | - HQV_SW_FLIP | - HQV_FLIP_STATUS | - HQV_SUBPIC_FLIP; + 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; - } + 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; + andWd &= ~HQV_FIELD_UV; + orWd &= ~HQV_FIELD_UV; } - - pciCommand(xl,HQV_CONTROL | 0x200,(VIDIN(xl,HQV_CONTROL) & andWd) | orWd, 0); + + pciCommand(xl, HQV_CONTROL | 0x200, (VIDIN(xl, + HQV_CONTROL) & andWd) | orWd, 0); } - -void -viaMpegSetFB(void *xlp,unsigned i, - unsigned yOffs, - unsigned uOffs, - unsigned vOffs) + +void +viaMpegSetFB(void *xlp, unsigned i, + unsigned yOffs, unsigned uOffs, unsigned vOffs) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; @@ -670,151 +666,147 @@ viaMpegSetFB(void *xlp,unsigned i, WAITFLAGS(xl, LL_MODE_DECODER_IDLE); } -void -viaMpegBeginPicture(void *xlp,ViaXvMCContext *ctx, - unsigned width, - unsigned height, - const XvMCMpegControl *control) { - +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)); + ((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)); - + ((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)); - } + 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)); - } + 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)); - } + 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)); - } + 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)); - -} + 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 +void viaMpegReset(void *xlp) { - int i,j; + 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(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(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); + 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); - + OUT_RING_QW_AGP(xl, H1_ADDR(j), 0); + } -void -viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode) +void +viaMpegWriteSlice(void *xlp, CARD8 * slice, int nBytes, CARD32 sCode) { int i, n, r; - CARD32* buf; + 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; + LL_IDCT_FIFO_ERROR | LL_SLICE_FIFO_ERROR | LL_SLICE_FAULT)) + return; n = nBytes >> 2; - if (sCode) nBytes += 4; + if (sCode) + nBytes += 4; r = nBytes & 3; - buf = (CARD32*) slice; + buf = (CARD32 *) slice; - if (r) nBytes += 4 - r; + if (r) + nBytes += 4 - r; nBytes += 8; @@ -822,14 +814,15 @@ viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode) 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); + + if (sCode) + OUT_RING_QW_AGP(xl, H1_ADDR(0xca0), sCode); i = 0; count = 0; do { - count += (LL_AGP_CMDBUF_SIZE -20) >> 1; + count += (LL_AGP_CMDBUF_SIZE - 20) >> 1; count = (count > n) ? n : count; BEGIN_RING_AGP(xl, (count - i) << 1); @@ -848,28 +841,30 @@ viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode) } -void -viaVideoSubPictureOffLocked(void *xlp) { +void +viaVideoSubPictureOffLocked(void *xlp) +{ CARD32 stride; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; + stride = VIDIN(xl, SUBP_CONTROL_STRIDE); - stride = VIDIN(xl,SUBP_CONTROL_STRIDE); - - pciCommand(xl, SUBP_CONTROL_STRIDE | 0x200, stride & ~SUBP_HQV_ENABLE,LL_MODE_VIDEO); + pciCommand(xl, SUBP_CONTROL_STRIDE | 0x200, stride & ~SUBP_HQV_ENABLE, + LL_MODE_VIDEO); } -void -viaVideoSubPictureLocked(void *xlp,ViaXvMCSubPicture *pViaSubPic) { +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); + 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); @@ -878,70 +873,68 @@ viaVideoSubPictureLocked(void *xlp,ViaXvMCSubPicture *pViaSubPic) { 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) +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 dwGEMode = 0, srcY = 0, srcX, dstY = 0, dstX; CARD32 cmd; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; - if (!w || !h) - return; + return; switch (bpp) { case 16: - dwGEMode |= VIA_GEM_16bpp; - break; + dwGEMode |= VIA_GEM_16bpp; + break; case 32: - dwGEMode |= VIA_GEM_32bpp; + dwGEMode |= VIA_GEM_32bpp; break; default: - dwGEMode |= VIA_GEM_8bpp; - break; + dwGEMode |= VIA_GEM_8bpp; + break; } srcX = srcBase & 31; dstX = dstBase & 31; switch (bpp) { case 16: - dwGEMode |= VIA_GEM_16bpp; + dwGEMode |= VIA_GEM_16bpp; srcX >>= 2; dstX >>= 2; - break; + break; case 32: - dwGEMode |= VIA_GEM_32bpp; + dwGEMode |= VIA_GEM_32bpp; srcX >>= 4; dstX >>= 4; break; default: - dwGEMode |= VIA_GEM_8bpp; - break; + 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; + cmd = 0; if (xdir < 0) { - cmd |= VIA_GEC_DECX; - srcX += (w - 1); - dstX += (w - 1); + cmd |= VIA_GEC_DECX; + srcX += (w - 1); + dstX += (w - 1); } if (ydir < 0) { - cmd |= VIA_GEC_DECY; - srcY += (h - 1); - dstY += (h - 1); + cmd |= VIA_GEC_DECY; + srcY += (h - 1); + dstY += (h - 1); } - switch(blitMode) { + 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); @@ -954,24 +947,24 @@ viaBlit(void *xlp,unsigned bpp,unsigned srcBase, 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)); + (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_DIMENSION), + (((h - 1) << 16) | (w - 1))); OUT_RING_QW_AGP(xl, H1_ADDR(VIA_REG_GECMD), cmd); } -unsigned +unsigned syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep, - CARD32 timeStamp) + CARD32 timeStamp) { - unsigned - errors; + unsigned errors; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; if (mode == 0) { @@ -981,41 +974,41 @@ syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep, } if ((mode & (LL_MODE_VIDEO | LL_MODE_3D)) || !xl->use_agp) { - if (xl->performLocking) - hwlLock(xl,0); + if (xl->performLocking) + hwlLock(xl, 0); if ((mode != LL_MODE_VIDEO)) syncDMA(xl, doSleep); - if (mode & LL_MODE_3D) + if (mode & LL_MODE_3D) syncAccel(xl, mode, doSleep); if (mode & LL_MODE_VIDEO) syncVideo(xl, doSleep); - if (xl->performLocking) - hwlUnlock(xl,0); + if (xl->performLocking) + hwlUnlock(xl, 0); } else { viaDMAWaitTimeStamp(xl, timeStamp, doSleep); } - if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE)) + 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 ) - +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; + + XvMCLowLevel *xl = (XvMCLowLevel *) malloc(sizeof(XvMCLowLevel)); + + if (!xl) + return NULL; xl->agp_pos = 0; xl->pci_pos = 0; @@ -1029,7 +1022,7 @@ extern void xl->performLocking = 1; xl->errors = 0; xl->agpSync = 0; - ret = viaDMAInitTimeStamp(xl); + ret = viaDMAInitTimeStamp(xl); if (ret) { free(xl); return NULL; @@ -1037,7 +1030,7 @@ extern void return xl; } -void +void setLowLevelLocking(void *xlp, int performLocking) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; @@ -1045,12 +1038,11 @@ setLowLevelLocking(void *xlp, int performLocking) xl->performLocking = performLocking; } -void -closeXvMCLowLevel(void *xlp) +void +closeXvMCLowLevel(void *xlp) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; - viaDMACleanupTimeStamp(xl); + viaDMACleanupTimeStamp(xl); free(xl); } - diff --git a/src/xvmc/viaLowLevel.h b/src/xvmc/viaLowLevel.h index 12e5fe3..0e70efb 100644 --- a/src/xvmc/viaLowLevel.h +++ b/src/xvmc/viaLowLevel.h @@ -22,16 +22,13 @@ * DEALINGS IN THE SOFTWARE. */ - /* * Authors: Thomas Hellström 2004 - 2005. */ - -#ifndef VIA_LOWLEVEL_H +#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 @@ -64,7 +61,7 @@ #define VIA_SLICEBUSYMASK 0x00000200 #define VIA_BUSYMASK 0x00000207 #define VIA_SLICEIDLEVAL 0x00000200 -#define VIA_IDLEVAL 0x00000204 +#define VIA_IDLEVAL 0x00000204 #include "via_drm.h" #include "viaXvMCPriv.h" @@ -83,13 +80,11 @@ (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 ); + *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); @@ -97,49 +92,45 @@ 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); + unsigned int doSleep, CARD32 timeStamp); -extern void hwlUnlock(void *xlp, int videoLock); -extern void hwlLock(void *xlp, int videoLock); +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); + 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); +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 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); + int progressiveSequence); -extern void viaVideoSubPictureLocked(void *xlp,ViaXvMCSubPicture *pViaSubPic); +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 */ diff --git a/src/xvmc/unichromeProA/viaLowLevelPro.c b/src/xvmc/viaLowLevelPro.c index 666166c..760ae92 100644 --- a/src/xvmc/unichromeProA/viaLowLevelPro.c +++ b/src/xvmc/viaLowLevelPro.c @@ -23,7 +23,6 @@ * 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 @@ -53,11 +52,12 @@ #include <sys/time.h> #include <stdio.h> -typedef enum {ll_init, ll_agpBuf, ll_pciBuf, ll_timeStamp, ll_llBuf} - LLState; - +typedef enum +{ ll_init, ll_agpBuf, ll_pciBuf, ll_timeStamp, ll_llBuf } +LLState; -typedef struct { +typedef struct +{ drm_via_mem_t mem; unsigned offset; unsigned stride; @@ -66,7 +66,8 @@ typedef struct { struct _XvMCLowLevel; -typedef struct _ViaCommandBuffer { +typedef struct _ViaCommandBuffer +{ CARD32 *buf; CARD32 waitFlags; unsigned pos; @@ -74,12 +75,14 @@ typedef struct _ViaCommandBuffer { int mode; int header_start; int rindex; - void (*flushFunc)(struct _ViaCommandBuffer *cb, struct _XvMCLowLevel *xl); + void (*flushFunc) (struct _ViaCommandBuffer * cb, + struct _XvMCLowLevel * xl); } ViaCommandBuffer; - -typedef struct _XvMCLowLevel{ + +typedef struct _XvMCLowLevel +{ ViaCommandBuffer agpBuf, pciBuf, *videoBuf; - int use_agp; + int use_agp; int fd; drm_context_t *drmcontext; drmLockPtr hwLock; @@ -116,15 +119,13 @@ typedef struct _XvMCLowLevel{ unsigned fetch; unsigned line; LLState state; -}XvMCLowLevel; - +} 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))) @@ -139,10 +140,10 @@ typedef struct _XvMCLowLevel{ #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_MINIFY_DEBLOCK 0x1E8 #define REG_HQV1_INDEX 0x00001000 - + #define HQV_SW_FLIP 0x00000010 #define HQV_FLIP_STATUS 0x00000001 #define HQV_SUBPIC_FLIP 0x00008000 @@ -162,8 +163,8 @@ typedef struct _XvMCLowLevel{ #define HQV_SCALE_DOWN 0x00001000 #define V_COMPOSE_MODE 0x98 -#define V1_COMMAND_FIRE 0x80000000 -#define V3_COMMAND_FIRE 0x40000000 +#define V1_COMMAND_FIRE 0x80000000 +#define V3_COMMAND_FIRE 0x40000000 /* SUBPICTURE Registers */ #define SUBP_CONTROL_STRIDE 0x1C0 @@ -181,25 +182,23 @@ typedef struct _XvMCLowLevel{ /* 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_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_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_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 @@ -211,26 +210,25 @@ typedef struct _XvMCLowLevel{ #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_SYNCWAITTIMEOUT 50000 /* Might be a bit conservative */ #define VIA_DMAWAITTIMEOUT 150000 #define VIA_VIDWAITTIMEOUT 50000 -#define VIA_XVMC_DECODERTIMEOUT 50000 /*(microseconds)*/ +#define VIA_XVMC_DECODERTIMEOUT 50000 /*(microseconds) */ #define VIA_AGP_HEADER5 0xFE040000 #define VIA_AGP_HEADER6 0xFE050000 -typedef struct{ +typedef struct +{ CARD32 data; Bool set; } HQVRegister; - #define H1_ADDR(val) (((val) >> 2) | 0xF0000000) #define WAITFLAGS(cb, flags) \ (cb)->waitFlags |= (flags) @@ -242,14 +240,13 @@ typedef struct{ } while(0) #define OUT_RING_AGP(cb, val) do{ \ (cb)->buf[(cb)->pos++] = (val); \ - } while(0); + } 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 { \ @@ -319,33 +316,68 @@ typedef struct{ static HQVRegister hqvShadow[HQV_SHADOW_SIZE]; - -static void -initHQVShadow(HQVRegister *r) +static void +initHQVShadow(HQVRegister * r) { int i; - - for(i=0; i<HQV_SHADOW_SIZE; ++i) { + + for (i = 0; i < HQV_SHADOW_SIZE; ++i) { r->data = 0; r++->set = FALSE; } } +#if 0 static void -setHQVDeblocking(HQVRegister *shadow, Bool on, Bool lowPass) +setHQVHWDeinterlacing(HQVRegister * shadow, Bool on, Bool motionDetect, + CARD32 stride, CARD32 height) +{ + CARD32 tmp = GETHQVSHADOW(shadow, 0x3E4); + + if (!on) { + tmp &= ~((1 << 0) | (1 << 12) | (1 << 27) | (1 << 31)); + SETHQVSHADOW(shadow, 0x3E4, tmp); + return; + } + + tmp = (1 << 31) | + (4 << 28) | + (1 << 27) | + (3 << 25) | (1 << 18) | (2 << 14) | (8 << 8) | (8 << 1) | (1 << 0); + + if (motionDetect) + tmp |= (1 << 12); + + SETHQVSHADOW(shadow, 0x3E4, tmp); + + tmp = GETHQVSHADOW(shadow, 0x3DC); + tmp |= (stride * height * 1536) / 1024 & 0x7ff; + + SETHQVSHADOW(shadow, 0x3DC, tmp); + + tmp = GETHQVSHADOW(shadow, 0x3D0); + tmp |= (1 << 23); + + SETHQVSHADOW(shadow, 0x3D0, tmp); +} + +#endif + +static void +setHQVDeblocking(HQVRegister * shadow, Bool on, Bool lowPass) { CARD32 tmp = GETHQVSHADOW(shadow, 0x3DC); - + if (!on) { tmp &= ~(1 << 27); - SETHQVSHADOW(shadow, 0x3DC , tmp); + SETHQVSHADOW(shadow, 0x3DC, tmp); return; } tmp |= (8 << 16) | (1 << 27); - if (lowPass) + if (lowPass) tmp |= (1 << 26); - SETHQVSHADOW(shadow, 0x3DC , tmp); + SETHQVSHADOW(shadow, 0x3DC, tmp); tmp = GETHQVSHADOW(shadow, 0x3D4); tmp |= (6 << 27); @@ -354,14 +386,14 @@ setHQVDeblocking(HQVRegister *shadow, Bool on, Bool lowPass) tmp = GETHQVSHADOW(shadow, 0x3D8); tmp |= (19 << 27); SETHQVSHADOW(shadow, 0x3D8, tmp); -} - -static void -setHQVStartAddress(HQVRegister *shadow, unsigned yOffs, unsigned uOffs, - unsigned stride, unsigned format) +} + +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); @@ -375,7 +407,7 @@ setHQVStartAddress(HQVRegister *shadow, unsigned yOffs, unsigned uOffs, if (format == 0) { /* * NV12 - */ + */ tmp |= (0x0C << 28); } else if (format == 1) { /* @@ -391,94 +423,138 @@ setHQVStartAddress(HQVRegister *shadow, unsigned yOffs, unsigned uOffs, SETHQVSHADOW(shadow, 0x3D0, tmp); } +#if 0 + static void -setHQVDeinterlacing(HQVRegister *shadow, CARD32 frameType) +setHQVColorSpaceConversion(HQVRegister * shadow, unsigned depth, Bool on) +{ + CARD32 tmp = GETHQVSHADOW(shadow, 0x3DC); + + if (!on) { + tmp &= ~(1 << 28); + SETHQVSHADOW(shadow, 0x3DC, tmp); + return; + } + + if (depth == 32) + tmp |= (1 << 29); + tmp |= (1 << 28); + tmp &= ~(1 << 15); + SETHQVSHADOW(shadow, 0x3DC, tmp); +} + +static void +setHQVFetchLine(HQVRegister * shadow, unsigned fetch, unsigned lines) +{ + SETHQVSHADOW(shadow, 0x3E0, + ((lines - 1) & 0x7FF) | (((fetch - 1) & 0x1FFF) << 16)); +} + +static void +setHQVScale(HQVRegister * shadow, unsigned horizontal, unsigned vertical) +{ + SETHQVSHADOW(shadow, 0x3E8, + (horizontal & 0xFFFF) | ((vertical & 0xFFFF) << 16)); +} + +static void +setHQVSingleDestination(HQVRegister * shadow, unsigned offset, + unsigned stride) +{ + CARD32 tmp = GETHQVSHADOW(shadow, 0x3D0); + + tmp |= (1 << 6); + + SETHQVSHADOW(shadow, 0x3D0, tmp); + SETHQVSHADOW(shadow, 0x3EC, offset & 0x03FFFFF8); + SETHQVSHADOW(shadow, 0x3F4, stride & 0x1FF8); +} +#endif + +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; + 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; - } + 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) +setHQVTripleBuffer(HQVRegister * shadow, Bool on) { CARD32 tmp = GETHQVSHADOW(shadow, 0x3D0); if (on) - tmp |= ( 1 << 26 ); - else - tmp &= ~( 1 << 26 ); + tmp |= (1 << 26); + else + tmp &= ~(1 << 26); SETHQVSHADOW(shadow, 0x3D0, tmp); } static void -finish_header_agp(ViaCommandBuffer *cb) +finish_header_agp(ViaCommandBuffer * cb) { - int - numDWords,i; - CARD32 - *hb; + int numDWords, i; + + CARD32 *hb; - if (!cb->mode) return; - numDWords = cb->pos - cb->header_start - 4; + 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. (?) */ + 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. (?) */ + 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) + for (i = 0; i < (4 - (numDWords & 3)); ++i) OUT_RING_AGP(cb, 0x00000000); } cb->mode = 0; } -void -hwlLock(void *xlp, int videoLock) +void +hwlLock(void *xlp, int videoLock) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; LL_HW_LOCK(xl); } -void -hwlUnlock(void *xlp, int videoLock) +void +hwlUnlock(void *xlp, int videoLock) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; LL_HW_UNLOCK(xl); } - -static unsigned -timeDiff(struct timeval *now,struct timeval *then) { + +static unsigned +timeDiff(struct timeval *now, struct timeval *then) +{ return (now->tv_usec >= then->tv_usec) ? - now->tv_usec - then->tv_usec : + now->tv_usec - then->tv_usec : 1000000 - (then->tv_usec - now->tv_usec); } -void +void setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; @@ -487,21 +563,21 @@ setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp) xl->agpSyncTimeStamp = timeStamp; } -CARD32 +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); + 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) +static void +viaDMAWaitTimeStamp(XvMCLowLevel * xl, CARD32 timeStamp, int doSleep) { struct timeval now, then; struct timezone here; @@ -512,23 +588,25 @@ viaDMAWaitTimeStamp(XvMCLowLevel *xl, CARD32 timeStamp, int doSleep) 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)) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } } } -static int -viaDMAInitTimeStamp(XvMCLowLevel *xl) +static int +viaDMAInitTimeStamp(XvMCLowLevel * xl) { int ret = 0; @@ -536,36 +614,37 @@ viaDMAInitTimeStamp(XvMCLowLevel *xl) 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) + 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->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) +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)); + 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) +static CARD32 +viaMpegGetStatus(XvMCLowLevel * xl) { - return MPEGIN(xl,0x54); + return MPEGIN(xl, 0x54); } -static int -viaMpegIsBusy(XvMCLowLevel *xl, CARD32 mask, CARD32 idle) +static int +viaMpegIsBusy(XvMCLowLevel * xl, CARD32 mask, CARD32 idle) { CARD32 tmp = viaMpegGetStatus(xl); @@ -574,16 +653,16 @@ viaMpegIsBusy(XvMCLowLevel *xl, CARD32 mask, CARD32 idle) * FIXME: Are errors really shown when error concealment is on? */ - if (tmp & 0x70) return 0; + if (tmp & 0x70) + return 0; return (tmp & mask) != idle; } - -static void -syncDMA(XvMCLowLevel *xl, unsigned int doSleep) +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. @@ -598,32 +677,34 @@ syncDMA(XvMCLowLevel *xl, unsigned int doSleep) 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)) { + 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); + 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 ) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } } #ifdef HQV_USE_IRQ -static void -syncVideo(XvMCLowLevel *xl, unsigned int doSleep) +static void +syncVideo(XvMCLowLevel * xl, unsigned int doSleep) { int proReg = REG_HQV1_INDEX; @@ -632,18 +713,20 @@ syncVideo(XvMCLowLevel *xl, unsigned int doSleep) * 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))) { + + 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) + 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) +static void +syncVideo(XvMCLowLevel * xl, unsigned int doSleep) { /* * Wait for HQV completion. Nothing strange here. We assume that the HQV @@ -651,7 +734,7 @@ syncVideo(XvMCLowLevel *xl, unsigned int doSleep) * always wait for SUBPIC_FLIP completion although subpictures are not always * used. */ - + struct timeval now, then; struct timezone here; struct timespec sleep, rem; @@ -662,22 +745,26 @@ syncVideo(XvMCLowLevel *xl, unsigned int doSleep) 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 )) ) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } } #endif -static void -syncAccel(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) +static void +syncAccel(XvMCLowLevel * xl, unsigned int mode, unsigned int doSleep) { struct timeval now, then; struct timezone here; @@ -689,22 +776,22 @@ syncAccel(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) 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) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } } - -static void -syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) +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 @@ -723,7 +810,7 @@ syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) sleep.tv_sec = 0; here.tz_minuteswest = 0; here.tz_dsttime = 0; - gettimeofday(&then,&here); + gettimeofday(&then, &here); if (mode & LL_MODE_DECODER_SLICE) { busyMask = VIA_SLICEBUSYMASK; idleVal = VIA_SLICEIDLEVAL; @@ -732,17 +819,18 @@ syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) busyMask |= VIA_BUSYMASK; idleVal = VIA_IDLEVAL; } - while(viaMpegIsBusy(xl, busyMask, idleVal)) { - gettimeofday(&now,&here); - if (timeDiff(&now,&then) > VIA_XVMC_DECODERTIMEOUT) { + 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); + if (doSleep) + nanosleep(&sleep, &rem); } - + ret = viaMpegGetStatus(xl); if (ret & 0x70) { xl->errors |= ((ret & 0x70) >> 3); @@ -750,40 +838,42 @@ syncMpeg(XvMCLowLevel *xl, unsigned int mode, unsigned int doSleep) return; } -static void -pciFlush(ViaCommandBuffer *cb, XvMCLowLevel *xl) +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 (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); + syncAccel(xl, mode, 0); } if (mode & LL_MODE_VIDEO) { - syncVideo(xl, 1); + syncVideo(xl, 1); } if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE)) { - syncMpeg(xl, mode, 0); + syncMpeg(xl, mode, 0); } ret = drmCommandWrite(xl->fd, DRM_VIA_PCICMD, &b, sizeof(b)); - if (xl->performLocking) hwlUnlock(xl,0); + 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) + +static void +agpFlush(ViaCommandBuffer * cb, XvMCLowLevel * xl) { drm_via_cmdbuffer_t b; int ret; @@ -794,53 +884,91 @@ agpFlush(ViaCommandBuffer *cb, XvMCLowLevel *xl) b.buf = (char *)cb->buf; b.size = cb->pos * sizeof(CARD32); if (xl->agpSync) { - syncXvMCLowLevel(xl, LL_MODE_DECODER_IDLE, 1, xl->agpSyncTimeStamp); + syncXvMCLowLevel(xl, LL_MODE_DECODER_IDLE, 1, + xl->agpSyncTimeStamp); xl->agpSync = 0; } - if (xl->performLocking) hwlLock(xl,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 (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]); + 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! */ + cb->waitFlags &= LL_MODE_VIDEO; /* FIXME: Check this! */ } else { - unsigned mode=cb->waitFlags; - + unsigned mode = cb->waitFlags; + b.buf = (char *)cb->buf; b.size = cb->pos * sizeof(CARD32); - if (xl->performLocking) hwlLock(xl,0); + 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)) + if ((mode & LL_MODE_2D) || (mode & LL_MODE_3D)) syncAccel(xl, mode, 0); - if (mode & LL_MODE_VIDEO) + 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 (xl->performLocking) + hwlUnlock(xl, 0); if (ret) { xl->errors |= LL_PCI_COMMAND_ERR; } cb->pos = 0; cb->waitFlags = 0; - } + } +} + +#if 0 /* Needs debugging */ +static void +uploadHQVDeinterlace(XvMCLowLevel * xl, unsigned offset, HQVRegister * shadow, + CARD32 cur_offset, CARD32 prev_offset, CARD32 stride, + Bool top_field_first, CARD32 height) +{ + CARD32 tmp; + ViaCommandBuffer *cb = &xl->agpBuf; + + BEGIN_HEADER6_DATA(cb, xl, 9); + tmp = GETHQVSHADOW(shadow, 0x3F8); + tmp &= ~(3 << 30); + tmp |= (1 << 30); + OUT_RING_QW_AGP(cb, 0x3F8 + offset, tmp); + OUT_RING_QW_AGP(cb, 0x3D4 + offset, prev_offset + + ((top_field_first) ? stride : 0)); + OUT_RING_QW_AGP(cb, 0x3D8 + offset, prev_offset + stride * height); + tmp &= ~(3 << 30); + tmp |= (2 << 30); + OUT_RING_QW_AGP(cb, 0x3F8 + offset, tmp); + OUT_RING_QW_AGP(cb, 0x3D4 + offset, cur_offset + + ((top_field_first) ? 0 : stride)); + OUT_RING_QW_AGP(cb, 0x3D8 + offset, cur_offset + stride * height); + tmp |= (3 << 30); + OUT_RING_QW_AGP(cb, 0x3F8 + offset, tmp); + OUT_RING_QW_AGP(cb, 0x3D4 + offset, cur_offset + + ((top_field_first) ? stride : 0)); + OUT_RING_QW_AGP(cb, 0x3D8 + offset, cur_offset + stride * height); } +#endif + static void -uploadHQVShadow(XvMCLowLevel *xl, unsigned offset, HQVRegister *shadow, - Bool flip) +uploadHQVShadow(XvMCLowLevel * xl, unsigned offset, HQVRegister * shadow, + Bool flip) { int i; CARD32 tmp; @@ -851,74 +979,72 @@ uploadHQVShadow(XvMCLowLevel *xl, unsigned offset, HQVRegister *shadow, 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; - } + + 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); + 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 +flushXvMCLowLevel(void *xlp) { - unsigned - errors; + unsigned errors; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; - - if(xl->pciBuf.pos) pciFlush(&xl->pciBuf, xl); - if(xl->agpBuf.pos) agpFlush(&xl->agpBuf, xl); + 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); + if (errors) + printf("Error 0x%x\n", errors); xl->errors = 0; return errors; } -void -flushPCIXvMCLowLevel(void *xlp) +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); + 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) +void +viaMpegSetSurfaceStride(void *xlp, ViaXvMCContext * ctx) { CARD32 y_stride = ctx->yStride; CARD32 uv_stride = y_stride >> 1; - XvMCLowLevel *xl = (XvMCLowLevel *) xlp; + 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)); + OUT_RING_QW_AGP(cb, 0xc50, (y_stride >> 3) | ((uv_stride >> 3) << 16)); WAITFLAGS(cb, LL_MODE_DECODER_IDLE); } - -void +void viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs, - unsigned vOffs, unsigned yStride, unsigned uvStride) + unsigned vOffs, unsigned yStride, unsigned uvStride) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; @@ -930,47 +1056,43 @@ viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs, uploadHQVShadow(xl, REG_HQV1_INDEX, hqvShadow, FALSE); xl->videoBuf->flushFunc(xl->videoBuf, xl); } - -void -viaVideoSWFlipLocked(void *xlp, unsigned flags, - Bool progressiveSequence) + +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); + 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); + 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) +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); + 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) { - +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; @@ -978,164 +1100,164 @@ viaMpegBeginPicture(void *xlp,ViaXvMCContext *ctx, 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)); + ((control->mpeg_coding == XVMC_MPEG_2) && + (control->flags & XVMC_PROGRESSIVE_SEQUENCE)) ? + 2 * ((height + 31) >> 5) : (((height + 15) >> 4)); - BEGIN_HEADER6_DATA(cb,xl, 72); + 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)); - + ((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)); - } + 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)); - } + 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)); - } + 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)); - } + 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)); -} + 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 +void viaMpegReset(void *xlp) { - int i,j; + int i, j; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; ViaCommandBuffer *cb = &xl->agpBuf; - BEGIN_HEADER6_DATA(cb,xl, 99); + BEGIN_HEADER6_DATA(cb, xl, 99); WAITFLAGS(cb, LL_MODE_DECODER_IDLE); - OUT_RING_QW_AGP(cb, 0xcf0 ,0); + 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, 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); + 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, 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, 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); + OUT_RING_QW_AGP(cb, 0xcf0, 0); } -void -viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode) +void +viaMpegWriteSlice(void *xlp, CARD8 * slice, int nBytes, CARD32 sCode) { int i, n, r; - CARD32* buf; + 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; + LL_IDCT_FIFO_ERROR | LL_SLICE_FIFO_ERROR | LL_SLICE_FAULT)) + return; n = nBytes >> 2; - if (sCode) nBytes += 4; + if (sCode) + nBytes += 4; r = nBytes & 3; - buf = (CARD32*) slice; + buf = (CARD32 *) slice; - if (r) nBytes += 4 - r; + if (r) + nBytes += 4 - r; nBytes += 8; - BEGIN_HEADER6_DATA(cb,xl, 2); + 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); + + if (sCode) + OUT_RING_QW_AGP(cb, 0xca0, sCode); i = 0; count = 0; do { - count += (LL_AGP_CMDBUF_SIZE -20); + count += (LL_AGP_CMDBUF_SIZE - 20); count = (count > n) ? n : count; BEGIN_HEADER5_DATA(cb, xl, (count - i), 0xca0); @@ -1150,13 +1272,14 @@ viaMpegWriteSlice(void *xlp, CARD8* slice, int nBytes, CARD32 sCode) if (r) { OUT_RING_AGP(cb, *buf & ((1 << (r << 3)) - 1)); } - OUT_RING_AGP(cb,0); - OUT_RING_AGP(cb,0); + OUT_RING_AGP(cb, 0); + OUT_RING_AGP(cb, 0); finish_header_agp(cb); } -void -viaVideoSubPictureOffLocked(void *xlp) { +void +viaVideoSubPictureOffLocked(void *xlp) +{ CARD32 stride; int proReg = REG_HQV1_INDEX; @@ -1165,101 +1288,103 @@ viaVideoSubPictureOffLocked(void *xlp) { if (xl->videoBuf == &xl->agpBuf) syncDMA(xl, 1); - stride = VIDIN(xl,proReg|SUBP_CONTROL_STRIDE); + 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); + OUT_RING_QW_AGP(cb, proReg | SUBP_CONTROL_STRIDE | 0x200, + stride & ~SUBP_HQV_ENABLE); } -void -viaVideoSubPictureLocked(void *xlp, ViaXvMCSubPicture *pViaSubPic) { +void +viaVideoSubPictureLocked(void *xlp, ViaXvMCSubPicture * pViaSubPic) +{ unsigned i; - CARD32 cWord; + CARD32 cWord; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; - int proReg = REG_HQV1_INDEX; + 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]); + 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); + 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) +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 dwGEMode = 0, srcY = 0, srcX, dstY = 0, dstX; CARD32 cmd; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; ViaCommandBuffer *cb = &xl->agpBuf; if (!w || !h) - return; + return; finish_header_agp(cb); switch (bpp) { case 16: - dwGEMode |= VIA_GEM_16bpp; - break; + dwGEMode |= VIA_GEM_16bpp; + break; case 32: - dwGEMode |= VIA_GEM_32bpp; + dwGEMode |= VIA_GEM_32bpp; break; default: - dwGEMode |= VIA_GEM_8bpp; - break; + dwGEMode |= VIA_GEM_8bpp; + break; } srcX = srcBase & 31; dstX = dstBase & 31; switch (bpp) { case 16: - dwGEMode |= VIA_GEM_16bpp; + dwGEMode |= VIA_GEM_16bpp; srcX >>= 2; dstX >>= 2; - break; + break; case 32: - dwGEMode |= VIA_GEM_32bpp; + dwGEMode |= VIA_GEM_32bpp; srcX >>= 4; dstX >>= 4; break; default: - dwGEMode |= VIA_GEM_8bpp; - break; + 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; + cmd = 0; if (xdir < 0) { - cmd |= VIA_GEC_DECX; - srcX += (w - 1); - dstX += (w - 1); + cmd |= VIA_GEC_DECX; + srcX += (w - 1); + dstX += (w - 1); } if (ydir < 0) { - cmd |= VIA_GEC_DECY; - srcY += (h - 1); - dstY += (h - 1); + cmd |= VIA_GEC_DECY; + srcY += (h - 1); + dstY += (h - 1); } - switch(blitMode) { + 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); @@ -1272,24 +1397,24 @@ viaBlit(void *xlp,unsigned bpp,unsigned srcBase, 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)); + (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_DIMENSION), + (((h - 1) << 16) | (w - 1))); OUT_RING_QW_AGP(cb, H1_ADDR(VIA_REG_GECMD), cmd); } -unsigned +unsigned syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep, - CARD32 timeStamp) + CARD32 timeStamp) { - unsigned - errors; + unsigned errors; XvMCLowLevel *xl = (XvMCLowLevel *) xlp; if (mode == 0) { @@ -1299,21 +1424,21 @@ syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep, } 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)) + if (xl->performLocking) + hwlLock(xl, 0); + if ((xl->videoBuf == &xl->agpBuf) || (mode != LL_MODE_VIDEO)) syncDMA(xl, doSleep); - if (mode & LL_MODE_3D) + if (mode & LL_MODE_3D) syncAccel(xl, mode, doSleep); if (mode & LL_MODE_VIDEO) syncVideo(xl, doSleep); - if (xl->performLocking) - hwlUnlock(xl,0); + if (xl->performLocking) + hwlUnlock(xl, 0); } else { viaDMAWaitTimeStamp(xl, timeStamp, doSleep); } - if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE)) + if (mode & (LL_MODE_DECODER_SLICE | LL_MODE_DECODER_IDLE)) syncMpeg(xl, mode, doSleep); errors = xl->errors; @@ -1323,31 +1448,30 @@ syncXvMCLowLevel(void *xlp, unsigned int mode, unsigned int doSleep, } static int -updateLowLevelBuf(XvMCLowLevel *xl, LowLevelBuffer *buf, - unsigned width, unsigned height) +updateLowLevelBuf(XvMCLowLevel * xl, LowLevelBuffer * buf, + unsigned width, unsigned height) { - unsigned - stride, size; + 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)); + 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) { + + if (((ret = drmCommandWriteRead(xl->fd, DRM_VIA_ALLOCMEM, mem, + sizeof(mem))) < 0) || mem->size != size) { mem->size = 0; - return -1; - } + return -1; + } } - + buf->offset = (mem->offset + 31) & ~31; buf->stride = stride; buf->height = height; @@ -1355,20 +1479,19 @@ updateLowLevelBuf(XvMCLowLevel *xl, LowLevelBuffer *buf, } static void -cleanupLowLevelBuf(XvMCLowLevel *xl, LowLevelBuffer *buf) +cleanupLowLevelBuf(XvMCLowLevel * xl, LowLevelBuffer * buf) { drm_via_mem_t *mem = &buf->mem; - if (mem->size) - drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, mem, sizeof(mem)); + if (mem->size) + drmCommandWrite(xl->fd, DRM_VIA_FREEMEM, mem, sizeof(mem)); mem->size = 0; } - -static void -*releaseXvMCLowLevel(XvMCLowLevel *xl) +static void * +releaseXvMCLowLevel(XvMCLowLevel * xl) { - switch(xl->state) { + switch (xl->state) { case ll_llBuf: cleanupLowLevelBuf(xl, &xl->scale); case ll_timeStamp: @@ -1384,21 +1507,22 @@ static void } 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 ) + +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)); + XvMCLowLevel *xl = (XvMCLowLevel *) malloc(sizeof(XvMCLowLevel)); - if (!xl) return NULL; + 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->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; @@ -1406,8 +1530,9 @@ void 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->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; @@ -1430,14 +1555,14 @@ void xl->agpSync = 0; xl->chipId = chipId; - if (viaDMAInitTimeStamp(xl)) + 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)) + if (updateLowLevelBuf(xl, &xl->scale, width, height)) return releaseXvMCLowLevel(xl); xl->state = ll_llBuf; @@ -1450,16 +1575,69 @@ void return xl; } -void +void setLowLevelLocking(void *xlp, int performLocking) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; + xl->performLocking = performLocking; } -void -closeXvMCLowLevel(void *xlp) +void +closeXvMCLowLevel(void *xlp) { XvMCLowLevel *xl = (XvMCLowLevel *) xlp; + releaseXvMCLowLevel(xl); } + +#if 0 /* Under development */ +static CARD32 +computeDownScaling(int dst, int *src) +{ + CARD32 value = 0x800; + + while (*src > dst) { + *src >>= 1; + value--; + } + return value; +} + +static void +computeHQVScaleAndFilter(XvMCLowLevel * xl) +{ + int srcW, srcH; + const XvMCRegion *src = &xl->sRegion, *back = &xl->dRegion; + + xl->downScaling = FALSE; + + if (back->w < src->w || back->h < src->h) { + + xl->downScaling = TRUE; + srcW = src->w; + srcH = src->h; + + xl->downScaleW = (back->w >= srcW) ? 0 : + HQV_SCALE_ENABLE | HQV_SCALE_DOWN | + (computeDownScaling(back->w, &srcW)); + + xl->downScaleH = (back->h >= srcH) ? 0 : + HQV_SCALE_ENABLE | HQV_SCALE_DOWN | + (computeDownScaling(back->h, &srcH)); + + } + + xl->upScaleW = + (back->w == srcW) ? 0 : (0x800 * srcW / back->w) | HQV_SCALE_ENABLE; + xl->upScaleH = + (back->h == srcH) ? 0 : (0x800 * srcH / back->h) | HQV_SCALE_ENABLE; +} + +static int +setupBackBuffer(XvMCLowLevel * xl) +{ + return updateLowLevelBuf(xl, &xl->back, xl->dRegion.w, xl->dRegion.h); +} + +#endif diff --git a/src/xvmc/viaXvMC.c b/src/xvmc/viaXvMC.c index eebc87e..5e2891e 100644 --- a/src/xvmc/viaXvMC.c +++ b/src/xvmc/viaXvMC.c @@ -22,7 +22,6 @@ * DEALINGS IN THE SOFTWARE. */ - /* *Author: Thomas Hellström, 2004. *Bugfixes by among others Pascal Brisset and Terry Barnaby. @@ -41,16 +40,13 @@ #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; @@ -59,7 +55,6 @@ static drmAddress sAreaAddress; static drmAddress fbAddress; static drmAddress mmioAddress; - #define FOURCC_XVMC (('C' << 24) + ('M' << 16) + ('V' << 8) + 'X') #define ppthread_mutex_lock(arg) \ @@ -72,35 +67,38 @@ static drmAddress mmioAddress; pthread_mutex_unlock(arg); \ } \ -static unsigned yOffs (ViaXvMCSurface *srf) +static unsigned +yOffs(ViaXvMCSurface * srf) { return srf->offsets[0]; } -static unsigned vOffs (ViaXvMCSurface *srf) +static unsigned +vOffs(ViaXvMCSurface * srf) { return srf->offsets[0] + srf->yStride * srf->height; } -static unsigned uOffs (ViaXvMCSurface *srf) +static unsigned +uOffs(ViaXvMCSurface * srf) { - return srf->offsets[0] + ( srf->yStride * srf->height) + + return srf->offsets[0] + (srf->yStride * srf->height) + (srf->yStride >> 1) * (srf->height >> 1); } - -static void defaultQMatrices(ViaXvMCContext *ctx) +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 + 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) { + + for (i = 0; i < 64; ++i) { ctx->intra_quantiser_matrix[i] = intra[i]; ctx->non_intra_quantiser_matrix[i] = 16; } @@ -108,19 +106,20 @@ static void defaultQMatrices(ViaXvMCContext *ctx) ctx->nonIntraLoaded = 0; } - -static void releaseDecoder(ViaXvMCContext *ctx,int clearCtx) +static void +releaseDecoder(ViaXvMCContext * ctx, int clearCtx) { volatile ViaXvMCSAreaPriv *sAPriv; sAPriv = SAREAPTR(ctx); - UNICHROME_UNLOCK(ctx->fd, UNICHROME_LOCK_DECODER1, sAPriv, ctx->drmcontext); + UNICHROME_UNLOCK(ctx->fd, UNICHROME_LOCK_DECODER1, sAPriv, + ctx->drmcontext); } - -static int grabDecoder( ViaXvMCContext *ctx, int *hadLastLock) +static int +grabDecoder(ViaXvMCContext * ctx, int *hadLastLock) { - volatile ViaXvMCSAreaPriv *sAPriv = SAREAPTR(ctx); + volatile ViaXvMCSAreaPriv *sAPriv = SAREAPTR(ctx); int retFtx, lc; /* @@ -131,68 +130,71 @@ static int grabDecoder( ViaXvMCContext *ctx, int *hadLastLock) */ if (ctx->haveDecoder) { - flushXvMCLowLevel(ctx->xl); /* Ignore errors here. */ - + flushXvMCLowLevel(ctx->xl); /* Ignore errors here. */ + /*fprintf(stderr,"ViaXvMC: ERROR: Trying to re-lock decoder.\n"); */ *hadLastLock = 1; - return 0; + return 0; } - UNICHROME_LOCK(ctx->fd, UNICHROME_LOCK_DECODER1, sAPriv, ctx->drmcontext, lc, - retFtx); + 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[]) + +static void +setupAttribDesc(Display * display, XvPortID port, + const ViaXvMCAttrHolder * attrib, XvAttribute attribDesc[]) { - XvAttribute *XvAttribs,*curAD; + XvAttribute *XvAttribs, *curAD; int num; - unsigned i,j; + unsigned i, j; XLockDisplay(display); XvAttribs = XvQueryPortAttributes(display, port, &num); - for(i=0; i<attrib->numAttr; ++i) { + 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)) { + 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); + if (XvAttribs) + XFree(XvAttribs); XUnlockDisplay(display); } -static void releaseAttribDesc(int numAttr, XvAttribute attribDesc[]) +static void +releaseAttribDesc(int numAttr, XvAttribute attribDesc[]) { int i; - for (i=0; i<numAttr; ++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) + +static Status +releaseContextResources(Display * display, XvMCContext * context, + int freePrivate, Status errType) { ViaXvMCContext *pViaXvMC = (ViaXvMCContext *) context->privData; - switch(pViaXvMC->resources) { + switch (pViaXvMC->resources) { case context_drawHash: - driDestroyHashContents( pViaXvMC->drawHash ); - drmHashDestroy( pViaXvMC->drawHash ); + driDestroyHashContents(pViaXvMC->drawHash); + drmHashDestroy(pViaXvMC->drawHash); case context_lowLevel: closeXvMCLowLevel(pViaXvMC->xl); case context_mutex: @@ -204,13 +206,13 @@ static Status releaseContextResources(Display *display, XvMCContext *context, case context_sAreaMap: numContexts--; if (numContexts == 0) - drmUnmap(pViaXvMC->sAreaAddress,pViaXvMC->sAreaSize); + drmUnmap(pViaXvMC->sAreaAddress, pViaXvMC->sAreaSize); case context_fbMap: if (numContexts == 0) - drmUnmap(pViaXvMC->fbAddress,pViaXvMC->fbSize); + drmUnmap(pViaXvMC->fbAddress, pViaXvMC->fbSize); case context_mmioMap: if (numContexts == 0) - drmUnmap(pViaXvMC->mmioAddress,pViaXvMC->mmioSize); + drmUnmap(pViaXvMC->mmioAddress, pViaXvMC->mmioSize); case context_fd: if (numContexts == 0) { if (pViaXvMC->fd >= 0) @@ -227,17 +229,20 @@ static Status releaseContextResources(Display *display, XvMCContext *context, XLockDisplay(display); _xvmc_destroy_context(display, context); XUnlockDisplay(display); - if (!freePrivate) break; + if (!freePrivate) + break; default: free(pViaXvMC); + context->privData = NULL; } return errType; } -Status XvMCCreateContext(Display *display, XvPortID port, - int surface_type_id, int width, int height, int flags, - XvMCContext *context) -{ +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; @@ -254,12 +259,12 @@ Status XvMCCreateContext(Display *display, XvPortID port, * Verify Obvious things first */ - if(context == NULL) { + if (context == NULL) { return XvMCBadContext; } - if(!(flags & XVMC_DIRECT)) { - fprintf(stderr,"Indirect Rendering not supported! Using Direct.\n"); + if (!(flags & XVMC_DIRECT)) { + fprintf(stderr, "Indirect Rendering not supported! Using Direct.\n"); } /* @@ -280,20 +285,19 @@ Status XvMCCreateContext(Display *display, XvPortID port, /* Allocate private Context data */ context->privData = (void *)malloc(sizeof(ViaXvMCContext)); - if(!context->privData) { - fprintf(stderr,"Unable to allocate resources for XvMC context.\n"); + if (!context->privData) { + fprintf(stderr, "Unable to allocate resources for XvMC context.\n"); return BadAlloc; } - - pViaXvMC = (ViaXvMCContext *)context->privData; + + 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"); + if (!XvMCQueryExtension(display, &event_base, &error_base)) { + fprintf(stderr, "XvMC Extension is not available!\n"); free(pViaXvMC); XUnlockDisplay(display); return BadAlloc; @@ -301,20 +305,20 @@ Status XvMCCreateContext(Display *display, XvPortID port, /* Verify XvMC version */ ret = XvMCQueryVersion(display, &major, &minor); - if(ret) { - fprintf(stderr,"XvMCQuery Version Failed, unable to determine " - "protocol version!\n"); + 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); + 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); @@ -322,13 +326,12 @@ Status XvMCCreateContext(Display *display, XvPortID port, * 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); + 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); } @@ -336,8 +339,8 @@ Status XvMCCreateContext(Display *display, XvPortID port, 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"); + 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); } @@ -369,62 +372,65 @@ Status XvMCCreateContext(Display *display, XvPortID port, * 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); + ret = + uniDRIQueryDirectRenderingCapable(display, pViaXvMC->screen, + &isCapable); if (!ret || !isCapable) { XUnlockDisplay(display); - fprintf(stderr,"Direct Rendering is not available on this system!\n"); + 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)) { + if (!uniDRIOpenConnection(display, pViaXvMC->screen, + &pViaXvMC->sAreaOffset, &curBusID)) { XUnlockDisplay(display); - fprintf(stderr,"Could not open DRI connection to X server!\n"); + 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'; + strncpy(pViaXvMC->busIdString, curBusID, 20); + pViaXvMC->busIdString[20] = '\0'; XFree(curBusID); - pViaXvMC->resources = context_driConnection; + pViaXvMC->resources = context_driConnection; - if((pViaXvMC->fd = drmOpen("via",pViaXvMC->busIdString)) < 0) { - fprintf(stderr,"DRM Device for via could not be opened.\n"); + 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."); + 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); + 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); - + 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"); + fprintf(stderr, + "viaXvMC: X server did not allow DRI. Check permissions.\n"); XFree(priv_data); return releaseContextResources(display, context, 1, BadAlloc); } @@ -434,11 +440,12 @@ Status XvMCCreateContext(Display *display, XvPortID port, * 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"); + 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; @@ -446,24 +453,23 @@ Status XvMCCreateContext(Display *display, XvPortID port, * Map Framebuffer memory */ - if(drmMap(pViaXvMC->fd,pViaXvMC->fbOffset, - pViaXvMC->fbSize,&fbAddress) < 0) { - fprintf(stderr,"Unable to map XvMC Framebuffer.\n"); + 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"); + 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; @@ -480,25 +486,27 @@ Status XvMCCreateContext(Display *display, XvPortID port, */ XLockDisplay(display); - ret = XMatchVisualInfo(display, pViaXvMC->screen, - (pViaXvMC->depth == 32) ? 24 : pViaXvMC->depth, TrueColor, - &pViaXvMC->visualInfo); + 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"); + 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)) { - 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) { + for (i = 0; i < VIA_MAX_RENDSURF; ++i) { pViaXvMC->rendSurf[i] = 0; } pViaXvMC->lastSrfDisplaying = ~0; @@ -513,54 +521,52 @@ Status XvMCCreateContext(Display *display, XvPortID port, pViaXvMC->attribChanged = 1; pViaXvMC->haveXv = 0; pViaXvMC->port = context->port; - pthread_mutex_init(&pViaXvMC->ctxMutex,NULL); + 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); + 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))) { + 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"); + 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"); + 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); + hwlLock(pViaXvMC->xl, 1); + setLowLevelLocking(pViaXvMC->xl, 0); viaVideoSubPictureOffLocked(pViaXvMC->xl); - flushXvMCLowLevel(pViaXvMC->xl); - setLowLevelLocking(pViaXvMC->xl,1); - hwlUnlock(pViaXvMC->xl,1); + flushXvMCLowLevel(pViaXvMC->xl); + setLowLevelLocking(pViaXvMC->xl, 1); + hwlUnlock(pViaXvMC->xl, 1); } return Success; } - -Status XvMCDestroyContext(Display *display, XvMCContext *context) +Status +XvMCDestroyContext(Display * display, XvMCContext * context) { ViaXvMCContext *pViaXvMC; - - if(context == NULL) { + if (context == NULL) { return (error_base + XvMCBadContext); } - if(NULL == (pViaXvMC = context->privData)) { + if (NULL == (pViaXvMC = context->privData)) { return (error_base + XvMCBadContext); } @@ -569,13 +575,14 @@ Status XvMCDestroyContext(Display *display, XvMCContext *context) * before XvMCDestroyContext, the X server will take care of this. */ - releaseAttribDesc(pViaXvMC->attrib.numAttr,pViaXvMC->attribDesc); - releaseDecoder(pViaXvMC,1); + releaseAttribDesc(pViaXvMC->attrib.numAttr, pViaXvMC->attribDesc); + releaseDecoder(pViaXvMC, 1); return releaseContextResources(display, context, 1, Success); } -Status XvMCCreateSurface( Display *display, XvMCContext *context, - XvMCSurface *surface) +Status +XvMCCreateSurface(Display * display, XvMCContext * context, + XvMCSurface * surface) { ViaXvMCContext *pViaXvMC; ViaXvMCSurface *pViaSurface; @@ -584,30 +591,31 @@ Status XvMCCreateSurface( Display *display, XvMCContext *context, unsigned i; Status ret; - if((surface == NULL) || (context == NULL) || (display == NULL)){ + 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 ); + 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 ); + 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))) { + 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 ); + fprintf(stderr, "Unable to create XvMC Surface.\n"); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return ret; } XUnlockDisplay(display); @@ -620,12 +628,11 @@ Status XvMCCreateSurface( Display *display, XvMCContext *context, */ pViaSurface->numBuffers = priv_data[1]; - for (i=0; i < pViaSurface->numBuffers; ++i) { - pViaSurface->offsets[i] = priv_data[i+2]; + 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); @@ -636,25 +643,26 @@ Status XvMCCreateSurface( Display *display, XvMCContext *context, pViaSurface->privContext = pViaXvMC; pViaSurface->privSubPic = NULL; pViaSurface->needsSync = 0; - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } -Status XvMCDestroySurface(Display *display, XvMCSurface *surface) +Status +XvMCDestroySurface(Display * display, XvMCSurface * surface) { ViaXvMCSurface *pViaSurface; - if((display == NULL) || (surface == NULL)) { + if ((display == NULL) || (surface == NULL)) { return BadValue; } - if(surface->privData == NULL) { + if (surface->privData == NULL) { return (error_base + XvMCBadSurface); } - pViaSurface = (ViaXvMCSurface *)surface->privData; + pViaSurface = (ViaXvMCSurface *) surface->privData; XLockDisplay(display); - _xvmc_destroy_surface(display,surface); + _xvmc_destroy_surface(display, surface); XUnlockDisplay(display); free(pViaSurface); @@ -662,93 +670,94 @@ Status XvMCDestroySurface(Display *display, XvMCSurface *surface) return Success; } -Status XvMCPutSlice2(Display *display,XvMCContext *context, char *slice, - int nBytes, int sliceCode) +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)) { + if ((display == NULL) || (context == NULL)) { return BadValue; } - if(NULL == (pViaXvMC = context->privData)) { + if (NULL == (pViaXvMC = context->privData)) { return (error_base + XvMCBadContext); } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); if (!pViaXvMC->haveDecoder) { - fprintf(stderr,"XvMCPutSlice: This context does not own decoder!\n"); - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + fprintf(stderr, "XvMCPutSlice: This context does not own decoder!\n"); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return BadAlloc; } - viaMpegWriteSlice(pViaXvMC->xl, (CARD8 *)slice, nBytes, sCode); + viaMpegWriteSlice(pViaXvMC->xl, (CARD8 *) slice, nBytes, sCode); - flushPCIXvMCLowLevel(pViaXvMC->xl); - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + flushPCIXvMCLowLevel(pViaXvMC->xl); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } -Status XvMCPutSlice(Display *display,XvMCContext *context, char *slice, - int nBytes) +Status +XvMCPutSlice(Display * display, XvMCContext * context, char *slice, + int nBytes) { ViaXvMCContext *pViaXvMC; - if((display == NULL) || (context == NULL)) { + if ((display == NULL) || (context == NULL)) { return BadValue; } - if(NULL == (pViaXvMC = context->privData)) { + if (NULL == (pViaXvMC = context->privData)) { return (error_base + XvMCBadContext); } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); if (!pViaXvMC->haveDecoder) { - fprintf(stderr,"XvMCPutSlice: This context does not own decoder!\n"); - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + fprintf(stderr, "XvMCPutSlice: This context does not own decoder!\n"); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return BadAlloc; } - viaMpegWriteSlice(pViaXvMC->xl, (CARD8 *)slice, nBytes, 0); + viaMpegWriteSlice(pViaXvMC->xl, (CARD8 *) slice, nBytes, 0); flushPCIXvMCLowLevel(pViaXvMC->xl); - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + 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) +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->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) ? + + 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 ) + 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))) { + if ((ret = XvPutImage(display, pViaXvMC->port, draw, pViaXvMC->gc, + pViaXvMC->xvImage, srcx, srcy, srcw, srch, + destx, desty, destw, desth))) { XUnlockDisplay(display); return ret; } @@ -758,11 +767,11 @@ static Status updateXVOverlay(Display *display,ViaXvMCContext *pViaXvMC, 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) +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 @@ -787,27 +796,26 @@ Status XvMCPutSurface(Display *display,XvMCSurface *surface,Drawable draw, XvMCRegion sReg, dReg; Bool forceUpdate = FALSE; - if((display == NULL) || (surface == NULL)) { + if ((display == NULL) || (surface == NULL)) { return BadValue; } - if(NULL == (pViaSurface = surface->privData )) { + if (NULL == (pViaSurface = surface->privData)) { return (error_base + XvMCBadSurface); } if (NULL == (pViaXvMC = pViaSurface->privContext)) { return (error_base + XvMCBadContext); } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); pViaSubPic = pViaSurface->privSubPic; - sAPriv = SAREAPTR( pViaXvMC ); + 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. */ @@ -816,21 +824,19 @@ Status XvMCPutSurface(Display *display,XvMCSurface *surface,Drawable draw, 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))) { + 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 ); + hwlUnlock(pViaXvMC->xl, 1); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return BadAccess; } - setLowLevelLocking(pViaXvMC->xl,0); - + setLowLevelLocking(pViaXvMC->xl, 0); /* * Put a surface ID in the SAREA to "authenticate" to the @@ -839,118 +845,122 @@ Status XvMCPutSurface(Display *display,XvMCSurface *surface,Drawable draw, dispSurface = sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort]; lastSurface = pViaXvMC->lastSrfDisplaying; - sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort] = + 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); + 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); + 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); + ret = + updateXVOverlay(display, pViaXvMC, pViaSurface, draw, srcx, srcy, + srcw, srch, destx, desty, destw, desth); if (ret) { - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return ret; } - hwlLock(pViaXvMC->xl,1); + 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 ); + 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); + + 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] + if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] != (pViaSubPic->srfNo | VIA_XVMC_VALID)) { - 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); + viaVideoSWFlipLocked(pViaXvMC->xl, flags, + pViaSurface->progressiveSequence); + flushXvMCLowLevel(pViaXvMC->xl); - setLowLevelLocking(pViaXvMC->xl,1); - hwlUnlock(pViaXvMC->xl,1); + setLowLevelLocking(pViaXvMC->xl, 1); + hwlUnlock(pViaXvMC->xl, 1); - if (overlayUpdated || !drawInfo->touched ) { - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + 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 ); + 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) +Status +XvMCBeginSurface(Display * display, + XvMCContext * context, + XvMCSurface * target_surface, + XvMCSurface * past_surface, + XvMCSurface * future_surface, const XvMCMpegControl * control) { - ViaXvMCSurface *targS,*futS,*pastS; + ViaXvMCSurface *targS, *futS, *pastS; ViaXvMCContext *pViaXvMC; int hadDecoderLast; CARD32 timeStamp; - if((display == NULL) || (context == NULL) || (target_surface == NULL)) { + if ((display == NULL) || (context == NULL) || (target_surface == NULL)) { return BadValue; } - - pViaXvMC = context->privData; - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + pViaXvMC = context->privData; + + ppthread_mutex_lock(&pViaXvMC->ctxMutex); if (grabDecoder(pViaXvMC, &hadDecoderLast)) { - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); - return BadAlloc; + 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 @@ -959,17 +969,17 @@ Status XvMCBeginSurface(Display *display, */ if (pViaXvMC->useAGP) { - if (!hadDecoderLast || pViaXvMC->timeStamp == 0) { + if (!hadDecoderLast || pViaXvMC->timeStamp == 0) { timeStamp = viaDMATimeStampLowLevel(pViaXvMC->xl); if (flushXvMCLowLevel(pViaXvMC->xl)) { - releaseDecoder(pViaXvMC, 0); - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + releaseDecoder(pViaXvMC, 0); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return BadAlloc; - } + } pViaXvMC->timeStamp = timeStamp; } else { timeStamp = pViaXvMC->timeStamp; - } + } setAGPSyncLowLevel(pViaXvMC->xl, 1, timeStamp); } @@ -980,96 +990,96 @@ Status XvMCBeginSurface(Display *display, viaMpegReset(pViaXvMC->xl); - targS = (ViaXvMCSurface *)target_surface->privData; + 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 = (ViaXvMCSurface *) future_surface->privData; futS->needsSync = 0; } - if (past_surface) { - pastS = (ViaXvMCSurface *)past_surface->privData; + 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)); + 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)); + viaMpegSetFB(pViaXvMC->xl, 1, yOffs(pastS), uOffs(pastS), + vOffs(pastS)); } else { - viaMpegSetFB(pViaXvMC->xl,1,0,0,0); + viaMpegSetFB(pViaXvMC->xl, 1, 0, 0, 0); } - + if (future_surface) { - viaMpegSetFB(pViaXvMC->xl,2,yOffs(futS),uOffs(futS),vOffs(futS)); + viaMpegSetFB(pViaXvMC->xl, 2, yOffs(futS), uOffs(futS), vOffs(futS)); } else { - viaMpegSetFB(pViaXvMC->xl,2,0,0,0); + viaMpegSetFB(pViaXvMC->xl, 2, 0, 0, 0); } - viaMpegBeginPicture(pViaXvMC->xl,pViaXvMC,context->width,context->height,control); + 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 ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } - - -Status XvMCSyncSurface(Display *display,XvMCSurface *surface) + +Status +XvMCSyncSurface(Display * display, XvMCSurface * surface) { ViaXvMCSurface *pViaSurface; ViaXvMCContext *pViaXvMC; unsigned i; - if((display == NULL) || (surface == NULL)) { + if ((display == NULL) || (surface == NULL)) { return BadValue; } - if(surface->privData == NULL) { + if (surface->privData == NULL) { return (error_base + XvMCBadSurface); } - - pViaSurface = (ViaXvMCSurface *)surface->privData; + + pViaSurface = (ViaXvMCSurface *) surface->privData; pViaXvMC = pViaSurface->privContext; - if(pViaXvMC == NULL) { + if (pViaXvMC == NULL) { return (error_base + XvMCBadSurface); } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); if (pViaSurface->needsSync) { - CARD32 timeStamp = pViaSurface->timeStamp; + CARD32 timeStamp = pViaSurface->timeStamp; int syncMode = pViaSurface->syncMode; if (pViaXvMC->useAGP) { - syncMode = (pViaSurface->syncMode == LL_MODE_2D || - pViaSurface->timeStamp < pViaXvMC->timeStamp) ? + 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; + if (pViaSurface->syncMode != LL_MODE_2D) + timeStamp = pViaXvMC->timeStamp; - } else if (syncMode != LL_MODE_2D && - pViaXvMC->rendSurf[0] != (pViaSurface->srfNo | VIA_XVMC_VALID)) { + } else if (syncMode != LL_MODE_2D && + pViaXvMC->rendSurf[0] != (pViaSurface->srfNo | VIA_XVMC_VALID)) { - pViaSurface->needsSync = 0; - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); - return Success; + pViaSurface->needsSync = 0; + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); + return Success; } - if (syncXvMCLowLevel(pViaXvMC->xl, syncMode, 1, - pViaSurface->timeStamp)) { - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + if (syncXvMCLowLevel(pViaXvMC->xl, syncMode, 1, + pViaSurface->timeStamp)) { + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return BadValue; } pViaSurface->needsSync = 0; @@ -1077,123 +1087,112 @@ Status XvMCSyncSurface(Display *display,XvMCSurface *surface) if (pViaXvMC->rendSurf[0] == (pViaSurface->srfNo | VIA_XVMC_VALID)) { pViaSurface->needsSync = 0; - for (i=0; i<VIA_MAX_RENDSURF; ++i) { + for (i = 0; i < VIA_MAX_RENDSURF; ++i) { pViaXvMC->rendSurf[i] = 0; } } - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } -Status XvMCLoadQMatrix(Display *display, XvMCContext *context, - const XvMCQMatrix *qmx) -{ - ViaXvMCContext - *pViaXvMC; +Status +XvMCLoadQMatrix(Display * display, XvMCContext * context, + const XvMCQMatrix * qmx) +{ + ViaXvMCContext * pViaXvMC; - if((display == NULL) || (context == NULL)) { + if ((display == NULL) || (context == NULL)) { return BadValue; } - if(NULL == (pViaXvMC = context->privData)) { + if (NULL == (pViaXvMC = context->privData)) { return (error_base + XvMCBadContext); } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + 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)); + 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)); + 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)); + 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)); + qmx->chroma_non_intra_quantiser_matrix, + sizeof(qmx->chroma_non_intra_quantiser_matrix)); pViaXvMC->chromaNonIntraLoaded = 0; } - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + 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, + (Display * display, + XvMCContext * context, unsigned int picture_structure, - XvMCSurface *target_surface, - XvMCSurface *past_surface, - XvMCSurface *future_surface, + 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 - ) + XvMCMacroBlockArray * macroblock_array, XvMCBlockArray * blocks) { return (error_base + XvMCBadContext); } -Status XvMCCreateBlocks -( - Display *display, - XvMCContext *context, - unsigned int num_blocks, - XvMCBlockArray * block - ) +Status XvMCCreateBlocks + (Display * display, + XvMCContext * context, unsigned int num_blocks, XvMCBlockArray * block) { return (error_base + XvMCBadContext); } -Status XvMCDestroyBlocks (Display *display, XvMCBlockArray * block) +Status +XvMCDestroyBlocks(Display * display, XvMCBlockArray * block) { return Success; } -Status XvMCCreateMacroBlocks -( - Display *display, - XvMCContext *context, - unsigned int num_blocks, - XvMCMacroBlockArray * blocks - ) +Status XvMCCreateMacroBlocks + (Display * display, + XvMCContext * context, + unsigned int num_blocks, XvMCMacroBlockArray * blocks) { return (error_base + XvMCBadContext); } -Status XvMCDestroyMacroBlocks(Display *display, XvMCMacroBlockArray * block) +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) +Status +XvMCCreateSubpicture(Display * display, + XvMCContext * context, + XvMCSubpicture * subpicture, + unsigned short width, unsigned short height, int xvimage_id) { ViaXvMCContext *pViaXvMC; ViaXvMCSubPicture *pViaSubPic; @@ -1201,42 +1200,41 @@ Status XvMCCreateSubpicture( Display *display, unsigned *priv_data; Status ret; - if((subpicture == NULL) || (context == NULL) || (display == NULL)){ + if ((subpicture == NULL) || (context == NULL) || (display == NULL)) { return BadValue; } - - pViaXvMC = (ViaXvMCContext *)context->privData; - if(pViaXvMC == NULL) { + + pViaXvMC = (ViaXvMCContext *) context->privData; + if (pViaXvMC == NULL) { return (error_base + XvMCBadContext); } subpicture->privData = (ViaXvMCSubPicture *) malloc(sizeof(ViaXvMCSubPicture)); - if(!subpicture->privData) { + if (!subpicture->privData) { return BadAlloc; } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); subpicture->width = context->width; subpicture->height = context->height; subpicture->xvimage_id = xvimage_id; - pViaSubPic = (ViaXvMCSubPicture *)subpicture->privData; + pViaSubPic = (ViaXvMCSubPicture *) subpicture->privData; XLockDisplay(display); - if((ret = _xvmc_create_subpicture(display, context, subpicture, - &priv_count, &priv_data))) { + 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 ); + 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); + strncpy(subpicture->component_order, "YUV", 4); pViaSubPic->srfNo = priv_data[0]; pViaSubPic->offset = priv_data[1]; pViaSubPic->stride = (subpicture->width + 31) & ~31; @@ -1247,28 +1245,28 @@ Status XvMCCreateSubpicture( Display *display, /* Free data returned from _xvmc_create_subpicture */ XFree(priv_data); - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } Status -XvMCSetSubpicturePalette (Display *display, XvMCSubpicture *subpicture, - unsigned char *palette) -{ +XvMCSetSubpicturePalette(Display * display, XvMCSubpicture * subpicture, + unsigned char *palette) +{ ViaXvMCSubPicture *pViaSubPic; ViaXvMCContext *pViaXvMC; volatile ViaXvMCSAreaPriv *sAPriv; unsigned i; CARD32 tmp; - if((subpicture == NULL) || (display == NULL)){ + if ((subpicture == NULL) || (display == NULL)) { return BadValue; } - if(subpicture->privData == NULL) { + if (subpicture->privData == NULL) { return (error_base + XvMCBadSubpicture); } pViaSubPic = (ViaXvMCSubPicture *) subpicture->privData; - for (i=0; i < VIA_SUBPIC_PALETTE_SIZE; ++i) { + for (i = 0; i < VIA_SUBPIC_PALETTE_SIZE; ++i) { tmp = *palette++ << 8; tmp |= *palette++ << 16; tmp |= *palette++ << 24; @@ -1277,42 +1275,39 @@ XvMCSetSubpicturePalette (Display *display, XvMCSubpicture *subpicture, } pViaXvMC = pViaSubPic->privContext; - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); - sAPriv = SAREAPTR( pViaXvMC ); - hwlLock(pViaXvMC->xl,1); - setLowLevelLocking(pViaXvMC->xl,0); + 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] == + if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] == (pViaSubPic->srfNo | VIA_XVMC_VALID)) { - viaVideoSubPictureLocked(pViaXvMC->xl,pViaSubPic); + viaVideoSubPictureLocked(pViaXvMC->xl, pViaSubPic); } flushPCIXvMCLowLevel(pViaXvMC->xl); - setLowLevelLocking(pViaXvMC->xl,1); - hwlUnlock(pViaXvMC->xl,1); - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + 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) +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; - + int w, h; + unsigned mWidth, mHeight; + w = *areaW; h = *areaH; - if ((*dstX >= width) || (*dstY >= height)) + if ((*dstX >= width) || (*dstY >= height)) return 1; if (*dstX < 0) { w += *dstX; @@ -1324,175 +1319,155 @@ static int findOverlap(unsigned width,unsigned height, *srcY -= *dstY; *dstY = 0; } - if ((w <= 0) || ((h <= 0))) + if ((w <= 0) || ((h <= 0))) return 1; mWidth = width - *dstX; mHeight = height - *dstY; *areaW = (w <= mWidth) ? w : mWidth; - *areaH = (h <= mHeight) ? h : mHeight; + *areaH = (h <= mHeight) ? h : mHeight; return 0; } - - -Status XvMCClearSubpicture ( - Display *display, - XvMCSubpicture *subpicture, +Status +XvMCClearSubpicture(Display * display, + XvMCSubpicture * subpicture, short x, - short y, - unsigned short width, - unsigned short height, - unsigned int color - ) + short y, unsigned short width, unsigned short height, unsigned int color) { ViaXvMCContext *pViaXvMC; ViaXvMCSubPicture *pViaSubPic; - short dummyX,dummyY; + short dummyX, dummyY; unsigned long bOffs; - if((subpicture == NULL) || (display == NULL)) { + if ((subpicture == NULL) || (display == NULL)) { return BadValue; } - if(subpicture->privData == NULL) { + if (subpicture->privData == NULL) { return (error_base + XvMCBadSubpicture); } pViaSubPic = (ViaXvMCSubPicture *) subpicture->privData; pViaXvMC = pViaSubPic->privContext; - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + 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 ); + &dummyX, &dummyY, &width, &height)) { + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } - - bOffs = pViaSubPic->offset + y*pViaSubPic->stride + x; + + bOffs = pViaSubPic->offset + y * pViaSubPic->stride + x; viaBlit(pViaXvMC->xl, 8, 0, pViaSubPic->stride, bOffs, pViaSubPic->stride, - width, height, 1, 1, VIABLIT_FILL, color); + width, height, 1, 1, VIABLIT_FILL, color); pViaSubPic->needsSync = 1; pViaSubPic->timeStamp = viaDMATimeStampLowLevel(pViaXvMC->xl); if (flushXvMCLowLevel(pViaXvMC->xl)) { - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return BadValue; } - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } Status -XvMCCompositeSubpicture ( - Display *display, - XvMCSubpicture *subpicture, - XvImage *image, +XvMCCompositeSubpicture(Display * display, + XvMCSubpicture * subpicture, + XvImage * image, short srcx, short srcy, - unsigned short width, - unsigned short height, - short dstx, - short dsty - ) + 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)){ + if ((subpicture == NULL) || (display == NULL) || (image == NULL)) { return BadValue; } - if(NULL == (pViaSubPic = (ViaXvMCSubPicture *)subpicture->privData)) { + if (NULL == (pViaSubPic = (ViaXvMCSubPicture *) subpicture->privData)) { return (error_base + XvMCBadSubpicture); } pViaXvMC = pViaSubPic->privContext; - - if (image->id != subpicture->xvimage_id) + if (image->id != subpicture->xvimage_id) return BadMatch; - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); - + 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 ); + 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 ); + 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 ); + 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); + 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 ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } - - Status -XvMCBlendSubpicture ( - Display *display, - XvMCSurface *target_surface, - XvMCSubpicture *subpicture, +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 - ) -{ + short surfx, short surfy, unsigned short surfw, unsigned short surfh) +{ ViaXvMCSurface *pViaSurface; ViaXvMCSubPicture *pViaSubPic; - if((display == NULL) || target_surface == NULL){ + 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"); + + 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)) { + if (NULL == (pViaSurface = target_surface->privData)) { return (error_base + XvMCBadSurface); } if (subpicture) { - if(NULL == (pViaSubPic = subpicture->privData)) { + if (NULL == (pViaSubPic = subpicture->privData)) { return (error_base + XvMCBadSubpicture); } - + pViaSurface->privSubPic = pViaSubPic; } else { pViaSurface->privSubPic = NULL; @@ -1501,43 +1476,37 @@ XvMCBlendSubpicture ( } Status -XvMCBlendSubpicture2 ( - Display *display, - XvMCSurface *source_surface, - XvMCSurface *target_surface, - XvMCSubpicture *subpicture, +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; + short surfx, short surfy, unsigned short surfw, unsigned short surfh) +{ + ViaXvMCSurface *pViaSurface, *pViaSSurface; ViaXvMCSubPicture *pViaSubPic; ViaXvMCContext *pViaXvMC; - unsigned width,height; + unsigned width, height; - if((display == NULL) || target_surface == NULL || source_surface == NULL){ + 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"); + + 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)) { + if (NULL == (pViaSurface = target_surface->privData)) { return (error_base + XvMCBadSurface); } - if(NULL == (pViaSSurface = source_surface->privData)) { + if (NULL == (pViaSSurface = source_surface->privData)) { return (error_base + XvMCBadSurface); } pViaXvMC = pViaSurface->privContext; @@ -1547,200 +1516,199 @@ XvMCBlendSubpicture2 ( return BadMatch; } - if (XvMCSyncSurface(display,source_surface)) { - return BadValue; + if (XvMCSyncSurface(display, source_surface)) { + return BadValue; } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); viaBlit(pViaXvMC->xl, 8, yOffs(pViaSSurface), pViaSSurface->yStride, - yOffs(pViaSurface), pViaSurface->yStride, - width, height, 1, 1, VIABLIT_COPY, 0); + 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); + + 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); + 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); + 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 ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return BadValue; } if (subpicture) { - if(NULL == (pViaSubPic = subpicture->privData)) { - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + 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 ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } - Status -XvMCSyncSubpicture (Display *display, XvMCSubpicture *subpicture) +XvMCSyncSubpicture(Display * display, XvMCSubpicture * subpicture) { ViaXvMCSubPicture *pViaSubPic; ViaXvMCContext *pViaXvMC; - Status retVal=0; + Status retVal = 0; - if((display == NULL) || subpicture == NULL){ + if ((display == NULL) || subpicture == NULL) { return BadValue; } - if(NULL == (pViaSubPic = subpicture->privData)) { + if (NULL == (pViaSubPic = subpicture->privData)) { return (error_base + XvMCBadSubpicture); } pViaXvMC = pViaSubPic->privContext; - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); if (pViaSubPic->needsSync) { - if (syncXvMCLowLevel(pViaXvMC->xl, LL_MODE_2D, - 0, pViaSubPic->timeStamp)) { + if (syncXvMCLowLevel(pViaXvMC->xl, LL_MODE_2D, + 0, pViaSubPic->timeStamp)) { retVal = BadValue; } pViaSubPic->needsSync = 0; } - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return retVal; } Status -XvMCFlushSubpicture (Display *display, XvMCSubpicture *subpicture) +XvMCFlushSubpicture(Display * display, XvMCSubpicture * subpicture) { ViaXvMCSubPicture *pViaSubPic; - if((display == NULL) || subpicture == NULL){ + if ((display == NULL) || subpicture == NULL) { return BadValue; } - if(NULL == (pViaSubPic = subpicture->privData)) { + if (NULL == (pViaSubPic = subpicture->privData)) { return (error_base + XvMCBadSubpicture); } - + return Success; } Status -XvMCDestroySubpicture (Display *display, XvMCSubpicture *subpicture) +XvMCDestroySubpicture(Display * display, XvMCSubpicture * subpicture) { ViaXvMCSubPicture *pViaSubPic; ViaXvMCContext *pViaXvMC; volatile ViaXvMCSAreaPriv *sAPriv; - if((display == NULL) || subpicture == NULL){ + if ((display == NULL) || subpicture == NULL) { return BadValue; } - if(NULL == (pViaSubPic = subpicture->privData)) { + if (NULL == (pViaSubPic = subpicture->privData)) { return (error_base + XvMCBadSubpicture); } pViaXvMC = pViaSubPic->privContext; - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + 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); + 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); + setLowLevelLocking(pViaXvMC->xl, 1); + hwlUnlock(pViaXvMC->xl, 1); XLockDisplay(display); - _xvmc_destroy_subpicture(display,subpicture); + _xvmc_destroy_subpicture(display, subpicture); XUnlockDisplay(display); free(pViaSubPic); subpicture->privData = NULL; - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } Status -XvMCGetSubpictureStatus (Display *display, XvMCSubpicture *subpic, int *stat) +XvMCGetSubpictureStatus(Display * display, XvMCSubpicture * subpic, int *stat) { ViaXvMCSubPicture *pViaSubPic; ViaXvMCContext *pViaXvMC; volatile ViaXvMCSAreaPriv *sAPriv; - - if((display == NULL) || subpic == NULL){ + if ((display == NULL) || subpic == NULL) { return BadValue; } - if(NULL == (pViaSubPic = subpic->privData)) { + 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; + sAPriv = SAREAPTR(pViaXvMC); + if (sAPriv->XvMCSubPicOn[pViaXvMC->xvMCPort] == + (pViaSubPic->srfNo | VIA_XVMC_VALID)) + *stat |= XVMC_DISPLAYING; } return Success; } Status -XvMCFlushSurface (Display *display, XvMCSurface *surface) +XvMCFlushSurface(Display * display, XvMCSurface * surface) { ViaXvMCSurface *pViaSurface; ViaXvMCContext *pViaXvMC; Status ret; - if((display == NULL) || surface == NULL){ + if ((display == NULL) || surface == NULL) { return BadValue; } - if(NULL == (pViaSurface = surface->privData)) { + 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); + 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); + hwlLock(pViaXvMC->xl, 0); pViaXvMC->haveDecoder = 0; releaseDecoder(pViaXvMC, 0); - hwlUnlock(pViaXvMC->xl,0); + hwlUnlock(pViaXvMC->xl, 0); } - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return ret; } Status -XvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat) +XvMCGetSurfaceStatus(Display * display, XvMCSurface * surface, int *stat) { ViaXvMCSurface *pViaSurface; ViaXvMCContext *pViaXvMC; @@ -1748,38 +1716,34 @@ XvMCGetSurfaceStatus (Display *display, XvMCSurface *surface, int *stat) unsigned i; int ret = 0; - if((display == NULL) || surface == NULL){ + if ((display == NULL) || surface == NULL) { return BadValue; } - if(NULL == (pViaSurface = surface->privData)) { + 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)) + 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)) { + 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 ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); } return ret; } XvAttribute * -XvMCQueryAttributes ( - Display *display, - XvMCContext *context, - int *number - ) +XvMCQueryAttributes(Display * display, XvMCContext * context, int *number) { ViaXvMCContext *pViaXvMC; XvAttribute *ret; @@ -1789,51 +1753,47 @@ XvMCQueryAttributes ( if ((display == NULL) || (context == NULL)) { return NULL; } - + if (NULL == (pViaXvMC = context->privData)) { return NULL; } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + 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; + malloc(siz = VIA_NUM_XVMC_ATTRIBUTES * sizeof(XvAttribute)))) { + memcpy(ret, pViaXvMC->attribDesc, siz); + *number = VIA_NUM_XVMC_ATTRIBUTES; } - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); - return ret; + return ret; } Status -XvMCSetAttribute ( - Display *display, - XvMCContext *context, - Atom attribute, - int value - ) +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 ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); found = 0; - for (i=0; i < pViaXvMC->attrib.numAttr; ++i) { + 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) + value > pViaXvMC->attribDesc[i].max_value) return BadValue; pViaXvMC->attrib.attributes[i].value = value; found = 1; @@ -1842,7 +1802,7 @@ XvMCSetAttribute ( } } if (!found) { - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return BadMatch; } if (pViaXvMC->haveXv) { @@ -1851,40 +1811,34 @@ XvMCSetAttribute ( 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); + 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 ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } - Status -XvMCGetAttribute ( - Display *display, - XvMCContext *context, - Atom attribute, - int *value - ) +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 ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); found = 0; - for (i=0; i < pViaXvMC->attrib.numAttr; ++i) { + 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; @@ -1893,15 +1847,15 @@ XvMCGetAttribute ( } } } - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); - if (!found) + if (!found) return BadMatch; return Success; } - -Status XvMCHideSurface(Display *display,XvMCSurface *surface) +Status +XvMCHideSurface(Display * display, XvMCSurface * surface) { ViaXvMCSurface *pViaSurface; @@ -1914,51 +1868,50 @@ Status XvMCHideSurface(Display *display,XvMCSurface *surface) if ((display == NULL) || (surface == NULL)) { return BadValue; } - if (NULL == (pViaSurface = surface->privData )) { + if (NULL == (pViaSurface = surface->privData)) { return (error_base + XvMCBadSurface); } if (NULL == (pViaXvMC = pViaSurface->privContext)) { return (error_base + XvMCBadContext); } - ppthread_mutex_lock( &pViaXvMC->ctxMutex ); + ppthread_mutex_lock(&pViaXvMC->ctxMutex); if (!pViaXvMC->haveXv) { - ppthread_mutex_unlock( &pViaXvMC->ctxMutex ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } - - sAPriv = SAREAPTR( pViaXvMC ); - hwlLock(pViaXvMC->xl,1); - if (sAPriv->XvMCDisplaying[pViaXvMC->xvMCPort] != + 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 ); + hwlUnlock(pViaXvMC->xl, 1); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } - setLowLevelLocking(pViaXvMC->xl,0); + 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); + viaVideoSubPictureOffLocked(pViaXvMC->xl); } } flushPCIXvMCLowLevel(pViaXvMC->xl); - setLowLevelLocking(pViaXvMC->xl,1); - hwlUnlock(pViaXvMC->xl,1); - + 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 ); + 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 ); + ppthread_mutex_unlock(&pViaXvMC->ctxMutex); return Success; } diff --git a/src/xvmc/viaXvMCPriv.h b/src/xvmc/viaXvMCPriv.h index de4976a..ee96722 100644 --- a/src/xvmc/viaXvMCPriv.h +++ b/src/xvmc/viaXvMCPriv.h @@ -33,99 +33,98 @@ #include <X11/extensions/vldXvMC.h> #include "via_xvmc.h" -typedef struct{ +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 +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]; +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 */ + 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 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; @@ -139,60 +138,60 @@ typedef struct{ 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 */ +} 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 */ +} 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 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; +} ViaXvMCSurface; /* * Take and release the global drm hardware lock. */ #define HW_LOCK(ctx) \ - DRM_LOCK((ctx)->fd,(ctx)->hwLock,(ctx)->drmcontext,0) + DRM_LOCK((ctx)->fd,(ctx)->hwLock,(ctx)->drmcontext,0) #define HW_UNLOCK(ctx) \ - DRM_UNLOCK((ctx)->fd,(ctx->hwLock),(ctx)->drmcontext) + 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/src/xvmc/xf86dri.c b/src/xvmc/xf86dri.c index dd1d1e0..1feb232 100644 --- a/src/xvmc/xf86dri.c +++ b/src/xvmc/xf86dri.c @@ -41,7 +41,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #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; @@ -57,82 +56,78 @@ static char xf86dri_extension_name[] = XF86DRINAME; * * *****************************************************************************/ -static int close_display(Display *dpy, XExtCodes *extCodes); +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 */ + 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) +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) + Bool uniDRIQueryExtension(dpy, event_basep, error_basep) Display *dpy; int *event_basep, *error_basep; { - XExtDisplayInfo *info = find_display (dpy); + 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"); + TRACE("QueryExtension... return True"); return True; } else { - TRACE("QueryExtension... return False"); + TRACE("QueryExtension... return False"); return False; } } - Bool uniDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) - Display* dpy; - int* majorVersion; - int* minorVersion; - int* patchVersion; +Bool +uniDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) + Display *dpy; + int *majorVersion; + int *minorVersion; + int *patchVersion; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86DRIQueryVersionReply rep; xXF86DRIQueryVersionReq *req; TRACE("QueryVersion..."); - uniDRICheckExtension (dpy, info, False); + 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)) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - TRACE("QueryVersion... return False"); + TRACE("QueryVersion... return False"); return False; } *majorVersion = rep.majorVersion; @@ -144,27 +139,28 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) return True; } - Bool uniDRIQueryDirectRenderingCapable(dpy, screen, isCapable) - Display* dpy; +Bool +uniDRIQueryDirectRenderingCapable(dpy, screen, isCapable) + Display *dpy; int screen; - Bool* isCapable; + Bool *isCapable; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86DRIQueryDirectRenderingCapableReply rep; xXF86DRIQueryDirectRenderingCapableReq *req; TRACE("QueryDirectRenderingCapable..."); - uniDRICheckExtension (dpy, info, False); + 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)) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - TRACE("QueryDirectRenderingCapable... return False"); + TRACE("QueryDirectRenderingCapable... return False"); return False; } *isCapable = rep.isCapable; @@ -174,47 +170,49 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) return True; } - Bool uniDRIOpenConnection(dpy, screen, hSAREA, busIdString) - Display* dpy; +Bool +uniDRIOpenConnection(dpy, screen, hSAREA, busIdString) + Display *dpy; int screen; - drm_handle_t * hSAREA; + drm_handle_t *hSAREA; char **busIdString; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86DRIOpenConnectionReply rep; xXF86DRIOpenConnectionReq *req; TRACE("OpenConnection..."); - uniDRICheckExtension (dpy, info, False); + 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)) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - TRACE("OpenConnection... return False"); + TRACE("OpenConnection... return False"); return False; } *hSAREA = rep.hSAREALow; #ifdef LONG64 - *hSAREA |= ((drm_handle_t)rep.hSAREAHigh) << 32; + if (sizeof(drm_handle_t) == 8) { + *hSAREA |= ((unsigned long)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; - } + 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; + *busIdString = NULL; } UnlockDisplay(dpy); SyncHandle(); @@ -222,17 +220,18 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) return True; } - Bool uniDRIAuthConnection(dpy, screen, magic) - Display* dpy; +Bool +uniDRIAuthConnection(dpy, screen, magic) + Display *dpy; int screen; drm_magic_t magic; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86DRIAuthConnectionReq *req; xXF86DRIAuthConnectionReply rep; TRACE("AuthConnection..."); - uniDRICheckExtension (dpy, info, False); + uniDRICheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86DRIAuthConnection, req); @@ -241,10 +240,10 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) req->screen = screen; req->magic = magic; rep.authenticated = 0; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) { UnlockDisplay(dpy); SyncHandle(); - TRACE("AuthConnection... return False"); + TRACE("AuthConnection... return False"); return False; } UnlockDisplay(dpy); @@ -253,16 +252,17 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) return True; } - Bool uniDRICloseConnection(dpy, screen) - Display* dpy; +Bool +uniDRICloseConnection(dpy, screen) + Display *dpy; int screen; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86DRICloseConnectionReq *req; TRACE("CloseConnection..."); - uniDRICheckExtension (dpy, info, False); + uniDRICheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86DRICloseConnection, req); @@ -275,31 +275,32 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) return True; } - Bool uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, - ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName) - Display* dpy; +Bool +uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, + ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName) + Display *dpy; int screen; - int* ddxDriverMajorVersion; - int* ddxDriverMinorVersion; - int* ddxDriverPatchVersion; - char** clientDriverName; + int *ddxDriverMajorVersion; + int *ddxDriverMinorVersion; + int *ddxDriverPatchVersion; + char **clientDriverName; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86DRIGetClientDriverNameReply rep; xXF86DRIGetClientDriverNameReq *req; TRACE("GetClientDriverName..."); - uniDRICheckExtension (dpy, info, False); + 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)) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - TRACE("GetClientDriverName... return False"); + TRACE("GetClientDriverName... return False"); return False; } @@ -308,16 +309,17 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) *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; - } + 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; + *clientDriverName = NULL; } UnlockDisplay(dpy); SyncHandle(); @@ -325,20 +327,20 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) return True; } - Bool uniDRICreateContextWithConfig(dpy, screen, configID, context, - hHWContext) - Display* dpy; +Bool +uniDRICreateContextWithConfig(dpy, screen, configID, context, hHWContext) + Display *dpy; int screen; int configID; - XID* context; - drm_context_t * hHWContext; + XID *context; + drm_context_t *hHWContext; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86DRICreateContextReply rep; xXF86DRICreateContextReq *req; TRACE("CreateContext..."); - uniDRICheckExtension (dpy, info, False); + uniDRICheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86DRICreateContext, req); @@ -348,10 +350,10 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) req->screen = screen; *context = XAllocID(dpy); req->context = *context; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - TRACE("CreateContext... return False"); + TRACE("CreateContext... return False"); return False; } *hHWContext = rep.hHWContext; @@ -361,26 +363,27 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) return True; } - Bool uniDRICreateContext(dpy, screen, visual, context, hHWContext) - Display* dpy; +Bool +uniDRICreateContext(dpy, screen, visual, context, hHWContext) + Display *dpy; int screen; - Visual* visual; - XID* context; - drm_context_t * hHWContext; + Visual *visual; + XID *context; + drm_context_t *hHWContext; { - return uniDRICreateContextWithConfig( dpy, screen, visual->visualid, - context, hHWContext ); + return uniDRICreateContextWithConfig(dpy, screen, visual->visualid, + context, hHWContext); } - Bool uniDRIDestroyContext( Display * ndpy, int screen, - XID context ) +Bool +uniDRIDestroyContext(Display * ndpy, int screen, XID context) { - Display * const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display (dpy); + Display *const dpy = (Display *) ndpy; + XExtDisplayInfo *info = find_display(dpy); xXF86DRIDestroyContextReq *req; TRACE("DestroyContext..."); - uniDRICheckExtension (dpy, info, False); + uniDRICheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86DRIDestroyContext, req); @@ -394,16 +397,17 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) return True; } -Bool uniDRICreateDrawable( Display * ndpy, int screen, - Drawable drawable, drm_drawable_t * hHWDrawable ) +Bool +uniDRICreateDrawable(Display * ndpy, int screen, + Drawable drawable, drm_drawable_t * hHWDrawable) { - Display * const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display (dpy); + Display *const dpy = (Display *) ndpy; + XExtDisplayInfo *info = find_display(dpy); xXF86DRICreateDrawableReply rep; xXF86DRICreateDrawableReq *req; TRACE("CreateDrawable..."); - uniDRICheckExtension (dpy, info, False); + uniDRICheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86DRICreateDrawable, req); @@ -411,10 +415,10 @@ Bool uniDRICreateDrawable( Display * ndpy, int screen, req->driReqType = X_XF86DRICreateDrawable; req->screen = screen; req->drawable = drawable; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - TRACE("CreateDrawable... return False"); + TRACE("CreateDrawable... return False"); return False; } *hHWDrawable = rep.hHWDrawable; @@ -424,15 +428,15 @@ Bool uniDRICreateDrawable( Display * ndpy, int screen, return True; } -Bool uniDRIDestroyDrawable( Display * ndpy, int screen, - Drawable drawable ) +Bool +uniDRIDestroyDrawable(Display * ndpy, int screen, Drawable drawable) { - Display * const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display (dpy); + Display *const dpy = (Display *) ndpy; + XExtDisplayInfo *info = find_display(dpy); xXF86DRIDestroyDrawableReq *req; TRACE("DestroyDrawable..."); - uniDRICheckExtension (dpy, info, False); + uniDRICheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86DRIDestroyDrawable, req); @@ -446,20 +450,21 @@ Bool uniDRIDestroyDrawable( Display * ndpy, int screen, 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 ) +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); + XExtDisplayInfo *info = find_display(dpy); xXF86DRIGetDrawableInfoReply rep; xXF86DRIGetDrawableInfoReq *req; int total_rects; TRACE("GetDrawableInfo..."); - uniDRICheckExtension (dpy, info, False); + uniDRICheckExtension(dpy, info, False); LockDisplay(dpy); GetReq(XF86DRIGetDrawableInfo, req); @@ -468,11 +473,10 @@ Bool uniDRIDestroyDrawable( Display * ndpy, int screen, req->screen = screen; req->drawable = drawable; - if (!_XReply(dpy, (xReply *)&rep, 1, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - TRACE("GetDrawableInfo... return False"); + TRACE("GetDrawableInfo... return False"); return False; } *index = rep.drawableTableIndex; @@ -494,35 +498,36 @@ Bool uniDRIDestroyDrawable( Display * ndpy, int screen, * 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); + 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; + TRACE("GetDrawableInfo... return False"); + return False; } #endif if (*numClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numClipRects); + int len = sizeof(drm_clip_rect_t) * (*numClipRects); - *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1); - if (*pClipRects) - _XRead(dpy, (char*)*pClipRects, len); + *pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); + if (*pClipRects) + _XRead(dpy, (char *)*pClipRects, len); } else { - *pClipRects = NULL; + *pClipRects = NULL; } if (*numBackClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); + int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); - *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1); - if (*pBackClipRects) - _XRead(dpy, (char*)*pBackClipRects, len); + *pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); + if (*pBackClipRects) + _XRead(dpy, (char *)*pBackClipRects, len); } else { - *pBackClipRects = NULL; + *pBackClipRects = NULL; } UnlockDisplay(dpy); @@ -531,39 +536,42 @@ Bool uniDRIDestroyDrawable( Display * ndpy, int screen, return True; } - Bool uniDRIGetDeviceInfo(dpy, screen, hFrameBuffer, - fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate) - Display* dpy; +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; + drm_handle_t *hFrameBuffer; + int *fbOrigin; + int *fbSize; + int *fbStride; + int *devPrivateSize; + void **pDevPrivate; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86DRIGetDeviceInfoReply rep; xXF86DRIGetDeviceInfoReq *req; TRACE("GetDeviceInfo..."); - uniDRICheckExtension (dpy, info, False); + 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)) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); - TRACE("GetDeviceInfo... return False"); + TRACE("GetDeviceInfo... return False"); return False; } *hFrameBuffer = rep.hFrameBufferLow; #ifdef LONG64 - *hFrameBuffer |= ((drm_handle_t)rep.hFrameBufferHigh) << 32; + if (sizeof(drm_handle_t) == 8) { + *hFrameBuffer |= ((unsigned long)rep.hFrameBufferHigh) << 32; + } #endif *fbOrigin = rep.framebufferOrigin; @@ -572,16 +580,16 @@ Bool uniDRIDestroyDrawable( Display * ndpy, int screen, *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); + 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; + *pDevPrivate = NULL; } UnlockDisplay(dpy); @@ -589,4 +597,3 @@ Bool uniDRIDestroyDrawable( Display * ndpy, int screen, TRACE("GetDeviceInfo... return True"); return True; } - diff --git a/src/xvmc/xf86dri.h b/src/xvmc/xf86dri.h index f82b573..3419787 100644 --- a/src/xvmc/xf86dri.h +++ b/src/xvmc/xf86dri.h @@ -54,8 +54,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define X_XF86DRIGetDrawableInfo 9 #define X_XF86DRIGetDeviceInfo 10 #define X_XF86DRIAuthConnection 11 -#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ -#define X_XF86DRICloseFullScreen 13 /* Deprecated */ +#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ +#define X_XF86DRICloseFullScreen 13 /* Deprecated */ #define XF86DRINumberEvents 0 @@ -65,57 +65,52 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef _XF86DRI_SERVER_ - _XFUNCPROTOBEGIN + Bool uniDRIQueryExtension(Display * dpy, int *event_base, + int *error_base); -Bool uniDRIQueryExtension( Display *dpy, int *event_base, int *error_base ); - -Bool uniDRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion, - int *patchVersion ); +Bool uniDRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, + int *patchVersion); -Bool uniDRIQueryDirectRenderingCapable( Display *dpy, int screen, - Bool *isCapable ); +Bool uniDRIQueryDirectRenderingCapable(Display * dpy, int screen, + Bool * isCapable); -Bool uniDRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA, - char **busIDString ); +Bool uniDRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, + char **busIDString); -Bool uniDRIAuthConnection( Display *dpy, int screen, drm_magic_t magic ); +Bool uniDRIAuthConnection(Display * dpy, int screen, drm_magic_t magic); -Bool uniDRICloseConnection( Display *dpy, int screen ); +Bool uniDRICloseConnection(Display * dpy, int screen); -Bool uniDRIGetClientDriverName( Display *dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName ); +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 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 ); +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 uniDRIDestroyContext(Display * dpy, int screen, XID context_id); -extern Bool uniDRICreateDrawable( Display *dpy, int screen, - Drawable drawable, drm_drawable_t *hHWDrawable ); +extern Bool uniDRICreateDrawable(Display * dpy, int screen, + Drawable drawable, drm_drawable_t * hHWDrawable); -extern Bool uniDRIDestroyDrawable( Display *dpy, int screen, - Drawable drawable); +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 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 ); +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/src/xvmc/xf86dristr.h b/src/xvmc/xf86dristr.h index ac05b18..3b43438 100644 --- a/src/xvmc/xf86dristr.h +++ b/src/xvmc/xf86dristr.h @@ -55,289 +55,336 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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 +#define sz_xXF86DRICloseFullScreenReply 32 #endif /* _XF86DRISTR_H_ */ |