1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/display.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,363 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// os\kernelhwsrv\kernel\eka\include\drivers\display.h
1.18 +// Interface to LDD of the Display GCE driver
1.19 +// Kernel side definitions for the GCE driver
1.20 +//
1.21 +
1.22 +/**
1.23 + @file
1.24 + @internalTechnology
1.25 + @prototype
1.26 +*/
1.27 +
1.28 +
1.29 +#ifndef __DISPLAY_H__
1.30 +#define __DISPLAY_H__
1.31 +
1.32 +#include <videodriver.h>
1.33 +#include <dispchannel.h>
1.34 +#include <platform.h>
1.35 +#include <pixelformats.h>
1.36 +
1.37 +
1.38 +
1.39 +const TInt KDisplayLBMax = 2;
1.40 +const TInt KDisplayCBMax = 2;
1.41 +const TInt KDisplayUBMax = 8;
1.42 +
1.43 +
1.44 +const TInt KPendingReqArraySize = RDisplayChannel::EReqWaitForPost +1;
1.45 +
1.46 +const TInt KMaxQueuedRequests = 3;
1.47 +
1.48 +class DDisplayChannel;
1.49 +
1.50 +
1.51 +enum TBufferType
1.52 +{
1.53 + EBufferTypeLegacy = 0,
1.54 + EBufferTypeComposition,
1.55 + EBufferTypeUser,
1.56 +};
1.57 +
1.58 +
1.59 +enum TBufferState
1.60 +{
1.61 + EBufferFree = 0,
1.62 + EBufferCompose,
1.63 + EBufferPending,
1.64 + EBufferActive
1.65 +};
1.66 +
1.67 +
1.68 +typedef struct
1.69 +{
1.70 + TInt iType;
1.71 + TInt iBufferId;
1.72 + TBool iFree;
1.73 + TInt iHandle;
1.74 + TInt iSize;
1.75 + TUint32 iAddress;
1.76 + TUint32 iPhysicalAddress;
1.77 + TInt iOffset ;
1.78 + DChunk * iChunk ;
1.79 + TBufferState iState;
1.80 + TRequestStatus* iPendingRequest;
1.81 +
1.82 +} TBufferNode;
1.83 +
1.84 +
1.85 +/**
1.86 +An object encapsulating a request from the client(iOwningThread) to the GCE driver.
1.87 +*/
1.88 +typedef struct
1.89 +{
1.90 +
1.91 + /** The TClientRequest object associated with the request - used to signal completion of the request and pass back a
1.92 + completion code. */
1.93 + TClientRequest* iTClientReq;
1.94 +
1.95 + /** The thread which issued the request and which supplied the request status. */
1.96 + DThread* iOwningThread;
1.97 +
1.98 +} TRequestNode;
1.99 +
1.100 +
1.101 +
1.102 +class DDisplayPdd;
1.103 +
1.104 +
1.105 +/**
1.106 + Logical Channel factory class for 'Display Channel LDD'
1.107 +*/
1.108 +
1.109 +class DDisplayLddFactory : public DLogicalDevice
1.110 + {
1.111 +public:
1.112 + static DDisplayLddFactory* CreateInstance();
1.113 + ~DDisplayLddFactory();
1.114 + // Inherited from DLogicalDevice
1.115 + virtual TInt Install();
1.116 + virtual void GetCaps(TDes8& aDes) const;
1.117 + virtual TInt Create(DLogicalChannelBase*& aChannel);
1.118 + TBool IsUnitOpen(TInt aUnit);
1.119 + TInt SetUnitOpen(TInt aUnit,TBool aIsOpenSetting);
1.120 +private:
1.121 + DDisplayLddFactory();
1.122 +
1.123 +
1.124 +private:
1.125 + /** Mask to keep track of which units have a channel open on them. */
1.126 + TUint iUnitsOpenMask;
1.127 + /** A mutex to protect access to the unit info mask. */
1.128 + NFastMutex iUnitInfoMutex;
1.129 + };
1.130 +
1.131 +
1.132 +/**
1.133 + Logical Channel class for 'Display Channel LDD'
1.134 +*/
1.135 +class DDisplayLdd : public DLogicalChannel
1.136 + {
1.137 +
1.138 +public:
1.139 + // create one instance of this object
1.140 + static DDisplayLdd* CreateInstance();
1.141 + virtual ~DDisplayLdd();
1.142 + virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
1.143 + virtual void HandleMsg(TMessageBase* aMsg);
1.144 +
1.145 +private:
1.146 + DDisplayLdd();
1.147 +
1.148 +private:
1.149 + // Implementation for the differnt kinds of messages sent through RBusLogicalChannel
1.150 + TInt DoControl(TInt aFunction, TAny* a1, TAny* a2, DThread* aClient);
1.151 + TInt DoRequest(TInt aReqNo, TAny* a1, TAny* a2, TInt index, DThread* aClient);
1.152 + void DoCancel(TUint aMask);
1.153 +
1.154 + TInt SendRequest(TMessageBase* aMsg);
1.155 + TInt SendControl(TMessageBase* aMsg);
1.156 + TInt SendMsg(TMessageBase* aMsg);
1.157 +
1.158 + TBufferNode* FindUserBufferNode(TInt aBufferId);
1.159 + TInt CheckAndOpenUserBuffer(TBufferNode* aNode, TInt aHandle, TInt aOffset, DThread* aClient);
1.160 + TInt FreeUserBufferNode(TBufferNode* aNode);
1.161 +
1.162 + void CompleteRequest(DThread* aThread, TClientRequest*& aTClientReq, TInt aReason);
1.163 +
1.164 + DDisplayPdd * Pdd();
1.165 +
1.166 +public:
1.167 + virtual TInt RequestComplete(TInt aRequest, TInt );
1.168 +
1.169 +
1.170 +public:
1.171 +
1.172 + // display info
1.173 + RDisplayChannel::TDisplayInfo iLegacyInfo;
1.174 + RDisplayChannel::TDisplayInfo iDisplayInfo;
1.175 +
1.176 + // post counters
1.177 + RDisplayChannel::TPostCount iCurrentPostCount;
1.178 + RDisplayChannel::TPostCount iRequestedPostCount;
1.179 +
1.180 +
1.181 + DThread* iClient;
1.182 + TInt iUnit;
1.183 +
1.184 + // frame buffer nodes
1.185 + TBufferNode iLegacyBuffer[KDisplayLBMax];
1.186 + TBufferNode iCompositionBuffer[KDisplayCBMax];
1.187 + TBufferNode iUserBuffer[KDisplayUBMax];
1.188 +
1.189 + //pending queue for asynchronous requests
1.190 + TRequestNode iPendingReq[KPendingReqArraySize][KMaxQueuedRequests];
1.191 +
1.192 + //Queue of TClientRequest objects, one for each type of asynchronous request.
1.193 + TClientRequest* iClientRequest[KPendingReqArraySize][KMaxQueuedRequests];
1.194 +
1.195 + //The index in structures iPendingReq and iClientRequest that identifies the active TClientRequest object.
1.196 + //For each type of asynchronous request, iPendingIndex is the index of the active TClientRequest object
1.197 + //in iPendingReq
1.198 + TInt iPendingIndex[KPendingReqArraySize];
1.199 +
1.200 + // Protect access of iClientRequest
1.201 + DMutex * iClientRequestMutex;
1.202 +
1.203 +
1.204 + // current index
1.205 + TInt iLegacyBuffIdx;
1.206 + TInt iCompositionBuffIdx;
1.207 + TInt iUserBuffIdx;
1.208 +
1.209 +
1.210 + RDisplayChannel::TDisplayRotation iLegacyRotation;
1.211 + RDisplayChannel::TDisplayRotation iCurrentRotation;
1.212 +
1.213 +
1.214 + TBool iReady;
1.215 +
1.216 + /** Used in debug builds to track that all calls to DThread::Open() are balanced with a close before the driver closes. */
1.217 + TInt iThreadOpenCount;
1.218 +
1.219 + /** Used in debug builds to track the number of asynchronous requests that are queued is equal to the number of
1.220 + requests that are completed, before the driver closes.*/
1.221 + TInt iAsyncReqCount;
1.222 +
1.223 + /** Chunk used in UDEB only for testing user buffers. */
1.224 + DChunk* iChunk;
1.225 + };
1.226 +
1.227 +
1.228 + /**
1.229 + Display PDD base class with GCE support.
1.230 + */
1.231 +
1.232 +class DDisplayPdd : public DBase
1.233 + {
1.234 +
1.235 + public:
1.236 +
1.237 + /**
1.238 + Called by the LDD to handle the device specific part of switching to Legacy mode.
1.239 +
1.240 + @return KErrNone if successful; or one of the other system wide error codes.
1.241 + */
1.242 + virtual TInt SetLegacyMode()=0;
1.243 +
1.244 + /**
1.245 + Called by the LDD to handle the device specific part of switching to GCE mode.
1.246 +
1.247 + @return KErrNone if successful; or one of the other system wide error codes.
1.248 + */
1.249 + virtual TInt SetGceMode()=0;
1.250 +
1.251 + /**
1.252 + Called by the LDD to handle the device specific part of setting the rotation.
1.253 +
1.254 + @return KErrNone if successful; or one of the other system wide error codes.
1.255 + */
1.256 + virtual TInt SetRotation(RDisplayChannel::TDisplayRotation aRotation)=0;
1.257 +
1.258 + /**
1.259 + Called by the LDD to handle the device specific part of posting a User Buffer.
1.260 +
1.261 + @return KErrNone if successful; or one of the other system wide error codes.
1.262 + */
1.263 + virtual TInt PostUserBuffer(TBufferNode* aNode)=0;
1.264 +
1.265 + /**
1.266 + Called by the LDD to handle the device specific part of posting a Composition Buffer
1.267 +
1.268 + @return KErrNone if successful; or one of the other system wide error codes.
1.269 + */
1.270 + virtual TInt PostCompositionBuffer(TBufferNode* aNode)=0;
1.271 +
1.272 + /**
1.273 + Called by the LDD to handle the device specific part of posting the Legacy Buffuer
1.274 +
1.275 + @return KErrNone if successful; or one of the other system wide error codes.
1.276 + */
1.277 + virtual TInt PostLegacyBuffer()=0;
1.278 +
1.279 + /**
1.280 + Called by the LDD to handle device specific cleanup operations when a channel is closed.
1.281 +
1.282 + @return KErrNone if successful; or one of the other system wide error codes.
1.283 + */
1.284 + virtual TInt CloseMsg()=0;
1.285 +
1.286 + /**
1.287 + Called by the LDD to handle device specific initialisation tasks when a channel is opened.
1.288 +
1.289 + @param aUnit The screen/hardware unit number.
1.290 + @return KErrNone if successful; or one of the other system wide error codes.
1.291 + */
1.292 + virtual TInt CreateChannelSetup(TInt aUnit)=0;
1.293 +
1.294 + /**
1.295 + Called by the LDD in order to detect whether a post operation is pending. This type of
1.296 + information is specific to the actual physical device.
1.297 +
1.298 + @return ETrue if a Post operation is pending otherwise EFalse.
1.299 + */
1.300 + virtual TBool PostPending()=0;
1.301 +
1.302 + /**
1.303 + Called by the LDD to retrieve the DFC Queue created in the PDD.
1.304 +
1.305 + @param aUnit The screen/hardware unit number.
1.306 + @return A pointer to the TDfcQue object created in the PDD.
1.307 + */
1.308 + virtual TDfcQue* DfcQ(TInt aUnit)=0;
1.309 +
1.310 + /**
1.311 + Called by the PDD when an asynchronous request should be completed with a specific reason.
1.312 + (Just calls the LDD's RequestComplete method)
1.313 +
1.314 + @param aRequest Any value from the RDisplayChannel::TRequest enumeration.
1.315 + @param aReason Any valid error reason.
1.316 +
1.317 + @return KErrNone if successful; or one of the other system wide error codes.
1.318 + */
1.319 + inline TInt RequestComplete(TInt aRequest, TInt aReason );
1.320 +
1.321 +
1.322 +public:
1.323 + /**
1.324 + A pointer to the logical device driver's channel that owns this device.
1.325 + */
1.326 + DDisplayLdd *iLdd;
1.327 + /**
1.328 + Every post operation sets this flag to true in order to identify when
1.329 + the previsouly posted buffer is no longer in use by the display hardware.
1.330 + */
1.331 + TBool iPostFlag;
1.332 +
1.333 + };
1.334 +
1.335 +
1.336 +inline DDisplayPdd * DDisplayLdd::Pdd()
1.337 + { return (DDisplayPdd*) iPdd; }
1.338 +
1.339 +
1.340 +inline TInt DDisplayPdd::RequestComplete(TInt aRequest, TInt aReason)
1.341 + { return iLdd->RequestComplete(aRequest,aReason); }
1.342 +
1.343 +
1.344 +
1.345 +
1.346 +//#define _GCE_DISPLAY_DEBUG
1.347 +
1.348 +#ifdef _GCE_DISPLAY_DEBUG
1.349 +
1.350 +#define __DEBUG_PRINT(a) Kern::Printf(a)
1.351 +#define __DEBUG_PRINT2(a,b) Kern::Printf(a,b)
1.352 +#define __DEBUG_PRINT3(a,b,c) Kern::Printf(a,b,c)
1.353 +#define __DEBUG_PRINT4(a,b,c,d) Kern::Printf(a,b,c,d)
1.354 +#define __DEBUG_PRINT5(a,b,c,d,e) Kern::Printf(a,b,c,d,e)
1.355 +
1.356 +#else
1.357 +#define __DEBUG_PRINT(a)
1.358 +#define __DEBUG_PRINT2(a,b)
1.359 +#define __DEBUG_PRINT3(a,b,c)
1.360 +#define __DEBUG_PRINT4(a,b,c,d)
1.361 +#define __DEBUG_PRINT5(a,b,c,d,e)
1.362 +
1.363 +#endif
1.364 +
1.365 +
1.366 +#endif // __DISPLAY_H__