18 |
18 |
19 /** |
19 /** |
20 @file |
20 @file |
21 */ |
21 */ |
22 |
22 |
|
23 #include <usbstates.h> |
|
24 #include <usberrors.h> |
|
25 #include <usb/usbshared.h> |
23 #include <usb/usblogger.h> |
26 #include <usb/usblogger.h> |
|
27 |
24 #include "CUsbSession.h" |
28 #include "CUsbSession.h" |
25 #include "CUsbDevice.h" |
29 #include "CUsbDevice.h" |
26 #include "CUsbServer.h" |
30 #include "CUsbServer.h" |
27 |
31 |
28 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
32 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
29 #include "CUsbOtg.h" |
33 #include "CUsbOtg.h" |
30 #include "cusbhost.h" |
34 #include "cusbhost.h" |
31 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
35 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
32 |
36 |
33 #include <usbstates.h> |
|
34 #include <usberrors.h> |
|
35 |
|
36 #include <usb/usbshared.h> |
|
37 #include "CPersonality.h" |
37 #include "CPersonality.h" |
38 #include "rusb.h" |
38 #include "rusb.h" |
39 #include "UsbSettings.h" |
39 #include "UsbSettings.h" |
40 |
40 #include "OstTraceDefinitions.h" |
41 #ifdef __FLOG_ACTIVE |
41 #ifdef OST_TRACE_COMPILER_IN_USE |
42 _LIT8(KLogComponent, "USBSVR"); |
42 #include "CUsbSessionTraces.h" |
43 #endif |
43 #endif |
|
44 |
|
45 |
44 |
46 |
45 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
47 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
46 CUsbSession* CUsbSession::iCtlSession = NULL; |
48 CUsbSession* CUsbSession::iCtlSession = NULL; |
47 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
49 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
48 |
50 |
73 * @param aServer Service the session will be a member of |
75 * @param aServer Service the session will be a member of |
74 */ |
76 */ |
75 CUsbSession::CUsbSession(CUsbServer* aServer) |
77 CUsbSession::CUsbSession(CUsbServer* aServer) |
76 : iUsbServer(aServer) |
78 : iUsbServer(aServer) |
77 { |
79 { |
78 LOG_FUNC |
80 OstTraceFunctionEntry0( CUSBSESSION_CUSBSESSION_CONS_ENTRY ); |
79 |
81 |
80 iUsbServer->IncrementSessionCount(); |
82 iUsbServer->IncrementSessionCount(); |
|
83 OstTraceFunctionExit0( CUSBSESSION_CUSBSESSION_CONS_EXIT ); |
81 } |
84 } |
82 |
85 |
83 |
86 |
84 /** |
87 /** |
85 * Destructor. |
88 * Destructor. |
86 */ |
89 */ |
87 CUsbSession::~CUsbSession() |
90 CUsbSession::~CUsbSession() |
88 { |
91 { |
89 LOG_FUNC |
92 OstTraceFunctionEntry0( CUSBSESSION_CUSBSESSION_DES_ENTRY ); |
90 |
93 |
91 LOGTEXT2(_L8("About to Device().DeRegisterObserver(%08x"),this); |
94 OstTrace1( TRACE_NORMAL, CUSBSESSION_CUSBSESSION, "CUsbSession::~CUsbSession;About to Device().DeRegisterObserver(%08x)", this ); |
92 iUsbServer->Device().DeRegisterObserver(*this); |
95 iUsbServer->Device().DeRegisterObserver(*this); |
93 |
96 |
94 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
97 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
95 #ifndef __OVER_DUMMYUSBDI__ |
98 #ifndef __OVER_DUMMYUSBDI__ |
96 LOGTEXT2(_L8("About to Otg().DeRegisterObserver(%08x"),this); |
99 OstTrace1( TRACE_NORMAL, CUSBSESSION_CUSBSESSION_DUP1, "CUsbSession::~CUsbSession;About to Otg().DeRegisterObserver(%08x)", this ); |
97 iUsbServer->Otg().DeRegisterObserver(*this); |
100 iUsbServer->Otg().DeRegisterObserver(*this); |
98 #endif |
101 #endif |
99 |
102 |
100 LOGTEXT2(_L8("About to Host().DeRegisterObserver(%08x"),this); |
103 OstTrace1( TRACE_NORMAL, CUSBSESSION_CUSBSESSION_DUP2, "CUsbSession::~CUsbSession;About to Host().DeRegisterObserver(%08x)", this ); |
101 iUsbServer->Host().DeregisterObserver(*this); |
104 iUsbServer->Host().DeregisterObserver(*this); |
102 |
105 |
103 if ( iCtlSession && (iCtlSession == this) ) |
106 if ( iCtlSession && (iCtlSession == this) ) |
104 { |
107 { |
105 iCtlSession = NULL; |
108 iCtlSession = NULL; |
106 } |
109 } |
107 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
110 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
108 |
111 |
109 LOGTEXT(_L8("About to iUsbServer->DecrementSessionCount()")); |
112 OstTrace0( TRACE_NORMAL, CUSBSESSION_CUSBSESSION_DUP3, "CUsbSession::~CUsbSession;About to iUsbServer->DecrementSessionCount()" ); |
110 iUsbServer->DecrementSessionCount(); |
113 iUsbServer->DecrementSessionCount(); |
|
114 OstTraceFunctionExit0( CUSBSESSION_CUSBSESSION_DES_EXIT ); |
111 } |
115 } |
112 |
116 |
113 |
117 |
114 /** |
118 /** |
115 * Called when a message is received from the client. |
119 * Called when a message is received from the client. |
116 * |
120 * |
117 * @param aMessage Message received from the client |
121 * @param aMessage Message received from the client |
118 */ |
122 */ |
119 void CUsbSession::ServiceL(const RMessage2& aMessage) |
123 void CUsbSession::ServiceL(const RMessage2& aMessage) |
120 { |
124 { |
121 LOG_FUNC |
125 OstTraceFunctionEntry0( CUSBSESSION_SERVICEL_ENTRY ); |
122 |
126 |
123 DispatchMessageL(aMessage); |
127 DispatchMessageL(aMessage); |
|
128 OstTraceFunctionExit0( CUSBSESSION_SERVICEL_EXIT ); |
124 } |
129 } |
125 |
130 |
126 /** |
131 /** |
127 * Handles 2nd Phase Construction. Implementation of the virtual method defined in CSession2 and called from |
132 * Handles 2nd Phase Construction. Implementation of the virtual method defined in CSession2 and called from |
128 * CServer2::DoConnectL() which executes when the client makes a connection request through CServer2::Connect(). If |
133 * CServer2::DoConnectL() which executes when the client makes a connection request through CServer2::Connect(). If |
129 * a Leave occurs at any point the CUsbSession object is cleaned up in CServer2::DoConnect(). |
134 * a Leave occurs at any point the CUsbSession object is cleaned up in CServer2::DoConnect(). |
130 */ |
135 */ |
131 void CUsbSession::CreateL() |
136 void CUsbSession::CreateL() |
132 { |
137 { |
133 LOG_FUNC |
138 OstTraceFunctionEntry0( CUSBSESSION_CREATEL_ENTRY ); |
134 |
139 |
135 // This code originally existed in the typical non-virtual ConstructL() method. |
140 // This code originally existed in the typical non-virtual ConstructL() method. |
136 // However it was moved to this method for minor optimisation reasons [three less |
141 // However it was moved to this method for minor optimisation reasons [three less |
137 // function calls and several lines less code in the NewL() method]. |
142 // function calls and several lines less code in the NewL() method]. |
138 |
143 |
139 iPersonalityCfged = iUsbServer->Device().isPersonalityCfged(); |
144 iPersonalityCfged = iUsbServer->Device().isPersonalityCfged(); |
140 |
145 |
141 LOGTEXT(_L8("Registering Device Observer\n")); |
146 OstTrace0( TRACE_NORMAL, CUSBSESSION_CREATEL, "CUsbSession::CreateL;Registering Device Observer" ); |
142 iUsbServer->Device().RegisterObserverL(*this); |
147 iUsbServer->Device().RegisterObserverL(*this); |
143 |
148 |
144 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
149 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
145 #ifndef __OVER_DUMMYUSBDI__ |
150 #ifndef __OVER_DUMMYUSBDI__ |
146 LOGTEXT(_L8("Registering OTG Observer\n")); |
151 OstTrace0( TRACE_NORMAL, CUSBSESSION_CREATEL_DUP1, "CUsbSession::CreateL;Registering OTG Observer" ); |
147 iUsbServer->Otg().RegisterObserverL(*this); |
152 iUsbServer->Otg().RegisterObserverL(*this); |
148 #endif |
153 #endif |
149 |
154 |
150 LOGTEXT(_L8("Registering HOST Observer\n")); |
155 OstTrace0( TRACE_NORMAL, CUSBSESSION_CREATEL_DUP2, "CUsbSession::CreateL;Registering HOST Observer" ); |
151 iUsbServer->Host().RegisterObserverL(*this); |
156 iUsbServer->Host().RegisterObserverL(*this); |
152 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
157 #endif // SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
|
158 OstTraceFunctionExit0( CUSBSESSION_CREATEL_EXIT ); |
153 } |
159 } |
154 |
160 |
155 /** |
161 /** |
156 * Called by CUsbDevice when the service state changes. |
162 * Called by CUsbDevice when the service state changes. |
157 * CUsbSession is an observer of the device. |
163 * CUsbSession is an observer of the device. |
161 * @param aNewState The device's new and current service state |
167 * @param aNewState The device's new and current service state |
162 */ |
168 */ |
163 void CUsbSession::UsbServiceStateChange(TInt aLastError, TUsbServiceState aOldState, |
169 void CUsbSession::UsbServiceStateChange(TInt aLastError, TUsbServiceState aOldState, |
164 TUsbServiceState aNewState) |
170 TUsbServiceState aNewState) |
165 { |
171 { |
166 LOG_FUNC |
172 OstTraceFunctionEntry0( CUSBSESSION_USBSERVICESTATECHANGE_ENTRY ); |
167 LOGTEXT3(_L8(" aOldState=0x%X, aNewState=0x%X"), aOldState, aNewState); |
173 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBSERVICESTATECHANGE, "CUsbSession::UsbServiceStateChange;aOldState=0x%X, aNewState=0x%X", aOldState, aNewState ); |
168 (void) aOldState; // a-void build warning in UREL |
174 (void) aOldState; // a-void build warning in UREL |
169 |
175 |
170 // Note that it's possible to have both a start and a stop outstanding! |
176 // Note that it's possible to have both a start and a stop outstanding! |
171 |
177 |
172 if (iStartOutstanding) |
178 if (iStartOutstanding) |
197 * @param aNewState The state we've moved to |
204 * @param aNewState The state we've moved to |
198 */ |
205 */ |
199 void CUsbSession::HandleServiceStateChangeWhileStarting(TInt aLastError, |
206 void CUsbSession::HandleServiceStateChangeWhileStarting(TInt aLastError, |
200 TUsbServiceState aNewState) |
207 TUsbServiceState aNewState) |
201 { |
208 { |
202 LOG_FUNC |
209 OstTraceFunctionEntry0( CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING_ENTRY ); |
203 |
210 |
204 switch (aNewState) |
211 switch (aNewState) |
205 { |
212 { |
206 case EUsbServiceStarted: |
213 case EUsbServiceStarted: |
207 LOGTEXT(_L8(" Completing Start successfully")); |
214 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING, "CUsbSession::HandleServiceStateChangeWhileStarting Completing Start successfully" ); |
208 |
215 |
209 // If the user has tried to cancel the start, they're too late! |
216 // If the user has tried to cancel the start, they're too late! |
210 if (iCancelOutstanding) |
217 if (iCancelOutstanding) |
211 { |
218 { |
212 LOGTEXT(_L8(" Completing cancel request with KErrNone")); |
219 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING_DUP1, "CUsbSession::HandleServiceStateChangeWhileStarting Completing cancel request with KErrNone" ); |
213 iCancelOutstanding = EFalse; |
220 iCancelOutstanding = EFalse; |
214 iCancelMessage.Complete(KErrNone); |
221 iCancelMessage.Complete(KErrNone); |
215 } |
222 } |
216 |
223 |
217 iStartMessage.Complete(KErrNone); |
224 iStartMessage.Complete(KErrNone); |
218 iStartOutstanding = EFalse; |
225 iStartOutstanding = EFalse; |
219 break; |
226 break; |
220 |
227 |
221 case EUsbServiceIdle: |
228 case EUsbServiceIdle: |
222 LOGTEXT2(_L8(" Completing Start with error=%d"), aLastError); |
229 OstTrace1( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING_DUP2, "CUsbSession::HandleServiceStateChangeWhileStarting; Completing Start with error=%d", aLastError ); |
223 |
230 |
224 // If there hasn't actually been an error, but we're in an unexpected |
231 // If there hasn't actually been an error, but we're in an unexpected |
225 // state now, that means that this client cancelled the request, or |
232 // state now, that means that this client cancelled the request, or |
226 // another client stopped the service. |
233 // another client stopped the service. |
227 if (aLastError == KErrNone) |
234 if (aLastError == KErrNone) |
228 { |
235 { |
229 // If there's a cancel outstanding, then that message succeeded, but |
236 // If there's a cancel outstanding, then that message succeeded, but |
230 // the start message should be completed with KErrCancel. |
237 // the start message should be completed with KErrCancel. |
231 if (iCancelOutstanding) |
238 if (iCancelOutstanding) |
232 { |
239 { |
233 LOGTEXT(_L8(" Completing original message with KErrCancel")); |
240 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTARTING_DUP3, "CUsbSession::HandleServiceStateChangeWhileStarting Completing original message with KErrCancel" ); |
234 iCancelOutstanding = EFalse; |
241 iCancelOutstanding = EFalse; |
235 iCancelMessage.Complete(KErrNone); |
242 iCancelMessage.Complete(KErrNone); |
236 iStartMessage.Complete(KErrCancel); |
243 iStartMessage.Complete(KErrCancel); |
237 } |
244 } |
238 else |
245 else |
267 * @param aNewState The state we've moved to |
275 * @param aNewState The state we've moved to |
268 */ |
276 */ |
269 void CUsbSession::HandleServiceStateChangeWhileStopping(TInt aLastError, |
277 void CUsbSession::HandleServiceStateChangeWhileStopping(TInt aLastError, |
270 TUsbServiceState aNewState) |
278 TUsbServiceState aNewState) |
271 { |
279 { |
272 LOG_FUNC |
280 OstTraceFunctionEntry0( CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING_ENTRY ); |
273 |
281 |
274 switch (aNewState) |
282 switch (aNewState) |
275 { |
283 { |
276 case EUsbServiceStarted: |
284 case EUsbServiceStarted: |
277 LOGTEXT2(_L8(" Completing Stop with error=%d"), aLastError); |
285 OstTrace1( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING, "CUsbSession::HandleServiceStateChangeWhileStopping; Completing Stop with error=%d", aLastError ); |
278 |
286 |
279 // If there hasn't actually been an error, but we're in an unexpected |
287 // If there hasn't actually been an error, but we're in an unexpected |
280 // state now, that means that this client cancelled the request, or |
288 // state now, that means that this client cancelled the request, or |
281 // another client has started the service. |
289 // another client has started the service. |
282 if (aLastError == KErrNone) |
290 if (aLastError == KErrNone) |
283 { |
291 { |
284 // If there's a cancel outstanding, then that message succeeded, but |
292 // If there's a cancel outstanding, then that message succeeded, but |
285 // the stop message should be completed with KErrCancel. |
293 // the stop message should be completed with KErrCancel. |
286 if (iCancelOutstanding) |
294 if (iCancelOutstanding) |
287 { |
295 { |
288 LOGTEXT(_L8(" Completing original message with KErrCancel")); |
296 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING_DUP1, "CUsbSession::HandleServiceStateChangeWhileStopping; Completing original message with KErrCancel" ); |
289 iCancelOutstanding = EFalse; |
297 iCancelOutstanding = EFalse; |
290 iCancelMessage.Complete(KErrNone); |
298 iCancelMessage.Complete(KErrNone); |
291 iStopMessage.Complete(KErrCancel); |
299 iStopMessage.Complete(KErrCancel); |
292 } |
300 } |
293 else |
301 else |
309 |
317 |
310 iStopOutstanding = EFalse; |
318 iStopOutstanding = EFalse; |
311 break; |
319 break; |
312 |
320 |
313 case EUsbServiceIdle: |
321 case EUsbServiceIdle: |
314 LOGTEXT(_L8(" Completing Stop with KErrNone")); |
322 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING_DUP2, "CUsbSession::HandleServiceStateChangeWhileStopping Completing Stop with KErrNone" ); |
315 |
323 |
316 // If the user has tried to cancel the stop, they're too late! |
324 // If the user has tried to cancel the stop, they're too late! |
317 if (iCancelOutstanding) |
325 if (iCancelOutstanding) |
318 { |
326 { |
319 LOGTEXT(_L8(" Completing cancel request with KErrNone")); |
327 OstTrace0( TRACE_NORMAL, CUSBSESSION_HANDLESERVICESTATECHANGEWHILESTOPPING_DUP3, "CUsbSession::HandleServiceStateChangeWhileStopping Completing cancel request with KErrNone" ); |
320 iCancelOutstanding = EFalse; |
328 iCancelOutstanding = EFalse; |
321 iCancelMessage.Complete(KErrNone); |
329 iCancelMessage.Complete(KErrNone); |
322 } |
330 } |
323 |
331 |
324 iStopMessage.Complete(KErrNone); |
332 iStopMessage.Complete(KErrNone); |
403 if (addToQueue) |
411 if (addToQueue) |
404 { |
412 { |
405 // add event to head of queue |
413 // add event to head of queue |
406 iDeviceStateQueue[iDevStateQueueHead] = aNewState; |
414 iDeviceStateQueue[iDevStateQueueHead] = aNewState; |
407 iDevStateQueueHead = (iDevStateQueueHead + 1) % KDeviceStatesQueueSize; |
415 iDevStateQueueHead = (iDevStateQueueHead + 1) % KDeviceStatesQueueSize; |
408 LOGTEXT3(_L8("+++ addqueue (%d, %d)"), iDevStateQueueHead, |
416 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBDEVICESTATECHANGE_DUP1, "CUsbSession::UsbDeviceStateChange;+++ addqueue (%d, %d)", iDevStateQueueHead, iDevStateQueueTail ); |
409 iDevStateQueueTail); |
|
410 } |
417 } |
411 |
418 |
412 // UsbDeviceDequeueEvent() will read from queue when RegisterObserver() |
419 // UsbDeviceDequeueEvent() will read from queue when RegisterObserver() |
413 // is next called. |
420 // is next called. |
414 } |
421 } |
|
422 OstTraceFunctionExit0( CUSBSESSION_USBDEVICESTATECHANGE_EXIT ); |
415 } |
423 } |
416 |
424 |
417 /** |
425 /** |
418 * Dequeues an event and completes the observer's request with it. |
426 * Dequeues an event and completes the observer's request with it. |
419 */ |
427 */ |
420 void CUsbSession::UsbDeviceDequeueEvent() |
428 void CUsbSession::UsbDeviceDequeueEvent() |
421 { |
429 { |
422 LOG_FUNC |
430 OstTraceFunctionEntry0( CUSBSESSION_USBDEVICEDEQUEUEEVENT_ENTRY ); |
423 |
431 |
424 // Work our way through the queue, until we reach the end |
432 // Work our way through the queue, until we reach the end |
425 // OR we find an event the current observer wants. |
433 // OR we find an event the current observer wants. |
426 while ((iDeviceObserverOutstanding) && (iDevStateQueueHead != iDevStateQueueTail)) |
434 while ((iDeviceObserverOutstanding) && (iDevStateQueueHead != iDevStateQueueTail)) |
427 { |
435 { |
438 { |
446 { |
439 TPckg<TUint32> pckg(newState); |
447 TPckg<TUint32> pckg(newState); |
440 |
448 |
441 iNotifiedDevState = newState; |
449 iNotifiedDevState = newState; |
442 |
450 |
443 LOGTEXT3(_L8(">>> dequeued event #%d (0x%x)"), iDevStateQueueTail, newState); |
451 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBDEVICEDEQUEUEEVENT, "CUsbSession::UsbDeviceDequeueEvent;dequeued event #%d (0x%x)", iDevStateQueueTail, newState ); |
444 |
452 |
445 iDeviceObserverOutstanding = EFalse; |
453 iDeviceObserverOutstanding = EFalse; |
446 const TInt err = iDeviceObserverMessage.Write(1, pckg); |
454 const TInt err = iDeviceObserverMessage.Write(1, pckg); |
447 iDeviceObserverMessage.Complete(err); |
455 iDeviceObserverMessage.Complete(err); |
448 break; |
456 break; |
449 } |
457 } |
450 } |
458 } |
|
459 OstTraceFunctionExit0( CUSBSESSION_USBDEVICEDEQUEUEEVENT_EXIT ); |
451 } |
460 } |
452 |
461 |
453 /** |
462 /** |
454 * Handles the request (in the form of a the message) received from the client |
463 * Handles the request (in the form of a the message) received from the client |
455 * |
464 * |
456 * @internalComponent |
465 * @internalComponent |
457 * @param aMessage The received message |
466 * @param aMessage The received message |
458 */ |
467 */ |
459 void CUsbSession::DispatchMessageL(const RMessage2& aMessage) |
468 void CUsbSession::DispatchMessageL(const RMessage2& aMessage) |
460 { |
469 { |
461 LOG_FUNC |
470 OstTraceFunctionEntry0( CUSBSESSION_DISPATCHMESSAGEL_ENTRY ); |
462 |
471 |
463 TBool complete = ETrue; |
472 TBool complete = ETrue; |
464 TInt ret = KErrNone; |
473 TInt ret = KErrNone; |
465 |
474 |
466 LOGTEXT2(_L8("CUsbSession::DispatchMessageL(): func# %d"), aMessage.Function()); |
475 OstTrace1( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL, "CUsbSession::DispatchMessageL;func#=%d", aMessage.Function() ); |
467 |
476 |
468 switch (aMessage.Function()) |
477 switch (aMessage.Function()) |
469 { |
478 { |
470 case EUsbStart: |
479 case EUsbStart: |
471 ret = StartDeviceL(aMessage, complete); |
480 ret = StartDeviceL(aMessage, complete); |
530 |
536 |
531 #ifdef _DEBUG |
537 #ifdef _DEBUG |
532 // Heap failure debug APIs. |
538 // Heap failure debug APIs. |
533 |
539 |
534 case EUsbDbgMarkHeap: |
540 case EUsbDbgMarkHeap: |
535 LOGTEXT(_L8("Marking heap")); |
541 OstTrace0( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP1, "CUsbSession::DispatchMessageL;Marking heap" ); |
536 __UHEAP_MARK; |
542 __UHEAP_MARK; |
537 break; |
543 break; |
538 case EUsbDbgCheckHeap: |
544 case EUsbDbgCheckHeap: |
539 LOGTEXT2(_L8("Checking heap (expecting %d cells)"), aMessage.Int0()); |
545 OstTrace1( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP2, "CUsbSession::DispatchMessageL;Checking heap (expecting %d cells)", aMessage.Int0() ); |
540 __UHEAP_CHECK(aMessage.Int0()); |
546 __UHEAP_CHECK(aMessage.Int0()); |
541 break; |
547 break; |
542 case EUsbDbgMarkEnd: |
548 case EUsbDbgMarkEnd: |
543 LOGTEXT2(_L8("End of marking heap (expecting %d cells)"), aMessage.Int0()); |
549 OstTrace1( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP3, "CUsbSession::DispatchMessageL;End of marking heap (expecting %d cells)", aMessage.Int0() ); |
544 __UHEAP_MARKENDC(aMessage.Int0()); |
550 __UHEAP_MARKENDC(aMessage.Int0()); |
545 break; |
551 break; |
546 case EUsbDbgFailNext: |
552 case EUsbDbgFailNext: |
547 { |
553 { |
548 LOGTEXT2(_L8("Simulating failure after %d allocation(s)"), aMessage.Int0()); |
554 OstTrace1( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP4, "CUsbSession::DispatchMessageL;Simulating failure after %d allocation(s)", aMessage.Int0() ); |
549 if (aMessage.Int0() == 0) |
555 if (aMessage.Int0() == 0) |
550 __UHEAP_RESET; |
556 __UHEAP_RESET; |
551 else |
557 else |
552 __UHEAP_FAILNEXT(aMessage.Int0()); |
558 __UHEAP_FAILNEXT(aMessage.Int0()); |
553 } |
559 } |
554 break; |
560 break; |
555 case EUsbDbgAlloc: |
561 case EUsbDbgAlloc: |
556 { |
562 { |
557 ret = KErrNone; |
563 ret = KErrNone; |
558 #ifdef _DEBUG |
564 #ifdef _DEBUG |
559 LOGTEXT(_L8("\tallocate on the heap")); |
565 OstTrace0( TRACE_NORMAL, CUSBSESSION_DISPATCHMESSAGEL_DUP5, "CUsbSession::DispatchMessageL;allocate on the heap" ); |
560 TInt* x = NULL; |
566 TInt* x = NULL; |
561 TRAP(ret, x = new(ELeave) TInt); |
567 TRAP(ret, x = new(ELeave) TInt); |
562 delete x; |
568 delete x; |
563 #endif // _DEBUG |
569 #endif // _DEBUG |
564 } |
570 } |
727 * @param aComplete Whether the request is complete or not |
737 * @param aComplete Whether the request is complete or not |
728 * @return Any error that occurred or KErrNone |
738 * @return Any error that occurred or KErrNone |
729 */ |
739 */ |
730 TInt CUsbSession::StopDeviceL(const RMessage2& aMessage, TBool& aComplete) |
740 TInt CUsbSession::StopDeviceL(const RMessage2& aMessage, TBool& aComplete) |
731 { |
741 { |
732 LOG_FUNC |
742 OstTraceFunctionEntry0( CUSBSESSION_STOPDEVICEL_ENTRY ); |
733 |
743 |
734 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
744 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
735 // Only 'control' session is allowed to stop USB support |
745 // Only 'control' session is allowed to stop USB support |
736 if ( !iSessionCtlMode ) |
746 if ( !iSessionCtlMode ) |
737 { |
747 { |
|
748 OstTraceFunctionExit0( CUSBSESSION_STOPDEVICEL_EXIT ); |
738 return KErrAccessDenied; |
749 return KErrAccessDenied; |
739 } |
750 } |
740 #endif |
751 #endif |
741 |
752 |
742 if (iStopOutstanding) |
753 if (iStopOutstanding) |
743 { |
754 { |
|
755 OstTraceFunctionExit0( CUSBSESSION_STOPDEVICEL_EXIT_DUP1 ); |
744 return KErrInUse; |
756 return KErrInUse; |
745 } |
757 } |
746 |
758 |
747 #ifndef __OVER_DUMMYUSBDI__ |
759 #ifndef __OVER_DUMMYUSBDI__ |
748 |
760 |
823 * @param aComplete Whether the message is complete or not |
839 * @param aComplete Whether the message is complete or not |
824 * @return KErrNone on success, otherwise standard error codes |
840 * @return KErrNone on success, otherwise standard error codes |
825 */ |
841 */ |
826 TInt CUsbSession::StopCancel(const RMessage2& aMessage, TBool& aComplete) |
842 TInt CUsbSession::StopCancel(const RMessage2& aMessage, TBool& aComplete) |
827 { |
843 { |
828 LOG_FUNC |
844 OstTraceFunctionEntry0( CUSBSESSION_STOPCANCEL_ENTRY ); |
829 |
|
830 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
845 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
831 // Only 'control' session is allowed to cancel outstaning stop request |
846 // Only 'control' session is allowed to cancel outstaning stop request |
832 if ( !iSessionCtlMode ) |
847 if ( !iSessionCtlMode ) |
833 { |
848 { |
|
849 OstTraceFunctionExit0( CUSBSESSION_STOPCANCEL_EXIT ); |
834 return KErrAccessDenied; |
850 return KErrAccessDenied; |
835 } |
851 } |
836 #endif |
852 #endif |
837 |
853 |
838 if (!iStopOutstanding) |
854 if (!iStopOutstanding) |
839 { |
855 { |
|
856 OstTraceFunctionExit0( CUSBSESSION_STOPCANCEL_EXIT_DUP1 ); |
840 return KErrNone; |
857 return KErrNone; |
841 } |
858 } |
842 |
859 |
843 aComplete = EFalse; |
860 aComplete = EFalse; |
844 iCancelMessage = aMessage; |
861 iCancelMessage = aMessage; |
878 |
897 |
879 if (iObserverQueueEvents == EFalse) |
898 if (iObserverQueueEvents == EFalse) |
880 { |
899 { |
881 // This is the first observer after c'tor or DeregisterObserver(), |
900 // This is the first observer after c'tor or DeregisterObserver(), |
882 // so zap the device event queue. |
901 // so zap the device event queue. |
883 LOGTEXT(_L8(" Reset Device Event Queue")); |
902 OstTrace0( TRACE_NORMAL, CUSBSESSION_REGISTERDEVICEOBSERVER, "CUsbSession::RegisterDeviceObserver Reset Device Event Queue" ); |
884 iDevStateQueueHead = 0; |
903 iDevStateQueueHead = 0; |
885 iDevStateQueueTail = 0; |
904 iDevStateQueueTail = 0; |
886 iObserverQueueEvents = ETrue; |
905 iObserverQueueEvents = ETrue; |
887 } |
906 } |
888 else if (iDevStateQueueHead != iDevStateQueueTail) |
907 else if (iDevStateQueueHead != iDevStateQueueTail) |
889 { |
908 { |
890 // event(s) queued, we can de-queue one now |
909 // event(s) queued, we can de-queue one now |
891 UsbDeviceDequeueEvent(); |
910 UsbDeviceDequeueEvent(); |
892 } |
911 } |
893 |
912 |
|
913 OstTraceFunctionExit0( CUSBSESSION_REGISTERDEVICEOBSERVER_EXIT_DUP1 ); |
894 return KErrNone; |
914 return KErrNone; |
895 } |
915 } |
896 |
916 |
897 /** |
917 /** |
898 * Client request to observe the service (for state changes) |
918 * Client request to observe the service (for state changes) |
1013 * @param aComplete set to true to complete the request |
1039 * @param aComplete set to true to complete the request |
1014 * @return Any error that occurred or KErrNone |
1040 * @return Any error that occurred or KErrNone |
1015 */ |
1041 */ |
1016 TInt CUsbSession::TryStartDeviceL(const RMessage2& aMessage, TBool& aComplete) |
1042 TInt CUsbSession::TryStartDeviceL(const RMessage2& aMessage, TBool& aComplete) |
1017 { |
1043 { |
1018 LOG_FUNC |
1044 OstTraceFunctionEntry0( CUSBSESSION_TRYSTARTDEVICEL_ENTRY ); |
1019 |
1045 |
1020 #ifndef __OVER_DUMMYUSBDI__ |
1046 #ifndef __OVER_DUMMYUSBDI__ |
1021 |
1047 |
1022 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1048 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1023 // Only 'control' session is allowed to start USB support |
1049 // Only 'control' session is allowed to start USB support |
1024 if ( !iSessionCtlMode ) |
1050 if ( !iSessionCtlMode ) |
1025 { |
1051 { |
|
1052 OstTraceFunctionExit0( CUSBSESSION_TRYSTARTDEVICEL_EXIT ); |
1026 return KErrAccessDenied; |
1053 return KErrAccessDenied; |
1027 } |
1054 } |
1028 #endif |
1055 #endif |
1029 |
1056 |
1030 if (!iPersonalityCfged) |
1057 if (!iPersonalityCfged) |
1031 { |
1058 { |
|
1059 OstTraceFunctionExit0( CUSBSESSION_TRYSTARTDEVICEL_EXIT_DUP1 ); |
1032 return KErrNotSupported; |
1060 return KErrNotSupported; |
1033 } |
1061 } |
1034 |
1062 |
1035 if (iStartOutstanding || iStopOutstanding) |
1063 if (iStartOutstanding || iStopOutstanding) |
1036 { |
1064 { |
|
1065 OstTraceFunctionExit0( CUSBSESSION_TRYSTARTDEVICEL_EXIT_DUP2 ); |
1037 return KErrServerBusy; |
1066 return KErrServerBusy; |
1038 } |
1067 } |
1039 |
1068 |
1040 // Obtains the curent service state |
1069 // Obtains the curent service state |
1041 TUsbServiceState state = iUsbServer->Device().ServiceState(); |
1070 TUsbServiceState state = iUsbServer->Device().ServiceState(); |
1107 * @param aComplete Whether the request is complete or not |
1140 * @param aComplete Whether the request is complete or not |
1108 * @return Any error that occurred or KErrNone |
1141 * @return Any error that occurred or KErrNone |
1109 */ |
1142 */ |
1110 TInt CUsbSession::TryStopDeviceL(const RMessage2& aMessage, TBool& aComplete) |
1143 TInt CUsbSession::TryStopDeviceL(const RMessage2& aMessage, TBool& aComplete) |
1111 { |
1144 { |
1112 LOG_FUNC |
1145 OstTraceFunctionEntry0( CUSBSESSION_TRYSTOPDEVICEL_ENTRY ); |
1113 |
1146 |
1114 #ifndef __OVER_DUMMYUSBDI__ |
1147 #ifndef __OVER_DUMMYUSBDI__ |
1115 |
1148 |
1116 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1149 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1117 // Only 'control' session is allowed to stop USB support |
1150 // Only 'control' session is allowed to stop USB support |
1118 if ( !iSessionCtlMode ) |
1151 if ( !iSessionCtlMode ) |
1119 { |
1152 { |
|
1153 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT ); |
1120 return KErrAccessDenied; |
1154 return KErrAccessDenied; |
1121 } |
1155 } |
1122 #endif |
1156 #endif |
1123 |
1157 |
1124 if (!iPersonalityCfged) |
1158 if (!iPersonalityCfged) |
1125 { |
1159 { |
|
1160 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP1 ); |
1126 return KErrNotSupported; |
1161 return KErrNotSupported; |
1127 } |
1162 } |
1128 |
1163 |
1129 if (iStartOutstanding || iStopOutstanding) |
1164 if (iStartOutstanding || iStopOutstanding) |
1130 { |
1165 { |
|
1166 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP2 ); |
1131 return KErrServerBusy; |
1167 return KErrServerBusy; |
1132 } |
1168 } |
1133 |
1169 |
1134 // Obtains the curent service state |
1170 // Obtains the curent service state |
1135 TUsbServiceState state = iUsbServer->Device().ServiceState(); |
1171 TUsbServiceState state = iUsbServer->Device().ServiceState(); |
1155 iStopMessage = aMessage; |
1191 iStopMessage = aMessage; |
1156 iStopOutstanding = ETrue; |
1192 iStopOutstanding = ETrue; |
1157 } |
1193 } |
1158 else if (state == EUsbServiceStarting) |
1194 else if (state == EUsbServiceStarting) |
1159 { |
1195 { |
|
1196 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP3 ); |
1160 return KErrServerBusy; |
1197 return KErrServerBusy; |
1161 } |
1198 } |
1162 else if (state == EUsbServiceStopping) |
1199 else if (state == EUsbServiceStopping) |
1163 { |
1200 { |
1164 aComplete = EFalse; |
1201 aComplete = EFalse; |
1165 iStopMessage = aMessage; |
1202 iStopMessage = aMessage; |
1166 iStopOutstanding = ETrue; |
1203 iStopOutstanding = ETrue; |
1167 } |
1204 } |
1168 |
1205 |
|
1206 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP4 ); |
1169 return KErrNone; |
1207 return KErrNone; |
1170 |
1208 |
1171 #else |
1209 #else |
1172 // pretend that the server is in Started state |
1210 // pretend that the server is in Started state |
1173 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1211 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1174 iUsbServer->Host().Stop(); |
1212 iUsbServer->Host().Stop(); |
1175 #endif |
1213 #endif |
1176 aMessage.IsNull(); |
1214 aMessage.IsNull(); |
1177 aComplete = ETrue; |
1215 aComplete = ETrue; |
1178 iStopOutstanding = EFalse; |
1216 iStopOutstanding = EFalse; |
|
1217 OstTraceFunctionExit0( CUSBSESSION_TRYSTOPDEVICEL_EXIT_DUP5 ); |
1179 return KErrNone; |
1218 return KErrNone; |
1180 #endif |
1219 #endif |
1181 } |
1220 } |
1182 |
1221 |
1183 /** |
1222 /** |
1225 * @param aMessage Message received from the client |
1266 * @param aMessage Message received from the client |
1226 * @return Any error that occurred or KErrNone |
1267 * @return Any error that occurred or KErrNone |
1227 */ |
1268 */ |
1228 TInt CUsbSession::GetCurrentPersonalityId(const RMessage2& aMessage) |
1269 TInt CUsbSession::GetCurrentPersonalityId(const RMessage2& aMessage) |
1229 { |
1270 { |
1230 LOG_FUNC |
1271 OstTraceFunctionEntry0( CUSBSESSION_GETCURRENTPERSONALITYID_ENTRY ); |
1231 |
1272 |
1232 if (!iPersonalityCfged) |
1273 if (!iPersonalityCfged) |
1233 { |
1274 { |
|
1275 OstTraceFunctionExit0( CUSBSESSION_GETCURRENTPERSONALITYID_EXIT ); |
1234 return KErrNotSupported; |
1276 return KErrNotSupported; |
1235 } |
1277 } |
1236 |
1278 |
1237 TInt currentPersonalityId = iUsbServer->Device().CurrentPersonalityId(); |
1279 TInt currentPersonalityId = iUsbServer->Device().CurrentPersonalityId(); |
1238 LOGTEXT2(_L8("\tcurrentPersonalityId = %d"), currentPersonalityId); |
1280 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETCURRENTPERSONALITYID, "CUsbSession::GetCurrentPersonalityId;currentPersonalityId=%d", currentPersonalityId ); |
1239 TPckgC<TInt> pckg(currentPersonalityId); |
1281 TPckgC<TInt> pckg(currentPersonalityId); |
1240 return aMessage.Write(0, pckg); |
1282 return aMessage.Write(0, pckg); |
1241 } |
1283 } |
1242 |
1284 |
1243 /** |
1285 /** |
1264 // Gets all class uids for the given personality |
1307 // Gets all class uids for the given personality |
1265 const RPointerArray<CPersonality>& personalities = iUsbServer->Device().Personalities(); |
1308 const RPointerArray<CPersonality>& personalities = iUsbServer->Device().Personalities(); |
1266 TInt personalityCount = personalities.Count(); |
1309 TInt personalityCount = personalities.Count(); |
1267 for (TInt i = 0; i < personalityCount; i++) |
1310 for (TInt i = 0; i < personalityCount; i++) |
1268 { |
1311 { |
1269 __ASSERT_ALWAYS(personalities[i] != NULL, _USB_PANIC(KUsbSvrPncCat, ENullPersonalityPointer)); |
1312 if(personalities[i] == NULL) |
|
1313 { |
|
1314 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDCLASSES, "CUsbSession::GetSupportedClasses;ENullPersonalityPointer=%d", ENullPersonalityPointer ); |
|
1315 User::Panic(KUsbSvrPncCat, ENullPersonalityPointer); |
|
1316 } |
1270 if (aMessage.Int0() == personalities[i]->PersonalityId()) |
1317 if (aMessage.Int0() == personalities[i]->PersonalityId()) |
1271 { |
1318 { |
1272 classUids[0] = personalities[i]->SupportedClasses().Count(); |
1319 classUids[0] = personalities[i]->SupportedClasses().Count(); |
1273 for (TInt j = 1; j <= classUids[0]; j++) |
1320 for (TInt j = 1; j <= classUids[0]; j++) |
1274 { |
1321 { |
1275 if (j < KUsbMaxSupportedClasses + 1) |
1322 if (j < KUsbMaxSupportedClasses + 1) |
1276 { |
1323 { |
1277 classUids[j] = personalities[i]->SupportedClasses()[j - 1].iUid; |
1324 classUids[j] = personalities[i]->SupportedClasses()[j - 1].iClassUid.iUid; |
1278 LOGTEXT3(_L8("\tclassUids[%d] = %d"), j, classUids[j]); |
1325 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDCLASSES_DUP1, "CUsbSession::GetSupportedClasses;classUids[%d] = ", j ); |
|
1326 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDCLASSES_DUP2, "%d", classUids[j] ); |
1279 } |
1327 } |
1280 else |
1328 else |
1281 { |
1329 { |
|
1330 OstTraceFunctionExit0( CUSBSESSION_GETSUPPORTEDCLASSES_EXIT_DUP1 ); |
1282 return KErrTooBig; |
1331 return KErrTooBig; |
1283 } |
1332 } |
1284 } |
1333 } |
1285 break; |
1334 break; |
1286 } |
1335 } |
1287 } |
1336 } |
1288 |
1337 |
1289 if (classUids[0] == 0) |
1338 if (classUids[0] == 0) |
1290 { |
1339 { |
1291 // No supported classes are found |
1340 // No supported classes are found |
|
1341 OstTraceFunctionExit0( CUSBSESSION_GETSUPPORTEDCLASSES_EXIT_DUP2 ); |
1292 return KErrNotSupported; |
1342 return KErrNotSupported; |
1293 } |
1343 } |
1294 |
1344 |
1295 TInt ret; |
1345 TInt ret; |
1296 HBufC8* buf = NULL; |
1346 HBufC8* buf = NULL; |
1313 * @param aMessage Message received from the client |
1364 * @param aMessage Message received from the client |
1314 * @return Any error that occurred or KErrNone |
1365 * @return Any error that occurred or KErrNone |
1315 */ |
1366 */ |
1316 TInt CUsbSession::GetPersonalityIds(const RMessage2& aMessage) |
1367 TInt CUsbSession::GetPersonalityIds(const RMessage2& aMessage) |
1317 { |
1368 { |
1318 LOG_FUNC |
1369 OstTraceFunctionEntry0( CUSBSESSION_GETPERSONALITYIDS_ENTRY ); |
1319 |
1370 |
1320 if (!iPersonalityCfged) |
1371 if (!iPersonalityCfged) |
1321 { |
1372 { |
|
1373 OstTraceFunctionExit0( CUSBSESSION_GETPERSONALITYIDS_EXIT ); |
1322 return KErrNotSupported; |
1374 return KErrNotSupported; |
1323 } |
1375 } |
1324 |
1376 |
1325 // +1 for the size of actual personality id count |
1377 // +1 for the size of actual personality id count |
1326 TInt personalityIds[KUsbMaxSupportedPersonalities + 1]; |
1378 TInt personalityIds[KUsbMaxSupportedPersonalities + 1]; |
1327 |
1379 |
1328 const RPointerArray<CPersonality>& personalities = iUsbServer->Device().Personalities(); |
1380 const RPointerArray<CPersonality>& personalities = iUsbServer->Device().Personalities(); |
1329 TInt personalityCount = personalities.Count(); |
1381 TInt personalityCount = personalities.Count(); |
1330 for (TInt i = 0; i < personalityCount; ++i) |
1382 for (TInt i = 0; i < personalityCount; ++i) |
1331 { |
1383 { |
1332 __ASSERT_ALWAYS(personalities[i] != NULL, _USB_PANIC(KUsbSvrPncCat, ENullPersonalityPointer)); |
1384 if(personalities[i] == NULL) |
|
1385 { |
|
1386 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETPERSONALITYIDS, "CUsbSession::GetPersonalityIds;Panic reason=%d", ENullPersonalityPointer ); |
|
1387 User::Panic(KUsbSvrPncCat, ENullPersonalityPointer); |
|
1388 } |
1333 personalityIds[i + 1] = personalities[i]->PersonalityId(); |
1389 personalityIds[i + 1] = personalities[i]->PersonalityId(); |
1334 } |
1390 } |
1335 personalityIds[0] = personalityCount; |
1391 personalityIds[0] = personalityCount; |
1336 |
1392 |
1337 TInt ret; |
1393 TInt ret; |
1370 { |
1428 { |
1371 return aMessage.Write(1, *(personality->Description())); |
1429 return aMessage.Write(1, *(personality->Description())); |
1372 } |
1430 } |
1373 |
1431 |
1374 // We should never reach here |
1432 // We should never reach here |
|
1433 OstTraceFunctionExit0( CUSBSESSION_GETDESCRIPTION_EXIT_DUP1 ); |
1375 return KErrNotSupported; |
1434 return KErrNotSupported; |
1376 } |
1435 } |
1377 |
1436 |
1378 /** |
1437 |
1379 * Gets personality detailed description |
1438 /** |
|
1439 * Gets personality property |
1380 * |
1440 * |
1381 * @internalComponent |
1441 * @internalComponent |
1382 * @param aMessage Message received from the client |
1442 * @param aMessage Message received from the client |
1383 * @return Any error that occurred or KErrNone |
1443 * @return Any error that occurred or KErrNone |
1384 */ |
1444 */ |
1385 TInt CUsbSession::GetDetailedDescription(const RMessage2& aMessage) |
|
1386 { |
|
1387 LOG_FUNC |
|
1388 |
|
1389 if (!iPersonalityCfged) |
|
1390 { |
|
1391 return KErrNotSupported; |
|
1392 } |
|
1393 |
|
1394 TInt personalityId = aMessage.Int0(); |
|
1395 const CPersonality* personality = iUsbServer->Device().GetPersonality(personalityId); |
|
1396 if (personality) |
|
1397 { |
|
1398 if(personality->Version() < EUsbManagerResourceVersionTwo) |
|
1399 { |
|
1400 return KErrNotFound; |
|
1401 } |
|
1402 return aMessage.Write(1, *(personality->DetailedDescription())); |
|
1403 } |
|
1404 |
|
1405 // We should never reach here |
|
1406 return KErrNotSupported; |
|
1407 } |
|
1408 |
|
1409 /** |
|
1410 * Gets personality property |
|
1411 * |
|
1412 * @internalComponent |
|
1413 * @param aMessage Message received from the client |
|
1414 * @return Any error that occurred or KErrNone |
|
1415 */ |
|
1416 TInt CUsbSession::GetPersonalityProperty(const RMessage2& aMessage) |
1445 TInt CUsbSession::GetPersonalityProperty(const RMessage2& aMessage) |
1417 { |
1446 { |
1418 LOG_FUNC |
1447 OstTraceFunctionEntry0( CUSBSESSION_GETPERSONALITYPROPERTY_ENTRY ); |
1419 |
1448 |
1420 if (!iPersonalityCfged) |
1449 if (!iPersonalityCfged) |
1421 { |
1450 { |
|
1451 OstTraceFunctionExit0( CUSBSESSION_GETPERSONALITYPROPERTY_EXIT ); |
1422 return KErrNotSupported; |
1452 return KErrNotSupported; |
1423 } |
1453 } |
1424 |
1454 |
1425 TInt personalityId = aMessage.Int0(); |
1455 TInt personalityId = aMessage.Int0(); |
1426 const CPersonality* personality = iUsbServer->Device().GetPersonality(personalityId); |
1456 const CPersonality* personality = iUsbServer->Device().GetPersonality(personalityId); |
1427 if (personality) |
1457 if (personality) |
1428 { |
1458 { |
1429 if(personality->Version() < EUsbManagerResourceVersionThree) |
|
1430 { |
|
1431 return KErrNotFound; |
|
1432 } |
|
1433 TPckg<TUint32> pckg(personality->Property()); |
1459 TPckg<TUint32> pckg(personality->Property()); |
1434 return aMessage.Write(1, pckg); |
1460 return aMessage.Write(1, pckg); |
1435 } |
1461 } |
1436 |
1462 |
|
1463 OstTraceFunctionExit0( CUSBSESSION_GETPERSONALITYPROPERTY_EXIT_DUP2 ); |
1437 return KErrNotSupported; |
1464 return KErrNotSupported; |
1438 } |
1465 } |
1439 |
1466 |
1440 /** |
1467 /** |
1441 * Checks if a given class is supported by a personality. |
1468 * Checks if a given class is supported by a personality. |
1444 * @param aMessage Message received from the client |
1471 * @param aMessage Message received from the client |
1445 * @return Any error that occurred or KErrNone |
1472 * @return Any error that occurred or KErrNone |
1446 */ |
1473 */ |
1447 TInt CUsbSession::ClassSupported(const RMessage2& aMessage) |
1474 TInt CUsbSession::ClassSupported(const RMessage2& aMessage) |
1448 { |
1475 { |
1449 LOG_FUNC |
1476 OstTraceFunctionEntry0( CUSBSESSION_CLASSSUPPORTED_ENTRY ); |
1450 |
|
1451 if (!iPersonalityCfged) |
1477 if (!iPersonalityCfged) |
1452 { |
1478 { |
|
1479 OstTraceFunctionExit0( CUSBSESSION_CLASSSUPPORTED_EXIT ); |
1453 return KErrNotSupported; |
1480 return KErrNotSupported; |
1454 } |
1481 } |
1455 |
1482 |
1456 TBool isSupported = EFalse; |
1483 TBool isSupported = EFalse; |
1457 TInt personalityId = aMessage.Int0(); |
1484 TInt personalityId = aMessage.Int0(); |
1458 TUid classUid = TUid::Uid(aMessage.Int1()); |
1485 TUid classUid = TUid::Uid(aMessage.Int1()); |
1459 const CPersonality* personality = iUsbServer->Device().GetPersonality(personalityId); |
1486 const CPersonality* personality = iUsbServer->Device().GetPersonality(personalityId); |
1460 if (personality) |
1487 if (personality) |
1461 { |
1488 { |
1462 isSupported = (personality->ClassSupported(classUid) != KErrNotFound); |
1489 isSupported = personality->ClassSupported(classUid); |
1463 TPckg<TBool> pkg2(isSupported); |
1490 TPckg<TBool> pkg2(isSupported); |
1464 return aMessage.Write(2, pkg2); |
1491 return aMessage.Write(2, pkg2); |
1465 } |
1492 } |
1466 |
1493 |
1467 // We should never reach here |
1494 // We should never reach here |
|
1495 OstTraceFunctionExit0( CUSBSESSION_CLASSSUPPORTED_EXIT_DUP1 ); |
1468 return KErrNotSupported; |
1496 return KErrNotSupported; |
1469 } |
1497 } |
1470 |
1498 |
1471 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1499 #ifdef SYMBIAN_ENABLE_USB_OTG_HOST_PRIV |
1472 /** |
1500 /** |
1476 * @param aMessage Message received from the client |
1504 * @param aMessage Message received from the client |
1477 * @return Any error that occurred or KErrNone |
1505 * @return Any error that occurred or KErrNone |
1478 */ |
1506 */ |
1479 TInt CUsbSession::SetCtlSessionMode(const RMessage2& aMessage) |
1507 TInt CUsbSession::SetCtlSessionMode(const RMessage2& aMessage) |
1480 { |
1508 { |
1481 LOG_FUNC |
1509 OstTraceFunctionEntry0( CUSBSESSION_SETCTLSESSIONMODE_ENTRY ); |
1482 |
1510 |
1483 TInt ret = KErrNone; |
1511 TInt ret = KErrNone; |
1484 |
1512 |
1485 TBool value = (TBool)aMessage.Int0(); |
1513 TBool value = (TBool)aMessage.Int0(); |
1486 LOGTEXT2(_L8("\tSetting = %d"), static_cast<TInt>(value)); |
1514 OstTrace1( TRACE_NORMAL, CUSBSESSION_SETCTLSESSIONMODE, "CUsbSession::SetCtlSessionMode;Setting = %d", static_cast<TInt>(value) ); |
1487 |
1515 |
1488 // Verify if this is the same session which set the value before |
1516 // Verify if this is the same session which set the value before |
1489 if ( iCtlSession && (iCtlSession != this) ) |
1517 if ( iCtlSession && (iCtlSession != this) ) |
1490 { |
1518 { |
1491 ret = KErrAccessDenied; |
1519 ret = KErrAccessDenied; |
1676 * @param aMessage Message received from the client |
1712 * @param aMessage Message received from the client |
1677 * @return Any error that occurred or KErrNone |
1713 * @return Any error that occurred or KErrNone |
1678 */ |
1714 */ |
1679 TInt CUsbSession::GetSupportedLanguagesL(const RMessage2& aMessage) |
1715 TInt CUsbSession::GetSupportedLanguagesL(const RMessage2& aMessage) |
1680 { |
1716 { |
1681 LOG_FUNC |
1717 OstTraceFunctionEntry0( CUSBSESSION_GETSUPPORTEDLANGUAGESL_ENTRY ); |
1682 |
|
1683 |
1718 |
1684 const TUint deviceId = aMessage.Int0(); |
1719 const TUint deviceId = aMessage.Int0(); |
1685 LOGTEXT2(_L8("\tdeviceId = %d"), deviceId); |
1720 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDLANGUAGESL, "CUsbSession::GetSupportedLanguagesL;deviceId=%d", deviceId ); |
1686 |
1721 |
1687 RArray<TUint> langIds; |
1722 RArray<TUint> langIds; |
1688 CleanupClosePushL(langIds); |
1723 CleanupClosePushL(langIds); |
1689 TInt ret = iUsbServer->Host().GetSupportedLanguages(deviceId,langIds); |
1724 TInt ret = iUsbServer->Host().GetSupportedLanguages(deviceId,langIds); |
1690 |
1725 |
1691 if (ret == KErrNone) |
1726 if (ret == KErrNone) |
1692 { |
1727 { |
1693 const TUint count = langIds.Count(); |
1728 const TUint count = langIds.Count(); |
1694 LOGTEXT2(_L8("\tcount = %d"), count); |
1729 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDLANGUAGESL_DUP1, "CUsbSession::GetSupportedLanguagesL;count=%d", count ); |
1695 |
1730 |
1696 // Set error code if there is no languages or there are too many |
1731 // Set error code if there is no languages or there are too many |
1697 if ( count == 0 ) |
1732 if ( count == 0 ) |
1698 { |
1733 { |
1699 ret = KErrNotSupported; |
1734 ret = KErrNotSupported; |
1715 |
1750 |
1716 // Save all received language Ids |
1751 // Save all received language Ids |
1717 for ( TUint ii = 0 ; ii < count; ++ii ) |
1752 for ( TUint ii = 0 ; ii < count; ++ii ) |
1718 { |
1753 { |
1719 buf.Append((TUint8*)&(langIds[ii]), sizeof(TUint)); |
1754 buf.Append((TUint8*)&(langIds[ii]), sizeof(TUint)); |
1720 LOGTEXT3(_L8("Append langID[%d] = %d"),ii,langIds[ii]); |
1755 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_GETSUPPORTEDLANGUAGESL_DUP2, "CUsbSession::GetSupportedLanguagesL;Append langID[%d] = %d", ii, langIds[ii] ); |
1721 } |
1756 } |
1722 |
1757 |
1723 // Write back to the client. |
1758 // Write back to the client. |
1724 ret = aMessage.Write(1, buf); |
1759 ret = aMessage.Write(1, buf); |
1725 CleanupStack::PopAndDestroy(&buf); |
1760 CleanupStack::PopAndDestroy(&buf); |
1726 } |
1761 } |
1727 } |
1762 } |
1728 |
1763 |
1729 CleanupStack::PopAndDestroy(); |
1764 CleanupStack::PopAndDestroy(); |
1730 |
1765 |
|
1766 OstTraceFunctionExit0( CUSBSESSION_GETSUPPORTEDLANGUAGESL_EXIT ); |
1731 return ret; |
1767 return ret; |
1732 } |
1768 } |
1733 |
1769 |
1734 /** |
1770 /** |
1735 * Requests a manufacturer string descriptor of connected device. |
1771 * Requests a manufacturer string descriptor of connected device. |
1738 * @param aMessage Message received from the client |
1774 * @param aMessage Message received from the client |
1739 * @return Any error that occurred or KErrNone |
1775 * @return Any error that occurred or KErrNone |
1740 */ |
1776 */ |
1741 TInt CUsbSession::GetManufacturerStringDescriptor(const RMessage2& aMessage) |
1777 TInt CUsbSession::GetManufacturerStringDescriptor(const RMessage2& aMessage) |
1742 { |
1778 { |
1743 LOG_FUNC |
1779 OstTraceFunctionEntry0( CUSBSESSION_GETMANUFACTURERSTRINGDESCRIPTOR_ENTRY ); |
1744 |
1780 |
1745 const TUint deviceId = aMessage.Int0(); |
1781 const TUint deviceId = aMessage.Int0(); |
1746 const TUint langId = aMessage.Int1(); |
1782 const TUint langId = aMessage.Int1(); |
1747 LOGTEXT3(_L8("\tdeviceId = %d, langId = %d"), deviceId, langId); |
1783 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_GETMANUFACTURERSTRINGDESCRIPTOR, "CUsbSession::GetManufacturerStringDescriptor;langId=%d;deviceId=%d", langId, deviceId ); |
1748 |
1784 |
1749 TName string; |
1785 TName string; |
1750 TInt ret = iUsbServer->Host().GetManufacturerStringDescriptor(deviceId,langId,string); |
1786 TInt ret = iUsbServer->Host().GetManufacturerStringDescriptor(deviceId,langId,string); |
1751 if (ret == KErrNone) |
1787 if (ret == KErrNone) |
1752 { |
1788 { |
1753 LOGTEXT2(_L("\tstring = \"%S\""), &string); |
1789 OstTraceExt1( TRACE_NORMAL, CUSBSESSION_GETMANUFACTURERSTRINGDESCRIPTOR_DUP1, "CUsbSession::GetManufacturerStringDescriptor;string = \"%S\"", string ); |
1754 ret = aMessage.Write(2, string); |
1790 ret = aMessage.Write(2, string); |
1755 } |
1791 } |
1756 |
1792 |
|
1793 OstTraceFunctionExit0( CUSBSESSION_GETMANUFACTURERSTRINGDESCRIPTOR_EXIT ); |
1757 return ret; |
1794 return ret; |
1758 } |
1795 } |
1759 |
1796 |
1760 /** |
1797 /** |
1761 * Requests a product string descriptor of connected device. |
1798 * Requests a product string descriptor of connected device. |
1764 * @param aMessage Message received from the client |
1801 * @param aMessage Message received from the client |
1765 * @return Any error that occurred or KErrNone |
1802 * @return Any error that occurred or KErrNone |
1766 */ |
1803 */ |
1767 TInt CUsbSession::GetProductStringDescriptor(const RMessage2& aMessage) |
1804 TInt CUsbSession::GetProductStringDescriptor(const RMessage2& aMessage) |
1768 { |
1805 { |
1769 LOG_FUNC |
1806 OstTraceFunctionEntry0( CUSBSESSION_GETPRODUCTSTRINGDESCRIPTOR_ENTRY ); |
1770 |
1807 |
1771 const TUint deviceId = aMessage.Int0(); |
1808 const TUint deviceId = aMessage.Int0(); |
1772 const TUint langId = aMessage.Int1(); |
1809 const TUint langId = aMessage.Int1(); |
1773 LOGTEXT3(_L8("\tdeviceId = %d, langId = %d"), deviceId, langId); |
1810 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_GETPRODUCTSTRINGDESCRIPTOR, "CUsbSession::GetProductStringDescriptor;deviceId=%d;langId=%d", deviceId, langId ); |
1774 |
1811 |
1775 TName string; |
1812 TName string; |
1776 TInt ret = iUsbServer->Host().GetProductStringDescriptor(deviceId,langId,string); |
1813 TInt ret = iUsbServer->Host().GetProductStringDescriptor(deviceId,langId,string); |
1777 if (ret == KErrNone) |
1814 if (ret == KErrNone) |
1778 { |
1815 { |
1779 LOGTEXT2(_L("\tstring = \"%S\""), &string); |
1816 OstTraceExt1( TRACE_NORMAL, CUSBSESSION_GETPRODUCTSTRINGDESCRIPTOR_DUP1, "CUsbSession::GetProductStringDescriptor;string = \"%S\"", string ); |
1780 ret = aMessage.Write(2, string); |
1817 ret = aMessage.Write(2, string); |
1781 } |
1818 } |
1782 |
1819 |
|
1820 OstTraceFunctionExit0( CUSBSESSION_GETPRODUCTSTRINGDESCRIPTOR_EXIT ); |
1783 return ret; |
1821 return ret; |
1784 } |
1822 } |
1785 |
1823 |
1786 /** |
1824 /** |
1787 * Requests a OTG descriptor of connected device. |
1825 * Requests a OTG descriptor of connected device. |
1790 * @param aMessage Message received from the client |
1828 * @param aMessage Message received from the client |
1791 * @return Any error that occurred or KErrNone |
1829 * @return Any error that occurred or KErrNone |
1792 */ |
1830 */ |
1793 TInt CUsbSession::GetOtgDescriptor(const RMessage2& aMessage) |
1831 TInt CUsbSession::GetOtgDescriptor(const RMessage2& aMessage) |
1794 { |
1832 { |
1795 LOG_FUNC |
1833 OstTraceFunctionEntry0( CUSBSESSION_GETOTGDESCRIPTOR_ENTRY ); |
1796 |
1834 |
1797 const TUint deviceId = aMessage.Int0(); |
1835 const TUint deviceId = aMessage.Int0(); |
1798 LOGTEXT2(_L8("\tdeviceId = %d"), deviceId); |
1836 OstTrace1( TRACE_NORMAL, CUSBSESSION_GETOTGDESCRIPTOR, "CUsbSession::GetOtgDescriptor;deviceId=%d", deviceId ); |
1799 |
1837 |
1800 TOtgDescriptor otgDescriptor; |
1838 TOtgDescriptor otgDescriptor; |
1801 TInt ret = iUsbServer->Host().GetOtgDescriptor(deviceId, otgDescriptor); |
1839 TInt ret = iUsbServer->Host().GetOtgDescriptor(deviceId, otgDescriptor); |
1802 if (ret == KErrNone) |
1840 if (ret == KErrNone) |
1803 { |
1841 { |
1804 TPckg<TOtgDescriptor> buf(otgDescriptor); |
1842 TPckg<TOtgDescriptor> buf(otgDescriptor); |
1805 ret = aMessage.Write(1, buf); |
1843 ret = aMessage.Write(1, buf); |
1806 } |
1844 } |
1807 |
1845 |
|
1846 OstTraceFunctionExit0( CUSBSESSION_GETOTGDESCRIPTOR_EXIT ); |
1808 return ret; |
1847 return ret; |
1809 } |
1848 } |
1810 |
1849 |
1811 /** |
1850 /** |
1812 * Client request to observe the host (for state changes). |
1851 * Client request to observe the host (for state changes). |
1835 |
1875 |
1836 if (iHostEventObserverQueueEvents == EFalse) |
1876 if (iHostEventObserverQueueEvents == EFalse) |
1837 { |
1877 { |
1838 // This is the first observer after c'tor or DeregisterObserver(), |
1878 // This is the first observer after c'tor or DeregisterObserver(), |
1839 // so zap the device event queue. |
1879 // so zap the device event queue. |
1840 LOGTEXT(_L8(" Reset OTG Host State Queue")); |
1880 OstTrace0( TRACE_NORMAL, CUSBSESSION_REGISTERHOSTOBSERVER, "CUsbSession::RegisterHostObserver; Reset OTG Host State Queue" ); |
1841 iHostEventQueueHead = 0; |
1881 iHostEventQueueHead = 0; |
1842 iHostEventQueueTail = 0; |
1882 iHostEventQueueTail = 0; |
1843 iHostEventObserverQueueEvents = ETrue; |
1883 iHostEventObserverQueueEvents = ETrue; |
1844 } |
1884 } |
1845 else if (iHostEventQueueHead != iHostEventQueueTail) |
1885 else if (iHostEventQueueHead != iHostEventQueueTail) |
1846 { |
1886 { |
1847 // event(s) queued, we can de-queue one now |
1887 // event(s) queued, we can de-queue one now |
1848 UsbHostEventDequeue(); |
1888 UsbHostEventDequeue(); |
1849 } |
1889 } |
1850 |
1890 |
|
1891 OstTraceFunctionExit0( CUSBSESSION_REGISTERHOSTOBSERVER_EXIT_DUP1 ); |
1851 return KErrNone; |
1892 return KErrNone; |
1852 } |
1893 } |
1853 |
1894 |
1854 /** |
1895 /** |
1855 * Deregister the client as an observer of host state changes. |
1896 * Deregister the client as an observer of host state changes. |
1857 * @internalComponent |
1898 * @internalComponent |
1858 * @return Always KErrNone |
1899 * @return Always KErrNone |
1859 */ |
1900 */ |
1860 TInt CUsbSession::DeRegisterHostObserver() |
1901 TInt CUsbSession::DeRegisterHostObserver() |
1861 { |
1902 { |
1862 LOG_FUNC |
1903 OstTraceFunctionEntry0( CUSBSESSION_DEREGISTERHOSTOBSERVER_ENTRY ); |
1863 |
|
1864 |
1904 |
1865 if (!iHostEventObserverQueueEvents) |
1905 if (!iHostEventObserverQueueEvents) |
1866 { |
1906 { |
1867 //Never register |
1907 //Never register |
1868 LOGTEXT(_L8("iHostEventObserverQueueEvents is FALSE!")); |
1908 OstTrace0( TRACE_NORMAL, CUSBSESSION_DEREGISTERHOSTOBSERVER, "CUsbSession::DeRegisterHostObserver;iHostEventObserverQueueEvents is FALSE!" ); |
|
1909 OstTraceFunctionExit0( CUSBSESSION_DEREGISTERHOSTOBSERVER_EXIT ); |
1869 return KErrNone; |
1910 return KErrNone; |
1870 } |
1911 } |
1871 |
1912 |
1872 if (iHostEventObserverOutstanding) |
1913 if (iHostEventObserverOutstanding) |
1873 { |
1914 { |
1874 iHostEventObserverOutstanding = EFalse; |
1915 iHostEventObserverOutstanding = EFalse; |
1875 iHostEventObserverMessage.Complete(KErrCancel); |
1916 iHostEventObserverMessage.Complete(KErrCancel); |
1876 LOGTEXT(_L8("iHostEventObserverMessage.Complete(KErrCancel);")); |
1917 OstTrace0( TRACE_NORMAL, CUSBSESSION_DEREGISTERHOSTOBSERVER_DUP1, "CUsbSession::DeRegisterHostObserver;iHostEventObserverMessage.Complete(KErrCancel);" ); |
1877 } |
1918 } |
1878 |
1919 |
1879 // client doesn't need events queuing any more |
1920 // client doesn't need events queuing any more |
1880 iHostEventObserverQueueEvents = EFalse; |
1921 iHostEventObserverQueueEvents = EFalse; |
1881 //Reset OTG Host State Queue |
1922 //Reset OTG Host State Queue |
1882 iHostEventQueueHead = 0; |
1923 iHostEventQueueHead = 0; |
1883 iHostEventQueueTail = 0; |
1924 iHostEventQueueTail = 0; |
1884 |
1925 |
|
1926 OstTraceFunctionExit0( CUSBSESSION_DEREGISTERHOSTOBSERVER_EXIT_DUP1 ); |
1885 return KErrNone; |
1927 return KErrNone; |
1886 } |
1928 } |
1887 |
1929 |
1888 /** |
1930 /** |
1889 * Client request to observe both OTG and HOST (for events and errors). |
1931 * Client request to observe both OTG and HOST (for events and errors). |
1978 else if (iMsgObserverQueueEvents) |
2024 else if (iMsgObserverQueueEvents) |
1979 { |
2025 { |
1980 // add event to head of queue |
2026 // add event to head of queue |
1981 iMsgQueue[iMsgQueueHead] = aMessage; |
2027 iMsgQueue[iMsgQueueHead] = aMessage; |
1982 iMsgQueueHead = (iMsgQueueHead + 1) % KOtgHostMessageQueueSize; |
2028 iMsgQueueHead = (iMsgQueueHead + 1) % KOtgHostMessageQueueSize; |
1983 LOGTEXT3(_L8("+++ CUsbSession::UsbOtgMessage() addqueue (%d, %d)"), iMsgQueueHead, |
2029 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBOTGHOSTMESSAGE, "CUsbSession::UsbOtgHostMessage; addqueue (%d, %d)", iMsgQueueHead, iMsgQueueTail ); |
1984 iMsgQueueTail); |
|
1985 |
2030 |
1986 // UsbMsgDequeueEvent() will read from queue when RegisterMsgObserver() |
2031 // UsbMsgDequeueEvent() will read from queue when RegisterMsgObserver() |
1987 // is next called. |
2032 // is next called. |
1988 } |
2033 } |
|
2034 OstTraceFunctionExit0( CUSBSESSION_USBOTGHOSTMESSAGE_EXIT ); |
1989 } |
2035 } |
1990 |
2036 |
1991 /** |
2037 /** |
1992 * Called by CUsbHost when it state change. CUsbSession is an observer of |
2038 * Called by CUsbHost when it state change. CUsbSession is an observer of |
1993 * the device. If the client has an Observer outstanding then complete it, |
2039 * the device. If the client has an Observer outstanding then complete it, |
1997 * @param aDevInfo The information about the device being attached or detached |
2043 * @param aDevInfo The information about the device being attached or detached |
1998 * along with the status of Function Driver loading |
2044 * along with the status of Function Driver loading |
1999 */ |
2045 */ |
2000 void CUsbSession::UsbHostEvent(TDeviceEventInformation& aDevInfo) |
2046 void CUsbSession::UsbHostEvent(TDeviceEventInformation& aDevInfo) |
2001 { |
2047 { |
2002 LOG_FUNC |
2048 OstTraceFunctionEntry0( CUSBSESSION_USBHOSTEVENT_ENTRY ); |
2003 |
2049 |
2004 // can we bypass the queue? |
2050 // can we bypass the queue? |
2005 if ((iHostEventObserverOutstanding) && (iHostEventQueueHead == iHostEventQueueTail)) |
2051 if ((iHostEventObserverOutstanding) && (iHostEventQueueHead == iHostEventQueueTail)) |
2006 { |
2052 { |
2007 iNotifiedHostState = aDevInfo; |
2053 iNotifiedHostState = aDevInfo; |
2008 iHostEventObserverOutstanding = EFalse; |
2054 iHostEventObserverOutstanding = EFalse; |
2009 |
2055 |
2010 LOGTEXT(_L8("CUsbSession::UsbHostEvent() detected outstanding request")); |
2056 OstTrace0( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENT, "CUsbSession::UsbHostEvent detected outstanding request" ); |
2011 |
2057 |
2012 TPckg<TDeviceEventInformation> info(aDevInfo); |
2058 TPckg<TDeviceEventInformation> info(aDevInfo); |
2013 const TInt err = iHostEventObserverMessage.Write(0, info); |
2059 const TInt err = iHostEventObserverMessage.Write(0, info); |
2014 iHostEventObserverMessage.Complete(err); |
2060 iHostEventObserverMessage.Complete(err); |
2015 LOGTEXT2(_L8("CUsbSession::UsbHostEvent() detects outstanding request: request is compeleted with %d"), err); |
2061 OstTrace1( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENT_DUP1, "CUsbSession::UsbHostEvent; detects outstanding request: request is compeleted with %d", err ); |
2016 } |
2062 } |
2017 else if (iHostEventObserverQueueEvents) |
2063 else if (iHostEventObserverQueueEvents) |
2018 { |
2064 { |
2019 // add dev info to head of queue |
2065 // add dev info to head of queue |
2020 iHostStateQueue[iHostEventQueueHead] = aDevInfo; |
2066 iHostStateQueue[iHostEventQueueHead] = aDevInfo; |
2021 iHostEventQueueHead = (iHostEventQueueHead + 1) % KDeviceStatesQueueSize; |
2067 iHostEventQueueHead = (iHostEventQueueHead + 1) % KDeviceStatesQueueSize; |
2022 LOGTEXT3(_L8("+++ CUsbSession::UsbHostEvent() addqueue (%d, %d)"), iHostEventQueueHead, |
2068 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENT_DUP2, "CUsbSession::UsbHostEvent; addqueue (%d, %d)", iHostEventQueueHead, iHostEventQueueTail ); |
2023 iHostEventQueueTail); |
|
2024 |
2069 |
2025 // UsbHostStateDequeueEvent() will read from queue when RegisterHostObserver() |
2070 // UsbHostStateDequeueEvent() will read from queue when RegisterHostObserver() |
2026 // is next called. |
2071 // is next called. |
2027 } |
2072 } |
|
2073 OstTraceFunctionExit0( CUSBSESSION_USBHOSTEVENT_EXIT ); |
2028 } |
2074 } |
2029 |
2075 |
2030 /** |
2076 /** |
2031 * Dequeues an event and completes the observer's request with it. |
2077 * Dequeues an event and completes the observer's request with it. |
2032 */ |
2078 */ |
2033 void CUsbSession::UsbMsgDequeue() |
2079 void CUsbSession::UsbMsgDequeue() |
2034 { |
2080 { |
2035 LOG_FUNC |
2081 OstTraceFunctionEntry0( CUSBSESSION_USBMSGDEQUEUE_ENTRY ); |
2036 |
2082 |
2037 // Work our way through the queue, until we reach the end |
2083 // Work our way through the queue, until we reach the end |
2038 // OR we find an event the current observer wants. |
2084 // OR we find an event the current observer wants. |
2039 if ((iMsgObserverOutstanding) && (iMsgQueueHead != iMsgQueueTail)) |
2085 if ((iMsgObserverOutstanding) && (iMsgQueueHead != iMsgQueueTail)) |
2040 { |
2086 { |
2044 iMsgQueueTail = (iMsgQueueTail + 1) % KOtgHostMessageQueueSize; |
2090 iMsgQueueTail = (iMsgQueueTail + 1) % KOtgHostMessageQueueSize; |
2045 |
2091 |
2046 TPckg<TUint32> pckg(newMsg); |
2092 TPckg<TUint32> pckg(newMsg); |
2047 iNotifiedMsg = newMsg; |
2093 iNotifiedMsg = newMsg; |
2048 |
2094 |
2049 LOGTEXT3(_L8(">>> dequeued event #%d (0x%x)"), iMsgQueueTail, newMsg); |
2095 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBMSGDEQUEUE, "CUsbSession::UsbMsgDequeue;dequeued event #%d (0x%x)", iMsgQueueTail, newMsg ); |
2050 |
2096 |
2051 iMsgObserverOutstanding = EFalse; |
2097 iMsgObserverOutstanding = EFalse; |
2052 const TInt err = iMsgObserverMessage.Write(0, pckg); |
2098 const TInt err = iMsgObserverMessage.Write(0, pckg); |
2053 iMsgObserverMessage.Complete(err); |
2099 iMsgObserverMessage.Complete(err); |
2054 } |
2100 } |
|
2101 OstTraceFunctionExit0( CUSBSESSION_USBMSGDEQUEUE_EXIT ); |
2055 } |
2102 } |
2056 |
2103 |
2057 /** |
2104 /** |
2058 * Dequeues an event and completes the observer's request with it. |
2105 * Dequeues an event and completes the observer's request with it. |
2059 */ |
2106 */ |
2060 void CUsbSession::UsbHostEventDequeue() |
2107 void CUsbSession::UsbHostEventDequeue() |
2061 { |
2108 { |
2062 LOG_FUNC |
2109 OstTraceFunctionEntry0( CUSBSESSION_USBHOSTEVENTDEQUEUE_ENTRY ); |
2063 |
2110 |
2064 // Work our way through the queue, until we reach the end |
2111 // Work our way through the queue, until we reach the end |
2065 // OR we find an event the current observer wants. |
2112 // OR we find an event the current observer wants. |
2066 if ((iHostEventObserverOutstanding) && (iHostEventQueueHead != iHostEventQueueTail)) |
2113 if ((iHostEventObserverOutstanding) && (iHostEventQueueHead != iHostEventQueueTail)) |
2067 { |
2114 { |
2071 iNotifiedHostState = newDevInfo; |
2118 iNotifiedHostState = newDevInfo; |
2072 |
2119 |
2073 // advance tail towards the head |
2120 // advance tail towards the head |
2074 iHostEventQueueTail = (iHostEventQueueTail + 1) % KDeviceStatesQueueSize; |
2121 iHostEventQueueTail = (iHostEventQueueTail + 1) % KDeviceStatesQueueSize; |
2075 |
2122 |
2076 LOGTEXT3(_L8(">>> CUsbSession::UsbHostStateDequeueEvent() dequeued event #%d (0x%x)"), iHostEventQueueTail, newDevInfo.iEventType); |
2123 OstTraceExt2( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENTDEQUEUE, "CUsbSession::UsbHostEventDequeue; dequeued event #%d (0x%x)", iHostEventQueueTail, newDevInfo.iEventType ); |
2077 |
2124 |
2078 TPckg<TDeviceEventInformation> info(newDevInfo); |
2125 TPckg<TDeviceEventInformation> info(newDevInfo); |
2079 iHostEventObserverOutstanding = EFalse; |
2126 iHostEventObserverOutstanding = EFalse; |
2080 const TInt err = iHostEventObserverMessage.Write(0, info); |
2127 const TInt err = iHostEventObserverMessage.Write(0, info); |
2081 iHostEventObserverMessage.Complete(err); |
2128 iHostEventObserverMessage.Complete(err); |
2082 |
2129 |
2083 LOGTEXT2(_L8("CUsbSession::UsbHostStateDequeueEvent() detects outstanding request: request is compeleted with %d"), err); |
2130 OstTrace1( TRACE_NORMAL, CUSBSESSION_USBHOSTEVENTDEQUEUE_DUP1, "CUsbSession::UsbHostStateDequeueEvent() detects outstanding request: request is compeleted with %d", err ); |
2084 } |
2131 } |
|
2132 OstTraceFunctionExit0( CUSBSESSION_USBHOSTEVENTDEQUEUE_EXIT ); |
2085 } |
2133 } |
2086 |
2134 |
2087 TInt CUsbSession::RequestSession() |
2135 TInt CUsbSession::RequestSession() |
2088 { |
2136 { |
2089 return DoRequestSession(); |
2137 return DoRequestSession(); |