os/kernelhwsrv/kernel/eka/include/d32otgdi.inl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/d32otgdi.inl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,368 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @internalTechnology
    1.22 + @prototype
    1.23 + 
    1.24 + The driver's name
    1.25 + 
    1.26 + @return The name of the driver
    1.27 + 
    1.28 + @internalComponent
    1.29 +*/
    1.30 +inline const TDesC& RUsbOtgDriver::Name()
    1.31 +	{
    1.32 +	_LIT( KDriverName, "USBOTGDRIVER" );
    1.33 +	return KDriverName;
    1.34 +	}
    1.35 +
    1.36 +/**
    1.37 +  The driver's version
    1.38 +
    1.39 +  @return The version number of the driver
    1.40 +
    1.41 +  @internalComponent
    1.42 +*/
    1.43 +inline TVersion RUsbOtgDriver::VersionRequired()
    1.44 +	{
    1.45 +	const TInt KBuildVersionNumber = KE32BuildVersionNumber;
    1.46 +
    1.47 +	return TVersion( KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber );
    1.48 +	}
    1.49 +
    1.50 +#ifndef __KERNEL_MODE__
    1.51 +
    1.52 +/**
    1.53 +  Open a a logical channel to the OTG driver
    1.54 +
    1.55 +  @return	System-wide error code giving status of connection attempt.
    1.56 +*/
    1.57 +inline TInt RUsbOtgDriver::Open()
    1.58 +	{
    1.59 +	TInt rc = KErrNone;
    1.60 +
    1.61 +	// Check to see if this object has already been opened - if it has,
    1.62 +	// there will be a handle set.
    1.63 +
    1.64 +	if ( Handle() )
    1.65 +		{
    1.66 +		User::Panic(OtgdiPanics::KUsbOtgDriverPanicCat, OtgdiPanics::EUsbOtgDriverAlreadyOpened);
    1.67 +		}
    1.68 +
    1.69 +	rc = DoCreate( Name(), VersionRequired(), KNullUnit, NULL, NULL, EOwnerThread );
    1.70 +
    1.71 +	// We expect back KErrNone - any other problem indicates an attempt by
    1.72 +	// the caller to double-open the driver, which is forbidden
    1.73 +
    1.74 +	if ( rc != KErrNone )
    1.75 +		{
    1.76 +		RDebug::Print(_L("********************************"));
    1.77 +		RDebug::Print(_L("* RUsbOtgDriver::Open() Fault! *"));
    1.78 +		RDebug::Print(_L("********************************"));
    1.79 +		}
    1.80 +
    1.81 +	return rc;
    1.82 +	}
    1.83 +
    1.84 +/**
    1.85 +  Special method to alter the default behaviour of the stack:
    1.86 +
    1.87 +  Test mode is activated (special) 
    1.88 +
    1.89 +  @return	Driver-specific error code or system-wide success
    1.90 +*/
    1.91 +inline TInt RUsbOtgDriver::ActivateOptTestMode()
    1.92 +	{
    1.93 +	return DoControl( EActivateOptTestMode );
    1.94 +	}
    1.95 +
    1.96 +/**
    1.97 +  Overall command to start USB stacks
    1.98 +
    1.99 +  @return	Driver-specific error code or system-wide success
   1.100 +*/
   1.101 +inline TInt RUsbOtgDriver::StartStacks()
   1.102 +	{
   1.103 +	return DoControl( EStartStacks );
   1.104 +	}
   1.105 +
   1.106 +/**
   1.107 +  Overall command to stop USB stacks
   1.108 +*/
   1.109 +inline void RUsbOtgDriver::StopStacks()
   1.110 +	{
   1.111 +	static_cast<void>(DoControl( EStopStacks ));
   1.112 +	}
   1.113 +
   1.114 +/**
   1.115 +  Generic event-reporting mechanism, provided in the form of a standard 
   1.116 +  watcher which registers and allows user to block until notification.
   1.117 +
   1.118 +  To cater for rapidly-occurring events, this function will return the 
   1.119 +  earliest event code (assuming a FIFO stack model for recording such 
   1.120 +  events)
   1.121 +
   1.122 +  The notification function does not support multiple instances, it is expected 
   1.123 +  to be limited solely to ownership by USBMAN
   1.124 +
   1.125 +  @param	aOldestEvent	parameter to collect the TOtgEvent
   1.126 +  @param	aStatus			standard request completion
   1.127 +*/
   1.128 +inline void RUsbOtgDriver::QueueOtgEventRequest(TOtgEvent& aOldestEvent, TRequestStatus& aStatus)
   1.129 +	{
   1.130 +	DoRequest( EQueueOtgEventRequest, aStatus, &aOldestEvent );
   1.131 +	}
   1.132 +
   1.133 +/**
   1.134 +  Cancellation method for event notification
   1.135 +
   1.136 +  Note that the 'cancel' function does not return an error code in the event
   1.137 +  that there is no registered watcher: it is assumed that the code
   1.138 +  within will contain an ASSERT_DEBUG check to confirm watcher validity.
   1.139 +*/
   1.140 +inline void RUsbOtgDriver::CancelOtgEventRequest()
   1.141 +	{
   1.142 +	static_cast<void>(DoControl( ECancelOtgEventRequest ));
   1.143 +	}
   1.144 +	
   1.145 +/**
   1.146 +  Generic state-reporting mechanism, provided in the form of a standard 
   1.147 +  watcher which registers and allows user to block until notification.
   1.148 +
   1.149 +  To cater for rapidly-occurring changes, this function will return the 
   1.150 +  earliest state code (assuming a FIFO stack model for recording such 
   1.151 +  States)
   1.152 +
   1.153 +  The notification function does not support multiple instances, it is expected 
   1.154 +  to be limited solely to ownership by USBMAN
   1.155 +
   1.156 +  @param	aState		parameter to collect the TOtgState
   1.157 +  @param	aStatus		standard request completion
   1.158 +*/
   1.159 +inline void RUsbOtgDriver::QueueOtgStateRequest(TOtgState& aState, TRequestStatus& aStatus)
   1.160 +	{
   1.161 +	DoRequest( EQueueOtgStateRequest, aStatus, &aState );
   1.162 +	}
   1.163 +
   1.164 +/**
   1.165 +  Cancellation method for state notification
   1.166 +
   1.167 +  Note that the 'cancel' function does not return an error code in the event
   1.168 +  that there is no registered watcher: it is assumed that the code
   1.169 +  within will contain an ASSERT_DEBUG check to confirm watcher validity.
   1.170 +*/
   1.171 +inline void RUsbOtgDriver::CancelOtgStateRequest()
   1.172 +	{
   1.173 +	static_cast<void>(DoControl( ECancelOtgStateRequest ));
   1.174 +	}
   1.175 +	
   1.176 +/**
   1.177 +  Generic message-reporting mechanism, provided in the form of a standard 
   1.178 +  watcher which registers and allows user to block until notification.
   1.179 +
   1.180 +  To cater for rapidly-occurring changes, this function will return the 
   1.181 +  earliest message code (assuming a FIFO stack model for recording such 
   1.182 +  Messages)
   1.183 +
   1.184 +  The notification function does not support multiple instances, it is expected 
   1.185 +  to be limited solely to ownership by USBMAN
   1.186 +
   1.187 +  @param	aMessage	parameter to collect the TOtgMessage
   1.188 +  @param	aStatus		standard request completion
   1.189 +*/
   1.190 +inline void RUsbOtgDriver::QueueOtgMessageRequest(TOtgMessage& aMessage, TRequestStatus& aStatus)
   1.191 +	{
   1.192 +	DoRequest( EQueueOtgMessageRequest, aStatus, &aMessage );
   1.193 +	}
   1.194 +
   1.195 +/**
   1.196 +  Cancellation method for message notification
   1.197 +
   1.198 +  Note that the 'cancel' function does not return an error code in the event
   1.199 +  that there is no registered watcher: it is assumed that the code
   1.200 +  within will contain an ASSERT_DEBUG check to confirm watcher validity.
   1.201 +*/
   1.202 +inline void RUsbOtgDriver::CancelOtgMessageRequest()
   1.203 +	{
   1.204 +	static_cast<void>(DoControl( ECancelOtgMessageRequest ));
   1.205 +	}
   1.206 +
   1.207 +/**
   1.208 +  Single-purpose instant-report mechanism to return the current state
   1.209 +  of the ID-Pin on the MIni/Micro-AB connector.
   1.210 +
   1.211 +  This method is expected to complete immediately and return the
   1.212 +  *current* state of the ID-Pin, it will omit any intermediate
   1.213 +  changes that may have occurred since it was last called.
   1.214 +
   1.215 +  @param	aCurrentIdPin	parameter to collect the ID-Pin state
   1.216 +  @param	aStatus			standard request completion
   1.217 +*/
   1.218 +inline void RUsbOtgDriver::QueueOtgIdPinNotification(TOtgIdPin& aCurrentIdPin, TRequestStatus& aStatus)
   1.219 +	{
   1.220 +	DoRequest( EQueueOtgIdPinNotification, aStatus, &aCurrentIdPin );
   1.221 +	}
   1.222 +
   1.223 +/**
   1.224 +  Cancellation method for ID-Pin notification
   1.225 +*/
   1.226 +inline void RUsbOtgDriver::CancelOtgIdPinNotification()
   1.227 +	{
   1.228 +	static_cast<void>(DoControl( ECancelOtgIdPinNotification ));
   1.229 +	}
   1.230 +
   1.231 +/**
   1.232 +  Single-purpose instant-report mechanism to return the current state
   1.233 +  of the Voltage level on the Mini/Micro-AB connector.
   1.234 +
   1.235 +  This method is expected to complete immediately and return the
   1.236 +  *current* state of the voltage, it will omit any intermediate
   1.237 +  changes that may have occurred since it was last called.
   1.238 +
   1.239 +  @param	aCurrentVbus	parameter to collect the voltage state
   1.240 +  @param	aStatus			standard request completion
   1.241 +*/
   1.242 +inline void RUsbOtgDriver::QueueOtgVbusNotification(TOtgVbus& aCurrentVbus, TRequestStatus& aStatus)
   1.243 +	{
   1.244 +	DoRequest( EQueueOtgVbusNotification, aStatus, &aCurrentVbus );
   1.245 +	}
   1.246 +
   1.247 +/**
   1.248 +  Cancellation method for Vbus notification
   1.249 +*/
   1.250 +inline void RUsbOtgDriver::CancelOtgVbusNotification()
   1.251 +	{
   1.252 +	static_cast<void>(DoControl( ECancelOtgVbusNotification ));
   1.253 +	}
   1.254 +
   1.255 +/**
   1.256 +  Single-purpose instant-report mechanism to return the current state
   1.257 +  of the permissive/advisory that indicates 'idle' state where it is
   1.258 +  deemed safe to drop VBUS.
   1.259 +
   1.260 +  This method is expected to complete immediately and return the
   1.261 +  *current* state of the idleness, it will omit any intermediate
   1.262 +  changes that may have occurred since it was last called.
   1.263 +
   1.264 +  @param	aCurrentIdle	parameter to collect the idle state
   1.265 +  @param	aStatus			standard request completion
   1.266 +*/
   1.267 +inline void RUsbOtgDriver::QueueOtgConnectionNotification(TOtgConnection& aCurrentIdle, TRequestStatus& aStatus)
   1.268 +	{
   1.269 +	DoRequest( EQueueOtgConnectionNotification, aStatus, &aCurrentIdle );
   1.270 +	}
   1.271 +
   1.272 +/**
   1.273 +  Cancellation method for Idle notification
   1.274 +*/
   1.275 +inline void RUsbOtgDriver::CancelOtgConnectionNotification()
   1.276 +	{
   1.277 +	static_cast<void>(DoControl( ECancelOtgConnectionNotification ));
   1.278 +	}
   1.279 +
   1.280 +/**
   1.281 +  Single-purpose instant-report mechanism to return the current state
   1.282 +  of the OTG state machine
   1.283 +
   1.284 +  This method is expected to complete immediately and return the
   1.285 +  *current* state, it will omit any intermediate changes that may 
   1.286 +  have occurred since it was last called.
   1.287 +
   1.288 +  @param	aCurrentState	parameter to collect the state
   1.289 +  @param	aStatus			standard request completion
   1.290 +*/
   1.291 +inline void RUsbOtgDriver::QueueOtgStateNotification(TOtgState& aCurrentState, TRequestStatus& aStatus)
   1.292 +	{
   1.293 +	DoRequest( EQueueOtgStateNotification, aStatus, &aCurrentState );
   1.294 +	}
   1.295 +
   1.296 +/**
   1.297 +  Cancellation method for State notification
   1.298 +*/
   1.299 +inline void RUsbOtgDriver::CancelOtgStateNotification()
   1.300 +	{
   1.301 +	static_cast<void>(DoControl( ECancelOtgStateNotification ));
   1.302 +	}
   1.303 +
   1.304 +/**
   1.305 +  USBMAN wants to assert bus request for 'Host' or 'Peripheral' duty
   1.306 +
   1.307 +  Default-Host: this will result in an attempt to raise Vbus
   1.308 +
   1.309 +  Default-Device: this will result in an attempt to use SRP(+HNP)
   1.310 +
   1.311 +  The bus request is asserted until BusDrop() is called.
   1.312 +
   1.313 +  @return	Error code returns are related to the current OTG state context
   1.314 +			at the time of calling, and not to the asynchronous result
   1.315 +			(which is reported via event notification)
   1.316 +*/
   1.317 +inline TInt RUsbOtgDriver::BusRequest()
   1.318 +	{
   1.319 +	return DoControl( EBusRequest );
   1.320 +	}
   1.321 +
   1.322 +/**
   1.323 +  USBMAN wants to permit use of the bus, in response to a request from
   1.324 +  the other (B) end of the link to make use of it.
   1.325 +
   1.326 +  @return	Error code returns are related to the current OTG state context
   1.327 +			at the time of calling, and not to the asynchronous result
   1.328 +			(which is reported via event notification)
   1.329 +*/
   1.330 +inline TInt RUsbOtgDriver::BusRespondSrp()
   1.331 +	{
   1.332 +	return DoControl( EBusRespondSrp );
   1.333 +	}
   1.334 +
   1.335 +/**
   1.336 +  USBMAN wants to stop using the bus.
   1.337 +
   1.338 +  This function can only be called from the A-Device and will result in 
   1.339 +  the voltage drive being removed from the Vbus line.
   1.340 +
   1.341 +  @return	Error code returns are related to the current OTG state context
   1.342 +			at the time of calling, and not to the asynchronous result
   1.343 +			(which is reported via event notification)
   1.344 +
   1.345 +			In particular, this function will return an error code if it
   1.346 +			is called in any 'B' state
   1.347 +*/
   1.348 +inline TInt RUsbOtgDriver::BusDrop()
   1.349 +	{
   1.350 +	return DoControl( EBusDrop );
   1.351 +	}
   1.352 +
   1.353 +/**
   1.354 +  USBMAN wants to clear the bus error state.
   1.355 +
   1.356 +  This function can only be called from the A-Device and will result in 
   1.357 +  the OTG state machine being moved out of the A_VBUS_ERR state.
   1.358 +
   1.359 +  @return	Error code returns are related to the current OTG state context
   1.360 +			at the time of calling, and not to the asynchronous result
   1.361 +			(which is reported via event notification)
   1.362 +
   1.363 +			In particular, this function will return an error code if it
   1.364 +			is called in any 'B' state 
   1.365 +*/
   1.366 +inline TInt RUsbOtgDriver::BusClearError()
   1.367 +	{
   1.368 +	return DoControl( EBusClearError );
   1.369 +	}
   1.370 +
   1.371 +#endif  // !__KERNEL_MODE__