merge heads bug235_bringup_0
authorFaisal Memon <faisal.memon@nokia.com>
Fri, 03 Sep 2010 10:14:54 +0100
branchbug235_bringup_0
changeset 12 a4c94be9fb92
parent 11 0738baed6953 (current diff)
parent 10 cd3ce1b777ef (diff)
child 13 220791dae4c4
merge heads
--- a/guestrendering/guestvideodriver/ldd/src/virtualvideohwinterface.cpp	Fri Sep 03 10:12:43 2010 +0100
+++ b/guestrendering/guestvideodriver/ldd/src/virtualvideohwinterface.cpp	Fri Sep 03 10:14:54 2010 +0100
@@ -23,14 +23,14 @@
 #include <graphics/virtualvideotracing.h>
 #include "syborg.h"
 
-
 // CONSTANTS
 
 _LIT( KVirtualVideoHwInterfacePanic, "DVirtualVideoHwInterface" );
-DVirtualVideoHwInterface * DVirtualVideoHwInterface::pVVHIf = NULL;
 
 // ============================ LOCAL DATA TYPES ===============================
 
+TPhysAddr DVirtualVideoHwInterface::iVideoRamBasePhys = NULL;
+
 // Register offsets for playback and recording channels
 // Note: The orders of these must match the order of enumarations
 const TLinAddr KRegisterOffsets[] =
@@ -48,7 +48,7 @@
     VVI_R_INPUT_BUFFER_MAX_TAIL,
     VVI_R_REQUEST_ID,
 	VVI_R_SHARED_CMD_MEMORY_BASE,
-	VVI_R_SHARED_FRAMEBUFFER_MEMORY_BASE,
+	VVI_R_SHARED_FRAMEBUFFER_MEMORY_BASE
     };
 #define ASSERT_PANIC(c,p) __ASSERT_DEBUG(c,Kern::PanicCurrentThread(KVirtualVideoHwInterfacePanic,p));
 
@@ -68,27 +68,30 @@
 //
 DVirtualVideoHwInterface::DVirtualVideoHwInterface()
     {
+    VVHW_TRACE("DVirtualVideoHwInterface::DVirtualVideoHwInterface()>");
     iInputParametersMemoryChunk = NULL;
     iOutputParametersMemoryChunk = NULL;
     iRegisterMemoryChunk = NULL;
 
-	DVirtualVideoHwInterface::pVVHIf = this;
-
-    Kern::Printf("DVirtualVideoHwInterface::DVirtualVideoHwInterface()>");
+#ifdef PLATSIM_CONFIG
+	iVideoRamBasePhys = VVI_BASE;
+#else
 	// Reserve a contiguous memory chunk for graphics usage
 	TUint32 ramSize = VVI_PARAMETERS_INPUT_MEMORY_SIZE +
 						VVI_PARAMETERS_OUTPUT_MEMORY_SIZE + 
-						VVI_FRAMEBUFFER_MEMORY_SIZE + 
-						VVI_REGISTERS_MEMORY_SIZE;
-	TInt r = Epoc::AllocPhysicalRam( ramSize, iVideoRamPhys );
+						VVI_FRAMEBUFFER_MEMORY_SIZE;
+	TInt r = Epoc::AllocPhysicalRam( ramSize, iVideoRamBasePhys );
     VVHW_TRACE("DVirtualVideoHwInterface::DVirtualVideoHwInterface() AllocPhysicalRam %d", r);
 	if (r != KErrNone)
 		{
 	    NKern::ThreadLeaveCS();
 		Kern::Fault("DVirtualVideoHwInterface Allocate Ram %d",r);
 		}
-	iFrameRamPhys = iVideoRamPhys + VVI_FRAMEBUFFER_BASE_ADDRESS;
-	Kern::Printf("DVirtualVideoHwInterface::DVirtualVideoHwInterface()<");
+ 	SetSharedCmdMemBase( iVideoRamBasePhys + VVI_PARAMETERS_INPUT_BASE_ADDRESS );
+	SetSharedFramebufferMemBase( iVideoRamBasePhys + VVI_FRAMEBUFFER_BASE_ADDRESS );
+
+#endif // PLATSIM_CONFIG
+    VVHW_TRACE("DVirtualVideoHwInterface::DVirtualVideoHwInterface()<");
     }
 
 
@@ -126,36 +129,27 @@
 
 TInt DVirtualVideoHwInterface::InitParametersInputMemory()
     {
-    TInt ret = InitPhysicalMemory( iVideoRamPhys + VVI_PARAMETERS_INPUT_BASE_ADDRESS, 
+    return InitPhysicalMemory(  iVideoRamBasePhys + VVI_PARAMETERS_INPUT_BASE_ADDRESS, 
             VVI_PARAMETERS_INPUT_MEMORY_SIZE, iInputParametersMemoryChunk, 
             iInputParametersChunkKernelAddress );    
-    Kern::Printf("DVirtualVideoHwInterface::InitParametersInputMemory - Base phy: 0x%08x lin: 0x%08x ret: %d", 
-    		iVideoRamPhys + VVI_PARAMETERS_INPUT_BASE_ADDRESS, 
-    		iInputParametersChunkKernelAddress, ret );
-    return ret;
-	}
+    }
 
 TInt DVirtualVideoHwInterface::InitParametersOutputMemory()
     {
-    TInt ret = InitPhysicalMemory( iVideoRamPhys + VVI_PARAMETERS_OUTPUT_BASE_ADDRESS, 
+    return InitPhysicalMemory( iVideoRamBasePhys + VVI_PARAMETERS_OUTPUT_BASE_ADDRESS, 
             VVI_PARAMETERS_OUTPUT_MEMORY_SIZE, iOutputParametersMemoryChunk, 
-            iOutputParametersChunkKernelAddress );
-    Kern::Printf("DVirtualVideoHwInterface::InitParametersOutputMemory - Base phy: 0x%08x lin: 0x%08x ret: %d", 
-    	iVideoRamPhys + VVI_PARAMETERS_OUTPUT_BASE_ADDRESS, 
-    	iOutputParametersChunkKernelAddress, ret );
-    return ret;
+            iOutputParametersChunkKernelAddress );    
     }
 
 TInt DVirtualVideoHwInterface::InitRegisterMemory()
     {
-    Kern::Printf(" DVirtualVideoHwInterface::InitRegisterMemory>");
-    Kern::Printf("DVirtualVideoHwInterface::InitRegisterMemory - parameter base phy: 0x%08x", iVideoRamPhys );
- 	SetSharedCmdMemBase( iVideoRamPhys );
-   	Kern::Printf("DVirtualVideoHwInterface::InitRegisterMemory - frame buffer phy: 0x%08x", iFrameRamPhys );
-	SetSharedFramebufferMemBase( iFrameRamPhys );
-
-    Kern::Printf(" DVirtualVideoHwInterface::InitRegisterMemory<");
-    return 0;   
+#ifdef PLATSIM_CONFIG
+    return InitPhysicalMemory( VVI_REGISTERS_BASE_ADDRESS, 
+            VVI_REGISTERS_MEMORY_SIZE, iRegisterMemoryChunk, 
+            iRegisterChunkKernelAddress );        
+#else
+    return KErrNone;    
+#endif // PLATSIM_CONFIG	
     }
 
 // -----------------------------------------------------------------------------
@@ -268,7 +262,6 @@
     SetRegisterValue( ERegSharedFramebufferMemBase, aPhysicalAddress );
     }
 
-
 // -----------------------------------------------------------------------------
 // DVirtualVideoHwInterface::GetRegisterValue
 // -----------------------------------------------------------------------------
@@ -277,17 +270,20 @@
     TRegister aRegister,
     TUint32& aValue )
     {
-    if ( 1 /* iRegisterMemoryChunk */ ) // FAISALMEMON check this line of code with Jani.  Can we get rid of it?
+    if ( iRegisterMemoryChunk )
         {
         TLinAddr offset = RegisterOffset( aRegister );
-		// FAISALMEMON check this with Jani.  Will the code still work for platsim or is this now syborg specific?
-        //TUint32* ptr = reinterpret_cast<TUint32*>( iRegisterChunkKernelAddress + offset );
-        //aValue = *ptr;
-		aValue = ReadReg( KHwGraphicsRegBase, offset );
+        TUint32* ptr = reinterpret_cast<TUint32*>( iRegisterChunkKernelAddress + offset );
+        aValue = *ptr;
         }
     else
         {
+#ifdef PLATSIM_CONFIG
         Kern::PanicCurrentThread( KVirtualVideoHwInterfacePanic, KErrNotReady );
+#else
+        TLinAddr offset = RegisterOffset( aRegister );
+		aValue = ReadReg( KHwGraphicsRegBase, offset );
+#endif // PLATSIM_CONFIG
         }
     }
 
@@ -308,16 +304,22 @@
         }
     else
         {
+#ifdef PLATSIM_CONFIG
         Kern::PanicCurrentThread( KVirtualVideoHwInterfacePanic, KErrNotReady );
+#else
+        TLinAddr offset = RegisterOffset( aRegister );
+		WriteReg( KHwGraphicsRegBase, offset, aValue );
+#endif // PLATSIM_CONFIG
         }
     }
 
 EXPORT_C TPhysAddr  DVirtualVideoHwInterface::GetFrameBase()
 	{
 	TPhysAddr ret = 0;
-	if(DVirtualVideoHwInterface::pVVHIf != NULL)
+	if( iVideoRamBasePhys != 0 )
 		{
-		ret = DVirtualVideoHwInterface::pVVHIf->iFrameRamPhys;
+		ret = iVideoRamBasePhys + VVI_FRAMEBUFFER_BASE_ADDRESS;
 		}
 	return ret;
-}
+    }
+