vghwinterface/vghwdriver/ldd/src/reqhandlerextension.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 // Guest video driver - request handler extension (a.k.a. Command Scheduler extension)
       
    15 //
       
    16 
       
    17 #include <kernel/kern_priv.h>
       
    18 #include <kernel.h>
       
    19 #include <graphics/reqhandlerextension.h>
       
    20 
       
    21 DReqHandlerExtensionImpl* TheReqHandlerExtensionImpl = NULL;
       
    22 
       
    23 DECLARE_STANDARD_EXTENSION()
       
    24 	{
       
    25 	__KTRACE_OPT(KBOOT, Kern::Printf("Starting TheReqHandlerExtension"));
       
    26 	TInt err;
       
    27 	TheReqHandlerExtensionImpl = new DReqHandlerExtensionImpl;
       
    28 	if (TheReqHandlerExtensionImpl)
       
    29 		{
       
    30 		err = TheReqHandlerExtensionImpl->Construct();
       
    31 		if (err != KErrNone)
       
    32 			{
       
    33 			delete TheReqHandlerExtensionImpl;
       
    34 			TheReqHandlerExtensionImpl = NULL;
       
    35 			}
       
    36 		}
       
    37 	else
       
    38 		{
       
    39 		err = KErrNoMemory;
       
    40 		}
       
    41 	if (err != KErrNone)
       
    42 		{
       
    43 		__KTRACE_OPT(KBOOT, Kern::Printf("Error: TheReqHandlerExtension failed to start"));
       
    44 		}
       
    45 	return err;
       
    46 	}
       
    47 
       
    48 
       
    49 EXPORT_C TInt ReqHandlerExtension::CreateSgImagePbuffer( const TSgImageMetaData& aInfo )
       
    50 	{
       
    51     VVHW_TRACE( "ReqHandlerExtension::CreateSgImagePbuffer ->" );
       
    52 	if ( !TheReqHandlerExtensionImpl )
       
    53 		{
       
    54 		__KTRACE_OPT(KPANIC, Kern::Printf("Error: The ReqHandlerExtension not ready"));
       
    55 		return KErrNotReady;
       
    56 		}
       
    57 	TRequestStatus status = KRequestPending;
       
    58 	TheReqHandlerExtensionImpl->CreateSgImagePbuffer( aInfo, &status, &Kern::CurrentThread() );
       
    59 	//Kern::WaitForRequest( status );
       
    60 	VVHW_TRACE( "ReqHandlerExtension::CreateSgImagePbuffer <-" );
       
    61 	return 0;
       
    62 	}
       
    63 
       
    64 EXPORT_C TInt ReqHandlerExtension::CreateSgImageVGImage( const TSgImageMetaData& aInfo )
       
    65     {
       
    66     VVHW_TRACE( "ReqHandlerExtension::CreateSgImageVGImage" );
       
    67     if ( !TheReqHandlerExtensionImpl )
       
    68         {
       
    69         __KTRACE_OPT(KPANIC, Kern::Printf("Error: The ReqHandlerExtension not ready"));
       
    70         return KErrNotReady;
       
    71         }
       
    72     TRequestStatus status;
       
    73     TheReqHandlerExtensionImpl->CreateSgImageVGImage( aInfo, &status, &Kern::CurrentThread() );
       
    74     //Kern::WaitForRequest( status );
       
    75     return 0;
       
    76     }
       
    77 
       
    78 
       
    79 EXPORT_C TInt ReqHandlerExtension::DestroySgImage( const TUint64 aId )
       
    80 	{
       
    81     VVHW_TRACE( "ReqHandlerExtension::DestroySgImage" );
       
    82 	if ( !TheReqHandlerExtensionImpl )
       
    83 		{
       
    84 		__KTRACE_OPT(KPANIC, Kern::Printf("Error: The ReqHandlerExtension not ready"));
       
    85 		return KErrNotReady;
       
    86 		}
       
    87 	return TheReqHandlerExtensionImpl->DestroySgImage( aId );
       
    88 	}
       
    89 
       
    90 EXPORT_C TInt ReqHandlerExtension::SetReqHandler( MReqHandlerCallback* aHandler )
       
    91 	{
       
    92 	if ( !TheReqHandlerExtensionImpl )
       
    93 		{
       
    94 		__KTRACE_OPT(KPANIC, Kern::Printf("Error: The ReqHandlerExtension not ready"));
       
    95 		return KErrNotReady;
       
    96 		}
       
    97 	return TheReqHandlerExtensionImpl->SetReqHandler( aHandler );
       
    98 	}
       
    99 
       
   100 //Implementation
       
   101 
       
   102 TInt DReqHandlerExtensionImpl::Construct()
       
   103 	{
       
   104 	return Kern::MutexCreate(iMutex, KNullDesC8, KMutexOrdGeneral0);
       
   105 	}
       
   106 
       
   107 void DReqHandlerExtensionImpl::CreateSgImagePbuffer( const TSgImageMetaData& aInfo, TRequestStatus* aStatus, DThread* aThread )
       
   108 	{
       
   109 	if( iCallBackHandler )
       
   110         {
       
   111 		return iCallBackHandler->CreateSgImagePbuffer( aInfo, aStatus, aThread );
       
   112 		}
       
   113 	}
       
   114 
       
   115 void DReqHandlerExtensionImpl::CreateSgImageVGImage( const TSgImageMetaData& aInfo, TRequestStatus* aStatus, DThread* aThread )
       
   116     {
       
   117     if( iCallBackHandler )
       
   118         {
       
   119         return iCallBackHandler->CreateSgImageVGImage( aInfo, aStatus, aThread );
       
   120         }
       
   121     }
       
   122 
       
   123 TInt DReqHandlerExtensionImpl::DestroySgImage( const TUint64 aId )
       
   124 	{
       
   125 	if( iCallBackHandler )
       
   126         {
       
   127         TRequestStatus status;
       
   128 	    TInt err = iCallBackHandler->DestroySgImage( aId );
       
   129 	    return err; 
       
   130 		}
       
   131     return 0;
       
   132 	}
       
   133 
       
   134 TInt DReqHandlerExtensionImpl::SetReqHandler( MReqHandlerCallback* aHandler )
       
   135 	{
       
   136 	iCallBackHandler = aHandler;
       
   137 	return 1;
       
   138 	}
       
   139