0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include "cusbpninterface.h"
|
|
20 |
#include "cusbpnalt.h"
|
|
21 |
#include "cusbpnpacket.h"
|
|
22 |
#include "cusbpnisareceiver.h"
|
|
23 |
#include "cusbpnusbreceiver.h"
|
|
24 |
#include "musbpncontrolobserver.h"
|
|
25 |
#include "usbpndefinitions.h" // For constants
|
|
26 |
#include "usbpntrace.h"
|
|
27 |
|
|
28 |
#include "osttracedefinitions.h"
|
|
29 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
30 |
#include "cusbpninterfaceTraces.h"
|
|
31 |
#endif
|
|
32 |
|
|
33 |
#include <d32usbc.h> // For RDevUsbcClient
|
|
34 |
#include <iscapi.h> // For RIscApi
|
|
35 |
#include <iscnokiadefinitions.h> // For Channel ID
|
|
36 |
|
|
37 |
// EXTERNAL DATA STRUCTURES
|
|
38 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
39 |
// CONSTANTS
|
|
40 |
// MACROS
|
|
41 |
// LOCAL CONSTANTS AND MACROS
|
|
42 |
// MODULE DATA STRUCTURES
|
|
43 |
// LOCAL FUNCTION PROTOTYPES
|
|
44 |
// FORWARD DECLARATIONS
|
|
45 |
|
|
46 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
47 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
48 |
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
// CUsbPnInterface::CUsbPnInterface
|
|
51 |
// C++ default constructor can NOT contain any code, that
|
|
52 |
// might leave.
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CUsbPnInterface::CUsbPnInterface()
|
|
56 |
{
|
|
57 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_CUSBPNINTERFACE_ENTRY, "CUsbPnInterface::CUsbPnInterface" );
|
|
58 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_CUSBPNINTERFACE_EXIT, "CUsbPnInterface::CUsbPnInterface - return" );
|
|
59 |
C_TRACE( ( _T( "CUsbPnInterface::CUsbPnInterface()" ) ) );
|
|
60 |
C_TRACE( ( _T( "CUsbPnInterface::CUsbPnInterface() - return" ) ) );
|
|
61 |
}
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// CUsbPnInterface::ConstructL
|
|
65 |
// Symbian 2nd phase constructor can leave.
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
void CUsbPnInterface::ConstructL()
|
|
69 |
{
|
|
70 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_CONSTRUCTL_ENTRY, "CUsbPnInterface::ConstructL" );
|
|
71 |
C_TRACE( ( _T( "CUsbPnInterface::ConstructL()" ) ) );
|
|
72 |
|
|
73 |
iAlt = CUsbPnAlt::NewL( *this, iPnDataLdd, iIscApi );
|
|
74 |
iIsaReceiver = CUsbPnIsaReceiver::NewL( iIscApi, iPnDataLdd );
|
|
75 |
iUsbReceiver = CUsbPnUsbReceiver::NewL( iPnDataLdd, iIscApi );
|
|
76 |
|
|
77 |
// Open ISC Channel
|
|
78 |
TRequestStatus openStatus;
|
|
79 |
iIscApi.Open( EIscNokiaUsbPhonetLink, openStatus );
|
|
80 |
User::WaitForRequest( openStatus );
|
|
81 |
User::LeaveIfError( openStatus.Int() );
|
|
82 |
|
|
83 |
// Start ISA receiver without forward
|
|
84 |
iIsaReceiver->Receive( EFalse );
|
|
85 |
|
|
86 |
InitialiseInterfaceL();
|
|
87 |
|
|
88 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_CONSTRUCTL_EXIT, "CUsbPnInterface::ConstructL - return void" );
|
|
89 |
C_TRACE( ( _T( "CUsbPnInterface::ConstructL() - return void" ) ) );
|
|
90 |
}
|
|
91 |
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
// CUsbPnInterface::NewL
|
|
94 |
// Two-phased constructor.
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
CUsbPnInterface* CUsbPnInterface::NewL()
|
|
98 |
{
|
|
99 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_NEWL_ENTRY, "CUsbPnInterface::NewL" );
|
|
100 |
C_TRACE( ( _T( "CUsbPnInterface::NewL()" ) ) );
|
|
101 |
|
|
102 |
CUsbPnInterface* self = new( ELeave ) CUsbPnInterface();
|
|
103 |
|
|
104 |
CleanupStack::PushL( self );
|
|
105 |
self->ConstructL();
|
|
106 |
CleanupStack::Pop( self );
|
|
107 |
|
|
108 |
OstTrace1( TRACE_NORMAL, CUSBPNINTERFACE_NEWL_EXIT, "CUsbPnInterface::NewL - return;self=%x", self );
|
|
109 |
C_TRACE( ( _T( "CUsbPnInterface::NewL() - return 0x%x" ), self ) );
|
|
110 |
return self;
|
|
111 |
}
|
|
112 |
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
// CUsbPnInterface::~CUsbPnInterface
|
|
115 |
// Two-phased constructor.
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
CUsbPnInterface::~CUsbPnInterface()
|
|
119 |
{
|
|
120 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_CUSBPNINTERFACE_DESTRUCTOR_ENTRY, "CUsbPnInterface::~CUsbPnInterface" );
|
|
121 |
C_TRACE( ( _T( "CUsbPnInterface::~CUsbPnInterface()" ) ) );
|
|
122 |
|
|
123 |
if( iUsbReceiver )
|
|
124 |
{
|
|
125 |
delete iUsbReceiver;
|
|
126 |
}
|
|
127 |
|
|
128 |
if( iIsaReceiver )
|
|
129 |
{
|
|
130 |
delete iIsaReceiver;
|
|
131 |
}
|
|
132 |
iIscApi.Close();
|
|
133 |
|
|
134 |
if( iInitialised )
|
|
135 |
{
|
|
136 |
ReleaseInterface();
|
|
137 |
}
|
|
138 |
|
|
139 |
if( iAlt )
|
|
140 |
{
|
|
141 |
delete iAlt;
|
|
142 |
}
|
|
143 |
|
|
144 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_CUSBPNINTERFACE_DESTRUCTOR_EXIT, "CUsbPnInterface::~CUsbPnInterface - return" );
|
|
145 |
C_TRACE( ( _T( "CUsbPnInterface::~CUsbPnInterface() - return" ) ) );
|
|
146 |
}
|
|
147 |
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
// CUsbPnInterface::HandleDeviceStateChange
|
|
150 |
// ?implementation_description
|
|
151 |
// (other items were commented in a header).
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
void CUsbPnInterface::HandleDeviceStateChange( TUint aDeviceState )
|
|
155 |
{
|
|
156 |
OstTrace1( TRACE_API, CUSBPNINTERFACE_HANDLEDEVICESTATECHANGE_ENTRY, "CUsbPnInterface::HandleDeviceStateChange;aDeviceState=%u", aDeviceState );
|
|
157 |
A_TRACE( ( _T( "CUsbPnInterface::HandleDeviceStateChange( aDeviceState:%d )"), aDeviceState ));
|
|
158 |
|
|
159 |
if(aDeviceState & KUsbAlternateSetting)
|
|
160 |
{
|
|
161 |
OstTrace0( TRACE_API, CUSBPNINTERFACE_HANDLEDEVICESTATECHANGE, "CUsbPnInterface::HandleDeviceStateChange - Change alternate setting" );
|
|
162 |
A_TRACE( ( _T( "CUsbPnInterface::HandleDeviceStateChange - Change alternate setting")));
|
|
163 |
TUint altSetNbr( aDeviceState & ~KUsbAlternateSetting );
|
|
164 |
|
|
165 |
SetAltSetting( altSetNbr );
|
|
166 |
}
|
|
167 |
else
|
|
168 |
{
|
|
169 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_HANDLEDEVICESTATECHANGE_DUP1, "CUsbPnInterface::HandleDeviceStateChange - Normal state change" );
|
|
170 |
E_TRACE( ( _T( "CUsbPnInterface::HandleDeviceStateChange - Normal state change")));
|
|
171 |
switch( aDeviceState )
|
|
172 |
{
|
|
173 |
case EUsbcDeviceStateUndefined:
|
|
174 |
{
|
|
175 |
OstTrace0( TRACE_API, CUSBPNINTERFACE_HANDLEDEVICESTATECHANGE_DUP4, "CUsbPnInterface::HandleDeviceStateChange - EUsbcDeviceStateUndefined" );
|
|
176 |
A_TRACE( ( _T( "CUsbPnInterface::HandleDeviceStateChange - EUsbcDeviceStateUndefined")));
|
|
177 |
// Cancel async USB operations
|
|
178 |
iUsbReceiver->SetEnumerated( EFalse );
|
|
179 |
iUsbReceiver->Cancel();
|
|
180 |
break;
|
|
181 |
}
|
|
182 |
case EUsbcDeviceStateDefault:
|
|
183 |
{
|
|
184 |
OstTrace0( TRACE_API, CUSBPNINTERFACE_HANDLEDEVICESTATECHANGE_DUP5, "CUsbPnInterface::HandleDeviceStateChange - EUsbcDeviceStateDefault" );
|
|
185 |
A_TRACE( ( _T( "CUsbPnInterface::HandleDeviceStateChange - EUsbcDeviceStateDefault")));
|
|
186 |
// Cancel async USB operations
|
|
187 |
iUsbReceiver->SetEnumerated( EFalse );
|
|
188 |
iUsbReceiver->Cancel();
|
|
189 |
break;
|
|
190 |
}
|
|
191 |
default:
|
|
192 |
{
|
|
193 |
OstTrace0( TRACE_API, CUSBPNINTERFACE_HANDLEDEVICESTATECHANGE_DUP6, "CUsbPnInterface::HandleDeviceStateChange - State of no interest" );
|
|
194 |
A_TRACE( ( _T( "CUsbPnInterface::HandleDeviceStateChange - State of no interest")));
|
|
195 |
break;
|
|
196 |
}
|
|
197 |
}
|
|
198 |
}
|
|
199 |
|
|
200 |
OstTrace0( TRACE_API, CUSBPNINTERFACE_HANDLEDEVICESTATECHANGE_EXIT, "CUsbPnInterface::HandleDeviceStateChange - return void" );
|
|
201 |
A_TRACE( ( _T( "CUsbPnInterface::HandleDeviceStateChange() - return void")));
|
|
202 |
}
|
|
203 |
|
|
204 |
// -----------------------------------------------------------------------------
|
|
205 |
// CUsbPnInterface::SetAltSetting
|
|
206 |
// ?implementation_description
|
|
207 |
// (other items were commented in a header).
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
//
|
|
210 |
void CUsbPnInterface::SetAltSetting( TUint aAltSetNumber )
|
|
211 |
{
|
|
212 |
OstTrace1( TRACE_API, CUSBPNINTERFACE_SETALTSETTING_ENTRY, "CUsbPnInterface::SetAltSetting;aAltSetNumber=%u", aAltSetNumber );
|
|
213 |
A_TRACE( ( _T( "CUsbPnInterface::SetAltSetting( aAltSetNumber:%d )" ), aAltSetNumber ) );
|
|
214 |
|
|
215 |
if( aAltSetNumber )
|
|
216 |
{
|
|
217 |
// Receive from ISA with forwarding
|
|
218 |
iIsaReceiver->SetForwardFlag( ETrue );
|
|
219 |
|
|
220 |
iUsbReceiver->SetEnumerated( ETrue );
|
|
221 |
iUsbReceiver->Receive( ETrue /*dummy*/ );
|
|
222 |
}
|
|
223 |
else
|
|
224 |
{
|
|
225 |
// Receive from ISA without forwarding
|
|
226 |
iIsaReceiver->SetForwardFlag( EFalse );
|
|
227 |
|
|
228 |
iUsbReceiver->SetEnumerated( EFalse );
|
|
229 |
iUsbReceiver->Cancel();
|
|
230 |
}
|
|
231 |
|
|
232 |
OstTrace0( TRACE_API, CUSBPNINTERFACE_SETALTSETTING_EXIT, "CUsbPnInterface::SetAltSetting - return void" );
|
|
233 |
A_TRACE( ( _T( "CUsbPnInterface::SetAltSetting() - return void")));
|
|
234 |
}
|
|
235 |
|
|
236 |
// -----------------------------------------------------------------------------
|
|
237 |
// CUsbPnInterface::InitialiseInterfaceL
|
|
238 |
// ?implementation_description
|
|
239 |
// (other items were commented in a header).
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
void CUsbPnInterface::InitialiseInterfaceL()
|
|
243 |
{
|
|
244 |
OstTrace0( TRACE_API, CUSBPNINTERFACE_INITIALISEINTERFACEL_ENTRY, "CUsbPnInterface::InitialiseInterfaceL" );
|
|
245 |
A_TRACE( ( _T( "CUsbPnInterface::InitialiseInterfaceL()" ) ) );
|
|
246 |
|
|
247 |
TInt ret = iCommLdd.Open(0);
|
|
248 |
if (ret != KErrNone)
|
|
249 |
{
|
|
250 |
// Maybe the device is not loaded yet.
|
|
251 |
_LIT(KUsbLDDName, "eusbc");
|
|
252 |
ret = User::LoadLogicalDevice( KUsbLDDName );
|
|
253 |
|
|
254 |
OstTrace1( TRACE_DETAILED, DUP100_CUSBPNINTERFACE_INITIALISEINTERFACEL, "CUsbPnInterface::InitialiseInterfaceL - Tried loading the device with status %d", ret );
|
|
255 |
E_TRACE( ( _T("CUsbPnInterface::InitialiseInterfaceL - Tried loading the device with status %d"), ret ) );
|
|
256 |
|
|
257 |
if (ret == KErrNone || ret == KErrAlreadyExists)
|
|
258 |
{
|
|
259 |
ret = iCommLdd.Open(0);
|
|
260 |
}
|
|
261 |
|
|
262 |
if (ret != KErrNone)
|
|
263 |
{
|
|
264 |
OstTrace1( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Cannot open Comm LDD %d", ret );
|
|
265 |
E_TRACE( ( _T( "USBPN - Cannot open Comm LDD %d" ), ret ) );
|
|
266 |
User::Leave( KErrNotReady );
|
|
267 |
}
|
|
268 |
}
|
|
269 |
|
|
270 |
ret = iPnDataLdd.Open(0);
|
|
271 |
if (ret != KErrNone)
|
|
272 |
{
|
|
273 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP1, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Cannot open PnData LDD" );
|
|
274 |
E_TRACE( ( _T( "USBPN - Cannot open PnData LDD" ) ) );
|
|
275 |
User::Leave( KErrNotReady );
|
|
276 |
}
|
|
277 |
|
|
278 |
|
|
279 |
//////////////////////////////////////////////////////////////////////
|
|
280 |
// Comm interface
|
|
281 |
//////////////////////////////////////////////////////////////////////
|
|
282 |
|
|
283 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP2, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Setup Comm interface" );
|
|
284 |
E_TRACE( ( _T( "USBPN - Setup Comm interface" ) ) );
|
|
285 |
|
|
286 |
TUsbcInterfaceInfoBuf ifc;
|
|
287 |
|
|
288 |
ifc().iString = const_cast<TDesC16*> (&KUsbPnCommIfc);
|
|
289 |
ifc().iTotalEndpointsUsed = 0;
|
|
290 |
ifc().iClass.iClassNum = KCommInterfaceClass;
|
|
291 |
ifc().iClass.iSubClassNum = KCommInterfaceSubClass;
|
|
292 |
ifc().iClass.iProtocolNum = KCommInterfaceProtocol;
|
|
293 |
|
|
294 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP3, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Call SetInterface 0" );
|
|
295 |
E_TRACE( ( _T( "USBPN - Call SetInterface 0" ) ) );
|
|
296 |
|
|
297 |
ret = iCommLdd.SetInterface(0, ifc);
|
|
298 |
if (ret != KErrNone)
|
|
299 |
{
|
|
300 |
TRACE_ASSERT_ALWAYS;
|
|
301 |
User::Leave( ret );
|
|
302 |
}
|
|
303 |
|
|
304 |
//Get the interface number for later
|
|
305 |
TBuf8<100> interfaceDescriptor;
|
|
306 |
iCommLdd.GetInterfaceDescriptor(0, interfaceDescriptor);
|
|
307 |
TUint8 interfaceNum;
|
|
308 |
interfaceNum = interfaceDescriptor.Ptr()[2];
|
|
309 |
|
|
310 |
HBufC8* descBuf = HBufC8::NewLC( 64 );
|
|
311 |
TPtr8 desc( descBuf->Des() );
|
|
312 |
|
|
313 |
//Comms Class Header Functional Descriptor
|
|
314 |
desc.Append(KPnHeaderFunctionalDescriptorLength);
|
|
315 |
desc.Append(KUsbDescType_CS_Interface);
|
|
316 |
desc.Append(KHeaderDescriptorSubType);
|
|
317 |
desc.Append(KCDCVersionNumber[0]);
|
|
318 |
desc.Append(KCDCVersionNumber[1]);
|
|
319 |
|
|
320 |
// PHONET Functional Descriptor
|
|
321 |
desc.Append(KPnFunctionalDescriptorLength);
|
|
322 |
desc.Append(KUsbDescType_CS_Interface);
|
|
323 |
desc.Append(KFunctionalDescriptorSubType);
|
|
324 |
|
|
325 |
// Union Functional Descriptor
|
|
326 |
desc.Append(KPnUnionFunctionalDescriptorLength);
|
|
327 |
desc.Append(KUsbDescType_CS_Interface);
|
|
328 |
desc.Append(KUnionDescriptorSubType);
|
|
329 |
desc.Append(interfaceNum);
|
|
330 |
TInt dataInt;
|
|
331 |
dataInt = interfaceNum + 1;
|
|
332 |
desc.Append(static_cast<TUint8>(dataInt));
|
|
333 |
|
|
334 |
// Vendor DMA FD
|
|
335 |
desc.Append(KVendorDMAFDDescriptorLength);
|
|
336 |
desc.Append(KUsbDescType_CS_Interface);
|
|
337 |
desc.Append(KVendorDMADescriptorSubType);
|
|
338 |
desc.Append(KDmaCapabilities); // Is zero. Meaning interface is DMA incapable
|
|
339 |
|
|
340 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP4, "CUsbPnInterface::InitialiseInterfaceL - USBPN - SetCSInterfaceDescriptorBlock" );
|
|
341 |
E_TRACE( ( _T( "USBPN - SetCSInterfaceDescriptorBlock" ) ) );
|
|
342 |
ret = iCommLdd.SetCSInterfaceDescriptorBlock(0, desc);
|
|
343 |
|
|
344 |
CleanupStack::PopAndDestroy( descBuf );
|
|
345 |
|
|
346 |
if (ret != KErrNone)
|
|
347 |
{
|
|
348 |
TRACE_ASSERT_ALWAYS;
|
|
349 |
User::Leave( ret );
|
|
350 |
}
|
|
351 |
|
|
352 |
|
|
353 |
//////////////////////////////////////////////////////////////////////
|
|
354 |
// PHONET data interface alt 0
|
|
355 |
//////////////////////////////////////////////////////////////////////
|
|
356 |
|
|
357 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP5, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Register PHONET Data IF (alt 0)" );
|
|
358 |
E_TRACE( ( _T( "USBPN - Register PHONET Data IF (alt 0)" ) ) );
|
|
359 |
TUsbcInterfaceInfoBuf dataifc;
|
|
360 |
|
|
361 |
dataifc().iString = const_cast<TDesC16*> (&KUsbPnDataAlt0Ifc);
|
|
362 |
dataifc().iClass.iClassNum = KDataInterfaceClass;
|
|
363 |
dataifc().iClass.iSubClassNum = KDataInterfaceSubClass;
|
|
364 |
dataifc().iClass.iProtocolNum = KDataInterfaceProtocol;
|
|
365 |
dataifc().iTotalEndpointsUsed = 0;
|
|
366 |
|
|
367 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP6, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Setup PHONET Data IF (alt 0)" );
|
|
368 |
E_TRACE( ( _T( "USBPN - Setup PHONET Data IF (alt 0)" ) ) );
|
|
369 |
|
|
370 |
ret = iPnDataLdd.SetInterface(0, dataifc);
|
|
371 |
if (ret != KErrNone)
|
|
372 |
{
|
|
373 |
TRACE_ASSERT_ALWAYS;
|
|
374 |
User::Leave( ret );
|
|
375 |
}
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
//////////////////////////////////////////////////////////////////////
|
|
380 |
// data interface alt 1
|
|
381 |
//////////////////////////////////////////////////////////////////////
|
|
382 |
|
|
383 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP7, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Register PHONET Data IF (alt 1)" );
|
|
384 |
E_TRACE( ( _T( "USBPN - Register PHONET Data IF (alt 1)" ) ) );
|
|
385 |
//Register Data Interface 1
|
|
386 |
TUsbcInterfaceInfoBuf dataifc1;
|
|
387 |
// Fill in dataifc1
|
|
388 |
dataifc1().iString = const_cast<TDesC16*> (&KUsbPnDataAlt1Ifc);;
|
|
389 |
dataifc1().iClass.iClassNum = KDataInterfaceClass;
|
|
390 |
dataifc1().iClass.iSubClassNum = KDataInterfaceSubClass;
|
|
391 |
dataifc1().iClass.iProtocolNum = KDataInterfaceProtocol;
|
|
392 |
dataifc1().iTotalEndpointsUsed = KUsbPnRequiredNumberOfEndpoints;
|
|
393 |
|
|
394 |
TUsbDeviceCaps dCaps1;
|
|
395 |
ret = iPnDataLdd.DeviceCaps(dCaps1);
|
|
396 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP8, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Checking result of DeviceCaps" );
|
|
397 |
E_TRACE( ( _T( "USBPN - Checking result of DeviceCaps" ) ) );
|
|
398 |
if ( ret )
|
|
399 |
{
|
|
400 |
TRACE_ASSERT_ALWAYS;
|
|
401 |
User::Leave( ret );
|
|
402 |
}
|
|
403 |
|
|
404 |
const TUint totalEndpoints1 = static_cast<TUint>(dCaps1().iTotalEndpoints);
|
|
405 |
OstTrace1( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP9, "CUsbPnInterface::InitialiseInterfaceL - USBPN - TotalEndpoints1=%d", totalEndpoints1 );
|
|
406 |
E_TRACE( ( _T( "USBPN - TotalEndpoints1 %d" ), totalEndpoints1 ) );
|
|
407 |
if (totalEndpoints1 < KUsbPnRequiredNumberOfEndpoints)
|
|
408 |
{
|
|
409 |
TRACE_ASSERT_ALWAYS;
|
|
410 |
User::Leave( KErrGeneral );
|
|
411 |
}
|
|
412 |
|
|
413 |
|
|
414 |
TUsbcEndpointData data1[KUsbcMaxEndpoints];
|
|
415 |
TPtr8 dataptr1 = TPtr8(reinterpret_cast<TUint8*>(data1), sizeof(data1), sizeof(data1));
|
|
416 |
ret = iPnDataLdd.EndpointCaps(dataptr1);
|
|
417 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP10, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Checking result of EndpointCaps" );
|
|
418 |
E_TRACE( ( _T( "USBPN - Checking result of EndpointCaps" ) ) );
|
|
419 |
if (ret)
|
|
420 |
{
|
|
421 |
TRACE_ASSERT_ALWAYS;
|
|
422 |
User::Leave( ret );
|
|
423 |
}
|
|
424 |
|
|
425 |
// Set data interface 1
|
|
426 |
TBool outFound = EFalse;
|
|
427 |
TBool inFound = EFalse;
|
|
428 |
|
|
429 |
for (TUint ii = 0 ; ii < totalEndpoints1; ii++)
|
|
430 |
{
|
|
431 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP11, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Set data interface 1" );
|
|
432 |
E_TRACE( ( _T( "USBPN - Set data interface 1" ) ) );
|
|
433 |
const TUsbcEndpointCaps* caps;
|
|
434 |
caps = &data1[ii].iCaps;
|
|
435 |
|
|
436 |
OstTraceExt2( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP12, "CUsbPnInterface::InitialiseInterfaceL - USBPN - iTypesAndDir=%d, epSize=%d", caps->iTypesAndDir, caps->MaxPacketSize() );
|
|
437 |
E_TRACE( ( _T( "USBPN - iTypesAndDir %d, epSize:%d" ), caps->iTypesAndDir, caps->MaxPacketSize() ) );
|
|
438 |
|
|
439 |
#ifdef EXTENDED_TRACE_FLAG
|
|
440 |
if(((caps->iTypesAndDir & (KUsbEpDirIn)) == (KUsbEpDirIn) ) )
|
|
441 |
{
|
|
442 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP13, "CUsbPnInterface::InitialiseInterfaceL - USBPN - IN" );
|
|
443 |
E_TRACE( ( _T( "USBPN - IN" )));
|
|
444 |
}
|
|
445 |
if(((caps->iTypesAndDir & (KUsbEpDirOut)) == (KUsbEpDirOut) ) )
|
|
446 |
{
|
|
447 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP14, "CUsbPnInterface::InitialiseInterfaceL - USBPN - OUT" );
|
|
448 |
E_TRACE( ( _T( "USBPN - OUT" )));
|
|
449 |
}
|
|
450 |
if(((caps->iTypesAndDir & (KUsbEpTypeBulk)) == (KUsbEpTypeBulk)))
|
|
451 |
{
|
|
452 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP15, "CUsbPnInterface::InitialiseInterfaceL - USBPN - BULK" );
|
|
453 |
E_TRACE( ( _T( "USBPN - BULK" )));
|
|
454 |
}
|
|
455 |
#endif // EXTENDED_TRACE_FLAG
|
|
456 |
|
|
457 |
if(data1[ii].iInUse)
|
|
458 |
{
|
|
459 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP16, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Ep in use. Next..." );
|
|
460 |
E_TRACE( ( _T( "USBPN - Ep in use. Next...")));
|
|
461 |
continue;
|
|
462 |
}
|
|
463 |
|
|
464 |
//changes to bulk in ep
|
|
465 |
if (((caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirIn)) ==
|
|
466 |
(KUsbEpTypeBulk | KUsbEpDirIn)) && !inFound)
|
|
467 |
{
|
|
468 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP17, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Bulk IN found for EEndpoint1" );
|
|
469 |
E_TRACE( ( _T( "USBPN - Bulk IN found for EEndpoint1" ) ) );
|
|
470 |
// EEndpoint1 is bulk in endpoint
|
|
471 |
dataifc1().iEndpointData[0].iType = KUsbEpTypeBulk;
|
|
472 |
dataifc1().iEndpointData[0].iDir = KUsbEpDirIn;
|
|
473 |
//dataifc1().iEndpointData[0].iInterval = 0;
|
|
474 |
|
|
475 |
dataifc1().iEndpointData[0].iSize = caps->MaxPacketSize();
|
|
476 |
inFound = ETrue;
|
|
477 |
}
|
|
478 |
else if (((caps->iTypesAndDir & (KUsbEpTypeBulk | KUsbEpDirOut)) ==
|
|
479 |
(KUsbEpTypeBulk | KUsbEpDirOut)) && !outFound)
|
|
480 |
{
|
|
481 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP18, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Bulk OUT found for EEndpoint2" );
|
|
482 |
E_TRACE( ( _T( "USBPN - Bulk OUT found for EEndpoint2" ) ) );
|
|
483 |
// EEndpoint2 is bulk out endpoint
|
|
484 |
dataifc1().iEndpointData[1].iType = KUsbEpTypeBulk;
|
|
485 |
dataifc1().iEndpointData[1].iDir = KUsbEpDirOut;
|
|
486 |
//dataifc1().iEndpointData[1].iInterval = 0;
|
|
487 |
|
|
488 |
dataifc1().iEndpointData[1].iSize = caps->MaxPacketSize();
|
|
489 |
outFound = ETrue;
|
|
490 |
}
|
|
491 |
|
|
492 |
if (outFound && inFound)
|
|
493 |
{
|
|
494 |
break;
|
|
495 |
}
|
|
496 |
} // end for ( ... )
|
|
497 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP19, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Checking epFound" );
|
|
498 |
E_TRACE( ( _T( "USBPN - Checking epFound" ) ) );
|
|
499 |
if (!outFound || !inFound )
|
|
500 |
{
|
|
501 |
TRACE_ASSERT_ALWAYS;
|
|
502 |
User::Leave( KErrGeneral );
|
|
503 |
}
|
|
504 |
|
|
505 |
OstTrace0( TRACE_DETAILED, CUSBPNINTERFACE_INITIALISEINTERFACEL_DUP20, "CUsbPnInterface::InitialiseInterfaceL - USBPN - Setting LCIF Data IF (alt 1)" );
|
|
506 |
E_TRACE( ( _T( "USBPN - Setting LCIF Data IF (alt 1)" ) ) );
|
|
507 |
|
|
508 |
ret = iPnDataLdd.SetInterface(1, dataifc1);
|
|
509 |
if (ret != KErrNone)
|
|
510 |
{
|
|
511 |
TRACE_ASSERT_ALWAYS;
|
|
512 |
User::Leave( ret );
|
|
513 |
}
|
|
514 |
|
|
515 |
iAlt->ListenStateChange();
|
|
516 |
iInitialised = ETrue;
|
|
517 |
|
|
518 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_INITIALISEINTERFACEL_EXIT, "CUsbPnInterface::InitialiseInterfaceL - return void" );
|
|
519 |
C_TRACE( ( _T( "CUsbPnInterface::InitialiseInterfaceL() - return void")));
|
|
520 |
}
|
|
521 |
|
|
522 |
// -----------------------------------------------------------------------------
|
|
523 |
// CUsbInterface::ReleaseInterface
|
|
524 |
// Release and close all LDD in reverse order as in setup
|
|
525 |
// -----------------------------------------------------------------------------
|
|
526 |
//
|
|
527 |
EXPORT_C void CUsbPnInterface::ReleaseInterface()
|
|
528 |
{
|
|
529 |
OstTrace0( TRACE_API, CUSBPNINTERFACE_RELEASEINTERFACE_ENTRY, "CUsbPnInterface::ReleaseInterface" );
|
|
530 |
A_TRACE( ( _T( "CUsbPnInterface::ReleaseInterface()" ) ) );
|
|
531 |
|
|
532 |
iAlt->Cancel();
|
|
533 |
|
|
534 |
TInt ret;
|
|
535 |
|
|
536 |
ret = iPnDataLdd.ReleaseInterface(1);
|
|
537 |
if (ret != KErrNone)
|
|
538 |
{
|
|
539 |
TRACE_ASSERT_ALWAYS;
|
|
540 |
}
|
|
541 |
|
|
542 |
ret = iPnDataLdd.ReleaseInterface(0);
|
|
543 |
if (ret != KErrNone)
|
|
544 |
{
|
|
545 |
TRACE_ASSERT_ALWAYS;
|
|
546 |
}
|
|
547 |
|
|
548 |
iPnDataLdd.Close();
|
|
549 |
|
|
550 |
ret = iCommLdd.ReleaseInterface(0);
|
|
551 |
if (ret != KErrNone)
|
|
552 |
{
|
|
553 |
TRACE_ASSERT_ALWAYS;
|
|
554 |
}
|
|
555 |
|
|
556 |
iCommLdd.Close();
|
|
557 |
|
|
558 |
iInitialised = EFalse;
|
|
559 |
|
|
560 |
OstTrace0( TRACE_NORMAL, CUSBPNINTERFACE_RELEASEINTERFACE_EXIT, "CUsbPnInterface::ReleaseInterface - return void" );
|
|
561 |
C_TRACE( ( _T( "CUsbPnInterface::ReleaseInterface() - return void" ) ) );
|
|
562 |
}
|
|
563 |
|
|
564 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
565 |
|
|
566 |
// End of File
|