1712 } |
1748 } |
1713 |
1749 |
1714 return KErrNone; |
1750 return KErrNone; |
1715 } |
1751 } |
1716 |
1752 |
|
1753 |
|
1754 #ifdef USB_SC |
|
1755 |
|
1756 void CActiveControl::SetupTransferedInterface(IFConfigPtr* aIfPtr, TInt aPortNumber) |
|
1757 { |
|
1758 TInt r; |
|
1759 TUSB_VERBOSE_PRINT1("SetupTransferedInterface %d", aPortNumber); |
|
1760 test.Start (_L("Setup Transfered Interface ")); |
|
1761 |
|
1762 #ifdef USB_SC |
|
1763 TUsbcScInterfaceInfoBuf ifc = *((*aIfPtr)->iInfoPtr); |
|
1764 #else |
|
1765 TUsbcInterfaceInfoBuf ifc = *((*aIfPtr)->iInfoPtr); |
|
1766 #endif |
|
1767 |
|
1768 TBuf8<KUsbDescSize_Interface> ifDescriptor; |
|
1769 r = iPort[aPortNumber].GetInterfaceDescriptor(0, ifDescriptor); |
|
1770 test_KErrNone(r); |
|
1771 |
|
1772 // Check the interface descriptor |
|
1773 test(ifDescriptor[KIfcDesc_SettingOffset] == 0 && ifDescriptor[KIfcDesc_NumEndpointsOffset] == (*aIfPtr)->iInfoPtr->iTotalEndpointsUsed && |
|
1774 ifDescriptor[KIfcDesc_ClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iClassNum && |
|
1775 ifDescriptor[KIfcDesc_SubClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iSubClassNum && |
|
1776 ifDescriptor[KIfcDesc_ProtocolOffset] == (*aIfPtr)->iInfoPtr->iClass.iProtocolNum); |
|
1777 |
|
1778 if ((*aIfPtr)->iNumber != 0 && ifDescriptor[KIfcDesc_NumberOffset] != (*aIfPtr)->iNumber) |
|
1779 { |
|
1780 ifDescriptor[KIfcDesc_NumberOffset] = (*aIfPtr)->iNumber; |
|
1781 r = iPort[aPortNumber].SetInterfaceDescriptor(0, ifDescriptor); |
|
1782 test_KErrNone(r); |
|
1783 } |
|
1784 else |
|
1785 { |
|
1786 (*aIfPtr)->iNumber = ifDescriptor[KIfcDesc_NumberOffset]; |
|
1787 } |
|
1788 TUint8 interfaceNumber = (*aIfPtr)->iNumber; |
|
1789 TUSB_PRINT1 ("Interface Number %d",interfaceNumber); |
|
1790 |
|
1791 // Check all endpoint descriptors |
|
1792 TBuf8<KUsbDescSize_AudioEndpoint> epDescriptor; |
|
1793 for (TUint i = 0; i < (*aIfPtr)->iInfoPtr->iTotalEndpointsUsed; i++) |
|
1794 { |
|
1795 if (!gSkip) |
|
1796 { |
|
1797 TestEndpointDescriptor (&iPort[aPortNumber],0,i+1,(*aIfPtr)->iInfoPtr->iEndpointData[i]); |
|
1798 |
|
1799 } |
|
1800 |
|
1801 if (firstBulkOutEndpoint < 0 && ((*aIfPtr)->iInfoPtr->iEndpointData[i].iDir & KUsbEpDirOut) && |
|
1802 (*aIfPtr)->iInfoPtr->iEndpointData[i].iType == KUsbEpTypeBulk) |
|
1803 { |
|
1804 firstBulkOutEndpoint = i+1; |
|
1805 } |
|
1806 } |
|
1807 |
|
1808 TUSB_PRINT1 ("Interface number is %d",interfaceNumber); |
|
1809 (*aIfPtr)->iPortNumber = aPortNumber; |
|
1810 gInterfaceConfig [interfaceNumber] [0] = *aIfPtr; |
|
1811 |
|
1812 TInt alternateNumber = 1; |
|
1813 // check for any alternatate interfaces and set any that are found |
|
1814 * aIfPtr = (*aIfPtr)->iPtrNext; |
|
1815 if (* aIfPtr != NULL) |
|
1816 { |
|
1817 test(SupportsAlternateInterfaces()); |
|
1818 |
|
1819 IFConfigPtr ifPtr = *aIfPtr; |
|
1820 while (ifPtr != NULL) |
|
1821 { |
|
1822 if (ifPtr->iAlternateSetting) |
|
1823 { |
|
1824 ifc = *(ifPtr->iInfoPtr); |
|
1825 |
|
1826 r = iPort[aPortNumber].GetInterfaceDescriptor(alternateNumber, ifDescriptor); |
|
1827 test_KErrNone(r); |
|
1828 |
|
1829 // Check the interface descriptor |
|
1830 test(ifDescriptor[KIfcDesc_SettingOffset] == alternateNumber && ifDescriptor[KIfcDesc_NumEndpointsOffset] == (*aIfPtr)->iInfoPtr->iTotalEndpointsUsed && |
|
1831 ifDescriptor[KIfcDesc_ClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iClassNum && |
|
1832 ifDescriptor[KIfcDesc_SubClassOffset] == (*aIfPtr)->iInfoPtr->iClass.iSubClassNum && |
|
1833 ifDescriptor[KIfcDesc_ProtocolOffset] == (*aIfPtr)->iInfoPtr->iClass.iProtocolNum); |
|
1834 |
|
1835 // Check all endpoint descriptors |
|
1836 for (TUint i = 0; i < ifPtr->iInfoPtr->iTotalEndpointsUsed; i++) |
|
1837 { |
|
1838 TInt desc_size; |
|
1839 r = iPort[aPortNumber].GetEndpointDescriptorSize(alternateNumber, i+1, desc_size); |
|
1840 test_KErrNone(r); |
|
1841 test_Equal(KUsbDescSize_Endpoint + (*aIfPtr)->iInfoPtr->iEndpointData[i].iExtra,static_cast<TUint>(desc_size)); |
|
1842 |
|
1843 r = iPort[aPortNumber].GetEndpointDescriptor(alternateNumber, i+1, epDescriptor); |
|
1844 test_KErrNone(r); |
|
1845 |
|
1846 test((((*aIfPtr)->iInfoPtr->iEndpointData[i].iDir & KUsbEpDirIn) && (epDescriptor[KEpDesc_AddressOffset] & 0x80) || |
|
1847 !((*aIfPtr)->iInfoPtr->iEndpointData[i].iDir & KUsbEpDirIn) && !(epDescriptor[KEpDesc_AddressOffset] & 0x80)) && |
|
1848 EpTypeMask2Value((*aIfPtr)->iInfoPtr->iEndpointData[i].iType) == (TUint)(epDescriptor[KEpDesc_AttributesOffset] & 0x03) && |
|
1849 (*aIfPtr)->iInfoPtr->iEndpointData[i].iInterval == epDescriptor[KEpDesc_IntervalOffset]); |
|
1850 |
|
1851 |
|
1852 if (!gSkip && (*aIfPtr)->iInfoPtr->iEndpointData[i].iExtra) |
|
1853 { |
|
1854 test.Next(_L("Extended Endpoint Descriptor Manipulation")); |
|
1855 TUint8 addr = 0x85; // bogus address |
|
1856 if (epDescriptor[KEpDesc_SynchAddressOffset] == addr) |
|
1857 addr++; |
|
1858 epDescriptor[KEpDesc_SynchAddressOffset] = addr; |
|
1859 r = iPort[aPortNumber].SetEndpointDescriptor(alternateNumber, i+1, epDescriptor); |
|
1860 test_KErrNone(r); |
|
1861 |
|
1862 TBuf8<KUsbDescSize_AudioEndpoint> descriptor2; |
|
1863 r = iPort[aPortNumber].GetEndpointDescriptor(alternateNumber, i+1, descriptor2); |
|
1864 test_KErrNone(r); |
|
1865 |
|
1866 test.Next(_L("Compare endpoint descriptor with value set")); |
|
1867 r = descriptor2.Compare(epDescriptor); |
|
1868 test_KErrNone(r); |
|
1869 } |
|
1870 } |
|
1871 |
|
1872 |
|
1873 // if no error move on to the next interface |
|
1874 ifPtr->iPortNumber = aPortNumber; |
|
1875 ifPtr->iNumber = interfaceNumber; |
|
1876 gInterfaceConfig [interfaceNumber] [alternateNumber] = ifPtr; |
|
1877 |
|
1878 alternateNumber++; |
|
1879 ifPtr = ifPtr->iPtrNext; |
|
1880 * aIfPtr = ifPtr; |
|
1881 } |
|
1882 else |
|
1883 { |
|
1884 ifPtr = NULL; |
|
1885 } |
|
1886 } |
|
1887 } |
|
1888 iNumInterfaceSettings[aPortNumber] = alternateNumber; |
|
1889 if (!gSkip) |
|
1890 { |
|
1891 TestInvalidSetInterface (&iPort[aPortNumber],iNumInterfaceSettings[aPortNumber]); |
|
1892 TestInvalidReleaseInterface (&iPort[aPortNumber],iNumInterfaceSettings[aPortNumber]); |
|
1893 |
|
1894 //TestDescriptorManipulation(iLddPtr->iHighSpeed,&iPort[aPortNumber],alternateNumber); |
|
1895 TestOtgExtensions(&iPort[aPortNumber]); |
|
1896 TestEndpoint0MaxPacketSizes(&iPort[aPortNumber]); |
|
1897 } |
|
1898 |
|
1899 test.End(); |
|
1900 } |
|
1901 |
|
1902 |
|
1903 void CActiveControl::ConstructLOnSharedLdd(const RMessagePtr2& aMsg) |
|
1904 { |
|
1905 // currently only support one interface with one alternate settings |
|
1906 test.Start (_L("ConstructLOnSharedLdd Configuration")); |
|
1907 |
|
1908 User::LeaveIfError(iPort[0].Open(aMsg, 0, EOwnerProcess)); |
|
1909 CleanupClosePushL(iPort[0]); |
|
1910 |
|
1911 RChunk* chunk; |
|
1912 //Get the Ldd's RChunk, but don't own it. |
|
1913 User::LeaveIfError(iPort[0].GetDataTransferChunk(chunk)); |
|
1914 User::LeaveIfError(chunk->Open(aMsg, 1, FALSE, EOwnerProcess)); |
|
1915 CleanupStack::Pop(); |
|
1916 |
|
1917 |
|
1918 TInt r; |
|
1919 |
|
1920 User::LeaveIfError(iFs.Connect()); |
|
1921 |
|
1922 test_Compare(iConfigFileName->Length(),!=,0); |
|
1923 |
|
1924 iTimer.CreateLocal(); |
|
1925 iPending = EPendingNone; |
|
1926 |
|
1927 test.Next (_L("Open configuration file")); |
|
1928 // set the session path to use the ROM if no drive specified |
|
1929 r=iFs.SetSessionPath(_L("Z:\\test\\")); |
|
1930 test_KErrNone(r); |
|
1931 |
|
1932 r = iConfigFile.Open(iFs, * iConfigFileName, EFileShareReadersOnly | EFileStreamText | EFileRead); |
|
1933 test_KErrNone(r); |
|
1934 TUSB_VERBOSE_PRINT1("Configuration file %s Opened successfully", iConfigFileName->PtrZ()); |
|
1935 |
|
1936 test.Next (_L("Process configuration file")); |
|
1937 test(ProcessConfigFile (iConfigFile,iConsole,&iLddPtr)); |
|
1938 |
|
1939 iConfigFile.Close(); |
|
1940 |
|
1941 test.Next (_L("LDD in configuration file")); |
|
1942 test_NotNull(iLddPtr); |
|
1943 |
|
1944 LDDConfigPtr lddPtr = iLddPtr; |
|
1945 TInt nextPort = 0; |
|
1946 while (lddPtr != NULL) |
|
1947 { |
|
1948 // Load logical driver (LDD) |
|
1949 // (There's no physical driver (PDD) with USB: it's a kernel extension DLL which |
|
1950 // was already loaded at boot time.) |
|
1951 test.Next (_L("Loading USB LDD")); |
|
1952 TUSB_VERBOSE_PRINT1("Loading USB LDD ",lddPtr->iName.PtrZ()); |
|
1953 r = User::LoadLogicalDevice(lddPtr->iName); |
|
1954 test(r == KErrNone || r == KErrAlreadyExists); |
|
1955 |
|
1956 IFConfigPtr ifPtr = lddPtr->iIFPtr; |
|
1957 |
|
1958 test.Next (_L("Opening Channels")); |
|
1959 TUSB_VERBOSE_PRINT1("Successfully opened USB port %d", lddPtr->iNumChannels); |
|
1960 for (TInt portNumber = nextPort; portNumber < nextPort+lddPtr->iNumChannels; portNumber++) |
|
1961 { |
|
1962 test_Compare(lddPtr->iNumChannels,>,0); |
|
1963 |
|
1964 // Open USB channel |
|
1965 |
|
1966 TUSB_VERBOSE_PRINT("Successfully opened USB port"); |
|
1967 |
|
1968 // Query the USB device/Setup the USB interface |
|
1969 if (portNumber == nextPort) |
|
1970 { |
|
1971 // Change some descriptors to contain suitable values |
|
1972 SetupDescriptors(lddPtr, &iPort[portNumber]); |
|
1973 } |
|
1974 |
|
1975 if (portNumber == 0) |
|
1976 { |
|
1977 QueryUsbClientL(lddPtr, &iPort[portNumber]); |
|
1978 } |
|
1979 |
|
1980 test_NotNull(ifPtr); |
|
1981 |
|
1982 if (iSupportResourceAllocationV2) |
|
1983 { |
|
1984 PopulateInterfaceResourceAllocation(ifPtr, portNumber); |
|
1985 } |
|
1986 |
|
1987 IFConfigPtr defaultIfPtr = ifPtr; |
|
1988 SetupTransferedInterface(&ifPtr,portNumber); |
|
1989 |
|
1990 |
|
1991 if (!iSupportResourceAllocationV2) |
|
1992 { |
|
1993 // allocate endpoint DMA and double buffering for all endpoints on default interface when using resource allocation v1 api |
|
1994 for (TUint8 i = 1; i <= defaultIfPtr->iInfoPtr->iTotalEndpointsUsed; i++) |
|
1995 { |
|
1996 defaultIfPtr->iEpDMA[i-1] ? AllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateEndpointDMA(&iPort[portNumber],(TENDPOINTNUMBER)i); |
|
1997 #ifndef USB_SC |
|
1998 defaultIfPtr->iEpDoubleBuff[i-1] ? AllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i) : DeAllocateDoubleBuffering(&iPort[portNumber],(TENDPOINTNUMBER)i); |
|
1999 #endif |
|
2000 } |
|
2001 } |
|
2002 } |
|
2003 |
|
2004 iTotalChannels += lddPtr->iNumChannels; |
|
2005 nextPort += lddPtr->iNumChannels; |
|
2006 lddPtr = lddPtr->iPtrNext; |
|
2007 } |
|
2008 |
|
2009 TUSB_VERBOSE_PRINT("All Interfaces and Alternate Settings successfully set up"); |
|
2010 |
|
2011 test.Next (_L("Start Idle Counter Thread")); |
|
2012 r = iIdleCounterThread.Create(_L("IdleCounter"), IdleCounterThread, KDefaultStackSize, KMinHeapSize, KMinHeapSize, NULL); |
|
2013 test_KErrNone(r); |
|
2014 iIdleCounterThread.Resume(); |
|
2015 // Allow some time for low-priority counter process |
|
2016 User::After(100000); // 0.1 second |
|
2017 r = iIdleCounterChunk.OpenGlobal(KTestIdleCounterChunkName, EFalse); |
|
2018 test_KErrNone(r); |
|
2019 iIdleCounter = (struct TTestIdleCounter*) iIdleCounterChunk.Base(); |
|
2020 test_NotNull(iIdleCounter); |
|
2021 // Allow some time for low-priority counter process |
|
2022 User::After(100000); // 0.1 second |
|
2023 TInt64 val1 = iIdleCounter->iCounter; |
|
2024 User::After(1000000); // 1 second |
|
2025 TInt64 val2 = iIdleCounter->iCounter; |
|
2026 TUSB_PRINT1("Idle Counter when test inactive: %Ldinc/ms", (val2 - val1) / 1000); |
|
2027 |
|
2028 test.Next (_L("Enumeration...")); |
|
2029 r = ReEnumerate(); |
|
2030 test_KErrNone(r); |
|
2031 |
|
2032 TUSB_VERBOSE_PRINT("Device successfully re-enumerated\n"); |
|
2033 |
|
2034 |
|
2035 if (iLddPtr->iHighSpeed && !gSkip) |
|
2036 { |
|
2037 test.Next (_L("High Speed")); |
|
2038 test(iHighSpeed); |
|
2039 } |
|
2040 |
|
2041 test.Next (_L("Create Notifiers")); |
|
2042 for (TInt portNumber = 0; portNumber < iTotalChannels; portNumber++) |
|
2043 { |
|
2044 |
|
2045 // Create device state active object |
|
2046 iDeviceStateNotifier[portNumber] = CActiveDeviceStateNotifier::NewL(iConsole, &iPort[portNumber], portNumber); |
|
2047 test_NotNull(iDeviceStateNotifier[portNumber]); |
|
2048 iDeviceStateNotifier[portNumber]->Activate(); |
|
2049 TUSB_VERBOSE_PRINT("Created device state notifier"); |
|
2050 |
|
2051 // Create endpoint stall status active object |
|
2052 iStallNotifier[portNumber] = CActiveStallNotifier::NewL(iConsole, &iPort[portNumber]); |
|
2053 test_NotNull(iStallNotifier[portNumber]); |
|
2054 iStallNotifier[portNumber]->Activate(); |
|
2055 TUSB_VERBOSE_PRINT("Created stall notifier"); |
|
2056 |
|
2057 TestInvalidSetInterface (&iPort[portNumber],iNumInterfaceSettings[portNumber]); |
|
2058 TestInvalidReleaseInterface (&iPort[portNumber],iNumInterfaceSettings[portNumber]); |
|
2059 |
|
2060 } |
|
2061 |
|
2062 test.Next (_L("Endpoint Zero Max Packet Sizes")); |
|
2063 TUint ep0Size = iPort[0].EndpointZeroMaxPacketSizes(); |
|
2064 switch (ep0Size) |
|
2065 { |
|
2066 case KUsbEpSize8 : |
|
2067 iEp0PacketSize = 8; |
|
2068 break; |
|
2069 |
|
2070 case KUsbEpSize16 : |
|
2071 iEp0PacketSize = 16; |
|
2072 break; |
|
2073 |
|
2074 case KUsbEpSize32 : |
|
2075 iEp0PacketSize = 32; |
|
2076 break; |
|
2077 |
|
2078 case KUsbEpSize64 : |
|
2079 iEp0PacketSize = 64; |
|
2080 break; |
|
2081 |
|
2082 default: |
|
2083 iEp0PacketSize = 0; |
|
2084 break; |
|
2085 } |
|
2086 test_Compare(iEp0PacketSize,>,0); |
|
2087 |
|
2088 test.Next (_L("Set Device Control")); |
|
2089 r = iPort[0].SetDeviceControl(); |
|
2090 test_KErrNone(r); |
|
2091 |
|
2092 #ifdef USB_SC |
|
2093 r = iPort[0].OpenEndpoint(iEp0Buf,0); |
|
2094 test_KErrNone(r); |
|
2095 #endif |
|
2096 |
|
2097 test.End(); |
|
2098 //iSrv.Close(); |
|
2099 RequestEp0ControlPacket(); |
|
2100 } |
|
2101 |
|
2102 #endif |
1717 // -eof- |
2103 // -eof- |