48 /** otgLoadLdd |
52 /** otgLoadLdd |
49 */ |
53 */ |
50 TInt COtgRoot::otgLoadLdd() |
54 TInt COtgRoot::otgLoadLdd() |
51 { |
55 { |
52 |
56 |
53 LOG_FUNC |
57 if(gVerboseOutput) |
|
58 { |
|
59 OstTraceFunctionEntry0(COTGROOT_OTGLOADLDD); |
|
60 } |
54 LOG_VERBOSE2(_L("Load driver: %S\n"), &KOTGDeviceInterfaceDriverName); |
61 LOG_VERBOSE2(_L("Load driver: %S\n"), &KOTGDeviceInterfaceDriverName); |
|
62 if(gVerboseOutput) |
|
63 { |
|
64 OstTraceExt1(TRACE_VERBOSE, COTGROOT_OTGLOADLDD_DUP01, "Load driver: %S\n", KOTGDeviceInterfaceDriverName); |
|
65 } |
55 |
66 |
56 if (!LddLoaded()) |
67 if (!LddLoaded()) |
57 { |
68 { |
58 |
69 |
59 // load ldd device drivers (load otg only, it will load the needed stuff for us) |
70 // load ldd device drivers (load otg only, it will load the needed stuff for us) |
60 TInt err(User::LoadLogicalDevice(KOTGDeviceInterfaceDriverName)); |
71 TInt err(User::LoadLogicalDevice(KOTGDeviceInterfaceDriverName)); |
61 if ( (err != KErrNone) && (err != KErrAlreadyExists) ) |
72 if ( (err != KErrNone) && (err != KErrAlreadyExists) ) |
62 { |
73 { |
63 test.Printf(_L("<Error %d> Unable to load driver: %S\n"), err, &KOTGDeviceInterfaceDriverName); |
74 test.Printf(_L("<Error %d> Unable to load driver: %S\n"), err, &KOTGDeviceInterfaceDriverName); |
|
75 OstTraceExt2(TRACE_NORMAL, COTGROOT_OTGLOADLDD_DUP02, "<Error %d> Unable to load driver: %S\n", err, KOTGDeviceInterfaceDriverName); |
64 SetLoaded(EFalse); |
76 SetLoaded(EFalse); |
65 return(err); |
77 return(err); |
66 } |
78 } |
67 else |
79 else |
68 { |
80 { |
69 LOG_VERBOSE2(_L("Loaded driver: '%S' OK\n"), &KOTGDeviceInterfaceDriverName); |
81 LOG_VERBOSE2(_L("Loaded driver: '%S' OK\n"), &KOTGDeviceInterfaceDriverName); |
|
82 if(gVerboseOutput) |
|
83 { |
|
84 OstTraceExt1(TRACE_VERBOSE, COTGROOT_OTGLOADLDD_DUP03, "Loaded driver: '%S' OK\n", KOTGDeviceInterfaceDriverName); |
|
85 } |
70 SetLoaded(ETrue); |
86 SetLoaded(ETrue); |
71 } |
87 } |
72 |
88 |
73 } |
89 } |
74 return(KErrNone); |
90 return(KErrNone); |
77 |
93 |
78 /** otgOpen |
94 /** otgOpen |
79 */ |
95 */ |
80 TInt COtgRoot::otgOpen() |
96 TInt COtgRoot::otgOpen() |
81 { |
97 { |
82 LOG_FUNC |
98 if(gVerboseOutput) |
|
99 { |
|
100 OstTraceFunctionEntry0(COTGROOT_OTGOPEN); |
|
101 } |
83 |
102 |
84 LOG_VERBOSE2(_L("Opening session... loaded = %d\n"), LddLoaded()); |
103 LOG_VERBOSE2(_L("Opening session... loaded = %d\n"), LddLoaded()); |
|
104 if(gVerboseOutput) |
|
105 { |
|
106 OstTrace1(TRACE_VERBOSE, COTGROOT_OTGOPEN_DUP01, "Opening session... loaded = %d\n", LddLoaded()); |
|
107 } |
85 |
108 |
86 TInt err(oUsbOtgDriver.Open()); |
109 TInt err(oUsbOtgDriver.Open()); |
87 if (err != KErrNone) |
110 if (err != KErrNone) |
88 { |
111 { |
89 test.Printf(_L("<Error %d> Unable to open a channel to USB OTG driver\n"),err); |
112 test.Printf(_L("<Error %d> Unable to open a channel to USB OTG driver\n"),err); |
|
113 OstTrace1(TRACE_NORMAL, COTGROOT_OTGOPEN_DUP02, "<Error %d> Unable to open a channel to USB OTG driver\n",err); |
90 return(err); |
114 return(err); |
91 } |
115 } |
92 else |
116 else |
93 { |
117 { |
94 LOG_VERBOSE1(_L("Open channel OK\n")); |
118 LOG_VERBOSE1(_L("Open channel OK\n")); |
|
119 if(gVerboseOutput) |
|
120 { |
|
121 OstTrace0(TRACE_VERBOSE, COTGROOT_OTGOPEN_DUP03, "Open channel OK\n"); |
|
122 } |
95 } |
123 } |
96 |
124 |
97 return(KErrNone); |
125 return(KErrNone); |
98 } |
126 } |
99 |
127 |
100 |
128 |
101 /** otgClose |
129 /** otgClose |
102 */ |
130 */ |
103 void COtgRoot::otgClose() |
131 void COtgRoot::otgClose() |
104 { |
132 { |
105 LOG_FUNC |
133 if(gVerboseOutput) |
|
134 { |
|
135 OstTraceFunctionEntry0(COTGROOT_OTGCLOSE); |
|
136 } |
106 |
137 |
107 test.Printf(_L("Closing session... loaded = %d\n"), LddLoaded()); |
138 test.Printf(_L("Closing session... loaded = %d\n"), LddLoaded()); |
|
139 OstTrace1(TRACE_NORMAL, COTGROOT_OTGCLOSE_DUP01, "Closing session... loaded = %d\n", LddLoaded()); |
108 oUsbOtgDriver.Close(); |
140 oUsbOtgDriver.Close(); |
109 } |
141 } |
110 |
142 |
111 |
143 |
112 /* otgActivateOptTestMode |
144 /* otgActivateOptTestMode |
113 */ |
145 */ |
114 TInt COtgRoot::otgActivateOptTestMode() |
146 TInt COtgRoot::otgActivateOptTestMode() |
115 { |
147 { |
116 LOG_FUNC |
148 if(gVerboseOutput) |
|
149 { |
|
150 OstTraceFunctionEntry0(COTGROOT_OTGACTIVATEOPTTESTMODE); |
|
151 } |
117 |
152 |
118 TInt err = oUsbOtgDriver.ActivateOptTestMode(); |
153 TInt err = oUsbOtgDriver.ActivateOptTestMode(); |
119 |
154 |
120 return(err); |
155 return(err); |
121 } |
156 } |
156 |
197 |
157 // code to unload the OTG ldd driver |
198 // code to unload the OTG ldd driver |
158 TInt err (User::FreeLogicalDevice(KOTGDeviceInterfaceDriverName)); |
199 TInt err (User::FreeLogicalDevice(KOTGDeviceInterfaceDriverName)); |
159 if (err != KErrNone) |
200 if (err != KErrNone) |
160 { |
201 { |
161 LOG_FUNCERROR(err) |
202 OstTrace1(TRACE_WARNING, COTGROOT_OTGUNLOADLDD, "[WARNING failed %d]", err); |
162 } |
203 } |
163 |
204 |
164 SetLoaded(EFalse); |
205 SetLoaded(EFalse); |
165 } |
206 } |
166 |
207 |
167 |
208 |
168 /** otgQueueOtgEventRequest |
209 /** otgQueueOtgEventRequest |
169 */ |
210 */ |
170 void COtgRoot::otgQueueOtgEventRequest(RUsbOtgDriver::TOtgEvent& aEvent, TRequestStatus &aStatus) |
211 void COtgRoot::otgQueueOtgEventRequest(RUsbOtgDriver::TOtgEvent& aEvent, TRequestStatus &aStatus) |
171 { |
212 { |
172 //LOG_FUNC |
|
173 LOG_VERBOSE2(_L("Queue an Event Request %08X.\n"), (TInt)(&aStatus)); |
213 LOG_VERBOSE2(_L("Queue an Event Request %08X.\n"), (TInt)(&aStatus)); |
|
214 if(gVerboseOutput) |
|
215 { |
|
216 OstTrace1(TRACE_VERBOSE, COTGROOT_OTGQUEUEOTGEVENTREQUEST_DUP01, "Queue an Event Request %08X.\n", (TInt)(&aStatus)); |
|
217 } |
174 |
218 |
175 oUsbOtgDriver.QueueOtgEventRequest(aEvent, aStatus); |
219 oUsbOtgDriver.QueueOtgEventRequest(aEvent, aStatus); |
176 |
220 |
177 } |
221 } |
178 |
222 |
180 /** otgCancelOtgEventRequest |
224 /** otgCancelOtgEventRequest |
181 */ |
225 */ |
182 void COtgRoot::otgCancelOtgEventRequest() |
226 void COtgRoot::otgCancelOtgEventRequest() |
183 { |
227 { |
184 LOG_VERBOSE1(_L("Cancel Event Request.\n")); |
228 LOG_VERBOSE1(_L("Cancel Event Request.\n")); |
|
229 if(gVerboseOutput) |
|
230 { |
|
231 OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELOTGEVENTREQUEST, "Cancel Event Request.\n"); |
|
232 } |
185 oUsbOtgDriver.CancelOtgEventRequest(); |
233 oUsbOtgDriver.CancelOtgEventRequest(); |
186 } |
234 } |
187 |
235 |
188 |
236 |
189 /** otgQueueOtgMessageRequest |
237 /** otgQueueOtgMessageRequest |
190 */ |
238 */ |
191 void COtgRoot::otgQueueOtgMessageRequest(RUsbOtgDriver::TOtgMessage& aMessage, TRequestStatus &aStatus) |
239 void COtgRoot::otgQueueOtgMessageRequest(RUsbOtgDriver::TOtgMessage& aMessage, TRequestStatus &aStatus) |
192 { |
240 { |
193 //LOG_FUNC |
241 |
194 LOG_VERBOSE2(_L("Queue a Message Request %08X.\n"), (TInt)(&aStatus)); |
242 LOG_VERBOSE2(_L("Queue a Message Request %08X.\n"), (TInt)(&aStatus)); |
195 |
243 if(gVerboseOutput) |
196 //LOG_VERBOSE1(_L("Queue a Message Request.\n")); |
244 { |
|
245 OstTrace1(TRACE_VERBOSE, COTGROOT_OTGQUEUEOTGMESSAGEREQUEST_DUP01, "Queue a Message Request %08X.\n", (TInt)(&aStatus)); |
|
246 } |
|
247 |
197 oUsbOtgDriver.QueueOtgMessageRequest(aMessage, aStatus); |
248 oUsbOtgDriver.QueueOtgMessageRequest(aMessage, aStatus); |
198 |
249 |
199 } |
250 } |
200 |
251 |
201 |
252 |
202 /** otgCancelOtgMessageRequest |
253 /** otgCancelOtgMessageRequest |
203 */ |
254 */ |
204 void COtgRoot::otgCancelOtgMessageRequest() |
255 void COtgRoot::otgCancelOtgMessageRequest() |
205 { |
256 { |
206 LOG_VERBOSE1(_L("Cancel Message Request.\n")); |
257 LOG_VERBOSE1(_L("Cancel Message Request.\n")); |
|
258 if(gVerboseOutput) |
|
259 { |
|
260 OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELOTGMESSAGEREQUEST, "Cancel Message Request.\n"); |
|
261 } |
207 oUsbOtgDriver.CancelOtgMessageRequest(); |
262 oUsbOtgDriver.CancelOtgMessageRequest(); |
208 } |
263 } |
209 |
264 |
210 void COtgRoot::otgQueuePeripheralStateRequest(TUint& aPeripheralState, TRequestStatus& aStatus) |
265 void COtgRoot::otgQueuePeripheralStateRequest(TUint& aPeripheralState, TRequestStatus& aStatus) |
211 { |
266 { |
212 LOG_VERBOSE1(_L("Queue Peripheral State Request.\n")); |
267 LOG_VERBOSE1(_L("Queue Peripheral State Request.\n")); |
|
268 if(gVerboseOutput) |
|
269 { |
|
270 OstTrace0(TRACE_VERBOSE, COTGROOT_OTGQUEUEPERIPHERALSTATEREQUEST, "Queue Peripheral State Request.\n"); |
|
271 } |
213 oUsbcClient.AlternateDeviceStatusNotify(aStatus, aPeripheralState); |
272 oUsbcClient.AlternateDeviceStatusNotify(aStatus, aPeripheralState); |
214 } |
273 } |
215 |
274 |
216 void COtgRoot::otgCancelPeripheralStateRequest() |
275 void COtgRoot::otgCancelPeripheralStateRequest() |
217 { |
276 { |
218 LOG_VERBOSE1(_L("Cancel Peripheral State Request.\n")); |
277 LOG_VERBOSE1(_L("Cancel Peripheral State Request.\n")); |
|
278 if(gVerboseOutput) |
|
279 { |
|
280 OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELPERIPHERALSTATEREQUEST, "Cancel Peripheral State Request.\n"); |
|
281 } |
219 oUsbcClient.AlternateDeviceStatusNotifyCancel(); |
282 oUsbcClient.AlternateDeviceStatusNotifyCancel(); |
220 } |
283 } |
221 |
284 |
222 void COtgRoot::otgQueueAConnectionIdleRequest(RUsbOtgDriver::TOtgConnection& aAConnectionIdle, TRequestStatus& aStatus) |
285 void COtgRoot::otgQueueAConnectionIdleRequest(RUsbOtgDriver::TOtgConnection& aAConnectionIdle, TRequestStatus& aStatus) |
223 { |
286 { |
224 LOG_VERBOSE1(_L("Queue A Connection Idle Request.\n")); |
287 LOG_VERBOSE1(_L("Queue A Connection Idle Request.\n")); |
|
288 if(gVerboseOutput) |
|
289 { |
|
290 OstTrace0(TRACE_VERBOSE, COTGROOT_OTGQUEUEACONNECTIONIDLEREQUEST, "Queue A Connection Idle Request.\n"); |
|
291 } |
225 oUsbOtgDriver.QueueOtgConnectionNotification(aAConnectionIdle, aStatus); |
292 oUsbOtgDriver.QueueOtgConnectionNotification(aAConnectionIdle, aStatus); |
226 } |
293 } |
227 |
294 |
228 void COtgRoot::otgCancelAConnectionIdleRequest() |
295 void COtgRoot::otgCancelAConnectionIdleRequest() |
229 { |
296 { |
230 LOG_VERBOSE1(_L("Cancel A Connection Idle Request.\n")); |
297 LOG_VERBOSE1(_L("Cancel A Connection Idle Request.\n")); |
|
298 if(gVerboseOutput) |
|
299 { |
|
300 OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELACONNECTIONIDLEREQUEST, "Cancel A Connection Idle Request.\n"); |
|
301 } |
231 oUsbOtgDriver.CancelOtgConnectionNotification(); |
302 oUsbOtgDriver.CancelOtgConnectionNotification(); |
232 } |
303 } |
233 |
304 |
234 |
305 |
235 /** otgQueueOtgStateRequest |
306 /** otgQueueOtgStateRequest |
236 */ |
307 */ |
237 void COtgRoot::otgQueueOtgStateRequest(RUsbOtgDriver::TOtgState& aState, TRequestStatus &aStatus) |
308 void COtgRoot::otgQueueOtgStateRequest(RUsbOtgDriver::TOtgState& aState, TRequestStatus &aStatus) |
238 { |
309 { |
239 //LOG_FUNC |
|
240 LOG_VERBOSE2(_L("Queue a State Request %08X.\n"), (TInt)(&aStatus)); |
310 LOG_VERBOSE2(_L("Queue a State Request %08X.\n"), (TInt)(&aStatus)); |
|
311 if(gVerboseOutput) |
|
312 { |
|
313 OstTrace1(TRACE_VERBOSE, COTGROOT_OTGQUEUEOTGSTATEREQUEST_DUP01, "Queue a State Request %08X.\n", (TInt)(&aStatus)); |
|
314 } |
241 |
315 |
242 oUsbOtgDriver.QueueOtgStateRequest(aState, aStatus); |
316 oUsbOtgDriver.QueueOtgStateRequest(aState, aStatus); |
243 |
317 |
244 } |
318 } |
245 |
319 |
247 /** otgCancelOtgStateRequest |
321 /** otgCancelOtgStateRequest |
248 */ |
322 */ |
249 void COtgRoot::otgCancelOtgStateRequest() |
323 void COtgRoot::otgCancelOtgStateRequest() |
250 { |
324 { |
251 LOG_VERBOSE1(_L("Cancel State Request.\n")); |
325 LOG_VERBOSE1(_L("Cancel State Request.\n")); |
|
326 if(gVerboseOutput) |
|
327 { |
|
328 OstTrace0(TRACE_VERBOSE, COTGROOT_OTGCANCELOTGSTATEREQUEST, "Cancel State Request.\n"); |
|
329 } |
252 oUsbOtgDriver.CancelOtgStateRequest(); |
330 oUsbOtgDriver.CancelOtgStateRequest(); |
253 } |
331 } |
254 |
332 |
255 |
333 |
256 /** otgBusRequest |
334 /** otgBusRequest |
257 raise VBus (in reality this must only happen when a 'A' is present... and when not present it starts HNP) |
335 raise VBus (in reality this must only happen when a 'A' is present... and when not present it starts HNP) |
258 */ |
336 */ |
259 TInt COtgRoot::otgBusRequest() |
337 TInt COtgRoot::otgBusRequest() |
260 { |
338 { |
261 LOG_FUNC |
339 if(gVerboseOutput) |
|
340 { |
|
341 OstTraceFunctionEntry0(COTGROOT_OTGBUSREQUEST); |
|
342 } |
262 |
343 |
263 TInt err(0); |
344 TInt err(0); |
264 err = oUsbOtgDriver.BusRequest(); |
345 err = oUsbOtgDriver.BusRequest(); |
265 if (err != KErrNone) |
346 if (err != KErrNone) |
266 { |
347 { |
267 LOG_FUNCERROR(err) |
348 OstTrace1(TRACE_WARNING, COTGROOT_OTGBUSREQUEST_DUP01, "[WARNING failed %d]", err); |
268 } |
349 } |
269 return(err); |
350 return(err); |
270 } |
351 } |
271 |
352 |
272 |
353 |
273 /* call when SRP has been recieved, based on our HNP Enable setting, this will allow HNP. The |
354 /* call when SRP has been recieved, based on our HNP Enable setting, this will allow HNP. The |
274 * A-device may choose to call BusRequest directly, which will result in a 'short-circuit' role-swap. |
355 * A-device may choose to call BusRequest directly, which will result in a 'short-circuit' role-swap. |
275 */ |
356 */ |
276 TInt COtgRoot::otgBusRespondSRP() |
357 TInt COtgRoot::otgBusRespondSRP() |
277 { |
358 { |
278 LOG_FUNC |
359 if(gVerboseOutput) |
|
360 { |
|
361 OstTraceFunctionEntry0(COTGROOT_OTGBUSRESPONDSRP); |
|
362 } |
279 TInt err(0); |
363 TInt err(0); |
280 err = oUsbOtgDriver.BusRespondSrp(); |
364 err = oUsbOtgDriver.BusRespondSrp(); |
281 if (err != KErrNone) |
365 if (err != KErrNone) |
282 { |
366 { |
283 LOG_FUNCERROR(err) |
367 OstTrace1(TRACE_WARNING, COTGROOT_OTGBUSRESPONDSRP_DUP01, "[WARNING failed %d]", err); |
284 } |
368 } |
285 return(err); |
369 return(err); |
286 } |
370 } |
287 |
371 |
288 |
372 |
289 /** Drop VBus (A-host) |
373 /** Drop VBus (A-host) |
290 */ |
374 */ |
291 TInt COtgRoot::otgBusDrop() |
375 TInt COtgRoot::otgBusDrop() |
292 { |
376 { |
293 LOG_FUNC |
377 if(gVerboseOutput) |
|
378 { |
|
379 OstTraceFunctionEntry0(COTGROOT_OTGBUSDROP); |
|
380 } |
294 TInt err(0); |
381 TInt err(0); |
295 err = oUsbOtgDriver.BusDrop(); |
382 err = oUsbOtgDriver.BusDrop(); |
296 if (err != KErrNone) |
383 if (err != KErrNone) |
297 { |
384 { |
298 LOG_FUNCERROR(err) |
385 OstTrace1(TRACE_WARNING, COTGROOT_OTGBUSDROP_DUP01, "[WARNING failed %d]", err); |
299 } |
386 } |
300 return(err); |
387 return(err); |
301 } |
388 } |
302 |
389 |
303 /** otgBusClearError |
390 /** otgBusClearError |
304 */ |
391 */ |
305 TInt COtgRoot::otgBusClearError() |
392 TInt COtgRoot::otgBusClearError() |
306 { |
393 { |
307 LOG_FUNC |
394 if(gVerboseOutput) |
|
395 { |
|
396 OstTraceFunctionEntry0(COTGROOT_OTGBUSCLEARERROR); |
|
397 } |
308 |
398 |
309 TInt err(0); |
399 TInt err(0); |
310 err = oUsbOtgDriver.BusClearError(); |
400 err = oUsbOtgDriver.BusClearError(); |
311 if (err != KErrNone) |
401 if (err != KErrNone) |
312 { |
402 { |
313 LOG_FUNCERROR(err) |
403 OstTrace1(TRACE_WARNING, COTGROOT_OTGBUSCLEARERROR_DUP01, "[WARNING failed %d]", err); |
314 } |
404 } |
315 return(err); |
405 return(err); |
316 } |
406 } |
317 |
407 |
318 |
408 |
319 |
409 |
320 void COtgRoot::otgQueueOtgIdPinNotification(RUsbOtgDriver::TOtgIdPin& aPin, TRequestStatus& aStatus) |
410 void COtgRoot::otgQueueOtgIdPinNotification(RUsbOtgDriver::TOtgIdPin& aPin, TRequestStatus& aStatus) |
321 { |
411 { |
322 LOG_FUNC |
412 if(gVerboseOutput) |
|
413 { |
|
414 OstTraceFunctionEntry0(COTGROOT_OTGQUEUEOTGIDPINNOTIFICATION); |
|
415 } |
323 oUsbOtgDriver.QueueOtgIdPinNotification(aPin, aStatus); // the kernel driver populates aPin... |
416 oUsbOtgDriver.QueueOtgIdPinNotification(aPin, aStatus); // the kernel driver populates aPin... |
324 } |
417 } |
325 |
418 |
326 |
419 |
327 void COtgRoot::otgCancelOtgIdPinNotification() |
420 void COtgRoot::otgCancelOtgIdPinNotification() |
328 { |
421 { |
329 LOG_FUNC |
422 if(gVerboseOutput) |
|
423 { |
|
424 OstTraceFunctionEntry0(COTGROOT_OTGCANCELOTGIDPINNOTIFICATION); |
|
425 } |
330 oUsbOtgDriver.CancelOtgIdPinNotification(); |
426 oUsbOtgDriver.CancelOtgIdPinNotification(); |
331 } |
427 } |
332 |
428 |
333 |
429 |
334 void COtgRoot::otgQueueOtgVbusNotification(RUsbOtgDriver::TOtgVbus& aVbus, |
430 void COtgRoot::otgQueueOtgVbusNotification(RUsbOtgDriver::TOtgVbus& aVbus, |
335 TRequestStatus& aStatus |
431 TRequestStatus& aStatus |
336 ) |
432 ) |
337 { |
433 { |
338 LOG_FUNC |
434 if(gVerboseOutput) |
|
435 { |
|
436 OstTraceFunctionEntry0(COTGROOT_OTGQUEUEOTGVBUSNOTIFICATION); |
|
437 } |
339 oUsbOtgDriver.QueueOtgVbusNotification(aVbus, aStatus); |
438 oUsbOtgDriver.QueueOtgVbusNotification(aVbus, aStatus); |
340 } |
439 } |
341 |
440 |
342 |
441 |
343 void COtgRoot::otgCancelOtgVbusNotification() |
442 void COtgRoot::otgCancelOtgVbusNotification() |
344 { |
443 { |
345 LOG_FUNC |
444 if(gVerboseOutput) |
|
445 { |
|
446 OstTraceFunctionEntry0(COTGROOT_OTGCANCELOTGVBUSNOTIFICATION); |
|
447 } |
346 oUsbOtgDriver.CancelOtgVbusNotification(); |
448 oUsbOtgDriver.CancelOtgVbusNotification(); |
347 } |
449 } |
348 |
450 |
349 |
451 |
350 TBool COtgRoot::otgIdPinPresent() |
452 TBool COtgRoot::otgIdPinPresent() |
351 { |
453 { |
352 LOG_FUNC |
454 if(gVerboseOutput) |
|
455 { |
|
456 OstTraceFunctionEntry0(COTGROOT_OTGIDPINPRESENT); |
|
457 } |
353 TRequestStatus aStatus; |
458 TRequestStatus aStatus; |
354 RUsbOtgDriver::TOtgIdPin aPin; |
459 RUsbOtgDriver::TOtgIdPin aPin; |
355 oUsbOtgDriver.QueueOtgIdPinNotification(aPin, aStatus); // the kernel driver populates aPin... |
460 oUsbOtgDriver.QueueOtgIdPinNotification(aPin, aStatus); // the kernel driver populates aPin... |
356 LOG_VERBOSE2(_L("(sync) ID_PIN=%d\n"), iOTGIdPin); |
461 LOG_VERBOSE2(_L("(sync) ID_PIN=%d\n"), iOTGIdPin); |
|
462 if(gVerboseOutput) |
|
463 { |
|
464 OstTrace1(TRACE_VERBOSE, COTGROOT_OTGIDPINPRESENT_DUP01, "(sync) ID_PIN=%d\n", iOTGIdPin); |
|
465 } |
357 |
466 |
358 oUsbOtgDriver.CancelOtgIdPinNotification(); |
467 oUsbOtgDriver.CancelOtgIdPinNotification(); |
359 // swallow the event |
468 // swallow the event |
360 User::WaitForRequest(aStatus); |
469 User::WaitForRequest(aStatus); |
361 |
470 |
515 |
627 |
516 TInt COtgRoot::otgActivateFdfActor() |
628 TInt COtgRoot::otgActivateFdfActor() |
517 { |
629 { |
518 if(iFdfActorActive) |
630 if(iFdfActorActive) |
519 { |
631 { |
520 RDebug::Print(_L("FdfActor already exists!")); |
632 OstTrace0(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR, "FdfActor already exists!"); |
521 return KErrAlreadyExists; |
633 return KErrAlreadyExists; |
522 } |
634 } |
523 |
635 |
524 const TUid KFdfSvrUid={0x10282B48}; |
636 const TUid KFdfSvrUid={0x10282B48}; |
525 const TUidType fdfActorUid(KNullUid, KNullUid, KFdfSvrUid); |
637 const TUidType fdfActorUid(KNullUid, KNullUid, KFdfSvrUid); |
526 |
638 |
527 RDebug::Print(_L("About to activate FDF Actor")); |
639 OstTrace0(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP01, "About to activate FDF Actor"); |
528 |
640 |
529 // RProcess fdfActorProcess; |
641 // RProcess fdfActorProcess; |
530 TInt err = iFdfActorProcess.Create(_L("t_otgdi_fdfactor.exe"), KNullDesC, fdfActorUid); |
642 TInt err = iFdfActorProcess.Create(_L("t_otgdi_fdfactor.exe"), KNullDesC, fdfActorUid); |
531 |
643 |
532 if (err != KErrNone) |
644 if (err != KErrNone) |
533 { |
645 { |
534 RDebug::Print(_L("Failed to create FDF Actor, err=%d"),err); |
646 OstTrace1(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP02, "Failed to create FDF Actor, err=%d",err); |
535 iFdfActorProcess.Close(); |
647 iFdfActorProcess.Close(); |
536 return err; |
648 return err; |
537 } |
649 } |
538 |
650 |
539 TRequestStatus stat; |
651 TRequestStatus stat; |
540 iFdfActorProcess.Rendezvous(stat); |
652 iFdfActorProcess.Rendezvous(stat); |
541 |
653 |
542 if (stat!=KRequestPending) |
654 if (stat!=KRequestPending) |
543 { |
655 { |
544 RDebug::Print(_L("Failed to commence rendezvous, err=%d"),stat.Int()); |
656 OstTrace1(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP03, "Failed to commence rendezvous, err=%d",stat.Int()); |
545 iFdfActorProcess.Kill(0); // abort startup |
657 iFdfActorProcess.Kill(0); // abort startup |
546 iFdfActorProcess.Close(); |
658 iFdfActorProcess.Close(); |
547 return stat.Int(); |
659 return stat.Int(); |
548 } |
660 } |
549 else |
661 else |
554 User::WaitForRequest(stat); // wait for start or death |
666 User::WaitForRequest(stat); // wait for start or death |
555 if(stat.Int()!=KErrNone) |
667 if(stat.Int()!=KErrNone) |
556 { |
668 { |
557 // Wasn't KErrNone, which means that the FDFActor didn't successfully |
669 // Wasn't KErrNone, which means that the FDFActor didn't successfully |
558 // start up. We shouldn't proceed with the test we're in. |
670 // start up. We shouldn't proceed with the test we're in. |
559 RDebug::Print(_L("Failed to activate FDF Actor, err=%d"),stat.Int()); |
671 OstTrace1(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP04, "Failed to activate FDF Actor, err=%d",stat.Int()); |
560 iFdfActorProcess.Close(); |
672 iFdfActorProcess.Close(); |
561 return stat.Int(); |
673 return stat.Int(); |
562 } |
674 } |
563 |
675 |
564 // We rendezvoused(?) with the FDFActor OK, so it is going to suspend |
676 // We rendezvoused(?) with the FDFActor OK, so it is going to suspend |
565 // any devices it sees being attached, and will shut itself down |
677 // any devices it sees being attached, and will shut itself down |
566 // when this process signals its Rendezvous (at the end of the test)... |
678 // when this process signals its Rendezvous (at the end of the test)... |
567 RDebug::Print(_L("Activated FDF Actor")); |
679 OstTrace0(TRACE_NORMAL, COTGROOT_OTGACTIVATEFDFACTOR_DUP05, "Activated FDF Actor"); |
568 iFdfActorActive = ETrue; |
680 iFdfActorActive = ETrue; |
569 |
681 |
570 return KErrNone; |
682 return KErrNone; |
571 } |
683 } |
572 |
684 |
573 void COtgRoot::otgDeactivateFdfActor() |
685 void COtgRoot::otgDeactivateFdfActor() |
574 { |
686 { |
575 if(!iFdfActorActive) |
687 if(!iFdfActorActive) |
576 { |
688 { |
577 RDebug::Print(_L("FdfActor is not running!")); |
689 OstTrace0(TRACE_NORMAL, COTGROOT_OTGDEACTIVATEFDFACTOR, "FdfActor is not running!"); |
578 return; |
690 return; |
579 } |
691 } |
580 |
692 |
581 // If iFdfActorActive is set, the FDF Actor should be waiting to |
693 // If iFdfActorActive is set, the FDF Actor should be waiting to |
582 // rendezvous with us before it shuts down... |
694 // rendezvous with us before it shuts down... |
589 RProcess::Rendezvous(KErrNone); |
701 RProcess::Rendezvous(KErrNone); |
590 |
702 |
591 // ...and wait for it to go away. |
703 // ...and wait for it to go away. |
592 User::WaitForRequest(waitForCloseStat); |
704 User::WaitForRequest(waitForCloseStat); |
593 test.Printf(_L("T_OTGDI confirms FDF Actor has gone away %d\n"), waitForCloseStat.Int()); |
705 test.Printf(_L("T_OTGDI confirms FDF Actor has gone away %d\n"), waitForCloseStat.Int()); |
|
706 OstTrace1(TRACE_NORMAL, COTGROOT_OTGDEACTIVATEFDFACTOR_DUP01, "T_OTGDI confirms FDF Actor has gone away %d\n", waitForCloseStat.Int()); |
594 |
707 |
595 // Now close our handle, and record that the process is no more... |
708 // Now close our handle, and record that the process is no more... |
596 iFdfActorProcess.Close(); |
709 iFdfActorProcess.Close(); |
597 iFdfActorActive = EFalse; |
710 iFdfActorActive = EFalse; |
598 } |
711 } |
601 * @return ETrue if the ldd unloaded sucessfully |
714 * @return ETrue if the ldd unloaded sucessfully |
602 */ |
715 */ |
603 TBool COtgRoot::StepUnloadClient() |
716 TBool COtgRoot::StepUnloadClient() |
604 { |
717 { |
605 test.Printf(_L("Unload USBCC Client\n")); |
718 test.Printf(_L("Unload USBCC Client\n")); |
|
719 OstTrace0(TRACE_NORMAL, COTGROOT_STEPUNLOADCLIENT, "Unload USBCC Client\n"); |
606 |
720 |
607 TInt err; |
721 TInt err; |
608 |
722 |
609 // Close the Client |
723 // Close the Client |
610 |
724 |
611 test.Printf(_L("..Close\n")); |
725 test.Printf(_L("..Close\n")); |
|
726 OstTrace0(TRACE_NORMAL, COTGROOT_STEPUNLOADCLIENT_DUP01, "..Close\n"); |
612 oUsbcClient.Close(); |
727 oUsbcClient.Close(); |
613 |
728 |
614 // Unload the LDD - note the name is *not* the same as for loading |
729 // Unload the LDD - note the name is *not* the same as for loading |
615 |
730 |
616 test.Printf(_L("..Unload\n")); |
731 test.Printf(_L("..Unload\n")); |
|
732 OstTrace0(TRACE_NORMAL, COTGROOT_STEPUNLOADCLIENT_DUP02, "..Unload\n"); |
617 err = User::FreeLogicalDevice( KUsbDeviceName ); |
733 err = User::FreeLogicalDevice( KUsbDeviceName ); |
618 if (err != KErrNone) |
734 if (err != KErrNone) |
619 { |
735 { |
620 AssertionFailed2(KErrAbort, _L("Client Unload Fail "), err); |
736 AssertionFailed2(KErrAbort, _L("Client Unload Fail "), err); |
621 return (EFalse); |
737 return (EFalse); |
666 } |
783 } |
667 |
784 |
668 // Load the LDD - note the name is *not* the same as for unload |
785 // Load the LDD - note the name is *not* the same as for unload |
669 |
786 |
670 test.Printf(_L("..Load LDD\n")); |
787 test.Printf(_L("..Load LDD\n")); |
|
788 OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP01, "..Load LDD\n"); |
671 err = User::LoadLogicalDevice( KUsbcLddFileName ); |
789 err = User::LoadLogicalDevice( KUsbcLddFileName ); |
672 if ((err != KErrNone) && (err !=KErrAlreadyExists)) |
790 if ((err != KErrNone) && (err !=KErrAlreadyExists)) |
673 { |
791 { |
674 AssertionFailed2(KErrAbort, _L("Client Load Fail "), err); |
792 AssertionFailed2(KErrAbort, _L("Client Load Fail "), err); |
675 return (EFalse); |
793 return (EFalse); |
676 } |
794 } |
677 |
795 |
678 // Open the Client |
796 // Open the Client |
679 |
797 |
680 test.Printf(_L("..Open LDD\n")); |
798 test.Printf(_L("..Open LDD\n")); |
|
799 OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP02, "..Open LDD\n"); |
681 err = oUsbcClient.Open(0); |
800 err = oUsbcClient.Open(0); |
682 if (err != KErrNone) |
801 if (err != KErrNone) |
683 { |
802 { |
684 AssertionFailed2(KErrAbort, _L("Client Open Fail "), err); |
803 AssertionFailed2(KErrAbort, _L("Client Open Fail "), err); |
685 return (EFalse); |
804 return (EFalse); |
686 } |
805 } |
687 |
806 |
688 // Set up descriptors |
807 // Set up descriptors |
689 |
808 |
690 test.Printf(_L("..Setup Descriptors\n")); |
809 test.Printf(_L("..Setup Descriptors\n")); |
|
810 OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP03, "..Setup Descriptors\n"); |
691 |
811 |
692 // the OTG descriptor |
812 // the OTG descriptor |
693 TBuf8<KUsbDescSize_Otg> theOtgDescriptor; |
813 TBuf8<KUsbDescSize_Otg> theOtgDescriptor; |
694 err = oUsbcClient.GetOtgDescriptor(theOtgDescriptor); |
814 err = oUsbcClient.GetOtgDescriptor(theOtgDescriptor); |
695 if (err != KErrNone) |
815 if (err != KErrNone) |
932 |
1060 |
933 theDeviceDescriptor[8] = ( aVID & 0x00FF ); |
1061 theDeviceDescriptor[8] = ( aVID & 0x00FF ); |
934 theDeviceDescriptor[9] = ( aVID & 0xFF00 ) >> 8; |
1062 theDeviceDescriptor[9] = ( aVID & 0xFF00 ) >> 8; |
935 |
1063 |
936 test.Printf(_L("..Change VID 0x%04X->0x%04X\n"), oldVID, aVID); |
1064 test.Printf(_L("..Change VID 0x%04X->0x%04X\n"), oldVID, aVID); |
|
1065 OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPCHANGEVIDPID_DUP01, "..Change VID 0x%04X->0x%04X\n", (TUint32)oldVID, (TUint32)aVID); |
937 |
1066 |
938 TUint16 oldPID = ( theDeviceDescriptor[10] ) |
1067 TUint16 oldPID = ( theDeviceDescriptor[10] ) |
939 + ( theDeviceDescriptor[11] << 8 ); |
1068 + ( theDeviceDescriptor[11] << 8 ); |
940 |
1069 |
941 theDeviceDescriptor[10] = ( aPID & 0x00FF ); |
1070 theDeviceDescriptor[10] = ( aPID & 0x00FF ); |
942 theDeviceDescriptor[11] = ( aPID & 0xFF00 ) >> 8; |
1071 theDeviceDescriptor[11] = ( aPID & 0xFF00 ) >> 8; |
943 |
1072 |
944 test.Printf(_L("..Change PID 0x%04X->0x%04X\n"), oldPID, aPID); |
1073 test.Printf(_L("..Change PID 0x%04X->0x%04X\n"), oldPID, aPID); |
|
1074 OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPCHANGEVIDPID_DUP02, "..Change PID 0x%04X->0x%04X\n", (TUint32)oldPID, (TUint32)aPID); |
945 |
1075 |
946 err = oUsbcClient.SetDeviceDescriptor(theDeviceDescriptor); |
1076 err = oUsbcClient.SetDeviceDescriptor(theDeviceDescriptor); |
947 if (err != KErrNone) |
1077 if (err != KErrNone) |
948 { |
1078 { |
949 AssertionFailed2(KErrAbort, _L("Client SetDes Fail "), err); |
1079 AssertionFailed2(KErrAbort, _L("Client SetDes Fail "), err); |
992 TBool COtgRoot::StepLoadLDD() |
1131 TBool COtgRoot::StepLoadLDD() |
993 { |
1132 { |
994 TInt err; |
1133 TInt err; |
995 |
1134 |
996 LOG_VERBOSE1(_L("Load otg LDD\n")); |
1135 LOG_VERBOSE1(_L("Load otg LDD\n")); |
|
1136 if(gVerboseOutput) |
|
1137 { |
|
1138 OstTrace0(TRACE_VERBOSE, COTGROOT_STEPLOADLDD, "Load otg LDD\n"); |
|
1139 } |
997 err = otgLoadLdd(); |
1140 err = otgLoadLdd(); |
998 if (err != KErrNone) |
1141 if (err != KErrNone) |
999 { |
1142 { |
1000 AssertionFailed2(KErrAbort, _L("Loading LDD failed "), err); |
1143 AssertionFailed2(KErrAbort, _L("Loading LDD failed "), err); |
1001 return (EFalse); |
1144 return (EFalse); |
1002 } |
1145 } |
1003 |
1146 |
1004 LOG_VERBOSE1(_L("Open the LDD session\n")); |
1147 LOG_VERBOSE1(_L("Open the LDD session\n")); |
|
1148 if(gVerboseOutput) |
|
1149 { |
|
1150 OstTrace0(TRACE_VERBOSE, COTGROOT_STEPLOADLDD_DUP01, "Open the LDD session\n"); |
|
1151 } |
1005 err = otgOpen(); |
1152 err = otgOpen(); |
1006 if (err != KErrNone) |
1153 if (err != KErrNone) |
1007 { |
1154 { |
1008 AssertionFailed2(KErrAbort, _L("Open LDD session failed "), err); |
1155 AssertionFailed2(KErrAbort, _L("Open LDD session failed "), err); |
1009 return (EFalse); |
1156 return (EFalse); |
1010 } |
1157 } |
1011 |
1158 |
1012 if ( iOptActive ) |
1159 if ( iOptActive ) |
1013 { |
1160 { |
1014 test.Printf(_L("Activate OPT Test Mode\n")); |
1161 test.Printf(_L("Activate OPT Test Mode\n")); |
|
1162 OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADLDD_DUP02, "Activate OPT Test Mode\n"); |
1015 err = otgActivateOptTestMode(); |
1163 err = otgActivateOptTestMode(); |
1016 if (err != KErrNone) |
1164 if (err != KErrNone) |
1017 { |
1165 { |
1018 AssertionFailed2(KErrAbort, _L("OPT Activate failed "), err); |
1166 AssertionFailed2(KErrAbort, _L("OPT Activate failed "), err); |
1019 return (EFalse); |
1167 return (EFalse); |
1020 } |
1168 } |
1021 } |
1169 } |
1022 |
1170 |
1023 test.Printf(_L("Start OTG+Host Stack\n")); |
1171 test.Printf(_L("Start OTG+Host Stack\n")); |
|
1172 OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADLDD_DUP03, "Start OTG+Host Stack\n"); |
1024 err = otgStartStacks(); |
1173 err = otgStartStacks(); |
1025 if (err != KErrNone) |
1174 if (err != KErrNone) |
1026 { |
1175 { |
1027 AssertionFailed2(KErrAbort, _L("Start stack failed "), err); |
1176 AssertionFailed2(KErrAbort, _L("Start stack failed "), err); |
1028 return (EFalse); |
1177 return (EFalse); |