summaryrefslogtreecommitdiff
path: root/hw/kdrive/mach64
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 /hw/kdrive/mach64
parentd2d221a012950b98e48e47b6dea38e6ad385fef8 (diff)
kdrive: Unmap vesa device when disabled
Diffstat (limited to 'hw/kdrive/mach64')
-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
4 files changed, 93 insertions, 28 deletions
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);