os/kernelhwsrv/kernel/eka/include/drivers/usbcshared.inl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/usbcshared.inl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,634 @@
     1.4 +// Copyright (c) 2000-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 +// e32\include\drivers\usbcshared.inl
    1.18 +// Kernel side definitions for the USB Device driver stack (PIL + LDD).
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file usbcshared.inl
    1.24 + @internalTechnology
    1.25 +*/
    1.26 +
    1.27 +#ifndef __USBCSHARED_INL__
    1.28 +#define __USBCSHARED_INL__
    1.29 +
    1.30 +//
    1.31 +// --- DUsbClientController (USB PDD) ---
    1.32 +//
    1.33 +
    1.34 +// --- Private member functions, used by controller itself ---
    1.35 +
    1.36 +const DBase* DUsbClientController::PEndpoint2ClientId(TInt aRealEndpoint) const
    1.37 +	{
    1.38 +	if (iRealEndpoints[aRealEndpoint].iLEndpoint)
    1.39 +		return iRealEndpoints[aRealEndpoint].iLEndpoint->iInterface->iInterfaceSet->iClientId;
    1.40 +	else
    1.41 +		return NULL;
    1.42 +	}
    1.43 +
    1.44 +
    1.45 +TInt DUsbClientController::PEndpoint2LEndpoint(TInt aRealEndpoint) const
    1.46 +	{
    1.47 +	if (iRealEndpoints[aRealEndpoint].iLEndpoint)
    1.48 +		return iRealEndpoints[aRealEndpoint].iLEndpoint->iLEndpointNum;
    1.49 +	else
    1.50 +		return -1;
    1.51 +	}
    1.52 +
    1.53 +
    1.54 +const TUsbcConfiguration* DUsbClientController::CurrentConfig() const
    1.55 +	{
    1.56 +	return (iCurrentConfig ? iConfigs[iCurrentConfig - 1] : NULL);
    1.57 +	}
    1.58 +
    1.59 +
    1.60 +TUsbcConfiguration* DUsbClientController::CurrentConfig()
    1.61 +	{
    1.62 +	return (iCurrentConfig ? iConfigs[iCurrentConfig - 1] : NULL);
    1.63 +	}
    1.64 +
    1.65 +
    1.66 +TBool DUsbClientController::InterfaceExists(TInt aNumber) const
    1.67 +	{
    1.68 +	const TInt num_ifcsets = iConfigs[0]->iInterfaceSets.Count();
    1.69 +	RPointerArray<TUsbcInterfaceSet>& ifcsets = iConfigs[0]->iInterfaceSets;
    1.70 +	for (TInt i = 0; i < num_ifcsets; i++)
    1.71 +		{
    1.72 +		if (ifcsets[i]->iInterfaceNumber == aNumber)
    1.73 +			{
    1.74 +			return ETrue;
    1.75 +			}
    1.76 +		}
    1.77 +	return EFalse;
    1.78 +	}
    1.79 +
    1.80 +
    1.81 +TBool DUsbClientController::EndpointExists(TUint aAddress) const
    1.82 +	{
    1.83 +	// Ep0 doesn't have a "logical ep" pointer (there's no virtual endpoint zero);
    1.84 +	// that's why this pointer being non-NULL is not a sufficient criterion for
    1.85 +	// endpoint-existence. (Apart from that, ep0 always exists.)
    1.86 +	const TInt idx = EpAddr2Idx(aAddress);
    1.87 +	return ((idx < iDeviceTotalEndpoints) &&
    1.88 +			((iRealEndpoints[idx].iLEndpoint != NULL) ||
    1.89 +			 ((aAddress & KUsbEpAddress_Portmask) == 0)));
    1.90 +	}
    1.91 +
    1.92 +
    1.93 +void DUsbClientController::Buffer2Setup(const TAny* aBuf, TUsbcSetup& aSetup) const
    1.94 +	{
    1.95 +	// TUint8 index
    1.96 +	aSetup.iRequestType = static_cast<const TUint8*>(aBuf)[0];
    1.97 +	aSetup.iRequest		= static_cast<const TUint8*>(aBuf)[1];
    1.98 +	// TUint16 index from here!
    1.99 +	aSetup.iValue  = SWAP_BYTES_16((static_cast<const TUint16*>(aBuf))[1]);
   1.100 +	aSetup.iIndex  = SWAP_BYTES_16((static_cast<const TUint16*>(aBuf))[2]);
   1.101 +	aSetup.iLength = SWAP_BYTES_16((static_cast<const TUint16*>(aBuf))[3]);
   1.102 +	}
   1.103 +
   1.104 +
   1.105 +TUint DUsbClientController::EpIdx2Addr(TUint aRealEndpoint) const
   1.106 +	{
   1.107 +	return ((aRealEndpoint << 7) & 0x80) | ((aRealEndpoint >> 1) & 0x0f);
   1.108 +	}
   1.109 +
   1.110 +
   1.111 +TUint DUsbClientController::EpAddr2Idx(TUint aAddress) const
   1.112 +	{
   1.113 +	return ((aAddress & 0x80) >> 7) | ((aAddress & 0x0f) << 1);
   1.114 +	}
   1.115 +
   1.116 +
   1.117 +void DUsbClientController::SetEp0DataOutVars(const TUsbcSetup& aPacket, const DBase* aClientId)
   1.118 +	{
   1.119 +	__KTRACE_OPT(KUSB, Kern::Printf("DUsbClientController::SetEp0DataOutVars()"));
   1.120 +	iSetup = aPacket;
   1.121 +	iEp0DataReceiving = ETrue;
   1.122 +	iEp0DataReceived = 0;
   1.123 +	iEp0ClientId = aClientId;
   1.124 +	}
   1.125 +
   1.126 +
   1.127 +void DUsbClientController::ResetEp0DataOutVars()
   1.128 +	{
   1.129 +	__KTRACE_OPT(KUSB, Kern::Printf("DUsbClientController::ResetEp0DataOutVars()"));
   1.130 +	iEp0DataReceiving = EFalse;
   1.131 +	iEp0DataReceived = 0;
   1.132 +	iEp0ClientId = NULL;
   1.133 +	}
   1.134 +
   1.135 +
   1.136 +TBool DUsbClientController::IsInTheRequestList(const TUsbcRequestCallback& aCallback)
   1.137 +	{
   1.138 +	const TInt irq = NKern::DisableAllInterrupts();
   1.139 +	TSglQueIter<TUsbcRequestCallback> iter(iEp0ReadRequestCallbacks);
   1.140 +	TUsbcRequestCallback* p;
   1.141 +	while ((p = iter++) != NULL)
   1.142 +		{
   1.143 +		if (p == &aCallback)
   1.144 +			{
   1.145 +			NKern::RestoreInterrupts(irq);
   1.146 +			return ETrue;
   1.147 +			}
   1.148 +		}
   1.149 +	NKern::RestoreInterrupts(irq);
   1.150 +	return EFalse;
   1.151 +	}
   1.152 +
   1.153 +
   1.154 +TBool DUsbClientController::IsInTheStatusList(const TUsbcStatusCallback& aCallback)
   1.155 +	{
   1.156 +	const TInt irq = NKern::DisableAllInterrupts();
   1.157 +	TSglQueIter<TUsbcStatusCallback> iter(iStatusCallbacks);
   1.158 +	TUsbcStatusCallback* p;
   1.159 +	while ((p = iter++) != NULL)
   1.160 +		{
   1.161 +		if (p == &aCallback)
   1.162 +			{
   1.163 +			NKern::RestoreInterrupts(irq);
   1.164 +			return ETrue;
   1.165 +			}
   1.166 +		}
   1.167 +	NKern::RestoreInterrupts(irq);
   1.168 +	return EFalse;
   1.169 +	}
   1.170 +
   1.171 +
   1.172 +TBool DUsbClientController::IsInTheEpStatusList(const TUsbcEndpointStatusCallback& aCallback)
   1.173 +	{
   1.174 +	const TInt irq = NKern::DisableAllInterrupts();
   1.175 +	TSglQueIter<TUsbcEndpointStatusCallback> iter(iEpStatusCallbacks);
   1.176 +	TUsbcEndpointStatusCallback* p;
   1.177 +	while ((p = iter++) != NULL)
   1.178 +		{
   1.179 +		if (p == &aCallback)
   1.180 +			{
   1.181 +			NKern::RestoreInterrupts(irq);
   1.182 +			return ETrue;
   1.183 +			}
   1.184 +		}
   1.185 +	NKern::RestoreInterrupts(irq);
   1.186 +	return EFalse;
   1.187 +	}
   1.188 +
   1.189 +
   1.190 +TBool DUsbClientController::IsInTheOtgFeatureList(const TUsbcOtgFeatureCallback& aCallback)
   1.191 +	{
   1.192 +	const TInt irq = NKern::DisableAllInterrupts();
   1.193 +	TSglQueIter<TUsbcOtgFeatureCallback> iter(iOtgCallbacks);
   1.194 +	TUsbcOtgFeatureCallback* p;
   1.195 +	while ((p = iter++) != NULL)
   1.196 +		{
   1.197 +		if (p == &aCallback)
   1.198 +			{
   1.199 +			NKern::RestoreInterrupts(irq);
   1.200 +			return ETrue;
   1.201 +			}
   1.202 +		}
   1.203 +	NKern::RestoreInterrupts(irq);
   1.204 +	return EFalse;
   1.205 +	}
   1.206 +
   1.207 +//
   1.208 +// --- Misc classes ---
   1.209 +//
   1.210 +
   1.211 +// --- TUsbcClientCallback
   1.212 +
   1.213 +/** Constructor.
   1.214 + */
   1.215 +TUsbcClientCallback::TUsbcClientCallback(DBase* aOwner, TDfcFn aCallback, TInt aPriority)
   1.216 +	: iOwner(aOwner),
   1.217 +	  iDfc(aCallback, aOwner, aPriority)
   1.218 +	{}
   1.219 +
   1.220 +
   1.221 +/** Returns a pointer to the owner of this request.
   1.222 +
   1.223 +	@return A pointer to the owner of this request.
   1.224 +*/
   1.225 +DBase* TUsbcClientCallback::Owner() const
   1.226 +	{
   1.227 +	return iOwner;
   1.228 +	}
   1.229 +
   1.230 +
   1.231 +/** Executes the callback function set by the owner of this request.
   1.232 +
   1.233 +	@return KErrNone.
   1.234 +*/
   1.235 +TInt TUsbcClientCallback::DoCallback()
   1.236 +	{
   1.237 +	__ASSERT_DEBUG((NKern::CurrentContext() == EThread), Kern::Fault(KUsbPILPanicCat, __LINE__));
   1.238 +	iDfc.Enque();
   1.239 +	return KErrNone;
   1.240 +	}
   1.241 +
   1.242 +
   1.243 +/** Cancels the callback function set by the owner of this request.
   1.244 + */
   1.245 +void TUsbcClientCallback::Cancel()
   1.246 +	{
   1.247 +	iDfc.Cancel();
   1.248 +	}
   1.249 +
   1.250 +
   1.251 +/** Sets the DFC queue used by the callback function.
   1.252 +	@param aDfcQ DFC queue to be set
   1.253 + */
   1.254 +void TUsbcClientCallback::SetDfcQ(TDfcQue* aDfcQ)
   1.255 +	{
   1.256 +	iDfc.SetDfcQ(aDfcQ);
   1.257 +	}
   1.258 +
   1.259 +
   1.260 +// --- TUsbcEndpointStatusCallback
   1.261 +
   1.262 +/** Constructor.
   1.263 + */
   1.264 +TUsbcEndpointStatusCallback::TUsbcEndpointStatusCallback(DBase* aOwner, TDfcFn aCallback,
   1.265 +														 TInt aPriority)
   1.266 +	: iOwner(aOwner),
   1.267 +	  iDfc(aCallback, aOwner, aPriority),
   1.268 +	  iState(0)
   1.269 +	{}
   1.270 +
   1.271 +
   1.272 +/** Sets the state of this request to aState.
   1.273 +
   1.274 +	@param aState The new state to be set.
   1.275 +*/
   1.276 +void TUsbcEndpointStatusCallback::SetState(TUint aState)
   1.277 +	{
   1.278 +	iState = aState;
   1.279 +	}
   1.280 +
   1.281 +
   1.282 +/** Returns the state value of this request.
   1.283 +
   1.284 +	@return The state value of this request.
   1.285 +*/
   1.286 +TUint TUsbcEndpointStatusCallback::State() const
   1.287 +	{
   1.288 +	return iState;
   1.289 +	}
   1.290 +
   1.291 +
   1.292 +/** Returns a pointer to the owner of this request.
   1.293 +
   1.294 +	@return A pointer to the owner of this request.
   1.295 +*/
   1.296 +DBase* TUsbcEndpointStatusCallback::Owner() const
   1.297 +	{
   1.298 +	return iOwner;
   1.299 +	}
   1.300 +
   1.301 +
   1.302 +/** Executes the callback function set by the owner of this request.
   1.303 +
   1.304 +	@return KErrNone.
   1.305 +*/
   1.306 +TInt TUsbcEndpointStatusCallback::DoCallback()
   1.307 +	{
   1.308 +	if (NKern::CurrentContext() == EThread)
   1.309 +		iDfc.Enque();
   1.310 +	else
   1.311 +		iDfc.Add();
   1.312 +	return KErrNone;
   1.313 +	}
   1.314 +
   1.315 +
   1.316 +/** Cancels the callback function set by the owner of this request.
   1.317 +*/
   1.318 +void TUsbcEndpointStatusCallback::Cancel()
   1.319 +	{
   1.320 +	iDfc.Cancel();
   1.321 +	}
   1.322 +
   1.323 +
   1.324 +/** Sets the DFC queue used by the callback function.
   1.325 +*/
   1.326 +void TUsbcEndpointStatusCallback::SetDfcQ(TDfcQue* aDfcQ)
   1.327 +	{
   1.328 +	iDfc.SetDfcQ(aDfcQ);
   1.329 +	}
   1.330 +
   1.331 +
   1.332 +// --- TUsbcStatusCallback
   1.333 +
   1.334 +/** Constructor.
   1.335 + */
   1.336 +TUsbcStatusCallback::TUsbcStatusCallback(DBase* aOwner, TDfcFn aCallback, TInt aPriority)
   1.337 +	: iOwner(aOwner),
   1.338 +	  iDfc(aCallback, aOwner, aPriority)
   1.339 +	{
   1.340 + 	ResetState();
   1.341 +	}
   1.342 +
   1.343 +
   1.344 +/** Sets the state of this request to aState (at the first available position
   1.345 +	in the state value array).
   1.346 +
   1.347 +	@param aState The new state to be set.
   1.348 +*/
   1.349 +void TUsbcStatusCallback::SetState(TUsbcDeviceState aState)
   1.350 +	{
   1.351 +	for (TInt i = 0; i < KUsbcDeviceStateRequests; i++)
   1.352 +		{
   1.353 +		if (iState[i] == EUsbcNoState)
   1.354 +			{
   1.355 +			iState[i] = aState;
   1.356 +			return;
   1.357 +			}
   1.358 +		}
   1.359 +	__KTRACE_OPT(KPANIC, Kern::Printf("  Error: KUsbcDeviceStateRequests too small (%d)!",
   1.360 +									  KUsbcDeviceStateRequests));
   1.361 +	}
   1.362 +
   1.363 +
   1.364 +/** Returns the state value of this request at a certain index.
   1.365 +
   1.366 +	@param aIndex The index to be used for referencing the state array.
   1.367 +
   1.368 +	@return The state value of this request at aIndex.
   1.369 +*/
   1.370 +TUsbcDeviceState TUsbcStatusCallback::State(TInt aIndex) const
   1.371 +	{
   1.372 +	if (aIndex >= 0 && aIndex < KUsbcDeviceStateRequests)
   1.373 +		{
   1.374 +		return iState[aIndex];
   1.375 +		}
   1.376 +	else
   1.377 +		{
   1.378 +		__KTRACE_OPT(KPANIC, Kern::Printf("  Error: aIndex too large (%d)!", aIndex));
   1.379 +		return EUsbcNoState;
   1.380 +		}
   1.381 +	}
   1.382 +
   1.383 +
   1.384 +/** Resets the entire state value array of this request.
   1.385 +*/
   1.386 +void TUsbcStatusCallback::ResetState()
   1.387 +	{
   1.388 +	for (TInt i = 0; i < KUsbcDeviceStateRequests; ++i)
   1.389 +		{
   1.390 +		iState[i] = EUsbcNoState;
   1.391 +		}
   1.392 +	}
   1.393 +
   1.394 +
   1.395 +/** Returns a pointer to the owner of this request.
   1.396 +
   1.397 +	@return A pointer to the owner of this request.
   1.398 +*/
   1.399 +DBase* TUsbcStatusCallback::Owner() const
   1.400 +	{
   1.401 +	return iOwner;
   1.402 +	}
   1.403 +
   1.404 +
   1.405 +/** Executes the callback function set by the owner of this request.
   1.406 +
   1.407 +	@return KErrNone.
   1.408 +*/
   1.409 +TInt TUsbcStatusCallback::DoCallback()
   1.410 +	{
   1.411 +	if (NKern::CurrentContext() == EThread)
   1.412 +		iDfc.Enque();
   1.413 +	else
   1.414 +		iDfc.Add();
   1.415 +	return KErrNone;
   1.416 +	}
   1.417 +
   1.418 +
   1.419 +/** Cancels the callback function set by the owner of this request.
   1.420 +*/
   1.421 +void TUsbcStatusCallback::Cancel()
   1.422 +	{
   1.423 +	iDfc.Cancel();
   1.424 +	}
   1.425 +
   1.426 +
   1.427 +/** Sets the DFC queue used by the callback function.
   1.428 +*/
   1.429 +void TUsbcStatusCallback::SetDfcQ(TDfcQue* aDfcQ)
   1.430 +	{
   1.431 +	iDfc.SetDfcQ(aDfcQ);
   1.432 +	}
   1.433 +
   1.434 +// --- TUsbcRequestCallback
   1.435 +
   1.436 +/** Constructor.
   1.437 + */
   1.438 +TUsbcRequestCallback::TUsbcRequestCallback(const DBase* aOwner, TInt aEndpointNum, TDfcFn aDfcFunc,
   1.439 +										   TAny* aEndpoint, TDfcQue* aDfcQ, TInt aPriority)
   1.440 +	: iEndpointNum(aEndpointNum),
   1.441 +	  iRealEpNum(-1),
   1.442 +	  iOwner(aOwner),
   1.443 +	  iDfc(aDfcFunc, aEndpoint, aDfcQ, aPriority),
   1.444 +	  iTransferDir(EControllerNone),
   1.445 +	  iBufferStart(NULL),
   1.446 +	  iPacketIndex(NULL),							  // actually TUint16 (*)[]
   1.447 +	  iPacketSize(NULL),							  // actually TUint16 (*)[]
   1.448 +	  iLength(0),
   1.449 +	  iZlpReqd(EFalse),
   1.450 +	  iTxBytes(0),
   1.451 +	  iRxPackets(0),
   1.452 +	  iError(KErrNone)
   1.453 +	{
   1.454 +	}
   1.455 +
   1.456 +
   1.457 +/** Destructor.
   1.458 + */
   1.459 +TUsbcRequestCallback::~TUsbcRequestCallback()
   1.460 +	{
   1.461 +	__KTRACE_OPT(KUSB, Kern::Printf("TUsbcRequestCallback::~TUsbcRequestCallback()"));
   1.462 +	iDfc.Cancel();
   1.463 +	}
   1.464 +
   1.465 +
   1.466 +/** Sets some data members of this request for a read request.
   1.467 +
   1.468 +	@param aBufferStart The start of the data buffer to be filled.
   1.469 +	@param aBufferAddr The physical address of the buffer (used for DMA).
   1.470 +	@param aPacketIndex A pointer to the packet index values array.
   1.471 +	@param aPacketSize A pointer to the packet size values array.
   1.472 +	@param aLength The number of bytes to be received.
   1.473 +*/
   1.474 +void TUsbcRequestCallback::SetRxBufferInfo(TUint8* aBufferStart, TPhysAddr aBufferAddr,
   1.475 +										   TUsbcPacketArray* aPacketIndex,
   1.476 +										   TUsbcPacketArray* aPacketSize,
   1.477 +										   TInt aLength)
   1.478 +	{
   1.479 +	iTransferDir = EControllerRead;
   1.480 +	iBufferStart = aBufferStart;
   1.481 +	iBufferAddr = aBufferAddr;
   1.482 +	iPacketIndex = aPacketIndex;
   1.483 +	iPacketSize = aPacketSize;
   1.484 +	iLength = aLength;
   1.485 +	}
   1.486 +
   1.487 +
   1.488 +/** Sets some data members of this request for a write request.
   1.489 +
   1.490 +	@param aBufferStart The start of the buffer that contains the data to be sent.
   1.491 +	@param aBufferAddr The physical address of the buffer (used for DMA).
   1.492 +	@param aLength The number of bytes to be transmitted.
   1.493 +*/
   1.494 +void TUsbcRequestCallback::SetTxBufferInfo(TUint8* aBufferStart, TPhysAddr aBufferAddr, TInt aLength)
   1.495 +	{
   1.496 +	iTransferDir = EControllerWrite;
   1.497 +	iBufferStart = aBufferStart;
   1.498 +	iBufferAddr = aBufferAddr;
   1.499 +	iLength = aLength;
   1.500 +	}
   1.501 +
   1.502 +
   1.503 +/** Sets the transfer direction for this request.
   1.504 +
   1.505 +	@param aTransferDir The new transfer direction.
   1.506 +*/
   1.507 +void TUsbcRequestCallback::SetTransferDirection(TTransferDirection aTransferDir)
   1.508 +	{
   1.509 +	iTransferDir = aTransferDir;
   1.510 +	}
   1.511 +
   1.512 +
   1.513 +/** Returns a pointer to the owner of this request.
   1.514 +
   1.515 +	@return A pointer to the owner of this request.
   1.516 +*/
   1.517 +const DBase* TUsbcRequestCallback::Owner() const
   1.518 +	{
   1.519 +	return iOwner;
   1.520 +	}
   1.521 +
   1.522 +
   1.523 +/** Executes the callback function set by the owner of this request.
   1.524 +
   1.525 +	@return KErrNone.
   1.526 +*/
   1.527 +TInt TUsbcRequestCallback::DoCallback()
   1.528 +	{
   1.529 +	if (NKern::CurrentContext() == NKern::EThread)
   1.530 +		iDfc.Enque();
   1.531 +	else
   1.532 +		iDfc.Add();
   1.533 +	return KErrNone;
   1.534 +	}
   1.535 +
   1.536 +
   1.537 +/** Cancels the callback function set by the owner of this request.
   1.538 +*/
   1.539 +void TUsbcRequestCallback::Cancel()
   1.540 +	{
   1.541 +	iDfc.Cancel();
   1.542 +	}
   1.543 +
   1.544 +// --- TUsbcOtgFeatureCallback
   1.545 +
   1.546 +/** Constructor.
   1.547 + */
   1.548 +TUsbcOtgFeatureCallback::TUsbcOtgFeatureCallback(DBase* aOwner, TDfcFn aCallback,
   1.549 +												 TInt aPriority)
   1.550 +	: iOwner(aOwner),
   1.551 +	  iDfc(aCallback, aOwner, aPriority),
   1.552 +	  iValue(0)
   1.553 +	{}
   1.554 +
   1.555 +
   1.556 +/** Returns a pointer to the owner of this request.
   1.557 +	@return A pointer to the owner of this request.
   1.558 +*/
   1.559 +DBase* TUsbcOtgFeatureCallback::Owner() const
   1.560 +	{
   1.561 +	return iOwner;
   1.562 +	}
   1.563 +
   1.564 +
   1.565 +/** Set feature value which is to be notified to client.
   1.566 +	@param OTG feature value to be set
   1.567 +*/
   1.568 +void TUsbcOtgFeatureCallback::SetFeatures(TUint8 aFeatures)
   1.569 +	{
   1.570 +	iValue = aFeatures;
   1.571 +	}
   1.572 +
   1.573 +
   1.574 +/** Set feature value which is to be notified to client.
   1.575 +	@return Value of OTG features
   1.576 +*/
   1.577 +TUint8 TUsbcOtgFeatureCallback::Features() const
   1.578 +	{
   1.579 +	return iValue;
   1.580 +	}
   1.581 +
   1.582 +
   1.583 +/** Set DFC queue.
   1.584 +	@param aDfcQ  DFC queue to be set
   1.585 +*/ 
   1.586 +void TUsbcOtgFeatureCallback::SetDfcQ(TDfcQue* aDfcQ)
   1.587 +	{
   1.588 +	iDfc.SetDfcQ(aDfcQ);
   1.589 +	}
   1.590 +
   1.591 +
   1.592 +/** Executes the callback function set by the owner of this request.
   1.593 +	@return KErrNone.
   1.594 +*/
   1.595 +TInt TUsbcOtgFeatureCallback::DoCallback()
   1.596 +	{
   1.597 +	if (NKern::CurrentContext() == EThread)
   1.598 +		iDfc.Enque();
   1.599 +	else
   1.600 +		iDfc.Add();
   1.601 +	return KErrNone;
   1.602 +	}
   1.603 +
   1.604 +
   1.605 +/** Cancels the callback function set by the owner of this request.
   1.606 + */
   1.607 +void TUsbcOtgFeatureCallback::Cancel()
   1.608 +	{
   1.609 +	iDfc.Cancel();
   1.610 +	}
   1.611 +
   1.612 +
   1.613 +/** Returns a pointer to the currently selected (active) setting of this interface.
   1.614 +
   1.615 +	@return A pointer to the currently selected (active) setting of this interface.
   1.616 +*/
   1.617 +const TUsbcInterface* TUsbcInterfaceSet::CurrentInterface() const
   1.618 +	{
   1.619 +	return iInterfaces[iCurrentInterface];
   1.620 +	}
   1.621 +
   1.622 +
   1.623 +/** Returns a pointer to the currently selected (active) setting of this interface.
   1.624 +
   1.625 +	@return A pointer to the currently selected (active) setting of this interface.
   1.626 +*/
   1.627 +
   1.628 +TUsbcInterface* TUsbcInterfaceSet::CurrentInterface()
   1.629 +	{
   1.630 +	return iInterfaces[iCurrentInterface];
   1.631 +	}
   1.632 +
   1.633 +
   1.634 +#endif // __USBCSHARED_INL__
   1.635 +
   1.636 +
   1.637 +