summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2001-07-24 19:06:04 +0000
committerKeith Packard <keithp@keithp.com>2001-07-24 19:06:04 +0000
commitb7eb8a35b51aa2edc9ff59f091ee88ea7000b757 (patch)
tree0b6d32a25c7aa27d0fd4a8a30c9539e354aef245
parentd2d221a012950b98e48e47b6dea38e6ad385fef8 (diff)
kdrive: Unmap vesa device when disabled
-rw-r--r--hw/kdrive/fbdev/fbdev.c6
-rw-r--r--hw/kdrive/mach64/mach64.c80
-rw-r--r--hw/kdrive/mach64/mach64.h23
-rw-r--r--hw/kdrive/mach64/mach64draw.c4
-rw-r--r--hw/kdrive/mach64/mach64video.c14
-rw-r--r--hw/kdrive/vesa/vesa.c38
6 files changed, 132 insertions, 33 deletions
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index 4bd800e6b..b5e2df9f9 100644
--- a/hw/kdrive/fbdev/fbdev.c
+++ b/hw/kdrive/fbdev/fbdev.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.26 2001/07/19 08:46:30 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.27 2001/07/20 19:35:29 keithp Exp $ */
#include "fbdev.h"
@@ -122,8 +122,8 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
case FB_VISUAL_PSEUDOCOLOR:
if (gray)
{
- screen->fb[0].visuals = ((1 << StaticGray) |
- (1 << GrayScale));
+ screen->fb[0].visuals = (1 << StaticGray);
+ /* could also support GrayScale, but what's the point? */
}
else
{
diff --git a/hw/kdrive/mach64/mach64.c b/hw/kdrive/mach64/mach64.c
index 1864907d5..72e91953e 100644
--- a/hw/kdrive/mach64/mach64.c
+++ b/hw/kdrive/mach64/mach64.c
@@ -19,7 +19,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64.c,v 1.5 2001/06/23 03:41:24 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64.c,v 1.6 2001/07/20 19:35:30 keithp Exp $ */
#include "mach64.h"
#include <sys/io.h>
@@ -33,17 +33,7 @@ mach64CardInit (KdCardInfo *card)
if (!mach64c)
return FALSE;
- mach64c->reg_base = (CARD8 *) KdMapDevice (MACH64_REG_BASE(card),
- MACH64_REG_SIZE(card));
-
- if (mach64c->reg_base)
- {
- KdSetMappedMode (MACH64_REG_BASE(card),
- MACH64_REG_SIZE(card),
- KD_MAPPED_MODE_REGISTERS);
- }
- mach64c->reg = (Reg *) (mach64c->reg_base + MACH64_REG_OFF(card));
- mach64c->media_reg = (MediaReg *) (mach64c->reg_base + MACH64_MEDIA_REG_OFF(card));
+ (void) mach64MapReg (card, mach64c);
mach64c->lcdEnabled = FALSE;
if (!vesaInitialize (card, &mach64c->vesa))
@@ -199,16 +189,58 @@ mach64Preserve (KdCardInfo *card)
}
}
+Bool
+mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c)
+{
+ mach64c->reg_base = (CARD8 *) KdMapDevice (MACH64_REG_BASE(card),
+ MACH64_REG_SIZE(card));
+
+ if (!mach64c->reg_base)
+ {
+ mach64c->reg = 0;
+ mach64c->media_reg = 0;
+ return FALSE;
+ }
+
+ KdSetMappedMode (MACH64_REG_BASE(card),
+ MACH64_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ mach64c->reg = (Reg *) (mach64c->reg_base + MACH64_REG_OFF(card));
+ mach64c->media_reg = (MediaReg *) (mach64c->reg_base + MACH64_MEDIA_REG_OFF(card));
+ return TRUE;
+}
+
void
-mach64SetMMIO (Mach64CardInfo *mach64c)
+mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c)
{
- if (mach64c->reg->GUI_STAT == 0xffffffff)
- FatalError ("Mach64 REG not visible\n");
+ if (mach64c->reg_base)
+ {
+ KdUnmapDevice ((void *) mach64c->reg_base, MACH64_REG_SIZE(card));
+ KdResetMappedMode (MACH64_REG_BASE(card),
+ MACH64_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ mach64c->reg_base = 0;
+ mach64c->reg = 0;
+ mach64c->media_reg = 0;
+ }
+}
+
+void
+mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c)
+{
+ if (!mach64c->reg_base)
+ mach64MapReg (card, mach64c);
+ if (mach64c->reg)
+ {
+ if (mach64c->reg->GUI_STAT == 0xffffffff)
+ FatalError ("Mach64 REG not visible\n");
+ }
}
void
-mach64ResetMMIO (Mach64CardInfo *mach64c)
+mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c)
{
+ mach64UnmapReg (card, mach64c);
}
Bool
@@ -220,7 +252,7 @@ mach64Enable (ScreenPtr pScreen)
if (!vesaEnable (pScreen))
return FALSE;
- mach64SetMMIO (mach64c);
+ mach64SetMMIO (pScreenPriv->card, mach64c);
mach64DPMS (pScreen, KD_DPMS_NORMAL);
#ifdef XV
KdXVEnable (pScreen);
@@ -231,9 +263,13 @@ mach64Enable (ScreenPtr pScreen)
void
mach64Disable (ScreenPtr pScreen)
{
+ KdScreenPriv(pScreen);
+ Mach64CardInfo *mach64c = pScreenPriv->card->driver;
+
#ifdef XV
KdXVDisable (pScreen);
#endif
+ mach64ResetMMIO (pScreenPriv->card, mach64c);
vesaDisable (pScreen);
}
@@ -354,7 +390,7 @@ mach64Restore (KdCardInfo *card)
{
mach64WriteLCD (reg, 1, mach64c->save.LCD_GEN_CTRL);
}
- mach64ResetMMIO (mach64c);
+ mach64ResetMMIO (card, mach64c);
vesaRestore (card);
}
@@ -373,13 +409,7 @@ mach64CardFini (KdCardInfo *card)
{
Mach64CardInfo *mach64c = card->driver;
- if (mach64c->reg_base)
- {
- KdUnmapDevice ((void *) mach64c->reg_base, MACH64_REG_SIZE(card));
- KdResetMappedMode (MACH64_REG_BASE(card),
- MACH64_REG_SIZE(card),
- KD_MAPPED_MODE_REGISTERS);
- }
+ mach64UnmapReg (card, mach64c);
vesaCardFini (card);
}
diff --git a/hw/kdrive/mach64/mach64.h b/hw/kdrive/mach64/mach64.h
index d305690bd..e33250604 100644
--- a/hw/kdrive/mach64/mach64.h
+++ b/hw/kdrive/mach64/mach64.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64.h,v 1.4 2001/06/19 09:31:47 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64.h,v 1.5 2001/06/23 03:41:24 keithp Exp $ */
#ifndef _MACH64_H_
#define _MACH64_H_
@@ -582,6 +582,27 @@ void
mach64WriteLCD (Reg *reg, int id, CARD32 data);
void
+mach64Preserve (KdCardInfo *card);
+
+Bool
+mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c);
+
+void
+mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c);
+
+void
+mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c);
+
+void
+mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c);
+
+Bool
+mach64Enable (ScreenPtr pScreen);
+
+void
+mach64Disable (ScreenPtr pScreen);
+
+void
mach64WaitAvail(Reg *reg, int n);
void
diff --git a/hw/kdrive/mach64/mach64draw.c b/hw/kdrive/mach64/mach64draw.c
index 75508ae12..272c5da95 100644
--- a/hw/kdrive/mach64/mach64draw.c
+++ b/hw/kdrive/mach64/mach64draw.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64draw.c,v 1.5 2001/06/23 03:41:24 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64draw.c,v 1.6 2001/07/23 03:44:17 keithp Exp $ */
#include "mach64.h"
#include "mach64draw.h"
@@ -97,6 +97,8 @@ mach64Setup (ScreenPtr pScreen, CARD32 combo, int wait)
avail = 0;
reg = mach64c->reg;
triple = mach64s->bpp24;
+ if (!reg)
+ return FALSE;
mach64WaitAvail(reg, wait + 3);
reg->DP_PIX_WIDTH = mach64s->DP_PIX_WIDTH;
diff --git a/hw/kdrive/mach64/mach64video.c b/hw/kdrive/mach64/mach64video.c
index c7588bbb8..e11f424ea 100644
--- a/hw/kdrive/mach64/mach64video.c
+++ b/hw/kdrive/mach64/mach64video.c
@@ -19,7 +19,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64video.c,v 1.4 2001/06/21 21:44:09 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/mach64/mach64video.c,v 1.5 2001/06/23 03:41:24 keithp Exp $ */
#include "mach64.h"
#include "Xv.h"
@@ -46,6 +46,9 @@ mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit)
REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
+ if (!media)
+ return;
+
if(pPortPriv->videoOn)
{
mach64WaitIdle (reg);
@@ -556,6 +559,9 @@ mach64PutImage(KdScreenInfo *screen,
if((x1 >= x2) || (y1 >= y2))
return Success;
+ if (!media)
+ return BadAlloc;
+
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
@@ -835,6 +841,12 @@ Bool mach64InitVideo(ScreenPtr pScreen)
KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
KdVideoAdaptorPtr newAdaptor = NULL;
int num_adaptors;
+ KdCardInfo *card = pScreenPriv->card;
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+ Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
+
+ if (!mach64c->media_reg)
+ return FALSE;
newAdaptor = mach64SetupImageVideo(pScreen);
diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c
index 1144c7400..ab8ea41e5 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.14 2001/06/11 01:38:54 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.15 2001/07/20 19:35:30 keithp Exp $ */
#include "vesa.h"
#ifdef RANDR
@@ -990,6 +990,7 @@ vesaUnmapFramebuffer (KdScreenInfo *screen)
VbeUnmapFramebuffer(priv->vi, priv->vbeInfo, pscr->mode.mode, pscr->fb);
else
VgaUnmapFramebuffer (priv->vi);
+ pscr->fb = 0;
}
}
@@ -1429,6 +1430,7 @@ vesaEnable(ScreenPtr pScreen)
KdScreenPriv(pScreen);
VesaCardPrivPtr priv = pScreenPriv->card->driver;
VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ KdScreenInfo *screen = pScreenPriv->screen;
int code;
int i;
CARD32 size;
@@ -1441,6 +1443,36 @@ vesaEnable(ScreenPtr pScreen)
case VESA_MONO:
VgaSetWritePlaneMask (priv->vi, 0x1);
case VESA_LINEAR:
+ /*
+ * Remap the frame buffer if necessary
+ */
+ if (!pscr->fb)
+ {
+ if (pscr->mode.vbe)
+ pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo,
+ pscr->mode.mode,
+ &pscr->fb_size);
+ else
+ pscr->fb = VgaMapFramebuffer (priv->vi,
+ pscr->mode.mode,
+ &pscr->fb_size);
+ if (!pscr->fb)
+ return FALSE;
+ screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb);
+ /*
+ * Set frame buffer mapping
+ */
+ if (!pscr->shadow)
+ {
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+ }
+ }
memcpy (priv->text, pscr->fb, VESA_TEXT_SAVE);
break;
case VESA_WINDOWED:
@@ -1473,8 +1505,9 @@ void
vesaDisable(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
VesaCardPrivPtr priv = pScreenPriv->card->driver;
- VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ VesaScreenPrivPtr pscr = screen->driver;
int i=0;
CARD32 size;
char *p;
@@ -1507,6 +1540,7 @@ vesaDisable(ScreenPtr pScreen)
}
break;
}
+ vesaUnmapFramebuffer (screen);
}
void