19 #include <kern_priv.h> |
19 #include <kern_priv.h> |
20 |
20 |
21 #include <graphics/guestvideodriverinterfaceconstants.h> |
21 #include <graphics/guestvideodriverinterfaceconstants.h> |
22 #include <graphics/virtualvideohwinterface.h> |
22 #include <graphics/virtualvideohwinterface.h> |
23 #include <graphics/virtualvideotracing.h> |
23 #include <graphics/virtualvideotracing.h> |
|
24 #include "syborg.h" |
24 |
25 |
25 |
26 |
26 // CONSTANTS |
27 // CONSTANTS |
27 |
28 |
28 _LIT( KVirtualVideoHwInterfacePanic, "DVirtualVideoHwInterface" ); |
29 _LIT( KVirtualVideoHwInterfacePanic, "DVirtualVideoHwInterface" ); |
|
30 DVirtualVideoHwInterface * DVirtualVideoHwInterface::pVVHIf = NULL; |
29 |
31 |
30 // ============================ LOCAL DATA TYPES =============================== |
32 // ============================ LOCAL DATA TYPES =============================== |
31 |
33 |
32 // Register offsets for playback and recording channels |
34 // Register offsets for playback and recording channels |
33 // Note: The orders of these must match the order of enumarations |
35 // Note: The orders of these must match the order of enumarations |
42 VVI_R_INPUT_BUFFER_TAIL, |
44 VVI_R_INPUT_BUFFER_TAIL, |
43 VVI_R_INPUT_BUFFER_HEAD, |
45 VVI_R_INPUT_BUFFER_HEAD, |
44 VVI_R_INPUT_BUFFER_READ_COUNT, |
46 VVI_R_INPUT_BUFFER_READ_COUNT, |
45 VVI_R_INPUT_BUFFER_WRITE_COUNT, |
47 VVI_R_INPUT_BUFFER_WRITE_COUNT, |
46 VVI_R_INPUT_BUFFER_MAX_TAIL, |
48 VVI_R_INPUT_BUFFER_MAX_TAIL, |
47 VVI_R_REQUEST_ID |
49 VVI_R_REQUEST_ID, |
|
50 VVI_R_SHARED_CMD_MEMORY_BASE, |
|
51 VVI_R_SHARED_FRAMEBUFFER_MEMORY_BASE, |
48 }; |
52 }; |
49 #define ASSERT_PANIC(c,p) __ASSERT_DEBUG(c,Kern::PanicCurrentThread(KVirtualVideoHwInterfacePanic,p)); |
53 #define ASSERT_PANIC(c,p) __ASSERT_DEBUG(c,Kern::PanicCurrentThread(KVirtualVideoHwInterfacePanic,p)); |
50 |
54 |
51 // ============================ LOCAL FUNCTIONS ================================ |
55 // ============================ LOCAL FUNCTIONS ================================ |
52 |
56 |
65 DVirtualVideoHwInterface::DVirtualVideoHwInterface() |
69 DVirtualVideoHwInterface::DVirtualVideoHwInterface() |
66 { |
70 { |
67 iInputParametersMemoryChunk = NULL; |
71 iInputParametersMemoryChunk = NULL; |
68 iOutputParametersMemoryChunk = NULL; |
72 iOutputParametersMemoryChunk = NULL; |
69 iRegisterMemoryChunk = NULL; |
73 iRegisterMemoryChunk = NULL; |
|
74 |
|
75 DVirtualVideoHwInterface::pVVHIf = this; |
|
76 |
|
77 Kern::Printf("DVirtualVideoHwInterface::DVirtualVideoHwInterface()>"); |
|
78 // Reserve a contiguous memory chunk for graphics usage |
|
79 TUint32 ramSize = VVI_PARAMETERS_INPUT_MEMORY_SIZE + |
|
80 VVI_PARAMETERS_OUTPUT_MEMORY_SIZE + |
|
81 VVI_FRAMEBUFFER_MEMORY_SIZE + |
|
82 VVI_REGISTERS_MEMORY_SIZE; |
|
83 TInt r = Epoc::AllocPhysicalRam( ramSize, iVideoRamPhys ); |
|
84 VVHW_TRACE("DVirtualVideoHwInterface::DVirtualVideoHwInterface() AllocPhysicalRam %d", r); |
|
85 if (r != KErrNone) |
|
86 { |
|
87 NKern::ThreadLeaveCS(); |
|
88 Kern::Fault("DVirtualVideoHwInterface Allocate Ram %d",r); |
|
89 } |
|
90 iFrameRamPhys = iVideoRamPhys + VVI_FRAMEBUFFER_BASE_ADDRESS; |
|
91 Kern::Printf("DVirtualVideoHwInterface::DVirtualVideoHwInterface()<"); |
70 } |
92 } |
71 |
93 |
72 |
94 |
73 // ----------------------------------------------------------------------------- |
95 // ----------------------------------------------------------------------------- |
74 // DVirtualVideoHwInterface::~DVirtualVideoHwInterface |
96 // DVirtualVideoHwInterface::~DVirtualVideoHwInterface |
102 NKern::ThreadLeaveCS(); |
124 NKern::ThreadLeaveCS(); |
103 } |
125 } |
104 |
126 |
105 TInt DVirtualVideoHwInterface::InitParametersInputMemory() |
127 TInt DVirtualVideoHwInterface::InitParametersInputMemory() |
106 { |
128 { |
107 return InitPhysicalMemory( VVI_PARAMETERS_INPUT_BASE_ADDRESS, |
129 TInt ret = InitPhysicalMemory( iVideoRamPhys + VVI_PARAMETERS_INPUT_BASE_ADDRESS, |
108 VVI_PARAMETERS_INPUT_MEMORY_SIZE, iInputParametersMemoryChunk, |
130 VVI_PARAMETERS_INPUT_MEMORY_SIZE, iInputParametersMemoryChunk, |
109 iInputParametersChunkKernelAddress ); |
131 iInputParametersChunkKernelAddress ); |
110 } |
132 Kern::Printf("DVirtualVideoHwInterface::InitParametersInputMemory - Base phy: 0x%08x lin: 0x%08x ret: %d", |
|
133 iVideoRamPhys + VVI_PARAMETERS_INPUT_BASE_ADDRESS, |
|
134 iInputParametersChunkKernelAddress, ret ); |
|
135 return ret; |
|
136 } |
111 |
137 |
112 TInt DVirtualVideoHwInterface::InitParametersOutputMemory() |
138 TInt DVirtualVideoHwInterface::InitParametersOutputMemory() |
113 { |
139 { |
114 return InitPhysicalMemory( VVI_PARAMETERS_OUTPUT_BASE_ADDRESS, |
140 TInt ret = InitPhysicalMemory( iVideoRamPhys + VVI_PARAMETERS_OUTPUT_BASE_ADDRESS, |
115 VVI_PARAMETERS_OUTPUT_MEMORY_SIZE, iOutputParametersMemoryChunk, |
141 VVI_PARAMETERS_OUTPUT_MEMORY_SIZE, iOutputParametersMemoryChunk, |
116 iOutputParametersChunkKernelAddress ); |
142 iOutputParametersChunkKernelAddress ); |
|
143 Kern::Printf("DVirtualVideoHwInterface::InitParametersOutputMemory - Base phy: 0x%08x lin: 0x%08x ret: %d", |
|
144 iVideoRamPhys + VVI_PARAMETERS_OUTPUT_BASE_ADDRESS, |
|
145 iOutputParametersChunkKernelAddress, ret ); |
|
146 return ret; |
117 } |
147 } |
118 |
148 |
119 TInt DVirtualVideoHwInterface::InitRegisterMemory() |
149 TInt DVirtualVideoHwInterface::InitRegisterMemory() |
120 { |
150 { |
121 return InitPhysicalMemory( VVI_REGISTERS_BASE_ADDRESS, |
151 Kern::Printf(" DVirtualVideoHwInterface::InitRegisterMemory>"); |
122 VVI_REGISTERS_MEMORY_SIZE, iRegisterMemoryChunk, |
152 Kern::Printf("DVirtualVideoHwInterface::InitRegisterMemory - parameter base phy: 0x%08x", iVideoRamPhys ); |
123 iRegisterChunkKernelAddress ); |
153 SetSharedCmdMemBase( iVideoRamPhys ); |
|
154 Kern::Printf("DVirtualVideoHwInterface::InitRegisterMemory - frame buffer phy: 0x%08x", iFrameRamPhys ); |
|
155 SetSharedFramebufferMemBase( iFrameRamPhys ); |
|
156 |
|
157 Kern::Printf(" DVirtualVideoHwInterface::InitRegisterMemory<"); |
|
158 return 0; |
124 } |
159 } |
125 |
160 |
126 // ----------------------------------------------------------------------------- |
161 // ----------------------------------------------------------------------------- |
127 // DVirtualVideoHwInterface::InitPhysicalMemory |
162 // DVirtualVideoHwInterface::InitPhysicalMemory |
128 // ----------------------------------------------------------------------------- |
163 // ----------------------------------------------------------------------------- |
216 void DVirtualVideoHwInterface::IssueCommand( TUint32 aCommand ) |
251 void DVirtualVideoHwInterface::IssueCommand( TUint32 aCommand ) |
217 { |
252 { |
218 SetRegisterValue( ERegCommand, aCommand ); |
253 SetRegisterValue( ERegCommand, aCommand ); |
219 } |
254 } |
220 |
255 |
|
256 // DVirtualVideoHwInterface::SetSharedCmdMemBase |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 void DVirtualVideoHwInterface::SetSharedCmdMemBase( TUint32 aPhysicalAddress ) |
|
260 { |
|
261 VVHW_TRACE("DVirtualVideoHwInterface::SetSharedCmdMemBase 0x%08x", aPhysicalAddress); |
|
262 SetRegisterValue( ERegSharedCmdMemBase, aPhysicalAddress ); |
|
263 } |
|
264 |
|
265 void DVirtualVideoHwInterface::SetSharedFramebufferMemBase( TUint32 aPhysicalAddress ) |
|
266 { |
|
267 VVHW_TRACE("DVirtualVideoHwInterface::SetSharedFramebufferMemBase 0x%08x", aPhysicalAddress); |
|
268 SetRegisterValue( ERegSharedFramebufferMemBase, aPhysicalAddress ); |
|
269 } |
|
270 |
|
271 |
221 // ----------------------------------------------------------------------------- |
272 // ----------------------------------------------------------------------------- |
222 // DVirtualVideoHwInterface::GetRegisterValue |
273 // DVirtualVideoHwInterface::GetRegisterValue |
223 // ----------------------------------------------------------------------------- |
274 // ----------------------------------------------------------------------------- |
224 // |
275 // |
225 void DVirtualVideoHwInterface::GetRegisterValue( |
276 void DVirtualVideoHwInterface::GetRegisterValue( |
226 TRegister aRegister, |
277 TRegister aRegister, |
227 TUint32& aValue ) |
278 TUint32& aValue ) |
228 { |
279 { |
229 if ( iRegisterMemoryChunk ) |
280 if ( 1 /* iRegisterMemoryChunk */ ) // FAISALMEMON check this line of code with Jani. Can we get rid of it? |
230 { |
281 { |
231 TLinAddr offset = RegisterOffset( aRegister ); |
282 TLinAddr offset = RegisterOffset( aRegister ); |
232 TUint32* ptr = reinterpret_cast<TUint32*>( iRegisterChunkKernelAddress + offset ); |
283 // FAISALMEMON check this with Jani. Will the code still work for platsim or is this now syborg specific? |
233 aValue = *ptr; |
284 //TUint32* ptr = reinterpret_cast<TUint32*>( iRegisterChunkKernelAddress + offset ); |
|
285 //aValue = *ptr; |
|
286 aValue = ReadReg( KHwGraphicsRegBase, offset ); |
234 } |
287 } |
235 else |
288 else |
236 { |
289 { |
237 Kern::PanicCurrentThread( KVirtualVideoHwInterfacePanic, KErrNotReady ); |
290 Kern::PanicCurrentThread( KVirtualVideoHwInterfacePanic, KErrNotReady ); |
238 } |
291 } |
257 { |
310 { |
258 Kern::PanicCurrentThread( KVirtualVideoHwInterfacePanic, KErrNotReady ); |
311 Kern::PanicCurrentThread( KVirtualVideoHwInterfacePanic, KErrNotReady ); |
259 } |
312 } |
260 } |
313 } |
261 |
314 |
262 // TODO FAISALMEMON This is the first portion of the port of Jani's |
|
263 // Dynamic framebuffer base address code. Inspect this code, and also |
|
264 // put in the rest of the code. |
|
265 EXPORT_C TPhysAddr DVirtualVideoHwInterface::GetFrameBase() |
315 EXPORT_C TPhysAddr DVirtualVideoHwInterface::GetFrameBase() |
266 { |
316 { |
267 #ifdef FAISALMEMON_DONE_DYNAMIC_FRAMEBUFFER_PORT |
|
268 TPhysAddr ret = 0; |
317 TPhysAddr ret = 0; |
269 if(DVirtualVideoHwInterface::pVVHIf != NULL) |
318 if(DVirtualVideoHwInterface::pVVHIf != NULL) |
270 { |
319 { |
271 ret = DVirtualVideoHwInterface::pVVHIf->iFrameRamPhys; |
320 ret = DVirtualVideoHwInterface::pVVHIf->iFrameRamPhys; |
272 } |
321 } |
273 return ret; |
322 return ret; |
274 #else |
|
275 return 0; |
|
276 #endif |
|
277 } |
323 } |