diff options
author | Luc Verhaegen <libv@skynet.be> | 2006-09-24 16:09:04 +0200 |
---|---|---|
committer | Luc Verhaegen <libv@skynet.be> | 2006-09-24 16:09:04 +0200 |
commit | 678ca117f6126277b943cff0e97eb21c0e01815a (patch) | |
tree | 1c10049d0a5a20c3c356462bf4bb86f954f516fe | |
parent | ced73c2735b0f14d0e90566b524e8553f6c6d904 (diff) |
Xv: Review allocation and destruction of structures.
Also add a define for the port name.
-rw-r--r-- | src/via_driver.c | 16 | ||||
-rw-r--r-- | src/via_driver.h | 3 | ||||
-rw-r--r-- | src/via_video.c | 78 | ||||
-rw-r--r-- | src/via_video.h | 2 |
4 files changed, 52 insertions, 47 deletions
diff --git a/src/via_driver.c b/src/via_driver.c index e5ec8c4..7c2b6ca 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -374,13 +374,6 @@ VIAGetRec(ScrnInfoPtr pScrn) pVia = VIAPTR(pScrn); pVia->scrnIndex = pScrn->scrnIndex; - pVia->Scratch = NULL; - pVia->Outputs = NULL; - pVia->Monitor = NULL; - - pVia->Cursor = NULL; - pVia->CursorImage = NULL; - return TRUE; } @@ -2434,7 +2427,8 @@ VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode) /* this is waaaay too simplistic and even plain wrong. */ #ifdef _VIA_VIDEO_H_ - pVia->Swov->Allowed = FALSE; + if (pVia->Swov) + pVia->Swov->Allowed = FALSE; #endif pScrn->vtSema = TRUE; @@ -2494,6 +2488,12 @@ static Bool VIACloseScreen(int scrnIndex, ScreenPtr pScreen) if (pVia->directRenderingEnabled) VIADRICloseScreen(pScrn, pScreen); #endif + +#ifdef _VIA_VIDEO_H_ + if (pVia->Swov) + ViaVideoDestroy(pScrn); +#endif + if (pVia->AccelInfoRec) { XAADestroyInfoRec(pVia->AccelInfoRec); pVia->AccelInfoRec = NULL; diff --git a/src/via_driver.h b/src/via_driver.h index 9fd1144..a3e758b 100644 --- a/src/via_driver.h +++ b/src/via_driver.h @@ -278,7 +278,7 @@ typedef struct _VIA { /* Video */ #ifdef _VIA_VIDEO_H_ - struct ViaSwov Swov[1]; + struct ViaSwov * Swov; #endif ViaSharedPtr sharedData; @@ -332,6 +332,7 @@ Bool VIADGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen); /*In via_video.c*/ #ifdef XvExtension void ViaVideoInit(ScrnInfoPtr pScrn, ScreenPtr pScreen); +void ViaVideoDestroy(ScrnInfoPtr pScrn); #endif /* via_i2c.c */ diff --git a/src/via_video.c b/src/via_video.c index 26072ba..bb86585 100644 --- a/src/via_video.c +++ b/src/via_video.c @@ -333,7 +333,7 @@ ViaSwovCopyDMA(VIAPtr pVia, struct ViaMem *Mem, CARD8 *buf) /* Everything VIA requires 16byte alignment -- idiots */ if (((int) buf & 0x0F)) { ViaDebug(pVia->scrnIndex, "%s: Buffer Misalignment!\n", __FUNCTION__); - new_buf = malloc(Mem->Size + 0x0F); + new_buf = xnfalloc(Mem->Size + 0x0F); aligned_buf = (CARD8 *) (((int) new_buf + 0x0F) & ~0x0F); memcpy(aligned_buf, buf, Mem->Size); } else @@ -2411,7 +2411,7 @@ ViaSwovStop(ScrnInfoPtr pScrn) * */ static void -viaStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) +ViaStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) { struct ViaSwov *Swov = VIAPTR(pScrn)->Swov; struct ViaXvPort *Port = (struct ViaXvPort *)data; @@ -2445,22 +2445,23 @@ viaStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) /* * */ -static void +static struct ViaSwov * ViaSwovInit(ScrnInfoPtr pScrn) { VIAPtr pVia = VIAPTR(pScrn); - struct ViaSwov *Swov = pVia->Swov; + struct ViaSwov *Swov; VIAFUNC(pVia->scrnIndex); + pVia->Swov = (struct ViaSwov *) xnfcalloc(1, sizeof(struct ViaSwov)); + + Swov = pVia->Swov; + Swov->scrnIndex = pVia->scrnIndex; Swov->Allowed = FALSE; Swov->Active = FALSE; - Swov->Adaptor = NULL; - Swov->Adaptors = NULL; - /* Set up memory Map */ Swov->Video = (struct ViaVideoRegs *) (pVia->MapBase + 0x200); Swov->HQV = (struct ViaHQVRegs *) (pVia->MapBase + 0x3D0); @@ -2488,6 +2489,8 @@ ViaSwovInit(ScrnInfoPtr pScrn) } ViaVideoReset(pScrn); + + return Swov; } /* @@ -2503,8 +2506,6 @@ ViaXvPortInit(ScreenPtr pScreen) Port->brightness = 5000.; Port->saturation = 10000; Port->contrast = 10000; - Port->hue = 0; - Port->Opacity = 0; #ifdef X_USE_REGION_NULL REGION_NULL(pScreen, &Port->clip); @@ -2512,32 +2513,9 @@ ViaXvPortInit(ScreenPtr pScreen) REGION_INIT(pScreen, &Port->clip, NullBox, 1); #endif - /* init ViaMem pointers */ - Port->Width = 0; - Port->Height = 0; - - Port->Front[0] = NULL; - Port->Front[1] = NULL; - Port->Back[0] = NULL; - Port->Back[1] = NULL; - Port->Back[2] = NULL; - Port->AlphaFB = NULL; - Port->AlphaLocalUnaligned = NULL; - Port->AlphaLocal = NULL; - /* attribute? */ Port->Deinterlace = VIA_DEINT_INTERLEAVE; - Port->Src_X = 0; - Port->Src_Y = 0; - Port->Src_W = 0; - Port->Src_H = 0; - - Port->Drw_X = 0; - Port->Drw_Y = 0; - Port->Drw_W = 0; - Port->Drw_H = 0; - return Port; } @@ -2556,7 +2534,7 @@ ViaXvAdaptorInit(ScrnInfoPtr pScrn) Adaptor->type = XvWindowMask | XvImageMask | XvInputMask; Adaptor->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - Adaptor->name = "XV_SWOV"; + Adaptor->name = ViaXVAdaptorName; Adaptor->nEncodings = 1; Adaptor->pEncodings = DummyEncoding; Adaptor->nFormats = sizeof(FormatsG) / sizeof(FormatsG[0]); @@ -2571,7 +2549,7 @@ ViaXvAdaptorInit(ScrnInfoPtr pScrn) Adaptor->nImages = NUM_IMAGES_G; Adaptor->pImages = ImagesG; Adaptor->PutVideo = NULL; - Adaptor->StopVideo = viaStopVideo; + Adaptor->StopVideo = ViaStopVideo; Adaptor->QueryBestSize = viaQueryBestSize; Adaptor->GetPortAttribute = viaGetPortAttribute; Adaptor->SetPortAttribute = viaSetPortAttribute; @@ -2605,23 +2583,47 @@ ViaVideoInit(ScrnInfoPtr pScrn, ScreenPtr pScreen) xvAutoPaint = MAKE_ATOM("XV_AUTOPAINT_COLORKEY"); xvOpacity = MAKE_ATOM("XV_OPACITY"); - ViaSwovInit(pScrn); - Swov = pVia->Swov; + Swov = ViaSwovInit(pScrn); Swov->Port = ViaXvPortInit(pScreen); Swov->Adaptor = ViaXvAdaptorInit(pScrn); - Swov->Adaptors = xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + Swov->Adaptors = xnfalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); if (num_adaptors) memcpy(Swov->Adaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr)); - adaptor[0] = pVia->Swov->Adaptor; + adaptor[0] = Swov->Adaptor; memcpy(Swov->Adaptors + num_adaptors, adaptor, sizeof(XF86VideoAdaptorPtr)); xf86XVScreenInit(pScreen, Swov->Adaptors, num_adaptors + 1); VIASetColorSpace(pVia); } +/* + * + */ +void +ViaVideoDestroy(ScrnInfoPtr pScrn) +{ + VIAPtr pVia = VIAPTR(pScrn); + struct ViaSwov *Swov = pVia->Swov; + + VIAFUNC(pScrn->scrnIndex); + + /* Make sure we're shut down first. */ + ViaStopVideo(pScrn, Swov->Port, TRUE); + + /* Now tear down the wallpaper */ + xfree(Swov->Adaptors); + xfree(Swov->Adaptor->pPortPrivates); + xfree(Swov->Adaptor->pImages); + xf86XVFreeVideoAdaptorRec(Swov->Adaptor); + xfree(Swov->Port); + xfree(Swov); + + pVia->Swov = NULL; +} + #endif /* XvExtension */ diff --git a/src/via_video.h b/src/via_video.h index d773e62..8ab2074 100644 --- a/src/via_video.h +++ b/src/via_video.h @@ -24,6 +24,8 @@ #ifndef _VIA_VIDEO_H_ #define _VIA_VIDEO_H_ 1 +#define ViaXVAdaptorName "VIA Unichrome HW video overlay" + /* * Stream specific stuff. */ |