author | Gareth Stockwell <gareth.stockwell@accenture.com> |
Wed, 22 Sep 2010 20:10:53 +0100 | |
branch | graphics-phase-3 |
changeset 113 | b842c0cb760e |
parent 111 | 345f1c88c950 |
permissions | -rw-r--r-- |
77 | 1 |
// This is the main DLL file. |
2 |
||
3 |
#include "platformtypes.h" |
|
4 |
#include <KhronosAPIWrapper.h> |
|
110
52ce3e8fba90
Header and class name changes
Jani Hyvonen<jani.hyvonen@nokia.com>
parents:
77
diff
changeset
|
5 |
#include <guestvideodriverinterfaceconstants.h> //Registers and enums |
77 | 6 |
#include <platformthreading.h> //mutex |
110
52ce3e8fba90
Header and class name changes
Jani Hyvonen<jani.hyvonen@nokia.com>
parents:
77
diff
changeset
|
7 |
#include <graphicsvhwcallback.h> |
111
345f1c88c950
Fixes to syborg-graphicswrapper.vcproj
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
110
diff
changeset
|
8 |
#include "syborg-graphicswrapper.h" |
77 | 9 |
|
10 |
SyborgGraphicsWrapper::SyborgGraphicsWrapper() |
|
110
52ce3e8fba90
Header and class name changes
Jani Hyvonen<jani.hyvonen@nokia.com>
parents:
77
diff
changeset
|
11 |
{ |
77 | 12 |
} |
13 |
||
14 |
SyborgGraphicsWrapper::~SyborgGraphicsWrapper() |
|
15 |
{ |
|
16 |
delete m_wrapper; |
|
17 |
m_wrapper = 0; |
|
18 |
||
19 |
Psu::platform_release_semaphore(m_outputBufferSemaphore); |
|
20 |
} |
|
21 |
||
22 |
int SyborgGraphicsWrapper::Reset( uint32_t *aGraphicsMemBase, uint32_t *aCommandMemBase ) |
|
23 |
{ |
|
24 |
int ret = -1; |
|
25 |
if ( m_wrapper ) |
|
26 |
{ |
|
27 |
delete m_wrapper; |
|
28 |
} |
|
29 |
m_wrapper = NULL; |
|
30 |
||
31 |
uint8_t *cmd_buffer = (uint8_t *)aCommandMemBase; |
|
32 |
uint8_t *frame_buffer = (uint8_t *)aGraphicsMemBase; |
|
33 |
if( (cmd_buffer != NULL) && (frame_buffer != NULL) ) |
|
34 |
{ |
|
110
52ce3e8fba90
Header and class name changes
Jani Hyvonen<jani.hyvonen@nokia.com>
parents:
77
diff
changeset
|
35 |
m_wrapper = new KhronosAPIWrapper( (MGraphicsVHWCallback*)this, |
77 | 36 |
frame_buffer, &cmd_buffer[VVHW_INPUT_BASE], &cmd_buffer[VVHW_OUTPUT_BASE] ); |
37 |
//Reset synchronisation mechanisms |
|
38 |
Psu::platform_release_semaphore(m_outputBufferSemaphore); |
|
39 |
Psu::platform_create_semaphore(m_outputBufferSemaphore, 1, 1); |
|
40 |
ret = 0; |
|
41 |
} |
|
42 |
else |
|
43 |
{ |
|
44 |
ret = -1; |
|
45 |
} |
|
46 |
return ret; |
|
47 |
} |
|
48 |
||
49 |
void SyborgGraphicsWrapper::LockOutputBuffer() |
|
50 |
{ |
|
51 |
#ifdef KHRONOS_API_W_MULTITHREAD |
|
52 |
Psu::platform_wait_for_signal(m_outputBufferSemaphore); |
|
53 |
#endif |
|
54 |
} |
|
55 |
||
56 |
void SyborgGraphicsWrapper::ReleaseOutputBuffer(){} |
|
57 |
||
110
52ce3e8fba90
Header and class name changes
Jani Hyvonen<jani.hyvonen@nokia.com>
parents:
77
diff
changeset
|
58 |
void SyborgGraphicsWrapper::ProcessingDone(int i) |
77 | 59 |
{ |
60 |
m_pythonCallBack( i ); |
|
61 |
} |
|
62 |
||
63 |
extern "C" |
|
64 |
{ |
|
65 |
SYBORG_GRAPHICSWRAPPER_API SyborgGraphicsWrapper* create_SyborgGraphicsWrapper() |
|
66 |
{ |
|
67 |
return new SyborgGraphicsWrapper(); |
|
68 |
} |
|
69 |
SYBORG_GRAPHICSWRAPPER_API int initialize_SyborgGraphicsWrapper( SyborgGraphicsWrapper* aSyborgGraphicsWrapper ) |
|
70 |
{ |
|
71 |
Psu::platform_create_semaphore(m_outputBufferSemaphore, 1, 1); |
|
72 |
// Change to proper error handling |
|
73 |
return 0; |
|
74 |
} |
|
75 |
||
76 |
SYBORG_GRAPHICSWRAPPER_API int set_GraphicsCallBack( SyborgGraphicsWrapper* aSyborgGraphicsWrapper, int (*aGraphicsCallBack) (int) ) |
|
77 |
{ |
|
78 |
m_pythonCallBack = aGraphicsCallBack; |
|
79 |
// Change to proper error handling |
|
80 |
return 0; |
|
81 |
} |
|
82 |
||
83 |
SYBORG_GRAPHICSWRAPPER_API int reset_SyborgGraphicsWrapper( SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t *aGraphicsMemBase, uint32_t *aCommandMemBase ) |
|
84 |
{ |
|
85 |
return aSyborgGraphicsWrapper->Reset( aGraphicsMemBase, aCommandMemBase ); |
|
86 |
} |
|
87 |
||
88 |
SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputBufferTail( SyborgGraphicsWrapper* aSyborgGraphicsWrapper ) |
|
89 |
{ |
|
90 |
return m_wrapper->InputBufferTail(); |
|
91 |
} |
|
92 |
SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputBufferHead( SyborgGraphicsWrapper* aSyborgGraphicsWrapper ) |
|
93 |
{ |
|
94 |
return m_wrapper->InputBufferHead( ); |
|
95 |
} |
|
96 |
SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputBufferReadCount( SyborgGraphicsWrapper* aSyborgGraphicsWrapper ) |
|
97 |
{ |
|
98 |
return m_wrapper->InputBufferReadCount( ); |
|
99 |
} |
|
100 |
SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputBufferWriteCount( SyborgGraphicsWrapper* aSyborgGraphicsWrapper ) |
|
101 |
{ |
|
102 |
return m_wrapper->InputBufferWriteCount( ); |
|
103 |
} |
|
104 |
SYBORG_GRAPHICSWRAPPER_API uint32_t get_InputMaxTailIndex( SyborgGraphicsWrapper* aSyborgGraphicsWrapper ) |
|
105 |
{ |
|
106 |
return m_wrapper->InputMaxTailIndex( ); |
|
107 |
} |
|
108 |
SYBORG_GRAPHICSWRAPPER_API uint32_t get_cmd_memsize( void ) |
|
109 |
{ |
|
110 |
return (VVI_PARAMETERS_INPUT_MEMORY_SIZE + |
|
111 |
VVI_PARAMETERS_OUTPUT_MEMORY_SIZE); |
|
112 |
} |
|
113 |
SYBORG_GRAPHICSWRAPPER_API uint32_t get_framebuffer_memsize( void ) |
|
114 |
{ |
|
115 |
return VVI_FRAMEBUFFER_MEMORY_SIZE; |
|
116 |
} |
|
117 |
||
118 |
||
119 |
SYBORG_GRAPHICSWRAPPER_API unsigned int execute_command( SyborgGraphicsWrapper* aSyborgGraphicsWrapper ) |
|
120 |
{ |
|
121 |
return m_wrapper->Execute( ); |
|
122 |
} |
|
123 |
SYBORG_GRAPHICSWRAPPER_API void set_InputBufferTail( SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal ) |
|
124 |
{ |
|
125 |
m_wrapper->SetInputBufferTail( aVal ); |
|
126 |
} |
|
127 |
SYBORG_GRAPHICSWRAPPER_API void set_InputBufferHead( SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal ) |
|
128 |
{ |
|
129 |
m_wrapper->SetInputBufferHead( aVal ); |
|
130 |
} |
|
131 |
SYBORG_GRAPHICSWRAPPER_API void set_InputBufferReadCount( SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal ) |
|
132 |
{ |
|
133 |
m_wrapper->SetInputBufferReadCount( aVal ); |
|
134 |
} |
|
135 |
SYBORG_GRAPHICSWRAPPER_API void set_InputBufferWriteCount( SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal ) |
|
136 |
{ |
|
137 |
m_wrapper->SetInputBufferWriteCount( aVal ); |
|
138 |
} |
|
139 |
SYBORG_GRAPHICSWRAPPER_API void set_InputMaxTailIndex( SyborgGraphicsWrapper* aSyborgGraphicsWrapper, uint32_t aVal ) |
|
140 |
{ |
|
141 |
m_wrapper->SetInputMaxTailIndex( aVal ); |
|
142 |
} |
|
143 |
SYBORG_GRAPHICSWRAPPER_API void signal_outputbuffer_semafore( SyborgGraphicsWrapper* aSyborgGraphicsWrapper ) |
|
144 |
{ |
|
145 |
#ifdef KHRONOS_API_W_MULTITHREAD |
|
146 |
Psu::platform_signal_semaphore(m_outputBufferSemaphore); |
|
147 |
#endif |
|
148 |
} |
|
149 |
||
150 |
} |