コード例 #1
0
			/**	\brief	解析
			*   
			*	@remarks 	解析
			*	@see		ParseImp
			*	@return   	U1
			*	@param		Mesh::Data * pData
			*	@param		std::vector<Mesh::Vertex> & lstVertex
			*	@param		std::vector<Mesh::Face32> & lstFace32
			*	@param		std::vector<Mesh::Face16> & lstFace16
			*	@param		U1 & bUseNormal
			*	@param		U1 & bUseTexCoord
			*	@param		U1 & bUseTangent
			*	@note
			*
			**/
			virtual	U1	Parse(	Data*					pData,
								std::vector<Mesh::Vertex>&	lstVertex,
								std::vector<Mesh::Face32>&	lstFace32,
								std::vector<Mesh::Face16>&	lstFace16,
								U1&							bUseNormal,
								U1&							bUseTexCoord,
								U1&							bUseTangent)
			{
				ParseOgre parse;
				MemoryDataStream	data(pData->GetBuff(),pData->GetSize());
				DataStreamPtr dataptr(&data);
				OgreMesh mesh;
				parse.importMesh(dataptr,&mesh);
	
				UInt iSize	=	mesh.mSubMeshList.size();
				if(iSize==0)
					return false;
	
				SubMesh&	subMesh	=	*mesh.mSubMeshList[0];
				lstVertex	=	subMesh.m_lstVertex;
				lstFace16	=	subMesh.m_lstFace16;
				lstFace32	=	subMesh.m_lstFace32;
	
				return true;
	
			};
コード例 #2
0
ファイル: otgroot.cpp プロジェクト: kuailexs/symbiandump-os1
/** Commonly used step to load the USB Client Driver and set up
 *	a 'useful' default device descriptor set
 * @return ETrue if the ldd loaded sucessfully
 */
