author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 26 | c734af59ce98 |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1 |
// Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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/drivers/usbcc/chapter9.cpp |
|
15 |
// Platform independent layer (PIL) of the USB Device controller driver: |
|
16 |
// Processing of USB spec chapter 9 standard requests. |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
/** |
|
21 |
@file chapter9.cpp |
|
22 |
@internalTechnology |
|
23 |
*/ |
|
24 |
||
25 |
#include <drivers/usbc.h> |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
26 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
27 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
28 |
#include "chapter9Traces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
29 |
#endif |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
30 |
|
0 | 31 |
|
32 |
||
33 |
//#define ENABLE_EXCESSIVE_DEBUG_OUTPUT |
|
34 |
||
35 |
// |
|
36 |
// The way functions are called after an request has been completed by the PSL: |
|
37 |
// |
|
38 |
// Ep0RequestComplete |
|
39 |
// | |
|
40 |
// ------------------------------------------------ |
|
41 |
// | | |
|
42 |
// ProcessEp0ReceiveDone ProcessEp0TransmitDone |
|
43 |
// | | |
|
44 |
// --------------------------------------- | |
|
45 |
// | | | |
|
46 |
// ProcessEp0SetupReceived ProcessEp0DataReceived ProcessDataTransferDone |
|
47 |
// | | |
|
48 |
// --------------------- --------------- |
|
49 |
// | | | | |
|
50 |
// ProcessXXX ProcessDataTransferDone ProceedXXX ProcessDataTransferDone |
|
51 |
// |
|
52 |
// XXX = Specific_Request |
|
53 |
// |
|
54 |
||
55 |
// |
|
56 |
// === USB Controller member function implementation - PSL API (protected) ======================== |
|
57 |
// |
|
58 |
||
59 |
/** Used to synchronize the Ep0 state machine between the PSL and PIL. |
|
60 |
Accepts a SETUP packet and returns the next Ep0 state. |
|
61 |
||
62 |
@param aSetupBuf The SETUP packet just received by the PSL. |
|
63 |
@return The next Ep0 state. |
|
64 |
||
65 |
@publishedPartner @released |
|
66 |
*/ |
|
67 |
TUsbcEp0State DUsbClientController::EnquireEp0NextState(const TUint8* aSetupBuf) const |
|
68 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
69 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_ENQUIREEP0NEXTSTATE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
70 |
"DUsbClientController::EnquireEp0NextState()" ); |
0 | 71 |
|
72 |
// This function may be called by the PSL from within an ISR -- so we have |
|
73 |
// to take care what we do here (and also in all functions that get called |
|
74 |
// from here). |
|
75 |
||
76 |
if (SWAP_BYTES_16((reinterpret_cast<const TUint16*>(aSetupBuf)[3])) == 0) // iLength |
|
77 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
78 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_ENQUIREEP0NEXTSTATE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
79 |
" --> EEp0StateStatusIn" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
80 |
|
0 | 81 |
return EEp0StateStatusIn; // No-data Control => Status_IN |
82 |
} |
|
83 |
else if ((aSetupBuf[0] & KUsbRequestType_DirMask) == KUsbRequestType_DirToDev) |
|
84 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
85 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_ENQUIREEP0NEXTSTATE_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
86 |
" --> EEp0StateDataOut" ); |
0 | 87 |
return EEp0StateDataOut; // Control Write => Data_OUT |
88 |
} |
|
89 |
else |
|
90 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
91 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_ENQUIREEP0NEXTSTATE_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
92 |
" --> EEp0StateDataIn" ); |
0 | 93 |
return EEp0StateDataIn; // Control Read => Data_IN |
94 |
} |
|
95 |
} |
|
96 |
||
97 |
||
98 |
TInt DUsbClientController::ProcessEp0ReceiveDone(TInt aCount) |
|
99 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
100 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0RECEIVEDONE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
101 |
"DUsbClientController::ProcessEp0ReceiveDone()" ); |
0 | 102 |
TInt r; |
103 |
if (iEp0DataReceiving == EFalse) |
|
104 |
{ |
|
105 |
// It's obviously a Setup packet, so... |
|
106 |
r = ProcessEp0SetupReceived(aCount); |
|
107 |
} |
|
108 |
else |
|
109 |
{ |
|
110 |
// If it isn't a Setup, it must be data... |
|
111 |
// (This is actually not quite true, as it could also be - in theory - a new Setup packet |
|
112 |
// when the host has abandoned, for whatever reason, the previous one which was still |
|
113 |
// in progress. However no such case is known to have occurred with this driver, or at |
|
114 |
// least it didn't lead to problems. |
|
115 |
// Some UDCs have a dedicated interrupt for Setup packets, but so far this driver hasn't |
|
116 |
// made use of such a feature (as it would require a PSL/PIL API change).) |
|
117 |
r = ProcessEp0DataReceived(aCount); |
|
118 |
} |
|
119 |
return r; |
|
120 |
} |
|
121 |
||
122 |
||
123 |
TInt DUsbClientController::ProcessEp0TransmitDone(TInt aCount, TInt aError) |
|
124 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
125 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0TRANSMITDONE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
126 |
"DUsbClientController::ProcessEp0TransmitDone()" ); |
0 | 127 |
// In any case: there's now no longer a write pending |
128 |
iEp0WritePending = EFalse; |
|
129 |
// If it was a client who set up this transmission, we report to that client |
|
130 |
if (iEp0ClientDataTransmitting) |
|
131 |
{ |
|
132 |
iEp0ClientDataTransmitting = EFalse; |
|
133 |
TUsbcRequestCallback* const p = iRequestCallbacks[KEp0_Tx]; |
|
134 |
if (p) |
|
135 |
{ |
|
136 |
__ASSERT_DEBUG((p->iTransferDir == EControllerWrite), Kern::Fault(KUsbPILPanicCat, __LINE__)); |
|
137 |
p->iError = aError; |
|
138 |
p->iTxBytes = aCount; |
|
139 |
ProcessDataTransferDone(*p); |
|
140 |
return KErrNone; |
|
141 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
142 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0TRANSMITDONE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
143 |
" Error: DUsbClientController::ProcessEpTransmitDone: Stalling Ep0" ); |
0 | 144 |
StallEndpoint(KEp0_In); // request not found |
145 |
return KErrNotFound; |
|
146 |
} |
|
147 |
// If _we_ sent the data, we simply do nothing here... |
|
148 |
return KErrNone; |
|
149 |
} |
|
150 |
||
151 |
TInt DUsbClientController::ProcessEp0SetupReceived(TInt aCount) |
|
152 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
153 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
154 |
"DUsbClientController::ProcessEp0SetupReceived()" ); |
0 | 155 |
|
156 |
if (aCount > iEp0MaxPacketSize) |
|
157 |
{ |
|
158 |
// Fatal error: too much data! |
|
159 |
aCount = iEp0MaxPacketSize; |
|
160 |
} |
|
161 |
||
162 |
// first we split the data into meaningful units: |
|
163 |
TUsbcSetup packet; |
|
164 |
Buffer2Setup(iEp0_RxBuf, packet); |
|
165 |
||
166 |
#if defined(_DEBUG) && defined(ENABLE_EXCESSIVE_DEBUG_OUTPUT) |
|
167 |
// let's see what we've got: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
168 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
169 |
" bmRequestType = 0x%02x", packet.iRequestType ); |
0 | 170 |
if ((packet.iRequestType & KUsbRequestType_TypeMask) == KUsbRequestType_TypeStd) |
171 |
{ |
|
172 |
switch (packet.iRequest) |
|
173 |
{ |
|
174 |
case KUsbRequest_GetStatus: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
175 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
176 |
" bRequest = 0x%02x (GET_STATUS)", KUsbRequest_GetStatus ); |
0 | 177 |
break; |
178 |
case KUsbRequest_ClearFeature: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
179 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
180 |
" bRequest = 0x%02x (CLEAR_FEATURE)", KUsbRequest_ClearFeature ); |
0 | 181 |
break; |
182 |
case KUsbRequest_SetFeature: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
183 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
184 |
" bRequest = 0x%02x (SET_FEATURE)", KUsbRequest_SetFeature ); |
0 | 185 |
break; |
186 |
case KUsbRequest_SetAddress: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
187 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP5, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
188 |
" bRequest = 0x%02x (SET_ADDRESS)", KUsbRequest_SetAddress ); |
0 | 189 |
break; |
190 |
case KUsbRequest_GetDescriptor: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
191 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP6, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
192 |
" bRequest = 0x%02x (GET_DESCRIPTOR)", KUsbRequest_GetDescriptor ); |
0 | 193 |
break; |
194 |
case KUsbRequest_SetDescriptor: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
195 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP7, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
196 |
" bRequest = 0x%02x (SET_DESCRIPTOR)", KUsbRequest_SetDescriptor ); |
0 | 197 |
break; |
198 |
case KUsbRequest_GetConfig: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
199 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP8, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
200 |
" bRequest = 0x%02x (GET_CONFIGURATION)", KUsbRequest_GetConfig ); |
0 | 201 |
break; |
202 |
case KUsbRequest_SetConfig: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
203 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP9, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
204 |
" bRequest = 0x%02x (SET_CONFIGURATION)", KUsbRequest_SetConfig ); |
0 | 205 |
break; |
206 |
case KUsbRequest_GetInterface: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
207 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP10, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
208 |
" bRequest = 0x%02x (GET_INTERFACE)", KUsbRequest_GetInterface ); |
0 | 209 |
break; |
210 |
case KUsbRequest_SetInterface: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
211 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP11, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
212 |
" bRequest = 0x%02x (SET_INTERFACE)", KUsbRequest_SetInterface ); |
0 | 213 |
break; |
214 |
case KUsbRequest_SynchFrame: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
215 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP12, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
216 |
" bRequest = 0x%02x (SYNCH_FRAME)", KUsbRequest_SynchFrame ); |
0 | 217 |
break; |
218 |
default: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
219 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP13, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
220 |
" Error: bRequest = 0x%02x (UNKNWON STANDARD REQUEST)", packet.iRequest ); |
0 | 221 |
break; |
222 |
} |
|
223 |
} |
|
224 |
else |
|
225 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
226 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP14, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
227 |
" bRequest = 0x%02x (NON-STANDARD REQUEST)", packet.iRequest ); |
0 | 228 |
} |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
229 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP15, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
230 |
" wValue = 0x%04x", packet.iValue ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
231 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP16, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
232 |
" wIndex = 0x%04x", packet.iIndex ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
233 |
OstTraceDef1( OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP17, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
234 |
" wLength = 0x%04x", packet.iLength ); |
0 | 235 |
#endif // defined(_DEBUG) && defined(ENABLE_EXCESSIVE_DEBUG_OUTPUT) |
236 |
||
237 |
// now the actual analysis |
|
238 |
if ((packet.iRequestType & KUsbRequestType_TypeMask) == KUsbRequestType_TypeStd) |
|
239 |
{ |
|
240 |
iEp0ReceivedNonStdRequest = EFalse; |
|
241 |
switch (packet.iRequest) |
|
242 |
{ |
|
243 |
case KUsbRequest_GetStatus: |
|
244 |
switch (packet.iRequestType & KUsbRequestType_DestMask) |
|
245 |
{ // Recipient |
|
246 |
case KUsbRequestType_DestDevice: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
247 |
if (ProcessGetDeviceStatus(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
248 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
249 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP18, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
250 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
251 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
252 |
} |
0 | 253 |
break; |
254 |
case KUsbRequestType_DestIfc: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
255 |
if (ProcessGetInterfaceStatus(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
256 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
257 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP19, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
258 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
259 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
260 |
} |
0 | 261 |
break; |
262 |
case KUsbRequestType_DestEp: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
263 |
if (ProcessGetEndpointStatus(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
264 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
265 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP20, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
266 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
267 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
268 |
} |
0 | 269 |
break; |
270 |
default: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
271 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP21, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
272 |
" Error: GET STATUS - Other or Unknown recipient" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
273 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP22, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
274 |
" -> DUsbClientController::ProcessEp0SetupReceived: Stalling Ep0" ); |
0 | 275 |
StallEndpoint(KEp0_In); |
276 |
break; |
|
277 |
} |
|
278 |
break; |
|
279 |
case KUsbRequest_ClearFeature: |
|
280 |
case KUsbRequest_SetFeature: |
|
281 |
switch (packet.iRequestType & KUsbRequestType_DestMask) |
|
282 |
{ // Recipient |
|
283 |
case KUsbRequestType_DestDevice: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
284 |
if (ProcessSetClearDevFeature(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
285 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
286 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP23, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
287 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
288 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
289 |
} |
0 | 290 |
break; |
291 |
case KUsbRequestType_DestIfc: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
292 |
if (ProcessSetClearIfcFeature(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
293 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
294 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP24, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
295 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
296 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
297 |
} |
0 | 298 |
break; |
299 |
case KUsbRequestType_DestEp: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
300 |
if (ProcessSetClearEpFeature(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
301 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
302 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP25, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
303 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
304 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
305 |
} |
0 | 306 |
break; |
307 |
default: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
308 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP26, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
309 |
" Error: SET/CLEAR FEATURE - Other or Unknown recipient" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
310 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP27, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
311 |
" -> Stalling Ep0" ); |
0 | 312 |
StallEndpoint(KEp0_In); |
313 |
break; |
|
314 |
} |
|
315 |
break; |
|
316 |
case KUsbRequest_SetAddress: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
317 |
if (ProcessSetAddress(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
318 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
319 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP28, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
320 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
321 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
322 |
} |
0 | 323 |
break; |
324 |
case KUsbRequest_GetDescriptor: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
325 |
if (ProcessGetDescriptor(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
326 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
327 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP29, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
328 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
329 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
330 |
} |
0 | 331 |
break; |
332 |
case KUsbRequest_SetDescriptor: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
333 |
if (ProcessSetDescriptor(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
334 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
335 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP30, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
336 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
337 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
338 |
} |
0 | 339 |
break; |
340 |
case KUsbRequest_GetConfig: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
341 |
if (ProcessGetConfiguration(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
342 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
343 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP31, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
344 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
345 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
346 |
} |
0 | 347 |
break; |
348 |
case KUsbRequest_SetConfig: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
349 |
if (ProcessSetConfiguration(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
350 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
351 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP32, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
352 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
353 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
354 |
} |
0 | 355 |
break; |
356 |
case KUsbRequest_GetInterface: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
357 |
if (ProcessGetInterface(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
358 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
359 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP33, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
360 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
361 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
362 |
} |
0 | 363 |
break; |
364 |
case KUsbRequest_SetInterface: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
365 |
if (ProcessSetInterface(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
366 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
367 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP34, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
368 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
369 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
370 |
} |
0 | 371 |
break; |
372 |
case KUsbRequest_SynchFrame: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
373 |
if (ProcessSynchFrame(packet) != KErrNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
374 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
375 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP35, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
376 |
"ProcessEp0SetupReceived: Stalling Ep0" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
377 |
StallEndpoint(KEp0_In); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
378 |
} |
0 | 379 |
break; |
380 |
default: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
381 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP36, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
382 |
" Error: Unknown/unsupported Std Setup Request" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
383 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP37, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
384 |
" -> Stalling Ep0" ); |
0 | 385 |
StallEndpoint(KEp0_In); |
386 |
break; |
|
387 |
} |
|
388 |
} |
|
389 |
else |
|
390 |
{ |
|
391 |
// Type mask != KUsbRequestType_TypeStd => class- or vendor-specific request |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
392 |
iEp0ReceivedNonStdRequest = ETrue; |
0 | 393 |
const DBase* client = NULL; |
394 |
switch (packet.iRequestType & KUsbRequestType_DestMask) |
|
395 |
{ // Recipient |
|
396 |
case KUsbRequestType_DestDevice: |
|
397 |
client = iEp0DeviceControl; |
|
398 |
break; |
|
399 |
case KUsbRequestType_DestIfc: |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
400 |
//Add this mutex to protect the interface set data structure |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
401 |
if (NKern::CurrentContext() == EThread) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
402 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
403 |
NKern::FMWait(&iMutex); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
404 |
} |
0 | 405 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateConfigured) |
406 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
407 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP38, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
408 |
" Error: Invalid device state" ); |
0 | 409 |
} |
410 |
else |
|
411 |
{ |
|
412 |
const TUsbcInterfaceSet* const ifcset_ptr = |
|
413 |
InterfaceNumber2InterfacePointer(packet.iIndex); |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
414 |
//In some rare case, ifcset_ptr is not NULL but the ifcset_ptr->iInterfaces.Count() is 0, |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
415 |
//so panic will happen when excute the following line. so I add the conditon |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
416 |
//0 != ifcset_ptr->iInterfaces.Count() here. |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
417 |
if (ifcset_ptr && 0 != ifcset_ptr->iInterfaces.Count()) |
0 | 418 |
{ |
419 |
if (ifcset_ptr->CurrentInterface()->iNoEp0Requests) |
|
420 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
421 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP39, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
422 |
" Recipient says: NoEp0RequestsPlease" ); |
0 | 423 |
} |
424 |
else |
|
425 |
{ |
|
426 |
client = ifcset_ptr->iClientId; |
|
427 |
} |
|
428 |
} |
|
429 |
else |
|
430 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
431 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP40, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
432 |
" Error: Interface 0x%02x does not exist", packet.iIndex ); |
0 | 433 |
} |
434 |
} |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
435 |
if (NKern::CurrentContext() == EThread) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
436 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
437 |
NKern::FMSignal(&iMutex); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
438 |
} |
0 | 439 |
break; |
440 |
case KUsbRequestType_DestEp: |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
441 |
//Add this mutex to protect the interface set data structure |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
442 |
if (NKern::CurrentContext() == EThread) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
443 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
444 |
NKern::FMWait(&iMutex); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
445 |
} |
0 | 446 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateConfigured) |
447 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
448 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP41, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
449 |
" Error: Invalid device state" ); |
0 | 450 |
} |
451 |
else if (EndpointExists(packet.iIndex) == EFalse) |
|
452 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
453 |
OstTraceDef1(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP42, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
454 |
" Error: Endpoint 0x%02x does not exist", packet.iIndex ); |
0 | 455 |
} |
456 |
else |
|
457 |
{ |
|
458 |
const TInt idx = EpAddr2Idx(packet.iIndex); |
|
459 |
const TUsbcInterfaceSet* const ifcset_ptr = |
|
460 |
iRealEndpoints[idx].iLEndpoint->iInterface->iInterfaceSet; |
|
461 |
if (ifcset_ptr->CurrentInterface()->iNoEp0Requests) |
|
462 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
463 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP43, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
464 |
" Recipient says: NoEp0RequestsPlease" ); |
0 | 465 |
} |
466 |
else |
|
467 |
{ |
|
468 |
client = ifcset_ptr->iClientId; |
|
469 |
} |
|
470 |
} |
|
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
471 |
if (NKern::CurrentContext() == EThread) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
472 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
473 |
NKern::FMSignal(&iMutex); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
474 |
} |
0 | 475 |
break; |
476 |
default: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
477 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP44, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
478 |
" Error: Other or Unknown recipient" ); |
0 | 479 |
break; |
480 |
} |
|
481 |
if (client != NULL) |
|
482 |
{ |
|
483 |
// Try to relay packet to the appropriate recipient |
|
484 |
TSglQueIter<TUsbcRequestCallback> iter(iEp0ReadRequestCallbacks); |
|
485 |
TUsbcRequestCallback* p; |
|
486 |
while ((p = iter++) != NULL) |
|
487 |
{ |
|
488 |
if (p->Owner() == client) |
|
489 |
{ |
|
490 |
__ASSERT_DEBUG((p->iEndpointNum == 0), Kern::Fault(KUsbPILPanicCat, __LINE__)); |
|
491 |
__ASSERT_DEBUG((p->iTransferDir == EControllerRead), Kern::Fault(KUsbPILPanicCat, __LINE__)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
492 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP45, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
493 |
" Found Ep0 read request" ); |
0 | 494 |
if (packet.iLength != 0) |
495 |
{ |
|
496 |
if ((packet.iRequestType & KUsbRequestType_DirMask) == KUsbRequestType_DirToDev) |
|
497 |
{ |
|
498 |
// Data transfer & direction OUT => there'll be a DATA_OUT stage |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
499 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP46, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
500 |
" Next is DATA_OUT: setting up DataOutVars" ); |
0 | 501 |
SetEp0DataOutVars(packet, client); |
502 |
} |
|
503 |
else if ((packet.iRequestType & KUsbRequestType_DirMask) == KUsbRequestType_DirToHost) |
|
504 |
{ |
|
505 |
// For possible later use (ZLP). |
|
506 |
iEp0_TxNonStdCount = packet.iLength; |
|
507 |
} |
|
508 |
} |
|
509 |
memcpy(p->iBufferStart, iEp0_RxBuf, aCount); |
|
510 |
p->iError = KErrNone; // if it wasn't 'KErrNone' we wouldn't be here |
|
511 |
*(p->iPacketSize) = aCount; |
|
512 |
p->iRxPackets = 1; |
|
513 |
*(p->iPacketIndex) = 0; |
|
514 |
ProcessDataTransferDone(*p); |
|
515 |
return KErrNone; |
|
516 |
} |
|
517 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
518 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP47, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
519 |
" Ep0 read request not found: setting RxExtra vars (Setup)" ); |
0 | 520 |
iEp0_RxExtraCount = aCount; |
521 |
iEp0_RxExtraData = ETrue; |
|
522 |
return KErrNotFound; |
|
523 |
} |
|
524 |
else // if (client == NULL) |
|
525 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
526 |
OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0SETUPRECEIVED_DUP48, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
527 |
" Ep0 request error: Stalling Ep0" ); |
0 | 528 |
StallEndpoint(KEp0_In); |
529 |
return KErrGeneral; |
|
530 |
} |
|
531 |
} |
|
532 |
return KErrNone; |
|
533 |
} |
|
534 |
||
535 |
TInt DUsbClientController::ProcessEp0DataReceived(TInt aCount) |
|
536 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
537 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSEP0DATARECEIVED, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
538 |
"DUsbClientController::ProcessEp0DataReceived()" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
539 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0DATARECEIVED_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
540 |
" : %d bytes", aCount ); |
0 | 541 |
if (aCount > iEp0MaxPacketSize) |
542 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
543 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0DATARECEIVED_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
544 |
" Error: Too much data" ); |
0 | 545 |
aCount = iEp0MaxPacketSize; |
546 |
} |
|
547 |
iEp0DataReceived += aCount; |
|
548 |
if (iEp0ClientId == NULL) |
|
549 |
{ |
|
550 |
// it is us (not an app), who owns this transaction |
|
551 |
switch (iSetup.iRequest) |
|
552 |
{ |
|
553 |
#ifdef USB_SUPPORTS_SET_DESCRIPTOR_REQUEST |
|
554 |
case KUsbRequest_SetDescriptor: |
|
555 |
memcpy(iEp0_RxCollectionBuf + iEp0DataReceived, iEp0_RxBuf, aCount); |
|
556 |
ProceedSetDescriptor(); |
|
557 |
break; |
|
558 |
#endif |
|
559 |
default: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
560 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0DATARECEIVED_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
561 |
" Error: invalid request in iSetup" ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
562 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSEP0DATARECEIVED_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
563 |
" -> DUsbClientController::ProcessEp0DataReceived: Stalling Ep0" ); |
0 | 564 |
StallEndpoint(KEp0_In); |
565 |
ResetEp0DataOutVars(); |
|
566 |
break; |
|
567 |
} |
|
568 |
} |
|
569 |
else |
|
570 |
{ |
|
571 |
// pass the data on to a client |
|
572 |
TSglQueIter<TUsbcRequestCallback> iter(iEp0ReadRequestCallbacks); |
|
573 |
TUsbcRequestCallback* p; |
|
574 |
while ((p = iter++) != NULL) |
|
575 |
{ |
|
576 |
if (p->Owner() == iEp0ClientId) |
|
577 |
{ |
|
578 |
__ASSERT_DEBUG((p->iEndpointNum == 0), Kern::Fault(KUsbPILPanicCat, __LINE__)); |
|
579 |
__ASSERT_DEBUG((p->iTransferDir == EControllerRead), Kern::Fault(KUsbPILPanicCat, __LINE__)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
580 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0DATARECEIVED_DUP5, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
581 |
" Found Ep0 read request" ); |
0 | 582 |
memcpy(p->iBufferStart, iEp0_RxBuf, aCount); |
583 |
p->iError = KErrNone; // if it wasn't 'KErrNone' we wouldn't be here |
|
584 |
*(p->iPacketSize) = aCount; |
|
585 |
p->iRxPackets = 1; |
|
586 |
*(p->iPacketIndex) = 0; |
|
587 |
ProcessDataTransferDone(*p); |
|
588 |
goto found; |
|
589 |
} |
|
590 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
591 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSEP0DATARECEIVED_DUP6, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
592 |
" Ep0 read request not found: setting RxExtra vars (Data)" ); |
0 | 593 |
iEp0_RxExtraCount = aCount; |
594 |
iEp0_RxExtraData = ETrue; |
|
595 |
iEp0DataReceived -= aCount; |
|
596 |
return KErrNotFound; |
|
597 |
} |
|
598 |
found: |
|
599 |
if (iEp0DataReceived >= iSetup.iLength) |
|
600 |
{ |
|
601 |
// all data seems now to be here |
|
602 |
ResetEp0DataOutVars(); |
|
603 |
} |
|
604 |
return KErrNone; |
|
605 |
} |
|
606 |
||
607 |
||
608 |
// --- The USB Spec Chapter 9 Standard Endpoint Zero Device Requests --- |
|
609 |
||
610 |
TInt DUsbClientController::ProcessGetDeviceStatus(const TUsbcSetup& aPacket) |
|
611 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
612 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSGETDEVICESTATUS, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
613 |
"DUsbClientController::ProcessGetDeviceStatus()" ); |
0 | 614 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateAddress) |
615 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
616 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETDEVICESTATUS_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
617 |
" Error: Invalid device state" ); |
0 | 618 |
return KErrGeneral; |
619 |
} |
|
620 |
const TUint16 status = ((DeviceSelfPowered() ? KUsbDevStat_SelfPowered : 0) | |
|
621 |
(iRmWakeupStatus_Enabled ? KUsbDevStat_RemoteWakeup : 0)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
622 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETDEVICESTATUS_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
623 |
" Reporting device status: 0x%02x", status ); |
0 | 624 |
*reinterpret_cast<TUint16*>(iEp0_TxBuf) = SWAP_BYTES_16(status); |
625 |
if (SetupEndpointZeroWrite(iEp0_TxBuf, sizeof(status)) == KErrNone) |
|
626 |
{ |
|
627 |
iEp0WritePending = ETrue; |
|
628 |
} |
|
629 |
return KErrNone; |
|
630 |
} |
|
631 |
||
632 |
||
633 |
TInt DUsbClientController::ProcessGetInterfaceStatus(const TUsbcSetup& aPacket) |
|
634 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
635 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACESTATUS, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
636 |
"DUsbClientController::ProcessGetInterfaceStatus()" ); |
0 | 637 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateConfigured) |
638 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
639 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACESTATUS_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
640 |
" Error: Invalid device state" ); |
0 | 641 |
return KErrGeneral; |
642 |
} |
|
643 |
if (InterfaceExists(aPacket.iIndex) == EFalse) |
|
644 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
645 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACESTATUS_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
646 |
" Error: Interface does not exist" ); |
0 | 647 |
return KErrGeneral; |
648 |
} |
|
649 |
const TUint16 status = 0x0000; // as of USB Spec 2.0 |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
650 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACESTATUS_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
651 |
" Reporting interface status: 0x%02x", status ); |
0 | 652 |
*reinterpret_cast<TUint16*>(iEp0_TxBuf) = SWAP_BYTES_16(status); |
653 |
if (SetupEndpointZeroWrite(iEp0_TxBuf, sizeof(status)) == KErrNone) |
|
654 |
{ |
|
655 |
iEp0WritePending = ETrue; |
|
656 |
} |
|
657 |
return KErrNone; |
|
658 |
} |
|
659 |
||
660 |
||
661 |
TInt DUsbClientController::ProcessGetEndpointStatus(const TUsbcSetup& aPacket) |
|
662 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
663 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSGETENDPOINTSTATUS, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
664 |
"DUsbClientController::ProcessGetEndpointStatus()" ); |
0 | 665 |
if (iTrackDeviceState && |
666 |
((iDeviceState < EUsbcDeviceStateAddress) || |
|
667 |
(iDeviceState == EUsbcDeviceStateAddress && (aPacket.iIndex & KUsbEpAddress_Portmask) != 0))) |
|
668 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
669 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETENDPOINTSTATUS_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
670 |
" Error: Invalid device state" ); |
0 | 671 |
return KErrGeneral; |
672 |
} |
|
673 |
if (EndpointExists(aPacket.iIndex) == EFalse) |
|
674 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
675 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETENDPOINTSTATUS_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
676 |
" Error: Endpoint does not exist" ); |
0 | 677 |
return KErrGeneral; |
678 |
} |
|
679 |
const TInt ep = EpAddr2Idx(aPacket.iIndex); |
|
680 |
const TUint16 status = (iRealEndpoints[ep].iHalt) ? KUsbEpStat_Halt : 0; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
681 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETENDPOINTSTATUS_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
682 |
" Reporting endpoint status 0x%02x for real endpoint %d", status, ep ); |
0 | 683 |
*reinterpret_cast<TUint16*>(iEp0_TxBuf) = SWAP_BYTES_16(status); |
684 |
if (SetupEndpointZeroWrite(iEp0_TxBuf, 2) == KErrNone) |
|
685 |
{ |
|
686 |
iEp0WritePending = ETrue; |
|
687 |
} |
|
688 |
return KErrNone; |
|
689 |
} |
|
690 |
||
691 |
||
692 |
TInt DUsbClientController::ProcessSetClearDevFeature(const TUsbcSetup& aPacket) |
|
693 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
694 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
695 |
"DUsbClientController::ProcessSetClearDevFeature()" ); |
0 | 696 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateDefault) |
697 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
698 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
699 |
" Error: Invalid device state" ); |
0 | 700 |
return KErrGeneral; |
701 |
} |
|
702 |
||
703 |
TUint test_sel = 0; |
|
704 |
||
705 |
if (aPacket.iRequest == KUsbRequest_SetFeature) |
|
706 |
{ |
|
707 |
switch (aPacket.iValue) |
|
708 |
{ |
|
709 |
case KUsbFeature_RemoteWakeup: |
|
710 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateAddress) |
|
711 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
712 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
713 |
" Error: Invalid device state" ); |
0 | 714 |
return KErrGeneral; |
715 |
} |
|
716 |
iRmWakeupStatus_Enabled = ETrue; |
|
717 |
break; |
|
718 |
case KUsbFeature_TestMode: |
|
719 |
if (!iHighSpeed) |
|
720 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
721 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
722 |
" Error: Request only supported in High-Speed mode" ); |
0 | 723 |
return KErrGeneral; |
724 |
} |
|
725 |
if (LowByte(aPacket.iIndex) != 0) |
|
726 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
727 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
728 |
" Error: Lower byte of wIndex must be zero" ); |
0 | 729 |
return KErrGeneral; |
730 |
} |
|
731 |
test_sel = HighByte(aPacket.iIndex); |
|
732 |
if ((test_sel < KUsbTestSelector_Test_J) || (test_sel > KUsbTestSelector_Test_Force_Enable)) |
|
733 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
734 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP5, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
735 |
" Error: Invalid test selector: %d", test_sel ); |
0 | 736 |
return KErrGeneral; |
737 |
} |
|
738 |
break; |
|
739 |
case KUsbFeature_B_HnpEnable: |
|
740 |
if (!iOtgSupport) |
|
741 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
742 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP6, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
743 |
" Error: Request only supported on a OTG device" ); |
0 | 744 |
return KErrGeneral; |
745 |
} |
|
746 |
if (!(iOtgFuncMap & KUsbOtgAttr_HnpSupp)) |
|
747 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
748 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP7, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
749 |
" Error: Request only valid if OTG device supports HNP" ); |
0 | 750 |
return KErrGeneral; |
751 |
} |
|
752 |
iOtgFuncMap |= KUsbOtgAttr_B_HnpEnable; |
|
753 |
OtgFeaturesNotify(); |
|
754 |
break; |
|
755 |
case KUsbFeature_A_HnpSupport: |
|
756 |
if (!iOtgSupport) |
|
757 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
758 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP8, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
759 |
" Error: Request only supported on a OTG device" ); |
0 | 760 |
return KErrGeneral; |
761 |
} |
|
762 |
if (!(iOtgFuncMap & KUsbOtgAttr_HnpSupp)) |
|
763 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
764 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP9, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
765 |
" Error: Request only valid if OTG device supports HNP" ); |
0 | 766 |
return KErrGeneral; |
767 |
} |
|
768 |
iOtgFuncMap |= KUsbOtgAttr_A_HnpSupport; |
|
769 |
OtgFeaturesNotify(); |
|
770 |
break; |
|
771 |
case KUsbFeature_A_AltHnpSupport: |
|
772 |
if (!iOtgSupport) |
|
773 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
774 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP10, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
775 |
" Error: Request only supported on a OTG device" ); |
0 | 776 |
return KErrGeneral; |
777 |
} |
|
778 |
if (!(iOtgFuncMap & KUsbOtgAttr_HnpSupp)) |
|
779 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
780 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP11, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
781 |
" Error: Request only valid if OTG device supports HNP" ); |
0 | 782 |
return KErrGeneral; |
783 |
} |
|
784 |
iOtgFuncMap |= KUsbOtgAttr_A_AltHnpSupport; |
|
785 |
OtgFeaturesNotify(); |
|
786 |
break; |
|
787 |
default: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
788 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP12, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
789 |
" Error: Unknown feature requested" ); |
0 | 790 |
return KErrGeneral; |
791 |
} |
|
792 |
} |
|
793 |
else // KUsbRequest_ClearFeature |
|
794 |
{ |
|
795 |
switch (aPacket.iValue) |
|
796 |
{ |
|
797 |
case KUsbFeature_RemoteWakeup: |
|
798 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateAddress) |
|
799 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
800 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP13, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
801 |
" Error: Invalid device state" ); |
0 | 802 |
return KErrGeneral; |
803 |
} |
|
804 |
iRmWakeupStatus_Enabled = EFalse; |
|
805 |
break; |
|
806 |
default: |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
807 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP14, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
808 |
" Error: Unknown feature requested" ); |
0 | 809 |
return KErrGeneral; |
810 |
} |
|
811 |
} |
|
812 |
||
813 |
SendEp0ZeroByteStatusPacket(); // success: zero bytes data during status stage |
|
814 |
||
815 |
// 9.4.9: "The transition to test mode of an upstream facing port must not happen until |
|
816 |
// after the status stage of the request." |
|
817 |
if (test_sel) |
|
818 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
819 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARDEVFEATURE_DUP15, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
820 |
" Entering HS Test Mode %d", test_sel ); |
0 | 821 |
EnterTestMode(test_sel); |
822 |
} |
|
823 |
||
824 |
return KErrNone; |
|
825 |
} |
|
826 |
||
827 |
||
828 |
TInt DUsbClientController::ProcessSetClearIfcFeature(const TUsbcSetup& aPacket) |
|
829 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
830 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSSETCLEARIFCFEATURE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
831 |
"DUsbClientController::ProcessSetClearIfcFeature()" ); |
0 | 832 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateConfigured) |
833 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
834 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEARIFCFEATURE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
835 |
" Error: Invalid device state" ); |
0 | 836 |
return KErrGeneral; |
837 |
} |
|
838 |
// No interface features defined in USB spec, thus |
|
839 |
return KErrGeneral; |
|
840 |
} |
|
841 |
||
842 |
||
843 |
TInt DUsbClientController::ProcessSetClearEpFeature(const TUsbcSetup& aPacket) |
|
844 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
845 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSSETCLEAREPFEATURE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
846 |
"DUsbClientController::ProcessSetClearEpFeature()" ); |
0 | 847 |
if (iTrackDeviceState && |
848 |
((iDeviceState < EUsbcDeviceStateAddress) || |
|
849 |
(iDeviceState == EUsbcDeviceStateAddress && (aPacket.iIndex & KUsbEpAddress_Portmask) != 0))) |
|
850 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
851 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEAREPFEATURE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
852 |
" Error: Invalid device state" ); |
0 | 853 |
return KErrGeneral; |
854 |
} |
|
855 |
if (aPacket.iValue != KUsbFeature_EndpointHalt) |
|
856 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
857 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEAREPFEATURE_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
858 |
" Error: Unknown feature requested" ); |
0 | 859 |
return KErrGeneral; |
860 |
} |
|
861 |
if (EndpointExists(aPacket.iIndex) == EFalse) |
|
862 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
863 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEAREPFEATURE_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
864 |
" Error: Endpoint does not exist" ); |
0 | 865 |
return KErrGeneral; |
866 |
} |
|
867 |
const TInt ep = EpAddr2Idx(aPacket.iIndex); |
|
868 |
if (iRealEndpoints[ep].iLEndpoint->iInfo.iType == KUsbEpTypeControl || |
|
869 |
iRealEndpoints[ep].iLEndpoint->iInfo.iType == KUsbEpTypeIsochronous) |
|
870 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
871 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCLEAREPFEATURE_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
872 |
" Error: Endpoint is Control or Isochronous" ); |
0 | 873 |
return KErrGeneral; |
874 |
} |
|
875 |
SetClearHaltFeature(ep, aPacket.iRequest); |
|
876 |
SendEp0ZeroByteStatusPacket(); // success: zero bytes data during status stage |
|
877 |
return KErrNone; |
|
878 |
} |
|
879 |
||
880 |
||
881 |
TInt DUsbClientController::ProcessSetAddress(const TUsbcSetup& aPacket) |
|
882 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
883 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSSETADDRESS, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
884 |
"DUsbClientController::ProcessSetAddress()" ); |
0 | 885 |
if (iTrackDeviceState && iDeviceState > EUsbcDeviceStateAddress) |
886 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
887 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETADDRESS_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
888 |
" Error: Invalid device state" ); |
0 | 889 |
return KErrGeneral; |
890 |
} |
|
891 |
const TUint16 addr = aPacket.iValue; |
|
892 |
if (addr > 127) |
|
893 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
894 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETADDRESS_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
895 |
" Error: Bad address value: %d (>127)", addr ); |
0 | 896 |
return KErrGeneral; |
897 |
} |
|
898 |
if (addr == 0) |
|
899 |
{ |
|
900 |
// Enter Default state (from Default or Address) |
|
901 |
NextDeviceState(EUsbcDeviceStateDefault); |
|
902 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
903 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSSETADDRESS_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
904 |
" USB address: %d", addr ); |
0 | 905 |
// The spec says, under section 9.4.6: |
906 |
// "Stages after the initial Setup packet assume the same device address as the Setup packet. The USB |
|
907 |
// device does not change its device address until after the Status stage of this request is completed |
|
908 |
// successfully. Note that this is a difference between this request and all other requests. For all other |
|
909 |
// requests, the operation indicated must be completed before the Status stage." |
|
910 |
// Therefore, here we first send the status packet and only then actually execute the request. |
|
911 |
SendEp0ZeroByteStatusPacket(); |
|
912 |
SetDeviceAddress(addr); |
|
913 |
return KErrNone; |
|
914 |
} |
|
915 |
||
916 |
||
917 |
TInt DUsbClientController::ProcessGetDescriptor(const TUsbcSetup& aPacket) |
|
918 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
919 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSGETDESCRIPTOR, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
920 |
"DUsbClientController::ProcessGetDescriptor()" ); |
0 | 921 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateDefault) |
922 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
923 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETDESCRIPTOR_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
924 |
" Error: Invalid device state" ); |
0 | 925 |
return KErrGeneral; |
926 |
} |
|
927 |
||
928 |
// Make sure we assume the correct speed |
|
929 |
__ASSERT_DEBUG((iHighSpeed == CurrentlyUsingHighSpeed()), Kern::Fault(KUsbPILPanicCat, __LINE__)); |
|
930 |
||
931 |
TInt size = 0; |
|
932 |
const TInt result = iDescriptors.FindDescriptor(HighByte(aPacket.iValue), // Type |
|
933 |
LowByte(aPacket.iValue), // Index |
|
934 |
aPacket.iIndex, // Language ID |
|
935 |
size); |
|
936 |
||
937 |
if ((result != KErrNone) || (size == 0)) |
|
938 |
{ |
|
939 |
// This doesn't have to be an error - protocol-wise it's OK. |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
940 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETDESCRIPTOR_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
941 |
" Couldn't retrieve descriptor" ); |
0 | 942 |
return KErrGeneral; |
943 |
} |
|
944 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
945 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETDESCRIPTOR_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
946 |
" Descriptor found, size: %d (requested: %d)", size, aPacket.iLength ); |
0 | 947 |
if (size > KUsbcBufSz_Ep0Tx) |
948 |
{ |
|
949 |
// This should actually not be possible (i.e. we should never get here). |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
950 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETDESCRIPTOR_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
951 |
" Error: Ep0_Tx buffer too small" ); |
0 | 952 |
} |
953 |
if (size > aPacket.iLength) |
|
954 |
{ |
|
955 |
// Send only as much data as requested by the host |
|
956 |
size = aPacket.iLength; |
|
957 |
} |
|
958 |
||
959 |
#ifdef ENABLE_EXCESSIVE_DEBUG_OUTPUT |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
960 |
OstTraceDefExt1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETDESCRIPTOR_DUP5, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
961 |
" Data: %{uint8[]}", TOstArray<TUint8>(iEp0_TxBuf, 8) ); |
0 | 962 |
#endif |
963 |
// If we're about to send less bytes than expected by the host AND our number is a |
|
964 |
// multiple of the packet size, in order to indicate the end of the control transfer, |
|
965 |
// we must finally send a zero length data packet (ZLP): |
|
966 |
const TBool zlp = ((size < aPacket.iLength) && (size % iEp0MaxPacketSize == 0)); |
|
967 |
if (SetupEndpointZeroWrite(iEp0_TxBuf, size, zlp) == KErrNone) |
|
968 |
{ |
|
969 |
iEp0WritePending = ETrue; |
|
970 |
} |
|
971 |
||
972 |
return KErrNone; |
|
973 |
} |
|
974 |
||
975 |
||
976 |
TInt DUsbClientController::ProcessSetDescriptor(const TUsbcSetup& aPacket) |
|
977 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
978 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSSETDESCRIPTOR, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
979 |
"DUsbClientController::ProcessSetDescriptor()" ); |
0 | 980 |
#ifndef USB_SUPPORTS_SET_DESCRIPTOR_REQUEST |
981 |
return KErrGeneral; |
|
982 |
#else |
|
983 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateAddress) |
|
984 |
{ |
|
985 |
// Error: Invalid device state! |
|
986 |
return KErrGeneral; |
|
987 |
} |
|
988 |
if (aPacket.iLength > KUsbcBufSz_Ep0Rx) |
|
989 |
{ |
|
990 |
// Error: Our Rx buffer is too small! (Raise a defect to make it larger) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
991 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETDESCRIPTOR_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
992 |
" Error: Ep0_Rx buffer too small" ); |
0 | 993 |
return KErrGeneral; |
994 |
} |
|
995 |
SetEp0DataOutVars(aPacket); |
|
996 |
SetupEndpointZeroRead(); |
|
997 |
return KErrNone; |
|
998 |
#endif |
|
999 |
} |
|
1000 |
||
1001 |
||
1002 |
TInt DUsbClientController::ProcessGetConfiguration(const TUsbcSetup& aPacket) |
|
1003 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1004 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSGETCONFIGURATION, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1005 |
"DUsbClientController::ProcessGetConfiguration()" ); |
0 | 1006 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateAddress) |
1007 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1008 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETCONFIGURATION_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1009 |
" Error: Invalid device state" ); |
0 | 1010 |
return KErrGeneral; |
1011 |
} |
|
1012 |
if (iTrackDeviceState && iDeviceState == EUsbcDeviceStateAddress && iCurrentConfig != 0) |
|
1013 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1014 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETCONFIGURATION_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1015 |
" Error: DeviceState Address && Config != 0" ); |
0 | 1016 |
return KErrGeneral; |
1017 |
} |
|
1018 |
if (iTrackDeviceState && iDeviceState == EUsbcDeviceStateConfigured && iCurrentConfig == 0) |
|
1019 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1020 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETCONFIGURATION_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1021 |
" Error: DeviceState Configured && Config == 0" ); |
0 | 1022 |
return KErrGeneral; |
1023 |
} |
|
1024 |
if (aPacket.iLength != 1) // "unspecified behavior" |
|
1025 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1026 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETCONFIGURATION_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1027 |
" Warning: wLength != 1 (= %d)", aPacket.iLength ); |
0 | 1028 |
} |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1029 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETCONFIGURATION_DUP5, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1030 |
" Reporting configuration value %d", iCurrentConfig ); |
0 | 1031 |
if (SetupEndpointZeroWrite(&iCurrentConfig, sizeof(iCurrentConfig)) == KErrNone) |
1032 |
{ |
|
1033 |
iEp0WritePending = ETrue; |
|
1034 |
} |
|
1035 |
return KErrNone; |
|
1036 |
} |
|
1037 |
||
1038 |
||
1039 |
/** Changes the device's configuration value, including interface setup and/or |
|
1040 |
teardown and state change notification of higher-layer clients. |
|
1041 |
May also be called by the PSL in special cases - therefore publishedPartner. |
|
1042 |
||
1043 |
@param aPacket The received Ep0 SET_CONFIGURATION setup request packet. |
|
1044 |
@return KErrGeneral in case of a protocol error, KErrNone otherwise. |
|
1045 |
||
1046 |
@publishedPartner @released |
|
1047 |
*/ |
|
1048 |
TInt DUsbClientController::ProcessSetConfiguration(const TUsbcSetup& aPacket) |
|
1049 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1050 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSSETCONFIGURATION, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1051 |
"DUsbClientController::ProcessSetConfiguration()" ); |
0 | 1052 |
// This function may be called by the PSL from within an ISR -- so we have |
1053 |
// to take care what we do here (and also in all functions that get called |
|
1054 |
// from here). |
|
1055 |
||
1056 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateAddress) |
|
1057 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1058 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCONFIGURATION_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1059 |
" Error: Invalid device state" ); |
0 | 1060 |
return KErrGeneral; |
1061 |
} |
|
1062 |
const TUint16 value = aPacket.iValue; |
|
1063 |
if (value > 1) // we support only one configuration |
|
1064 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1065 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETCONFIGURATION_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1066 |
" Error: Configuration value too large: %d", value ); |
0 | 1067 |
return KErrGeneral; |
1068 |
} |
|
1069 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1070 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSSETCONFIGURATION_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1071 |
" Configuration value: %d", value ); |
0 | 1072 |
ChangeConfiguration(value); |
1073 |
||
1074 |
// In 9.4.5 under GET_STATUS we read, that after SET_CONFIGURATION the HALT feature |
|
1075 |
// for all endpoints is reset to zero. |
|
1076 |
TInt num = 0; |
|
1077 |
(TAny) DoForEveryEndpointInUse(&DUsbClientController::ClearHaltFeature, num); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1078 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSSETCONFIGURATION_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1079 |
" Called ClearHaltFeature() for %d endpoints", num ); |
0 | 1080 |
SendEp0ZeroByteStatusPacket(); // success: zero bytes data during status stage |
1081 |
return KErrNone; |
|
1082 |
} |
|
1083 |
||
1084 |
||
1085 |
TInt DUsbClientController::ProcessGetInterface(const TUsbcSetup& aPacket) |
|
1086 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1087 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1088 |
"DUsbClientController::ProcessGetInterface()" ); |
0 | 1089 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateConfigured) |
1090 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1091 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1092 |
" Error: Invalid device state" ); |
0 | 1093 |
return KErrGeneral; |
1094 |
} |
|
1095 |
if (iCurrentConfig == 0) |
|
1096 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1097 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACE_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1098 |
" Error: Device not configured" ); |
0 | 1099 |
return KErrGeneral; |
1100 |
} |
|
1101 |
const TInt number = aPacket.iIndex; |
|
1102 |
if (!InterfaceExists(number)) |
|
1103 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1104 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACE_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1105 |
" Error: Bad interface index: %d", number ); |
0 | 1106 |
return KErrGeneral; |
1107 |
} |
|
1108 |
// Send alternate setting code of iCurrentInterface of Interface(set) <number> of the current |
|
1109 |
// config (iCurrentConfig). |
|
1110 |
const TUint8 setting = InterfaceNumber2InterfacePointer(number)->iCurrentInterface; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1111 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSGETINTERFACE_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1112 |
" Reporting interface setting %d", setting ); |
0 | 1113 |
if (SetupEndpointZeroWrite(&setting, 1) == KErrNone) |
1114 |
{ |
|
1115 |
iEp0WritePending = ETrue; |
|
1116 |
} |
|
1117 |
return KErrNone; |
|
1118 |
} |
|
1119 |
||
1120 |
||
1121 |
TInt DUsbClientController::ProcessSetInterface(const TUsbcSetup& aPacket) |
|
1122 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1123 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSSETINTERFACE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1124 |
"DUsbClientController::ProcessSetInterface()" ); |
0 | 1125 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateConfigured) |
1126 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1127 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETINTERFACE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1128 |
" Error: Invalid device state" ); |
0 | 1129 |
return KErrGeneral; |
1130 |
} |
|
1131 |
if (iCurrentConfig == 0) |
|
1132 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1133 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETINTERFACE_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1134 |
" Error: Device not configured" ); |
0 | 1135 |
return KErrGeneral; |
1136 |
} |
|
1137 |
const TInt number = aPacket.iIndex; |
|
1138 |
if (!InterfaceExists(number)) |
|
1139 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1140 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETINTERFACE_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1141 |
" Error: Bad interface index: %d", number ); |
0 | 1142 |
return KErrGeneral; |
1143 |
} |
|
1144 |
const TInt setting = aPacket.iValue; |
|
1145 |
TUsbcInterfaceSet* const ifcset_ptr = InterfaceNumber2InterfacePointer(number); |
|
1146 |
RPointerArray<TUsbcInterface>& ifcs = ifcset_ptr->iInterfaces; |
|
1147 |
if (setting >= ifcs.Count()) |
|
1148 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1149 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSETINTERFACE_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1150 |
" Error: Alt Setting >= bNumAltSettings: %d", setting ); |
0 | 1151 |
return KErrGeneral; |
1152 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1153 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_PROCESSSETINTERFACE_DUP5, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1154 |
" Interface setting:: %d", setting ); |
0 | 1155 |
// Set iCurrentInterface of Interface(set) <number> of the current config |
1156 |
// (iCurrentConfig) to alternate setting <setting>. |
|
1157 |
ChangeInterface(ifcs[setting]); |
|
1158 |
// In 9.4.5 under GET_STATUS we read, that after SET_INTERFACE the HALT feature |
|
1159 |
// for all endpoints (of the now current interface setting) is reset to zero. |
|
1160 |
RPointerArray<TUsbcLogicalEndpoint>& eps = ifcset_ptr->CurrentInterface()->iEndpoints; |
|
1161 |
const TInt num_eps = eps.Count(); |
|
1162 |
for (TInt i = 0; i < num_eps; i++) |
|
1163 |
{ |
|
1164 |
const TInt ep_num = EpAddr2Idx(eps[i]->iPEndpoint->iEndpointAddr); |
|
1165 |
(TAny) ClearHaltFeature(ep_num); |
|
1166 |
} |
|
1167 |
SendEp0ZeroByteStatusPacket(); // success: zero bytes data during status stage |
|
1168 |
return KErrNone; |
|
1169 |
} |
|
1170 |
||
1171 |
||
1172 |
TInt DUsbClientController::ProcessSynchFrame(const TUsbcSetup& aPacket) |
|
1173 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1174 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCESSSYNCHFRAME, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1175 |
"DUsbClientController::ProcessSynchFrame()" ); |
0 | 1176 |
if (iTrackDeviceState && iDeviceState < EUsbcDeviceStateConfigured) |
1177 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1178 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSYNCHFRAME_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1179 |
" Error: Invalid device state" ); |
0 | 1180 |
return KErrGeneral; |
1181 |
} |
|
1182 |
const TInt ep = aPacket.iIndex; |
|
1183 |
if (EndpointExists(ep) == EFalse) |
|
1184 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1185 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSYNCHFRAME_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1186 |
" Error: Endpoint does not exist" ); |
0 | 1187 |
return KErrGeneral; |
1188 |
} |
|
1189 |
if (iRealEndpoints[EpAddr2Idx(ep)].iLEndpoint->iInfo.iType != KUsbEpTypeIsochronous) |
|
1190 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1191 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_PROCESSSYNCHFRAME_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1192 |
" Error: Endpoint is not isochronous" ); |
0 | 1193 |
return KErrGeneral; |
1194 |
} |
|
1195 |
// We always send 0: |
|
1196 |
*reinterpret_cast<TUint16*>(iEp0_TxBuf) = 0x00; |
|
1197 |
if (SetupEndpointZeroWrite(iEp0_TxBuf, 2) == KErrNone) |
|
1198 |
{ |
|
1199 |
iEp0WritePending = ETrue; |
|
1200 |
} |
|
1201 |
return KErrNone; |
|
1202 |
} |
|
1203 |
||
1204 |
||
1205 |
#ifdef USB_SUPPORTS_SET_DESCRIPTOR_REQUEST |
|
1206 |
void DUsbClientController::ProceedSetDescriptor() |
|
1207 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1208 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_PROCEEDSETDESCRIPTOR, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1209 |
"DUsbClientController::ProceedSetDescriptor()" ); |
0 | 1210 |
// iEp0DataReceived already reflects the current buffer state |
1211 |
if (iEp0DataReceived < iSetup.iLength) |
|
1212 |
{ |
|
1213 |
// Not yet all data received => proceed |
|
1214 |
return; |
|
1215 |
} |
|
1216 |
if (iEp0DataReceived > iSetup.iLength) |
|
1217 |
{ |
|
1218 |
// Error: more data received than expected |
|
1219 |
// but we don't care... |
|
1220 |
} |
|
1221 |
// at this point: iEp0DataReceived == iSetup.iLength |
|
1222 |
const TUint8 type = HighByte(iSetup.iValue); |
|
1223 |
if (type == KUsbDescType_String) |
|
1224 |
{ |
|
1225 |
// set/add new string descriptor |
|
1226 |
} |
|
1227 |
else |
|
1228 |
{ |
|
1229 |
// set/add new ordinary descriptor |
|
1230 |
} |
|
1231 |
TUint8 index = LowByte(iSetup.iValue); |
|
1232 |
TUint16 langid = iSetup.iIndex; |
|
1233 |
TUint16 length_total = iSetup.iLength; |
|
1234 |
} |
|
1235 |
#endif |
|
1236 |
||
1237 |
||
1238 |
// --- Secondary (Helper) Functions |
|
1239 |
||
1240 |
void DUsbClientController::SetClearHaltFeature(TInt aRealEndpoint, TUint8 aRequest) |
|
1241 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1242 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_SETCLEARHALTFEATURE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1243 |
"DUsbClientController::SetClearHaltFeature()" ); |
0 | 1244 |
if (aRequest == KUsbRequest_SetFeature) |
1245 |
{ |
|
1246 |
if (iRealEndpoints[aRealEndpoint].iHalt) |
|
1247 |
{ |
|
1248 |
// (This condition is not really an error) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1249 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_SETCLEARHALTFEATURE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1250 |
" Warning: HALT feature already set" ); |
0 | 1251 |
return; |
1252 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1253 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_SETCLEARHALTFEATURE_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1254 |
" setting HALT feature for real endpoint %d", aRealEndpoint ); |
0 | 1255 |
StallEndpoint(aRealEndpoint); |
1256 |
iRealEndpoints[aRealEndpoint].iHalt = ETrue; |
|
1257 |
} |
|
1258 |
else // KUsbRequest_ClearFeature |
|
1259 |
{ |
|
1260 |
if (iRealEndpoints[aRealEndpoint].iHalt == EFalse) |
|
1261 |
{ |
|
1262 |
// In this case, before we return, the data toggles are reset to DATA0. |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1263 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_SETCLEARHALTFEATURE_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1264 |
" Warning: HALT feature already cleared" ); |
0 | 1265 |
ResetDataToggle(aRealEndpoint); |
1266 |
return; |
|
1267 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1268 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_SETCLEARHALTFEATURE_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1269 |
" clearing HALT feature for real endpoint %d", aRealEndpoint ); |
0 | 1270 |
ResetDataToggle(aRealEndpoint); |
1271 |
ClearStallEndpoint(aRealEndpoint); |
|
1272 |
iRealEndpoints[aRealEndpoint].iHalt = EFalse; |
|
1273 |
} |
|
1274 |
EpStatusNotify(aRealEndpoint); // only called if actually something changed |
|
1275 |
} |
|
1276 |
||
1277 |
||
1278 |
TInt DUsbClientController::ClearHaltFeature(TInt aRealEndpoint) |
|
1279 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1280 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_CLEARHALTFEATURE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1281 |
"DUsbClientController::ClearHaltFeature()" ); |
0 | 1282 |
if (iRealEndpoints[aRealEndpoint].iHalt != EFalse) |
1283 |
{ |
|
1284 |
ClearStallEndpoint(aRealEndpoint); |
|
1285 |
iRealEndpoints[aRealEndpoint].iHalt = EFalse; |
|
1286 |
} |
|
1287 |
return KErrNone; |
|
1288 |
} |
|
1289 |
||
1290 |
||
1291 |
void DUsbClientController::ChangeConfiguration(TUint16 aValue) |
|
1292 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1293 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1294 |
"DUsbClientController::ChangeConfiguration()" ); |
0 | 1295 |
// New configuration is the same as the old one: 0 |
1296 |
if (iCurrentConfig == 0 && aValue == 0) |
|
1297 |
{ |
|
1298 |
// no-op |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1299 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1300 |
" Configuration: New == Old == 0 --> exiting" ); |
0 | 1301 |
return; |
1302 |
} |
|
1303 |
// New configuration is the same as the old one (but not 0) |
|
1304 |
if (iCurrentConfig == aValue) |
|
1305 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1306 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1307 |
" Configuration: New == Old == %d --> exiting", aValue ); |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1308 |
// From the spec 9.1.1.5, Data toggle is reset to zero here when |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1309 |
// setconfiguration(x->x)(x!=0) received, although we only support |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1310 |
// single configuration currently. |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1311 |
TInt num = 0; |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1312 |
TInt ret = DoForEveryEndpointInUse(&DUsbClientController::ResetDataToggle, num); |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1313 |
if(ret != KErrNone) |
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1314 |
{ |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1315 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1316 |
" Error: Endpoint data toggle reset failed" ); |
26
c734af59ce98
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1317 |
} |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1318 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1319 |
" Called ResetDataToggle()for %d endpoints", num ); |
0 | 1320 |
return; |
1321 |
} |
|
1322 |
// Device is already configured |
|
1323 |
if (iCurrentConfig != 0) |
|
1324 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1325 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP5, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1326 |
" Device was configured: %d", iCurrentConfig ); |
0 | 1327 |
// Tear down all interface(set)s of the old configuration |
1328 |
RPointerArray<TUsbcInterfaceSet>& ifcsets = CurrentConfig()->iInterfaceSets; |
|
1329 |
for (TInt i = 0; i < ifcsets.Count(); ++i) |
|
1330 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1331 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP6, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1332 |
" Tearing down InterfaceSet %d", i ); |
0 | 1333 |
InterfaceSetTeardown(ifcsets[i]); |
1334 |
} |
|
1335 |
iCurrentConfig = 0; |
|
1336 |
// Enter Address state (from Configured) |
|
1337 |
if (iDeviceState == EUsbcDeviceStateConfigured) |
|
1338 |
NextDeviceState(EUsbcDeviceStateAddress); |
|
1339 |
} |
|
1340 |
// Device gets a new configuration |
|
1341 |
if (aValue != 0) |
|
1342 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1343 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP7, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1344 |
" Device gets new configuration..." ); |
0 | 1345 |
// Setup all alternate settings 0 of all interfaces |
1346 |
// (Don't separate the next two lines of code.) |
|
1347 |
iCurrentConfig = aValue; |
|
1348 |
RPointerArray<TUsbcInterfaceSet>& ifcsets = CurrentConfig()->iInterfaceSets; |
|
1349 |
const TInt n = ifcsets.Count(); |
|
1350 |
for (TInt i = 0; i < n; ++i) |
|
1351 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1352 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP8, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1353 |
" Setting up InterfaceSet %d", i ); |
0 | 1354 |
InterfaceSetup(ifcsets[i]->iInterfaces[0]); |
1355 |
} |
|
1356 |
// Enter Configured state (from Address or Configured) |
|
1357 |
NextDeviceState(EUsbcDeviceStateConfigured); |
|
1358 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1359 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGECONFIGURATION_DUP9, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1360 |
" New configuration: %d", iCurrentConfig ); |
0 | 1361 |
return; |
1362 |
} |
|
1363 |
||
1364 |
||
1365 |
void DUsbClientController::InterfaceSetup(TUsbcInterface* aIfc) |
|
1366 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1367 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_INTERFACESETUP, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1368 |
"DUsbClientController::InterfaceSetup()" ); |
0 | 1369 |
const TInt num_eps = aIfc->iEndpoints.Count(); |
1370 |
for (TInt i = 0; i < num_eps; i++) |
|
1371 |
{ |
|
1372 |
// Prepare this endpoint for I/O |
|
1373 |
TUsbcLogicalEndpoint* const ep = aIfc->iEndpoints[i]; |
|
1374 |
// (TUsbcLogicalEndpoint's FS/HS endpoint sizes and interval values got |
|
1375 |
// adjusted in its constructor.) |
|
1376 |
if (iHighSpeed) |
|
1377 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1378 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_INTERFACESETUP_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1379 |
" Setting Ep info size to %d (HS)", ep->iEpSize_Hs ); |
0 | 1380 |
ep->iInfo.iSize = ep->iEpSize_Hs; |
1381 |
} |
|
1382 |
else |
|
1383 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1384 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_INTERFACESETUP_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1385 |
" Setting Ep info size to %d (FS)", ep->iEpSize_Fs ); |
0 | 1386 |
ep->iInfo.iSize = ep->iEpSize_Fs; |
1387 |
} |
|
1388 |
const TInt idx = EpAddr2Idx(ep->iPEndpoint->iEndpointAddr); |
|
1389 |
if (ConfigureEndpoint(idx, ep->iInfo) != KErrNone) |
|
1390 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1391 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_INTERFACESETUP_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1392 |
" Error: Endpoint %d configuration failed", idx ); |
0 | 1393 |
continue; |
1394 |
} |
|
1395 |
// Should there be a problem with it then we could try resetting the ep |
|
1396 |
// data toggle at this point (or before the Configure) as well. |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1397 |
OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_INTERFACESETUP_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1398 |
" Connecting real ep addr 0x%02x & logical ep #%d", ep->iPEndpoint->iEndpointAddr, ep->iLEndpointNum ); |
0 | 1399 |
ep->iPEndpoint->iLEndpoint = ep; |
1400 |
} |
|
1401 |
aIfc->iInterfaceSet->iCurrentInterface = aIfc->iSettingCode; |
|
1402 |
return; |
|
1403 |
} |
|
1404 |
||
1405 |
||
1406 |
void DUsbClientController::InterfaceSetTeardown(TUsbcInterfaceSet* aIfcSet) |
|
1407 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1408 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_INTERFACESETTEARDOWN, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1409 |
"DUsbClientController::InterfaceSetTeardown()" ); |
0 | 1410 |
if (aIfcSet->iInterfaces.Count() == 0) |
1411 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1412 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_INTERFACESETTEARDOWN_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1413 |
" No interfaces exist - returning" ); |
0 | 1414 |
return; |
1415 |
} |
|
1416 |
RPointerArray<TUsbcLogicalEndpoint>& eps = aIfcSet->CurrentInterface()->iEndpoints; |
|
1417 |
const TInt num_eps = eps.Count(); |
|
1418 |
for (TInt i = 0; i < num_eps; i++) |
|
1419 |
{ |
|
1420 |
TUsbcLogicalEndpoint* const ep = eps[i]; |
|
1421 |
const TInt idx = EpAddr2Idx(ep->iPEndpoint->iEndpointAddr); |
|
1422 |
||
1423 |
CancelTransferRequests(idx); |
|
1424 |
||
1425 |
if (!ep->iPEndpoint->iLEndpoint) |
|
1426 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1427 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_INTERFACESETTEARDOWN_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1428 |
" real ep %d not configured: skipping", idx ); |
0 | 1429 |
continue; |
1430 |
} |
|
1431 |
if (ResetDataToggle(idx) != KErrNone) |
|
1432 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1433 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_INTERFACESETTEARDOWN_DUP3, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1434 |
" Error: Endpoint %d data toggle reset failed", idx ); |
0 | 1435 |
} |
1436 |
if (DeConfigureEndpoint(idx) != KErrNone) |
|
1437 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1438 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, DUSBCLIENTCONTROLLER_INTERFACESETTEARDOWN_DUP4, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1439 |
" Error: Endpoint %d de-configuration failed", idx ); |
0 | 1440 |
} |
1441 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1442 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_INTERFACESETTEARDOWN_DUP5, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1443 |
" disconnecting real ep & logical ep" ); |
0 | 1444 |
ep->iPEndpoint->iLEndpoint = NULL; |
1445 |
} |
|
1446 |
if (aIfcSet->CurrentInterface() != 0) |
|
1447 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1448 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_INTERFACESETTEARDOWN_DUP6, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1449 |
" Resetting alternate interface setting to 0" ); |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1450 |
//Add this mutex to protect the interface set data structure |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1451 |
if (NKern::CurrentContext() == EThread) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1452 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1453 |
NKern::FMWait(&iMutex); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1454 |
} |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1455 |
|
0 | 1456 |
aIfcSet->iCurrentInterface = 0; |
22
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1457 |
if (NKern::CurrentContext() == EThread) |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1458 |
{ |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1459 |
NKern::FMSignal(&iMutex); |
2f92ad2dc5db
Revision: 201013
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1460 |
} |
0 | 1461 |
} |
1462 |
return; |
|
1463 |
} |
|
1464 |
||
1465 |
||
1466 |
void DUsbClientController::ChangeInterface(TUsbcInterface* aIfc) |
|
1467 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1468 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_CHANGEINTERFACE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1469 |
"DUsbClientController::ChangeInterface()" ); |
0 | 1470 |
TUsbcInterfaceSet* ifcset = aIfc->iInterfaceSet; |
1471 |
const TUint8 setting = aIfc->iSettingCode; |
|
1472 |
if (ifcset->iCurrentInterface == setting) |
|
1473 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1474 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGEINTERFACE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1475 |
" New Ifc == old Ifc: nothing to do" ); |
0 | 1476 |
return; |
1477 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1478 |
OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_CHANGEINTERFACE_DUP2, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1479 |
" Setting new interface setting #%d", setting ); |
0 | 1480 |
InterfaceSetTeardown(ifcset); |
1481 |
InterfaceSetup(aIfc); |
|
1482 |
StatusNotify(static_cast<TUsbcDeviceState>(KUsbAlternateSetting | setting), ifcset->iClientId); |
|
1483 |
} |
|
1484 |
||
1485 |
||
1486 |
// aFunction gets called, successively, with the endpoint index of every ep in-use as its argument. |
|
1487 |
// (BTW: The declaration "type (class::*name)(params)" makes <name> a "pointer to element function".) |
|
1488 |
// |
|
1489 |
TInt DUsbClientController::DoForEveryEndpointInUse(TInt (DUsbClientController::*aFunction)(TInt), TInt& aCount) |
|
1490 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1491 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, DUSBCLIENTCONTROLLER_DOFOREVERYENDPOINTINUSE, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1492 |
"DUsbClientController::DoForEveryEndpointInUse()" ); |
0 | 1493 |
aCount = 0; |
1494 |
TUsbcConfiguration* const config = CurrentConfig(); |
|
1495 |
if (!config) |
|
1496 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1497 |
OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, DUSBCLIENTCONTROLLER_DOFOREVERYENDPOINTINUSE_DUP1, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
1498 |
" Device is not configured - returning" ); |
0 | 1499 |
return KErrNone; |
1500 |
} |
|
1501 |
RPointerArray<TUsbcInterfaceSet>& ifcsets = config->iInterfaceSets; |
|
1502 |
const TInt num_ifcsets = ifcsets.Count(); |
|
1503 |
for (TInt i = 0; i < num_ifcsets; i++) |
|
1504 |
{ |
|
1505 |
RPointerArray<TUsbcLogicalEndpoint>& eps = ifcsets[i]->CurrentInterface()->iEndpoints; |
|
1506 |
const TInt num_eps = eps.Count(); |
|
1507 |
for (TInt j = 0; j < num_eps; j++) |
|
1508 |
{ |
|
1509 |
const TInt ep_num = EpAddr2Idx(eps[j]->iPEndpoint->iEndpointAddr); |
|
1510 |
const TInt result = (this->*aFunction)(ep_num); |
|
1511 |
++aCount; |
|
1512 |
if (result != KErrNone) |
|
1513 |
{ |
|
1514 |
return result; |
|
1515 |
} |
|
1516 |
} |
|
1517 |
} |
|
1518 |
return KErrNone; |
|
1519 |
} |
|
1520 |
||
1521 |
||
1522 |
// -eof- |