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