164 * |
160 * |
165 * @param aStatus The caller's request status, filled in with an error code |
161 * @param aStatus The caller's request status, filled in with an error code |
166 */ |
162 */ |
167 void CUsbstub3ClassController::Start(TRequestStatus& aStatus) |
163 void CUsbstub3ClassController::Start(TRequestStatus& aStatus) |
168 { |
164 { |
169 OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_START_ENTRY ); |
165 LOG_FUNC |
170 |
166 |
171 aStatus = KRequestPending; |
167 aStatus = KRequestPending; |
172 iReportStatus = &aStatus; |
168 iReportStatus = &aStatus; |
173 //If we are already started then just complete the request. |
169 //If we are already started then just complete the request. |
174 if (iState == EUsbServiceStarted) |
170 if (iState == EUsbServiceStarted) |
175 { |
171 { |
176 User::RequestComplete(iReportStatus, KErrNone); |
172 User::RequestComplete(iReportStatus, KErrNone); |
177 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT ); |
|
178 return; |
173 return; |
179 } |
174 } |
180 |
175 |
181 if (iFailToStart) |
176 if (iFailToStart) |
182 { |
177 { |
183 User::RequestComplete(iReportStatus, KErrGeneral); |
178 User::RequestComplete(iReportStatus, KErrGeneral); |
184 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT_DUP1 ); |
|
185 return; |
179 return; |
186 } |
180 } |
187 |
181 |
188 iState = EUsbServiceStarting; |
182 iState = EUsbServiceStarting; |
189 |
183 |
190 #ifndef __WINS__ |
184 #ifndef __WINS__ |
191 TInt ret = iLdd.Open(0); |
185 TInt ret = iLdd.Open(0); |
192 OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_START, _L8("Open LDD, ret=%d"), ret ); |
186 LOGTEXT2(_L8("Open LDD, ret=%d"), ret); |
193 |
|
194 ret = SetUpInterface(); |
187 ret = SetUpInterface(); |
195 OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_START_DUP1, |
188 LOGTEXT2(_L8("SetUpInterface(), ret=%d"), ret); |
196 _L8("SetUpInterface(), ret=%d"), ret ); |
|
197 |
|
198 #endif |
189 #endif |
199 |
190 |
200 |
191 |
201 iTimer.After(iStatus, iStartDelay*1000); //convert from usec to msec |
192 iTimer.After(iStatus, iStartDelay*1000); //convert from usec to msec |
202 SetActive(); |
193 SetActive(); |
203 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_START_EXIT_DUP2 ); |
|
204 } |
194 } |
205 |
195 |
206 /** |
196 /** |
207 * Called by UsbMan when it wants to stop the USB stub3 class. |
197 * Called by UsbMan when it wants to stop the USB stub3 class. |
208 * |
198 * |
209 * @param aStatus The caller's request status: always set to KErrNone |
199 * @param aStatus The caller's request status: always set to KErrNone |
210 */ |
200 */ |
211 void CUsbstub3ClassController::Stop(TRequestStatus& aStatus) |
201 void CUsbstub3ClassController::Stop(TRequestStatus& aStatus) |
212 { |
202 { |
213 OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_STOP_ENTRY ); |
203 LOG_FUNC |
214 |
204 |
215 aStatus = KRequestPending; |
205 aStatus = KRequestPending; |
216 iReportStatus = &aStatus; |
206 iReportStatus = &aStatus; |
217 //If we are already idle then just complete the request. |
207 //If we are already idle then just complete the request. |
218 if (iState == EUsbServiceIdle) |
208 if (iState == EUsbServiceIdle) |
219 { |
209 { |
220 User::RequestComplete(iReportStatus, KErrNone); |
210 User::RequestComplete(iReportStatus, KErrNone); |
221 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT ); |
|
222 return; |
211 return; |
223 } |
212 } |
224 |
213 |
225 if (iFailToStop) |
214 if (iFailToStop) |
226 { |
215 { |
227 User::RequestComplete(iReportStatus, KErrGeneral); |
216 User::RequestComplete(iReportStatus, KErrGeneral); |
228 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT_DUP1 ); |
|
229 return; |
217 return; |
230 } |
218 } |
231 |
219 |
232 iState = EUsbServiceStopping; |
220 iState = EUsbServiceStopping; |
233 |
221 |
236 #endif |
224 #endif |
237 |
225 |
238 |
226 |
239 iTimer.After(iStatus, iStopDelay*1000); //convert from usec to msec |
227 iTimer.After(iStatus, iStopDelay*1000); //convert from usec to msec |
240 SetActive(); |
228 SetActive(); |
241 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_STOP_EXIT_DUP2 ); |
|
242 } |
229 } |
243 |
230 |
244 /** |
231 /** |
245 * Gets information about the descriptor which this class provides. |
232 * Gets information about the descriptor which this class provides. |
246 * |
233 * |
247 * @param aDescriptorInfo Descriptor info structure filled in by this function |
234 * @param aDescriptorInfo Descriptor info structure filled in by this function |
248 */ |
235 */ |
249 void CUsbstub3ClassController::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const |
236 void CUsbstub3ClassController::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const |
250 { |
237 { |
251 OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_GETDESCRIPTORINFO_ENTRY ); |
238 LOG_FUNC |
252 |
239 |
253 aDescriptorInfo.iLength = Kstub3DescriptorLength; |
240 aDescriptorInfo.iLength = Kstub3DescriptorLength; |
254 aDescriptorInfo.iNumInterfaces = Kstub3NumberOfInterfacesPerstub3Function; |
241 aDescriptorInfo.iNumInterfaces = Kstub3NumberOfInterfacesPerstub3Function; |
255 |
|
256 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_GETDESCRIPTORINFO_EXIT ); |
|
257 } |
242 } |
258 |
243 |
259 |
244 |
260 /** |
245 /** |
261 * Standard active object RunL. |
246 * Standard active object RunL. |
262 */ |
247 */ |
263 void CUsbstub3ClassController::RunL() |
248 void CUsbstub3ClassController::RunL() |
264 { |
249 { |
265 OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_RUNL_ENTRY ); |
250 LOG_FUNC |
266 |
251 |
267 if(iStatus != KErrNone) |
252 __ASSERT_DEBUG( iStatus == KErrNone, _USB_PANIC(Kstub3CcPanicCategory, EPanicUnexpectedStatus) ); |
268 { |
|
269 OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNL, |
|
270 "CUsbstub3ClassController::RunL panic with error %d", EPanicUnexpectedStatus ); |
|
271 __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus)); |
|
272 } |
|
273 switch (iState) |
253 switch (iState) |
274 { |
254 { |
275 case EUsbServiceStarting: |
255 case EUsbServiceStarting: |
276 iState = EUsbServiceStarted; |
256 iState = EUsbServiceStarted; |
277 break; |
257 break; |
278 case EUsbServiceStopping: |
258 case EUsbServiceStopping: |
279 iState = EUsbServiceIdle; |
259 iState = EUsbServiceIdle; |
280 break; |
260 break; |
281 default: |
261 default: |
282 OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNL_DUP1, |
262 _USB_PANIC(Kstub3CcPanicCategory, EPanicUnexpectedState); |
283 "CUsbstub3ClassController::RunL panic with error %d", EPanicUnexpectedStatus ); |
|
284 User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus); |
|
285 } |
263 } |
286 *iReportStatus = KErrNone; |
264 *iReportStatus = KErrNone; |
287 User::RequestComplete(iReportStatus, iStatus.Int()); |
265 User::RequestComplete(iReportStatus, iStatus.Int()); |
288 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_RUNL_EXIT ); |
|
289 } |
266 } |
290 |
267 |
291 /** |
268 /** |
292 * Standard active object cancellation function. Never called because this |
269 * Standard active object cancellation function. Never called because this |
293 * class has no asynchronous requests. |
270 * class has no asynchronous requests. |
323 * @param aError The error code (unused) |
298 * @param aError The error code (unused) |
324 * @return Always KErrNone to avoid an active scheduler panic |
299 * @return Always KErrNone to avoid an active scheduler panic |
325 */ |
300 */ |
326 TInt CUsbstub3ClassController::RunError(TInt /*aError*/) |
301 TInt CUsbstub3ClassController::RunError(TInt /*aError*/) |
327 { |
302 { |
328 OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_RUNERROR, |
303 __ASSERT_DEBUG( EFalse, _USB_PANIC(Kstub3CcPanicCategory, EUnusedFunction) ); |
329 "CUsbstub3ClassController::RunError panic with error %d", EUnusedFunction ); |
|
330 __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EUnusedFunction)); |
|
331 return KErrNone; |
304 return KErrNone; |
332 } |
305 } |
333 |
306 |
334 TInt CUsbstub3ClassController::SetUpInterface() |
307 TInt CUsbstub3ClassController::SetUpInterface() |
335 /** |
308 /** |
336 * Set up the interface for use. This involves finding a "Interrupt IN" |
309 * Set up the interface for use. This involves finding a "Interrupt IN" |
337 * endpoint and, if found, configuring the interface. |
310 * endpoint and, if found, configuring the interface. |
338 */ |
311 */ |
339 { |
312 { |
340 OstTraceFunctionEntry0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_ENTRY ); |
313 LOG_FUNC |
341 |
314 |
342 TUsbDeviceCaps dCaps; |
315 TUsbDeviceCaps dCaps; |
343 TInt ret = iLdd.DeviceCaps(dCaps); |
316 TInt ret = iLdd.DeviceCaps(dCaps); |
344 OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE, |
317 LOGTEXT(_L8("\tchecking result of DeviceCaps")); |
345 _L8("\tchecking result of DeviceCaps")); |
|
346 |
|
347 if ( ret ) |
318 if ( ret ) |
348 { |
319 { |
349 OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP1, |
320 LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret); |
350 _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret ); |
|
351 |
|
352 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT ); |
|
353 return ret; |
321 return ret; |
354 } |
322 } |
355 |
323 |
356 const TUint KRequiredNumberOfEndpoints = 1; // in addition to endpoint 0. |
324 const TUint KRequiredNumberOfEndpoints = 1; // in addition to endpoint 0. |
357 |
325 |
358 const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints); |
326 const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints); |
359 OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP2, |
327 LOGTEXT2(_L8("\tiTotalEndpoints = %d"), totalEndpoints); |
360 _L8("\tiTotalEndpoints = %d"), totalEndpoints ); |
|
361 |
|
362 if ( totalEndpoints < KRequiredNumberOfEndpoints ) |
328 if ( totalEndpoints < KRequiredNumberOfEndpoints ) |
363 { |
329 { |
364 OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP3, |
330 LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), |
365 _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), KErrGeneral ); |
331 KErrGeneral); |
366 |
|
367 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP1 ); |
|
368 return KErrGeneral; |
332 return KErrGeneral; |
369 } |
333 } |
370 |
334 |
371 // Endpoints |
335 // Endpoints |
372 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
336 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
373 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
337 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
374 ret = iLdd.EndpointCaps(dataptr); |
338 ret = iLdd.EndpointCaps(dataptr); |
375 OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP4, |
339 LOGTEXT(_L8("\tchecking result of EndpointCaps")); |
376 _L8("\tchecking result of EndpointCaps")); |
|
377 |
|
378 if ( ret ) |
340 if ( ret ) |
379 { |
341 { |
380 OstTrace1( TRACE_ERROR, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP5, |
342 LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret); |
381 _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret ); |
|
382 |
|
383 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP2 ); |
|
384 return ret; |
343 return ret; |
385 } |
344 } |
386 |
345 |
387 // Set the active interface |
346 // Set the active interface |
388 TUsbcInterfaceInfoBuf ifc; |
347 TUsbcInterfaceInfoBuf ifc; |
389 TBool epFound = EFalse; |
348 TBool epFound = EFalse; |
390 for ( TUint i = 0 ; i < totalEndpoints ; i++ ) |
349 for ( TUint i = 0 ; i < totalEndpoints ; i++ ) |
391 { |
350 { |
392 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
351 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
393 if(!caps) |
352 __ASSERT_DEBUG(caps,_USB_PANIC(Kstub3CcPanicCategory, EPanicUnexpectedStatus)); |
394 { |
|
395 OstTrace1( TRACE_FATAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP6, |
|
396 "CUsbstub3ClassController::SetUpInterface panic with error %d", |
|
397 EPanicUnexpectedStatus ); |
|
398 __ASSERT_DEBUG(EFalse,User::Panic(Kstub3CcPanicCategory,EPanicUnexpectedStatus)); |
|
399 } |
|
400 |
353 |
401 if (data[i].iInUse) |
354 if (data[i].iInUse) |
402 { |
355 { |
403 continue; |
356 continue; |
404 } |
357 } |
439 // Codes taken from USBCDC 1.1. |
389 // Codes taken from USBCDC 1.1. |
440 ifc().iClass.iClassNum = 0x02; // Table 15- Communication Interface Class |
390 ifc().iClass.iClassNum = 0x02; // Table 15- Communication Interface Class |
441 ifc().iClass.iSubClassNum = 0x02; // Table 16- Abstract Control Model |
391 ifc().iClass.iSubClassNum = 0x02; // Table 16- Abstract Control Model |
442 ifc().iClass.iProtocolNum = 0x01; // Table 17- Hayes compatible |
392 ifc().iClass.iProtocolNum = 0x01; // Table 17- Hayes compatible |
443 |
393 |
444 OstTrace0( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP9, |
394 LOGTEXT(_L8("\tabout to call SetInterface")); |
445 _L8("\tabout to call SetInterface")); |
|
446 |
|
447 // Zero effectively indicates that alternate interfaces are not used. |
395 // Zero effectively indicates that alternate interfaces are not used. |
448 ret = iLdd.SetInterface(0, ifc); |
396 ret = iLdd.SetInterface(0, ifc); |
449 |
397 |
450 OstTrace1( TRACE_NORMAL, CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_DUP10, |
398 LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret); |
451 _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret ); |
|
452 |
|
453 OstTraceFunctionExit0( CUSBSTUB3CLASSCONTROLLER_SETUPINTERFACE_EXIT_DUP4 ); |
|
454 return ret; |
399 return ret; |
455 } |
400 } |
456 |
401 |
457 // |
402 // |
458 // End of file |
403 // End of file |