1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/d32usbdi.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,256 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef D32USBDI_H
1.20 +#define D32USBDI_H
1.21 +
1.22 +#ifdef __KERNEL_MODE__
1.23 +#include <kernel/klib.h>
1.24 +#else
1.25 +#include <e32base.h>
1.26 +#include <d32usbdescriptors.h>
1.27 +#endif
1.28 +#include <e32ver.h>
1.29 +#include <d32usbdi_errors.h>
1.30 +
1.31 +/**
1.32 +@file
1.33 +@publishedPartner
1.34 +@prototype
1.35 +Intended to be available to 3rd parties later
1.36 +*/
1.37 +
1.38 +
1.39 +class RUsbPipe;
1.40 +class RUsbTransferDescriptor;
1.41 +class RUsbTransferStrategy;
1.42 +
1.43 +typedef TUint32 TUsbBusId;
1.44 +typedef void* TUsbBus; // handle for an os_bus
1.45 +
1.46 +/**
1.47 +Functions which act on a specific interface on a remote device.
1.48 +*/
1.49 +class RUsbInterface : public RBusLogicalChannel
1.50 + {
1.51 +public:
1.52 + NONSHARABLE_CLASS(TUsbTransferRequestDetails)
1.53 + {
1.54 + public:
1.55 + enum TEp0TransferFlags
1.56 + {
1.57 + EShortTransferOk = 0x04,
1.58 + };
1.59 +
1.60 + public:
1.61 + TUint8 iRequestType;
1.62 + TUint8 iRequest;
1.63 + TUint16 iValue;
1.64 + TUint16 iIndex;
1.65 + TInt iFlags;
1.66 +
1.67 + // Internal: these should not be set or used, however making them private
1.68 + // would require the internal DUsbChannel class be exposed as a friend in
1.69 + // userside
1.70 + const TDesC8* iSend;
1.71 + TDes8* iRecv;
1.72 + };
1.73 +
1.74 + NONSHARABLE_CLASS(TChunkRequestDetails)
1.75 + {
1.76 + public:
1.77 + // In
1.78 + TInt iRequestSize;
1.79 + //Out
1.80 + TInt* iChunkHandle;
1.81 + TInt* iOffset;
1.82 + };
1.83 +
1.84 + NONSHARABLE_CLASS(TTransferMemoryDetails)
1.85 + {
1.86 + public:
1.87 + TInt iType;
1.88 + TUint iAlignment;
1.89 + TInt iSize;
1.90 + TInt iMaxPackets;
1.91 + };
1.92 +
1.93 + enum TDeviceSpeed
1.94 + {
1.95 + ELowSpeed,
1.96 + EFullSpeed,
1.97 + EHighSpeed
1.98 + };
1.99 + enum TUsbInterfaceRequest
1.100 + {
1.101 + ESuspend,
1.102 + EEp0Transfer,
1.103 + };
1.104 + enum TUsbInterfaceControl
1.105 + {
1.106 + EOpenPipe,
1.107 + EPermitRemoteWakeup,
1.108 + EGetInterfaceDescriptorSize,
1.109 + EGetInterfaceDescriptor,
1.110 + EGetStringDescriptor,
1.111 + ESelectAlternateInterface,
1.112 + EAllocChunk,
1.113 + EGetDeviceSpeed,
1.114 + EGetBusId,
1.115 + EHcdPageSize,
1.116 + EGetSizeAndAlignment,
1.117 + };
1.118 + enum TUsbInterfaceCancel
1.119 + {
1.120 + ECancelSuspend = 0x00000001,
1.121 + ECancelWaitForResume = 0x00000002,
1.122 + ECancelEp0Transfer = 0x00000004
1.123 + };
1.124 +
1.125 +public:
1.126 + inline static const TDesC& Name();
1.127 + inline static TVersion VersionRequired();
1.128 +
1.129 +#ifndef __KERNEL_MODE__
1.130 +friend class RUsbPipe;
1.131 +friend class RUsbZeroCopyTransferStrategy;
1.132 +
1.133 +public:
1.134 + inline RUsbInterface();
1.135 +
1.136 + //
1.137 + // Standard R-class lifetime controls
1.138 + //
1.139 + IMPORT_C TInt Open(TUint32 aToken, TOwnerType aType = EOwnerProcess);
1.140 + IMPORT_C void Close();
1.141 +
1.142 + //
1.143 + // Transfer allocation/initialisation functions
1.144 + //
1.145 + IMPORT_C TInt RegisterTransferDescriptor(RUsbTransferDescriptor& aTransfer);
1.146 + IMPORT_C void ResetTransferDescriptors();
1.147 + IMPORT_C TInt InitialiseTransferDescriptors();
1.148 +
1.149 + //
1.150 + // Endpoint Zero transfer utilities
1.151 + //
1.152 + inline void Ep0Transfer(TUsbTransferRequestDetails& aDetails, const TDesC8& aSend, TDes8& aRecv, TRequestStatus& aRequest);
1.153 + inline void CancelEP0Transfer();
1.154 + inline TInt GetStringDescriptor(TDes8& aStringDescriptor, TUint8 aIndex, TUint16 aLangId);
1.155 +
1.156 + //
1.157 + // Suspend/Resume functionality
1.158 + //
1.159 + inline void PermitSuspendAndWaitForResume(TRequestStatus& aResumeSignal);
1.160 + inline void CancelPermitSuspend();
1.161 + inline void CancelWaitForResume();
1.162 + inline TInt PermitRemoteWakeup(TBool aPermitted);
1.163 +
1.164 +
1.165 + //
1.166 + // Descriptor access functions
1.167 + //
1.168 + inline TInt GetInterfaceDescriptor(TUsbInterfaceDescriptor& aDescriptor);
1.169 + inline TInt GetAlternateInterfaceDescriptor(TInt aAlternateInterface, TUsbInterfaceDescriptor& aDescriptor);
1.170 + inline TInt GetEndpointDescriptor(TInt aAlternateInterface, TInt aEndpoint, TUsbEndpointDescriptor& aDescriptor);
1.171 +
1.172 + // Utility functions to avoid having to parse the entire descriptor tree in simple cases.
1.173 + inline TInt GetAlternateInterfaceCount();
1.174 + inline TInt EnumerateEndpointsOnInterface(TInt aAlternateInterface);
1.175 +
1.176 + //
1.177 + // Interface configuration functions
1.178 + //
1.179 + inline TInt SelectAlternateInterface(TInt aAlternateInterface);
1.180 + inline TInt OpenPipeForEndpoint(RUsbPipe& aPipe, TInt aEndpoint, TBool aUseDMA);
1.181 +
1.182 + //
1.183 + // Some utility functions
1.184 + //
1.185 + inline TInt GetBusId(TUsbBusId& aBusId);
1.186 + inline TInt HcdPageSize();
1.187 + inline TInt GetDeviceSpeed(TDeviceSpeed& aDeviceSpeed);
1.188 +
1.189 +private:
1.190 + inline TInt AllocateSharedChunk(RChunk& aChunk, TInt aSize, TInt& aOffset);
1.191 + TInt RegisterTransferDescriptor(RUsbTransferDescriptor& aTransfer, TUsbBusId aBusId);
1.192 + inline TInt GetEndpointDescriptor(TInt aAlternateInterface, TInt aEndpoint, TUsbEndpointDescriptor*& aDescriptor);
1.193 +
1.194 +private:
1.195 + TUsbInterfaceDescriptor* iHeadInterfaceDescriptor;
1.196 + HBufC8* iInterfaceDescriptorData;
1.197 +
1.198 + RUsbTransferStrategy* iTransferStrategy;
1.199 +
1.200 + TInt iAlternateSetting;
1.201 +#endif
1.202 + };
1.203 +
1.204 +typedef TUint64 TUsbEndpointId;
1.205 +
1.206 +/**
1.207 +Functions which act on an individual pipe established between the local host and a remote device.
1.208 +*/
1.209 +class RUsbPipe
1.210 + {
1.211 +public:
1.212 + enum TUsbPipeRequest
1.213 + {
1.214 + EIssueTransfer = 0x4000000, // Start from a different value compared to interfaces
1.215 + // to allow them to be distinguished while debugging
1.216 + };
1.217 + enum TUsbPipeControl
1.218 + {
1.219 + EClose = 0x4000000, // Start from a different value compared to interfaces
1.220 + // to allow them to be distinguished while debugging
1.221 + EAbort,
1.222 + EClearRemoteStall,
1.223 + EGetEndpointId,
1.224 + };
1.225 +
1.226 +#ifndef __KERNEL_MODE__
1.227 +friend class RUsbInterface;
1.228 +friend class RUsbTransferStrategy;
1.229 +friend class RUsbZeroCopyTransferStrategy;
1.230 +public:
1.231 + inline RUsbPipe();
1.232 +
1.233 + inline void Close();
1.234 + inline TUint32 Handle() const;
1.235 +
1.236 + inline TInt GetEndpointId(TUsbEndpointId& aEndpointId);
1.237 + inline TInt GetBusId(TUsbBusId& aBusId);
1.238 +
1.239 + inline TInt GetEndpointDescriptor(TUsbEndpointDescriptor& aDescriptor);
1.240 +
1.241 + IMPORT_C void Transfer(RUsbTransferDescriptor& aTransfer, TRequestStatus& aRequest);
1.242 + inline void CancelAllTransfers();
1.243 +
1.244 + inline TInt ClearRemoteStall();
1.245 +
1.246 +private:
1.247 + inline void IssueTransfer(TInt aTransferHandle, TRequestStatus& aRequest);
1.248 +
1.249 +private:
1.250 + TUint32 iHandle;
1.251 + RUsbInterface* iInterface;
1.252 + TUsbEndpointDescriptor* iHeadEndpointDescriptor;
1.253 +#endif
1.254 + };
1.255 +
1.256 +
1.257 +#include <d32usbdi.inl>
1.258 +
1.259 +#endif // D32USBDI_H