Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 101372 Details for
Bug 140323
ebuild for ivtvdev xdriver
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
ivtv-0.10.6-r1-xorg.patch
ivtv-0.10.6-r1-xorg.patch (text/plain), 130.77 KB, created by
Jeffrey Gardner (RETIRED)
on 2006-11-06 20:59:51 UTC
(
hide
)
Description:
ivtv-0.10.6-r1-xorg.patch
Filename:
MIME Type:
Creator:
Jeffrey Gardner (RETIRED)
Created:
2006-11-06 20:59:51 UTC
Size:
130.77 KB
patch
obsolete
>diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/Imakefile ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/Imakefile >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/Imakefile 2006-11-06 20:52:19.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/Imakefile 1969-12-31 18:00:00.000000000 -0600 >@@ -1,55 +0,0 @@ >-XCOMM >-XCOMM This is an Imakefile for the fbdev driver. >-XCOMM >-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile,v 1.10 2001/04/06 18:16:30 dawes Exp $ >-#undef DefaultCCOptions >-#define DefaultCCOptions >-#define IHaveModules >-#include <Server.tmpl> >- >-SRCS = ivtvdev.c ivtvhw.c ivtv_xv.c >-OBJS = ivtvdev.o ivtvhw.o ivtv_xv.o >- >-#if defined(XF86DriverSDK) >-INCLUDES = -I. -I../../include >-#else >-INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ >- -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ >- -I$(SERVERSRC)/fb -I$(XF86SRC)/xaa \ >- -I$(XF86SRC)/fbdevhw -I$(XF86SRC)/ramdac \ >- -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ >- -I$(XF86SRC)/rac \ >- -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf24_32bpp\ >- -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ >- -I$(SERVERSRC)/miext/shadow -I$(EXTINCSRC) -I$(SERVERSRC)/render >-#endif >-#ifdef XF86_VERSION_CURRENT >-XCOMM We are using Xfree86 >- >-#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,99,16,0) >-DEFREGIONNULL = -DX_USE_REGION_NULL >-#endif >- >-#else >-XCOMM We are using X.org >-DEFREGIONNULL = -DX_USE_REGION_NULL >-#endif >-DEFINES = FbdevDefines $(DEFREGIONNULL) >- >-#if MakeHasPosixVariableSubstitutions >-SubdirLibraryRule($(OBJS)) >-#endif >- >-ModuleObjectRule() >- >-ObjectModuleTarget(ivtvdev,$(OBJS)) >- >-InstallObjectModule(ivtvdev,$(MODULEDIR),drivers) >- >- >-DependTarget() >- >-InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/ivtvdev) >-InstallDriverSDKNonExecFile(ivtvdev.c,$(DRIVERSDKDIR)/drivers/ivtvdev) >- >-InstallDriverSDKObjectModule(ivtvdev,$(DRIVERSDKMODULEDIR),drivers) >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvdev.c ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvdev.c >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvdev.c 2006-11-06 20:52:19.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvdev.c 1969-12-31 18:00:00.000000000 -0600 >@@ -1,605 +0,0 @@ >-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtv.c,v 1.42 2002/10/10 01:35:20 dawes Exp $ */ >- >-/* >- * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> >- * Michel Dänzer, <michdaen@iiic.ethz.ch> >- */ >- >-#include "ivtvhw.h" >-#include "ivtvdev.h" >-/* all driver need this */ >-#include "xf86.h" >-#include "xf86_OSproc.h" >-#include "xf86_ansic.h" >- >-#include "mipointer.h" >-#include "mibstore.h" >-#include "micmap.h" >-#include "colormapst.h" >-#include "xf86cmap.h" >-#include "shadow.h" >- >-/* for visuals */ >-#include "fb.h" >- >-#include "xf86Resources.h" >-#include "xf86RAC.h" >- >-#ifdef XvExtension >-#include "xf86xv.h" >-#endif >-enum HAUPAGE_CHIPTAGS { >- PVR_UNKNOWN = 0, >- PVR_350, >- PVR_LAST >-}; >-#define PCI_CHIP_PVR350 0x0803 >- >-static SymTabRec IVTVChipsets[] = { >- {PVR_350, "PVR-350"}, >- {-1, NULL} >-}; >- >-/* This table maps a PCI device ID to a chipset family identifier. */ >-static PciChipsets IVTVPciChipsets[] = { >- {PVR_350, PCI_CHIP_PVR350, RES_SHARED_VGA}, >- {-1, -1, RES_UNDEFINED} >-}; >- >-#define DEBUG 0 >- >-#if DEBUG >-# define TRACE_ENTER(str) ErrorF("ivtv: " str " %d\n",pScrn->scrnIndex) >-# define TRACE_EXIT(str) ErrorF("ivtv: " str " done\n") >-# define TRACE(str) ErrorF("ivtv trace: " str "\n") >-#else >-# define TRACE_ENTER(str) >-# define TRACE_EXIT(str) >-# define TRACE(str) >-#endif >- >-/* -------------------------------------------------------------------- */ >-/* prototypes */ >- >-static const OptionInfoRec *IVTVDevAvailableOptions(int chipid, int busid); >-static void IVTVDevIdentify(int flags); >-static Bool IVTVDevProbe(DriverPtr drv, int flags); >-static Bool IVTVDevPreInit(ScrnInfoPtr pScrn, int flags); >-static Bool IVTVDevScreenInit(int Index, ScreenPtr pScreen, int argc, >- char **argv); >-static Bool IVTVDevCloseScreen(int scrnIndex, ScreenPtr pScreen); >- >-/* -------------------------------------------------------------------- */ >- >-/* >- * This is intentionally screen-independent. It indicates the binding >- * choice made in the first PreInit. >- */ >-static int pix24bpp = 0; >- >-#define VERSION 4000 >-#define IVTVDEV_NAME "IVTVDEV_TST" >-#define IVTVDEV_DRIVER_NAME "ivtvdev" >-#define IVTVDEV_MAJOR_VERSION 0 >-#define IVTVDEV_MINOR_VERSION 10 >- >-DriverRec IVTVDEV = { >- VERSION, >- IVTVDEV_DRIVER_NAME, >-#if 0 >- "driver for linux framebuffer devices", >-#endif >- IVTVDevIdentify, >- IVTVDevProbe, >- IVTVDevAvailableOptions, >- NULL, >- 0 >-}; >- >-/* Supported options */ >-typedef enum { >- OPTION_IVTVDEV >-} IVTVDevOpts; >- >-static const OptionInfoRec IVTVDevOptions[] = { >- {OPTION_IVTVDEV, "ivtv", OPTV_STRING, {0}, FALSE}, >- {-1, NULL, OPTV_NONE, {0}, FALSE} >-}; >- >-/* -------------------------------------------------------------------- */ >- >-static const char *fbSymbols[] = { >- "fbScreenInit", >- "fbPictureInit", >- NULL >-}; >- >-static const char *shadowSymbols[] = { >- "shadowAdd", >- "shadowAlloc", >- "shadowInit", >- "shadowSetup", >- "shadowUpdatePacked", >- "shadowUpdateRotatePacked", >- NULL >-}; >- >-#ifdef XFree86LOADER >- >-MODULESETUPPROTO(IVTVDevSetup); >- >-static XF86ModuleVersionInfo IVTVDevVersRec = { >- "ivtv", >- MODULEVENDORSTRING, >- MODINFOSTRING1, >- MODINFOSTRING2, >- XF86_VERSION_CURRENT, >- IVTVDEV_MAJOR_VERSION, IVTVDEV_MINOR_VERSION, 6, >- ABI_CLASS_VIDEODRV, >- ABI_VIDEODRV_VERSION, >- NULL, >- {0, 0, 0, 0} >-}; >- >-XF86ModuleData ivtvdevModuleData = { &IVTVDevVersRec, IVTVDevSetup, NULL }; >- >-pointer IVTVDevSetup(pointer module, pointer opts, int *errmaj, int *errmin) >-{ >- static Bool setupDone = FALSE; >- >- if (!setupDone) { >- setupDone = TRUE; >- xf86AddDriver(&IVTVDEV, module, 0); >- LoaderRefSymLists(fbSymbols, shadowSymbols, NULL); >- return (pointer) 1; >- } else { >- if (errmaj) >- *errmaj = LDR_ONCEONLY; >- return NULL; >- } >-} >- >-#endif /* XFree86LOADER */ >- >-void FBshadowUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) >-{ >- >- RegionPtr damage = &pBuf->damage; >- int nbox = REGION_NUM_RECTS(damage); >- BoxPtr pbox = REGION_RECTS(damage); >- >- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >- IVTVDevPtr fPtr = IVTVDEVPTR(pScrn); >- int x1 = pScrn->virtualX; >- int x2 = 0; >- int y1 = pScrn->virtualY; >- int y2 = 0; >- while (nbox--) { >- if (pbox->x1 < x1) >- x1 = pbox->x1; >- if (pbox->x2 > x2) >- x2 = pbox->x2; >- if (pbox->y1 < y1) >- y1 = pbox->y1; >- if (pbox->y2 > y2) >- y2 = pbox->y2; >- pbox++; >- }; >- >- ivtvHWSendDMA(pScrn, fPtr->shadowmem, x1, x2, y1, y2); >-} >- >-static Bool IVTVDevGetRec(ScrnInfoPtr pScrn) >-{ >- if (pScrn->driverPrivate != NULL) >- return TRUE; >- >- pScrn->driverPrivate = xnfcalloc(sizeof(IVTVDevRec), 1); >- return TRUE; >-} >- >-static void IVTVDevFreeRec(ScrnInfoPtr pScrn) >-{ >- if (pScrn->driverPrivate == NULL) >- return; >- xfree(pScrn->driverPrivate); >- pScrn->driverPrivate = NULL; >-} >- >-/* -------------------------------------------------------------------- */ >- >-static const OptionInfoRec *IVTVDevAvailableOptions(int chipid, int busid) >-{ >- return IVTVDevOptions; >-} >- >-static void IVTVDevIdentify(int flags) >-{ >- xf86PrintChipsets(IVTVDEV_NAME, "driver for framebuffer", IVTVChipsets); >-} >- >-static Bool IVTVDevProbe(DriverPtr drv, int flags) >-{ >- int i; >- ScrnInfoPtr pScrn; >- GDevPtr *devSections; >- int numDevSections; >- int bus, device, func; >- char *dev; >- Bool foundScreen = FALSE; >- int *usedChips; >- int numUsed; >- TRACE("probe start"); >- >- /* For now, just bail out for PROBE_DETECT. */ >- if (flags & PROBE_DETECT) >- return FALSE; >- >- /* sanity checks */ >- if ((numDevSections = >- xf86MatchDevice(IVTVDEV_DRIVER_NAME, &devSections)) <= 0) >- return FALSE; >- >- if (xf86GetPciVideoInfo() == NULL) >- return FALSE; >- >- numUsed = xf86MatchPciInstances(IVTVDEV_DRIVER_NAME, >- PCI_HAUPAGGE_VENDOR_ID, >- IVTVChipsets, >- IVTVPciChipsets, >- devSections, >- numDevSections, drv, &usedChips); >- >- if (numUsed <= 0) >- return FALSE; >- >- if (flags & PROBE_DETECT) { >- foundScreen = TRUE; >- } else { >- for (i = 0; i < numUsed; i++) { >- ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); >- EntityInfoPtr pEnt; >- dev = >- xf86FindOptionValue(devSections[i]->options, >- "fbdev"); >- if (ivtvHWProbe(NULL, dev, NULL)) { >- pScrn = >- xf86ConfigPciEntity(pScrn, 0, usedChips[i], >- IVTVPciChipsets, 0, 0, >- 0, 0, 0); >- >- /* xf86DrvMsg() can't be called without setting these */ >- pScrn->driverName = IVTVDEV_DRIVER_NAME; >- pScrn->name = IVTVDEV_NAME; >- >- if (pScrn) { >- foundScreen = TRUE; >- >- pScrn->driverVersion = VERSION; >- pScrn->driverName = IVTVDEV_DRIVER_NAME; >- pScrn->name = IVTVDEV_NAME; >- pScrn->Probe = IVTVDevProbe; >- pScrn->PreInit = IVTVDevPreInit; >- pScrn->ScreenInit = IVTVDevScreenInit; >- pScrn->SwitchMode = ivtvHWSwitchMode; >- pScrn->AdjustFrame = ivtvHWAdjustFrame; >- pScrn->EnterVT = ivtvHWEnterVT; >- pScrn->LeaveVT = ivtvHWLeaveVT; >- pScrn->ValidMode = ivtvHWValidMode; >- >- xf86DrvMsg(pScrn->scrnIndex, X_INFO, >- "using %s\n", >- dev ? dev : >- "default device"); >- } >- } >- } >- } >- xfree(devSections); >- TRACE("probe done"); >- return foundScreen; >-} >- >-static Bool IVTVDevPreInit(ScrnInfoPtr pScrn, int flags) >-{ >- IVTVDevPtr fPtr; >- int default_depth, fbbpp; >- const char *mod = NULL; >- const char **syms = NULL; >- >- if (flags & PROBE_DETECT) >- return FALSE; >- >- TRACE_ENTER("PreInit"); >- >- /* Check the number of entities, and fail if it isn't one. */ >- if (pScrn->numEntities != 1) >- return FALSE; >- >- pScrn->monitor = pScrn->confScreen->monitor; >- >- IVTVDevGetRec(pScrn); >- fPtr = IVTVDEVPTR(pScrn); >- >- fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); >- >- pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; >- /* XXX Is this right? Can probably remove RAC_FB */ >- pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; >- >- if (fPtr->pEnt->location.type == BUS_PCI && >- xf86RegisterResources(fPtr->pEnt->index, NULL, ResExclusive)) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "xf86RegisterResources() found resource conflicts\n"); >- return FALSE; >- } >- >- /* open device */ >- if (!ivtvHWInit >- (pScrn, NULL, >- xf86FindOptionValue(fPtr->pEnt->device->options, "fbdev"))) >- return FALSE; >- default_depth = ivtvHWGetDepth(pScrn, &fbbpp); >- if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, fbbpp, 0)) >- return FALSE; >- xf86PrintDepthBpp(pScrn); >- >- /* Get the depth24 pixmap format */ >- if (pScrn->depth == 24 && pix24bpp == 0) >- pix24bpp = xf86GetBppFromDepth(pScrn, 24); >- >- /* color weight */ >- if (pScrn->depth > 8) { >- rgb zeros = { 0, 0, 0 }; >- if (!xf86SetWeight(pScrn, zeros, zeros)) >- return FALSE; >- } >- >- /* visual init */ >- if (!xf86SetDefaultVisual(pScrn, -1)) >- return FALSE; >- >- /* We don't currently support DirectColor at > 8bpp */ >- if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" >- " (%s) is not supported at depth %d\n", >- xf86GetVisualName(pScrn->defaultVisual), >- pScrn->depth); >- return FALSE; >- } >- >- { >- Gamma zeros = { 0.0, 0.0, 0.0 }; >- >- if (!xf86SetGamma(pScrn, zeros)) { >- return FALSE; >- } >- } >- >- pScrn->progClock = TRUE; >- pScrn->rgbBits = 8; >- pScrn->chipset = "ivtvdev"; >- pScrn->videoRam = ivtvHWGetVidmem(pScrn); >- >- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Hardware: %s (vidmem: %dk)\n", >- ivtvHWGetName(pScrn), pScrn->videoRam / 1024); >- >- /* handle options */ >- xf86CollectOptions(pScrn, NULL); >- if (!(fPtr->Options = xalloc(sizeof(IVTVDevOptions)))) >- return FALSE; >- memcpy(fPtr->Options, IVTVDevOptions, sizeof(IVTVDevOptions)); >- xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options, >- fPtr->Options); >- >- /* select video modes */ >- >- xf86DrvMsg(pScrn->scrnIndex, X_INFO, >- "Checking Modes against framebuffer device...\n"); >- ivtvHWSetVideoModes(pScrn); >- >- xf86DrvMsg(pScrn->scrnIndex, X_INFO, >- "Checking Modes against monitor...\n"); >- { >- DisplayModePtr mode, first = mode = pScrn->modes; >- >- if (mode != NULL) >- do { >- mode->status = >- xf86CheckModeForMonitor(mode, >- pScrn->monitor); >- mode = mode->next; >- } while (mode != NULL && mode != first); >- >- xf86PruneDriverModes(pScrn); >- } >- >- if (NULL == pScrn->modes) >- ivtvHWUseBuildinMode(pScrn); >- pScrn->currentMode = pScrn->modes; >- >- pScrn->displayWidth = pScrn->virtualX; /* ShadowFB handles this correctly */ >- >- xf86PrintModes(pScrn); >- >- /* Set display resolution */ >- xf86SetDpi(pScrn, 0, 0); >- >- /* Load bpp-specific modules */ >- mod = "fb"; >- syms = fbSymbols; >- >- if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { >- IVTVDevFreeRec(pScrn); >- return FALSE; >- } >- if (mod && syms) { >- xf86LoaderReqSymLists(syms, NULL); >- } >- >- /* Load shadow */ >- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, >- "Using \"Shadow Framebuffer\"\n"); >- if (!xf86LoadSubModule(pScrn, "shadow")) { >- IVTVDevFreeRec(pScrn); >- return FALSE; >- } >- xf86LoaderReqSymLists(shadowSymbols, NULL); >- >- TRACE_EXIT("PreInit"); >- return TRUE; >-} >- >-void IvtvInitVideo(ScreenPtr pScreen); >- >-static Bool >-IVTVDevScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) >-{ >- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >- IVTVDevPtr fPtr = IVTVDEVPTR(pScrn); >- VisualPtr visual; >- int init_picture = 0; >- int ret, flags, width, height; >- >- TRACE_ENTER("IVTVDevScreenInit"); >- >- ErrorF("\tbitsPerPixel=%d, depth=%d, defaultVisual=%s\n" >- "\tmask: %x,%x,%x, offset: %d,%d,%d\n", >- pScrn->bitsPerPixel, >- pScrn->depth, >- xf86GetVisualName(pScrn->defaultVisual), >- pScrn->mask.red, pScrn->mask.green, pScrn->mask.blue, >- pScrn->offset.red, pScrn->offset.green, pScrn->offset.blue); >- >- ivtvHWSave(pScrn); >- >- if (!ivtvHWModeInit(pScrn, pScrn->currentMode)) { >- xf86DrvMsg(scrnIndex, X_ERROR, "Mode init failed\n"); >- return FALSE; >- } >- ivtvHWSaveScreen(pScreen, SCREEN_SAVER_ON); >- ivtvHWAdjustFrame(scrnIndex, 0, 0, 0); >- >- /* mi layer */ >- miClearVisualTypes(); >- if (pScrn->bitsPerPixel > 8) { >- if (!miSetVisualTypes >- (pScrn->depth, TrueColorMask, pScrn->rgbBits, TrueColor)) { >- xf86DrvMsg(scrnIndex, X_ERROR, >- "Set visual types failed\n"); >- return FALSE; >- } >- } else { >- if (!miSetVisualTypes(pScrn->depth, >- miGetDefaultVisualMask(pScrn->depth), >- pScrn->rgbBits, pScrn->defaultVisual)) { >- xf86DrvMsg(scrnIndex, X_ERROR, >- "Set visual types failed\n"); >- return FALSE; >- } >- } >- if (!miSetPixmapDepths()) { >- xf86DrvMsg(scrnIndex, X_ERROR, "Set pixmap depths failed\n"); >- return FALSE; >- } >- >- height = pScrn->virtualY; >- width = pScrn->virtualX; >- >- /* shadowfb */ >- if ((fPtr->shadowmem = shadowAlloc(width, height, >- pScrn->bitsPerPixel)) == NULL) { >- xf86DrvMsg(scrnIndex, X_ERROR, >- "Allocation of shadow memory failed\n"); >- return FALSE; >- } >- >- ret = fbScreenInit(pScreen, fPtr->shadowmem, width, height, >- pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, >- pScrn->bitsPerPixel); >- init_picture = 1; >- >- if (!ret) >- return FALSE; >- >- if (pScrn->bitsPerPixel > 8) { >- /* Fixup RGB ordering */ >- visual = pScreen->visuals + pScreen->numVisuals; >- while (--visual >= pScreen->visuals) { >- if ((visual->class | DynamicClass) == DirectColor) { >- visual->offsetRed = pScrn->offset.red; >- visual->offsetGreen = pScrn->offset.green; >- visual->offsetBlue = pScrn->offset.blue; >- visual->redMask = pScrn->mask.red; >- visual->greenMask = pScrn->mask.green; >- visual->blueMask = pScrn->mask.blue; >- } >- } >- } >- >- /* must be after RGB ordering fixed */ >- if (init_picture && !fbPictureInit(pScreen, NULL, 0)) >- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, >- "RENDER extension initialisation failed.\n"); >- >- if (!shadowSetup(pScreen) || !shadowAdd(pScreen, NULL, >- FBshadowUpdatePacked, >- NULL, 0, NULL)) { >- xf86DrvMsg(scrnIndex, X_ERROR, >- "Shadow framebuffer initialization failed.\n"); >- return FALSE; >- } >- >- /* IVTVDGAInit(pScreen); >- */ >- >- if (pScrn->bitsPerPixel == 24) >- xf86DrvMsg(scrnIndex, X_WARNING, >- "Rotation might be broken in 24 bpp\n"); >- >- xf86SetBlackWhitePixels(pScreen); >- miInitializeBackingStore(pScreen); >- xf86SetBackingStore(pScreen); >- >- /* software cursor */ >- miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); >- >- /* XXX It would be simpler to use miCreateDefColormap() in all cases. */ >- if (!miCreateDefColormap(pScreen)) >- return FALSE; >- >- flags = CMAP_PALETTED_TRUECOLOR; >- if (!xf86HandleColormaps >- (pScreen, 256, 8, ivtvHWLoadPalette, NULL, flags)) >- return FALSE; >- >- xf86DPMSInit(pScreen, ivtvHWDPMSSet, 0); >- >- pScreen->SaveScreen = ivtvHWSaveScreen; >- >- /* Wrap the current CloseScreen function */ >- fPtr->CloseScreen = pScreen->CloseScreen; >- pScreen->CloseScreen = IVTVDevCloseScreen; >- >- { >- ErrorF("Init Video\n"); >- IvtvInitVideo(pScreen); >- } >- >- TRACE_EXIT("IVTVDevScreenInit"); >- >- return TRUE; >-} >- >-static Bool IVTVDevCloseScreen(int scrnIndex, ScreenPtr pScreen) >-{ >- ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >- IVTVDevPtr fPtr = IVTVDEVPTR(pScrn); >- >- ivtvHWRestore(pScrn); >- xfree(fPtr->shadowmem); >- pScrn->vtSema = FALSE; >- >- pScreen->CloseScreen = fPtr->CloseScreen; >- return (*pScreen->CloseScreen) (scrnIndex, pScreen); >-} >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvdev.h ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvdev.h >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvdev.h 2006-11-06 20:52:19.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvdev.h 1969-12-31 18:00:00.000000000 -0600 >@@ -1,17 +0,0 @@ >-/* -------------------------------------------------------------------- */ >-/* our private data, and two functions to allocate/free this */ >- >-typedef struct { >- int lineLength; >- unsigned char *shadowmem; >- CloseScreenProcPtr CloseScreen; >- DGAModePtr pDGAMode; >- int nDGAMode; >- void (*PointerMoved) (int index, int x, int y); >- EntityInfoPtr pEnt; >- OptionInfoPtr Options; >-} IVTVDevRec, *IVTVDevPtr; >- >-#define IVTVDEVPTR(p) ((IVTVDevPtr)((p)->driverPrivate)) >- >-Bool IVTVDGAInit(ScreenPtr pScreen); >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvhw.c ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvhw.c >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvhw.c 2006-11-06 20:52:19.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvhw.c 1969-12-31 18:00:00.000000000 -0600 >@@ -1,819 +0,0 @@ >-/* $XFree86: xc/programs/Xserver/hw/xfree86/ivtvhw/ivtvhw.c,v 1.30 2002/11/25 14:05:00 eich Exp $ */ >- >-#include "ivtvhw.h" >- >-/* all driver need this */ >-#include "xf86.h" >-#include "xf86_OSproc.h" >-#include "xf86_ansic.h" >- >-/* pci stuff */ >-#include "xf86PciInfo.h" >-#include "xf86Pci.h" >- >-#include "xf86cmap.h" >- >-#include "fbpriv.h" >- >-#include "asm/page.h" /* #define for PAGE_* */ >-#include "globals.h" >-#define DPMS_SERVER >-#include "extensions/dpms.h" >- >-#define DEBUG 0 >- >-#if DEBUG >-# define TRACE_ENTER(str) ErrorF("ivtvHW: " str " %d\n",pScrn->scrnIndex) >-#else >-# define TRACE_ENTER(str) >-#endif >- >-/* -------------------------------------------------------------------- */ >- >-#ifdef XFree86LOADER >- >-static MODULESETUPPROTO(ivtvhwSetup); >- >-static XF86ModuleVersionInfo ivtvHWVersRec = { >- "ivtvhw", >- MODULEVENDORSTRING, >- MODINFOSTRING1, >- MODINFOSTRING2, >- XF86_VERSION_CURRENT, >- 0, 0, 2, >- ABI_CLASS_VIDEODRV, >- ABI_VIDEODRV_VERSION, >- MOD_CLASS_NONE, >- {0, 0, 0, 0} >-}; >- >-XF86ModuleData ivtvhwModuleData = { &ivtvHWVersRec, ivtvhwSetup, NULL }; >- >-static pointer >-ivtvhwSetup(pointer module, pointer opts, int *errmaj, int *errmin) >-{ >- const char *osname; >- >- /* Check that we're being loaded on a Linux system */ >- LoaderGetOS(&osname, NULL, NULL, NULL); >- if (!osname || strcmp(osname, "linux") != 0) { >- if (errmaj) >- *errmaj = LDR_BADOS; >- if (errmin) >- *errmin = 0; >- return NULL; >- } else { >- /* OK */ >- return (pointer) 1; >- } >-} >- >-#else /* XFree86LOADER */ >- >-#include <fcntl.h> >-#include <errno.h> >-#include <sys/mman.h> >- >-#endif /* XFree86LOADER */ >- >-/* -------------------------------------------------------------------- */ >-/* our private data, and two functions to allocate/free this */ >- >-int ivtvHWPrivateIndex = -1; >- >-Bool ivtvHWGetRec(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr; >- >- if (ivtvHWPrivateIndex < 0) >- ivtvHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); >- >- if (FBDEVHWPTR(pScrn) != NULL) >- return TRUE; >- >- fPtr = FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(ivtvHWRec), 1); >- return TRUE; >-} >- >-void ivtvHWFreeRec(ScrnInfoPtr pScrn) >-{ >- if (ivtvHWPrivateIndex < 0) >- return; >- if (FBDEVHWPTR(pScrn) == NULL) >- return; >- xfree(FBDEVHWPTR(pScrn)); >- FBDEVHWPTRLVAL(pScrn) = NULL; >-} >- >-/* -------------------------------------------------------------------- */ >-/* some helpers for printing debug informations */ >- >-#if DEBUG >-static void print_ivtv_mode(char *txt, struct fb_var_screeninfo *var) >-{ >- ErrorF("ivtv %s mode:\t%d %d %d %d %d %d %d %d %d %d %d:%d:%d\n", >- txt, var->pixclock, >- var->xres, var->right_margin, var->hsync_len, var->left_margin, >- var->yres, var->lower_margin, var->vsync_len, var->upper_margin, >- var->bits_per_pixel, >- var->red.length, var->green.length, var->blue.length); >-} >- >-static void print_xfree_mode(char *txt, DisplayModePtr mode) >-{ >- ErrorF("xfree %s mode:\t%d %d %d %d %d %d %d %d %d\n", >- txt, mode->Clock, >- mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal, >- mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal); >-} >-#endif >- >-/* -------------------------------------------------------------------- */ >-/* Convert timings between the XFree and the Frame Buffer Device */ >- >-static void >-xfree2ivtv_fblayout(ScrnInfoPtr pScrn, struct fb_var_screeninfo *var) >-{ >- var->xres_virtual = pScrn->virtualX; >- var->yres_virtual = pScrn->virtualY; >- var->bits_per_pixel = pScrn->bitsPerPixel; >- var->red.length = pScrn->weight.red; >- var->green.length = pScrn->weight.green; >- var->blue.length = pScrn->weight.blue; >-} >- >-static void >-xfree2ivtv_timing(DisplayModePtr mode, struct fb_var_screeninfo *var) >-{ >- var->xres = mode->HDisplay; >- var->yres = mode->VDisplay; >- if (var->xres_virtual < var->xres) >- var->xres_virtual = var->xres; >- if (var->yres_virtual < var->yres) >- var->yres_virtual = var->yres; >- var->xoffset = var->yoffset = 0; >- var->pixclock = mode->Clock ? 1000000000 / mode->Clock : 0; >- var->right_margin = mode->HSyncStart - mode->HDisplay; >- var->hsync_len = mode->HSyncEnd - mode->HSyncStart; >- var->left_margin = mode->HTotal - mode->HSyncEnd; >- var->lower_margin = mode->VSyncStart - mode->VDisplay; >- var->vsync_len = mode->VSyncEnd - mode->VSyncStart; >- var->upper_margin = mode->VTotal - mode->VSyncEnd; >- var->sync = 0; >- if (mode->Flags & V_PHSYNC) >- var->sync |= FB_SYNC_HOR_HIGH_ACT; >- if (mode->Flags & V_PVSYNC) >- var->sync |= FB_SYNC_VERT_HIGH_ACT; >- if (mode->Flags & V_PCSYNC) >- var->sync |= FB_SYNC_COMP_HIGH_ACT; >-#if 1 /* Badly needed for PAL/NTSC on Amiga (amifb)!! [geert] */ >- if (mode->Flags & V_BCAST) >- var->sync |= FB_SYNC_BROADCAST; >-#endif >- if (mode->Flags & V_INTERLACE) >- var->vmode = FB_VMODE_INTERLACED; >- else if (mode->Flags & V_DBLSCAN) >- var->vmode = FB_VMODE_DOUBLE; >- else >- var->vmode = FB_VMODE_NONINTERLACED; >-} >- >-static void >-ivtv2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode) >-{ >- mode->Clock = var->pixclock ? 1000000000 / var->pixclock : 28000000; >- mode->HDisplay = var->xres; >- mode->HSyncStart = mode->HDisplay + var->right_margin; >- mode->HSyncEnd = mode->HSyncStart + var->hsync_len; >- mode->HTotal = mode->HSyncEnd + var->left_margin; >- mode->VDisplay = var->yres; >- mode->VSyncStart = mode->VDisplay + var->lower_margin; >- mode->VSyncEnd = mode->VSyncStart + var->vsync_len; >- mode->VTotal = mode->VSyncEnd + var->upper_margin; >- mode->Flags = 0; >- mode->Flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC; >- mode->Flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC; >- mode->Flags |= var->sync & FB_SYNC_COMP_HIGH_ACT ? V_PCSYNC : V_NCSYNC; >-#if 1 /* Badly needed for PAL/NTSC on Amiga (amifb)!! [geert] */ >- if (var->sync & FB_SYNC_BROADCAST) >- mode->Flags |= V_BCAST; >-#endif >- if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) >- mode->Flags |= V_INTERLACE; >- else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) >- mode->Flags |= V_DBLSCAN; >- mode->SynthClock = mode->Clock; >- mode->CrtcHDisplay = mode->HDisplay; >- mode->CrtcHSyncStart = mode->HSyncStart; >- mode->CrtcHSyncEnd = mode->HSyncEnd; >- mode->CrtcHTotal = mode->HTotal; >- mode->CrtcVDisplay = mode->VDisplay; >- mode->CrtcVSyncStart = mode->VSyncStart; >- mode->CrtcVSyncEnd = mode->VSyncEnd; >- mode->CrtcVTotal = mode->VTotal; >- mode->CrtcHAdjusted = FALSE; >- mode->CrtcVAdjusted = FALSE; >-} >- >-/* -------------------------------------------------------------------- */ >-/* open correct framebuffer device */ >- >-/* try to find the framebuffer device for a given PCI device */ >-struct v4l2_capability { >- __u8 driver[16]; /* i.e. "bttv" */ >- __u8 card[32]; /* i.e. "Hauppauge WinTV" */ >- __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ >- __u32 version; /* should use KERNEL_VERSION() */ >- __u32 capabilities; /* Device capabilities */ >- __u32 reserved[4]; >-}; >-#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) >- >-static int ivtv_open(int scrnIndex, char *dev, char **namep, ivtvHWPtr fPtr) >-{ >- struct fb_fix_screeninfo fix; >- int fd; >- >- /* try argument (from XF86Config) first */ >- if (dev) { >- fd = open(dev, O_RDWR, 0); >- } else { >- /* second: environment variable */ >- dev = getenv("FRAMEBUFFER"); >- if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) { >- /* last try: default device */ >- dev = "/dev/fb0"; >- fd = open(dev, O_RDWR, 0); >- } >- } >- >- if (fd == -1) { >- xf86DrvMsg(scrnIndex, X_ERROR, >- "open %s: %s\n", dev, strerror(errno)); >- return -1; >- } >- >- if (namep) { >- if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *)(&fix))) { >- *namep = NULL; >- xf86DrvMsg(scrnIndex, X_ERROR, >- "FBIOGET_FSCREENINFO: %s\n", >- strerror(errno)); >- return -1; >- } else { >- *namep = xnfalloc(16); >- strncpy(*namep, fix.id, 16); >- } >- } >- if (fd != -1 && fPtr) { >- int fbufId = 255; >- int yuvId; >- char *devid = dev+7; >- if (*devid == '/') >- devid++; >- sscanf(devid, "%d", &fbufId); >- >- xf86DrvMsg(scrnIndex, X_ERROR,"Framebuffer id from dev %sis %d\n",dev, fbufId); >- >- for (yuvId = 48; yuvId < 64 && fPtr->yuvDevName == NULL; >- yuvId++) { >- char yuvDev[20] = "/dev/video"; >- char yuvDevFull[20]; >- char yuvDevFull1[20]; >- int yuvFd; >- sprintf(yuvDevFull, "%s%d", yuvDev, yuvId); >- yuvFd = open(yuvDevFull, O_RDONLY); >- xf86DrvMsg(scrnIndex, X_ERROR,"open %s returned %d\n",yuvDevFull, yuvFd); >- >- if (yuvFd == -1 && errno == ENODEV) { >- sprintf(yuvDevFull1, "%s%d", yuvDev, >- yuvId - 48); >- yuvFd = open(yuvDevFull1, O_RDONLY); >- xf86DrvMsg(scrnIndex, X_ERROR,"2nd open %s returned %d\n",yuvDevFull, yuvFd); >- } >- >- if (yuvFd != -1) { >- int yuvFbId=-1; >- int ret = ioctl(yuvFd, IVTV_IOC_GET_FB, &yuvFbId); >- xf86DrvMsg(scrnIndex, X_ERROR,"get_fb returned %d fbid %d\n",ret, yuvFbId); >- if (ret != -1 && yuvFbId == fbufId) { >- struct v4l2_capability vcap; >- memset(&vcap, 0, sizeof(vcap)); >- if (ioctl(yuvFd, VIDIOC_QUERYCAP, &vcap) >- < 0) { >- ErrorF >- ("Can't query driver version so not adding Xv support on %s\n", >- yuvDevFull); >- } else { >- if (vcap.version >= 0x306) { >- fPtr->yuvDevName = >- strdup(yuvDevFull); >- } else { >- ErrorF >- ("Version of ivtv is too old to support Xv\n"); >- } >- >- } >- } >- close(yuvFd); >- } >- >- } >- } >- return fd; >-} >- >-/* -------------------------------------------------------------------- */ >- >-Bool ivtvHWProbe(pciVideoPtr pPci, char *device, char **namep) >-{ >- int fd; >- Bool retVal = TRUE; >- struct ivtvfb_ioctl_state_info state; >- fd = ivtv_open(-1, device, namep, NULL); >- >- if (-1 == fd) >- return FALSE; >- >- if (0 != ioctl(fd, IVTVFB_IOCTL_GET_STATE, (void *)&state)) { >- xf86DrvMsg(0, X_ERROR, >- "ivtvHWProvbe failed to do IVTVFB_IOCTL_GET_STATE for device %s\n", >- device); >- >- retVal = FALSE; >- } >- close(fd); >- return retVal; >-} >- >-Bool ivtvHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device) >-{ >- ivtvHWPtr fPtr; >- >- TRACE_ENTER("Init"); >- ivtvHWGetRec(pScrn); >- fPtr = FBDEVHWPTR(pScrn); >- fPtr->fd_yuv = -1; >- fPtr->yuvDevName = NULL; >- /* open device */ >- >- fPtr->fd = ivtv_open(pScrn->scrnIndex, device, NULL, fPtr); >- >- if (-1 == fPtr->fd) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "Failed to open framebuffer device, consult warnings" >- " and/or errors above for possible reasons\n" >- "\t(you may have to look at the server log to see" >- " warnings)\n"); >- return FALSE; >- } >- >- /* get current fb device settings */ >- if (-1 == ioctl(fPtr->fd, FBIOGET_FSCREENINFO, (void *)(&fPtr->fix))) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "ioctl FBIOGET_FSCREENINFO: %s\n", strerror(errno)); >- return FALSE; >- } >- if (-1 == ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *)(&fPtr->var))) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno)); >- return FALSE; >- } >- >- /* we can use the current settings as "buildin mode" */ >- ivtv2xfree_timing(&fPtr->var, &fPtr->buildin); >- fPtr->buildin.name = "current"; >- fPtr->buildin.next = &fPtr->buildin; >- fPtr->buildin.prev = &fPtr->buildin; >- fPtr->buildin.type |= M_T_BUILTIN; >- >- return TRUE; >-} >- >-char *ivtvHWGetName(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- return fPtr->fix.id; >-} >- >-int ivtvHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- if (fbbpp) >- *fbbpp = fPtr->var.bits_per_pixel; >- >- if (fPtr->fix.visual == FB_VISUAL_TRUECOLOR || >- fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR) >- return fPtr->var.red.length + fPtr->var.green.length + >- fPtr->var.blue.length; >- else >- return fPtr->var.bits_per_pixel; >-} >- >-int ivtvHWGetLineLength(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- if (fPtr->fix.line_length) >- return fPtr->fix.line_length; >- else >- return fPtr->var.xres_virtual * fPtr->var.bits_per_pixel / 8; >-} >- >-int ivtvHWGetType(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- return fPtr->fix.type; >-} >- >-int ivtvHWGetVidmem(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- return fPtr->fix.smem_len; >-} >- >-void ivtvHWSetVideoModes(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- int virtX = pScrn->display->virtualX; >- int virtY = pScrn->display->virtualY; >- struct fb_var_screeninfo var; >- char **modename; >- DisplayModePtr mode, this, last = NULL; >- >- TRACE_ENTER("VerifyModes"); >- if (NULL == pScrn->display->modes) >- return; >- >- for (modename = pScrn->display->modes; *modename != NULL; modename++) { >- for (mode = pScrn->monitor->Modes; mode != NULL; >- mode = mode->next) >- if (0 == strcmp(mode->name, *modename)) >- break; >- if (NULL == mode) { >- xf86DrvMsg(pScrn->scrnIndex, X_INFO, >- "\tmode \"%s\" not found\n", *modename); >- continue; >- } >- memset(&var, 0, sizeof(var)); >- xfree2ivtv_timing(mode, &var); >- var.xres_virtual = virtX; >- var.yres_virtual = virtY; >- var.bits_per_pixel = pScrn->bitsPerPixel; >- var.red.length = pScrn->weight.red; >- var.green.length = pScrn->weight.green; >- var.blue.length = pScrn->weight.blue; >- >- var.activate = FB_ACTIVATE_TEST; >- if (var.xres_virtual < var.xres) >- var.xres_virtual = var.xres; >- if (var.yres_virtual < var.yres) >- var.yres_virtual = var.yres; >- if (-1 == ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&var))) { >- xf86DrvMsg(pScrn->scrnIndex, X_INFO, >- "\tmode \"%s\" test failed\n", *modename); >- continue; >- } >- xf86DrvMsg(pScrn->scrnIndex, X_INFO, >- "\tmode \"%s\" ok\n", *modename); >- if (virtX < var.xres) >- virtX = var.xres; >- if (virtY < var.yres) >- virtY = var.yres; >- if (NULL == pScrn->modes) { >- pScrn->modes = xnfalloc(sizeof(DisplayModeRec)); >- this = pScrn->modes; >- memcpy(this, mode, sizeof(DisplayModeRec)); >- this->next = this; >- this->prev = this; >- } else { >- this = xnfalloc(sizeof(DisplayModeRec)); >- memcpy(this, mode, sizeof(DisplayModeRec)); >- this->next = pScrn->modes; >- this->prev = last; >- last->next = this; >- pScrn->modes->prev = this; >- } >- last = this; >- } >- pScrn->virtualX = virtX; >- pScrn->virtualY = virtY; >-} >- >-DisplayModePtr ivtvHWGetBuildinMode(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- return &fPtr->buildin; >-} >- >-void ivtvHWUseBuildinMode(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- TRACE_ENTER("UseBuildinMode"); >- pScrn->modes = &fPtr->buildin; >- pScrn->virtualX = pScrn->display->virtualX; >- pScrn->virtualY = pScrn->display->virtualY; >- if (pScrn->virtualX < fPtr->buildin.HDisplay) >- pScrn->virtualX = fPtr->buildin.HDisplay; >- if (pScrn->virtualY < fPtr->buildin.VDisplay) >- pScrn->virtualY = fPtr->buildin.VDisplay; >-} >- >-/* -------------------------------------------------------------------- */ >- >-void ivtvcalculateFbmem_len(ivtvHWPtr fPtr) >-{ >- fPtr->fboff = (unsigned long)fPtr->fix.smem_start & ~PAGE_MASK; >- fPtr->fbmem_len = (fPtr->fboff + fPtr->fix.smem_len + ~PAGE_MASK) & >- PAGE_MASK; >-} >- >-int ivtvHWLinearOffset(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- TRACE_ENTER("LinearOffset"); >- return fPtr->fboff; >-} >- >-/* -------------------------------------------------------------------- */ >- >-Bool ivtvHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- TRACE_ENTER("ModeInit"); >- xfree2ivtv_fblayout(pScrn, &fPtr->var); >- xfree2ivtv_timing(mode, &fPtr->var); >-#if DEBUG >- print_xfree_mode("init", mode); >- print_ivtv_mode("init", &fPtr->var); >-#endif >- pScrn->vtSema = TRUE; >- >- /* set */ >- if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&fPtr->var))) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); >- return FALSE; >- } >- /* read back */ >- if (0 != ioctl(fPtr->fd, FBIOGET_FSCREENINFO, (void *)(&fPtr->fix))) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "FBIOGET_FSCREENINFO: %s\n", strerror(errno)); >- return FALSE; >- } >- if (0 != ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *)(&fPtr->var))) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); >- return FALSE; >- } >- return TRUE; >-} >- >-/* -------------------------------------------------------------------- */ >-/* video mode save/restore */ >- >-/* TODO: colormap */ >-void ivtvHWSave(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- TRACE_ENTER("Save"); >- if (0 != >- ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *)(&fPtr->saved_var))) >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); >-} >- >-void ivtvHWRestore(ScrnInfoPtr pScrn) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- TRACE_ENTER("Restore"); >- if (0 != >- ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&fPtr->saved_var))) >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); >-} >- >-/* -------------------------------------------------------------------- */ >-/* callback for xf86HandleColormaps */ >- >-void >-ivtvHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, >- LOCO * colors, VisualPtr pVisual) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- struct fb_cmap cmap; >- unsigned short red, green, blue; >- int i; >- >- TRACE_ENTER("ModeInit"); >- cmap.len = 1; >- cmap.red = &red; >- cmap.green = &green; >- cmap.blue = &blue; >- cmap.transp = NULL; >- for (i = 0; i < numColors; i++) { >- cmap.start = indices[i]; >- red = (colors[indices[i]].red << 8) | colors[indices[i]].red; >- green = (colors[indices[i]].green << 8) | >- colors[indices[i]].green; >- blue = (colors[indices[i]].blue << 8) | colors[indices[i]].blue; >- if (-1 == ioctl(fPtr->fd, FBIOPUTCMAP, (void *)&cmap)) >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "FBIOPUTCMAP: %s\n", strerror(errno)); >- } >-} >- >-/* -------------------------------------------------------------------- */ >-/* these can be hooked directly into ScrnInfoRec */ >- >-int ivtvHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) >-{ >- ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- struct fb_var_screeninfo var; >- >- TRACE_ENTER("ValidMode"); >- memcpy(&var, &fPtr->var, sizeof(var)); >- xfree2ivtv_timing(mode, &var); >- var.activate = FB_ACTIVATE_TEST; >- if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&fPtr->var))) { >- xf86DrvMsg(scrnIndex, X_ERROR, >- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); >- return MODE_BAD; >- } >- return MODE_OK; >-} >- >-Bool ivtvHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) >-{ >- ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- TRACE_ENTER("SwitchMode"); >- xfree2ivtv_timing(mode, &fPtr->var); >- if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&fPtr->var))) { >- xf86DrvMsg(scrnIndex, X_ERROR, >- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); >- return FALSE; >- } >- return TRUE; >-} >- >-void ivtvHWAdjustFrame(int scrnIndex, int x, int y, int flags) >-{ >- ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- >- TRACE_ENTER("AdjustFrame"); >-#ifdef JOHN >- fPtr->var.xoffset = x; >- fPtr->var.yoffset = y; >- if (-1 == ioctl(fPtr->fd, FBIOPAN_DISPLAY, (void *)&fPtr->var)) >- xf86DrvMsgVerb(scrnIndex, 5, X_WARNING, >- "FBIOPAN_DISPLAY: %s\n", strerror(errno)); >-#endif >-} >- >-Bool ivtvHWEnterVT(int scrnIndex, int flags) >-{ >- ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >- >- TRACE_ENTER("EnterVT"); >- if (!ivtvHWModeInit(pScrn, pScrn->currentMode)) >- return FALSE; >- ivtvHWAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); >- return TRUE; >-} >- >-void ivtvHWLeaveVT(int scrnIndex, int flags) >-{ >- ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >- >- TRACE_ENTER("LeaveVT"); >- ivtvHWRestore(pScrn); >-} >- >-void ivtvHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- unsigned long fbmode; >- >- if (!pScrn->vtSema) >- return; >- >- switch (mode) { >- case DPMSModeOn: >- fbmode = 0; >- break; >- case DPMSModeStandby: >- fbmode = 2; >- break; >- case DPMSModeSuspend: >- fbmode = 3; >- break; >- case DPMSModeOff: >- fbmode = 4; >- break; >- default: >- return; >- } >- >-#ifdef JOHN >- if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)fbmode)) >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "FBIOBLANK: %s\n", strerror(errno)); >-#endif >-} >- >-Bool ivtvHWSaveScreen(ScreenPtr pScreen, int mode) >-{ >- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- unsigned long unblank; >- >- if (!pScrn->vtSema) >- return TRUE; >- >- unblank = xf86IsUnblank(mode); >- >-#ifdef JOHN >- if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)(1 - unblank))) { >- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >- "FBIOBLANK: %s\n", strerror(errno)); >- return FALSE; >- } >-#endif >- return TRUE; >-} >- >-#define MAX_RETRY_DMA 10 >-char *lastScreen = NULL; >- >-Bool ivtvHWSendDMA(ScrnInfoPtr pScrn, void *ptr, int x1, int x2, int y1, int y2) >-{ >- int totalScreenSize = >- pScrn->virtualX * pScrn->virtualY * pScrn->bitsPerPixel / 8; >- int secondOffset = 0; >- >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- struct ivtvfb_ioctl_dma_host_to_ivtv_args args; >- int cpt = MAX_RETRY_DMA; >- >- int startOffset = >- (((y1) * pScrn->virtualX) + x1) * pScrn->bitsPerPixel / 8; >- int endOffset = >- (((y2 - 1) * pScrn->virtualX) + x2) * pScrn->bitsPerPixel / 8; >- >- unsigned long totalData = endOffset - startOffset; >- >- if (totalData > 64 * 1024 * 4) { >- /* This is a bigger lump so send in 2 bits */ >- totalData /= 2; >- totalData = (totalData + 65535) & ~65535; >- secondOffset = endOffset - totalData; >- } else >- { >- totalData = (totalData + 65535) & ~65535; >- >- if ((startOffset + totalData) > totalScreenSize) { >- startOffset -= >- (startOffset + totalData) - totalScreenSize; >- } >- } >- >- args.source = ((char *)ptr + startOffset); >- args.dest_offset = startOffset; >- args.count = totalData; >- >- if (0 != ioctl(fPtr->fd, IVTVFB_IOCTL_PREP_FRAME, (void *)(&args))) { >- while (cpt--) { >- if (0 == ioctl(fPtr->fd, >- IVTVFB_IOCTL_PREP_FRAME, >- (void *)(&args))) >- break; >- } >- } >- if (secondOffset) { >- args.source = ((char *)ptr + secondOffset); >- args.dest_offset = secondOffset; >- args.count = totalData; >- >- if (0 != ioctl(fPtr->fd, >- IVTVFB_IOCTL_PREP_FRAME, (void *)(&args))) { >- while (cpt--) { >- if (0 == ioctl(fPtr->fd, >- IVTVFB_IOCTL_PREP_FRAME, >- (void *)(&args))) >- break; >- } >- } >- } >- >- return TRUE; >-} >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvhw.h ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvhw.h >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvhw.h 2006-11-06 20:52:19.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtvhw.h 1969-12-31 18:00:00.000000000 -0600 >@@ -1,86 +0,0 @@ >-/* $XFree86: xc/programs/Xserver/hw/xfree86/ivtvhw/ivtvhw.h,v 1.11 2001/10/01 13:44:12 eich Exp $ */ >- >-#ifndef _FBDEVHW_H_ >-#define _FBDEVHW_H_ >-#include "xf86str.h" >-#include "colormapst.h" >-#include <asm/ioctl.h> >-#undef __STRICT_ANSI__ >-#include <inttypes.h> >-#include <linux/ivtv.h> >- >-#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */ >-#define FBDEVHW_PLANES 1 /* Non interleaved planes */ >-#define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */ >-#define FBDEVHW_TEXT 3 /* Text/attributes */ >-#define FBDEVHW_VGA_PLANES 4 /* EGA/VGA planes */ >-#include "fbpriv.h" >-typedef struct { >- /* framebuffer device: filename (/dev/fb*), handle, more */ >- char *device; >- int fd; >- char *yuvDevName; >- int fd_yuv; >- unsigned int fbmem_len; >- unsigned int fboff; >- char *mmio; >- unsigned int mmio_len; >- >- /* current hardware state */ >- struct fb_fix_screeninfo fix; >- struct fb_var_screeninfo var; >- >- /* saved video mode */ >- struct fb_var_screeninfo saved_var; >- >- /* buildin video mode */ >- DisplayModeRec buildin; >- >-} ivtvHWRec, *ivtvHWPtr; >-extern int ivtvHWPrivateIndex; >- >-#define FBDEVHWPTRLVAL(p) (p)->privates[ivtvHWPrivateIndex].ptr >-#define FBDEVHWPTR(p) ((ivtvHWPtr)(FBDEVHWPTRLVAL(p))) >- >-Bool IVTVDGAInit(ScreenPtr pScreen); >- >-#define PCI_HAUPAGGE_VENDOR_ID 0x4444 >- >-Bool ivtvHWGetRec(ScrnInfoPtr pScrn); >-void ivtvHWFreeRec(ScrnInfoPtr pScrn); >- >-Bool ivtvHWProbe(pciVideoPtr pPci, char *device, char **namep); >-Bool ivtvHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device); >- >-char *ivtvHWGetName(ScrnInfoPtr pScrn); >-int ivtvHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp); >-int ivtvHWGetLineLength(ScrnInfoPtr pScrn); >-int ivtvHWGetType(ScrnInfoPtr pScrn); >-int ivtvHWGetVidmem(ScrnInfoPtr pScrn); >- >-/*void* ivtvHWMapVidmem(ScrnInfoPtr pScrn);*/ >-int ivtvHWLinearOffset(ScrnInfoPtr pScrn); >- >-void ivtvHWSetVideoModes(ScrnInfoPtr pScrn); >-DisplayModePtr ivtvHWGetBuildinMode(ScrnInfoPtr pScrn); >-void ivtvHWUseBuildinMode(ScrnInfoPtr pScrn); >-Bool ivtvHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); >-void ivtvHWSave(ScrnInfoPtr pScrn); >-void ivtvHWRestore(ScrnInfoPtr pScrn); >- >-void ivtvHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, >- LOCO * colors, VisualPtr pVisual); >- >-int ivtvHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, >- int flags); >-Bool ivtvHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); >-void ivtvHWAdjustFrame(int scrnIndex, int x, int y, int flags); >-Bool ivtvHWEnterVT(int scrnIndex, int flags); >-void ivtvHWLeaveVT(int scrnIndex, int flags); >-void ivtvHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); >- >-Bool ivtvHWSaveScreen(ScreenPtr pScreen, int mode); >-Bool ivtvHWSendDMA(ScrnInfoPtr pScrn, void *ptr, int x1, int x2, int y1, >- int y2); >- >-#endif >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtv_xv.c ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtv_xv.c >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtv_xv.c 2006-11-06 20:52:19.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtv_xv.c 1969-12-31 18:00:00.000000000 -0600 >@@ -1,785 +0,0 @@ >-/* Based on s3virge xv code from XFree86 */ >-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c,v 1.7 2003/02/04 02:20:50 dawes Exp $ */ >-/* >-Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved. >- >-Permission is hereby granted, free of charge, to any person obtaining a copy of >-this software and associated documentation files (the "Software"), to deal in >-the Software without restriction, including without limitation the rights to >-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies >-of the Software, and to permit persons to whom the Software is furnished to do >-so, subject to the following conditions: >- >-The above copyright notice and this permission notice shall be included in all >-copies or substantial portions of the Software. >- >-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- >-NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >-XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN >-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION >-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >- >-Except as contained in this notice, the name of the XFree86 Project shall not >-be used in advertising or otherwise to promote the sale, use or other dealings >-in this Software without prior written authorization from the XFree86 Project. >-*/ >- >-/* >- * s3v_xv.c >- * X Video Extension support >- * >- * S3 ViRGE driver >- * >- * 7/2000 Kevin Brosius >- * >- * Useful references: >- * X Video extension support -> xc/programs/hw/xfree86/common/xf86xv.c >- * >- */ >- >-/* >- * I N C L U D E S >- */ >-#include "ivtvhw.h" >-#include "ivtvdev.h" >- >-#include "xf86.h" >-#include "xf86xv.h" >-#include "Xv.h" >-#include "fourcc.h" >-#include "regionstr.h" >-typedef struct ivtv_xv_portData >-{ >- unsigned int colorKey; >- RegionRec clip; >- int autopaintColorKey; >-}Ivtv_Xv_PortData; >- >- >-#define IVTV_MAX_PORTS 1 >-#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) >- >-#if !defined(XvExtension) || !defined(IVTV_IOC_PREP_FRAME_YUV) >-void IvtvInitVideo(ScreenPtr pScreen) >-{ >- ErrorF("XVDriver disabled at compilation time\n"); >-} >-#else >- >-static XF86VideoAdaptorPtr IVTVSetupImageVideoOverlay(ScreenPtr); >-static int IVTVSetPortAttributeOverlay(ScrnInfoPtr, Atom, INT32, pointer); >-static int IVTVGetPortAttributeOverlay(ScrnInfoPtr, Atom, INT32 *, pointer); >- >-static void IVTVStopVideo(ScrnInfoPtr, pointer, Bool); >- >-static void IVTVQueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, >- unsigned int *, unsigned int *, pointer); >-static int IVTVPutImage(ScrnInfoPtr, short, short, short, short, short, >- short, short, short, int, unsigned char *, short, >- short, Bool, RegionPtr, pointer); >-static int IVTVQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, >- unsigned short *, int *, int *); >- >-void IvtvInitVideo(ScreenPtr pScreen) >-{ >- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >- XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; >- XF86VideoAdaptorPtr newAdaptor = NULL; >- int num_adaptors; >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- if (!fPtr->yuvDevName) >- return; >- >- xf86DrvMsg(pScrn->scrnIndex, X_INFO, >- "Enabling Xv support for PVR350\n"); >- newAdaptor = IVTVSetupImageVideoOverlay(pScreen); >- >- num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); >- >- if (newAdaptor) { >- if (!num_adaptors) { >- num_adaptors = 1; >- adaptors = &newAdaptor; >- } else { >- newAdaptors = /* need to free this someplace */ >- xalloc((num_adaptors + >- 1) * sizeof(XF86VideoAdaptorPtr *)); >- if (newAdaptors) { >- memcpy(newAdaptors, adaptors, num_adaptors * >- sizeof(XF86VideoAdaptorPtr)); >- newAdaptors[num_adaptors] = newAdaptor; >- adaptors = newAdaptors; >- num_adaptors++; >- } >- } >- } >- >- if (num_adaptors) >- xf86XVScreenInit(pScreen, adaptors, num_adaptors); >- >- if (newAdaptors) >- xfree(newAdaptors); >-} >- >-/* client libraries expect an encoding */ >-static XF86VideoEncodingRec DummyEncoding[1] = { >- { /* overlay limit */ >- 0, >- "XV_IMAGE", >- 768, 576, >- {1, 1} >- } >-}; >- >-#define NUM_FORMATS_OVERLAY 4 >-#define NUM_FORMATS_TEXTURE 4 >- >-static XF86VideoFormatRec Formats[NUM_FORMATS_TEXTURE] = { >- /*{15, TrueColor}, */ {16, TrueColor}, {24, TrueColor} >- /* , >- {15, DirectColor} */ , {16, DirectColor}, {24, DirectColor} >-}; >- >-#define NUM_IMAGES 1 >- >-static XF86ImageRec Images[NUM_IMAGES] = { >- XVIMAGE_YV12 >- /* XVIMAGE_UYVY */ >-}; >- >-#define NUM_ATTRIBUTES_OVERLAY 2 >- >-static XF86AttributeRec Attributes[NUM_ATTRIBUTES_OVERLAY] = >-{ >- {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, >- {XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLORKEY"}, >- >-#if 0 >- {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, >- {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"} >-#endif >-}; >-static Atom xvColorKey, xvAutopaintColorKey; >- >-static int >-IVTVSetPortAttributeOverlay(ScrnInfoPtr pScrn, >- Atom attribute, INT32 value, pointer data) >-{ >- IVTVDevPtr devPtr = IVTVDEVPTR(pScrn); >- Ivtv_Xv_PortData *pPriv = (Ivtv_Xv_PortData *)data; >-#ifdef JOHN >- if (attribute == xvBrightness) { >- if ((value < -128) || (value > 127)) >- return BadValue; >- pPriv->brightness = value; >- OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | >- (pPriv->contrast & 0xff)); >- } else if (attribute == xvContrast) { >- if ((value < 0) || (value > 255)) >- return BadValue; >- pPriv->contrast = value; >- OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | >- (pPriv->contrast & 0xff)); >- } else >-#endif >- if (attribute == xvColorKey) { >- pPriv->colorKey = value; >-#ifdef JOHN >- outMGAdac(0x55, (pPriv->colorKey & pScrn->mask.red) >> >- pScrn->offset.red); >- outMGAdac(0x56, (pPriv->colorKey & pScrn->mask.green) >> >- pScrn->offset.green); >- outMGAdac(0x57, (pPriv->colorKey & pScrn->mask.blue) >> >- pScrn->offset.blue); >-#endif >- REGION_EMPTY(pScrn->pScreen, &pPriv->clip); >- }else if (attribute == xvAutopaintColorKey) { >- pPriv->autopaintColorKey = value; >- } else >- { >- ErrorF("IvtvSetPortAttributeOverlay bad attribute\n"); >- >- return BadMatch; >- } >- >- return Success; >-} >- >-static int >-IVTVGetPortAttributeOverlay(ScrnInfoPtr pScrn, >- Atom attribute, INT32 * value, pointer data) >-{ >- IVTVDevPtr devPtr = IVTVDEVPTR(pScrn); >- Ivtv_Xv_PortData *pPriv = (Ivtv_Xv_PortData *)data; >- >-#ifdef JOHN >- if (attribute == xvBrightness) { >- *value = pPriv->brightness; >- } else if (attribute == xvContrast) { >- *value = pPriv->contrast; >- } else >-#endif >- if (attribute == xvColorKey) { >- *value = pPriv->colorKey; >- } else if (attribute == xvAutopaintColorKey) { >- *value = pPriv->autopaintColorKey; >- } else >- { >- ErrorF("IvtvGetPortAttributeOverlay bad attribute\n"); >- return BadMatch; >- } >- >- return Success; >-} >- >-static void >-IVTVQueryBestSize(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) >-{ >- ErrorF("Query best vid_w %d vid_h %d drw_w %d drw_h %d\n", >- vid_w, vid_h, drw_w, drw_h); >- *p_w = drw_w; >- *p_h = drw_h; >-} >- >-static XF86VideoAdaptorPtr IVTVAllocAdaptor(ScreenPtr pScreen) >-{ >- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >- XF86VideoAdaptorPtr adapt; >- DevUnion *pPriv; >- IVTVDevPtr devPtr = IVTVDEVPTR(pScrn); >- int i; >- >- if (!(adapt = xf86XVAllocateVideoAdaptorRec(pScrn))) >- return NULL; >- >- if (!(pPriv = xcalloc(1, sizeof(DevUnion) * IVTV_MAX_PORTS))) { >- xfree(adapt); >- return NULL; >- } >- >- adapt->pPortPrivates = pPriv; >- >- for (i = 0; i < IVTV_MAX_PORTS; i++) >- { >- Ivtv_Xv_PortData *portData = (Ivtv_Xv_PortData *)xcalloc(1,sizeof(Ivtv_Xv_PortData)); >- portData->colorKey = 101; >- portData->autopaintColorKey = 0; >-#ifdef X_USE_REGION_NULL >- REGION_NULL(pScreen, &portData->clip); >-#else >- REGION_INIT(pScreen, &portData->clip, NullBox, 0); >-#endif >- adapt->pPortPrivates[i].ptr =portData; >- } >- >- >-#if 0 >- xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); >- xvContrast = MAKE_ATOM("XV_CONTRAST"); >-#endif >- xvColorKey = MAKE_ATOM("XV_COLORKEY"); >- xvAutopaintColorKey = MAKE_ATOM("XV_AUTOPAINT_COLORKEY"); >- >- return adapt; >-} >- >-static XF86VideoAdaptorPtr IVTVSetupImageVideoOverlay(ScreenPtr pScreen) >-{ >- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >-#ifdef JOHN >- IVTVPtr ps3v = IVTVPTR(pScrn); >-#endif >- XF86VideoAdaptorPtr adapt; >- adapt = IVTVAllocAdaptor(pScreen); >- >- adapt->type = XvWindowMask | XvInputMask | XvImageMask; >- adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; >- adapt->name = "PVR350"; >- adapt->nEncodings = 1; >- adapt->pEncodings = &DummyEncoding[0]; >- adapt->nFormats = NUM_FORMATS_OVERLAY; >- adapt->pFormats = Formats; >- adapt->nPorts = 1; >- adapt->pAttributes = Attributes /*Attributes */ ; >- adapt->nImages = 1; >- adapt->nAttributes = NUM_ATTRIBUTES_OVERLAY; >- adapt->pImages = Images; >- adapt->PutVideo = NULL; >- adapt->PutStill = NULL; >- adapt->GetVideo = NULL; >- adapt->GetStill = NULL; >- adapt->StopVideo = IVTVStopVideo; >- /* Empty Attrib functions - required anyway */ >- adapt->SetPortAttribute = IVTVSetPortAttributeOverlay; >- adapt->GetPortAttribute = IVTVGetPortAttributeOverlay; >- adapt->QueryBestSize = IVTVQueryBestSize; >- adapt->PutImage = IVTVPutImage; >- adapt->QueryImageAttributes = IVTVQueryImageAttributes; >- >- return adapt; >-} >- >-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.x2 != B->extents.x2) || >- (A->extents.y1 != B->extents.y1) || >- (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; >-} >- >-#ifdef JOHN >-/* Not using this at the moment */ >-/* IVTVClipVideo - copied from MGAClipVideo - >- >- 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. >-*/ >- >-#define DummyScreen screenInfo.screens[0] >- >-static Bool >-IVTVClipVideo(BoxPtr dst, >- INT32 * x1, >- INT32 * x2, >- INT32 * y1, INT32 * y2, RegionPtr reg, INT32 width, INT32 height) >-{ >- INT32 vscale, hscale, delta; >- BoxPtr extents = REGION_EXTENTS(DummyScreen, reg); >- 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 (*x1 >= *x2) >- return FALSE; >- >- 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; >- } >- if (*y1 >= *y2) >- return FALSE; >- >- if ((dst->x1 != extents->x1) || (dst->x2 != extents->x2) || >- (dst->y1 != extents->y1) || (dst->y2 != extents->y2)) { >- RegionRec clipReg; >- REGION_INIT(DummyScreen, &clipReg, dst, 1); >- REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); >- REGION_UNINIT(DummyScreen, &clipReg); >- } >- return TRUE; >-} >-#endif >- >-static void IVTVStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- Ivtv_Xv_PortData *pPriv = (Ivtv_Xv_PortData *)data; >- >- REGION_EMPTY(pScrn->pScreen, &pPriv->clip); >- >- if (shutdown) { >- if (fPtr->fd_yuv != -1) { >- IVTVDevPtr devPtr = IVTVDEVPTR(pScrn); >- struct ivtvfb_ioctl_state_info state; >- close(fPtr->fd_yuv); >- fPtr->fd_yuv = -1; >- struct ivtvfb_ioctl_colorkey colorKey; >- colorKey.state = 0; >- colorKey.colorKey = pPriv->colorKey; >- if (ioctl(fPtr->fd,IVTVFB_IOCTL_SET_COLORKEY, &colorKey) < 0) { >- ErrorF >- ("IVTVFB_IOCTL_SET_COLORKEY failed (error: %s)\n", >- strerror(errno)); >- } >- } >- } >- >-} >- >-static void de_macro_y(unsigned char *src, unsigned char *dst, >- int w, int h, int src_x, int src_y, int height, int width) >-{ >- unsigned int x, y, i; >- unsigned char *dst_2; >- unsigned int h_tail, w_tail; >- unsigned int h_size, w_size; >- unsigned int h_lead, w_lead; >- >- // Always round the origin, but compensate by increasing the size >- if (src_x & 15) { >- w += src_x & 15; >- src_x &= ~15; >- } >- >- if (src_y & 15) { >- h += src_y & 15; >- src_y &= ~15; >- } >- >- // The right / bottom edge might not be a multiple of 16 >- h_tail = h & 15; >- w_tail = w & 15; >- >- // One block is 16 pixels high >- h_size = 16; >- >- // descramble Y plane >- for (y = 0; y < h; y += 16) { >- >- // Clip if we've reached the bottom & the size isn't a multiple of 16 >- if (y + 16 > h) h_size = h_tail; >- >- for (x = 0; x < w; x += 16) { >- if (x + 16 > w) >- w_size = w_tail; >- else >- w_size = 16; >- >- dst_2 = dst + (720 * y) + (720 * src_y) + (256 * (src_x>>4)) + (x * 16); >- >- for (i = 0; i < h_size; i++) { >- memcpy(dst_2, src + src_x + x + (y + i) * width + (src_y * width), w_size); >- dst_2 += 16; >- } >- } >- } >-} >- >-static void de_macro_uv(unsigned char *srcu, unsigned char *srcv, >- unsigned char *dst, int w, int h, int src_x, int src_y, >- int height, int width) >-{ >- unsigned int x, y, i, f; >- unsigned char *dst_2; >- unsigned int h_tail, w_tail; >- unsigned int h_size, w_size; >- unsigned int h_lead, w_lead; >- >- // The uv plane is half the size of the y plane, so 'correct' all dimensions. >- w /= 2; >- h /= 2; >- src_x /= 2; >- src_y /= 2; >- height /= 2; >- width /= 2; >- >- // Always round the origin, but compensate by increasing the size >- if (src_x & 7) { >- w += src_x & 7; >- src_x &= ~7; >- } >- >- if (src_y & 15) { >- h += src_y & 15; >- src_y &= ~15; >- } >- >- // The right / bottom edge may not be a multiple of 16 >- h_tail = h & 15; >- w_tail = w & 7; >- >- h_size = 16; >- >- // descramble U/V plane >- for (y = 0; y < h; y += 16) { >- if ( y + 16 > h ) h_size = h_tail; >- for (x = 0; x < w; x += 8) { >- dst_2 = dst + (720 * y) + (720 * src_y) + (256 * (src_x>>3)) + (x * 32); >- if (x + 8 <= w) { >- for (i = 0; i < h_size; i++) { >- int idx = src_x + x + ((y + i) * width) + (src_y * width); >- dst_2[0] = srcu[idx + 0]; >- dst_2[1] = srcv[idx + 0]; >- dst_2[2] = srcu[idx + 1]; >- dst_2[3] = srcv[idx + 1]; >- dst_2[4] = srcu[idx + 2]; >- dst_2[5] = srcv[idx + 2]; >- dst_2[6] = srcu[idx + 3]; >- dst_2[7] = srcv[idx + 3]; >- dst_2[8] = srcu[idx + 4]; >- dst_2[9] = srcv[idx + 4]; >- dst_2[10] = srcu[idx + 5]; >- dst_2[11] = srcv[idx + 5]; >- dst_2[12] = srcu[idx + 6]; >- dst_2[13] = srcv[idx + 6]; >- dst_2[14] = srcu[idx + 7]; >- dst_2[15] = srcv[idx + 7]; >- dst_2 += 16; >- } >- } >- else { >- for (i = 0; i < h_size; i ++) { >- int idx = src_x + x + ((y + i) * width) + (src_y * width); >- for (f = 0; f < w_tail; f++) { >- dst_2[0] = srcu[idx + f]; >- dst_2[1] = srcv[idx + f]; >- dst_2 += 2; >- } >-/* >- // Used for testing edge cutoff. Sets colour to Green >- for (f = w_tail;f < 8;f ++) { >- dst_2[0] = 0; >- dst_2[1] = 0; >- dst_2 += 2; >- } >-*/ >- dst_2 += 16 - (w_tail << 1); >- } >- } >- } >- } >-} >- >-static char outbuf[622080]; >- >-static int >-IVTVPutImage(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) >-{ >- ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >- Ivtv_Xv_PortData *pPriv = (Ivtv_Xv_PortData *)data; >- >- struct ivtvyuv_ioctl_dma_host_to_ivtv_args args; >-#ifdef JOHN >- ErrorF("src_w %d src_h %d drw_w %d drw_h %d width %d height %d\n", >- src_w, src_h, drw_w, drw_h, width, height); >- ErrorF("src_x %d src_y %d drw_x %d drw_y %d width %d height %d\n", >- src_x, src_y, drw_x, drw_y, width, height); >-#endif >- >- // FIXME - Is this the correct place for this ? >- >- // Source coordinates must be even >- // For origin, round down >- src_x &= ~1; >- src_y &= ~1; >- >- // For size, round up >- src_w += src_w & 1; >- src_h += src_h & 1; >- >-#ifdef JOHN >- INT32 x1, x2, y1, y2; >- unsigned char *dst_start; >- int top, left, npixels, nlines; >- >- BoxRec dstBox; >- CARD32 tmp; >- static int once = 1; >- static int once2 = 1; >- >- /* 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; >- >-#ifdef JOHN >- if (!IVTVClipVideo >- (&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height)) >- return Success; >-#endif >- >- dstBox.x1 -= pScrn->frameX0; >- dstBox.x2 -= pScrn->frameX0; >- dstBox.y1 -= pScrn->frameY0; >- dstBox.y2 -= pScrn->frameY0; >- >- pitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; >- >- dstPitch = ((width << 1) + 15) & ~15; >- new_h = ((dstPitch * height) + pitch - 1) / pitch; >-#endif >- >- switch (id) { >- >- case FOURCC_YV12: >- { >- de_macro_y(buf, outbuf, src_w, src_h, src_x, src_y, height, width); >- de_macro_uv(buf + (width * height) + width * height/ 4, >- buf + (width * height), outbuf + 720 * 576, >- src_w, src_h, src_x, src_y, height, width); >- >- args.y_source = outbuf; >- args.uv_source = outbuf + (720 * 576); >- args.src_x = src_x; >- args.src_y = src_y; >- args.dst_x = drw_x; >- args.dst_y = drw_y; >- args.src_w = src_w; >- args.dst_w = drw_w; >- args.srcBuf_width = width; >- args.src_h = src_h; >- args.dst_h = drw_h; >- args.srcBuf_height = height; >- args.yuv_type = IVTV_YUV_TYPE_HME12; >- } >- break; >- default: >- return BadMatch; >- } >- if (fPtr->fd_yuv == -1) { >- if ((fPtr->fd_yuv = open(fPtr->yuvDevName, O_RDWR)) == -1) { >- if (errno == ENODEV) >- ErrorF >- ("Failed to open \"%s\". Need to initialize the mpeg decoder before the YUV output can be used\n", >- fPtr->yuvDevName); >- else >- ErrorF("Failed to open \"%s\" Error %s\n", >- fPtr->yuvDevName, strerror(errno)); >- return BadAccess; >- } >- struct ivtvfb_ioctl_colorkey colorKey; >- colorKey.state = 1; >- colorKey.colorKey = pPriv->colorKey; >- if (ioctl(fPtr->fd,IVTVFB_IOCTL_SET_COLORKEY, &colorKey) < 0) { >- ErrorF >- ("IVTVFB_IOCTL_SET_COLORKEY failed (error: %s)\n", >- strerror(errno)); >- } >- } >- int ret = ioctl(fPtr->fd_yuv, IVTV_IOC_PREP_FRAME_YUV, &args); >- if (ret == -1) { >- ErrorF >- ("Ioctl IVTV_IOC_PREP_FRAME_YUV returned failed Error %s\n", >- strerror(errno)); >- return BadImplementation; >- } >- >- if(pPriv->autopaintColorKey && >- !RegionsEqual( &pPriv->clip, clipBoxes)) >- { >- /* we always paint V4L's color key */ >- REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); >- xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); >- } >- return Success; >-} >- >-static int >-IVTVQueryImageAttributes(ScrnInfoPtr pScrn, >- int id, >- unsigned short *w, unsigned short *h, >- int *pitches, int *offsets) >-{ >- int size = 0, tmp; >- >- if (*w > 768) >- *w = 768; >- if (*h > pScrn->virtualY) >- *h = pScrn->virtualY; >- >- *w = (*w + 1) & ~1; >- if (offsets) >- offsets[0] = 0; >- >- switch (id) { >- case FOURCC_YV12: >- *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; >- default: >- break; >- } >- >- return size; >-} >- >-#endif /* !XvExtension */ >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/Makefile ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/Makefile >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/Makefile 2006-11-06 20:52:19.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/Makefile 1969-12-31 18:00:00.000000000 -0600 >@@ -1,6 +0,0 @@ >- >- >-all: >- echo "Run xmkmf /PATH_TO_X_SOURCE/" >- >- >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvdev.c ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvdev.c >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvdev.c 1969-12-31 18:00:00.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvdev.c 2006-11-06 09:12:00.000000000 -0600 >@@ -0,0 +1,635 @@ >+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ivtv/ivtv.c,v 1.42 2002/10/10 01:35:20 dawes Exp $ */ >+ >+/* >+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> >+ * Michel Dänzer, <michdaen@iiic.ethz.ch> >+ */ >+ >+#include "string.h" >+#include "config.h" >+#include "ivtvhw.h" >+#include "ivtvdev.h" >+/* all driver need this */ >+#include "xf86.h" >+#include "xf86_OSproc.h" >+ >+#include "mipointer.h" >+#include "mibstore.h" >+#include "micmap.h" >+#include "colormapst.h" >+#include "xf86cmap.h" >+#include "shadow.h" >+#include "shadowfb.h" >+ >+/* for visuals */ >+#include "fb.h" >+ >+#include "xf86Resources.h" >+#include "xf86RAC.h" >+ >+#ifdef XvExtension >+#include "xf86xv.h" >+#endif >+enum HAUPAGE_CHIPTAGS { >+ PVR_UNKNOWN = 0, >+ PVR_350, >+ PVR_LAST >+}; >+#define PCI_CHIP_PVR350 0x0803 >+ >+static SymTabRec IVTVChipsets[] = { >+ {PVR_350, "PVR-350"}, >+ {-1, NULL} >+}; >+ >+/* This table maps a PCI device ID to a chipset family identifier. */ >+static PciChipsets IVTVPciChipsets[] = { >+ {PVR_350, PCI_CHIP_PVR350, RES_SHARED_VGA}, >+ {-1, -1, RES_UNDEFINED} >+}; >+ >+#define DEBUG 0 >+ >+#if DEBUG >+# define TRACE_ENTER(str) ErrorF("ivtv: " str " %d\n",pScrn->scrnIndex) >+# define TRACE_EXIT(str) ErrorF("ivtv: " str " done\n") >+# define TRACE(str) ErrorF("ivtv trace: " str "\n") >+#else >+# define TRACE_ENTER(str) >+# define TRACE_EXIT(str) >+# define TRACE(str) >+#endif >+ >+/* -------------------------------------------------------------------- */ >+/* prototypes */ >+ >+static const OptionInfoRec *IVTVDevAvailableOptions(int chipid, int busid); >+static void IVTVDevIdentify(int flags); >+static Bool IVTVDevProbe(DriverPtr drv, int flags); >+static Bool IVTVDevPreInit(ScrnInfoPtr pScrn, int flags); >+static Bool IVTVDevScreenInit(int Index, ScreenPtr pScreen, int argc, >+ char **argv); >+static Bool IVTVDevCloseScreen(int scrnIndex, ScreenPtr pScreen); >+ >+/* -------------------------------------------------------------------- */ >+ >+/* >+ * This is intentionally screen-independent. It indicates the binding >+ * choice made in the first PreInit. >+ */ >+static int pix24bpp = 0; >+ >+#define IVTVDEV_VERSION 4000 >+#define IVTVDEV_NAME "IVTVDEV_TST" >+#define IVTVDEV_DRIVER_NAME "ivtvdev" >+#define IVTVDEV_MAJOR_VERSION 0 >+#define IVTVDEV_MINOR_VERSION 10 >+ >+DriverRec IVTVDEV = { >+ IVTVDEV_VERSION, >+ IVTVDEV_DRIVER_NAME, >+#if 0 >+ "driver for linux framebuffer devices", >+#endif >+ IVTVDevIdentify, >+ IVTVDevProbe, >+ IVTVDevAvailableOptions, >+ NULL, >+ 0 >+}; >+ >+/* Supported options */ >+typedef enum { >+ OPTION_IVTVDEV >+} IVTVDevOpts; >+ >+static const OptionInfoRec IVTVDevOptions[] = { >+ {OPTION_IVTVDEV, "ivtv", OPTV_STRING, {0}, FALSE}, >+ {-1, NULL, OPTV_NONE, {0}, FALSE} >+}; >+ >+/* -------------------------------------------------------------------- */ >+ >+const char *IVTVDevshadowFBSymbols[] = { >+ "ShadowFBInit", >+ NULL >+}; >+ >+static const char *fbSymbols[] = { >+ "fbScreenInit", >+ "fbPictureInit", >+ NULL >+}; >+ >+static const char *shadowSymbols[] = { >+ "shadowAdd", >+ "shadowInit", >+ "shadowSetup", >+ NULL >+}; >+ >+#ifdef XFree86LOADER >+ >+MODULESETUPPROTO(IVTVDevSetup); >+ >+static XF86ModuleVersionInfo IVTVDevVersRec = { >+ "ivtv", >+ MODULEVENDORSTRING, >+ MODINFOSTRING1, >+ MODINFOSTRING2, >+ XORG_VERSION_CURRENT, >+ IVTVDEV_MAJOR_VERSION, IVTVDEV_MINOR_VERSION, 6, >+ ABI_CLASS_VIDEODRV, >+ ABI_VIDEODRV_VERSION, >+ MOD_CLASS_VIDEODRV, >+ {0, 0, 0, 0} >+}; >+ >+XF86ModuleData ivtvdevModuleData = { &IVTVDevVersRec, IVTVDevSetup, NULL }; >+ >+pointer IVTVDevSetup(pointer module, pointer opts, int *errmaj, int *errmin) >+{ >+ static Bool setupDone = FALSE; >+ >+ if (!setupDone) { >+ setupDone = TRUE; >+ xf86AddDriver(&IVTVDEV, module, 0); >+ LoaderRefSymLists(fbSymbols, shadowSymbols, >+ IVTVDevshadowFBSymbols, NULL); >+ return (pointer) 1; >+ } else { >+ if (errmaj) >+ *errmaj = LDR_ONCEONLY; >+ return NULL; >+ } >+} >+ >+#endif /* XFree86LOADER */ >+ >+void FBshadowUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) >+{ >+ >+ RegionPtr damage = &pBuf->damage; >+ int nbox = REGION_NUM_RECTS(damage); >+ BoxPtr pbox = REGION_RECTS(damage); >+ >+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >+ IVTVDevPtr fPtr = IVTVDEVPTR(pScrn); >+ int x1 = pScrn->virtualX; >+ int x2 = 0; >+ int y1 = pScrn->virtualY; >+ int y2 = 0; >+ while (nbox--) { >+ if (pbox->x1 < x1) >+ x1 = pbox->x1; >+ if (pbox->x2 > x2) >+ x2 = pbox->x2; >+ if (pbox->y1 < y1) >+ y1 = pbox->y1; >+ if (pbox->y2 > y2) >+ y2 = pbox->y2; >+ pbox++; >+ }; >+ >+ ivtvHWSendDMA(pScrn, fPtr->shadowmem, x1, x2, y1, y2); >+} >+ >+void >+IVTVDevRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) >+{ >+ IVTVDevPtr fPtr = IVTVDEVPTR(pScrn); >+ int x1 = pScrn->virtualX; >+ int x2 = 0; >+ int y1 = pScrn->virtualY; >+ int y2 = 0; >+ while (num--) { >+ if (pbox->x1 < x1) >+ x1 = pbox->x1; >+ if (pbox->x2 > x2) >+ x2 = pbox->x2; >+ if (pbox->y1 < y1) >+ y1 = pbox->y1; >+ if (pbox->y2 > y2) >+ y2 = pbox->y2; >+ pbox++; >+ }; >+ >+ ivtvHWSendDMA(pScrn, fPtr->shadowmem, x1, x2, y1, y2); >+} >+ >+static Bool IVTVDevGetRec(ScrnInfoPtr pScrn) >+{ >+ if (pScrn->driverPrivate != NULL) >+ return TRUE; >+ >+ pScrn->driverPrivate = xnfcalloc(sizeof(IVTVDevRec), 1); >+ return TRUE; >+} >+ >+static void IVTVDevFreeRec(ScrnInfoPtr pScrn) >+{ >+ if (pScrn->driverPrivate == NULL) >+ return; >+ xfree(pScrn->driverPrivate); >+ pScrn->driverPrivate = NULL; >+} >+ >+/* -------------------------------------------------------------------- */ >+ >+static const OptionInfoRec *IVTVDevAvailableOptions(int chipid, int busid) >+{ >+ return IVTVDevOptions; >+} >+ >+static void IVTVDevIdentify(int flags) >+{ >+ xf86PrintChipsets(IVTVDEV_NAME, "driver for framebuffer", IVTVChipsets); >+} >+ >+static Bool IVTVDevProbe(DriverPtr drv, int flags) >+{ >+ int i; >+ GDevPtr *devSections; >+ int numDevSections; >+ char *dev; >+ Bool foundScreen = FALSE; >+ int *usedChips; >+ int numUsed; >+ TRACE("probe start"); >+ >+ /* For now, just bail out for PROBE_DETECT. */ >+ if (flags & PROBE_DETECT) >+ return FALSE; >+ >+ /* sanity checks */ >+ if ((numDevSections = >+ xf86MatchDevice(IVTVDEV_DRIVER_NAME, &devSections)) <= 0) >+ return FALSE; >+ >+ if (xf86GetPciVideoInfo() == NULL) >+ return FALSE; >+ >+ numUsed = xf86MatchPciInstances(IVTVDEV_DRIVER_NAME, >+ PCI_HAUPAGGE_VENDOR_ID, >+ IVTVChipsets, >+ IVTVPciChipsets, >+ devSections, >+ numDevSections, drv, &usedChips); >+ >+ if (numUsed <= 0) >+ return FALSE; >+ >+ if (flags & PROBE_DETECT) { >+ foundScreen = TRUE; >+ } else { >+ for (i = 0; i < numUsed; i++) { >+ ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); >+ dev = >+ xf86FindOptionValue(devSections[i]->options, >+ "fbdev"); >+ if (ivtvHWProbe(NULL, dev, NULL)) { >+ pScrn = >+ xf86ConfigPciEntity(pScrn, 0, usedChips[i], >+ IVTVPciChipsets, 0, 0, >+ 0, 0, 0); >+ >+ /* xf86DrvMsg() can't be called without setting these */ >+ pScrn->driverName = IVTVDEV_DRIVER_NAME; >+ pScrn->name = IVTVDEV_NAME; >+ >+ if (pScrn) { >+ foundScreen = TRUE; >+ >+ pScrn->driverVersion = IVTVDEV_VERSION; >+ pScrn->driverName = IVTVDEV_DRIVER_NAME; >+ pScrn->name = IVTVDEV_NAME; >+ pScrn->Probe = IVTVDevProbe; >+ pScrn->PreInit = IVTVDevPreInit; >+ pScrn->ScreenInit = IVTVDevScreenInit; >+ pScrn->SwitchMode = ivtvHWSwitchMode; >+ pScrn->AdjustFrame = ivtvHWAdjustFrame; >+ pScrn->EnterVT = ivtvHWEnterVT; >+ pScrn->LeaveVT = ivtvHWLeaveVT; >+ pScrn->ValidMode = ivtvHWValidMode; >+ >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, >+ "using %s\n", >+ dev ? dev : >+ "default device"); >+ } >+ } >+ } >+ } >+ xfree(devSections); >+ TRACE("probe done"); >+ return foundScreen; >+} >+ >+static Bool IVTVDevPreInit(ScrnInfoPtr pScrn, int flags) >+{ >+ IVTVDevPtr fPtr; >+ int default_depth, fbbpp; >+ const char *mod = NULL; >+ const char **syms = NULL; >+ >+ if (flags & PROBE_DETECT) >+ return FALSE; >+ >+ TRACE_ENTER("PreInit"); >+ >+ /* Check the number of entities, and fail if it isn't one. */ >+ if (pScrn->numEntities != 1) >+ return FALSE; >+ >+ pScrn->monitor = pScrn->confScreen->monitor; >+ >+ IVTVDevGetRec(pScrn); >+ fPtr = IVTVDEVPTR(pScrn); >+ >+ fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); >+ >+ pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; >+ /* XXX Is this right? Can probably remove RAC_FB */ >+ pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; >+ >+ if (fPtr->pEnt->location.type == BUS_PCI && >+ xf86RegisterResources(fPtr->pEnt->index, NULL, ResExclusive)) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "xf86RegisterResources() found resource conflicts\n"); >+ return FALSE; >+ } >+ >+ /* open device */ >+ if (!ivtvHWInit >+ (pScrn, NULL, >+ xf86FindOptionValue(fPtr->pEnt->device->options, "fbdev"))) >+ return FALSE; >+ default_depth = ivtvHWGetDepth(pScrn, &fbbpp); >+ if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, fbbpp, 0)) >+ return FALSE; >+ xf86PrintDepthBpp(pScrn); >+ >+ /* Get the depth24 pixmap format */ >+ if (pScrn->depth == 24 && pix24bpp == 0) >+ pix24bpp = xf86GetBppFromDepth(pScrn, 24); >+ >+ /* color weight */ >+ if (pScrn->depth > 8) { >+ rgb zeros = { 0, 0, 0 }; >+ if (!xf86SetWeight(pScrn, zeros, zeros)) >+ return FALSE; >+ } >+ >+ /* visual init */ >+ if (!xf86SetDefaultVisual(pScrn, -1)) >+ return FALSE; >+ >+ /* We don't currently support DirectColor at > 8bpp */ >+ if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" >+ " (%s) is not supported at depth %d\n", >+ xf86GetVisualName(pScrn->defaultVisual), >+ pScrn->depth); >+ return FALSE; >+ } >+ >+ { >+ Gamma zeros = { 0.0, 0.0, 0.0 }; >+ >+ if (!xf86SetGamma(pScrn, zeros)) { >+ return FALSE; >+ } >+ } >+ >+ pScrn->progClock = TRUE; >+ pScrn->rgbBits = 8; >+ pScrn->chipset = "ivtvdev"; >+ pScrn->videoRam = ivtvHWGetVidmem(pScrn); >+ >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Hardware: %s (vidmem: %dk)\n", >+ ivtvHWGetName(pScrn), pScrn->videoRam / 1024); >+ >+ /* handle options */ >+ xf86CollectOptions(pScrn, NULL); >+ if (!(fPtr->Options = xalloc(sizeof(IVTVDevOptions)))) >+ return FALSE; >+ memcpy(fPtr->Options, IVTVDevOptions, sizeof(IVTVDevOptions)); >+ xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options, >+ fPtr->Options); >+ >+ /* select video modes */ >+ >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, >+ "Checking Modes against framebuffer device...\n"); >+ ivtvHWSetVideoModes(pScrn); >+ >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, >+ "Checking Modes against monitor...\n"); >+ { >+ DisplayModePtr mode, first = mode = pScrn->modes; >+ >+ if (mode != NULL) >+ do { >+ mode->status = >+ xf86CheckModeForMonitor(mode, >+ pScrn->monitor); >+ mode = mode->next; >+ } while (mode != NULL && mode != first); >+ >+ xf86PruneDriverModes(pScrn); >+ } >+ >+ if (NULL == pScrn->modes) >+ ivtvHWUseBuildinMode(pScrn); >+ pScrn->currentMode = pScrn->modes; >+ >+ pScrn->displayWidth = pScrn->virtualX; /* ShadowFB handles this correctly */ >+ >+ xf86PrintModes(pScrn); >+ >+ /* Set display resolution */ >+ xf86SetDpi(pScrn, 0, 0); >+ >+ /* Load bpp-specific modules */ >+ mod = "fb"; >+ syms = fbSymbols; >+ >+ if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { >+ IVTVDevFreeRec(pScrn); >+ return FALSE; >+ } >+ if (mod && syms) { >+ xf86LoaderReqSymLists(syms, NULL); >+ } >+ >+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "loading shadowfb"); >+ if (!xf86LoadSubModule(pScrn, "shadowfb")) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "Couldn't load shadowfb module:\n"); >+ return FALSE; >+ } >+ xf86LoaderReqSymLists(IVTVDevshadowFBSymbols, NULL); >+ >+ /* Load shadow */ >+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using \"Shadow Framebuffer\"\n"); >+ if (!xf86LoadSubModule(pScrn, "shadow")) { >+ IVTVDevFreeRec(pScrn); >+ return FALSE; >+ } >+ xf86LoaderReqSymLists(shadowSymbols, NULL); >+ >+ TRACE_EXIT("PreInit"); >+ return TRUE; >+} >+ >+void IvtvInitVideo(ScreenPtr pScreen); >+ >+static Bool >+IVTVDevScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) >+{ >+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >+ IVTVDevPtr fPtr = IVTVDEVPTR(pScrn); >+ VisualPtr visual; >+ int ret, flags, width, height; >+ >+ TRACE_ENTER("IVTVDevScreenInit"); >+ >+ ErrorF("\tbitsPerPixel=%d, depth=%d, defaultVisual=%s\n" >+ "\tmask: %x,%x,%x, offset: %d,%d,%d\n", >+ pScrn->bitsPerPixel, >+ pScrn->depth, >+ xf86GetVisualName(pScrn->defaultVisual), >+ pScrn->mask.red, pScrn->mask.green, pScrn->mask.blue, >+ pScrn->offset.red, pScrn->offset.green, pScrn->offset.blue); >+ >+ ivtvHWSave(pScrn); >+ >+ if (!ivtvHWModeInit(pScrn, pScrn->currentMode)) { >+ xf86DrvMsg(scrnIndex, X_ERROR, "Mode init failed\n"); >+ return FALSE; >+ } >+ ivtvHWSaveScreen(pScreen, SCREEN_SAVER_ON); >+ ivtvHWAdjustFrame(scrnIndex, 0, 0, 0); >+ >+ /* mi layer */ >+ miClearVisualTypes(); >+ if (pScrn->bitsPerPixel > 8) { >+ if (!miSetVisualTypes >+ (pScrn->depth, TrueColorMask, pScrn->rgbBits, TrueColor)) { >+ xf86DrvMsg(scrnIndex, X_ERROR, >+ "Set visual types failed\n"); >+ return FALSE; >+ } >+ } else { >+ if (!miSetVisualTypes(pScrn->depth, >+ miGetDefaultVisualMask(pScrn->depth), >+ pScrn->rgbBits, pScrn->defaultVisual)) { >+ xf86DrvMsg(scrnIndex, X_ERROR, >+ "Set visual types failed\n"); >+ return FALSE; >+ } >+ } >+ if (!miSetPixmapDepths()) { >+ xf86DrvMsg(scrnIndex, X_ERROR, "Set pixmap depths failed\n"); >+ return FALSE; >+ } >+ >+ height = pScrn->virtualY; >+ width = pScrn->virtualX; >+ >+ /* shadowfb */ >+ if ((fPtr->shadowmem = shadowAlloc(width, height, >+ pScrn->bitsPerPixel)) == NULL) { >+ xf86DrvMsg(scrnIndex, X_ERROR, >+ "Allocation of shadow memory failed\n"); >+ return FALSE; >+ } >+ >+ ret = fbScreenInit(pScreen, fPtr->shadowmem, width, height, >+ pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, >+ pScrn->bitsPerPixel); >+ >+ if (!ret) >+ return FALSE; >+ >+ if (pScrn->bitsPerPixel > 8) { >+ /* Fixup RGB ordering */ >+ visual = pScreen->visuals + pScreen->numVisuals; >+ while (--visual >= pScreen->visuals) { >+ if ((visual->class | DynamicClass) == DirectColor) { >+ visual->offsetRed = pScrn->offset.red; >+ visual->offsetGreen = pScrn->offset.green; >+ visual->offsetBlue = pScrn->offset.blue; >+ visual->redMask = pScrn->mask.red; >+ visual->greenMask = pScrn->mask.green; >+ visual->blueMask = pScrn->mask.blue; >+ } >+ } >+ } >+ >+ /* must be after RGB ordering fixed */ >+ if (!fbPictureInit(pScreen, NULL, 0)) >+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, >+ "RENDER extension initialisation failed.\n"); >+ >+ if (!shadowInit(pScreen, FBshadowUpdatePacked, NULL)) { >+ xf86DrvMsg(scrnIndex, X_ERROR, >+ "Shadow framebuffer initialization failed.\n"); >+ return FALSE; >+ } >+ >+ /* IVTVDGAInit(pScreen); >+ */ >+ >+ if (pScrn->bitsPerPixel == 24) >+ xf86DrvMsg(scrnIndex, X_WARNING, >+ "Rotation might be broken in 24 bpp\n"); >+ >+ xf86SetBlackWhitePixels(pScreen); >+ miInitializeBackingStore(pScreen); >+ xf86SetBackingStore(pScreen); >+ >+ /* software cursor */ >+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); >+ >+ ShadowFBInit(pScreen, IVTVDevRefreshArea); >+ >+ /* XXX It would be simpler to use miCreateDefColormap() in all cases. */ >+ if (!miCreateDefColormap(pScreen)) >+ return FALSE; >+ >+ flags = CMAP_PALETTED_TRUECOLOR; >+ if (!xf86HandleColormaps >+ (pScreen, 256, 8, ivtvHWLoadPalette, NULL, flags)) >+ return FALSE; >+ >+ xf86DPMSInit(pScreen, ivtvHWDPMSSet, 0); >+ >+ pScreen->SaveScreen = ivtvHWSaveScreen; >+ >+ /* Wrap the current CloseScreen function */ >+ fPtr->CloseScreen = pScreen->CloseScreen; >+ pScreen->CloseScreen = IVTVDevCloseScreen; >+ >+ { >+ ErrorF("Init Video\n"); >+ IvtvInitVideo(pScreen); >+ } >+ >+ TRACE_EXIT("IVTVDevScreenInit"); >+ >+ return TRUE; >+} >+ >+static Bool IVTVDevCloseScreen(int scrnIndex, ScreenPtr pScreen) >+{ >+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >+ IVTVDevPtr fPtr = IVTVDEVPTR(pScrn); >+ >+ ivtvHWRestore(pScrn); >+ xfree(fPtr->shadowmem); >+ pScrn->vtSema = FALSE; >+ >+ pScreen->CloseScreen = fPtr->CloseScreen; >+ return (*pScreen->CloseScreen) (scrnIndex, pScreen); >+} >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvdev.h ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvdev.h >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvdev.h 1969-12-31 18:00:00.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvdev.h 2005-05-15 14:40:33.000000000 -0500 >@@ -0,0 +1,17 @@ >+/* -------------------------------------------------------------------- */ >+/* our private data, and two functions to allocate/free this */ >+ >+typedef struct { >+ int lineLength; >+ unsigned char *shadowmem; >+ CloseScreenProcPtr CloseScreen; >+ DGAModePtr pDGAMode; >+ int nDGAMode; >+ void (*PointerMoved) (int index, int x, int y); >+ EntityInfoPtr pEnt; >+ OptionInfoPtr Options; >+} IVTVDevRec, *IVTVDevPtr; >+ >+#define IVTVDEVPTR(p) ((IVTVDevPtr)((p)->driverPrivate)) >+ >+Bool IVTVDGAInit(ScreenPtr pScreen); >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvhw.c ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvhw.c >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvhw.c 1969-12-31 18:00:00.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvhw.c 2006-11-06 10:00:02.000000000 -0600 >@@ -0,0 +1,834 @@ >+/* $XFree86: xc/programs/Xserver/hw/xfree86/ivtvhw/ivtvhw.c,v 1.30 2002/11/25 14:05:00 eich Exp $ */ >+ >+#include "errno.h" >+#include "fcntl.h" >+#include "stdio.h" >+#include "stdlib.h" >+#include "string.h" >+#include "unistd.h" >+ >+#include "sys/ioctl.h" >+ >+#include "config.h" >+ >+#include "ivtvhw.h" >+ >+/* all driver need this */ >+#include "xf86.h" >+#include "xf86_OSproc.h" >+ >+/* pci stuff */ >+#include "xf86PciInfo.h" >+#include "xf86Pci.h" >+ >+#include "xf86cmap.h" >+ >+#include "linux/fb.h" >+#include "asm/page.h" /* #define for PAGE_* */ >+#include "globals.h" >+#define DPMS_SERVER >+#include "extensions/dpms.h" >+ >+#define DEBUG 0 >+ >+#if DEBUG >+# define TRACE_ENTER(str) ErrorF("ivtvHW: " str " %d\n",pScrn->scrnIndex) >+#else >+# define TRACE_ENTER(str) >+#endif >+ >+/* -------------------------------------------------------------------- */ >+ >+#ifdef XFree86LOADER >+ >+static MODULESETUPPROTO(ivtvhwSetup); >+ >+static XF86ModuleVersionInfo ivtvHWVersRec = { >+ "ivtvhw", >+ MODULEVENDORSTRING, >+ MODINFOSTRING1, >+ MODINFOSTRING2, >+ XF86_VERSION_CURRENT, >+ 0, 0, 2, >+ ABI_CLASS_VIDEODRV, >+ ABI_VIDEODRV_VERSION, >+ MOD_CLASS_VIDEODRV, >+ {0, 0, 0, 0} >+}; >+ >+XF86ModuleData ivtvhwModuleData = { &ivtvHWVersRec, ivtvhwSetup, NULL }; >+ >+static pointer >+ivtvhwSetup(pointer module, pointer opts, int *errmaj, int *errmin) >+{ >+ const char *osname; >+ >+ /* Check that we're being loaded on a Linux system */ >+ LoaderGetOS(&osname, NULL, NULL, NULL); >+ if (!osname || strcmp(osname, "linux") != 0) { >+ if (errmaj) >+ *errmaj = LDR_BADOS; >+ if (errmin) >+ *errmin = 0; >+ return NULL; >+ } else { >+ /* OK */ >+ return (pointer) 1; >+ } >+} >+ >+#else /* XFree86LOADER */ >+ >+#include <fcntl.h> >+#include <errno.h> >+#include <sys/mman.h> >+ >+#endif /* XFree86LOADER */ >+ >+/* -------------------------------------------------------------------- */ >+/* our private data, and two functions to allocate/free this */ >+ >+int ivtvHWPrivateIndex = -1; >+ >+Bool ivtvHWGetRec(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr; >+ >+ if (ivtvHWPrivateIndex < 0) >+ ivtvHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); >+ >+ if (FBDEVHWPTR(pScrn) != NULL) >+ return TRUE; >+ >+ fPtr = FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(ivtvHWRec), 1); >+ return TRUE; >+} >+ >+void ivtvHWFreeRec(ScrnInfoPtr pScrn) >+{ >+ if (ivtvHWPrivateIndex < 0) >+ return; >+ if (FBDEVHWPTR(pScrn) == NULL) >+ return; >+ xfree(FBDEVHWPTR(pScrn)); >+ FBDEVHWPTRLVAL(pScrn) = NULL; >+} >+ >+/* -------------------------------------------------------------------- */ >+/* some helpers for printing debug informations */ >+ >+#if DEBUG >+static void print_ivtv_mode(char *txt, struct fb_var_screeninfo *var) >+{ >+ ErrorF("ivtv %s mode:\t%d %d %d %d %d %d %d %d %d %d %d:%d:%d\n", >+ txt, var->pixclock, >+ var->xres, var->right_margin, var->hsync_len, var->left_margin, >+ var->yres, var->lower_margin, var->vsync_len, var->upper_margin, >+ var->bits_per_pixel, >+ var->red.length, var->green.length, var->blue.length); >+} >+ >+static void print_xfree_mode(char *txt, DisplayModePtr mode) >+{ >+ ErrorF("xfree %s mode:\t%d %d %d %d %d %d %d %d %d\n", >+ txt, mode->Clock, >+ mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal, >+ mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal); >+} >+#endif >+ >+/* -------------------------------------------------------------------- */ >+/* Convert timings between the XFree and the Frame Buffer Device */ >+ >+static void >+xfree2ivtv_fblayout(ScrnInfoPtr pScrn, struct fb_var_screeninfo *var) >+{ >+ var->xres_virtual = pScrn->virtualX; >+ var->yres_virtual = pScrn->virtualY; >+ var->bits_per_pixel = pScrn->bitsPerPixel; >+ var->red.length = pScrn->weight.red; >+ var->green.length = pScrn->weight.green; >+ var->blue.length = pScrn->weight.blue; >+} >+ >+static void >+xfree2ivtv_timing(DisplayModePtr mode, struct fb_var_screeninfo *var) >+{ >+ var->xres = mode->HDisplay; >+ var->yres = mode->VDisplay; >+ if (var->xres_virtual < var->xres) >+ var->xres_virtual = var->xres; >+ if (var->yres_virtual < var->yres) >+ var->yres_virtual = var->yres; >+ var->xoffset = var->yoffset = 0; >+ var->pixclock = mode->Clock ? 1000000000 / mode->Clock : 0; >+ var->right_margin = mode->HSyncStart - mode->HDisplay; >+ var->hsync_len = mode->HSyncEnd - mode->HSyncStart; >+ var->left_margin = mode->HTotal - mode->HSyncEnd; >+ var->lower_margin = mode->VSyncStart - mode->VDisplay; >+ var->vsync_len = mode->VSyncEnd - mode->VSyncStart; >+ var->upper_margin = mode->VTotal - mode->VSyncEnd; >+ var->sync = 0; >+ if (mode->Flags & V_PHSYNC) >+ var->sync |= FB_SYNC_HOR_HIGH_ACT; >+ if (mode->Flags & V_PVSYNC) >+ var->sync |= FB_SYNC_VERT_HIGH_ACT; >+ if (mode->Flags & V_PCSYNC) >+ var->sync |= FB_SYNC_COMP_HIGH_ACT; >+#if 1 /* Badly needed for PAL/NTSC on Amiga (amifb)!! [geert] */ >+ if (mode->Flags & V_BCAST) >+ var->sync |= FB_SYNC_BROADCAST; >+#endif >+ if (mode->Flags & V_INTERLACE) >+ var->vmode = FB_VMODE_INTERLACED; >+ else if (mode->Flags & V_DBLSCAN) >+ var->vmode = FB_VMODE_DOUBLE; >+ else >+ var->vmode = FB_VMODE_NONINTERLACED; >+} >+ >+static void >+ivtv2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode) >+{ >+ mode->Clock = var->pixclock ? 1000000000 / var->pixclock : 28000000; >+ mode->HDisplay = var->xres; >+ mode->HSyncStart = mode->HDisplay + var->right_margin; >+ mode->HSyncEnd = mode->HSyncStart + var->hsync_len; >+ mode->HTotal = mode->HSyncEnd + var->left_margin; >+ mode->VDisplay = var->yres; >+ mode->VSyncStart = mode->VDisplay + var->lower_margin; >+ mode->VSyncEnd = mode->VSyncStart + var->vsync_len; >+ mode->VTotal = mode->VSyncEnd + var->upper_margin; >+ mode->Flags = 0; >+ mode->Flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC; >+ mode->Flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC; >+ mode->Flags |= var->sync & FB_SYNC_COMP_HIGH_ACT ? V_PCSYNC : V_NCSYNC; >+#if 1 /* Badly needed for PAL/NTSC on Amiga (amifb)!! [geert] */ >+ if (var->sync & FB_SYNC_BROADCAST) >+ mode->Flags |= V_BCAST; >+#endif >+ if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) >+ mode->Flags |= V_INTERLACE; >+ else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) >+ mode->Flags |= V_DBLSCAN; >+ mode->SynthClock = mode->Clock; >+ mode->CrtcHDisplay = mode->HDisplay; >+ mode->CrtcHSyncStart = mode->HSyncStart; >+ mode->CrtcHSyncEnd = mode->HSyncEnd; >+ mode->CrtcHTotal = mode->HTotal; >+ mode->CrtcVDisplay = mode->VDisplay; >+ mode->CrtcVSyncStart = mode->VSyncStart; >+ mode->CrtcVSyncEnd = mode->VSyncEnd; >+ mode->CrtcVTotal = mode->VTotal; >+ mode->CrtcHAdjusted = FALSE; >+ mode->CrtcVAdjusted = FALSE; >+} >+ >+/* -------------------------------------------------------------------- */ >+/* open correct framebuffer device */ >+ >+/* try to find the framebuffer device for a given PCI device */ >+struct v4l2_capability { >+ __u8 driver[16]; /* i.e. "bttv" */ >+ __u8 card[32]; /* i.e. "Hauppauge WinTV" */ >+ __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ >+ __u32 version; /* should use KERNEL_VERSION() */ >+ __u32 capabilities; /* Device capabilities */ >+ __u32 reserved[4]; >+}; >+#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) >+ >+static int ivtv_open(int scrnIndex, char *dev, char **namep, ivtvHWPtr fPtr) >+{ >+ struct fb_fix_screeninfo fix; >+ int fd; >+ >+ /* try argument (from XF86Config) first */ >+ if (dev) { >+ fd = open(dev, O_RDWR, 0); >+ } else { >+ /* second: environment variable */ >+ dev = getenv("FRAMEBUFFER"); >+ if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) { >+ /* last try: default device */ >+ dev = "/dev/fb0"; >+ fd = open(dev, O_RDWR, 0); >+ } >+ } >+ >+ if (fd == -1) { >+ xf86DrvMsg(scrnIndex, X_ERROR, >+ "open %s: %s\n", dev, strerror(errno)); >+ return -1; >+ } >+ >+ if (namep) { >+ if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *)(&fix))) { >+ *namep = NULL; >+ xf86DrvMsg(scrnIndex, X_ERROR, >+ "FBIOGET_FSCREENINFO: %s\n", >+ strerror(errno)); >+ return -1; >+ } else { >+ *namep = xnfalloc(16); >+ strncpy(*namep, fix.id, 16); >+ } >+ } >+ if (fd != -1 && fPtr) { >+ int fbufId = 255; >+ int yuvId; >+ char *devid = dev+7; >+ if (*devid == '/') >+ devid++; >+ sscanf(devid, "%d", &fbufId); >+ >+ xf86DrvMsg(scrnIndex, X_ERROR,"Framebuffer id from dev %sis %d\n",dev, fbufId); >+ >+ for (yuvId = 48; yuvId < 64 && fPtr->yuvDevName == NULL; >+ yuvId++) { >+ char yuvDev[20] = "/dev/video"; >+ char yuvDevFull[20]; >+ char yuvDevFull1[20]; >+ int yuvFd; >+ sprintf(yuvDevFull, "%s%d", yuvDev, yuvId); >+ yuvFd = open(yuvDevFull, O_RDONLY); >+ xf86DrvMsg(scrnIndex, X_ERROR,"open %s returned %d\n",yuvDevFull, yuvFd); >+ >+ if (yuvFd == -1 && errno == ENODEV) { >+ sprintf(yuvDevFull1, "%s%d", yuvDev, >+ yuvId - 48); >+ yuvFd = open(yuvDevFull1, O_RDONLY); >+ xf86DrvMsg(scrnIndex, X_ERROR,"2nd open %s returned %d\n",yuvDevFull, yuvFd); >+ } >+ >+ if (yuvFd != -1) { >+ int yuvFbId=-1; >+ int ret = ioctl(yuvFd, IVTV_IOC_GET_FB, &yuvFbId); >+ xf86DrvMsg(scrnIndex, X_ERROR,"get_fb returned %d fbid %d\n",ret, yuvFbId); >+ if (ret != -1 && yuvFbId == fbufId) { >+ struct v4l2_capability vcap; >+ memset(&vcap, 0, sizeof(vcap)); >+ if (ioctl(yuvFd, VIDIOC_QUERYCAP, &vcap) >+ < 0) { >+ ErrorF >+ ("Can't query driver version so not adding Xv support on %s\n", >+ yuvDevFull); >+ } else { >+ if (vcap.version >= 0x306) { >+ fPtr->yuvDevName = >+ strdup(yuvDevFull); >+ } else { >+ ErrorF >+ ("Version of ivtv is too old to support Xv\n"); >+ } >+ >+ } >+ } >+ close(yuvFd); >+ } >+ >+ } >+ } >+ return fd; >+} >+ >+/* -------------------------------------------------------------------- */ >+ >+Bool ivtvHWProbe(pciVideoPtr pPci, char *device, char **namep) >+{ >+ int fd; >+ Bool retVal = TRUE; >+ struct ivtvfb_ioctl_state_info state; >+ fd = ivtv_open(-1, device, namep, NULL); >+ >+ if (-1 == fd) >+ return FALSE; >+ >+ if (0 != ioctl(fd, IVTVFB_IOCTL_GET_STATE, (void *)&state)) { >+ xf86DrvMsg(0, X_ERROR, >+ "ivtvHWProvbe failed to do IVTVFB_IOCTL_GET_STATE for device %s\n", >+ device); >+ >+ retVal = FALSE; >+ } >+ close(fd); >+ return retVal; >+} >+ >+Bool ivtvHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device) >+{ >+ ivtvHWPtr fPtr; >+ >+ TRACE_ENTER("Init"); >+ ivtvHWGetRec(pScrn); >+ fPtr = FBDEVHWPTR(pScrn); >+ fPtr->fd_yuv = -1; >+ fPtr->yuvDevName = NULL; >+ /* open device */ >+ >+ fPtr->fd = ivtv_open(pScrn->scrnIndex, device, NULL, fPtr); >+ >+ if (-1 == fPtr->fd) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "Failed to open framebuffer device, consult warnings" >+ " and/or errors above for possible reasons\n" >+ "\t(you may have to look at the server log to see" >+ " warnings)\n"); >+ return FALSE; >+ } >+ >+ /* get current fb device settings */ >+ if (-1 == ioctl(fPtr->fd, FBIOGET_FSCREENINFO, (void *)(&fPtr->fix))) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "ioctl FBIOGET_FSCREENINFO: %s\n", strerror(errno)); >+ return FALSE; >+ } >+ if (-1 == ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *)(&fPtr->var))) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno)); >+ return FALSE; >+ } >+ >+ /* we can use the current settings as "buildin mode" */ >+ ivtv2xfree_timing(&fPtr->var, &fPtr->buildin); >+ fPtr->buildin.name = "current"; >+ fPtr->buildin.next = &fPtr->buildin; >+ fPtr->buildin.prev = &fPtr->buildin; >+ fPtr->buildin.type |= M_T_BUILTIN; >+ >+ return TRUE; >+} >+ >+char *ivtvHWGetName(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ return fPtr->fix.id; >+} >+ >+int ivtvHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ if (fbbpp) >+ *fbbpp = fPtr->var.bits_per_pixel; >+ >+ if (fPtr->fix.visual == FB_VISUAL_TRUECOLOR || >+ fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR) >+ return fPtr->var.red.length + fPtr->var.green.length + >+ fPtr->var.blue.length; >+ else >+ return fPtr->var.bits_per_pixel; >+} >+ >+int ivtvHWGetLineLength(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ if (fPtr->fix.line_length) >+ return fPtr->fix.line_length; >+ else >+ return fPtr->var.xres_virtual * fPtr->var.bits_per_pixel / 8; >+} >+ >+int ivtvHWGetType(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ return fPtr->fix.type; >+} >+ >+int ivtvHWGetVidmem(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ return fPtr->fix.smem_len; >+} >+ >+void ivtvHWSetVideoModes(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ int virtX = pScrn->display->virtualX; >+ int virtY = pScrn->display->virtualY; >+ struct fb_var_screeninfo var; >+ char **modename; >+ DisplayModePtr mode, this, last = NULL; >+ >+ TRACE_ENTER("VerifyModes"); >+ if (NULL == pScrn->display->modes) >+ return; >+ >+ for (modename = pScrn->display->modes; *modename != NULL; modename++) { >+ for (mode = pScrn->monitor->Modes; mode != NULL; >+ mode = mode->next) >+ if (0 == strcmp(mode->name, *modename)) >+ break; >+ if (NULL == mode) { >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, >+ "\tmode \"%s\" not found\n", *modename); >+ continue; >+ } >+ memset(&var, 0, sizeof(var)); >+ xfree2ivtv_timing(mode, &var); >+ var.xres_virtual = virtX; >+ var.yres_virtual = virtY; >+ var.bits_per_pixel = pScrn->bitsPerPixel; >+ var.red.length = pScrn->weight.red; >+ var.green.length = pScrn->weight.green; >+ var.blue.length = pScrn->weight.blue; >+ >+ var.activate = FB_ACTIVATE_TEST; >+ if (var.xres_virtual < var.xres) >+ var.xres_virtual = var.xres; >+ if (var.yres_virtual < var.yres) >+ var.yres_virtual = var.yres; >+ if (-1 == ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&var))) { >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, >+ "\tmode \"%s\" test failed\n", *modename); >+ continue; >+ } >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, >+ "\tmode \"%s\" ok\n", *modename); >+ if (virtX < var.xres) >+ virtX = var.xres; >+ if (virtY < var.yres) >+ virtY = var.yres; >+ if (NULL == pScrn->modes) { >+ pScrn->modes = xnfalloc(sizeof(DisplayModeRec)); >+ this = pScrn->modes; >+ memcpy(this, mode, sizeof(DisplayModeRec)); >+ this->next = this; >+ this->prev = this; >+ } else { >+ this = xnfalloc(sizeof(DisplayModeRec)); >+ memcpy(this, mode, sizeof(DisplayModeRec)); >+ this->next = pScrn->modes; >+ this->prev = last; >+ last->next = this; >+ pScrn->modes->prev = this; >+ } >+ last = this; >+ } >+ pScrn->virtualX = virtX; >+ pScrn->virtualY = virtY; >+} >+ >+DisplayModePtr ivtvHWGetBuildinMode(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ return &fPtr->buildin; >+} >+ >+void ivtvHWUseBuildinMode(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ TRACE_ENTER("UseBuildinMode"); >+ pScrn->modes = &fPtr->buildin; >+ pScrn->virtualX = pScrn->display->virtualX; >+ pScrn->virtualY = pScrn->display->virtualY; >+ if (pScrn->virtualX < fPtr->buildin.HDisplay) >+ pScrn->virtualX = fPtr->buildin.HDisplay; >+ if (pScrn->virtualY < fPtr->buildin.VDisplay) >+ pScrn->virtualY = fPtr->buildin.VDisplay; >+} >+ >+/* -------------------------------------------------------------------- */ >+ >+void ivtvcalculateFbmem_len(ivtvHWPtr fPtr) >+{ >+ fPtr->fboff = (unsigned long)fPtr->fix.smem_start & ~PAGE_MASK; >+ fPtr->fbmem_len = (fPtr->fboff + fPtr->fix.smem_len + ~PAGE_MASK) & >+ PAGE_MASK; >+} >+ >+int ivtvHWLinearOffset(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ TRACE_ENTER("LinearOffset"); >+ return fPtr->fboff; >+} >+ >+/* -------------------------------------------------------------------- */ >+ >+Bool ivtvHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ TRACE_ENTER("ModeInit"); >+ xfree2ivtv_fblayout(pScrn, &fPtr->var); >+ xfree2ivtv_timing(mode, &fPtr->var); >+#if DEBUG >+ print_xfree_mode("init", mode); >+ print_ivtv_mode("init", &fPtr->var); >+#endif >+ pScrn->vtSema = TRUE; >+ >+ /* set */ >+ if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&fPtr->var))) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); >+ return FALSE; >+ } >+ /* read back */ >+ if (0 != ioctl(fPtr->fd, FBIOGET_FSCREENINFO, (void *)(&fPtr->fix))) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "FBIOGET_FSCREENINFO: %s\n", strerror(errno)); >+ return FALSE; >+ } >+ if (0 != ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *)(&fPtr->var))) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); >+ return FALSE; >+ } >+ return TRUE; >+} >+ >+/* -------------------------------------------------------------------- */ >+/* video mode save/restore */ >+ >+/* TODO: colormap */ >+void ivtvHWSave(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ TRACE_ENTER("Save"); >+ if (0 != >+ ioctl(fPtr->fd, FBIOGET_VSCREENINFO, (void *)(&fPtr->saved_var))) >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); >+} >+ >+void ivtvHWRestore(ScrnInfoPtr pScrn) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ TRACE_ENTER("Restore"); >+ if (0 != >+ ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&fPtr->saved_var))) >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); >+} >+ >+/* -------------------------------------------------------------------- */ >+/* callback for xf86HandleColormaps */ >+ >+void >+ivtvHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, >+ LOCO * colors, VisualPtr pVisual) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ struct fb_cmap cmap; >+ unsigned short red, green, blue; >+ int i; >+ >+ TRACE_ENTER("ModeInit"); >+ cmap.len = 1; >+ cmap.red = &red; >+ cmap.green = &green; >+ cmap.blue = &blue; >+ cmap.transp = NULL; >+ for (i = 0; i < numColors; i++) { >+ cmap.start = indices[i]; >+ red = (colors[indices[i]].red << 8) | colors[indices[i]].red; >+ green = (colors[indices[i]].green << 8) | >+ colors[indices[i]].green; >+ blue = (colors[indices[i]].blue << 8) | colors[indices[i]].blue; >+ if (-1 == ioctl(fPtr->fd, FBIOPUTCMAP, (void *)&cmap)) >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "FBIOPUTCMAP: %s\n", strerror(errno)); >+ } >+} >+ >+/* -------------------------------------------------------------------- */ >+/* these can be hooked directly into ScrnInfoRec */ >+ >+int ivtvHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) >+{ >+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ struct fb_var_screeninfo var; >+ >+ TRACE_ENTER("ValidMode"); >+ memcpy(&var, &fPtr->var, sizeof(var)); >+ xfree2ivtv_timing(mode, &var); >+ var.activate = FB_ACTIVATE_TEST; >+ if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&fPtr->var))) { >+ xf86DrvMsg(scrnIndex, X_ERROR, >+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); >+ return MODE_BAD; >+ } >+ return MODE_OK; >+} >+ >+Bool ivtvHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) >+{ >+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ TRACE_ENTER("SwitchMode"); >+ xfree2ivtv_timing(mode, &fPtr->var); >+ if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void *)(&fPtr->var))) { >+ xf86DrvMsg(scrnIndex, X_ERROR, >+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); >+ return FALSE; >+ } >+ return TRUE; >+} >+ >+void ivtvHWAdjustFrame(int scrnIndex, int x, int y, int flags) >+{ >+#if defined(JOHN) || DEBUG >+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >+#endif >+#ifdef JOHN >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+#endif >+ >+ TRACE_ENTER("AdjustFrame"); >+#ifdef JOHN >+ fPtr->var.xoffset = x; >+ fPtr->var.yoffset = y; >+ if (-1 == ioctl(fPtr->fd, FBIOPAN_DISPLAY, (void *)&fPtr->var)) >+ xf86DrvMsgVerb(scrnIndex, 5, X_WARNING, >+ "FBIOPAN_DISPLAY: %s\n", strerror(errno)); >+#endif >+} >+ >+Bool ivtvHWEnterVT(int scrnIndex, int flags) >+{ >+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >+ >+ TRACE_ENTER("EnterVT"); >+ if (!ivtvHWModeInit(pScrn, pScrn->currentMode)) >+ return FALSE; >+ ivtvHWAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); >+ return TRUE; >+} >+ >+void ivtvHWLeaveVT(int scrnIndex, int flags) >+{ >+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; >+ >+ TRACE_ENTER("LeaveVT"); >+ ivtvHWRestore(pScrn); >+} >+ >+void ivtvHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) >+{ >+#ifdef JOHN >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+#endif >+ unsigned long fbmode; >+ >+ if (!pScrn->vtSema) >+ return; >+ >+ switch (mode) { >+ case DPMSModeOn: >+ fbmode = 0; >+ break; >+ case DPMSModeStandby: >+ fbmode = 2; >+ break; >+ case DPMSModeSuspend: >+ fbmode = 3; >+ break; >+ case DPMSModeOff: >+ fbmode = 4; >+ break; >+ default: >+ return; >+ } >+ >+#ifdef JOHN >+ if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)fbmode)) >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "FBIOBLANK: %s\n", strerror(errno)); >+#endif >+} >+ >+Bool ivtvHWSaveScreen(ScreenPtr pScreen, int mode) >+{ >+#ifdef JOHN >+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ int unblank; >+ >+ if (!pScrn->vtSema) >+ return TRUE; >+ >+ unblank = xf86IsUnblank(mode); >+ >+ if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)(1 - unblank))) { >+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, >+ "FBIOBLANK: %s\n", strerror(errno)); >+ return FALSE; >+ } >+#endif >+ return TRUE; >+} >+ >+#define MAX_RETRY_DMA 10 >+char *lastScreen = NULL; >+ >+Bool ivtvHWSendDMA(ScrnInfoPtr pScrn, void *ptr, int x1, int x2, int y1, int y2) >+{ >+ int totalScreenSize = >+ pScrn->virtualX * pScrn->virtualY * pScrn->bitsPerPixel / 8; >+ int secondOffset = 0; >+ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ struct ivtvfb_ioctl_dma_host_to_ivtv_args args; >+ int cpt = MAX_RETRY_DMA; >+ >+ int startOffset = >+ (((y1) * pScrn->virtualX) + x1) * pScrn->bitsPerPixel / 8; >+ int endOffset = >+ (((y2 - 1) * pScrn->virtualX) + x2) * pScrn->bitsPerPixel / 8; >+ >+ unsigned long totalData = endOffset - startOffset; >+ >+ if (totalData > 64 * 1024 * 4) { >+ /* This is a bigger lump so send in 2 bits */ >+ totalData /= 2; >+ totalData = (totalData + 65535) & ~65535; >+ secondOffset = endOffset - totalData; >+ } else >+ { >+ totalData = (totalData + 65535) & ~65535; >+ >+ if ((startOffset + totalData) > totalScreenSize) { >+ startOffset -= >+ (startOffset + totalData) - totalScreenSize; >+ } >+ } >+ >+ args.source = ((char *)ptr + startOffset); >+ args.dest_offset = startOffset; >+ args.count = totalData; >+ >+ if (0 != ioctl(fPtr->fd, IVTVFB_IOCTL_PREP_FRAME, (void *)(&args))) { >+ while (cpt--) { >+ if (0 == ioctl(fPtr->fd, >+ IVTVFB_IOCTL_PREP_FRAME, >+ (void *)(&args))) >+ break; >+ } >+ } >+ if (secondOffset) { >+ args.source = ((char *)ptr + secondOffset); >+ args.dest_offset = secondOffset; >+ args.count = totalData; >+ >+ if (0 != ioctl(fPtr->fd, >+ IVTVFB_IOCTL_PREP_FRAME, (void *)(&args))) { >+ while (cpt--) { >+ if (0 == ioctl(fPtr->fd, >+ IVTVFB_IOCTL_PREP_FRAME, >+ (void *)(&args))) >+ break; >+ } >+ } >+ } >+ >+ return TRUE; >+} >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvhw.h ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvhw.h >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvhw.h 1969-12-31 18:00:00.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtvhw.h 2006-11-06 09:55:41.000000000 -0600 >@@ -0,0 +1,86 @@ >+/* $XFree86: xc/programs/Xserver/hw/xfree86/ivtvhw/ivtvhw.h,v 1.11 2001/10/01 13:44:12 eich Exp $ */ >+ >+#ifndef _FBDEVHW_H_ >+#define _FBDEVHW_H_ >+#include "xf86str.h" >+#include "colormapst.h" >+#include <asm/ioctl.h> >+#undef __STRICT_ANSI__ >+#include <inttypes.h> >+#include <linux/ivtv.h> >+ >+#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */ >+#define FBDEVHW_PLANES 1 /* Non interleaved planes */ >+#define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */ >+#define FBDEVHW_TEXT 3 /* Text/attributes */ >+#define FBDEVHW_VGA_PLANES 4 /* EGA/VGA planes */ >+#include "linux/fb.h" >+typedef struct { >+ /* framebuffer device: filename (/dev/fb*), handle, more */ >+ char *device; >+ int fd; >+ char *yuvDevName; >+ int fd_yuv; >+ unsigned int fbmem_len; >+ unsigned int fboff; >+ char *mmio; >+ unsigned int mmio_len; >+ >+ /* current hardware state */ >+ struct fb_fix_screeninfo fix; >+ struct fb_var_screeninfo var; >+ >+ /* saved video mode */ >+ struct fb_var_screeninfo saved_var; >+ >+ /* buildin video mode */ >+ DisplayModeRec buildin; >+ >+} ivtvHWRec, *ivtvHWPtr; >+extern int ivtvHWPrivateIndex; >+ >+#define FBDEVHWPTRLVAL(p) (p)->privates[ivtvHWPrivateIndex].ptr >+#define FBDEVHWPTR(p) ((ivtvHWPtr)(FBDEVHWPTRLVAL(p))) >+ >+Bool IVTVDGAInit(ScreenPtr pScreen); >+ >+#define PCI_HAUPAGGE_VENDOR_ID 0x4444 >+ >+Bool ivtvHWGetRec(ScrnInfoPtr pScrn); >+void ivtvHWFreeRec(ScrnInfoPtr pScrn); >+ >+Bool ivtvHWProbe(pciVideoPtr pPci, char *device, char **namep); >+Bool ivtvHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device); >+ >+char *ivtvHWGetName(ScrnInfoPtr pScrn); >+int ivtvHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp); >+int ivtvHWGetLineLength(ScrnInfoPtr pScrn); >+int ivtvHWGetType(ScrnInfoPtr pScrn); >+int ivtvHWGetVidmem(ScrnInfoPtr pScrn); >+ >+/*void* ivtvHWMapVidmem(ScrnInfoPtr pScrn);*/ >+int ivtvHWLinearOffset(ScrnInfoPtr pScrn); >+ >+void ivtvHWSetVideoModes(ScrnInfoPtr pScrn); >+DisplayModePtr ivtvHWGetBuildinMode(ScrnInfoPtr pScrn); >+void ivtvHWUseBuildinMode(ScrnInfoPtr pScrn); >+Bool ivtvHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); >+void ivtvHWSave(ScrnInfoPtr pScrn); >+void ivtvHWRestore(ScrnInfoPtr pScrn); >+ >+void ivtvHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, >+ LOCO * colors, VisualPtr pVisual); >+ >+int ivtvHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, >+ int flags); >+Bool ivtvHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); >+void ivtvHWAdjustFrame(int scrnIndex, int x, int y, int flags); >+Bool ivtvHWEnterVT(int scrnIndex, int flags); >+void ivtvHWLeaveVT(int scrnIndex, int flags); >+void ivtvHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); >+ >+Bool ivtvHWSaveScreen(ScreenPtr pScreen, int mode); >+Bool ivtvHWSendDMA(ScrnInfoPtr pScrn, void *ptr, int x1, int x2, int y1, >+ int y2); >+ >+#endif >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtv_xv.c ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtv_xv.c >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtv_xv.c 1969-12-31 18:00:00.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/src/ivtv_xv.c 2006-11-06 09:12:00.000000000 -0600 >@@ -0,0 +1,791 @@ >+/* Based on s3virge xv code from XFree86 */ >+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c,v 1.7 2003/02/04 02:20:50 dawes Exp $ */ >+/* >+Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved. >+ >+Permission is hereby granted, free of charge, to any person obtaining a copy of >+this software and associated documentation files (the "Software"), to deal in >+the Software without restriction, including without limitation the rights to >+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies >+of the Software, and to permit persons to whom the Software is furnished to do >+so, subject to the following conditions: >+ >+The above copyright notice and this permission notice shall be included in all >+copies or substantial portions of the Software. >+ >+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- >+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >+XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN >+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION >+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >+ >+Except as contained in this notice, the name of the XFree86 Project shall not >+be used in advertising or otherwise to promote the sale, use or other dealings >+in this Software without prior written authorization from the XFree86 Project. >+*/ >+ >+/* >+ * s3v_xv.c >+ * X Video Extension support >+ * >+ * S3 ViRGE driver >+ * >+ * 7/2000 Kevin Brosius >+ * >+ * Useful references: >+ * X Video extension support -> xc/programs/hw/xfree86/common/xf86xv.c >+ * >+ */ >+ >+/* >+ * I N C L U D E S >+ */ >+#include "errno.h" >+#include "fcntl.h" >+#include "string.h" >+#include "unistd.h" >+ >+#include "sys/ioctl.h" >+ >+#include "config.h" >+#include "ivtvhw.h" >+#include "ivtvdev.h" >+ >+#include "xf86.h" >+#include "xf86xv.h" >+#include "X11/extensions/Xv.h" >+#include "fourcc.h" >+#include "regionstr.h" >+typedef struct ivtv_xv_portData >+{ >+ unsigned int colorKey; >+ RegionRec clip; >+ int autopaintColorKey; >+}Ivtv_Xv_PortData; >+ >+ >+#define IVTV_MAX_PORTS 1 >+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) >+ >+#if !defined(XvExtension) || !defined(IVTV_IOC_PREP_FRAME_YUV) >+void IvtvInitVideo(ScreenPtr pScreen) >+{ >+ ErrorF("XVDriver disabled at compilation time\n"); >+} >+#else >+ >+static XF86VideoAdaptorPtr IVTVSetupImageVideoOverlay(ScreenPtr); >+static int IVTVSetPortAttributeOverlay(ScrnInfoPtr, Atom, INT32, pointer); >+static int IVTVGetPortAttributeOverlay(ScrnInfoPtr, Atom, INT32 *, pointer); >+ >+static void IVTVStopVideo(ScrnInfoPtr, pointer, Bool); >+ >+static void IVTVQueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, >+ unsigned int *, unsigned int *, pointer); >+static int IVTVPutImage(ScrnInfoPtr, short, short, short, short, short, >+ short, short, short, int, unsigned char *, short, >+ short, Bool, RegionPtr, pointer, DrawablePtr); >+static int IVTVQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, >+ unsigned short *, int *, int *); >+ >+void IvtvInitVideo(ScreenPtr pScreen) >+{ >+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >+ XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; >+ XF86VideoAdaptorPtr newAdaptor = NULL; >+ int num_adaptors; >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ >+ ErrorF("Here I am with fPtr %p\n", fPtr); >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, >+ "and YUV dev name %p\n", fPtr->yuvDevName); >+ >+ if (!fPtr->yuvDevName) >+ return; >+ >+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, >+ "Enabling Xv support for PVR350\n"); >+ newAdaptor = IVTVSetupImageVideoOverlay(pScreen); >+ >+ num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); >+ >+ if (newAdaptor) { >+ if (!num_adaptors) { >+ num_adaptors = 1; >+ adaptors = &newAdaptor; >+ } else { >+ newAdaptors = /* need to free this someplace */ >+ xalloc((num_adaptors + >+ 1) * sizeof(XF86VideoAdaptorPtr *)); >+ if (newAdaptors) { >+ memcpy(newAdaptors, adaptors, num_adaptors * >+ sizeof(XF86VideoAdaptorPtr)); >+ newAdaptors[num_adaptors] = newAdaptor; >+ adaptors = newAdaptors; >+ num_adaptors++; >+ } >+ } >+ } >+ >+ if (num_adaptors) >+ xf86XVScreenInit(pScreen, adaptors, num_adaptors); >+ >+ if (newAdaptors) >+ xfree(newAdaptors); >+} >+ >+/* client libraries expect an encoding */ >+static XF86VideoEncodingRec DummyEncoding[1] = { >+ { /* overlay limit */ >+ 0, >+ "XV_IMAGE", >+ 768, 576, >+ {1, 1} >+ } >+}; >+ >+#define NUM_FORMATS_OVERLAY 4 >+#define NUM_FORMATS_TEXTURE 4 >+ >+static XF86VideoFormatRec Formats[NUM_FORMATS_TEXTURE] = { >+ /*{15, TrueColor}, */ {16, TrueColor}, {24, TrueColor} >+ /* , >+ {15, DirectColor} */ , {16, DirectColor}, {24, DirectColor} >+}; >+ >+#define NUM_IMAGES 1 >+ >+static XF86ImageRec Images[NUM_IMAGES] = { >+ XVIMAGE_YV12 >+ /* XVIMAGE_UYVY */ >+}; >+ >+#define NUM_ATTRIBUTES_OVERLAY 2 >+ >+static XF86AttributeRec Attributes[NUM_ATTRIBUTES_OVERLAY] = >+{ >+ {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, >+ {XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLORKEY"}, >+ >+#if 0 >+ {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, >+ {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"} >+#endif >+}; >+static Atom xvColorKey, xvAutopaintColorKey; >+ >+static int >+IVTVSetPortAttributeOverlay(ScrnInfoPtr pScrn, >+ Atom attribute, INT32 value, pointer data) >+{ >+ Ivtv_Xv_PortData *pPriv = (Ivtv_Xv_PortData *)data; >+#ifdef JOHN >+ if (attribute == xvBrightness) { >+ if ((value < -128) || (value > 127)) >+ return BadValue; >+ pPriv->brightness = value; >+ OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | >+ (pPriv->contrast & 0xff)); >+ } else if (attribute == xvContrast) { >+ if ((value < 0) || (value > 255)) >+ return BadValue; >+ pPriv->contrast = value; >+ OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | >+ (pPriv->contrast & 0xff)); >+ } else >+#endif >+ if (attribute == xvColorKey) { >+ pPriv->colorKey = value; >+#ifdef JOHN >+ outMGAdac(0x55, (pPriv->colorKey & pScrn->mask.red) >> >+ pScrn->offset.red); >+ outMGAdac(0x56, (pPriv->colorKey & pScrn->mask.green) >> >+ pScrn->offset.green); >+ outMGAdac(0x57, (pPriv->colorKey & pScrn->mask.blue) >> >+ pScrn->offset.blue); >+#endif >+ REGION_EMPTY(pScrn->pScreen, &pPriv->clip); >+ }else if (attribute == xvAutopaintColorKey) { >+ pPriv->autopaintColorKey = value; >+ } else >+ { >+ ErrorF("IvtvSetPortAttributeOverlay bad attribute\n"); >+ >+ return BadMatch; >+ } >+ >+ return Success; >+} >+ >+static int >+IVTVGetPortAttributeOverlay(ScrnInfoPtr pScrn, >+ Atom attribute, INT32 * value, pointer data) >+{ >+ Ivtv_Xv_PortData *pPriv = (Ivtv_Xv_PortData *)data; >+ >+#ifdef JOHN >+ if (attribute == xvBrightness) { >+ *value = pPriv->brightness; >+ } else if (attribute == xvContrast) { >+ *value = pPriv->contrast; >+ } else >+#endif >+ if (attribute == xvColorKey) { >+ *value = pPriv->colorKey; >+ } else if (attribute == xvAutopaintColorKey) { >+ *value = pPriv->autopaintColorKey; >+ } else >+ { >+ ErrorF("IvtvGetPortAttributeOverlay bad attribute\n"); >+ return BadMatch; >+ } >+ >+ return Success; >+} >+ >+static void >+IVTVQueryBestSize(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) >+{ >+ ErrorF("Query best vid_w %d vid_h %d drw_w %d drw_h %d\n", >+ vid_w, vid_h, drw_w, drw_h); >+ *p_w = drw_w; >+ *p_h = drw_h; >+} >+ >+static XF86VideoAdaptorPtr IVTVAllocAdaptor(ScreenPtr pScreen) >+{ >+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >+ XF86VideoAdaptorPtr adapt; >+ DevUnion *pPriv; >+ int i; >+ >+ if (!(adapt = xf86XVAllocateVideoAdaptorRec(pScrn))) >+ return NULL; >+ >+ if (!(pPriv = xcalloc(1, sizeof(DevUnion) * IVTV_MAX_PORTS))) { >+ xfree(adapt); >+ return NULL; >+ } >+ >+ adapt->pPortPrivates = pPriv; >+ >+ for (i = 0; i < IVTV_MAX_PORTS; i++) >+ { >+ Ivtv_Xv_PortData *portData = (Ivtv_Xv_PortData *)xcalloc(1,sizeof(Ivtv_Xv_PortData)); >+ portData->colorKey = 101; >+ portData->autopaintColorKey = 0; >+#ifdef X_USE_REGION_NULL >+ REGION_NULL(pScreen, &portData->clip); >+#else >+ REGION_INIT(pScreen, &portData->clip, NullBox, 0); >+#endif >+ adapt->pPortPrivates[i].ptr =portData; >+ } >+ >+ >+#if 0 >+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); >+ xvContrast = MAKE_ATOM("XV_CONTRAST"); >+#endif >+ xvColorKey = MAKE_ATOM("XV_COLORKEY"); >+ xvAutopaintColorKey = MAKE_ATOM("XV_AUTOPAINT_COLORKEY"); >+ >+ return adapt; >+} >+ >+static XF86VideoAdaptorPtr IVTVSetupImageVideoOverlay(ScreenPtr pScreen) >+{ >+#ifdef JOHN >+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; >+#endif >+ XF86VideoAdaptorPtr adapt; >+ adapt = IVTVAllocAdaptor(pScreen); >+ >+ adapt->type = XvWindowMask | XvInputMask | XvImageMask; >+ adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; >+ adapt->name = "PVR350"; >+ adapt->nEncodings = 1; >+ adapt->pEncodings = &DummyEncoding[0]; >+ adapt->nFormats = NUM_FORMATS_OVERLAY; >+ adapt->pFormats = Formats; >+ adapt->nPorts = 1; >+ adapt->pAttributes = Attributes /*Attributes */ ; >+ adapt->nImages = 1; >+ adapt->nAttributes = NUM_ATTRIBUTES_OVERLAY; >+ adapt->pImages = Images; >+ adapt->PutVideo = NULL; >+ adapt->PutStill = NULL; >+ adapt->GetVideo = NULL; >+ adapt->GetStill = NULL; >+ adapt->StopVideo = IVTVStopVideo; >+ /* Empty Attrib functions - required anyway */ >+ adapt->SetPortAttribute = IVTVSetPortAttributeOverlay; >+ adapt->GetPortAttribute = IVTVGetPortAttributeOverlay; >+ adapt->QueryBestSize = IVTVQueryBestSize; >+ adapt->PutImage = IVTVPutImage; >+ adapt->QueryImageAttributes = IVTVQueryImageAttributes; >+ >+ return adapt; >+} >+ >+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.x2 != B->extents.x2) || >+ (A->extents.y1 != B->extents.y1) || >+ (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; >+} >+ >+#ifdef JOHN >+/* Not using this at the moment */ >+/* IVTVClipVideo - copied from MGAClipVideo - >+ >+ 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. >+*/ >+ >+#define DummyScreen screenInfo.screens[0] >+ >+static Bool >+IVTVClipVideo(BoxPtr dst, >+ INT32 * x1, >+ INT32 * x2, >+ INT32 * y1, INT32 * y2, RegionPtr reg, INT32 width, INT32 height) >+{ >+ INT32 vscale, hscale, delta; >+ BoxPtr extents = REGION_EXTENTS(DummyScreen, reg); >+ 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 (*x1 >= *x2) >+ return FALSE; >+ >+ 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; >+ } >+ if (*y1 >= *y2) >+ return FALSE; >+ >+ if ((dst->x1 != extents->x1) || (dst->x2 != extents->x2) || >+ (dst->y1 != extents->y1) || (dst->y2 != extents->y2)) { >+ RegionRec clipReg; >+ REGION_INIT(DummyScreen, &clipReg, dst, 1); >+ REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); >+ REGION_UNINIT(DummyScreen, &clipReg); >+ } >+ return TRUE; >+} >+#endif >+ >+static void IVTVStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ Ivtv_Xv_PortData *pPriv = (Ivtv_Xv_PortData *)data; >+ >+ REGION_EMPTY(pScrn->pScreen, &pPriv->clip); >+ >+ if (shutdown) { >+ if (fPtr->fd_yuv != -1) { >+ close(fPtr->fd_yuv); >+ fPtr->fd_yuv = -1; >+ struct ivtvfb_ioctl_colorkey colorKey; >+ colorKey.state = 0; >+ colorKey.colorKey = pPriv->colorKey; >+ if (ioctl(fPtr->fd,IVTVFB_IOCTL_SET_COLORKEY, &colorKey) < 0) { >+ ErrorF >+ ("IVTVFB_IOCTL_SET_COLORKEY failed (error: %s)\n", >+ strerror(errno)); >+ } >+ } >+ } >+ >+} >+ >+static void de_macro_y(unsigned char *src, unsigned char *dst, >+ int w, int h, int src_x, int src_y, int height, int width) >+{ >+ unsigned int x, y, i; >+ unsigned char *dst_2; >+ unsigned int h_tail, w_tail; >+ unsigned int h_size, w_size; >+ >+ // Always round the origin, but compensate by increasing the size >+ if (src_x & 15) { >+ w += src_x & 15; >+ src_x &= ~15; >+ } >+ >+ if (src_y & 15) { >+ h += src_y & 15; >+ src_y &= ~15; >+ } >+ >+ // The right / bottom edge might not be a multiple of 16 >+ h_tail = h & 15; >+ w_tail = w & 15; >+ >+ // One block is 16 pixels high >+ h_size = 16; >+ >+ // descramble Y plane >+ for (y = 0; y < h; y += 16) { >+ >+ // Clip if we've reached the bottom & the size isn't a multiple of 16 >+ if (y + 16 > h) h_size = h_tail; >+ >+ for (x = 0; x < w; x += 16) { >+ if (x + 16 > w) >+ w_size = w_tail; >+ else >+ w_size = 16; >+ >+ dst_2 = dst + (720 * y) + (720 * src_y) + (256 * (src_x>>4)) + (x * 16); >+ >+ for (i = 0; i < h_size; i++) { >+ memcpy(dst_2, src + src_x + x + (y + i) * width + (src_y * width), w_size); >+ dst_2 += 16; >+ } >+ } >+ } >+} >+ >+static void de_macro_uv(unsigned char *srcu, unsigned char *srcv, >+ unsigned char *dst, int w, int h, int src_x, int src_y, >+ int height, int width) >+{ >+ unsigned int x, y, i, f; >+ unsigned char *dst_2; >+ unsigned int h_tail, w_tail; >+ unsigned int h_size; >+ >+ // The uv plane is half the size of the y plane, so 'correct' all dimensions. >+ w /= 2; >+ h /= 2; >+ src_x /= 2; >+ src_y /= 2; >+ height /= 2; >+ width /= 2; >+ >+ // Always round the origin, but compensate by increasing the size >+ if (src_x & 7) { >+ w += src_x & 7; >+ src_x &= ~7; >+ } >+ >+ if (src_y & 15) { >+ h += src_y & 15; >+ src_y &= ~15; >+ } >+ >+ // The right / bottom edge may not be a multiple of 16 >+ h_tail = h & 15; >+ w_tail = w & 7; >+ >+ h_size = 16; >+ >+ // descramble U/V plane >+ for (y = 0; y < h; y += 16) { >+ if ( y + 16 > h ) h_size = h_tail; >+ for (x = 0; x < w; x += 8) { >+ dst_2 = dst + (720 * y) + (720 * src_y) + (256 * (src_x>>3)) + (x * 32); >+ if (x + 8 <= w) { >+ for (i = 0; i < h_size; i++) { >+ int idx = src_x + x + ((y + i) * width) + (src_y * width); >+ dst_2[0] = srcu[idx + 0]; >+ dst_2[1] = srcv[idx + 0]; >+ dst_2[2] = srcu[idx + 1]; >+ dst_2[3] = srcv[idx + 1]; >+ dst_2[4] = srcu[idx + 2]; >+ dst_2[5] = srcv[idx + 2]; >+ dst_2[6] = srcu[idx + 3]; >+ dst_2[7] = srcv[idx + 3]; >+ dst_2[8] = srcu[idx + 4]; >+ dst_2[9] = srcv[idx + 4]; >+ dst_2[10] = srcu[idx + 5]; >+ dst_2[11] = srcv[idx + 5]; >+ dst_2[12] = srcu[idx + 6]; >+ dst_2[13] = srcv[idx + 6]; >+ dst_2[14] = srcu[idx + 7]; >+ dst_2[15] = srcv[idx + 7]; >+ dst_2 += 16; >+ } >+ } >+ else { >+ for (i = 0; i < h_size; i ++) { >+ int idx = src_x + x + ((y + i) * width) + (src_y * width); >+ for (f = 0; f < w_tail; f++) { >+ dst_2[0] = srcu[idx + f]; >+ dst_2[1] = srcv[idx + f]; >+ dst_2 += 2; >+ } >+/* >+ // Used for testing edge cutoff. Sets colour to Green >+ for (f = w_tail;f < 8;f ++) { >+ dst_2[0] = 0; >+ dst_2[1] = 0; >+ dst_2 += 2; >+ } >+*/ >+ dst_2 += 16 - (w_tail << 1); >+ } >+ } >+ } >+ } >+} >+ >+static unsigned char outbuf[622080]; >+ >+static int >+IVTVPutImage(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, DrawablePtr pDraw) >+{ >+ ivtvHWPtr fPtr = FBDEVHWPTR(pScrn); >+ Ivtv_Xv_PortData *pPriv = (Ivtv_Xv_PortData *)data; >+ >+ struct ivtvyuv_ioctl_dma_host_to_ivtv_args args; >+#ifdef JOHN >+ ErrorF("src_w %d src_h %d drw_w %d drw_h %d width %d height %d\n", >+ src_w, src_h, drw_w, drw_h, width, height); >+ ErrorF("src_x %d src_y %d drw_x %d drw_y %d width %d height %d\n", >+ src_x, src_y, drw_x, drw_y, width, height); >+#endif >+ >+ // FIXME - Is this the correct place for this ? >+ >+ // Source coordinates must be even >+ // For origin, round down >+ src_x &= ~1; >+ src_y &= ~1; >+ >+ // For size, round up >+ src_w += src_w & 1; >+ src_h += src_h & 1; >+ >+#ifdef JOHN >+ INT32 x1, x2, y1, y2; >+ unsigned char *dst_start; >+ int top, left, npixels, nlines; >+ int pitch, dstPitch; >+ int new_h; >+ >+ BoxRec dstBox; >+ CARD32 tmp; >+ static int once = 1; >+ static int once2 = 1; >+ >+ /* 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; >+ >+#ifdef JOHN >+ if (!IVTVClipVideo >+ (&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height)) >+ return Success; >+#endif >+ >+ dstBox.x1 -= pScrn->frameX0; >+ dstBox.x2 -= pScrn->frameX0; >+ dstBox.y1 -= pScrn->frameY0; >+ dstBox.y2 -= pScrn->frameY0; >+ >+ pitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; >+ >+ dstPitch = ((width << 1) + 15) & ~15; >+ new_h = ((dstPitch * height) + pitch - 1) / pitch; >+#endif >+ >+ switch (id) { >+ >+ case FOURCC_YV12: >+ { >+ de_macro_y(buf, outbuf, src_w, src_h, src_x, src_y, height, width); >+ de_macro_uv(buf + (width * height) + width * height/ 4, >+ buf + (width * height), outbuf + 720 * 576, >+ src_w, src_h, src_x, src_y, height, width); >+ >+ args.y_source = outbuf; >+ args.uv_source = outbuf + (720 * 576); >+ args.src_x = src_x; >+ args.src_y = src_y; >+ args.dst_x = drw_x; >+ args.dst_y = drw_y; >+ args.src_w = src_w; >+ args.dst_w = drw_w; >+ args.srcBuf_width = width; >+ args.src_h = src_h; >+ args.dst_h = drw_h; >+ args.srcBuf_height = height; >+ } >+ break; >+ default: >+ return BadMatch; >+ } >+ if (fPtr->fd_yuv == -1) { >+ if ((fPtr->fd_yuv = open(fPtr->yuvDevName, O_RDWR)) == -1) { >+ if (errno == ENODEV) >+ ErrorF >+ ("Failed to open \"%s\". Need to initialize the mpeg decoder before the YUV output can be used\n", >+ fPtr->yuvDevName); >+ else >+ ErrorF("Failed to open \"%s\" Error %s\n", >+ fPtr->yuvDevName, strerror(errno)); >+ return BadAccess; >+ } >+ struct ivtvfb_ioctl_colorkey colorKey; >+ colorKey.state = 1; >+ colorKey.colorKey = pPriv->colorKey; >+ if (ioctl(fPtr->fd,IVTVFB_IOCTL_SET_COLORKEY, &colorKey) < 0) { >+ ErrorF >+ ("IVTVFB_IOCTL_SET_COLORKEY failed (error: %s)\n", >+ strerror(errno)); >+ } >+ } >+ int ret = ioctl(fPtr->fd_yuv, IVTV_IOC_PREP_FRAME_YUV, &args); >+ if (ret == -1) { >+ ErrorF >+ ("Ioctl IVTV_IOC_PREP_FRAME_YUV returned failed Error %s\n", >+ strerror(errno)); >+ return BadImplementation; >+ } >+ >+ if(pPriv->autopaintColorKey && >+ !RegionsEqual( &pPriv->clip, clipBoxes)) >+ { >+ /* we always paint V4L's color key */ >+ REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); >+ xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); >+ } >+ return Success; >+} >+ >+static int >+IVTVQueryImageAttributes(ScrnInfoPtr pScrn, >+ int id, >+ unsigned short *w, unsigned short *h, >+ int *pitches, int *offsets) >+{ >+ int size = 0, tmp; >+ >+ if (*w > 768) >+ *w = 768; >+ if (*h > pScrn->virtualY) >+ *h = pScrn->virtualY; >+ >+ *w = (*w + 1) & ~1; >+ if (offsets) >+ offsets[0] = 0; >+ >+ switch (id) { >+ case FOURCC_YV12: >+ *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; >+ default: >+ break; >+ } >+ >+ return size; >+} >+ >+#endif /* !XvExtension */ >diff -aurN ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/TODO ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/TODO >--- ivtvdrv-noX-no-autotools/xc/programs/Xserver/hw/xfree86/drivers/ivtv/TODO 2006-11-06 20:52:19.000000000 -0600 >+++ ivtvdrv/xc/programs/Xserver/hw/xfree86/drivers/ivtv/TODO 1969-12-31 18:00:00.000000000 -0600 >@@ -1,11 +0,0 @@ >- DONE write to 82c registers from driver >- DONE open /dev/video0 if 48 returns ENODEV and check id. >- DONE Try to fail sensibly in PutImage >- DONE define better structure for ioctl >- DONE Buffer allocation for stream in driver >- DONE Compiler warnings >- DONE Apply to latest ivtv source >- DONE Make ivtv_xv cope with NTSC (don't hard code 576) >- DONE vsync wakeup for dma_to_device_vsync >-make ioctl fail if bad type >-do ioctl with bad type and make sure it fails appropriatly to detect correct driver.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 140323
:
91691
|
91692
|
91836
|
92836
|
93201
|
93762
|
93763
|
94196
|
94197
|
101370
|
101371
|
101372