📄 neomagic.diff
字号:
++ dstBox.x1 = drw_x;+ dstBox.y1 = drw_y;+ dstBox.x2 = drw_x + drw_w;+ dstBox.y2 = drw_y + drw_h;++ if (!NEOClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, src_w, src_h)){+ return(Success);+ }+#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutVideo: %d %d %d %d\n", x1, y1, x2, y2);+#endif++ dstBox.x1 -= pScrn->frameX0;+ dstBox.y1 -= pScrn->frameY0;+ dstBox.x2 -= pScrn->frameX0;+ dstBox.y2 -= pScrn->frameY0;+#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutVideo: dstBox %d %d %d %d\n", dstBox.x1, dstBox.y1, dstBox.x2, dstBox.y2);+#endif++ bpp = pScrn->bitsPerPixel >> 3;+ src_pitch = (src_w + 7) & ~7;++ xscale = 0x1000;+ if (src_w <= drw_w){+ xscale = (src_w * 0x1000 / drw_w) & 0xffff;+ }++ yscale = 0x0800;+ if (src_h <= drw_h){+ yscale = (src_h * 0x0800 / drw_h) & 0xffff;+ }++ size = src_h * src_pitch;+ if ((pPriv->linear = NEOAllocateMemory(pScrn, pPriv->linear, size)) == NULL){+ return (BadAlloc);+ }+ offset = pPriv->linear->offset * bpp;+#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutVideo: offset=0x%x\n", offset);+#endif+ memset(nPtr->NeoFbBase + offset, 0, size);++ if (!RegionsEqual(&pPriv->clip, clipBoxes)){+ REGION_COPY(pScreen, &pPriv->clip, clipBoxes);+ XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0,+ REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes));+ }++ x1 >>= 16;+ y1 >>= 16;+ x2 >>= 16;+ y2 >>= 16;++ OUTGR(0xb1, (((dstBox.x2-1)>>4)&0xf0)|((dstBox.x1>>8)&0x0f));+ OUTGR(0xb2, dstBox.x1);+ OUTGR(0xb3, dstBox.x2-1);+ OUTGR(0xb4, (((dstBox.y2-1)>>4)&0xf0)|((dstBox.y1>>8)&0x0f));+ OUTGR(0xb5, dstBox.y1);+ OUTGR(0xb6, dstBox.y2-1);+ OUTGR(0xb7, offset >> 17);+ OUTGR(0xb8, offset >> 9);+ OUTGR(0xb9, offset >> 1);+ OUTGR(0xba, src_pitch >> 8);+ OUTGR(0xbb, src_pitch);++ OUTGR(0xbc, 0x4f);++ OUTGR(0xc0, xscale >> 8);+ OUTGR(0xc1, xscale);+ OUTGR(0xc2, yscale >> 8);+ OUTGR(0xc3, yscale);+ OUTGR(0xbf, 0x02);++ OUTGR(0x0a, 0x21);++ OUTSR(0x0c, offset >> 1);+ OUTSR(0x0d, offset >> 9);+ OUTSR(0x0e, offset >> 17);+ OUTSR(0x1a, src_pitch);+ OUTSR(0x1b, src_pitch>>8);++ OUTSR(0x17, 0+x1);+ OUTSR(0x18, 0+x2-1);+ OUTSR(0x19, (((0+x2-1)>>4)&0xf0)|(((0+x1)>>8)&0x0f));++ OUTSR(0x14, 14 + y1/2);+ OUTSR(0x15, 14 + y2/2 - 2);+ OUTSR(0x16, 0);++ OUTSR(0x1c, 0xfb);+ OUTSR(0x1d, 0x00);+ OUTSR(0x1e, 0xe2);+ OUTSR(0x1f, 0x02);++ OUTSR(0x09, 0x11);+ OUTSR(0x0a, 0x00);+ OUTSR(0x08, 0xa1);++#if 0+ OUTGR(0x0a, 0x01);+#endif+ OUTGR(0xb0, 0x03);++ pPriv->video_status = CLIENT_VIDEO_ON;+ return (Success);+}++static void+NEOStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit)+{+ NEOPortPtr pPriv = (NEOPortPtr)data;+ NEOPtr nPtr = NEOPTR(pScrn);++#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOStopVideo\n");+#endif+ REGION_EMPTY(pScrn->pScreen, &pPriv->clip);++ if (exit){+ if (pPriv->video_status & CLIENT_VIDEO_ON){+#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOStopVideo: stop capture\n");+#endif+ OUTGR(0xb0, 0x02);+ OUTGR(0x0a, 0x21);+ OUTSR(0x08, 0xa0);+#if 0+ OUTGR(0x0a, 0x01);+#endif+ }+ if (pPriv->linear != NULL){+ xf86FreeOffscreenLinear(pPriv->linear);+ pPriv->linear = NULL;+ }+ pPriv->video_status = 0;+ } else {+ if (pPriv->video_status & CLIENT_VIDEO_ON){+ OUTGR(0xb0, 0x02);+ OUTGR(0x0a, 0x21);+ OUTSR(0x08, 0xa0);+#if 0+ OUTGR(0x0a, 0x01);+#endif+ pPriv->video_status |= OFF_TIMER;+ pPriv->offTime = currentTime.milliseconds + OFF_DELAY;+ }+ }+}++static int+NEOSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 value, pointer data)+{+ NEOPortPtr pPriv = (NEOPortPtr)data;+ NEOPtr nPtr = NEOPTR(pScrn);++#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOSetPortAttribute\n");+#endif+ if (attribute == xvColorKey){+ int r, g, b;++ pPriv->colorKey = value;+ switch (pScrn->depth){+ case 8:+ OUTGR(0xc6, pPriv->colorKey & 0xff);+ OUTGR(0xc5, 0x00);+ OUTGR(0xc7, 0x00);+ break;+ default:+ r = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red;+ g = (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green;+ b = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue;+ OUTGR(0xc5, r);+ OUTGR(0xc6, g);+ OUTGR(0xc7, b);+ }+ } else if (attribute == xvBrightness){+ if ((value < -128) || (value > 127)){+ return (BadValue);+ }+ pPriv->brightness = value;+ OUTGR(0xc4, value);+ } else {+ return (BadMatch);+ }+ return (Success);+}++static int+NEOGetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 *value, pointer data)+{+ NEOPortPtr pPriv = (NEOPortPtr)data;++#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOGetPortAttribute\n");+#endif+ if (attribute == xvColorKey){+ *value = pPriv->colorKey;+ } else if (attribute == xvBrightness){+ *value = pPriv->brightness;+ } else {+ return (BadMatch);+ }+ return (Success);+}++static void+NEOQueryBestSize(ScrnInfoPtr pScrn, Bool motion, + short vid_w, short vid_h, short drw_w, short drw_h,+ unsigned int *p_w, unsigned int *p_h,+ pointer data)+{+#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOQueryBestSize\n");+#endif+ *p_w = min(drw_w, 1024);+ *p_h = min(drw_h, 1024);+}++static int+NEOPutImage(ScrnInfoPtr pScrn, + short src_x, short src_y, short drw_x, short drw_y,+ short src_w, short src_h, short drw_w, short drw_h,+ int id, unsigned char *buf, short width, short height,+ Bool sync, RegionPtr clipBoxes, pointer data)+{+ NEOPtr nPtr = NEOPTR(pScrn);+ NEOPortPtr pPriv = (NEOPortPtr)nPtr->overlayAdaptor->pPortPrivates[0].ptr;+ INT32 x1, y1, x2, y2;+ int bpp;+ int srcPitch, srcPitch2 = 0, dstPitch, size;+ BoxRec dstBox;+ CARD32 offset, offset2 = 0, offset3 = 0, tmp;+ int left, top, nPixels, nLines;+ unsigned char *dstStart;++#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutImage\n");+#endif+ x1 = src_x;+ y1 = src_y;+ x2 = src_x + src_w;+ y2 = src_y + src_h;++ dstBox.x1 = drw_x;+ dstBox.y1 = drw_y;+ dstBox.x2 = drw_x + drw_w;+ dstBox.y2 = drw_y + drw_h;++ if (!NEOClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, height)){+ return (Success);+ }++ dstBox.x1 -= pScrn->frameX0;+ dstBox.y1 -= pScrn->frameY0;+ dstBox.x2 -= pScrn->frameX0;+ dstBox.y2 -= pScrn->frameY0;++ bpp = 2;+ switch (id){+ case FOURCC_YV12:+ srcPitch = (width + 3) & ~3;+ offset2 = srcPitch * height;+ srcPitch2 = ((width >> 1) + 3) & ~3;+ offset3 = offset2 + (srcPitch2 * (height >> 1));+ dstPitch = ((width << 1) + 15) & ~15;+ break;+ case FOURCC_I420:+ srcPitch = (width + 3) & ~3;+ offset3 = srcPitch * height;+ srcPitch2 = ((width >> 1) + 3) & ~3;+ offset2 = offset3 + (srcPitch2 * (height >> 1));+ dstPitch = ((width << 1) + 15) & ~15;+ break;+ case FOURCC_YUY2:+ case FOURCC_RV15:+ case FOURCC_RV16:+ default:+ srcPitch = width * bpp;+ dstPitch = (srcPitch + 15) & ~15;+ break;+ }++ size = dstPitch * height;+ if ((pPriv->linear = NEOAllocateMemory(pScrn, pPriv->linear, size)) == NULL){+ return (BadAlloc);+ }++ top = y1 >> 16;+ left = (x1 >> 16) & ~1;+ nPixels = ((((x2 + 0xFFFF) >> 16) + 1) & ~1) - left;+ left *= bpp;++ offset = pPriv->linear->offset * bpp;+ dstStart = (unsigned char *)(nPtr->NeoFbBase + offset + left);++ switch (id){+ case FOURCC_YV12:+ case FOURCC_I420:+ top &= ~1;+ tmp = ((top >> 1) * srcPitch2) + (left >> 2);+ offset2 += tmp;+ offset3 += tmp;+ nLines = ((((y2 + 0xFFFF) >> 16) + 1) & ~1) - top;+ NEOCopyYV12Data(buf + (top * srcPitch) + (left >> 1), buf + offset2, buf + offset3, dstStart, srcPitch, srcPitch2, dstPitch, nLines, nPixels);+ break;+ default:+ buf += (top * srcPitch) + left;+ nLines = ((y2 + 0xFFFF) >> 16) - top;+ NEOCopyData(buf, dstStart, srcPitch, dstPitch, nLines, nPixels * bpp);+ }++ if (!RegionsEqual(&pPriv->clip, clipBoxes)){+ REGION_COPY(pScreen, &pPriv->clip, clipBoxes);+ XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes));+ }++ NEODisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2,+ &dstBox, src_w, src_h, drw_w, drw_h);++ pPriv->video_status = CLIENT_VIDEO_ON;+ return (Success);+ +}++static int+NEOQueryImageAttributes(ScrnInfoPtr pScrn, int id, + unsigned short *width, unsigned short *height,+ int *pitches, int *offsets)+{+ int size, tmp;++#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOQueryImageAttributes\n");+#endif+ if (*width > 1024){+ *width = 1024;+ }+ if (*height > 1024){+ *height = 1024;+ }++ *width = (*width + 1) & ~1;+ if (offsets != NULL){+ offsets[0] = 0;+ }++ switch (id){+ case FOURCC_YV12:+ case FOURCC_I420:+ *height = (*height + 1) & ~1;+ size = (*width + 3) & ~3;+ if (pitches != NULL){+ pitches[0] = size;+ }+ size *= *height;+ if (offsets != NULL){+ offsets[1] = size;+ }+ tmp = ((*width >> 1) + 3) & ~3;+ if (pitches != NULL){+ pitches[1] = pitches[2] = tmp;+ }+ tmp *= (*height >> 1);+ size += tmp;+ if (offsets != NULL){+ offsets[2] = size;+ }+ size += tmp;+ break;+ case FOURCC_YUY2:+ case FOURCC_RV15:+ case FOURCC_RV16:+ default:+ size = *width * 2;+ if (pitches != NULL){+ pitches[0] = size;+ }+ size *= *height;+ break;+ }+ return (size);+}++static Bool+RegionsEqual(RegionPtr A, RegionPtr B)+{+ int *dataA, *dataB;+ int num;++ num = REGION_NUM_RECTS(A);+ if (num != REGION_NUM_RECTS(B)){+ return (FALSE);+ }++ if ((A->extents.x1 != B->extents.x1)+ || (A->extents.y1 != B->extents.y1)+ || (A->extents.x2 != B->extents.x2)+ || (A->extents.y2 != B->extents.y2)){+ return (FALSE);+ }++ dataA = (int*) REGION_RECTS(A);+ dataB = (int*) REGION_RECTS(B);++ while (num--){+ if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])){+ return (FALSE);+ }+ dataA += 2;+ dataB += 2;+ }+ return (TRUE);+}++static Bool+NEOClipVideo(ScrnInfoPtr pScrn, BoxPtr dst, + INT32 *x1, INT32 *y1, INT32 *x2, INT32 *y2,+ RegionPtr reg, INT32 width, INT32 height)+{+ INT32 vscale, hscale, delta;+ BoxPtr extents = REGION_EXTENTS(pScrn, reg);+ int diff;++#ifdef DEBUG+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOClipVideo\n");+#endif+ extents->x1 = max(extents->x1, pScrn->frameX0);+ extents->y1 = max(extents->y1, pScrn->frameY0);++ hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);+ vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);++ *x1 <<= 16; *y1 <<= 16;+ *x2 <<= 16; *y2 <<= 16;++ diff = extents->x1 - dst->x1;+ if (diff > 0){+ dst->x1 = extents->x1;+ *x1 += diff * hscale;+ }+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -