Commit cdf3377f authored by Keith Packard's avatar Keith Packard

-Wall fixes. Support off-screen pixmaps

parent 777f31cd
INCLUDES = \
-I$(top_srcdir)/fb \
-I$(top_srcdir)/hw/kdrive/src \
-I$(top_srcdir)/hw/kdrive/linux \
-I$(top_srcdir)/hw/kdrive/vesa \
-I$(top_srcdir)/mi \
-I$(top_srcdir)/miext/layer \
......
......@@ -88,25 +88,10 @@ mach64ScreenInit (KdScreenInfo *screen)
}
memory = mach64s->vesa.fb_size;
screen_size = screen->fb[0].byteStride * screen->height;
if (mach64s->screen && memory >= screen_size + 2048)
{
memory -= 2048;
mach64s->cursor_base = mach64s->screen + memory - 2048;
}
else
mach64s->cursor_base = 0;
screen->softCursor = TRUE; /* XXX for now */
memory -= screen_size;
if (memory > screen->fb[0].byteStride)
{
mach64s->off_screen = mach64s->screen + screen_size;
mach64s->off_screen_size = memory;
}
else
{
mach64s->off_screen = 0;
mach64s->off_screen_size = 0;
}
screen->softCursor = TRUE;
screen->off_screen_base = screen_size;
screen->off_screen_size = memory;
screen->driver = mach64s;
return TRUE;
}
......@@ -124,13 +109,12 @@ mach64InitScreen (ScreenPtr pScreen)
}
#ifdef RANDR
Bool
mach64RandRSetConfig (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize)
{
KdScreenPriv(pScreen);
KdCheckSync (pScreen);
if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
......@@ -281,8 +265,8 @@ const CARD8 mach64DPMSModes[4] = {
0x8c, /* KD_DPMS_STANDBY */
0x8c, /* KD_DPMS_STANDBY */
0x8c, /* KD_DPMS_STANDBY */
/* 0xb0, /* KD_DPMS_SUSPEND */
/* 0xbc, /* KD_DPMS_POWERDOWN */
/* 0xb0, KD_DPMS_SUSPEND */
/* 0xbc, KD_DPMS_POWERDOWN */
};
#define PWR_MGT_ON (1 << 0)
......@@ -320,7 +304,7 @@ mach64DPMS (ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
Mach64CardInfo *mach64c = pScreenPriv->card->driver;
int hsync_off, vsync_off, blank;
int hsync_off = 0, vsync_off = 0, blank = 0;
CARD32 CRTC_GEN_CNTL;
CARD32 LCD_GEN_CTRL;
Reg *reg = mach64c->reg;
......
......@@ -553,19 +553,16 @@ typedef struct _mach64PortPriv {
Time freeTime;
CARD32 size;
CARD32 offset;
KdOffscreenArea *off_screen;
} Mach64PortPrivRec, *Mach64PortPrivPtr;
Bool mach64InitVideo(ScreenPtr pScreen);
typedef struct _mach64ScreenInfo {
VesaScreenPrivRec vesa;
CARD8 *cursor_base;
CARD8 *screen;
CARD8 *off_screen;
int off_screen_size;
CARD32 DP_PIX_WIDTH;
CARD32 DP_SET_GUI_ENGINE;
CARD32 USR1_DST_OFF_PITCH;
Bool bpp24;
Mach64Cursor cursor;
CARD32 colorKey;
......@@ -602,6 +599,9 @@ mach64Enable (ScreenPtr pScreen);
void
mach64Disable (ScreenPtr pScreen);
Bool
mach64DPMS (ScreenPtr pScreen, int mode);
void
mach64WaitAvail(Reg *reg, int n);
......
......@@ -65,10 +65,8 @@ CARD8 mach64Rop[16] = {
#define MACH64_DRAW_COMBO_COPY 0x8
static Reg *reg;
static CARD32 cmd;
static CARD32 avail;
static CARD32 triple;
static CARD32 combo;
#define IDX(reg,n) (&(reg)->n - &(reg)->CRTC_H_TOTAL_DISP)
......@@ -91,32 +89,58 @@ mach64WaitIdle (Reg *reg)
}
static Bool
mach64Setup (ScreenPtr pScreen, CARD32 combo, int wait)
mach64Setup (PixmapPtr pDst, PixmapPtr pSrc, CARD32 combo, int wait)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
KdScreenPriv(pScreen);
mach64ScreenInfo(pScreenPriv);
mach64CardInfo(pScreenPriv);
CARD32 DST_PITCH;
CARD32 DST_OFFSET;
CARD32 SRC_PITCH;
CARD32 SRC_OFFSET;
avail = 0;
reg = mach64c->reg;
triple = mach64s->bpp24;
if (!reg)
return FALSE;
mach64WaitAvail(reg, wait + 3);
reg->DP_PIX_WIDTH = mach64s->DP_PIX_WIDTH;
reg->USR1_DST_OFF_PITCH = mach64s->USR1_DST_OFF_PITCH;
/* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
DST_PITCH = pDst->devKind / pDst->drawable.bitsPerPixel;
if (triple)
DST_PITCH *= 3;
/* bytes / 8 */
DST_OFFSET = ((CARD8 *) pDst->devPrivate.ptr - mach64s->screen) >> 3;
mach64WaitAvail(reg, wait + (pSrc ? 5 : 4));
reg->DP_SET_GUI_ENGINE = mach64s->DP_SET_GUI_ENGINE | (combo << 20);
reg->DP_PIX_WIDTH = mach64s->DP_PIX_WIDTH;
reg->DST_OFF_PITCH = ((DST_OFFSET << 0) | /* USR1_DST_OFFSET */
(DST_PITCH << 22) | /* USR1_DST_PITCH */
0);
if (pSrc)
{
/* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
SRC_PITCH = pSrc->devKind / pSrc->drawable.bitsPerPixel;
if (triple)
SRC_PITCH *= 3;
/* bytes / 8 */
SRC_OFFSET = ((CARD8 *) pSrc->devPrivate.ptr - mach64s->screen) >> 3;
reg->SRC_OFF_PITCH = ((SRC_OFFSET << 0) |
(SRC_PITCH << 22) |
0);
}
return TRUE;
}
Bool
mach64PrepareSolid (DrawablePtr pDrawable,
int alu,
Pixel pm,
Pixel fg)
mach64PrepareSolid (PixmapPtr pPixmap,
int alu,
Pixel pm,
Pixel fg)
{
if (!mach64Setup (pDrawable->pScreen, 1, 3))
if (!mach64Setup (pPixmap, 0, 1, 3))
return FALSE;
reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
reg->DP_WRITE_MSK = pm;
......@@ -153,22 +177,33 @@ mach64DoneSolid (void)
static int copyDx;
static int copyDy;
static CARD32 copyCombo;
Bool
mach64PrepareCopy (DrawablePtr pSrcDrawable,
DrawablePtr pDstDrawable,
mach64PrepareCopy (PixmapPtr pSrcPixmap,
PixmapPtr pDstPixmap,
int dx,
int dy,
int alu,
Pixel pm)
{
CARD32 combo = 8;
copyCombo = 8 | 2 | 1;
copyDx = dx;
copyDy = dy;
/*
* Avoid going backwards when copying pixmaps to the screen.
* This should reduce tearing somewhat
*/
if (pSrcPixmap == pDstPixmap)
{
if (dx <= 0)
copyCombo &= ~1;
if (dy <= 0)
copyCombo &= ~2;
}
if ((copyDx = dx) > 0)
combo |= 1;
if ((copyDy = dy) > 0)
combo |= 2;
if (!mach64Setup (pDstDrawable->pScreen, combo, 2))
if (!mach64Setup (pDstPixmap, pSrcPixmap, copyCombo, 2))
return FALSE;
reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
......@@ -194,20 +229,20 @@ mach64Copy (int srcX,
traj = DST_24_ROT_EN | DST_24_ROT((dstX / 4) % 6);
if (copyDx > 0)
if (copyCombo & 1)
traj |= 1;
if (copyDy > 0)
if (copyCombo & 2)
traj |= 2;
mach64WaitAvail (reg, 1);
reg->GUI_TRAJ_CNTL = traj;
}
if (copyDx <= 0)
if ((copyCombo & 1) == 0)
{
srcX += w - 1;
dstX += w - 1;
}
if (copyDy <= 0)
if ((copyCombo & 2) == 0)
{
srcY += h - 1;
dstY += h - 1;
......@@ -232,6 +267,10 @@ KaaScreenInfoRec mach64Kaa = {
mach64PrepareCopy,
mach64Copy,
mach64DoneCopy,
64, /* Offscreen byte alignment */
64, /* Offscreen pitch */
KAA_OFFSCREEN_PIXMAPS, /* Flags */
};
Bool
......@@ -264,12 +303,12 @@ mach64DrawEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
mach64ScreenInfo(pScreenPriv);
CARD32 DP_PIX_WIDTH;
CARD32 DP_SET_GUI_ENGINE;
CARD32 SET_DP_DST_PIX_WIDTH;
CARD32 DST1_PITCH;
CARD32 DP_PIX_WIDTH = 0;
CARD32 SET_DP_DST_PIX_WIDTH = 0;
avail = 0;
mach64s->bpp24 = FALSE;
switch (pScreenPriv->screen->fb[0].depth) {
case 1:
DP_PIX_WIDTH = ((PIX_FORMAT_MONO << 0) | /* DP_DST_PIX_WIDTH */
......@@ -378,18 +417,12 @@ mach64DrawEnable (ScreenPtr pScreen)
}
mach64s->DP_PIX_WIDTH = DP_PIX_WIDTH;
DST1_PITCH = (pScreenPriv->screen->fb[0].pixelStride) >> 3;
if (mach64s->bpp24)
DST1_PITCH *= 3;
mach64s->USR1_DST_OFF_PITCH = ((0 << 0) | /* USR1_DST_OFFSET */
(DST1_PITCH << 22) | /* USR1_DST_PITCH */
0);
mach64s->DP_SET_GUI_ENGINE = ((SET_DP_DST_PIX_WIDTH << 3) |
(1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
(0 << 7) | /* SET_DST_OFFSET */
(6 << 7) | /* SET_DST_OFFSET */
(0 << 10) | /* SET_DST_PITCH */
(0 << 14) | /* SET_DST_PITCH_BY_2 */
(1 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 16) | /* SET_SRC_HGTWID1_2 */
(0 << 20) | /* SET_DRAWING_COMBO */
(1 << 24) | /* SET_BUS_MASTER_OP */
......
......@@ -28,6 +28,7 @@
#include <config.h>
#endif
#include "mach64.h"
#include <klinux.h>
void
InitCard (char *name)
......
......@@ -66,6 +66,11 @@ mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit)
pPortPriv->videoOn = FALSE;
mach64WaitIdle (reg);
}
if (pPortPriv->off_screen)
{
KdOffscreenFree (pPortPriv->off_screen);
pPortPriv->off_screen = 0;
}
}
static int
......@@ -74,13 +79,8 @@ mach64SetPortAttribute(KdScreenInfo *screen,
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)
{
......@@ -161,14 +161,10 @@ mach64CopyPackedData(KdScreenInfo *screen,
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;
int srcDown, srcRight, srcNext;
CARD8 *src = buf, *dst;
int srcDown = srcPitch, srcRight = 2, srcNext;
int p;
switch (randr & RR_Rotate_All) {
......@@ -235,15 +231,12 @@ mach64CopyPlanarData(KdScreenInfo *screen,
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;
int i, j;
CARD8 *src1, *src2, *src3, *dst1;
int srcDown, srcDown2, srcRight, srcRight2, srcNext;
int srcDown = srcPitch, srcDown2 = srcPitch2;
int srcRight = 2, srcRight2 = 1, srcNext = 1;
/* compute source data pointers */
src1 = buf;
......@@ -475,15 +468,8 @@ mach64DisplayVideo(KdScreenInfo *screen,
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
Reg *reg = mach64c->reg;
MediaReg *media = mach64c->media_reg;
int xscaleInt, xscaleFract, yscaleInt, yscaleFract;
int xscaleIntUV = 0, xscaleFractUV = 0;
int yscaleIntUV = 0, yscaleFractUV = 0;
int randr = mach64s->vesa.randr;
int HORZ_INC, VERT_INC;
CARD32 SCALER_IN;
CARD32 OVERLAY_SCALE_CNTL;
int tmp;
int left;
int bright;
int sat;
......@@ -570,6 +556,16 @@ mach64DisplayVideo(KdScreenInfo *screen,
media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1);
}
static void
mach64VideoMoveIn (KdOffscreenArea *area)
{
}
static void
mach64VideoMoveOut (KdOffscreenArea *area)
{
}
static int
mach64PutImage(KdScreenInfo *screen,
short src_x,
......@@ -592,7 +588,6 @@ mach64PutImage(KdScreenInfo *screen,
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
Reg *reg = mach64c->reg;
MediaReg *media = mach64c->media_reg;
INT32 x1, x2, y1, y2;
int randr = mach64s->vesa.randr;
......@@ -645,6 +640,7 @@ mach64PutImage(KdScreenInfo *screen,
switch (randr & RR_Rotate_All) {
case RR_Rotate_0:
default:
dst_x1 = dstBox.x1;
dst_y1 = dstBox.y1;
dst_x2 = dstBox.x2;
......@@ -700,11 +696,29 @@ mach64PutImage(KdScreenInfo *screen,
default:
dstPitch = ((dst_width << 1) + 15) & ~15;
srcPitch = (width << 1);
srcPitch2 = 0;
size = dstPitch * (int) dst_height;
break;
}
pPortPriv->offset = mach64s->off_screen - (CARD8 *) mach64s->vesa.fb;
if (pPortPriv->off_screen && size != pPortPriv->size)
{
KdOffscreenFree (pPortPriv->off_screen);
pPortPriv->off_screen = 0;
}
if (!pPortPriv->off_screen)
{
pPortPriv->off_screen = KdOffscreenAlloc (screen->pScreen, size * 2, 64,
TRUE, mach64VideoMoveIn,
mach64VideoMoveOut,
pPortPriv);
if (!pPortPriv->off_screen)
return BadAlloc;
}
pPortPriv->offset = pPortPriv->off_screen->offset;
pPortPriv->size = size;
/* fixup pointers */
pPortPriv->YBuf0Offset = pPortPriv->offset;
......@@ -860,18 +874,6 @@ static KdImageRec Images[NUM_IMAGES] =
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
*/
}
static int
......@@ -881,10 +883,9 @@ mach64ReputImage (KdScreenInfo *screen,
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);
BoxPtr pOldExtents = REGION_EXTENTS (screen->pScreen, &pPortPriv->clip);
BoxPtr pNewExtents = REGION_EXTENTS (screen->pScreen, clipBoxes);
if (pOldExtents->x1 == pNewExtents->x1 &&
pOldExtents->x2 == pNewExtents->x2 &&
......@@ -906,10 +907,8 @@ static KdVideoAdaptorPtr
mach64SetupImageVideo(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
mach64CardInfo(pScreenPriv);
mach64ScreenInfo(pScreenPriv);
KdScreenInfo *screen = pScreenPriv->screen;
KdCardInfo *card = pScreenPriv->card;
KdVideoAdaptorPtr adapt;
Mach64PortPrivPtr pPortPriv;
......@@ -952,6 +951,9 @@ mach64SetupImageVideo(ScreenPtr pScreen)
pPortPriv->brightness = 0;
pPortPriv->saturation = 0;
pPortPriv->currentBuf = 0;
pPortPriv->off_screen = 0;
pPortPriv->size = 0;
pPortPriv->offset = 0;
/* gotta uninit this someplace */
REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0);
......@@ -975,7 +977,6 @@ Bool mach64InitVideo(ScreenPtr pScreen)
KdVideoAdaptorPtr newAdaptor = NULL;
int num_adaptors;
KdCardInfo *card = pScreenPriv->card;
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
if (!mach64c->media_reg)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment