kerneltest/e32test/usb/t_usb_device/src/activecontrol.cpp
branchRCL_3
changeset 19 4a8fed1c0ef6
parent 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
15:2d65c2f76d7b 19:4a8fed1c0ef6
   125 
   125 
   126 CActiveControl::CActiveControl(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile)
   126 CActiveControl::CActiveControl(CConsoleBase* aConsole, TDes * aConfigFile, TDes * aScriptFile)
   127 	: CActive(EPriorityNormal),
   127 	: CActive(EPriorityNormal),
   128 	  iConsole(aConsole),
   128 	  iConsole(aConsole),
   129 	  iSoftwareConnect(EFalse),
   129 	  iSoftwareConnect(EFalse),
       
   130 	  iSupportResourceAllocationV2(EFalse),
   130 	  iHighSpeed(EFalse),
   131 	  iHighSpeed(EFalse),
   131 	  iConfigFileName(aConfigFile),
   132 	  iConfigFileName(aConfigFile),
   132 	  iScriptFileName(aScriptFile),
   133 	  iScriptFileName(aScriptFile),
   133 	  iEp0PacketSize(0)
   134 	  iEp0PacketSize(0)
   134 	{}
   135 	{}
   217 				{
   218 				{
   218 				QueryUsbClientL(lddPtr, &iPort[portNumber]);
   219 				QueryUsbClientL(lddPtr, &iPort[portNumber]);
   219 				}
   220 				}
   220 
   221 
   221 			test_NotNull(ifPtr);
   222 			test_NotNull(ifPtr);
   222 
   223 			
       
   224 			if (iSupportResourceAllocationV2)
       
   225 				{
       
   226 				PopulateInterfaceResourceAllocation(ifPtr, portNumber);
       
   227 				}
       
   228 				
   223 			IFConfigPtr defaultIfPtr = ifPtr;
   229 			IFConfigPtr defaultIfPtr = ifPtr;
   224 			SetupInterface(&ifPtr,portNumber);
   230 			SetupInterface(&ifPtr,portNumber);
   225 					
   231 					
   226 			#ifdef USB_SC
   232 			#ifdef USB_SC
   227 			RChunk *tChunk = &gChunk;
   233 			RChunk *tChunk = &gChunk;
   228 			test_KErrNone(iPort[portNumber].FinalizeInterface(tChunk));
   234 			test_KErrNone(iPort[portNumber].FinalizeInterface(tChunk));
   229 			#endif
   235 			#endif
   230 
   236 
   231 			// 	allocate endpoint DMA and double buffering for all endpoints on default interface
   237 			if (!iSupportResourceAllocationV2)
   232 			for (TUint8 i = 1; i <= defaultIfPtr->iInfoPtr->iTotalEndpointsUsed; i++)
   238 				{
   233 				{
   239 				// 	allocate endpoint DMA and double buffering for all endpoints on default interface when using resource allocation v1 api
   234 				defaultIfPtr->iEpDMA[i-1] ? AllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i);
   240 				for (TUint8 i = 1; i <= defaultIfPtr->iInfoPtr->iTotalEndpointsUsed; i++)
   235 				#ifndef USB_SC
   241 					{
   236 				defaultIfPtr->iEpDoubleBuff[i-1] ? AllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i);
   242 					defaultIfPtr->iEpDMA[i-1] ? AllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i);
   237 				#endif
   243 					#ifndef USB_SC
   238 				}				
   244 					defaultIfPtr->iEpDoubleBuff[i-1] ? AllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i);
   239 
   245 					#endif
       
   246 					}				
       
   247 				}
   240 			}
   248 			}
   241 	
   249 	
   242 		iTotalChannels += lddPtr->iNumChannels;
   250 		iTotalChannels += lddPtr->iNumChannels;
   243 		nextPort += lddPtr->iNumChannels;	
   251 		nextPort += lddPtr->iNumChannels;	
   244 		lddPtr = lddPtr->iPtrNext;	
   252 		lddPtr = lddPtr->iPtrNext;	
   367 					
   375 					
   368 			#ifdef USB_SC
   376 			#ifdef USB_SC
   369 			RChunk *tChunk = &gChunk;
   377 			RChunk *tChunk = &gChunk;
   370 			test_KErrNone(iPort[portNumber].FinalizeInterface(tChunk));
   378 			test_KErrNone(iPort[portNumber].FinalizeInterface(tChunk));
   371 			#endif
   379 			#endif
   372 
   380 			
   373 			// 	allocate endpoint DMA and double buffering for all endpoints on default interface
   381 			if (!iSupportResourceAllocationV2)
   374 			for (TUint8 i = 1; i <= defaultIfPtr->iInfoPtr->iTotalEndpointsUsed; i++)
   382 				{
   375 				{
   383 				// 	allocate endpoint DMA and double buffering for all endpoints on default interface with resource allocation v1 api
   376 				defaultIfPtr->iEpDMA[i-1] ? AllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i);
   384 				for (TUint8 i = 1; i <= defaultIfPtr->iInfoPtr->iTotalEndpointsUsed; i++)
   377 				#ifndef USB_SC
   385 					{
   378 				defaultIfPtr->iEpDoubleBuff[i-1] ? AllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i);
   386 					defaultIfPtr->iEpDMA[i-1] ? AllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i);
   379 				#endif
   387 					#ifndef USB_SC
       
   388 					defaultIfPtr->iEpDoubleBuff[i-1] ? AllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i);
       
   389 					#endif
       
   390 					}
   380 				}				
   391 				}				
   381 			}
   392 			}
   382 	
   393 	
   383 		nextPort += lddPtr->iNumChannels;	
   394 		nextPort += lddPtr->iNumChannels;	
   384 		lddPtr = lddPtr->iPtrNext;	
   395 		lddPtr = lddPtr->iPtrNext;	
   419 			
   430 			
   420 			}
   431 			}
   421 		}
   432 		}
   422 	
   433 	
   423 	test.End();
   434 	test.End();
       
   435 	}
       
   436 
       
   437 void CActiveControl::FillEndpointsResourceAllocation(IFConfigPtr aIfCfg)
       
   438 	{
       
   439 	
       
   440 	#ifdef USB_SC
       
   441 		TUsbcScInterfaceInfo* iInfoPtr = aIfCfg->iInfoPtr;
       
   442 	#else
       
   443 		TUsbcInterfaceInfo* iInfoPtr = aIfCfg->iInfoPtr;
       
   444 	#endif
       
   445 	
       
   446 	// 	fill resource allocation info in the endpoint info with resource allocation v2
       
   447 	for (TUint8 i = 1; i <= iInfoPtr->iTotalEndpointsUsed; i++)
       
   448 		{
       
   449 		if (aIfCfg->iEpDMA[i-1])
       
   450 			{
       
   451 			iInfoPtr->iEndpointData[i-1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA;
       
   452 			}
       
   453 		else
       
   454 			{
       
   455 			iInfoPtr->iEndpointData[i-1].iFeatureWord1 &= (~KUsbcEndpointInfoFeatureWord1_DMA);
       
   456 			}
       
   457 		#ifndef USB_SC
       
   458 		if (aIfCfg->iEpDoubleBuff[i-1])
       
   459 			{
       
   460 			iInfoPtr->iEndpointData[i-1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DoubleBuffering;
       
   461 			}
       
   462 		else
       
   463 			{
       
   464 			iInfoPtr->iEndpointData[i-1].iFeatureWord1 &= (~KUsbcEndpointInfoFeatureWord1_DoubleBuffering);
       
   465 			}
       
   466 		#endif
       
   467 		}	
       
   468 	}
       
   469 
       
   470 // all alternative settings of the interface 'aFirstIfCfg' will be populated
       
   471 void CActiveControl::PopulateInterfaceResourceAllocation(IFConfigPtr aFirstIfCfg, TInt aPortNumber)
       
   472 	{
       
   473 	FillEndpointsResourceAllocation(aFirstIfCfg);
       
   474 	
       
   475 	IFConfigPtr ifCfgPtr = aFirstIfCfg->iPtrNext;
       
   476 	while (ifCfgPtr != NULL)
       
   477 		{
       
   478 		if (ifCfgPtr->iAlternateSetting)
       
   479 			{
       
   480 			FillEndpointsResourceAllocation(ifCfgPtr);
       
   481 			ifCfgPtr = ifCfgPtr->iPtrNext;
       
   482 			}
       
   483 		else
       
   484 			{
       
   485 			ifCfgPtr = NULL;
       
   486 			}
       
   487 		}
   424 	}
   488 	}
   425 	
   489 	
   426 void CActiveControl::SetupInterface(IFConfigPtr* aIfPtr, TInt aPortNumber)
   490 void CActiveControl::SetupInterface(IFConfigPtr* aIfPtr, TInt aPortNumber)
   427 	{
   491 	{
   428 	test.Start (_L("Setup Interface"));
   492 	test.Start (_L("Setup Interface"));
  1395 	TUSB_PRINT1("Supports High-speed:                %s",
  1459 	TUSB_PRINT1("Supports High-speed:                %s",
  1396 				d_caps().iHighSpeed ? _S("yes") : _S("no"));
  1460 				d_caps().iHighSpeed ? _S("yes") : _S("no"));
  1397 	TUSB_PRINT1("Supports unpowered cable detection: %s\n",
  1461 	TUSB_PRINT1("Supports unpowered cable detection: %s\n",
  1398 				(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ?
  1462 				(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_CableDetectWithoutPower) ?
  1399 				_S("yes") : _S("no"));
  1463 				_S("yes") : _S("no"));
       
  1464 	TUSB_PRINT1("Supports endpoint resource allocation v2 scheme: %s\n",
       
  1465 				(d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) ?
       
  1466 				_S("yes") : _S("no"));					
  1400 	TUSB_PRINT("");
  1467 	TUSB_PRINT("");
  1401 
  1468 
  1402 	iSoftwareConnect = d_caps().iConnect;					// we need to remember this
  1469 	iSoftwareConnect = d_caps().iConnect;					// we need to remember this
  1403 	test_Equal(aLddPtr->iSoftConnect,iSoftwareConnect);
  1470 	test_Equal(aLddPtr->iSoftConnect,iSoftwareConnect);
  1404 
  1471 
       
  1472 	iSupportResourceAllocationV2 = ((d_caps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0);
       
  1473 	
  1405 	// only check capabilities if set; therefore allowing them to be disabled
  1474 	// only check capabilities if set; therefore allowing them to be disabled
  1406 	if (aLddPtr->iSelfPower)
  1475 	if (aLddPtr->iSelfPower)
  1407 		{
  1476 		{
  1408 		test(d_caps().iSelfPowered);	
  1477 		test(d_caps().iSelfPowered);	
  1409 		}
  1478 		}