summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2000-09-27 20:47:37 +0000
committerKeith Packard <keithp@keithp.com>2000-09-27 20:47:37 +0000
commit6171187e92152a443f7d5dd7f0dad866b3e275ea (patch)
treefac456544632cc6febb67edf12dc2801d72280ed
parent367cab99ece8655bbd8a65096bb68bcfd7ef6fea (diff)
kdrive: memory/fd leaks fixed in fbdev/vesa/trident drivers
-rw-r--r--hw/kdrive/fbdev/fbdev.c50
-rw-r--r--hw/kdrive/fbdev/fbdev.h2
-rw-r--r--hw/kdrive/src/kdrive.c10
-rw-r--r--hw/kdrive/src/kdrive.h3
-rw-r--r--hw/kdrive/src/kshadow.c9
-rw-r--r--hw/kdrive/trident/trident.c3
-rw-r--r--hw/kdrive/vesa/vbe.c2
-rw-r--r--hw/kdrive/vesa/vesa.c4
8 files changed, 59 insertions, 24 deletions
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index 7748b798f..8f628ec1a 100644
--- a/hw/kdrive/fbdev/fbdev.c
+++ b/hw/kdrive/fbdev/fbdev.c
@@ -136,13 +136,14 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
priv->var.bits_per_pixel == 16)
{
fake24 = TRUE;
+ scrpriv->shadow = TRUE;
+ scrpriv->rotate = FALSE;
screen->fb[0].redMask = 0xff0000;
screen->fb[0].greenMask = 0x00ff00;
screen->fb[0].blueMask = 0x0000ff;
screen->width = priv->var.xres;
screen->height = priv->var.yres;
screen->softCursor = TRUE;
- return KdShadowScreenInit (screen);
}
else
#endif
@@ -164,9 +165,13 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
screen->width = priv->var.yres;
screen->height = priv->var.xres;
screen->softCursor = TRUE;
- return KdShadowScreenInit (screen);
}
}
+ if (scrpriv->rotate)
+ scrpriv->shadow = TRUE;
+ if (scrpriv->shadow)
+ return KdShadowScreenInit (screen);
+ return TRUE;
}
Bool
@@ -293,23 +298,30 @@ fbdevInitScreen (ScreenPtr pScreen)
ShadowUpdateProc update;
ShadowWindowProc window;
-#ifdef FAKE24_ON_16
- if (pScreenPriv->screen->fb[0].bitsPerPixel == 24 && priv->var.bits_per_pixel == 16)
+ if (scrpriv->shadow)
{
- return KdShadowInitScreen (pScreen, fbdevUpdateFake24, fbdevWindowLinear);
- }
- else
+ window = fbdevWindowLinear;
+#ifdef FAKE24_ON_16
+ if (pScreenPriv->screen->fb[0].bitsPerPixel == 24 && priv->var.bits_per_pixel == 16)
+ {
+ update = fbdevUpdateFake24;
+ }
+ else
#endif /* FAKE24_ON_16 */
- if (scrpriv->rotate)
- {
- window = fbdevWindowLinear;
- switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
- case 8:
- update = shadowUpdateRotate8; break;
- case 16:
- update = shadowUpdateRotate16; break;
- case 32:
- update = shadowUpdateRotate32; break;
+ {
+ update = shadowUpdatePacked;
+ if (scrpriv->rotate)
+ {
+ window = fbdevWindowLinear;
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ update = shadowUpdateRotate8; break;
+ case 16:
+ update = shadowUpdateRotate16; break;
+ case 32:
+ update = shadowUpdateRotate32; break;
+ }
+ }
}
return KdShadowInitScreen (pScreen, update, window);
}
@@ -405,6 +417,10 @@ fbdevRestore (KdCardInfo *card)
void
fbdevScreenFini (KdScreenInfo *screen)
{
+ FbdevScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->shadow)
+ KdShadowScreenFini (screen);
}
void
diff --git a/hw/kdrive/fbdev/fbdev.h b/hw/kdrive/fbdev/fbdev.h
index 9846cdce4..f28997bff 100644
--- a/hw/kdrive/fbdev/fbdev.h
+++ b/hw/kdrive/fbdev/fbdev.h
@@ -40,11 +40,11 @@ typedef struct _fbdevPriv {
int fd;
char *fb;
char *fb_base;
- Bool rotate;
} FbdevPriv;
typedef struct _fbdevScrPriv {
Bool rotate;
+ Bool shadow;
} FbdevScrPriv;
Bool
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index c6a6fc36f..b6d57a138 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -633,11 +633,6 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pScreen->SaveScreen = KdSaveScreen;
pScreen->CreateWindow = KdCreateWindow;
-#ifdef RENDER
- if (!fbPictureInit (pScreen, 0, 0))
- return FALSE;
-#endif
-
#ifdef FB_OLD_SCREEN
pScreenPriv->BackingStoreFuncs.SaveAreas = fbSaveAreas;
pScreenPriv->BackingStoreFuncs.RestoreAreas = fbSaveAreas;
@@ -685,6 +680,11 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pScreen->BlockHandler = KdBlockHandler;
pScreen->WakeupHandler = KdWakeupHandler;
+#ifdef RENDER
+ if (!fbPictureInit (pScreen, 0, 0))
+ return FALSE;
+#endif
+
if (card->cfuncs->initScreen)
if (!(*card->cfuncs->initScreen) (pScreen))
return FALSE;
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 7b0b70cdf..e6dedbafb 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -591,6 +591,9 @@ KdShadowScreenInit (KdScreenInfo *screen);
Bool
KdShadowInitScreen (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window);
+void
+KdShadowScreenFini (KdScreenInfo *screen);
+
/* ktest.c */
Bool
KdFrameBufferValid (CARD8 *base, int size);
diff --git a/hw/kdrive/src/kshadow.c b/hw/kdrive/src/kshadow.c
index 57796c987..2a26cef57 100644
--- a/hw/kdrive/src/kshadow.c
+++ b/hw/kdrive/src/kshadow.c
@@ -30,6 +30,8 @@ KdShadowScreenInit (KdScreenInfo *screen)
void *buf;
buf = shadowAlloc (screen->width, screen->height, screen->fb[0].bitsPerPixel);
+ if (!buf)
+ return FALSE;
screen->fb[0].frameBuffer = buf;
screen->fb[0].byteStride = BitmapBytePad (screen->width * screen->fb[0].bitsPerPixel);
screen->fb[0].pixelStride = screen->fb[0].byteStride * 8 / screen->fb[0].bitsPerPixel;
@@ -44,3 +46,10 @@ KdShadowInitScreen (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc
return shadowInit (pScreen, update, window);
}
+
+void
+KdShadowScreenFini (KdScreenInfo *screen)
+{
+ if (screen->fb[0].frameBuffer)
+ xfree (screen->fb[0].frameBuffer);
+}
diff --git a/hw/kdrive/trident/trident.c b/hw/kdrive/trident/trident.c
index dfcf79054..57b2b93c2 100644
--- a/hw/kdrive/trident/trident.c
+++ b/hw/kdrive/trident/trident.c
@@ -286,6 +286,9 @@ tridentScreenFini (KdScreenInfo *screen)
{
TridentScreenInfo *tridents = (TridentScreenInfo *) screen->driver;
+#ifdef VESA
+ vesaScreenFini (screen);
+#endif
xfree (tridents);
screen->driver = 0;
}
diff --git a/hw/kdrive/vesa/vbe.c b/hw/kdrive/vesa/vbe.c
index fecb05803..fa2fbeaa3 100644
--- a/hw/kdrive/vesa/vbe.c
+++ b/hw/kdrive/vesa/vbe.c
@@ -188,6 +188,8 @@ VbeCleanup(VbeInfoPtr vi)
munmap(vi->magicMem, MAGICMEM_SIZE);
munmap(vi->loMem, LOMEM_SIZE);
munmap(vi->hiMem, HIMEM_SIZE);
+ close (vi->devmem);
+ close (vi->devzero);
xfree(vi);
}
diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c
index 4542611c0..fa5bfc62d 100644
--- a/hw/kdrive/vesa/vesa.c
+++ b/hw/kdrive/vesa/vesa.c
@@ -19,7 +19,7 @@ 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.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.5 2000/09/15 07:25:13 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.6 2000/09/19 23:50:47 keithp Exp $ */
#include "vesa.h"
@@ -795,6 +795,8 @@ vesaScreenFini(KdScreenInfo *screen)
if (pscr->fb)
VbeUnmapFramebuffer(priv->vi, &pscr->mode->vmib, pscr->fb);
+ if (pscr->shadow)
+ KdShadowScreenFini (screen);
screen->fb[0].depth = pscr->origDepth;
return;
}