summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Teira <manuel.teira@telefonica.net>2007-06-14 19:57:28 +0000
committerManuel Teira <manuel.teira@telefonica.net>2007-06-14 19:57:28 +0000
commitec123df895a70f2f065159e0318cee6afd2a166f (patch)
tree6b0ed4a07e22e4b993d16a8c3b1a810ade9ba8a2
parentd0ef53fabcf86956214e1cbae3f112f6825689bb (diff)
xserver-kdrive-imageon X11R7.1-1.1.0 : XV Port changes, cleanups
* Avoid recalculation of surface boundaries when possible * Cleanups and optimizations in support functions * More rational APIs for blitting functions. * Release bumped up to r2
-rw-r--r--packages/xorg-xserver/xserver-kdrive-imageon_X11R7.1-1.1.0.bb2
-rw-r--r--packages/xorg-xserver/xserver-kdrive/kdrive-imageon.patch1700
2 files changed, 945 insertions, 757 deletions
diff --git a/packages/xorg-xserver/xserver-kdrive-imageon_X11R7.1-1.1.0.bb b/packages/xorg-xserver/xserver-kdrive-imageon_X11R7.1-1.1.0.bb
index 106d5405a6..9cdc72f797 100644
--- a/packages/xorg-xserver/xserver-kdrive-imageon_X11R7.1-1.1.0.bb
+++ b/packages/xorg-xserver/xserver-kdrive-imageon_X11R7.1-1.1.0.bb
@@ -11,7 +11,7 @@ DEPENDS = "tslib xproto libxdmcp xextproto xtrans libxau virtual/libx11 libxext
PROVIDES = "virtual/xserver"
RPROVIDES = "virtual/xserver"
-PR = "r1"
+PR = "r2"
FILESPATH = "${FILE_DIRNAME}/xserver-kdrive"
diff --git a/packages/xorg-xserver/xserver-kdrive/kdrive-imageon.patch b/packages/xorg-xserver/xserver-kdrive/kdrive-imageon.patch
index f4272f80e0..2f7f5ca020 100644
--- a/packages/xorg-xserver/xserver-kdrive/kdrive-imageon.patch
+++ b/packages/xorg-xserver/xserver-kdrive/kdrive-imageon.patch
@@ -902,7 +902,7 @@
+#endif
--- /dev/null
+++ xorg-server-X11R7.1-1.1.0.work/hw/kdrive/imageon/imageon_cursor.c
-@@ -0,0 +1,566 @@
+@@ -0,0 +1,565 @@
+/*
+ * Copyright © 2007 Manuel Teira
+ *
@@ -934,8 +934,9 @@
+#include "imageon_regs.h"
+
+#define W100_CURSOR_HEIGHT (16)
-+#define W100_CURSOR_PITCH (4)
+#define W100_CURSOR_WIDTH (16)
++#define W100_CURSOR_PITCH (W100_CURSOR_WIDTH / 4)
++
+#define W100_CURSOR_SIZE W100_CURSOR_PITCH * W100_CURSOR_WIDTH
+
+static CARD16 expand2bpp[256];
@@ -968,7 +969,7 @@
+ (((y) * W100_CURSOR_PITCH + ((x) / 4)) >> 2)
+
+#define PixelShift(x, y) \
-+ (2 * ((x) % W100_CURSOR_WIDTH))
++ (2 * ((x) % 16))
+
+#define PixelMask(x, y) \
+ ((0xc0000000) >> PixelShift(x, y))
@@ -1210,7 +1211,7 @@
+ cursor_v_pos_u vpos;
+ graphic_h_disp_u graphic_hdisp;
+ graphic_v_disp_u graphic_vdisp;
-+ int tx, ty, tw, th;
++ BoxRec cursorBox, deviceBox;
+
+
+ if (!pCurPriv->has_cursor) {
@@ -1224,30 +1225,28 @@
+ graphic_vdisp.val = w100c->regs.GRAPHIC_V_DISP;
+ xoffs = 0;
+ yoffs = 0;
-+ x -= pCurPriv->xhot;
-+ y -= pCurPriv->yhot;
-+ tx = W100MapToHWX(w100c, x, y, pCurPriv->width, pCurPriv->height);
-+ ty = W100MapToHWY(w100c, x, y, pCurPriv->width, pCurPriv->height);
-+ tw = W100MapToHWW(w100c, x, y, pCurPriv->width, pCurPriv->height);
-+ th = W100MapToHWH(w100c, x, y, pCurPriv->width, pCurPriv->height);
++ cursorBox.x1 = x - pCurPriv->xhot;
++ cursorBox.y1 = y - pCurPriv->yhot;
++ cursorBox.x2 = cursorBox.x1 + pCurPriv->width - 1;
++ cursorBox.y2 = cursorBox.y1 + pCurPriv->height - 1;
++ W100MapToDevice(w100c, &cursorBox, &deviceBox);
+
-+ if (tx < 0) {
-+ xoffs = -tx;
-+ tw -= xoffs;
-+ tx = 0;
++ if (deviceBox.x1 < 0) {
++ xoffs = -deviceBox.x1;
++ deviceBox.x1 = 0;
+ }
+
-+ if (ty < 0) {
-+ yoffs = -ty;
-+ th -= yoffs;
-+ ty = 0;
++ if (deviceBox.y1 < 0) {
++ yoffs = -deviceBox.y1;
++ deviceBox.y1 = 0;
+ }
-+
-+ hpos.f.cur_h_start = graphic_hdisp.f.graphic_h_start + tx;
-+ hpos.f.cur_h_end = hpos.f.cur_h_start + tw;
++
++ hpos.f.cur_h_start = graphic_hdisp.f.graphic_h_start + deviceBox.x1;
++ hpos.f.cur_h_end = graphic_hdisp.f.graphic_h_start + deviceBox.x2 + 1;
+ hpos.f.cur_en = 1;
-+ vpos.f.cur_v_start = graphic_vdisp.f.graphic_v_start + ty;
-+ vpos.f.cur_v_end = vpos.f.cur_v_start + th;
++ vpos.f.cur_v_start = graphic_vdisp.f.graphic_v_start + deviceBox.y1;
++ vpos.f.cur_v_end = graphic_vdisp.f.graphic_v_start + deviceBox.y2 + 1;
++
+ cursor_offset.f.cur_x_offset = xoffs;
+ cursor_offset.f.cur_y_offset = yoffs;
+ cursor_offset.f.cur_offset = (CARD32)
@@ -1255,7 +1254,7 @@
+ + pCurPriv->area->offset);
+ DBG_IMAGEON(("W100MoveCursor dst(x:%d,y:%d),"
+ "mapped(x:%d,y:%d,xoffs:%d,yoffs:%d)\n",
-+ x, y, tx, ty, xoffs, yoffs));
++ x, y, deviceBox.x1, deviceBox.y1, xoffs, yoffs));
+
+ W100DisableDisplayUpdate(w100c);
+ MMIO_OUT32(mmCURSOR1_OFFSET, cursor_offset.val);
@@ -1471,7 +1470,7 @@
+}
--- /dev/null
+++ xorg-server-X11R7.1-1.1.0.work/hw/kdrive/imageon/imageon_draw.c
-@@ -0,0 +1,237 @@
+@@ -0,0 +1,238 @@
+/*
+ * Copyright © 2007 Manuel Teira
+ *
@@ -1520,6 +1519,7 @@
+ KdScreenPriv(pPix->drawable.pScreen);
+ W100ScreenInfo(pScreenPriv);
+ W100CardInfo(pScreenPriv);
++ W100PortPrivPtr pPortPriv = w100s->pAdaptor->pPortPrivates[0].ptr;
+ int fifoEntries = 4;
+
+ DBG_IMAGEON(("W100PrepareSolid(alu:%d, pm:0x%08x, fg:%d)\n",
@@ -1711,7 +1711,7 @@
+}
--- /dev/null
+++ xorg-server-X11R7.1-1.1.0.work/hw/kdrive/imageon/imageon.h
-@@ -0,0 +1,261 @@
+@@ -0,0 +1,284 @@
+/*
+ * Copyright © 2007 Manuel Teira
+ *
@@ -1822,6 +1822,13 @@
+ Bool supported;
+} W100ModeSpec;
+
++typedef struct _W100BoxRec {
++ CARD16 x;
++ CARD16 y;
++ CARD16 w;
++ CARD16 h;
++} W100BoxRec, *W100BoxPtr;
++
+typedef struct _W100Mode {
+ CARD16 width;
+ CARD16 height;
@@ -1929,23 +1936,39 @@
+ CARD32 videoStatus;
+ CARD32 videoCtrl;
+ RegionRec clip;
-+ KdOffscreenArea *offSurface;
-+ CARD32 offSize;
-+ KdOffscreenArea *ovlSurface;
-+ CARD32 ovlSize;
-+ CARD32 YPlaneOffset;
-+ CARD32 UPlaneOffset;
-+ CARD32 VPlaneOffset;
-+ CARD32 colorKey;
-+ CARD8 brightness;
-+ CARD32 maxOverlaySize;
-+ CARD16 ovlX;
-+ CARD16 ovlY;
-+ CARD16 ovlWidth;
-+ CARD16 ovlHeight;
-+ CARD8 videoHorExp;
-+ CARD8 videoVerExp;
-+ int id;
++ struct {
++ int width; /* Source width */
++ int height; /* Source height */
++ unsigned char *buffer; /* Source buffer */
++ int id; /* Source FOURCC */
++ int size; /* Size of source rect (bytes) */
++ KdOffscreenArea *surface; /* Source surface (on card memory) */
++ BoxRec box; /* Source rect boundaries */
++ } src;
++ struct {
++ BoxRec box; /* Screen rectangle */
++ } dst;
++ struct {
++ int size; /* Size of the overlay surface (bytes) */
++ KdOffscreenArea *surface; /* Overlay surface (on card memory) */
++ BoxRec box; /* Overlay box (util size) */
++ BoxRec frame; /* Overlay box (plus corrections) */
++ Bool changed; /* To avoid recalculations */
++ int horExp; /* Horizontal expansion */
++ int verExp; /* Vertical expansion */
++ int maxSize; /* Maximum allowed surface size (bytes) */
++ int colorKey; /* Colour to replace with overlay */
++ int brightness; /* Brigthness */
++ } ovl;
++ struct {
++ int size; /* Number of planes */
++ int bpp; /* bpp of the planes */
++ int offset[3]; /* Planes offsets */
++ CARD32 yplane; /* Offset (card) of Y plane */
++ CARD32 uplane; /* Offset (card) of U plane */
++ CARD32 vplane; /* Offset (card) of V plane */
++ } planes;
++ Bool changed; /* To track changes and avoid recalculations */
+} W100PortPrivRec, *W100PortPrivPtr;
+
+extern KdCardFuncs W100Funcs;
@@ -6231,7 +6254,7 @@
+}
--- /dev/null
+++ xorg-server-X11R7.1-1.1.0.work/hw/kdrive/imageon/imageon_support.c
-@@ -0,0 +1,1438 @@
+@@ -0,0 +1,1474 @@
+/*
+ * Copyright © 2007 Manuel Teira
+ *
@@ -6856,7 +6879,6 @@
+ } else {
+ w100c->ctx.mask.enable = FALSE;
+ }
-+
+}
+
+Bool W100SetSource(KdScreenInfo *screen,
@@ -6962,184 +6984,140 @@
+ pPix->drawable.bitsPerPixel);
+}
+
-+int W100MapToHWX(W100CardInfo *w100c,
-+ int x, int y, int w, int h)
++void W100MapToDevice(W100CardInfo *w100c, BoxPtr src, BoxPtr dst)
+{
-+ int tx;
+ switch (w100c->hw_window.randr & RR_Rotate_All) {
+ case RR_Rotate_0:
-+ tx = x;
++ dst->x1 = src->x1;
++ dst->y1 = src->y1;
++ dst->x2 = src->x2;
++ dst->y2 = src->y2;
+ break;
+ case RR_Rotate_90:
-+ tx = w100c->hw_window.height - (y + h);
++ dst->x1 = w100c->hw_window.height - src->y2 - 1;
++ dst->y1 = src->x1;
++ dst->x2 = w100c->hw_window.height - src->y1 - 1;
++ dst->y2 = src->x2;
+ break;
+ case RR_Rotate_180:
-+ tx = w100c->hw_window.width - (x + w);
++ dst->x1 = w100c->hw_window.width - src->x2 - 1;
++ dst->y1 = w100c->hw_window.height - src->y2 - 1;
++ dst->x2 = w100c->hw_window.width - src->x1 - 1;
++ dst->y2 = w100c->hw_window.height - src->y1 - 1;
+ break;
+ case RR_Rotate_270:
-+ tx = y;
++ dst->x1 = src->y1;
++ dst->y1 = w100c->hw_window.width - src->x2 - 1;
++ dst->x2 = src->y2;
++ dst->y2 = w100c->hw_window.height - src->x1 - 1;
+ break;
-+ default:
-+ tx = x;
+ }
-+ return tx;
++ DBG_IMAGEON(("MapToDevice (x1:%d,y1:%d,x2:%d,y2:%d)->(x1:%d,y1:%d,x2:%d,y2:%d)\n",
++ src->x1, src->y1, src->x2, src->y2,
++ dst->x1, dst->y1, dst->x2, dst->y2));
+}
+
-+int W100MapToHWY(W100CardInfo *w100c,
-+ int x, int y, int w, int h)
++void W100MapFromDevice(W100CardInfo *w100c, BoxPtr src, BoxPtr dst)
+{
-+ int ty;
+ switch (w100c->hw_window.randr & RR_Rotate_All) {
+ case RR_Rotate_0:
-+ ty = y;
++ dst->x1 = src->x1;
++ dst->y1 = src->y1;
++ dst->x2 = src->x2;
++ dst->y2 = src->y2;
+ break;
+ case RR_Rotate_90:
-+ ty = x;
++ dst->x1 = src->y1;
++ dst->y1 = w100c->hw_window.height - src->x2 - 1;
++ dst->x2 = src->y2;
++ dst->y2 = w100c->hw_window.height - src->x1 - 1;
+ break;
+ case RR_Rotate_180:
-+ ty = w100c->hw_window.height - (y + h);
++ dst->x1 = w100c->hw_window.width - src->x2 - 1;
++ dst->y1 = w100c->hw_window.height - src->y2 - 1;
++ dst->x2 = w100c->hw_window.width - src->x1 - 1;
++ dst->y2 = w100c->hw_window.height - src->y1 - 1;
+ break;
+ case RR_Rotate_270:
-+ ty = w100c->hw_window.width - (x + w);
++ dst->x1 = w100c->hw_window.height - src->y2 - 1;
++ dst->y1 = src->x1;
++ dst->x2 = w100c->hw_window.width - src->y1 - 1;
++ dst->y2 = src->x2;
+ break;
-+ default:
-+ ty = y;
+ }
-+ return ty;
++ DBG_IMAGEON(("MapFromDevice (x1:%d,y1:%d,x2:%d,y2:%d)->(x1:%d,y1:%d,x2:%d,y2:%d)\n",
++ src->x1, src->y1, src->x2, src->y2,
++ dst->x1, dst->y1, dst->x2, dst->y2));
+}
+
-+int W100MapToHWW(W100CardInfo *w100c,
-+ int x, int y, int w, int h)
++void W100MoveTo(BoxPtr src, int x, int y)
+{
-+ int tw;
-+ switch (w100c->hw_window.randr & RR_Rotate_All) {
-+ case RR_Rotate_0:
-+ case RR_Rotate_180:
-+ tw = w;
-+ break;
-+ case RR_Rotate_90:
-+ case RR_Rotate_270:
-+ tw = h;
-+ break;
-+ }
-+ return tw;
++ src->x1 += x;
++ src->y1 += y;
++ src->x2 += x;
++ src->y2 += y;
+}
+
-+int W100MapToHWH(W100CardInfo *w100c,
-+ int x, int y, int w, int h)
++void W100ChangeOrigin(BoxPtr src, int x, int y)
+{
-+ int th;
-+ switch (w100c->hw_window.randr & RR_Rotate_All) {
-+ case RR_Rotate_0:
-+ case RR_Rotate_180:
-+ th = h;
-+ break;
-+ case RR_Rotate_90:
-+ case RR_Rotate_270:
-+ th = w;
-+ break;
++ src->x1 -= x;
++ src->y1 -= y;
++ src->x2 -= x;
++ src->y2 -= y;
++}
++
++void W100ScaleBox(BoxPtr src, BoxPtr dst, int scale)
++{
++ if (scale >= 0) {
++ dst->x1 = src->x1 << scale;
++ dst->x2 = src->x2 << scale;
++ dst->y1 = src->y1 << scale;
++ dst->y2 = src->y2 << scale;
++ } else {
++ dst->x1 = src->x1 >> -scale;
++ dst->x2 = src->x2 >> -scale;
++ dst->y1 = src->y1 >> -scale;
++ dst->y2 = src->y2 >> -scale;
+ }
-+ return th;
+}
+
-+CARD16 W100XformX(W100CardInfo *w100c,
-+ CARD16 x, CARD16 y, CARD16 w, CARD16 h)
++void W100TrajectoryOrigin(W100CardInfo *w100c, BoxPtr box, short *x, short *y)
+{
-+ CARD16 tx;
+ switch (w100c->ctx.xform.randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ if (w100c->ctx.xform.mirror) {
-+ tx = x + w - 1;
++ *x = box->x2;
+ } else {
-+ tx = x;
++ *x = box->x1;
+ }
++ *y = box->y1;
+ break;
+ case RR_Rotate_90:
-+ tx = x + h - 1;
-+ break;
-+ case RR_Rotate_180:
++ *x = box->x2;
+ if (w100c->ctx.xform.mirror) {
-+ tx = x;
++ *y = box->y2;
+ } else {
-+ tx = x + w - 1;
++ *y = box->y1;
+ }
+ break;
-+ case RR_Rotate_270:
-+ default:
-+ tx = x;
-+ break;
-+ }
-+ return tx;
-+}
-+
-+CARD16 W100XformY(W100CardInfo *w100c,
-+ CARD16 x, CARD16 y, CARD16 w, CARD16 h)
-+{
-+ CARD16 ty;
-+ switch (w100c->ctx.xform.randr & RR_Rotate_All) {
-+ case RR_Rotate_0:
-+ ty = y;
-+ break;
-+ case RR_Rotate_90:
++ case RR_Rotate_180:
+ if (w100c->ctx.xform.mirror) {
-+ ty = y + w - 1;
++ *x = box->x1;
+ } else {
-+ ty = y;
++ *x = box->x2;
+ }
-+ break;
-+ case RR_Rotate_180:
-+ ty = y + h - 1;
++ *y = box->y2;
+ break;
+ case RR_Rotate_270:
-+ default:
++ *x = box->x1;
+ if (w100c->ctx.xform.mirror) {
-+ ty = y;
++ *y = box->y1;
+ } else {
-+ ty = y + w - 1;
++ *y = box->y2;
+ }
-+ break;
+ }
-+ return ty;
+}
-+
-+CARD16 W100XformW(W100CardInfo *w100c,
-+ CARD16 x, CARD16 y, CARD16 w, CARD16 h)
-+{
-+ CARD16 tw;
-+
-+ switch (w100c->ctx.xform.randr & RR_Rotate_All) {
-+ case RR_Rotate_0:
-+ case RR_Rotate_180:
-+ default:
-+ tw = w;
-+ break;
-+ case RR_Rotate_90:
-+ case RR_Rotate_270:
-+ tw = h;
-+ break;
-+ }
-+ return tw;
-+}
-+
-+CARD16 W100XformH(W100CardInfo *w100c,
-+ CARD16 x, CARD16 y, CARD16 w, CARD16 h)
-+{
-+ CARD16 th;
-+
-+ switch (w100c->ctx.xform.randr & RR_Rotate_All) {
-+ case RR_Rotate_0:
-+ case RR_Rotate_180:
-+ default:
-+ th = h;
-+ break;
-+ case RR_Rotate_90:
-+ case RR_Rotate_270:
-+ th = w;
-+ break;
-+ }
-+ return th;
-+}
-+
++
+CARD8 W100GetScaler(CARD16 dstsize, CARD16 srcsize)
+{
+ return W100_MAX(1, W100_MIN(31, ((16 * srcsize) + dstsize - 1) / dstsize));
@@ -7152,22 +7130,18 @@
+}
+
+
-+static void W100Blt(KdScreenInfo *screen,
-+ int randr,
-+ int bpp,
++static void W100Blt(KdScreenInfo *screen,
++ int randr, int bpp,
+ CARD32 srcOffset,
-+ CARD16 srcW,
-+ CARD16 srcH,
+ CARD16 srcPitch,
++ BoxPtr srcBox,
+ CARD32 dstOffset,
+ CARD16 dstPitch,
-+ CARD16 dstX,
-+ CARD16 dstY)
++ BoxPtr dstBox)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ W100CardInfo(pScreenPriv);
-+ CARD16 x, y, w, h;
+ int fifoEntries = 9;
+ Bool hasXForm = FALSE;
+ eng_cntl_u eng_cntl;
@@ -7176,12 +7150,8 @@
+ src_width_u src_width;
+ src_height_u src_height;
+ dst_width_height_u dst_width_height;
-+
-+ DBG_IMAGEON(("W100Blt(randr:%d,bpp:%d,srcOffset:0x%08x,"
-+ "srcW:%d,srcH:%d,srcPitch:%d,dstOffset:0x%08x,"
-+ "dstPitch:%d,dstX:%d,dstY:%d)\n",
-+ randr, bpp, srcOffset, srcW, srcH,
-+ srcPitch, dstOffset, dstPitch, dstX, dstY));
++ CARD16 dstX;
++ CARD16 dstY;
+
+ if (randr & (RR_Rotate_90|RR_Rotate_270)) {
+ hasXForm = TRUE;
@@ -7195,21 +7165,28 @@
+ W100SetRotation(w100c, randr, FALSE);
+ W100SetSource(screen, srcPitch, srcOffset, bpp);
+ W100SetDestination(screen, dstPitch, dstOffset, bpp);
-+
-+ x = W100XformX(w100c, dstX, dstY, srcW, srcH);
-+ y = W100XformY(w100c, dstX, dstY, srcW, srcH);
-+ w = W100XformW(w100c, dstX, dstY, srcW, srcH);
-+ h = W100XformH(w100c, dstX, dstY, srcW, srcH);
-+
-+ src_x_y.f.src_y = 0;
-+ src_x_y.f.src_x = 0;
-+ dst_x_y.f.dst_x = x;
-+ dst_x_y.f.dst_y = y;
-+ src_width.f.src_width = srcW;
-+ src_height.f.src_height = srcH;
-+ dst_width_height.f.dst_height = h;
-+ dst_width_height.f.dst_width_b0 = w & 0xff;
-+ dst_width_height.f.dst_width_b1 = (w >> 8) & 0x3f;
++ W100TrajectoryOrigin(w100c, dstBox, &dstX, &dstY);
++
++ src_x_y.f.src_x = srcBox->x1;
++ src_x_y.f.src_y = srcBox->y1;
++ dst_x_y.f.dst_x = dstX;
++ dst_x_y.f.dst_y = dstY;
++ src_width.f.src_width = srcBox->x2 - srcBox->x1 + 1;
++ src_height.f.src_height = srcBox->y2 - srcBox->y1 + 1;
++ dst_width_height.f.dst_height = dstBox->y2 - dstBox->y1 + 1;
++ dst_width_height.f.dst_width_b0 = (dstBox->x2 - dstBox->x1 + 1) & 0xff;
++ dst_width_height.f.dst_width_b1 = ((dstBox->x2 - dstBox->x1 + 1) >> 8) & 0x3f;
++
++ DBG_IMAGEON(("W100Blt src(x:%d,y:%d,w:%d,h:%d) dst(x:%d,y:%d,w:%d,h:%d)\n",
++ src_x_y.f.src_x,
++ src_x_y.f.src_y,
++ src_width.f.src_width,
++ src_height.f.src_height,
++ dst_x_y.f.dst_x,
++ dst_x_y.f.dst_y,
++ dst_width_height.f.dst_width_b0 |
++ dst_width_height.f.dst_width_b1 << 8,
++ dst_width_height.f.dst_height));
+
+ if (W100WaitCmdFifoEntries(w100c, fifoEntries)) {
+ MMIO_OUT32(mmDST_PITCH, w100c->ctx.dst.pitch);
@@ -7239,20 +7216,17 @@
+ int randr,
+ int bpp,
+ CARD32 srcOffset,
-+ CARD16 srcW,
-+ CARD16 srcH,
+ CARD16 srcPitch,
++ BoxPtr srcBox,
+ CARD32 dstOffset,
+ CARD16 dstPitch,
-+ CARD16 dstX,
-+ CARD16 dstY,
++ BoxPtr dstBox,
+ CARD8 xscaler,
+ CARD8 yscaler)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ W100CardInfo(pScreenPriv);
-+ CARD16 x, y, w, h, sw, sh;
+ Bool hasXForm = FALSE;
+ dp_datatype_u dp_datatype;
+ dp_mix_u dp_mix;
@@ -7266,13 +7240,22 @@
+ dst_width_height_u dst_width_height;
+ int firstStage = 10;
+ int secondStage = 10;
-+
-+ DBG_IMAGEON(("W100StretchBlt(randr:%d,bpp:%d,srcOffset:0x%08x,"
-+ "srcW:%d,srcH:%d,srcPitch:%d,dstOffset:0x%08x,"
-+ "dstPitch:%d,dstX:%d,dstY:%d,xscaler:%d,yscaler:%d)\n",
-+ randr, bpp, srcOffset, srcW, srcH,
-+ srcPitch, dstOffset, dstPitch,
-+ dstX, dstY, xscaler, yscaler));
++ CARD16 dx, dy, sw, sh, dw, dh;
++ BoxRec dst;
++
++ DBG_IMAGEON(("W100StretchBlt(randr:%d,bpp:%d,"
++ "src(x1:%d,y1:%d,x2:%d,y2:%d,pitch:%d,offset:%d),"
++ "dst(x1:%d,y1:%d,x2:%d,y2:%d,pitch:%d,offset:%d),"
++ "xscaler:%d,yscaler:%d)\n",
++ randr, bpp,
++ srcBox->x1, srcBox->y1, srcBox->x2, srcBox->y2,
++ srcPitch, srcOffset,
++ dstBox->x1, dstBox->y1, dstBox->x2, dstBox->y2,
++ dstPitch, dstOffset,
++ xscaler, yscaler));
++
++ sw = W100ApplyScaler(srcBox->x2 - srcBox->x1 + 1, xscaler);
++ sh = W100ApplyScaler(srcBox->y2 - srcBox->y1 + 1, yscaler);
+
+ if (randr & (RR_Rotate_90|RR_Rotate_270)) {
+ hasXForm = TRUE;
@@ -7281,12 +7264,23 @@
+ eng_cntl.f.dis_src_uses_dst_dirmaj = 1;
+ ++firstStage;
+ ++secondStage;
++ dh = sw;
++ dw = sh;
++ } else {
++ dh = sh;
++ dw = sw;
+ }
+
++ dst.x1 = dstBox->x1;
++ dst.y1 = dstBox->y1;
++ dst.x2 = dst.x1 + dw - 1;
++ dst.y2 = dst.y1 + dh - 1;
++
+ W100ResetContext(w100c);
+ W100SetRotation(w100c, randr, FALSE);
+ W100SetSource(screen, srcPitch, srcOffset, bpp);
+ W100SetDestination(screen, dstPitch, dstOffset, bpp);
++ W100TrajectoryOrigin(w100c, &dst, &dx, &dy);
+
+ src_inc.val = 0;
+ src_inc.f.src_xinc = xscaler;
@@ -7308,23 +7302,15 @@
+ e2.f.srcblend = E2_SRCBLEND_ZERO;
+ e2.f.dstblend = E2_DSTBLEND_ZERO;
+
-+ sw = W100ApplyScaler(srcW, xscaler);
-+ sh = W100ApplyScaler(srcH, yscaler);
-+
-+ x = W100XformX(w100c, dstX, dstY, sw, sh);
-+ y = W100XformY(w100c, dstX, dstY, sw, sh);
-+ w = W100XformW(w100c, dstX, dstY, sw, sh);
-+ h = W100XformH(w100c, dstX, dstY, sw, sh);
-+
-+ src_x_y.f.src_y = 0;
-+ src_x_y.f.src_x = 0;
-+ dst_x_y.f.dst_x = x;
-+ dst_x_y.f.dst_y = y;
++ src_x_y.f.src_x = srcBox->x1;
++ src_x_y.f.src_y = srcBox->y1;
++ dst_x_y.f.dst_x = dx;
++ dst_x_y.f.dst_y = dy;
+ src_width.f.src_width = sw + 1;
+ src_height.f.src_height = sh;
-+ dst_width_height.f.dst_height = h;
-+ dst_width_height.f.dst_width_b0 = w & 0xff;
-+ dst_width_height.f.dst_width_b1 = (w >> 8) & 0x3f;
++ dst_width_height.f.dst_height = dh;
++ dst_width_height.f.dst_width_b0 = dw & 0xff;
++ dst_width_height.f.dst_width_b1 = (dw >> 8) & 0x3f;
+
+
+ if (W100WaitCmdFifoEntries(w100c, firstStage)) {
@@ -7373,20 +7359,17 @@
+ int randr,
+ int bpp,
+ CARD32 srcOffset,
-+ CARD16 srcW,
-+ CARD16 srcH,
+ CARD16 srcPitch,
++ BoxPtr srcBox,
+ CARD32 dstOffset,
+ CARD16 dstPitch,
-+ CARD16 dstX,
-+ CARD16 dstY,
++ BoxPtr dstBox,
+ CARD8 xscaler,
+ CARD8 yscaler)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ W100CardInfo(pScreenPriv);
-+ CARD16 x, y, w, h, sw, sh;
+ Bool hasXForm = FALSE;
+ dp_datatype_u dp_datatype;
+ dp_mix_u dp_mix;
@@ -7401,14 +7384,23 @@
+ dst_width_height_u dst_width_height;
+ int firstStage = 11;
+ int secondStage = 11;
-+
-+ DBG_IMAGEON(("W100ScaledBlt(randr:%d,bpp:%d,srcOffset:0x%08x,"
-+ "srcW:%d,srcH:%d,srcPitch:%d,dstOffset:0x%08x,"
-+ "dstPitch:%d,dstX:%d,dstY:%d,xscaler:%d,yscaler:%d)\n",
-+ randr, bpp, srcOffset, srcW, srcH,
-+ srcPitch, dstOffset, dstPitch,
-+ dstX, dstY, xscaler, yscaler));
-+
++ CARD16 dx, dy, sw, sh, dw, dh;
++ BoxRec dst;
++
++ DBG_IMAGEON(("W100ScaledBlt(randr:%d,bpp:%d,"
++ "src(x1:%d,y1:%d,x2:%d,y2:%d,pitch:%d,offset:%d),"
++ "dst(x1:%d,y1:%d,x2:%d,y2:%d,pitch:%d,offset:%d),"
++ "xscaler:%d,yscaler:%d)\n",
++ randr, bpp,
++ srcBox->x1, srcBox->y1, srcBox->x2, srcBox->y2,
++ srcPitch, srcOffset,
++ dstBox->x1, dstBox->y1, dstBox->x2, dstBox->y2,
++ dstPitch, dstOffset,
++ xscaler, yscaler));
++
++ sw = W100ApplyScaler(srcBox->x2 - srcBox->x1 + 1, xscaler);
++ sh = W100ApplyScaler(srcBox->y2 - srcBox->y1 + 1, yscaler);
++
+ if (randr & (RR_Rotate_90|RR_Rotate_270)) {
+ hasXForm = TRUE;
+ eng_cntl.val = w100c->regs.ENG_CNTL;
@@ -7416,12 +7408,27 @@
+ eng_cntl.f.dis_src_uses_dst_dirmaj = 1;
+ ++firstStage;
+ ++secondStage;
++ dh = sw;
++ dw = sh;
++ } else {
++ dh = sh;
++ dw = sw;
+ }
+
++ dst.x1 = dstBox->x1;
++ dst.y1 = dstBox->y1;
++ dst.x2 = dst.x1 + dw - 1;
++ dst.y2 = dst.y1 + dh - 1;
++
+ W100ResetContext(w100c);
+ W100SetRotation(w100c, randr, FALSE);
+ W100SetSource(screen, srcPitch, srcOffset, bpp);
+ W100SetDestination(screen, dstPitch, dstOffset, bpp);
++ W100TrajectoryOrigin(w100c, &dst, &dx, &dy);
++
++ DBG_IMAGEON(("Corrected dst(x1:%d,y1:%d,x2:%d,y2:%d). Origin(%d,%d)\n",
++ dst.x1, dst.y1, dst.x2, dst.y2,
++ dx, dy));
+
+ src_inc.val = 0;
+ src_inc.f.src_xinc = xscaler;
@@ -7446,25 +7453,18 @@
+ e2.f.srcblend = E2_SRCBLEND_ZERO;
+ e2.f.dstblend = E2_DSTBLEND_ZERO;
+
-+ sw = W100ApplyScaler(srcW, xscaler);
-+ sh = W100ApplyScaler(srcH, yscaler);
-+
-+ x = W100XformX(w100c, dstX, dstY, sw, sh);
-+ y = W100XformY(w100c, dstX, dstY, sw, sh);
-+ w = W100XformW(w100c, dstX, dstY, sw, sh);
-+ h = W100XformH(w100c, dstX, dstY, sw, sh);
+
-+ src_x_y.f.src_y = 0;
-+ src_x_y.f.src_x = 0;
-+ src2_x_y.f.src_y = 0 + 4;
-+ src2_x_y.f.src_x = 0;
-+ dst_x_y.f.dst_x = x;
-+ dst_x_y.f.dst_y = y;
++ src_x_y.f.src_x = srcBox->x1;
++ src_x_y.f.src_y = srcBox->y1;
++ src2_x_y.f.src_x = srcBox->x1;
++ src2_x_y.f.src_y = srcBox->y1 + 4;
++ dst_x_y.f.dst_x = dx;
++ dst_x_y.f.dst_y = dy;
+ src_width.f.src_width = sw + 1;
+ src_height.f.src_height = sh;
-+ dst_width_height.f.dst_height = h;
-+ dst_width_height.f.dst_width_b0 = w & 0xff;
-+ dst_width_height.f.dst_width_b1 = (w >> 8) & 0x3f;
++ dst_width_height.f.dst_height = dh;
++ dst_width_height.f.dst_width_b0 = dw & 0xff;
++ dst_width_height.f.dst_width_b1 = (dw >> 8) & 0x3f;
+
+ if (W100WaitCmdFifoEntries(w100c, firstStage)) {
+ /* Set Source */
@@ -7517,82 +7517,93 @@
+}
+
+void W100PlanarBlt(KdScreenInfo *screen,
-+ int planes,
-+ int bpp,
-+ int randr,
++ int planes, int planeOffsets[],
++ int bpp, int randr,
+ KdOffscreenArea *src,
+ int srcW,
-+ int srcPitch,
+ int srcH,
++ BoxPtr srcBox,
+ KdOffscreenArea *dst,
-+ int planeOffsets[],
+ int dstW,
-+ int dstPitch,
+ int dstH,
-+ int dstX,
-+ int dstY)
++ BoxPtr dstBox)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ W100CardInfo(pScreenPriv);
+ W100ScreenInfo(pScreenPriv);
++
++ CARD16 dstBoxW, dstBoxH, srcBoxW, srcBoxH;
+ CARD8 *srcOffset, *dstBase, *dstOffset;
-+ int xoffs, yoffs;
++ int xerror, yerror;
+ unsigned int subsampling[] = {0, 1, 1};
+ int plane;
-+ int stretch = ((srcW != dstW) || (srcH != dstH));
++ srcBoxW = srcBox->x2 - srcBox->x1 + 1;
++ srcBoxH = srcBox->y2 - srcBox->y1 + 1;
++ if (randr & (RR_Rotate_90 | RR_Rotate_270)) {
++ dstBoxW = dstBox->y2 - dstBox->y1 + 1;
++ dstBoxH = dstBox->x2 - dstBox->x1 + 1;
++ } else {
++ dstBoxW = dstBox->x2 - dstBox->x1 + 1;
++ dstBoxH = dstBox->y2 - dstBox->y1 + 1;
++ }
++
++ Bool stretch = ((srcBoxW != dstBoxW) || (srcBoxH != dstBoxH));
+ CARD8 xscaler, yscaler;
++ BoxRec dstb = *dstBox;
+
+ DBG_IMAGEON(("W100PlanarBlt(planes:%d,bpp:%d,randr:%d,"
-+ "src(w:%d,pitch:%d,h:%d),"
-+ "dst(w:%d,pitch:%d,h:%d,x:%d,y:%d)\n",
++ "src(x1:%d,y1:%d,x2:%d,y2:%d,w:%d,h:%d),"
++ "dst(x1:%d,y1:%d,x2:%d,y2:%d,w:%d,h:%d)\n",
+ planes, bpp, randr,
-+ srcW, srcPitch, srcH,
-+ dstW, dstPitch, dstH, dstX, dstY));
++ srcBox->x1, srcBox->y1, srcBox->x2, srcBox->y2, srcW, srcH,
++ dstBox->x1, dstBox->y1, dstBox->x2, dstBox->y2, dstW, dstH));
+
++ xerror = yerror = 0;
+ if (stretch) {
-+ xscaler = W100GetScaler(dstW, srcW);
-+ yscaler = W100GetScaler(dstH, srcH);
-+ xoffs = yoffs = 0;
++ xscaler = W100GetScaler(dstBoxW, srcBoxW);
++ yscaler = W100GetScaler(dstBoxH, srcBoxH);
+ if (xscaler != 16 || yscaler != 16) {
-+ xoffs = (dstW - W100ApplyScaler(srcW, xscaler)) / 2;
-+ yoffs = (dstH - W100ApplyScaler(srcH, yscaler)) / 2;
++ xerror = (dstBoxW - W100ApplyScaler(srcBoxW, xscaler)) / 2;
++ yerror = (dstBoxH - W100ApplyScaler(srcBoxH, yscaler)) / 2;
+ DBG_IMAGEON(("Stretching with xscaler:%d,yscaler:%d,"
-+ "xoffs:%d,yoffs:%d\n",
-+ xscaler, yscaler, xoffs, yoffs));
++ "xerror:%d,yerror:%d\n",
++ xscaler, yscaler, xerror, yerror));
+ } else {
-+ xoffs = yoffs = 0;
++ xerror = yerror = 0;
+ stretch = FALSE;
+ }
+ }
+
++ W100MoveTo(&dstb, xerror, yerror);
++
+ srcOffset = src->vidmem->base + src->offset;
+ dstBase = dst->vidmem->base + dst->offset;
+ for (plane = 0; plane < planes; plane++) {
++ BoxRec srcCBox;
++ BoxRec dstCBox;
+ dstOffset = dstBase + planeOffsets[plane];
++ W100ScaleBox(srcBox, &srcCBox, -subsampling[plane]);
++ W100ScaleBox(&dstb, &dstCBox, -subsampling[plane]);
+ if (stretch) {
+ W100ScaledBlt(screen, randr, bpp,
+ (CARD32) srcOffset,
+ srcW >> subsampling[plane],
-+ srcH >> subsampling[plane],
-+ srcPitch >> subsampling[plane],
++ &srcCBox,
+ (CARD32) dstOffset,
-+ dstPitch >> subsampling[plane],
-+ (dstX + xoffs) >> subsampling[plane],
-+ (dstY + yoffs) >> subsampling[plane],
++ dstW >> subsampling[plane],
++ &dstCBox,
+ xscaler, yscaler);
+ } else {
+ W100Blt(screen, randr, bpp,
+ (CARD32) srcOffset,
+ srcW >> subsampling[plane],
-+ srcH >> subsampling[plane],
-+ srcPitch >> subsampling[plane],
++ &srcCBox,
+ (CARD32) dstOffset,
-+ dstPitch >> subsampling[plane],
-+ dstX >> subsampling[plane],
-+ dstY >> subsampling[plane]);
++ dstW >> subsampling[plane],
++ &dstCBox);
+ }
-+ srcOffset += (srcPitch * srcH) >> (subsampling[plane] * 2);
++ srcOffset += (srcW * srcH) >> (subsampling[plane] * 2);
+ }
+}
+
@@ -7668,11 +7679,59 @@
+ *y >>= 1;
+ }
+}
-+
++
++void W100VSync(W100CardInfo *w100c)
++{
++ int timeout = 30000; /* VSync timeout = 30[ms] > 16.8[ms] */
++ active_v_disp_u active_v_disp;
++ disp_int_cntl_u disp_int_cntl;
++ gen_int_cntl_u gen_int_cntl;
++ gen_int_status_wr_u gen_int_status;
++
++ active_v_disp.val = MMIO_IN32(mmACTIVE_V_DISP);
++
++ /*set vline pos */
++ disp_int_cntl.val = 0;
++ disp_int_cntl.f.vline_int_pos = active_v_disp.f.active_v_end;
++ MMIO_OUT32(mmDISP_INT_CNTL, disp_int_cntl.val);
++
++ /* disable vline irq */
++ gen_int_cntl.val = MMIO_IN32(mmGEN_INT_CNTL);
++ gen_int_cntl.f.crtc_vline_mask = 0;
++ MMIO_OUT32(mmGEN_INT_CNTL, gen_int_cntl.val);
++
++ /* clear vline irq status */
++ gen_int_status.val = 0;
++ gen_int_status.f.crtc_vline_stat_ak = 1;
++ MMIO_OUT32(mmGEN_INT_STATUS, gen_int_status.val);
++
++ /* enable vline irq */
++ gen_int_cntl.f.crtc_vline_mask = 1;
++ MMIO_OUT32(gen_int_cntl.val, mmGEN_INT_CNTL);
++
++ /* clear vline irq status */
++ MMIO_OUT32(mmGEN_INT_STATUS, gen_int_status.val);
++
++ while (timeout > 0) {
++ if (MMIO_IN32(mmGEN_INT_STATUS) & 0x00000002) {
++ break;
++ }
++ usleep(1);
++ timeout--;
++ }
++
++ /* disable vline irq */
++ gen_int_cntl.f.crtc_vline_mask = 0;
++ MMIO_OUT32(mmGEN_INT_CNTL, gen_int_cntl.val);
++
++ /* clear vline irq status */
++ MMIO_OUT32(mmGEN_INT_STATUS, gen_int_status.val);
++}
++
+
--- /dev/null
+++ xorg-server-X11R7.1-1.1.0.work/hw/kdrive/imageon/imageon_video.c
-@@ -0,0 +1,1051 @@
+@@ -0,0 +1,1170 @@
+/*
+ * Copyright © 2007 Manuel Teira
+ *
@@ -7754,19 +7813,32 @@
+static struct {
+ CARD8 xfactor;
+ CARD8 yfactor;
-+} ovlResizers[10] = {
-+ { 0, 0 },
-+ { 1, 0 },
-+ { 0, 1 },
-+ { 1, 1 },
-+ { 2, 1 },
-+ { 1, 2 },
-+ { 2, 2 },
-+ { 3, 2 },
-+ { 2, 3 },
-+ { 3, 3 }
++} ovlResizers[NUM_OVL_RESIZERS] = {
++ { 0, 0 },
++ { 0, 1 }, { 1, 0 }, { 1, 1 },
++ { 1, 2 }, { 2, 1 }, { 2, 2 },
++ { 2, 3 }, { 3, 2 }, { 3, 3 }
+};
+
++static int W100SurfaceSize(W100PortPrivPtr port, short w, short h)
++{
++ int size = 0;
++ DBG_IMAGEON(("W100SurfaceSize for id=%08x, w=%d, h=%d\n",
++ port->src.id, w, h));
++
++ switch (port->src.id) {
++ case FOURCC_YV12:
++ case FOURCC_I420:
++ size = (3 * w * h) / 2;
++ break;
++ case FOURCC_UYVY:
++ case FOURCC_YUY2:
++ size = w * h * 2;
++ break;
++ }
++ return size;
++}
++
+static void W100ClearSurface(KdScreenInfo *screen,
+ KdOffscreenArea *area,
+ CARD16 x,
@@ -7825,8 +7897,8 @@