[Mplayer-cvslog] CVS: main/drivers mga_vid.c,1.24,1.25

Arpi of Ize arpi at mplayer.dev.hu
Fri Oct 5 00:25:34 CEST 2001


Update of /cvsroot/mplayer/main/drivers
In directory mplayer:/var/tmp.root/cvs-serv13448

Modified Files:
	mga_vid.c 
Log Message:
save and restore colorkey, to work together with Xv

Index: mga_vid.c
===================================================================
RCS file: /cvsroot/mplayer/main/drivers/mga_vid.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- mga_vid.c	4 Oct 2001 21:15:01 -0000	1.24
+++ mga_vid.c	4 Oct 2001 22:25:13 -0000	1.25
@@ -165,6 +165,11 @@
 
 static mga_vid_config_t mga_config; 
 
+static int colkey_saved=0;
+static int colkey_on=0;
+static unsigned char colkey_color[4];
+static unsigned char colkey_mask[4];
+
 static int mga_irq = -1;
 
 //All register offsets are converted to word aligned offsets (32 bit)
@@ -254,13 +259,74 @@
 }
 
 
-static void mga_vid_write_regs(void)
+static void mga_vid_write_regs(int restore)
 {
 	//Make sure internal registers don't get updated until we're done
 	writel( (readl(mga_mmio_base + VCOUNT)-1)<<16,
 			mga_mmio_base + BESGLOBCTL);
 
 	// color or coordinate keying
+	
+	if(restore && colkey_saved){
+	    // restore it
+	    colkey_saved=0;
+
+		printk("mga_vid: Restoring colorkey (ON: %d  %02X:%02X:%02X)\n",
+			colkey_on,colkey_color[0],colkey_color[1],colkey_color[2]);
+
+		// Set color key registers:
+		writeb( XKEYOPMODE, mga_mmio_base + PALWTADD);
+		writeb( colkey_on, mga_mmio_base + X_DATAREG);
+		
+		writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD);
+		writeb( colkey_color[0], mga_mmio_base + X_DATAREG);
+		writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD);
+		writeb( colkey_color[1], mga_mmio_base + X_DATAREG);
+		writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD);
+		writeb( colkey_color[2], mga_mmio_base + X_DATAREG);
+		writeb( X_COLKEY, mga_mmio_base + PALWTADD);
+		writeb( colkey_color[3], mga_mmio_base + X_DATAREG);
+
+		writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD);
+		writeb( colkey_mask[0], mga_mmio_base + X_DATAREG);
+		writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD);
+		writeb( colkey_mask[1], mga_mmio_base + X_DATAREG);
+		writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD);
+		writeb( colkey_mask[2], mga_mmio_base + X_DATAREG);
+		writeb( XCOLMSK, mga_mmio_base + PALWTADD);
+		writeb( colkey_mask[3], mga_mmio_base + X_DATAREG);
+
+	} else if(!colkey_saved){
+	    // save it
+	    colkey_saved=1;
+		// Get color key registers:
+		writeb( XKEYOPMODE, mga_mmio_base + PALWTADD);
+		colkey_on=(unsigned char)readb(mga_mmio_base + X_DATAREG) & 1;
+		
+		writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD);
+		colkey_color[0]=(unsigned char)readb(mga_mmio_base + X_DATAREG);
+		writeb( XCOLKEY0GREEN, mga_mmio_base + PALWTADD);
+		colkey_color[1]=(unsigned char)readb(mga_mmio_base + X_DATAREG);
+		writeb( XCOLKEY0BLUE, mga_mmio_base + PALWTADD);
+		colkey_color[2]=(unsigned char)readb(mga_mmio_base + X_DATAREG);
+		writeb( X_COLKEY, mga_mmio_base + PALWTADD);
+		colkey_color[3]=(unsigned char)readb(mga_mmio_base + X_DATAREG);
+
+		writeb( XCOLMSK0RED, mga_mmio_base + PALWTADD);
+		colkey_mask[0]=(unsigned char)readb(mga_mmio_base + X_DATAREG);
+		writeb( XCOLMSK0GREEN, mga_mmio_base + PALWTADD);
+		colkey_mask[1]=(unsigned char)readb(mga_mmio_base + X_DATAREG);
+		writeb( XCOLMSK0BLUE, mga_mmio_base + PALWTADD);
+		colkey_mask[2]=(unsigned char)readb(mga_mmio_base + X_DATAREG);
+		writeb( XCOLMSK, mga_mmio_base + PALWTADD);
+		colkey_mask[3]=(unsigned char)readb(mga_mmio_base + X_DATAREG);
+
+		printk("mga_vid: Saved colorkey (ON: %d  %02X:%02X:%02X)\n",
+			colkey_on,colkey_color[0],colkey_color[1],colkey_color[2]);
+
+	}
+	
+if(!restore){
 	writeb( XKEYOPMODE, mga_mmio_base + PALWTADD);
 	writeb( mga_config.colkey_on, mga_mmio_base + X_DATAREG);
 	if ( mga_config.colkey_on ) 
@@ -302,6 +368,7 @@
 		writeb( X_COLKEY, mga_mmio_base + PALWTADD);
 		writeb( 0x00, mga_mmio_base + X_DATAREG);
 
+
 		// Set up color key registers
 		writeb( XCOLKEY0RED, mga_mmio_base + PALWTADD);
 		writeb( r, mga_mmio_base + X_DATAREG);
@@ -319,6 +386,8 @@
 		writeb( 0xff, mga_mmio_base + X_DATAREG);
 	}
 
+}
+
 	// Backend Scaler
 	writel( regs.besctl,      mga_mmio_base + BESCTL); 
 	if(is_g400)
@@ -527,7 +596,7 @@
 	regs.besv2wght = regs.besv1wght = (weights << 16) + ((weight & 0x3FFF) << 2);
 	regs.besv2srclst = regs.besv1srclst = sh - 1 - (((ofstop * regs.besviscal) >> 16) & 0x03FF);
 
-	mga_vid_write_regs();
+	mga_vid_write_regs(0);
 	return 0;
 }
 
@@ -687,7 +756,7 @@
 			if(vid_overlay_on)
 			{
 				regs.besctl |= 1;
-				mga_vid_write_regs();
+				mga_vid_write_regs(0);
 			}
 #ifdef MGA_ALLOW_IRQ
 			if ( mga_irq != -1 ) enable_irq();
@@ -703,7 +772,7 @@
 #endif
 			regs.besctl &= ~1;
                         regs.besglobctl &= ~(1<<6);  // UYVY format selected
-			mga_vid_write_regs();
+			mga_vid_write_regs(0);
 		break;
 			
 		case MGA_VID_FSEL:
@@ -879,8 +948,8 @@
 	vid_src_ready = 0;   
 	regs.besctl &= ~1;
         regs.besglobctl &= ~(1<<6);  // UYVY format selected
-	mga_config.colkey_on=0; //!!!
-	mga_vid_write_regs();
+//	mga_config.colkey_on=0; //!!!
+	mga_vid_write_regs(1);
 	mga_vid_in_use = 0;
 
 	MOD_DEC_USE_COUNT;




More information about the MPlayer-cvslog mailing list