vghwinterface/vghwdriver/ldd/src/virtualvideohwdevice.cpp
branchbug235_bringup_0
changeset 51 4f400a6ea71f
parent 7 ec0e558822c5
equal deleted inserted replaced
49:3b4f7e9d873f 51:4f400a6ea71f
       
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Virtual Video Hardware Device Implementation
       
    15 
       
    16 #include <kernel/kernel.h>
       
    17 #include <assp.h>
       
    18 
       
    19 #include <graphics/guestvideodriverprotocol.h>
       
    20 #include <graphics/virtualvideohwdevice.h>
       
    21 #include <graphics/virtualvideohwchannel.h>
       
    22 #include <graphics/virtualvideohwinterface.h>
       
    23 #include <graphics/virtualvideotracing.h>
       
    24 #include <graphics/guestvideodrivercommon.h>
       
    25 #include <graphics/devicereqhandler.h>
       
    26 
       
    27 const TInt KPriority = 27; // DfcQue0 has same priority
       
    28 
       
    29 // a .LDD requires that the first exported function creates the device. By
       
    30 // returning a concrete DLogicalDevice-derived class, this implements
       
    31 // polymorphism using a named DLL.
       
    32 DECLARE_STANDARD_LDD()
       
    33     {
       
    34     return new DVirtualVideoHwDevice; 
       
    35     }
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // DVirtualVideoHwDevice::DVirtualVideoHwDevice
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 DVirtualVideoHwDevice::DVirtualVideoHwDevice()
       
    44     {
       
    45     // No need to set iParseMask as we don't have PDD.
       
    46     // Just set the version.
       
    47     using namespace GuestVideoDriver;
       
    48     iVersion = TVersion( KMajorVer, KMinorVer, KBuildVer );
       
    49 	iHwInterface = new DVirtualVideoHwInterface;
       
    50 	Kern::Printf("DVirtualVideoHwDevice::DVirtualVideoHwDevice()<");
       
    51     VVHW_TRACE("DVirtualVideoHwDevice::DVirtualVideoHwDevice");
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // DVirtualVideoHwDevice::Install
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 TInt DVirtualVideoHwDevice::Install()
       
    59     {
       
    60     // Our name, used by User::FreeLogicalDevice 
       
    61     TInt err = SetName( &GuestVideoDriver::KDeviceName );
       
    62     if ( err != KErrNone )
       
    63         {
       
    64         VVHW_TRACE("DVirtualVideoHwDevice::Install SetName %d", err);
       
    65         return err;
       
    66         }
       
    67 
       
    68     // Enter critical section
       
    69     NKern::ThreadEnterCS();
       
    70     
       
    71     err = Kern::DfcQCreate( iDfcQ, KPriority, &GuestVideoDriver::KDfcThreadName );
       
    72 
       
    73     // Leave critical section
       
    74     NKern::ThreadLeaveCS();
       
    75 
       
    76     if ( err != KErrNone )
       
    77         {
       
    78         VVHW_TRACE("DVirtualVideoHwDevice::Install Kern::DfcQCreate %d", err);
       
    79         return err;
       
    80         }
       
    81     
       
    82 	// We have already created this during construction
       
    83     // iHwInterface = new DVirtualVideoHwInterface;
       
    84 
       
    85     if ( !iHwInterface )
       
    86         {
       
    87         return KErrNoMemory;
       
    88         }
       
    89 
       
    90     err = iHwInterface->InitRegisterMemory();
       
    91     if ( err != KErrNone )
       
    92         {
       
    93         VVHW_TRACE("DVirtualVideoHwDevice::Install InitRegisterMemory %d", err);
       
    94         return err;
       
    95         }
       
    96 
       
    97     err = iHwInterface->InitParametersInputMemory();
       
    98     if ( err != KErrNone )
       
    99         {
       
   100         VVHW_TRACE("DVirtualVideoHwDevice::Install InitParametersInputMemory %d", err);
       
   101         return err;
       
   102         }
       
   103 
       
   104     err = iHwInterface->InitParametersOutputMemory();
       
   105     if ( err != KErrNone )
       
   106         {
       
   107         VVHW_TRACE("DVirtualVideoHwDevice::Install InitParametersOutputMemory %d", err);
       
   108         return err;
       
   109         }
       
   110 
       
   111     iDeviceReqHandler = new DDeviceReqHandler( *iHwInterface, iDfcQ );
       
   112     if ( !iDeviceReqHandler )
       
   113         {
       
   114         return KErrNoMemory;
       
   115         }
       
   116 
       
   117     VVHW_TRACE("DVirtualVideoHwDevice::Install return %d", err);
       
   118     return err;
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // DVirtualVideoHwDevice::~DVirtualVideoHwDevice
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 DVirtualVideoHwDevice::~DVirtualVideoHwDevice()
       
   126     {
       
   127     delete iDeviceReqHandler;
       
   128     delete iDfcQ;
       
   129     delete iHwInterface;
       
   130     VVHW_TRACE("DVirtualVideoHwDevice:~DVirtualVideoHwDevice");
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // DVirtualVideoHwDevice::GetCaps
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 void DVirtualVideoHwDevice::GetCaps( TDes8& aDes ) const
       
   138     {
       
   139     TVersion version; 
       
   140 
       
   141     // fill it with information
       
   142     version = iVersion; 
       
   143 
       
   144     // copy as much of our information as will fit into this descriptor
       
   145     aDes.Copy( (TUint8*)&version, Min( aDes.MaxLength(), sizeof( version ) ) );
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // DVirtualVideoHwDevice::Create
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 TInt DVirtualVideoHwDevice::Create( DLogicalChannelBase*& aChannel )
       
   153     { 
       
   154     aChannel = NULL;
       
   155     TInt error = KErrNone;
       
   156     aChannel = new DVirtualVideoHwChannel(
       
   157             *this,
       
   158             *iHwInterface,
       
   159             *iDeviceReqHandler,
       
   160             iDfcQ);
       
   161     
       
   162     if ( !aChannel )
       
   163         {
       
   164         error = KErrNoMemory;
       
   165         }
       
   166     return error;
       
   167     }