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