190b17f1bSmrg/***************************************************************************** 290b17f1bSmrg * VIA Unichrome XvMC extension client lib. 390b17f1bSmrg * 490b17f1bSmrg * Copyright (c) 2004 The Unichrome Project. All rights reserved. 590b17f1bSmrg * 690b17f1bSmrg * Permission is hereby granted, free of charge, to any person obtaining a 790b17f1bSmrg * copy of this software and associated documentation files (the "Software"), 890b17f1bSmrg * to deal in the Software without restriction, including without limitation 990b17f1bSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1090b17f1bSmrg * and/or sell copies of the Software, and to permit persons to whom the 1190b17f1bSmrg * Software is furnished to do so, subject to the following conditions: 1290b17f1bSmrg * 1390b17f1bSmrg * The above copyright notice and this permission notice shall be included in 1490b17f1bSmrg * all copies or substantial portions of the Software. 1590b17f1bSmrg * 1690b17f1bSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1790b17f1bSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1890b17f1bSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1990b17f1bSmrg * AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2090b17f1bSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2190b17f1bSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2290b17f1bSmrg * DEALINGS IN THE SOFTWARE. 2390b17f1bSmrg */ 2490b17f1bSmrg 2590b17f1bSmrg/* 2690b17f1bSmrg * Authors: Thomas Hellstr�m 2004 - 2005. 2790b17f1bSmrg */ 2890b17f1bSmrg 2990b17f1bSmrg#ifndef VIA_LOWLEVEL_H 3090b17f1bSmrg#define VIA_LOWLEVEL_H 3190b17f1bSmrg 3290b17f1bSmrg/* 3390b17f1bSmrg * The below define is cache size sensitive. Increasing the AGP buffer size 3490b17f1bSmrg * will enable the library to do deeper pipelining, but will degrade the 3590b17f1bSmrg * performance in the drm dma command verifier. 3690b17f1bSmrg */ 3790b17f1bSmrg 3890b17f1bSmrg#define LL_AGP_CMDBUF_SIZE (4096*2) 3990b17f1bSmrg#define LL_PCI_CMDBUF_SIZE (4096) 4090b17f1bSmrg 4190b17f1bSmrg#define LL_MODE_DECODER_SLICE 0x01 4290b17f1bSmrg#define LL_MODE_DECODER_IDLE 0x02 4390b17f1bSmrg#define LL_MODE_VIDEO 0x04 4490b17f1bSmrg#define LL_MODE_2D 0x08 4590b17f1bSmrg#define LL_MODE_3D 0x10 4690b17f1bSmrg 4790b17f1bSmrg/* 4890b17f1bSmrg * Errors 4990b17f1bSmrg */ 5090b17f1bSmrg 5190b17f1bSmrg#define LL_DECODER_TIMEDOUT 0x00000001 5290b17f1bSmrg#define LL_IDCT_FIFO_ERROR 0x00000002 5390b17f1bSmrg#define LL_SLICE_FIFO_ERROR 0x00000004 5490b17f1bSmrg#define LL_SLICE_FAULT 0x00000008 5590b17f1bSmrg#define LL_DMA_TIMEDOUT 0x00000010 5690b17f1bSmrg#define LL_VIDEO_TIMEDOUT 0x00000020 5790b17f1bSmrg#define LL_ACCEL_TIMEDOUT 0x00000040 5890b17f1bSmrg#define LL_PCI_COMMAND_ERR 0x00000080 5990b17f1bSmrg#define LL_AGP_COMMAND_ERR 0x00000100 6090b17f1bSmrg 6190b17f1bSmrg#define VIA_SLICEBUSYMASK 0x00000200 6290b17f1bSmrg#define VIA_BUSYMASK 0x00000207 6390b17f1bSmrg#define VIA_SLICEIDLEVAL 0x00000200 6490b17f1bSmrg#define VIA_IDLEVAL 0x00000204 6590b17f1bSmrg 6690b17f1bSmrg#include "via_drm.h" 6790b17f1bSmrg#include "viaXvMCPriv.h" 6890b17f1bSmrg 6990b17f1bSmrg#define setRegion(xx,yy,ww,hh,region) \ 7090b17f1bSmrg do { \ 7190b17f1bSmrg (region).x = (xx); \ 7290b17f1bSmrg (region).y = (yy); \ 7390b17f1bSmrg (region).w = (ww); \ 7490b17f1bSmrg (region).h = (hh); \ 7590b17f1bSmrg } while(0) 7690b17f1bSmrg 7790b17f1bSmrg#define regionEqual(r1, r2) \ 7890b17f1bSmrg ((r1).x == (r2).x && \ 7990b17f1bSmrg (r1).y == (r2).y && \ 8090b17f1bSmrg (r1).w == (r2).w && \ 8190b17f1bSmrg (r1).h == (r2).h) 8290b17f1bSmrg 8390b17f1bSmrgextern void 8490b17f1bSmrg *initXvMCLowLevel(int fd, drm_context_t * ctx, 8590b17f1bSmrg drmLockPtr hwLock, drmAddress mmioAddress, 8690b17f1bSmrg drmAddress fbAddress, unsigned fbStride, unsigned fbDepth, 8790b17f1bSmrg unsigned width, unsigned height, int useAgp, unsigned chipId); 8890b17f1bSmrg 8990b17f1bSmrgextern void setLowLevelLocking(void *xlp, int perFormLocking); 9090b17f1bSmrgextern void closeXvMCLowLevel(void *xlp); 9190b17f1bSmrgextern void flushPCIXvMCLowLevel(void *xlp); 9290b17f1bSmrgextern CARD32 viaDMATimeStampLowLevel(void *xlp); 9390b17f1bSmrgextern void setAGPSyncLowLevel(void *xlp, int val, CARD32 timeStamp); 9490b17f1bSmrg 9590b17f1bSmrg/* 9690b17f1bSmrg * These two functions also return and clear the current error status. 9790b17f1bSmrg */ 9890b17f1bSmrg 9990b17f1bSmrgextern unsigned flushXvMCLowLevel(void *xlp); 10090b17f1bSmrgextern unsigned syncXvMCLowLevel(void *xlp, unsigned int mode, 10190b17f1bSmrg unsigned int doSleep, CARD32 timeStamp); 10290b17f1bSmrg 10390b17f1bSmrgextern void hwlUnlock(void *xlp, int videoLock); 10490b17f1bSmrgextern void hwlLock(void *xlp, int videoLock); 10590b17f1bSmrg 10690b17f1bSmrgextern void viaVideoSetSWFLipLocked(void *xlp, unsigned yOffs, unsigned uOffs, 10790b17f1bSmrg unsigned vOffs, unsigned yStride, unsigned uvStride); 10890b17f1bSmrg 10990b17f1bSmrgextern void viaMpegReset(void *xlp); 11090b17f1bSmrgextern void viaMpegWriteSlice(void *xlp, CARD8 * slice, 11190b17f1bSmrg int nBytes, CARD32 sCode); 11290b17f1bSmrgextern void viaMpegSetSurfaceStride(void *xlp, ViaXvMCContext * ctx); 11390b17f1bSmrgextern void viaMpegSetFB(void *xlp, unsigned i, unsigned yOffs, 11490b17f1bSmrg unsigned uOffs, unsigned vOffs); 11590b17f1bSmrgextern void viaMpegBeginPicture(void *xlp, ViaXvMCContext * ctx, 11690b17f1bSmrg unsigned width, unsigned height, const XvMCMpegControl * control); 11790b17f1bSmrg 11890b17f1bSmrg/* 11990b17f1bSmrg * Low-level Video functions in viaLowLevel.c 12090b17f1bSmrg */ 12190b17f1bSmrg 12290b17f1bSmrgextern void viaBlit(void *xlp, unsigned bpp, unsigned srcBase, 12390b17f1bSmrg unsigned srcPitch, unsigned dstBase, unsigned dstPitch, 12490b17f1bSmrg unsigned w, unsigned h, int xdir, int ydir, 12590b17f1bSmrg unsigned blitMode, unsigned color); 12690b17f1bSmrg 12790b17f1bSmrgextern void viaVideoSWFlipLocked(void *xlp, unsigned flags, 12890b17f1bSmrg int progressiveSequence); 12990b17f1bSmrg 13090b17f1bSmrgextern void viaVideoSubPictureLocked(void *xlp, 13190b17f1bSmrg ViaXvMCSubPicture * pViaSubPic); 13290b17f1bSmrgextern void viaVideoSubPictureOffLocked(void *xlp); 13390b17f1bSmrg 13490b17f1bSmrg#define PCI_CHIP_VT3204 0x3108 /* K8M800 */ 13590b17f1bSmrg#define PCI_CHIP_VT3259 0x3118 /* PM800/PM880/CN400 */ 13690b17f1bSmrg#define PCI_CHIP_CLE3122 0x3122 /* CLE266 */ 13790b17f1bSmrg#define PCI_CHIP_VT3205 0x7205 /* KM400 */ 13890b17f1bSmrg#define PCI_CHIP_VT3327 0x3343 /* P4M890 */ 13990b17f1bSmrg#define PCI_CHIP_VT3364 0x3371 /* P4M900 */ 14090b17f1bSmrg 14190b17f1bSmrg#endif 142