accessoryservices/pluggeddisplay/edidparser/src/edidparserbase.cpp
changeset 0 4e1aa6a622a0
child 17 0b0048910c20
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2  * Copyright (c) 2008,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  * Implementation of CEdidParserBase class.
       
    16  *
       
    17  */
       
    18 
       
    19 #include "trace.h"
       
    20 #include "edidparserbase.h"
       
    21 #include "cea861edidparser.h"
       
    22 #include "traceediddata.h"
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // CEdidParserBase::CEdidParserBase
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CEdidParserBase::CEdidParserBase() :
       
    29     iNumberOfExtensionBlocks( 0 )
       
    30     {
       
    31     FUNC_LOG;
       
    32     }
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CEdidParserBase::ConstructL
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 void CEdidParserBase::ConstructL( const TDesC8& aBinaryData )
       
    39     {
       
    40     FUNC_LOG;
       
    41 
       
    42     //Check if it is EDID data
       
    43     if( !IsEdidData( aBinaryData ) )
       
    44         {
       
    45         // Not EDID data
       
    46         User::Leave( KErrNotSupported );
       
    47         }
       
    48 
       
    49     iRawData = HBufC8::NewL( aBinaryData.Length() );
       
    50     TPtr8 rawPtr = iRawData->Des();
       
    51     rawPtr.Copy( aBinaryData );
       
    52 
       
    53     // Make a copy of base EDID data
       
    54     Mem::Copy( &iBaseEdidData, rawPtr.Ptr(), KEdidParserSizeOfEdidBlock );
       
    55     
       
    56     TRACE_EDID_DATA( *this );
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CEdidParserBase::NewL
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C CEdidParserBase* CEdidParserBase::NewL( const TDesC8& aBinaryData )
       
    64     {
       
    65     FUNC_LOG;
       
    66 
       
    67     CEdidParserBase* self = CEdidParserBase::NewLC( aBinaryData );
       
    68     CleanupStack::Pop( self );
       
    69 
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CEdidParserBase::NewLC
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 EXPORT_C CEdidParserBase* CEdidParserBase::NewLC( const TDesC8& aBinaryData )
       
    78     {
       
    79     FUNC_LOG;
       
    80 
       
    81     CEdidParserBase* self = new ( ELeave ) CEdidParserBase();
       
    82     CleanupStack::PushL( self );
       
    83     self->ConstructL( aBinaryData );
       
    84 
       
    85     return self;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CEdidParserBase::CEdidParserBase
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 CEdidParserBase::~CEdidParserBase()
       
    93     {
       
    94     FUNC_LOG;
       
    95 
       
    96     delete iRawData;
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CEdidParserBase::IsEdidData
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 EXPORT_C TBool CEdidParserBase::IsEdidData( const TDesC8& aBinaryData )
       
   104     {
       
   105     FUNC_LOG;
       
   106     INFO_1( "TBool CEdidParserBase::IsEdidData: aBinaryData length: %d", aBinaryData.Length() );
       
   107 
       
   108     TBool edidData = EFalse;
       
   109 
       
   110     // Check the length
       
   111     if( aBinaryData.Length() >= KEdidParserSizeOfEdidBlock )
       
   112         {
       
   113         for( int ii = 0; ii < KEdidParserSizeOfEdidHeader; ii++ )
       
   114             {
       
   115             if( aBinaryData[ii] != KBaseEdidHeader[ii] )
       
   116                 {
       
   117                     // Not a valid EDID header
       
   118                 ERROR_1( KErrArgument, "TBool CEdidParserBase::IsEdidData: Not a valid EDID header: %d", ii );
       
   119                 return EFalse;
       
   120                 }
       
   121             }
       
   122         edidData = ETrue;
       
   123         }
       
   124 
       
   125     return edidData;
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CEdidParserBase::GetManufacturerCode
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 EXPORT_C void CEdidParserBase::GetManufacturerCode( TDes& aCode )
       
   133     {
       
   134     FUNC_LOG;
       
   135 
       
   136     if( aCode.Length() < KEdidParserManufacturerCodeLength )
       
   137         {
       
   138         //return;
       
   139         }
       
   140 
       
   141     TUint16 data = iBaseEdidData.iVendorProductInfo.iManufacturerCode;
       
   142 
       
   143     // Manufacturer codes are also called the ISA (Industry Standard Architecture)
       
   144     // Plug and Play Device Identifier (PNPID). They are based on 5 bit compressed
       
   145     // ASCII codes
       
   146     // bits 14-10: first letter (01h='A', 02h='B',..)
       
   147     // bits 9-5: second letter
       
   148     // bits 4-0: third letter
       
   149 
       
   150     // Convert to big endian
       
   151     data = ( ( data >> 8 ) & 0xff ) + ( ( data << 8 ) & 0xff00 );
       
   152 
       
   153     // Get ASCII codes
       
   154     TChar asciicode;
       
   155     asciicode = ( ( data >> 10 ) & 0x1f ) + 'A' - 1;
       
   156     aCode.Append( asciicode );
       
   157     asciicode = ( ( data >> 5 ) & 0x1f ) + 'A' - 1;
       
   158     aCode.Append( asciicode );
       
   159     asciicode = ( data & 0x1f ) + 'A' - 1;
       
   160     aCode.Append( asciicode );
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // CEdidParserBase::GetProductId
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C void CEdidParserBase::GetProductId( TDes& aCode )
       
   168     {
       
   169     FUNC_LOG;
       
   170 
       
   171     aCode.AppendFormat( _L( "%04x" ), iBaseEdidData.iVendorProductInfo.iProductId );
       
   172     }
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // CEdidParserBase::GetManufactureWeek
       
   176 // ---------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C TUint8 CEdidParserBase::GetManufactureWeek()
       
   179     {
       
   180     FUNC_LOG;
       
   181 
       
   182     return iBaseEdidData.iVendorProductInfo.iWeek;
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // CEdidParserBase::GetManufactureYear
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C TUint16 CEdidParserBase::GetManufactureYear()
       
   190     {
       
   191     FUNC_LOG;
       
   192 
       
   193     // Year of manufacture stored in EDID data is "Year of Manufacture - 1990"
       
   194     return ( iBaseEdidData.iVendorProductInfo.iYear + KEdidBaseYear );
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CEdidParserBase::GetVersion
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 EXPORT_C TUint8 CEdidParserBase::GetVersion()
       
   202     {
       
   203     FUNC_LOG;
       
   204 
       
   205     return iBaseEdidData.iVersion;
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // CEdidParserBase::GetRevision
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 EXPORT_C TUint8 CEdidParserBase::GetRevision()
       
   213     {
       
   214     FUNC_LOG;
       
   215 
       
   216     return iBaseEdidData.iRevision;
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // CEdidParserBase::GetVideoInputDefinition
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C TUint8 CEdidParserBase::GetVideoInputDefinition()
       
   224     {
       
   225     FUNC_LOG;
       
   226 
       
   227     // Analog if bit 7 is 0. Digital if bit 7 is 1
       
   228     return ( ( iBaseEdidData.iVideoInputDefinition & KBit7 ) == KBit7 ? 1 : 0 );
       
   229     }
       
   230 
       
   231 // ---------------------------------------------------------------------------
       
   232 // CEdidParserBase::GetHorizontalScreenSize
       
   233 // ---------------------------------------------------------------------------
       
   234 //
       
   235 EXPORT_C TUint8 CEdidParserBase::GetHorizontalScreenSize()
       
   236     {
       
   237     FUNC_LOG;
       
   238 
       
   239     return iBaseEdidData.iScreenSize.iHorizontal;
       
   240     }
       
   241 
       
   242 // ---------------------------------------------------------------------------
       
   243 // CEdidParserBase::GetVerticalScreenSize
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246 EXPORT_C TUint8 CEdidParserBase::GetVerticalScreenSize()
       
   247     {
       
   248     FUNC_LOG;
       
   249 
       
   250     return iBaseEdidData.iScreenSize.iVertical;
       
   251     }
       
   252 
       
   253 // ---------------------------------------------------------------------------
       
   254 // CEdidParserBase::GetAspectRatioLandscape
       
   255 // ---------------------------------------------------------------------------
       
   256 //
       
   257 EXPORT_C TUint8 CEdidParserBase::GetAspectRatioLandscape()
       
   258     {
       
   259 	FUNC_LOG;
       
   260 	
       
   261     // TEdidAspectRatio contains same values as TEdidScreenSize
       
   262     // Horizontal = Landscape 
       
   263     return iBaseEdidData.iScreenSize.iHorizontal;
       
   264     }
       
   265 
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // CEdidParserBase::GetAspectRatioPortrait
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 EXPORT_C TUint8 CEdidParserBase::GetAspectRatioPortrait()
       
   272     {
       
   273 	FUNC_LOG;
       
   274 	
       
   275     // TEdidAspectRatio contains same values as TEdidScreenSize
       
   276     // Vertical = Portrait 
       
   277     return iBaseEdidData.iScreenSize.iVertical;
       
   278     }
       
   279 
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // CEdidParserBase::IsAspectRationUsed
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 EXPORT_C TBool CEdidParserBase::IsAspectRatioUsed()
       
   286     {
       
   287     FUNC_LOG;
       
   288 
       
   289     // If byte 15h != 00h then byte 16h = Vertical Screen Size in cm.     (Range is 1 cm -> 255 cm)
       
   290     // If byte 15h == 00h then byte 16h = Aspect Ratio (Portrait)         (Range is 0.28 : 1 AR -> 0.99 : 1 AR)
       
   291     //
       
   292     // If byte 16h != 00h then byte 15h = Horizontal Screen Size in cm.   (Range is 1 cm -> 255 cm)
       
   293     // If byte 16h == 00h then byte 15h = Aspect Ratio (Landscape)        (Range is 1 : 1 AR -> 3.54 : 1 AR)
       
   294 
       
   295     if( ( iBaseEdidData.iScreenSize.iHorizontal == 0 )
       
   296         || ( iBaseEdidData.iScreenSize.iVertical == 0 ) )
       
   297         {
       
   298         return ETrue;
       
   299         }
       
   300 
       
   301     return EFalse;
       
   302     }
       
   303 
       
   304 // ---------------------------------------------------------------------------
       
   305 // CEdidParserBase::DisplayTransferCharacteristics
       
   306 // ---------------------------------------------------------------------------
       
   307 //
       
   308 EXPORT_C TUint8 CEdidParserBase::DisplayTransferCharacteristics()
       
   309     {
       
   310     FUNC_LOG;
       
   311 
       
   312     // Stored Value = (GAMMA x 100) – 100
       
   313     return iBaseEdidData.iDisplayTransferCharasteristics;
       
   314     }
       
   315 
       
   316 // ---------------------------------------------------------------------------
       
   317 // CEdidParserBase::GetColorCoordinatesRedX
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 EXPORT_C TUint16 CEdidParserBase::GetColorCoordinatesRedX()
       
   321     {
       
   322     FUNC_LOG;
       
   323 
       
   324     // Address 19h bits 7&6 are RedX bits 1&0
       
   325     // Address 1Bh = RedX bits 9 to 2
       
   326     TUint16 ret = iBaseEdidData.iColorCharasteristics[2]; //1Bh
       
   327     ret = ret << 2;
       
   328     TUint8 add = 0;
       
   329     if( iBaseEdidData.iColorCharasteristics[0] & KBit7 )
       
   330         {
       
   331         add++;
       
   332         }
       
   333     add = add << 1;
       
   334     if( iBaseEdidData.iColorCharasteristics[0] & KBit6 )
       
   335         {
       
   336         add++;
       
   337         }
       
   338     ret += add;
       
   339     return ret;
       
   340     }
       
   341 
       
   342 // ---------------------------------------------------------------------------
       
   343 // CEdidParserBase::GetColorCoordinatesRedY
       
   344 // ---------------------------------------------------------------------------
       
   345 //
       
   346 EXPORT_C TUint16 CEdidParserBase::GetColorCoordinatesRedY()
       
   347     {
       
   348     FUNC_LOG;
       
   349 
       
   350     // Address 19h bits 5&4 are RedY bits 1&0
       
   351     // Address 1Ch = RedY bits 9 to 2
       
   352     TUint16 ret = iBaseEdidData.iColorCharasteristics[3]; //1Ch
       
   353     ret = ret << 2;
       
   354     TUint8 add = 0;
       
   355     if( iBaseEdidData.iColorCharasteristics[0] & KBit5 )
       
   356         {
       
   357         add++;
       
   358         }
       
   359     add = add << 1;
       
   360     if( iBaseEdidData.iColorCharasteristics[0] & KBit4 )
       
   361         {
       
   362         add++;
       
   363         }
       
   364     ret += add;
       
   365     return ret;
       
   366     }
       
   367 
       
   368 // ---------------------------------------------------------------------------
       
   369 // CEdidParserBase::GetColorCoordinatesGreenX
       
   370 // ---------------------------------------------------------------------------
       
   371 //
       
   372 EXPORT_C TUint16 CEdidParserBase::GetColorCoordinatesGreenX()
       
   373     {
       
   374     FUNC_LOG;
       
   375 
       
   376     // Address 19h bits 3&2 are GreenX bits 1&0
       
   377     // Address 1Dh = GreenX bits 9 to 2
       
   378     TUint16 ret = iBaseEdidData.iColorCharasteristics[4]; //1Dh
       
   379     ret = ret << 2;
       
   380     TUint8 add = 0;
       
   381     if( iBaseEdidData.iColorCharasteristics[0] & KBit3 )
       
   382         {
       
   383         add++;
       
   384         }
       
   385     add = add << 1;
       
   386     if( iBaseEdidData.iColorCharasteristics[0] & KBit2 )
       
   387         {
       
   388         add++;
       
   389         }
       
   390     ret += add;
       
   391     return ret;
       
   392     }
       
   393 
       
   394 // ---------------------------------------------------------------------------
       
   395 // CEdidParserBase::GetColorCoordinatesGreenY
       
   396 // ---------------------------------------------------------------------------
       
   397 //
       
   398 EXPORT_C TUint16 CEdidParserBase::GetColorCoordinatesGreenY()
       
   399     {
       
   400     FUNC_LOG;
       
   401 
       
   402     // Address 19h bits 1&0 are GreenY bits 1&0
       
   403     // Address 1Eh = GreenY bits 9 to 2
       
   404     TUint16 ret = iBaseEdidData.iColorCharasteristics[5]; //1Dh
       
   405     ret = ret << 2;
       
   406     TUint8 add = 0;
       
   407     if( iBaseEdidData.iColorCharasteristics[0] & KBit1 )
       
   408         {
       
   409         add++;
       
   410         }
       
   411     add = add << 1;
       
   412     if( iBaseEdidData.iColorCharasteristics[0] & KBit0 )
       
   413         {
       
   414         add++;
       
   415         }
       
   416     ret += add;
       
   417     return ret;
       
   418     }
       
   419 
       
   420 // ---------------------------------------------------------------------------
       
   421 // CEdidParserBase::GetColorCoordinatesBlueX
       
   422 // ---------------------------------------------------------------------------
       
   423 //
       
   424 EXPORT_C TUint16 CEdidParserBase::GetColorCoordinatesBlueX()
       
   425     {
       
   426     FUNC_LOG;
       
   427 
       
   428     // Address 1Ah bits 7&6 are BlueX bits 1&0
       
   429     // Address 1Fh = BlueX bits 9 to 2
       
   430     TUint16 ret = iBaseEdidData.iColorCharasteristics[6]; //1Fh
       
   431     ret = ret << 2;
       
   432     TUint8 add = 0;
       
   433     if( iBaseEdidData.iColorCharasteristics[1] & KBit7 )
       
   434         {
       
   435         add++;
       
   436         }
       
   437     add = add << 1;
       
   438     if( iBaseEdidData.iColorCharasteristics[1] & KBit6 )
       
   439         {
       
   440         add++;
       
   441         }
       
   442     ret += add;
       
   443     return ret;
       
   444     }
       
   445 
       
   446 // ---------------------------------------------------------------------------
       
   447 // CEdidParserBase::GetColorCoordinatesBlueY
       
   448 // ---------------------------------------------------------------------------
       
   449 //
       
   450 EXPORT_C TUint16 CEdidParserBase::GetColorCoordinatesBlueY()
       
   451     {
       
   452     FUNC_LOG;
       
   453 
       
   454     // Address 1Ah bits 5&4 are BlueY bits 1&0
       
   455     // Address 20h = BlueY bits 9 to 2
       
   456     TUint16 ret = iBaseEdidData.iColorCharasteristics[7]; //20h
       
   457     ret = ret << 2;
       
   458     TUint8 add = 0;
       
   459     if( iBaseEdidData.iColorCharasteristics[1] & KBit5 )
       
   460         {
       
   461         add++;
       
   462         }
       
   463     add = add << 1;
       
   464     if( iBaseEdidData.iColorCharasteristics[1] & KBit4 )
       
   465         {
       
   466         add++;
       
   467         }
       
   468     ret += add;
       
   469     return ret;
       
   470     }
       
   471 
       
   472 // ---------------------------------------------------------------------------
       
   473 // CEdidParserBase::GetColorCoordinatesWhiteX
       
   474 // ---------------------------------------------------------------------------
       
   475 //
       
   476 EXPORT_C TUint16 CEdidParserBase::GetColorCoordinatesWhiteX()
       
   477     {
       
   478     FUNC_LOG;
       
   479 
       
   480     // Address 1Ah bits 3&2 are WhiteX bits 1&0
       
   481     // Address 21h = WhiteX bits 9 to 2
       
   482     TUint16 ret = iBaseEdidData.iColorCharasteristics[8]; //21h
       
   483     ret = ret << 2;
       
   484     TUint8 add = 0;
       
   485     if( iBaseEdidData.iColorCharasteristics[1] & KBit3 )
       
   486         {
       
   487         add++;
       
   488         }
       
   489     add = add << 1;
       
   490     if( iBaseEdidData.iColorCharasteristics[1] & KBit2 )
       
   491         {
       
   492         add++;
       
   493         }
       
   494     ret += add;
       
   495     return ret;
       
   496     }
       
   497 
       
   498 // ---------------------------------------------------------------------------
       
   499 // CEdidParserBase::GetColorCoordinatesWhiteY
       
   500 // ---------------------------------------------------------------------------
       
   501 //
       
   502 EXPORT_C TUint16 CEdidParserBase::GetColorCoordinatesWhiteY()
       
   503     {
       
   504     FUNC_LOG;
       
   505 
       
   506     // Address 1Ah bits 3&2 are WhiteX bits 1&0
       
   507     // Address 22h = WhiteX bits 9 to 2
       
   508     TUint16 ret = iBaseEdidData.iColorCharasteristics[9]; //22h
       
   509     ret = ret << 2;
       
   510     TUint8 add = 0;
       
   511     if( iBaseEdidData.iColorCharasteristics[1] & KBit1 )
       
   512         {
       
   513         add++;
       
   514         }
       
   515     add = add << 1;
       
   516     if( iBaseEdidData.iColorCharasteristics[1] & KBit0 )
       
   517         {
       
   518         add++;
       
   519         }
       
   520     ret += add;
       
   521     return ret;
       
   522     }
       
   523 
       
   524 // ---------------------------------------------------------------------------
       
   525 // CEdidParserBase::GetEstablishedTimings1
       
   526 // ---------------------------------------------------------------------------
       
   527 //
       
   528 EXPORT_C TUint8 CEdidParserBase::GetEstablishedTimings1()
       
   529     {
       
   530     FUNC_LOG;
       
   531 
       
   532     //Bit - Established Timing I
       
   533     // 7     720 x 400  @ 70Hz
       
   534     // 6     720 x 400  @ 88Hz
       
   535     // 5     640 x 480  @ 60Hz
       
   536     // 4     640 x 480  @ 67Hz
       
   537     // 3     640 x 480  @ 72Hz
       
   538     // 2     640 x 480  @ 75Hz
       
   539     // 1     800 x 600  @ 56Hz
       
   540     // 0     800 x 600  @ 60Hz
       
   541     return iBaseEdidData.iEstablishedTimings[0];
       
   542     }
       
   543 
       
   544 // ---------------------------------------------------------------------------
       
   545 // CEdidParserBase::GetEstablishedTimings2
       
   546 // ---------------------------------------------------------------------------
       
   547 //
       
   548 EXPORT_C TUint8 CEdidParserBase::GetEstablishedTimings2()
       
   549     {
       
   550     FUNC_LOG;
       
   551 
       
   552     //Bit - Established Timing I
       
   553     // 7     800 x 600    @ 72Hz
       
   554     // 6     800 x 600    @ 75Hz
       
   555     // 5     832 x 624    @ 75Hz
       
   556     // 4     1024 x 768   @ 87Hz
       
   557     // 3     1024 x 768   @ 60Hz
       
   558     // 2     1024 x 768   @ 70Hz
       
   559     // 1     1024 x 768   @ 75Hz
       
   560     // 0     1280 x 1024  @ 75Hz
       
   561     return iBaseEdidData.iEstablishedTimings[1];
       
   562     }
       
   563 
       
   564 // ---------------------------------------------------------------------------
       
   565 // CEdidParserBase::GetManufacturerTimings
       
   566 // ---------------------------------------------------------------------------
       
   567 //
       
   568 EXPORT_C TUint8 CEdidParserBase::GetManufacturerTimings()
       
   569     {
       
   570     FUNC_LOG;
       
   571 
       
   572     //Bit - Manufacturer Timing
       
   573     // 7     1152 x 870   @ 75Hz
       
   574     // 6-0   Reserved for Manufacturer Specified Timings
       
   575     return iBaseEdidData.iEstablishedTimings[2];
       
   576     }
       
   577 
       
   578 // ---------------------------------------------------------------------------
       
   579 // CEdidParserBase::GetManufacturerTimings
       
   580 // ---------------------------------------------------------------------------
       
   581 //
       
   582 EXPORT_C TUint8 CEdidParserBase::GetStandardTimings( TInt aIndex )
       
   583     {
       
   584     FUNC_LOG;
       
   585     
       
   586     TUint8 byte = 0;
       
   587     if( aIndex >= 0 && aIndex < 15 )
       
   588         {
       
   589         byte = iBaseEdidData.iStdTimingIdentifications[aIndex];
       
   590         }
       
   591     
       
   592     return byte;
       
   593     }
       
   594 
       
   595 // ----------------------------------------------------------------------------
       
   596 // CBaseEdid::GetDescriptorBlock
       
   597 // ----------------------------------------------------------------------------
       
   598 //
       
   599 EXPORT_C TEdidDescriptorBlock CEdidParserBase::GetDescriptorBlock( TUint8 aDescriptorBlockNumber ) const
       
   600     {
       
   601     FUNC_LOG;
       
   602 
       
   603     TEdidDescriptorBlock descBlock;
       
   604 
       
   605     descBlock.iPixelClock = GetPixelClock( aDescriptorBlockNumber );
       
   606 
       
   607     descBlock.iHorizontalAddressableVideoPixels
       
   608         = GetHorizontalAddressableVideo( aDescriptorBlockNumber );
       
   609 
       
   610     descBlock.iHorizontalBlanking
       
   611         = GetHorizontalBlanking( aDescriptorBlockNumber );
       
   612 
       
   613     descBlock.iVerticalAddressableVideoPixels
       
   614         = GetVerticalAddressableVideo( aDescriptorBlockNumber );
       
   615     
       
   616     descBlock.iVerticalBlanking
       
   617             = GetVerticalBlanking( aDescriptorBlockNumber );
       
   618     
       
   619     descBlock.iHorizontalFrontPorch
       
   620         = GetHorizontalFrontPorch( aDescriptorBlockNumber );
       
   621 
       
   622     descBlock.iHorizontalSyncPulse
       
   623         = GetHorizontalSyncPulseWidth( aDescriptorBlockNumber );
       
   624 
       
   625     descBlock.iVerticalFrontPorch
       
   626         = GetVerticalFrontPorch( aDescriptorBlockNumber );
       
   627 
       
   628     descBlock.iVerticalSyncPulse
       
   629         = GetVerticalSyncPulseWidth( aDescriptorBlockNumber );
       
   630 
       
   631     descBlock.iHorizontalAddressableImageSize
       
   632         = GetHorizontalAddressableImageSize( aDescriptorBlockNumber );
       
   633 
       
   634     descBlock.iVerticalAddressableImageSize
       
   635         = GetVerticalAddressableImageSize( aDescriptorBlockNumber );
       
   636 
       
   637     descBlock.iHorizontalBorder
       
   638         = GetHorizontalBorderSize( aDescriptorBlockNumber );
       
   639 
       
   640     descBlock.iVerticalBorder = GetVerticalBorderSize( aDescriptorBlockNumber );
       
   641 
       
   642     descBlock.iInterlacedVideo = GetVideoIsInterlaced( aDescriptorBlockNumber );
       
   643 
       
   644     descBlock.iStereoSupport = GetStereoViewingSupport( aDescriptorBlockNumber );
       
   645 
       
   646     descBlock.iSyncs = GetSyncSignalDefinitions( aDescriptorBlockNumber );
       
   647 
       
   648     return descBlock;
       
   649     }
       
   650 
       
   651 // ---------------------------------------------------------------------------
       
   652 // CEdidParserBase::GetNumberOfExtensions
       
   653 // ---------------------------------------------------------------------------
       
   654 //
       
   655 EXPORT_C TUint8 CEdidParserBase::GetNumberOfExtensions()
       
   656     {
       
   657     FUNC_LOG;
       
   658 
       
   659     // If Block Maps are used then 254 is the maximum value of number of
       
   660     // extension blocks. If Block Maps are not used then 255 is the maximum
       
   661     // value of number of extension blocks
       
   662     return iBaseEdidData.iExtensionNumber;
       
   663     }
       
   664 
       
   665 // ---------------------------------------------------------------------------
       
   666 // CEdidParserBase::GetExtension
       
   667 // ---------------------------------------------------------------------------
       
   668 //
       
   669 EXPORT_C TInt CEdidParserBase::ReadExtension( TInt aNumber )
       
   670     {
       
   671     FUNC_LOG;
       
   672 
       
   673     // |-----Base block-----|----Ext1----|---Ext2---|---.....|
       
   674     //                            ^           ^
       
   675     //                           Extension numbers (1,2,..)
       
   676     TInt err = KErrNone;
       
   677     if( aNumber <= GetNumberOfExtensions() )
       
   678         {
       
   679         // Make a copy of extension data. Call ReadExtensionL() with different
       
   680         // extension number to read other extension
       
   681         TPtr8 rawPtr = iRawData->Des();
       
   682         Mem::Copy( &iExtensionData, rawPtr.Ptr() + ( aNumber
       
   683             * KEdidParserSizeOfEdidBlock ), KEdidParserSizeOfEdidBlock );
       
   684         }
       
   685     else
       
   686         {
       
   687         // Invalid extension number. Return with KErrNotSupported
       
   688         err = KErrNotSupported;
       
   689         }
       
   690 
       
   691     return err;
       
   692     }
       
   693 
       
   694 // ---------------------------------------------------------------------------
       
   695 // CEdidParserBase::GetExtensionType
       
   696 // ---------------------------------------------------------------------------
       
   697 //
       
   698 EXPORT_C TEdidExtensionTagCode CEdidParserBase::GetExtensionType( TInt aNumber )
       
   699     {
       
   700     FUNC_LOG;
       
   701 
       
   702     TEdidExtensionTagCode tag( EUnknownExt );
       
   703     TInt err = ReadExtension( aNumber );
       
   704     if( err == KErrNone )
       
   705         {
       
   706         switch( iExtensionData[0] )
       
   707             {
       
   708             case 0x02:
       
   709                 tag = ECea861Ext;
       
   710                 break;
       
   711             case 0x10:
       
   712                 tag = EVTBExt;
       
   713                 break;
       
   714             case 0x20:
       
   715                 tag = EEDID20;
       
   716                 break;
       
   717             case 0x40:
       
   718                 tag = EDIExt;
       
   719                 break;
       
   720             case 0x50:
       
   721                 tag = ELSExt;
       
   722                 break;
       
   723             case 0x60:
       
   724                 tag = EDPVLExt;
       
   725                 break;
       
   726             default:
       
   727                 // tag is EUnknownExt
       
   728                 break;
       
   729             }
       
   730         }
       
   731 
       
   732     return tag;
       
   733     }
       
   734 
       
   735 // ---------------------------------------------------------------------------
       
   736 // CEdidParserBase::CreateCea861ExtensionParserL
       
   737 // ---------------------------------------------------------------------------
       
   738 //
       
   739 EXPORT_C CCea861EdidParser* CEdidParserBase::CreateCea861ExtensionParserL( TInt aNumber )
       
   740     {
       
   741     FUNC_LOG;
       
   742 
       
   743     CCea861EdidParser* parser = NULL;
       
   744     TInt ext = GetExtensionType( aNumber );
       
   745     switch( ext )
       
   746         {
       
   747         case ECea861Ext:
       
   748             {
       
   749             // CEA 861 extension
       
   750             parser = CCea861EdidParser::NewL( iExtensionData );
       
   751             break;
       
   752             }
       
   753         default:
       
   754             {
       
   755             // Not supported
       
   756             break;
       
   757             }
       
   758         }
       
   759 
       
   760     // Extension is not supported. Return NULL
       
   761     return parser;
       
   762     }
       
   763 
       
   764 // ---------------------------------------------------------------------------
       
   765 // CEdidParserBase::GetChecksum
       
   766 // ---------------------------------------------------------------------------
       
   767 //
       
   768 EXPORT_C TUint8 CEdidParserBase::GetChecksum()
       
   769     {
       
   770     FUNC_LOG;
       
   771 
       
   772     // The Checksum Byte contains a value such that a checksum of the entire
       
   773     // 128 byte base EDID equals 00h
       
   774     return iBaseEdidData.iChecksum;
       
   775     }
       
   776 
       
   777 // ----------------------------------------------------------------------------
       
   778 // CEdidParserBase::GetPixelClock
       
   779 // ----------------------------------------------------------------------------
       
   780 //
       
   781 TUint16 CEdidParserBase::GetPixelClock( TUint8 aDataBlockNumber ) const
       
   782     {
       
   783     FUNC_LOG;
       
   784 
       
   785     // Stored Value = Pixel clock ÷ 10,000
       
   786     // LSB stored in byte 0 and MSB stored in byte 1
       
   787     // 0, 1 2 Range: 10 kHz to 655.35 MHz in 10 kHz steps
       
   788     // (00 00)h Reserved: Do not use for Detailed Timing Descriptor
       
   789 
       
   790     TUint16 word1;
       
   791     TUint16 word2;
       
   792 
       
   793     if( aDataBlockNumber == 1 )
       
   794         {
       
   795         word1 = iBaseEdidData.iTimingDescriptor[0];
       
   796         word2 = iBaseEdidData.iTimingDescriptor[1];
       
   797         }
       
   798     else if( aDataBlockNumber == 2 )
       
   799         {
       
   800         word1 = iBaseEdidData.iSecondTimingDescriptor[0];
       
   801         word2 = iBaseEdidData.iSecondTimingDescriptor[1];
       
   802         }
       
   803     else if( aDataBlockNumber == 3 )
       
   804         {
       
   805         word1 = iBaseEdidData.iMonitorDescriptor[0];
       
   806         word2 = iBaseEdidData.iMonitorDescriptor[1];
       
   807         }
       
   808     else
       
   809         {
       
   810         //ERROR
       
   811         return 0;
       
   812         }
       
   813 
       
   814     // xxxx xxxx 1010 1010
       
   815     TUint16 pixelClock = word2;
       
   816     // 1010 1010 xxxx xxxx shifted to left (MSB)
       
   817     pixelClock = pixelClock << 8;
       
   818     // 1010 1010 0101 0101 add the LSB
       
   819     pixelClock += word1;
       
   820 
       
   821     return pixelClock;
       
   822     }
       
   823 
       
   824 // ----------------------------------------------------------------------------
       
   825 // CEdidParserBase::GetHorizontalAddressableVideo
       
   826 // ----------------------------------------------------------------------------
       
   827 //
       
   828 TUint16 CEdidParserBase::GetHorizontalAddressableVideo( TUint8 aDataBlockNumber ) const
       
   829     {
       
   830     FUNC_LOG;
       
   831 
       
   832     TUint16 word1;
       
   833     TUint16 word2;
       
   834 
       
   835     if( aDataBlockNumber == 1 )
       
   836         {
       
   837         word1 = iBaseEdidData.iTimingDescriptor[4];
       
   838         word2 = iBaseEdidData.iTimingDescriptor[2];
       
   839         }
       
   840     else if( aDataBlockNumber == 2 )
       
   841         {
       
   842         word1 = iBaseEdidData.iSecondTimingDescriptor[4];
       
   843         word2 = iBaseEdidData.iSecondTimingDescriptor[2];
       
   844         }
       
   845     else if( aDataBlockNumber == 3 )
       
   846         {
       
   847         word1 = iBaseEdidData.iMonitorDescriptor[4];
       
   848         word2 = iBaseEdidData.iMonitorDescriptor[2];
       
   849         }
       
   850     else
       
   851         {
       
   852         //ERROR
       
   853         return 0;
       
   854         }
       
   855 
       
   856     // 12bits long, defined in 8 bits of byte 2 and
       
   857     // upper nibble of byte 4 (4bits), range 0-4095
       
   858     TUint16 horAddrVideo = 0;
       
   859 
       
   860     // Nullify the 4 lsb
       
   861     // ---- ---- xxxx yyyy >> 4  = ---- ---- ---- xxxx
       
   862     horAddrVideo = word1 >> 4;
       
   863     // return back to original position (4)+4
       
   864     // ---- ---- ---- xxxx << 4  = ---- xxxx 0000 0000
       
   865     horAddrVideo = horAddrVideo << ( 4 + 4 );
       
   866     // ---- xxxx zzzz zzzz = correct values for the 12-bit-long var
       
   867     horAddrVideo += word2;
       
   868 
       
   869     return horAddrVideo;
       
   870     }
       
   871 
       
   872 // ----------------------------------------------------------------------------
       
   873 // CBaseEdid::GetHorizontalBlanking
       
   874 // ----------------------------------------------------------------------------
       
   875 //
       
   876 TUint16 CEdidParserBase::GetHorizontalBlanking( TUint8 aDataBlockNumber ) const
       
   877     {
       
   878     FUNC_LOG;
       
   879 
       
   880     TUint16 word1;
       
   881     TUint16 word2;
       
   882 
       
   883     if( aDataBlockNumber == 1 )
       
   884         {
       
   885         word1 = iBaseEdidData.iTimingDescriptor[4];
       
   886         word2 = iBaseEdidData.iTimingDescriptor[3];
       
   887         }
       
   888     else if( aDataBlockNumber == 2 )
       
   889         {
       
   890         word1 = iBaseEdidData.iSecondTimingDescriptor[4];
       
   891         word2 = iBaseEdidData.iSecondTimingDescriptor[3];
       
   892         }
       
   893     else if( aDataBlockNumber == 3 )
       
   894         {
       
   895         word1 = iBaseEdidData.iMonitorDescriptor[4];
       
   896         word2 = iBaseEdidData.iMonitorDescriptor[3];
       
   897         }
       
   898     else
       
   899         {
       
   900         //ERROR
       
   901         return 0;
       
   902         }
       
   903 
       
   904     TUint16 horBlanking = 0;
       
   905 
       
   906     // nullify the 4 msb
       
   907     //      ---- ---- xxxx yyyy << 12 = yyyy ---- ---- ----
       
   908     horBlanking = word1 << 12;
       
   909     // nullify the 4 msb
       
   910     // yyyy ---- ---- ---- >> 4  = ---- yyyy ---- ----
       
   911     horBlanking = horBlanking >> 4;
       
   912     // ---- yyyy zzzz zzzz = correct values for the 12-bit-long var
       
   913     horBlanking += word2;
       
   914 
       
   915     return horBlanking;
       
   916     }
       
   917 
       
   918 // ----------------------------------------------------------------------------
       
   919 // CBaseEdid::GetVerticalAddressableVideo
       
   920 // ----------------------------------------------------------------------------
       
   921 //
       
   922 TUint16 CEdidParserBase::GetVerticalAddressableVideo( TUint8 aDataBlockNumber ) const
       
   923     {
       
   924     FUNC_LOG;
       
   925 
       
   926     TUint16 word1;
       
   927     TUint16 word2;
       
   928 
       
   929     if( aDataBlockNumber == 1 )
       
   930         {
       
   931         word1 = iBaseEdidData.iTimingDescriptor[7];
       
   932         word2 = iBaseEdidData.iTimingDescriptor[5];
       
   933         }
       
   934     else if( aDataBlockNumber == 2 )
       
   935         {
       
   936         word1 = iBaseEdidData.iSecondTimingDescriptor[7];
       
   937         word2 = iBaseEdidData.iSecondTimingDescriptor[5];
       
   938         }
       
   939     else if( aDataBlockNumber == 3 )
       
   940         {
       
   941         word1 = iBaseEdidData.iMonitorDescriptor[7];
       
   942         word2 = iBaseEdidData.iMonitorDescriptor[5];
       
   943         }
       
   944     else
       
   945         {
       
   946         //ERROR
       
   947         return 0;
       
   948         }
       
   949 
       
   950     //Upper nibble of byte 7 and the 8 bits of byte 5)
       
   951     //Range is 0 lines to 4095 lines
       
   952     TUint16 vertAddrVideo = 0;
       
   953     vertAddrVideo = word1 >> 4;
       
   954     vertAddrVideo = vertAddrVideo << ( 4 + 4 );
       
   955     vertAddrVideo += word2;
       
   956 
       
   957     return vertAddrVideo;
       
   958     }
       
   959 
       
   960 // ----------------------------------------------------------------------------
       
   961 // CBaseEdid::GetVerticalBlanking
       
   962 // ----------------------------------------------------------------------------
       
   963 //
       
   964 TUint16 CEdidParserBase::GetVerticalBlanking( TUint8 aDataBlockNumber ) const
       
   965     {
       
   966     FUNC_LOG;
       
   967 
       
   968     TUint16 word1;
       
   969     TUint16 word2;
       
   970 
       
   971     if( aDataBlockNumber == 1 )
       
   972         {
       
   973         word1 = iBaseEdidData.iTimingDescriptor[7];
       
   974         word2 = iBaseEdidData.iTimingDescriptor[6];
       
   975         }
       
   976     else if( aDataBlockNumber == 2 )
       
   977         {
       
   978         word1 = iBaseEdidData.iSecondTimingDescriptor[7];
       
   979         word2 = iBaseEdidData.iSecondTimingDescriptor[6];
       
   980         }
       
   981     else if( aDataBlockNumber == 3 )
       
   982         {
       
   983         word1 = iBaseEdidData.iMonitorDescriptor[7];
       
   984         word2 = iBaseEdidData.iMonitorDescriptor[6];
       
   985         }
       
   986     else
       
   987         {
       
   988         //ERROR
       
   989         return 0;
       
   990         }
       
   991 
       
   992     // 12bits long, defined in 8 bits of byte 2 and
       
   993     // upper nibble of byte 4 (4bits), range 0-4095
       
   994     TUint16 vertBlanking = 0;
       
   995 
       
   996     // nullify the 4 msb
       
   997     // ---- ---- xxxx yyyy << 12 = yyyy ---- ---- ----
       
   998     vertBlanking = word1 << 12;
       
   999     // nullify the 4 msb
       
  1000     // yyyy ---- ---- ---- >> 4  = 0000 yyyy ---- ----
       
  1001     vertBlanking = vertBlanking >> 4;
       
  1002     // ---- yyyy zzzz zzzz = correct values for the 12-bit-long var
       
  1003     vertBlanking += word2;
       
  1004 
       
  1005     return vertBlanking;
       
  1006     }
       
  1007 
       
  1008 // ----------------------------------------------------------------------------
       
  1009 // CBaseEdid::GetHorizontalFrontPorch
       
  1010 // ----------------------------------------------------------------------------
       
  1011 //
       
  1012 TUint16 CEdidParserBase::GetHorizontalFrontPorch( TUint8 aDataBlockNumber ) const
       
  1013     {
       
  1014     FUNC_LOG;
       
  1015 
       
  1016     TUint16 word1;
       
  1017     TUint16 word2;
       
  1018 
       
  1019     if( aDataBlockNumber == 1 )
       
  1020         {
       
  1021         word1 = iBaseEdidData.iTimingDescriptor[6];
       
  1022         word2 = iBaseEdidData.iTimingDescriptor[8];
       
  1023         }
       
  1024     else if( aDataBlockNumber == 2 )
       
  1025         {
       
  1026         word1 = iBaseEdidData.iSecondTimingDescriptor[6];
       
  1027         word2 = iBaseEdidData.iSecondTimingDescriptor[8];
       
  1028         }
       
  1029     else if( aDataBlockNumber == 3 )
       
  1030         {
       
  1031         word1 = iBaseEdidData.iMonitorDescriptor[6];
       
  1032         word2 = iBaseEdidData.iMonitorDescriptor[8];
       
  1033         }
       
  1034     else
       
  1035         {
       
  1036         //ERROR
       
  1037         return 0;
       
  1038         }
       
  1039 
       
  1040     // Horizontal Front Porch in Pixels (from blanking start to start of sync)
       
  1041     // is represented by a 10 bit number (Bits 7 & 6 of byte 11 and the 8 bits of byte 8)
       
  1042     // Range is 0 pixels to 1023 pixels.
       
  1043 
       
  1044     TUint16 horFrontPorch = 0;
       
  1045 
       
  1046     TUint8 bit67 = word1;
       
  1047     // bits 6 and 7 remain
       
  1048     bit67 = ( bit67 & KBit7 ) | ( bit67 & KBit6 );
       
  1049 
       
  1050     horFrontPorch = bit67 << 2;
       
  1051     horFrontPorch += word2;
       
  1052 
       
  1053     return horFrontPorch;
       
  1054     }
       
  1055 
       
  1056 // ----------------------------------------------------------------------------
       
  1057 // CEdidParserBase::GetHorizontalSyncPulseWidth
       
  1058 // ----------------------------------------------------------------------------
       
  1059 //
       
  1060 TUint16 CEdidParserBase::GetHorizontalSyncPulseWidth( TUint8 aDataBlockNumber ) const
       
  1061     {
       
  1062     FUNC_LOG;
       
  1063 
       
  1064     //Horizontal Sync Pulse Width in Pixels (from the end of the front porch to the start of the back
       
  1065     //porch) is represented by a 10 bit number (Bits 5 & 4 of byte 11 and the 8 bits of byte 9) - Range
       
  1066     //is 0 pixels to 1023 pixels.
       
  1067 
       
  1068     TUint8 word1;
       
  1069     TUint8 word2;
       
  1070 
       
  1071     if( aDataBlockNumber == 1 )
       
  1072         {
       
  1073         word1 = iBaseEdidData.iTimingDescriptor[11];
       
  1074         word2 = iBaseEdidData.iTimingDescriptor[9];
       
  1075         }
       
  1076     else if( aDataBlockNumber == 2 )
       
  1077         {
       
  1078         word1 = iBaseEdidData.iSecondTimingDescriptor[11];
       
  1079         word2 = iBaseEdidData.iSecondTimingDescriptor[9];
       
  1080         }
       
  1081     else if( aDataBlockNumber == 3 )
       
  1082         {
       
  1083         word1 = iBaseEdidData.iMonitorDescriptor[11];
       
  1084         word2 = iBaseEdidData.iMonitorDescriptor[9];
       
  1085         }
       
  1086     else
       
  1087         {
       
  1088         //ERROR
       
  1089         return 0;
       
  1090         }
       
  1091 
       
  1092     TUint16 horSyncPulseWidth = word1;
       
  1093 
       
  1094     // only bits 5 and 4 remain: xx00 xxxx
       
  1095     horSyncPulseWidth = ( horSyncPulseWidth & KBit5 ) | ( horSyncPulseWidth
       
  1096         & KBit4 );
       
  1097 
       
  1098     // xx00 xxxx -> xx00 xxxx xxxx
       
  1099     horSyncPulseWidth = horSyncPulseWidth << 4;
       
  1100 
       
  1101     // xx00 xxxx xxxx -> 00 0000 0000
       
  1102     horSyncPulseWidth += word2;
       
  1103 
       
  1104     return horSyncPulseWidth;
       
  1105     }
       
  1106 
       
  1107 // ----------------------------------------------------------------------------
       
  1108 // CEdidParserBase::GetVerticalFrontPorch
       
  1109 // ----------------------------------------------------------------------------
       
  1110 //
       
  1111 TUint16 CEdidParserBase::GetVerticalFrontPorch( TUint8 aDataBlockNumber ) const
       
  1112     {
       
  1113     FUNC_LOG;
       
  1114 
       
  1115     // Vertical Front Porch in Lines (from blanking start to start of sync) is represented by a 6 bit
       
  1116     // number (Bits 3 & 2 of byte 11 and the upper nibble of byte 10) - Range is 0 lines to 63 lines.
       
  1117 
       
  1118     TUint16 word1;
       
  1119     TUint16 word2;
       
  1120 
       
  1121     if( aDataBlockNumber == 1 )
       
  1122         {
       
  1123         word1 = iBaseEdidData.iTimingDescriptor[11];
       
  1124         word2 = iBaseEdidData.iTimingDescriptor[10];
       
  1125         }
       
  1126     else if( aDataBlockNumber == 2 )
       
  1127         {
       
  1128         word1 = iBaseEdidData.iSecondTimingDescriptor[11];
       
  1129         word2 = iBaseEdidData.iSecondTimingDescriptor[10];
       
  1130         }
       
  1131     else if( aDataBlockNumber == 3 )
       
  1132         {
       
  1133         word1 = iBaseEdidData.iMonitorDescriptor[11];
       
  1134         word2 = iBaseEdidData.iMonitorDescriptor[10];
       
  1135         }
       
  1136     else
       
  1137         {
       
  1138         //ERROR
       
  1139         return 0;
       
  1140         }
       
  1141 
       
  1142     TUint16 vertFrontPorch = 0;
       
  1143     TUint8 bit23 = word1;
       
  1144 
       
  1145     // bits 2 and 3 remain  0000 xx00
       
  1146     bit23 = ( bit23 & KBit3 ) | ( bit23 & KBit2 );
       
  1147 
       
  1148     // 00xx 0000
       
  1149     vertFrontPorch = bit23 << 2;
       
  1150 
       
  1151     // only the upper nibble
       
  1152     // 00xx yyyy
       
  1153     vertFrontPorch += ( word2 >> 4 );
       
  1154 
       
  1155     return vertFrontPorch;
       
  1156     }
       
  1157 
       
  1158 // ----------------------------------------------------------------------------
       
  1159 // CEdidParserBase::GetVerticalSyncPulseWidth
       
  1160 // ----------------------------------------------------------------------------
       
  1161 //
       
  1162 TUint8 CEdidParserBase::GetVerticalSyncPulseWidth( TUint8 aDataBlockNumber ) const
       
  1163     {
       
  1164     FUNC_LOG;
       
  1165 
       
  1166     // Vertical Sync Pulse Width in Lines (from the end of the front porch to the start of the back
       
  1167     // porch) is represented by a 6 bit number (Bits 1 & 0 of byte 11 and the lower nibble of byte 10 -
       
  1168     // Range is 0 lines to 63 lines.
       
  1169 
       
  1170     TUint8 word1;
       
  1171     TUint8 word2;
       
  1172 
       
  1173     if( aDataBlockNumber == 1 )
       
  1174         {
       
  1175         word1 = iBaseEdidData.iTimingDescriptor[10];
       
  1176         word2 = iBaseEdidData.iTimingDescriptor[11];
       
  1177         }
       
  1178     else if( aDataBlockNumber == 2 )
       
  1179         {
       
  1180         word1 = iBaseEdidData.iSecondTimingDescriptor[10];
       
  1181         word2 = iBaseEdidData.iSecondTimingDescriptor[11];
       
  1182         }
       
  1183     else if( aDataBlockNumber == 3 )
       
  1184         {
       
  1185         word1 = iBaseEdidData.iMonitorDescriptor[10];
       
  1186         word2 = iBaseEdidData.iMonitorDescriptor[11];
       
  1187         }
       
  1188     else
       
  1189         {
       
  1190         //ERROR
       
  1191         return 0;
       
  1192         }
       
  1193 
       
  1194     // Vertical Sync Pulse Width in Lines (from the end of the front porch to the start of the back
       
  1195     // porch) is represented by a 6 bit number (Bits 1 & 0 of byte 11 and the lower nibble of byte 10 -
       
  1196     // Range is 0 lines to 63 lines.
       
  1197     TUint8 vertSyncPulse = 0;
       
  1198 
       
  1199     // bits 1 and 0 remain   0000 00xx
       
  1200     word2 = ( word2 & KBit1 ) | ( word2 & KBit0 );
       
  1201 
       
  1202     // 00xx 0000
       
  1203     vertSyncPulse = word2 << 4;
       
  1204     // only the lower nibble, %16 removes the upper nibble
       
  1205     word1 = word1 % 16;
       
  1206     // 00xx yyyy
       
  1207     vertSyncPulse += word1;
       
  1208 
       
  1209     return vertSyncPulse;
       
  1210     }
       
  1211 
       
  1212 // ----------------------------------------------------------------------------
       
  1213 // CEdidParserBase::GetHorizontalAddressableImageSize
       
  1214 // ----------------------------------------------------------------------------
       
  1215 //
       
  1216 TUint16 CEdidParserBase::GetHorizontalAddressableImageSize( TUint8 aDataBlockNumber ) const
       
  1217     {
       
  1218     FUNC_LOG;
       
  1219 
       
  1220     TUint16 word1;
       
  1221     TUint16 word2;
       
  1222 
       
  1223     if( aDataBlockNumber == 1 )
       
  1224         {
       
  1225         word1 = iBaseEdidData.iTimingDescriptor[14];
       
  1226         word2 = iBaseEdidData.iTimingDescriptor[12];
       
  1227         }
       
  1228     else if( aDataBlockNumber == 2 )
       
  1229         {
       
  1230         word1 = iBaseEdidData.iSecondTimingDescriptor[14];
       
  1231         word2 = iBaseEdidData.iSecondTimingDescriptor[12];
       
  1232         }
       
  1233     else if( aDataBlockNumber == 3 )
       
  1234         {
       
  1235         word1 = iBaseEdidData.iMonitorDescriptor[14];
       
  1236         word2 = iBaseEdidData.iMonitorDescriptor[12];
       
  1237         }
       
  1238     else
       
  1239         {
       
  1240         //ERROR
       
  1241         return 0;
       
  1242         }
       
  1243 
       
  1244     //Horizontal Addressable Video Image Size in mm is represented by a 12 bit number (Upper
       
  1245     //nibble of byte 14 and the 8 bits of byte 12) - Range is 0 mm to 4095 mm.
       
  1246 
       
  1247     TUint16 hais = word1 >> 4; // first nullify 4 lsb
       
  1248     hais = hais << ( 4 + 4 ); // and then move back the first 4 and then again 4
       
  1249     hais += word2;
       
  1250 
       
  1251     return hais;
       
  1252     }
       
  1253 
       
  1254 // ----------------------------------------------------------------------------
       
  1255 // CEdidParserBase::GetVerticalAddressableImageSize
       
  1256 // ----------------------------------------------------------------------------
       
  1257 //
       
  1258 TUint16 CEdidParserBase::GetVerticalAddressableImageSize( TUint8 aDataBlockNumber ) const
       
  1259     {
       
  1260     FUNC_LOG;
       
  1261 
       
  1262     TUint16 word1;
       
  1263     TUint16 word2;
       
  1264 
       
  1265     if( aDataBlockNumber == 1 )
       
  1266         {
       
  1267         word1 = iBaseEdidData.iTimingDescriptor[14];
       
  1268         word2 = iBaseEdidData.iTimingDescriptor[13];
       
  1269         }
       
  1270     else if( aDataBlockNumber == 2 )
       
  1271         {
       
  1272         word1 = iBaseEdidData.iSecondTimingDescriptor[14];
       
  1273         word2 = iBaseEdidData.iSecondTimingDescriptor[13];
       
  1274         }
       
  1275     else if( aDataBlockNumber == 3 )
       
  1276         {
       
  1277         word1 = iBaseEdidData.iMonitorDescriptor[14];
       
  1278         word2 = iBaseEdidData.iMonitorDescriptor[13];
       
  1279         }
       
  1280     else
       
  1281         {
       
  1282         //ERROR
       
  1283         return 0;
       
  1284         }
       
  1285 
       
  1286     //Vertical Addressable Video Image Size in mm is represented by a 12 bit number (Lower nibble
       
  1287     //of byte 14 and the 8 bits of byte 13) - Range is 0 mm to 4095 mm.
       
  1288 
       
  1289     TUint16 vais = word1;
       
  1290     vais = vais << 12; // first nullify 4 msb and then move back 1 nibble
       
  1291     vais = vais >> 4;
       
  1292     vais += word2;
       
  1293 
       
  1294     return vais;
       
  1295     }
       
  1296 
       
  1297 // ----------------------------------------------------------------------------
       
  1298 // CEdidParserBase::GetHorizontalBorderSize
       
  1299 // ----------------------------------------------------------------------------
       
  1300 //
       
  1301 TUint8 CEdidParserBase::GetHorizontalBorderSize( TUint8 aDataBlockNumber ) const
       
  1302     {
       
  1303     FUNC_LOG;
       
  1304 
       
  1305     TUint16 word1;
       
  1306 
       
  1307     if( aDataBlockNumber == 1 )
       
  1308         {
       
  1309         word1 = iBaseEdidData.iTimingDescriptor[15];
       
  1310         }
       
  1311     else if( aDataBlockNumber == 2 )
       
  1312         {
       
  1313         word1 = iBaseEdidData.iSecondTimingDescriptor[15];
       
  1314         }
       
  1315     else if( aDataBlockNumber == 3 )
       
  1316         {
       
  1317         word1 = iBaseEdidData.iMonitorDescriptor[15];
       
  1318         }
       
  1319     else
       
  1320         {
       
  1321         //ERROR
       
  1322         return 0;
       
  1323         }
       
  1324 
       
  1325     //Right Horizontal Border or Left Horizontal Border in Pixels is represented by
       
  1326     // an 8 bit number (the 8 bits of byte 15) - Range is 0 pixels to 255 pixels.
       
  1327 
       
  1328     // the same value is used for (left and right) / (top and bottom)
       
  1329     return word1;
       
  1330     }
       
  1331 
       
  1332 // ----------------------------------------------------------------------------
       
  1333 // CEdidParserBase::GetVerticalBorderSize
       
  1334 // ----------------------------------------------------------------------------
       
  1335 //
       
  1336 TUint8 CEdidParserBase::GetVerticalBorderSize( TUint8 aDataBlockNumber ) const
       
  1337     {
       
  1338     FUNC_LOG;
       
  1339 
       
  1340     TUint16 word1;
       
  1341 
       
  1342     if( aDataBlockNumber == 1 )
       
  1343         {
       
  1344         word1 = iBaseEdidData.iTimingDescriptor[16];
       
  1345         }
       
  1346     else if( aDataBlockNumber == 2 )
       
  1347         {
       
  1348         word1 = iBaseEdidData.iSecondTimingDescriptor[16];
       
  1349         }
       
  1350     else if( aDataBlockNumber == 3 )
       
  1351         {
       
  1352         word1 = iBaseEdidData.iMonitorDescriptor[16];
       
  1353         }
       
  1354     else
       
  1355         {
       
  1356         //ERROR
       
  1357         return 0;
       
  1358         }
       
  1359 
       
  1360     //Top Vertical Border or Bottom Vertical Border in Lines is represented by an 8 bit number (the
       
  1361     //8 bits of byte 16) - Range is 0 lines to 255 lines.
       
  1362     return word1;
       
  1363     }
       
  1364 
       
  1365 // ----------------------------------------------------------------------------
       
  1366 // CEdidParserBase::GetVideoIsInterlaced
       
  1367 // ----------------------------------------------------------------------------
       
  1368 //
       
  1369 TBool CEdidParserBase::GetVideoIsInterlaced( TUint8 aDataBlockNumber ) const
       
  1370     {
       
  1371     FUNC_LOG;
       
  1372 
       
  1373     TUint16 word1;
       
  1374     if( aDataBlockNumber == 1 )
       
  1375         {
       
  1376         word1 = iBaseEdidData.iTimingDescriptor[17];
       
  1377         }
       
  1378     else if( aDataBlockNumber == 2 )
       
  1379         {
       
  1380         word1 = iBaseEdidData.iSecondTimingDescriptor[17];
       
  1381         }
       
  1382     else if( aDataBlockNumber == 3 )
       
  1383         {
       
  1384         word1 = iBaseEdidData.iMonitorDescriptor[17];
       
  1385         }
       
  1386     else
       
  1387         {
       
  1388         //ERROR
       
  1389         return EFalse;
       
  1390         }
       
  1391 
       
  1392     // byte 17
       
  1393     // Bytes Bit Definitions Detailed Timing Definitions
       
  1394     // 7 6 5 4 3 2 1 0 Signal Interface Type:
       
  1395     // 0 _ _ _ _ _ _ _ Non-Interlaced (1 frame = 1 field)
       
  1396     // 1 _ _ _ _ _ _ _ Interlaced (1 frame = 2 fields)
       
  1397 
       
  1398     return KBit7 & word1;
       
  1399     }
       
  1400 
       
  1401 // ----------------------------------------------------------------------------
       
  1402 // CBaseEdid::GetStereoViewingSupport
       
  1403 // ----------------------------------------------------------------------------
       
  1404 //
       
  1405 TEdidStereoViewingSupport CEdidParserBase::GetStereoViewingSupport( TUint8 aDataBlockNumber ) const
       
  1406     {
       
  1407     FUNC_LOG;
       
  1408 
       
  1409     TUint16 word1;
       
  1410 
       
  1411     if( aDataBlockNumber == 1 )
       
  1412         {
       
  1413         word1 = iBaseEdidData.iTimingDescriptor[17];
       
  1414         }
       
  1415     else if( aDataBlockNumber == 2 )
       
  1416         {
       
  1417         word1 = iBaseEdidData.iSecondTimingDescriptor[17];
       
  1418         }
       
  1419     else if( aDataBlockNumber == 3 )
       
  1420         {
       
  1421         word1 = iBaseEdidData.iMonitorDescriptor[17];
       
  1422         }
       
  1423     else
       
  1424         {
       
  1425         //ERROR
       
  1426         return EUnknownStereoViewingSupport;
       
  1427         }
       
  1428 
       
  1429     //Bytes Bit Definitions Detailed Timing Definitions
       
  1430     //_ 6 5 _ _ _ _ 0 Stereo Viewing Support:
       
  1431     //  0 0 _ _ _ _ x Normal Display – No Stereo. The value of bit 0 is "don't care"
       
  1432     //  0 1 _ _ _ _ 0 Field sequential stereo, right image when stereo sync signal = 1
       
  1433     //  1 0 _ _ _ _ 0 Field sequential stereo, left image when stereo sync signal = 1
       
  1434     //  0 1 _ _ _ _ 1 2-way interleaved stereo, right image on even lines
       
  1435     //  1 0 _ _ _ _ 1 2-way interleaved stereo, left image on even lines
       
  1436     //  1 1 _ _ _ _ 0 4-way interleaved stereo
       
  1437     //  1 1 _ _ _ _ 1 Side-by-Side interleaved stereo
       
  1438     TUint8 bit17 = word1;
       
  1439     if( !( ( KBit6 & bit17 ) | ( KBit5 & bit17 ) ) ) //  0 0 _ _ _ _ x Normal Display – No Stereo.
       
  1440         { //                The value of bit 0 is "don't care"
       
  1441         return ENormalDisplay;
       
  1442         }
       
  1443     else if( !( KBit6 & bit17 ) && ( KBit5 & bit17 ) && !( KBit0 & bit17 ) ) //  0 1 _ _ _ _ 0 Field sequential stereo,
       
  1444         { //                right image when stereo sync signal=1
       
  1445         return EFieldSequentialStereoRightWhenStereoSyncSignal1;
       
  1446         }
       
  1447     else if( ( KBit6 & bit17 ) && !( KBit5 & bit17 ) && !( KBit0 & bit17 ) ) //  1 0 _ _ _ _ 0 Field sequential stereo,
       
  1448         { //                left image when stereo sync signal=1
       
  1449         return EFieldSequentialStereoLeftWhenStereoSyncSignal1;
       
  1450         }
       
  1451     else if( !( KBit6 & bit17 ) && ( KBit5 & bit17 ) && ( KBit0 & bit17 ) ) //  0 1 _ _ _ _ 1 2-way interleaved stereo,
       
  1452         { //                right image on even lines
       
  1453         return ETwoWayInterleavedStereoRightImageOnEvenLines;
       
  1454         }
       
  1455     else if( ( KBit6 & bit17 ) && !( KBit5 & bit17 ) && ( KBit0 & bit17 ) ) //  1 0 _ _ _ _ 1 2-way interleaved stereo,
       
  1456         { //                left image on even lines
       
  1457         return ETwoWayInterleavedStereoLeftImageOnEvenLines;
       
  1458         }
       
  1459     else if( ( KBit6 & bit17 ) && ( KBit5 & bit17 ) && !( KBit0 & bit17 ) ) //  1 1 _ _ _ _ 0 4-way interleaved stereo
       
  1460         {
       
  1461         return EFourWayInterleaverStereo;
       
  1462         }
       
  1463     else if( ( KBit6 & bit17 ) && ( KBit5 & bit17 ) && ( KBit0 & bit17 ) ) //  1 1 _ _ _ _ 1 Side-by-Side interleaved stereo
       
  1464         {
       
  1465         return ESideBySideInterleavedStere;
       
  1466         }
       
  1467     else
       
  1468         {
       
  1469         // ERROR
       
  1470         return EUnknownStereoViewingSupport;
       
  1471         }
       
  1472 
       
  1473     // Unreachable
       
  1474     }
       
  1475 
       
  1476 // ----------------------------------------------------------------------------
       
  1477 // CBaseEdid::GetSyncSignalDefinitions
       
  1478 // ----------------------------------------------------------------------------
       
  1479 //
       
  1480 TEdidSyncSignalDefinitions CEdidParserBase::GetSyncSignalDefinitions( TUint8 aDataBlockNumber ) const
       
  1481     {
       
  1482     FUNC_LOG;
       
  1483 
       
  1484     // byte 17
       
  1485     // 4 3 2 1 _ Analog Sync Signal Definitions:
       
  1486     //------------------------------------------
       
  1487     // 0 0 _ _ _ Analog Composite Sync:
       
  1488     // 0 1 _ _ _ Bipolar Analog Composite Sync:
       
  1489 
       
  1490     TUint8 byte17 = 0;
       
  1491     if( aDataBlockNumber == 1 )
       
  1492         {
       
  1493         byte17 = iBaseEdidData.iTimingDescriptor[17];
       
  1494         }
       
  1495     else if( aDataBlockNumber == 2 )
       
  1496         {
       
  1497         byte17 = iBaseEdidData.iSecondTimingDescriptor[17];
       
  1498         }
       
  1499     else if( aDataBlockNumber == 3 )
       
  1500         {
       
  1501         byte17 = iBaseEdidData.iMonitorDescriptor[17];
       
  1502         }
       
  1503     else
       
  1504         {
       
  1505         // ERROR
       
  1506         return EUnknownSignalDefinition;
       
  1507         }
       
  1508 
       
  1509     if( !( KBit4 & byte17 ) ) // if bit4 == 0 then this is analog display
       
  1510         {
       
  1511         return GetAnalogSyncSignalDefinitions( byte17 );
       
  1512         }
       
  1513     else
       
  1514         {
       
  1515         return GetDigitalSyncSignalDefinitions( byte17 );
       
  1516         }
       
  1517     // unreachable
       
  1518     }
       
  1519 
       
  1520 // ----------------------------------------------------------------------------
       
  1521 // CBaseEdid::GetAnalogSyncSignalDefinitions
       
  1522 // ----------------------------------------------------------------------------
       
  1523 //
       
  1524 TEdidSyncSignalDefinitions CEdidParserBase::GetAnalogSyncSignalDefinitions( const TUint aByte17 )
       
  1525     {
       
  1526     FUNC_LOG;
       
  1527 
       
  1528     // byte 17
       
  1529     // 4 3 2 1 _ Analog Sync Signal Definitions:
       
  1530     //------------------------------------------
       
  1531     // 0 0 _ _ _ Analog Composite Sync:
       
  1532     // 0 1 _ _ _ Bipolar Analog Composite Sync:
       
  1533     // 0 _ 0 _ _ ---------- Without Serrations;
       
  1534     // 0 _ 1 _ _ ---------- With Serrations (H-sync during V-sync);
       
  1535     // 0 _ _ 0 _ -------------------- Sync On Green Signal only
       
  1536     // 0 _ _ 1 _ -------------------- Sync On all three (RGB) video signals
       
  1537 
       
  1538     TBool ACS = !( KBit3 & aByte17 ); // if true -> bipolar analog composite sync
       
  1539     TBool serrations = KBit2 & aByte17;
       
  1540     TBool syncOnGreen = !( KBit1 & aByte17 );
       
  1541 
       
  1542     if( ACS )
       
  1543         {
       
  1544         if( !serrations )
       
  1545             {
       
  1546             if( syncOnGreen )
       
  1547                 {
       
  1548                 return EAnalogCompositeSyncWithoutSerrationsSyncSyncOnGreenSignalOnly;
       
  1549                 }
       
  1550             else
       
  1551                 {
       
  1552                 return EAnalogCompositeSyncWithoutSerrationsSyncOnAllThreeVideoSignals;
       
  1553                 }
       
  1554             }
       
  1555         else
       
  1556             {
       
  1557             if( syncOnGreen )
       
  1558                 {
       
  1559                 return EAnalogCompositeSyncWithoutSerrationsSyncSyncOnGreenSignalOnly;
       
  1560                 }
       
  1561             else
       
  1562                 {
       
  1563                 return EAnalogCompositeSyncWithoutSerrationsSyncOnAllThreeVideoSignals;
       
  1564                 }
       
  1565             }
       
  1566         }
       
  1567     else
       
  1568         {
       
  1569         if( !serrations )
       
  1570             {
       
  1571             if( syncOnGreen )
       
  1572                 {
       
  1573                 return EAnalogBipolarAnalogCompositeSyncWithoutSerrationsSyncSyncOnGreenSignalOnly;
       
  1574                 }
       
  1575             else
       
  1576                 {
       
  1577                 return EAnalogBipolarAnalogCompositeSyncWithoutSerrationsSyncOnAllThreeVideoSignals;
       
  1578                 }
       
  1579             }
       
  1580         else
       
  1581             {
       
  1582             if( syncOnGreen )
       
  1583                 {
       
  1584                 return EAnalogBipolarAnalogCompositeSyncWithSerrationsSyncSyncOnGreenSignalOnly;
       
  1585                 }
       
  1586             else
       
  1587                 {
       
  1588                 return EAnalogBipolarAnalogCompositeSyncWithSerrationsSyncOnAllThreeVideoSignals;
       
  1589                 }
       
  1590             }
       
  1591         }
       
  1592     // unreachable
       
  1593     }
       
  1594 
       
  1595 // ----------------------------------------------------------------------------
       
  1596 // CBaseEdid::GetDigitalSyncSignalDefinitions
       
  1597 // ----------------------------------------------------------------------------
       
  1598 //
       
  1599 TEdidSyncSignalDefinitions CEdidParserBase::GetDigitalSyncSignalDefinitions( const TUint aByte17 )
       
  1600     {
       
  1601     FUNC_LOG;
       
  1602 
       
  1603     //        4 3 2 1 0 bit
       
  1604     //        --------------
       
  1605     //        1 0 _ _ _ Digital Composite Sync:
       
  1606     //        1 0 0 _ _ ---------- Without Serrations;
       
  1607     //        1 0 1 _ _ ---------- With Serrations (H-sync during V-sync);
       
  1608     //        1 1 _ _ _ Digital Separate Sync:
       
  1609     //        1 1 0 _ _ ---------- Vertical Sync is Negative;
       
  1610     //        1 1 1 _ _ ---------- Vertical Sync is Positive;
       
  1611     //        1 _ _ 0 _ -------------------- Horizontal Sync is Negative (outside of V-sync)
       
  1612     //        1 _ _ 1 _ -------------------- Horizontal Sync is Positive (outside of V-sync)
       
  1613     TBool digComp = ( KBit3 & aByte17 ); // ETrue == digital separate sync
       
  1614     TBool bit2 = KBit2 & aByte17;
       
  1615 
       
  1616     if( !digComp ) // digital composite sync
       
  1617         {
       
  1618         if( !bit2 ) // without serrations
       
  1619             {
       
  1620             return EDigitalCompositeSyncWithoutSerrations;
       
  1621             }
       
  1622         else // with serrations
       
  1623             {
       
  1624             return EDigitalCompositeSyncWithSerrations;
       
  1625             }
       
  1626         } // endif  digital composite sync
       
  1627     else //        digital separate sync
       
  1628         {
       
  1629         TBool bit1 = KBit1 & aByte17;
       
  1630 
       
  1631         if( !bit2 ) // vertical = neg
       
  1632             {
       
  1633             if( !bit1 )
       
  1634                 { // vertical = neg, horizontal = neg
       
  1635                 return EDigitalSeparateSyncVerticalSyncIsNegativeHorizontalSyncIsNegative;
       
  1636                 }
       
  1637             else
       
  1638                 { // vertical = neg, horizontal = pos
       
  1639                 return EDigitalSeparateSyncVerticalSyncIsNegativeHorizontalSyncIsPositive;
       
  1640                 }
       
  1641             }
       
  1642         else // vertical = pos
       
  1643             {
       
  1644             if( !bit1 )
       
  1645                 { // vertical = pos, horizontal = neg
       
  1646                 return EDigitalSeparateSyncVerticalSyncIsPositiveHorizontalSyncIsNegative;
       
  1647                 }
       
  1648             else
       
  1649                 { // vertical = pos, horizontal = pos
       
  1650                 return EDigitalSeparateSyncVerticalSyncIsPositiveHorizontalSyncIsPositive;
       
  1651                 }
       
  1652             }
       
  1653         }
       
  1654     // unreachable
       
  1655     }
       
  1656 
       
  1657 // End of file