TBool COtgRoot::StepLoadClient(TUint16 aPID, 
								TBool aEnableHNP/*=ETrue*/, 
								TBool aEnableSRP/*=ETrue*/)
	{
	test.Printf(_L("Load USBCC Client 0x%04x\n"),aPID);
	OstTrace1(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT, "Load USBCC Client 0x%04x\n",aPID);

	TInt err;

	// The incoming PID is expected to have a form of 0x0TTT or 0xFTTT
	// where 'TTT' is the test number: if the lead is 0xF000 we now 
	// overlay an 'A' or a 'B' depending on the default role
	
	if (   ( ( aPID & 0xF000 ) != 0xF000 )
		&& ( ( aPID & 0xF000 ) != 0x0000 )
	   )
		{
		AssertionFailed(KErrAbort, _L("Bad default PID"));
		}
		
	if ( aPID & 0xF000 )
		{
		aPID &= 0x0FFF;
		
		if ( gTestRoleMaster )
			{
			// this is the 'B' device
			aPID |= 0xB000;
			}
		else
			{
			// this is the 'A' device
			aPID |= 0xA000;
			}
		}
	
	// Load the LDD - note the name is *not* the same as for unload

	test.Printf(_L("..Load LDD\n"));
	OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP01, "..Load LDD\n");
	err = User::LoadLogicalDevice( KUsbcLddFileName );
	if ((err != KErrNone) && (err !=KErrAlreadyExists))
		{
		AssertionFailed2(KErrAbort, _L("Client Load Fail "), err);
		return (EFalse);
		}

	// Open the Client

	test.Printf(_L("..Open LDD\n"));
	OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP02, "..Open LDD\n");
	err = oUsbcClient.Open(0);
	if (err != KErrNone)
		{
		AssertionFailed2(KErrAbort, _L("Client Open Fail "), err);
		return (EFalse);
		}

	// Set up descriptors
	
	test.Printf(_L("..Setup Descriptors\n"));
	OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP03, "..Setup Descriptors\n");

	// the OTG descriptor
	TBuf8<KUsbDescSize_Otg> theOtgDescriptor;
	err = oUsbcClient.GetOtgDescriptor(theOtgDescriptor);
	if (err != KErrNone)
		{
		AssertionFailed2(KErrAbort, _L("OTG GetDes Fail "), err);
		return (EFalse);
		}
	// modify OTG descriptor based on parameters passed
	if (aEnableHNP)
		aEnableSRP=ETrue;	// Keep the device Legal according to OTG spec 6.4.2
	/*Attribute Fields
	  D7…2: Reserved (reset to zero)
	  D1: HNP support
	  D0: SRP support*/
	TUint8 aByte = theOtgDescriptor[2];
		aByte &= (~0x03);
		aByte |= (aEnableSRP? 1 : 0); 
		aByte |= (aEnableHNP? 2 : 0); 
	test.Printf(_L("..Change OTG 0x%02X->0x%02X\n"), theOtgDescriptor[2], aByte);
	OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP04, "..Change OTG 0x%02X->0x%02X\n", (TUint32)theOtgDescriptor[2], (TUint32)aByte);
	theOtgDescriptor[2] = aByte;
	
	err = oUsbcClient.SetOtgDescriptor(theOtgDescriptor);
	if (err != KErrNone)
		{
		AssertionFailed2(KErrAbort, _L("OTG SetDes Fail "), err);
		return (EFalse);
		}
	
	//

	TUsbDeviceCaps d_caps;
	err = oUsbcClient.DeviceCaps(d_caps);
	TBool softwareConnect;

	if (err != KErrNone)
		{
		AssertionFailed2(KErrAbort, _L("Client DevCaps Fail "), err);
		return (EFalse);
		}

	const TInt n = d_caps().iTotalEndpoints;

	softwareConnect = d_caps().iConnect;
	test.Printf(_L("..SoftwareConnect = %d\n"),softwareConnect);
	OstTrace1(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP05, "..SoftwareConnect = %d\n",softwareConnect);

	if (n < 2)
		{
		AssertionFailed2(KErrAbort, _L("Client Endpoints Fail "), err);
		return (EFalse);
		}

	// Endpoints
	TUsbcEndpointData data[KUsbcMaxEndpoints];
	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
	err = oUsbcClient.EndpointCaps(dataptr);
	if (err != KErrNone)
		{
		AssertionFailed2(KErrAbort, _L("Client EpCaps Fail "), err);
		return (EFalse);
		}

	// Set up the active interface
	TUsbcInterfaceInfoBuf ifc;
	TInt ep_found = 0;
	TBool foundBulkIN = EFalse;
	TBool foundBulkOUT = EFalse;
	for (TInt i = 0; i < n; i++)
		{
		const TUsbcEndpointCaps* const caps = &data[i].iCaps;
		const TInt mps = caps->MaxPacketSize();
		if (!foundBulkIN &&
			(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) ==
			(KUsbEpTypeBulk | KUsbEpDirIn))
			{
			if (!(mps == 64 || mps == 512))
				{
				}
			// EEndpoint1 is going to be our Tx (IN) endpoint
			ifc().iEndpointData[0].iType = KUsbEpTypeBulk;
			ifc().iEndpointData[0].iDir	 = KUsbEpDirIn;
			ifc().iEndpointData[0].iSize = mps;
			foundBulkIN = ETrue;
			if (++ep_found == 2)
				break;
			}
		else if (!foundBulkOUT &&
			(caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) ==
			(KUsbEpTypeBulk | KUsbEpDirOut))
			{
			if (!(mps == 64 || mps == 512))
				{
				}
			// EEndpoint2 is going to be our Rx (OUT) endpoint
			ifc().iEndpointData[1].iType = KUsbEpTypeBulk;
			ifc().iEndpointData[1].iDir	 = KUsbEpDirOut;
			ifc().iEndpointData[1].iSize = mps;
			foundBulkOUT = ETrue;
			if (++ep_found == 2)
				break;
			}
		}
	if (ep_found != 2)
		{
		AssertionFailed2(KErrAbort, _L("Client EpFound Fail "), err);
		return (EFalse);
		}

	_LIT16(ifcname, "T_OTGDI Test Interface (Default Setting 0)");
	ifc().iString = const_cast<TDesC16*>(&ifcname);
	ifc().iTotalEndpointsUsed = 2;
	ifc().iClass.iClassNum	  = 0xff;						// vendor-specific
	ifc().iClass.iSubClassNum = 0xff;						// vendor-specific
	ifc().iClass.iProtocolNum = 0xff;						// vendor-specific

	err = oUsbcClient.SetInterface(0, ifc, (EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault));

	if( err != KErrNone )
		{
		AssertionFailed2(KErrAbort, _L("Client SetInt Fail "), err);
		return (EFalse);
		}
	
	// Set the revised PID
	
	TBuf8<KUsbDescSize_Device> theDeviceDescriptor;
	err = oUsbcClient.GetDeviceDescriptor(theDeviceDescriptor);
	if (err != KErrNone)
		{
		AssertionFailed2(KErrAbort, _L("Client GetDes Fail "), err);
		return (EFalse);
		}

	TUint16 oldPID = ( theDeviceDescriptor[10] )
		           + ( theDeviceDescriptor[11] << 8 );

	theDeviceDescriptor[10] = ( aPID & 0x00FF );
	theDeviceDescriptor[11] = ( aPID & 0xFF00 ) >> 8;

	test.Printf(_L("..Change PID 0x%04X->0x%04X\n"), oldPID, aPID);
	OstTraceExt2(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP06, "..Change PID 0x%04X->0x%04X\n", (TUint32)oldPID, (TUint32)aPID);

	err = oUsbcClient.SetDeviceDescriptor(theDeviceDescriptor);
	if (err != KErrNone)
		{
		AssertionFailed2(KErrAbort, _L("Client SetDes Fail "), err);
		return (EFalse);
		}


	// Power Up UDC - KErrNotReady is expected

	test.Printf(_L("..Power Up UDC\n"));
	OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP07, "..Power Up UDC\n");

	err = oUsbcClient.PowerUpUdc();
	if( err != KErrNotReady )
		{
		AssertionFailed2(KErrAbort, _L("PowerUp UDC Fail "), err);
		return (EFalse);
		}

	// Connect to Host

	test.Printf(_L("..Connect to Host\n"));
	OstTrace0(TRACE_NORMAL, COTGROOT_STEPLOADCLIENT_DUP08, "..Connect to Host\n");

	err = oUsbcClient.DeviceConnectToHost();
	if( err != KErrNone )
		{
		AssertionFailed2(KErrAbort, _L("Host Connect Fail "), err);
		return (EFalse);
		}

	// Default no-problem return

	return(ETrue);
	}
