2001-06-16 07:48:49 +02:00
|
|
|
|
/*
|
|
|
|
|
* Copyright <EFBFBD> 2001 Keith Packard
|
|
|
|
|
*
|
|
|
|
|
* 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 Keith Packard not be used in
|
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
|
* specific, written prior permission. Keith Packard makes no
|
|
|
|
|
* representations about the suitability of this software for any purpose. It
|
|
|
|
|
* is provided "as is" without express or implied warranty.
|
|
|
|
|
*
|
|
|
|
|
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
|
* EVENT SHALL KEITH PACKARD 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.
|
|
|
|
|
*/
|
2003-07-07 21:13:03 +02:00
|
|
|
|
/* $RCSId: xc/programs/Xserver/hw/kdrive/mach64/mach64video.c,v 1.9tsi Exp $ */
|
2001-06-16 07:48:49 +02:00
|
|
|
|
#include "mach64.h"
|
|
|
|
|
|
|
|
|
|
#include "Xv.h"
|
|
|
|
|
#include "../../xfree86/common/fourcc.h"
|
|
|
|
|
|
|
|
|
|
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
|
|
|
|
|
|
2001-06-19 11:31:47 +02:00
|
|
|
|
static Atom xvBrightness, xvSaturation, xvColorKey;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
|
|
|
|
#define IMAGE_MAX_WIDTH 720
|
|
|
|
|
#define IMAGE_MAX_HEIGHT 576
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screen->pScreen;
|
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdCardInfo *card = pScreenPriv->card;
|
|
|
|
|
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
|
|
|
|
|
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
|
|
|
|
|
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
Reg *reg = mach64c->reg;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
MediaReg *media = mach64c->media_reg;
|
|
|
|
|
|
|
|
|
|
REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
|
|
|
|
|
|
2001-07-24 21:06:04 +02:00
|
|
|
|
if (!media)
|
|
|
|
|
return;
|
|
|
|
|
|
2001-06-16 07:48:49 +02:00
|
|
|
|
if(pPortPriv->videoOn)
|
|
|
|
|
{
|
2001-06-19 11:31:47 +02:00
|
|
|
|
mach64WaitIdle (reg);
|
2001-06-23 05:41:24 +02:00
|
|
|
|
/* wait for buffer to be displayed */
|
|
|
|
|
while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf)
|
|
|
|
|
;
|
|
|
|
|
/* wait for buffer to be finished */
|
|
|
|
|
while (((media->TRIG_CNTL >> 6) & 1) != 0)
|
|
|
|
|
;
|
|
|
|
|
mach64WaitAvail (reg, 1);
|
2001-06-19 11:31:47 +02:00
|
|
|
|
media->OVERLAY_SCALE_CNTL = 0;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
pPortPriv->videoOn = FALSE;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
mach64WaitIdle (reg);
|
2001-06-16 07:48:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
mach64SetPortAttribute(KdScreenInfo *screen,
|
|
|
|
|
Atom attribute,
|
|
|
|
|
int value,
|
|
|
|
|
pointer data)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screen->pScreen;
|
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdCardInfo *card = pScreenPriv->card;
|
|
|
|
|
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
|
|
|
|
|
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
|
|
|
|
|
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
|
|
|
|
|
MediaReg *media = mach64c->media_reg;
|
|
|
|
|
|
|
|
|
|
if(attribute == xvBrightness)
|
|
|
|
|
{
|
2001-06-19 11:31:47 +02:00
|
|
|
|
if(value < -1000)
|
|
|
|
|
value = -1000;
|
|
|
|
|
if (value > 1000)
|
|
|
|
|
value = 1000;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
pPortPriv->brightness = value;
|
|
|
|
|
}
|
2001-06-19 11:31:47 +02:00
|
|
|
|
else if(attribute == xvSaturation)
|
2001-06-16 07:48:49 +02:00
|
|
|
|
{
|
2001-06-19 11:31:47 +02:00
|
|
|
|
if (value < -1000)
|
|
|
|
|
value = -1000;
|
|
|
|
|
if (value > 1000)
|
|
|
|
|
value = 1000;
|
|
|
|
|
pPortPriv->saturation = value;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
}
|
|
|
|
|
else if(attribute == xvColorKey)
|
|
|
|
|
{
|
2001-06-23 05:41:24 +02:00
|
|
|
|
if (pPortPriv->colorKey != value)
|
|
|
|
|
{
|
|
|
|
|
pPortPriv->colorKey = value;
|
|
|
|
|
REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
|
|
|
|
|
}
|
2001-06-16 07:48:49 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
mach64GetPortAttribute(KdScreenInfo *screen,
|
|
|
|
|
Atom attribute,
|
|
|
|
|
int *value,
|
|
|
|
|
pointer data)
|
|
|
|
|
{
|
|
|
|
|
Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
|
|
|
|
|
|
|
|
|
|
if(attribute == xvBrightness)
|
|
|
|
|
*value = pPortPriv->brightness;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
else if(attribute == xvSaturation)
|
|
|
|
|
*value = pPortPriv->saturation;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
else if(attribute == xvColorKey)
|
|
|
|
|
*value = pPortPriv->colorKey;
|
|
|
|
|
else
|
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
mach64QueryBestSize(KdScreenInfo *screen,
|
|
|
|
|
Bool motion,
|
|
|
|
|
short vid_w,
|
|
|
|
|
short vid_h,
|
|
|
|
|
short drw_w,
|
|
|
|
|
short drw_h,
|
|
|
|
|
unsigned int *p_w,
|
|
|
|
|
unsigned int *p_h,
|
|
|
|
|
pointer data)
|
|
|
|
|
{
|
|
|
|
|
*p_w = drw_w;
|
|
|
|
|
*p_h = drw_h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
mach64CopyPackedData(KdScreenInfo *screen,
|
|
|
|
|
unsigned char *buf,
|
2002-10-04 00:09:04 +02:00
|
|
|
|
int randr,
|
2001-06-16 07:48:49 +02:00
|
|
|
|
int srcPitch,
|
|
|
|
|
int dstPitch,
|
2001-08-09 11:08:55 +02:00
|
|
|
|
int srcW,
|
|
|
|
|
int srcH,
|
2001-06-16 07:48:49 +02:00
|
|
|
|
int top,
|
|
|
|
|
int left,
|
|
|
|
|
int h,
|
|
|
|
|
int w)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screen->pScreen;
|
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdCardInfo *card = pScreenPriv->card;
|
|
|
|
|
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
|
|
|
|
|
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
|
|
|
|
|
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
|
|
|
|
|
CARD8 *src, *dst;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
int srcDown, srcRight, srcNext;
|
|
|
|
|
int p;
|
|
|
|
|
|
2002-10-04 00:09:04 +02:00
|
|
|
|
switch (randr & RR_Rotate_All) {
|
|
|
|
|
case RR_Rotate_0:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src = buf;
|
|
|
|
|
srcDown = srcPitch;
|
|
|
|
|
srcRight = 2;
|
|
|
|
|
break;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
case RR_Rotate_90:
|
|
|
|
|
src = buf + (srcH - 1) * 2;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
srcDown = -2;
|
|
|
|
|
srcRight = srcPitch;
|
|
|
|
|
break;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
case RR_Rotate_180:
|
|
|
|
|
src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
srcDown = -srcPitch;
|
|
|
|
|
srcRight = -2;
|
|
|
|
|
break;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
case RR_Rotate_270:
|
|
|
|
|
src = buf + srcPitch * (srcW - 1);
|
2001-08-09 11:08:55 +02:00
|
|
|
|
srcDown = 2;
|
|
|
|
|
srcRight = -srcPitch;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src = src + top*srcDown + left*srcRight;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
|
|
|
|
if (pPortPriv->currentBuf == 0)
|
|
|
|
|
dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset;
|
|
|
|
|
else
|
|
|
|
|
dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset;
|
|
|
|
|
|
2001-08-09 11:08:55 +02:00
|
|
|
|
w >>= 1;
|
|
|
|
|
srcRight >>= 1;
|
|
|
|
|
srcNext = srcRight >> 1;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
while(h--)
|
|
|
|
|
{
|
2001-08-09 11:08:55 +02:00
|
|
|
|
CARD16 *s = (CARD16 *) src;
|
|
|
|
|
CARD32 *d = (CARD32 *) dst;
|
|
|
|
|
p = w;
|
|
|
|
|
while (p--)
|
|
|
|
|
{
|
|
|
|
|
*d++ = s[0] | (s[srcNext] << 16);
|
|
|
|
|
s += srcRight;
|
|
|
|
|
}
|
2001-06-16 07:48:49 +02:00
|
|
|
|
src += srcPitch;
|
|
|
|
|
dst += dstPitch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
mach64CopyPlanarData(KdScreenInfo *screen,
|
|
|
|
|
unsigned char *buf,
|
2002-10-18 08:00:29 +02:00
|
|
|
|
int randr,
|
2001-06-16 07:48:49 +02:00
|
|
|
|
int srcPitch,
|
2001-06-19 11:31:47 +02:00
|
|
|
|
int srcPitch2,
|
2001-06-16 07:48:49 +02:00
|
|
|
|
int dstPitch, /* of chroma */
|
2001-08-09 11:08:55 +02:00
|
|
|
|
int srcW,
|
2001-06-16 07:48:49 +02:00
|
|
|
|
int srcH,
|
2001-08-09 11:08:55 +02:00
|
|
|
|
int height,
|
2001-06-16 07:48:49 +02:00
|
|
|
|
int top,
|
|
|
|
|
int left,
|
|
|
|
|
int h,
|
|
|
|
|
int w,
|
|
|
|
|
int id)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screen->pScreen;
|
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdCardInfo *card = pScreenPriv->card;
|
|
|
|
|
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
|
|
|
|
|
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
|
|
|
|
|
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
int i, j;
|
|
|
|
|
CARD8 *src1, *src2, *src3, *dst1;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
int srcDown, srcDown2, srcRight, srcRight2, srcNext;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-19 11:31:47 +02:00
|
|
|
|
/* compute source data pointers */
|
|
|
|
|
src1 = buf;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src2 = src1 + height * srcPitch;
|
|
|
|
|
src3 = src2 + (height >> 1) * srcPitch2;
|
2002-10-18 08:00:29 +02:00
|
|
|
|
switch (randr & RR_Rotate_All) {
|
|
|
|
|
case RR_Rotate_0:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
srcDown = srcPitch;
|
|
|
|
|
srcDown2 = srcPitch2;
|
|
|
|
|
srcRight = 2;
|
|
|
|
|
srcRight2 = 1;
|
|
|
|
|
srcNext = 1;
|
|
|
|
|
break;
|
2002-10-18 08:00:29 +02:00
|
|
|
|
case RR_Rotate_90:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src1 = src1 + srcH - 1;
|
|
|
|
|
src2 = src2 + (srcH >> 1) - 1;
|
|
|
|
|
src3 = src3 + (srcH >> 1) - 1;
|
|
|
|
|
srcDown = -1;
|
|
|
|
|
srcDown2 = -1;
|
|
|
|
|
srcRight = srcPitch * 2;
|
|
|
|
|
srcRight2 = srcPitch2;
|
|
|
|
|
srcNext = srcPitch;
|
|
|
|
|
break;
|
2002-10-18 08:00:29 +02:00
|
|
|
|
case RR_Rotate_180:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1);
|
|
|
|
|
src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
|
|
|
|
|
src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
|
|
|
|
|
srcDown = -srcPitch;
|
|
|
|
|
srcDown2 = -srcPitch2;
|
|
|
|
|
srcRight = -2;
|
|
|
|
|
srcRight2 = -1;
|
|
|
|
|
srcNext = -1;
|
|
|
|
|
break;
|
2002-10-18 08:00:29 +02:00
|
|
|
|
case RR_Rotate_270:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src1 = src1 + srcPitch * (srcW - 1);
|
|
|
|
|
src2 = src2 + srcPitch2 * ((srcW >> 1) - 1);
|
|
|
|
|
src3 = src3 + srcPitch2 * ((srcW >> 1) - 1);
|
|
|
|
|
srcDown = 1;
|
|
|
|
|
srcDown2 = 1;
|
|
|
|
|
srcRight = -srcPitch * 2;
|
|
|
|
|
srcRight2 = -srcPitch2;
|
|
|
|
|
srcNext = -srcPitch;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-06-19 11:31:47 +02:00
|
|
|
|
|
|
|
|
|
/* adjust for origin */
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src1 += top * srcDown + left * srcNext;
|
|
|
|
|
src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
|
|
|
|
|
src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
|
|
|
|
|
if (id == FOURCC_I420)
|
|
|
|
|
{
|
|
|
|
|
CARD8 *srct = src2;
|
|
|
|
|
src2 = src3;
|
|
|
|
|
src3 = srct;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-16 07:48:49 +02:00
|
|
|
|
if (pPortPriv->currentBuf == 0)
|
|
|
|
|
dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset;
|
|
|
|
|
else
|
|
|
|
|
dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset;
|
|
|
|
|
|
2001-06-19 11:31:47 +02:00
|
|
|
|
w >>= 1;
|
|
|
|
|
for (j = 0; j < h; j++)
|
2001-06-16 07:48:49 +02:00
|
|
|
|
{
|
2001-06-19 11:31:47 +02:00
|
|
|
|
CARD32 *dst = (CARD32 *) dst1;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
CARD8 *s1l = src1;
|
|
|
|
|
CARD8 *s1r = src1 + srcNext;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
CARD8 *s2 = src2;
|
|
|
|
|
CARD8 *s3 = src3;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < w; i++)
|
|
|
|
|
{
|
2001-08-09 11:08:55 +02:00
|
|
|
|
*dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
|
|
|
|
|
s1l += srcRight;
|
|
|
|
|
s1r += srcRight;
|
|
|
|
|
s2 += srcRight2;
|
|
|
|
|
s3 += srcRight2;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
}
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src1 += srcDown;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
dst1 += dstPitch;
|
|
|
|
|
if (j & 1)
|
|
|
|
|
{
|
2001-08-09 11:08:55 +02:00
|
|
|
|
src2 += srcDown2;
|
|
|
|
|
src3 += srcDown2;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
}
|
2001-06-16 07:48:49 +02:00
|
|
|
|
}
|
2001-06-19 11:31:47 +02:00
|
|
|
|
}
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-19 11:31:47 +02:00
|
|
|
|
static void
|
|
|
|
|
mach64PaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg)
|
|
|
|
|
{
|
|
|
|
|
WindowPtr pRoot = WindowTable[pScreen->myNum];
|
2001-06-23 05:41:24 +02:00
|
|
|
|
GCPtr pGC;
|
|
|
|
|
CARD32 val[2];
|
|
|
|
|
xRectangle *rects, *r;
|
|
|
|
|
BoxPtr pBox = REGION_RECTS (pRgn);
|
|
|
|
|
int nBox = REGION_NUM_RECTS (pRgn);
|
|
|
|
|
|
|
|
|
|
rects = ALLOCATE_LOCAL (nBox * sizeof (xRectangle));
|
|
|
|
|
if (!rects)
|
|
|
|
|
goto bail0;
|
|
|
|
|
r = rects;
|
|
|
|
|
while (nBox--)
|
|
|
|
|
{
|
|
|
|
|
r->x = pBox->x1;
|
|
|
|
|
r->y = pBox->y1;
|
|
|
|
|
r->width = pBox->x2 - pBox->x1;
|
|
|
|
|
r->height = pBox->y2 - pBox->y1;
|
|
|
|
|
r++;
|
|
|
|
|
pBox++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pGC = GetScratchGC (pRoot->drawable.depth, pScreen);
|
|
|
|
|
if (!pGC)
|
|
|
|
|
goto bail1;
|
|
|
|
|
|
|
|
|
|
val[0] = fg;
|
|
|
|
|
val[1] = IncludeInferiors;
|
|
|
|
|
ChangeGC (pGC, GCForeground|GCSubwindowMode, val);
|
|
|
|
|
|
|
|
|
|
ValidateGC (&pRoot->drawable, pGC);
|
|
|
|
|
|
|
|
|
|
(*pGC->ops->PolyFillRect) (&pRoot->drawable, pGC,
|
|
|
|
|
REGION_NUM_RECTS (pRgn), rects);
|
|
|
|
|
|
|
|
|
|
FreeScratchGC (pGC);
|
|
|
|
|
bail1:
|
|
|
|
|
DEALLOCATE_LOCAL (rects);
|
|
|
|
|
bail0:
|
|
|
|
|
;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Mach64ClipVideo -
|
|
|
|
|
|
|
|
|
|
Takes the dst box in standard X BoxRec form (top and left
|
|
|
|
|
edges inclusive, bottom and right exclusive). The new dst
|
|
|
|
|
box is returned. The source boundaries are given (x1, y1
|
|
|
|
|
inclusive, x2, y2 exclusive) and returned are the new source
|
|
|
|
|
boundaries in 16.16 fixed point.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
Mach64ClipVideo(BoxPtr dst,
|
|
|
|
|
INT32 *x1,
|
|
|
|
|
INT32 *x2,
|
|
|
|
|
INT32 *y1,
|
|
|
|
|
INT32 *y2,
|
|
|
|
|
BoxPtr extents, /* extents of the clip region */
|
|
|
|
|
INT32 width,
|
|
|
|
|
INT32 height)
|
|
|
|
|
{
|
|
|
|
|
INT32 vscale, hscale, delta;
|
|
|
|
|
int diff;
|
|
|
|
|
|
|
|
|
|
hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
|
|
|
|
|
vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
|
|
|
|
|
|
|
|
|
|
*x1 <<= 16; *x2 <<= 16;
|
|
|
|
|
*y1 <<= 16; *y2 <<= 16;
|
|
|
|
|
|
|
|
|
|
diff = extents->x1 - dst->x1;
|
|
|
|
|
if(diff > 0) {
|
|
|
|
|
dst->x1 = extents->x1;
|
|
|
|
|
*x1 += diff * hscale;
|
|
|
|
|
}
|
|
|
|
|
diff = dst->x2 - extents->x2;
|
|
|
|
|
if(diff > 0) {
|
|
|
|
|
dst->x2 = extents->x2;
|
|
|
|
|
*x2 -= diff * hscale;
|
|
|
|
|
}
|
|
|
|
|
diff = extents->y1 - dst->y1;
|
|
|
|
|
if(diff > 0) {
|
|
|
|
|
dst->y1 = extents->y1;
|
|
|
|
|
*y1 += diff * vscale;
|
|
|
|
|
}
|
|
|
|
|
diff = dst->y2 - extents->y2;
|
|
|
|
|
if(diff > 0) {
|
|
|
|
|
dst->y2 = extents->y2;
|
|
|
|
|
*y2 -= diff * vscale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(*x1 < 0) {
|
|
|
|
|
diff = (- *x1 + hscale - 1)/ hscale;
|
|
|
|
|
dst->x1 += diff;
|
|
|
|
|
*x1 += diff * hscale;
|
|
|
|
|
}
|
|
|
|
|
delta = *x2 - (width << 16);
|
|
|
|
|
if(delta > 0) {
|
|
|
|
|
diff = (delta + hscale - 1)/ hscale;
|
|
|
|
|
dst->x2 -= diff;
|
|
|
|
|
*x2 -= diff * hscale;
|
|
|
|
|
}
|
|
|
|
|
if(*y1 < 0) {
|
|
|
|
|
diff = (- *y1 + vscale - 1)/ vscale;
|
|
|
|
|
dst->y1 += diff;
|
|
|
|
|
*y1 += diff * vscale;
|
|
|
|
|
}
|
|
|
|
|
delta = *y2 - (height << 16);
|
|
|
|
|
if(delta > 0) {
|
|
|
|
|
diff = (delta + vscale - 1)/ vscale;
|
|
|
|
|
dst->y2 -= diff;
|
|
|
|
|
*y2 -= diff * vscale;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
mach64DisplayVideo(KdScreenInfo *screen,
|
|
|
|
|
int id,
|
|
|
|
|
int dstPitch, /* of chroma for 4:2:0 */
|
|
|
|
|
int x1,
|
|
|
|
|
int y1,
|
|
|
|
|
int x2,
|
|
|
|
|
int y2,
|
2001-08-09 11:08:55 +02:00
|
|
|
|
int dst_x1,
|
|
|
|
|
int dst_y1,
|
|
|
|
|
int dst_x2,
|
|
|
|
|
int dst_y2,
|
2001-06-16 07:48:49 +02:00
|
|
|
|
short src_w,
|
|
|
|
|
short src_h,
|
|
|
|
|
short drw_w,
|
|
|
|
|
short drw_h)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screen->pScreen;
|
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdCardInfo *card = pScreenPriv->card;
|
|
|
|
|
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
|
|
|
|
|
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
|
|
|
|
|
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
Reg *reg = mach64c->reg;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
MediaReg *media = mach64c->media_reg;
|
|
|
|
|
int xscaleInt, xscaleFract, yscaleInt, yscaleFract;
|
|
|
|
|
int xscaleIntUV = 0, xscaleFractUV = 0;
|
|
|
|
|
int yscaleIntUV = 0, yscaleFractUV = 0;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
int randr = mach64s->vesa.randr;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
int HORZ_INC, VERT_INC;
|
|
|
|
|
CARD32 SCALER_IN;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
CARD32 OVERLAY_SCALE_CNTL;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
int tmp;
|
|
|
|
|
int left;
|
|
|
|
|
int bright;
|
|
|
|
|
int sat;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
if (id == FOURCC_UYVY)
|
|
|
|
|
SCALER_IN = SCALER_IN_YVYU422;
|
|
|
|
|
else
|
|
|
|
|
SCALER_IN = SCALER_IN_VYUY422;
|
|
|
|
|
|
|
|
|
|
mach64WaitAvail (reg, 4);
|
2001-06-19 11:31:47 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422;
|
|
|
|
|
|
2001-06-16 07:48:49 +02:00
|
|
|
|
/* color key */
|
|
|
|
|
media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
/* set key control to obey only graphics color key */
|
|
|
|
|
media->OVERLAY_KEY_CNTL = 0x50;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
|
|
|
|
|
mach64WaitAvail (reg, 9);
|
|
|
|
|
media->CAPTURE_DEBUG = 0;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
/* no exclusive video region */
|
|
|
|
|
media->OVERLAY_EXCLUSIVE_HORZ = 0;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
media->OVERLAY_EXCLUSIVE_VERT = 0;
|
|
|
|
|
/* scaling coefficients */
|
|
|
|
|
media->SCALER_H_COEFF0 = 0x00002000;
|
|
|
|
|
media->SCALER_H_COEFF1 = 0x0D06200D;
|
|
|
|
|
media->SCALER_H_COEFF2 = 0x0D0A1C0D;
|
|
|
|
|
media->SCALER_H_COEFF3 = 0x0C0E1A0C;
|
|
|
|
|
media->SCALER_H_COEFF4 = 0x0C14140C;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
media->SCALER_TEST = 0;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
mach64WaitAvail (reg, 2);
|
2001-06-16 07:48:49 +02:00
|
|
|
|
media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND |
|
2001-06-19 11:31:47 +02:00
|
|
|
|
SCALE_GAMMA_BRIGHT |
|
|
|
|
|
SCALE_BANDWIDTH |
|
|
|
|
|
SCALE_OVERLAY_EN |
|
2001-06-16 07:48:49 +02:00
|
|
|
|
SCALE_EN);
|
2001-06-19 11:31:47 +02:00
|
|
|
|
|
|
|
|
|
bright = (pPortPriv->brightness * 64 / 1000);
|
|
|
|
|
if (bright < -0x40)
|
|
|
|
|
bright = -0x40;
|
|
|
|
|
if (bright > 0x3f)
|
|
|
|
|
bright = 0x3f;
|
|
|
|
|
bright = bright & 0x7f;
|
|
|
|
|
sat = ((pPortPriv->saturation * 31 + 31000) / 2000);
|
|
|
|
|
if (sat > 0x1f)
|
|
|
|
|
sat = 0x1f;
|
|
|
|
|
if (sat < 0)
|
|
|
|
|
sat = 0;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
|
2001-06-19 11:31:47 +02:00
|
|
|
|
media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */
|
|
|
|
|
(sat << 8) | /* SATURATION_U */
|
|
|
|
|
(sat << 16) | /* SATURATION_V */
|
2001-06-16 07:48:49 +02:00
|
|
|
|
(0 << 21) | /* SCALER_VERT_ADJ_UV */
|
|
|
|
|
(0 << 28)); /* SCALER_HORZ_ADJ_UV */
|
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
VERT_INC = (src_h << 12) / drw_h;
|
|
|
|
|
HORZ_INC = (src_w << 12) / drw_w;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
mach64WaitAvail (reg, 13);
|
2001-06-19 11:31:47 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
/* lock registers to prevent non-atomic update */
|
2001-08-09 11:08:55 +02:00
|
|
|
|
media->OVERLAY_Y_X_START = 0x80000000 | MACH64_YX (dst_x1, dst_y1);
|
2001-06-23 05:41:24 +02:00
|
|
|
|
/* ending screen coordinate */
|
2001-08-09 11:08:55 +02:00
|
|
|
|
media->OVERLAY_Y_X_END = 0x80000000 | MACH64_YX (dst_x2, dst_y2);
|
2001-06-23 05:41:24 +02:00
|
|
|
|
|
|
|
|
|
media->OVERLAY_SCALE_INC = MACH64_YX(HORZ_INC, VERT_INC);
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset;
|
|
|
|
|
media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset;
|
|
|
|
|
|
|
|
|
|
media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset;
|
|
|
|
|
media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset;
|
|
|
|
|
|
|
|
|
|
media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset;
|
|
|
|
|
media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
media->SCALER_BUF_PITCH = dstPitch >> 1;
|
|
|
|
|
media->SCALER_HEIGHT_WIDTH = MACH64_YX(src_w - (x1 >> 16), src_h - (y1 >> 16));
|
|
|
|
|
|
|
|
|
|
media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28;
|
|
|
|
|
|
2001-06-16 07:48:49 +02:00
|
|
|
|
/* set XY location and unlock */
|
2001-08-09 11:08:55 +02:00
|
|
|
|
media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1);
|
2001-06-16 07:48:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
mach64PutImage(KdScreenInfo *screen,
|
|
|
|
|
short src_x,
|
|
|
|
|
short src_y,
|
|
|
|
|
short drw_x,
|
|
|
|
|
short drw_y,
|
|
|
|
|
short src_w,
|
|
|
|
|
short src_h,
|
|
|
|
|
short drw_w,
|
|
|
|
|
short drw_h,
|
2001-08-09 11:08:55 +02:00
|
|
|
|
int id,
|
2001-06-16 07:48:49 +02:00
|
|
|
|
unsigned char *buf,
|
|
|
|
|
short width,
|
|
|
|
|
short height,
|
|
|
|
|
Bool sync,
|
|
|
|
|
RegionPtr clipBoxes,
|
|
|
|
|
pointer data)
|
|
|
|
|
{
|
|
|
|
|
KdCardInfo *card = screen->card;
|
|
|
|
|
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
Reg *reg = mach64c->reg;
|
|
|
|
|
MediaReg *media = mach64c->media_reg;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
INT32 x1, x2, y1, y2;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
int randr = mach64s->vesa.randr;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
int srcPitch, srcPitch2, dstPitch;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
int top, left, npixels, nlines, size;
|
|
|
|
|
BoxRec dstBox;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
int dst_width = width, dst_height = height;
|
|
|
|
|
int rot_x1, rot_y1, rot_x2, rot_y2;
|
|
|
|
|
int dst_x1, dst_y1, dst_x2, dst_y2;
|
|
|
|
|
int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
|
|
|
|
/* Clip */
|
|
|
|
|
x1 = src_x;
|
|
|
|
|
x2 = src_x + src_w;
|
|
|
|
|
y1 = src_y;
|
|
|
|
|
y2 = src_y + src_h;
|
|
|
|
|
|
|
|
|
|
dstBox.x1 = drw_x;
|
|
|
|
|
dstBox.x2 = drw_x + drw_w;
|
|
|
|
|
dstBox.y1 = drw_y;
|
|
|
|
|
dstBox.y2 = drw_y + drw_h;
|
|
|
|
|
|
|
|
|
|
Mach64ClipVideo(&dstBox, &x1, &x2, &y1, &y2,
|
|
|
|
|
REGION_EXTENTS(pScreen, clipBoxes), width, height);
|
|
|
|
|
|
|
|
|
|
if((x1 >= x2) || (y1 >= y2))
|
|
|
|
|
return Success;
|
|
|
|
|
|
2001-07-24 21:06:04 +02:00
|
|
|
|
if (!media)
|
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
2002-10-04 00:09:04 +02:00
|
|
|
|
if (randr & (RR_Rotate_0|RR_Rotate_180))
|
|
|
|
|
{
|
2001-08-09 11:08:55 +02:00
|
|
|
|
dst_width = width;
|
|
|
|
|
dst_height = height;
|
|
|
|
|
rot_src_w = src_w;
|
|
|
|
|
rot_src_h = src_h;
|
|
|
|
|
rot_drw_w = drw_w;
|
|
|
|
|
rot_drw_h = drw_h;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2001-08-09 11:08:55 +02:00
|
|
|
|
dst_width = height;
|
|
|
|
|
dst_height = width;
|
|
|
|
|
rot_src_w = src_h;
|
|
|
|
|
rot_src_h = src_w;
|
|
|
|
|
rot_drw_w = drw_h;
|
|
|
|
|
rot_drw_h = drw_w;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-04 00:09:04 +02:00
|
|
|
|
switch (randr & RR_Rotate_All) {
|
|
|
|
|
case RR_Rotate_0:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
dst_x1 = dstBox.x1;
|
|
|
|
|
dst_y1 = dstBox.y1;
|
|
|
|
|
dst_x2 = dstBox.x2;
|
|
|
|
|
dst_y2 = dstBox.y2;
|
|
|
|
|
rot_x1 = x1;
|
|
|
|
|
rot_y1 = y1;
|
|
|
|
|
rot_x2 = x2;
|
|
|
|
|
rot_y2 = y2;
|
|
|
|
|
break;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
case RR_Rotate_90:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
dst_x1 = dstBox.y1;
|
|
|
|
|
dst_y1 = screen->height - dstBox.x2;
|
|
|
|
|
dst_x2 = dstBox.y2;
|
|
|
|
|
dst_y2 = screen->height - dstBox.x1;
|
|
|
|
|
|
|
|
|
|
rot_x1 = y1;
|
|
|
|
|
rot_y1 = (src_w << 16) - x2;
|
|
|
|
|
rot_x2 = y2;
|
|
|
|
|
rot_y2 = (src_w << 16) - x1;
|
|
|
|
|
break;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
case RR_Rotate_180:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
dst_x1 = screen->width - dstBox.x2;
|
|
|
|
|
dst_y1 = screen->height - dstBox.y2;
|
|
|
|
|
dst_x2 = screen->width - dstBox.x1;
|
|
|
|
|
dst_y2 = screen->height - dstBox.y1;
|
|
|
|
|
rot_x1 = (src_w << 16) - x2;
|
|
|
|
|
rot_y1 = (src_h << 16) - y2;
|
|
|
|
|
rot_x2 = (src_w << 16) - x1;
|
|
|
|
|
rot_y2 = (src_h << 16) - y1;
|
|
|
|
|
break;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
case RR_Rotate_270:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
dst_x1 = screen->width - dstBox.y2;
|
|
|
|
|
dst_y1 = dstBox.x1;
|
|
|
|
|
dst_x2 = screen->width - dstBox.y1;
|
|
|
|
|
dst_y2 = dstBox.x2;
|
|
|
|
|
rot_x1 = (src_h << 16) - y2;
|
|
|
|
|
rot_y1 = x1;
|
|
|
|
|
rot_x2 = (src_h << 16) - y1;
|
|
|
|
|
rot_y2 = x2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-16 07:48:49 +02:00
|
|
|
|
switch(id) {
|
|
|
|
|
case FOURCC_YV12:
|
|
|
|
|
case FOURCC_I420:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
dstPitch = ((dst_width << 1) + 15) & ~15;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
srcPitch = (width + 3) & ~3;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
srcPitch2 = ((width >> 1) + 3) & ~3;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
size = dstPitch * (int) dst_height;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
break;
|
|
|
|
|
case FOURCC_UYVY:
|
|
|
|
|
case FOURCC_YUY2:
|
|
|
|
|
default:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
dstPitch = ((dst_width << 1) + 15) & ~15;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
srcPitch = (width << 1);
|
2001-08-09 11:08:55 +02:00
|
|
|
|
size = dstPitch * (int) dst_height;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortPriv->offset = mach64s->off_screen - (CARD8 *) mach64s->vesa.fb;
|
|
|
|
|
/* fixup pointers */
|
2001-06-23 05:41:24 +02:00
|
|
|
|
|
2001-06-16 07:48:49 +02:00
|
|
|
|
pPortPriv->YBuf0Offset = pPortPriv->offset;
|
|
|
|
|
pPortPriv->YBuf1Offset = pPortPriv->offset + size;
|
|
|
|
|
|
|
|
|
|
#if 0
|
2001-06-23 05:41:24 +02:00
|
|
|
|
mach64WaitIdle (reg);
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
if (pPortPriv->videoOn)
|
|
|
|
|
{
|
|
|
|
|
/* wait for buffer to be displayed */
|
|
|
|
|
while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf)
|
|
|
|
|
;
|
|
|
|
|
}
|
2001-06-19 11:31:47 +02:00
|
|
|
|
#endif
|
2001-06-23 05:41:24 +02:00
|
|
|
|
/*
|
|
|
|
|
* Use the other buffer
|
|
|
|
|
*/
|
|
|
|
|
pPortPriv->currentBuf = 1 - pPortPriv->currentBuf;
|
|
|
|
|
|
2001-06-16 07:48:49 +02:00
|
|
|
|
/* copy data */
|
2001-08-09 11:08:55 +02:00
|
|
|
|
top = rot_y1 >> 16;
|
|
|
|
|
left = (rot_x1 >> 16) & ~1;
|
|
|
|
|
npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
|
|
|
|
switch(id) {
|
|
|
|
|
case FOURCC_YV12:
|
|
|
|
|
case FOURCC_I420:
|
|
|
|
|
top &= ~1;
|
2001-08-09 11:08:55 +02:00
|
|
|
|
nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
mach64CopyPlanarData(screen, buf, randr,
|
2001-08-09 11:08:55 +02:00
|
|
|
|
srcPitch, srcPitch2, dstPitch,
|
|
|
|
|
rot_src_w, rot_src_h, height,
|
|
|
|
|
top, left, nlines, npixels, id);
|
2001-06-16 07:48:49 +02:00
|
|
|
|
break;
|
|
|
|
|
case FOURCC_UYVY:
|
|
|
|
|
case FOURCC_YUY2:
|
|
|
|
|
default:
|
2001-08-09 11:08:55 +02:00
|
|
|
|
nlines = ((rot_y2 + 0xffff) >> 16) - top;
|
2002-10-04 00:09:04 +02:00
|
|
|
|
mach64CopyPackedData(screen, buf, randr,
|
2001-08-09 11:08:55 +02:00
|
|
|
|
srcPitch, dstPitch,
|
|
|
|
|
rot_src_w, rot_src_h,
|
|
|
|
|
top, left, nlines,
|
|
|
|
|
npixels);
|
2001-06-16 07:48:49 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-09 11:08:55 +02:00
|
|
|
|
mach64DisplayVideo(screen, id, dstPitch,
|
|
|
|
|
rot_x1, rot_y1, rot_x2, rot_y2,
|
|
|
|
|
dst_x1, dst_y1,
|
|
|
|
|
dst_x2, dst_y2,
|
|
|
|
|
rot_src_w, rot_src_h, rot_drw_w, rot_drw_h);
|
2001-06-23 05:41:24 +02:00
|
|
|
|
|
2001-06-16 07:48:49 +02:00
|
|
|
|
/* update cliplist */
|
2003-04-23 23:51:18 +02:00
|
|
|
|
if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes))
|
2001-06-19 11:31:47 +02:00
|
|
|
|
{
|
|
|
|
|
REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes);
|
|
|
|
|
mach64PaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey);
|
2001-06-16 07:48:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortPriv->videoOn = TRUE;
|
|
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
mach64QueryImageAttributes(KdScreenInfo *screen,
|
|
|
|
|
int id,
|
|
|
|
|
unsigned short *w,
|
|
|
|
|
unsigned short *h,
|
|
|
|
|
int *pitches,
|
|
|
|
|
int *offsets)
|
|
|
|
|
{
|
|
|
|
|
int size, tmp;
|
|
|
|
|
|
|
|
|
|
if(*w > IMAGE_MAX_WIDTH)
|
|
|
|
|
*w = IMAGE_MAX_WIDTH;
|
|
|
|
|
if(*h > IMAGE_MAX_HEIGHT)
|
|
|
|
|
*h = IMAGE_MAX_HEIGHT;
|
|
|
|
|
|
|
|
|
|
*w = (*w + 1) & ~1;
|
|
|
|
|
if(offsets) offsets[0] = 0;
|
|
|
|
|
|
|
|
|
|
switch(id) {
|
|
|
|
|
case FOURCC_YV12:
|
|
|
|
|
case FOURCC_I420:
|
|
|
|
|
*h = (*h + 1) & ~1;
|
|
|
|
|
size = (*w + 3) & ~3;
|
|
|
|
|
if(pitches)
|
|
|
|
|
pitches[0] = size;
|
|
|
|
|
size *= *h;
|
|
|
|
|
if(offsets)
|
|
|
|
|
offsets[1] = size;
|
|
|
|
|
tmp = ((*w >> 1) + 3) & ~3;
|
|
|
|
|
if(pitches)
|
|
|
|
|
pitches[1] = pitches[2] = tmp;
|
|
|
|
|
tmp *= (*h >> 1);
|
|
|
|
|
size += tmp;
|
|
|
|
|
if(offsets)
|
|
|
|
|
offsets[2] = size;
|
|
|
|
|
size += tmp;
|
|
|
|
|
break;
|
|
|
|
|
case FOURCC_UYVY:
|
|
|
|
|
case FOURCC_YUY2:
|
|
|
|
|
default:
|
|
|
|
|
size = *w << 1;
|
|
|
|
|
if(pitches)
|
|
|
|
|
pitches[0] = size;
|
|
|
|
|
size *= *h;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* client libraries expect an encoding */
|
|
|
|
|
static KdVideoEncodingRec DummyEncoding[1] =
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
0,
|
|
|
|
|
"XV_IMAGE",
|
|
|
|
|
IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
|
|
|
|
|
{1, 1}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NUM_FORMATS 3
|
|
|
|
|
|
|
|
|
|
static KdVideoFormatRec Formats[NUM_FORMATS] =
|
|
|
|
|
{
|
|
|
|
|
{15, TrueColor}, {16, TrueColor}, {24, TrueColor}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NUM_ATTRIBUTES 3
|
|
|
|
|
|
|
|
|
|
static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
|
|
|
|
|
{
|
2001-06-19 11:31:47 +02:00
|
|
|
|
{XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"},
|
|
|
|
|
{XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
|
|
|
|
|
{XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"}
|
2001-06-16 07:48:49 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define NUM_IMAGES 4
|
|
|
|
|
|
|
|
|
|
static KdImageRec Images[NUM_IMAGES] =
|
|
|
|
|
{
|
|
|
|
|
XVIMAGE_YUY2,
|
|
|
|
|
XVIMAGE_YV12,
|
|
|
|
|
XVIMAGE_I420,
|
|
|
|
|
XVIMAGE_UYVY
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void mach64ResetVideo(KdScreenInfo *screen)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screen->pScreen;
|
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdCardInfo *card = pScreenPriv->card;
|
|
|
|
|
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
|
|
|
|
|
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
|
|
|
|
|
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
|
|
|
|
|
MediaReg *media = mach64c->media_reg;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Default to maximum image size in YV12
|
|
|
|
|
*/
|
2001-06-23 05:41:24 +02:00
|
|
|
|
|
|
|
|
|
}
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
static int
|
|
|
|
|
mach64ReputImage (KdScreenInfo *screen,
|
|
|
|
|
short drw_x,
|
|
|
|
|
short drw_y,
|
|
|
|
|
RegionPtr clipBoxes,
|
|
|
|
|
pointer data)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = screen->pScreen;
|
|
|
|
|
Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
|
|
|
|
|
BoxPtr pOldExtents = REGION_EXTENTS (pScreen, &pPortPriv->clip);
|
|
|
|
|
BoxPtr pNewExtents = REGION_EXTENTS (pScreen, clipBoxes);
|
|
|
|
|
|
|
|
|
|
if (pOldExtents->x1 == pNewExtents->x1 &&
|
|
|
|
|
pOldExtents->x2 == pNewExtents->x2 &&
|
|
|
|
|
pOldExtents->y1 == pNewExtents->y1 &&
|
|
|
|
|
pOldExtents->y2 == pNewExtents->y2)
|
|
|
|
|
{
|
|
|
|
|
/* update cliplist */
|
2003-04-23 23:51:18 +02:00
|
|
|
|
if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes))
|
2001-06-23 05:41:24 +02:00
|
|
|
|
{
|
|
|
|
|
REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes);
|
|
|
|
|
mach64PaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey);
|
|
|
|
|
}
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
return BadMatch;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static KdVideoAdaptorPtr
|
|
|
|
|
mach64SetupImageVideo(ScreenPtr pScreen)
|
|
|
|
|
{
|
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
mach64CardInfo(pScreenPriv);
|
|
|
|
|
mach64ScreenInfo(pScreenPriv);
|
|
|
|
|
KdScreenInfo *screen = pScreenPriv->screen;
|
|
|
|
|
KdCardInfo *card = pScreenPriv->card;
|
|
|
|
|
KdVideoAdaptorPtr adapt;
|
|
|
|
|
Mach64PortPrivPtr pPortPriv;
|
|
|
|
|
|
|
|
|
|
if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) +
|
|
|
|
|
sizeof(Mach64PortPrivRec) +
|
|
|
|
|
sizeof(DevUnion))))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
adapt->type = XvWindowMask | XvInputMask | XvImageMask;
|
|
|
|
|
adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
|
|
|
|
|
adapt->name = "Mach64 Video Overlay";
|
|
|
|
|
adapt->nEncodings = 1;
|
|
|
|
|
adapt->pEncodings = DummyEncoding;
|
|
|
|
|
adapt->nFormats = NUM_FORMATS;
|
|
|
|
|
adapt->pFormats = Formats;
|
|
|
|
|
adapt->nPorts = 1;
|
|
|
|
|
adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
|
|
|
|
|
|
|
|
|
|
pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]);
|
|
|
|
|
|
|
|
|
|
adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv);
|
|
|
|
|
adapt->pAttributes = Attributes;
|
|
|
|
|
adapt->nImages = NUM_IMAGES;
|
|
|
|
|
adapt->nAttributes = NUM_ATTRIBUTES;
|
|
|
|
|
adapt->pImages = Images;
|
|
|
|
|
adapt->PutVideo = NULL;
|
|
|
|
|
adapt->PutStill = NULL;
|
|
|
|
|
adapt->GetVideo = NULL;
|
|
|
|
|
adapt->GetStill = NULL;
|
|
|
|
|
adapt->StopVideo = mach64StopVideo;
|
|
|
|
|
adapt->SetPortAttribute = mach64SetPortAttribute;
|
|
|
|
|
adapt->GetPortAttribute = mach64GetPortAttribute;
|
|
|
|
|
adapt->QueryBestSize = mach64QueryBestSize;
|
|
|
|
|
adapt->PutImage = mach64PutImage;
|
2001-06-23 05:41:24 +02:00
|
|
|
|
adapt->ReputImage = mach64ReputImage;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
adapt->QueryImageAttributes = mach64QueryImageAttributes;
|
|
|
|
|
|
2001-06-23 05:41:24 +02:00
|
|
|
|
pPortPriv->colorKey = mach64s->colorKey;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
pPortPriv->videoOn = FALSE;
|
|
|
|
|
pPortPriv->brightness = 0;
|
2001-06-19 11:31:47 +02:00
|
|
|
|
pPortPriv->saturation = 0;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
pPortPriv->currentBuf = 0;
|
|
|
|
|
|
|
|
|
|
/* gotta uninit this someplace */
|
|
|
|
|
REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0);
|
|
|
|
|
|
|
|
|
|
mach64s->pAdaptor = adapt;
|
|
|
|
|
|
|
|
|
|
xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
|
2001-06-19 11:31:47 +02:00
|
|
|
|
xvSaturation = MAKE_ATOM("XV_SATURATION");
|
2001-06-16 07:48:49 +02:00
|
|
|
|
xvColorKey = MAKE_ATOM("XV_COLORKEY");
|
|
|
|
|
|
|
|
|
|
mach64ResetVideo(screen);
|
|
|
|
|
|
|
|
|
|
return adapt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool mach64InitVideo(ScreenPtr pScreen)
|
|
|
|
|
{
|
|
|
|
|
KdScreenPriv(pScreen);
|
|
|
|
|
KdScreenInfo *screen = pScreenPriv->screen;
|
|
|
|
|
KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
|
|
|
|
|
KdVideoAdaptorPtr newAdaptor = NULL;
|
|
|
|
|
int num_adaptors;
|
2001-07-24 21:06:04 +02:00
|
|
|
|
KdCardInfo *card = pScreenPriv->card;
|
|
|
|
|
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
|
|
|
|
|
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
|
|
|
|
|
|
|
|
|
|
if (!mach64c->media_reg)
|
|
|
|
|
return FALSE;
|
2001-06-16 07:48:49 +02:00
|
|
|
|
|
|
|
|
|
newAdaptor = mach64SetupImageVideo(pScreen);
|
|
|
|
|
|
|
|
|
|
num_adaptors = KdXVListGenericAdaptors(screen, &adaptors);
|
|
|
|
|
|
|
|
|
|
if(newAdaptor)
|
|
|
|
|
{
|
|
|
|
|
if(!num_adaptors)
|
|
|
|
|
{
|
|
|
|
|
num_adaptors = 1;
|
|
|
|
|
adaptors = &newAdaptor;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newAdaptors = xalloc((num_adaptors + 1) *
|
|
|
|
|
sizeof(KdVideoAdaptorPtr*));
|
|
|
|
|
if(newAdaptors)
|
|
|
|
|
{
|
|
|
|
|
memcpy(newAdaptors, adaptors,
|
|
|
|
|
num_adaptors * sizeof(KdVideoAdaptorPtr));
|
|
|
|
|
newAdaptors[num_adaptors] = newAdaptor;
|
|
|
|
|
adaptors = newAdaptors;
|
|
|
|
|
num_adaptors++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(num_adaptors)
|
|
|
|
|
KdXVScreenInit(pScreen, adaptors, num_adaptors);
|
|
|
|
|
|
|
|
|
|
if(newAdaptors)
|
|
|
|
|
xfree(newAdaptors);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|