Moved syborggraphicswrapper from qemu package bug235_bringup_0
authorGareth Stockwell <gareth.stockwell@accenture.com>
Fri, 24 Sep 2010 12:02:04 +0100
branchbug235_bringup_0
changeset 36 563aa0c4cea3
parent 35 44e8593dd747
child 37 1a4430846fcf
Moved syborggraphicswrapper from qemu package
holdingarea/CMakeLists.txt
holdingarea/syborggraphicswrapper/CMakeLists.txt
holdingarea/syborggraphicswrapper/inc/syborg-graphicswrapper.h
holdingarea/syborggraphicswrapper/src/syborg-graphicswrapper.cpp
--- a/holdingarea/CMakeLists.txt	Fri Sep 24 11:23:48 2010 +0100
+++ b/holdingarea/CMakeLists.txt	Fri Sep 24 12:02:04 2010 +0100
@@ -98,9 +98,11 @@
 
 if(WIN32)
     if (PLATSIM_EXTENSIONS)
-        add_subdirectory(serialization/Graphics/KhronosAPIWrapper)	# Platsim serialization
+        add_subdirectory(serialization/Graphics/KhronosAPIWrapper)	# Simulator serialization (host)
         add_dependencies(KhronosAPIWrapper libEGL libGLESv1 libGLESv2 hostthreadadapter)
