author | William Roberts <williamr@symbian.org> |
Tue, 06 Jul 2010 13:05:35 +0100 | |
branch | GCC_SURGE |
changeset 195 | 3411883d8fcf |
parent 90 | 947f0dc9f7a8 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2000-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 |
// e32\include\drivers\usbcshared.inl |
|
15 |
// Kernel side definitions for the USB Device driver stack (PIL + LDD). |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
/** |
|
20 |
@file usbcshared.inl |
|
21 |
@internalTechnology |
|
22 |
*/ |
|
23 |
||
24 |
#ifndef __USBCSHARED_INL__ |
|
25 |
#define __USBCSHARED_INL__ |
|
26 |
||
27 |
// |
|
28 |
// --- DUsbClientController (USB PDD) --- |
|
29 |
// |
|
30 |
||
31 |
// --- Private member functions, used by controller itself --- |
|
32 |
||
33 |
const DBase* DUsbClientController::PEndpoint2ClientId(TInt aRealEndpoint) const |
|
34 |
{ |
|
35 |
if (iRealEndpoints[aRealEndpoint].iLEndpoint) |
|
36 |
return iRealEndpoints[aRealEndpoint].iLEndpoint->iInterface->iInterfaceSet->iClientId; |
|
37 |
else |
|
38 |
return NULL; |
|
39 |
} |
|
40 |
||
41 |
||
42 |
TInt DUsbClientController::PEndpoint2LEndpoint(TInt aRealEndpoint) const |
|
43 |
{ |
|
44 |
if (iRealEndpoints[aRealEndpoint].iLEndpoint) |
|
45 |
return iRealEndpoints[aRealEndpoint].iLEndpoint->iLEndpointNum; |
|
46 |
else |
|
47 |
return -1; |
|
48 |
} |
|
49 |
||
50 |
||
51 |
const TUsbcConfiguration* DUsbClientController::CurrentConfig() const |
|
52 |
{ |
|
53 |
return (iCurrentConfig ? iConfigs[iCurrentConfig - 1] : NULL); |
|
54 |
} |
|
55 |
||
56 |
||
57 |
TUsbcConfiguration* DUsbClientController::CurrentConfig() |
|
58 |
{ |
|
59 |
return (iCurrentConfig ? iConfigs[iCurrentConfig - 1] : NULL); |
|
60 |
} |
|
61 |
||
62 |
||
63 |
TBool DUsbClientController::InterfaceExists(TInt aNumber) const |
|
64 |
{ |
|
65 |
const TInt num_ifcsets = iConfigs[0]->iInterfaceSets.Count(); |
|
66 |
RPointerArray<TUsbcInterfaceSet>& ifcsets = iConfigs[0]->iInterfaceSets; |
|
67 |
for (TInt i = 0; i < num_ifcsets; i++) |
|
68 |
{ |
|
69 |
if (ifcsets[i]->iInterfaceNumber == aNumber) |
|
70 |
{ |
|
71 |
return ETrue; |
|
72 |
} |
|
73 |
} |
|
74 |
return EFalse; |
|
75 |
} |
|
76 |
||
77 |
||
78 |
TBool DUsbClientController::EndpointExists(TUint aAddress) const |
|
79 |
{ |
|
80 |
// Ep0 doesn't have a "logical ep" pointer (there's no virtual endpoint zero); |
|
81 |
// that's why this pointer being non-NULL is not a sufficient criterion for |
|
82 |
// endpoint-existence. (Apart from that, ep0 always exists.) |
|
83 |
const TInt idx = EpAddr2Idx(aAddress); |
|
84 |
return ((idx < iDeviceTotalEndpoints) && |
|
85 |
((iRealEndpoints[idx].iLEndpoint != NULL) || |
|
86 |
((aAddress & KUsbEpAddress_Portmask) == 0))); |
|
87 |
} |
|
88 |
||
89 |
||
90 |
void DUsbClientController::Buffer2Setup(const TAny* aBuf, TUsbcSetup& aSetup) const |
|
91 |
{ |
|
92 |
// TUint8 index |
|
93 |
aSetup.iRequestType = static_cast<const TUint8*>(aBuf)[0]; |
|
94 |
aSetup.iRequest = static_cast<const TUint8*>(aBuf)[1]; |
|
95 |
// TUint16 index from here! |
|
96 |
aSetup.iValue = SWAP_BYTES_16((static_cast<const TUint16*>(aBuf))[1]); |
|
97 |
aSetup.iIndex = SWAP_BYTES_16((static_cast<const TUint16*>(aBuf))[2]); |
|
98 |
aSetup.iLength = SWAP_BYTES_16((static_cast<const TUint16*>(aBuf))[3]); |
|
99 |
} |
|
100 |
||
101 |
||
102 |
TUint DUsbClientController::EpIdx2Addr(TUint aRealEndpoint) const |
|
103 |
{ |
|
104 |
return ((aRealEndpoint << 7) & 0x80) | ((aRealEndpoint >> 1) & 0x0f); |
|
105 |
} |
|
106 |
||
107 |
||
108 |
TUint DUsbClientController::EpAddr2Idx(TUint aAddress) const |
|
109 |
{ |
|
110 |
return ((aAddress & 0x80) >> 7) | ((aAddress & 0x0f) << 1); |
|
111 |
} |
|
112 |
||
113 |
||
114 |
void DUsbClientController::SetEp0DataOutVars(const TUsbcSetup& aPacket, const DBase* aClientId) |
|
115 |
{ |
|
116 |
__KTRACE_OPT(KUSB, Kern::Printf("DUsbClientController::SetEp0DataOutVars()")); |
|
117 |
iSetup = aPacket; |
|
118 |
iEp0DataReceiving = ETrue; |
|
119 |
iEp0DataReceived = 0; |
|
120 |
iEp0ClientId = aClientId; |
|
121 |
} |
|
122 |
||
123 |
||
124 |
void DUsbClientController::ResetEp0DataOutVars() |
|
125 |
{ |
|
126 |
__KTRACE_OPT(KUSB, Kern::Printf("DUsbClientController::ResetEp0DataOutVars()")); |
|
127 |
iEp0DataReceiving = EFalse; |
|
128 |
iEp0DataReceived = 0; |
|
129 |
iEp0ClientId = NULL; |
|
130 |
} |
|
131 |
||
132 |
||
133 |
TBool DUsbClientController::IsInTheRequestList(const TUsbcRequestCallback& aCallback) |
|
134 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
const TInt irq = __SPIN_LOCK_IRQSAVE(iUsbLock); |
0 | 136 |
TSglQueIter<TUsbcRequestCallback> iter(iEp0ReadRequestCallbacks); |
137 |
TUsbcRequestCallback* p; |
|
138 |
while ((p = iter++) != NULL) |
|
139 |
{ |
|
140 |
if (p == &aCallback) |
|
141 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
__SPIN_UNLOCK_IRQRESTORE(iUsbLock, irq); |
0 | 143 |
return ETrue; |
144 |
} |
|
145 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
__SPIN_UNLOCK_IRQRESTORE(iUsbLock, irq); |
0 | 147 |
return EFalse; |
148 |
} |
|
149 |
||
150 |
||
151 |
TBool DUsbClientController::IsInTheStatusList(const TUsbcStatusCallback& aCallback) |
|
152 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
const TInt irq = __SPIN_LOCK_IRQSAVE(iUsbLock); |
0 | 154 |
TSglQueIter<TUsbcStatusCallback> iter(iStatusCallbacks); |
155 |
TUsbcStatusCallback* p; |
|
156 |
while ((p = iter++) != NULL) |
|
157 |
{ |
|
158 |
if (p == &aCallback) |
|
159 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
160 |
__SPIN_UNLOCK_IRQRESTORE(iUsbLock, irq); |
0 | 161 |
return ETrue; |
162 |
} |
|
163 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
__SPIN_UNLOCK_IRQRESTORE(iUsbLock, irq); |
0 | 165 |
return EFalse; |
166 |
} |
|
167 |
||
168 |
||
169 |
TBool DUsbClientController::IsInTheEpStatusList(const TUsbcEndpointStatusCallback& aCallback) |
|
170 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
const TInt irq = __SPIN_LOCK_IRQSAVE(iUsbLock); |
0 | 172 |
TSglQueIter<TUsbcEndpointStatusCallback> iter(iEpStatusCallbacks); |
173 |
TUsbcEndpointStatusCallback* p; |
|
174 |
while ((p = iter++) != NULL) |
|
175 |
{ |
|
176 |
if (p == &aCallback) |
|
177 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
178 |
__SPIN_UNLOCK_IRQRESTORE(iUsbLock, irq); |
0 | 179 |
return ETrue; |
180 |
} |
|
181 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
182 |
__SPIN_UNLOCK_IRQRESTORE(iUsbLock, irq); |
0 | 183 |
return EFalse; |
184 |
} |
|
185 |
||
186 |
||
187 |
TBool DUsbClientController::IsInTheOtgFeatureList(const TUsbcOtgFeatureCallback& aCallback) |
|
188 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
const TInt irq = __SPIN_LOCK_IRQSAVE(iUsbLock); |
0 | 190 |
TSglQueIter<TUsbcOtgFeatureCallback> iter(iOtgCallbacks); |
191 |
TUsbcOtgFeatureCallback* p; |
|
192 |
while ((p = iter++) != NULL) |
|
193 |
{ |
|
194 |
if (p == &aCallback) |
|
195 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
__SPIN_UNLOCK_IRQRESTORE(iUsbLock, irq); |
0 | 197 |
return ETrue; |
198 |
} |
|
199 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
__SPIN_UNLOCK_IRQRESTORE(iUsbLock, irq); |
0 | 201 |
return EFalse; |
202 |
} |
|
203 |
||
204 |
// |
|
205 |
// --- Misc classes --- |
|
206 |
// |
|
207 |
||
208 |
// --- TUsbcClientCallback |
|
209 |
||
210 |
/** Constructor. |
|
211 |
*/ |
|
212 |
TUsbcClientCallback::TUsbcClientCallback(DBase* aOwner, TDfcFn aCallback, TInt aPriority) |
|
213 |
: iOwner(aOwner), |
|
214 |
iDfc(aCallback, aOwner, aPriority) |
|
215 |
{} |
|
216 |
||
217 |
||
218 |
/** Returns a pointer to the owner of this request. |
|
219 |
||
220 |
@return A pointer to the owner of this request. |
|
221 |
*/ |
|
222 |
DBase* TUsbcClientCallback::Owner() const |
|
223 |
{ |
|
224 |
return iOwner; |
|
225 |
} |
|
226 |
||
227 |
||
228 |
/** Executes the callback function set by the owner of this request. |
|
229 |
||
230 |
@return KErrNone. |
|
231 |
*/ |
|
232 |
TInt TUsbcClientCallback::DoCallback() |
|
233 |
{ |
|
234 |
__ASSERT_DEBUG((NKern::CurrentContext() == EThread), Kern::Fault(KUsbPILPanicCat, __LINE__)); |
|
235 |
iDfc.Enque(); |
|
236 |
return KErrNone; |
|
237 |
} |
|
238 |
||
239 |
||
240 |
/** Cancels the callback function set by the owner of this request. |
|
241 |
*/ |
|
242 |
void TUsbcClientCallback::Cancel() |
|
243 |
{ |
|
244 |
iDfc.Cancel(); |
|
245 |
} |
|
246 |
||
247 |
||
248 |
/** Sets the DFC queue used by the callback function. |
|
249 |
@param aDfcQ DFC queue to be set |
|
250 |
*/ |
|
251 |
void TUsbcClientCallback::SetDfcQ(TDfcQue* aDfcQ) |
|
252 |
{ |
|
253 |
iDfc.SetDfcQ(aDfcQ); |
|
254 |
} |
|
255 |
||
256 |
||
257 |
// --- TUsbcEndpointStatusCallback |
|
258 |
||
259 |
/** Constructor. |
|
260 |
*/ |
|
261 |
TUsbcEndpointStatusCallback::TUsbcEndpointStatusCallback(DBase* aOwner, TDfcFn aCallback, |
|
262 |
TInt aPriority) |
|
263 |
: iOwner(aOwner), |
|
264 |
iDfc(aCallback, aOwner, aPriority), |
|
265 |
iState(0) |
|
266 |
{} |
|
267 |
||
268 |
||
269 |
/** Sets the state of this request to aState. |
|
270 |
||
271 |
@param aState The new state to be set. |
|
272 |
*/ |
|
273 |
void TUsbcEndpointStatusCallback::SetState(TUint aState) |
|
274 |
{ |
|
275 |
iState = aState; |
|
276 |
} |
|
277 |
||
278 |
||
279 |
/** Returns the state value of this request. |
|
280 |
||
281 |
@return The state value of this request. |
|
282 |
*/ |
|
283 |
TUint TUsbcEndpointStatusCallback::State() const |
|
284 |
{ |
|
285 |
return iState; |
|
286 |
} |
|
287 |
||
288 |
||
289 |
/** Returns a pointer to the owner of this request. |
|
290 |
||
291 |
@return A pointer to the owner of this request. |
|
292 |
*/ |
|
293 |
DBase* TUsbcEndpointStatusCallback::Owner() const |
|
294 |
{ |
|
295 |
return iOwner; |
|
296 |
} |
|
297 |
||
298 |
||
299 |
/** Executes the callback function set by the owner of this request. |
|
300 |
||
301 |
@return KErrNone. |
|
302 |
*/ |
|
303 |
TInt TUsbcEndpointStatusCallback::DoCallback() |
|
304 |
{ |
|
305 |
if (NKern::CurrentContext() == EThread) |
|
306 |
iDfc.Enque(); |
|
307 |
else |
|
308 |
iDfc.Add(); |
|
309 |
return KErrNone; |
|
310 |
} |
|
311 |
||
312 |
||
313 |
/** Cancels the callback function set by the owner of this request. |
|
314 |
*/ |
|
315 |
void TUsbcEndpointStatusCallback::Cancel() |
|
316 |
{ |
|
317 |
iDfc.Cancel(); |
|
318 |
} |
|
319 |
||
320 |
||
321 |
/** Sets the DFC queue used by the callback function. |
|
322 |
*/ |
|
323 |
void TUsbcEndpointStatusCallback::SetDfcQ(TDfcQue* aDfcQ) |
|
324 |
{ |
|
325 |
iDfc.SetDfcQ(aDfcQ); |
|
326 |
} |
|
327 |
||
328 |
||
329 |
// --- TUsbcStatusCallback |
|
330 |
||
331 |
/** Constructor. |
|
332 |
*/ |
|
333 |
TUsbcStatusCallback::TUsbcStatusCallback(DBase* aOwner, TDfcFn aCallback, TInt aPriority) |
|
334 |
: iOwner(aOwner), |
|
335 |
iDfc(aCallback, aOwner, aPriority) |
|
336 |
{ |
|
337 |
ResetState(); |
|
338 |
} |
|
339 |
||
340 |
||
341 |
/** Sets the state of this request to aState (at the first available position |
|
342 |
in the state value array). |
|
343 |
||
344 |
@param aState The new state to be set. |
|
345 |
*/ |
|
346 |
void TUsbcStatusCallback::SetState(TUsbcDeviceState aState) |
|
347 |
{ |
|
348 |
for (TInt i = 0; i < KUsbcDeviceStateRequests; i++) |
|
349 |
{ |
|
350 |
if (iState[i] == EUsbcNoState) |
|
351 |
{ |
|
352 |
iState[i] = aState; |
|
353 |
return; |
|
354 |
} |
|
355 |
} |
|
356 |
__KTRACE_OPT(KPANIC, Kern::Printf(" Error: KUsbcDeviceStateRequests too small (%d)!", |
|
357 |
KUsbcDeviceStateRequests)); |
|
358 |
} |
|
359 |
||
360 |
||
361 |
/** Returns the state value of this request at a certain index. |
|
362 |
||
363 |
@param aIndex The index to be used for referencing the state array. |
|
364 |
||
365 |
@return The state value of this request at aIndex. |
|
366 |
*/ |
|
367 |
TUsbcDeviceState TUsbcStatusCallback::State(TInt aIndex) const |
|
368 |
{ |
|
369 |
if (aIndex >= 0 && aIndex < KUsbcDeviceStateRequests) |
|
370 |
{ |
|
371 |
return iState[aIndex]; |
|
372 |
} |
|
373 |
else |
|
374 |
{ |
|
375 |
__KTRACE_OPT(KPANIC, Kern::Printf(" Error: aIndex too large (%d)!", aIndex)); |
|
376 |
return EUsbcNoState; |
|
377 |
} |
|
378 |
} |
|
379 |
||
380 |
||
381 |
/** Resets the entire state value array of this request. |
|
382 |
*/ |
|
383 |
void TUsbcStatusCallback::ResetState() |
|
384 |
{ |
|
385 |
for (TInt i = 0; i < KUsbcDeviceStateRequests; ++i) |
|
386 |
{ |
|
387 |
iState[i] = EUsbcNoState; |
|
388 |
} |
|
389 |
} |
|
390 |
||
391 |
||
392 |
/** Returns a pointer to the owner of this request. |
|
393 |
||
394 |
@return A pointer to the owner of this request. |
|
395 |
*/ |
|
396 |
DBase* TUsbcStatusCallback::Owner() const |
|
397 |
{ |
|
398 |
return iOwner; |
|
399 |
} |
|
400 |
||
401 |
||
402 |
/** Executes the callback function set by the owner of this request. |
|
403 |
||
404 |
@return KErrNone. |
|
405 |
*/ |
|
406 |
TInt TUsbcStatusCallback::DoCallback() |
|
407 |
{ |
|
408 |
if (NKern::CurrentContext() == EThread) |
|
409 |
iDfc.Enque(); |
|
410 |
else |
|
411 |
iDfc.Add(); |
|
412 |
return KErrNone; |
|
413 |
} |
|
414 |
||
415 |
||
416 |
/** Cancels the callback function set by the owner of this request. |
|
417 |
*/ |
|
418 |
void TUsbcStatusCallback::Cancel() |
|
419 |
{ |
|
420 |
iDfc.Cancel(); |
|
421 |
} |
|
422 |
||
423 |
||
424 |
/** Sets the DFC queue used by the callback function. |
|
425 |
*/ |
|
426 |
void TUsbcStatusCallback::SetDfcQ(TDfcQue* aDfcQ) |
|
427 |
{ |
|
428 |
iDfc.SetDfcQ(aDfcQ); |
|
429 |
} |
|
430 |
||
431 |
// --- TUsbcRequestCallback |
|
432 |
||
433 |
/** Constructor. |
|
434 |
*/ |
|
435 |
TUsbcRequestCallback::TUsbcRequestCallback(const DBase* aOwner, TInt aEndpointNum, TDfcFn aDfcFunc, |
|
436 |
TAny* aEndpoint, TDfcQue* aDfcQ, TInt aPriority) |
|
437 |
: iEndpointNum(aEndpointNum), |
|
438 |
iRealEpNum(-1), |
|
439 |
iOwner(aOwner), |
|
440 |
iDfc(aDfcFunc, aEndpoint, aDfcQ, aPriority), |
|
441 |
iTransferDir(EControllerNone), |
|
442 |
iBufferStart(NULL), |
|
443 |
iPacketIndex(NULL), // actually TUint16 (*)[] |
|
444 |
iPacketSize(NULL), // actually TUint16 (*)[] |
|
445 |
iLength(0), |
|
446 |
iZlpReqd(EFalse), |
|
447 |
iTxBytes(0), |
|
448 |
iRxPackets(0), |
|
449 |
iError(KErrNone) |
|
450 |
{ |
|
451 |
} |
|
452 |
||
453 |
||
454 |
/** Destructor. |
|
455 |
*/ |
|
456 |
TUsbcRequestCallback::~TUsbcRequestCallback() |
|
457 |
{ |
|
458 |
__KTRACE_OPT(KUSB, Kern::Printf("TUsbcRequestCallback::~TUsbcRequestCallback()")); |
|
459 |
iDfc.Cancel(); |
|
460 |
} |
|
461 |
||
462 |
||
463 |
/** Sets some data members of this request for a read request. |
|
464 |
||
465 |
@param aBufferStart The start of the data buffer to be filled. |
|
466 |
@param aBufferAddr The physical address of the buffer (used for DMA). |
|
467 |
@param aPacketIndex A pointer to the packet index values array. |
|
468 |
@param aPacketSize A pointer to the packet size values array. |
|
469 |
@param aLength The number of bytes to be received. |
|
470 |
*/ |
|
471 |
void TUsbcRequestCallback::SetRxBufferInfo(TUint8* aBufferStart, TPhysAddr aBufferAddr, |
|
472 |
TUsbcPacketArray* aPacketIndex, |
|
473 |
TUsbcPacketArray* aPacketSize, |
|
474 |
TInt aLength) |
|
475 |
{ |
|
476 |
iTransferDir = EControllerRead; |
|
477 |
iBufferStart = aBufferStart; |
|
478 |
iBufferAddr = aBufferAddr; |
|
479 |
iPacketIndex = aPacketIndex; |
|
480 |
iPacketSize = aPacketSize; |
|
481 |
iLength = aLength; |
|
482 |
} |
|
483 |
||
484 |
||
485 |
/** Sets some data members of this request for a write request. |
|
486 |
||
487 |
@param aBufferStart The start of the buffer that contains the data to be sent. |
|
488 |
@param aBufferAddr The physical address of the buffer (used for DMA). |
|
489 |
@param aLength The number of bytes to be transmitted. |
|
490 |
*/ |
|
491 |
void TUsbcRequestCallback::SetTxBufferInfo(TUint8* aBufferStart, TPhysAddr aBufferAddr, TInt aLength) |
|
492 |
{ |
|
493 |
iTransferDir = EControllerWrite; |
|
494 |
iBufferStart = aBufferStart; |
|
495 |
iBufferAddr = aBufferAddr; |
|
496 |
iLength = aLength; |
|
497 |
} |
|
498 |
||
499 |
||
500 |
/** Sets the transfer direction for this request. |
|
501 |
||
502 |
@param aTransferDir The new transfer direction. |
|
503 |
*/ |
|
504 |
void TUsbcRequestCallback::SetTransferDirection(TTransferDirection aTransferDir) |
|
505 |
{ |
|
506 |
iTransferDir = aTransferDir; |
|
507 |
} |
|
508 |
||
509 |
||
510 |
/** Returns a pointer to the owner of this request. |
|
511 |
||
512 |
@return A pointer to the owner of this request. |
|
513 |
*/ |
|
514 |
const DBase* TUsbcRequestCallback::Owner() const |
|
515 |
{ |
|
516 |
return iOwner; |
|
517 |
} |
|
518 |
||
519 |
||
520 |
/** Executes the callback function set by the owner of this request. |
|
521 |
||
522 |
@return KErrNone. |
|
523 |
*/ |
|
524 |
TInt TUsbcRequestCallback::DoCallback() |
|
525 |
{ |
|
526 |
if (NKern::CurrentContext() == NKern::EThread) |
|
527 |
iDfc.Enque(); |
|
528 |
else |
|
529 |
iDfc.Add(); |
|
530 |
return KErrNone; |
|
531 |
} |
|
532 |
||
533 |
||
534 |
/** Cancels the callback function set by the owner of this request. |
|
535 |
*/ |
|
536 |
void TUsbcRequestCallback::Cancel() |
|
537 |
{ |
|
538 |
iDfc.Cancel(); |
|
539 |
} |
|
540 |
||
541 |
// --- TUsbcOtgFeatureCallback |
|
542 |
||
543 |
/** Constructor. |
|
544 |
*/ |
|
545 |
TUsbcOtgFeatureCallback::TUsbcOtgFeatureCallback(DBase* aOwner, TDfcFn aCallback, |
|
546 |
TInt aPriority) |
|
547 |
: iOwner(aOwner), |
|
548 |
iDfc(aCallback, aOwner, aPriority), |
|
549 |
iValue(0) |
|
550 |
{} |
|
551 |
||
552 |
||
553 |
/** Returns a pointer to the owner of this request. |
|
554 |
@return A pointer to the owner of this request. |
|
555 |
*/ |
|
556 |
DBase* TUsbcOtgFeatureCallback::Owner() const |
|
557 |
{ |
|
558 |
return iOwner; |
|
559 |
} |
|
560 |
||
561 |
||
562 |
/** Set feature value which is to be notified to client. |
|
563 |
@param OTG feature value to be set |
|
564 |
*/ |
|
565 |
void TUsbcOtgFeatureCallback::SetFeatures(TUint8 aFeatures) |
|
566 |
{ |
|
567 |
iValue = aFeatures; |
|
568 |
} |
|
569 |
||
570 |
||
571 |
/** Set feature value which is to be notified to client. |
|
572 |
@return Value of OTG features |
|
573 |
*/ |
|
574 |
TUint8 TUsbcOtgFeatureCallback::Features() const |
|
575 |
{ |
|
576 |
return iValue; |
|
577 |
} |
|
578 |
||
579 |
||
580 |
/** Set DFC queue. |
|
581 |
@param aDfcQ DFC queue to be set |
|
582 |
*/ |
|
583 |
void TUsbcOtgFeatureCallback::SetDfcQ(TDfcQue* aDfcQ) |
|
584 |
{ |
|
585 |
iDfc.SetDfcQ(aDfcQ); |
|
586 |
} |
|
587 |
||
588 |
||
589 |
/** Executes the callback function set by the owner of this request. |
|
590 |
@return KErrNone. |
|
591 |
*/ |
|
592 |
TInt TUsbcOtgFeatureCallback::DoCallback() |
|
593 |
{ |
|
594 |
if (NKern::CurrentContext() == EThread) |
|
595 |
iDfc.Enque(); |
|
596 |
else |
|
597 |
iDfc.Add(); |
|
598 |
return KErrNone; |
|
599 |
} |
|
600 |
||
601 |
||
602 |
/** Cancels the callback function set by the owner of this request. |
|
603 |
*/ |
|
604 |
void TUsbcOtgFeatureCallback::Cancel() |
|
605 |
{ |
|
606 |
iDfc.Cancel(); |
|
607 |
} |
|
608 |
||
609 |
||
610 |
/** Returns a pointer to the currently selected (active) setting of this interface. |
|
611 |
||
612 |
@return A pointer to the currently selected (active) setting of this interface. |
|
613 |
*/ |
|
614 |
const TUsbcInterface* TUsbcInterfaceSet::CurrentInterface() const |
|
615 |
{ |
|
616 |
return iInterfaces[iCurrentInterface]; |
|
617 |
} |
|
618 |
||
619 |
||
620 |
/** Returns a pointer to the currently selected (active) setting of this interface. |
|
621 |
||
622 |
@return A pointer to the currently selected (active) setting of this interface. |
|
623 |
*/ |
|
624 |
||
625 |
TUsbcInterface* TUsbcInterfaceSet::CurrentInterface() |
|
626 |
{ |
|
627 |
return iInterfaces[iCurrentInterface]; |
|
628 |
} |
|
629 |
||
630 |
||
631 |
#endif // __USBCSHARED_INL__ |
|
632 |
||
633 |
||
634 |