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 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2007-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 |
// @internalComponent |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32std.h> |
|
19 |
#include <e32std_private.h> |
|
20 |
#include <u32std.h> // unicode builds |
|
21 |
#include <e32base.h> |
|
22 |
#include <e32base_private.h> |
|
23 |
#include <e32cons.h> |
|
24 |
#include <e32Test.h> // RTest header |
|
25 |
#include <e32def.h> |
|
26 |
#include <e32def_private.h> |
|
27 |
#include <d32otgdi.h> // OTGDI header |
|
28 |
#include <d32usbc.h> // USBCC header |
|
29 |
#include "otgroot.h" |
|
30 |
#include "testcaseroot.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
#include "otgrootTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
#endif |
0 | 35 |
|
36 |
RUsbOtgDriver oUsbOtgDriver; |
|
37 |
RDevUsbcClient oUsbcClient; |
|
38 |
||
39 |
||
40 |
//===================================================================================== |
|
41 |
||
42 |
/* this class wraps all OTGDI calls as well to simplify |
|
43 |
calling and normalising object access. - it has no base-class hence we can use multiple-inheritance |
|
44 |
*/ |
|
45 |
COtgRoot::COtgRoot() |
|
46 |
{ |
|
47 |
iOptActive = EFalse; |
|
48 |
SetLoaded(EFalse); |
|
49 |
} |
|
50 |
||
51 |
||
52 |
/** otgLoadLdd |
|
53 |
*/ |
|
54 |
TInt COtgRoot::otgLoadLdd() |
|
55 |
{ |
|
56 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
OstTraceFunctionEntry0(COTGROOT_OTGLOADLDD); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
} |
0 | 61 |
LOG_VERBOSE2(_L("Load driver: %S\n"), &KOTGDeviceInterfaceDriverName); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
OstTraceExt1(TRACE_VERBOSE, COTGROOT_OTGLOADLDD_DUP01, "Load driver: %S\n", KOTGDeviceInterfaceDriverName); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
65 |
} |
0 | 66 |
|
67 |
if (!LddLoaded()) |
|
68 |
{ |
|
69 |
||
70 |
// load ldd device drivers (load otg only, it will load the needed stuff for us) |
|
71 |
TInt err(User::LoadLogicalDevice(KOTGDeviceInterfaceDriverName)); |
|
72 |
if ( (err != KErrNone) && (err != KErrAlreadyExists) ) |
|
73 |
{ |
|
74 |
test.Printf(_L("<Error %d> Unable to load driver: %S\n"), err, &KOTGDeviceInterfaceDriverName); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
OstTraceExt2(TRACE_NORMAL, COTGROOT_OTGLOADLDD_DUP02, "<Error %d> Unable to load driver: %S\n", err, KOTGDeviceInterfaceDriverName); |
0 | 76 |
SetLoaded(EFalse); |
77 |
return(err); |
|
78 |
} |
|
79 |
else |
|
80 |
{ |
|
81 |
LOG_VERBOSE2(_L("Loaded driver: '%S' OK\n"), &KOTGDeviceInterfaceDriverName); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
OstTraceExt1(TRACE_VERBOSE, COTGROOT_OTGLOADLDD_DUP03, "Loaded driver: '%S' OK\n", KOTGDeviceInterfaceDriverName); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
} |
0 | 86 |
SetLoaded(ETrue); |
87 |
} |
|
88 |
||
89 |
} |
|
90 |
return(KErrNone); |
|
91 |
} |
|
92 |
||
93 |
||
94 |
/** otgOpen |
|
95 |
*/ |
|
96 |
TInt COtgRoot::otgOpen() |
|
97 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
99 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
OstTraceFunctionEntry0(COTGROOT_OTGOPEN); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
101 |
} |
0 | 102 |
|
103 |
LOG_VERBOSE2(_L("Opening session... loaded = %d\n"), LddLoaded()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
OstTrace1(TRACE_VERBOSE, COTGROOT_OTGOPEN_DUP01, "Opening session... loaded = %d\n", LddLoaded()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
} |
0 | 108 |
|
109 |
TInt err(oUsbOtgDriver.Open()); |
|
110 |
if (err != KErrNone) |
|
111 |
{ |
|
112 |
test.Printf(_L("<Error %d> Unable to open a channel to USB OTG driver\n"),err); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
OstTrace1(TRACE_NORMAL, COTGROOT_OTGOPEN_DUP02, "<Error %d> Unable to open a channel to USB OTG driver\n",err); |
0 | 114 |
return(err); |
115 |
} |
|
116 |
else |
|
117 |
{ |
|
118 |
LOG_VERBOSE1(_L("Open channel OK\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
OstTrace0(TRACE_VERBOSE, COTGROOT_OTGOPEN_DUP03, "Open channel OK\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
} |
0 | 123 |
} |
124 |
||
125 |
return(KErrNone); |
|
126 |
} |
|
127 |
||
128 |
||
129 |
/** otgClose |
|
130 |
*/ |
|
131 |
void COtgRoot::otgClose() |
|
132 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
134 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
OstTraceFunctionEntry0(COTGROOT_OTGCLOSE); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
} |
0 | 137 |
|
138 |
test.Printf(_L("Closing session... loaded = %d\n"), LddLoaded()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
OstTrace1(TRACE_NORMAL, COTGROOT_OTGCLOSE_DUP01, "Closing session... loaded = %d\n", LddLoaded()); |
0 | 140 |
oUsbOtgDriver.Close(); |
141 |
} |
|
142 |
||
143 |
||
144 |
/* otgActivateOptTestMode |
|
145 |
*/ |
|
146 |
TInt COtgRoot::otgActivateOptTestMode() |
|
147 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
OstTraceFunctionEntry0(COTGROOT_OTGACTIVATEOPTTESTMODE); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
} |
0 | 152 |
|
153 |
TInt err = oUsbOtgDriver.ActivateOptTestMode(); |
|
154 |
||
155 |
return(err); |
|
156 |
} |
|
157 |
||
158 |
||
159 |
/** otgStartStacks |
|
160 |
*/ |
|
161 |
TInt COtgRoot::otgStartStacks() |
|
162 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
OstTraceFunctionEntry0(COTGROOT_OTGSTARTSTACKS); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
166 |
} |
0 | 167 |
|
168 |
TInt err(oUsbOtgDriver.StartStacks()); |
|
169 |
if (err != KErrNone) |
|
170 |
{ |
|
171 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
172 |
OstTrace1(TRACE_WARNING, COTGROOT_OTGSTARTSTACKS_DUP01, "[WARNING failed %d]", err); |
0 | 173 |
|
174 |
} |
|
175 |
return(err); |
|
176 |
||
177 |
} |
|
178 |
||
179 |
||
180 |
/** otgStopStacks |
|
181 |
*/ |
|
182 |
void COtgRoot::otgStopStacks() |
|
183 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
OstTraceFunctionEntry0(COTGROOT_OTGSTOPSTACKS); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
187 |
} |
0 | 188 |
|
189 |
oUsbOtgDriver.StopStacks(); |
|
190 |
} |
|
191 |
||
192 |
||
193 |
/** otgUnloadLdd |
|
194 |
*/ |
|
195 |
void COtgRoot::otgUnloadLdd() |
|
196 |
{ |
|
197 |
||
198 |
// code to unload the OTG ldd driver |
|
199 |
TInt err (User::FreeLogicalDevice(KOTGDeviceInterfaceDriverName)); |
|
200 |
if (err != KErrNone) |
|
201 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
OstTrace1(TRACE_WARNING, COTGROOT_OTGUNLOADLDD, "[WARNING failed %d]", err); |
0 | 203 |
} |
204 |
||
205 |
SetLoaded(EFalse); |
|
206 |
} |
|
207 |
||
208 |
||
209 |
/** otgQueueOtgEventRequest |
|
210 |
*/ |
|
211 |
void COtgRoot::otgQueueOtgEventRequest(RUsbOtgDriver::TOtgEvent& aEvent, TRequestStatus &aStatus) |
|
212 |
{ |
|
213 |
LOG_VERBOSE2(_L("Queue an Event Request %08X.\n"), (TInt)(&aStatus)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
OstTrace1(TRACE_VERBOSE, COTGROOT_OTGQUEUEOTGEVENTREQUEST_DUP01, "Queue an Event Request %08X.\n", (TInt)(&aStatus)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
} |
0 | 218 |
|
219 |
oUsbOtgDriver.QueueOtgEventRequest(aEvent, aStatus); |
|
220 |
||
221 |
} |
|
222 |
||
223 |
||
224 |
/** otgCancelOtgEventRequest |
|
225 |
*/ |
|
226 |
void COtgRoot::otgCancelOtgEventRequest() |
|
227 |
{ |
|
228 |
LOG_VERBOSE1(_L("Cancel Event Request.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
229 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELOTGEVENTREQUEST, "Cancel Event Request.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
} |
0 | 233 |
oUsbOtgDriver.CancelOtgEventRequest(); |
234 |
} |
|
235 |
||
236 |
||
237 |
/** otgQueueOtgMessageRequest |
|
238 |
*/ |
|
239 |
void COtgRoot::otgQueueOtgMessageRequest(RUsbOtgDriver::TOtgMessage& aMessage, TRequestStatus &aStatus) |
|
240 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
|
0 | 242 |
LOG_VERBOSE2(_L("Queue a Message Request %08X.\n"), (TInt)(&aStatus)); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
244 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
OstTrace1(TRACE_VERBOSE, COTGROOT_OTGQUEUEOTGMESSAGEREQUEST_DUP01, "Queue a Message Request %08X.\n", (TInt)(&aStatus)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
246 |
} |
0 | 247 |
|
248 |
oUsbOtgDriver.QueueOtgMessageRequest(aMessage, aStatus); |
|
249 |
||
250 |
} |
|
251 |
||
252 |
||
253 |
/** otgCancelOtgMessageRequest |
|
254 |
*/ |
|
255 |
void COtgRoot::otgCancelOtgMessageRequest() |
|
256 |
{ |
|
257 |
LOG_VERBOSE1(_L("Cancel Message Request.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
258 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
259 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
260 |
OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELOTGMESSAGEREQUEST, "Cancel Message Request.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
} |
0 | 262 |
oUsbOtgDriver.CancelOtgMessageRequest(); |
263 |
} |
|
264 |
||
265 |
void COtgRoot::otgQueuePeripheralStateRequest(TUint& aPeripheralState, TRequestStatus& aStatus) |
|
266 |
{ |
|
267 |
LOG_VERBOSE1(_L("Queue Peripheral State Request.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
270 |
OstTrace0(TRACE_VERBOSE, COTGROOT_OTGQUEUEPERIPHERALSTATEREQUEST, "Queue Peripheral State Request.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
} |
0 | 272 |
oUsbcClient.AlternateDeviceStatusNotify(aStatus, aPeripheralState); |
273 |
} |
|
274 |
||
275 |
void COtgRoot::otgCancelPeripheralStateRequest() |
|
276 |
{ |
|
277 |
LOG_VERBOSE1(_L("Cancel Peripheral State Request.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
278 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
280 |
OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELPERIPHERALSTATEREQUEST, "Cancel Peripheral State Request.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
281 |
} |
0 | 282 |
oUsbcClient.AlternateDeviceStatusNotifyCancel(); |
283 |
} |
|
284 |
||
285 |
void COtgRoot::otgQueueAConnectionIdleRequest(RUsbOtgDriver::TOtgConnection& aAConnectionIdle, TRequestStatus& aStatus) |
|
286 |
{ |
|
287 |
LOG_VERBOSE1(_L("Queue A Connection Idle Request.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
OstTrace0(TRACE_VERBOSE, COTGROOT_OTGQUEUEACONNECTIONIDLEREQUEST, "Queue A Connection Idle Request.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
} |
0 | 292 |
oUsbOtgDriver.QueueOtgConnectionNotification(aAConnectionIdle, aStatus); |
293 |
} |
|
294 |
||
295 |
void COtgRoot::otgCancelAConnectionIdleRequest() |
|
296 |
{ |
|
297 |
LOG_VERBOSE1(_L("Cancel A Connection Idle Request.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELACONNECTIONIDLEREQUEST, "Cancel A Connection Idle Request.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
} |
0 | 302 |
oUsbOtgDriver.CancelOtgConnectionNotification(); |
303 |
} |
|
304 |
||
305 |
||
306 |
/** otgQueueOtgStateRequest |
|
307 |
*/ |
|
308 |
void COtgRoot::otgQueueOtgStateRequest(RUsbOtgDriver::TOtgState& aState, TRequestStatus &aStatus) |
|
309 |
{ |
|
310 |
LOG_VERBOSE2(_L("Queue a State Request %08X.\n"), (TInt)(&aStatus)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
311 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
312 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
OstTrace1(TRACE_VERBOSE, COTGROOT_OTGQUEUEOTGSTATEREQUEST_DUP01, "Queue a State Request %08X.\n", (TInt)(&aStatus)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
314 |
} |
0 | 315 |
|
316 |
oUsbOtgDriver.QueueOtgStateRequest(aState, aStatus); |
|
317 |
||
318 |
} |
|
319 |
||
320 |
||
321 |
/** otgCancelOtgStateRequest |
|
322 |
*/ |
|
323 |
void COtgRoot::otgCancelOtgStateRequest() |
|
324 |
{ |
|
325 |
LOG_VERBOSE1(_L("Cancel State Request.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
326 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
327 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
328 |
OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELOTGSTATEREQUEST, "Cancel State Request.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
329 |
} |
0 | 330 |
oUsbOtgDriver.CancelOtgStateRequest(); |
331 |
} |
|
332 |
||
333 |
||
334 |
/** otgBusRequest |
|
335 |
raise VBus (in reality this must only happen when a 'A' is present... and when not present it starts HNP) |
|
336 |
*/ |
|
337 |
TInt COtgRoot::otgBusRequest() |
|
338 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
341 |
OstTraceFunctionEntry0(COTGROOT_OTGBUSREQUEST); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
} |
0 | 343 |
|
344 |
TInt err(0); |
|
345 |
err = oUsbOtgDriver.BusRequest(); |
|
346 |
if (err != KErrNone) |
|
347 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
OstTrace1(TRACE_WARNING, COTGROOT_OTGBUSREQUEST_DUP01, "[WARNING failed %d]", err); |
0 | 349 |
} |
350 |
return(err); |
|
351 |
} |
|
352 |
||
353 |
||
354 |
/* call when SRP has been recieved, based on our HNP Enable setting, this will allow HNP. The |
|
355 |
* A-device may choose to call BusRequest directly, which will result in a 'short-circuit' role-swap. |
|
356 |
*/ |
|
357 |
TInt COtgRoot::otgBusRespondSRP() |
|
358 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
360 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
361 |
OstTraceFunctionEntry0(COTGROOT_OTGBUSRESPONDSRP); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
362 |
} |
0 | 363 |
TInt err(0); |
364 |
err = oUsbOtgDriver.BusRespondSrp(); |
|
365 |
if (err != KErrNone) |
|
366 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
OstTrace1(TRACE_WARNING, COTGROOT_OTGBUSRESPONDSRP_DUP01, "[WARNING failed %d]", err); |
0 | 368 |
} |
369 |
return(err); |
|
370 |
} |
|
371 |
||
372 |
||
373 |
/** Drop VBus (A-host) |
|
374 |
*/ |
|
375 |
TInt COtgRoot::otgBusDrop() |
|
376 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
377 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
378 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
379 |
OstTraceFunctionEntry0(COTGROOT_OTGBUSDROP); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
380 |
} |
0 | 381 |
TInt err(0); |
382 |
err = oUsbOtgDriver.BusDrop(); |
|
383 |
if (err != KErrNone) |
|
384 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
385 |
OstTrace1(TRACE_WARNING, COTGROOT_OTGBUSDROP_DUP01, "[WARNING failed %d]", err); |
0 | 386 |
} |
387 |
return(err); |
|
388 |
} |
|
389 |
||
390 |
/** otgBusClearError |
|
391 |
*/ |
|
392 |
TInt COtgRoot::otgBusClearError() |
|
393 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
394 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
395 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
396 |
OstTraceFunctionEntry0(COTGROOT_OTGBUSCLEARERROR); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
397 |
} |
0 | 398 |
|
399 |
TInt err(0); |
|
400 |
err = oUsbOtgDriver.BusClearError(); |
|
401 |
if (err != KErrNone) |
|
402 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
403 |
OstTrace1(TRACE_WARNING, COTGROOT_OTGBUSCLEARERROR_DUP01, "[WARNING failed %d]", err); |
0 | 404 |
} |
405 |
return(err); |
|
406 |
} |
|
407 |
||
408 |
||
409 |
||
410 |
void COtgRoot::otgQueueOtgIdPinNotification(RUsbOtgDriver::TOtgIdPin& aPin, TRequestStatus& aStatus) |
|
411 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
412 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
413 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
414 |
OstTraceFunctionEntry0(COTGROOT_OTGQUEUEOTGIDPINNOTIFICATION); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
415 |
} |
0 | 416 |
oUsbOtgDriver.QueueOtgIdPinNotification(aPin, aStatus); // the kernel driver populates aPin... |
417 |
} |
|
418 |
||
419 |
||
420 |
void COtgRoot::otgCancelOtgIdPinNotification() |
|
421 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
422 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
423 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
424 |
OstTraceFunctionEntry0(COTGROOT_OTGCANCELOTGIDPINNOTIFICATION); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
425 |
} |
0 | 426 |
oUsbOtgDriver.CancelOtgIdPinNotification(); |
427 |
} |
|
428 |
||
429 |
||
430 |
void COtgRoot::otgQueueOtgVbusNotification(RUsbOtgDriver::TOtgVbus& aVbus, |
|
431 |
TRequestStatus& aStatus |
|
432 |
) |
|
433 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
434 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
435 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
436 |
OstTraceFunctionEntry0(COTGROOT_OTGQUEUEOTGVBUSNOTIFICATION); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
437 |
} |
0 | 438 |
oUsbOtgDriver.QueueOtgVbusNotification(aVbus, aStatus); |
439 |
} |
|
440 |
||
441 |
||
442 |
void COtgRoot::otgCancelOtgVbusNotification() |
|
443 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
444 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
445 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
446 |
OstTraceFunctionEntry0(COTGROOT_OTGCANCELOTGVBUSNOTIFICATION); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
} |
0 | 448 |
oUsbOtgDriver.CancelOtgVbusNotification(); |
449 |
} |
|
450 |
||
451 |
||
452 |
TBool COtgRoot::otgIdPinPresent() |
|
453 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
454 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
455 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
456 |
OstTraceFunctionEntry0(COTGROOT_OTGIDPINPRESENT); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
457 |
} |
0 | 458 |
TRequestStatus aStatus; |
459 |
RUsbOtgDriver::TOtgIdPin aPin; |
|
460 |
oUsbOtgDriver.QueueOtgIdPinNotification(aPin, aStatus); // the kernel driver populates aPin... |
|
461 |
LOG_VERBOSE2(_L("(sync) ID_PIN=%d\n"), iOTGIdPin); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
462 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
463 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
464 |
OstTrace1(TRACE_VERBOSE, COTGROOT_OTGIDPINPRESENT_DUP01, "(sync) ID_PIN=%d\n", iOTGIdPin); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
465 |
} |
0 | 466 |
|
467 |
oUsbOtgDriver.CancelOtgIdPinNotification(); |
|
468 |
// swallow the event |
|
469 |
User::WaitForRequest(aStatus); |
|
470 |
||
471 |
if (RUsbOtgDriver::EIdPinAPlug == aPin) // at this stage, the aPin value is known |
|
472 |
{ |
|
473 |
return(ETrue); |
|
474 |
} |
|
475 |
return(EFalse); |
|
476 |
} |
|
477 |
||
478 |
||
479 |
TBool COtgRoot::otgVbusPresent() |
|
480 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
481 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
482 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
OstTraceFunctionEntry0(COTGROOT_OTGVBUSPRESENT); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
484 |
} |
0 | 485 |
TRequestStatus aStatus; |
486 |
RUsbOtgDriver::TOtgVbus aVBus; |
|
487 |
oUsbOtgDriver.QueueOtgVbusNotification(aVBus, aStatus); // the kernel driver populates aPin in a kernel thread... |
|
488 |
oUsbOtgDriver.CancelOtgVbusNotification(); |
|
489 |
// swallow the event |
|
490 |
User::WaitForRequest(aStatus); |
|
491 |
||
492 |
if (RUsbOtgDriver::EVbusHigh == aVBus) // by this stage, the aVBus value is known |
|
493 |
{ |
|
494 |
return(ETrue); |
|
495 |
} |
|
496 |
return(EFalse); |
|
497 |
} |
|
498 |
||
499 |
||
500 |
TBool COtgRoot::iLoadedLdd = EFalse; |
|
501 |
TBool COtgRoot::iFdfActorActive = EFalse; |
|
502 |
RProcess COtgRoot::iFdfActorProcess; |
|
503 |
||
504 |
/** static */ |
|
505 |
TBool& COtgRoot::LddLoaded() |
|
506 |
{ |
|
507 |
return(iLoadedLdd); |
|
508 |
} |
|
509 |
||
510 |
||
511 |
/** static */ |
|
512 |
TBool COtgRoot::SetLoaded(TBool aState) |
|
513 |
{ |
|
514 |
iLoadedLdd = aState; |
|
515 |
return(LddLoaded()); |
|
516 |
} |
|
517 |
||
518 |
/** static */ |
|
519 |
void COtgRoot::OtgEventString( RUsbOtgDriver::TOtgEvent aEvent, TBuf<MAX_DSTRLEN> &aDescription) |
|
520 |
{ |
|
521 |
||
522 |
switch( aEvent ) |
|
523 |
{ |
|
524 |
case RUsbOtgDriver::EEventAPlugInserted: aDescription= _L("A Plug Inserted");break; |
|
525 |
case RUsbOtgDriver::EEventAPlugRemoved: aDescription= _L("A Plug Removed"); break; |
|
526 |
case RUsbOtgDriver::EEventVbusRaised: aDescription= _L("VBUS Raised"); break; |
|
527 |
case RUsbOtgDriver::EEventVbusDropped: aDescription= _L("VBUS Dropped"); break; |
|
528 |
case RUsbOtgDriver::EEventSrpReceived: aDescription= _L("SRP Received"); break; |
|
529 |
case RUsbOtgDriver::EEventSrpInitiated: aDescription= _L("SRP Initiated"); break; |
|
530 |
case RUsbOtgDriver::EEventHnpEnabled: aDescription= _L("HNP Enabled"); break; |
|
531 |
case RUsbOtgDriver::EEventHnpDisabled: aDescription= _L("HNP Disabled"); break; |
|
532 |
case RUsbOtgDriver::EEventRoleChangedToHost: aDescription= _L("Role->Host"); break; |
|
533 |
case RUsbOtgDriver::EEventRoleChangedToDevice: aDescription= _L("Role->Device"); break; |
|
534 |
case RUsbOtgDriver::EEventRoleChangedToIdle: aDescription= _L("Role->Idle"); break; |
|
535 |
||
536 |
case RUsbOtgDriver::EEventHnpSupported : aDescription= _L("HNP Supported"); break; |
|
537 |
case RUsbOtgDriver::EEventHnpAltSupported: aDescription= _L("Alt-HNP Supp."); break; |
|
538 |
case RUsbOtgDriver::EEventBusConnectionBusy: aDescription= _L("Connection Busy"); break; |
|
539 |
case RUsbOtgDriver::EEventBusConnectionIdle: aDescription= _L("Connection Idle"); break; |
|
540 |
default: aDescription= _L("Unknown"); break; |
|
541 |
} |
|
542 |
} |
|
543 |
||
544 |
/** static */ |
|
545 |
void COtgRoot::OtgStateString( RUsbOtgDriver::TOtgState aState, TBuf<MAX_DSTRLEN> &aDescription) |
|
546 |
{ |
|
547 |
||
548 |
switch( aState ) |
|
549 |
{ |
|
550 |
case RUsbOtgDriver::EStateReset: aDescription= _L("Reset"); break; |
|
551 |
case RUsbOtgDriver::EStateAIdle: aDescription= _L("A-Idle"); break; |
|
552 |
case RUsbOtgDriver::EStateAHost: aDescription= _L("A-Host"); break; |
|
553 |
case RUsbOtgDriver::EStateAPeripheral: aDescription= _L("A-Peripheral"); break; |
|
554 |
case RUsbOtgDriver::EStateAVbusError: aDescription= _L("A-VBus Error"); break; |
|
555 |
case RUsbOtgDriver::EStateBIdle: aDescription= _L("B-Idle"); break; |
|
556 |
case RUsbOtgDriver::EStateBPeripheral: aDescription= _L("B-Peripheral"); break; |
|
557 |
case RUsbOtgDriver::EStateBHost: aDescription= _L("B-Host"); break; |
|
558 |
default: aDescription= _L("Unknown"); break; |
|
559 |
} |
|
560 |
} |
|
561 |
||
562 |
/** static */ |
|
563 |
void COtgRoot::OtgMessageString( RUsbOtgDriver::TOtgMessage aMessage, TBuf<MAX_DSTRLEN> &aDescription) |
|
564 |
{ |
|
565 |
||
566 |
switch( aMessage ) |
|
567 |
{ |
|
568 |
case RUsbOtgDriver::EEventQueueOverflow: aDescription = _L("Event Queue Overflow"); break; |
|
569 |
case RUsbOtgDriver::EStateQueueOverflow: aDescription = _L("State Queue Overflow"); break; |
|
570 |
case RUsbOtgDriver::EMessageQueueOverflow: aDescription = _L("Message Queue Overflow"); break; |
|
571 |
case RUsbOtgDriver::EMessageBadState: aDescription = _L("Bad State"); break; |
|
572 |
case RUsbOtgDriver::EMessageStackNotStarted: aDescription = _L("Stack Not Started"); break; |
|
573 |
case RUsbOtgDriver::EMessageVbusAlreadyRaised: aDescription = _L("Vbus Already Raised"); break; |
|
574 |
case RUsbOtgDriver::EMessageSrpForbidden: aDescription = _L("SRP Forbidden"); break; |
|
575 |
case RUsbOtgDriver::EMessageBusControlProblem: aDescription = _L("Bus Control Problem"); break; |
|
576 |
case RUsbOtgDriver::EMessageVbusError: aDescription = _L("Vbus Error"); break; |
|
577 |
case RUsbOtgDriver::EMessageSrpTimeout: aDescription = _L("SRP Timeout"); break; |
|
578 |
case RUsbOtgDriver::EMessageSrpActive: aDescription = _L("SRP In Use"); break; |
|
579 |
// PREQ 1305 messages |
|
580 |
case RUsbOtgDriver::EMessageSrpNotPermitted: aDescription = _L("Srp Not Permitted"); break; |
|
581 |
case RUsbOtgDriver::EMessageHnpNotPermitted: aDescription = _L("Hnp Not Permitted"); break; |
|
582 |
case RUsbOtgDriver::EMessageHnpNotEnabled: aDescription = _L("Hnp Not Enabled"); break; |
|
583 |
case RUsbOtgDriver::EMessageHnpNotSuspended: aDescription = _L("HNP not possible, not suspended"); break; |
|
584 |
case RUsbOtgDriver::EMessageVbusPowerUpNotPermitted: aDescription = _L("Vbus PowerUp Not Permitted"); break; |
|
585 |
case RUsbOtgDriver::EMessageVbusPowerUpError: aDescription = _L("Vbus PowerUp Error"); break; |
|
586 |
case RUsbOtgDriver::EMessageVbusPowerDownNotPermitted: aDescription = _L("Vbus PowerDown Not Permitted"); break; |
|
587 |
case RUsbOtgDriver::EMessageVbusClearErrorNotPermitted: aDescription = _L("Vbus ClearError Not Permitted"); break; |
|
588 |
case RUsbOtgDriver::EMessageHnpNotResponding: aDescription = _L("Not reposnding to HNP"); |
|
589 |
case RUsbOtgDriver::EMessageHnpBusDrop: aDescription = _L("VBUS drop during HNP"); |
|
590 |
default: aDescription = _L("Unknown"); break; |
|
591 |
} |
|
592 |
} |
|
593 |
||
594 |
void COtgRoot::PeripheralStateString( TUint aPeripheralState, TBuf<MAX_DSTRLEN> &aDescription) |
|
595 |
{ |
|
596 |
if(aPeripheralState & KUsbAlternateSetting) |
|
597 |
{ |
|
598 |
aDescription = _L("Interface Alternate Setting Change"); |
|
599 |
} |
|
600 |
else |
|
601 |
{ |
|
602 |
switch( aPeripheralState ) |
|
603 |
{ |
|
604 |
case EUsbcDeviceStateUndefined: aDescription = _L("Undefined"); break; |
|
605 |
case EUsbcDeviceStateAttached: aDescription = _L("Attached"); break; |
|
606 |
case EUsbcDeviceStatePowered: aDescription = _L("Powered"); break; |
|
607 |
case EUsbcDeviceStateDefault: aDescription = _L("Default"); break; |
|
608 |
case EUsbcDeviceStateAddress: aDescription = _L("Addressed"); break; |
|
609 |
case EUsbcDeviceStateConfigured: aDescription = _L("Configured"); break; |
|
610 |
case EUsbcDeviceStateSuspended: aDescription = _L("Suspended"); break; |
|
611 |
case EUsbcNoState: aDescription = _L("NoState!"); break; |
|
612 |
default: aDescription = _L("Unknown"); break; |
|
613 |
} |
|
614 |
} |
|
615 |
} |
|
616 |
||
617 |
void COtgRoot::AConnectionIdleString(RUsbOtgDriver::TOtgConnection aAConnectionIdle, TBuf<MAX_DSTRLEN> &aDescription) |
|
618 |
{ |
|
619 |
switch( aAConnectionIdle ) |
|
620 |
{ |
|
621 |
case RUsbOtgDriver::EConnectionBusy: aDescription = _L("Busy"); break; |
|
622 |
case RUsbOtgDriver::EConnectionIdle: aDescription = _L("Idle"); break; |
|
623 |
case RUsbOtgDriver::EConnectionUnknown: aDescription = _L("Unknown"); break; |
|
624 |
default: aDescription = _L("Not recognised");break; |
|
625 |
} |
|
626 |
} |
|
627 |
||
628 |
TInt COtgRoot::otgActivateFdfActor() |
|
629 |
{ |
|
630 |
if(iFdfActorActive) |
|
631 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
632 |
OstTrace0(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR, "FdfActor already exists!"); |
0 | 633 |
return KErrAlreadyExists; |
634 |
} |
|
635 |
||
636 |
const TUid KFdfSvrUid={0x10282B48}; |
|
637 |
const TUidType fdfActorUid(KNullUid, KNullUid, KFdfSvrUid); |
|
638 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
639 |
OstTrace0(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP01, "About to activate FDF Actor"); |
0 | 640 |
|
641 |
// RProcess fdfActorProcess; |
|
642 |
TInt err = iFdfActorProcess.Create(_L("t_otgdi_fdfactor.exe"), KNullDesC, fdfActorUid); |
|
643 |
||
644 |
if (err != KErrNone) |
|
645 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
646 |
OstTrace1(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP02, "Failed to create FDF Actor, err=%d",err); |
0 | 647 |
iFdfActorProcess.Close(); |
648 |
return err; |
|
649 |
} |
|
650 |
||
651 |
TRequestStatus stat; |
|
652 |
iFdfActorProcess.Rendezvous(stat); |
|
653 |
||
654 |
if (stat!=KRequestPending) |
|
655 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
656 |
OstTrace1(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP03, "Failed to commence rendezvous, err=%d",stat.Int()); |
0 | 657 |
iFdfActorProcess.Kill(0); // abort startup |
658 |
iFdfActorProcess.Close(); |
|
659 |
return stat.Int(); |
|
660 |
} |
|
661 |
else |
|
662 |
{ |
|
663 |
iFdfActorProcess.Resume(); // logon OK - start the server |
|
664 |
} |
|
665 |
||
666 |
User::WaitForRequest(stat); // wait for start or death |
|
667 |
if(stat.Int()!=KErrNone) |
|
668 |
{ |
|
669 |
// Wasn't KErrNone, which means that the FDFActor didn't successfully |
|
670 |
// start up. We shouldn't proceed with the test we're in. |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
671 |
OstTrace1(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP04, "Failed to activate FDF Actor, err=%d",stat.Int()); |
0 | 672 |
iFdfActorProcess.Close(); |
673 |
return stat.Int(); |
|
674 |
} |
|
675 |
||
676 |
// We rendezvoused(?) with the FDFActor OK, so it is going to suspend |
|
677 |
// any devices it sees being attached, and will shut itself down |
|
678 |
// when this process signals its Rendezvous (at the end of the test)... |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
679 |
OstTrace0(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP05, "Activated FDF Actor"); |
0 | 680 |
iFdfActorActive = ETrue; |
681 |
||
682 |
return KErrNone; |
|
683 |
} |
|
684 |
||
685 |
void COtgRoot::otgDeactivateFdfActor() |
|
686 |
{ |
|
687 |
if(!iFdfActorActive) |
|
688 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
689 |
OstTrace0(TRACE_NORMAL, COTGROOT_OTGDEACTIVATEFDFACTOR, "FdfActor is not running!"); |
0 | 690 |
return; |
691 |
} |
|
692 |
||
693 |
// If iFdfActorActive is set, the FDF Actor should be waiting to |
|
694 |
// rendezvous with us before it shuts down... |
|
695 |
// First of all, logon to wait for it to close down properly |
|
696 |
TRequestStatus waitForCloseStat; |
|
697 |
iFdfActorProcess.Logon(waitForCloseStat); |
|
698 |
||
699 |
// Now, trigger the FDF Actor to close down |
|
700 |
||
701 |
RProcess::Rendezvous(KErrNone); |
|
702 |
||
703 |
// ...and wait for it to go away. |
|
704 |
User::WaitForRequest(waitForCloseStat); |
|
705 |
test.Printf(_L("T_OTGDI confirms FDF Actor has gone away %d\n"), waitForCloseStat.Int()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
706 |
OstTrace1(TRACE_NORMAL, COTGROOT_OTGDEACTIVATEFDFACTOR_DUP01, "T_OTGDI confirms FDF Actor has gone away %d\n", waitForCloseStat.Int()); |
0 | 707 |
|
708 |
// Now close our handle, and record that the process is no more... |
|
709 |
iFdfActorProcess.Close(); |
|
710 |
iFdfActorActive = EFalse; |
|
711 |
} |
|
712 |
||
713 |
/** Commonly used step to unload the USB Client Driver |
|
714 |
* @return ETrue if the ldd unloaded sucessfully |
|
715 |
*/ |
|
716 |
TBool COtgRoot::StepUnloadClient() |
|
717 |
{ |
|
718 |
test.Printf(_L("Unload USBCC Client\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
719 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPUNLOADCLIENT, "Unload USBCC Client\n"); |
0 | 720 |
|
721 |
TInt err; |
|
722 |
||
723 |
// Close the Client |
|
724 |
||
725 |
test.Printf(_L("..Close\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
726 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPUNLOADCLIENT_DUP01, "..Close\n"); |
0 | 727 |
oUsbcClient.Close(); |
728 |
||
729 |
// Unload the LDD - note the name is *not* the same as for loading |
|
730 |
||
731 |
test.Printf(_L("..Unload\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
732 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPUNLOADCLIENT_DUP02, "..Unload\n"); |
0 | 733 |
err = User::FreeLogicalDevice( KUsbDeviceName ); |
734 |
if (err != KErrNone) |
|
735 |
{ |
|
736 |
AssertionFailed2(KErrAbort, _L("Client Unload Fail "), err); |
|
737 |
return (EFalse); |
|
738 |
} |
|
739 |
||
740 |
||
741 |
return(ETrue); |
|
742 |
} |
|
743 |
||
744 |
||
745 |
/** Commonly used step to load the USB Client Driver and set up |
|
746 |
* a 'useful' default device descriptor set |
|
747 |
* @return ETrue if the ldd loaded sucessfully |
|
748 |
*/ |
|
749 |
TBool COtgRoot::StepLoadClient(TUint16 aPID, |
|
750 |
TBool aEnableHNP/*=ETrue*/, |
|
751 |
TBool aEnableSRP/*=ETrue*/) |
|
752 |
{ |
|
753 |
test.Printf(_L("Load USBCC Client 0x%04x\n"),aPID); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
754 |
OstTrace1(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT, "Load USBCC Client 0x%04x\n",aPID); |
0 | 755 |
|
756 |
TInt err; |
|
757 |
||
758 |
// The incoming PID is expected to have a form of 0x0TTT or 0xFTTT |
|
759 |
// where 'TTT' is the test number: if the lead is 0xF000 we now |
|
760 |
// overlay an 'A' or a 'B' depending on the default role |
|
761 |
||
762 |
if ( ( ( aPID & 0xF000 ) != 0xF000 ) |
|
763 |
&& ( ( aPID & 0xF000 ) != 0x0000 ) |
|
764 |
) |
|
765 |
{ |
|
766 |
AssertionFailed(KErrAbort, _L("Bad default PID")); |
|
767 |
} |
|
768 |
||
769 |
if ( aPID & 0xF000 ) |
|
770 |
{ |
|
771 |
aPID &= 0x0FFF; |
|
772 |
||
773 |
if ( gTestRoleMaster ) |
|
774 |
{ |
|
775 |
// this is the 'B' device |
|
776 |
aPID |= 0xB000; |
|
777 |
} |
|
778 |
else |
|
779 |
{ |
|
780 |
// this is the 'A' device |
|
781 |
aPID |= 0xA000; |
|
782 |
} |
|
783 |
} |
|
784 |
||
785 |
// Load the LDD - note the name is *not* the same as for unload |
|
786 |
||
787 |
test.Printf(_L("..Load LDD\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
788 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP01, "..Load LDD\n"); |
0 | 789 |
err = User::LoadLogicalDevice( KUsbcLddFileName ); |
790 |
if ((err != KErrNone) && (err !=KErrAlreadyExists)) |
|
791 |
{ |
|
792 |
AssertionFailed2(KErrAbort, _L("Client Load Fail "), err); |
|
793 |
return (EFalse); |
|
794 |
} |
|
795 |
||
796 |
// Open the Client |
|
797 |
||
798 |
test.Printf(_L("..Open LDD\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
799 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP02, "..Open LDD\n"); |
0 | 800 |
err = oUsbcClient.Open(0); |
801 |
if (err != KErrNone) |
|
802 |
{ |
|
803 |
AssertionFailed2(KErrAbort, _L("Client Open Fail "), err); |
|
804 |
return (EFalse); |
|
805 |
} |
|
806 |
||
807 |
// Set up descriptors |
|
808 |
||
809 |
test.Printf(_L("..Setup Descriptors\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
810 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP03, "..Setup Descriptors\n"); |
0 | 811 |
|
812 |
// the OTG descriptor |
|
813 |
TBuf8<KUsbDescSize_Otg> theOtgDescriptor; |
|
814 |
err = oUsbcClient.GetOtgDescriptor(theOtgDescriptor); |
|
815 |
if (err != KErrNone) |
|
816 |
{ |
|
817 |
AssertionFailed2(KErrAbort, _L("OTG GetDes Fail "), err); |
|
818 |
return (EFalse); |
|
819 |
} |
|
820 |
// modify OTG descriptor based on parameters passed |
|
821 |
if (aEnableHNP) |
|
822 |
aEnableSRP=ETrue; // Keep the device Legal according to OTG spec 6.4.2 |
|
823 |
/*Attribute Fields |
|
824 |
D7…2: Reserved (reset to zero) |
|
825 |
D1: HNP support |
|
826 |
D0: SRP support*/ |
|
827 |
TUint8 aByte = theOtgDescriptor[2]; |
|
828 |
aByte &= (~0x03); |
|
829 |
aByte |= (aEnableSRP? 1 : 0); |
|
830 |
aByte |= (aEnableHNP? 2 : 0); |
|
831 |
test.Printf(_L("..Change OTG 0x%02X->0x%02X\n"), theOtgDescriptor[2], aByte); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
832 |
OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP04, "..Change OTG 0x%02X->0x%02X\n", (TUint32)theOtgDescriptor[2], (TUint32)aByte); |
0 | 833 |
theOtgDescriptor[2] = aByte; |
834 |
||
835 |
err = oUsbcClient.SetOtgDescriptor(theOtgDescriptor); |
|
836 |
if (err != KErrNone) |
|
837 |
{ |
|
838 |
AssertionFailed2(KErrAbort, _L("OTG SetDes Fail "), err); |
|
839 |
return (EFalse); |
|
840 |
} |
|
841 |
||
842 |
// |
|
843 |
||
844 |
TUsbDeviceCaps d_caps; |
|
845 |
err = oUsbcClient.DeviceCaps(d_caps); |
|
846 |
TBool softwareConnect; |
|
847 |
||
848 |
if (err != KErrNone) |
|
849 |
{ |
|
850 |
AssertionFailed2(KErrAbort, _L("Client DevCaps Fail "), err); |
|
851 |
return (EFalse); |
|
852 |
} |
|
853 |
||
854 |
const TInt n = d_caps().iTotalEndpoints; |
|
855 |
||
856 |
softwareConnect = d_caps().iConnect; |
|
857 |
test.Printf(_L("..SoftwareConnect = %d\n"),softwareConnect); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
858 |
OstTrace1(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP05, "..SoftwareConnect = %d\n",softwareConnect); |
0 | 859 |
|
860 |
if (n < 2) |
|
861 |
{ |
|
862 |
AssertionFailed2(KErrAbort, _L("Client Endpoints Fail "), err); |
|
863 |
return (EFalse); |
|
864 |
} |
|
865 |
||
866 |
// Endpoints |
|
867 |
TUsbcEndpointData data[KUsbcMaxEndpoints]; |
|
868 |
TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
|
869 |
err = oUsbcClient.EndpointCaps(dataptr); |
|
870 |
if (err != KErrNone) |
|
871 |
{ |
|
872 |
AssertionFailed2(KErrAbort, _L("Client EpCaps Fail "), err); |
|
873 |
return (EFalse); |
|
874 |
} |
|
875 |
||
876 |
// Set up the active interface |
|
877 |
TUsbcInterfaceInfoBuf ifc; |
|
878 |
TInt ep_found = 0; |
|
879 |
TBool foundBulkIN = EFalse; |
|
880 |
TBool foundBulkOUT = EFalse; |
|
881 |
for (TInt i = 0; i < n; i++) |
|
882 |
{ |
|
883 |
const TUsbcEndpointCaps* const caps = &data[i].iCaps; |
|
884 |
const TInt mps = caps->MaxPacketSize(); |
|
885 |
if (!foundBulkIN && |
|
886 |
(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) == |
|
887 |
(KUsbEpTypeBulk | KUsbEpDirIn)) |
|
888 |
{ |
|
889 |
if (!(mps == 64 || mps == 512)) |
|
890 |
{ |
|
891 |
} |
|
892 |
// EEndpoint1 is going to be our Tx (IN) endpoint |
|
893 |
ifc().iEndpointData[0].iType = KUsbEpTypeBulk; |
|
894 |
ifc().iEndpointData[0].iDir = KUsbEpDirIn; |
|
895 |
ifc().iEndpointData[0].iSize = mps; |
|
896 |
foundBulkIN = ETrue; |
|
897 |
if (++ep_found == 2) |
|
898 |
break; |
|
899 |
} |
|
900 |
else if (!foundBulkOUT && |
|
901 |
(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) == |
|
902 |
(KUsbEpTypeBulk | KUsbEpDirOut)) |
|
903 |
{ |
|
904 |
if (!(mps == 64 || mps == 512)) |
|
905 |
{ |
|
906 |
} |
|
907 |
// EEndpoint2 is going to be our Rx (OUT) endpoint |
|
908 |
ifc().iEndpointData[1].iType = KUsbEpTypeBulk; |
|
909 |
ifc().iEndpointData[1].iDir = KUsbEpDirOut; |
|
910 |
ifc().iEndpointData[1].iSize = mps; |
|
911 |
foundBulkOUT = ETrue; |
|
912 |
if (++ep_found == 2) |
|
913 |
break; |
|
914 |
} |
|
915 |
} |
|
916 |
if (ep_found != 2) |
|
917 |
{ |
|
918 |
AssertionFailed2(KErrAbort, _L("Client EpFound Fail "), err); |
|
919 |
return (EFalse); |
|
920 |
} |
|
921 |
||
922 |
_LIT16(ifcname, "T_OTGDI Test Interface (Default Setting 0)"); |
|
923 |
ifc().iString = const_cast<TDesC16*>(&ifcname); |
|
924 |
ifc().iTotalEndpointsUsed = 2; |
|
925 |
ifc().iClass.iClassNum = 0xff; // vendor-specific |
|
926 |
ifc().iClass.iSubClassNum = 0xff; // vendor-specific |
|
927 |
ifc().iClass.iProtocolNum = 0xff; // vendor-specific |
|
928 |
||
929 |
err = oUsbcClient.SetInterface(0, ifc, (EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault)); |
|
930 |
||
931 |
if( err != KErrNone ) |
|
932 |
{ |
|
933 |
AssertionFailed2(KErrAbort, _L("Client SetInt Fail "), err); |
|
934 |
return (EFalse); |
|
935 |
} |
|
936 |
||
937 |
// Set the revised PID |
|
938 |
||
939 |
TBuf8<KUsbDescSize_Device> theDeviceDescriptor; |
|
940 |
err = oUsbcClient.GetDeviceDescriptor(theDeviceDescriptor); |
|
941 |
if (err != KErrNone) |
|
942 |
{ |
|
943 |
AssertionFailed2(KErrAbort, _L("Client GetDes Fail "), err); |
|
944 |
return (EFalse); |
|
945 |
} |
|
946 |
||
947 |
TUint16 oldPID = ( theDeviceDescriptor[10] ) |
|
948 |
+ ( theDeviceDescriptor[11] << 8 ); |
|
949 |
||
950 |
theDeviceDescriptor[10] = ( aPID & 0x00FF ); |
|
951 |
theDeviceDescriptor[11] = ( aPID & 0xFF00 ) >> 8; |
|
952 |
||
953 |
test.Printf(_L("..Change PID 0x%04X->0x%04X\n"), oldPID, aPID); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
954 |
OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP06, "..Change PID 0x%04X->0x%04X\n", (TUint32)oldPID, (TUint32)aPID); |
0 | 955 |
|
956 |
err = oUsbcClient.SetDeviceDescriptor(theDeviceDescriptor); |
|
957 |
if (err != KErrNone) |
|
958 |
{ |
|
959 |
AssertionFailed2(KErrAbort, _L("Client SetDes Fail "), err); |
|
960 |
return (EFalse); |
|
961 |
} |
|
962 |
||
963 |
||
964 |
// Power Up UDC - KErrNotReady is expected |
|
965 |
||
966 |
test.Printf(_L("..Power Up UDC\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
967 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP07, "..Power Up UDC\n"); |
0 | 968 |
|
969 |
err = oUsbcClient.PowerUpUdc(); |
|
970 |
if( err != KErrNotReady ) |
|
971 |
{ |
|
972 |
AssertionFailed2(KErrAbort, _L("PowerUp UDC Fail "), err); |
|
973 |
return (EFalse); |
|
974 |
} |
|
975 |
||
976 |
// Connect to Host |
|
977 |
||
978 |
test.Printf(_L("..Connect to Host\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
979 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP08, "..Connect to Host\n"); |
0 | 980 |
|
981 |
err = oUsbcClient.DeviceConnectToHost(); |
|
982 |
if( err != KErrNone ) |
|
983 |
{ |
|
984 |
AssertionFailed2(KErrAbort, _L("Host Connect Fail "), err); |
|
985 |
return (EFalse); |
|
986 |
} |
|
987 |
||
988 |
// Default no-problem return |
|
989 |
||
990 |
return(ETrue); |
|
991 |
} |
|
992 |
||
993 |
||
994 |
/** Commonly used steps to control D+ connect/disconnect |
|
995 |
* the device to/from the host |
|
996 |
*/ |
|
997 |
TBool COtgRoot::StepDisconnect() |
|
998 |
{ |
|
999 |
test.Printf(_L("Disconnect from Host\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1000 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPDISCONNECT, "Disconnect from Host\n"); |
0 | 1001 |
|
1002 |
TInt err; |
|
1003 |
||
1004 |
err = oUsbcClient.DeviceDisconnectFromHost(); |
|
1005 |
if( err != KErrNone ) |
|
1006 |
{ |
|
1007 |
AssertionFailed2(KErrAbort, _L("Host Disconnect Fail "), err); |
|
1008 |
return (EFalse); |
|
1009 |
} |
|
1010 |
||
1011 |
// Default no-problem return |
|
1012 |
||
1013 |
return(ETrue); |
|
1014 |
} |
|
1015 |
||
1016 |
TBool COtgRoot::StepConnect() |
|
1017 |
{ |
|
1018 |
test.Printf(_L("Connect to Host\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1019 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPCONNECT, "Connect to Host\n"); |
0 | 1020 |
|
1021 |
TInt err; |
|
1022 |
||
1023 |
err = oUsbcClient.DeviceConnectToHost(); |
|
1024 |
if( err != KErrNone ) |
|
1025 |
{ |
|
1026 |
AssertionFailed2(KErrAbort, _L("Host Connect Fail "), err); |
|
1027 |
return (EFalse); |
|
1028 |
} |
|
1029 |
||
1030 |
// Default no-problem return |
|
1031 |
||
1032 |
return(ETrue); |
|
1033 |
} |
|
1034 |
||
1035 |
||
1036 |
/** Commonly used step to load the USB Client Driver and set up |
|
1037 |
* a High-Speed electrical test VID/PID pair |
|
1038 |
* @return ETrue if the ldd loaded sucessfully |
|
1039 |
*/ |
|
1040 |
TBool COtgRoot::StepChangeVidPid(TUint16 aVID, TUint16 aPID) |
|
1041 |
||
1042 |
{ |
|
1043 |
test.Printf(_L("Load USBCC HS Test Client 0x%04x/0x%04x\n"),aVID,aPID); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1044 |
OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPCHANGEVIDPID, "Load USBCC HS Test Client 0x%04x/0x%04x\n",(TUint32)aVID,(TUint32)aPID); |
0 | 1045 |
|
1046 |
TInt err; |
|
1047 |
||
1048 |
// Set the revised VID/PID pair |
|
1049 |
||
1050 |
TBuf8<KUsbDescSize_Device> theDeviceDescriptor; |
|
1051 |
err = oUsbcClient.GetDeviceDescriptor(theDeviceDescriptor); |
|
1052 |
if (err != KErrNone) |
|
1053 |
{ |
|
1054 |
AssertionFailed2(KErrAbort, _L("Client GetDes Fail "), err); |
|
1055 |
return (EFalse); |
|
1056 |
} |
|
1057 |
||
1058 |
TUint16 oldVID = ( theDeviceDescriptor[8] ) |
|
1059 |
+ ( theDeviceDescriptor[9] << 8 ); |
|
1060 |
||
1061 |
theDeviceDescriptor[8] = ( aVID & 0x00FF ); |
|
1062 |
theDeviceDescriptor[9] = ( aVID & 0xFF00 ) >> 8; |
|
1063 |
||
1064 |
test.Printf(_L("..Change VID 0x%04X->0x%04X\n"), oldVID, aVID); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1065 |
OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPCHANGEVIDPID_DUP01, "..Change VID 0x%04X->0x%04X\n", (TUint32)oldVID, (TUint32)aVID); |
0 | 1066 |
|
1067 |
TUint16 oldPID = ( theDeviceDescriptor[10] ) |
|
1068 |
+ ( theDeviceDescriptor[11] << 8 ); |
|
1069 |
||
1070 |
theDeviceDescriptor[10] = ( aPID & 0x00FF ); |
|
1071 |
theDeviceDescriptor[11] = ( aPID & 0xFF00 ) >> 8; |
|
1072 |
||
1073 |
test.Printf(_L("..Change PID 0x%04X->0x%04X\n"), oldPID, aPID); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1074 |
OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPCHANGEVIDPID_DUP02, "..Change PID 0x%04X->0x%04X\n", (TUint32)oldPID, (TUint32)aPID); |
0 | 1075 |
|
1076 |
err = oUsbcClient.SetDeviceDescriptor(theDeviceDescriptor); |
|
1077 |
if (err != KErrNone) |
|
1078 |
{ |
|
1079 |
AssertionFailed2(KErrAbort, _L("Client SetDes Fail "), err); |
|
1080 |
return (EFalse); |
|
1081 |
} |
|
1082 |
||
1083 |
// Default no-problem return |
|
1084 |
||
1085 |
return(ETrue); |
|
1086 |
} |
|
1087 |
||
1088 |
||
1089 |
/** Commonly used step to set a flag that will cause the |
|
1090 |
OPT test mode to be activated when the stacks are |
|
1091 |
started |
|
1092 |
*/ |
|
1093 |
void COtgRoot::StepSetOptActive() |
|
1094 |
{ |
|
1095 |
iOptActive = ETrue; |
|
1096 |
} |
|
1097 |
||
1098 |
||
1099 |
/** Commonly used step to unload the ldd and shut it down |
|
1100 |
*@return ETrue if the ldd unloaded sucessfully |
|
1101 |
*/ |
|
1102 |
TBool COtgRoot::StepUnloadLDD() |
|
1103 |
{ |
|
1104 |
test.Printf(_L("Unload otg LDD (implicit Stop() + Close()) \n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1105 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPUNLOADLDD, "Unload otg LDD (implicit Stop(+ Close()) \n"); |
0 | 1106 |
|
1107 |
LOG_VERBOSE1(_L(" Stop OTG+Host Stack\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1108 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1109 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1110 |
OstTrace0(TRACE_VERBOSE, COTGROOT_STEPUNLOADLDD_DUP01, " Stop OTG+Host Stack\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1111 |
} |
0 | 1112 |
otgStopStacks(); |
1113 |
otgClose(); |
|
1114 |
||
1115 |
LOG_VERBOSE1(_L(" Unload\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1116 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1117 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1118 |
OstTrace0(TRACE_VERBOSE, COTGROOT_STEPUNLOADLDD_DUP02, " Unload\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1119 |
} |
0 | 1120 |
otgUnloadLdd(); |
1121 |
||
1122 |
iOptActive = EFalse; // retain the OTGDI behavour to clears this flag when client shuts |
|
1123 |
if (LddLoaded()) |
|
1124 |
return(EFalse); |
|
1125 |
return(ETrue); |
|
1126 |
} |
|
1127 |
||
1128 |
||
1129 |
/** StepLoadLDD - utility method : load the LDD, open it and init the stacks |
|
1130 |
a commonly used test step */ |
|
1131 |
TBool COtgRoot::StepLoadLDD() |
|
1132 |
{ |
|
1133 |
TInt err; |
|
1134 |
||
1135 |
LOG_VERBOSE1(_L("Load otg LDD\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1136 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1137 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1138 |
OstTrace0(TRACE_VERBOSE, COTGROOT_STEPLOADLDD, "Load otg LDD\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1139 |
} |
0 | 1140 |
err = otgLoadLdd(); |
1141 |
if (err != KErrNone) |
|
1142 |
{ |
|
1143 |
AssertionFailed2(KErrAbort, _L("Loading LDD failed "), err); |
|
1144 |
return (EFalse); |
|
1145 |
} |
|
1146 |
||
1147 |
LOG_VERBOSE1(_L("Open the LDD session\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1148 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1149 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1150 |
OstTrace0(TRACE_VERBOSE, COTGROOT_STEPLOADLDD_DUP01, "Open the LDD session\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1151 |
} |
0 | 1152 |
err = otgOpen(); |
1153 |
if (err != KErrNone) |
|
1154 |
{ |
|
1155 |
AssertionFailed2(KErrAbort, _L("Open LDD session failed "), err); |
|
1156 |
return (EFalse); |
|
1157 |
} |
|
1158 |
||
1159 |
if ( iOptActive ) |
|
1160 |
{ |
|
1161 |
test.Printf(_L("Activate OPT Test Mode\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1162 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADLDD_DUP02, "Activate OPT Test Mode\n"); |
0 | 1163 |
err = otgActivateOptTestMode(); |
1164 |
if (err != KErrNone) |
|
1165 |
{ |
|
1166 |
AssertionFailed2(KErrAbort, _L("OPT Activate failed "), err); |
|
1167 |
return (EFalse); |
|
1168 |
} |
|
1169 |
} |
|
1170 |
||
1171 |
test.Printf(_L("Start OTG+Host Stack\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1172 |
OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADLDD_DUP03, "Start OTG+Host Stack\n"); |
0 | 1173 |
err = otgStartStacks(); |
1174 |
if (err != KErrNone) |
|
1175 |
{ |
|
1176 |
AssertionFailed2(KErrAbort, _L("Start stack failed "), err); |
|
1177 |
return (EFalse); |
|
1178 |
} |
|
1179 |
||
1180 |
// DS - Temporarily adding .1 second delay in here to beat the race |
|
1181 |
// condition to be fixed as part of third part USB HOST/OTG stack issue 60761 |
|
1182 |
User::After(100000); |
|
1183 |
||
1184 |
return(ETrue); |
|
1185 |
} |
|
1186 |
||
1187 |
void COtgRoot::SetMaxPowerToL(TUint16 aVal) |
|
1188 |
{ |
|
1189 |
||
1190 |
TBuf8<KUsbDescSize_Config> buf; |
|
1191 |
||
1192 |
oUsbcClient.GetConfigurationDescriptor(buf); |
|
1193 |
||
1194 |
aVal %= 500; |
|
1195 |
||
1196 |
buf[8] = (TUint8)(aVal / 2); |
|
1197 |
||
1198 |
oUsbcClient.SetConfigurationDescriptor(buf); |
|
1199 |
||
1200 |
} |
|
1201 |
||
1202 |
void COtgRoot::GetMaxPower(TUint16& aVal) |
|
1203 |
{ |
|
1204 |
TBuf8<KUsbDescSize_Config> buf; |
|
1205 |
||
1206 |
oUsbcClient.GetConfigurationDescriptor(buf); |
|
1207 |
||
1208 |
aVal = buf[8] * 2; |
|
1209 |
} |
|
1210 |
||
1211 |