Commit 6171187e authored by Keith Packard's avatar Keith Packard
Browse files

kdrive: memory/fd leaks fixed in fbdev/vesa/trident drivers

parent 367cab99
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
}
......@@ -286,6 +286,9 @@ tridentScreenFini (KdScreenInfo *screen)
{
TridentScreenInfo *tridents = (TridentScreenInfo *) screen->driver;
#ifdef VESA
vesaScreenFini (screen);
#endif
xfree (tridents);
screen->driver = 0;
}
......
......@@ -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);
}
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment