Support bug 235 by providing interface layers in graphics. First is the surface manager API, to be implemented in graphics.nokia, second is the adptation-to-adaption interface for the guestvideodriver and virtual video hardware. This allows graphics.nokia to provide a syborg version of surface manager driver based upon the guestvideodriver, implemented in the graphics.simulator package. This submission includes a version 2 syntax package definition file purely for those components of interest to bug 235. This makes selective compilation of the graphics package easier. A further submission will prune down the surface manager component in the graphics package. bug235_bringup_0
authorFaisal Memon <faisal.memon@nokia.com>
Fri, 13 Aug 2010 15:11:40 +0100
branchbug235_bringup_0
changeset 146 4d1fe4a7ce83
parent 145 8f2c3e21aac9
child 147 af143508cc47
Support bug 235 by providing interface layers in graphics. First is the surface manager API, to be implemented in graphics.nokia, second is the adptation-to-adaption interface for the guestvideodriver and virtual video hardware. This allows graphics.nokia to provide a syborg version of surface manager driver based upon the guestvideodriver, implemented in the graphics.simulator package. This submission includes a version 2 syntax package definition file purely for those components of interest to bug 235. This makes selective compilation of the graphics package easier. A further submission will prune down the surface manager component in the graphics package.
bug235.pkgdef.xml
graphics_plat/guestvideodriver_api/eabi/guestvideodriveru.def
graphics_plat/guestvideodriver_api/eabi/guestvideohwu.def
graphics_plat/guestvideodriver_api/group/bld.inf
graphics_plat/guestvideodriver_api/group/guestvideodriverlib.mmp
graphics_plat/guestvideodriver_api/group/guestvideohwlib.mmp
graphics_plat/guestvideodriver_api/inc/guestvideodriver.h
graphics_plat/guestvideodriver_api/inc/guestvideodrivercommon.h
graphics_plat/guestvideodriver_api/inc/guestvideodriverinterfaceconstants.h
graphics_plat/guestvideodriver_api/inc/guestvideodriverprotocol.h
graphics_plat/guestvideodriver_api/ldd/inc/devicereqhandler.h
graphics_plat/guestvideodriver_api/ldd/inc/reqhandlerextension.h
graphics_plat/guestvideodriver_api/ldd/inc/virtualvideohwchannel.h
graphics_plat/guestvideodriver_api/ldd/inc/virtualvideohwdevice.h
graphics_plat/guestvideodriver_api/ldd/inc/virtualvideohwdeviceinterface.h
graphics_plat/guestvideodriver_api/ldd/inc/virtualvideohwinterface.h
graphics_plat/guestvideodriver_api/ldd/inc/virtualvideotracing.h
graphics_plat/surfacemanager_api/bwins/distribution.policy.s60
graphics_plat/surfacemanager_api/bwins/surfacemanageru.def
graphics_plat/surfacemanager_api/eabi/distribution.policy.s60
graphics_plat/surfacemanager_api/eabi/surfacemanageru.def
graphics_plat/surfacemanager_api/group/bld.inf
graphics_plat/surfacemanager_api/group/distribution.policy.s60
graphics_plat/surfacemanager_api/group/surfacemanager.iby
graphics_plat/surfacemanager_api/group/surfacemanagerlib.mmp
graphics_plat/surfacemanager_api/inc/distribution.policy.s60
graphics_plat/surfacemanager_api/inc/surface_hints.h
graphics_plat/surfacemanager_api/inc/surfacemanager.h
graphicstest/graphicstestharness/automation/graphicssystemgui.sysdef.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bug235.pkgdef.xml	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE SystemDefinition [
+<!ELEMENT SystemDefinition ( systemModel )>
+<!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED
+>
+<!-- all paths are relative to the environment variable specified by the root attribute, or SOURCEROOT if not.  -->
+
+<!-- System Model Section of DTD -->
+<!ELEMENT systemModel (layer+)>
+
+<!ELEMENT layer (block* | collection*)*>
+<!-- Kernel Services, Base Services, OS Services, Etc -->
+<!ATTLIST layer
+  name CDATA #REQUIRED
+  long-name CDATA #IMPLIED
+  levels NMTOKENS #IMPLIED
+  span CDATA #IMPLIED
+>
+
+<!ELEMENT block (subblock* | collection*)*>
+ <!-- Generic OS services, Comms Services, etc -->
+<!ATTLIST block
+  levels NMTOKENS #IMPLIED
+  span CDATA #IMPLIED
+  level NMTOKEN #IMPLIED
+  name CDATA #REQUIRED
+  long-name CDATA #IMPLIED
+>
+
+<!ELEMENT subblock (collection)*>
+<!-- Cellular Baseband Services, Networking Services, etc -->
+<!ATTLIST subblock
+  name CDATA #REQUIRED
+  long-name CDATA #IMPLIED
+>
+
+<!ELEMENT collection (component)*>
+<!-- Screen Driver, Content Handling, etc -->
+<!ATTLIST collection
+  name CDATA #REQUIRED
+  long-name CDATA #IMPLIED
+  level NMTOKEN #IMPLIED
+>
+
+<!ELEMENT component (unit)*>
+<!-- contains units or is a  package or prebuilt -->
+<!ATTLIST component
+  name CDATA #REQUIRED
+  long-name CDATA #IMPLIED
+  deprecated CDATA #IMPLIED
+  introduced CDATA #IMPLIED
+  contract CDATA #IMPLIED
+  plugin (Y|N) "N"
+  filter CDATA #IMPLIED
+  class NMTOKENS #IMPLIED
+  supports CDATA #IMPLIED
+  purpose ( optional | mandatory | development ) "optional"
+>
+
+<!ELEMENT unit EMPTY >
+<!-- must be buildable (bld.inf) -->
+<!-- bldFile  may someday be removed in favour of mrp -->
+<!ATTLIST unit
+  mrp CDATA #IMPLIED
+  filter CDATA #IMPLIED
+  bldFile CDATA #IMPLIED
+  root CDATA #IMPLIED
+  version NMTOKEN #IMPLIED
+  prebuilt NMTOKEN #IMPLIED
+  late (Y|N) #IMPLIED
+  priority CDATA #IMPLIED
+>
+]>
+<SystemDefinition schema="2.0.1" name="Graphics">
+<systemModel>
+<layer name="anonymous">
+<block name="graphics" long-name="Graphics" levels="adaptation engines internal-adaptations device-interface internal-utils app-if">
+<collection name="graphics_plat" long-name="Graphics Platform Interfaces" level="shai">
+<component name="guestvideodriver_api" long-name="Guest Video Driver API" introduced="^4" class="api">
+<unit bldFile="graphics_plat/guestvideodriver_api/group"/>
+</component>
+<component name="surfacemanager_api" long-name="Surface Manager API" introduced="^3" class="api">
+<unit bldFile="graphics_plat/surfacemanager_api/group"/>
+</component>
+</collection>
+<collection name="graphicshwdrivers" long-name="Graphics Hardware Drivers" level="adaptation">
+<!-- displayldd to be moved here -->
+<component name="surfacemgr" long-name="Surface Manager" introduced="^3" purpose="optional">
+<unit bldFile="graphicshwdrivers/surfacemgr/group" mrp="os/deviceplatformrelease/foundation_system/system_model/graphicshwdrivers/surfacemgr/group/graphics_surfacemanager.mrp"/>
+</component>
+</collection>
+</block>
+</layer>
+</systemModel>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/eabi/guestvideodriveru.def	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,1 @@
+EXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/eabi/guestvideohwu.def	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,2 @@
+EXPORTS
+_ZN24DVirtualVideoHwInterface12GetFrameBaseEv @ 1 NONAME
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/group/bld.inf	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,40 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Guest side Virtual Video Driver Interface for adaptation layer software use
+//
+// This interface component provides an interface for adapt layer callers
+// only so one adapt layer package can call another adapy layer package.
+// The graphics package, nor any other app, mw, or os layer package may
+// call this interface.
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_EXPORTS
+../inc/guestvideodriver.h					OS_LAYER_PLATFORM_EXPORT_PATH(graphics/guestvideodriver.h)
+../inc/guestvideodrivercommon.h				OS_LAYER_PLATFORM_EXPORT_PATH(graphics/guestvideodrivercommon.h)
+../inc/guestvideodriverinterfaceconstants.h	OS_LAYER_PLATFORM_EXPORT_PATH(graphics/guestvideodriverinterfaceconstants.h)
+../inc/guestvideodriverprotocol.h			OS_LAYER_PLATFORM_EXPORT_PATH(graphics/guestvideodriverprotocol.h)
+
+../ldd/inc/devicereqhandler.h				OS_LAYER_PLATFORM_EXPORT_PATH(graphics/devicereqhandler.h)
+../ldd/inc/reqhandlerextension.h			OS_LAYER_PLATFORM_EXPORT_PATH(graphics/reqhandlerextension.h)
+../ldd/inc/virtualvideohwchannel.h			OS_LAYER_PLATFORM_EXPORT_PATH(graphics/virtualvideohwchannel.h)
+../ldd/inc/virtualvideohwdevice.h			OS_LAYER_PLATFORM_EXPORT_PATH(graphics/virtualvideohwdevice.h)
+../ldd/inc/virtualvideohwdeviceinterface.h	OS_LAYER_PLATFORM_EXPORT_PATH(graphics/virtualvideohwdeviceinterface.h)
+../ldd/inc/virtualvideohwinterface.h		OS_LAYER_PLATFORM_EXPORT_PATH(graphics/virtualvideohwinterface.h)
+../ldd/inc/virtualvideotracing.h			OS_LAYER_PLATFORM_EXPORT_PATH(graphics/virtualvideotracing.h)
+
+PRJ_MMPFILES
+guestvideodriverlib.mmp
+guestvideohwlib.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/group/guestvideodriverlib.mmp	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,21 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Provide a library interface for the guest video driver.  This interface
+// is expected to be implemented in an adapt layer component.
+
+#include <platform_paths.hrh>
+
+TARGET          guestvideodriver.lib
+TARGETTYPE      IMPLIB
+DEFFILE         ../eabi/guestvideodriver.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/group/guestvideohwlib.mmp	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,21 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Provide a library interface for the guest video hardware device.  This
+// interface is expected to be implemented in an adapt layer component.
+
+#include <platform_paths.hrh>
+
+TARGET          guestvideohw.lib
+TARGETTYPE      IMPLIB
+DEFFILE         ../eabi/guestvideohw.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/inc/guestvideodriver.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,96 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Header file for guest video driver
+
+#ifndef __GUESTVIDEODRIVER_H__
+#define __GUESTVIDEODRIVER_H__
+
+#include <e32cmn.h>
+#include <e32std.h>
+#include <babitflags.h>
+
+#include "guestvideodrivercommon.h"
+
+class RemoteFunctionCallData;
+
+//Local request buffering size
+const TInt KRequestBufferSize = 20000;
+
+/**
+ * Guest video driver user API. One instance exists per process.
+ */
+NONSHARABLE_CLASS(RGuestVideoDriver) : public RBusLogicalChannel
+    {
+public:
+	// Default constructor
+	IMPORT_C RGuestVideoDriver();
+
+	// Destructor
+	IMPORT_C ~RGuestVideoDriver();
+
+	/**
+	 * Opens this driver handle. Calls RBusLogicalChannel::DoCreate.
+	 * 
+	 * @return System wide error code
+	 */
+	IMPORT_C TInt Open();
+
+	/**
+	 * Executes a command 
+	 * @param aRequestData Remote function call
+	 */
+	IMPORT_C void ExecuteCommand(RemoteFunctionCallData& aRequestData);
+
+	/**
+	 * Flushes any buffered commands.
+	 */
+	IMPORT_C void Flush();
+
+	IMPORT_C TInt MapToHWAddress( const TInt aChunkHandle, TUint32& aHWAddress );
+
+	IMPORT_C TInt EglGetSgHandles( const TUint64 aId, TUint64 *aSgHandles );
+
+	/**
+     * Gets Base Address of Frame Buffer
+     * @param aHWAddress	returned Base Address
+     *
+	 * @note	A base address of 0 is invalid, and indicates a failure to
+     *          obtain the base address.
+	 */
+	IMPORT_C TInt GetFrameBufferBaseAddress( TUint32& aHWAddress );
+
+
+private:
+	/*
+	 Buffer, or send if it needs a reply, a command to the virtual video hardware
+	 @param aRFC Remote function call to buffer
+	 @return ETrue if buffering succeeds, otherwise the aRFC needs to be executed directly
+	 */
+	TBool BufferCommand( RemoteFunctionCallData& aRFC );
+
+	// Sends buffered commands 
+	void SendBuffer();
+
+private:
+	TBool     iIsOpen;
+	RMutex    iThreadLock;
+	/**
+	 * Request buffer
+	 */
+	TUint32                   iProcessId;
+	TBuf8<KRequestBufferSize> iBuffer;
+    };
+
+
+#endif // __GUESTVIDEODRIVER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/inc/guestvideodrivercommon.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,49 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Header file for guest video driver
+
+#ifndef __GUESTVIDEODRIVERCOMMON_H
+#define __GUESTVIDEODRIVERCOMMON_H
+
+#include <e32cmn.h>
+
+/**
+ * Namespace for Platform Simulator Audio Driver.
+ */
+namespace GuestVideoDriver
+    {
+    /**
+     * Name of the DFC thread used by logical channels.
+     */
+    _LIT( KDfcThreadName, "DfcThreadVirtualVideoHw" );
+    
+    /**
+     * Name of the logical device used to identify the device.
+     */
+    _LIT( KDeviceName, "VirtualVideoHwDevice" );
+
+    /**
+     * Name of the logical device dll file name.
+     */
+    _LIT( KDeviceFileName, "guestvideohw" );
+
+    /**
+     * Current version of the driver.
+     */
+    const TInt KMajorVer = 1;
+    const TInt KMinorVer = 0;
+    const TInt KBuildVer = 1;
+    }
+
+#endif // __GUESTVIDEODRIVERCOMMON_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/inc/guestvideodriverinterfaceconstants.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,58 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Header file for the guest video driver
+
+#ifndef VirtualVideoInterfaceConstants_h_
+#define VirtualVideoInterfaceConstants_h_
+
+//      virtualhw.irq => ic.input[391];
+//        pvbus.pvbus_m_range[0x60000000..0x62ffffff] => graphicsvirtualhw.mbus; //=>Reserve own memory area later
+//        pvbus.pvbus_m_range[0x63000000..0x63000fff] => graphicsvirtualhw.pbus; //=>Reserve own memory area later                
+
+// base address
+#define VVI_REGISTERS_BASE_ADDRESS 0x63000000
+#define VVI_REGISTERS_MEMORY_SIZE 0x1000
+#define VVI_REGISTERS_MASK 0x0FFF
+
+#define VVI_PARAMETERS_INPUT_BASE_ADDRESS 0x60000000
+#define VVI_PARAMETERS_INPUT_MEMORY_SIZE  0x01000000
+
+#define VVI_PARAMETERS_OUTPUT_BASE_ADDRESS 0x61000000
+#define VVI_PARAMETERS_OUTPUT_MEMORY_SIZE  0x01000000
+
+#define VVI_FRAMEBUFFER_BASE_ADDRESS 0x62000000
+#define VVI_FRAMEBUFFER_MEMORY_SIZE  0x01000000
+
+// register indices, TODO: cleanup needed, some are not used
+#define VVI_R_ID                       0x0000
+#define VVI_R_IRQ_ENABLE               0x0004
+#define VVI_R_IRQ_STATUS               0x0008
+#define VVI_R_COMMAND                  0x000c
+#define VVI_R_PARAMETER_LOAD           0x0010
+#define VVI_R_ERROR                    0x0014
+#define VVI_R_INPUT_BUFFER_TAIL        0x0018
+#define VVI_R_INPUT_BUFFER_HEAD        0x001c
+#define VVI_R_INPUT_BUFFER_READ_COUNT  0x0020
+#define VVI_R_INPUT_BUFFER_WRITE_COUNT 0x0024
+#define VVI_R_INPUT_BUFFER_MAX_TAIL    0x0028
+#define VVI_R_REQUEST_ID               0x002c
+#define VVI_R_LASTREG                  0x0030  // not a register, address of last register
+
+// COMMAND register values
+#define VVI_EXECUTE 0
+
+//IRQ number
+#define VVI_IRQ 391
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/inc/guestvideodriverprotocol.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,45 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Header file for the guest video driver
+
+
+#ifndef __GUESTVIDEODRIVERPROTOCOL_H
+#define __GUESTVIDEODRIVERPROTOCOL_H
+
+#include <e32cmn.h>
+#include "guestvideodrivercommon.h"
+
+/**
+ * Namespace for Platform Simulator Video Driver.
+ * The user API - kernel LDD messaging protocol is defined within this
+ * namespace.
+ */
+namespace GuestVideoDriver
+    {
+
+    /**
+     * Enumeration of different requests
+     */
+    enum TRequestId
+        {
+        ERequestExecuteCommand = 0x1001, // Asynchronous (DoRequest)
+        ERequestMapAddress = 0x1002, // Synchronous (DoControl)
+        ERequestLoadCommands = 0x1004, // Synchronous (DoRequest)
+        ERequestSgHandles = 0x1005, //Synchronous (DoControl)
+        };
+
+    }
+
+
+#endif // __GUESTVIDEODRIVERPROTOCOL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/ldd/inc/devicereqhandler.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,594 @@
+// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#ifndef DEVICEREQHANDLER_H
+#define DEVICEREQHANDLER_H
+
+#include <kernel/kernel.h>
+#include <kernel/kern_priv.h>
+#include <e32cmn.h>
+
+#include <sgresource/sgcommon.h>//TSgImageMetaData
+#include "sgextension.h"//For SgExtension
+
+#include "guestvideodriverprotocol.h"
+#include "virtualvideohwinterface.h"
+#include "remotefunctioncall.h"
+#include "requestbuffer.h"
+#include "reqhandlerextension.h"
+
+#include <EGL/egltypes.h>//For EGLint
+
+class RSgImage;//we only need pointers anyways
+
+using namespace GuestVideoDriver;
+
+
+//Container class for the mapping from pbuffers to sgimages
+class TPbSId
+    {
+    public:
+    TInt iPbuffer;
+    TUint64 iSgId;
+    TPbSId( TInt aP, TUint64 aId ) : iPbuffer( aP ), iSgId( aId ){}
+    };
+class TVGISId
+    {
+    public:
+    TInt iVGImage;
+    TUint64 iSgId;
+    TVGISId( TInt aI, TUint64 aId ) : iVGImage( aI ), iSgId( aId ){}
+    };
+
+/**
+ * Class for handling requests to the Video driver.
+ */
+class DDeviceReqHandler : public DBase, MReqHandlerCallback , protected MRequestBufferBookKeepingWriter
+    {
+public:
+    enum TRequestMode
+        {
+        ENormal, //to be issued by the normal route
+        EHandled, //already completed (in the scheduler)
+        EQueued //queued into another outstanding request 
+        };
+    enum TOpChainType
+        {//for performing a series of operations in sequence
+        EOpInit = 1
+        };
+    enum { KMaxFreeRequests = 20 }; 
+    
+    struct SgImageMetaInfo
+    	{
+    	TUint32 iSgImagePointer;
+    	};
+    /*
+     * Stores data belonging to a client thread
+     */
+    struct TPerThreadData
+        {
+        TRequestStatus* iStatus;
+        DThread* iAsyncClient;//asynchronous client
+        TUint32 iProcessId;
+        TUint32 iThreadId;
+        
+        TUint32 iCurrApiUid;//5.2 in "Implementing sgImage on Guest EGL"
+        TUint32 iCurrOpCode;//Not required
+        
+        TBool   iErrUpdatedGLES;
+        TBool   iErrUpdatedVG;
+        TBool   iErrUpdatedEGL;
+        TUint32  iErrorGLES;//The error for the previous GLES call
+        TUint32  iErrorVG;//The error for the previous VG call
+        TUint32  iErrorEGL;//The error for the previous EGL call
+        
+        EGLContext iContext;//The last set context
+
+        
+        RArray<SgImageMetaInfo> iImageInfo;
+        
+
+        TBool sameThread( TUint32 aProcId, TUint32 aThreadId )
+            {
+            return ( ( aProcId == iProcessId && aThreadId == iThreadId ) ? ETrue : EFalse );
+            }
+        TPerThreadData( TRequestStatus* aStatus, DThread* aAsyncClient, TUint32 aProcId, TUint32 aThreadId ) :
+            iStatus( aStatus),
+            iAsyncClient(aAsyncClient),
+            iProcessId( aProcId ),
+            iThreadId( aThreadId ),
+            iErrUpdatedGLES(EFalse),
+            iErrUpdatedVG(EFalse),
+            iErrUpdatedEGL(EFalse)
+            {}
+        };
+    
+    struct TTransactionInfo
+        {
+    public:
+        TUint32 iTransactionId;
+        //this must be valid for the whole duration of the transaction, and is now owned here
+        TAny* iTransactionData;
+        TTransactionInfo( TUint32 aTransactionId, TAny* aTransactionData = 0 ) :
+            iTransactionId( aTransactionId ),
+            iTransactionData( aTransactionData )
+            {}
+        };
+    
+    /*
+     * Stores an async request before serialisation
+     */
+    struct TAsyncRequest
+        {
+        enum TRequestType
+            {
+            ERTDriver,
+            ERTRequest,
+            ERTCommandLoad
+            };
+        
+        TAsyncRequest( TRequestStatus* aStatus,
+                        DThread* aAsyncClient,
+                        TAny* aA1,
+                        TAny* aA2,
+                        TRequestType aCommandLoadRequest ):
+        iStatus( aStatus ),
+        iAsyncClient( aAsyncClient ),
+        iA1( aA1 ),
+        iA2( aA2 ),
+        iCommandLoadRequest( aCommandLoadRequest ),
+        iNext( NULL )
+            {    
+            }
+
+        void Init(TRequestStatus* aStatus,
+                        DThread* aAsyncClient,
+                        TAny* aA1,
+                        TAny* aA2,
+                        TRequestType aCommandLoadRequest )
+            {
+            iStatus = aStatus;
+            iAsyncClient = aAsyncClient;
+            iA1 = aA1;
+            iA2 = aA2;
+            iCommandLoadRequest = aCommandLoadRequest;
+            iNext = NULL;
+            }
+        
+        void AppendToList( TAsyncRequest* iPrev )
+            {
+            if ( iPrev->iNext )
+                {
+                this->iNext = iPrev->iNext;
+                }
+            iPrev->iNext = this;
+            }
+        
+        void RemoveFromList( TAsyncRequest* iPrev )
+            {
+            if ( iPrev->iNext == this )
+                {
+                iPrev->iNext = this->iNext;
+                }
+            this->iNext = NULL;
+            }
+        
+        //Current request status
+        TRequestStatus* iStatus;
+        
+        //Current asynchronous client
+        DThread* iAsyncClient;
+        
+        TAny* iA1;
+        TAny* iA2;
+
+        TRequestType iCommandLoadRequest;
+        
+        RemoteFunctionCallData iRemoteFunctionCall;
+        
+        //Link for linked list
+        TAsyncRequest* iNext;
+        };
+    
+    struct TAsyncRequestRoot: public TAsyncRequest
+        {
+        TAsyncRequestRoot():
+        TAsyncRequest( NULL, NULL, NULL, NULL, ERTRequest )
+            {
+            }
+        
+        void AppendToLast( TAsyncRequest* aReq )
+            {
+            TAsyncRequest* last( this );
+            TAsyncRequest* next( iNext );            
+            while ( next )
+                {
+                last = next;
+                next = next->iNext;
+                }
+            aReq->AppendToList( last );
+            }
+
+        void DeleteAll()
+            {
+            TAsyncRequest* next( iNext );
+            while ( next )
+                {
+                TAsyncRequest* nextToDel( next );
+                next = next->iNext;
+                delete nextToDel;
+                }
+            }
+        };
+
+    /**
+     * Constructor.
+     * 
+     * @param aHwInterface
+     *   Interface to the hardware
+     * @param aQueue
+     *   Deferred function call queue
+     * @param aMdaifSvTable
+     *   MDAIF shared variable table
+     */
+    DDeviceReqHandler(
+            DVirtualVideoHwInterface& aHwInterface,
+            TDfcQue* aQueue );
+
+    /**
+     * Destructor.
+     */
+    virtual ~DDeviceReqHandler();
+    
+    /**
+     * Handles a command execution
+     * 
+     * @param aUserThread
+     *   Thread making the request
+     * @param aStatus
+     *   Request status to be used in request completion.
+     * @param a1
+     *   Request parameter 1
+     */
+    TInt HandleExecuteAsync(
+            DThread*& aUserThread,
+            TRequestStatus* aStatus,
+            TAny* a1);
+
+    /**
+     * Handles a command buffering
+     * 
+     * @param aUserThread
+     *   Thread making the request
+     * @param a1
+     *   Request parameter 1
+     */
+    TInt HandleLoadCommands(
+            DThread*& aUserThread,
+            TRequestStatus* aStatus,
+            TAny* a1 );
+    
+    TInt HandleClientShutdown( TUint aProcessId, TUint aThreadId );
+    
+public: // Called from Dfc context
+    
+    /**
+     * Directs hardware interrupts to appropriate functions.
+     */
+    void ProcessDfc();
+            
+public: // Inline functions
+
+    /**
+     * Returns current interrupt ID.
+     * 
+     * @return
+     *   Interrupt ID.
+     */
+    inline TInt InterruptId() { return iInterruptId; }
+        
+    /**
+     * Returns hardware interface.
+     * 
+     * @return
+     *   Hardware interface reference.
+     */
+    inline DVirtualVideoHwInterface& HwInterface() { return iHwInterface; }
+    
+    /**
+     * Returns DFC.
+     * 
+     * @return
+     *   Reference to TDfc object.
+     */
+    inline TDfc& Dfc() { return iDfc; }
+
+    /**
+     * Returns current interrupt ID.
+     * 
+     * @param aInterrupt
+     *   Interrupt to be reset.
+     * @return
+     *   KErrNone - Successful
+     *   System wide errorcodes in error situations.
+     */
+    inline TInt ResetAndEnableInterrupt(
+            DVirtualVideoHwInterface::TInterrupt aInterrupt )
+        {
+        iHwInterface.ResetInterruptStatus( aInterrupt );
+        Interrupt::Clear( InterruptId() );
+        return Interrupt::Enable( iInterruptId );
+        }
+
+    /**
+     * Process next request from ring buffer
+     */ 
+    TInt ProcessNextPendingRequest();
+    
+protected: // Ring buffer book keaping routines
+    void IncrementInputWriteCount( TUint32 aWriteCount )
+        {
+        TUint32 inputBufferWriteCount = GetWriteCount() + aWriteCount;
+        iHwInterface.SetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferWriteCount,
+                inputBufferWriteCount );
+        }
+    
+    TUint32 GetInputWriteCount()
+        {
+        TUint32 inputBufferWriteCount;
+        iHwInterface.GetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferWriteCount,
+                inputBufferWriteCount );
+        return inputBufferWriteCount;
+        }
+    
+    TUint32 GetInputReadCount()
+        {
+        TUint32 inputBufferReadCount;
+        iHwInterface.GetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferReadCount,
+                inputBufferReadCount );
+        return inputBufferReadCount;
+        }
+    
+    TUint32 InputBufferTail()
+        {
+        TUint32 val;
+        iHwInterface.GetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferTail,
+                val );
+        return val;
+        }
+    
+    TUint32 InputBufferHead()
+        {
+        TUint32 val;
+        iHwInterface.GetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferHead,
+                val );
+        return val;        
+        }
+    
+    void SetInputBufferTail( TUint32 aIndex )
+        {
+        iHwInterface.SetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferTail,
+                aIndex );    
+        }
+    
+    void SetInputBufferHead( TUint32 aIndex )
+        {
+        iHwInterface.SetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferHead,
+                aIndex );
+        }
+
+protected: // From MRequestBufferBookKeeping
+    /**
+     * See MRequestBufferBookKeepingWriter
+     */ 
+    void IncrementWriteCount( TUint32 aWriteCount ){ IncrementInputWriteCount( aWriteCount ); }
+
+    /**
+     * See MRequestBufferBookKeepingWriter
+     */ 
+    TUint32 GetWriteCount(){ return GetInputWriteCount(); }
+    
+    /**
+     * See MRequestBufferBookKeepingWriter
+     */ 
+    TUint32 GetReadCount(){ return GetInputReadCount(); }
+
+    /**
+     * See MRequestBufferBookKeepingWriter
+     */ 
+    TUint32 BufferTail(){ return InputBufferTail(); }
+
+    /**
+     * See MRequestBufferBookKeepingWriter
+     */ 
+    TUint32 BufferHead(){ return InputBufferHead(); }
+
+    /**
+     * See MRequestBufferBookKeepingWriter
+     */ 
+    void SetBufferHead( TUint32 aIndex ){ SetInputBufferHead( aIndex ); }
+
+    /**
+     * See MRequestBufferBookKeepingWriter
+     */ 
+    TUint32 MaxTailIndex()
+        {
+        TUint32 val;
+        iHwInterface.GetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferMaxTail,
+                val );
+        return val;        
+        }
+    
+    /**
+     * See MRequestBufferBookKeepingWriter
+     */ 
+    void SetMaxTailIndex( TUint32 aIndex )
+        {
+        iHwInterface.SetRegisterValue( DVirtualVideoHwInterface::ERegInputBufferMaxTail,
+                        aIndex );
+        }
+    
+protected: //Command Scheduling functions
+    /**
+     * DDeviceReqHandler::InterpretRequest
+     * This function is the focal point of the implementation
+     * of the 1st paragraph of 3.4 in the "Implementing SgImage" design doc.
+     * This function therefore intercepts and interprets SOME EGL,VG (and, in the future GLES)
+     * calls.
+     * 
+     * @param aReq the request
+     * 
+     * @return TBool has the call already been processed? If true, then no further processing
+     * is required for that call (doesn't have to be sent host-side).
+     */
+    DDeviceReqHandler::TRequestMode InterpretRequest( TAsyncRequest* aReq );
+    
+    
+    void ConsumeSchedulerInitiatedRequestResult( TAsyncRequest* aReq );
+    
+    /**
+     * RemoveClientData
+     * @param aProcId
+     * @param aThreadId
+     */
+    void RemoveClientData( const TUint32 aProcId, const TUint32 aThreadId );
+    /**
+     * Initiate a request to the host side from the scheduler (this)
+     * This is needed so that the scheduler can make requests that are not
+     * directly client-originated.
+     */
+    TBool InitiateRequestWithReply( TAsyncRequest* req, TAny* aTransactionData = 0 );
+
+    /**
+     * Helper function for getting the stored client data for the proc/thread, if present
+     * @return TPerThreadData object, or NULL, if no object was found with the right proc/thread id
+     */
+    TPerThreadData* GetClientData( const TUint32 aProcId, const TUint32 aThreadId );
+    
+    /**
+     * getVGSync
+     * Check if the VGImage is sg image backing, and if it's sync flag is set to dirty.
+     * If both above conditions are met, add the required parameters to the hostside call
+     * so that the hostside can proceed to making the sync.
+     * 
+     */
+    DDeviceReqHandler::TRequestMode DDeviceReqHandler::getVGSync( VGImage aImg, TAsyncRequest* aReq );
+    
+    /**
+     * 
+     * @param aReq the request to add the additional info to
+     * @param aImageIndexInReq the index of the vg image in the rfc call. This will
+     *        be used to determine what the sgImage is, and find the sync bit
+     * @param aSetBufferDirty: set the buffer dirty in any case
+     * @param aAddFalseForOther. All sync operations are prepared to handle two vgimages, thus need to have another
+     *        value to read. Set this to ETrue if you are not going to add another real sync operation.
+     */
+    void getVGSyncInOp( TAsyncRequest* aReq, TInt aSgHandleIndexInReq, TBool aSetBufferDirty = EFalse );
+    
+public:
+    HBuf8* OpenSgImageMetaData( const TUint64 aId, DSgResource*& aResource );
+	void CreateSgImagePbuffer( const TSgImageMetaData& aInfo, TRequestStatus* aStatus, DThread* aThread );
+	void CreateSgImageVGImage( const TSgImageMetaData& aInfo, TRequestStatus* aStatus, DThread* aThread );
+	TInt DestroySgImage( const TUint64 aId );
+    void ContinueInit( TAsyncRequest* aReq );
+
+    
+
+
+private: //Request management
+    TInt iOpType; 
+    TInt iOpChainPhase;//just a running nummber
+    TInt iOpReturn;//return value from host side calls
+    TRequestStatus iOpStatus;//dummy request status
+    /*
+     * Allocates a new request data structure
+     */
+    TAsyncRequest* AllocRequest( TRequestStatus* aStatus,
+            DThread* aAsyncClient,
+            TAny* aA1,
+            TAny* aA2,
+            TAsyncRequest::TRequestType aRequestType = TAsyncRequest::ERTRequest );
+    
+    
+
+    /*
+     * Releases a request data structure
+     */
+    void ReleaseRequest( TAsyncRequest* aReq );
+
+    /*
+     * Free request data structures
+     */
+    TAsyncRequestRoot iFreeListRoot;
+    
+    /*
+     * Number of free request data structures
+     */
+    TInt iFreeCount;
+    
+private:
+    
+    TLinearOrder<TPbSId> iPbufferSgMapOrder;
+    TLinearOrder<TVGISId> iVGImageSgMapOrder;
+    //map pbuffer surface handles -> sgImage ID
+    RArray<TPbSId> iPbufferSgMap;
+    RArray<TVGISId> iVGImageSgMap;
+    //The data structs for storing per process&thread information
+    RPointerArray<TPerThreadData>   iClientData;
+    //The current client
+    TPerThreadData* iCurrClientData;
+    RArray<TTransactionInfo> iSchedulerInitiatedTransactionIds;
+    TAny* iSchedulerInitiatedTransactionData;
+    // The process- and thread ids to use in driver rfcs
+    // This is needed as the calling thread may be different, while we still want the same
+    // state to remain on the hostside.
+    TUint32 iDriverRfcProcessId;
+    TUint32 iDriverRfcThreadId;
+    //Is egl initialized or not. If not, then it needs to be done before processing any other command
+    TBool iInitialized;
+    
+    /// Interface to the hardware.
+    DVirtualVideoHwInterface& iHwInterface;
+
+    /// DFC.
+    TDfc iDfc;
+    
+    /// Current interrupt ID.
+    TInt iInterruptId;
+    
+    /// Kernel address of the shared chunk. 
+    TLinAddr iChunkKernelAddress;
+    
+    /// Size of the chunk.
+    TUint32 iChunkSize;
+    
+    //Request lists
+    TAsyncRequestRoot iSerializedRequestRoot;
+    TAsyncRequestRoot iPendingRequestRoot;
+
+    /*
+     * Current transaction id 
+     */
+    TUint32 iTransactionId;
+    
+    /*
+     * Ring buffer for requests
+     */    
+    RequestBufferWriter iRequestBuffer;
+    
+    };
+
+#endif // DEVICEREQHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/ldd/inc/reqhandlerextension.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Guest video driver - request handler extension (a.k.a. Command Scheduler extension)
+// This allows the sgdevice.ldd to make calls into the Command Scheduler
+//
+
+#ifndef ReqHandlerExtension_H
+#define ReqHandlerExtension_H
+
+
+#include <kernel/kernel.h>
+
+#include <sgresource/sgcommon.h>//TSgImageMetaData
+
+#include "virtualvideotracing.h"
+
+class MReqHandlerCallback
+    {
+public:
+	virtual void CreateSgImagePbuffer( const TSgImageMetaData& aInfo, TRequestStatus* aStatus, DThread* aThread ) = 0;
+	virtual void CreateSgImageVGImage( const TSgImageMetaData& aInfo, TRequestStatus* aStatus, DThread* aThread ) = 0;
+	virtual TInt DestroySgImage( const TUint64 aId ) = 0;    
+    };
+
+NONSHARABLE_CLASS(DReqHandlerExtensionImpl): public DBase
+	{
+public:
+	TInt Construct();
+	void CreateSgImagePbuffer( const TSgImageMetaData& aInfo, TRequestStatus* aStatus, DThread* aThread );
+	void CreateSgImageVGImage( const TSgImageMetaData& aInfo, TRequestStatus* aStatus, DThread* aThread );
+	TInt DestroySgImage( const TUint64 aId );
+	TInt SetReqHandler( MReqHandlerCallback* aHandler );
+private:
+	DMutex* iMutex;
+	MReqHandlerCallback* iCallBackHandler;//not owned
+	};
+
+class ReqHandlerExtension
+	{
+public:
+	//SgImage Creation and Destruction commands:
+	IMPORT_C static TInt CreateSgImagePbuffer( const TSgImageMetaData& aInfo );
+	IMPORT_C static TInt CreateSgImageVGImage( const TSgImageMetaData& aInfo );
+	IMPORT_C static TInt DestroySgImage( const TUint64 aId );
+	IMPORT_C static TInt SetReqHandler( MReqHandlerCallback* aHandler );
+	//other functions to be added
+	};
+
+//#include <sgresource/ReqHandlerExtension.inl>
+
+#endif // ReqHandlerExtension_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/ldd/inc/virtualvideohwchannel.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,152 @@
+// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#ifndef VIRTUALVIDEOHWCHANNEL_H
+#define VIRTUALVIDEOHWCHANNEL_H
+
+#include <kernel/kernel.h>
+#include <kernel/kern_priv.h>
+#include "sgextension.h"//For SgExtension
+
+#include "virtualvideohwinterface.h"
+
+class MVirtualVideoHwDeviceInterface;
+class DDeviceReqHandler;
+
+_LIT( KVirtualVideoHwChannelPanic, "DVVideoHwChannel" );
+
+/**
+ * Logical channel for the ARM virtual video peripheral used in the
+ * platform simulator.
+ */
+class DVirtualVideoHwChannel : public DLogicalChannel
+    {
+public:
+
+    /**
+     * Constructor.
+     * 
+     * @param aDeviceInterface
+     *   Interface to the device driver.
+     * @param aHwInterface
+     *   Interface to the hardware.
+     * @param aDeviceReqHandler
+     *   Shared request handler for channels
+     * @param aQueue
+     *   Deferred function call queue.
+     */
+    DVirtualVideoHwChannel(
+            MVirtualVideoHwDeviceInterface& aDeviceInterface,
+            DVirtualVideoHwInterface& aHwInterface,
+            DDeviceReqHandler& aDeviceReqHandler,
+            TDfcQue* aQueue
+            );
+
+    /**
+     * Destructor.
+     */
+    virtual ~DVirtualVideoHwChannel();
+
+protected: // From DLogicalChannelBase
+
+    /**
+     * Second phase constructor for DLogicalChannelBase objects.
+     * @see DLogicalChannelBase::DoCreate
+     */
+    virtual TInt DoCreate( TInt aUnit, const TDesC8* aInfo, const TVersion& aVer );
+
+protected: // From DLogicalChannel
+
+    /**
+     * Handles a client request in the client context.
+     * @see DLogicalChannelBase::Request
+     */
+    virtual TInt Request( TInt aReqNo, TAny *a1, TAny *a2 );
+
+    /**
+     * Processes a message for this logical channel.
+     * @see DLogicalChannel::HandleMsg
+     */
+    void HandleMsg( TMessageBase* aMsgRequest );
+
+protected: // New functions
+    
+    /**
+     * This function is called from HandleMsg(). It is used to handle
+     * asynchronous requests.
+     * 
+     * @param aUserThread
+     *   User thread
+     * @param aReqNo
+     *   Request number
+     * @param aStatus
+     *   Request status
+     * @param a1
+     *   Optional parameter
+     * @param a2
+     *   Optional parameter
+     * @return
+     *   KErrNone - Successful
+     *   KErrArgument - a1 is NULL
+     *   KErrNotSupported - Invalid aReqNo
+     *   System wide errorcodes in other error situations.
+     */
+    virtual TInt DoRequest(
+            DThread*& aUserThread,
+            TInt aReqNo,
+            TRequestStatus* aStatus,
+            TAny* a1 = NULL,
+            TAny* a2 = NULL );
+    
+    /**
+     * This function is called from HandleMsg(). It is used to handle
+     * synchronous requests.
+     * 
+     * @param aUserThread
+     *   User thread
+     * @param aFunction
+     *   Function number
+     * @param a1
+     *   Required parameter
+     * @param a2
+     *   Optional parameter
+     * @return
+     *   KErrNone - Successful
+     *   KErrArgument - a1 is NULL
+     *   KErrNotReady - Buffer not allocated yet for playback or recording.
+     *   KErrInUse - Playback or recording already ongoing.
+     *   KErrNotSupported - Invalid aFunction
+     *   System wide errorcodes in other error situations.
+     */
+    virtual TInt DoControl( DThread*& aUserThread, TInt aFunction, TAny* a1, TAny* a2 = NULL );
+
+private:
+
+    /// Interface to the logical device
+    MVirtualVideoHwDeviceInterface& iDeviceInterface;
+    
+    /// Interface to the hardware
+    DVirtualVideoHwInterface& iHwInterface;
+
+    TInt GetSgImageMetaData(TSgImageMetaData& aSgInfo, const TUint64 aId);
+
+    TInt iValue;
+    
+    /// Request handler (Owned)
+    DDeviceReqHandler& iReqHandler;
+    };
+
+#endif // VIRTUALVIDEOHWCHANNEL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/ldd/inc/virtualvideohwdevice.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,82 @@
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef VIRTUALVIDEOHWDEVICE_H
+#define VIRTUALVIDEOHWDEVICE_H
+
+#include <kernel/kernel.h>
+#include <kernel/kern_priv.h>
+#include "virtualvideohwdeviceinterface.h"
+
+class DVirtualVideoHwInterface;
+class DDeviceReqHandler;
+
+_LIT( KVirtualVideoHwDevicePanic, "DVVideoHwDevice" );
+
+/**
+ * Logical device driver for the virtual Video peripheral used in the
+ * platform simulator.
+ */
+class DVirtualVideoHwDevice : public DLogicalDevice,
+                              public MVirtualVideoHwDeviceInterface
+    {
+public:
+
+    /**
+     * Default constructor.
+     */
+    DVirtualVideoHwDevice();
+
+    /**
+     * Destructor.
+     */
+    virtual ~DVirtualVideoHwDevice();
+
+public: // From DLogicalDevice
+
+    /**
+     * Second stage constructor.
+     * @see DLogicalDevice::Install
+     */
+    virtual TInt Install();
+    
+    /**
+     * Gets the driver's capabilities.
+     * @see DLogicalDevice::GetCaps
+     */
+    virtual void GetCaps( TDes8& aDes ) const;
+
+    /**
+     * Called by the kernel's device driver framework to create
+     * a Logical Channel.
+     * @see DLogicalDevice::Create
+     */
+    virtual TInt Create( DLogicalChannelBase*& aChannel );
+    
+private: // From MVirtualVideoHwDeviceInterface
+    
+private:
+
+    // Interface to the hardware
+    DVirtualVideoHwInterface* iHwInterface;
+    
+    // DFC queue
+    TDfcQue* iDfcQ;
+    
+    // Request handler
+    DDeviceReqHandler* iDeviceReqHandler;     
+    };
+
+#endif // VIRTUALVIDEOHWDEVICE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/ldd/inc/virtualvideohwdeviceinterface.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,30 @@
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef VIRTUALVIDEOHWDEVICEINTERFACE_H
+#define VIRTUALVIDEOHWDEVICEINTERFACE_H
+
+#include "virtualvideohwinterface.h"
+
+/**
+ * Interface to the logical device.
+ */
+class MVirtualVideoHwDeviceInterface
+    {
+public:
+
+    };
+
+#endif // VIRTUALVIDEOHWDEVICEINTERFACE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/ldd/inc/virtualvideohwinterface.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,207 @@
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+
+#ifndef VIRTUALVIDEOHWINTERFACE_H
+#define VIRTUALVIDEOHWINTERFACE_H
+
+#include <kernel/kernel.h>
+#include <internal/trace_utils.h>
+#include <graphics/guestvideodriverinterfaceconstants.h>
+
+/**
+ * Class that encapsulates the Virtual Video Hw interface behind a function
+ * interface. Intended to be instantiated only once in the device driver.
+ */
+class DVirtualVideoHwInterface : public DBase
+    {
+    public: // Data types
+        
+        /**
+         * Enumeration for different interrupts.
+         */
+        enum TInterrupt
+            {
+            EInterruptNewDataAvailable  = 0x01 ///< Video HW has new data available
+            };
+        /**
+         * Enumeration for different registers.
+         */
+        enum TRegister
+            {
+            ERegId,                             ///< Id register
+            ERegIrqEnable,                      ///< IRQ enabling register
+            ERegIrqStatus,                      ///< IRQ status register
+            ERegCommand,                        ///< Command register
+            ERegParameterLoad,
+            ERegError,                         ///< 
+            ERegInputBufferTail,
+            ERegInputBufferHead,
+            ERegInputBufferReadCount,
+            ERegInputBufferWriteCount,
+            ERegInputBufferMaxTail,
+            ERegRequestId,
+            ENumRegisters                       ///< Number of registers                                                
+            
+            };
+
+    public: // Construction and destruction
+
+        /**
+         * Constructor.
+         */
+        DVirtualVideoHwInterface();
+
+        /**
+         * Destructor.
+         * NOTE: Enters and leaves critical section.
+         */
+        virtual ~DVirtualVideoHwInterface();
+
+    public: // Functions
+
+
+        /**
+         * Initializes the Virtual Video HW's memory mapped I/O model.
+         * NOTE: Enters and leaves critical section.
+         *
+         * @return System-wide error code
+         */
+        TInt InitParametersInputMemory();
+        TInt InitParametersOutputMemory();
+        
+        /**
+         * Enables interrupts in the Virtual Video HW.
+         *
+         * @param aChannel The channel, whose interrupts are enabled
+         * @param aInterruptBitField A bitmask of TInterrupt enumeration.
+         *      Enabled interrupt bits should be set to 1 and disabled interrupt
+         *      bits to 0.
+         */
+        void EnableInterrupts( TUint32 aInterruptBitField );
+        
+        /**
+         * Initializes the Virtual Video HW's memory mapped I/O model.
+         * NOTE: Enters and leaves critical section.
+         *
+         * @return System-wide error code
+         */
+         TInt InitRegisterMemory();
+        /**
+         * Retrieves interrupt enabled state in the Virtual Video HW.
+         *
+         * @param aChannel The channel, whose interrupt states are queried
+         * @param aInterruptBitField A reference parameter, where a bitmask of
+         *      TInterrupt enumeration will be written. Enabled interrupt bits
+         *      are set to 1 and disabled interrupt bits to 0.
+         */
+        void GetInterruptEnabledState( TUint32& aInterruptBitField );
+
+        /**
+         * Retrieves interrupt status in the Virtual Video HW.
+         *
+         * @param aChannel The channel, whose interrupt status is queried
+         * @param aInterruptBitField A reference parameter, where a bitmask of
+         *      TInterrupt enumeration will be written. Those interrupt lines
+         *      are active, whose bits are set to 1 in the bitmask.
+         */
+        void GetInterruptStatus( TUint32& aInterruptBitField );
+
+        /**
+         * Resets interrupt status in the Virtual Video HW.
+         *
+         * @param aChannel The channel, whose interrupt statuses are being reset
+         * @param aInterruptBitField The bitmask of TInterrupt enumeration. Those
+         *      interrupts are reset, whose bits are set to 1 in the bitfield.
+         */
+        void ResetInterruptStatus( TUint32 aInterruptBitField );
+        
+        /**
+         * Issues a command to the Virtual Video HW.
+         *
+         * @param aCommand One of TCommand enumeration commands.
+         */
+        void IssueCommand( TUint32 aCommand );
+        
+        /**
+         * Address to input parameter buffer
+         */
+        TLinAddr InputParametersAddress(){ return iInputParametersChunkKernelAddress; }
+        
+        /**
+         * Address to output parameter buffer
+         */
+        TLinAddr OutputParametersAddress(){ return iOutputParametersChunkKernelAddress; }
+
+        
+        /**
+         * Gets a register value.
+         * 
+         * @param aRegisterRange The register range
+         * @param aRegister The register in the given register range, whose value is being read
+         * @param aValue A reference parameter, where the register's value is written
+         */
+        void GetRegisterValue(
+            TRegister aRegister,
+            TUint32& aValue );
+
+        /**
+         * Sets a register value.
+         * 
+         * @param aRegisterRange The register range
+         * @param aRegister The register in the given register range, whose value is being written
+         * @param aValue A new value to be written into register
+         */
+        void SetRegisterValue( TRegister aRegister,
+            TUint32 aValue );
+
+public:
+		IMPORT_C static TPhysAddr GetFrameBase();
+
+    protected:
+
+        /**
+         * Maps a virtual address range to physical address space
+         * 
+         * @param aPhysicalAddress 
+         * @param aMaxSize 
+         * @param aChunk
+         * @param aLinAddr 
+         * @return System wide error code
+         */
+        TInt InitPhysicalMemory( TUint32 aPhysicalAddress, 
+                TInt aMaxSize, DChunk*& aChunk, TLinAddr& aLinAddr );
+
+    private: // Data
+
+        /// A memory chunk that is mapped to the Virtual Video HW's physical memory area
+        DChunk* iRegisterMemoryChunk;        
+        /// The virtual start address of the Virtual Video HW's memory map
+        TLinAddr iRegisterChunkKernelAddress;
+
+        /// A memory chunk that is mapped to the Virtual Video HW's physical memory area
+        DChunk* iInputParametersMemoryChunk;        
+        /// The virtual start address of the Virtual Video HW's memory map
+        TLinAddr iInputParametersChunkKernelAddress;
+
+        /// A memory chunk that is mapped to the Virtual Video HW's physical memory area
+        DChunk* iOutputParametersMemoryChunk;        
+        /// The virtual start address of the Virtual Video HW's memory map
+        TLinAddr iOutputParametersChunkKernelAddress;
+
+    };
+
+
+#endif // VIRTUALVIDEOHWINTERFACE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/guestvideodriver_api/ldd/inc/virtualvideotracing.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,25 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#ifndef VIRTUAL_VIDEO_TRACING_H
+#define VIRTUAL_VIDEO_TRACING_H
+
+#ifdef _DEBUG
+    #define VVHW_TRACE(fmt, args...) Kern::Printf(fmt, ##args)
+#else
+    #define VVHW_TRACE(fmt, args...)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/bwins/distribution.policy.s60	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/bwins/surfacemanageru.def	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,17 @@
+EXPORTS
+	?AddSurfaceHint@RSurfaceManager@@QAEHABVTSurfaceId@@ABVTHintPair@1@@Z @ 1 NONAME ; int RSurfaceManager::AddSurfaceHint(class TSurfaceId const &, class RSurfaceManager::THintPair const &)
+	?Open@RSurfaceManager@@QAEHXZ @ 2 NONAME ; int RSurfaceManager::Open(void)
+	?GetSurfaceManagerAttrib@RSurfaceManager@@QAEHW4TSurfaceManagerAttrib@1@AAH@Z @ 3 NONAME ; int RSurfaceManager::GetSurfaceManagerAttrib(enum RSurfaceManager::TSurfaceManagerAttrib, int &)
+	?CreateSurface@RSurfaceManager@@QAEHABV?$TPckgBuf@VTSurfaceCreationAttributes@RSurfaceManager@@@@AAVTSurfaceId@@ABVRChunk@@@Z @ 4 NONAME ; int RSurfaceManager::CreateSurface(class TPckgBuf<class RSurfaceManager::TSurfaceCreationAttributes> const &, class TSurfaceId &, class RChunk const &)
+	?SurfaceInfo@RSurfaceManager@@QAEHABVTSurfaceId@@AAV?$TPckgBuf@VTSurfaceInfoV01@RSurfaceManager@@@@@Z @ 5 NONAME ; int RSurfaceManager::SurfaceInfo(class TSurfaceId const &, class TPckgBuf<class RSurfaceManager::TSurfaceInfoV01> &)
+	?CloseSurface@RSurfaceManager@@QAEHABVTSurfaceId@@@Z @ 6 NONAME ; int RSurfaceManager::CloseSurface(class TSurfaceId const &)
+	?SynchronizeCache@RSurfaceManager@@QAEHABVTSurfaceId@@HW4TSyncOperation@1@@Z @ 7 NONAME ; int RSurfaceManager::SynchronizeCache(class TSurfaceId const &, int, enum RSurfaceManager::TSyncOperation)
+	?Close@RSurfaceManager@@QAEXXZ @ 8 NONAME ; void RSurfaceManager::Close(void)
+	?GetBufferOffset@RSurfaceManager@@QAEHABVTSurfaceId@@HAAH@Z @ 9  NONAME ; int RSurfaceManager::GetBufferOffset(class TSurfaceId const &, int, int &)
+	?SetSurfaceHint@RSurfaceManager@@QAEHABVTSurfaceId@@ABVTHintPair@1@@Z @ 10 NONAME ; int RSurfaceManager::SetSurfaceHint(class TSurfaceId const &, class RSurfaceManager::THintPair const &)
+	?GetSurfaceHint@RSurfaceManager@@QAEHABVTSurfaceId@@AAVTHintPair@1@@Z @ 11 NONAME ; int RSurfaceManager::GetSurfaceHint(class TSurfaceId const &, class RSurfaceManager::THintPair &)
+	?CreateSurface@RSurfaceManager@@QAEHABV?$TPckgBuf@VTSurfaceCreationAttributes@RSurfaceManager@@@@AAVTSurfaceId@@@Z @ 12 NONAME ; int RSurfaceManager::CreateSurface(class TPckgBuf<class RSurfaceManager::TSurfaceCreationAttributes> const &, class TSurfaceId &)
+	?MapSurface@RSurfaceManager@@QAEHABVTSurfaceId@@AAVRChunk@@@Z @ 13 NONAME ; int RSurfaceManager::MapSurface(class TSurfaceId const &, class RChunk &)
+	??0RSurfaceManager@@QAE@XZ @ 14 NONAME ; RSurfaceManager::RSurfaceManager(void)
+	?OpenSurface@RSurfaceManager@@QAEHABVTSurfaceId@@@Z @ 15 NONAME ; int RSurfaceManager::OpenSurface(class TSurfaceId const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/eabi/distribution.policy.s60	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/eabi/surfacemanageru.def	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,18 @@
+EXPORTS
+	_ZN15RSurfaceManager10MapSurfaceERK10TSurfaceIdR6RChunk @ 1 NONAME
+	_ZN15RSurfaceManager11OpenSurfaceERK10TSurfaceId @ 2 NONAME
+	_ZN15RSurfaceManager11SurfaceInfoERK10TSurfaceIdR8TPckgBufINS_15TSurfaceInfoV01EE @ 3 NONAME
+	_ZN15RSurfaceManager12CloseSurfaceERK10TSurfaceId @ 4 NONAME
+	_ZN15RSurfaceManager13CreateSurfaceERK8TPckgBufINS_26TSurfaceCreationAttributesEER10TSurfaceId @ 5 NONAME
+	_ZN15RSurfaceManager13CreateSurfaceERK8TPckgBufINS_26TSurfaceCreationAttributesEER10TSurfaceIdRK6RChunk @ 6 NONAME
+	_ZN15RSurfaceManager14AddSurfaceHintERK10TSurfaceIdRKNS_9THintPairE @ 7 NONAME
+	_ZN15RSurfaceManager14GetSurfaceHintERK10TSurfaceIdRNS_9THintPairE @ 8 NONAME
+	_ZN15RSurfaceManager14SetSurfaceHintERK10TSurfaceIdRKNS_9THintPairE @ 9 NONAME
+	_ZN15RSurfaceManager16SynchronizeCacheERK10TSurfaceIdiNS_14TSyncOperationE @ 10 NONAME
+	_ZN15RSurfaceManager23GetSurfaceManagerAttribENS_21TSurfaceManagerAttribERi @ 11 NONAME
+	_ZN15RSurfaceManager4OpenEv @ 12 NONAME
+	_ZN15RSurfaceManager5CloseEv @ 13 NONAME
+	_ZN15RSurfaceManagerC1Ev @ 14 NONAME
+	_ZN15RSurfaceManagerC2Ev @ 15 NONAME
+	_ZN15RSurfaceManager15GetBufferOffsetERK10TSurfaceIdiRi @ 16 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/group/bld.inf	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,27 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// User side interface for the surface manager
+
+PRJ_PLATFORMS
+BASEDEFAULT
+
+PRJ_EXPORTS
+../inc/surfacemanager.h			OS_LAYER_PLATFORM_EXPORT_PATH(graphics/surfacemanager.h)
+../inc/surface_hints.h			OS_LAYER_PLATFORM_EXPORT_PATH(graphics/surface_hints.h)
+surfacemanager.iby				/epoc32/rom/include/surfacemanager.iby
+../bwins/surfacemanageru.def	/epoc32/include/def/win32/surfacemanageru.def
+../eabi/surfacemanageru.def		/epoc32/include/def/eabi/surfacemanageru.def
+
+PRJ_MMPFILES
+surfacemanagerlib.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/group/distribution.policy.s60	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/group/surfacemanager.iby	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,24 @@
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// surfacemanager_ref.iby
+//
+
+#ifndef __SURFACEMANAGER_IBY__
+#define __SURFACEMANAGER_IBY__
+
+#include <graphics_adaptation.hby>
+#include SURFACEMANAGER_DRV
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/group/surfacemanagerlib.mmp	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,28 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Provide a library interface for the surface manager.  This interface is
+// expected to be implemented in an adapt layer component.
+
+#include <platform_paths.hrh>
+
+TARGET          surfacemanager.lib
+TARGETTYPE      IMPLIB
+
+#ifdef WINS
+DEFFILE       ../bwins/surfacemanager.def
+#else
+DEFFILE       ../eabi/surfacemanager.def
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/inc/distribution.policy.s60	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,1 @@
+7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/inc/surface_hints.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,210 @@
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Surface Manager API
+//
+
+#ifndef __SURFACE_HINTS_H__
+#define __SURFACE_HINTS_H__
+
+//- Include Files  ----------------------------------------------------------
+
+#include <e32cmn.h>
+
+
+//- Namespace ---------------------------------------------------------------
+
+namespace surfaceHints
+{
+
+//- Constants ---------------------------------------------------------------
+
+/** Hint of the surface content.
+    @see TSurfaceContent for possible values
+*/
+const TInt KSurfaceContent = 0x1;
+
+/** Hint of the expected update rate of the surface content.
+    Value for a surface containing e.g. 25 fps video the value should be 25.
+    For a static UI element the value should be 0.
+    @see TSurfaceUpdate
+*/
+const TInt KSurfaceUpdate = 0x2;
+
+/** Hint whether the surface content is copy protected and can it be
+    shown on external displays.
+    @see TSurfaceProtection for possible values.
+*/
+const TInt KSurfaceProtection = 0x3;
+
+/** Hint about the surface’s characteristics or properties,
+   For example if a surface can be persisted by the effects engine.
+   @see TSurfaceCharacteristics for possible values.
+*/
+const TInt KSurfaceCharacteristics = 0x4;
+
+
+/** Values used for the KSurfaceContent key */
+enum TSurfaceContent
+    {
+    /** No specific use-case */
+    EGeneric,
+    /** Camera viewfinder frames */
+    EViewFinder,
+    /** Images captured by camera */
+    EStillImage,
+    /** Decoded video frames */
+    EVideoPlayback,
+    /** Video frames from video telephony */
+    EVideoTelephony,
+    /** EGL surface */
+    EGfx,
+    /** Main UI surface */
+    EUi,
+    /** Composition target surface */
+    ECompositionTarget,
+    /** Indicates that the surface has to accessible by ARM.
+        This can be orr'ed with other TSurfaceContent enumerations. */
+    EArmAccess = 0x80000000
+    };
+
+
+/** Values used for the KSurfaceProtection key. The values are bitmasks and can be combined
+* e.g. EAllowAnalogProtectionRequired | EAllowDigitalProtectionRequired.
+*/
+enum TSurfaceProtection
+    {
+    /**
+    * Not allowed on external outputs
+    */
+    EAllowInternalOnly                  = 0x00000000,
+
+    /**
+    * Allowed on all external outputs
+    */
+    EAllowAllExternals                  = 0xFFFFFFFF,
+
+    /**
+    * Allow passing content over analog outputs,
+    * e.g. composite and S-video
+    */
+    EAllowAnalog                        = 0x00000010,
+
+    /**
+    * Allow output over an analog output channel which has a protection
+    * mechanism
+    */
+    EAllowAnalogProtectionRequired      = 0x00000020,
+
+    /**
+    * Allow passing content over digital outputs,
+    * e.g. DVI and HDMI
+    */
+    EAllowDigital                       = 0x00000200,
+
+    /**
+    * Licensed product must attempt to engage HDCP to protect the content.
+    * However it should be passed through to HDMI even if HDCP is not engaged or fails to engage.
+    */
+    EAllowDigitalProtectionRequested    = 0x00000400,
+
+    /**
+    * Licensed product is required to engage HDCP to protect the content.
+    * If HDCP is not engaged or can not be engaged the content must not be passed through to HDMI.
+    */
+    EAllowDigitalProtectionRequired     = 0x00000800,
+    };
+
+
+/** Values used for the KSurfaceCharacteristics key. The values are bitmasks and can be combined.
+*/
+enum TSurfaceCharacteristics
+    {
+    /**
+    * Surface cannot be persisted once it has been closed by the creator
+    */
+    ENotPersistable = 1,
+    };
+
+
+class TSurfaceUpdate
+    {
+    /** Constructor.
+        @param aUpdateRate   How often the surface content is redrawn per second.
+        @param aTearingFree  When ETrue surface updates should be synchronized
+                             with display refresh rate, otherwise surface can
+                             be updated as fast as possible.
+    */
+    inline TSurfaceUpdate(TUint aUpdateRate, TBool aTearingFree);
+
+    /** Converts a value to TSurfaceUpdate */
+    inline TSurfaceUpdate(TInt aValue);
+
+    /** Converts TSurfaceUpdate to a signed integer, so it can be used as
+        a value for KSurfaceUpdate key. */
+    inline operator TInt() const;
+
+    /** Getter for surface update rate.
+        @return updates per second
+    */
+    inline TUint UpdateRate() const;
+
+    /** Getter for surface update synchronization.
+        @return ETrue - updates should be synchronized with display refresh rate,
+                EFalse - surface can be updated as fast as possible.
+    */
+    inline TBool TearingFree() const;
+
+    private:
+        TUint iValue;
+    };
+
+
+//- Forward Declarations ----------------------------------------------------
+
+
+//- Class Definitions -------------------------------------------------------
+
+
+//- Inline Functions --------------------------------------------------------
+
+TSurfaceUpdate::TSurfaceUpdate(TUint aUpdateRate, TBool aTearingFree)
+    : iValue( ( aUpdateRate & 0xFFFF ) | ( aTearingFree ? 0x80000000 : 0x0 ) )
+    {
+    }
+TSurfaceUpdate::TSurfaceUpdate(TInt aValue)
+    : iValue( static_cast<TUint>( aValue ) )
+    {
+    }
+
+TSurfaceUpdate::operator TInt() const
+    {
+    return static_cast<TInt>( iValue );
+    }
+
+TUint TSurfaceUpdate::UpdateRate() const
+    {
+    return ( iValue & 0xFFFF );
+    }
+
+TBool TSurfaceUpdate::TearingFree() const
+    {
+    return ( iValue & 0x80000000 ) ? ETrue : EFalse;
+    }
+
+} //namespace surfaceHints
+
+#endif //__SURFACE_HINTS_H__
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics_plat/surfacemanager_api/inc/surfacemanager.h	Fri Aug 13 15:11:40 2010 +0100
@@ -0,0 +1,223 @@
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Surface Manager API
+// 
+//
+
+/**
+ @file
+ @publishedPartner
+ @prototype
+*/
+
+#ifndef __SURFACEMANAGER_H__
+#define __SURFACEMANAGER_H__
+
+#ifndef __KERNEL_MODE__
+#include <e32std.h>
+#endif
+
+#include <e32cmn.h>
+#include <e32ver.h>
+#include <pixelformats.h>
+#include <graphics/surface.h>
+
+class RSurfaceManagerDriver;
+
+/**
+RSurface Manager User API.
+*/
+class RSurfaceManager
+	{
+public:
+
+	class THintPair
+		{
+	public:
+		/** UID key number */
+		TUid iKey;
+		/** Integer key value */
+		TInt iValue;
+		/** Is the value modifiable */
+		TBool iMutable;
+	public:
+		inline void Set(TUid aKey,TInt aValue,TBool aMutable);
+		};
+	
+	enum TCacheAttribute
+		{
+		/** CPU cached */
+		ECached = 0,
+		/** Non CPU cached */
+		ENotCached = 1
+		};
+
+	class TSurfaceCreationAttributes
+		{
+	public:
+		/** Width and height of the surface in pixels. */
+		TSize iSize;
+		/** Number of buffers in the surface. */
+		TInt iBuffers;
+		/** The pixel format. */
+		TUidPixelFormat iPixelFormat;
+		/** Minimum or required number of bytes between start of one line and
+		start of next. */
+		TInt iStride;
+		/** Minimum or required offset to the first buffer from the base of the
+		chunk. Typically this will be set to 0. The value specified for the
+		offset must comply with the alignment specified in iAlignment.
+		
+		If iAlignment is page aligned, this value will be rounded up to a
+		multiple of the page size when the surface is created, therefore the
+		surface info must be queried for the actual value used. */
+		TInt iOffsetToFirstBuffer;
+		/** Alignment applied to the base address of each buffer in the surface:
+		1, 2, 4, 8 ,16, 32, 64 bytes or EPageAligned. */
+		TInt iAlignment;
+		/** Require physically contiguous memory. This value will be ignored if
+		using a chunk which already exists. */
+		TBool iContiguous;
+		/** Caching attribute to create chunk memory. This value will be 
+		ignored if using a chunk which already exists. */
+		TCacheAttribute iCacheAttrib;
+		/** Minimum or required offset between the start of one buffer and the
+		start of the next one in bytes. When set to 0 the surface manager will
+	   	choose how buffers are laid out within the chunk. If it is too small
+		and doesn't fit with the alignment, CreateSurface() will return
+		KErrArgument. */
+		TInt iOffsetBetweenBuffers;
+		/** Array of hints which should be associated with the surface. This
+		array must not contain duplicate hint keys. */
+		THintPair* iSurfaceHints;
+		/** Number of hints in the array iSurfaceHints. The number should not
+		exceed the maximum number supported by the surface manager, see 
+		GetSurfaceManagerAttrib(EMaxNumberOfHints). */
+		TInt iHintCount;
+		/** Should the surface be mappable. If EFalse any call to MapSurface()
+		will fail with KErrNotSupported -- Note, some architectures may not
+		support mappable surfaces. */
+		TBool iMappable;
+	public:
+		inline TSurfaceCreationAttributes();
+		};
+
+	class TSurfaceInfoV01
+		{
+	public:
+		/** Width and height of the surface in pixels */
+		TSize iSize;
+		/** Number of buffers in the surface */
+		TInt iBuffers;
+		/** The pixel format */
+		TUidPixelFormat iPixelFormat;
+		/** Number of bytes between start of one line and start of next */
+		TInt iStride;
+		/** Has physically contiguous memory */
+		TBool iContiguous;
+		/** Specified if the underlying chunk is CPU cached or not */
+		TCacheAttribute iCacheAttrib;
+		/** ETrue if the surface can be mapped */
+		TBool iMappable;
+		};
+	
+	enum TSurfaceManagerAttrib
+		{
+		/** Maximum number of hints per surface */
+		EMaxNumberOfHints = 0x0 
+		};
+
+	/** Package buf used to pass information about a surface from the driver */
+	typedef TPckgBuf<TSurfaceInfoV01> TInfoBuf;
+	/** Package buf used to pass the surface creation attributes to the device driver */
+	typedef TPckgBuf<TSurfaceCreationAttributes> TSurfaceCreationAttributesBuf;
+
+	enum TSyncOperation
+		{
+		/** Synchronize before non CPU hardware reads from the memory, i.e. if the
+		buffer is cached and may have been written to by the CPU, this type of
+		synchronisation should be used before a peripheral is used to read from the
+		buffer's memory */
+		ESyncBeforeNonCPURead,
+		/** Synchronize before non CPU hardware writes to the memory, i.e. if the
+		buffer is cached and may have been written to by the CPU, this type of
+		synchronisation should be used before a peripheral is used to write to the
+		buffer's memory */
+		ESyncBeforeNonCPUWrite,
+		/** Synchronize after non CPU hardware writes to the memory, i.e. if the
+		buffer is cached, this type of synchronisation should be used after a
+		peripheral has been used to write to the buffer's memory */
+		ESyncAfterNonCPUWrite
+		};
+
+	enum TPageAlignment
+		{
+		/** Specifies iAlignment is a page alignment */
+		EPageAligned = -1
+		};
+	
+public:
+#ifndef __KERNEL_MODE__
+	IMPORT_C RSurfaceManager();
+	IMPORT_C TInt Open();
+	IMPORT_C void Close();
+	IMPORT_C TInt CreateSurface(const TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId);
+	IMPORT_C TInt CreateSurface(const TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId, const RChunk& aChunkHandle);
+	IMPORT_C TInt OpenSurface(const TSurfaceId& aSurfaceId);
+	IMPORT_C TInt CloseSurface(const TSurfaceId& aSurfaceId);
+	IMPORT_C TInt MapSurface(const TSurfaceId& aSurfaceId, RChunk& aHandle);
+	IMPORT_C TInt SurfaceInfo(const TSurfaceId& aSurfaceId, TInfoBuf& aInfo);
+	IMPORT_C TInt SynchronizeCache(const TSurfaceId& aSurfaceId, TInt aBuffer, TSyncOperation aOperation);
+	IMPORT_C TInt GetSurfaceManagerAttrib(TSurfaceManagerAttrib aAttrib, TInt& aValue);
+	IMPORT_C TInt GetSurfaceHint(const TSurfaceId& aSurfaceId, THintPair& aHint);
+	IMPORT_C TInt SetSurfaceHint(const TSurfaceId& aSurfaceId, const THintPair& aHint);
+	IMPORT_C TInt AddSurfaceHint(const TSurfaceId&aSurface, const THintPair& aHint);
+	IMPORT_C TInt GetBufferOffset(const TSurfaceId& aSurfaceId, TInt aBuffer, TInt& aOffset);
+#endif	//__KERNEL_MODE__	
+private:
+	inline RSurfaceManagerDriver& Driver();
+private:
+	TInt32 iDriverBuf[4];
+	};
+
+//
+// THintPair inline
+//
+
+/**
+Sets key, value and mutability of the hint.
+@param aKeyUid The UID of the key
+@param aValue The value of the hint
+@param aMutable ETrue if the hint value is mutable
+*/
+inline void RSurfaceManager::THintPair::Set(TUid aKeyUid,TInt aValue,TBool aMutable)
+	{
+	iKey = aKeyUid;
+	iValue = aValue;
+	iMutable = aMutable;
+	}
+
+//
+// TSurfaceCreationAttributes inline
+//
+
+/**
+Default constructor, zero initializes all attributes.
+*/
+inline RSurfaceManager::TSurfaceCreationAttributes::TSurfaceCreationAttributes()
+	{
+	memclr(this, sizeof(TSurfaceCreationAttributes));
+	}
+
+#endif //__SURFACEMANAGER_H__
--- a/graphicstest/graphicstestharness/automation/graphicssystemgui.sysdef.xml	Fri Aug 13 10:56:35 2010 +0100
+++ b/graphicstest/graphicstestharness/automation/graphicssystemgui.sysdef.xml	Fri Aug 13 15:11:40 2010 +0100
@@ -302,6 +302,14 @@
 						<unit bldFile="sf\os\graphics\printingservices\printerdriversupport\group" mrp="sf\os\graphics\printingservices\printerdriversupport\group\graphics_pdrstore.mrp"/>
 					</component>
 				</collection>
+                                <collection name="Graphics Platform Interfaces">
+                                        <component name="Guest Video Driver API">
+                                                <unit bldFile="sf\os\graphics\graphics_plat\guestvideodriver_api\group"/>
+                                        </component>
+                                        <component name="Surface Manager API">
+                                                <unit bldFile="sf\os\graphics\graphics_plat\surfacemanager_api\group"/>
+                                        </component>
+                                </collection>
 				<collection name="Windowing">
 					<component name="Window Server">
 						<unit bldFile="sf\os\graphics\windowing\windowserver\group" mrp="sf\os\graphics\windowing\windowserver\group\graphics_wserv.mrp"/>