kernel/eka/include/drivers/display.h
changeset 0 a41df078684a
child 31 56f325a607ea
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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 // e32\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 /**
       
    21  @file
       
    22  @internalTechnology
       
    23  @prototype
       
    24 */
       
    25 
       
    26 
       
    27 #ifndef __DISPLAY_H__
       
    28 #define __DISPLAY_H__
       
    29 
       
    30 #include <videodriver.h>
       
    31 #include <dispchannel.h>
       
    32 #include <platform.h>
       
    33 #include <pixelformats.h>
       
    34 
       
    35 
       
    36 
       
    37 const TInt KDisplayLBMax = 2;
       
    38 const TInt KDisplayCBMax = 2;
       
    39 const TInt KDisplayUBMax = 8;
       
    40 
       
    41 
       
    42 const TInt KPendingReqArraySize  = RDisplayChannel::EReqWaitForPost +1;
       
    43   
       
    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 	  /** The request status associated with the request - used to signal completion of the request and pass back a
       
    88 	   completion code. */
       
    89 	  TRequestStatus* 	iStatus;
       
    90 	  
       
    91 	  /** The thread which issued the request and which supplied the request status. */
       
    92 	  DThread* 			iOwningThread;
       
    93 	  
       
    94 } TRequestNode;
       
    95 
       
    96 
       
    97 
       
    98 class DDisplayPdd; 
       
    99 
       
   100 
       
   101 /**
       
   102   Logical Channel factory class for 'Display Channel LDD'
       
   103 */
       
   104 
       
   105 class DDisplayLddFactory : public DLogicalDevice
       
   106 	{
       
   107 public:
       
   108     static DDisplayLddFactory* CreateInstance();
       
   109 	~DDisplayLddFactory();
       
   110 	//	Inherited from DLogicalDevice
       
   111 	virtual TInt Install();
       
   112 	virtual void GetCaps(TDes8& aDes) const;
       
   113 	virtual TInt Create(DLogicalChannelBase*& aChannel);
       
   114 	TBool 	IsUnitOpen(TInt aUnit);
       
   115 	TInt 	SetUnitOpen(TInt aUnit,TBool aIsOpenSetting);
       
   116 private:
       
   117 	DDisplayLddFactory();
       
   118 	
       
   119 	
       
   120 private:
       
   121 	/** Mask to keep track of which units have a channel open on them. */
       
   122 	TUint iUnitsOpenMask;				
       
   123 	/** A mutex to protect access to the unit info mask. */
       
   124 	NFastMutex iUnitInfoMutex;	
       
   125 	};
       
   126 
       
   127 
       
   128 /**
       
   129   Logical Channel class for 'Display Channel LDD'
       
   130 */
       
   131 class DDisplayLdd : public DLogicalChannel 
       
   132 	{
       
   133 
       
   134 public:
       
   135     // create one instance of this object
       
   136 	static DDisplayLdd* CreateInstance();
       
   137 	virtual ~DDisplayLdd();
       
   138 	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
       
   139     virtual void HandleMsg(TMessageBase* aMsg);
       
   140 
       
   141 private:
       
   142 	DDisplayLdd();
       
   143 
       
   144 private:
       
   145 	// Implementation for the differnt kinds of messages sent through RBusLogicalChannel
       
   146 	TInt  			DoControl(TInt aFunction, TAny* a1, TAny* a2, DThread* aClient);
       
   147 	TInt  			DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2, DThread* aClient);
       
   148 	void  			DoCancel(TUint aMask);
       
   149            
       
   150        
       
   151     TBufferNode*  	FindUserBufferNode(TInt aBufferId);  
       
   152     TInt 			CheckAndOpenUserBuffer(TBufferNode* aNode, TInt aHandle, TInt aOffset, DThread* aClient);         
       
   153     TInt  			FreeUserBufferNode(TBufferNode* aNode);
       
   154     
       
   155     void 			CompleteRequest(DThread* aThread,TRequestStatus*& aStatus,TInt aReason);
       
   156           
       
   157     DDisplayPdd * 	Pdd();  
       
   158     	
       
   159 public: 	
       
   160  	virtual TInt 	RequestComplete(TInt aRequest, TInt );
       
   161 
       
   162 
       
   163 public:
       
   164               	    
       
   165     // display info
       
   166     RDisplayChannel::TDisplayInfo 	iLegacyInfo;
       
   167     RDisplayChannel::TDisplayInfo 	iDisplayInfo;
       
   168     
       
   169         // post counters
       
   170     RDisplayChannel::TPostCount   	iCurrentPostCount;
       
   171     RDisplayChannel::TPostCount   	iRequestedPostCount;
       
   172     
       
   173     
       
   174     DThread*    	iClient;	
       
   175 	TInt        	iUnit;      
       
   176     
       
   177     // frame buffer nodes
       
   178     TBufferNode 	iLegacyBuffer[KDisplayLBMax];
       
   179     TBufferNode 	iCompositionBuffer[KDisplayCBMax];
       
   180     TBufferNode 	iUserBuffer[KDisplayUBMax];
       
   181      
       
   182     //pending queue for asynchronous requests
       
   183     TRequestNode 	iPendingReq[KPendingReqArraySize];
       
   184      
       
   185     // current index
       
   186     TInt    		iLegacyBuffIdx;
       
   187 	TInt    		iCompositionBuffIdx;
       
   188     TInt    		iUserBuffIdx;
       
   189      
       
   190     // rotations
       
   191     TInt    		iLegacyRotation;
       
   192     TInt    		iCurrentRotation;
       
   193     
       
   194     TBool    		iReady;  
       
   195     
       
   196     /** Used in debug builds to track that all calls to DThread::Open() are balanced with a close before the driver closes. */
       
   197 	TInt iThreadOpenCount; 
       
   198      
       
   199 	};
       
   200 
       
   201 
       
   202  /**
       
   203     Display PDD base class with GCE support.
       
   204    */
       
   205 
       
   206 class DDisplayPdd : public DBase
       
   207 	{
       
   208 
       
   209 	public:
       
   210     
       
   211   	/**  
       
   212     Called by the LDD to handle the device specific part of switching to Legacy mode.
       
   213  
       
   214 	@return KErrNone if successful; or one of the other system wide error codes.
       
   215     */    
       
   216     virtual TInt  SetLegacyMode()=0;
       
   217         
       
   218      /**
       
   219      Called by the LDD to handle the device specific part of switching to GCE mode.
       
   220      
       
   221      @return KErrNone if successful; or one of the other system wide error codes.
       
   222      */       
       
   223     virtual TInt  SetGceMode()=0;
       
   224     
       
   225      /**
       
   226      Called by the LDD to handle the device specific part of setting the rotation.
       
   227      
       
   228      @return KErrNone if successful; or one of the other system wide error codes.
       
   229      */       
       
   230     virtual TInt  SetRotation(TInt aRotation)=0;
       
   231 
       
   232      /**
       
   233      Called by the LDD to handle the device specific part of posting a User Buffer.
       
   234      
       
   235      @return KErrNone if successful; or one of the other system wide error codes.
       
   236      */ 	
       
   237 	virtual TInt  PostUserBuffer(TBufferNode* aNode)=0;
       
   238 	
       
   239      /**
       
   240      Called by the LDD to handle the device specific part of posting a Composition Buffer
       
   241      
       
   242      @return KErrNone if successful; or one of the other system wide error codes.
       
   243      */ 		
       
   244 	virtual TInt  PostCompositionBuffer(TBufferNode* aNode)=0;
       
   245         
       
   246      /**
       
   247      Called by the LDD to handle the device specific part of posting the Legacy Buffuer
       
   248      
       
   249      @return KErrNone if successful; or one of the other system wide error codes.
       
   250      */   
       
   251     virtual TInt  PostLegacyBuffer()=0;
       
   252     
       
   253     /**
       
   254      Called by the LDD to handle device specific cleanup operations when a channel is closed.
       
   255           
       
   256      @return KErrNone if successful; or one of the other system wide error codes.
       
   257      */  
       
   258     virtual TInt  CloseMsg()=0;
       
   259             
       
   260      /**
       
   261      Called by the LDD to handle device specific initialisation tasks when a channel is opened.
       
   262      
       
   263      @param aUnit The screen/hardware unit number.
       
   264      @return KErrNone if successful; or one of the other system wide error codes.
       
   265      */    
       
   266     virtual TInt  CreateChannelSetup(TInt aUnit)=0;
       
   267           
       
   268      /**
       
   269      Called by the LDD in order to detect whether a post operation is pending. This type of 
       
   270      information is specific to the actual physical device.
       
   271      
       
   272      @return ETrue if a Post operation is pending otherwise EFalse.
       
   273      */       
       
   274    	virtual TBool  PostPending()=0;
       
   275     
       
   276     /**
       
   277      Called by the LDD to retrieve the DFC Queue created in the PDD.      
       
   278      
       
   279      @param aUnit The screen/hardware unit number.
       
   280      @return A pointer to the TDfcQue object created in the PDD.
       
   281      */    
       
   282     virtual TDfcQue* DfcQ(TInt  aUnit)=0;    
       
   283             
       
   284      /**
       
   285      Called by the PDD when an asynchronous request should be completed with a specific reason.
       
   286      (Just calls the LDD's RequestComplete method)
       
   287      
       
   288       @param aRequest Any value from the RDisplayChannel::TRequest enumeration.
       
   289       @param aReason  Any valid error reason.
       
   290       
       
   291       @return KErrNone if successful; or one of the other system wide error codes.
       
   292      */
       
   293     inline TInt RequestComplete(TInt aRequest, TInt aReason );
       
   294     
       
   295 
       
   296 public:        
       
   297   	/**
       
   298     A pointer to the logical device driver's channel that owns this device.
       
   299     */        
       
   300     DDisplayLdd *iLdd;
       
   301     /**
       
   302 	Every post operation sets this flag to true in order to identify when
       
   303 	the previsouly posted buffer is no longer in use by the display hardware. 
       
   304     */ 
       
   305 	TBool		 iPostFlag;
       
   306            
       
   307 	};
       
   308 
       
   309 
       
   310 inline DDisplayPdd * DDisplayLdd::Pdd()
       
   311     { return (DDisplayPdd*) iPdd; }
       
   312 
       
   313 
       
   314 inline TInt DDisplayPdd::RequestComplete(TInt aRequest, TInt aReason)
       
   315 	{ return iLdd->RequestComplete(aRequest,aReason); }
       
   316 
       
   317 
       
   318 
       
   319 //#define _GCE_DISPLAY_DEBUG
       
   320 
       
   321 #ifdef _GCE_DISPLAY_DEBUG
       
   322 
       
   323 #define  __DEBUG_PRINT(a) 		Kern::Printf(a)
       
   324 #define  __DEBUG_PRINT2(a,b) 	Kern::Printf(a,b)
       
   325 
       
   326 #else
       
   327 
       
   328 #define  __DEBUG_PRINT(a)
       
   329 #define  __DEBUG_PRINT2(a,b)
       
   330 
       
   331 #endif
       
   332 
       
   333 
       
   334 #endif	// __DISPLAY_H__