Add blanking support (GetSync/SetSync calls)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
diff --git a/QemuVGADriver/src/DriverQDCalls.c b/QemuVGADriver/src/DriverQDCalls.c
old mode 100755
new mode 100644
index f33a76e..80f8d2c
--- a/QemuVGADriver/src/DriverQDCalls.c
+++ b/QemuVGADriver/src/DriverQDCalls.c
@@ -272,11 +272,39 @@
 OSStatus
 GraphicsCoreSetSync(VDSyncInfoRec *syncInfo)
 {
+	UInt8 sync, mask;
+
 	Trace(GraphicsCoreSetSync);
 
 	CHECK_OPEN( controlErr );
 
-	return paramErr;
+	sync = syncInfo->csMode;
+	mask = syncInfo->csFlags;	
+
+	/* Unblank shortcut */
+	if (sync == 0 && mask == 0) {
+		sync = 0;
+		mask = kDPMSSyncMask;
+	}
+	/* Blank shortcut */
+	if (sync == 0xff && mask == 0xff) {
+		sync = 0x7;
+		mask = kDPMSSyncMask;
+	}
+	
+	lprintf("SetSync req: sync=%x mask=%x\n", sync, mask);
+	
+	/* Only care about the DPMS mode */
+	if ((mask & kDPMSSyncMask) == 0)
+		return noErr;
+	
+	/* If any sync is disabled, blank */
+	if (sync & kDPMSSyncMask)
+		QemuVga_Blank(true);
+	else
+		QemuVga_Blank(false);
+
+	return noErr;
 }
 
 OSStatus
@@ -284,7 +312,20 @@
 {
 	Trace(GraphicsCoreGetSync);
 
-	return paramErr;
+	if (syncInfo->csMode == 0xff) {
+		/* Return HW caps */
+		syncInfo->csMode = (1 << kDisableHorizontalSyncBit) |
+						   (1 << kDisableVerticalSyncBit) |
+						   (1 << kDisableCompositeSyncBit) |
+						   (1 << kNoSeparateSyncControlBit);
+	} else if (syncInfo->csMode == 0x00){
+		syncInfo->csMode = GLOBAL.blanked ? kDPMSSyncMask : 0;
+	} else
+		return statusErr;
+
+	syncInfo->csFlags = 0;
+
+	return noErr;
 }
 
 OSStatus
diff --git a/QemuVGADriver/src/QemuVga.c b/QemuVGADriver/src/QemuVga.c
index a208ae0..4584242 100644
--- a/QemuVGADriver/src/QemuVga.c
+++ b/QemuVGADriver/src/QemuVga.c
@@ -364,3 +364,19 @@
 	
 	return noErr;
 }
+
+OSStatus QemuVga_Blank(Boolean blank)
+{
+	/* We use the AR Index VGA register which is a flip flop
+	 * so we need to ensure we write twice. We use a non-existing
+	 * index so that the second write is dropped.
+	 */
+	if (blank) {
+		VgaWriteB(0x3c0, 0x1f);
+		VgaWriteB(0x3c0, 0x1f);
+	} else {
+		VgaWriteB(0x3c0, 0x3f);
+		VgaWriteB(0x3c0, 0x3f);
+	}
+	GLOBAL.blanked = blank;
+}
diff --git a/QemuVGADriver/src/QemuVga.h b/QemuVGADriver/src/QemuVga.h
old mode 100755
new mode 100644
index d7bf053..69e80fa
--- a/QemuVGADriver/src/QemuVga.h
+++ b/QemuVGADriver/src/QemuVga.h
@@ -66,4 +66,6 @@
 extern OSStatus QemuVga_GetModeInfo(UInt32 index, UInt32 *width, UInt32 *height);
 extern OSStatus QemuVga_SetMode(UInt32 modeIndex, UInt32 depth, UInt32 page);
 
+extern OSStatus QemuVga_Blank(Boolean blank);
+
 #endif
diff --git a/QemuVGADriver/src/VideoDriverPrivate.h b/QemuVGADriver/src/VideoDriverPrivate.h
old mode 100755
new mode 100644
index 65c161c..47a95a6
--- a/QemuVGADriver/src/VideoDriverPrivate.h
+++ b/QemuVGADriver/src/VideoDriverPrivate.h
@@ -68,6 +68,7 @@
 	UInt32				numModes;
 	UInt32				curPage;
 	LogicalAddress		curBaseAddress;
+	Boolean				blanked;
 };
 typedef struct DriverGlobal DriverGlobal, *DriverGlobalPtr;
 
diff --git a/builds/qemu_vga.ndrv b/builds/qemu_vga.ndrv
index 930e9c2..6e02f74 100644
--- a/builds/qemu_vga.ndrv
+++ b/builds/qemu_vga.ndrv
Binary files differ
diff --git a/builds/qemu_vga_debugosi.ndrv b/builds/qemu_vga_debugosi.ndrv
index 3b86f5a..639a0c5 100644
--- a/builds/qemu_vga_debugosi.ndrv
+++ b/builds/qemu_vga_debugosi.ndrv
Binary files differ