kernel/eka/include/d32otgdi.inl
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-2009 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 the License "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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19  @prototype
       
    20  
       
    21  The driver's name
       
    22  
       
    23  @return The name of the driver
       
    24  
       
    25  @internalComponent
       
    26 */
       
    27 inline const TDesC& RUsbOtgDriver::Name()
       
    28 	{
       
    29 	_LIT( KDriverName, "USBOTGDRIVER" );
       
    30 	return KDriverName;
       
    31 	}
       
    32 
       
    33 /**
       
    34   The driver's version
       
    35 
       
    36   @return The version number of the driver
       
    37 
       
    38   @internalComponent
       
    39 */
       
    40 inline TVersion RUsbOtgDriver::VersionRequired()
       
    41 	{
       
    42 	const TInt KBuildVersionNumber = KE32BuildVersionNumber;
       
    43 
       
    44 	return TVersion( KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber );
       
    45 	}
       
    46 
       
    47 #ifndef __KERNEL_MODE__
       
    48 
       
    49 /**
       
    50   Open a a logical channel to the OTG driver
       
    51 
       
    52   @return	System-wide error code giving status of connection attempt.
       
    53 */
       
    54 inline TInt RUsbOtgDriver::Open()
       
    55 	{
       
    56 	TInt rc = KErrNone;
       
    57 
       
    58 	// Check to see if this object has already been opened - if it has,
       
    59 	// there will be a handle set.
       
    60 
       
    61 	if ( Handle() )
       
    62 		{
       
    63 		User::Panic(OtgdiPanics::KUsbOtgDriverPanicCat, OtgdiPanics::EUsbOtgDriverAlreadyOpened);
       
    64 		}
       
    65 
       
    66 	rc = DoCreate( Name(), VersionRequired(), KNullUnit, NULL, NULL, EOwnerThread );
       
    67 
       
    68 	// We expect back KErrNone - any other problem indicates an attempt by
       
    69 	// the caller to double-open the driver, which is forbidden
       
    70 
       
    71 	if ( rc != KErrNone )
       
    72 		{
       
    73 		RDebug::Print(_L("********************************"));
       
    74 		RDebug::Print(_L("* RUsbOtgDriver::Open() Fault! *"));
       
    75 		RDebug::Print(_L("********************************"));
       
    76 		}
       
    77 
       
    78 	return rc;
       
    79 	}
       
    80 
       
    81 /**
       
    82   Special method to alter the default behaviour of the stack:
       
    83 
       
    84   Test mode is activated (special) 
       
    85 
       
    86   @return	Driver-specific error code or system-wide success
       
    87 */
       
    88 inline TInt RUsbOtgDriver::ActivateOptTestMode()
       
    89 	{
       
    90 	return DoControl( EActivateOptTestMode );
       
    91 	}
       
    92 
       
    93 /**
       
    94   Overall command to start USB stacks
       
    95 
       
    96   @return	Driver-specific error code or system-wide success
       
    97 */
       
    98 inline TInt RUsbOtgDriver::StartStacks()
       
    99 	{
       
   100 	return DoControl( EStartStacks );
       
   101 	}
       
   102 
       
   103 /**
       
   104   Overall command to stop USB stacks
       
   105 */
       
   106 inline void RUsbOtgDriver::StopStacks()
       
   107 	{
       
   108 	static_cast<void>(DoControl( EStopStacks ));
       
   109 	}
       
   110 
       
   111 /**
       
   112   Generic event-reporting mechanism, provided in the form of a standard 
       
   113   watcher which registers and allows user to block until notification.
       
   114 
       
   115   To cater for rapidly-occurring events, this function will return the 
       
   116   earliest event code (assuming a FIFO stack model for recording such 
       
   117   events)
       
   118 
       
   119   The notification function does not support multiple instances, it is expected 
       
   120   to be limited solely to ownership by USBMAN
       
   121 
       
   122   @param	aOldestEvent	parameter to collect the TOtgEvent
       
   123   @param	aStatus			standard request completion
       
   124 */
       
   125 inline void RUsbOtgDriver::QueueOtgEventRequest(TOtgEvent& aOldestEvent, TRequestStatus& aStatus)
       
   126 	{
       
   127 	DoRequest( EQueueOtgEventRequest, aStatus, &aOldestEvent );
       
   128 	}
       
   129 
       
   130 /**
       
   131   Cancellation method for event notification
       
   132 
       
   133   Note that the 'cancel' function does not return an error code in the event
       
   134   that there is no registered watcher: it is assumed that the code
       
   135   within will contain an ASSERT_DEBUG check to confirm watcher validity.
       
   136 */
       
   137 inline void RUsbOtgDriver::CancelOtgEventRequest()
       
   138 	{
       
   139 	static_cast<void>(DoControl( ECancelOtgEventRequest ));
       
   140 	}
       
   141 	
       
   142 /**
       
   143   Generic state-reporting mechanism, provided in the form of a standard 
       
   144   watcher which registers and allows user to block until notification.
       
   145 
       
   146   To cater for rapidly-occurring changes, this function will return the 
       
   147   earliest state code (assuming a FIFO stack model for recording such 
       
   148   States)
       
   149 
       
   150   The notification function does not support multiple instances, it is expected 
       
   151   to be limited solely to ownership by USBMAN
       
   152 
       
   153   @param	aState		parameter to collect the TOtgState
       
   154   @param	aStatus		standard request completion
       
   155 */
       
   156 inline void RUsbOtgDriver::QueueOtgStateRequest(TOtgState& aState, TRequestStatus& aStatus)
       
   157 	{
       
   158 	DoRequest( EQueueOtgStateRequest, aStatus, &aState );
       
   159 	}
       
   160 
       
   161 /**
       
   162   Cancellation method for state notification
       
   163 
       
   164   Note that the 'cancel' function does not return an error code in the event
       
   165   that there is no registered watcher: it is assumed that the code
       
   166   within will contain an ASSERT_DEBUG check to confirm watcher validity.
       
   167 */
       
   168 inline void RUsbOtgDriver::CancelOtgStateRequest()
       
   169 	{
       
   170 	static_cast<void>(DoControl( ECancelOtgStateRequest ));
       
   171 	}
       
   172 	
       
   173 /**
       
   174   Generic message-reporting mechanism, provided in the form of a standard 
       
   175   watcher which registers and allows user to block until notification.
       
   176 
       
   177   To cater for rapidly-occurring changes, this function will return the 
       
   178   earliest message code (assuming a FIFO stack model for recording such 
       
   179   Messages)
       
   180 
       
   181   The notification function does not support multiple instances, it is expected 
       
   182   to be limited solely to ownership by USBMAN
       
   183 
       
   184   @param	aMessage	parameter to collect the TOtgMessage
       
   185   @param	aStatus		standard request completion
       
   186 */
       
   187 inline void RUsbOtgDriver::QueueOtgMessageRequest(TOtgMessage& aMessage, TRequestStatus& aStatus)
       
   188 	{
       
   189 	DoRequest( EQueueOtgMessageRequest, aStatus, &aMessage );
       
   190 	}
       
   191 
       
   192 /**
       
   193   Cancellation method for message notification
       
   194 
       
   195   Note that the 'cancel' function does not return an error code in the event
       
   196   that there is no registered watcher: it is assumed that the code
       
   197   within will contain an ASSERT_DEBUG check to confirm watcher validity.
       
   198 */
       
   199 inline void RUsbOtgDriver::CancelOtgMessageRequest()
       
   200 	{
       
   201 	static_cast<void>(DoControl( ECancelOtgMessageRequest ));
       
   202 	}
       
   203 
       
   204 /**
       
   205   Single-purpose instant-report mechanism to return the current state
       
   206   of the ID-Pin on the MIni/Micro-AB connector.
       
   207 
       
   208   This method is expected to complete immediately and return the
       
   209   *current* state of the ID-Pin, it will omit any intermediate
       
   210   changes that may have occurred since it was last called.
       
   211 
       
   212   @param	aCurrentIdPin	parameter to collect the ID-Pin state
       
   213   @param	aStatus			standard request completion
       
   214 */
       
   215 inline void RUsbOtgDriver::QueueOtgIdPinNotification(TOtgIdPin& aCurrentIdPin, TRequestStatus& aStatus)
       
   216 	{
       
   217 	DoRequest( EQueueOtgIdPinNotification, aStatus, &aCurrentIdPin );
       
   218 	}
       
   219 
       
   220 /**
       
   221   Cancellation method for ID-Pin notification
       
   222 */
       
   223 inline void RUsbOtgDriver::CancelOtgIdPinNotification()
       
   224 	{
       
   225 	static_cast<void>(DoControl( ECancelOtgIdPinNotification ));
       
   226 	}
       
   227 
       
   228 /**
       
   229   Single-purpose instant-report mechanism to return the current state
       
   230   of the Voltage level on the Mini/Micro-AB connector.
       
   231 
       
   232   This method is expected to complete immediately and return the
       
   233   *current* state of the voltage, it will omit any intermediate
       
   234   changes that may have occurred since it was last called.
       
   235 
       
   236   @param	aCurrentVbus	parameter to collect the voltage state
       
   237   @param	aStatus			standard request completion
       
   238 */
       
   239 inline void RUsbOtgDriver::QueueOtgVbusNotification(TOtgVbus& aCurrentVbus, TRequestStatus& aStatus)
       
   240 	{
       
   241 	DoRequest( EQueueOtgVbusNotification, aStatus, &aCurrentVbus );
       
   242 	}
       
   243 
       
   244 /**
       
   245   Cancellation method for Vbus notification
       
   246 */
       
   247 inline void RUsbOtgDriver::CancelOtgVbusNotification()
       
   248 	{
       
   249 	static_cast<void>(DoControl( ECancelOtgVbusNotification ));
       
   250 	}
       
   251 
       
   252 /**
       
   253   Single-purpose instant-report mechanism to return the current state
       
   254   of the permissive/advisory that indicates 'idle' state where it is
       
   255   deemed safe to drop VBUS.
       
   256 
       
   257   This method is expected to complete immediately and return the
       
   258   *current* state of the idleness, it will omit any intermediate
       
   259   changes that may have occurred since it was last called.
       
   260 
       
   261   @param	aCurrentIdle	parameter to collect the idle state
       
   262   @param	aStatus			standard request completion
       
   263 */
       
   264 inline void RUsbOtgDriver::QueueOtgConnectionNotification(TOtgConnection& aCurrentIdle, TRequestStatus& aStatus)
       
   265 	{
       
   266 	DoRequest( EQueueOtgConnectionNotification, aStatus, &aCurrentIdle );
       
   267 	}
       
   268 
       
   269 /**
       
   270   Cancellation method for Idle notification
       
   271 */
       
   272 inline void RUsbOtgDriver::CancelOtgConnectionNotification()
       
   273 	{
       
   274 	static_cast<void>(DoControl( ECancelOtgConnectionNotification ));
       
   275 	}
       
   276 
       
   277 /**
       
   278   Single-purpose instant-report mechanism to return the current state
       
   279   of the OTG state machine
       
   280 
       
   281   This method is expected to complete immediately and return the
       
   282   *current* state, it will omit any intermediate changes that may 
       
   283   have occurred since it was last called.
       
   284 
       
   285   @param	aCurrentState	parameter to collect the state
       
   286   @param	aStatus			standard request completion
       
   287 */
       
   288 inline void RUsbOtgDriver::QueueOtgStateNotification(TOtgState& aCurrentState, TRequestStatus& aStatus)
       
   289 	{
       
   290 	DoRequest( EQueueOtgStateNotification, aStatus, &aCurrentState );
       
   291 	}
       
   292 
       
   293 /**
       
   294   Cancellation method for State notification
       
   295 */
       
   296 inline void RUsbOtgDriver::CancelOtgStateNotification()
       
   297 	{
       
   298 	static_cast<void>(DoControl( ECancelOtgStateNotification ));
       
   299 	}
       
   300 
       
   301 /**
       
   302   USBMAN wants to assert bus request for 'Host' or 'Peripheral' duty
       
   303 
       
   304   Default-Host: this will result in an attempt to raise Vbus
       
   305 
       
   306   Default-Device: this will result in an attempt to use SRP(+HNP)
       
   307 
       
   308   The bus request is asserted until BusDrop() is called.
       
   309 
       
   310   @return	Error code returns are related to the current OTG state context
       
   311 			at the time of calling, and not to the asynchronous result
       
   312 			(which is reported via event notification)
       
   313 */
       
   314 inline TInt RUsbOtgDriver::BusRequest()
       
   315 	{
       
   316 	return DoControl( EBusRequest );
       
   317 	}
       
   318 
       
   319 /**
       
   320   USBMAN wants to permit use of the bus, in response to a request from
       
   321   the other (B) end of the link to make use of it.
       
   322 
       
   323   @return	Error code returns are related to the current OTG state context
       
   324 			at the time of calling, and not to the asynchronous result
       
   325 			(which is reported via event notification)
       
   326 */
       
   327 inline TInt RUsbOtgDriver::BusRespondSrp()
       
   328 	{
       
   329 	return DoControl( EBusRespondSrp );
       
   330 	}
       
   331 
       
   332 /**
       
   333   USBMAN wants to stop using the bus.
       
   334 
       
   335   This function can only be called from the A-Device and will result in 
       
   336   the voltage drive being removed from the Vbus line.
       
   337 
       
   338   @return	Error code returns are related to the current OTG state context
       
   339 			at the time of calling, and not to the asynchronous result
       
   340 			(which is reported via event notification)
       
   341 
       
   342 			In particular, this function will return an error code if it
       
   343 			is called in any 'B' state
       
   344 */
       
   345 inline TInt RUsbOtgDriver::BusDrop()
       
   346 	{
       
   347 	return DoControl( EBusDrop );
       
   348 	}
       
   349 
       
   350 /**
       
   351   USBMAN wants to clear the bus error state.
       
   352 
       
   353   This function can only be called from the A-Device and will result in 
       
   354   the OTG state machine being moved out of the A_VBUS_ERR state.
       
   355 
       
   356   @return	Error code returns are related to the current OTG state context
       
   357 			at the time of calling, and not to the asynchronous result
       
   358 			(which is reported via event notification)
       
   359 
       
   360 			In particular, this function will return an error code if it
       
   361 			is called in any 'B' state 
       
   362 */
       
   363 inline TInt RUsbOtgDriver::BusClearError()
       
   364 	{
       
   365 	return DoControl( EBusClearError );
       
   366 	}
       
   367 
       
   368 #endif  // !__KERNEL_MODE__