accessoryservices/pluggeddisplay/pluggeddisplayengine/inc/edidhandler.h
changeset 0 4e1aa6a622a0
child 41 c87e5f80c17d
child 43 0b0048910c20
child 44 2c28af138640
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  * 
       
    14  * Description:
       
    15  * CEDIDHandler class declaration.
       
    16  *
       
    17  */
       
    18 
       
    19 #ifndef C_EDIDHANDLER_H
       
    20 #define C_EDIDHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <ddc_access.h>
       
    25 #include <tvoutconfig.h>
       
    26 #include <accpolhdmiaudioformat.h>
       
    27 #include <accpolhdmivideoformat.h>
       
    28 #include <accpolhdmilatency.h>
       
    29 #include <tvoutconfigdef.h>
       
    30 
       
    31 #include "ediddatatypes.h"
       
    32 #include "videotimings.h"
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // MACROS
       
    37 
       
    38 // DATA TYPES
       
    39 
       
    40 // FUNCTION PROTOTYPES
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 class CDdcPortAccess;
       
    44 class MFSMForBody;
       
    45 class CEdidParserBase;
       
    46 class CCea861EdidParser;
       
    47 class CTVOutConfigForHDMI;
       
    48 class CAccPolHdmiSink;
       
    49 class CAccPolHdmiLatency;
       
    50 class CAccPolHdmiSpeakerAllocation;
       
    51 
       
    52 // CLASS DECLARATION
       
    53 /**
       
    54  *  Class to handle EDID data.
       
    55  *
       
    56  *  @code
       
    57  *   ?good_class_usage_example(s)
       
    58  *  @endcode
       
    59  *
       
    60  *  @lib none.
       
    61  *  @since TB 9.2
       
    62  */
       
    63 NONSHARABLE_CLASS( CEDIDHandler ): public CActive
       
    64     {
       
    65 public:
       
    66     // Request Identifier
       
    67     enum TRequestTypeID
       
    68         {
       
    69         EUndefRequest = 0x0,
       
    70         EDdcReadRequest,
       
    71         ERetryTimerRequest,
       
    72         };
       
    73     
       
    74     // Constructors and destructor
       
    75 
       
    76     /**
       
    77      * Symbian two phased constructor.
       
    78      * 
       
    79      * @since S60 TB9.2
       
    80      * @param aFSM A FSM.
       
    81      * @param CTVOutConfigForHDMI TV Out Configurer.
       
    82      * @return CEDIDHandler*
       
    83      */
       
    84     static CEDIDHandler* NewL( MFSMForBody& aFSM,
       
    85         CTVOutConfigForHDMI& aTVOutConfigForHDMI );
       
    86 
       
    87     /**
       
    88      * Destructor.
       
    89      */
       
    90     virtual ~CEDIDHandler();
       
    91 
       
    92 public:
       
    93     // New methods
       
    94 
       
    95     /**
       
    96      * Fetch EDID Data.
       
    97      * 
       
    98      * @since TB9.2
       
    99      * @param None.
       
   100      * @return Error code, KErrNone if successfull.
       
   101      */
       
   102     TInt FetchEDIDData();
       
   103 
       
   104     /**
       
   105      * Set video parameters of TV Out Configuration.
       
   106      * 
       
   107      * @since TB9.2
       
   108      * @param None.
       
   109      * @return Error code, KErrNone if successfull.
       
   110      */
       
   111     TInt SetVideoParameters();
       
   112 
       
   113     /**
       
   114      * Reset EDID Data.
       
   115      * 
       
   116      * @since TB9.2
       
   117      * @param None.
       
   118      * @return void.
       
   119      */
       
   120     void ResetData();
       
   121 
       
   122     /**
       
   123      * Create HDMI Sink object.
       
   124      * 
       
   125      * @since TB9.2
       
   126      * @param None.
       
   127      * @return CAccPolHdmiSink* HDMI sink object.
       
   128      */
       
   129     CAccPolHdmiSink* CreateHdmiSinkL();
       
   130 
       
   131     /**
       
   132      * Create HDMI Video Format object.
       
   133      * 
       
   134      * @since TB9.2
       
   135      * @param aHdmiVideoFormatArray Array of CAccPolHdmiVideoFormat pointers.
       
   136      * @return void.
       
   137      */
       
   138     void CreateHdmiVideoFormatL( RAccPolHdmiVideoFormatArray& aHdmiVideoFormatArray );
       
   139 
       
   140     /**
       
   141      * Create HDMI Latency object.
       
   142      * 
       
   143      * @since TB9.2
       
   144      * @param aHdmiLatencyArray Array of CAccPolHdmiLatency pointers.
       
   145      * @return None.
       
   146      */
       
   147     void CreateHdmiLatencyL( RAccPolHdmiLatencyArray& aHdmiLatencyArray );
       
   148 
       
   149     /**
       
   150      * Create HDMI Audio Format object.
       
   151      * 
       
   152      * @since TB9.2
       
   153      * @param aHdmiAudioFormatArray Array of CAccPolHdmiAudioFormat pointers.
       
   154      * @return void.
       
   155      */
       
   156     void CreateHdmiAudioFormatL( RAccPolHdmiAudioFormatArray& aHdmiAudioFormatArray );
       
   157 
       
   158     /**
       
   159      * Create HDMI Speaker Allocation object.
       
   160      * 
       
   161      * @since TB9.2
       
   162      * @param None.
       
   163      * @return CAccPolHdmiSpeakerAllocation* HDMI Speaker Allocation object.
       
   164      */
       
   165     CAccPolHdmiSpeakerAllocation* CreateHdmiSpeakerAllocationL();
       
   166 
       
   167     /**
       
   168      * Tells whether or not HDCP is supported at the moment.
       
   169      * 
       
   170      * @since TB9.2
       
   171      * @param None.
       
   172      * @return TBool Symbian error code. KErrNone, if ok. KErrNotFound if cannot be defined.
       
   173      */
       
   174     TInt GetHdcpSupportStatus( TBool& aHdcpSupport ) const;
       
   175 
       
   176 private:
       
   177 
       
   178     /**
       
   179      * Read EDID Data from DDC Access.
       
   180      * 
       
   181      * @since TB9.2
       
   182      * @param None.
       
   183      * @return Error code. KErrNone if successful.
       
   184      */
       
   185     TInt ReadEDIDDataL();
       
   186 
       
   187     // Functions from base class CActive
       
   188 
       
   189     /**
       
   190      * RunL()
       
   191      */
       
   192     void RunL();
       
   193 
       
   194     /**
       
   195      * DoCancel()
       
   196      */
       
   197     void DoCancel();
       
   198 
       
   199     /**
       
   200      * RunError()
       
   201      */
       
   202     TInt RunError( TInt aError );
       
   203 
       
   204 private:
       
   205     // Constructors
       
   206 
       
   207     /**
       
   208      * C++ constructor.
       
   209      * @param aFSM A FSM.
       
   210      * @param CTVOutConfigForHDMI TV Out Configurer.
       
   211      */
       
   212     CEDIDHandler( MFSMForBody& aFSM,
       
   213             CTVOutConfigForHDMI& aTVOutConfigForHDMI );
       
   214 
       
   215     /**
       
   216      * Symbian 2nd phase constructor.
       
   217      * 
       
   218      */
       
   219     void ConstructL();
       
   220 
       
   221 private:
       
   222     
       
   223     /**
       
   224      * Fills the common timing attributes which can be received from
       
   225      * edidparser or cenrep.
       
   226      * 
       
   227      * @param aTimings Timings struct which is filled.
       
   228      * @return None.
       
   229      */
       
   230     void FillCommonHdmiDviTimings( THdmiDviTimings& aTimings ) const;
       
   231         
       
   232     /**
       
   233      * Fills out the THdmiDviTimings based on the timing item.
       
   234      * 
       
   235      * @param aItem Timing item from which the data is used.
       
   236      * @param aTimings Timings struct which is filled.
       
   237      * @return None.
       
   238      */
       
   239     void FillHdmiDviTimings( const TTimingItem& aItem,
       
   240         THdmiDviTimings& aTimings ) const;
       
   241     
       
   242     /**
       
   243      * Fills out the THdmiDviTimings based on the descriptor block.
       
   244      * 
       
   245      * @param aDescBlock Descriptor block.
       
   246      * @param aTimings Timings struct which is filled.
       
   247      * @return None.
       
   248      */
       
   249     void FillHdmiDviTimings( const TEdidDescriptorBlock& aDescBlock,
       
   250         THdmiDviTimings& aTimings ) const;
       
   251     
       
   252     /**
       
   253      * Set cea modes.
       
   254      * 
       
   255      * @param aTimings Array to fill.
       
   256      * @return system error code.
       
   257      */
       
   258     TInt SetCeaModes( RArray<THdmiDviTimings>& aTimings ) const;
       
   259     
       
   260     /**
       
   261      * Set dmt modes.
       
   262      * 
       
   263      * @param aTimings Array to fill.
       
   264      * @return system error code.
       
   265      */
       
   266     TInt SetDmtModes( RArray<THdmiDviTimings>& aTimings ) const;
       
   267     
       
   268     /**
       
   269      * Set dmt modes from established timings 1 and 2.
       
   270      * 
       
   271      * @param aTimings Array to fill.
       
   272      * @return system error code.
       
   273      */
       
   274     TInt SetDmtModesFromEstablishedTimings( RArray<THdmiDviTimings>& aTimings ) const;
       
   275     
       
   276     /**
       
   277      * Set dmt modes from standard timings.
       
   278      * 
       
   279      * @param aTimings Array to fill.
       
   280      * @return None.
       
   281      */
       
   282     TInt SetDmtModesFromStandardTimings( RArray<THdmiDviTimings>& aTimings ) const;
       
   283     
       
   284     /**
       
   285      * Set dmt modes from timing descriptors.
       
   286      * 
       
   287      * @param aTimings Array to fill.
       
   288      * @return None.
       
   289      */
       
   290     TInt SetDmtModesFromTimingDescriptors( RArray<THdmiDviTimings>& aTimings ) const;
       
   291     
       
   292     /**
       
   293      * Get timing by index.
       
   294      * 
       
   295      * @param aIndex Indes of the item to get
       
   296      * @param aType Timing type: CEA or DMT.
       
   297      * @return const TTimingItem*
       
   298      */
       
   299     const TTimingItem* TimingByIndex( TInt aIndex,
       
   300         TTimingModeType aType ) const;
       
   301     
       
   302     /**
       
   303      * Get timing by resolution.
       
   304      * 
       
   305      * @param aWidth Horizontal size.
       
   306      * @param aHeight Vertical size.
       
   307      * @param 
       
   308      * @param aType Timing type: CEA or DMT.
       
   309      * @return const TTimingItem*
       
   310      */
       
   311     const TTimingItem* TimingByResolution( TUint16 aWidth,
       
   312         TUint16 aHeight,
       
   313         TUint16 aRefreshRate,
       
   314         TTimingModeType aType ) const;
       
   315     
       
   316     /**
       
   317      * Set DMT mode by resolution.
       
   318      * 
       
   319      * @param aTimings Array where to append new DMT timing.
       
   320      * @param aWidth Width of the resolution. 
       
   321      * @param aHeight Height of the resolution.
       
   322      * @param aRefreshRate Refresh rate used.
       
   323      * @return None.
       
   324      */
       
   325     TInt SetDmtModeByResolution( RArray<THdmiDviTimings>& aTimings,
       
   326         TUint16 aWidth,
       
   327         TUint16 aHeight,
       
   328         TUint16 aRefreshRate ) const;
       
   329     
       
   330     /**
       
   331      * Resolves aspect ratio from width and height.
       
   332      * 
       
   333      * @param aWidth Horizontal pixels.
       
   334      * @param aHeight Vertical lines.
       
   335      * @return TTvSettings::TAspectRatio.
       
   336      */
       
   337     TTvSettings::TAspectRatio ResolveAspectRatio( TUint16 aWidth,
       
   338         TUint16 aHeight ) const;
       
   339     
       
   340     /**
       
   341      * Calculates overscan in pixels. The top left and right bottom should
       
   342      * cover the full screen from which the overscan is calculated.
       
   343      * 
       
   344      * @param aTLCorner Top left corner.
       
   345      * @param aRBCorner Right bottom corner.
       
   346      * @return None.
       
   347      */
       
   348     void CalculateOverscan( TPoint& aTLCorner, TPoint& aBRCorner ) const;
       
   349     
       
   350     /**
       
   351      * Update overscan values from cenrep.
       
   352      * 
       
   353      * @param None.
       
   354      * @return None.
       
   355      */
       
   356     void UpdateOverscanValues();
       
   357     
       
   358 	/**
       
   359 	 * Filter out the unsupported TV configurations.
       
   360 	 * 
       
   361 	 * @param  aHdmiConfigs    Available HDMI/DVI Tv configurations.
       
   362 	 * @return KErrNone if OK. KErrNotFound if the filtered list is empty.
       
   363 	 *			 
       
   364 	 */
       
   365 	TInt FilterAvailableTvConfigList( RArray<THdmiDviTimings>& aHdmiConfigs );
       
   366     
       
   367 private: // Data
       
   368 
       
   369     class TDataBlock
       
   370         {
       
   371     public:
       
   372         TUint8 iDataBlock[KSizeOfSegment];
       
   373         };
       
   374 
       
   375     // Display Data Channel
       
   376     // Own.
       
   377     CDdcPortAccess* iDdcPortAccess;
       
   378 
       
   379     // A FSM pointer.
       
   380     // Not own.
       
   381     MFSMForBody& iFSM;
       
   382 
       
   383     // CEdidParserBase is the base class for parsing EDID data
       
   384     // Own.
       
   385     CEdidParserBase* iEdidParserPtr;
       
   386 
       
   387     // CCea861EdidParser is the base class for parsing 
       
   388     // CEA 861 EDID extension data
       
   389     // Own.
       
   390     CCea861EdidParser* iExtensionParserPtr;
       
   391 
       
   392     // EDID Data Block pointer.
       
   393     // Own
       
   394     TDataBlock* iDataBlockPtr;
       
   395 
       
   396     // TV Out Configurer.
       
   397     // Not own.
       
   398     CTVOutConfigForHDMI& iTVOutConfigForHDMI;
       
   399     
       
   400     // Horizontal overscan in pixels (1% == 100)
       
   401     TInt iHOverscan;
       
   402 
       
   403     // Vertical overscan in pixels (1% == 100)
       
   404     TInt iVOverscan;
       
   405     
       
   406     // Timer for reading EDID data
       
   407     RTimer iRetryTimer;
       
   408     
       
   409     // Retry Counter
       
   410     TInt iRetryCounter;
       
   411     
       
   412     // Request ID
       
   413     TRequestTypeID iRequestID;
       
   414     };
       
   415 
       
   416 #endif // C_EDIDHANDLER_H