|
1 // Copyright (c) 1998-2009 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 the License "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 // os\kernelhwsrv\kernel\eka\include\drivers\display.h |
|
15 // Interface to LDD of the Display GCE driver |
|
16 // Kernel side definitions for the GCE driver |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 @prototype |
|
23 */ |
|
24 |
|
25 |
|
26 #ifndef __DISPLAY_H__ |
|
27 #define __DISPLAY_H__ |
|
28 |
|
29 #include <videodriver.h> |
|
30 #include <dispchannel.h> |
|
31 #include <platform.h> |
|
32 #include <pixelformats.h> |
|
33 |
|
34 |
|
35 |
|
36 const TInt KDisplayLBMax = 2; |
|
37 const TInt KDisplayCBMax = 2; |
|
38 const TInt KDisplayUBMax = 8; |
|
39 |
|
40 |
|
41 const TInt KPendingReqArraySize = RDisplayChannel::EReqWaitForPost +1; |
|
42 |
|
43 const TInt KMaxQueuedRequests = 3; |
|
44 |
|
45 class DDisplayChannel; |
|
46 |
|
47 |
|
48 enum TBufferType |
|
49 { |
|
50 EBufferTypeLegacy = 0, |
|
51 EBufferTypeComposition, |
|
52 EBufferTypeUser, |
|
53 }; |
|
54 |
|
55 |
|
56 enum TBufferState |
|
57 { |
|
58 EBufferFree = 0, |
|
59 EBufferCompose, |
|
60 EBufferPending, |
|
61 EBufferActive |
|
62 }; |
|
63 |
|
64 |
|
65 typedef struct |
|
66 { |
|
67 TInt iType; |
|
68 TInt iBufferId; |
|
69 TBool iFree; |
|
70 TInt iHandle; |
|
71 TInt iSize; |
|
72 TUint32 iAddress; |
|
73 TUint32 iPhysicalAddress; |
|
74 TInt iOffset ; |
|
75 DChunk * iChunk ; |
|
76 TBufferState iState; |
|
77 TRequestStatus* iPendingRequest; |
|
78 |
|
79 } TBufferNode; |
|
80 |
|
81 |
|
82 /** |
|
83 An object encapsulating a request from the client(iOwningThread) to the GCE driver. |
|
84 */ |
|
85 typedef struct |
|
86 { |
|
87 |
|
88 /** The TClientRequest object associated with the request - used to signal completion of the request and pass back a |
|
89 completion code. */ |
|
90 TClientRequest* iTClientReq; |
|
91 |
|
92 /** The thread which issued the request and which supplied the request status. */ |
|
93 DThread* iOwningThread; |
|
94 |
|
95 } TRequestNode; |
|
96 |
|
97 |
|
98 |
|
99 class DDisplayPdd; |
|
100 |
|
101 |
|
102 /** |
|
103 Logical Channel factory class for 'Display Channel LDD' |
|
104 */ |
|
105 |
|
106 class DDisplayLddFactory : public DLogicalDevice |
|
107 { |
|
108 public: |
|
109 static DDisplayLddFactory* CreateInstance(); |
|
110 ~DDisplayLddFactory(); |
|
111 // Inherited from DLogicalDevice |
|
112 virtual TInt Install(); |
|
113 virtual void GetCaps(TDes8& aDes) const; |
|
114 virtual TInt Create(DLogicalChannelBase*& aChannel); |
|
115 TBool IsUnitOpen(TInt aUnit); |
|
116 TInt SetUnitOpen(TInt aUnit,TBool aIsOpenSetting); |
|
117 private: |
|
118 DDisplayLddFactory(); |
|
119 |
|
120 |
|
121 private: |
|
122 /** Mask to keep track of which units have a channel open on them. */ |
|
123 TUint iUnitsOpenMask; |
|
124 /** A mutex to protect access to the unit info mask. */ |
|
125 NFastMutex iUnitInfoMutex; |
|
126 }; |
|
127 |
|
128 |
|
129 /** |
|
130 Logical Channel class for 'Display Channel LDD' |
|
131 */ |
|
132 class DDisplayLdd : public DLogicalChannel |
|
133 { |
|
134 |
|
135 public: |
|
136 // create one instance of this object |
|
137 static DDisplayLdd* CreateInstance(); |
|
138 virtual ~DDisplayLdd(); |
|
139 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
140 virtual void HandleMsg(TMessageBase* aMsg); |
|
141 |
|
142 private: |
|
143 DDisplayLdd(); |
|
144 |
|
145 private: |
|
146 // Implementation for the differnt kinds of messages sent through RBusLogicalChannel |
|
147 TInt DoControl(TInt aFunction, TAny* a1, TAny* a2, DThread* aClient); |
|
148 TInt DoRequest(TInt aReqNo, TAny* a1, TAny* a2, TInt index, DThread* aClient); |
|
149 void DoCancel(TUint aMask); |
|
150 |
|
151 TInt SendRequest(TMessageBase* aMsg); |
|
152 TInt SendControl(TMessageBase* aMsg); |
|
153 TInt SendMsg(TMessageBase* aMsg); |
|
154 |
|
155 TBufferNode* FindUserBufferNode(TInt aBufferId); |
|
156 TInt CheckAndOpenUserBuffer(TBufferNode* aNode, TInt aHandle, TInt aOffset, DThread* aClient); |
|
157 TInt FreeUserBufferNode(TBufferNode* aNode); |
|
158 |
|
159 void CompleteRequest(DThread* aThread, TClientRequest*& aTClientReq, TInt aReason); |
|
160 |
|
161 DDisplayPdd * Pdd(); |
|
162 |
|
163 public: |
|
164 virtual TInt RequestComplete(TInt aRequest, TInt ); |
|
165 |
|
166 |
|
167 public: |
|
168 |
|
169 // display info |
|
170 RDisplayChannel::TDisplayInfo iLegacyInfo; |
|
171 RDisplayChannel::TDisplayInfo iDisplayInfo; |
|
172 |
|
173 // post counters |
|
174 RDisplayChannel::TPostCount iCurrentPostCount; |
|
175 RDisplayChannel::TPostCount iRequestedPostCount; |
|
176 |
|
177 |
|
178 DThread* iClient; |
|
179 TInt iUnit; |
|
180 |
|
181 // frame buffer nodes |
|
182 TBufferNode iLegacyBuffer[KDisplayLBMax]; |
|
183 TBufferNode iCompositionBuffer[KDisplayCBMax]; |
|
184 TBufferNode iUserBuffer[KDisplayUBMax]; |
|
185 |
|
186 //pending queue for asynchronous requests |
|
187 TRequestNode iPendingReq[KPendingReqArraySize][KMaxQueuedRequests]; |
|
188 |
|
189 //Queue of TClientRequest objects, one for each type of asynchronous request. |
|
190 TClientRequest* iClientRequest[KPendingReqArraySize][KMaxQueuedRequests]; |
|
191 |
|
192 //The index in structures iPendingReq and iClientRequest that identifies the active TClientRequest object. |
|
193 //For each type of asynchronous request, iPendingIndex is the index of the active TClientRequest object |
|
194 //in iPendingReq |
|
195 TInt iPendingIndex[KPendingReqArraySize]; |
|
196 |
|
197 // Protect access of iClientRequest |
|
198 DMutex * iClientRequestMutex; |
|
199 |
|
200 |
|
201 // current index |
|
202 TInt iLegacyBuffIdx; |
|
203 TInt iCompositionBuffIdx; |
|
204 TInt iUserBuffIdx; |
|
205 |
|
206 |
|
207 RDisplayChannel::TDisplayRotation iLegacyRotation; |
|
208 RDisplayChannel::TDisplayRotation iCurrentRotation; |
|
209 |
|
210 |
|
211 TBool iReady; |
|
212 |
|
213 /** Used in debug builds to track that all calls to DThread::Open() are balanced with a close before the driver closes. */ |
|
214 TInt iThreadOpenCount; |
|
215 |
|
216 /** Used in debug builds to track the number of asynchronous requests that are queued is equal to the number of |
|
217 requests that are completed, before the driver closes.*/ |
|
218 TInt iAsyncReqCount; |
|
219 |
|
220 /** Chunk used in UDEB only for testing user buffers. */ |
|
221 DChunk* iChunk; |
|
222 }; |
|
223 |
|
224 |
|
225 /** |
|
226 Display PDD base class with GCE support. |
|
227 */ |
|
228 |
|
229 class DDisplayPdd : public DBase |
|
230 { |
|
231 |
|
232 public: |
|
233 |
|
234 /** |
|
235 Called by the LDD to handle the device specific part of switching to Legacy mode. |
|
236 |
|
237 @return KErrNone if successful; or one of the other system wide error codes. |
|
238 */ |
|
239 virtual TInt SetLegacyMode()=0; |
|
240 |
|
241 /** |
|
242 Called by the LDD to handle the device specific part of switching to GCE mode. |
|
243 |
|
244 @return KErrNone if successful; or one of the other system wide error codes. |
|
245 */ |
|
246 virtual TInt SetGceMode()=0; |
|
247 |
|
248 /** |
|
249 Called by the LDD to handle the device specific part of setting the rotation. |
|
250 |
|
251 @return KErrNone if successful; or one of the other system wide error codes. |
|
252 */ |
|
253 virtual TInt SetRotation(RDisplayChannel::TDisplayRotation aRotation)=0; |
|
254 |
|
255 /** |
|
256 Called by the LDD to handle the device specific part of posting a User Buffer. |
|
257 |
|
258 @return KErrNone if successful; or one of the other system wide error codes. |
|
259 */ |
|
260 virtual TInt PostUserBuffer(TBufferNode* aNode)=0; |
|
261 |
|
262 /** |
|
263 Called by the LDD to handle the device specific part of posting a Composition Buffer |
|
264 |
|
265 @return KErrNone if successful; or one of the other system wide error codes. |
|
266 */ |
|
267 virtual TInt PostCompositionBuffer(TBufferNode* aNode)=0; |
|
268 |
|
269 /** |
|
270 Called by the LDD to handle the device specific part of posting the Legacy Buffuer |
|
271 |
|
272 @return KErrNone if successful; or one of the other system wide error codes. |
|
273 */ |
|
274 virtual TInt PostLegacyBuffer()=0; |
|
275 |
|
276 /** |
|
277 Called by the LDD to handle device specific cleanup operations when a channel is closed. |
|
278 |
|
279 @return KErrNone if successful; or one of the other system wide error codes. |
|
280 */ |
|
281 virtual TInt CloseMsg()=0; |
|
282 |
|
283 /** |
|
284 Called by the LDD to handle device specific initialisation tasks when a channel is opened. |
|
285 |
|
286 @param aUnit The screen/hardware unit number. |
|
287 @return KErrNone if successful; or one of the other system wide error codes. |
|
288 */ |
|
289 virtual TInt CreateChannelSetup(TInt aUnit)=0; |
|
290 |
|
291 /** |
|
292 Called by the LDD in order to detect whether a post operation is pending. This type of |
|
293 information is specific to the actual physical device. |
|
294 |
|
295 @return ETrue if a Post operation is pending otherwise EFalse. |
|
296 */ |
|
297 virtual TBool PostPending()=0; |
|
298 |
|
299 /** |
|
300 Called by the LDD to retrieve the DFC Queue created in the PDD. |
|
301 |
|
302 @param aUnit The screen/hardware unit number. |
|
303 @return A pointer to the TDfcQue object created in the PDD. |
|
304 */ |
|
305 virtual TDfcQue* DfcQ(TInt aUnit)=0; |
|
306 |
|
307 /** |
|
308 Called by the PDD when an asynchronous request should be completed with a specific reason. |
|
309 (Just calls the LDD's RequestComplete method) |
|
310 |
|
311 @param aRequest Any value from the RDisplayChannel::TRequest enumeration. |
|
312 @param aReason Any valid error reason. |
|
313 |
|
314 @return KErrNone if successful; or one of the other system wide error codes. |
|
315 */ |
|
316 inline TInt RequestComplete(TInt aRequest, TInt aReason ); |
|
317 |
|
318 |
|
319 public: |
|
320 /** |
|
321 A pointer to the logical device driver's channel that owns this device. |
|
322 */ |
|
323 DDisplayLdd *iLdd; |
|
324 /** |
|
325 Every post operation sets this flag to true in order to identify when |
|
326 the previsouly posted buffer is no longer in use by the display hardware. |
|
327 */ |
|
328 TBool iPostFlag; |
|
329 |
|
330 }; |
|
331 |
|
332 |
|
333 inline DDisplayPdd * DDisplayLdd::Pdd() |
|
334 { return (DDisplayPdd*) iPdd; } |
|
335 |
|
336 |
|
337 inline TInt DDisplayPdd::RequestComplete(TInt aRequest, TInt aReason) |
|
338 { return iLdd->RequestComplete(aRequest,aReason); } |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 //#define _GCE_DISPLAY_DEBUG |
|
344 |
|
345 #ifdef _GCE_DISPLAY_DEBUG |
|
346 |
|
347 #define __DEBUG_PRINT(a) Kern::Printf(a) |
|
348 #define __DEBUG_PRINT2(a,b) Kern::Printf(a,b) |
|
349 #define __DEBUG_PRINT3(a,b,c) Kern::Printf(a,b,c) |
|
350 #define __DEBUG_PRINT4(a,b,c,d) Kern::Printf(a,b,c,d) |
|
351 #define __DEBUG_PRINT5(a,b,c,d,e) Kern::Printf(a,b,c,d,e) |
|
352 |
|
353 #else |
|
354 #define __DEBUG_PRINT(a) |
|
355 #define __DEBUG_PRINT2(a,b) |
|
356 #define __DEBUG_PRINT3(a,b,c) |
|
357 #define __DEBUG_PRINT4(a,b,c,d) |
|
358 #define __DEBUG_PRINT5(a,b,c,d,e) |
|
359 |
|
360 #endif |
|
361 |
|
362 |
|
363 #endif // __DISPLAY_H__ |