kernel/eka/include/dispchannel.h
changeset 9 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 2008-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 // User side class definitions for GCE mode support.
       
    15 // This file contains declarations for the generic
       
    16 // screen display channel and APIs.
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file dispchannel.h
       
    22  @publishedPartner
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __DISPLAY_CHANNEL_H__
       
    27 #define __DISPLAY_CHANNEL_H__ 
       
    28 
       
    29 #include <e32cmn.h>
       
    30 #include <e32ver.h>
       
    31 #ifndef __KERNEL_MODE__
       
    32 #include <e32std.h>
       
    33 #endif
       
    34 
       
    35 _LIT(KDisplayDriverName,"displaychannel");
       
    36 
       
    37 // the defined versions to be used for macros, condititional complilation, etc. 
       
    38 
       
    39 // The major version number. MUST be a number in the range 0 to 127
       
    40 #define K_DISPLAY_CH_MAJOR_VERSION_NUMBER 1
       
    41 // The minor version number. MUST be a number in the range 0 to 99
       
    42 #define K_DISPLAY_CH_MINOR_VERSION_NUMBER 2
       
    43 // The build number. MUST be a number in the range 0 to 32,767
       
    44 #define K_DISPLAY_CH_BUILD_VERSION_NUMBER 1
       
    45 
       
    46 // legacy set of version constants
       
    47 const TInt KDisplayChMajorVersionNumber = K_DISPLAY_CH_MAJOR_VERSION_NUMBER;
       
    48 const TInt KDisplayChMinorVersionNumber = K_DISPLAY_CH_MINOR_VERSION_NUMBER;
       
    49 const TInt KDisplayChBuildVersionNumber = K_DISPLAY_CH_BUILD_VERSION_NUMBER;
       
    50 
       
    51 // the base version supported across all implementation
       
    52 const TInt KDisplayChMajorVersionNumberAlwaysSupported = 1;
       
    53 const TInt KDisplayChMinorVersionNumberAlwaysSupported = 0;
       
    54 const TInt KDisplayChBuildVersionNumberAlwaysSupported = 1;
       
    55 
       
    56 
       
    57 /*
       
    58     Generic display driver interface
       
    59 */
       
    60 class RDisplayChannel : public RBusLogicalChannel
       
    61 	{
       
    62 public:
       
    63 
       
    64 	typedef TInt  TPixelFormat;
       
    65 	typedef TUint TBufferId;
       
    66 	typedef TUint TPostCount;
       
    67 
       
    68     enum TDisplayRotation
       
    69          /** Used to communicate available rotations as a bit field and used to set a 
       
    70              particular rotation as a single value. Rotations are specified relative 
       
    71              to the normal physical orientation of the device.
       
    72          */
       
    73         {
       
    74             ERotationNormal    = 1,
       
    75             ERotation90CW      = 2,
       
    76             ERotation180       = 4,
       
    77             ERotation270CW     = 8,
       
    78             // v 1.1
       
    79             ERotationAll       = 0xF
       
    80         };
       
    81 
       
    82     // control messages
       
    83 	enum TControl
       
    84 		{
       
    85 		// v 1.0
       
    86 		ECtrlGetCaps = 0,
       
    87 		ECtrlIsSingleBuffered,
       
    88 		ECtrlGetDisplayInfo,
       
    89 		ECtrlOpen,
       
    90 		ECtrlClose,
       
    91 		ECtrlPostCompositionBuffer,
       
    92 		ECtrlPostLegacyBuffer,
       
    93 		ECtrlRegisterUserBuffer,
       
    94 		ECtrlDeregisterUserBuffer,
       
    95 		ECtrlPostCount,
       
    96 		ECtrlSetRotation,
       
    97 		ECtrlCurrentRotation,
       
    98 		ECtrlGetCompositionBufferInfo,
       
    99 		// intermediate version
       
   100 		ECtrlVersion,
       
   101 		// v 1.1
       
   102 		ECtrlNumberOfResolutions,
       
   103 		ECtrlGetResolutions,
       
   104 		ECtrlSetResolution,
       
   105 		ECtrlGetResolution,
       
   106 		ECtrlGetTwips,
       
   107 		ECtrlNumberOfPixelFormats,
       
   108 		ECtrlGetPixelFormats,
       
   109 		ECtrlSetBufferFormat,
       
   110 		ECtrlGetBufferFormat,
       
   111 		ECtrlNextPlaneOffset,
       
   112 		ECtrlNextLineOffset,
       
   113 		// v 1.2
       
   114 		ECtrlNextPlaneOffsetExtended,
       
   115 		ECtrlNextLineOffsetExtended,
       
   116 		ECtrlCreateUserBuffer
       
   117 		};
       
   118 
       
   119     // request messages
       
   120 	enum TRequest
       
   121 		{
       
   122 		EReqGetCompositionBuffer = 0,
       
   123 		EReqPostUserBuffer,
       
   124 		EReqWaitForPost,
       
   125 		// v 1.1
       
   126 		EReqWaitForDisplayConnect
       
   127 		};
       
   128 
       
   129     // corresponding cancel
       
   130     enum TCancel
       
   131     	{
       
   132            ECtrlCancelGetCompositionBuffer = 0,
       
   133 	       ECtrlCancelPostUserBuffer,
       
   134 	       ECtrlCancelWaitForPost,
       
   135 			// v 1.1
       
   136 	       ECtrlCancelWaitForDisplayConnect
       
   137 	       
       
   138     	};
       
   139 
       
   140     enum TPanic
       
   141     	{
       
   142             EWrongRequest,      // wrong request number from the user side
       
   143     		EReqAlreadyPending, // user asynchronous reques is already pending
       
   144     		EDriverNotReady,    // wrong operation mode
       
   145 			// v 1.1
       
   146     		EInvalidResolution,	// Negative resolution passed
       
   147     		ENullArgument,		// NULL argument passed
       
   148     	};
       
   149 
       
   150 public:		//structures used
       
   151 	
       
   152     // display channel configuration information per orientation
       
   153     class TOrientationSpecificInfo
       
   154     /** Used to communicate the display configuration for a particular orientation.
       
   155     */
       
   156         {
       
   157     public:
       
   158         TUint iWidth;               //the width of the display in pixels.
       
   159         TUint iHeight;              // the height of the display in pixels.
       
   160         TInt iOffsetBetweenLines;
       
   161         TUint32 reserved_0;        // reserved fields for future extension
       
   162         TUint32 reserved_1;
       
   163         TUint32 reserved_2;
       
   164         TUint32 reserved_3;
       
   165         TUint32 reserved_4;
       
   166         };
       
   167 
       
   168     // display channel info
       
   169     class TDisplayInfo
       
   170         {
       
   171     public:
       
   172 		enum { KMaxUserBuffers = 8 };
       
   173 		enum { KMaxRectangles = 4 };
       
   174         TUint iBitsPerPixel;
       
   175         TUint iRefreshRateHz;
       
   176         TUint iAvailableRotations;
       
   177         TPixelFormat iPixelFormat;
       
   178         TOrientationSpecificInfo iNormal;       // rotation of 0 or 180 degrees
       
   179         TOrientationSpecificInfo iFlipped;      // rotation of 90 or 270 degrees
       
   180         TUint iNumCompositionBuffers;
       
   181         TUint32 reserved_0;                     // reserved fields for future extension
       
   182         TUint32 reserved_1;
       
   183         TUint32 reserved_2;
       
   184         TUint32 reserved_3;
       
   185         TUint32 reserved_4;
       
   186         };
       
   187     
       
   188 	/** Defines a resolution setting, a combination of a size in pixels and the
       
   189 		rotations of that size that can be used. For consistency, the size is always
       
   190 		given in terms of ERotationNormal, regardless of whether that rotation is
       
   191 		supported or not.
       
   192 	 */
       
   193 	class TResolution
       
   194 		{	//Kernel mode makes use of agregate constructors
       
   195 	public:
       
   196 #ifndef __KERNEL_MODE__
       
   197 		inline TResolution(TSize aPixelSize,TSize aTwipsSize, TUint32 aFlags = ERotationNormal);
       
   198 #endif
       
   199 
       
   200 	public:
       
   201 		/** The physical display size in pixels with no rotation (i.e. ERotationNormal).
       
   202 		    See RDisplayChannel::SetResolution().
       
   203 		*/
       
   204 		TSize iPixelSize;
       
   205 		/** The physical display size in twips with no rotation (i.e. ERotationNormal).
       
   206 		    See RDisplayChannel::SetResolution().
       
   207 		*/
       
   208 		TSize iTwipsSize;
       
   209 		/** A bitwise combination of RDisplayChannel::TDisplayRotation values.
       
   210 		*/
       
   211 		TUint32 iFlags;
       
   212 #ifndef __KERNEL_MODE__
       
   213 	private:
       
   214 #endif
       
   215 		/** Reserved for extension and alignment.
       
   216 		*/
       
   217 		TUint32 reserved_0;
       
   218 		};
       
   219 
       
   220 	/**
       
   221 	  Defines the format of a buffer to be posted using PostCompositionBuffer(),
       
   222 	  PostLegacyBuffer() or PostUserBuffer().
       
   223 	 */
       
   224 	class TBufferFormat
       
   225 		{	//Kernel mode makes use of agregate constructors
       
   226 	public:
       
   227 #ifndef __KERNEL_MODE__
       
   228 		inline TBufferFormat(TSize aSize, TPixelFormat aPixelFormat);
       
   229 #endif
       
   230 	public:
       
   231 		/** The pixel dimensions of the buffer.
       
   232 		*/
       
   233 		TSize iSize;
       
   234 		/** The pixel format of the buffer.
       
   235 		*/
       
   236 		TPixelFormat iPixelFormat;
       
   237 #ifndef __KERNEL_MODE__
       
   238 	private:
       
   239 #endif
       
   240 		/** Reserved for extension and alignment
       
   241 		*/
       
   242 		TUint32 reserved_0;
       
   243 		};
       
   244 	
       
   245 	struct TBufferFormatContext
       
   246 		{
       
   247 #ifndef __KERNEL_MODE__
       
   248 		inline TBufferFormatContext(TResolution aResolution, TDisplayRotation aRotation, TInt aPlane);
       
   249 #endif
       
   250 		/** The resolution to be used when the buffer format is processed
       
   251 		*/
       
   252 		TResolution iResolution;
       
   253 		
       
   254 		/** The rotation to be used when the buffer format is processed
       
   255 		*/
       
   256 		TDisplayRotation iRotation;
       
   257 		
       
   258 		/** The plane number, starting at zero
       
   259 		*/
       
   260 		TInt iPlane;
       
   261 		};
       
   262 
       
   263 	inline static const TDesC& Name();
       
   264 	inline static TVersion VersionRequired(void);
       
   265 #ifndef __KERNEL_MODE__
       
   266 	// v1.0 methods
       
   267 	inline TInt Open(TUint aScreen);
       
   268 	inline void Close(void);
       
   269 	inline TInt	GetDisplayInfo(TDes8& aInfo);
       
   270 	inline TDisplayRotation CurrentRotation(void);
       
   271 	inline TInt GetCompositionBufferInfo(TUint aBufferIndex, RChunk& aChunk, TInt& aOffset);
       
   272 	inline void GetCompositionBuffer(TUint& aBufferIndex, TRequestStatus& aStatus);
       
   273 	inline void CancelGetCompositionBuffer(void);
       
   274 	inline TInt PostCompositionBuffer(const TRegionFix<TDisplayInfo::KMaxRectangles>* aRegion, TPostCount& aCount );
       
   275 	inline TInt	PostLegacyBuffer(const TRegionFix<TDisplayInfo::KMaxRectangles>* aRegion, TPostCount& aCount);
       
   276 	inline TInt RegisterUserBuffer(TBufferId& aBufferId, const RChunk& aChunk, TInt aOffset);
       
   277     inline void PostUserBuffer(TBufferId aBufferId, TRequestStatus& aStatus, const TRegionFix<TDisplayInfo::KMaxRectangles>* aRegion, TPostCount& aCount );
       
   278     inline void CancelPostUserBuffer(void);
       
   279     inline TInt DeregisterUserBuffer(TBufferId aBufferId);
       
   280     inline void WaitForPost(TPostCount aTPostCount, TRequestStatus& aStatus);
       
   281     inline void CancelWaitForPost(void);
       
   282     inline TInt SetRotation(TDisplayRotation aRotation, TBool& aDisplayConfigChanged);
       
   283     // added to v1.0
       
   284     inline TInt Version(TVersion& aVersion); 
       
   285     // v1.1 methods
       
   286 	inline void NotifyOnDisplayChange(TRequestStatus& aStatus);
       
   287 	inline void NotifyOnDisplayChangeCancel();
       
   288 	inline TInt NumberOfResolutions();
       
   289 	inline TInt GetResolutions(TDes8& aResolutions, TInt& aCount);
       
   290 	inline TInt SetResolution(const TSize& aRes);
       
   291 	inline TInt GetResolution(TSize& aSize);
       
   292 	inline TInt GetTwips(TSize& aTwips);
       
   293 	inline TInt NumberOfPixelFormats();
       
   294 	inline TInt GetPixelFormats(TDes8& aFormatsBuf, TInt& aCount);
       
   295 	inline TInt SetBufferFormat(const TBufferFormat& aBufferFormat);
       
   296 	inline TInt GetBufferFormat(TBufferFormat& aBufferFormat);
       
   297 	inline TInt NextPlaneOffset(const TBufferFormat& aBufferFormat, TInt aPlane);
       
   298 	inline TInt NextLineOffset(const TBufferFormat& aBufferFormat, TInt aPlane);
       
   299     // v1.2 methods
       
   300 	inline TInt NextPlaneOffset(const TBufferFormat& aBufferFormat, const TResolution& aResolution, TDisplayRotation aRotation, TInt aPlane);
       
   301 	inline TInt NextLineOffset(const TBufferFormat& aBufferFormat, const TResolution& aResolution, TDisplayRotation aRotation, TInt aPlane);
       
   302 #ifdef _DEBUG
       
   303 	inline TInt CreateUserBuffer(TBufferFormat& aBufferFormat, RChunk& aChunk);
       
   304 #endif // _DEBUG
       
   305 #endif
       
   306 	};
       
   307 
       
   308 #include <dispchannel.inl>
       
   309 
       
   310 #endif /* __DISPLAY_CHANNEL__ */
       
   311 
       
   312 // EOF