49 delete iUsbHostWatcher[i]; |
49 delete iUsbHostWatcher[i]; |
50 iUsbHostWatcher[i] = NULL; |
50 iUsbHostWatcher[i] = NULL; |
51 } |
51 } |
52 iObservers.Close(); |
52 iObservers.Close(); |
53 iInstance = 0; |
53 iInstance = 0; |
|
54 OstTraceFunctionExit0( CUSBHOST_CUSBHOST_DES_EXIT ); |
54 } |
55 } |
55 |
56 |
56 CUsbHost::CUsbHost() |
57 CUsbHost::CUsbHost() |
57 { |
58 { |
58 LOG_FUNC |
59 OstTraceFunctionEntry0( CUSBHOST_CUSBHOST_CONS_ENTRY ); |
|
60 OstTraceFunctionExit0( CUSBHOST_CUSBHOST_CONS_EXIT ); |
59 } |
61 } |
60 |
62 |
61 void CUsbHost::ConstructL() |
63 void CUsbHost::ConstructL() |
62 { |
64 { |
63 LOG_FUNC |
65 OstTraceFunctionEntry0( CUSBHOST_CONSTRUCTL_ENTRY ); |
64 |
66 |
65 iUsbHostWatcher[EHostEventMonitor] = |
67 iUsbHostWatcher[EHostEventMonitor] = |
66 CActiveUsbHostEventWatcher::NewL(iUsbHostStack,*this,iHostEventInfo); |
68 CActiveUsbHostEventWatcher::NewL(iUsbHostStack,*this,iHostEventInfo); |
67 iUsbHostWatcher[EHostMessageMonitor] = |
69 iUsbHostWatcher[EHostMessageMonitor] = |
68 CActiveUsbHostMessageWatcher::NewL(iUsbHostStack,*this,iHostMessage); |
70 CActiveUsbHostMessageWatcher::NewL(iUsbHostStack,*this,iHostMessage); |
|
71 OstTraceFunctionExit0( CUSBHOST_CONSTRUCTL_EXIT ); |
69 } |
72 } |
70 void CUsbHost::StartL() |
73 void CUsbHost::StartL() |
71 { |
74 { |
72 LOG_FUNC |
75 OstTraceFunctionEntry0( CUSBHOST_STARTL_ENTRY ); |
73 |
76 |
74 if(!iHasBeenStarted) |
77 if(!iHasBeenStarted) |
75 { |
78 { |
76 |
79 TInt err = iUsbHostStack.Connect(); |
77 LEAVEIFERRORL(iUsbHostStack.Connect()); |
80 if(err < 0) |
|
81 { |
|
82 OstTrace1( TRACE_NORMAL, CUSBHOST_STARTL, "CUsbHost::StartL; iUsbHostStack.Connect() error. Leave error=%d", err ); |
|
83 User::Leave(err); |
|
84 } |
78 |
85 |
79 for(TInt i=0;i<ENumMonitor;i++) |
86 for(TInt i=0;i<ENumMonitor;i++) |
80 { |
87 { |
81 iUsbHostWatcher[i]->Post(); |
88 iUsbHostWatcher[i]->Post(); |
82 } |
89 } |
83 iHasBeenStarted = ETrue; |
90 iHasBeenStarted = ETrue; |
84 } |
91 } |
|
92 OstTraceFunctionExit0( CUSBHOST_STARTL_EXIT ); |
85 } |
93 } |
86 |
94 |
87 void CUsbHost::Stop() |
95 void CUsbHost::Stop() |
88 { |
96 { |
89 LOG_FUNC |
97 OstTraceFunctionEntry0( CUSBHOST_STOP_ENTRY ); |
90 |
98 |
91 TInt i=0; |
99 TInt i=0; |
92 for(i=0;i<ENumMonitor;i++) |
100 for(i=0;i<ENumMonitor;i++) |
93 { |
101 { |
94 if (iUsbHostWatcher[i]) |
102 if (iUsbHostWatcher[i]) |
98 } |
106 } |
99 |
107 |
100 iUsbHostStack.Close(); |
108 iUsbHostStack.Close(); |
101 |
109 |
102 iHasBeenStarted = EFalse; |
110 iHasBeenStarted = EFalse; |
|
111 OstTraceFunctionExit0( CUSBHOST_STOP_EXIT ); |
103 } |
112 } |
104 |
113 |
105 void CUsbHost::RegisterObserverL(MUsbOtgHostNotifyObserver& aObserver) |
114 void CUsbHost::RegisterObserverL(MUsbOtgHostNotifyObserver& aObserver) |
106 { |
115 { |
107 LOG_FUNC |
116 OstTraceFunctionEntry0( CUSBHOST_REGISTEROBSERVERL_ENTRY ); |
108 |
117 |
109 iObservers.AppendL(&aObserver); |
118 iObservers.AppendL(&aObserver); |
110 UpdateNumOfObservers(); |
119 UpdateNumOfObservers(); |
|
120 OstTraceFunctionExit0( CUSBHOST_REGISTEROBSERVERL_EXIT ); |
111 } |
121 } |
112 |
122 |
113 void CUsbHost::DeregisterObserver(MUsbOtgHostNotifyObserver& aObserver) |
123 void CUsbHost::DeregisterObserver(MUsbOtgHostNotifyObserver& aObserver) |
114 { |
124 { |
115 LOG_FUNC |
125 OstTraceFunctionEntry0( CUSBHOST_DEREGISTEROBSERVER_ENTRY ); |
116 TInt index = iObservers.Find(&aObserver); |
126 TInt index = iObservers.Find(&aObserver); |
117 if(index == KErrNotFound) |
127 if(index == KErrNotFound) |
118 { |
128 { |
119 LOGTEXT(_L8("\t Cannot remove observer, not found")); |
129 OstTrace0( TRACE_NORMAL, CUSBHOST_DEREGISTEROBSERVER, "CUsbHost::DeregisterObserver; Cannot remove observer, not found" ); |
120 } |
130 } |
121 else |
131 else |
122 { |
132 { |
123 iObservers.Remove(index); |
133 iObservers.Remove(index); |
124 } |
134 } |
125 |
135 |
126 UpdateNumOfObservers(); |
136 UpdateNumOfObservers(); |
|
137 OstTraceFunctionExit0( CUSBHOST_DEREGISTEROBSERVER_EXIT ); |
127 } |
138 } |
128 |
139 |
129 TInt CUsbHost::GetSupportedLanguages(TUint aDeviceId,RArray<TUint>& aLangIds) |
140 TInt CUsbHost::GetSupportedLanguages(TUint aDeviceId,RArray<TUint>& aLangIds) |
130 { |
141 { |
131 LOG_FUNC |
142 OstTraceFunctionEntry0( CUSBHOST_GETSUPPORTEDLANGUAGES_ENTRY ); |
132 TInt err = KErrNone; |
143 TInt err = KErrNone; |
133 if ( iUsbHostStack.Handle() ) |
144 if ( iUsbHostStack.Handle() ) |
134 { |
145 { |
135 err = iUsbHostStack.GetSupportedLanguages(aDeviceId,aLangIds); |
146 err = iUsbHostStack.GetSupportedLanguages(aDeviceId,aLangIds); |
136 } |
147 } |
137 else |
148 else |
138 { |
149 { |
139 err = KErrBadHandle; |
150 err = KErrBadHandle; |
140 } |
151 } |
|
152 OstTraceFunctionExit0( CUSBHOST_GETSUPPORTEDLANGUAGES_EXIT ); |
141 return err; |
153 return err; |
142 } |
154 } |
143 |
155 |
144 TInt CUsbHost::GetManufacturerStringDescriptor(TUint aDeviceId,TUint aLangId,TName& aString) |
156 TInt CUsbHost::GetManufacturerStringDescriptor(TUint aDeviceId,TUint aLangId,TName& aString) |
145 { |
157 { |
146 LOG_FUNC |
158 OstTraceFunctionEntry0( CUSBHOST_GETMANUFACTURERSTRINGDESCRIPTOR_ENTRY ); |
147 TInt err = KErrNone; |
159 TInt err = KErrNone; |
148 if ( iUsbHostStack.Handle() ) |
160 if ( iUsbHostStack.Handle() ) |
149 { |
161 { |
150 err = iUsbHostStack.GetManufacturerStringDescriptor(aDeviceId,aLangId,aString); |
162 err = iUsbHostStack.GetManufacturerStringDescriptor(aDeviceId,aLangId,aString); |
151 } |
163 } |
152 else |
164 else |
153 { |
165 { |
154 err = KErrBadHandle; |
166 err = KErrBadHandle; |
155 } |
167 } |
|
168 OstTraceFunctionExit0( CUSBHOST_GETMANUFACTURERSTRINGDESCRIPTOR_EXIT ); |
156 return err; |
169 return err; |
157 } |
170 } |
158 |
171 |
159 TInt CUsbHost::GetProductStringDescriptor(TUint aDeviceId,TUint aLangId,TName& aString) |
172 TInt CUsbHost::GetProductStringDescriptor(TUint aDeviceId,TUint aLangId,TName& aString) |
160 { |
173 { |
161 LOG_FUNC |
174 OstTraceFunctionEntry0( CUSBHOST_GETPRODUCTSTRINGDESCRIPTOR_ENTRY ); |
162 TInt err = KErrNone; |
175 TInt err = KErrNone; |
163 if ( iUsbHostStack.Handle() ) |
176 if ( iUsbHostStack.Handle() ) |
164 { |
177 { |
165 err = iUsbHostStack.GetProductStringDescriptor(aDeviceId,aLangId,aString); |
178 err = iUsbHostStack.GetProductStringDescriptor(aDeviceId,aLangId,aString); |
166 } |
179 } |
167 else |
180 else |
168 { |
181 { |
169 err = KErrBadHandle; |
182 err = KErrBadHandle; |
170 } |
183 } |
|
184 OstTraceFunctionExit0( CUSBHOST_GETPRODUCTSTRINGDESCRIPTOR_EXIT ); |
171 return err; |
185 return err; |
172 } |
186 } |
173 |
187 |
174 TInt CUsbHost::GetOtgDescriptor(TUint aDeviceId, TOtgDescriptor& otgDescriptor) |
188 TInt CUsbHost::GetOtgDescriptor(TUint aDeviceId, TOtgDescriptor& otgDescriptor) |
175 { |
189 { |
176 LOG_FUNC |
190 OstTraceFunctionEntry0( CUSBHOST_GETOTGDESCRIPTOR_ENTRY ); |
177 |
191 |
178 TInt err(KErrNone); |
192 TInt err(KErrNone); |
179 |
193 |
180 if (iUsbHostStack.Handle()) |
194 if (iUsbHostStack.Handle()) |
181 { |
195 { |
184 else |
198 else |
185 { |
199 { |
186 err = KErrBadHandle; |
200 err = KErrBadHandle; |
187 } |
201 } |
188 |
202 |
|
203 OstTraceFunctionExit0( CUSBHOST_GETOTGDESCRIPTOR_EXIT ); |
189 return err; |
204 return err; |
190 } |
205 } |
191 |
206 |
192 void CUsbHost::NotifyHostEvent(TUint aWatcherId) |
207 void CUsbHost::NotifyHostEvent(TUint aWatcherId) |
193 { |
208 { |
194 LOG_FUNC |
209 OstTraceFunctionEntry0( CUSBHOST_NOTIFYHOSTEVENT_ENTRY ); |
|
210 |
195 if(aWatcherId == EHostEventMonitor) |
211 if(aWatcherId == EHostEventMonitor) |
196 { |
212 { |
197 |
213 OstTrace1( TRACE_NORMAL, CUSBHOST_NOTIFYHOSTEVENT, "CUsbHost::NotifyHostEvent;DeviceId=%d", iHostEventInfo.iDeviceId ); |
198 LOGTEXT2(_L8("\t Device id %d"),iHostEventInfo.iDeviceId); |
214 OstTrace1( TRACE_NORMAL, CUSBHOST_NOTIFYHOSTEVENT_DUP1, "CUsbHost::NotifyHostEvent;iEventType=%d", iHostEventInfo.iEventType ); |
199 LOGTEXT2(_L8("\t iEventType %d"),iHostEventInfo.iEventType); |
215 OstTrace1( TRACE_NORMAL, CUSBHOST_NOTIFYHOSTEVENT_DUP2, "CUsbHost::NotifyHostEvent;TDriverLoadStatus=%d", iHostEventInfo.iDriverLoadStatus ); |
200 LOGTEXT2(_L8("\t TDriverLoadStatus %d"),iHostEventInfo.iDriverLoadStatus); |
216 OstTrace1( TRACE_NORMAL, CUSBHOST_NOTIFYHOSTEVENT_DUP3, "CUsbHost::NotifyHostEvent;VID=%d", iHostEventInfo.iVid ); |
201 LOGTEXT2(_L8("\t VID %d"),iHostEventInfo.iVid); |
217 OstTrace1( TRACE_NORMAL, CUSBHOST_NOTIFYHOSTEVENT_DUP4, "CUsbHost::NotifyHostEvent;Pid=%d", iHostEventInfo.iPid ); |
202 LOGTEXT2(_L8("\t PID %d"),iHostEventInfo.iPid); |
|
203 |
218 |
204 for(TUint i=0;i<iNumOfObservers;i++) |
219 for(TUint i=0;i<iNumOfObservers;i++) |
205 { |
220 { |
206 iObservers[i]->UsbHostEvent(iHostEventInfo); |
221 iObservers[i]->UsbHostEvent(iHostEventInfo); |
207 } |
222 } |
208 } |
223 } |
209 else |
224 else |
210 { |
225 { |
211 LOGTEXT2(_L8("\t Host Message %d"),iHostMessage); |
226 OstTrace1( TRACE_NORMAL, CUSBHOST_NOTIFYHOSTEVENT_DUP5, "CUsbHost::NotifyHostEvent;Host Message=%d", iHostMessage ); |
212 |
227 |
213 for(TUint i=0;i<iNumOfObservers;i++) |
228 for(TUint i=0;i<iNumOfObservers;i++) |
214 { |
229 { |
215 iObservers[i]->UsbOtgHostMessage(iHostMessage); |
230 iObservers[i]->UsbOtgHostMessage(iHostMessage); |
216 } |
231 } |
217 } |
232 } |
|
233 OstTraceFunctionExit0( CUSBHOST_NOTIFYHOSTEVENT_EXIT ); |
218 } |
234 } |
219 |
235 |
220 void CUsbHost::UpdateNumOfObservers() |
236 void CUsbHost::UpdateNumOfObservers() |
221 { |
237 { |
222 LOG_FUNC |
238 OstTraceFunctionEntry0( CUSBHOST_UPDATENUMOFOBSERVERS_ENTRY ); |
223 iNumOfObservers = iObservers.Count(); |
239 iNumOfObservers = iObservers.Count(); |
|
240 OstTraceFunctionExit0( CUSBHOST_UPDATENUMOFOBSERVERS_EXIT ); |
224 } |
241 } |
225 |
242 |
226 TInt CUsbHost::EnableDriverLoading() |
243 TInt CUsbHost::EnableDriverLoading() |
227 { |
244 { |
228 LOG_FUNC |
245 OstTraceFunctionEntry0( CUSBHOST_ENABLEDRIVERLOADING_ENTRY ); |
229 TInt err = KErrNone; |
246 TInt err = KErrNone; |
230 if ( iUsbHostStack.Handle() ) |
247 if ( iUsbHostStack.Handle() ) |
231 { |
248 { |
232 err = iUsbHostStack.EnableDriverLoading(); |
249 err = iUsbHostStack.EnableDriverLoading(); |
233 } |
250 } |
234 else |
251 else |
235 { |
252 { |
236 err = KErrBadHandle; |
253 err = KErrBadHandle; |
237 } |
254 } |
|
255 OstTraceFunctionExit0( CUSBHOST_ENABLEDRIVERLOADING_EXIT ); |
238 return err; |
256 return err; |
239 } |
257 } |
240 |
258 |
241 void CUsbHost::DisableDriverLoading() |
259 void CUsbHost::DisableDriverLoading() |
242 { |
260 { |
243 LOG_FUNC |
261 OstTraceFunctionEntry0( CUSBHOST_DISABLEDRIVERLOADING_ENTRY ); |
244 if ( iUsbHostStack.Handle() ) |
262 if ( iUsbHostStack.Handle() ) |
245 { |
263 { |
246 iUsbHostStack.DisableDriverLoading(); |
264 iUsbHostStack.DisableDriverLoading(); |
247 } |
265 } |
248 } |
266 OstTraceFunctionExit0( CUSBHOST_DISABLEDRIVERLOADING_EXIT ); |
|
267 } |