コード例 #3
0
TInt CCdcDataInterface::SetUpInterface()
/**
 * Retrieves the device capabilities and searches for suitable input and 
 * output bulk endpoints. If suitable endpoints are found, an interface 
 * descriptor for the endpoints is registered with the LDD.
 */
	{
	OstTraceFunctionEntry0( CCDCDATAINTERFACE_SETUPINTERFACE_ENTRY );

	TUsbDeviceCaps dCaps;
	TInt ret = iLdd.DeviceCaps(dCaps);
	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE, "CCdcDataInterface::SetUpInterface;\tchecking result of DeviceCaps" );
	if ( ret )
		{
		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP1, "CCdcDataInterface::SetUpInterface;ret=%d", ret );
		OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT );
		return ret;
		}

	TInt maxBulkPacketSize = (dCaps().iHighSpeed) ? KMaxPacketTypeBulkHS : KMaxPacketTypeBulkFS;
	const TUint KRequiredNumberOfEndpoints = 2;

	const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints);
	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP2, 
			"CCdcDataInterface::SetUpInterface;totalEndpoints=%d", (TInt)totalEndpoints );
	
	if ( totalEndpoints < KRequiredNumberOfEndpoints )
		{
		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP3, "CCdcDataInterface::SetUpInterface;ret=%d", KErrGeneral );
		OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP1 );
		return KErrGeneral;
		}
	
	// Endpoints
	TUsbcEndpointData data[KUsbcMaxEndpoints];
	TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data));
	ret = iLdd.EndpointCaps(dataptr);
	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP9, "CCdcDataInterface::SetUpInterface;\tchecking result of EndpointCaps" );
	if ( ret )
		{
		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP4, "CCdcDataInterface::SetUpInterface;ret=%d", ret );
		OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP2 );
		return ret;
		}

	// 
	TUsbcInterfaceInfoBuf ifc;
	TBool foundIn = EFalse;
	TBool foundOut = EFalse;
	
	for ( TUint i = 0; !(foundIn && foundOut) && i < totalEndpoints; i++ )
		{
		const TUsbcEndpointCaps* caps = &data[i].iCaps;
		if (!caps)
			{
			OstTraceExt1( TRACE_FATAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP5, "CCdcDataInterface::SetUpInterface;caps=%p", caps );
			__ASSERT_DEBUG( EFalse, User::Panic(KAcmPanicCat, EPanicInternalError) );
			}
		if (data[i].iInUse)
			continue;

		//get the max packet size it can potentially support
		//it's possible that it can support Isoch (1023) which is greater
		//than max for Bulk at 64
		const TInt maxSize = Min (	maxBulkPacketSize, 
									caps->MaxPacketSize() );

		const TUint KBulkInFlags = KUsbEpTypeBulk | KUsbEpDirIn;
		const TUint KBulkOutFlags = KUsbEpTypeBulk | KUsbEpDirOut;

		// use EEndPoint1 for TX (IN) EEndpoint1
		if (! foundIn && (caps->iTypesAndDir & KBulkInFlags) == KBulkInFlags)
			{

			ifc().iEndpointData[0].iType  = KUsbEpTypeBulk;
			ifc().iEndpointData[0].iDir   = KUsbEpDirIn; 

			//get the max packet size it can potentially support
			//it's possible that it can support Isoch (1023) which is greater
			//than max for Bulk at 64
			ifc().iEndpointData[0].iSize  = maxSize;
			foundIn = ETrue;
			}
		// use EEndPoint2 for RX (OUT) endpoint
		else if (	!foundOut 
			&&		(caps->iTypesAndDir & KBulkOutFlags) == KBulkOutFlags
			)
			{
			// EEndpoint2 is going to be our RX (OUT, read) endpoint
			ifc().iEndpointData[1].iType  = KUsbEpTypeBulk;
			ifc().iEndpointData[1].iDir   = KUsbEpDirOut;

			//get the max packet size it can potentially support
			//it's possible that it can support Isoch (1023) which is greater
			//than max for Bulk at 64
			ifc().iEndpointData[1].iSize  = maxSize;
			foundOut = ETrue;
			}
		}

	if (! (foundIn && foundOut))
		{
		OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP6, "CCdcDataInterface::SetUpInterface;ret=%d", KErrGeneral );
		OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP3 );
		return KErrGeneral;
		}

		// If the device supports USB High-speed, then we request 64KB buffers
		// (otherwise the default 4KB ones will do).

	TUint bandwidthPriority = (EUsbcBandwidthOUTDefault | EUsbcBandwidthINDefault);
	if (dCaps().iHighSpeed)
		{
		bandwidthPriority = (EUsbcBandwidthOUTPlus2 | EUsbcBandwidthINPlus2);
		}

	ifc().iString = &iIfcName;
	ifc().iTotalEndpointsUsed = KRequiredNumberOfEndpoints;
	ifc().iClass.iClassNum	  = 0x0A; // Table 18- Data Interface Class
	ifc().iClass.iSubClassNum = 0x00; // Section 4.6- unused.
	ifc().iClass.iProtocolNum = 0x00; // Table 19- no class specific protocol required

	// Indicate that this interface does not expect any control transfers 
	// from EP0.
	ifc().iFeatureWord |= KUsbcInterfaceInfo_NoEp0RequestsPlease;

	OstTrace0( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP7, "CCdcDataInterface::SetUpInterface;\tcalling SetInterface" );
	// Zero effectively indicates that alternate interfaces are not used.
	ret = iLdd.SetInterface(0, ifc, bandwidthPriority);

	OstTrace1( TRACE_NORMAL, CCDCDATAINTERFACE_SETUPINTERFACE_DUP8, "CCdcDataInterface::SetUpInterface;ret=%d", ret );
	OstTraceFunctionExit0( CCDCDATAINTERFACE_SETUPINTERFACE_EXIT_DUP4 );
	return ret;
	}