-        set(ALL_TARGETS libEGL libOpenVG libGLESv1 libGLESv2 hostthreadadapter KhronosAPIWrapper ${DEV_EXTRA_TARGETS})
+		add_subdirectory(syborggraphicswrapper) # Simulator serialization (guest)
+        add_dependencies(syborg-graphicswrapper KhronosAPIWrapper hostthreadadapter)
+        set(ALL_TARGETS libEGL libOpenVG libGLESv1 libGLESv2 hostthreadadapter KhronosAPIWrapper syborg-graphicswrapper ${DEV_EXTRA_TARGETS})
     else(PLATSIM_EXTENSIONS)
         set(ALL_TARGETS libEGL libOpenVG libGLESv1 libGLESv2 ${DEV_EXTRA_TARGETS})
     endif(PLATSIM_EXTENSIONS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/holdingarea/syborggraphicswrapper/CMakeLists.txt	Fri Sep 24 12:02:04 2010 +0100
@@ -0,0 +1,47 @@
+# 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:
+# CMake meta build file for the simulator guest-side API wrapper
+
+set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
+set(INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc)
+set(LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
+
+set(HOSTTHREADADAPTER_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../hostsupport/hostthreadadapter/inc)
+set(KHRONOSAPIWRAPPER_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../serialization/Graphics/KhronosAPIWrapper/inc)
+set(GUESTVIDEODRIVERINTERFACECONSTANTS_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../serialization/Graphics)
+set(SERIALIZER_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../guestrendering/vghwserialiser/inc)
+
+set(SRC_FILES
+    ${INC_DIR}/syborg-graphicswrapper.h
+    ${SRC_DIR}/syborg-graphicswrapper.cpp
+)
+
+include_directories(
+  ${INC_DIR}
+  ${COMMON_INC_DIR}
+  ${HOSTTHREADADAPTER_INC_DIR}
+  ${KHRONOSAPIWRAPPER_INC_DIR}
+  ${SERIALIZER_INC_DIR}
+  ${GUESTVIDEODRIVERINTERFACECONSTANTS_INC_DIR}
+  )
+
+link_directories(${LIBS_DIR} ${GLOBAL_LIB_DIR})
+
+add_definitions(-DSYBORG_GRAPHICSWRAPPER_EXPORTS)
+
+add_library(syborg-graphicswrapper SHARED ${SRC_FILES})
+
+target_link_libraries(syborg-graphicswrapper KhronosAPIWrapper hostthreadadapter)
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/holdingarea/syborggraphicswrapper/inc/syborg-graphicswrapper.h	Fri Sep 24 12:02:04 2010 +0100
@@ -0,0 +1,47 @@
+#ifndef _SYBORG_GRAPHICSWRAPPER_H
+#define _SYBORG_GRAPHICSWRAPPER_H
+
+#pragma once
+					  
+#ifdef WIN32
+#ifdef SYBORG_GRAPHICSWRAPPER_EXPORTS
+#define SYBORG_GRAPHICSWRAPPER_API __declspec(dllexport)
+#else
+#define SYBORG_GRAPHICSWRAPPER_API __declspec(dllimport)
+#endif
+#else
+#define SYBORG_GRAPHICSWRAPPER_API
+#endif
+
+Psu::PLATFORM_SEMAPHORE_T m_outputBufferSemaphore;
+int (*m_pythonCallBack)(int); 
+KhronosAPIWrapper* m_wrapper;
+														   
+
+// Derived from GraphicsVirtualHW.lisa
+static const int VVHW_BUFFER (0x3000000);
+static const int VVHW_INPUT_BUFFER (0x1000000);
+static const int VVHW_INPUT_BASE(0x0);
+static const int VVHW_OUTPUT_BUFFER (0x1000000);
+static const int VVHW_OUTPUT_BASE(0x1000000);
+static const int VVHW_FRAME_BUFFER (0x1000000);
+static const int VVHW_FRAME_BASE(0x2000000);
+
+class SyborgGraphicsWrapper : public MGraphicsVHWCallback
+    {
+    public:
+
+        SyborgGraphicsWrapper();
+        ~SyborgGraphicsWrapper();
+
+        int Reset( uint32_t *aGraphicsMemBase,  uint32_t *aCommandMemBase );
+
+        virtual void LockOutputBuffer();
+	    virtual void ReleaseOutputBuffer();
+	    virtual void ProcessingDone(int i);
+
+    private:
+    };
+
+
+#endif // _SYBORG_GRAPHICSWRAPPER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/holdingarea/syborggraphicswrapper/src/syborg-graphicswrapper.cpp	Fri Sep 24 12:02:04 2010 +0100
@@ -0,0 +1,150 @@
+// This is the main DLL file.
+
+#include "platformtypes.h"
+#include <KhronosAPIWrapper.h>
+#include <guestvideodriverinterfaceconstants.h>  //Registers and enums 
+#include <platformthreading.h>  //mutex
+#include <graphicsvhwcallback.h>
+#include "syborg-graphicswrapper.h"
+
+SyborgGraphicsWrapper::SyborgGraphicsWrapper()
+    {															
+    }
+
+SyborgGraphicsWrapper::~SyborgGraphicsWrapper()
+    {
+    delete m_wrapper;
+    m_wrapper = 0;
+
+    Psu::platform_release_semaphore(m_outputBufferSemaphore);
+    }
+
+int SyborgGraphicsWrapper::Reset( uint32_t *aGraphicsMemBase,  uint32_t *aCommandMemBase )
+    {
+    int ret = -1;
+    if ( m_wrapper )
+        {
+        delete m_wrapper;
+	    }
+    m_wrapper = NULL;
+
+    uint8_t *cmd_buffer = (uint8_t *)aCommandMemBase;
+    uint8_t *frame_buffer = (uint8_t *)aGraphicsMemBase;
+    if( (cmd_buffer != NULL) && (frame_buffer != NULL) )
+        {
+        m_wrapper = new KhronosAPIWrapper( (MGraphicsVHWCallback*)this,
+            frame_buffer, &cmd_buffer[VVHW_INPUT_BASE], &cmd_buffer[VVHW_OUTPUT_BASE] );
+        //Reset synchronisation mechanisms
+        Psu::platform_release_semaphore(m_outputBufferSemaphore);
+        Psu::platform_create_semaphore(m_outputBufferSemaphore, 1, 1);
+        ret = 0;
+        }
+    else
+        {
+        ret = -1;
+        }
+    return ret;
+    }
+
+void SyborgGraphicsWrapper::LockOutputBuffer()
+    {
+    #ifdef KHRONOS_API_W_MULTITHREAD
+    Psu::platform_wait_for_signal(m_outputBufferSemaphore);
+    #endif
+    }
+
+void SyborgGraphicsWrapper::ReleaseOutputBuffer(){}
+
+void SyborgGraphicsWrapper::ProcessingDone(int i)
+    {
+    m_pythonCallBack( i );
+    }
+
+extern "C"
+    {
+    SYBORG_GRAPHICSWRAPPER_API SyborgGraphicsWrapper* create_SyborgGraphicsWrapper()
+        {
+        return new SyborgGraphicsWrapper();
+        }
+    SYBORG_GRAPHICSWRAPPER_API int initialize_SyborgGraphicsWrapper( SyborgGraphicsWrapper* aSyborgGraphicsWrapper )
+        {
+        Psu::platform_create_semaphore(m_outputBufferSemaphore, 1, 1);
+        // Change to proper error handling
+        return 0;
+        }
+
+    SYBORG_GRAPHICSWRAPPER_API int set_GraphicsCallBack( SyborgGraphicsWrapper* aSyborgGraphicsWrapper, int (*aGraphicsCallBack) (int) )
+        {
+        m_pythonCallBack = aGraphicsCallBack;
+        // Change to proper error handling
+        return 0;
+        }
+
+    SYBORG_GRAPHICSWRAPPER_API int reset_SyborgGraphicsWrapper(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t *aGraphicsMemBase,  uint32_t *aCommandMemBase )
+        {
+        return aSyborgGraphicsWrapper->Reset( aGraphicsMemBase, aCommandMemBase );
+        }
+
+    SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputBufferTail(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper )
+        {
+        return m_wrapper->InputBufferTail();
+        }
+    SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputBufferHead(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper )
+        {
+        return m_wrapper->InputBufferHead( );
+        }
+    SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputBufferReadCount(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper )
+        {
+        return m_wrapper->InputBufferReadCount( );
+        }
+    SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputBufferWriteCount(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper )
+        {
+        return m_wrapper->InputBufferWriteCount( );
+        }
+    SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputMaxTailIndex(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper )
+        {
+        return m_wrapper->InputMaxTailIndex( );
+        }
+    SYBORG_GRAPHICSWRAPPER_API uint32_t get_cmd_memsize( void )
+        {
+        return (VVI_PARAMETERS_INPUT_MEMORY_SIZE +
+                VVI_PARAMETERS_OUTPUT_MEMORY_SIZE);
+        }
+    SYBORG_GRAPHICSWRAPPER_API uint32_t get_framebuffer_memsize( void )
+        {
+        return VVI_SURFACEBUFFER_BASE_ADDRESS;
+        }
+
+    
+    SYBORG_GRAPHICSWRAPPER_API unsigned int execute_command(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper )
+        {
+        return m_wrapper->Execute( );
+        }
+    SYBORG_GRAPHICSWRAPPER_API void set_InputBufferTail(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal )
+        {
+        m_wrapper->SetInputBufferTail( aVal );
+        }
+    SYBORG_GRAPHICSWRAPPER_API void set_InputBufferHead(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal )
+        {
+        m_wrapper->SetInputBufferHead( aVal );
+        }
+    SYBORG_GRAPHICSWRAPPER_API void set_InputBufferReadCount(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal )
+        {
+        m_wrapper->SetInputBufferReadCount( aVal );
+        }
+    SYBORG_GRAPHICSWRAPPER_API void set_InputBufferWriteCount(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal )
+        {
+        m_wrapper->SetInputBufferWriteCount( aVal );
+        }
+    SYBORG_GRAPHICSWRAPPER_API void set_InputMaxTailIndex(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal )
+        {
+        m_wrapper->SetInputMaxTailIndex( aVal );
+        }
+    SYBORG_GRAPHICSWRAPPER_API void signal_outputbuffer_semafore(  SyborgGraphicsWrapper* aSyborgGraphicsWrapper )
+        {
+        #ifdef KHRONOS_API_W_MULTITHREAD
+            Psu::platform_signal_semaphore(m_outputBufferSemaphore);
+        #endif
+        }
+
+    }