|
1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #ifndef VIRTUALVIDEOHWINTERFACE_H |
|
18 #define VIRTUALVIDEOHWINTERFACE_H |
|
19 |
|
20 #include <kernel/kernel.h> |
|
21 #include <internal/trace_utils.h> |
|
22 #include <graphics/guestvideodriverinterfaceconstants.h> |
|
23 |
|
24 /** |
|
25 * Class that encapsulates the Virtual Video Hw interface behind a function |
|
26 * interface. Intended to be instantiated only once in the device driver. |
|
27 */ |
|
28 class DVirtualVideoHwInterface : public DBase |
|
29 { |
|
30 public: // Data types |
|
31 |
|
32 /** |
|
33 * Enumeration for different interrupts. |
|
34 */ |
|
35 enum TInterrupt |
|
36 { |
|
37 EInterruptNewDataAvailable = 0x01 ///< Video HW has new data available |
|
38 }; |
|
39 /** |
|
40 * Enumeration for different registers. |
|
41 */ |
|
42 enum TRegister |
|
43 { |
|
44 ERegId, ///< Id register |
|
45 ERegIrqEnable, ///< IRQ enabling register |
|
46 ERegIrqStatus, ///< IRQ status register |
|
47 ERegCommand, ///< Command register |
|
48 ERegParameterLoad, |
|
49 ERegError, ///< |
|
50 ERegInputBufferTail, |
|
51 ERegInputBufferHead, |
|
52 ERegInputBufferReadCount, |
|
53 ERegInputBufferWriteCount, |
|
54 ERegInputBufferMaxTail, |
|
55 ERegRequestId, |
|
56 ENumRegisters ///< Number of registers |
|
57 |
|
58 }; |
|
59 |
|
60 public: // Construction and destruction |
|
61 |
|
62 /** |
|
63 * Constructor. |
|
64 */ |
|
65 DVirtualVideoHwInterface(); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 * NOTE: Enters and leaves critical section. |
|
70 */ |
|
71 virtual ~DVirtualVideoHwInterface(); |
|
72 |
|
73 public: // Functions |
|
74 |
|
75 |
|
76 /** |
|
77 * Initializes the Virtual Video HW's memory mapped I/O model. |
|
78 * NOTE: Enters and leaves critical section. |
|
79 * |
|
80 * @return System-wide error code |
|
81 */ |
|
82 TInt InitParametersInputMemory(); |
|
83 TInt InitParametersOutputMemory(); |
|
84 |
|
85 /** |
|
86 * Enables interrupts in the Virtual Video HW. |
|
87 * |
|
88 * @param aChannel The channel, whose interrupts are enabled |
|
89 * @param aInterruptBitField A bitmask of TInterrupt enumeration. |
|
90 * Enabled interrupt bits should be set to 1 and disabled interrupt |
|
91 * bits to 0. |
|
92 */ |
|
93 void EnableInterrupts( TUint32 aInterruptBitField ); |
|
94 |
|
95 /** |
|
96 * Initializes the Virtual Video HW's memory mapped I/O model. |
|
97 * NOTE: Enters and leaves critical section. |
|
98 * |
|
99 * @return System-wide error code |
|
100 */ |
|
101 TInt InitRegisterMemory(); |
|
102 /** |
|
103 * Retrieves interrupt enabled state in the Virtual Video HW. |
|
104 * |
|
105 * @param aChannel The channel, whose interrupt states are queried |
|
106 * @param aInterruptBitField A reference parameter, where a bitmask of |
|
107 * TInterrupt enumeration will be written. Enabled interrupt bits |
|
108 * are set to 1 and disabled interrupt bits to 0. |
|
109 */ |
|
110 void GetInterruptEnabledState( TUint32& aInterruptBitField ); |
|
111 |
|
112 /** |
|
113 * Retrieves interrupt status in the Virtual Video HW. |
|
114 * |
|
115 * @param aChannel The channel, whose interrupt status is queried |
|
116 * @param aInterruptBitField A reference parameter, where a bitmask of |
|
117 * TInterrupt enumeration will be written. Those interrupt lines |
|
118 * are active, whose bits are set to 1 in the bitmask. |
|
119 */ |
|
120 void GetInterruptStatus( TUint32& aInterruptBitField ); |
|
121 |
|
122 /** |
|
123 * Resets interrupt status in the Virtual Video HW. |
|
124 * |
|
125 * @param aChannel The channel, whose interrupt statuses are being reset |
|
126 * @param aInterruptBitField The bitmask of TInterrupt enumeration. Those |
|
127 * interrupts are reset, whose bits are set to 1 in the bitfield. |
|
128 */ |
|
129 void ResetInterruptStatus( TUint32 aInterruptBitField ); |
|
130 |
|
131 /** |
|
132 * Issues a command to the Virtual Video HW. |
|
133 * |
|
134 * @param aCommand One of TCommand enumeration commands. |
|
135 */ |
|
136 void IssueCommand( TUint32 aCommand ); |
|
137 |
|
138 /** |
|
139 * Address to input parameter buffer |
|
140 */ |
|
141 TLinAddr InputParametersAddress(){ return iInputParametersChunkKernelAddress; } |
|
142 |
|
143 /** |
|
144 * Address to output parameter buffer |
|
145 */ |
|
146 TLinAddr OutputParametersAddress(){ return iOutputParametersChunkKernelAddress; } |
|
147 |
|
148 |
|
149 /** |
|
150 * Gets a register value. |
|
151 * |
|
152 * @param aRegisterRange The register range |
|
153 * @param aRegister The register in the given register range, whose value is being read |
|
154 * @param aValue A reference parameter, where the register's value is written |
|
155 */ |
|
156 void GetRegisterValue( |
|
157 TRegister aRegister, |
|
158 TUint32& aValue ); |
|
159 |
|
160 /** |
|
161 * Sets a register value. |
|
162 * |
|
163 * @param aRegisterRange The register range |
|
164 * @param aRegister The register in the given register range, whose value is being written |
|
165 * @param aValue A new value to be written into register |
|
166 */ |
|
167 void SetRegisterValue( TRegister aRegister, |
|
168 TUint32 aValue ); |
|
169 |
|
170 public: |
|
171 IMPORT_C static TPhysAddr GetFrameBase(); |
|
172 |
|
173 protected: |
|
174 |
|
175 /** |
|
176 * Maps a virtual address range to physical address space |
|
177 * |
|
178 * @param aPhysicalAddress |
|
179 * @param aMaxSize |
|
180 * @param aChunk |
|
181 * @param aLinAddr |
|
182 * @return System wide error code |
|
183 */ |
|
184 TInt InitPhysicalMemory( TUint32 aPhysicalAddress, |
|
185 TInt aMaxSize, DChunk*& aChunk, TLinAddr& aLinAddr ); |
|
186 |
|
187 private: // Data |
|
188 |
|
189 /// A memory chunk that is mapped to the Virtual Video HW's physical memory area |
|
190 DChunk* iRegisterMemoryChunk; |
|
191 /// The virtual start address of the Virtual Video HW's memory map |
|
192 TLinAddr iRegisterChunkKernelAddress; |
|
193 |
|
194 /// A memory chunk that is mapped to the Virtual Video HW's physical memory area |
|
195 DChunk* iInputParametersMemoryChunk; |
|
196 /// The virtual start address of the Virtual Video HW's memory map |
|
197 TLinAddr iInputParametersChunkKernelAddress; |
|
198 |
|
199 /// A memory chunk that is mapped to the Virtual Video HW's physical memory area |
|
200 DChunk* iOutputParametersMemoryChunk; |
|
201 /// The virtual start address of the Virtual Video HW's memory map |
|
202 TLinAddr iOutputParametersChunkKernelAddress; |
|
203 |
|
204 }; |
|
205 |
|
206 |
|
207 #endif // VIRTUALVIDEOHWINTERFACE_H |