Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #ifdef __KERNEL_MODE__
20 #include <kernel/klib.h>
23 #include <d32usbdescriptors.h>
26 #include <d32usbdi_errors.h>
32 Intended to be available to 3rd parties later
37 class RUsbTransferDescriptor;
38 class RUsbTransferStrategy;
40 typedef TUint32 TUsbBusId;
41 typedef void* TUsbBus; // handle for an os_bus
44 Functions which act on a specific interface on a remote device.
46 class RUsbInterface : public RBusLogicalChannel
49 NONSHARABLE_CLASS(TUsbTransferRequestDetails)
52 enum TEp0TransferFlags
54 EShortTransferOk = 0x04,
64 // Internal: these should not be set or used, however making them private
65 // would require the internal DUsbChannel class be exposed as a friend in
71 NONSHARABLE_CLASS(TChunkRequestDetails)
81 NONSHARABLE_CLASS(TTransferMemoryDetails)
96 enum TUsbInterfaceRequest
101 enum TUsbInterfaceControl
105 EGetInterfaceDescriptorSize,
106 EGetInterfaceDescriptor,
107 EGetStringDescriptor,
108 ESelectAlternateInterface,
113 EGetSizeAndAlignment,
115 enum TUsbInterfaceCancel
117 ECancelSuspend = 0x00000001,
118 ECancelWaitForResume = 0x00000002,
119 ECancelEp0Transfer = 0x00000004
123 inline static const TDesC& Name();
124 inline static TVersion VersionRequired();
126 #ifndef __KERNEL_MODE__
127 friend class RUsbPipe;
128 friend class RUsbZeroCopyTransferStrategy;
131 inline RUsbInterface();
134 // Standard R-class lifetime controls
136 IMPORT_C TInt Open(TUint32 aToken, TOwnerType aType = EOwnerProcess);
137 IMPORT_C void Close();
140 // Transfer allocation/initialisation functions
142 IMPORT_C TInt RegisterTransferDescriptor(RUsbTransferDescriptor& aTransfer);
143 IMPORT_C void ResetTransferDescriptors();
144 IMPORT_C TInt InitialiseTransferDescriptors();
147 // Endpoint Zero transfer utilities
149 inline void Ep0Transfer(TUsbTransferRequestDetails& aDetails, const TDesC8& aSend, TDes8& aRecv, TRequestStatus& aRequest);
150 inline void CancelEP0Transfer();
151 inline TInt GetStringDescriptor(TDes8& aStringDescriptor, TUint8 aIndex, TUint16 aLangId);
154 // Suspend/Resume functionality
156 inline void PermitSuspendAndWaitForResume(TRequestStatus& aResumeSignal);
157 inline void CancelPermitSuspend();
158 inline void CancelWaitForResume();
159 inline TInt PermitRemoteWakeup(TBool aPermitted);
163 // Descriptor access functions
165 inline TInt GetInterfaceDescriptor(TUsbInterfaceDescriptor& aDescriptor);
166 inline TInt GetAlternateInterfaceDescriptor(TInt aAlternateInterface, TUsbInterfaceDescriptor& aDescriptor);
167 inline TInt GetEndpointDescriptor(TInt aAlternateInterface, TInt aEndpoint, TUsbEndpointDescriptor& aDescriptor);
169 // Utility functions to avoid having to parse the entire descriptor tree in simple cases.
170 inline TInt GetAlternateInterfaceCount();
171 inline TInt EnumerateEndpointsOnInterface(TInt aAlternateInterface);
174 // Interface configuration functions
176 inline TInt SelectAlternateInterface(TInt aAlternateInterface);
177 inline TInt OpenPipeForEndpoint(RUsbPipe& aPipe, TInt aEndpoint, TBool aUseDMA);
180 // Some utility functions
182 inline TInt GetBusId(TUsbBusId& aBusId);
183 inline TInt HcdPageSize();
184 inline TInt GetDeviceSpeed(TDeviceSpeed& aDeviceSpeed);
187 inline TInt AllocateSharedChunk(RChunk& aChunk, TInt aSize, TInt& aOffset);
188 TInt RegisterTransferDescriptor(RUsbTransferDescriptor& aTransfer, TUsbBusId aBusId);
189 inline TInt GetEndpointDescriptor(TInt aAlternateInterface, TInt aEndpoint, TUsbEndpointDescriptor*& aDescriptor);
192 TUsbInterfaceDescriptor* iHeadInterfaceDescriptor;
193 HBufC8* iInterfaceDescriptorData;
195 RUsbTransferStrategy* iTransferStrategy;
197 TInt iAlternateSetting;
201 typedef TUint64 TUsbEndpointId;
204 Functions which act on an individual pipe established between the local host and a remote device.
211 EIssueTransfer = 0x4000000, // Start from a different value compared to interfaces
212 // to allow them to be distinguished while debugging
216 EClose = 0x4000000, // Start from a different value compared to interfaces
217 // to allow them to be distinguished while debugging
223 #ifndef __KERNEL_MODE__
224 friend class RUsbInterface;
225 friend class RUsbTransferStrategy;
226 friend class RUsbZeroCopyTransferStrategy;
231 inline TUint32 Handle() const;
233 inline TInt GetEndpointId(TUsbEndpointId& aEndpointId);
234 inline TInt GetBusId(TUsbBusId& aBusId);
236 inline TInt GetEndpointDescriptor(TUsbEndpointDescriptor& aDescriptor);
238 IMPORT_C void Transfer(RUsbTransferDescriptor& aTransfer, TRequestStatus& aRequest);
239 inline void CancelAllTransfers();
241 inline TInt ClearRemoteStall();
244 inline void IssueTransfer(TInt aTransferHandle, TRequestStatus& aRequest);
248 RUsbInterface* iInterface;
249 TUsbEndpointDescriptor* iHeadEndpointDescriptor;
254 #include <d32usbdi.inl>