sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of the License "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: /**
sl@0:  @file dispchannel.inl
sl@0:  @publishedPartner
sl@0:  @released
sl@0: */
sl@0: 
sl@0: #ifndef __DISPCHANNEL_INL__
sl@0: #define __DISPCHANNEL_INL__
sl@0: 
sl@0: #include <dispchannel.h>
sl@0: 
sl@0: #ifndef __KERNEL_MODE__
sl@0: 
sl@0: /** Creates a connection to the DisplayChannel Driver logical device driver.
sl@0:     This handle will need to be closed by calling Close()
sl@0:     when the connection to the Display Driver is no longer required.
sl@0: 
sl@0:     @param aScreen  Identifies the screen this object will control
sl@0:     @return KErrNone if successful, otherwise one of the system-wide error codes.
sl@0: */
sl@0: inline TInt RDisplayChannel::Open(TUint aScreen)
sl@0: 	{
sl@0: 	TVersion versionAlwaysSupported(KDisplayChMajorVersionNumberAlwaysSupported,
sl@0:                                     KDisplayChMinorVersionNumberAlwaysSupported,
sl@0:                                     KDisplayChBuildVersionNumberAlwaysSupported);
sl@0: 	
sl@0:     TInt r = DoCreate(Name(), versionAlwaysSupported, aScreen, NULL, NULL);
sl@0: 	return r;
sl@0: 	}
sl@0: 
sl@0: /** The connection is closed and the driver reverts back to legacy behaviour,
sl@0:     i.e. Non-GCE mode where the legacy buffer is used as the screen output
sl@0: */
sl@0: inline void RDisplayChannel::Close(void)
sl@0: 	{
sl@0:   	RBusLogicalChannel::Close();
sl@0: 	}
sl@0: 
sl@0: /** Get the static details of the display-owned composition buffer(s).
sl@0:     These are used with the address returned by GetCompositionBuffer()
sl@0:     to describe the current composition buffer.
sl@0: 
sl@0:     The normal and flipped size information reflects the maximum direct access display resolution,
sl@0:     rather than the current resolution. The offset between lines remains constant,
sl@0:     regardless of current buffer format. See NextLineOffset() for specific buffer
sl@0:     format details.
sl@0: 
sl@0:     The available rotations indicates all the possible rotations, across all
sl@0:     resolutions, even if not all are supported in all cases.
sl@0: 
sl@0:     @see SetResolution
sl@0:     @see SetBufferFormat
sl@0:     @see NextLineOffset
sl@0: 
sl@0:     @param aInfo The static details of the composition buffer(s).
sl@0:     @return KErrNone if successful, otherwise one of the system-wide error codes.
sl@0: */
sl@0: inline TInt	RDisplayChannel::GetDisplayInfo(TDes8& aInfo)
sl@0: 	{
sl@0: 	return (DoControl(ECtrlGetDisplayInfo, &aInfo));
sl@0:     }
sl@0: 
sl@0: /** Return the access details for a composition buffer, opening a new handle to the chunk containing
sl@0:     the composition buffer.  Note that because all returned information is static, this function will
sl@0:     normally only be called called once for each composition buffer when the RDisplayChannel is opened.
sl@0: 
sl@0:     @param aBufferIndex  The index of a composition buffer.
sl@0:     @param aChunk A new open handle to chunk containing the composition buffer indexed by aBufferIndex.
sl@0:     @param aChunkOffset The offset from the base address of aChunk to the composition buffer indexed by aBufferIndex.
sl@0:     @return KErrNone if this command completed successfully, otherwise this is another of the system-wide error codes.
sl@0: */
sl@0: inline TInt RDisplayChannel::GetCompositionBufferInfo(TUint aBufferIndex, RChunk& aChunk, TInt& aOffset)
sl@0: 	{
sl@0: 	TInt arg[2] = {0,0};
sl@0: 	(DoControl(ECtrlGetCompositionBufferInfo, &aBufferIndex, &arg));
sl@0:     aChunk.SetHandle(arg[0]);
sl@0:     aOffset = arg[1];
sl@0: 	return KErrNone;
sl@0: 	}
sl@0: 
sl@0: /** Request the driver to identify a driver-owned composition buffer for the user to render into.
sl@0:     This may not be completed until the next display refresh if the system is implementing multi-buffering
sl@0:     and there are no composition buffers available immediately.
sl@0: 
sl@0:     @param  aBufferIndex On completion of aStatus, contains the buffer index of driver-owned buffer suitable
sl@0:     for client rendering.  The buffer access details can be retrieved by calling GetCompositionBufferInfo().
sl@0:     The remaining buffer attributes are described by GetDisplayInfo()
sl@0:     @param aStatus On completion, contains the status of the request. This is KErrNone if 
sl@0:     the system is multi-buffered and an available buffer was returned.  
sl@0:     This is KErrNone is the system is single-buffered and the primary buffer was returned.  
sl@0:     Otherwise this is another of the system-wide error codes.
sl@0: */
sl@0: inline void	RDisplayChannel::GetCompositionBuffer(TUint& aIndex, TRequestStatus& aStatus)
sl@0: 	{
sl@0: 	DoRequest(EReqGetCompositionBuffer, aStatus, (TAny*)&aIndex);
sl@0: 	}
sl@0: 
sl@0: /** Cancel the outstanding request to GetCompositionBuffer()
sl@0: */
sl@0: inline void	RDisplayChannel::CancelGetCompositionBuffer(void)
sl@0: 	{
sl@0: 	DoCancel(1<<ECtrlCancelGetCompositionBuffer);
sl@0: 	}
sl@0: 
sl@0: /** Tells the driver to queue a request to show the composition buffer on screen at the next display refresh.
sl@0: 
sl@0:     @param aRegion The region changed by the client.  The driver may choose to optimise posting using this
sl@0:     information or it may ignore it.  Up to KMaxRectangles rectangles can be specified.  If null, the whole buffer is used.
sl@0:     @param aPostCount This is an identifier returned by the driver for this Post request on exiting the method
sl@0: */
sl@0: inline TInt RDisplayChannel::PostCompositionBuffer(const TRegionFix<TDisplayInfo::KMaxRectangles>* aRegion, TPostCount& aCount)
sl@0: 	{
sl@0: 	return (DoControl(ECtrlPostCompositionBuffer, (TAny*)aRegion, &aCount));
sl@0: 	}
sl@0: 
sl@0: /** Request the driver to show the legacy buffer on screen at the next display refresh.
sl@0:     @param aPostCount This is an identifier returned by the driver for this Post request on exiting the method.
sl@0:     @return KErrNone if the request was queued successfully, otherwise this is another of the system-wide error codes.
sl@0: */
sl@0: inline TInt	RDisplayChannel::PostLegacyBuffer(const TRegionFix<TDisplayInfo::KMaxRectangles>* aRegion, TPostCount& aCount)
sl@0: 	{
sl@0: 	return (DoControl(ECtrlPostLegacyBuffer, (TAny*)aRegion, &aCount));
sl@0: 	}
sl@0: 
sl@0: /** Register a user-provided buffer for use by the driver.  This enables the user to subsequently post the buffer. 
sl@0:     The number of registered buffers will need to have a limit and this is set to KMaxUserBuffers.
sl@0: 
sl@0:     @param aBufferId Identifier to be used in the call to PostUserBuffer().
sl@0:     @param aChunk Chunk containing memory to be used by the driver.
sl@0:     @param aOffset Byte offset of the buffer from the chunk base.
sl@0:     @return KErrNone if the buffer has successfully registered.  
sl@0:     KErrTooBig if the number of registered buffers is at its limit when this call was made.  
sl@0:     Otherwise this is another of the system-wide error codes.
sl@0: */
sl@0: inline TInt RDisplayChannel::RegisterUserBuffer(TBufferId& aBufferId, const RChunk& aChunk, TInt aOffset)
sl@0: 	{
sl@0: 	TInt arg[2] = {aChunk.Handle(), aOffset};
sl@0: 	return (DoControl(ECtrlRegisterUserBuffer, arg, &aBufferId));
sl@0: 	}
sl@0: 
sl@0: /** Request the driver to show a buffer on screen at the next display refresh and notify the user when the buffer 
sl@0:     is no longer being displayed or has been dropped. Note that if two successive calls are made to PostUserBuffer() 
sl@0:     in between vertical sync pulses, the latest PostUserBuffer() call will supersede the previous call and will complete 
sl@0:     any outstanding request status object for that call with KErrCancel
sl@0: 
sl@0:     @param aBufferId Identifier representing a buffer.  Generated by a previous call to RegisterUserBuffer().
sl@0:     @param aStatus On completion the submitted buffer is no longer in use by the display hardware, unless the same 
sl@0:     buffer is posted a second time before it has completed. aStatus contains the status of the request. This is KErrNone 
sl@0:     if the request was executed successfully.  This is KErrCancel if this posting request was superseded by a more recent request.  
sl@0:     This is KErrArgument if aBufferId is not a registered buffer. Otherwise this is another of the system-wide error codes.
sl@0:     @param aRegion The region changed by the client.  The driver may choose to optimise posting using this information or it may ignore it.  
sl@0:     Up to KMaxRectangles rectangles can be specified.  If null, the whole buffer is used.
sl@0:     @param aPostCount This is an identifier returned by the driver for this Post request on exiting the method.
sl@0: */
sl@0: inline void RDisplayChannel::PostUserBuffer(TBufferId aBufferId, TRequestStatus& aStatus, const TRegionFix<TDisplayInfo::KMaxRectangles>* aRegion, TPostCount& aCount)
sl@0: 	{
sl@0: 	TInt arg[2] = {aBufferId, reinterpret_cast<const TInt>(aRegion)};
sl@0: 	DoRequest(EReqPostUserBuffer, aStatus, arg, &aCount);
sl@0: 	}
sl@0: 
sl@0: /** Cancel the outstanding request to PostUserBuffer
sl@0: */
sl@0: inline void RDisplayChannel::CancelPostUserBuffer(void)
sl@0: 	{
sl@0: 	DoCancel(1<<ECtrlCancelPostUserBuffer);
sl@0: 	}
sl@0: 
sl@0: /** Deregister a previously registered buffer.
sl@0: 
sl@0:     @param aBufferId Identifier for a previously registered buffer, generated by a call to RegisterUserBuffer().
sl@0:     @return KErrNone if successful, KErrArgument if the token is not recognised, KErrInUse if the buffer is still in use,
sl@0: */
sl@0: inline TInt RDisplayChannel::DeregisterUserBuffer(TBufferId aBufferId)
sl@0: 	{
sl@0: 	return (DoControl(ECtrlDeregisterUserBuffer, (TAny*)&aBufferId));
sl@0: 	}
sl@0: 
sl@0: /** This function allows the caller to be notified when a specified post either gets displayed or dropped.
sl@0:     Completes when a specified post request either gets displayed or dropped.  
sl@0:     Used to determine timing information for when a particular frame was displayed.
sl@0: 
sl@0:     @param aPostCount An identifier representing a particular post request obtained from PostUserBuffer().
sl@0:     @param aStatus On completion, contains the status of the request. This is KErrNone if the post request was 
sl@0:     valid and was either displayed or dropped.  If aPostCount is less than the current count then this will complete 
sl@0:     immediately with KErrNone. Otherwise this is another of the system-wide error codes.
sl@0: */
sl@0: inline void RDisplayChannel::WaitForPost(TPostCount aPostCount, TRequestStatus& aStatus)
sl@0: 	{
sl@0:     DoRequest(EReqWaitForPost, aStatus, &aPostCount);
sl@0: 	}
sl@0: 
sl@0: /** Cancel the outstanding request to WaitForPost().
sl@0: */
sl@0: inline void RDisplayChannel::CancelWaitForPost(void)
sl@0: 	{
sl@0: 	DoCancel(1<<ECtrlCancelWaitForPost);
sl@0: 	}
sl@0: 
sl@0: /** Ensures that the next post request will be displayed using the requested rotation.
sl@0: 
sl@0:     @param aRotation A specific rotation value.
sl@0:     @param aDisplayConfigChanged Returns ETrue if the composition buffer is now using an alternative 
sl@0:     (either Normal or Flipped) orientation following this call.
sl@0:     @return KErrNone if rotation can be achieved.  KErrNotSupported if the requested rotation is not supported. 
sl@0:     Otherwise this is another of the system-wide error codes.
sl@0: */
sl@0: inline TInt RDisplayChannel::SetRotation(TDisplayRotation aRotation, TBool& aDisplayConfigChanged)
sl@0: 	{
sl@0: 	aDisplayConfigChanged = EFalse;
sl@0: 	return (DoControl(ECtrlSetRotation, &aRotation, &aDisplayConfigChanged));
sl@0: 	}
sl@0: 
sl@0: /** Return the current rotation setting of the display.
sl@0: */
sl@0: inline RDisplayChannel::TDisplayRotation RDisplayChannel::CurrentRotation(void)
sl@0: 	{
sl@0:     TDisplayRotation rotation = ERotationNormal;
sl@0:     DoControl(ECtrlCurrentRotation, &rotation);
sl@0:     return rotation;
sl@0: 	}
sl@0: 
sl@0: /** Asynchronous request for notification of when a display change occurs.
sl@0:     The request is completed when the connectedness of the display changes, or when
sl@0:     the set of available resolutions or pixel formats changes.
sl@0:     
sl@0:     If a failure occurs, it is passed back in the aStatus.
sl@0: 
sl@0:     @panic DISPCHAN KNotificationAlreadySet if a notification request is pending.
sl@0:     @param aStatus    Completed on display change, or cancellation.
sl@0: */
sl@0: inline void RDisplayChannel::NotifyOnDisplayChange(TRequestStatus& aStatus)
sl@0: 	{
sl@0: 	DoRequest(EReqWaitForDisplayConnect, aStatus);
sl@0: 	}
sl@0: 
sl@0: /** Cancels a pending request to notify on display change.
sl@0: 
sl@0:     If there is a pending notification request, the status value will be set to
sl@0:     KErrCancelled and it will be completed. If there is no pending request for
sl@0:     notification, the call will simply return.
sl@0: */
sl@0: inline void RDisplayChannel::NotifyOnDisplayChangeCancel()
sl@0: 	{
sl@0: 	DoCancel(1<<ECtrlCancelWaitForDisplayConnect);
sl@0: 	}
sl@0: 
sl@0: /** Returns the number of display resolutions currently available.
sl@0: 
sl@0:     This is the maximum number of resolutions that can currently be retrieved using
sl@0:     GetResolutions() and set using a combination of SetResolution() and
sl@0:     SetRotation().
sl@0:     When no display is connected, there shall be a single entry.
sl@0:     
sl@0:     @return The number of TResolution elements that can be retrieved using
sl@0:     GetResolutions().
sl@0: */
sl@0: inline TInt RDisplayChannel::NumberOfResolutions()  
sl@0: 	{
sl@0: 	return (DoControl(ECtrlNumberOfResolutions));
sl@0: 	}
sl@0: 
sl@0: /** Retrieves the resolutions that are currently available.
sl@0: 
sl@0:     If the given buffer is large enough to hold them all, the set of available
sl@0:     resolutions shall be written to it as a contiguous sequence of TResolution
sl@0:     elements. aCount shall be set to the number of TResolution elements written and
sl@0:     the length of the buffer shall be set to the total number of bytes written.
sl@0: 
sl@0:     If a display can be disabled or become disconnected, the list shall include the
sl@0:     size (0,0). If the display is connected but disabled, the list shall also
sl@0:     include the other supported resolutions. If a display cannot be disconnected or
sl@0:     disabled, the list shall not include (0,0).
sl@0: 
sl@0:     @return KErrNone on success, KErrOverflow if the buffer is not large enough, or
sl@0:     KErrNotSupported if not supported by driver..
sl@0:     @param aResolutions    Buffer to receive resolutions, as a contiguous sequence
sl@0:     of TResolution elements.
sl@0:     @param aCount    The number of TResolution elements written to the buffer.
sl@0: */
sl@0: inline TInt RDisplayChannel::GetResolutions(TDes8& aResolutions, TInt& aCount)  
sl@0: 	{
sl@0: 	return (DoControl(ECtrlGetResolutions,&aResolutions,&aCount));
sl@0: 	}
sl@0: 
sl@0: /** Sets the display's new pixel resolution.
sl@0: 
sl@0:     The resolution shall be in terms of no rotation (ERotationNormal), but the
sl@0:     actual display output will depend on the current Rotation() value.
sl@0: 
sl@0:     A successful call to this function may change any of the other attributes of
sl@0:     the display channel. The change to the attributes happens immediately, but the
sl@0:     change to the display output will only take place on the next buffer posting.
sl@0: 
sl@0:     It is recommended that the implementation tries to minimize changes to other
sl@0:     attributes, if possible. For example, if the current rotation is set to
sl@0:     ERotation90CW and the new resolution supports that rotation, it should remain
sl@0:     as the current rotation. On the other hand, if the new resolution does not
sl@0:     support that rotation, it must be changed to a supported one.
sl@0: 
sl@0:     If (0,0) is in the resolution list, passing a zero width and/or zero height
sl@0:     resolution shall select it, and shall have the effect of disabling output.
sl@0: 
sl@0:     If either dimension of the given resolution is negative, KErrArgument shall be
sl@0:     returned. If the parameter is valid, but not currently available,
sl@0:     KErrNotSupported shall be returned.
sl@0: 
sl@0:     @see GetResolutions
sl@0:     @capability WriteDeviceData Used to prevent arbitrary changes to the display
sl@0:     resolution.
sl@0:     @param aRes    The new display resolution.
sl@0:     @return KErrNone on success. KErrNotSupported, KErrOutOfMemory or KErrArgument
sl@0:     on failure.
sl@0: */
sl@0: inline TInt RDisplayChannel::SetResolution(const TSize& aRes)
sl@0: 	{
sl@0: 	return (DoControl(ECtrlSetResolution,const_cast<TSize*>(&aRes)));
sl@0: 	}
sl@0: 
sl@0: /** Returns the current resolution.
sl@0: 
sl@0:     This is always in terms of the ERotationNormal rotation regardless of current
sl@0:     and supported rotations. When the display is disconnected or disabled, this
sl@0:     returns (0,0).
sl@0: 
sl@0:     If the current rotation is ERotation90CW or ERotation270CW, the width and
sl@0:     height values must be swapped by the caller to get the apparent width and
sl@0:     height.
sl@0: 
sl@0:     @param aSize    Receives the current resolution.
sl@0:     @return KErrNone on success, KErrNotSupported if not supported by driver.
sl@0: */
sl@0: inline TInt RDisplayChannel::GetResolution(TSize& aSize)  
sl@0: 	{
sl@0: 	return (DoControl(ECtrlGetResolution,&aSize));
sl@0: 	}
sl@0: 
sl@0: inline TInt RDisplayChannel::GetTwips(TSize& aTwips)
sl@0: 	{
sl@0: 	return (DoControl(ECtrlGetTwips,&aTwips));
sl@0: 	}
sl@0: 
sl@0: /** Returns the number of different buffer pixel formats that can be retrieved
sl@0:     using GetPixelFormats().
sl@0: 
sl@0:     @return The number of pixel formats supported.
sl@0: */
sl@0: inline TInt RDisplayChannel::NumberOfPixelFormats()  
sl@0: 	{
sl@0: 	return (DoControl(ECtrlNumberOfPixelFormats));
sl@0: 	}
sl@0: 
sl@0: /** Retrieves the buffer pixel formats that are supported.
sl@0: 
sl@0:     If aFormatsBuf is large enough to hold them all, the set of available pixel
sl@0:     formats shall be written to it as a contiguous sequence of TPixelFormat
sl@0:     elements. aCount shall be set to the number of TPixelFormat elements written
sl@0:     and the length of the buffer shall be set to the total number of bytes written.
sl@0: 
sl@0:     Not all pixel formats may be valid in all circumstances.
sl@0: 
sl@0:     @see SetBufferFormat
sl@0: 
sl@0:     @param aFormatsBuf    Buffer to receive pixel formats, as a contiguous sequence
sl@0:     of TUid elements.
sl@0:     @param aCount    Receives the number of TUid elements written to the buffer.
sl@0:     @return KErrNone on success, KErrOverflow if the buffer is too small to hold
sl@0:     all the elements, or KErrNotSupported if not supported by driver.
sl@0: */
sl@0: inline TInt RDisplayChannel::GetPixelFormats(TDes8& aFormatsBuf, TInt& aCount)  
sl@0: 	{
sl@0: 	return (DoControl(ECtrlGetPixelFormats,&aFormatsBuf,&aCount));
sl@0: 	}
sl@0: 
sl@0: /** Sets the buffer format to be used when the next buffer is posted.
sl@0: 
sl@0:     The width and height used in the buffer format correspond to the current
sl@0:     rotation in effect. The size in the buffer format must be at least as big as
sl@0:     the buffer mapping size, or the function shall fail with KErrNotSupported.
sl@0: 
sl@0:     @see SetBufferMapping
sl@0:     @see PostCompositionBuffer
sl@0:     @see PostLegacyBuffer
sl@0:     @see PostUserBuffer
sl@0: 
sl@0:     @capability WriteDeviceData Used to prevent arbitrary changes to the buffer
sl@0:     format.
sl@0:     @param aBufferFormat    The buffer format to be used.
sl@0:     @return KErrNone on success, KErrArgument if the buffer format is not valid,
sl@0:     KErrNotSupported if the format is valid but not supported, or KErrOutOfMemory
sl@0:     on memory allocation failure.
sl@0: */
sl@0: inline TInt RDisplayChannel::SetBufferFormat(const TBufferFormat& aBufferFormat)
sl@0: 	{
sl@0: 	return (DoControl(ECtrlSetBufferFormat,const_cast<TBufferFormat*>(&aBufferFormat)));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /** Retrieves the buffer format that will be used on the next buffer posting.
sl@0: 
sl@0:     Initially, this will match the information returned by GetDisplayInfo() for the
sl@0:     current rotation.
sl@0:     When a new resolution, rotation or mapping is chosen, the buffer format may
sl@0:     change.
sl@0: 
sl@0:     @param aBufferFormat    Receives the buffer format.
sl@0:     @return KErrNone on success, KErrNotSupported if not supported by driver.
sl@0: */
sl@0: inline TInt RDisplayChannel::GetBufferFormat(TBufferFormat& aBufferFormat)  
sl@0: 	{
sl@0: 	return (DoControl(ECtrlGetBufferFormat,&aBufferFormat));
sl@0: 	}
sl@0: 
sl@0: /** Returns the offset in bytes from the start of a plane to the next one, for the
sl@0:     given buffer format.
sl@0: 
sl@0:     This allows for additional bytes at the end of a plane before the start of the
sl@0:     next one, to allow for alignment, for example.
sl@0: 
sl@0:     For packed pixel formats and interleaved planes in semi-planar formats, the
sl@0:     return value is zero.
sl@0:     
sl@0:     The current display channel resolution and the rotation is used in computing the
sl@0:     next plane offset.
sl@0: 
sl@0:     @param aBufferFormat    A buffer width, in pixels.
sl@0:     @param aPlane    The plane number, starting at zero, for planar formats.
sl@0:     @return The next plane offset, in bytes, or zero if the parameters are invalid,
sl@0:     not recognised or not supported.
sl@0: */
sl@0: inline TInt RDisplayChannel::NextPlaneOffset(const TBufferFormat& aBufferFormat, TInt aPlane) 
sl@0: 	{
sl@0: 	return (DoControl(ECtrlNextPlaneOffset,const_cast<TBufferFormat*>(&aBufferFormat),&aPlane));
sl@0: 	}
sl@0: 
sl@0: /** Returns the offset in bytes between pixels in adjacent lines, for the given
sl@0:     plane if relevant.
sl@0: 
sl@0:     The value returned may allow for additional bytes at the end of each line, for
sl@0:     the purposes of alignment, for example. This is also known as the "stride" of
sl@0:     the line.
sl@0: 
sl@0:     For packed pixel formats, aPlane is ignored. The offset returned shall be at
sl@0:     least the width in pixels multiplied by the bytes per pixel.
sl@0: 
sl@0:     The current display channel resolution and the rotation is used in computing the
sl@0:     next line offset.
sl@0:     
sl@0:     For planar and semi-planar formats, aPlane dictates which offset is returned.
sl@0:     It must be at least the width in pixels multiplied by the (possibly fractional)
sl@0:     number of bytes per pixel for the plane.
sl@0: 
sl@0:     @param aBufferFormat    The buffer format.
sl@0:     @param aPlane    The plane number, starting at zero.
sl@0:     @return The stride for a given combination of width in pixels and pixel format,
sl@0:     or zero if the parameters are invalid, not recognised or not supported.
sl@0: */
sl@0: inline TInt RDisplayChannel::NextLineOffset(const TBufferFormat& aBufferFormat, TInt aPlane) 
sl@0: 	{
sl@0: 	return (DoControl(ECtrlNextLineOffset,const_cast<TBufferFormat*>(&aBufferFormat),&aPlane));
sl@0: 	}
sl@0: 
sl@0: /** Returns the offset in bytes from the start of a plane to the next one, for the
sl@0:     given parameters.
sl@0: 
sl@0:     This allows for additional bytes at the end of a plane before the start of the
sl@0:     next one, to allow for alignment, for example.
sl@0: 
sl@0:     For packed pixel formats and interleaved planes in semi-planar formats, the
sl@0:     return value is zero.
sl@0: 
sl@0:     For planar and semi-planar formats, aPlane dictates which offset is returned.
sl@0:     It must be at least the width in pixels multiplied by the (possibly fractional)
sl@0:     number of bytes per pixel for the plane.
sl@0: 
sl@0:     @param aBufferFormat    The buffer format.
sl@0:     @param aResolution	The resolution to be taken in consideration
sl@0:     @param aRotation    The rotation to be taken in consideration
sl@0:     @param aPlane    The plane number, starting at zero.
sl@0:     @return The stride for a given combination of width in pixels and pixel format,
sl@0:     or zero if the parameters are invalid, not recognised or not supported.
sl@0: */
sl@0: inline TInt RDisplayChannel::NextPlaneOffset(const TBufferFormat& aBufferFormat, const TResolution& aResolution, TDisplayRotation aRotation, TInt aPlane)
sl@0: 	{
sl@0: 	TBufferFormatContext context(aResolution, aRotation, aPlane);
sl@0: 	return (DoControl(ECtrlNextPlaneOffsetExtended, const_cast<TBufferFormat*>(&aBufferFormat), &context));
sl@0: 	}
sl@0: 
sl@0: /** Returns the offset in bytes between pixels in adjacent lines, for the given
sl@0:     plane if relevant.
sl@0: 
sl@0:     The value returned may allow for additional bytes at the end of each line, for
sl@0:     the purposes of alignment, for example. This is also known as the "stride" of
sl@0:     the line.
sl@0: 
sl@0:     For packed pixel formats, aPlane is ignored. The offset returned shall be at
sl@0:     least the width in pixels multiplied by the bytes per pixel.
sl@0: 
sl@0:     For planar and semi-planar formats, aPlane dictates which offset is returned.
sl@0:     It must be at least the width in pixels multiplied by the (possibly fractional)
sl@0:     number of bytes per pixel for the plane.
sl@0: 
sl@0:     @param aBufferFormat    The buffer format.
sl@0:     @param aResolution	The resolution to be taken in consideration
sl@0:     @param aRotation    The rotation to be taken in consideration
sl@0:     @param aPlane    The plane number, starting at zero.
sl@0:     @return The stride for a given combination of width in pixels and pixel format,
sl@0:     or zero if the parameters are invalid, not recognised or not supported.
sl@0: */
sl@0: inline TInt RDisplayChannel::NextLineOffset(const TBufferFormat& aBufferFormat, const TResolution& aResolution, TDisplayRotation aRotation, TInt aPlane)
sl@0: 	{
sl@0: 	TBufferFormatContext context(aResolution, aRotation, aPlane);
sl@0: 	return (DoControl(ECtrlNextLineOffsetExtended, const_cast<TBufferFormat*>(&aBufferFormat), &context));
sl@0: 	}
sl@0: 
sl@0: /** Returns the current version of the driver.
sl@0: */
sl@0: inline TInt RDisplayChannel::Version(TVersion& aVersion) 
sl@0: 	{
sl@0: 	return (DoControl(ECtrlVersion, &aVersion));
sl@0: 	}
sl@0: 
sl@0: #ifdef _DEBUG
sl@0: /** Debug only function to allocate a shared chunk user buffer for testing.
sl@0: */
sl@0: inline TInt RDisplayChannel::CreateUserBuffer(TBufferFormat& aBufferFormat, RChunk& aChunk)
sl@0: 	{
sl@0: 	return (aChunk.SetReturnedHandle(DoControl(ECtrlCreateUserBuffer, &aBufferFormat)));
sl@0: 	}
sl@0: #endif // _DEBUG
sl@0: 
sl@0: /** Constructs a resolution setting.
sl@0: 
sl@0:     @param aSize    The resolution size in pixels, in ERotationNormal rotation.
sl@0:     @param aRotations    A bitwise combination of one or more TDisplayRotation
sl@0:     values.
sl@0: */
sl@0: inline RDisplayChannel::TResolution::TResolution(TSize aPixelSize, TSize aTwipsSize, TUint32 aFlags):
sl@0: 	iPixelSize(aPixelSize),iTwipsSize(aTwipsSize),iFlags(aFlags),reserved_0(0)
sl@0: 	{	}
sl@0: 
sl@0: /** Constructs a buffer format.
sl@0: 
sl@0:     @param aSize    The size in pixels.
sl@0:     @param aPixelFormat    The pixel format.
sl@0: */
sl@0: inline RDisplayChannel::TBufferFormat::TBufferFormat(TSize aSize, TPixelFormat aPixelFormat):
sl@0: 	iSize(aSize),iPixelFormat(aPixelFormat),reserved_0(0)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: 
sl@0: /** Constructs a buffer context.
sl@0: 
sl@0:     @param aResolution    The display resolution.
sl@0:     @param aRotation    The display rotation.
sl@0:     @param aPlane
sl@0: */
sl@0: inline RDisplayChannel::TBufferFormatContext::TBufferFormatContext(TResolution aResolution, TDisplayRotation aRotation, TInt aPlane):
sl@0: 	iResolution(aResolution), iRotation(aRotation), iPlane(aPlane)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: 
sl@0: #endif
sl@0: 
sl@0: /**
sl@0: */
sl@0: inline const TDesC& RDisplayChannel::Name()
sl@0: {
sl@0:  return (KDisplayDriverName);
sl@0: }
sl@0: 
sl@0: /**
sl@0: */
sl@0: inline TVersion RDisplayChannel::VersionRequired(void)
sl@0: {
sl@0: 	return TVersion(KDisplayChMajorVersionNumber,
sl@0: 				    KDisplayChMinorVersionNumber,
sl@0: 			        KDisplayChBuildVersionNumber);
sl@0: }
sl@0: 
sl@0: #endif // __DISPCHANNEL_INL__