210 case KUsbEpTypeBulk: |
217 case KUsbEpTypeBulk: |
211 return (iCaps.iTypesAndDir & KUsbEpTypeBulk); |
218 return (iCaps.iTypesAndDir & KUsbEpTypeBulk); |
212 case KUsbEpTypeInterrupt: |
219 case KUsbEpTypeInterrupt: |
213 return (iCaps.iTypesAndDir & KUsbEpTypeInterrupt); |
220 return (iCaps.iTypesAndDir & KUsbEpTypeInterrupt); |
214 default: |
221 default: |
215 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: invalid EP type: %d", aType)); |
222 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCPHYSICALENDPOINT_TYPEAVAILABLE_DUP1, |
|
223 " Error: invalid EP type: %d", aType ); |
216 return 0; |
224 return 0; |
217 } |
225 } |
218 } |
226 } |
219 |
227 |
220 |
228 |
221 TInt TUsbcPhysicalEndpoint::DirAvailable(TUint aDir) const |
229 TInt TUsbcPhysicalEndpoint::DirAvailable(TUint aDir) const |
222 { |
230 { |
223 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcPhysicalEndpoint::DirAvailable")); |
231 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCPHYSICALENDPOINT_DIRAVAILABLE, |
|
232 "TUsbcPhysicalEndpoint::DirAvailable" ); |
224 switch (aDir) |
233 switch (aDir) |
225 { |
234 { |
226 case KUsbEpDirIn: |
235 case KUsbEpDirIn: |
227 return (iCaps.iTypesAndDir & KUsbEpDirIn); |
236 return (iCaps.iTypesAndDir & KUsbEpDirIn); |
228 case KUsbEpDirOut: |
237 case KUsbEpDirOut: |
229 return (iCaps.iTypesAndDir & KUsbEpDirOut); |
238 return (iCaps.iTypesAndDir & KUsbEpDirOut); |
230 default: |
239 default: |
231 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: invalid EP direction: %d", aDir)); |
240 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCPHYSICALENDPOINT_DIRAVAILABLE_DUP1, |
|
241 " Error: invalid EP direction: %d", aDir ); |
232 return 0; |
242 return 0; |
233 } |
243 } |
234 } |
244 } |
235 |
245 |
236 |
246 |
237 TInt TUsbcPhysicalEndpoint::EndpointSuitable(const TUsbcEndpointInfo* aEpInfo, TInt aIfcNumber) const |
247 TInt TUsbcPhysicalEndpoint::EndpointSuitable(const TUsbcEndpointInfo* aEpInfo, TInt aIfcNumber) const |
238 { |
248 { |
239 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcPhysicalEndpoint::EndpointSuitable")); |
249 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCPHYSICALENDPOINT_ENDPOINTSUITABLE, |
240 __KTRACE_OPT(KUSB, Kern::Printf(" looking for EP: type=0x%x dir=0x%x size=%d (ifc_num=%d)", |
250 "TUsbcPhysicalEndpoint::EndpointSuitable" ); |
241 aEpInfo->iType, aEpInfo->iDir, aEpInfo->iSize, aIfcNumber)); |
251 OstTraceDefExt4( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCPHYSICALENDPOINT_ENDPOINTSUITABLE_DUP1, |
|
252 " looking for EP: type=0x%x dir=0x%x size=%d (ifc_num=%d)", |
|
253 aEpInfo->iType, aEpInfo->iDir, aEpInfo->iSize, aIfcNumber ); |
242 if (iSettingReserve) |
254 if (iSettingReserve) |
243 { |
255 { |
244 __KTRACE_OPT(KUSB, Kern::Printf(" -> setting conflict")); |
256 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCPHYSICALENDPOINT_ENDPOINTSUITABLE_DUP2, |
|
257 " -> setting conflict" ); |
245 return 0; |
258 return 0; |
246 } |
259 } |
247 // (aIfcNumber == -1) means the ep is for a new default interface setting |
260 // (aIfcNumber == -1) means the ep is for a new default interface setting |
248 else if (iIfcNumber && (*iIfcNumber != aIfcNumber)) |
261 else if (iIfcNumber && (*iIfcNumber != aIfcNumber)) |
249 { |
262 { |
252 // (*iIfcNumber != aIfcNumber), then it's not available. |
265 // (*iIfcNumber != aIfcNumber), then it's not available. |
253 // This works because we can assign the same physical endpoint |
266 // This works because we can assign the same physical endpoint |
254 // to different alternate settings of the *same* interface, and |
267 // to different alternate settings of the *same* interface, and |
255 // because we check for available endpoints for every alternate setting |
268 // because we check for available endpoints for every alternate setting |
256 // as a whole. |
269 // as a whole. |
257 __KTRACE_OPT(KUSB, Kern::Printf(" -> ifc conflict")); |
270 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCPHYSICALENDPOINT_ENDPOINTSUITABLE_DUP3, |
|
271 " -> ifc conflict" ); |
258 return 0; |
272 return 0; |
259 } |
273 } |
260 else if (!TypeAvailable(aEpInfo->iType)) |
274 else if (!TypeAvailable(aEpInfo->iType)) |
261 { |
275 { |
262 __KTRACE_OPT(KUSB, Kern::Printf(" -> type conflict")); |
276 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCPHYSICALENDPOINT_ENDPOINTSUITABLE_DUP4, |
|
277 " -> type conflict" ); |
263 return 0; |
278 return 0; |
264 } |
279 } |
265 else if (!DirAvailable(aEpInfo->iDir)) |
280 else if (!DirAvailable(aEpInfo->iDir)) |
266 { |
281 { |
267 __KTRACE_OPT(KUSB, Kern::Printf(" -> direction conflict")); |
282 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCPHYSICALENDPOINT_ENDPOINTSUITABLE_DUP5, |
|
283 " -> direction conflict" ); |
268 return 0; |
284 return 0; |
269 } |
285 } |
270 else if (!(iCaps.iSizes & PacketSize2Mask(aEpInfo->iSize)) && !(iCaps.iSizes & KUsbEpSizeCont)) |
286 else if (!(iCaps.iSizes & PacketSize2Mask(aEpInfo->iSize)) && !(iCaps.iSizes & KUsbEpSizeCont)) |
271 { |
287 { |
272 __KTRACE_OPT(KUSB, Kern::Printf(" -> size conflict")); |
288 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCPHYSICALENDPOINT_ENDPOINTSUITABLE_DUP6, |
|
289 " -> size conflict" ); |
273 return 0; |
290 return 0; |
274 } |
291 } |
275 else |
292 else |
276 return 1; |
293 return 1; |
277 } |
294 } |
278 |
295 |
279 |
296 |
280 TUsbcPhysicalEndpoint::~TUsbcPhysicalEndpoint() |
297 TUsbcPhysicalEndpoint::~TUsbcPhysicalEndpoint() |
281 { |
298 { |
282 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcPhysicalEndpoint::~TUsbcPhysicalEndpoint()")); |
299 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCPHYSICALENDPOINT_TUSBCPHYSICALENDPOINT_DES, |
|
300 "TUsbcPhysicalEndpoint::~TUsbcPhysicalEndpoint()" ); |
283 iLEndpoint = NULL; |
301 iLEndpoint = NULL; |
284 } |
302 } |
285 |
303 |
286 |
304 |
287 TUsbcLogicalEndpoint::TUsbcLogicalEndpoint(DUsbClientController* aController, TUint aEndpointNum, |
305 TUsbcLogicalEndpoint::TUsbcLogicalEndpoint(DUsbClientController* aController, TUint aEndpointNum, |
288 const TUsbcEndpointInfo& aEpInfo, TUsbcInterface* aInterface, |
306 const TUsbcEndpointInfo& aEpInfo, TUsbcInterface* aInterface, |
289 TUsbcPhysicalEndpoint* aPEndpoint) |
307 TUsbcPhysicalEndpoint* aPEndpoint) |
290 : iController(aController), iLEndpointNum(aEndpointNum), iInfo(aEpInfo), iInterface(aInterface), |
308 : iController(aController), iLEndpointNum(aEndpointNum), iInfo(aEpInfo), iInterface(aInterface), |
291 iPEndpoint(aPEndpoint) |
309 iPEndpoint(aPEndpoint) |
292 { |
310 { |
293 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcLogicalEndpoint::TUsbcLogicalEndpoint()")); |
311 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_CONS, |
|
312 "TUsbcLogicalEndpoint::TUsbcLogicalEndpoint()" ); |
294 // Adjust FS/HS endpoint sizes |
313 // Adjust FS/HS endpoint sizes |
295 if (iInfo.AdjustEpSizes(iEpSize_Fs, iEpSize_Hs) != KErrNone) |
314 if (iInfo.AdjustEpSizes(iEpSize_Fs, iEpSize_Hs) != KErrNone) |
296 { |
315 { |
297 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Unknown endpoint type: %d", iInfo.iType)); |
316 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_CONS_DUP1, |
298 } |
317 " Error: Unknown endpoint type: %d", iInfo.iType ); |
299 __KTRACE_OPT(KUSB, Kern::Printf(" Now set: iEpSize_Fs=%d iEpSize_Hs=%d (iInfo.iSize=%d)", |
318 } |
300 iEpSize_Fs, iEpSize_Hs, iInfo.iSize)); |
319 OstTraceDefExt3( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_CONS_DUP2, |
|
320 " Now set: iEpSize_Fs=%d iEpSize_Hs=%d (iInfo.iSize=%d)", iEpSize_Fs, iEpSize_Hs, iInfo.iSize ); |
301 // Adjust HS polling interval |
321 // Adjust HS polling interval |
302 if (iInfo.AdjustPollInterval() != KErrNone) |
322 if (iInfo.AdjustPollInterval() != KErrNone) |
303 { |
323 { |
304 __KTRACE_OPT(KPANIC, Kern::Printf(" Error: Unknown ep type (%d) or invalid interval value (%d)", |
324 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_CONS_DUP3, |
305 iInfo.iType, iInfo.iInterval)); |
325 " Error: Unknown ep type (%d) or invalid interval value (%d)", iInfo.iType, iInfo.iInterval ); |
306 } |
326 } |
307 __KTRACE_OPT(KUSB, Kern::Printf(" Now set: iInfo.iInterval=%d iInfo.iInterval_Hs=%d", |
327 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_CONS_DUP4, |
308 iInfo.iInterval, iInfo.iInterval_Hs)); |
328 " Now set: iInfo.iInterval=%d iInfo.iInterval_Hs=%d", iInfo.iInterval, iInfo.iInterval_Hs ); |
309 // Additional transactions requested on a non High Bandwidth ep? |
329 // Additional transactions requested on a non High Bandwidth ep? |
310 if ((iInfo.iTransactions > 0) && !aPEndpoint->iCaps.iHighBandwidth) |
330 if ((iInfo.iTransactions > 0) && !aPEndpoint->iCaps.iHighBandwidth) |
311 { |
331 { |
312 __KTRACE_OPT(KPANIC, |
332 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FATAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_CONS_DUP5, |
313 Kern::Printf(" Warning: Additional transactions requested but not a High Bandwidth ep")); |
333 " Warning: Additional transactions requested but not a High Bandwidth ep" ); |
314 } |
334 } |
315 } |
335 } |
316 |
336 |
317 |
337 |
318 TUsbcLogicalEndpoint::~TUsbcLogicalEndpoint() |
338 TUsbcLogicalEndpoint::~TUsbcLogicalEndpoint() |
319 { |
339 { |
320 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcLogicalEndpoint::~TUsbcLogicalEndpoint: #%d", iLEndpointNum)); |
340 OstTraceDef1( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_DES, |
|
341 "TUsbcLogicalEndpoint::~TUsbcLogicalEndpoint: #%d", iLEndpointNum ); |
321 // If the real endpoint this endpoint points to is also used by |
342 // If the real endpoint this endpoint points to is also used by |
322 // any other logical endpoint in any other setting of this interface |
343 // any other logical endpoint in any other setting of this interface |
323 // then we leave the real endpoint marked as used. Otherwise we mark |
344 // then we leave the real endpoint marked as used. Otherwise we mark |
324 // it as available (set its ifc number pointer to NULL). |
345 // it as available (set its ifc number pointer to NULL). |
325 const TInt n = iInterface->iInterfaceSet->iInterfaces.Count(); |
346 const TInt n = iInterface->iInterfaceSet->iInterfaces.Count(); |
330 for (TInt j = 0; j < m; ++j) |
351 for (TInt j = 0; j < m; ++j) |
331 { |
352 { |
332 const TUsbcLogicalEndpoint* const ep = ifc->iEndpoints[j]; |
353 const TUsbcLogicalEndpoint* const ep = ifc->iEndpoints[j]; |
333 if ((ep->iPEndpoint == iPEndpoint) && (ep != this)) |
354 if ((ep->iPEndpoint == iPEndpoint) && (ep != this)) |
334 { |
355 { |
335 __KTRACE_OPT(KUSB, Kern::Printf(" Physical endpoint still in use -> we leave it as is")); |
356 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_DES_DUP1, |
|
357 " Physical endpoint still in use -> we leave it as is" ); |
336 return; |
358 return; |
337 } |
359 } |
338 } |
360 } |
339 } |
361 } |
340 __KTRACE_OPT(KUSB, Kern::Printf(" Closing DMA channel")); |
362 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_DES_DUP2, |
|
363 " Closing DMA channel" ); |
341 const TInt idx = iController->EpAddr2Idx(iPEndpoint->iEndpointAddr); |
364 const TInt idx = iController->EpAddr2Idx(iPEndpoint->iEndpointAddr); |
342 // If the endpoint doesn't support DMA (now or ever) the next operation will be a no-op. |
365 // If the endpoint doesn't support DMA (now or ever) the next operation will be a no-op. |
343 iController->CloseDmaChannel(idx); |
366 iController->CloseDmaChannel(idx); |
344 __KTRACE_OPT(KUSB, Kern::Printf(" Setting physical ep 0x%02x ifc number to NULL (was %d)", |
367 OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TUSBCLOGICALENDPOINT_TUSBCLOGICALENDPOINT_DES_DUP3, |
345 iPEndpoint->iEndpointAddr, *iPEndpoint->iIfcNumber)); |
368 " Setting physical ep 0x%02x ifc number to NULL (was %d)", |
|
369 iPEndpoint->iEndpointAddr, *iPEndpoint->iIfcNumber ); |
346 iPEndpoint->iIfcNumber = NULL; |
370 iPEndpoint->iIfcNumber = NULL; |
347 } |
371 } |
348 |
372 |
349 |
373 |
350 TUsbcInterface::TUsbcInterface(TUsbcInterfaceSet* aIfcSet, TUint8 aSetting, TBool aNoEp0Requests) |
374 TUsbcInterface::TUsbcInterface(TUsbcInterfaceSet* aIfcSet, TUint8 aSetting, TBool aNoEp0Requests) |
351 : iEndpoints(2), iInterfaceSet(aIfcSet), iSettingCode(aSetting), iNoEp0Requests(aNoEp0Requests) |
375 : iEndpoints(2), iInterfaceSet(aIfcSet), iSettingCode(aSetting), iNoEp0Requests(aNoEp0Requests) |
352 { |
376 { |
353 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcInterface::TUsbcInterface()")); |
377 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCINTERFACE_TUSBCINTERFACE_CONS, |
|
378 "TUsbcInterface::TUsbcInterface()" ); |
354 } |
379 } |
355 |
380 |
356 |
381 |
357 TUsbcInterface::~TUsbcInterface() |
382 TUsbcInterface::~TUsbcInterface() |
358 { |
383 { |
359 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcInterface::~TUsbcInterface()")); |
384 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCINTERFACE_TUSBCINTERFACE_DES, |
|
385 "TUsbcInterface::~TUsbcInterface()" ); |
360 iEndpoints.ResetAndDestroy(); |
386 iEndpoints.ResetAndDestroy(); |
361 } |
387 } |
362 |
388 |
363 |
389 |
364 TUsbcInterfaceSet::TUsbcInterfaceSet(const DBase* aClientId, TUint8 aIfcNum) |
390 TUsbcInterfaceSet::TUsbcInterfaceSet(const DBase* aClientId, TUint8 aIfcNum) |
365 : iInterfaces(2), iClientId(aClientId), iInterfaceNumber(aIfcNum), iCurrentInterface(0) |
391 : iInterfaces(2), iClientId(aClientId), iInterfaceNumber(aIfcNum), iCurrentInterface(0) |
366 { |
392 { |
367 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcInterfaceSet::TUsbcInterfaceSet()")); |
393 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCINTERFACESET_TUSBCINTERFACESET_CONS, |
|
394 "TUsbcInterfaceSet::TUsbcInterfaceSet()" ); |
368 } |
395 } |
369 |
396 |
370 |
397 |
371 TUsbcInterfaceSet::~TUsbcInterfaceSet() |
398 TUsbcInterfaceSet::~TUsbcInterfaceSet() |
372 { |
399 { |
373 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcInterfaceSet::~TUsbcInterfaceSet()")); |
400 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCINTERFACESET_TUSBCINTERFACESET_DES, |
|
401 "TUsbcInterfaceSet::~TUsbcInterfaceSet()" ); |
374 iInterfaces.ResetAndDestroy(); |
402 iInterfaces.ResetAndDestroy(); |
375 } |
403 } |
376 |
404 |
377 |
405 |
378 TUsbcConfiguration::TUsbcConfiguration(TUint8 aConfigVal) |
406 TUsbcConfiguration::TUsbcConfiguration(TUint8 aConfigVal) |
379 : iInterfaceSets(1), iConfigValue(aConfigVal) // iInterfaceSets(1): granularity |
407 : iInterfaceSets(1), iConfigValue(aConfigVal) // iInterfaceSets(1): granularity |
380 { |
408 { |
381 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcConfiguration::TUsbcConfiguration()")); |
409 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCCONFIGURATION_TUSBCCONFIGURATION_CONS, |
|
410 "TUsbcConfiguration::TUsbcConfiguration()" ); |
382 } |
411 } |
383 |
412 |
384 |
413 |
385 TUsbcConfiguration::~TUsbcConfiguration() |
414 TUsbcConfiguration::~TUsbcConfiguration() |
386 { |
415 { |
387 __KTRACE_OPT(KUSB, Kern::Printf("TUsbcConfiguration::~TUsbcConfiguration()")); |
416 OstTraceDef0( OST_TRACE_CATEGORY_RND, TRACE_FLOW, TUSBCCONFIGURATION_TUSBCCONFIGURATION_DES, |
|
417 "TUsbcConfiguration::~TUsbcConfiguration()" ); |
388 iInterfaceSets.ResetAndDestroy(); |
418 iInterfaceSets.ResetAndDestroy(); |
389 } |
419 } |
390 |
420 |
391 |
421 |
392 _LIT(KDriverName, "Usbcc"); |
422 _LIT(KDriverName, "Usbcc"); |