📄 atimach64xv.c
字号:
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64xv.c,v 1.7 2003/11/10 18:22:18 tsi Exp $ *//* * Copyright 2003 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting documentation, and * that the name of Marc Aurele La France not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Marc Aurele La France makes no representations * about the suitability of this software for any purpose. It is provided * "as-is" without express or implied warranty. * * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <string.h>#include "ati.h"#include "atiaccel.h"#include "atichip.h"#include "atimach64accel.h"#include "atimach64io.h"#include "atimach64xv.h"#include <X11/extensions/Xv.h>#include "fourcc.h"#define MAKE_ATOM(string) MakeAtom(string, strlen(string), TRUE)#define MaxScale (CARD32)(CARD16)(-1)static unsigned long ATIMach64XVAtomGeneration = (unsigned long)(-1);static XF86VideoEncodingRec ATIMach64VideoEncoding_A[] ={ { 0, "XV_IMAGE", 384, 2048, {1, 1} }};#define nATIMach64VideoEncoding_A NumberOf(ATIMach64VideoEncoding_A)static XF86VideoEncodingRec ATIMach64VideoEncoding_B[] ={ { 0, "XV_IMAGE", 720, 2048, {1, 1} }};#define nATIMach64VideoEncoding_B NumberOf(ATIMach64VideoEncoding_B)/* nATIMach64VideoEncoding_[AB] should be equal */#define nATIMach64VideoEncoding nATIMach64VideoEncoding_Astatic XF86VideoFormatRec ATIMach64VideoFormat[] ={ { 8, TrueColor}, { 8, DirectColor}, { 8, PseudoColor}, { 8, GrayScale}, { 8, StaticGray}, { 8, StaticColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor}, {15, DirectColor}, {16, DirectColor}, {24, DirectColor}};#define nATIMach64VideoFormat NumberOf(ATIMach64VideoFormat)static XF86AttributeRec ATIMach64Attribute[] ={ /* These are only supported on the Rage Pro and later ... */ { XvSettable | XvGettable, -1000, 1000, "XV_SATURATION" }, { XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS" }, { XvSettable | XvGettable, -1000, 1000, "XV_COLOUR" }, { XvSettable | XvGettable, -1000, 1000, "XV_COLOR" }, /* Local attributes, odds and ends for compatibility, etc... */ { XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLOURKEY" }, { XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLORKEY" }, { XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLOURKEY" }, { XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY" }, { XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLOURKEY_MASK" }, { XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY_MASK" }, { XvSettable, 0, 0, "XV_SET_DEFAULTS" }, { /* Keep last */ XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER" }};#define nATIMach64Attribute NumberOf(ATIMach64Attribute)static XF86ImageRec ATIMach64Image[] ={ XVIMAGE_YUY2, XVIMAGE_UYVY, XVIMAGE_YV12, XVIMAGE_I420};#define nATIMach64Image NumberOf(ATIMach64Image)/* A local XVideo adaptor attribute record */typedef struct _ATIMach64Attribute{ Atom AttributeID; INT32 MaxValue; /* ... for the hardware */ void (*SetAttribute) (ATIPtr, INT32); INT32 (*GetAttribute) (ATIPtr);} ATIMach64AttributeRec, *ATIMach64AttributePtr;/* Functions to get/set XVideo adaptor attributes */static voidATIMach64SetSaturationAttribute( ATIPtr pATI, INT32 Value){ /* Set the register */ pATI->NewHW.scaler_colour_cntl &= ~(SCALE_SATURATION_U | SCALE_SATURATION_V); pATI->NewHW.scaler_colour_cntl |= SetBits(Value, SCALE_SATURATION_U) | SetBits(Value, SCALE_SATURATION_V); outf(SCALER_COLOUR_CNTL, pATI->NewHW.scaler_colour_cntl);}static INT32ATIMach64GetSaturationAttribute( ATIPtr pATI){ return (INT32)GetBits(pATI->NewHW.scaler_colour_cntl, SCALE_SATURATION_U);}static voidATIMach64SetBrightnessAttribute( ATIPtr pATI, INT32 Value){ /* Set the register */ pATI->NewHW.scaler_colour_cntl &= ~SCALE_BRIGHTNESS; pATI->NewHW.scaler_colour_cntl |= SetBits(Value, SCALE_BRIGHTNESS); outf(SCALER_COLOUR_CNTL, pATI->NewHW.scaler_colour_cntl);}static INT32ATIMach64GetBrightnessAttribute( ATIPtr pATI){ return (INT32)GetBits(pATI->NewHW.scaler_colour_cntl, SCALE_BRIGHTNESS);}static voidATIMach64SetDoubleBufferAttribute( ATIPtr pATI, INT32 Value){ pATI->DoubleBuffer = Value;}static INT32ATIMach64GetDoubleBufferAttribute( ATIPtr pATI){ return (int)pATI->DoubleBuffer;}static voidATIMach64SetAutoPaintAttribute( ATIPtr pATI, INT32 Value){ pATI->AutoPaint = Value;}static INT32ATIMach64GetAutoPaintAttribute( ATIPtr pATI){ return (int)pATI->AutoPaint;}static voidATIMach64SetColourKeyAttribute( ATIPtr pATI, INT32 Value){ pATI->NewHW.overlay_graphics_key_clr = (CARD32)(Value & ((1 << pATI->depth) - 1)); outf(OVERLAY_GRAPHICS_KEY_CLR, pATI->NewHW.overlay_graphics_key_clr);}static INT32ATIMach64GetColourKeyAttribute( ATIPtr pATI){ return (INT32)pATI->NewHW.overlay_graphics_key_clr;}static voidATIMach64SetColourKeyMaskAttribute( ATIPtr pATI, INT32 Value){ pATI->NewHW.overlay_graphics_key_msk = (CARD32)(Value & ((1 << pATI->depth) - 1)); outf(OVERLAY_GRAPHICS_KEY_MSK, pATI->NewHW.overlay_graphics_key_msk);}static INT32ATIMach64GetColourKeyMaskAttribute( ATIPtr pATI){ return (INT32)pATI->NewHW.overlay_graphics_key_msk;}/* * ATIMach64SetDefaultAttributes -- * * This function calls other functions to set default values for the various * attributes of an XVideo port. */static voidATIMach64SetDefaultAttributes( ATIPtr pATI, INT32 Value){ ATIMach64SetAutoPaintAttribute(pATI, TRUE); ATIMach64SetDoubleBufferAttribute(pATI, FALSE); ATIMach64SetColourKeyMaskAttribute(pATI, (1 << pATI->depth) - 1); ATIMach64SetColourKeyAttribute(pATI, (3 << ((2 * pATI->depth) / 3)) | (2 << ((1 * pATI->depth) / 3)) | (1 << ((0 * pATI->depth) / 3))); if (pATI->Chip < ATI_CHIP_264GTPRO) return; ATIMach64SetBrightnessAttribute(pATI, 32); ATIMach64SetSaturationAttribute(pATI, 16);}/* * There is a one-to-one correspondance between elements of the following array * and those of ATIMach64Attribute. */static ATIMach64AttributeRec ATIMach64AttributeInfo[nATIMach64Attribute] ={ { /* SATURATION */ 0, 23, ATIMach64SetSaturationAttribute, ATIMach64GetSaturationAttribute }, { /* BRIGHTNESS */ 0, 63, ATIMach64SetBrightnessAttribute, ATIMach64GetBrightnessAttribute }, { /* COLOUR */ 0, 23, ATIMach64SetSaturationAttribute, ATIMach64GetSaturationAttribute }, { /* COLOR */ 0, 23, ATIMach64SetSaturationAttribute, ATIMach64GetSaturationAttribute }, { /* AUTOPAINT_COLOURKEY */ 0, 1, ATIMach64SetAutoPaintAttribute, ATIMach64GetAutoPaintAttribute }, { /* AUTOPAINT_COLORKEY */ 0, 1, ATIMach64SetAutoPaintAttribute, ATIMach64GetAutoPaintAttribute }, { /* COLOURKEY */ 0, (1 << 24) - 1, ATIMach64SetColourKeyAttribute, ATIMach64GetColourKeyAttribute }, { /* COLORKEY */ 0, (1 << 24) - 1, ATIMach64SetColourKeyAttribute, ATIMach64GetColourKeyAttribute }, { /* COLOURKEY_MASK */ 0, (1 << 24) - 1, ATIMach64SetColourKeyMaskAttribute, ATIMach64GetColourKeyMaskAttribute }, { /* COLORKEY_MASK */ 0, (1 << 24) - 1, ATIMach64SetColourKeyMaskAttribute, ATIMach64GetColourKeyMaskAttribute }, { /* SET_DEFAULTS */ 0, 0, ATIMach64SetDefaultAttributes, NULL }, { /* DOUBLE_BUFFER */ 0, 1, ATIMach64SetDoubleBufferAttribute, ATIMach64GetDoubleBufferAttribute }};/* * ATIMach64FindAttribute -- * * This function is called to locate an Xv attribute's table entry. */static intATIMach64FindPortAttribute( ATIPtr pATI, Atom AttributeID){ int iAttribute; if (pATI->Chip < ATI_CHIP_264GTPRO) iAttribute = 4; else iAttribute = 0; for (; iAttribute < nATIMach64Attribute; iAttribute++) if (AttributeID == ATIMach64AttributeInfo[iAttribute].AttributeID) return iAttribute; return -1;}/* * ATIMach64SetPortAttribute -- * * This function sets the value of a particular port's attribute. */static intATIMach64SetPortAttribute( ScrnInfoPtr pScreenInfo, Atom AttributeID, INT32 Value, pointer pATI){ INT32 Range; int iAttribute; if (((iAttribute = ATIMach64FindPortAttribute(pATI, AttributeID)) < 0) || !ATIMach64AttributeInfo[iAttribute].SetAttribute) return BadMatch; Range = ATIMach64Attribute[iAttribute].max_value - ATIMach64Attribute[iAttribute].min_value; if (Range >= 0) { /* Limit and scale the value */ Value -= ATIMach64Attribute[iAttribute].min_value; if (Value < 0) Value = 0; else if (Value > Range) Value = Range; if (Range != ATIMach64AttributeInfo[iAttribute].MaxValue) { if (ATIMach64AttributeInfo[iAttribute].MaxValue > 0) Value *= ATIMach64AttributeInfo[iAttribute].MaxValue; if (Range > 0) Value /= Range; } } (*ATIMach64AttributeInfo[iAttribute].SetAttribute)(pATI, Value); return Success;}/* * ATIMach64SetPortAttribute -- * * This function retrieves the value of a particular port's attribute. */static intATIMach64GetPortAttribute( ScrnInfoPtr pScreenInfo, Atom AttributeID, INT32 *Value, pointer pATI){ INT32 Range; int iAttribute; if (!Value || ((iAttribute = ATIMach64FindPortAttribute(pATI, AttributeID)) < 0) || !ATIMach64AttributeInfo[iAttribute].GetAttribute) return BadMatch; *Value = (*ATIMach64AttributeInfo[iAttribute].GetAttribute)(pATI); Range = ATIMach64Attribute[iAttribute].max_value - ATIMach64Attribute[iAttribute].min_value; if (Range >= 0) { if (Range != ATIMach64AttributeInfo[iAttribute].MaxValue) { /* (Un-)scale the value */ if (Range > 0) *Value *= Range; if (ATIMach64AttributeInfo[iAttribute].MaxValue > 0) *Value /= ATIMach64AttributeInfo[iAttribute].MaxValue; } *Value += ATIMach64Attribute[iAttribute].min_value; } return Success;}static pointerATIMach64XVMemAlloc( ScreenPtr pScreen, pointer pVideo, int size, int *offset, ATIPtr pATI);static voidATIMach64XVMemFree( ScreenPtr pScreen, pointer pVideo, ATIPtr pATI);#ifdef USE_XAA/* * ATIMach64RemoveLinearCallback -- * * This is called by the framebuffer manager to release the offscreen XVideo * buffer after the video has been temporarily disabled due to its window being * iconified or completely occluded. */static voidATIMach64RemoveLinearCallback( FBLinearPtr pLinear){ ATIPtr pATI = ATIPTR(xf86Screens[pLinear->pScreen->myNum]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -