changeset 8513:679abb24a76e

more safer version by the author
author alex
date Sat, 21 Dec 2002 21:01:19 +0000
parents 9c784bd027ad
children a1ff87c254ff
files vidix/drivers/cyberblade_vid.c
diffstat 1 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/vidix/drivers/cyberblade_vid.c	Sat Dec 21 21:00:45 2002 +0000
+++ b/vidix/drivers/cyberblade_vid.c	Sat Dec 21 21:01:19 2002 +0000
@@ -2,11 +2,11 @@
     Driver for CyberBlade/i1 - Version 0.1.1
 
     Copyright (C) 2002 by Alastair M. Robinson.
+    Official homepage: http://www.blackfiveservices.co.uk/EPIAVidix.shtml
+
     Based on Permedia 3 driver by Måns Rullgård
 
     Thanks to Gilles Frattini for bugfixes
-    
-    Official homepage: http://www.blackfiveservices.co.uk/EPIAVidix.shtml
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -200,6 +200,7 @@
 	SROUTB(0x11, protect);
 	unmap_phys_mem(cyberblade_reg_base, 0x20000);
 	unmap_phys_mem(cyberblade_mem, 0x800000);
+	disable_app_io();
 }
 
 
@@ -255,8 +256,12 @@
 int vixSetGrKeys(const vidix_grkey_t *grkey)
 {
 	int pixfmt=CRINB(0x38);
+	int protect;
 	memcpy(&cyberblade_grkey, grkey, sizeof(vidix_grkey_t));
 
+	protect=SRINB(0x11);
+	SROUTB(0x11, 0x92);
+
 	if(pixfmt&0x28) /* 32 or 24 bpp */
 	{
 		SROUTB(0x50, cyberblade_grkey.ckey.blue); /* Colour Key */
@@ -278,6 +283,7 @@
 		SROUTB(0x55, 0xff); /* Colour Key Mask */
 		SROUTB(0x56, 0x00); /* Colour Key Mask */
 	}
+	SROUTB(0x11,protect);
 	return(0);
 }
 
@@ -385,13 +391,13 @@
 			break;
 	}
 
-	/* Assume we have 4 MB to play with */
-	info->num_frames = 0x400000 / info->frame_size;
+	/* Assume we have 2 MB to play with */
+	info->num_frames = 0x200000 / info->frame_size;
 	if(info->num_frames > VID_PLAY_MAXFRAMES)
 		info->num_frames = VID_PLAY_MAXFRAMES;
 
-	/* Start at 4 MB. Let's hope it's not in use. */
-	base0 = 0x400000;
+	/* Start at 6 MB. Let's hope it's not in use. */
+	base0 = 0x600000;
 	info->dga_addr = cyberblade_mem + base0;
 
 	info->dest.pitch.y = 16;
@@ -404,6 +410,12 @@
 		frames[i] = base0+info->offsets[i];
 	}
 
+	enable_app_io();
+	OUTPORT8(0x3d4,0x39);
+	OUTPORT8(0x3d5,INPORT(0x3d5)|1);
+
+	SRINB(0x0b); /* Select new mode */
+
 	/* Unprotect hardware registers... */
 	protect=SRINB(0x11);
 	SROUTB(0x11, 0x92);
@@ -422,6 +434,7 @@
 			SROUTB(0x54, 0xff); /* Colour Key Mask */
 			SROUTB(0x55, 0xff); /* Colour Key Mask */
 			SROUTB(0x56, 0xff); /* Colour Key Mask */
+                        printf("[cyberblade] 24/32-bit mode detected\n"); 
 		}
 		else
 		{
@@ -434,6 +447,7 @@
 			SROUTB(0x54, 0xff); /* Colour Key Mask */
 			SROUTB(0x55, 0xff); /* Colour Key Mask */
 			SROUTB(0x56, 0x00); /* Colour Key Mask */
+                        printf("[cyberblade] 16-bit assumed\n"); 
 		}
 	}
 	/* compute_scale_factor(&src_w, &drw_w, &shrink, &zoom); */
@@ -443,7 +457,7 @@
 
 		if(CRINB(0xd1)&0x80)
 		{
-			fprintf(stderr,"[cyberblade] Using TV-CRTC\n");
+			printf("[cyberblade] Using TV-CRTC\n");
 			HTotal=CRINB(0xe0);
 			HSync=CRINB(0xe4);
 			VTotal=CRINB(0xe6);
@@ -459,7 +473,7 @@
 		}
 		else
 		{
-			fprintf(stderr,"[cyberblade] Using Standard CRTC\n");
+			printf("[cyberblade] Using Standard CRTC\n");
 			HTotal=CRINB(0x00);
 			HSync=CRINB(0x04);
 			VTotal=CRINB(0x06);
@@ -469,10 +483,13 @@
 			HSync <<=3;
 			VTotal |= (Overflow & 1) <<8;
 			VTotal |= (Overflow & 0x20) <<4;
+			VTotal +=4;
 			VSync |= (Overflow & 4) <<6;
 			VSync |= (Overflow & 0x80) <<2;
 		}
 
+		printf("[cyberblade] HTotal: 0x%x, HSStart: 0x%x\n",HTotal,HSync); 
+		printf("  VTotal: 0x%x, VStart: 0x%x\n",VTotal,VSync);
 		tx1=(HTotal-HSync)+15+info->dest.x;
 		ty1=(VTotal-VSync)-8+info->dest.y;
 		tx2=tx1+info->dest.w;